Skip to content

fix(sessions): shipped updaters refuse the next release because the transcript worker re-emits the Gateway graph - #200321

Merged
fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/transcript-worker-private-chunk-budget
Nov 17, 2026
Merged

fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/transcript-worker-private-chunk-budget

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Related: #200114 introduced the regression and its feature is kept. #164494 is an open proposal to run the installed-tree budget on main pushes.

What Problem This Solves

Fixes: already-published updaters would refuse the next release, because a clean build of main installs to 52,229 entries and those updaters reject installed trees over 50,000.

The 47,500-entry release budget exists to catch this before a release. main has been over it since #200114, and the scheduled published-driver update cell fails with Installed candidate tree exceeds the release budget.

User Impact

User impact: a clean build of this branch installs to 46,826 entries, 674 under the 47,500 budget, so openclaw update from a published version can install the next release. Compaction still prepares large histories in the transcript reader, as #200114 added.

No config, schema, protocol or dependency changes. The budget, the cap and their counting rules are unchanged.

The headroom is thin. 674 entries is 1.4% of the budget. That is roughly where main stood before #200114, not new slack. Earlier measurements that I did not repeat put the parent of #200114 at 46,795 and published [email protected] at 47,481. More headroom needs separate reduction work and is not part of this fix.

Update behavior. This changes what the package contains, not how an update runs. The installed updater still walks the candidate tree against its frozen cap, and the candidate now fits. Nothing keys on updater markers and no operator state is read or changed.

Why This Change Was Made

The transcript reader is built on its own, with code splitting and private chunk names, so it shares no chunks with the main bundle. Every module it can reach, statically or through import(), is emitted again as a private file.

#200114 made the reader lazily import session-compaction-prepared.worker.ts, which constructs SessionManagerCore to read the active branch. That class also carried host-side hydration. The traced edge:

src/config/sessions/session-transcript.worker.ts            import()
-> src/config/sessions/session-compaction-prepared.worker.ts
-> src/agents/sessions/session-manager-core.ts
-> src/agents/sessions/session-manager-incognito.ts          also reached through session-manager-reload.ts
-> src/config/sessions/session-transcript-hydration.ts
-> src/config/sessions/session-cold-storage-read.ts          import()
-> src/config/sessions/session-cold-storage.ts
-> src/sessions/session-controller.lifecycle.ts -> ... -> src/plugins/loader.ts
-> ... -> src/agents/tools/in-process-gateway.ts -> src/gateway/server-methods/*

Only the host restores cold storage. A read worker reports a cold transcript to its host and stops. On main the reader's graph is 11,596 source modules by esbuild metafile, against 1,831 without that import, and it builds to 5,792 private chunks.

The fix moves the five host hydration methods out of SessionManagerCore into a new SessionManagerHydration class between the core and SessionManagerNativePersistence. The method bodies are unchanged, and SessionManager inherits every one of them through the same chain. The reader still constructs the core, and nothing it reaches imports host hydration now. Its graph is 2,068 modules and it builds to 382 private chunks.

The smaller graph exposed one more edge. The session codec's static import of the root logger landed in the same chunk as the lazy import("../logger.js") in src/process/exec.ts, and the build rejects an ineffective dynamic import. The codec now calls createSubsystemLogger("parseJsonlEntries") directly. The root logger already routed that prefixed line to the same subsystem logger, so the log line is unchanged.

Options considered
  • Build the reader, or only the lazy module, without code splitting. One file would carry the 11,596-module graph. The entry count drops, but the reader ships and parses Gateway code it never runs, and the build-graph guard stays red. Building the whole reader unsplit also removes the lazy boundaries between its handlers.
  • Let the reader share the main bundle's chunks. Every reader thread would evaluate shared Gateway chunks. The private build exists to prevent that.
  • Narrow the imports. Chosen. It removes the files and restores what the guard already states, that a standalone worker does not contain the Gateway graph.
  • Cut at the cold-storage import() instead. session-transcript-hydration.ts imports that module statically and is itself reached from the core, so this cut needs a restore hook registered by the host. Moving hydration off the core needs no new hook.
  • Revert improve(compaction): prepare large histories outside the Gateway thread #200114. Not needed.

Why PR CI missed it, and what guards it now

The installed-tree budget runs in Package Acceptance, which is dispatched manually or called from release checks, and in the published-driver update cell on scheduled main validation. Neither runs on pull requests. shouldRunPublishedDriverUpdate returns false for pull_request, and the cell shows skipping on #200114. The scheduled cell did catch it afterwards. CI run 43959978735 failed on Linux with Installed candidate tree exceeds the release budget (52228 entries, 619284167 bytes).

A cheaper guard already existed and already fails on main. test/scripts/runtime-process-build-graph.test.ts asserts that no standalone worker contains the Gateway server graph. It bundles the workers at test time, so the PR planner's import graph never connects it to src/**, and the planner treats files under test/scripts/ as release-only tooling unless a change selects them. With #200114's 100 changed files and the options PR CI passes, the planner on main selects 1,826 test files and not this one.

This PR registers that test with the existing source policy watch, next to eager-import-closure.test.ts, so source changes select it on PRs. It adds no workflow. With the watch entry, the same input selects it. The test also gains two checks:

  • Each code-split worker builds to at most 1,000 chunks. This catches a worker re-emitting the application graph. It is not the release budget.
  • The reader's graph contains none of session-manager-hydration.ts, session-transcript-hydration.ts and session-cold-storage.ts.

I did not add an installed-entry count to PRs. It needs a full build, a pack and an npm install per PR, which is a slow job. #164494 proposes it for main pushes.

Evidence

macOS arm64, Node 26.12.1, npm 11.20.0. One clean build each, with no dist, dist-runtime or .artifacts beforehand.

node scripts/package-openclaw-for-docker.mjs --allow-unreleased-changelog --output-dir <fresh> --output-name openclaw-candidate.tgz
npm install -g --prefix <fresh> --cache <fresh> --no-fund --no-audit <fresh>/openclaw-candidate.tgz
node scripts/check-openclaw-installed-package-budget.mts <prefix>/lib/node_modules/openclaw
Build Tarball entries Tarball bytes dist/config/sessions/transcript-* Installed entries Installed size Budget check
main 9a6a00e 27,102 123,873,280 5,792 52,229 597.0 MiB exit 1
this diff on 910f6b9 21,697 113,530,880 382 46,824 565.1 MiB exit 0
this PR, bbd2cac on 2cc6988 21,699 113,530,880 382 46,826 565.1 MiB exit 0

The base moved twice while I worked, from 9a6a00e to 910f6b9 and then to 2cc6988. Neither range touches a file in this diff, the build configuration, the lockfile or the budget script. I did not repeat the full red install on the later bases. With this PR's src change reversed on 910f6b9, the reader alone builds to 5,796 chunks, and with the change it builds to 383, counting its entry file.

The lazy module still loads from built output.

  • src/agents/sessions/session-manager-hydration-stream.test.ts drives readPreparedSessionCompactionInWorker through a real reader thread for plan, render, cancellation and oversized-history cases. The test runner compiles that reader with the same private-chunk options as dist. All 12 cases in that file pass.
  • Against the npm-installed tree of this PR, a worker thread imported the chunk the built entry names, ./transcript-session-compaction-prepared.worker-Wt6Onj7f.mjs, found readPreparedSessionCompaction as its export and ran it to its first cancellation check. Loading that chunk evaluates its whole static closure from installed files, SessionManagerCore included. The smoke does not read a database.
  • No existing built-runtime lane reaches prepared compaction. I did not run a built Gateway compacting a session against a model.

Guard, red then green. With this PR's src and planner changes reversed on 910f6b9, three cases in the two touched test files fail. The reader builds to 5,796 chunks against the 1,000 limit, the reader's graph contains 623 forbidden Gateway, flows and wizard modules, and the planner does not select the guard for a source change. With the change, all 64 cases pass. ci-changed-node-test-plan.source-owners.test.ts now expects the guard among the tests any source change selects, and that expectation fails without the watch entry.

Checks. The diff is identical across the rebases below, and each line names the base it ran on.

Check Result Base
oxfmt --check on the 11 changed files, git diff --check clean 2cc6988
pnpm tsgo:all pass 2cc6988
node scripts/run-oxlint.mjs <changed files> pass 910f6b9
OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 node scripts/check-changed.mjs exit 0 910f6b9
Guard, routing and both hydration test files 4 files, 175 tests pass 2cc6988
Guard plus the CI planner test files 21 files, 1,010 tests pass 910f6b9
Session manager, #200114's tests, compaction and hydration worker tests 50 files, 641 tests pass 910f6b9

PR CI on bbd2cac finished with 83 checks passing and none failing, build-artifacts included. The guard file ran there on Linux in checks-node-compact-small-8, 64 tests in 21.5s. This PR edits the guard file, so that run does not by itself show the new watch selecting it. The planner numbers above do.

The dead-export scan is skipped in check-changed. Run alone, pnpm deadcode:exports exits 1 with 126 entries, and none is in a file this PR changes.

Test files audited in full

  • test/scripts/runtime-process-build-graph.test.ts. All three existing behaviors stay: the shared-entry filter, the lazy optional handlers and the Gateway-graph exclusion. The inlined tsdown build became one helper that the new chunk cases share, with the same build options, disposal and temp-dir owner. Nothing was removed.
  • test/scripts/ci-changed-node-test-plan.source-owners.test.ts. One expectation gained an entry. I found no dead, vacuous or duplicate case to prune.

Not proven

  • Linux and npm 12 installed counts for this branch. The Package Acceptance budget step installs with an npm 12 prefix, and my numbers are npm 11 on macOS. The only Linux number is the red one from scheduled CI.
  • The published-driver Docker cells against this branch.
  • An end-to-end compaction through a built Gateway, as noted above.
  • scripts/perf/session-reload-measure.ts swaps session-manager-core.ts and session-manager-codec.ts for A/B runs. I left it alone. The async reload entry point it calls now lives in session-manager-hydration.ts.

Review. A fresh agent reviewed the diff read-only and found no blockers. This head addresses its findings on the chunk guard, the comments and a stale doc reference. The autoreview helper cannot run on this machine, so there is no autoreview result.

…ranscript worker re-emits the Gateway graph

The transcript reader constructs SessionManagerCore to plan compaction. The
class also carried host-side hydration, whose cold-storage restore reaches the
session controller, plugin loader and Gateway methods. The reader's private
code-split build re-emitted that graph as about 5,800 chunks and pushed the
installed tree past the 47,500-entry budget and the 50,000-entry cap frozen in
published updaters.

Host hydration moves to SessionManagerHydration, between the core and native
persistence, so the reader's graph no longer reaches it. The session codec logs
through its subsystem logger directly: in the smaller graph its static import
of the root logger defeated the lazy one in process/exec and failed the build.

The build-graph guard now runs on source changes in PRs, counts private chunks
per worker and names the host hydration modules the reader must not load.
@clawsweeper

clawsweeper Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts agents Agent runtime and tooling size: M labels Nov 17, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 7bda907 into openclaw:main Nov 17, 2026
169 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/transcript-worker-private-chunk-budget branch November 17, 2026 00:50
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Integrate main 687dc6c into PR #200313 only. Preserve #200321 host hydration ownership while retaining shared read-only navigation and the host-only JSONL parser. Keep the beta release baseline unchanged.

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
…ranscript worker re-emits the Gateway graph (openclaw#200321)

The transcript reader constructs SessionManagerCore to plan compaction. The
class also carried host-side hydration, whose cold-storage restore reaches the
session controller, plugin loader and Gateway methods. The reader's private
code-split build re-emitted that graph as about 5,800 chunks and pushed the
installed tree past the 47,500-entry budget and the 50,000-entry cap frozen in
published updaters.

Host hydration moves to SessionManagerHydration, between the core and native
persistence, so the reader's graph no longer reaches it. The session codec logs
through its subsystem logger directly: in the smaller graph its static import
of the root logger defeated the lazy one in process/exec and failed the build.

The build-graph guard now runs on source changes in PRs, counts private chunks
per worker and names the host hydration modules the reader must not load.
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
Derive the build mode and preparation cost from exact selected test files.
Declare and exercise the already-packaged transcript reconciliation worker
for both lifecycle test paths.

Release adaptation: add the build-mode calculation to stable's selected
planner without importing main-only worker-env and #204314 timeout changes.
Retain the stable runtime-config dir and lint inventory; remove only the
retired close-failure fixture suppression, not add the unrelated compacted
session-model fixture entry that is absent on stable.

Companion audit: #201666, #201181 and #203241 are present-equivalent; the
canonical transcript worker manifest/build entry is already on stable.
#204314 is not required (independent timeout projection). #200321 is not
required for this test-only worker switch. The original audit pin predates
#202514; no later same-path, PR-number, or SHA follow-up through ad629bc.

(cherry picked from commit ad2f629)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit c23a5aeddea2f5b92a135dec4ae47ef67393675e)
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 scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant