Skip to content

fix(chat): restore first turns in a new session store - #170464

Merged
steipete merged 2 commits into
mainfrom
ci/fix7-heartbeat-store
Oct 13, 2026
Merged

steipete merged 2 commits into
mainfrom
ci/fix7-heartbeat-store

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes the first message to a cold configured session store failing before any provider request. This also breaks the parent turn in the heartbeat store-lifecycle product test before it can spawn a child.

User Impact

The first turn can create its configured store and continue with the request's original authorization. Source replacement, credential revocation, and membership changes retain their existing refusal behavior.

Why This Change Was Made

Regression from #169622 (cbc53ac75eca): native reply admission followed its own first-store registration, but the Gateway request's separate retained sharing witness did not. The witness invalidated itself on that registration.

Forward the existing committed registration callback through reply admission to that witness, after updating the admission selector and before public observers run. Keep asynchronous preparation and the reduced database work; add no SQL, retries, fallback reads, or new lifetime owner. Group the existing session-initialization callbacks in their small owner module while preserving their dispatch-time read. Schema, stored data, and update behavior stay unchanged.

Evidence

  • Current-main baseline and the same run under four CPU workers: 0/2 original product cases pass; the parent makes zero provider requests.
  • Extended existing cold-admission regression fails before the production fix and passes after it, while retaining the no-main-thread-SQL and cleanup assertions.
  • First repaired focused run: 46/46 tests pass across the original product file, sharing preparation, and admission/retention controls.
  • Final version under the same CPU pressure: 2/2 original product cases pass, including child execution and notification ownership across both store transitions. pnpm test src/gateway/server.heartbeat-store-lifecycle.product-proof.test.ts --maxWorkers=1: 179.73s Vitest, 194.65s wrapper including worker preparation; timing is not a performance comparison.
  • Final binding/dispatch lifecycle run: 95/95 pass (304.50s wrapper), including credential and membership revocation.
  • Final core types, targeted Gateway/infrastructure test types, lint, boundary lint, formatting, line caps, import-cycle checks, and independent P2 review pass.
  • Full architecture and source-contract commands pass. All three deadcode export scans pass with zero entries. Broad affected-suite and complete check-changed proof belong to PR CI under the current local-proof policy. No remote lease was used.

The first PR CI run caught a type-only import cycle in the callback extraction. The follow-up removes the recorder import while preserving the exact six-field initialization type. Corrected Madge, core types, lint, and P2 review pass; runtime behavior is unchanged, so the completed behavior tests are reused. Corrected-head CI 38330353532 passes all 76 jobs at b024cd13b300.

The retained mutation authorization introduced by #169622 (cbc53ac)
did not follow reply admission's own first-store registration. Its sharing
witness expired before provider execution, so the first parent turn failed
before it could spawn a child.

Forward the existing committed registration callback through reply admission,
after the admission selector follows it and before public observers run.
Keep asynchronous preparation, current-authority checks and the reduced SQL
work. Group session initialization callbacks without changing their lazy
read time or lifecycle ownership.

Extend the existing cold-admission regression without weakening its SQLite
and retirement assertions. Preserve schema, stored data and update behavior.
@clawsweeper

clawsweeper Bot commented Oct 13, 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.

@steipete
steipete marked this pull request as ready for review October 13, 2026 00:56
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Oct 13, 2026
CI found a type-only dependency cycle from chat admission through session
binding and the user-turn recorder. Replace the recorder import with the
same six-field initialization contract already declared by its getter.

Runtime behavior is unchanged. The full Madge check, core types, targeted
lint and P2 review pass after this correction.
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 13, 2026
@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR forwards first-store registration receipts to the chat request’s retained authorization witness.

Example: Send “Spawn one worker now.” to agent:main:store-proof with a configured session store that does not yet exist.

  • Before: Store registration invalidates the request’s sharing witness, and the parent turn fails before contacting the provider.
  • After: The witness follows the turn’s own registration, allowing the parent and child turns to execute.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch has no identified introduced defect, but the required authority evidence does not yet support merge readiness.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The first message to a new configured session store fails before any provider request.
Reason: The repair restores ordinary chat execution and preserves the existing worker and authorization design; the supplied maintainer-author context establishes direction.

Regression provenance

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

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this PR open: it repairs a concrete first-turn regression still present on current main, and review found no actionable introduced code defect.

Priority: P1
Reviewed head: b024cd13b300a78ef90340c5855a5520a0e7dcef

Before merge

  • Add real behavior proof - Authority-chain proof required: the reported Gateway/HTTP product run exercises successful cold-store parent and child execution, but the supplied binding tests mock dispatch and establish no final provider-boundary rejection for a revoked credential or removed member; provide redacted logs or a terminal trace covering those controls, with keys, IPs, phone numbers, and non-public endpoints removed. 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.
  • Resolve security concern: Verify retained authority after first-store registration - The new callback advances the request’s retained sharing witness across registration; existing revocation checks stop at mocked dispatch or direct assertions and do not establish refusal before provider I/O on this path.
  • Resolve merge risk - Following first-store registration must not keep a revoked caller or removed session member authorized to reach provider I/O.

Findings

  • [medium] Verify retained authority after first-store registration — src/gateway/server-methods/chat-send-session-binding.ts:74

Tests

  • Missing end-to-end proof: Supply a cold-store Gateway/provider trace for authorized execution and rejection before provider I/O after credential or membership revocation.
Agent review details

How this fits together

Gateway chat.send retains caller and session authorization, passes initialization callbacks through reply admission, and uses worker-owned database preparation before agent execution and provider requests.

flowchart TD
  A[Gateway chat request] --> B[Retained session authorization]
  A --> C[Reply dispatch]
  C --> D[Reply admission]
  D --> E[Database worker preparation]
  E --> F[Registration receipt]
  F --> B
  D --> G[Agent and provider execution]
Loading

Technical review

Best possible solution:

Retain this focused receipt-forwarding repair and verify that cold-store execution preserves authorization at the provider boundary.

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

Current-main source exposes the missing registration forwarding, and the PR reports failure of both existing Gateway product cases before the fix; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch repairs the missing publication path at the existing admission owner without adding SQL, retries, fallback reads, or a competing lifetime owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 64d15a871282.

Merge-risk options

Maintainer options:

  1. Prove cold-store authorization before merge (recommended)
    Supply a production-path trace showing an authorized first turn reaching the provider and credential or membership revocation preventing provider I/O after awaited store preparation.

Provenance checked

  • Retained chat authorization and creation callbacks keeps the original intent (cbc53ac: Move reads and authorization into workers while retaining request facts and publishing committed creation before dependent effects.)
  • Worker-backed reply admission keeps the original intent (0269af6: Keep admission responsive during contention and retain physical ownership and current request authority across awaited preparation.)
  • Dispatch lifecycle interruption keeps the original intent (b49119b: Refresh stale dispatches while refusing genuine session-owner changes.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was found, but final-effect revocation evidence remains incomplete.

Evidence

Security concerns:

  • [medium] Verify retained authority after first-store registration — src/gateway/server-methods/chat-send-session-binding.ts:74
    The new callback advances the request’s retained sharing witness across registration; existing revocation checks stop at mocked dispatch or direct assertions and do not establish refusal before provider I/O on this path.
    Confidence: 0.94

What I checked:

PR surface

Source +46, Tests +12. Total +58 across 13 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 11 72 26 +46
Tests 2 13 1 +12
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 85 27 +58

Review metrics

Metric Value Why it matters
Production versus test LOC Production +72/-26; tests +13/-1 Production growth primarily carries the existing registration callback and groups lazily read initialization options; the regression extends existing coverage.

Labels

Label changes:

  • add P1: The source-backed regression prevents the first chat turn in a new configured store from reaching agent execution.
  • add merge-risk: 🚨 security-boundary: The patch preserves a retained authorization witness across registration, requiring final-effect evidence that revocation still prevents provider access.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P1: The source-backed regression prevents the first chat turn in a new configured store from reaching agent execution.
  • merge-risk: 🚨 security-boundary: The patch preserves a retained authorization witness across registration, requiring final-effect evidence that revocation still prevents provider access.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Show an authorized cold-store turn reaching the provider and credential or membership revocation blocking the same path before provider I/O.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 12, 2026, 9:12 PM ET / October 13, 2026, 01:12 UTC.

@steipete
steipete merged commit 3026b63 into main Oct 13, 2026
146 of 148 checks passed
@steipete
steipete deleted the ci/fix7-heartbeat-store branch October 13, 2026 01:19
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
Fix the first message to a cold configured session store failing before any provider request. Reply admission created and registered the SQLite store, but the retained request authorization introduced by openclaw#169622 (27c3ba3) did not follow its own registration and invalidated itself.

Forward the existing committed registration callback to that witness after updating the admission selector and before public observers. Preserve asynchronous preparation, current-authority checks, and the reduced database work. Keep session-initialization types independent of the recorder to avoid a type-only import cycle.

The cold-admission regression fails before the fix. Original product cases pass under the same four-worker CPU pressure; focused sharing, binding, dispatch, admission and retention tests pass. Core and targeted test types, lint, boundary lint, architecture/source contracts, deadcode and P2 review pass. Corrected-head CI 38330353532 passes all 76 jobs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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