Skip to content

fix: keep revoked and cancelled callers from affecting shared database preparation - #175307

Merged
steipete merged 4 commits into
mainfrom
fix/agent-preparation-live-callers
Oct 17, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/agent-preparation-live-callers

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A revoked session-deletion caller could repair its database before being refused. Shared database preparation must retain current caller authority without letting one cancelled or refused opener poison healthy borrowers. These failures were originally reproduced from main hourly 39013936147.

User Impact

Revoked callers cannot authorize schema repair or deletion. Healthy replies retain access after another caller is cancelled or refused, while current callers still share physical preparation. First-use creation, fatal native failures, cleanup failures, and unknown outcomes retain their existing ownership rules.

Why This Change Was Made

The shared preparation owner now retains each follower's authority check in that caller's context. Preparation effects require at least one current follower. The execution owner waits for pending initial native opening before choosing whether to reuse or replace a generation. Initial opening and shared promotion capture their actual admission outcome: a confirmed refusal before native entry preserves retained borrowers; protocol faults, unknown outcomes, committed work and cleanup failures keep their terminal handling.

Rebased onto main b46ec6167975f57fa33cc298e78c8338ae59746e. Peer commit b499c60e1968 says: “Existing-file opening belongs to the physical owner, like integrity preparation. Keep caller authority for first-use creation and actual operations so cancellation cannot poison a healthy peer.” The resolution preserves its shared-source and cancellation isolation, physical-failure fixtures, and creation-witness tests. It also preserves this PR's requirement that preparation effects have a current caller. The Gateway regression still checks that revocation leaves the index absent, the session and transcript unchanged, and native custody settled.

Main already contains the transcript seed needed to exercise reclamation after #175091 moved eventless deletion to the admitted writer. That duplicate fixture hunk was removed. The idle-generation fixture includes the required getPendingNativeOpen method. A remaining close-wedge fixture now observes the real physical open through the existing admission probe, since the peer change stopped routing that open through caller admission. Every refusal, concurrent-survivor, exact-result and cleanup assertion remains; the unused caller callback was removed.

The patch keeps one preparation owner and one admission-capture helper. It introduces no schema, dependency, retry, timeout, or permission expansion.

Evidence

Reviewed head: 6ab6bb04830eeee99b6e9c702bdc95059ee46689.

The original two-SHA evidence remains recorded: both reported cases failed on main 8d4591a6c152 and passed on #175008's parent 77cb93218d60. The reordered Gateway assertion demonstrated actual index repair after authority revocation, not just a worker-lifetime mismatch. The retained-borrower regression also failed before the promotion-outcome correction.

Fresh proof after conflict resolution:

OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1 pnpm test src/state/openclaw-agent-execution*.test.ts src/gateway/server/__tests__/server.sessions.reclamation-admission.test.ts src/auto-reply/reply/reply-turn-admission.worker.test.ts --maxWorkers=1
pnpm test src/state/openclaw-agent-execution.close-wedge.test.ts --maxWorkers=1
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.state-logging.json --pretty false

The requested ten-file run passed 99 cases and exposed the stale close-wedge trigger described above. After that fixture correction, its complete file passed 7/7 in 17.37 seconds. Combined retained proof covers 100 distinct passing cases across the requested files, including Gateway reclamation 2/2 (35.25 seconds) and all reply-turn admission cases. The pre-existing Linux-only killed-owner case remains unchanged and is skipped on this macOS host; PR CI covers Linux. The other passing suites were reused after the fixture-only correction.

The state-logging test type graph, targeted type-aware lint, formatting and whitespace checks pass. Typecheck and lint were repeated after the fixture imports changed. Independent P2 reviews are scoped-clean for the full rebased candidate and the final fixture delta; the reviewed final tree matches this head.

No CI dispatch or rerun. The lead owns landing after this head's CI.

@clawsweeper

clawsweeper Bot commented Oct 17, 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 Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Require a current caller for shared database preparation and preserve healthy borrowers after confirmed admission refusals.

Example: Deletion of agent:main:validation-revoked loses authority during database integrity validation.

  • Before: Preparation recreates idx_agent_cache_expiry before rejecting the deletion.
  • After: The index remains absent, the session and transcript remain unchanged, and refused worker custody settles.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch has no actionable finding and meaningful real-worker authority coverage; validation is reported through production-owner harnesses rather than a shipped-entry-point demonstration.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (none): For this maintainer-authored PR, the authority evidence covers real lifecycle owners, SQLite workers, revocation during blocked validation, unchanged session/transcript state, absent unauthorized index repair, and persisted healthy-peer writes; the body reports these scenarios passing on the resolved candidate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Revoked deletion work can repair storage before refusal, and a refused opener can invalidate healthy borrowers.
Reason: The maintainer-authored direction restores existing authority and borrower-isolation contracts without adding configuration, schemas, or another lifecycle owner.

Regression provenance

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

Merge readiness

✅ Ready for maintainer review

This PR fixes a current caller-authority defect without sacrificing shared database preparation; no introduced defect was found, the earlier conflict blocker is resolved, and exact-head CI remains pending.

Priority: P1
Reviewed head: 6ab6bb04830eeee99b6e9c702bdc95059ee46689

Before merge

None.

Findings

None.

Agent review details

How this fits together

The agent database executor coordinates logical borrowers, physical worker generations, preparation, and cleanup; caller authority enters through admission sources and governs worker database effects.

flowchart TD
  A[Session and reply callers] --> B[Execution owner]
  B --> C[Native generation]
  C --> D[Shared preparation followers]
  D --> E[Current caller admission]
  E --> F[Database worker]
  F --> G[Agent database]
Loading

Technical review

Best possible solution:

Keep preparation with the existing physical owner while requiring live follower authority and preserving borrower recovery only for confirmed uncommitted refusals.

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

Current-main source exposes generation-only preparation authority, and the supplied real-worker regressions exercise revocation during validation and refusal before promotion; no target code was executed during this review.

Is this the best way to solve the issue?

The fix belongs in the shared preparation and execution owners, preserves physical preparation sharing, and distinguishes confirmed refusals from protocol faults, unknown outcomes, and cleanup failures.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared preparation authority changes intended behavior with a stated reason (5b5a595: Separate physical preparation from the initiating caller so cancellation cannot poison healthy peer chats.)
  • Physical opening and promotion keeps the original intent (b499c60: Existing-file opening belongs to the physical owner; first-use creation and actual operations retain caller authority.)
  • Preparation completion and discovery keeps the original intent (55d9dab: Discovery must await canonical schema preparation while individual cancellation must not cancel shared creation.)
  • Worker lifetime and borrower recovery keeps the original intent (97f27a6: Recover established native generations without replaying failed operations or reviving old authority.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +51, Tests +54, Docs +5. Total +110 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 98 47 +51
Tests 4 66 12 +54
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 169 59 +110

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Current preparation can perform schema repair after caller revocation, while incorrect refusal handling can invalidate healthy chats' retained database access.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-17T07:57:43.430Z sha 46c9464 :: needs changes before merge. :: none
  • reviewed 2026-10-17T09:19:47.051Z sha ec2e277cc13c556a89a26cb7461670a542fb3985 :: needs changes before merge. :: none

Reviewed October 17, 2026, 5:27 AM ET / 09:27 UTC (Revision 3).

@steipete
steipete force-pushed the fix/agent-preparation-live-callers branch from 46c9464 to 67ee184 Compare October 17, 2026 08:40
@steipete
steipete marked this pull request as ready for review October 17, 2026 08:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T09:25:07.584731Z 6ab6bb0 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the idle-generation fixture contract at ec2e277cc13c. The full execution test group, state-logging test types, targeted checks, and independent P2 review pass; the PR body contains the proof and existing platform-specific gap.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
Require one current follower for shared integrity/schema effects. Settle request-owned native opening before a healthy successor reuses or replaces the generation; keep the full shared preparation joinable.

Both hourly 39010956087 regressions came from #175008. Preserve the existing reclamation assertions while checking the missing index before incidental worker termination. Initial native admission and first-use creation retain original caller authority.

Focused six-file proof plus final three-case integration cover 74 distinct passing cases; the existing Linux-only killed-owner case remains for CI. Targeted types, type-aware lint, docs, formatting and P2 review pass. Integrates with prerequisite #175295, which owns refusal propagation; no duplicate broker or worker changes.
Capture shared promotion admission as well as initial native admission, preserving logical borrowers only for known, uncommitted refusals. Protocol faults, unknown outcomes and cleanup failures retain their terminal handling.

The new retained-borrower regression failed before this correction and passes with it. Also seed transcript data in the reclamation concurrency fixture: #175091 intentionally avoids reclamation workers for eventless deletes. Keep all original assertions and deadlines.

Rebased focused proof covers 75 cases including both hourly 39013936147 reds; all 8 final error-path cases pass. Targeted types, lint, format, docs and independent P2 review pass.
Return no pending native open from the timer-only generation stub, matching
the required contract introduced by #175307. The production factory already
supplies this method; wrappers retain the real generation. Keep every idle
expiry, reborrow, creation, alias, cleanup and restart assertion unchanged.

Before: four idle lifecycle cases fail with getPendingNativeOpen missing,
and the state-logging test graph reports TS2345.
After: all eight openclaw-agent-execution test files pass (91 tests, one
existing Linux-only skip; 125.20 seconds including worker preparation).
State-logging test types, targeted lint, formatting and P2 review pass.
@clawsweeper clawsweeper Bot removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
Main b499c60 moved existing-file opening off caller admission. Observe
the real physical open so the refusal fixture still starts concurrent
survivor reads, and remove its obsolete caller callback. Keep all refusal,
liveness, exact-result and cleanup assertions. Clarify the shared native
opening wording after integrating the peer cancellation fix.

The requested ten-file proof passed 99 cases and exposed this stale trigger.
The corrected close-wedge file passes all 7 cases (17.37 seconds), bringing
combined coverage to 100 distinct passes and one existing Linux-only skip.
Gateway reclamation is 2/2; reply admission, state-logging types, targeted
lint and formatting pass. No CI reruns.

Independent P2 review is scoped-clean for the rebased candidate and this fixture follow-up.
@steipete
steipete force-pushed the fix/agent-preparation-live-callers branch from ec2e277 to 6ab6bb0 Compare October 17, 2026 09:22
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto current main and resolved the shared-opening conflicts at 6ab6bb0. The PR body records the preserved authority and cancellation checks, 100 passing focused cases with one existing platform skip, targeted checks, and clean P2 reviews.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@steipete
steipete merged commit 03e18cf into main Oct 17, 2026
131 of 135 checks passed
@steipete
steipete deleted the fix/agent-preparation-live-callers branch October 17, 2026 09:50
steipete added a commit that referenced this pull request Oct 17, 2026
#175461)

Fix forward from #175307. The native admission helper recognized a committed
registration notice, but its outer callback still checked the retired caller.
Refusing that bookkeeping notice left an opened worker without its installed
identity and replaced the expected lifecycle refusal with unknown settlement.

End authorization for this already-observed COMMIT at the outer callback.
Receipt observation still validates and records the exact registration owner;
subsequent validation, preparation and command admission keep live authority.
Generic failed-report retirement and first-use creation checks are unchanged.

Also align the queued-collector fixture with #174111's documented contract:
uncaptured lifecycle events publish current updated facts. Select create or
updated session publications while retaining every payload, runtime, Stop and
authority assertion. A forced initial capture miss reproduced the exact hourly
failure with a correctly published Collector B row, and passes after this fix.

Current main with #175307 reverted passed both full files (48 tests). Restoring
it reproduced both cold-registration failures. The repair passes 148 tests
across the execution, restart, reclamation, reply and collector files; one
existing Linux-only killed-owner test remains skipped on macOS. Targeted state
and Gateway test type graphs, type-aware lint, formatting and P0-P2 review pass.
No timeouts, retries, schemas or permission contracts changed.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…e preparation (openclaw#175307)

* fix(state): retain caller authority during shared database preparation

Require one current follower for shared integrity/schema effects. Settle request-owned native opening before a healthy successor reuses or replaces the generation; keep the full shared preparation joinable.

Both hourly 39010956087 regressions came from openclaw#175008. Preserve the existing reclamation assertions while checking the missing index before incidental worker termination. Initial native admission and first-use creation retain original caller authority.

Focused six-file proof plus final three-case integration cover 74 distinct passing cases; the existing Linux-only killed-owner case remains for CI. Targeted types, type-aware lint, docs, formatting and P2 review pass. Integrates with prerequisite openclaw#175295, which owns refusal propagation; no duplicate broker or worker changes.

* fix(state): preserve borrowers after known promotion refusals

Capture shared promotion admission as well as initial native admission, preserving logical borrowers only for known, uncommitted refusals. Protocol faults, unknown outcomes and cleanup failures retain their terminal handling.

The new retained-borrower regression failed before this correction and passes with it. Also seed transcript data in the reclamation concurrency fixture: openclaw#175091 intentionally avoids reclamation workers for eventless deletes. Keep all original assertions and deadlines.

Rebased focused proof covers 75 cases including both hourly 39013936147 reds; all 8 final error-path cases pass. Targeted types, lint, format, docs and independent P2 review pass.

* test(state): complete idle generation fixture contract

Return no pending native open from the timer-only generation stub, matching
the required contract introduced by openclaw#175307. The production factory already
supplies this method; wrappers retain the real generation. Keep every idle
expiry, reborrow, creation, alias, cleanup and restart assertion unchanged.

Before: four idle lifecycle cases fail with getPendingNativeOpen missing,
and the state-logging test graph reports TS2345.
After: all eight openclaw-agent-execution test files pass (91 tests, one
existing Linux-only skip; 125.20 seconds including worker preparation).
State-logging test types, targeted lint, formatting and P2 review pass.

* test(state): follow physical admission in refusal fixture

Main 0f21575 moved existing-file opening off caller admission. Observe
the real physical open so the refusal fixture still starts concurrent
survivor reads, and remove its obsolete caller callback. Keep all refusal,
liveness, exact-result and cleanup assertions. Clarify the shared native
opening wording after integrating the peer cancellation fix.

The requested ten-file proof passed 99 cases and exposed this stale trigger.
The corrected close-wedge file passes all 7 cases (17.37 seconds), bringing
combined coverage to 100 distinct passes and one existing Linux-only skip.
Gateway reclamation is 2/2; reply admission, state-logging types, targeted
lint and formatting pass. No CI reruns.

Independent P2 review is scoped-clean for the rebased candidate and this fixture follow-up.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
openclaw#175461)

Fix forward from openclaw#175307. The native admission helper recognized a committed
registration notice, but its outer callback still checked the retired caller.
Refusing that bookkeeping notice left an opened worker without its installed
identity and replaced the expected lifecycle refusal with unknown settlement.

End authorization for this already-observed COMMIT at the outer callback.
Receipt observation still validates and records the exact registration owner;
subsequent validation, preparation and command admission keep live authority.
Generic failed-report retirement and first-use creation checks are unchanged.

Also align the queued-collector fixture with openclaw#174111's documented contract:
uncaptured lifecycle events publish current updated facts. Select create or
updated session publications while retaining every payload, runtime, Stop and
authority assertion. A forced initial capture miss reproduced the exact hourly
failure with a correctly published Collector B row, and passes after this fix.

Current main with openclaw#175307 reverted passed both full files (48 tests). Restoring
it reproduced both cold-registration failures. The repair passes 148 tests
across the execution, restart, reclamation, reply and collector files; one
existing Linux-only killed-owner test remains skipped on macOS. Targeted state
and Gateway test type graphs, type-aware lint, formatting and P0-P2 review pass.
No timeouts, retries, schemas or permission contracts changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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