Skip to content

fix(gateway): persist response continuations and reject unresolved previous_response_id - #159227

Merged
steipete merged 1 commit into
mainfrom
fix/live2-responses-unknown-previous
Sep 28, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/live2-responses-unknown-previous

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

On the Gateway's OpenResponses endpoint, POST /v1/responses with a previous_response_id the Gateway could not resolve returned HTTP 200 with a completed response in a new conversation. The caller was never told its context was dropped. Continuation mappings were also memory-only (30 minutes, 500 entries), so every Gateway restart or idle gap silently broke legitimate continuations. Found by live QA on main: {"model":"openclaw","input":"Hi","previous_response_id":"missing"} returned 200.

Why This Change Was Made

Maintainer decision: persist mappings, then go strict.

  1. Persist continuations in the existing core keyed store. No new table and no schema change. The in-memory Map is replaced by createCorePluginStateKeyedStore (src/gateway/openresponses-session-store.ts) in the shared state DB:
    • ownerId core:openresponses, namespace response-sessions
    • 30-day TTL and a 5,000-entry cap with evict-oldest
    • expired entries are excluded on read and swept by the existing shared maintenance
      The value holds the session key plus the request scope. A lookup returns the session only when the auth subject, agent, and requested session key all match. This PR does not touch the SQLite schema, the state-worker contracts, or the generated DB types.
  2. Protect credentials. A bearer caller's authSubject is an HMAC-SHA-256 of the bearer under a purpose-bound key derived from the existing config_revision_keys installation key (label openresponses-session-scope, via src/gateway/config-revision-token.ts). It is never a raw or unsalted hash. Trusted-proxy and gateway-auth subjects are unchanged. Incognito mappings, including short session-key aliases, are never written.
  3. Order persistence before publication. The mapping is committed before any terminal JSON or SSE event is published. SSE terminal events cannot go out until the run has settled, and the run commits continuity first; an inline comment at maybeFinalize records that invariant.
    • If persistence fails on a successful run, the client gets a visible failure (HTTP 500 / response.failed).
    • A failed run, whether it rejected or resolved with runFailed, keeps its own error response, and the persistence failure is logged.
  4. Go strict. An unresolved, expired, or out-of-scope previous_response_id returns 400 invalid_request_error ("Cannot resolve previous_response_id. Retry with full input context and omit previous_response_id."), including for stream: true. The error is uniform, so it does not reveal whether another caller's id exists.

docs/gateway/openresponses-http-api.md documents the rule and the mapping lifetime.

User Impact

  • Continuations survive Gateway restarts and idle gaps for up to 30 days.
  • Genuinely unknown or expired ids get a clear 400 instead of a context-less answer. Clients that relied on the silent fallback must resend full input on that 400.

Evidence

  • Regressions:
    • unknown and out-of-scope ids return 400; they returned 200 on main
    • a continuation survives a store reopen with the same bearer
    • a different bearer is rejected
    • the stored value contains no sha256(bearer)
    • Incognito is not persisted
    • expiry after the TTL
    • successful, rejected, and resolved-failed runs combined with persistence failure, for both JSON and SSE (the resolved-failed cases failed 2/131 with the fix reverted)
  • Blacksmith Testbox: 527 tests on the keyed-store rework (OpenResponses/store/config-token, plugin-state, and related Gateway suites), 149 on the final head. node scripts/check-changed.mjs passes.
  • Codex autoreview: its SSE-ordering concern was rejected with code evidence (terminal events are gated on finalUsage, which is assigned only after the run settles). The resolved-failed-run finding was fixed.
  • LOC: net production +41 for the keyed-store rework, plus +11 for the failed-run fix.

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 28, 2026, 5:22 AM ET / 09:22 UTC (Revision 5).

ClawSweeper review

What this changes

The branch stores OpenResponses continuation IDs in SQLite for up to 30 days, scopes bearer IDs with an installation-keyed HMAC, and returns HTTP 400 for unresolved IDs.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 10 items remain

Keep open: current main still has the reported continuation failure, while the pinned branch has unresolved compatibility and session-boundary defects. Its after-fix proof does not reach the final agent effect.

Priority: P2
Reviewed head: 4053d29be3c17becc50c5df1d054b717f95b4e5b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The persistence implementation has focused tests, but three compatibility or session-boundary findings and missing final-effect and upgrade proof limit merge confidence.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: Authority-chain proof required: The changed Gateway handler and SQLite store are exercised through HTTP tests, but the agent command is mocked; there is no after-fix final-effect observation for the allowed bearer, a different bearer, or a reset-stale ID. Existing-state candidate opening and rollback are also unproven. A redacted production-path trace should show those outcomes before merge; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Authority-chain proof required: The changed Gateway handler and SQLite store are exercised through HTTP tests, but the agent command is mocked; there is no after-fix final-effect observation for the allowed bearer, a different bearer, or a reset-stale ID. Existing-state candidate opening and rollback are also unproven. A redacted production-path trace should show those outcomes before merge; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 11 items Current main still falls back: At the fetched main revision, a missing response mapping falls back to the request's resolved session key; the reported silent context loss remains possible for a stateless request.
Stable session remains resolvable: An explicit session header or a stable user value produces a repeatable session key independently of the response mapping.
Strict rejection on the PR head: The introduced guard returns 400 for any supplied ID without a mapping before an available stable session key can be used.
Findings 3 actionable findings [P1] Preserve recovery for an authorized stable session
[P1] Fence stored response IDs to the session generation
[P1] Retain live Incognito response-ID continuation
Security Needs attention Stale response handle can address a replacement session: A response ID retained across reset still resolves to the same logical key after its lifecycle revision changes. Current request authorization does not establish that the old handle belongs to the replacement generation before agent dispatch.

How this fits together

The Gateway OpenResponses endpoint accepts authenticated HTTP requests and selects an agent session before running a turn. It returns JSON or streaming events, and later requests can use a response ID to select that session again.

flowchart LR
A[Authenticated HTTP request] --> B[OpenResponses handler]
B --> C[Response ID lookup]
C --> D[Shared SQLite store]
C --> E[Session authorization]
E --> F[Agent turn]
F --> G[JSON or streaming reply]
F --> D
Loading

Decision needed

Question Recommendation
Should adopting strict response IDs also remove recovery for a live authorized stable session and remove response-ID continuation for a live Incognito session? Preserve live-session recovery: Reject genuinely unresolvable stateless IDs while retaining verified stable-session recovery and ephemeral Incognito ID continuity.

Why: Both paths worked before this branch; the PR body states a strict direction, but the available discussion does not specifically accept these client-visible compatibility changes or their upgrade behavior.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Authority-chain proof required: The changed Gateway handler and SQLite store are exercised through HTTP tests, but the agent command is mocked; there is no after-fix final-effect observation for the allowed bearer, a different bearer, or a reset-stale ID. Existing-state candidate opening and rollback are also unproven. A redacted production-path trace should show those outcomes before merge; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve recovery for an authorized stable session (P1) - When a mapping expires, is evicted, or is lost across upgrade, the same caller's user or explicit session key can still identify a live authorized session. This guard returns 400 before that session can be used, breaking existing clients. Preserve the verified path or obtain specific acceptance of the breaking contract with upgrade proof.
  • Fence stored response IDs to the session generation (P1) - The durable value stores only a session key and request scope. Reset can retain that key while rotating its lifecycle revision, so an old response ID can dispatch into the replacement session. Bind and recheck the generation at run admission, or retire its mappings on reset.
  • Retain live Incognito response-ID continuation (P1) - The old in-memory map recorded Incognito response IDs, but this early return skips every new mapping, so a successful Incognito response's ID immediately receives 400 on the next request. Keep its continuation ephemeral while the live session exists, or obtain explicit acceptance of this API break.
  • Resolve security concern: Stale response handle can address a replacement session - A response ID retained across reset still resolves to the same logical key after its lifecycle revision changes. Current request authorization does not establish that the old handle belongs to the replacement generation before agent dispatch.
  • Resolve merge risk (P1) - The strict default rejects existing stable-session clients after mapping loss and rejects Incognito response IDs immediately; no specific accepted compatibility and recovery plan covers both changes.
  • Resolve merge risk (P1) - A durable response ID can outlive a reset and select the replacement session generation; rejection before the final agent effect remains unproven.
  • Resolve merge risk (P1) - Opening existing state with the candidate and rolling back candidate-written state have not been demonstrated for the new durable mapping.
  • Complete next step (P2) - Resolve the three findings, obtain explicit continuation-contract acceptance, add allowed and forbidden final-effect plus existing-state upgrade and rollback proof, and record new-test cost.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Preserve recovery for an authorized stable session — src/gateway/openresponses-http.ts:420-425
  • [P1] Fence stored response IDs to the session generation — src/gateway/openresponses-session-store.ts:50-57
  • [P1] Retain live Incognito response-ID continuation — src/gateway/openresponses-session-store.ts:47-49
  • [medium] Stale response handle can address a replacement session — src/gateway/openresponses-session-store.ts:50
Agent review details

Security

Needs attention: Bearer subjects use a purpose-bound HMAC, but durable response IDs are not fenced to the live session generation.

PR surface

Source +52, Tests +405, Docs +6. Total +463 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 4 190 138 +52
Tests 17 567 162 +405
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 763 300 +463

Review metrics

Metric Value Why it matters
Continuation retention 30 days and 5,000 IDs; previously 30 minutes and 500 in memory The longer durable lifetime makes reset, eviction, and upgrade behavior material.
Production versus test growth production net +52 lines; tests and test support net +405 lines The production growth replaces the ephemeral map, while the new coverage still mocks the final agent dispatch.

Merge-risk options

Maintainer options:

  1. Repair continuation boundaries (recommended)
    Preserve the accepted live-session paths, fence durable IDs to the current lifecycle, and prove final effects plus upgrade and rollback behavior.
  2. Accept the strict client contract
    A maintainer can accept the compatibility break after documenting recovery and proving upgrades, while still requiring the session-generation repair.

Technical review

Best possible solution:

Keep ordinary continuations in the shared keyed store, preserve authorized stable-session recovery and live Incognito continuation, and fence every stored ID to the current session generation before agent dispatch.

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

Yes, at source level. Current main falls back for an unknown ID, and the pinned branch has direct stable-session, Incognito, and reset-stale paths; this read-only review did not execute them.

Is this the best way to solve the issue?

No. The shared keyed store is the appropriate persistence owner, but the unconditional 400 changes recoverable existing paths and its stored value cannot identify a replaced session generation.

Full review comments:

  • [P1] Preserve recovery for an authorized stable session — src/gateway/openresponses-http.ts:420-425
    When a mapping expires, is evicted, or is lost across upgrade, the same caller's user or explicit session key can still identify a live authorized session. This guard returns 400 before that session can be used, breaking existing clients. Preserve the verified path or obtain specific acceptance of the breaking contract with upgrade proof.
    Confidence: 0.95
  • [P1] Fence stored response IDs to the session generation — src/gateway/openresponses-session-store.ts:50-57
    The durable value stores only a session key and request scope. Reset can retain that key while rotating its lifecycle revision, so an old response ID can dispatch into the replacement session. Bind and recheck the generation at run admission, or retire its mappings on reset.
    Confidence: 0.91
  • [P1] Retain live Incognito response-ID continuation — src/gateway/openresponses-session-store.ts:47-49
    The old in-memory map recorded Incognito response IDs, but this early return skips every new mapping, so a successful Incognito response's ID immediately receives 400 on the next request. Keep its continuation ephemeral while the live session exists, or obtain explicit acceptance of this API break.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded Gateway HTTP repair with material continuation defects and limited endpoint blast radius.
  • merge-risk: 🚨 compatibility: The new default can reject existing stable-session and Incognito response-ID clients.
  • merge-risk: 🚨 session-state: A durable response ID can select a logical session key after its lifecycle revision changes.
  • merge-risk: 🚨 security-boundary: A retained response handle is not checked against the live session generation before agent dispatch.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Authority-chain proof required: The changed Gateway handler and SQLite store are exercised through HTTP tests, but the agent command is mocked; there is no after-fix final-effect observation for the allowed bearer, a different bearer, or a reset-stale ID. Existing-state candidate opening and rollback are also unproven. A redacted production-path trace should show those outcomes before merge; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Stale response handle can address a replacement session — src/gateway/openresponses-session-store.ts:50
    A response ID retained across reset still resolves to the same logical key after its lifecycle revision changes. Current request authorization does not establish that the old handle belongs to the replacement generation before agent dispatch.
    Confidence: 0.89

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Dallin Romney: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: 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.

  • Show the allowed continuation reaching a real final agent turn and prove a different bearer and reset-stale ID are rejected before agent I/O.
  • Prove a published-driver to candidate upgrade and rollback using existing session state and pre-upgrade response IDs.
  • Record the required one-worker wall cost for the new test files.

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 (4 earlier review cycles)
  • reviewed 2026-09-26T22:53:01.995Z sha c411ca1 :: blocked before merge. :: [P1] Preserve stable-session continuation after mapping loss
  • reviewed 2026-09-27T08:20:57.049Z sha b6442d8 :: blocked before merge. :: [P1] Preserve authorized stable-session recovery after mapping loss | [P1] Bind stored response IDs to the session generation
  • reviewed 2026-09-28T03:48:47.552Z sha 77ffd16 :: blocked before merge. :: [P1] Preserve authorized stable-session recovery after mapping loss | [P1] Bind persisted response IDs to the session lifecycle
  • reviewed 2026-09-28T08:11:15.461Z sha 970cf2114306e4b5bfcbad5a7645a6671c28e66b :: needs real behavior proof before merge. :: [P1] Preserve recovery for an authorized stable session | [P1] Fence stored response IDs to the session generation

@steipete
steipete force-pushed the fix/live2-responses-unknown-previous branch from c411ca1 to b6442d8 Compare September 27, 2026 08:13
@steipete steipete changed the title fix(gateway): reject unresolved previous_response_id instead of starting a new conversation fix(gateway): persist response continuations and reject unresolved previous_response_id Sep 27, 2026
@steipete
steipete marked this pull request as ready for review September 27, 2026 08:13
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 27, 2026
@steipete
steipete force-pushed the fix/live2-responses-unknown-previous branch from b6442d8 to 77ffd16 Compare September 28, 2026 03:40
@steipete
steipete force-pushed the fix/live2-responses-unknown-previous branch from 77ffd16 to 970cf21 Compare September 28, 2026 08:03
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 28, 2026
…evious_response_id

Persist previous_response_id mappings in the core keyed store (core:openresponses/response-sessions, 30-day TTL, 5,000 cap) with purpose-bound HMAC bearer scoping, never persist Incognito mappings, commit continuity before terminal publication, keep failed-run errors, and return a uniform 400 for unresolved ids.
@steipete
steipete force-pushed the fix/live2-responses-unknown-previous branch from 970cf21 to 4053d29 Compare September 28, 2026 09:14
@steipete
steipete merged commit 14f6562 into main Sep 28, 2026
149 of 200 checks passed
@steipete
steipete deleted the fix/live2-responses-unknown-previous branch September 28, 2026 10:37
@steipete

Copy link
Copy Markdown
Contributor Author

Admin-merged at the maintainer's direction at exact reviewed head 4053d29be3c17becc50c5df1d054b717f95b4e5b.

The red checks (checks-node-changed-2 / -3) are two Gateway e2e failures that already exist on main. Neither test touches OpenResponses continuity. Both were reproduced on a Blacksmith Testbox, run the same way as in CI, at clean origin/main and at this head:

  • src/gateway/subagent-completion-blocked.e2e.test.ts, "suspends native completion delivery after ordinary delivery exhaustion": main 5/5 fail, this head 5/5 fail.
  • src/gateway/gateway-agent-skill-refresh.e2e.test.ts, "refreshes managed-worktree skills once per edit…": main 5/5 fail, this head 5/5 fail.

The root-cause fix for both is being prepared directly on main.

Proof for this PR is in its body: focused OpenResponses and Gateway tests, the keyed-store persistence and restart continuity, and the bearer-scoped HMAC isolation. The final Codex autoreview found no remaining accepted findings. There is no schema change; continuity uses the core plugin-state keyed store.

steipete added a commit that referenced this pull request Sep 28, 2026
The shared HTTP server fixture omitted the Gateway request context required
for bearer-scoped OpenResponses continuity after 14f6562 (#159227).
Use the existing request-context factory and real config revision projector,
matching production wiring while preserving explicit fixture overrides.
Production authentication, persistence, and current-authority checks are
unchanged.

Reproduced all five HTTP 500 failures on pristine main 6aa5242.
The existing regression cases pass 34/34 after the fix. On isolated Linux,
the failed CI shard plus every harness consumer and OpenResponses suite
pass 1179 tests across 65 files; pnpm tsgo:core and formatting also pass.
Focused runner wall time: 49.49s before (cold compiler), 17.05s after
(cached compiler); these are validation costs, not a performance claim.
Independent review found no actionable issues.
steipete added a commit that referenced this pull request Sep 28, 2026
Picks up main's fixes for failing gates on this PR's merge ref: dd3fb2b
(current Gateway context in the HTTP test harness after #159227), f504ddd
(join Gateway completion before teardown) and d923cd0 (fixture alignment).
No files touched by this PR changed on main.
steipete added a commit that referenced this pull request Sep 28, 2026
## What Problem This Solves

Cron exit watcher retry deadlines now use the required Gateway scheduler. A scheduled retry joins startup and failed-start state publication, then the existing watcher owns the long-running child through exit. Cancellation and replacement still preserve exact slot ownership and drain watcher lifecycles.

The cutover deletes native timeout handles, `unref` calls, and the unused shell-injection option. No operator configuration or persisted schema changes.

Production **+32/-26/net +6**; tests **+101/-38/net +63**. This correctness-driven slice uses the closeout's real deletion offsets.

## Evidence

Final head `66d57e0dfa26e242a9c80f415c7f29d65a5721cd`, based on merged main `14f65626bd25cd23182cba98a2b9ca1af6fc5f23` after cron stream merge `2aaf6d41a73e43180334a669315eb68bad1b3173`. Only the exit commit is included. The rebase is patch-identical (`git range-diff` reports `=`), and all three changed files are byte-identical to the tested head below. Existing review and Testbox proof are reused; `git diff --check` passes and the worktree is clean.

- Independent Codex autoreview: clean through P2. The committed patch exactly matches the reviewed patch (SHA256 `3ca06c7e52888c92689d9dbc5cebcbb1a18199c1bf3290351d81a14693e81755`).
- Exact-head Blacksmith Testbox `tbx_01m3kjwyph0svfjebr22jy7w8q`, run [36399017112](https://github.com/openclaw/openclaw/actions/runs/36399017112), head `80fc468ac824da48ef94423d7a79da316d4ed976`: `pnpm test src/gateway/cron-exit-watchers.test.ts --maxWorkers=1` passed (**28 tests**, **3.75s wall**).
- Scoped `node scripts/check-changed.mjs --base 42975a2 -- src/gateway/cron-exit-watchers.test.ts src/gateway/cron-exit-watchers.ts src/gateway/server-cron.ts` passed on the same exact head: **1463.25s wall**, including production and all core test type graphs, format, lint, line ratchets, dead-export scan, and architecture guards.

Release-note context: Gateway-owned cron exit retries now share scheduler catch-up and shutdown ownership while child-process settlement remains with its watcher.


### Final inherited-CI classification

CI run [36411857535](https://github.com/openclaw/openclaw/actions/runs/36411857535) completed on reviewed head `66d57e0dfa26e242a9c80f415c7f29d65a5721cd`, testing merge tree `80ef6fe243fb9c0c148975007d087c81f1a1a52d` against main parent `fc168b2f6c16312181ce15bcb56d36a14e2c4849`. All six failing test jobs have independent evidence in owners this change does not modify:

| Failure | This PR | Matching independent evidence |
| --- | --- | --- |
| Session rename remains Original session after ordinary Enter | [job 108894925328](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894925328) | Clean main at `251c610735855d2955f9f0f1aa5e4338be18f5e4`: [job 108908250303](https://github.com/openclaw/openclaw/actions/runs/36416233754/job/108908250303). The same parameterized test body fails at line 119 with the same expected committed title and received Original session. Matrix cells differ: this PR uses legacy/Escape; main uses modern/Enter. Both already passed the composition assertions, then execute the identical ordinary Enter, matching patch, list reconciliation, and final rendered-title assertion. |
| Manually unread UI state times out waiting for its unread dot | [job 108894925308](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894925308) | Independent MCP [job 108865636156](https://github.com/openclaw/openclaw/actions/runs/36402978963/job/108865636156): same `session-management.unread.e2e.test.ts` case, line 266, unread-dot locator, and 30000ms timeout. |
| Canonical skills refresh E2E exceeds its 90000ms timeout | [job 108894929439](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894929439) | Independent questions [job 108880022656](https://github.com/openclaw/openclaw/actions/runs/36407409443/job/108880022656): identical canonical-skills test and 90000ms timeout. |
| Subagent completion remains pending instead of suspended | [job 108894929700](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894929700) | Independent activity [job 108869549339](https://github.com/openclaw/openclaw/actions/runs/36404157978/job/108869549339): same ordinary-delivery-exhaustion test and pending/retryable versus suspended/permanent_failure assertion. |
| Requester serial continuation never reaches delivered cleanup | [job 108894933085](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894933085) | Config [job 108890604749](https://github.com/openclaw/openclaw/actions/runs/36410694894/job/108890604749) and companion [job 108888541543](https://github.com/openclaw/openclaw/actions/runs/36410052666/job/108888541543): identical CLI cell with next child accepted=false and requester final=false; same failed/intentional_non_delivery state, `worker task timed out`, and helper line 101. |
| Five OpenResponses HTTP fixture cases receive 500 instead of 200 | [job 108894933187](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894933187) | Clean actual CI main parent `fc168b2f6c16312181ce15bcb56d36a14e2c4849`, complete-file reproduction on Blacksmith Testbox `tbx_01m3kswm6aw0bxmdxv2e6qpfv6` ([lease run 36411554208](https://github.com/openclaw/openclaw/actions/runs/36411554208)): identical five failures, 29 passes, and missing Gateway context error. |

The remaining red is the aggregate [CI gate](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108903858681), derived from those six jobs.

For the HTTP baseline, a separate clean detached worktree passed exact-SHA, clean-tree, and frozen-install assertions. The complete `src/gateway/server-http.openai-compat.test.ts` ran once through `node --import tsx scripts/ci-run-node-test-shard.mts` with the CI `test/vitest/vitest.gateway-server.config.ts` config, `bun-compatible` runtime policy, empty prebuilt-dist setting, and two-worker group setting. Wall time: **73.419s**. Responses image-limit hot reload and the completed image/file requests with streaming enabled and disabled all fail at the same `OpenResponses bearer scope requires a current Gateway context` guard in `openresponses-http.ts:127`. The fixture omits `resolveGatewayContext`; the guard introduced on main by #159227 requires its `configRevisionProjector`.

This PR changes only cron exit watchers, their focused tests, and `server-cron.ts` wiring. No assertions were weakened, no baseline source was changed, and no hosted CI was rerun for this evidence.

The maintainer’s standing instruction authorizes pinned admin squash over these proven inherited failures. The protected native GraphQL route preserves the expected head, squash method, and reviewed message.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…penclaw#159227)

Persist previous_response_id mappings in the core keyed store (core:openresponses/response-sessions, 30-day TTL, 5,000 cap) with purpose-bound HMAC bearer scoping, never persist Incognito mappings, commit continuity before terminal publication, keep failed-run errors, and return a uniform 400 for unresolved ids.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
The shared HTTP server fixture omitted the Gateway request context required
for bearer-scoped OpenResponses continuity after a13bb6b (openclaw#159227).
Use the existing request-context factory and real config revision projector,
matching production wiring while preserving explicit fixture overrides.
Production authentication, persistence, and current-authority checks are
unchanged.

Reproduced all five HTTP 500 failures on pristine main dba4154.
The existing regression cases pass 34/34 after the fix. On isolated Linux,
the failed CI shard plus every harness consumer and OpenResponses suite
pass 1179 tests across 65 files; pnpm tsgo:core and formatting also pass.
Focused runner wall time: 49.49s before (cold compiler), 17.05s after
(cached compiler); these are validation costs, not a performance claim.
Independent review found no actionable issues.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
## What Problem This Solves

Cron exit watcher retry deadlines now use the required Gateway scheduler. A scheduled retry joins startup and failed-start state publication, then the existing watcher owns the long-running child through exit. Cancellation and replacement still preserve exact slot ownership and drain watcher lifecycles.

The cutover deletes native timeout handles, `unref` calls, and the unused shell-injection option. No operator configuration or persisted schema changes.

Production **+32/-26/net +6**; tests **+101/-38/net +63**. This correctness-driven slice uses the closeout's real deletion offsets.

## Evidence

Final head `66d57e0dfa26e242a9c80f415c7f29d65a5721cd`, based on merged main `a13bb6b2dcc93892ce304c8141d522d5bd11f0c2` after cron stream merge `9942ecb05f9fabbd6858661cbf38d92c1c55b083`. Only the exit commit is included. The rebase is patch-identical (`git range-diff` reports `=`), and all three changed files are byte-identical to the tested head below. Existing review and Testbox proof are reused; `git diff --check` passes and the worktree is clean.

- Independent Codex autoreview: clean through P2. The committed patch exactly matches the reviewed patch (SHA256 `3ca06c7e52888c92689d9dbc5cebcbb1a18199c1bf3290351d81a14693e81755`).
- Exact-head Blacksmith Testbox `tbx_01m3kjwyph0svfjebr22jy7w8q`, run [36399017112](https://github.com/openclaw/openclaw/actions/runs/36399017112), head `80fc468ac824da48ef94423d7a79da316d4ed976`: `pnpm test src/gateway/cron-exit-watchers.test.ts --maxWorkers=1` passed (**28 tests**, **3.75s wall**).
- Scoped `node scripts/check-changed.mjs --base 42975a2 -- src/gateway/cron-exit-watchers.test.ts src/gateway/cron-exit-watchers.ts src/gateway/server-cron.ts` passed on the same exact head: **1463.25s wall**, including production and all core test type graphs, format, lint, line ratchets, dead-export scan, and architecture guards.

Release-note context: Gateway-owned cron exit retries now share scheduler catch-up and shutdown ownership while child-process settlement remains with its watcher.


### Final inherited-CI classification

CI run [36411857535](https://github.com/openclaw/openclaw/actions/runs/36411857535) completed on reviewed head `66d57e0dfa26e242a9c80f415c7f29d65a5721cd`, testing merge tree `80ef6fe243fb9c0c148975007d087c81f1a1a52d` against main parent `fe49033cd6a57cf09fce7aa1401f29695460ad6b`. All six failing test jobs have independent evidence in owners this change does not modify:

| Failure | This PR | Matching independent evidence |
| --- | --- | --- |
| Session rename remains Original session after ordinary Enter | [job 108894925328](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894925328) | Clean main at `8aae819471a9328e0bfe29676372dcb8717cfaa0`: [job 108908250303](https://github.com/openclaw/openclaw/actions/runs/36416233754/job/108908250303). The same parameterized test body fails at line 119 with the same expected committed title and received Original session. Matrix cells differ: this PR uses legacy/Escape; main uses modern/Enter. Both already passed the composition assertions, then execute the identical ordinary Enter, matching patch, list reconciliation, and final rendered-title assertion. |
| Manually unread UI state times out waiting for its unread dot | [job 108894925308](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894925308) | Independent MCP [job 108865636156](https://github.com/openclaw/openclaw/actions/runs/36402978963/job/108865636156): same `session-management.unread.e2e.test.ts` case, line 266, unread-dot locator, and 30000ms timeout. |
| Canonical skills refresh E2E exceeds its 90000ms timeout | [job 108894929439](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894929439) | Independent questions [job 108880022656](https://github.com/openclaw/openclaw/actions/runs/36407409443/job/108880022656): identical canonical-skills test and 90000ms timeout. |
| Subagent completion remains pending instead of suspended | [job 108894929700](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894929700) | Independent activity [job 108869549339](https://github.com/openclaw/openclaw/actions/runs/36404157978/job/108869549339): same ordinary-delivery-exhaustion test and pending/retryable versus suspended/permanent_failure assertion. |
| Requester serial continuation never reaches delivered cleanup | [job 108894933085](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894933085) | Config [job 108890604749](https://github.com/openclaw/openclaw/actions/runs/36410694894/job/108890604749) and companion [job 108888541543](https://github.com/openclaw/openclaw/actions/runs/36410052666/job/108888541543): identical CLI cell with next child accepted=false and requester final=false; same failed/intentional_non_delivery state, `worker task timed out`, and helper line 101. |
| Five OpenResponses HTTP fixture cases receive 500 instead of 200 | [job 108894933187](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108894933187) | Clean actual CI main parent `fe49033cd6a57cf09fce7aa1401f29695460ad6b`, complete-file reproduction on Blacksmith Testbox `tbx_01m3kswm6aw0bxmdxv2e6qpfv6` ([lease run 36411554208](https://github.com/openclaw/openclaw/actions/runs/36411554208)): identical five failures, 29 passes, and missing Gateway context error. |

The remaining red is the aggregate [CI gate](https://github.com/openclaw/openclaw/actions/runs/36411857535/job/108903858681), derived from those six jobs.

For the HTTP baseline, a separate clean detached worktree passed exact-SHA, clean-tree, and frozen-install assertions. The complete `src/gateway/server-http.openai-compat.test.ts` ran once through `node --import tsx scripts/ci-run-node-test-shard.mts` with the CI `test/vitest/vitest.gateway-server.config.ts` config, `bun-compatible` runtime policy, empty prebuilt-dist setting, and two-worker group setting. Wall time: **73.419s**. Responses image-limit hot reload and the completed image/file requests with streaming enabled and disabled all fail at the same `OpenResponses bearer scope requires a current Gateway context` guard in `openresponses-http.ts:127`. The fixture omits `resolveGatewayContext`; the guard introduced on main by openclaw#159227 requires its `configRevisionProjector`.

This PR changes only cron exit watchers, their focused tests, and `server-cron.ts` wiring. No assertions were weakened, no baseline source was changed, and no hosted CI was rerun for this evidence.

The maintainer’s standing instruction authorizes pinned admin squash over these proven inherited failures. The protected native GraphQL route preserves the expected head, squash method, and reviewed message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant