Skip to content

refactor(sessions): read bundled currentness checks in workers - #169646

Merged
steipete merged 64 commits into
mainfrom
dbasync/t1cut-s1-currentcheck
Oct 12, 2026
Merged

steipete merged 64 commits into
mainfrom
dbasync/t1cut-s1-currentcheck

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Bundled consumers still reached synchronous session readers through currentness callbacks and retained completion snapshots. The snapshots could also reject a run after its own successful write. Durable bundled callers now prepare source facts through the existing session workers, carry the owner's receipts to effects, and validate live authority at dispatch or commit.

This completes the lane after merged #169608 (status/typed creation reads) and #169659 (chat leaf validation). Final head: 8bbc1b1; integrated main: 90c03ae.

Ownership and compatibility

captureSessionEntryCurrentCheckAsync reads selected entry fields and conversation alternatives in one reader-worker snapshot. Completion bookkeeping uses its live host claim; effects prepare current worker-owned facts and preserve the existing writer's commit validation. Source metadata propagates through filesystem, command/process, spawn, delivery, node and worker adapters. Successful effects use checkAfter: false so their own write receipt cannot retroactively fail them.

The node integration retains main's awaited durable approval before the existing source scope. The final node identity, pairing, policy, cancellation, deadline and source checks remain at dispatch. The source scope ends before waiting for a node reply. Cross-store worker commits enter the same existing effect scope. Slack fallback looks up conversation predicates and DM parents in the selected live publisher's store.

The old synchronous SDK currentness API is deprecated with a runtime warning and an async replacement. Bundled callers have migrated. Native incognito and deprecated external SDK/opaque transaction paths retain their compatibility implementation. There is no new database, cache, worker, generation, fencing, schema or retention mechanism.

Removed checks and accepted edges

  • Tool descriptor construction no longer rereads policy before and after assembly. Policy may change during preparation; execution checks it at the effect.
  • Spawn delegation/model planning no longer repeats source checks. Cancelled preparation may finish a plan or reserve a temporary child slot; dispatch refuses stale authority and cleanup releases the slot.
  • Run-attempt preparation no longer repeats its final policy read. A replaced attempt may finish preparing; native execution refuses stale authority.
  • History projection and client retention no longer repeat currentness reads. Preparation may finish after revocation; native history injection checks before writing.
  • Stop preparation and source-bearing persistence no longer repeat synchronous currentness reads. Cancellation and the writer validate the source at their effects.
  • Completion bookkeeping no longer retains and compares the original entry/transcript snapshot. Housekeeping may finish after replacement; each effect prepares current facts.
  • Delivery no longer prepares authority before its own queue receipt or rechecks that stale snapshot on a transport-preparation failure. A transient failure remains queued for recovery; adapter dispatch prepares and checks current authority.
  • A source change after a successful effect does not retroactively fail that effect. Timeout reattachment settles an already accepted RPC without readmission.
  • A newly recorded Slack owner does not revoke an operation already targeting a captured, still-live publisher. The next event resolves the new owner.

Credential, approval, command/tool, native wire and cross-user disclosure checks remain at their real effects.

T1 result

Across the original 17 lane files, raw T1 expressions are 46 → 42. These are source expressions in mixed kernels, not runtime statements. Ordinary durable bundled paths use the actor or existing worker operations; the shared kernels remain honestly classified mixed.

The residual audit groups are currentness/Goal/reset/ACP/creation (11), archive/conversation (17), and active transcript/rewrite/compaction (14). Retained reachability is deprecated/warned SDK and opaque synchronous transactions, excluded native incognito, offline import/repair/reset, or named final user-data effect guards. conversation-registry.ts retains its one shared primitive for those contracts. This PR does not claim raw T1 zero. The inventory and worker-access documentation record the paths and retirement boundary.

Final repository inventory: 626 files / 2,384 call expressions; T1 496, T1-compat 2, T2 404, T3 261, worker 1,221. No dialect or T1 baseline was raised.

Live SQL evidence

The shared harness used immutable baseline 9c54108f9f20a and combined candidate 22bf8aa966027. Later changes repair types, fixtures, cold authority boundaries and the main integration; this is not a measurement of the final SHA. No SQL or performance saving is claimed for this API cutover.

The original pair was duration-skewed (candidate warmed window 114.302s versus 18.806s). Warmed medians were SQL 294.5 [291–340] → 357.5 [344–514] and requests 81 [79–95] → 100 [95–128]. It also returned retryable UNAVAILABLE for mentions.dismiss; it was not an entirely passing harness run. Two diagnostic candidate attempts subsequently timed out during connection before any turn.

The final entire-workload recheck passed every RPC, all 13 turns, child completion, cron, compaction and shutdown. The baseline had additional cache-decision logging, so timing and controlled-speedup conclusions are not valid. The table describes one run per side and ten warmed turns, as permitted by RELAXED TESTING v6.

Measurement Baseline Candidate
Warmed statements, median [min–max] 343.5 [328–409] 347.5 [302–447]
Warmed requests, median [min–max] 95 [91–119] 97 [83–117]
Warmed MAIN statements, median [min–max] 0 [0–2] 0 [0–2]
Warmed statements / requests, mean 348.0 / 96.9 357.1 / 99.0
First-turn statements / requests 1086 / 229 908 / 182
First-turn MAIN statements 38 38
Whole-workload statements / requests 9929 / 1889 9850 / 1851
Whole-workload MAIN statements 1989 1992
Shared read family Warmed mean per turn, before → after Whole workload, before → after
Exact-entry facts 10.9 → 11.4 173 → 172
Actor hydration 6.2 → 5.5 87 → 81
Entry-cache snapshots 1.1 → 1.3 27 → 24
Row-fact SELECTs 5.4 → 5.1 73 → 72
Watermark SELECTs 7.4 → 7.1 98 → 97

The RAW TURN INCREASE recheck has lower whole-workload statements, requests and all five shared-family totals. Extra warm snapshots are a Memory corpus cycle and a first-turn registry request executed in the warm window. The recorded admission misses follow real Memory commits by 11.52ms and 4.27ms. The original C05 admission and one replacement turn-01 writer miss still lack a recorded rejection reason; they are individual attribution limits, not declared proven noise. Their families add no whole-workload work. Extra MAIN statements are unchanged scheduled GitHub OAuth maintenance.

Warmed operation totals remain transcript hydration 240 statements/20 requests, anchors 110/10, entry patch commit 370/60 and patch preparation 60/30. Row facts change 270/54 → 255/51. Lifecycle projection 120/10 → 133/10 is one existing tracker initialization batch, without another lifecycle request. The active-path projection is absent from these chat requests because they carry no expected-leaf parameter.

Evidence

Two real delivery defects found during CI were repaired. Pre-enqueue authority became stale after the queue's own receipt and could delete a retry on a transient preparation failure. A retired caller rejected during async handoff could also leave a replayable queue entry. Preparation now occurs at handoff; its error is captured, the existing one final authority assertion runs, and then the error is rethrown or dispatch proceeds. Cross-store commits likewise preserve source authority through the existing effect scope. The node expiry tests also caught a real ordering defect: the authority callback can publish a deadline abort, so its existing final check must run before the signal check. The final commit reorders those two checks, preventing cancellation bookkeeping for an undispatched request; no new check or read was added.

  • Requester-custody assertions: all three cases pass on 6ba95d (physical requester retry 16,490ms; unchanged requester after cleanup 15,184ms; revision requester after cleanup 12,520ms). Vitest reports 3 passed/16 skipped in 290.45s. The wrapper later received SIGINT during cleanup, exit130; this is passing assertion evidence, not a successful whole command.
  • Cross-store source-revocation regression passes on 6ba95d in job 114772222762, 534ms.
  • Both cancellation-through-recovery cases pass at unchanged delivery implementation 51d62ee3 in job 114767320999, 2662ms/2398ms.
  • Final node dispatch integration: At exact final head 8bbc1b1, job 114823242081 passes type-aware lint (zero warnings/errors), the SDK surface check, and all 92 tests across four files (85 Gateway tests and seven runtime-api guardrails). Both deadline cases and durable dispatch allowed/denied/revoked cases pass. The test command took 62.81s.
  • Final static qualification: Production/general/all five test-type lanes, general/all five lint stripes, source contracts, guards, extension package boundaries, Madge (zero cycles), and T1/dialect/worker ratchets pass at 1aec560 in run 38251170153. Its completed static jobs remain the proof for those unchanged inputs; the superseded whole run was cancelled after collecting them. The subsequent 8bbc1b1 commit only reorders existing final node checks; the focused final-head lint and tests are reported above. Knip is qualified by the inherited UI findings below. Basic changed-file oxfmt, oxlint and diff checks pass. Older interrupted/cancelled jobs are not passing coverage.
  • SDK surface check passes at unchanged SDK surface 51d62ee3 in run 38236081663. SDK API diff passes from f61bbd1668c5 to a4393bd6a462 (ack 9eae0857, artifact 11738973587). The runtime-api guardrail actually executed and passed in job114749036603.

At exact final head 8bbc1b1, all seven Security High jobs pass in CodeQL run 38252475379, all nine executed Critical Quality jobs pass in run 38252475337, and Security Review passes. The current PR-context job intentionally skips the MEMBER author under the workflow condition; the earlier failed event used the old body. OpenGrep retains only the unchanged-helper finding described below.

Codex autoreview rounds1 and2 completed with no accepted outstanding P0/P1 finding. The second review used immutable source 025d1d8f176da and noted limited unchanged-helper context. Later CI-driven repairs and conflict resolutions received direct source inspection; no third routine review was run. Tests that only pinned retired preparation checks were deleted.

Inherited failures and integration limits

All seven server.agent-input-authority.test.ts failures are independently reproduced on exact baseline 1248e1eaa663874ec2546c05068bed758f688667 in run 38244536981, job 114795040015: four delayed native/peer replies report Session communication state changed before admission., and three directed-send policy cases report Send ended before input staging. These are executed assertions (7 failed/8 skipped), not setup failures. The test and communication-admission owner are unchanged here. The redundant broad baseline run was cancelled after this proof.

Final production Knip reports two UI files and six UI exports in job 114817898575. All eight are byte-unchanged from integrated main 90c03ae5. The independent all-exports scan at exact 1aec560 reports only four of those same UI exports and no session/worker findings in job 114818395234, 122.57s. The final guard-order change does not alter imports, declarations or exports. The X typed-hook allowlist failure was reproduced on clean main fe79a0ff62af at boundary-invariants.test.ts:369 with the same extra extensions/x/src/work-origin.ts; this PR changes neither input. Inherited failures are recorded in the campaign red-main inbox for their owners.

The known OpenGrep hit is the unchanged withCodexAppServerGitConfig helper at transport-stdio.ts:120 (GIT_CONFIG_PARAMETERS); its trusted Git configuration handling predates this PR. No scanner rule or source suppression was changed.

Other inherited executed failures are catalog readiness in three session-creation, five voice-creation and six HTTP-history cases (identical creation signatures on main run 38242205565); the unchanged agents restart-required fixture; the missing-rg fixture; and the unchanged non-isolated runner fixture after main stopped emitting provenance notifications on database open. An unchanged node-host plugin abort fixture also expires its one-second wait; that path does not call the Gateway registry changed here. Its sole timing cause was not independently reproduced. These are failures, not passing checks, and their evidence is recorded for the red-main owners.

Final diff against integrated main: 163 files, +3,617 / −2,314; tests/support +612 / −347; production/docs +3,005 / −1,967. No update/Doctor/schema migration/plugin loading/service lifecycle change; no published-driver update cell applies. The aggregate worker type file was over its lint limit on integrated main; current-entry wire contracts were moved unchanged into the worker-read contract module and row-backfill into its existing request module. The first relocation introduced a type-import cycle; the corrective commit restores the current-entry domain module’s original dependencies. Basic lint passes; the final CI graph check is reported above. The final native Codex request boundary was personally checked against sibling app-server/src/message_processor.rs and app-server/src/request_processors/turn_processor.rs.

@clawsweeper

clawsweeper Bot commented Oct 12, 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 channel: matrix Channel integration: matrix channel: slack Channel integration: slack app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime extensions: memory-core Extension: memory-core cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling channel: feishu Channel integration: feishu extensions: qa-lab extensions: codex plugin: file-transfer extensions: llama-cpp extensions: clawrouter Extension: clawrouter labels Oct 12, 2026
Base automatically changed from dbasync/t1cut-s1-memory to main October 12, 2026 11:28
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 8bbc1b11ef955636d403c0a018fbf46cee6f8a4f
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/command/delivery-authority.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/tools/message-tool-turn-authority.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/workspace-sandbox.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 12, 2026
@steipete steipete closed this Oct 12, 2026
@steipete steipete reopened this Oct 12, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Oct 12, 2026
@steipete steipete changed the title improve(sessions): read bundled currentness checks in workers refactor(sessions): read bundled currentness checks in workers Oct 12, 2026
@steipete
steipete merged commit bc60cd9 into main Oct 12, 2026
175 of 186 checks passed
@steipete
steipete deleted the dbasync/t1cut-s1-currentcheck branch October 12, 2026 13:06
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…law#169646)

Migrate bundled currentness callers to worker-backed source preparation and carry owner authority to real effects. Deprecate the synchronous SDK API and remove duplicate preparation and completion checks.

Preserve queued delivery retries on transient preparation failures while terminally rejecting retired callers at the final handoff. Document accepted preparation edges, SQL attribution, and retained compatibility paths in the PR.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
First-parent upstream f956a18..9d9761d (openclaw#169879 database worker
ownership docs, UI retired render adapters, openclaw#169884 macOS discovery).
No conflicts; the one file both sides touched (agent-schema-history.md,
upstream reworded the snapshot paragraph) keeps our schema-27 rows and
section byte-for-byte. Stops before openclaw#169646 (fp#722),
which is step 69 on its own.

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
…absorb: step 69

openclaw#169646 "read bundled currentness checks in workers",
isolated as its own step. Source-execution scopes now wrap the effects
(runWithAgentToolSourceExecutionScope / runWithBoundAgentToolSourceExecution
Scope), and the final source checks move to the effect boundary.

Conflicts:
- agent-tools.before-tool-call.wrapper.ts: upstream's bound source scope and
  effect-boundary checks around the invocation; kept our continuation
  diagnostic trace context around the forwarded execute inside it.
- subagent-spawn.ts: upstream's scope wraps on initial session, attachment
  materialization (with our continuation patch/admission fields, mount-path
  hint and redacted continuation errors) and upstream's
  recordSubagentSessionSetup call after our continuation launch fields.
  Imports follow both sides' moves.
- subagent-spawn-child-launch.ts (fork helper holding launchChildRun): ported
  upstream's dispatch scope around callNativeSubagentGateway.
- subagent-spawn-lifecycle.ts (upstream's new recordSubagentSessionSetup):
  records the creation state event only; Home is notified after acceptance
  (H1, notifyHomeOfAcceptedSubagentSession), so the fork's duplicate
  recordSubagentSessionCreated is retired.
- session-accessor.sqlite-entry.ts: took upstream's patchNative form and
  re-inserted our afterPersistInTransaction hook at the same point.
- worker inventory regenerated.

Focused: 51 spawn/wrapper/recipient-authority/session-created files, 50
executed, 581 tests; one red (launch-key gateway test) is step-66 test drift,
fixed in the next commit; production-boundary skipped behind it (rerun).

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
…tachment limits (Gate 2.7 batch 3 A)

Brings 97b1f2b onto the step-69 head. Plain spawns get upstream's
inline-attachment caps and whitespace-tolerant base64 again; only
continuation delegate snapshots keep the uncapped path, now named
continuationDelegateSnapshot (was redactContinuationErrorDetails).

Conflict: subagent-spawn.ts materialize call — kept step 69's
runWithAgentToolSourceExecutionScope wrapper (openclaw#169646) with the renamed
field.

Proof at the merge: tsgo core 0; the branch's 42 focused files (spawn,
attachments, continue-delegate, delegate-flow, inline-attachments)
42 executed / 743 tests green. On the branch itself (97b1f2b) the
Docker workspace-isolation e2e fails only because this host has no
openclaw-sandbox:bookworm-slim image (provisioning error before the
test body; environment, not product).

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
1. command-queue.ts: the step-71 line-cap trim (578de4c) turned the bare
   re-export of waitForCommandLaneIdle into `export ... from`, which adds a
   static-export edge next to the static import. project84-owned-topology
   pins that edge to one static import (06c373d, "lane waiters below
   their assemblers"), so the contract has been red since step 71; the
   step-72 focused sweep caught it. The re-export is the imported binding
   again. To stay inside the file's 702-line cap, command-queue.lane-idle.ts
   now exposes one notify helper: notifyCommandLaneIdleWaiters(lane) wakes
   one lane, and with no lane (only resetAllLanes) every lane, as
   notifyAllCommandLaneIdleWaiters did. The import fits on one line;
   command-queue.ts drops to 699 counted lines. Waiter behavior unchanged.

2. subagent-spawn.ts: the step-69 merge (8baca31) took it from 697 to
   701 counted lines (cap 700). Upstream's openclaw#169646 scope wraps grew the
   file while upstream removed imports the fork had already moved out, so
   upstream itself stays at 700. The two pass-through contract types are
   now re-exported on one line instead of two identity aliases: 700.

Proof: project84-owned-topology 9/9; command-queue cancellation,
capacity-groups, lane-idle, publish-transaction and main suites 66/66
(6 files, 75 tests, 0 failed). tsgo:core 0, 32/32 test-shard graphs 0,
oxlint clean, import cycles 0; line-cap ratchet lists neither file.

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zozo123 added a commit to zozo123/openclaw that referenced this pull request Oct 31, 2026
…nfig owners

Current main retired swarm-scheduler.test-support in favor of the native lifecycle observer, requires prepared runtime config before spawnSubagentDirect, and removed the duplicate post-dispatch source recheck (openclaw#169646). Update the bounded launch fixtures accordingly; behavior under test is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: slack Channel integration: slack docs Improvements or additions to documentation extensions: codex gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security-sensitive-changed size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant