Skip to content

fix(#606): escalate waiting_for_qa_gate to merged when PR merged externally - #622

Merged
admarble merged 2 commits into
mainfrom
feature/606-fix-run-pre-flight-guard-misses-waiting-for-qa-gat
May 10, 2026
Merged

admarble merged 2 commits into
mainfrom
feature/606-fix-run-pre-flight-guard-misses-waiting-for-qa-gat

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

Symmetric sibling fix to #592. reconcileStateAtStartup now also escalates issues in waiting_for_qa_gate to merged when their PR was merged outside the current sequant session (web UI, gh pr merge, separate process). Without this, sequant run <N> was re-executing the QA phase against already-merged work because the pre-flight guard at run-orchestrator.ts:472-498 only short-circuits ready_for_merge/merged.

Loop-guard relaxation only — existing PR-status check, git fallback, state mutation, and resolvedAt stamp are unchanged.

Closes #606.

Changes

Test plan

Related

admarble added 2 commits May 9, 2026 11:05
…rnally

Symmetric sibling fix to #592 (which covered in_progress).
Loop-guard relaxation in reconcileStateAtStartup adds
waiting_for_qa_gate alongside ready_for_merge and in_progress, so
sequant run skips issues whose PR was merged outside the current
session before the next QA-gate invocation.

Mirror the #592 test pattern: positive escalation case + offline
fallthrough preserving existing behavior.

Closes #606
…_qa_gate git-fallback test

Gap-fix sweep on #606 QA review:

- ReconcileResult JSDoc (state-cleanup.ts): "advanced" and "stillPending"
  field comments were stuck on the pre-#592 2-status reality. Updated to
  reflect the 3-status allowlist (ready_for_merge, in_progress,
  waiting_for_qa_gate).
- Stale guard-test name (state-cleanup.test.ts:152): "neither in_progress
  nor ready_for_merge" no longer reflected the allowlist; renamed to
  "not in the reconcile allowlist". Body unchanged — abandoned and
  not_started are still excluded, so the assertion holds.
- Stale describe block title: dropped the "(#592 in_progress escalation)"
  qualifier now that the block also hosts #606 escalation tests, the
  ready_for_merge regression, and both git-fallback paths. Renamed to
  "reconcileStateAtStartup escalation".
- New positive git-fallback test for waiting_for_qa_gate (#606): mirrors
  the existing in_progress git-fallback test (line 252+); exercises the
  no-pr.number path through isIssueMergedIntoMain. Without it, a future
  status-specific regression on the git fallback could land silently.
- File-top docblock notes the AC-2 scope decision: pre-flight guard skip
  behavior is verified by construction, not by integration test. The
  existing #305 short-circuit on "ready_for_merge || merged" is unchanged
  by #592/#606, so escalation to "merged" is sufficient.

No production behavior change. Tests: 9/9 in state-cleanup.test.ts,
816/816 in src/lib/workflow/.
@admarble
admarble merged commit 7633d26 into main May 10, 2026
5 checks passed
admarble added a commit that referenced this pull request May 11, 2026
Gap 1 — §6c precondition greps diff hunks, not file content.

The first cut of this section's precondition shelled out to
`xargs grep -lE ...` against the *current* skill-md file content. All
19 sequant SKILL.md files mention `grep|awk|jq|sed` in unrelated
example code, so the gate triggered on 100% of skill-md PRs and the
cost-saving intent of #608 / #609 evaporated. The fix iterates the
diffed skill-md files and only triggers §6c when the **added lines**
contain the patterns. On 6 historical merged PRs (#623 #620 #621 #617
#622 #547) the new gate skips §6c on 4/6 (67%) — vs 0/6 under the old
content-grep gate. Mirrored across `.claude/skills/`,
`templates/skills/`, `skills/`.

Gap 2 — `extractIdentifiersFromDiff` skips indented locals.

`content = line.slice(1).trimStart()` defeated the comment's claim of
"no nested-block decls" by stripping the indent that distinguishes
top-level from function-body declarations. The dogfood run on #609
surfaced 24 identifiers (17 of them local `const lines = …` /
`let inFence = …` style variables). Dropping `.trimStart()` brings
the surface to top-level decls only. New test asserts indented
`+  const local = …` is skipped while `+const topLevel = …` matches.

Gap 3 — Empirical 5-PR replay for AC-5 / AC-6.

New `--base-sha` / `--head-sha` CLI flags let `precheck.ts` replay
against historical merged PRs. SHAs validated with `/^[0-9a-f]{4,40}$/`
to avoid shell injection. Ran replay against 6 PRs (5 recent +
#547 for AC-6 demo): aggregate ≈ −1,002 tok/PR under the new gate;
PR #620's replay surfaced `acLiteralDiff.missingInPR.length = 8` —
a real catch the inline §1 prose was supposed to make but #608's
data shows §1 surfaced silently for years. Investigation doc
appended with per-PR table + correction to the prior
"true on 0 PRs" calibration claim.

Test count: 27 → 30 (indented-skip + 2 parseArgs flag tests).
`scripts/check-skill-sync.ts` reports qa/SKILL.md synced 3/3.
admarble added a commit that referenced this pull request May 11, 2026
…628)

* feat(#609): extract deterministic QA gap-checks into precheck script

New `scripts/qa/precheck.ts` runs three deterministic gap-checks before
the QA agent and emits `.sequant/gap-precheck.json`:

  - fixtures      — verbatim motivating-example extraction from issue body
                    (feeds §6d Q1 / §6c Step 4)
  - siblingGrep   — changed-identifier scan for cross-file sibling sites
                    (feeds §5)
  - acLiteralDiff — AC checkbox IDs in issue body vs PR body (feeds §1)

`qa/SKILL.md` gains Phase 0c that runs the precheck inline and consumes
its findings. §6c becomes a file-glob hard precondition (no skill-md
diff → emit nothing). §6c Step 4 prefers precheck `fixtures` over the
inline `awk` extractor when available. §6d trims to a single
adversarial paragraph (per #608's 9/14 / 0-actioned signal).

Inline fallback preserved on missing/error/`not_applicable` output.
Mirrored across all three `qa/SKILL.md` copies. Exit code always 0.

Investigation doc at `docs/investigations/qa-precheck-extraction.md`
covers AC-1 (22-row gate classification), AC-2 (per-PR run frequency),
AC-5 (section-size delta calibration via #608's 50-PR window:
~−1,585 tok/invoke window-typical), and AC-6 (regression-coverage
methodology against PR #547 / PR #533 shapes).

Builds on #608's signal-to-noise data which informed Phase A scope.

* fix(#609): close three gaps surfaced in post-commit QA

Gap 1 — §6c precondition greps diff hunks, not file content.

The first cut of this section's precondition shelled out to
`xargs grep -lE ...` against the *current* skill-md file content. All
19 sequant SKILL.md files mention `grep|awk|jq|sed` in unrelated
example code, so the gate triggered on 100% of skill-md PRs and the
cost-saving intent of #608 / #609 evaporated. The fix iterates the
diffed skill-md files and only triggers §6c when the **added lines**
contain the patterns. On 6 historical merged PRs (#623 #620 #621 #617
#622 #547) the new gate skips §6c on 4/6 (67%) — vs 0/6 under the old
content-grep gate. Mirrored across `.claude/skills/`,
`templates/skills/`, `skills/`.

Gap 2 — `extractIdentifiersFromDiff` skips indented locals.

`content = line.slice(1).trimStart()` defeated the comment's claim of
"no nested-block decls" by stripping the indent that distinguishes
top-level from function-body declarations. The dogfood run on #609
surfaced 24 identifiers (17 of them local `const lines = …` /
`let inFence = …` style variables). Dropping `.trimStart()` brings
the surface to top-level decls only. New test asserts indented
`+  const local = …` is skipped while `+const topLevel = …` matches.

Gap 3 — Empirical 5-PR replay for AC-5 / AC-6.

New `--base-sha` / `--head-sha` CLI flags let `precheck.ts` replay
against historical merged PRs. SHAs validated with `/^[0-9a-f]{4,40}$/`
to avoid shell injection. Ran replay against 6 PRs (5 recent +
#547 for AC-6 demo): aggregate ≈ −1,002 tok/PR under the new gate;
PR #620's replay surfaced `acLiteralDiff.missingInPR.length = 8` —
a real catch the inline §1 prose was supposed to make but #608's
data shows §1 surfaced silently for years. Investigation doc
appended with per-PR table + correction to the prior
"true on 0 PRs" calibration claim.

Test count: 27 → 30 (indented-skip + 2 parseArgs flag tests).
`scripts/check-skill-sync.ts` reports qa/SKILL.md synced 3/3.
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.

fix(run): pre-flight guard misses waiting_for_qa_gate issues already merged on GitHub (sibling of #592)

1 participant