Skip to content

fix(state): join retained creators during agent preparation - #201272

Merged
vincentkoc merged 6 commits into
mainfrom
fix/agent-preparation-creation-admission-20261118
Nov 18, 2026
Merged

vincentkoc merged 6 commits into
mainfrom
fix/agent-preparation-creation-admission-20261118

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

What this fixes

Standalone agent database preparation could fail with Originally observed agent target requires its captured creating reference when another first-open caller retained the creation witness. The helper captured an ordinary borrower before acquiring writer admission.

Preparation now follows the existing worker-store owner: acquire writer admission, capture the inherited creation identity inside that admitted operation, recheck caller authority, initialize the store, and release the captured execution after settlement. Ordinary-borrower and physical-identity guards remain intact.

Validation

  • Baseline red reproduction: the new retained-creator case failed at the expected guard while all 31 existing cases passed. Red run.
  • Final head 2f0ac519ecfe89d507b34ae7633f2f5d9624e369: CI passed, with all 70 jobs successful or intentionally skipped. A single failed-jobs retry cleared seven Git package mirror HTTP 503 setup failures; passed jobs were retained.
  • The final run covers all four PostgreSQL 17 shards, PostgreSQL 16 smoke, real SQLite/PostgreSQL interactive setup and Gateway startup, corrected profile-authority assertions, lint, type checks, and baseline ratchets. The creation-witness shard passes retained-creator preparation, queued cancellation, queued revocation, and the existing sibling cases.
  • Windows validation passed in the earlier manual run against identical production and test blobs.
  • Independent owner, test, and final-delta reviews passed. The final-head ClawSweeper review reports no actionable findings or remaining rank-up moves.

Scope and compatibility

Production: +11/-5 lines. Tests: +94/-1 lines. Only the preparation owner and its regression suite change; capture moves into the canonical writer flow without another abstraction or fallback.

No SQLite schema/version, DDL, migration, persisted-format, retention, durability, config, or public API changes. Release-note context stays here because changelog entries are release-owned.

The native-owner regression establishes the retained-creator failure and subsequent successful read. The CLI/Gateway tests qualify the production entry points, but the exact competing creator in the earlier onboarding incident remains unestablished; this is not a traced end-to-end reproduction of that race.

@clawsweeper

clawsweeper Bot commented Nov 18, 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 Nov 18, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 18, 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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR acquires writer admission before borrowing a retained creation witness for standalone agent database preparation.

Example: Agent main is prepared while another caller retains its original missing-database witness.

  • Before: Preparation fails with “Originally observed agent target requires its captured creating reference”.
  • After: Preparation initializes the shared database, and reading agent:main:missing returns an empty entries list.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The repair is focused and source-correct with meaningful native-owner coverage, but the required shipped-flow proof remains absent and exact-head runtime qualification is incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Cold agent preparation can fail when another first-open caller retains creation ownership.
Reason: The maintainer-authored change restores an established creation contract without adding configuration, public API, storage format, or another owner.

Merge readiness

✅ Ready for maintainer review

Keep this focused, maintainer-authored repair open: current main retains the failing capture order, and source review found no actionable patch defect.

Priority: P2
Reviewed head: 2f0ac519ecfe89d507b34ae7633f2f5d9624e369

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted CLI or Gateway output showing preparation succeeds while the retained-creator condition is present, followed by a successful session operation.
Agent review details

How this fits together

Gateway startup and session-store preparation call the standalone helper, which acquires database writer admission and asks the existing execution owner to initialize the native store.

flowchart TD
  A[Gateway or session preparation] --> B[Database writer admission]
  B --> C[Existing execution owner]
  C --> D[Retained creation witness]
  C --> E[Native database worker]
  E --> F[Initialized agent database]
Loading

Technical review

Best possible solution:

Keep the existing creation guard and reuse inherited creation identity only within the standalone helper's admitted writer turn.

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

The retained-creator input reaches the existing guard deterministically in source, and the PR supplies a red regression revision; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is the smallest complete repair using existing owners: capture with inherited creation identity after writer admission, preserve authority checks, and release after settlement.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Standalone database preparation keeps the original intent (b1cadee: Prepare agent runtime databases before publishing roster entries while preserving unaffected agents and accepted work.)
  • Asynchronous execution capture keeps the original intent (2c4413a: Move necessary filesystem observation off the Gateway main thread while retaining physical custody, FIFO ordering, and settlement.)
  • Creation-witness test suite keeps the original intent (9222917: Consolidate repeated test setup while preserving distinct contracts; the added cases cover distinct standalone preparation boundaries.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Introduced fix: The pinned introduced diff moves capture inside writer admission, selects the existing inherit mode, preserves caller checks, and releases the captured execution after settlement. (src/state/openclaw-agent-execution.ts:100, 2f0ac519ecfe)
  • Current-main failure remains: Fetched main still captures an ordinary borrower before writer admission; the execution owner's creation-reference guard rejects that borrower while a creator is retained. (src/state/openclaw-agent-execution.ts:98, 0aafe6691b81)
  • Existing owner pattern: The worker-store owner already captures with inherited creation identity inside its admitted writer callback, supporting the same placement here without another owner or fallback. (src/state/openclaw-agent-worker-store.ts:467, 2f0ac519ecfe)
  • Distinct regression coverage: The added cases exercise retained-creator preparation followed by a native session read, cancellation before queued work starts, and caller revocation before queued work starts. (src/state/openclaw-agent-execution.creation-witness.test.ts:51, 2f0ac519ecfe)
  • Historical creation contract: fix(memory): restore indexing during fresh agent startup #170220 previously repaired the same guard failure in memory worker preparation by inheriting the canonical owner's creation reference; this PR applies that contract to a different preparation caller. (src/state/openclaw-agent-execution.ts:128, 647ef8843a2b)
  • Proof scope and inspection limit: The body supplies red/green native-owner regression evidence and CLI/Gateway test results, while explicitly disclaiming a traced end-to-end reproduction of the competing creator. GitHub job metadata confirms the native regression shard passed at the production-identical prior head. Downloading job logs was blocked by the proxy's Azure storage allowlist; that inspection limit is not a contributor defect. (46730a7fd575)

Likely related people:

  • Peter Steinberger: Raw commit b1cadee adds src/state/openclaw-agent-execution.ts:43 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b1cadeefe0b6; files: src/state/openclaw-agent-execution.ts)
  • Vincent Koc: Raw commit 827a749 adds src/state/openclaw-agent-execution.creation-witness.test.ts:570 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 827a749e2c66; files: src/state/openclaw-agent-execution.creation-witness.test.ts)

PR surface

Source +6, Tests +93. Total +99 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 11 5 +6
Tests 1 94 1 +93
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 105 6 +99

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A concrete cold database preparation failure remains on main, with a narrow repair and limited demonstrated blast radius.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 (1 earlier review cycle)
  • reviewed 2026-11-18T15:23:41.993Z sha 46730a7 :: needs maintainer review before merge. :: none

Reviewed November 18, 2026, 10:47 AM ET / 15:47 UTC (Revision 2).

@vincentkoc
vincentkoc marked this pull request as ready for review November 18, 2026 15:37
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc
vincentkoc enabled auto-merge (squash) November 18, 2026 16:10
@vincentkoc
vincentkoc merged commit 24c2e74 into main Nov 18, 2026
198 of 206 checks passed
@vincentkoc
vincentkoc deleted the fix/agent-preparation-creation-admission-20261118 branch November 18, 2026 16:19
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…#201272)

* test(state): reproduce preparation with a retained creation witness

* test(state): bound creation witness regression to native read

* fix(state): join retained creators during agent preparation

* test(state): observe native preparation admission

* test(state): pass cancellation test context with for

* chore: keep preparation release notes in PR body
RomneyDa added a commit that referenced this pull request Nov 19, 2026
Retire completed absent native reads without dropping retained logical borrowers or pending-opener protection.

Companion audit: #201272 is selected next; no other later same-path or PR-reference fix exists in the pinned scan. Existing callers and fixture contracts remain unchanged.

Release adaptation: none in the reviewed patch. Parent regression reproduces the retained-reader failure; the complete two-fix cohort passes 69 tests across creation and writer admission. Broader release qualification remains pending.

(cherry picked from commit e25ad96)

Co-authored-by: VACInc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 19, 2026
Capture the inherited creation witness inside the admitted writer turn, check caller authority before and after capture, and release only the captured reference. Preserve queued cancellation and next-creator behavior.

Companion audit: follows #201103; no later same-path or PR-reference fix exists in the pinned scan. Existing startup and session-writer callers retain their current interfaces.

Release adaptation: none in the reviewed patch. Parent regression reproduces the retained-witness failure; both fixes pass 69 tests across creation and writer admission, with touched production and test type-aware lint and formatting green. Broader release qualification remains pending.

(cherry picked from commit 24c2e74)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…#201272)

* test(state): reproduce preparation with a retained creation witness

* test(state): bound creation witness regression to native read

* fix(state): join retained creators during agent preparation

* test(state): observe native preparation admission

* test(state): pass cancellation test context with for

* chore: keep preparation release notes in PR body

(cherry picked from commit 24c2e74)

Release adaptation: Use stable boolean creation inheritance through async capture inside admitted writer; preserve default capture constraints and caller cancellation/revocation checks. Native proof blocked by existing shared setup.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
Baseline adaptation: Borrow the retained creator only inside the shipped writer-admission turn, using its synchronous execution capture and existing native admission guard.

(cherry picked from commit 24c2e74)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant