Repository navigation
ci-gate --affected: iteration runs test only what the change can reach (ci-kit test history, M4) - #101
Conversation
…h (ci-kit test history, M4) scripts/ci-gate.sh --affected lists the change's paths (git diff --name-status -M from the merge base with origin/master) in the pushed commit, under `Selection: affected` and the subject `ci-gate: <short> affected`. The plan (gate-affected.mjs) narrows unit and unit:darwin to vitest's related mode over them, or runs the full suite with the reason in its summary where the module graph cannot see: the lockfile or a package.json, a vitest or vite config, test support, gate files, a path outside the source and test trees, a deleted or renamed non-test file, a file read through fs, a glob or a query import. Suites that read source trees without importing them (guards, builds, bundles) join the related list when their tree changes. unit:darwin takes only the related suites among its own files (unit-related.mjs, vitest's API). A run without the trailer is unchanged. A selected run is never landing evidence. Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)
Skip the path-trailer loop for an empty affected array: Bash 3.2 treats its expansion as unbound under set -u. Preserve the affected subject and zero-count trailers, with a regression test on master's unchanged tree. Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… --affected for iteration runs: the trailers, vitest related, the fallbacks, READ_AS_DATA and SOURCE_READERS in place of the fs/glob rule; never landing evidence; the docs/ follow-up); §3.5's --affected bullet Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ebe0d6af5d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // a support module in the list brings every suite that imports it. A suite that starts reading a source tree that way | ||
| // belongs here. One that is missing goes unrun in a selected run while it should have run, and the landing's full | ||
| // class 1a is what catches it. | ||
| export const SOURCE_READERS = [ |
There was a problem hiding this comment.
Add the browser-import logging guard to source readers
When an affected run changes a script under src/main/browser/import/ other than log.ts, Vitest's import graph does not select src/main/browser/import/log.test.ts: that test imports only ./log but recursively reads every TypeScript file in the directory to enforce the no-console invariant. Consequently, a unit-only --affected run can pass without executing this guard; add this directory/test pair to SOURCE_READERS.
Useful? React with 👍 / 👎.
| trailers+=$'\n'"Selection: affected"$'\n'"Affected-Count: ${#affected_lines[@]}" | ||
| if ((${#affected_lines[@]} > 0 && ${#affected_lines[@]} <= AFFECTED_BOUND)); then for line in "${affected_lines[@]}"; do trailers+=$'\n'"Affected: $line"; done; fi |
There was a problem hiding this comment.
Bound affected trailers by encoded byte size
When a change contains at most 200 unusually long paths, this count-only bound still writes every path into the commit message. For example, a few dozen paths near Linux's approximately 4 KiB path limit can make github.event.head_commit.message exceed the per-environment-string limit when assigned to HEAD_MESSAGE, preventing the plan step from starting instead of falling back to the full suite. Apply a byte-size bound to the serialized trailers, not only a path-count bound.
Useful? React with 👍 / 👎.
M4 of ci-kit's test-history spec (
docs/doperpowers/specs/2026-10-21-test-history-design.md, "Selection (M4)"). The architect agreed the rule on 2026-10-21. About three of every four unit runs are iteration runs on trees that never land.scripts/ci-gate.sh --affectedlets such a run test only what its change can reach.A selected run is never landing evidence. That holds even when a fallback made it run the whole suite. A red selected run counts as red. A landing still needs a full class 1a run on the head's tree, without
--affected.What changed
scripts/ci-gate.sh --affected. It fetchesorigin/masterand lists the change in the pushed commit: every line ofgit diff --name-status -M -zfrom the merge base to the tested commit. If the fetch fails, it goes ahead, since a staleorigin/masteronly widens the set. The list is written as:Affected-Count: <n>;Affected: <status>\t<path>[\t<new path>]line per path;Selection: affected.The commit's subject is
ci-gate: <short> affected, and that subject is the run's display title, sogh run listandgh run viewshowaffected. Above 200 paths it lists none, and the plan runs the whole suite with the reason "too many paths". The list reaches the plan as one environment variable, which Linux caps at 128 KiB; the bound keeps even renames between the tree's longest paths near 60 KiB. 200 is the 93rd percentile of the files a landing changed over the last 200 landings. The header documents the flag and the landing rule..github/scripts/gate-affected.mjs(new) holds the decision as a pure function,affected(message). Its result is either{ paths, related }(run vitest related overrelated) or{ paths, reason }(run the whole suite).gate-plan.mjsreads theSelection:trailer on a push only, and refuses any value other thanaffected. It then writesselection=affectedandrelated=<JSON | empty>to its outputs, plus one summary line:Selection: affected — <n> paths, unit runs vitest related, orSelection: affected — full suite: <reason> (<the path>).A run without the trailer writes neither. A test pins its outputs and summary byte for byte.
.github/workflows/gate.yml. The plan exportsselectionandrelated. Whenrelatedis set, the unit and unit:darwin test steps run.github/scripts/unit-related.mjs(new); otherwise they run the commands they always ran. That script calls vitest 5'sstartVitestwithrelatedandpassWithNoTests. It exists because vitest's CLI cannot intersect related mode with file filters:relatedtakes no filters, and--relatedis not an option ofrun. unit:darwin needs that intersection to keep its own file set (scripts/darwin-unit-files.sh). The JUnit report, the upload and the step names are unchanged.The fallbacks
The architect's list, unchanged. The first one that applies gives the reason:
package.json;vitest.config.*,vite.config.*,electron.vite.config.*), or test support: a non-test file under asupport/directory of a test tree (test/support,test/live/support,apps/desk-hub/test/support), which holds the setup files, the global setup, the config's own helper and the scripts suites spawn;.github/,scripts/);src/,test/,apps/<app>/src/andapps/<app>/test/;What the graph cannot see. I found this by reading the suites for
readFileSync,readdir,import.meta.glob, query imports and spawned or bundled code, in test files and test support. Then I checked it against vitest 5.0.2's owngetRelevantTestSpecifications, run locally.Query imports are invisible to vitest's related walk. It checks
existsSyncon the dependency's id with the query still attached, so?raw,?inlineand?assetimports are dropped. Measured:src/renderer/src/styles/tokens.cssreaches no suite, although four DOM suites import it?raw. A plain.cssor.jsonimport is followed. So any non-script file in the source and test trees runs the whole suite: fixtures, snapshots, the guides'.md, css read as text, and the design-system defaults. This covers more than the data part of the fs/glob item.The named data directories (
READ_AS_DATA) fall back for script files too:test/fixtures/;test/snapshots/;apps/desk-web/test/fixtures/;src/artifacts/types/design_system/defaults/;src/artifacts/slides/fixtures/claude/;src/renderer/src/terminal/__fixtures__/.Outside the trees, the suites also read the following, which fallback 4 already covers:
spikes/protocol-probe/fixtures,spikes/browser-probe,e2e/fixtures,e2e/support,apps/desk-hub/{deploy,fake-machine,local},apps/desk-hub/wrangler.jsonc,apps/desk-web/public, anddocs/doperpowers/evidence(read bysrc/shared/plugins/cli.test.ts).⚠ Source readers (
SOURCE_READERS) are not fallbacks; this departs from the literal rule. Some suites read whole source trees through fs, a lint, a build, or a bundle they build and run:src/renderer);compiled-suites.test(src/renderer,src/main/artifacts);src/engine-host/fs);one-schema(lintssrc/);bundle-guardand the preloadbundle.test(they readout/, which the job builds fromsrc/);bridge.test(walkssrc/preloadandsrc/shared);react-compiler.test(four named files);sigkillandretention-crash(an esbuild-bundled writer);apps/desk-hub/srconly through the global setup's bundle, the fake machine'sbin.tsandlocal/run.ts);sw-imports.test(apps/desk-web/src/sw).Making these trees fallback directories would send nearly every change to the whole suite. Instead, a change under a reader's tree adds that reader to the related list; for the hub, it adds its
local.tsandhub.ts, which brings in all 23 suites that import them. No fallback is weakened. CI-opt agreed this and told the architect. One place, with a comment, names the rule: a suite that starts reading a source tree this way belongs in the list, and the landing's full class 1a catches one that is missing.Proof runs
All three are unit-only, on the pool, on scratch commits off this branch. This branch changes
.github/andscripts/, so a change taken from master would always fall back ("a gate file"). The proofs therefore took the change from this PR's head, as a session's will once this lands: they ran from a scratch clone whoseorigin/masterwas pinned at the PR head, with no fetch refspec. The script itself was unmodified.src/renderer/src/sidebar/reveal.ts: run 39570557690, green.ci-gate: ce6b943d affected, and the summary readsSelection: affected — 1 paths, unit runs vitest related.src/rendererandsrc/.App.test.tsx, which the sidebar reaches through the whole-app mount; the compiled one took 56 s.reveal.test.ts(related to the module): run 39571488563, red:1 failed | 2006 passed, the planted assertion.test/fixtures/m4-proof.txt: run 39573713454, green. Its title isci-gate: ab7b289a affected. The summary readsSelection: affected — full suite: read through fs, a glob or a query import (test/fixtures/m4-proof.txt), and the whole suite ran: 1,615 files, 22,450 passed and 80 skipped.unit:darwin with
--affectedon the mini is not run here. CI-opt schedules that one.Landing evidence
Class 1a on the pool at the head
ebe0d6af5, without--affected: run 39575096972, green. static, unit and probes all passed.ci-gate: ebe0d6af, with noaffected.Master has moved since this branch's base
909a1e5bdby one commit,a594a452e, which touches only docs; it shares no path with this branch.Tests
.github/scripts/gate-plan.test.mjscovers:Selection:value;scripts/ci-gate.test.mjsruns the script whole, against a local origin with a master, and covers:gate-plan.mjsreads those trailers;doperpowers:reviewer-medium; its one finding was fixed in ebe0d6a).node --test .github/scripts/*.test.mjs scripts/*.test.mjs: 73 pass.What the data says about the rule as written
I replayed the plan's decision over the whole diffs of the last 200 landings. Only 10 would select. In 143, a path outside the trees sends the run to the whole suite, almost always
docs/(141 landings touch it). Gate files account for 29, too many paths for 11, data for 4 and test support for 3. Leaving outdocs/would give 45 selections; leaving outdocs/ande2e/would give 63.Iteration runs are earlier states of a branch, with fewer docs edits, so this is a floor. The store records each run's selection, which will show the real rate.
docs/cannot simply be exempted: a unit suite readsdocs/doperpowers/evidence. This is the question the spec's Decision Log left for the store's data.Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)