Skip to content

refactor(sessions): bind incognito actors for production acquisition (P7h1, inactive) - #165525

Merged
steipete merged 5 commits into
mainfrom
dbasync/incogp7h
Oct 5, 2026
Merged

steipete merged 5 commits into
mainfrom
dbasync/incogp7h

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The final incognito worker activation needs one actor binding shared by SessionManager and Codex. Separate binding scopes can lose the captured owner between acquisition, later manager calls, history reads, and cleanup. Synchronous SDK persistence must reject actor access before SQLite, detached-view mutation, or tool-result hooks.

Why This Change Was Made

Introduce one captured actor binding and retain it on SessionManager. Validate the physical namespace before yielding, retain accepted work through settlement, and refuse synchronous persistence before side effects, including a later retarget to durable storage. Codex captures the awaited reader through its existing SDK subpath and retains the actor through scan, consumption, validation, and cleanup. Extract the pure transcript-context reader factory to preserve the lazy import boundary.

Move actor grant validation into the admission module. Reuse the pending-history settlement owner already extracted on main by 17e945fb8220. The session-facts owner retains authority, FIFO, revision, and publication decisions; its implementation is now 667 physical lines, below the 700-line guard.

Preserve registered error identity across ephemeral worker failures even without a durable state context. The regression strengthens an existing real actor read to assert SessionCanonicalKeyMigrationRequiredError, using the same worker invocation and fixture. With the old transport it fails because only the error name/message survive.

User Impact

P7h1 remains inactive. T1: 883 → 883. Production acquisition stays host-owned. Native routes remain; activation must install the binding together with the remaining adapters. No schema, persistent cache, worker service, retention, durability, permissions, expiry, configuration, update behavior, or new OPENCLAW_* names.

Public creation, generic entry patches, and framed entry receipts are deferred to P7h2. This PR contains only their shared prerequisite and does not claim the final actor-bound Gateway creation flow.

Production delta against integrated main: +352 / −183 / net +169, across 25 implementation/test/doc/inventory files. Main is integrated by merge commit 0b330965bf6d27f2c59fbe5ecbd9445ff3a48ea6 with parent e8915f68f3cb87cffb90fc7e7799a2d70edeb45e; the original branch ancestry is preserved for the stacked P7h2 child. The sole conflict was the duplicate pending-history helper extraction; main’s existing owner is retained. The two former baseline corrections are now already on main. Related prerequisites: #164869, #164883, #164819, #165134. Parallel overlap remains P7i/P7j and the non-active umbrella draft #162433.

Evidence

Historical pre-integration runtime, build, and SDK evidence below is bound to 200160789425; the baseline-only follow-up bd77e156ebc1 changed no production or test code. Current integration evidence follows separately.

  • Old-transport control: the new canonical-error identity assertion fails through the real ephemeral worker (117.80s command wall time).
  • Gateway setup/rebuild passed (229.38s); core typecheck passed (52.79s); focused type-aware lint passed (22.17s); madge reports zero cycles (89.78s).
  • Focused runtime/SDK/close/importer proof: 216 tests in 20 files passed with pnpm test ... --maxWorkers=1 (1,844.83s command wall time). This includes zero caller-thread SQL assertions, real server close order, the canonical worker-error regression, and the required shared-registry/import-closure suites. CI seconds are not yet measured; the error assertion reuses the existing read and fixture.
  • P2 Codex autoreview is scoped-clean against the pinned integration base, with high reasoning and --codex-speed ultrafast. The worker ratchet passed against the pinned integration base (29.67s).
  • SDK comparison: no entrypoints added/removed; 128 affected exports are classified reachable, spanning two changed declaration modules. The 128 exports listed by that report retain their direct declarations and kinds; separately, the existing codex-session-transcript-runtime subpath adds the exported captureCodexSessionContextReader acquisition helper. The command passed in 1,626.85s. Digest: da155ccb348d9b79ee257fa07fe81383aa9cba07f64c7b8c8cdedea02ae3b7d5.
  • Full Linux pnpm build passed in 589.09s on Blacksmith Testbox tbx_01m45f70asnc79x3hzawya4q7b, with all 25 changed-file hashes verified before execution. Remote run. The initial changed-file check stopped on inherited stale baselines: the removed Telegram fetch max-lines entry and environment-name budget 469 versus the verified count 464. Both exact shrink-only fixes from 1ae6fa18f759 are included and have a separate clean P2 review. The corrected local check passed every preceding guard and typecheck, plus core lint, then its extension-lint prerequisite hit a 300-second SDK declaration-build tooling timeout. The complete node scripts/check-changed.mjs --base d7f9ebd8de66effa1fd71d4b0556497f03909b4f --timed then passed at final head bd77e156ebc1 on an isolated Hetzner Crabbox in 3,118.83s. The runner fetched and verified the exact pushed commit before/after execution and used the repository CI toolchain/containment helpers. This includes extension lint and the final database/import/security-boundary guards. No production or test source changed between that runtime/build/SDK proof and bd77e156ebc1.
  • Worker test routing: the new SDK actor suite is explicitly registered in test/vitest/vitest.database-worker-core-paths.mjs; SessionManager, Gateway, and the Codex extension tests already use their host-owned fork projects. The transport regression stays in the existing routed incognito session suite.

Integration validation

At 0b330965bf6d27f2c59fbe5ecbd9445ff3a48ea6:

  • Fresh P2 Codex autoreview: scoped-clean, no actionable findings. Formatting and git diff --check passed.
  • Focused proof through the repository test wrapper with --maxWorkers=1: 112 tests in 12 files passed. The first run covered actor sessions, SessionManager, SDK refusal, Codex history, real Gateway close order, wrapper inventory, runtime build graph, and import closure (68 tests, 757.30s wrapper wall time). The supplemental run covered pending-history settlement, actor history, SDK metadata admission, and the P7f1 snapshot races (44 tests, 448.90s command wall time; 447.83s wrapper time). The exact-head CI workflow passed 60 jobs and skipped 23; successful jobs consumed 10,774 aggregate job-seconds (whole selected workflow, not the marginal cost of these tests).
  • P7f1 recheck: delayed validation holds the actor FIFO through native settlement; subsequent writes require fresh host grants. The memory database has no independent synchronous host writer. Retained lifetime and post-await authority checks prevent disclosure after release or close. Both existing durable snapshot regressions pass.
  • Worker routing audit: the new SDK suite is registered in the database-worker project; affected SessionManager, Gateway, and Codex suites already run in their host-owned fork projects. No missing route found.
  • Current SDK comparison (e8915f68f3cb → 0b330965bf6d): zero entrypoints added/removed, 128 reachable changes, and zero direct declaration/kind changes among those reported exports. This does not mean zero additive SDK exports: captureCodexSessionContextReader is newly exported on the existing subpath. Report digest: 929303a592dfeedb89874463fdbac9fe9b32bceb28cc85113b749e187e05a4d3.
  • Released SDK check against v2026.9.8: existing context read and validation signatures remain synchronous and source-compatible; the captured reader is additive. Existing deprecation records remain applicable. No new OPENCLAW_* name is introduced.
  • The transport change only preserves registered error identity for ephemeral actors; it changes no schema or stored format. No data migration or published-driver update cell is required for this inactive prerequisite.

The previous context/evidence check failed because the body used Problem instead of the template’s What Problem This Solves heading. This body corrects that metadata defect without changing source; the replacement context/evidence run passed. The exact-head CI workflow also passed its aggregate check.

Wire inactive creation, entry patches, SessionManager and Codex reads through one captured actor binding. Preserve transaction predicates, current authority, native commit receipts, publication ordering and accepted settlement. Keep production routing host-owned and T1 unchanged at 887.
Apply the exact shrink-only baseline corrections from 1ae6fa1. No production or test code changes.
@clawsweeper

clawsweeper Bot commented Oct 5, 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 scripts Repository scripts agents Agent runtime and tooling extensions: codex size: L labels Oct 5, 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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 5, 2026, 7:10 AM ET / 11:10 UTC (Revision 2).

ClawSweeper review

What this changes

The PR shares a captured incognito worker binding between session management and Codex history, rejects synchronous actor access before side effects, and preserves registered worker error identities.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful prerequisite absent from current main. The integration resolves the previous conflict blocker, and no introduced correctness or security defect was found.

Priority: P2
Reviewed head: 0b330965bf6d27f2c59fbe5ecbd9445ff3a48ea6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused ownership preparation with meaningful worker-boundary evidence and no actionable code finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Recorded production-worker runs exercise ephemeral error transport, retained SessionManager operations, SDK context reads, and real close ordering, including a failing old-transport control followed by preserved canonical error identity. The integration adopts the existing settlement owner; no stored-data model changes require migration proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded production-worker runs exercise ephemeral error transport, retained SessionManager operations, SDK context reads, and real close ordering, including a failing old-transport control followed by preserved canonical error identity. The integration adopts the existing settlement owner; no stored-data model changes require migration proof.
Evidence reviewed 10 items Pinned introduction and original parentage: Reviewed the explicit e8915f6..0b33096 introduced delta. Raw commit records confirm the original head’s parents are the previously reviewed head followed by the integrated main revision. The supplied stale test merge was not used to claim removal of current-main behavior.
Conflict resolution preserves the existing settlement owner: The current actor imports createIncognitoPendingInputHistorySettlement from the existing pending-input contract, whose implementation matches the pinned base. The prior-head actor blob was unavailable locally; GitHub’s blob API supplied its complete contents, confirming the former duplicate-helper import. The maintainer’s integration comment agrees with this source inspection.
Production acquisition remains inactive: The shared actor installation entrypoint has only test callers. Bundled Codex captures the reader synchronously, while absence of a binding retains the existing host route. Current main still uses the separate SessionManager actor scope and lacks the new SDK capture helper.
Findings None None.
Security None None.

How this fits together

OpenClaw’s session subsystem stores conversation history and supplies context to agents and bundled plugins. This inactive preparation lets session managers and Codex history readers retain the same ephemeral database owner across asynchronous work.

flowchart TD
  A[Session target] --> B[Captured actor binding]
  B --> C[Session manager]
  B --> D[Codex history reader]
  C --> E[Worker admission and FIFO]
  D --> E
  E --> F[Ephemeral SQLite]
  F --> G[Validated context and commit facts]
Loading

Before merge

  • Complete next step (P2) - Use the required PR-template headings and correct the SDK evidence to acknowledge captureCodexSessionContextReader as an added export.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +169, Tests +149, Docs +36, Other +1. Total +355 across 25 files.

View PR surface stats
Area Files Added Removed Net
Source 16 352 183 +169
Tests 6 184 35 +149
Docs 2 36 0 +36
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 25 573 218 +355

Review metrics

Metric Value Why it matters
SDK acquisition surface 1 added exported reader-capture function The existing SDK subpath gains an additive helper, so the API evidence should explicitly acknowledge it.

Stored data model

Persistent data-model change detected: database schema: src/infra/sqlite-store.worker.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep one captured actor owner across acquisition and settlement, preserve released host behavior, and activate production routing only with the complete adapter cutover.

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

Not applicable to the inactive refactor as a whole; the error-identity subfix has a recorded real-worker failing control and after-fix assertion.

Is this the best way to solve the issue?

Yes: sharing the existing actor lifetime and extracting unchanged admission logic avoids competing ownership while preserving the host route.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Recorded production-worker runs exercise ephemeral error transport, retained SessionManager operations, SDK context reads, and real close ordering, including a failing old-transport control followed by preserved canonical error identity. The integration adopts the existing settlement owner; no stored-data model changes require migration proof.

Label justifications:

  • P2: This is bounded internal session-worker preparation with production activation deliberately deferred.
  • merge-risk: 🚨 compatibility: The SDK gains an additive acquisition helper and actor-bound synchronous refusals; inspected released signatures and inactive production routing preserve existing compatibility.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded production-worker runs exercise ephemeral error transport, retained SessionManager operations, SDK context reads, and real close ordering, including a failing old-transport control followed by preserved canonical error identity. The integration adopts the existing settlement owner; no stored-data model changes require migration proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded production-worker runs exercise ephemeral error transport, retained SessionManager operations, SDK context reads, and real close ordering, including a failing old-transport control followed by preserved canonical error identity. The integration adopts the existing settlement owner; no stored-data model changes require migration proof.

Evidence

What I checked:

  • Pinned introduction and original parentage: Reviewed the explicit e8915f6..0b33096 introduced delta. Raw commit records confirm the original head’s parents are the previously reviewed head followed by the integrated main revision. The supplied stale test merge was not used to claim removal of current-main behavior. (0b330965bf6d)
  • Conflict resolution preserves the existing settlement owner: The current actor imports createIncognitoPendingInputHistorySettlement from the existing pending-input contract, whose implementation matches the pinned base. The prior-head actor blob was unavailable locally; GitHub’s blob API supplied its complete contents, confirming the former duplicate-helper import. The maintainer’s integration comment agrees with this source inspection. (src/config/sessions/session-incognito-actor.ts:39, 0b330965bf6d)
  • Production acquisition remains inactive: The shared actor installation entrypoint has only test callers. Bundled Codex captures the reader synchronously, while absence of a binding retains the existing host route. Current main still uses the separate SessionManager actor scope and lacks the new SDK capture helper. (src/config/sessions/session-incognito-binding.ts:81, 0b330965bf6d)
  • Current-main necessity: Current main’s SDK reader factory and synchronous validators do not contain the added captured-reader acquisition path. The merged related prerequisites therefore do not supersede this distinct binding work. (src/plugin-sdk/codex-session-transcript-runtime.ts, 2795ad9d0e03)
  • Released SDK compatibility: Inspected the v2026.9.8 SDK source through GitHub because the release object was unavailable locally. Existing synchronous reader and validator signatures remain intact; actor-bound refusal is gated by the inactive binding. captureCodexSessionContextReader is nevertheless an added exported function, which the PR’s claim of unchanged direct exported declarations should acknowledge. (src/plugin-sdk/codex-session-transcript-runtime.ts:49, fc23bc864e45)
  • Authority and lifetime safeguards: The captured reader checks cancellation, retained admission, write ownership, actor lifetime, and session generation before and after its lazy import. Its existing compute owner verifies the requested target before reading and revalidates after consumption. Manager regressions exercise released borrows, closed admission, rejected writes, acknowledged settlement, and synchronous refusal before SQL or hooks. (src/plugin-sdk/codex-session-transcript-runtime.ts:61, 0b330965bf6d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • be-student: 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.

  • Align the PR description with the required template headings and acknowledge the added SDK capture export.

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 (1 earlier review cycle)
  • reviewed 2026-10-05T10:44:24.650Z sha bd77e15 :: blocked before merge. :: none

Integrate main e8915f6 without rewriting the stacked branch history. Reuse the pending-history settlement owner already extracted by 17e945f and remove the duplicate helper from this prerequisite. Preserve inactive production routing and the existing SDK signatures.
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Integrated main in merge commit 0b33096. The sole conflict reused main's pending-history settlement helper from 17e945f and removed this branch's duplicate. Production routing remains inactive. The worker transport change preserves registered error identity; it changes no database schema or stored format, so no data migration is required.

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Oct 5, 2026
@steipete
steipete merged commit b0d6eea into main Oct 5, 2026
167 of 168 checks passed
@steipete
steipete deleted the dbasync/incogp7h branch October 5, 2026 12:02
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…(P7h1, inactive) (openclaw#165525)

* refactor(sessions): prepare shared incognito actor binding

Wire inactive creation, entry patches, SessionManager and Codex reads through one captured actor binding. Preserve transaction predicates, current authority, native commit receipts, publication ordering and accepted settlement. Keep production routing host-owned and T1 unchanged at 887.

* fix(sessions): frame incognito entry commit receipts

* fix(ci): sync inherited source ratchet baselines

Apply the exact shrink-only baseline corrections from d25126d. No production or test code changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L 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