Skip to content

refactor(sessions): compose history and SessionManager reads on the incognito actor (P7f1, inactive) - #165134

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

steipete merged 3 commits into
mainfrom
dbasync/incogp7f

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The incognito actor could serve individual history commands, but transcript anchor/accounting/tail facades and SessionManager context reads still lacked the composition needed for atomic activation. Managers also needed to retain their original actor incarnation beyond their opening scope.

Why This Change Was Made

Add explicit, inactive actor bindings for anchor, accounting, and bounded-tail reads. Anchor and model-context publication remain synchronous inside the actor FIFO. SessionManager retains its captured actor, validates retargeting and context lifetime, rejects fresh work after retained or current admission closes, and joins already accepted persistence.

Add SessionManager.readSessionContextAsync with awaited full-fidelity consumption, iterator closure, and source revalidation. Keep the synchronous SDK method deprecated with its compatibility record, migration note, once-per-method warning, and type contract. Build on the merged transcript-context worker facade from #164989.

User Impact

Production incognito routing remains host-owned. This is P7f1, an inactive prerequisite; atomic activation still owns native route deletion. Compute, fork, deferred reconciliation/readiness, and usage composition are split into P7f2. Schema, retention, durability, and update behavior are unchanged. The compatibility record is static SDK deprecation metadata; it introduces no stored-data migration, backfill, schema, or format change. ClawSweeper's data-model checklist is therefore not applicable, consistent with its finding of no introduced stored-data contract changes.

28 files; production +747 / −88 / net +659 (835 changed production lines). T1: 895 → 895. Adds 0 new OPENCLAW_* names.

Overlaps: incogp7e, incogcell, #164922, sessauthtail A/B/C, nativepatchtail, and the inactive umbrella draft #162433. Hunks remain scoped to P7f1; the later lander rebases.

Evidence

Base pinned to 0816aa1b57dc815d0c1e0d48bcb9517980985438.

Released SDK surface check: v2026.9.8 exports SessionManager through openclaw/plugin-sdk/agent-sessions. Its synchronous readSessionContext<T>(target, read, options): T signature is preserved, with the session-manager-sync-context-read deprecation record and a type contract; the awaited twin is additive. Other changed actor/context helpers are internal, and added facade parameters are optional.

Initial SDK acknowledgement digest (PR-base comparison at c9dbbfc46e0): dffe69c0. The diff reports 166 reachable affected exports across 10 declaration changes: the async context method, typed read commands, optional internal parameters, and compatibility record.

Gate Result Wall time
Gateway qaRuntime rebuild Both build and runtime-postbuild stamps accepted 423.76 s
Focused tests, --maxWorkers=1 154 passed across 18 files 720.13 s
Affected manager/context replay after lint fixes, --maxWorkers=1 28 passed 416.09 s
PR wrapper inventory, --maxWorkers=1 Passed 19.83 s
check-changed Passed, including all production/test type graphs and lint 1,956.29 s
Madge 0 cycles 131.98 s
Database-worker ratchet Passed on final source; T1 unchanged Included in check-changed
Local SDK API diff, physical TMPDIR No entrypoint/export removals; synchronous signature preserved 1,387.54 s
Initial independent Codex review through P2 (c9dbbfc) Clean; no accepted/actionable findings 205.56 s

Landing routing audit: production callers do not install the actor scope or supply explicit actor bindings. The affected manager suites already use the agents-support fork project, and the shutdown suite uses Gateway forks. Indirect callers retain existing database-worker routing; no additional host-owner routing is needed. The focused proof below includes the required runtime build graph and import-closure suites.

The focused proofs cover zero caller-thread SQL for moved reads, FIFO publication, physical/source replacement, original actor retention, iterator lifetime, and the real server-close order. Regression baselines demonstrated queued/in-flight reads accepting revoked admission and a following actor operation overtaking model publication. The final code rejects those reads while accepted append and branch persistence still settle; publication stays inside validation. All test type graphs passed, and the affected tests were replayed after the final lint-only cleanup. Hosted CI runtime is not yet measured.

Focused test command
pnpm test \
  src/state/openclaw-agent-execution-incognito.history.test.ts \
  src/agents/sessions/session-manager-incognito.test.ts \
  src/agents/sessions/session-manager-model-context.test.ts \
  src/agents/sessions/session-manager-model-context-snapshot.test.ts \
  src/agents/sessions/session-manager-target-capture.test.ts \
  src/gateway/server-close.incognito-manager.test.ts \
  src/plugin-sdk/agent-sessions.context-compat.test.ts \
  src/plugins/compat/registry.test.ts \
  src/config/sessions/session-transcript-anchor-read.worker.test.ts \
  src/config/sessions/session-transcript-context-read.worker.test.ts \
  src/gateway/session-transcript-readers.test.ts \
  test/scripts/runtime-process-build-graph.test.ts \
  src/auto-reply/reply/get-reply.imports.test.ts \
  src/state/openclaw-state.worker.imports.test.ts \
  src/config/sessions/session-history-read.imports.test.ts \
  src/config/sessions/session-transcript-reconcile.imports.test.ts \
  src/gateway/session-archive.imports.test.ts \
  src/worker/worker.runtime-imports.test.ts \
  --maxWorkers=1
pnpm test test/scripts/eager-import-closure.test.ts -t 'PR wrapper inventory' --maxWorkers=1

CI repair at 5745cfdffe2

The initial changed-Node CI shard timed out in the two SDK bounded-selection race cases. Initial context now reads through the retained-manager helper, so their spy on SessionManager.openModelContextAsync never ran. The tests now pause the real context worker read, retain their rejection/leaf/transcript assertions, and fail promptly if SDK creation bypasses the pause. This repair changes only the test.

The original PR file reproduced the same two 120-second timeouts locally. Four further replays with unchanged original production code and a stricter fail-fast diagnostic failed the same two missing-hook cases; all five exact merge-base replays passed all 12 cases. The repaired file passed all 12 cases (pnpm test src/agents/sessions/sdk.metadata-admission.test.ts --maxWorkers=1, 231.66 s wall time on the loaded local host), targeted changed checks passed (840.94 s), and independent P2 AutoReview was clean. The first CI run's SDK shard spent 270.75 s before failing; fresh-head CI run 37242367714 failed in Bun Doctor owner-repair tests and a Doctor scale subprocess timeout, with sibling jobs cancelled afterward. Production proof above remains applicable because this repair changes no production source.

Durable reader repair at b759cc69cac

Both late ClawSweeper findings are addressed through the existing owners. The durable reader retains withSessionTranscriptReadSource across scanning, awaited consumption, validation, and cleanup. Final acceptance uses readSessionTranscriptAnchorsAsync, retaining writer FIFO custody and checking the native mutation witness before publication. The separate worker-validation operation and its path-checking wrapper were removed. The released synchronous SDK method and inactive production actor routing remain unchanged.

Both new regressions failed before the fix by returning context instead of rejecting: one holds the actual validation reply while a synchronous SDK rewrite occurs, and the other closes the database during a held async consumer. They use held promises, with no real timers. All 103 focused tests across 10 files passed (161.47 s wall), including incognito/context siblings, the SDK type contract, runtime build graph, and import closures. The regression file alone passed all 11 cases (156.98 s wall, including compiler preparation). Production types, every test type graph, ratchets, formatting, and dead-export checks passed; final targeted lint passed after an identifier-only no-shadow correction. The full candidate and final repair delta received clean P2 AutoReview.

The refreshed comparison against released v2026.9.8 has digest cc961c68. Its eight removed subpaths are inherited from the PR base; this PR changes no package export entrypoints. The released SessionManager.readSessionContext<T>(target, read, options): T signature remains intact in source and its type test. The final current-head PR-base comparison passed with digest c69de1a8: 166 reachable affected exports, zero added or removed entrypoints, and zero removed exports.

Current-head CI 37249385458, attempt 1 tested merge 723bbaea9fdd8cbb6d722c45da26ee364acd24a4, with main parent c5012333049eef43cefe9c38ee4805a0dce971be and PR head b759cc69cac85d390557db81c3e84fad70724c2e. Two Doctor jobs are independently qualified as inherited: 12 canonical-key cases and one race case reproduced on exact main c501 with pinned Bun; nine owner-repair broker failures and the scale child's 60-second SIGTERM independently reproduced on main parent d2167f41b6d3a93757d175307b885a1d5b5db51e. The relevant d216-to-c501 projection change affects a maintenance-preservation branch Doctor bypasses. All 27 named failure inputs match c501 and the tested merge. The scale child's internal stall remains unexplained; its identical main failure is recorded without attributing it to the broker errors. Scheduled-main Node failures were not used as Bun evidence.

Job 111573913628 failed; job 111573913730 was cancelled after its Node step 18 failed and remains a second root. The successful fail-fast monitor cancelled 36 other jobs. Those cancellations are incomplete coverage, not passing evidence. The operator authorized the native inherited-failure admin exception; complete exact-head source, checkout, failure, and cancellation evidence is retained for native verification. CI is not claimed green.

Completed ClawSweeper review at this head confirms both durable-reader findings are addressed and reports no remaining actionable patch defect. Its remaining automatic data-model checklist is inapplicable: the compatibility record is static SDK metadata, with no schema, persisted-format, retention, or durability change.

@clawsweeper

clawsweeper Bot commented Oct 4, 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 agents Agent runtime and tooling size: XL labels Oct 4, 2026
@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 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 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 4, 2026, 9:26 PM ET / October 5, 2026, 01:26 UTC (Revision 6).

ClawSweeper review

What this changes

The PR composes incognito transcript reads on the existing session actor, retains managers’ original actor bindings, and adds awaited full-fidelity context consumption while preserving the synchronous SDK method.

Merge readiness

⛔ Blocked before merge - 1 item remains

The PR remains useful and distinct from the merged worker-reader foundation. Both prior durable-reader findings are resolved, and no remaining actionable patch defect was found. The previous migration checklist is inapplicable because the introduced changes do not alter a stored-data contract.

Priority: P2
Reviewed head: b759cc69cac85d390557db81c3e84fad70724c2e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-based refactor with focused regression evidence and no remaining actionable correctness findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies this as maintainer-authored, so ordinary external-contributor proof is exempt. Inspected production actor, worker, and real shutdown regressions cover retained ownership and revocation; no unresolved authority-chain proof requirement remains. No stored-data contract changes were introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies this as maintainer-authored, so ordinary external-contributor proof is exempt. Inspected production actor, worker, and real shutdown regressions cover retained ownership and revocation; no unresolved authority-chain proof requirement remains. No stored-data contract changes were introduced.
Evidence reviewed 8 items Pinned introduction and review continuity: Reviewed the introduced delta from 0816aa1 to b759cc6. The previous completed review used this same head; its outstanding migration request was reassessed against the actual storage boundary.
Durable reader repairs: The full-context reader retains withSessionTranscriptReadSource through scanning, awaited consumption, final anchor validation, and cleanup. Acceptance runs through the existing anchor reader’s writer FIFO and native mutation witness, addressing both earlier findings.
Regression and authority coverage: Inspected regressions for a synchronous rewrite after the actual worker validation reply, database closure during awaited consumption, released actor borrows, revoked admission, wrong-store history bindings, and FIFO publication. The captured PR body reports both durable regressions failed before repair and 103 focused cases passed afterward; this read-only review did not rerun tests.
Findings None None.
Security None None.

How this fits together

SessionManager supplies transcript history and context to agents and plugins. Its readers consume durable or incognito session storage and return context only after checking source lifetime and current admission.

flowchart TD
  A[Agent or plugin request] --> B[SessionManager reader]
  B --> C{Captured storage owner}
  C --> D[Incognito session actor]
  C --> E[Durable history worker]
  D --> F[Consume context]
  E --> F
  F --> G[Validate source and admission]
  G --> H[Return accepted context]
Loading

Before merge

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

Security

None.

PR surface

Source +659, Tests +713, Docs +38. Total +1410 across 28 files.

View PR surface stats
Area Files Added Removed Net
Source 19 747 88 +659
Tests 7 731 18 +713
Docs 2 38 0 +38
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 28 1516 106 +1410

Review metrics

Metric Value Why it matters
SDK compatibility window 1 additive async method; 1 synchronous method deprecated and retained The shipped synchronous contract stays supported until the next SDK major.
Stored-data changes 0 introduced schema or persisted-format changes Static deprecation metadata does not require a data migration checklist.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/plugins/compat/session-persistence-records.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep one session actor and history-reader owner, preserving synchronous SDK compatibility while preparing the separately reviewed atomic activation.

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

Not applicable as a standalone bug report. The prior defects have specific worker-boundary regressions and recorded failing-before/passing-after results, which were inspected but not executed here.

Is this the best way to solve the issue?

Yes. The patch composes existing actor and reader owners, fences acceptance through the established writer boundary, and preserves the released SDK contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The SDK gains an async companion and a deprecation warning; the documented direction preserves the released synchronous signature and result throughout its compatibility window.

Label justifications:

  • P2: This is a bounded internal session-read and lifecycle improvement without an introduced urgent user-facing regression.
  • merge-risk: 🚨 compatibility: The SDK gains an async companion and a deprecation warning; the documented direction preserves the released synchronous signature and result throughout its compatibility window.
  • 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: The supplied repository state identifies this as maintainer-authored, so ordinary external-contributor proof is exempt. Inspected production actor, worker, and real shutdown regressions cover retained ownership and revocation; no unresolved authority-chain proof requirement remains. No stored-data contract changes were introduced.

Evidence

What I checked:

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 (5 earlier review cycles)
  • reviewed 2026-10-04T21:50:51.711Z sha c9dbbfc :: blocked before merge. :: none
  • reviewed 2026-10-04T22:00:00.373Z sha c9dbbfc :: blocked before merge. :: none
  • reviewed 2026-10-04T23:10:27.244Z sha 5745cfd :: blocked before merge. :: [P2] Fence durable context acceptance against intervening writes | [P2] Retain the durable read owner through awaited consumption
  • reviewed 2026-10-04T23:41:03.440Z sha 5745cfd :: blocked before merge. :: [P2] Fence durable context acceptance against intervening writes | [P2] Retain the durable read owner through awaited consumption
  • reviewed 2026-10-05T01:06:12.964Z sha b759cc6 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 4, 2026
Pause the actual model-context worker read after the retained-manager
refactor changed the initial-context call path. Preserve the branch/reset
rejection and transcript assertions, and fail promptly when SDK creation
finishes without entering the reader pause. Always settle and dispose the
created session during cleanup.

This repairs the PR-caused SDK metadata-admission CI timeouts without
changing production routing or the released SDK contract.
@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 4, 2026
Retain the existing history read source across scanning, awaited consumers,
validation, and cleanup. Accept full-fidelity context through the existing
anchor reader so writer FIFO custody and the native mutation witness fence
synchronous rewrites between validation and publication.

Remove the independent context-validation worker operation. Add regressions
for delayed validation replies and database closure during consumption; both
returned stale context before the repair. Preserve the released synchronous
SDK signature and inactive production incognito routing.
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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 added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 5, 2026
@steipete
steipete merged commit ea00cb3 into main Oct 5, 2026
128 of 168 checks passed
@steipete
steipete deleted the dbasync/incogp7f branch October 5, 2026 01:30
@steipete

steipete commented Oct 5, 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 5, 2026
…ncognito actor (P7f1, inactive) (openclaw#165134)

* refactor(sessions): compose incognito history and manager reads

* test(sessions): observe worker reads in SDK selection races

Pause the actual model-context worker read after the retained-manager
refactor changed the initial-context call path. Preserve the branch/reset
rejection and transcript assertions, and fail promptly when SDK creation
finishes without entering the reader pause. Always settle and dispose the
created session during cleanup.

This repairs the PR-caused SDK metadata-admission CI timeouts without
changing production routing or the released SDK contract.

* fix(sessions): retain durable context read ownership

Retain the existing history read source across scanning, awaited consumers,
validation, and cleanup. Accept full-fidelity context through the existing
anchor reader so writer FIFO custody and the native mutation witness fence
synchronous rewrites between validation and publication.

Remove the independent context-validation worker operation. Add regressions
for delayed validation replies and database closure during consumption; both
returned stale context before the repair. Preserve the released synchronous
SDK signature and inactive production incognito routing.
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 gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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