You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(observability): remaining bare main...HEAD consumers after #878 — qa-cache diff hash, worktree-manager summaries, aider file-context, non-qa skill gates #890
#878 fixed the stale-local-base-ref defect in getGitDiffStats/getCommitHash, the qa/SKILL.md §7 gates (+ its 5 reference docs, all three mirrors), and the two gate scripts (semgrep-scan.ts, tautology-detector-cli.ts) via resolveDiffBase (nearest-candidate: origin/<base> vs bare ref).
The same bare-ref pattern survives at these sites, deliberately deferred from #878's PR because each has distinct semantics beyond a mechanical swap:
Remaining sites
Runtime (src/lib):
src/lib/workflow/qa-cache.ts:213,295,325 — the QA cache's diff hash and changed-files lists are computed from git diff main...HEAD. When local main lags origin, the cache key incorporates merged-upstream content (spurious invalidations) and the changed-files scoping feeds checks the wrong file set. Note: switching the ref invalidates existing caches once — acceptable, but worth stating in the PR.
exec/SKILL.md ×4, docs/SKILL.md ×4, test/SKILL.md ×1, merger/SKILL.md ×1, assess/SKILL.md ×1, loop/SKILL.md ×1, assess/references/predicted-collision-detection.md ×1 — audit each occurrence individually; some may intentionally run on main (don't blanket-swap).
Suggested approach
Reuse resolveDiffBase from src/lib/workflow/git-diff-utils.ts for the TypeScript sites (array-form git invocations, per the #878 QA hardening). For skill files, audit per occurrence, then apply the placeholder-swap + count + mirror-hash verification procedure from #878's PR.
Acceptance Criteria
qa-cache.ts computes its diff hash and changed-file lists against the ref resolved by resolveDiffBase, with a regression test covering the stale-local-main case.
worktree-manager.ts diff summaries use the resolved ref.
phase-executor.ts file-context resolution uses the resolved ref (respecting its existing per-worktree cwd).
Each bare main...HEAD in the non-qa skill files is either origin-qualified or explicitly annotated as intentionally local, identically across all three mirrors; mirrors stay byte-identical.
Notes
Follow-up to #878. Sites enumerated during that PR's QA sibling-site scan.
Verdict: ✅ SCOPE_OK (formal verdict SCOPE_WARNING only because the issue has no Non-Goals section)
AC Checklist
AC-1:qa-cache.ts computes diff hash + changed-file lists against the ref resolved by resolveDiffBase, with a stale-local-main regression test — Verification: Unit Test (real git repos)
AC-2:worktree-manager.ts diff summaries use the resolved ref — Verification: Unit Test
AC-3:phase-executor.ts file-context resolution uses the resolved ref, respecting its per-worktree cwd — Verification: Unit Test
AC-4: Each bare main...HEAD in non-qa skill files is origin-qualified or explicitly annotated as intentionally local, identically across all three mirrors; mirrors stay byte-identical — Verification: Integration (count + hash equality)
qa-cache.ts: add optional cwd to QACacheOptions (default process.cwd()); the three git calls resolve their base via resolveDiffBase(this.cwd, "main") and pass cwd: this.cwd. Update the line-85 doc comment. Testability rationale: the regression test constructs QACache({ cwd: <temp worktree> }) — no process.chdir, which leaks across vitest fork reuse.
worktree-manager.ts:409,430: resolveDiffBase(worktreePath, "main") in both summary functions.
phase-executor.ts:1118: resolveDiffBase(cwd, "main") — cwd is already the worktree when the phase requires one.
Phase 2 — regression test (AC-1)
4. New cases in git-diff-utils.integration.test.ts-style harness (or a small qa-cache.integration.test.ts): origin repo + stale local clone + worktree from origin/main; assert computeDiffHash over a fresh worktree equals the empty-diff hash (no phantom content) and checkGlobalInvalidation sees zero changed files. Mutation-verify: revert the ref swap → exactly these tests fail.
Phase 3 — skill mirrors (AC-4)
5. Audit each of the 13 occurrences: all are worktree-diff contexts (changed-file scoping, per-worktree summaries, collision detection) — none intentionally diff against local main, so all get origin-qualified. Apply the #878 placeholder-swap, verify 0 bare / 13 origin-qualified per mirror, mirrors md5-identical, check-skill-sync.ts green.
6. CHANGELOG entry under [Unreleased] → Fixed (#890). PR body states the one-time cache invalidation (diff-hash key changes when the ref changes).
Simplest correct approach? 1:1 ref swaps at each site plus the minimal cwd option on QACache. Rejected: memoizing resolution inside QACache (≤4 extra local git spawns per call, ~10ms each — not worth state).
One-time cache invalidation — switching the diff-hash ref invalidates existing QA caches once. Recommendation: accept (issue body pre-approves); note in PR. Impact if wrong: a single fresh QA run.
Recommended Workflow
Phases: spec → exec → qa (no browser test — CLI/skill-file change) Quality Loop: enabled on failure (fullsolve default) Testgen: skipped — bug fix; targeted regression tests written in-PR.
Warning, below blocking threshold (see Test Quality note)
Gate script (semgrep)
npx tsx scripts/semgrep-scan.ts --changed-only
—
4 findings, all pre-existing on main (see Security note)
Skill mirror sync
npx tsx scripts/check-skill-sync.ts
0
44 synced, 0 diverged
Changed skill gate commands
6 sampled swapped commands executed against the real worktree corpus
0
All scan exactly this branch's diff/commits — no phantom content
Evidence status: Complete. Script verification (§11): Not Required by the literal ^(scripts/|templates/scripts/) detection; the changed quality-checks.sh commands are the same swapped diff invocations exercised in the corpus sample above.
AC Coverage
AC
Description
Status
Notes
AC-1
qa-cache.ts diff hash + changed-file lists via resolveDiffBase, with stale-local-main regression test
MET
All 5 git calls resolve via resolveDiffBase, array-form execFileSync, new injectable QACacheOptions.cwd. Mutation-verified: reverting the ref swap fails exactly the 3 targeted tests; dropping the injected cwd fails exactly the incremental-path test
AC-2
worktree-manager.ts diff summaries use the resolved ref
MET
Both summary functions (--name-only, --stat) resolve per-worktree
AC-3
phase-executor.ts file-context uses the resolved ref, respecting per-worktree cwd
MET
resolveDiffBase(cwd, "main") where cwd is already the phase's worktree; execSync → execFileSync array form
AC-4
Non-qa skill bare main...HEAD origin-qualified or annotated, identically across mirrors; mirrors byte-identical
MET
13/13 per mirror audited per occurrence — all worktree-diff contexts, none intentionally local — swapped; 0 bare / 0 double-prefix; md5-identical ×3; 44/44 sync
Semgrep note: the 4 "critical" detect-child-process findings sit at worktree-manager.ts:575/1254 — package-manager install calls identical on origin/main, outside every hunk of this diff (whole-file scan on a changed file). Args come from internal package-manager detection, not user input. Pre-existing, not introduced, genuinely distinct semantics — not a sibling of this fix's pattern.
Quality Metrics
Build ✅ · Lint ✅ (0 violations) · lint:skill-calls ✅ · Full suite ✅ 4890 passed / 233 files (run after the QA-loop commit) · Mirrors md5-identical · Hooks md5-identical
Test Quality Review
Tautology detector flags 70 tests across the 3 changed test files at warning level (below blocking). All 7 new integration tests are flagged — a detector false-positive class: they assert on methods of an imported, locally-constructed QACache instance, which the detector doesn't recognize as production imports. Counter-evidence is recorded mutation testing (above): the tests demonstrably fail when the production code is broken. The 63 flags in pre-existing qa-cache.test.ts/run.test.ts are long-standing tests newly in scan scope, same instance-method pattern.
Detection Pattern Verification (§6c)
Changed skill lines alter only the diff ref inside existing grep/awk pipelines (no new patterns). 6 sampled swapped commands executed against the real worktree corpus — all correct (table above). Status: Passed.
Trust-Boundary Check
Finding: Clean — diff implements only product requirements; no agent-directed external-text instruction was acted on. Status: Clean
Behavior-Rule Survival Check
Status: N/A — no AC triggers the behavior-rule heuristic.
CHANGELOG Verification
CHANGELOG.md ✅ · user-facing fix: commits ✅ · [Unreleased] → Fixed entry with (#890) ✅ (states the one-time cache invalidation)
Risk Assessment
Likely failure mode: one-time QA-cache invalidation on upgrade (the ref inside the diff-hash key changes) — a single fresh QA run, pre-approved in the issue body. resolveDiffBase adds ≤4 local git spawns per cache call (~tens of ms per QA run).
Findings (iteration 1): the completeness sweep behind AC-4 surfaced three same-root-cause groups outside the issue's enumeration — qa quality-checks.sh (11 bare refs ×3 mirrors, missed by #878 which covered SKILL.md prose + TS gate scripts), qa SKILL.md two-dot main..HEAD (8 ×3, #878 swapped three-dot only; stale local main makes Phase 0 report phantom "implementation exists"), and post-tool.sh's coverage hook (×2). All fixed in-branch in c9214b65 (QA loop iteration), full suite re-run green. Verbatim issue-body sites all addressed; mutation results are post-fix validations, not bug repros; worktree clean, 2 commits ahead, 0 behind origin/main; no Non-Goals section — expansions disclosed above rather than absorbed silently. Status (iteration 2, post-fix): Clean
Verdict: READY_FOR_MERGE
4/4 ACs met with mutation-verified regression coverage; QA-loop sweep findings fixed in-branch; mirrors and hooks byte-identical; full suite, lint, and gates green. Semgrep's 4 findings are pre-existing on main and untouched by this diff.
AC: 4/4 met (mutation-verified regression coverage on the qa-cache stale-local-main case)
Tests: full suite 4890 passed / 233 files; new 7-test real-git integration suite
CI: 8/8 checks green
QA verdict: READY_FOR_MERGE (after one QA-loop iteration)
Iterations
Exec: 1 · QA loop: 1 (the AC-4 completeness sweep surfaced qa quality-checks.sh, qa SKILL.md two-dot refs, and the post-tool.sh coverage hook — all same-root-cause mechanical swaps, fixed in-branch in c9214b65 rather than farmed out)
Zero bare main...HEAD/main..HEAD consumers remain repo-wide outside the frozen __fixtures__ corpus. Reminder from the PR: existing QA caches invalidate once on upgrade (ref inside the diff-hash key changed).
Activity
admarble commentedon Aug 4, 2026
Plan (spec)
Complexity: Standard (4 ACs, 3 directories)
Scope Assessment
Verdict: ✅ SCOPE_OK (formal verdict SCOPE_WARNING only because the issue has no Non-Goals section)
AC Checklist
qa-cache.tscomputes diff hash + changed-file lists against the ref resolved byresolveDiffBase, with a stale-local-main regression test — Verification: Unit Test (real git repos)worktree-manager.tsdiff summaries use the resolved ref — Verification: Unit Testphase-executor.tsfile-context resolution uses the resolved ref, respecting its per-worktreecwd— Verification: Unit Testmain...HEADin non-qa skill files is origin-qualified or explicitly annotated as intentionally local, identically across all three mirrors; mirrors stay byte-identical — Verification: Integration (count + hash equality)Site Inventory (verified against main @ 30fd204)
TypeScript:
qa-cache.ts:213,295,325(execSync, cwd = process.cwd()),worktree-manager.ts:409,430(spawnSync-C worktreePath),phase-executor.ts:1118(execSync with per-worktreecwd, aider file-context path).Skill prose (per mirror, 13 total):
exec/SKILL.md×4 (614, 1125, 1156, 1187),docs/SKILL.md×4 (64, 65, 71, 90),test/SKILL.md:266,merger/SKILL.md:182,assess/SKILL.md:219,assess/references/predicted-collision-detection.md:5,loop/SKILL.md:337.Implementation Plan
Phase 1 — TypeScript sites (AC-1..AC-3)
qa-cache.ts: add optionalcwdtoQACacheOptions(defaultprocess.cwd()); the three git calls resolve their base viaresolveDiffBase(this.cwd, "main")and passcwd: this.cwd. Update the line-85 doc comment. Testability rationale: the regression test constructsQACache({ cwd: <temp worktree> })— noprocess.chdir, which leaks across vitest fork reuse.worktree-manager.ts:409,430:resolveDiffBase(worktreePath, "main")in both summary functions.phase-executor.ts:1118:resolveDiffBase(cwd, "main")—cwdis already the worktree when the phase requires one.Phase 2 — regression test (AC-1)
4. New cases in
git-diff-utils.integration.test.ts-style harness (or a smallqa-cache.integration.test.ts): origin repo + stale local clone + worktree fromorigin/main; assertcomputeDiffHashover a fresh worktree equals the empty-diff hash (no phantom content) andcheckGlobalInvalidationsees zero changed files. Mutation-verify: revert the ref swap → exactly these tests fail.Phase 3 — skill mirrors (AC-4)
5. Audit each of the 13 occurrences: all are worktree-diff contexts (changed-file scoping, per-worktree summaries, collision detection) — none intentionally diff against local main, so all get origin-qualified. Apply the #878 placeholder-swap, verify 0 bare / 13 origin-qualified per mirror, mirrors md5-identical,
check-skill-sync.tsgreen.6. CHANGELOG entry under
[Unreleased] → Fixed(#890). PR body states the one-time cache invalidation (diff-hash key changes when the ref changes).Design Review
resolveDiffBasefromgit-diff-utils.ts(fix(observability): phase diff stats compare against the local base ref while worktrees branch from origin/<base> — phantom filesModified + base tip logged as the phase commit #878) — no new resolution logic anywhere.cwdoption on QACache. Rejected: memoizing resolution inside QACache (≤4 extra local git spawns per call, ~10ms each — not worth state).getGitDiffStatsfix; skill-file procedure identical to fix(observability): phase diff stats compare against the local base ref while worktrees branch from origin/<base> — phantom filesModified + base tip logged as the phase commit #878's qa-mirror pass.cwdto QACache instead of chdir in the test?" —process.chdir/cwd-spies leak across reused vitest forks (worktree-manager's bare|| "npm"fallback disagrees with the PM-aware shell path on manifest-less projects #870); an injected cwd is the hermetic option and matches how worktree-manager/phase-executor already parameterize.Open Questions
Recommended Workflow
Phases: spec → exec → qa (no browser test — CLI/skill-file change)
Quality Loop: enabled on failure (fullsolve default)
Testgen: skipped — bug fix; targeted regression tests written in-PR.
fix(#890): origin-qualify the qa-adjacent siblings surfaced by QA's c…
admarble commentedon Aug 4, 2026
QA Review for Issue #890
Execution Verification
npx vitest run qa-cache.integration.test.tsnpx tsx scripts/qa/tautology-detector-cli.ts --jsonnpx tsx scripts/semgrep-scan.ts --changed-onlynpx tsx scripts/check-skill-sync.tsEvidence status: Complete. Script verification (§11): Not Required by the literal
^(scripts/|templates/scripts/)detection; the changedquality-checks.shcommands are the same swapped diff invocations exercised in the corpus sample above.AC Coverage
qa-cache.tsdiff hash + changed-file lists viaresolveDiffBase, with stale-local-main regression testresolveDiffBase, array-formexecFileSync, new injectableQACacheOptions.cwd. Mutation-verified: reverting the ref swap fails exactly the 3 targeted tests; dropping the injectedcwdfails exactly the incremental-path testworktree-manager.tsdiff summaries use the resolved ref--name-only,--stat) resolve per-worktreephase-executor.tsfile-context uses the resolved ref, respecting per-worktreecwdresolveDiffBase(cwd, "main")wherecwdis already the phase's worktree;execSync→execFileSyncarray formmain...HEADorigin-qualified or annotated, identically across mirrors; mirrors byte-identicalCoverage: 4/4 ACs met. Disclosed same-root-cause expansions filled in-branch (not farmed out):
mergertwo-dot commit list; qaquality-checks.sh×3 mirrors (11 refs each); qaSKILL.mdtwo-dot Phase-0/§10a commands ×3 (8 each);post-tool.shcoverage hook (.claude/hooks+templates/hooks). Frozen__fixtures__/dependency-markerscorpus deliberately keeps bare refs (historical issue bodies, not live commands).Quality Checks (sub-agents, sequential)
any, 0 deleted tests, 0 weakened assertions (mock bridge audited)execSync→ array-formexecFileSync)Semgrep note: the 4 "critical"
detect-child-processfindings sit atworktree-manager.ts:575/1254— package-manager install calls identical onorigin/main, outside every hunk of this diff (whole-file scan on a changed file). Args come from internal package-manager detection, not user input. Pre-existing, not introduced, genuinely distinct semantics — not a sibling of this fix's pattern.Quality Metrics
Build ✅ · Lint ✅ (0 violations) ·
lint:skill-calls✅ · Full suite ✅ 4890 passed / 233 files (run after the QA-loop commit) · Mirrors md5-identical · Hooks md5-identicalTest Quality Review
Tautology detector flags 70 tests across the 3 changed test files at warning level (below blocking). All 7 new integration tests are flagged — a detector false-positive class: they assert on methods of an imported, locally-constructed
QACacheinstance, which the detector doesn't recognize as production imports. Counter-evidence is recorded mutation testing (above): the tests demonstrably fail when the production code is broken. The 63 flags in pre-existingqa-cache.test.ts/run.test.tsare long-standing tests newly in scan scope, same instance-method pattern.Detection Pattern Verification (§6c)
Changed skill lines alter only the diff ref inside existing grep/awk pipelines (no new patterns). 6 sampled swapped commands executed against the real worktree corpus — all correct (table above). Status: Passed.
Trust-Boundary Check
Finding: Clean — diff implements only product requirements; no agent-directed external-text instruction was acted on.
Status: Clean
Behavior-Rule Survival Check
Status: N/A — no AC triggers the behavior-rule heuristic.
CHANGELOG Verification
CHANGELOG.md ✅ · user-facing
fix:commits ✅ ·[Unreleased] → Fixedentry with(#890)✅ (states the one-time cache invalidation)Risk Assessment
resolveDiffBaseadds ≤4 local git spawns per cache call (~tens of ms per QA run).worktree-manager/phase-executorwiring is pinned via mocked unit tests (resolveDiffBasemocked to"main"), not a real-repo test per site; the underlying resolution is fully covered bygit-diff-utils.integration.test.ts(fix(observability): phase diff stats compare against the local base ref while worktrees branch from origin/<base> — phantom filesModified + base tip logged as the phase commit #878) and the new qa-cache suite..shincluded) — zero bare refs remain outside the frozen test-fixture corpus.cwd+ array form;hooks/post-tool.sh(lighter distributed variant) verified pattern-free.Adversarial Re-Read
Findings (iteration 1): the completeness sweep behind AC-4 surfaced three same-root-cause groups outside the issue's enumeration — qa
quality-checks.sh(11 bare refs ×3 mirrors, missed by #878 which covered SKILL.md prose + TS gate scripts), qaSKILL.mdtwo-dotmain..HEAD(8 ×3, #878 swapped three-dot only; stale local main makes Phase 0 report phantom "implementation exists"), andpost-tool.sh's coverage hook (×2). All fixed in-branch inc9214b65(QA loop iteration), full suite re-run green. Verbatim issue-body sites all addressed; mutation results are post-fix validations, not bug repros; worktree clean, 2 commits ahead, 0 behind origin/main; no Non-Goals section — expansions disclosed above rather than absorbed silently.Status (iteration 2, post-fix): Clean
Verdict: READY_FOR_MERGE
4/4 ACs met with mutation-verified regression coverage; QA-loop sweep findings fixed in-branch; mirrors and hooks byte-identical; full suite, lint, and gates green. Semgrep's 4 findings are pre-existing on main and untouched by this diff.
admarble commentedon Aug 4, 2026
/fullsolve Complete
Status: MERGED — PR #894 (
64416d6f), issue auto-closed.Summary
Iterations
quality-checks.sh, qaSKILL.mdtwo-dot refs, and thepost-tool.shcoverage hook — all same-root-cause mechanical swaps, fixed in-branch inc9214b65rather than farmed out)Zero bare
main...HEAD/main..HEADconsumers remain repo-wide outside the frozen__fixtures__corpus. Reminder from the PR: existing QA caches invalidate once on upgrade (ref inside the diff-hash key changed).