Skip to content

fix(sessions): scope legacy-main owner notice to real legacy rows - #126551

Merged
steipete merged 3 commits into
mainfrom
steipete/keen-elgamal-1e77b7
Aug 20, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/keen-elgamal-1e77b7

Conversation

@steipete

@steipete steipete commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators starting a correctly configured multi-agent fleet would see a Doctor notice claiming legacy main session rows needed an owner, on a brand-new install with zero session data.

Every gateway startup printed:

[gateway] session: retired main-agent session migration warnings:
- session: legacy main rows have no unambiguous configured owner; preserve them and run openclaw doctor after assigning agents.defaults.sessionStore.agentId

The wording implies data exists and asks the operator to assign ownership for nothing. Running openclaw doctor cannot clear it, because there is nothing to migrate.

The same unresolved-owner result also dead-ended agent creation. openclaw agents create main failed with legacy main sessions have no unambiguous configured owner ... Run openclaw doctor --fix, then retry, on a fleet with no legacy rows. doctor --fix could never resolve it, so the only escape was configuring agents.defaults.sessionStore.agentId to satisfy a check about data that did not exist.

Why This Change Was Made

resolveArmingDecision decides ownership purely from config and returns before any session store is read, so the notice and the creation gate had never been conditional on data. Neither surface had ever checked whether a legacy row exists.

The unresolved-owner branch now probes the candidate stores and reports no-legacy-rows when every store proves clean. Absence must be proven: unreadable stores, legacy JSON stores, and genuine read failures still fail open and keep the notice, so the precaution survives exactly where the fleet cannot be shown clean.

Store scanning moved into legacy-main-session-key-scan.ts so the probe and the armed claim reader share one normalization-aware key predicate. This matters for correctness: normalizeAgentId falls back to main for unrepresentable ids, so keys such as agent:---:chat are genuine legacy rows. A raw LIKE 'agent:main:%' probe would have missed them and silenced a real pending migration. The extraction also keeps legacy-main-session-migration.ts under the max-lines limit (703 -> 689) without adding a suppression.

The creation gate now blocks an unarmed run only when the scan did not prove the fleet clean. Armed runs still require a completed ledger, so every previously blocked outcome still blocks.

User Impact

A correctly configured new fleet starts clean, and agents create main is no longer blocked by a migration that has nothing to migrate. Operators with real legacy main rows see exactly the same notice and the same gate as before.

Evidence

Live gateway startup, isolated OPENCLAW_STATE_DIR, non-default port, identical config both runs:

Before (pre-fix build):

2026-08-19T22:26:08.377 [gateway] session: retired main-agent session migration warnings:
- session: legacy main rows have no unambiguous configured owner; preserve them and run openclaw doctor after assigning agents.defaults.sessionStore.agentId

After (rebuilt from the fixed sources, same command and config):

2026-08-19T22:30:27.868 [gateway] starting HTTP server...
2026-08-19T22:30:29.563 [gateway] http server listening (16 plugins ...)

No migration warning block. The gateway reaches listening normally.

Config used for both runs:

{ "gateway": { "mode": "local", "port": 19199 },
  "agents": { "ownership": "explicit",
    "defaults": { "systemAgent": { "agentId": "ops" } },
    "entries": { "ops": {}, "research": {}, "support": {} } } }

Regression coverage. The new state-migrations case fails on pre-fix code for the right reason:

FAIL src/infra/state-migrations.test.ts > starts a new explicit-ownership fleet without a legacy-main owner notice
AssertionError: expected [ Array(1) ] to not deep equally contain StringContaining{...}
+ Received: [ "session: legacy main rows have no unambiguous configured owner; ..." ]

The pre-existing unresolved-owner tests were changed to seed a real agent:main:chat row before asserting the notice, since they previously asserted it on an empty store. New cases cover the proven-clean store, the unreadable-store fail-open, and unarmed-but-clean agent creation.

Test and check runs:

node scripts/run-vitest.mjs src/config/sessions/legacy-main-session-migration   27 passed
node scripts/run-vitest.mjs src/infra/state-migrations                          521 passed | 2 skipped
node scripts/run-vitest.mjs src/agents/agent-create                             50 passed
node scripts/run-vitest.mjs src/commands/doctor-session-transcripts             14 passed
node scripts/check-changed.mjs                                                  exit 0

Codex autoreview on the full diff: clean, no accepted or actionable findings.

Production LOC delta is +66 (tests +95). This is a bug fix, so the growth is called out deliberately rather than left for review to find. Proving absence is a capability that did not exist anywhere in this module: the arming decision is config-only by design, and it must stay that way because the exported error path calls it from a catch where store I/O would be wrong. The absorbing refactor was attempted and taken as far as it goes: the probe reuses resolvePhysicalStores for discovery instead of adding a second path, the armed reader and the probe now share one key predicate instead of two copies, and a double parse of every session key was removed along the way. What remains is the probe itself, the owner-optional plumbing, and the import header of the extracted module.

Unrelated CI heal included

main was already red when this branch was cut. Base commit 0a8226c3 fails checks-node-compact-small-4 with the same five tests and the same error as this PR's first run:

FAIL src/gateway/server.sessions.compaction-read-errors.test.ts (5 tests)
Error: transcript reader mock was not initialized

That file captures the real loadTranscriptEvents as a side effect of its vi.mock factory and requires it in beforeEach. The factory only runs when the mocked module is first imported, and nothing in the file imported it directly, so once a shard shares a worker (--isolate=false) the capture could still be unset. Flaky by construction, not by timing.

Fixed here rather than waited out, per the repo rule that red main gets fixed in the landing PR: the file now imports the mocked module for its side effect, so the factory always runs.

The first attempt in this branch resolved the reader with vi.importActual instead, and CI caught that it was wrong. importActual returns a separately instantiated, unmocked copy that does not share the module-level SQLite state the harness sets up, so it read no events, compaction no-opped successfully, and the three rejection tests failed on response.ok while the two empty-transcript tests passed. Capturing through importOriginal keeps the harness's own module instance; only the import was missing.

Honest limitation: this does not reproduce locally, including with the exact 25-file shard composition taken from the failing CI log (25 files, 300 tests, green before and after). CI on the Linux runners is the verification for this part.

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 20, 2026 05:33
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 20, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Aug 20, 2026
@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 20, 2026, 1:39 AM ET / 05:39 UTC.

ClawSweeper review

What this changes

The PR checks candidate SQLite session stores for actual retired main-agent rows before showing an unresolved-owner migration notice or blocking creation of a main agent.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this maintainer-authored PR open. Source review finds the migration-owner fix coherent and no blocking patch defect; exact-head CI is still incomplete with one failed compact check requiring resolution before merge.

Priority: P1
Reviewed head: dafd1a42b1793f0bac10f2a09315b21303b9a645

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong supplied terminal proof and focused owner-boundary coverage support a good patch, pending exact-head CI completion.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The PR body contains an isolated-state terminal before/after gateway run showing the false warning disappears and the fixed gateway reaches listening.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR body contains an isolated-state terminal before/after gateway run showing the false warning disappears and the fixed gateway reaches listening.
Evidence reviewed 7 items Current-main defect: Current main returns the unresolved-owner result before inspecting stores, so an empty explicit multi-agent fleet receives the legacy-owner warning.
Creation gate on current main: Current main blocks creating main whenever migration is unarmed, including the empty-store unresolved-owner case.
Owner-boundary repair: The branch performs absence proof in the migration owner, preserves fail-open behavior for unreadable and JSON candidates, and returns a clean outcome only when no candidate has a legacy key.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw gateway --help

Result: PASS (completed)

pnpm openclaw gateway --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-126551-w2Sqr6/target$ pnpm openclaw gateway --help
$ node scripts/run-node.mjs gateway --help
pnpm openclaw gateway --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 105.81 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 13.7s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4256ms (slowest: built plugin control-plane loads 3532ms)
│
◇

OpenClaw 2026.8.1 (dafd1a4) — All your chats, one OpenClaw.

Usage: openclaw gateway [options] [command]

Run, inspect, and query the WebSocket Gateway

Options:
  --allow-unconfigured      Allow gateway start without enforcing gateway.mode=local in config (does not repair config) (default: false)
  --ambient-channels        Allow the gateway to auto-configure channels from ambient environment variables (default: false)
  --auth ‹mode›            
… output truncated …

Assertions:

  • PASS expect_output: gateway

How this fits together

Gateway startup and agent creation consult session migration to detect retired main-agent session keys. The migration result either preserves a warning/gate for real or uncertain legacy data, or lets a clean new fleet continue.

flowchart LR
  A[Gateway startup or agent creation] --> B[Session migration check]
  B --> C[Resolve configured owner]
  C --> D[Scan candidate session stores]
  D --> E{Legacy rows or uncertainty?}
  E -->|Yes| F[Keep notice or creation gate]
  E -->|No| G[Continue normally]
Loading

Before merge

  • Resolve merge risk (P1) - The new clean-state result controls whether existing session data blocks main-agent creation; a false clean classification could permit creation before legacy rows are migrated, so the fail-open paths need exact-head validation.
  • Resolve merge risk (P1) - This bug fix has a production net increase of 66 lines; the added scan is justified by the absence-proof boundary, but it expands a session-migration decision surface.
  • Complete next step (P2) - Keep the maintainer-authored, protected-label PR open while the failed and in-progress exact-head checks are resolved; no mechanical repair finding is established.
Agent review details

Security

None.

PR surface

Source +66, Tests +95. Total +161 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 130 64 +66
Tests 3 95 0 +95
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 225 64 +161

Review metrics

Metric Value Why it matters
Production versus test LOC production +130/-64 (net +66); tests +95/-0 The net production growth is the new store scan and extraction needed to prove absence before relaxing a session-migration gate.
Migration gate behavior 1 creation gate changed Main-agent creation now proceeds only for an unarmed migration result that proves every candidate store clean.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/agents/agent-create.ts, migration/backfill/repair: src/config/sessions/legacy-main-session-key-scan.ts, serialized state: src/config/sessions/legacy-main-session-key-scan.ts, serialized state: src/config/sessions/legacy-main-session-migration.test.ts, serialized state: src/config/sessions/legacy-main-session-migration.ts, serialized state: src/infra/state-migrations.test.ts, and 3 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

  • One compact CI check is failing and the exact-head check set is incomplete; its failure cause is not present in the supplied review context.

Maintainer options:

  1. Complete exact-head migration verification (recommended)
    Resolve the failed check and require green exact-head validation of clean, legacy-row, unreadable, and JSON-store paths before merging this state-gate change.

Technical review

Best possible solution:

Retain the migration-owner scan and fail-open behavior, then merge only after exact-head checks confirm both clean-store and uncertain-store paths.

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

Yes, source-reproducible: current main emits the unresolved-owner result before store inspection and blocks unarmed main-agent creation; the PR also provides an isolated gateway before/after transcript. I did not execute the reproduction in this read-only checkout.

Is this the best way to solve the issue?

Yes: placing absence proof in the migration owner is better than special-casing gateway or agent-creation consumers, and the shared scanner keeps the armed and unarmed paths on one key predicate.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0a8226c3db52.

Labels

Label changes:

  • add P1: The existing behavior can dead-end main-agent creation for correctly configured new multi-agent fleets.
  • add merge-risk: 🚨 session-state: The patch changes the decision that protects retired session rows from being bypassed before migration.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains an isolated-state terminal before/after gateway run showing the false warning disappears and the fixed gateway reaches listening.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body contains an isolated-state terminal before/after gateway run showing the false warning disappears and the fixed gateway reaches listening.

Label justifications:

  • P1: The existing behavior can dead-end main-agent creation for correctly configured new multi-agent fleets.
  • merge-risk: 🚨 session-state: The patch changes the decision that protects retired session rows from being bypassed before migration.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body contains an isolated-state terminal before/after gateway run showing the false warning disappears and the fixed gateway reaches listening.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains an isolated-state terminal before/after gateway run showing the false warning disappears and the fixed gateway reaches listening.

Evidence

What I checked:

Likely related people:

  • Erick Kinnee: Current-main blame attributes the implicated migration and creation-gate lines to the commit that introduced this legacy-session migration surface. (role: introduced the current migration and creation-gate behavior; confidence: high; commits: 6ac998eba8c6; files: src/config/sessions/legacy-main-session-migration.ts, src/agents/agent-create.ts)
  • Martin Cleary: The commit that introduced the current behavior records Martin Cleary as committer, making this a useful routing contact alongside the code author. (role: recent merger/committer of the affected migration surface; confidence: medium; commits: 6ac998eba8c6; files: src/config/sessions/legacy-main-session-migration.ts, src/agents/agent-create.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve the failed compact check and wait for the remaining exact-head checks to finish green.

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.

@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Aug 20, 2026
resolveArmingDecision returns owner-unresolved purely from config, before any
session store is read, so the unresolved-owner notice and the agents-create
gate both fired without checking whether any legacy `main` rows exist. A new
explicit-ownership fleet with zero session data printed "legacy main rows have
no unambiguous configured owner" on every startup, and `agents create main`
dead-ended: it told operators to run `openclaw doctor --fix`, which cannot
resolve anything when there is nothing to migrate.

Probe the candidate stores in the unresolved-owner branch and report
no-legacy-rows when every store proves clean. Unreadable stores, legacy JSON
stores, and genuine read failures still fail open and keep the notice, so the
precaution survives exactly where absence cannot be proven. The main-creation
gate now blocks an unarmed run only when the scan did not prove the fleet
clean; armed runs still require a completed ledger.

Store scanning moves to legacy-main-session-key-scan.ts: the probe and the
armed claim reader share one normalization-aware key predicate, so a store
holding `agent:Main:...` or another key that normalizes to `main` cannot be
misread as clean, and the migration module stays under the max-lines limit.
…order

src/gateway/server.sessions.compaction-read-errors.test.ts captured the real
loadTranscriptEvents as a side effect of its vi.mock factory, then required it
in beforeEach. The factory runs on first import of the mocked module, so once a
shard shares a worker (--isolate=false) the field could still be unset and all
five tests failed with "transcript reader mock was not initialized".

Resolve the real reader with vi.importActual in beforeAll instead, so the
default implementation no longer depends on whether the factory has run.

Pre-existing on main: 0a8226c fails the same checks-node-compact-small-4 shard
with the identical five tests. Not reproducible locally, including with the
exact 25-file shard composition; CI on Linux runners is the verification.
src/gateway/server.sessions.compaction-read-errors.test.ts captures the real
loadTranscriptEvents as a side effect of its vi.mock factory and requires it in
beforeEach. The factory only runs when the mocked module is first imported, and
nothing in this file imported it directly, so once a shard shares a worker
(--isolate=false) the capture could still be unset and all five tests failed
with "transcript reader mock was not initialized".

Import the mocked module for its side effect so the factory always runs.

Resolving the reader with vi.importActual instead was wrong: that returns a
separately instantiated, unmocked copy that does not share the module-level
SQLite state the harness sets up, so it read no events, compaction no-opped
successfully and the three rejection tests failed on response.ok. Capturing
through importOriginal keeps the harness's own module instance.

Pre-existing on main: 0a8226c fails the same checks-node-compact-small-4 shard
with the identical five tests.
@steipete
steipete force-pushed the steipete/keen-elgamal-1e77b7 branch from 8d08e44 to 8093878 Compare August 20, 2026 06:12
@steipete
steipete merged commit a947730 into main Aug 20, 2026
228 of 230 checks passed
@steipete
steipete deleted the steipete/keen-elgamal-1e77b7 branch August 20, 2026 06:25
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 21, 2026
…enclaw#126551)

* fix(sessions): scope legacy-main owner notice to real legacy rows

resolveArmingDecision returns owner-unresolved purely from config, before any
session store is read, so the unresolved-owner notice and the agents-create
gate both fired without checking whether any legacy `main` rows exist. A new
explicit-ownership fleet with zero session data printed "legacy main rows have
no unambiguous configured owner" on every startup, and `agents create main`
dead-ended: it told operators to run `openclaw doctor --fix`, which cannot
resolve anything when there is nothing to migrate.

Probe the candidate stores in the unresolved-owner branch and report
no-legacy-rows when every store proves clean. Unreadable stores, legacy JSON
stores, and genuine read failures still fail open and keep the notice, so the
precaution survives exactly where absence cannot be proven. The main-creation
gate now blocks an unarmed run only when the scan did not prove the fleet
clean; armed runs still require a completed ledger.

Store scanning moves to legacy-main-session-key-scan.ts: the probe and the
armed claim reader share one normalization-aware key predicate, so a store
holding `agent:Main:...` or another key that normalizes to `main` cannot be
misread as clean, and the migration module stays under the max-lines limit.

* test(gateway): stop compaction read-error mocks depending on factory order

src/gateway/server.sessions.compaction-read-errors.test.ts captured the real
loadTranscriptEvents as a side effect of its vi.mock factory, then required it
in beforeEach. The factory runs on first import of the mocked module, so once a
shard shares a worker (--isolate=false) the field could still be unset and all
five tests failed with "transcript reader mock was not initialized".

Resolve the real reader with vi.importActual in beforeAll instead, so the
default implementation no longer depends on whether the factory has run.

Pre-existing on main: fadb67d fails the same checks-node-compact-small-4 shard
with the identical five tests. Not reproducible locally, including with the
exact 25-file shard composition; CI on Linux runners is the verification.

* test(gateway): load the mocked transcript reader deterministically

src/gateway/server.sessions.compaction-read-errors.test.ts captures the real
loadTranscriptEvents as a side effect of its vi.mock factory and requires it in
beforeEach. The factory only runs when the mocked module is first imported, and
nothing in this file imported it directly, so once a shard shares a worker
(--isolate=false) the capture could still be unset and all five tests failed
with "transcript reader mock was not initialized".

Import the mocked module for its side effect so the factory always runs.

Resolving the reader with vi.importActual instead was wrong: that returns a
separately instantiated, unmocked copy that does not share the module-level
SQLite state the harness sets up, so it read no events, compaction no-opped
successfully and the three rejection tests failed on response.ok. Capturing
through importOriginal keeps the harness's own module instance.

Pre-existing on main: fadb67d fails the same checks-node-compact-small-4 shard
with the identical five tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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