Skip to content

feat(state): incognito actor compute and usage routing (P5b, inactive) - #164044

Merged
steipete merged 2 commits into
mainfrom
dbasync/incognito-p5b
Oct 3, 2026
Merged

steipete merged 2 commits into
mainfrom
dbasync/incognito-p5b

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Incognito usage extraction and transcript-index reconciliation still depend on SQLite on the host. The inactive actor needs compute routing and cleanup ownership before P7 can switch production routing.

Solution

Route usage reverse RPC and projection source/claim/chunk/finalize operations through the captured actor and existing writer FIFO. Compute retains actor lifetime without reserving that queue while another worker runs. Each compute scope owns distinct source IDs and refresh-lock tokens, allowing exact cleanup after requester revocation or borrow release while P5a's grants and disclosure checks protect results. Partial projection cleanup remains bound to the accepted claim; actor loss returns INCOGNITO_SESSION_ENDED without replay.

Preserve explicit empty usage selections and the durable path's discovery-cutoff behavior. Reuse the existing reconciliation and publication owners; extract the actor adapter to keep the reconcile module within its line cap. Update the compiled-wrapper dependency inventory.

Impact

Inactive until P7: production incognito continues using the host. No schema, retention, durability, configuration, permission expansion, or update behavior changes. No new OPENCLAW_* names. T1 remains 1,333 → 1,333.

P5a (#163987) is merged and this branch incorporates main at 9e34368e594b358692f552624d4879f316ab3ddc. P5c is next: Memory entry/reset-recall and Codex history through the public SDK were saved separately and are excluded here.

Integrated incidental overlap: #163960 simplified error handling in the actor's perform function. This PR keeps its cleanup-admission hunk there minimal; the two changes address different responsibilities.

Evidence

  • node scripts/worktree-setup.mjs gateway: passed, including the full build (78.4s build phase).
  • Actor compute + history: 18 passed, 59.08s wall with pnpm test src/state/openclaw-agent-execution-incognito.compute.test.ts src/state/openclaw-agent-execution-incognito.history.test.ts --maxWorkers=1. Covers FIFO, revocation/borrow-release cleanup, collision isolation, partial projection recovery, typed actor loss, cross-agent disclosure, and zero caller-thread SQL.
  • Existing durable/native usage paths: 2 passed, 18.66s wall, using pnpm test src/infra/session-cost-usage-cache.worker.test.ts --maxWorkers=1 -t 'refreshes and loads usage without executing cache SQL|retains the process-held incognito cache' (8 unrelated cases not selected).
  • Negative checks: all 10 new tests fail with pre-P5b P5a production code. Reinstating the three concrete pre-fix behaviors also produces the intended failures: nonempty results for an empty selection, colliding sources, and a leaked lock after borrow release.
  • node scripts/check-changed.mjs --staged --base 9e34368e594b358692f552624d4879f316ab3ddc: passed (full plan, including all core/test typecheck shards and core/script lint).
  • Madge: 0 cycles. Database worker ratchet: passed against the same pinned main base. Wrapper import closure: 0 missing / 0 stale entries.
  • Codex autoreview through P2, high reasoning, pinned to that base: scoped-clean, no actionable findings.

Production diff: +955 / −60 / net +895 (1,015 changed lines, 14 production files). There are 18 changed files including docs, tooling and tests. CI run 37098300862 completed with 64 successful jobs, one inherited failing test job and its aggregate gate, and 20 skipped jobs (11,563 summed job seconds); the measured local wall times above include harness preparation. Production activation and P5c validation remain separate work.

Released SDK and admission review

Compared the changed signatures against the latest stable release, v2026.9.8: reconcileSessionTranscriptIndexes, runUsageCostWorker, IncognitoSessionRunner, the actor binding, and the projection worker backend are internal-only. They are not exported by src/plugin-sdk/**, exposed by api.runtime.*, or documented SDK subpaths. Existing SDK consumers retain their released signatures; no deprecation compatibility record or new SDK type test is required.

The new compute grant path adds no host SQL. Session-generation and projection-claim predicates execute on the actor; host authorization consumes the existing published session facts. No additional host-read debt was introduced inside grants.

Landing CI attribution

The approved head remains ce7a4d185e521612c0b8e2cb4d7b18271f29eb07. Trusted ClawSweeper review completed at 2026-10-03 05:13:23 UTC with no actionable findings. The coordinator approved this head and its clean P2 autoreview; landing introduced no source changes.

CI attempt 1 of run 37098300862 failed only checks-node-changed-compact-small-5 and its downstream CI aggregate. The root is session-accessor.sqlite-byte-size.test.ts > sizes active context without reading transcript overflow payloads, line 192. Scheduled main run 37094503398, job 111121626866 independently fails the same assertion.

The failure originates in earlier main cleanup 346b89d81d8c34ebb01d790035fae4385cc1f4e1: combining header discovery and sizing exposes serialized_bytes on a query whose header predicate may read event_json. The test then treats that entire query as a sizing-only query and rejects its normal payload-read opcode. The test, active-context query, payload helper, and read-bytes helper are byte-identical between the PR, merge base, CI baseline, and scheduled-main failure. This is incidental cleanup overlap; P5b does not change those owners, and no fix was present at captured main 9d2ebf60d97a44f2b72054e1c2363b8db7fdaafc.

Five separate serial file runs with --maxWorkers=1 reproduced exactly one failure and 19 passes each on both the PR head and merge base 9e34368e594b358692f552624d4879f316ab3ddc. PR wall times: 153.55, 93.65, 56.69, 69.16, 114.51 seconds. Baseline wall times: 129.26, 98.16, 111.59, 130.38, 138.69 seconds. These are failure-attribution runs, not passing test claims. No CI rerun was used.

The CI checkout log binds tested merge 07a8ba9f0a8677c40031f364b32ab3c7b3f80d86 to baseline 7ff3b3be3713751de356800167d67ce752ad0d04 and the approved head. The native inherited-failure admin route is explicitly authorized by the repository owner. Security-fast, production types, lint, and the Gateway usage/memory API boundary job passed; the failed and skipped results remain recorded as such. The initial PR-context failure was a missing authored problem section and was superseded by a successful run after the body was corrected.

Reuse worker history selectors on the retained incognito actor with FIFO, live disclosure authorization, and snapshot hydration. Keep production host-owned until P7; P5b compute, Memory, and Codex routing is stacked next.
Prepare usage reverse RPC and projection reconciliation on the existing actor FIFO. Retain exact compute cleanup custody after revocation and borrow release, preserve disclosure checks and typed actor loss, and keep production routing inactive until P7. Memory and Codex history adapters remain deferred to P5c.
@clawsweeper

clawsweeper Bot commented Oct 3, 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 scripts Repository scripts size: XL labels Oct 3, 2026
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 1:30 AM ET / 05:30 UTC (Revision 2).

ClawSweeper review

What this changes

Adds inactive worker routing for incognito usage calculations and transcript-index rebuilding, with scoped cleanup after caller revocation or borrow release.

Merge readiness

✅ Ready for maintainer review

Keep open: the compute routing remains distinct from merged history work and is absent from fetched main. No introduced blocking defect was found at the unchanged reviewed head.

Likely related people: steipete (routing candidate).

Priority: P2
Reviewed head: ce7a4d185e521612c0b8e2cb4d7b18271f29eb07

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Coherent staged implementation with focused boundary coverage and no actionable introduced findings; inherited CI remains separately recorded.
Proof confidence 🌊 off-meta tidepool Not applicable: Verified repository-admin authorship exempts ordinary contributor proof. The changed actor path has reported and inspected boundary coverage for allowed usage, denied disclosure, revocation, borrow release, and projection recovery; this review ran no code. No unresolved authority violation or stored-data contract change was identified.
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 ordinary contributor proof. The changed actor path has reported and inspected boundary coverage for allowed usage, denied disclosure, revocation, borrow release, and projection recovery; this review ran no code. No unresolved authority violation or stored-data contract change was identified.
Evidence reviewed 10 items Pinned introduction and merge ownership: Reviewed the merge-base-to-head introduction. The raw test-merge commit records the pinned base followed by the exact PR head; its changes preserve the same scoped product delta.
Live caller authority and cleanup custody: Compute operations retain the existing transaction and commit admission path, recheck session claims before disclosure, and reserve the borrow-release exception for scope-owned cleanup commands.
Cleanup cannot consume another scope's resources: The compute scope replaces caller source identifiers and lock tokens with distinct owned identities. Worker source cleanup validates the captured generation and accepted projection claim; the existing lock kernel deletes only the matching token.
Findings None None.
Security None None.

How this fits together

Incognito sessions hold temporary conversation data in an in-memory database. This change prepares usage and transcript-index workers to access that database through its existing actor while preserving authorization and cleanup ownership.

flowchart TD
  A[Usage or index request] --> B[Captured session and caller authority]
  B --> C[Compute scope]
  C --> D[Actor writer queue]
  D --> E[Temporary session database]
  E --> F[Usage or index worker]
  F --> B
  B --> G[Authorized result]
  C --> H[Exact resource cleanup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +895, Tests +577, Docs +18, Other +2. Total +1492 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 14 955 60 +895
Tests 2 577 0 +577
Docs 1 18 0 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 18 1552 60 +1492

Review metrics

Metric Value Why it matters
Inactive implementation cost Production net +895 lines; regression tests +576 lines; 0 production routing activations The growth is justified as staged compute custody and actor adapters that reuse existing storage owners before the complete cutover.

Technical review

Best possible solution:

Keep compute and cleanup under the existing actor and publication owners, with production activation reserved for the complete caller cutover.

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

Not applicable: this prepares an inactive internal execution path. Source and focused boundary tests establish the intended contracts; no current-main failure was executed during this read-only review.

Is this the best way to solve the issue?

Yes: reusing actor FIFO admission, usage kernels, and projection publication avoids competing storage owners while retaining exact cleanup and live disclosure checks.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is bounded worker-migration preparation with production activation deferred and no demonstrated urgent user regression.
  • 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 ordinary contributor proof. The changed actor path has reported and inspected boundary coverage for allowed usage, denied disclosure, revocation, borrow release, and projection recovery; this review ran no code. No unresolved authority violation or stored-data contract change was identified.

Evidence

What I checked:

  • Pinned introduction and merge ownership: Reviewed the merge-base-to-head introduction. The raw test-merge commit records the pinned base followed by the exact PR head; its changes preserve the same scoped product delta. (07a8ba9f0a86)
  • Live caller authority and cleanup custody: Compute operations retain the existing transaction and commit admission path, recheck session claims before disclosure, and reserve the borrow-release exception for scope-owned cleanup commands. (src/config/sessions/session-incognito-actor.ts:364, ce7a4d185e52)
  • Cleanup cannot consume another scope's resources: The compute scope replaces caller source identifiers and lock tokens with distinct owned identities. Worker source cleanup validates the captured generation and accepted projection claim; the existing lock kernel deletes only the matching token. (src/config/sessions/session-incognito-compute.ts:36, ce7a4d185e52)
  • Projection cleanup preserves successors and finalized state: Deletion requires the projection to remain marked for rebuilding with the exact accepted claim identifier, so finalized projections and replacement claims are not removed. (src/config/sessions/session-transcript-projection-rebuild.ts:424, ce7a4d185e52)
  • Focused boundary coverage: Read the complete new suite covering real actor FIFO visibility, usage publication, empty selections, foreign bindings, denied disclosure, revocation cleanup, overlapping scopes, borrow release, partial projection recovery, actor loss, and zero caller-thread SQL. The captured body reports 18 passing compute/history tests and baseline failures for all 10 new cases; this review did not execute tests. (src/state/openclaw-agent-execution-incognito.compute.test.ts, ce7a4d185e52)
  • Current-main necessity and staged activation: Fetched main's actor has no compute binding. Current production usage callers do not supply the new actor binding, and the documented P7 cutover remains separate. Schemas, stored formats, configuration, and update behavior are unchanged. Codex adapters are explicitly deferred rather than imported or exercised by this patch. Public docs: docs/reference/database-schemas/worker-access.md. (docs/reference/database-schemas/worker-access.md:197, ce7a4d185e52)

Likely related people:

  • steipete: 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 (1 earlier review cycle)
  • reviewed 2026-10-03T05:13:23.468Z sha ce7a4d1 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 34ba15d into main Oct 3, 2026
175 of 181 checks passed
@steipete
steipete deleted the dbasync/incognito-p5b branch October 3, 2026 06:02
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…w#164044)

Reuse worker history selectors on the retained incognito actor with FIFO, live disclosure authorization, and snapshot hydration. Keep production host-owned until P7; P5b compute, Memory, and Codex routing is stacked next.
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. scripts Repository scripts 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