Skip to content

fix(qa): wait for config restart wake completion - #126721

Closed
vincentkoc wants to merge 2 commits into
mainfrom
fix/qa-wake-lifecycle-20260820
Closed

vincentkoc wants to merge 2 commits into
mainfrom
fix/qa-wake-lifecycle-20260820

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Related: #126259

What Problem This Solves

Fixes an issue where daily-main qualification could treat the config-restart wake session as settled while its correlated agent run had not started or had failed, making the capability-flip scenario race the restart lifecycle.

Why This Change Was Made

The QA harness now records the restart request timestamp and waits for a correlated session run. It uses agent.wait when sessions.list exposes one exact active run ID, otherwise it requires a correlated terminal row and surfaces the gateway-redacted failure reason. Timeout diagnostics allowlist only lifecycle state.

The scenario retains the real restart-required config.apply path. This PR does not change product restart, auth, provider, failover, or cooldown behavior.

User Impact

No product runtime behavior changes. Maintainers get deterministic qualification evidence for the config restart capability flip instead of a false idle success or a racy follow-up prompt.

Evidence

  • Exact head: f15af388f4c87d8fe908361f75723ac8cc8fa338
  • Focused tests: 49 passed across the agent-process, scenario catalog, runtime API, and flow wiring suites.
  • Extension typecheck: pnpm tsgo:extensions:all passed.
  • Formatting and git diff --check passed.
  • check-changed passed all pre-typecheck gates, including full-tree Knip after disabling the inherited sparse profile. Its only code finding was a TypeScript narrowing error; the classified extension-typecheck retry passed after the fix.
  • Required stacked runtime-pair proof remains pending against fix: explicit Codex runtime policies reach embedded attempts #126259 exact head 52c37be00173761a48cc1d5fa26d8b9467ae1895.

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@vincentkoc vincentkoc self-assigned this Aug 20, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 20, 2026
@clawsweeper

clawsweeper Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 4:36 PM ET / 20:36 UTC.

ClawSweeper review

What this changes

The PR makes the QA config-restart capability scenario wait for the correlated post-restart agent run before checking restored capabilities.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this PR open: its new sentinel assertion rejects a valid recovered restart result before the correlated-run wait can execute. Its lifecycle-wait idea remains useful, but it must be rebased onto the shipped restart-boundary scenario on current main.

Priority: P2
Reviewed head: fc70d6950bd1f32386b56ea0ff1efc3c9c8fed00

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The lifecycle-wait approach is coherent, but the supported recovery path still causes the scenario to fail before that behavior runs.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored internal QA reliability PR is exempt from the external-contributor proof gate; its body nevertheless records that the relevant stacked runtime-pair trace remains pending after the required rebase.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored internal QA reliability PR is exempt from the external-contributor proof gate; its body nevertheless records that the relevant stacked runtime-pair trace remains pending after the required rebase.
Evidence reviewed 6 items Introduced failing assertion: The introduced assertion requires a returned sentinel, so the scenario exits before its wake and correlated-run checks when config application recovers from a restart race.
Valid recovery omits the RPC payload: The QA mutation owner intentionally treats a visible post-restart configuration as success and returns only { ok: true, restarted: true }, which has no sentinel field.
Recovery path is covered by the owner test: The existing QA gateway test injects a restart error after the mutation becomes visible and expects the recovered success result, establishing this as supported behavior rather than an error case.
Findings 1 actionable finding [P2] Accept recovered config.apply restart success
Security None None.

How this fits together

QA Lab runs declarative qualification scenarios against an ephemeral Gateway and mock channel/provider environment. This scenario changes Gateway configuration, observes the restart wake, then checks that the agent sees the restored tool capability.

flowchart LR
  A[QA scenario] --> B[Apply restart-required configuration]
  B --> C[Gateway restart wake]
  C --> D[Correlated agent run]
  D --> E[Restored tool check]
  E --> F[Qualification result]
Loading

Before merge

  • Accept recovered config.apply restart success (P2) - applyConfig may validly recover from a restart race with { ok: true, restarted: true } after confirming the requested config is already visible. That result has no RPC sentinel, so this assertion aborts the scenario before the new correlated-run wait; accept the recovery result and cover it at the scenario boundary.
  • Resolve merge risk (P1) - The branch is dirty against current main, which already ships the terminal-setting restart scenario from fix(qa): exercise a real config restart boundary #127285; a rebase must retain that scenario’s restart-boundary and post-restart request attribution.
  • Resolve merge risk (P1) - The PR body records that the stacked runtime-pair trace remains pending, so the corrected rebased scenario still needs a redacted run through the real QA lifecycle before merge.
  • Complete next step (P2) - Accept recovered config.apply restart success, add scenario-level coverage, then rebase the lifecycle wait onto current main’s terminal-setting scenario and provide a redacted runtime-pair trace.

Findings

  • [P2] Accept recovered config.apply restart success — qa/scenarios/config/config-restart-capability-flip.yaml:122-124
Agent review details

Security

None.

PR surface

Source +127, Tests +212, Other +9. Total +348 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 132 5 +127
Tests 2 218 6 +212
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 32 23 +9
Total 6 382 34 +348

Review metrics

Metric Value Why it matters
Classified LOC production +0/-0; QA tests and test-support +382/-34 All introduced code is qualification-scenario or harness support; no product runtime surface grows.

Merge-risk options

Maintainer options:

  1. Repair and rebase the lifecycle wait (recommended)
    Accept the supported recovered config.apply result, add scenario-level coverage, and rebase the wait onto the shipped terminal-setting scenario before validating the QA flow.

Technical review

Best possible solution:

Accept the recovered config.apply result as a completed restart, then apply the correlated-run wait to current main’s terminal-setting scenario and validate the real restart path.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: inject the supported restart-race recovery result { ok: true, restarted: true } from the QA mutation owner, and the introduced assertion fails before the wake wait.

Is this the best way to solve the issue?

No; the correlated-run wait is a sound addition, but requiring a sentinel on every successful apply contradicts the owner’s supported recovery result and the branch needs rebasing onto the current scenario.

Full review comments:

  • [P2] Accept recovered config.apply restart success — qa/scenarios/config/config-restart-capability-flip.yaml:122-124
    applyConfig may validly recover from a restart race with { ok: true, restarted: true } after confirming the requested config is already visible. That result has no RPC sentinel, so this assertion aborts the scenario before the new correlated-run wait; accept the recovery result and cover it at the scenario boundary.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 762063f08f0e.

Labels

Label justifications:

  • P2: The defect can make a maintained qualification scenario fail or provide unreliable restart evidence, without changing product runtime behavior.
  • merge-risk: 🚨 automation: The PR changes the restart qualification scenario and its lifecycle assertions, and it currently conflicts with the shipped scenario implementation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This MEMBER-authored internal QA reliability PR is exempt from the external-contributor proof gate; its body nevertheless records that the relevant stacked runtime-pair trace remains pending after the required rebase.

Evidence

What I checked:

Likely related people:

  • RomneyDa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Accept and cover recovered config.apply restart success.
  • Rebase the lifecycle wait onto current main’s terminal-setting restart scenario.
  • Attach a redacted runtime-pair trace from the corrected scenario.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-20T22:47:33.584Z sha fc70d69 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T07:36:37.215Z sha fc70d69 :: needs changes before merge. :: [P2] Accept the recovered config.apply restart result
  • reviewed 2026-08-22T08:06:59.240Z sha fc70d69 :: found issues before merge. :: [P2] Accept recovered config.apply restart success
  • reviewed 2026-08-24T12:20:14.973Z sha fc70d69 :: found issues before merge. :: [P2] Accept recovered config.apply restart success
  • reviewed 2026-08-25T14:18:33.080Z sha fc70d69 :: needs changes before merge. :: [P2] Accept recovered config.apply restart success
  • reviewed 2026-08-25T14:36:49.987Z sha fc70d69 :: found issues before merge. :: [P2] Accept recovered config.apply restart success
  • reviewed August 25, 2026, 11:19 AM ET / 15:19 UTC sha unknown :: found issues before merge. :: [P2] Accept recovered config.apply restart success
  • reviewed 2026-09-02T07:28:07.958Z sha fc70d69 :: found issues before merge. :: [P2] Accept recovered config.apply restart success

@vincentkoc
vincentkoc force-pushed the fix/qa-wake-lifecycle-20260820 branch from f15af38 to fc70d69 Compare August 20, 2026 22:40
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 22, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Closing as superseded by #127285, landed in 0d727c3 and retained on current main 6b07b94.

The current QA flow waits directly for the restart wake message before polling restored tools:

- call: waitForGatewayHealthy
args:
- ref: env
- 60000
- call: waitForQaChannelReady
args:
- ref: env
- 60000
- call: waitForOutboundMessage
args:
- ref: state
- lambda:
params: [candidate]
expr: "candidate.conversation.id === 'qa-operator' && candidate.text.includes(wakeMarker)"
- expr: liveTurnTimeoutMs(env, config.imageTurnTimeoutMs)
- call: waitForCondition
saveAs: afterTools
args:
- lambda:
async: true
expr: "(() => readEffectiveTools(env, sessionKey).then((tools) => (tools.has('image_generate') ? tools : undefined)))()"
- expr: liveTurnTimeoutMs(env, config.imageTurnTimeoutMs)

Its follow-up prompt helper starts the run and awaits agent.wait, so completion is observed at the owning boundary:

const started = await startAgentRun(env, params);
const waited = await waitForAgentRun(env, started.runId!, params.timeoutMs ?? 30_000);
if (!isSuccessfulAgentWaitResult(waited)) {
throw new Error(
`agent.wait returned ${waited.status ?? "unknown"}: ${waited.error ?? "no error"}`,
);
}
if (params.transcriptToolName) {
await waitForPersistedTranscriptToolEvidence(env, {
sessionKey: params.sessionKey,
toolName: params.transcriptToolName,
requireSuccessfulResult: params.requireSuccessfulTranscriptToolResult === true,
});
}
return {
started,
waited,
};

Restart work is durably enqueued before sentinel consumption and the exact wake/continuation entries are drained afterward:

// Every downstream intent is durable before consuming the singleton. A
// failed or stale compare-delete cannot lose work or remove a newer row.
const consumed = await clearRestartSentinelIfRevision(sentinelRevision);
if (!consumed) {
log.info(`${summary}: newer restart sentinel preserved while draining durable work`, {
sessionKey: canonicalKey,
});
}
if (wakeQueueId) {
await drainRestartContinuationQueue({
deps: params.deps,
entryId: wakeQueueId,
log,
queueContext,
});
}
if (route && noticeQueueId && noticeQueueCreated) {
const delivered = await deliverRestartSentinelNotice({
deps: params.deps,
cfg,
sessionKey: canonicalKey,
summary,
message: noticeMessage,
...route,
queueId: noticeQueueId,
});
if (delivered && updateRunId) {
recordUpdateRunVerification(updateRunId, { noticeDelivered: true });
}
} else if (noticeQueueId && !noticeQueueCreated) {
log.info(`${summary}: durable restart notice already owned`, {
sessionKey: canonicalKey,
});
}
if (continuationQueueId) {
await drainRestartContinuationQueue({
deps: params.deps,
entryId: continuationQueueId,
log,
queueContext,
});
}

That makes the historical sessions.list / runId inference unnecessary and less authoritative than the direct wake plus awaited follow-up proof. No code from this branch needs landing.

@vincentkoc vincentkoc closed this Sep 16, 2026
@RomneyDa
RomneyDa deleted the fix/qa-wake-lifecycle-20260820 branch October 22, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: qa-lab maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant