Skip to content

feat(#1349): improve(skills): phases run affected tests (vitest --changed) instead of the full suite; CI keeps the full run - #1358

Merged
admarble merged 6 commits into
mainfrom
feature/1349-improve-skills-phases-run-affected-tests-vitest-ch
Oct 8, 2026
Merged

admarble merged 6 commits into
mainfrom
feature/1349-improve-skills-phases-run-affected-tests-vitest-ch

Conversation

@admarble

@admarble admarble commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Exec and qa now run the tests a branch affects instead of the full npm test. CI's test job stays the full-suite merge gate. (This body was rebuilt from exec's transcript: the 2.19.0 MCP server dropped exec's summary and left the placeholder, #1311.)

  • Skills: both now say to run npx vitest run --changed origin/main (jest: --changedSince). On top of that they run the test files named in each AC's Evidence: command and every changed test file. A grep -rlF "<changed path>" lookup adds the tests that read a changed non-test file. CI stays the full-suite merge gate. Each skill's allowed-tools gained npx vitest and npx jest.
  • Resolver: resolveAffectedTestCommand and detectTestRunner are in src/lib/stacks.ts, not stack-config.ts. That file only persists .sequant/stack.json and holds no commands. A stack with no affected mode falls back to its full test command.
  • Also added: docs/adr/0010-phases-run-affected-tests.md, with status Proposed, and a CHANGELOG entry. The mirrors were synced with npm run sync:skills.

Pre-PR AC verification

AC Status Evidence
AC-1 ✅ --changed origin/main and --changedSince appear in .claude/skills/exec/SKILL.md and qa/SKILL.md, inside delimited affected-tests (#1349) regions. Round 1 left several "Run npm test" steps elsewhere in exec; they now point at the affected-tests run, and a gate test keeps them out of both skills.
AC-2 ✅ Three affectedTest cases in src/lib/stacks.test.ts cover vitest and jest, the fallback, and runner detection
AC-3 ✅ One-line change to src/lib/ac-parser.ts: npx vitest list --changed --filesOnly → 23 files including src/lib/ac-parser.test.ts (2.7 s); npx vitest run --changed → 23 files, 522 tests passed, 11 s wall (re-measured by the runner, idle machine; exec's 56 s was under load). A hub module (mutation-marker.ts) selects 60 of 373 files and ran past 300 s, so the skill now counts the set first and shards a large one (--shard=1/3..3/3, each under timeout 590).
AC-4 ✅ scripts/affected-tests-skill.test.ts runs the documented grep -rlF command from each skill's region against .claude/skills/exec/SKILL.md. It finds scripts/exec-skill-marker.test.ts.
AC-5 ✅ lint:skill-sync (48 synced) and lint:skill-gates pass

Checks

  • npm run build and npm run lint pass. Targeted tests pass: 181 across stacks, affected-tests-skill, exec-skill-marker and check-skill-sync.
  • lint:skill-calls reports no violations.
  • No ordinary test file changed or sits outside the diff; the full suite was not run.

Mutation records

Each mutation failed exactly that test, and I restored the file afterwards. I did not run the parseMutationMarkers check from /qa §6i on these markers.

QA round 1 fixes (runner, 2b4c38d5, e0689326)

Mutation-verified: AC-1 — restored one "3. Run npm test" step in exec; scripts/affected-tests-skill.test.ts > exec and qa run affected tests, not the full suite > exec: no other step tells the agent to run the bare npm test failed; restored.
Mutation-verified: AC-4 — deleted rule 4 (the whole-tree scanner) from the exec region; scripts/affected-tests-skill.test.ts > exec and qa run affected tests, not the full suite > exec: names the whole-tree tautology scanner, which no path rule selects failed; restored.
Mutation-verified: AC-3 — changed --shard=1/3 in the exec region; scripts/affected-tests-skill.test.ts > exec and qa run affected tests, not the full suite > exec: counts a large affected set and shards it under the Bash cap failed; restored.

CI round fix (790caae2)

CI's full suite failed src/lib/__tests__/skill-allowed-tools-gate.test.ts (#1287): round 1 added Bash(npx vitest:*) and Bash(npx jest:*) to exec and qa, and those are runner wildcards outside RUNNER_ALLOWLIST. The grants are dropped. Phases run under bypassPermissions, and interactive /exec asks before a vitest call. Widening the allowlist to npx vitest run * is the owner's call (#1292 narrowed it on purpose).

That gate iterates SKILL_ROOTS and names no path, so no affected-test rule selected it, which is the gap this PR is meant to close. Rule 4 now adds every test that references SKILL_ROOTS when a skill file changes. On this branch the rules select 42 files: 780 tests in 17 s, all passing.

Mutation-verified: AC-4 — renamed SKILL_ROOTS in the exec region's skill-tree lookup; scripts/affected-tests-skill.test.ts > exec and qa run affected tests, not the full suite > exec: the documented skill-tree lookup selects the allowed-tools gate failed; restored.

QA round 2 fix (9e28bebd)

QA round 2 returned AC_MET_BUT_NOT_A_PLUS. Its one fixable gap: qa's region lacked exec's rule 4 and the count/shard step. It now carries both, and the exec-only gate tests run over both skills.

Mutation-verified: AC-4 — renamed SKILL_ROOTS in the qa region's skill-tree lookup; scripts/affected-tests-skill.test.ts > exec and qa run affected tests, not the full suite > qa: the documented skill-tree lookup selects the allowed-tools gate failed; restored.

Follow-up (not in this PR): loop and fullsolve still say npm test (ADR-0010 Consequences). The resolver in stacks.ts has no production caller yet: the skills spell the commands out, and a test keeps them in sync with it.

QA verdict (round 2): AC_MET_BUT_NOT_A_PLUS. All 5 ACs met; see the QA comment on #1349. The 2.19.0 server rewrote this body to its placeholder after that QA run; the runner restored it.

Pre-PR confidence check

  • Weakest part: --changed has a wide blast radius. A change to a module many files import, like stacks.ts or mutation-marker.ts, selects most of the suite, so the 120 s bar fails there.
  • Coverage gaps: only the qa skill's reverse-lookup test is a copy of the exec one. loop, fullsolve and test still say npm test; that's a follow-up, as the spec noted.

Fixes #1349


🤖 Generated by sequant run; runner fixes after QA round 1

…the full suite

Entire-Checkpoint: 466129e947a7
…npm test; add the whole-tree tautology scanner

QA round 1 found exec still telling the agent to run npm test in several steps, contradicting the new section. Each now points at the affected-tests run, guarded by a gate test over exec and qa. The dangling 'see the next block for others' now points at the section. A fourth rule names scripts/qa/tautology-detector-cli.test.ts, which reads every test file, so no path rule selects it.

Entire-Checkpoint: 9b1024182cfb
…the 600 s Bash cap

Entire-Checkpoint: 3bbc3d9c2aff
…jects; select skill-tree tests when a skill changes

CI's full suite failed skill-allowed-tools-gate.test.ts (#1287): Bash(npx vitest:*) and Bash(npx jest:*) are runner wildcards outside RUNNER_ALLOWLIST. The grants are dropped; phases run under bypassPermissions and interactive runs ask. The gate test iterates SKILL_ROOTS and names no path, so no affected-test rule selected it; rule 4 now adds every test that references SKILL_ROOTS when a skill file changes.

Entire-Checkpoint: d163c54ab0c2
…unt/shard step

QA round 2: qa's region lacked exec's rule 4 (tautology scanner, SKILL_ROOTS lookup) and the large-set sharding, so qa could miss the allowed-tools gate. The region now carries both; the exec-only gate tests run over both skills.

Entire-Checkpoint: fee5f8d045c8
@admarble
admarble merged commit f79b210 into main Oct 8, 2026
12 checks passed
@admarble
admarble deleted the feature/1349-improve-skills-phases-run-affected-tests-vitest-ch branch October 8, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improve(skills): phases run affected tests (vitest --changed) instead of the full suite; CI keeps the full run

1 participant