Repository navigation
Description
Motivation
/loop's Orchestration Context table says (point 4): "Trust issue context — Orchestrator has already validated issue." But its concrete Step 1A instructions contradict this: in orchestrated mode, they unconditionally re-fetch QA findings via gh issue view <N> --json comments -q '.comments[] | select(.body | startswith("## QA Review for Issue")) | .body' | tail -1 — ignoring the promptContext the orchestrator already embedded directly into loop's own invocation prompt (basePrompt += "\n\n---\n\n" + promptContext, src/lib/workflow/phase-executor.ts:1093-1094; built by buildLoopContext in both ready-gate.ts and batch-executor.ts).
This is silently correct only when QA happens to post a ## QA Review for Issue comment to GitHub before /loop runs. It does not under sequant ready: QA there runs orchestrated and — by design — defers comment-posting to the orchestrator (qa/SKILL.md §9: "Skip posting GitHub comment"). sequant ready's own postReport (added in #937 AC-4) only fires at the terminal state, not after each mid-loop QA pass. So during any qa → loop cycle inside sequant ready, /loop's GitHub fetch finds no matching comment from the run in progress and falls back to whatever other comments exist on the issue.
Reproduced live (2026-08-23, dogfooding #937's AC-4 against #958/PR #959 via sequant ready 958):
- QA ran, independently re-verified the PR, and correctly found AC-1
MET(with aSEQUANT_QA_GAPSmarker classifying the one real remaining gap aspause_for_human— outside/loop's scope by design). ready-gate.tscomputedfixableGapscorrectly (empty — nothing loop should touch) and passed it viapromptContext/failedAcsinto loop's invocation, exactly as designed./loopran anyway (NEEDS_VERIFICATIONdoesn't satisfyacpolicy's threshold), and its own transcript opened with "I'm in orchestrated mode. Let me fetch the QA findings from the issue comments" — then reported an AC table with AC-1 asPENDING, directly contradicting the QA pass that had just run in the samesequant readyinvocation, and stated "NoSEQUANT_QA_GAPSmarker present (0 matches)" even though one demonstrably existed in the live QA output.- Root cause confirmed: issue fix(fullsolve): Phase 5.3 auto-merges the PR — the skill's own stop-list says to halt at the final summary #958 had exactly 3 comments at that point — a
/speccomment, a stale## /fullsolve Completeself-assessment from an earlier, unrelated session (whose AC-1 status wasPENDING), and (after the run finished) thesequant readyterminal report. None start with## QA Review for Issue, so/loop's grep matched nothing and it reconstructed state from the stale/fullsolve Completecomment instead — landing on exactly its (wrong, outdated) AC-1 status.
Consequence in this run: harmless by coincidence — there was nothing genuinely fixable either way, so /loop made no diff and the gate correctly halted at LOOP_NO_DIFF. But the mechanism is a live data-integrity bug: whenever /loop genuinely has fix_now work to do under sequant ready, it may reason from stale or absent GitHub context instead of the accurate, already-computed promptContext/failedAcs sitting in its own prompt — risking a skipped fix, a redundant fix, or action on contradicted AC statuses.
This is distinct from #942 (which reduces how often /loop runs at all when the only gaps are human-decision items) — #942 would narrow the exposure window but not fix the underlying bug, which still applies whenever /loop runs with real work under sequant ready.
Proposal
Make /loop's Step 1A actually honor its own Orchestration Context table's point 4 ("trust issue context"):
- When
SEQUANT_ORCHESTRATORis set, check the invocation prompt itself for the embeddedpromptContextblock first — it is always present when dispatched byready-gate.tsorbatch-executor.ts(both build it viabuildLoopContextbefore every loop dispatch). Treat it as the authoritative QA-findings source and skip thegh issue viewcomment fetch entirely in that case. - Only fall back to the
gh issue view "## QA Review for Issue"fetch when no such embedded context is present — i.e., genuinely standalone/loop <N>invocations, or an orchestrator that doesn't injectpromptContext(verify none currently exist before assuming this branch is dead). - Update the Orchestration Context table's point 4 to say precisely what "trust issue context" means operationally (currently vague enough that Step 1A's contradicting behavior wasn't caught by review).
Non-Goals
- Not changing whether QA posts comments under orchestration — the fix is on the consuming side (
/loop), not forcing noisier QA comment-posting. - Not touching
#942's human-decision early-stop — complementary, not overlapping; both should land. - Not re-litigating
sequant ready'spostReport-at-terminal-only design (feat(qa/loop/ready): structured gap findings — finite taxonomy with required evidence, replacing the lossy prose-scrape gap channel #937 AC-4) — that's working as intended for the human-facing report; this issue is about the loop-facing mid-run context.
Tailored caveats
- All three skill mirrors (
.claude/skills/,templates/skills/,skills/) must change in sync (npm run lint:skill-sync). - Verify
batch-executor.ts's (plainsequant run) loop dispatch has the samepromptContext-embedding property before assuming the fix is safe there too — confirmed present at the code level (buildLoopContext(result)wired the same way), but worth a live check similar to the one that surfaced this issue.
Acceptance Criteria
- AC-1:
/loop, when orchestrated and given apromptContextblock in its own invocation prompt, does not fetchgh issue viewfor QA findings and instead parses that embedded block. Evidence: gate test scoped to the delimited Step 1A section (clone the mutation-verified pattern from fix(fullsolve): Phase 5.3 auto-merges the PR — the skill's own stop-list says to halt at the final summary #958's own gate test), mutation-verified. - AC-2: A live
sequant readydogfood run against an issue with a genuinefix_nowgap (not just human-decision/document gaps) shows/loopcorrectly reflecting the fresh QA data, not a stale GitHub comment. Evidence: transcript. - AC-3: Standalone
/loop <N>(noSEQUANT_ORCHESTRATOR) is unaffected — still fetches from GitHub comments as before. Evidence: existing standalone-mode tests/gate-test coverage stays green.
Human decisions required
- Whether the "no embedded promptContext, no matching GH comment, no log file" three-way-miss case should hard error (per the skill's existing documented fallback) or degrade to "no actionable issues found" — recommend hard error, since a silent miss is exactly this bug's failure mode.
Context
Discovered live while dogfooding #937's AC-4 (structured gap findings, sequant ready comment-persisting) against #958/PR #959 (sequant ready 958, 2026-08-23). Related: #937 (the gap-schema this bug undermines the intended consumption of), #942 (adjacent — reduces loop's run frequency in the human-decision case but doesn't fix this), #958 (the PR whose ready-gate run surfaced this).
Activity
admarble commentedon Aug 24, 2026
Spec: Plan for #960
Complexity: Standard (3 ACs, 4 directories)
Acceptance Criteria
/loopwith an embeddedpromptContextblock parses that block and skips thegh issue viewQA-comment fetch. — Verification: Unit Test (gate test scoped to the delimited Step 1A span, cloned from fix(fullsolve): Phase 5.3 auto-merges the PR — the skill's own stop-list says to halt at the final summary #958's mutation-verified pattern, all 3 skill mirrors)sequant readydogfood run with a genuinefix_nowgap shows/loopacting on fresh QA data, not a stale GitHub comment. — Verification: Manual Test (transcript;gh issue view --json commentsfetches in Step 1)/loop <N>(noSEQUANT_ORCHESTRATOR) still fetches from GitHub comments / log file as before. — Verification: Unit Test (src/lib/__tests__/— the new gate test should pin Step 1B's fetch path too, otherwise AC-3's "existing coverage stays green" is vacuous)Implementation Plan
Phase 1 — Runtime sentinel (single chokepoint):
src/lib/workflow/phase-executor.tsgetPhasePrompt()is the only placepromptContextis embedded (basePrompt += "\n\n---\n\n" + promptContext) — bothready-gate.ts:710andbatch-executor.ts:1625flow through it. Wrap the appended block in a stable sentinel, e.g.<!-- SEQUANT_PROMPT_CONTEXT -->\n{context}\n<!-- /SEQUANT_PROMPT_CONTEXT -->, so the skill detects embedded context deterministically instead of pattern-matching prose ("Ready gate (#683)…"vs"Previous phase … failed."differ per producer).phase-executor.test.ts(getPhasePromptis@internal-exported for testing): sentinel present whenpromptContextgiven, absent otherwise.Phase 2 — Skill edit (all 3 mirrors:
.claude/skills/,skills/,templates/skills/—npm run lint:skill-sync):3. Restructure
loop/SKILL.mdStep 1A inside new delimiters<!-- BEGIN: step-1a-context-source (#960) -->…<!-- END -->: first check the invocation prompt for theSEQUANT_PROMPT_CONTEXTsentinel → treat as authoritative QA findings, skipgh issue viewentirely; only when absent, fall back to the existing GH-comment fetch → log file → hard error (keeps the documented fallback chain; the three-way miss stays a hard error per the issue's recommendation).4. Rewrite Orchestration Context point 4 to state the operational rule: "Trust embedded context — when the orchestrator injected a
SEQUANT_PROMPT_CONTEXTblock, it is the QA-findings source; do not re-fetch from GitHub."5. Keep the #937
SEQUANT_QA_GAPSexclusion semantics intact: the embeddedpromptContextis alreadyfixableGaps-filtered by both producers (selectFixableGaps/ ready-gate's filter), so Step 2's exclusion filter applies only to the fetched-comment path — note this explicitly in the skill to avoid double-filtering confusion.Phase 3 — Gate test + dogfood:
6. New
src/lib/__tests__/loop-context-source-skill.test.tscloned fromfullsolve-merge-gate-skill.test.ts(anchored toimport.meta.url, all 3 roots, delimited-span extraction that throws on missing delimiters): asserts sentinel-first instruction in Step 1A span +gh issue viewfetch retained in the fallback/Step 1B span. Commit before mutation-verifying; recordMutation-verified:markers in the PR body (CLAUDE.md gate-test rule).7. AC-2 dogfood: live
sequant readyagainst an issue with a realfix_nowgap; capture transcript (copy out of.sequant/promptly — evidence rotates).Key decisions
getPhasePrompt(generic) over per-producer prefixes — one TS touchpoint covers both dispatch paths (and any future orchestrator), vs. editing twobuildLoopContexts that already drifted apart once (fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833-style dual-producer trap).Open Questions
Recommended Workflow
Phases: spec → exec → qa
Quality Loop: disabled
Reasoning:
buglabel, Standard tier; gate tests are hand-written + mutation-verified in exec (testgen adds nothing for skill-text gate tests); no UI. AC-2's live dogfood is a manual post-implementation step, not an automatable phase.fix(#960): reorder PROMPT_CONTEXT_SENTINEL doc comment ahead of getPh…
admarble commentedon Aug 24, 2026
/fullsolve Complete
Issue: #960
Status: NEEDS_VERIFICATION (AC-1 and AC-3 fully met; AC-2 requires a live post-merge dogfood run)
Progress Table
ui/frontend/adminlabelsNEEDS_VERIFICATIONAC Coverage
/looptrusts embeddedpromptContext, skipsgh issue viewsequant readydogfood shows/loopreflecting fresh QA datafix_nowgap to dogfood against; not reproducible synthetically inside this PR/loop <N>unaffectedCoverage: 2/3 fully met, 1 pending external verification
Quality Metrics
phase-executor.test.ts(+2 tests), newloop-context-source-skill.test.ts(21 tests)npm run lint:skill-sync: 44 synced, 0 divergedRisk Assessment
promptContextwithout going throughgetPhasePrompt, the sentinel wouldn't be added and/loopwould silently fall back to the (still-correct) GitHub-fetch path — degrades gracefully, doesn't break.fix_nowgap was available during this session to exercise the fix end-to-end under realsequant readyorchestration.getPhasePrompt's own docstring and the function, leaving that docstring describing the wrong symbol — caught in QA code review and fixed as a follow-up commit (3812e2a9), verified clean before push.PR
PR: #962
Next Steps
--auto-mergeflag orrun.autoMergesetting was in effect for this run).sequant readyagainst the next issue that reaches aqa → loopcycle with a genuinefix_nowgap, and confirm/loop's transcript reflects the embeddedSEQUANT_PROMPT_CONTEXTblock rather than a GitHub comment fetch. Post the transcript to bug(loop): orchestrated Step 1A re-fetches QA findings from GitHub instead of trusting the promptContext already embedded in its own prompt #960.Ready for human review; AC-2 verification recommended before final close.
fix(#960): close sentinel-rename drift hole; map embedded gap list to…
fix(#960): /loop's orchestrated Step 1A trusts embedded promptContext…
admarble commentedon Aug 24, 2026
Post-merge note: PR #962 merged (4c20536). AC-1 and AC-3 are confirmed via mutation-verified gate tests. AC-2 (live
sequant readydogfood against a genuinefix_nowgap) was never executed — no qualifying in-flight issue was available during this work. Auto-closed by the PR'sCloses #960, but that verification is still outstanding.Recommend: watch the next
sequant readyrun that hits aqa → loopcycle with a realfix_nowgap, confirm/loop's transcript reflects the embedded context (not a GitHub comment fetch), and post the transcript here.admarble commentedon Aug 24, 2026
AC-2 dogfood attempt — outcome: pending, four real attempts, no genuine fix_now gap surfaced.
Searched across sequant, ad-motion, varius, and thenewwayai for an in-flight issue with a genuine
fix_nowQA gap to exercise/loop's fixed Step 1A live. Ran four real end-to-end attempts:NEEDS_VERIFICATIONonly on CI-pending, resolved to green with no fix needed.sequant run, all 4 ACsMETon first pass,NEEDS_VERIFICATION→READY_FOR_MERGEonce CI resolved. PR: https://github.com/admarble/ad-motion/pull/227 (real, ready for merge).pre-tool.shno-changes-guard — only recognizes literal single-linecd path && git commit, not a prior-linecdvia variable), salvaged and committed manually. QA: all ACsMET,NEEDS_VERIFICATION→ resolved once CI green. PR: https://github.com/admarble/ad-motion/pull/228 (real, ready for merge).sequant ready --policy a-plus— the actual production mechanism AC-2 names — landed straight onREADY_FOR_MERGEin one iteration,tokensUsed: 0, no/loopdispatch. Nothing to fix.Secondary finding (unrelated to #960): ad-motion's orchestrated
sequant run --phases qare-run produced a genuinely fresh internal verdict (AC_MET_BUT_NOT_A_PLUS) that was never posted anywhere (not the issue, not the PR) — GitHub showed a stale prior verdict until the latersequant readyrun posted its own report. Worth filing on ad-motion separately if useful; not touched here since it's outside #960's scope.Conclusion: across four real, honest attempts the pipeline never organically produced a
fix_nowgap for/loopto act on — QA rigor at/exectime appears high enough that this is a genuinely rare live scenario, not a search failure. AC-2 remains the one open item on #960; recommend leaving it pending for a natural future occurrence rather than continuing to spend real repo/CI time chasing it. AC-1 and AC-3 remain fully verified (mutation-tested).