Skip to content

feat(state): worker-owned incognito session actor (P1, inactive) - #163145

Merged
steipete merged 5 commits into
mainfrom
dbasync/incognito-p1
Oct 2, 2026
Merged

steipete merged 5 commits into
mainfrom
dbasync/incognito-p1

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Provides the ownership and lifetime foundation needed to move incognito session SQLite into workers without splitting a live store between the Gateway and a worker.

User Impact

No production behavior change. Production incognito remains host-owned until P7. This is an inactive, isolated-test-backed foundation; it introduces no configuration flag, schema change, migration, retention change, or content quota.

Why This Change Was Made

Design link summary

The accepted design and decisions extend the existing agent execution owner, SQLite broker, writer queue, and resource lifecycle. Explicit ephemeral targets use the existing capture API. Ordinary file captures remain synchronous and retain their existing implementation.

One agent/state-root namespace gets one pinned actor on a dedicated worker within the broker's existing capacity. Opaque handles and incarnations bind work to that actor. Concurrent creators converge; existing-only lookup never creates a store and cannot observe an unpublished actor. Close joins accepted work and native cleanup. Cancelled publication retires an unclaimed actor while preserving a valid concurrent creator.

Decisions

  • Use :memory: and set and verify temp_store=MEMORY before schema work. No durable registration, lease, backing file, WAL, archive, or recovery snapshot is created. OS swap and crash dumps remain outside the application guarantee.
  • Worker loss ends that agent's incognito sessions with INCOGNITO_SESSION_ENDED. Old handles never adopt a replacement.
  • Keep no-idle-eviction and existing session retention. Capacity exhaustion refuses creation visibly; the per-agent gauge reports page_count * page_size, without claiming to measure total process memory.
  • Preserve existing shared ACP metadata persistence and retention.
  • The separate SDK migration adds awaited *Async twins for every SessionManager persistence method, returning committed results, and migrates all bundled/internal callers. Synchronous methods receive @deprecated JSDoc naming the async twin, an SDK compatibility record with removal at the next Plugin SDK major, a docs migration note, and a once-per-method runtime warning. After P7 activation, synchronous persistence targeting an incognito session throws an actionable error naming the async replacement; durable targets keep working until the removal major.

What is inactive

No production caller requests the ephemeral capture target. Only lifecycle operations and the memory gauge are admitted in P1. Session facts, session mutations, domain adapters, and activation remain later stages. The SDK persistence migration proceeds separately. The durable session-entry patch path is unchanged. P1 removes zero production T1 sites.

Update behavior

None: inactive. Existing installed updaters, stored databases, and Gateway restart behavior are unchanged; no operator action is required.

Evidence

Current main integration and cancellation repair

Current head: 57510ef6ddf909665a47c2344f6f13601b787960. Exact-head CI run 36960488298 passed; the watcher reported green with no pending checks. ClawSweeper completed review of this head at 2026-10-02 03:36 UTC with no actionable finding, including its review of the cancellation repair. Its generated table-warning banner remains unsupported by the code and is explicitly dismissed in its own detailed assessment. No CI rerun or admin exception was used.

Merged main at 7fc0cfb379f4ba6f3eefd75a1e342f56dc859415 with a merge commit. The single conflict was in the execution closer: main's joined WAL retirement remains intact, with P1's AgentDatabaseFileExecutionIdentity type used in its captured state.

Fresh review found that cancelling the initiating worker open could also reject independent valid creators waiting on it. A real-worker regression with two valid followers failed before the repair. The existing owner now settles failed opening and native cleanup before a waiting creator can retry, and requires the initiating source to be refused plus the caller, agent, and state-root facts to remain current. Existing-only lookups, published handles, worker-loss behavior, and domain commands are not replayed. P1 remains inactive.

Validation after integration: the affected state/logging type configuration passed; 53 tests across incognito and three close-lifecycle suites passed in 138.97s command wall. After the cancellation repair, all 7 incognito tests passed (66.58s wrapper wall, including 43.19s compiler preparation); the new regression itself took 0.901s. Typechecking, scoped type-aware lint, formatting, and whitespace checks passed. Full-candidate Codex autoreview against the pinned main is clean through P2. Unchanged durable close proof is reused.

Original runtime implementation reviewed and tested at: d00e504d7d3085e51a23fc1d61d260040abc7a6d. Codex branch autoreview is clean through P2 severity; no accepted/actionable P0–P2 findings remain.

Documentation-only SDK decision correction at f5545dec0ebc8879c02029f15f1e5f73c4a42ef4: git diff --check and full pnpm check:docs passed; focused Codex autoreview is clean through P2 severity. Runtime code is unchanged.

All 67 focused tests passed on Blacksmith Testbox with Node 24.19.0. Commands used the repository test wrapper with --maxWorkers=1; wall times include wrapper preparation:

Selection Tests Command wall
src/state/openclaw-agent-execution-incognito.test.ts 6 22.82s
src/infra/sqlite-worker-broker.test.ts 13 29.07s
src/auto-reply/reply/reply-turn-admission.worker.test.ts 5 31.19s
src/config/sessions/session-accessor.sqlite-page-reclamation.binding.test.ts 7 27.69s
Broker lifecycle/native-stop and execution creation-witness/close-wedge/cleanup siblings 36 34.69s

Provider: blacksmith-testbox, lease tbx_01m3x134v0kw06gbvmjvtdkyq9, Testbox run. The focused command results above are the proof; the lease workflow's conclusion is not a claim that the full changed-check command passed.

  • pnpm check:madge-import-cycles: 0 cycles, 157.81s wall.
  • pnpm check:database-worker-ratchet --base e25e244b68e9b9ae03aef7bb406c2b45a2e9db47: no T1 call-count growth, 33.54s wall.
  • git diff --check: passed.
  • Local node scripts/check-changed.mjs passed core types, all 27 core test-type groups, core/scripts lint, three Knip scans (zero entries), runtime cycle checks, and preceding structural/storage/auth guards. The wrapper terminated abnormally at the final pairing-account guard after 3914.40s; that exact guard passed when replayed directly. The interrupted wrapper is not reported as green.
  • Testbox node scripts/check-changed.mjs stopped after 45.15s at the inherited date-triggered plugin-boundary failure: 11 compatibility records are due for removal. The reporter, complete compatibility registry, and SDK-entry inputs are byte-identical to the pinned base. Running that base's reporter and records reproduced exit 1 and the same count in 20.56s. Reference scans used candidate source; the failing eligibility count depends only on unchanged records and the UTC date. No compatibility record or guard was altered or suppressed. A later remote continuation did not execute because its lease expired during local source staging; completed proof was reused.

Scope: 949 changed production lines (861 additions, 88 deletions), across 17 production files; 24 files total including documentation and tests.

The publication regression failed on the pre-fix candidate because an existing-only lookup returned the cancelled creator's actor. Its concurrent valid-creator control passed. Both cases pass after the owner-level repair. Tests inspect isolated state and temp directories while actors are live and after close.

Landing validation

CI at f5545dec0ebc8879c02029f15f1e5f73c4a42ef4 exposed a test-only tuple inference error under noUncheckedIndexedAccess. Correction 40e37e93a3957 retains the concurrent captures’ two-element tuple type; runtime behavior and concurrency are unchanged. The affected state/logging test type configuration passes, all 6 incognito tests pass (125.19s command wall, including 63.12s compiler preparation), formatting and git diff --check pass, and focused Codex autoreview is clean through P2.

The earlier head 40e37e93a3957f1c4da6c12a9e00c6ad8e73f6f5 CI run 36953175518 is green; the exact-head watcher reported zero pending checks. No CI rerun or admin exception was used.

The prior run also had two failures independently reproduced on main in files outside this PR's test changes:

  • The resolved-model projection case in src/gateway/session-utils.test.ts: main run 36946915948, job 110651166926.
  • The same 30 cases in attempt.spawn-workspace.context-engine.test.ts: main run 36949496803, job 110659259709. Main's attempt quota lookup uses the worker session reader while that suite still runs in Vitest's thread pool, reaching the unchanged host-only admission guard. The normalized main and PR failure-name sets match exactly.

The previous completed ClawSweeper review of head 40e37e93a3957f1c4da6c12a9e00c6ad8e73f6f5 reports no actionable introduced finding and explicitly concludes that migration proof is inapplicable: this inactive stage introduces no persistent DDL or stored-data contract change. Its generated persisted-table warning is a false positive; sqlite-worker-store.ts changes broker admission, not tables.

Next stages P2–P7

  • P2: session facts, creation, authority, topology, and expiry bound to actor incarnations.
  • P3: side-data domain adapters.
  • P4: transcript mutation and lifecycle.
  • P5: history and compute routing.
  • P6: ACP sequencing and the final shared-owner audit.
  • P7: atomic activation and deletion of the host incognito routes.

@clawsweeper

clawsweeper Bot commented Oct 2, 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 size: XL labels Oct 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 1, 2026, 11:36 PM ET / October 2, 2026, 03:36 UTC (Revision 6).

ClawSweeper review

What this changes

Adds inactive worker ownership for incognito databases, including creation, cancellation, lifetime management, memory diagnostics, regression coverage, and staged migration documentation.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/infra/sqlite-worker-store.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this is distinct, useful staged work absent from current main. No actionable introduced defect was found, and the earlier migration-proof blocker does not apply to this inactive, memory-only stage.

Priority: P2
Reviewed head: 57510ef6ddf909665a47c2344f6f13601b787960

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent staged implementation with meaningful lifecycle regressions and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: Verified repository-admin authorship exempts this PR from external-contributor proof requirements. The captured body reports real-worker cancellation and lifecycle validation; production activation remains absent, and no stored-data contract changes require migration proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Verified repository-admin authorship exempts this PR from external-contributor proof requirements. The captured body reports real-worker cancellation and lifecycle validation; production activation remains absent, and no stored-data contract changes require migration proof.
Evidence reviewed 11 items Pinned introduction boundary: Reviewed the merge-base-to-head introduced hunks. Raw head records match the supplied two parents; the stale GitHub test merge was not used to infer removal of current-main behavior.
Current main still excludes incognito execution: Current main retains the file execution owner and explicitly excludes incognito paths from supported worker execution; the new incognito actor modules are absent.
Latest release contract: The supplied latest release’s execution contract contains only file-backed opening identity and no ephemeral target or incognito memory operation.
Findings None None.
Security None None.

How this fits together

OpenClaw’s agent database executor coordinates database work through the SQLite worker broker. This stage adds an explicit in-memory target for internal captures while production incognito sessions continue using their existing host owner.

flowchart TD
  A[Internal ephemeral capture] --> B[Agent execution owner]
  B --> C[Current caller admission]
  C --> D[Dedicated broker worker]
  D --> E[In-memory SQLite database]
  E --> F[Memory diagnostics]
  B --> G[Joined close and cleanup]
  G --> D
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +773, Tests +389, Docs +55. Total +1217 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 17 861 88 +773
Tests 6 393 4 +389
Docs 1 55 0 +55
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 24 1309 92 +1217

Review metrics

Metric Value Why it matters
Production versus validation growth production +773; tests, test support, and test routing +389 net lines Production growth is justified by the documented staged actor lifetime, admission, cancellation, and cleanup responsibilities.

Stored data model

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

Technical review

Best possible solution:

Keep incognito worker lifetime under the canonical executor and defer production activation until the documented complete caller cutover.

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

Not applicable to this inactive foundation PR; source and regression scenarios establish its intended boundary, but this read-only review did not execute them.

Is this the best way to solve the issue?

Yes: extending the existing executor, broker, writer queue, and cleanup lifecycle preserves one owner while leaving production routing unchanged.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is bounded internal worker-foundation work with production incognito activation explicitly deferred.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Verified repository-admin authorship exempts this PR from external-contributor proof requirements. The captured body reports real-worker cancellation and lifecycle validation; production activation remains absent, and no stored-data contract changes require migration proof.

Evidence

What I checked:

  • Pinned introduction boundary: Reviewed the merge-base-to-head introduced hunks. Raw head records match the supplied two parents; the stale GitHub test merge was not used to infer removal of current-main behavior. (57510ef6ddf9)
  • Current main still excludes incognito execution: Current main retains the file execution owner and explicitly excludes incognito paths from supported worker execution; the new incognito actor modules are absent. (src/state/openclaw-agent-execution.ts:109, fd56b79c2228)
  • Latest release contract: The supplied latest release’s execution contract contains only file-backed opening identity and no ephemeral target or incognito memory operation. (src/state/openclaw-agent-execution-contract.ts, c074824a27c9)
  • No stored-data migration introduced: The changed database branch opens :memory: and verifies temp_store=MEMORY before existing schema initialization. The backend admits only memory diagnostics; no persistent DDL, stored format, migration, retention change, or production activation is introduced. This resolves the previous review’s migration-proof next step. (src/state/openclaw-agent-db.ts:255, 57510ef6ddf9)
  • Native admission and operation boundary: The worker validates namespace, handle, and incarnation, requests live opening admission before database creation, and requests fresh preparation admission before reading the memory gauge. Other domain commands are rejected. (src/state/openclaw-agent-execution-incognito.worker.ts:28, 57510ef6ddf9)
  • Cancellation repair and regression: Waiting creators retry only after failed opening and cleanup settle, when the initiating source was refused and captured agent/state-root admission remains current. The new real-worker regression cancels the initiating open, verifies two surviving creators converge, reads their memory gauge, and checks that state/temp directories remain empty. The captured PR body reports seven passing incognito tests after this repair; this review did not execute tests. (src/state/openclaw-agent-execution-incognito.test.ts:86, 57510ef6ddf9)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • aspalagin: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (5 earlier review cycles)
  • reviewed 2026-10-02T01:15:00.075Z sha d00e504 :: blocked before merge. :: none
  • reviewed 2026-10-02T01:33:44.789Z sha f5545de :: blocked before merge. :: none
  • reviewed 2026-10-02T01:39:30.985Z sha f5545de :: blocked before merge. :: none
  • reviewed 2026-10-02T02:01:21.343Z sha 40e37e9 :: blocked before merge. :: none
  • reviewed 2026-10-02T02:13:28.625Z sha 40e37e9 :: blocked before merge. :: none

@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Keep the two creating captures as a tuple so strict indexed-access checking preserves both resolved references. Runtime behavior and concurrency are unchanged.
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Merge main at 7fc0cfb, retaining its WAL retirement closer and P1's durable identity type. Resolve the opening-cancellation regression found during review: valid concurrent creators may retry only after failed opening and native cleanup settle, with current caller and captured owner facts rechecked. Incognito P1 remains inactive.
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 70abbe7 into main Oct 2, 2026
182 checks passed
@steipete
steipete deleted the dbasync/incognito-p1 branch October 2, 2026 03:47
@steipete

steipete commented Oct 2, 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 2, 2026
…nclaw#163145)

* feat(state): add inactive incognito worker actor

* fix(state): settle incognito capture publication

* docs(state): record revised incognito SDK migration

* test(state): preserve concurrent incognito capture tuple

Keep the two creating captures as a tuple so strict indexed-access checking preserves both resolved references. Runtime behavior and concurrency are unchanged.
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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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