Commit Graph
35 Commits
Author SHA1 Message Date
Igor Šćekić 1dec5d3fb8 feat(cli): make goals and the timing tools one system
https://github.com/Kilo-Org/kilocode/pull/14504
2026-09-24 01:00:27 +02:00
Yury Zialionka 031ae4a7a3 fix(test): second review round — measurement integrity and hang budget
--update-durations now disables batching so every file is measured
per-file (batched members' entries otherwise rot), and only passing
runs record durations (a timed-out file would write the kill deadline
and permanently skew LPT).

Timed-out work items are no longer retried: the deadline already
proves a hang, and a second 600s attempt could push a shard past the
45-minute job budget.

A flaky batch now annotates the member files that failed the first
attempt instead of the pseudo-file. Defender exclusions apply per
path instead of aborting on the first policy-locked one.
2026-08-13 21:24:42 -06:00
Yury Zialionka 5aed6f5f18 refactor(test): flatten tier entries; bound the demotion scan; fix a stale comment
FAST_TIERS drops the single-field wrapper left from the hand-weight era.
The unsafe-marker scan reads files in chunks of 64 so a low soft fd
limit cannot fail startup. The durations comment points at
--update-durations instead of a workflow that no longer exists.
2026-08-13 21:07:44 -06:00
Yury Zialionka fb65ca161b fix(test): merge --update-durations over existing measurements
Replacing the file wiped every batched member's measured duration —
exactly the data the computed batch weights read. Fresh per-file
timings now merge over the existing entries; deleted files drop out.
2026-08-13 18:50:56 -06:00
Yury Zialionka a4539b8804 perf(test): compute batch weights from member durations; review fixes
Batch shard weights are now the sum of member durations (hint >
measured > typical boot-dominated file) plus one process boot, replacing
hand-tuned per-tier constants that had gone stale (fast-tier-misc
declared 30s of ~86s real work; fast-tier-tool 55s of ~250s on Windows).

Review fixes: tool/shell, tool/task, and kilocode/daemon leave the
batches (real-work-dominated or subprocess-timing files); weight() is
memoized (it runs inside sort comparators, each miss a stat syscall);
timeout messages report the deadline actually applied to the work item;
the module-scope env-write detector also matches bracket assignments;
--update-durations refreshes the measured-durations file after a full
run; entry matching is one shared helper.
2026-08-13 18:38:50 -06:00
Yury Zialionka aea90225fc refactor(test): make batch composition self-maintaining
Tier entries are directory prefixes; a new test file batches (or not)
by location alone. The hand-kept exclude list shrinks to the four
timing-sensitive entries a source scan cannot detect; files with
detectable process-wide markers (mock.module, AppRuntime.dispose,
global fetch spies, module-scope env writes) are demoted to per-file
runs automatically instead of failing the suite.
2026-08-13 18:19:59 -06:00
Yury Zialionka a7bdcfc2f7 perf(test): start heavy batches first; make artifact upload non-fatal
The worker queue sorted by raw file weight, which is 0 for batch
pseudo-files (not real paths) — batches started last, leaving one
worker running a full batch after the rest of the shard drained.
Sorting by shard weight starts the heaviest items first and shortens
the tail.

The batch-safety guard now reads member sources in parallel, and the
diagnostics-only artifact upload no longer fails a green job on a
runner-side network blip (seen as ECONNREFUSED on Blacksmith).
2026-08-13 18:05:47 -06:00
Yury Zialionka 9b9cbe896e fix(test): honor the batch-safety guard for subdirectory tiers
The new guard correctly flagged four files inside batched subdirectories
(mock.module in kilocode/presence, global fetch spies in kilocode/sessions)
that had been batch-safe only by luck of batch composition. They run
per-file now; the exclude set applies to every tier, not just the root.
2026-08-13 18:00:21 -06:00
Yury Zialionka eed3a153e6 perf(test): batch cli, tool, and misc dirs; weight shards by measured durations
Three probes proved cli/ (minus run/), tool/, and the small acp/lsp/mcp/
plugin/storage/... dirs isolation-safe in a shared process (1052 tests,
0 failures). Work items drop from 327 to 233.

Sharding now weights unbatched files by measured durations
(script/kilocode/test-durations.json, parsed from a full local run)
instead of byte size, so LPT packs shards evenly.

The batch builder now refuses to batch files with process-wide markers
(mock.module, AppRuntime.dispose, global fetch spies) so a future test
cannot silently poison a shared process.
2026-08-13 17:54:32 -06:00
Yury Zialionka 13a6b9d452 perf(test): split root fast tier into eight smaller batches
Smaller max work items let LPT pack the six Windows shards evenly;
a batch retry also costs half as much wall-clock.
2026-08-13 17:21:05 -06:00
Yury Zialionka da1fb306e6 fix(test): keep the stall-simulation test out of the fast tier
issue-8656-stall waits on a 90s real-time stall window; under batch
CPU contention on the Windows runner it misses the window. It joins
the timing-sensitive exclusion class and runs per-file again.
2026-08-13 17:15:33 -06:00
Yury Zialionka da089f0c7a perf(test): batch top-level kilocode tests into four hash-split fast tiers
194 of 211 top-level kilocode/*.test.ts files are isolation-safe in a
shared process (validated: 1612 tests, 0 failures in one superset run).
The 17 exclusions are files that mutate process-wide state: bun
mock.module (process-wide and permanent), AppRuntime.dispose() in
teardown, global fetch spies, and real subprocess/watcher timing.

Work items drop from 506 to 327; each root batch runs ~50 files for
one process spawn instead of fifty.
2026-08-13 16:39:31 -06:00
Yury Zialionka f81fc29622 fix(test): drop kilocode/permission from the fast tier
permission-origins.test.ts asserts the merged config carries no
global-scope keys, so it cannot share an XDG root with batch-mates
that write global config (seen on CI as a leaked '*': 'global' bash
rule). The directory returns to per-file isolation.
2026-08-13 15:45:38 -06:00
Yury Zialionka 140a75393f perf(test): expand the fast tier to four parallel batches (161 files)
Extends the fast tier from 37 to 161 files (~25% of the suite) across
four independently-scheduled batches, each empirically verified to pass
in a shared process (probes: 449 + 497 + 184 tests, zero failures):

- fast-tier-core: unchanged 37-file batch
- fast-tier-kilocode: 51 files (config, permission, provider, util, ...)
- fast-tier-kilocode-sessions: 49 files (session-export, sessions, session)
- fast-tier-kilocode-tools: 24 files (tool, cloud, anaconda-desktop)

Multiple batches instead of one keep each batch short enough to
schedule like a normal heavy file; LPT spreads them across shards and
worker slots. ~157 fewer process spawns per run - the dominant unit
cost on Windows (CreateProcessW + Defender per spawn).

The 208 top-level kilocode/*.test.ts files were probed and are NOT
batch-safe (536 cross-contamination failures in a shared process) -
they stay per-file until the #12998 singleton work lands.

Full suite locally: 505/506 with all four batches green (the one
failure is the pre-existing run-process SIGINT timeout that fails solo
on unmodified main on this machine).
2026-08-13 15:28:11 -06:00
Yury Zialionka a4c6080170 perf(test): run isolation-safe test files in one shared process
Part of #12986 (in-process fast tier).

The per-file process model exists to contain cross-test state, but it
taxes every file with a process boot + TypeScript compile even when the
file is pure. This adds a fast tier: 14 directories/files empirically
verified to pass together in a single 'bun test' pass (~37 files, all
of util/, config/, effect/, patch/, provider transforms, and other
boot-dominated suites; 1360-test superset probe ran clean).

- The batch enters LPT shard splitting as one pseudo-file with a
  duration-scale weight, so exactly one shard executes it and balancing
  is preserved.
- JUnit: the batch writes one XML containing all member suites; the
  existing merge picks it up by work-item name.
- Batching disables itself under --profile (macOS curated run) and
  positional pattern filters, and the batch gets a roomier process
  deadline since it compiles once for ~37 files.
- I/O-heavy directories (git/, lsp/, storage/, auth/) stay per-file:
  their runtime is real work that parallelizes across the worker pool,
  while a batch runs members sequentially.

Validated locally: full suite 626/627 with the batch green (the one
failure is cli/run/run-process.test.ts SIGINT timing out solo on
unmodified main on this machine - pre-existing, unrelated).
2026-08-13 14:50:01 -06:00
Yury Zialionka 4431875e86 fix(ci): reduce Windows CLI test contention
Windows CLI unit tests ran 4-at-a-time on the 4-vCPU runner (custom
test-runner default = min(4, cpus)), oversubscribing CPU so heavy
real-server test files blew their per-test timeouts.

- Cap KILO_TEST_CONCURRENCY=2 on Windows (each file gets ~2 vCPU).
- Grow Windows shards 4 -> 6 to absorb the lower per-shard parallelism.
- Shard by observed duration instead of file size, so the two heaviest
  files no longer stack in one shard.
- Raise the Windows per-file kill deadline to 600s (KILO_TEST_FILE_TIMEOUT);
  the heaviest file runs ~270s, only ~30s under the old 300s default.

Scoped to the @kilocode/cli custom runner on Windows only. Linux/macOS
unchanged; the non-CLI/core suite runs via plain 'bun test' and is not
affected (separate lever).
2026-08-11 17:05:11 -06:00
marius-kilocode 3b2686af84 chore(annotations): wrap upstream changes with kilocode_change markers 2026-08-07 14:08:59 +02:00
marius-kilocode dc3af535bb perf(build): optimize cli and extension compile and test times 2026-08-07 14:08:54 +02:00
marius-kilocode c4aebfe305 fix(cli): tolerate process signal failures in test runner 2026-07-24 17:06:49 +02:00
marius-kilocode a33493e722 fix(cli): stabilize cross-platform subprocess tests 2026-07-24 14:23:03 +02:00
dengbushiandmarius-kilocode 88afe3d3c2 fix(cli): clean test runner temp environments (#12232)
* fix(cli): clean test runner temp environments

* fix(cli): clean test environments on runner shutdown

---------

Co-authored-by: marius-kilocode <marius@kilocode.ai>
2026-07-16 12:42:54 +02:00
marius-kilocode 443d510915 test: shard cross-platform CLI suite 2026-07-08 19:59:22 +02:00
marius-kilocode bb9680bc22 chore(ci): reduce test log noise 2026-06-29 16:10:51 +02:00
marius-kilocode 7a156bb205 fix(ci): normalize test paths on Windows 2026-06-23 13:12:17 +02:00
marius-kilocode 31095168d2 test(ci): focus macOS PR coverage 2026-06-23 12:53:03 +02:00
Catriel Müller f40970557f refactor: renegare sdk 2026-05-06 14:26:06 -03:00
Catriel Müller 0de07760a7 ci: bump actions to Node 24 and surface flaky tests to the UI
- Bump all active workflows to action versions that natively target Node 24:
  checkout@v6, setup-node@v6, cache@v5, upload-artifact@v7, download-artifact@v8.
  Resolves the "Node.js 20 is deprecated" warning in CI logs. The kept
  `FORCE_JAVASCRIPT_ACTIONS_TO_NODE24` env stays as a no-op safety net (also
  in upstream OpenCode).
- test-runner: when running under GitHub Actions, emit a `::warning::`
  annotation per flaky file and append a markdown table to
  `$GITHUB_STEP_SUMMARY`. mikepenz/action-junit-report already surfaces
  failures from the JUnit XML, but flakies pass cleanly on retry and were
  invisible in the UI.
2026-05-05 12:53:03 -03:00
Catriel Müller 3f5ed52cd3 refactor: include quarantine on the same runner file 2026-05-05 12:53:03 -03:00
Catriel Müller c21a1b855f fix(cli): produce well-formed JUnit when bun emits nested testsuites
The per-file JUnit merge was walking `<testsuite>` tags by hand and closing
on the first `</testsuite>` it found. Bun's junit reporter nests one
`<testsuite>` per `describe` block inside an outer `<testsuite>` for the
file itself, so the inner close was matched and the outer one got dropped.
Every file contributed one unclosed `<testsuite>` to the merged output,
pushing XML depth up until mikepenz/action-junit-report's sax parser
failed with "Unexpected close tag" (and xmllint with "Excessive depth").

Switch to grabbing everything between the outer `<testsuites ...>` and
`</testsuites>` of each file's XML — nested structure is preserved
verbatim, no custom walking needed. Read aggregate counts from the root
`<testsuites>` attributes so nested `tests="..."` attrs don't get
double-counted either.

Validated locally: `xmllint --noout` passes on the merged output for a
mix of files with and without nested describes.
2026-05-05 12:53:03 -03:00
Catriel Müller 3d063eb47f test(cli): stabilize flaky unit test CI
- Lower default runner concurrency from `os.cpus().length` to `min(4, cpus)`.
  The bottleneck in CI is shared resources (OAuth callback ports, global
  filesystem like `~/.local/share/kilo`), not CPU, so eight parallel Bun
  processes were triggering port/FS races instead of going faster.
- Raise per-test timeout from 30s to 60s. Slow `spawn` on Windows was
  tripping the 30s limit on tests that were just slow, not broken
  (e.g. `session/prompt.test.ts` at ~86s, `provider/provider.test.ts` at ~54s).
- Retry failing files once and surface them as FLAKY in the summary plus a
  dedicated section. Bugs still fail on every attempt; contention recovers.
- Drop CI runners from 8vcpu to 4vcpu to match upstream OpenCode — with
  concurrency capped at 4, the extra cores bought us nothing.
2026-05-05 12:53:03 -03:00
marius-kilocode c0c982befd test(cli): allow explicit quarantined test runs 2026-05-05 13:47:34 +02:00
marius-kilocode 279a86c2b6 test(cli): quarantine flaky MCP OAuth browser tests 2026-05-05 13:43:00 +02:00
kiloconnect[bot] 325bdae8a4 chore(cli): annotate MCP OAuth fix 2026-05-04 14:29:05 +00:00
kiloconnect[bot] acc30a6458 feat(mcp): defer oauth callback server startup
Move the initialization of the MCP OAuth callback server from the layer setup to the point where browser authentication is actually required. This prevents unnecessary port binding when authentication is not needed.

Additionally, improve the test runner's XML parsing to correctly handle multiple testsuite attributes and ensure tags are matched accurately.

- Update `packages/opencode/src/mcp/index.ts` to call `McpOAuthCallback.ensureRunning` only upon `UnauthorizedError`.
- Refactor `packages/opencode/script/test-runner.ts` to use a more robust `open` and `sum` logic for test results.
- Add verification to `packages/opencode/test/mcp/oauth-auto-connect.test.ts` to ensure the callback server remains inactive when not needed.
2026-05-04 14:14:09 +00:00
Catriel Müller d039bdf6c3 feat: test runner 2026-04-15 15:11:33 -03:00