Skip to content

improve(doctor): updates scan retained transcripts once instead of twice - #177933

Merged
fuller-stack-dev merged 4 commits into
mainfrom
openclaw/doctor-transcript-scan-reuse-20261019
Oct 20, 2026
Merged

fuller-stack-dev merged 4 commits into
mainfrom
openclaw/doctor-transcript-scan-reuse-20261019

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Each openclaw update scans every retained session transcript for legacy labels twice, once in the pre-plugin Doctor pass and again in the post-plugin pass, which adds minutes on installations with large histories.

User Impact

User impact: when the first Doctor pass completes a clean label scan and the databases have not changed, the second pass in the same update reuses it instead of reading every transcript again. Any change, doubt or missing information still produces a full scan, and real findings are reported both times. There is no new setting.

This needs the installed updater to carry the scan receipt between its two Doctor passes, so the saving starts with the update after this release is installed. An older installed updater simply rescans, with no warnings.

Why This Change Was Made

A complete, clean scan returns a receipt through the existing Doctor result channel. The installed driver keeps it for that update only and passes it to the post-plugin Doctor. Reuse requires unchanged physical database generations, native write tokens and file-family observations, matched by the canonical database path that the backup inventory uses. The scan, its read connection and any repair are bound to that admitted database, so a state directory reached through a symlink is reused correctly, and a scan whose symlink changes while it runs is never certified. Missing, stale, empty or oversized hints rescan quietly; a malformed hint keeps a warning. The three legacy-cron Doctor substeps are now timed separately.

Evidence

  • Published-driver update: in a disposable container, the published npm latest driver (2026.10.5) updated to a candidate packed from an earlier revision of all six fixes together (commit 3331e8d12be, before the latest rebase): update finished, readyz 200, running version verified, durable and incognito session data unchanged.
  • CI repair (run 39447933203): the doctor-config-preflight cron readiness process test capped itself at 45s while Doctor, Gateway start and status run in sequence under their own 30s deadlines. On a loaded bun runner every child finished inside its deadline and Vitest still stopped the test at 45037ms; every test in that shard ran 2-3x slower than the earlier passing run, including ones that never reach the transcript scan. The budget now comes from the child deadlines through the file's getCliProcessTestTimeout helper (whole file 27/27 locally; most of that diff is formatter re-indentation).
  • CI: update-doctor-result now imports the scan-receipt schema at load, so the PR wrapper inventory and the production restart-outcome fixture include that module (3 failing tooling tests before, 20/20 after).
  • Real three-process proof with a private database (120 retained events in six archived sessions) behind a symlinked state directory, using the existing driver record/consume transport: transcript payload reads were 6 in the first pass, 0 in the reused second pass and 6 again without a hint, with no warnings.
  • Reuse suite (25 tests) covers append, rewrite, delete, schema change, writes after admission (in process and from a child process), replaced databases, findings and read errors, profile and repair-mode separation, malformed, oversized and empty receipts, sustained and away-and-back symlink retargeting, and older-driver misses staying quiet through the real fresh-process Doctor runner.
  • The canonical-owner fix was red first: 7 failing reuse cases before binding to the canonical path, and one false clean receipt during an away-and-back symlink change before binding the scan to the admitted owner.
  • Doctor, update Doctor result IPC and fresh-Doctor suites pass locally; independent API-only review found no P0–P2 issues.

@clawsweeper

clawsweeper Bot commented Oct 20, 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.

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review October 20, 2026 01:52
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: L labels Oct 20, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR carries clean transcript-label scan receipts between update-time Doctor passes so unchanged history is scanned once.

Example: An update inspects six archived sessions containing 120 retained events.

  • Before: Both Doctor passes read all six transcripts.
  • After: The first pass reads six transcripts and the second reads zero when the receipt and database observations still match.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation is coherent and both earlier defects are repaired; optimization evidence reaches the production owners, with complete shipped-update reuse still unshown.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this MEMBER-authored PR; supplied evidence reports production-owner three-process reuse counts and published-driver compatibility, but does not show a receipt-capable installed updater skipping its second scan.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Updates reread unchanged retained transcript history during successive Doctor passes, extending maintenance on large installations.
Reason: The maintainer-authored direction removes redundant work without an operator setting, while preserving findings, repair ownership, and conservative fallback.

Merge readiness

✅ Ready for maintainer review

Both prior tooling findings are fixed, and no remaining correctness or security defect was found; the exact-head CI gate remains red because of a separately observed UI timeout.

Priority: P2
Reviewed head: 9d9e4a0b82708d7f999b8edba99ce149070d0ade

Before merge

None.

Findings

None.

Tests

  • Low-value test src/commands/doctor-session-transcript-labels.reuse.test.ts: Remove the older-driver fresh-Doctor subprocess case: its fixture serializes the already-computed warnings array instead of running Doctor, repeating the adjacent quiet-miss assertions and existing warning transport coverage.
  • Missing end-to-end proof: A shipped update with a receipt-capable installed driver exercising reuse across both Doctor passes is not shown.
Agent review details

How this fits together

The updater invokes candidate Doctor before and after plugin convergence; Doctor inspects retained agent transcripts and returns optional scan receipts through its existing result channel.

flowchart TD
  A[Installed updater] --> B[Pre-plugin Doctor]
  B --> C[Transcript label scanner]
  C --> D[Existing database observations]
  B --> E[Operation-local receipt]
  E --> F[Post-plugin Doctor]
  F --> D
  F --> C
Loading

Technical review

Best possible solution:

Keep scan reuse within the existing update receipt lifecycle, preserving full scans whenever identity or write evidence differs.

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

Current main invokes the same exhaustive label scanner in both Doctor passes without sharing its clean result; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch follows the smallest complete ownership path: record the scanner's clean result, transport it through existing Doctor receipts, and reuse existing database observations instead of adding another fingerprint pass.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Legacy transcript-label migration keeps the original intent (d7627d6: Migrate historical inbound-context labels while preserving the provenance-marker recognition contract.)
  • Shared transcript scanner keeps the original intent (6725e57: Share transcript inspection while retaining exact snapshots and domain-owned repair transactions.)
  • Update database write receipts keeps the original intent (d780fdc: Bind automatic rollback to verified database generations and preserve independent writes.)
  • Doctor result evidence keeps the original intent (74a8a5a: Carry database restoration evidence through canonical receipts without losing warnings.)
  • Restart-outcome fixture keeps the original intent (447d5f1: Evaluate production Doctor fact owners instead of replacing their normalization and schema behavior.)
  • Legacy-cron contribution ordering keeps the original intent (1ae0dfe: Split Doctor contributions while preserving their ordering, dynamic imports, repair ownership, and output.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +343, Tests +496, Other +1. Total +840 across 11 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 8 365 22 +343
Tests 2 496 0 +496
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 11 862 22 +840

Review metrics

Metric Value Why it matters
Production versus test growth Production +365/-22 lines; tests and fixtures +496/-0 lines Production growth carries and validates cross-process receipts through existing owners; most test growth covers distinct invalidation and fallback boundaries.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 automation: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Avoids repeated retained-history inspection during updates, with the largest benefit on installations with substantial session history.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Record both Doctor passes during an update driven by a receipt-capable installed version, showing the second scan is skipped and stale receipts still rescan.
  • Remove the redundant fixture-only warning-forwarding subprocess test.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-20T02:09:42.743Z sha 6e67970 :: needs changes before merge. :: [P2] Include the new runtime dependency in the PR wrapper inventory | [P2] Load the new schema in the restart-outcome harness

Reviewed October 19, 2026, 11:05 PM ET / October 20, 2026, 03:05 UTC (Revision 2).

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 20, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Both findings are fixed on head 9d9e4a0b827:

  • [P2] PR wrapper inventory: src/infra/update-doctor-scan-receipts.ts is added to scripts/pr-lib/wrapper-components.txt.
  • [P2] Restart-outcome harness: the fixture now loads the real scan-receipt module, matching its rule that Doctor facts use production owners.

test/scripts/eager-import-closure.test.ts and test/scripts/update-restart-module-outcome.test.ts failed 3 cases on the old head and now pass 20/20.

The remaining CI red, checks-ui-e2e (custodian-onboarding-locale.e2e.test.ts), also fails on main itself (f7a72c7cc28, e4178022618), independent of this PR.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
The pre-plugin and post-plugin Doctor processes of one update both scanned
every retained transcript for labels. A complete, clean scan now returns a
receipt through the existing Doctor result channel; the installed driver
keeps it for that operation only and passes it to the post-plugin Doctor.
Reuse requires unchanged physical database generations, native write tokens
and file-family observations. Any missing, stale, invalid or oversized
receipt falls back to a full scan. The three legacy-cron substeps are now
timed separately.
The backup inventory records canonical database paths, but Doctor can
discover a database through a symlinked state directory, so a clean scan
was never reused. Reuse now matches by the canonical owner, and the scan,
its read connection and any repair use that admitted owner instead of the
mutable alias. A scan whose alias changes while it runs is not certified.
Routine missing, stale, empty or oversized hints rescan quietly; malformed
hints still warn.
…rt checks

update-doctor-result now imports the scan-receipt schema at module load.
The PR wrapper's runtime inventory did not list that module, and the
production restart fixture stubbed it, so its schema was not callable.
Both now include the real module.
@fuller-stack-dev
fuller-stack-dev force-pushed the openclaw/doctor-transcript-scan-reuse-20261019 branch from 9d9e4a0 to bd29e41 Compare October 20, 2026 15:23
@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) October 20, 2026 15:43
The cron readiness process test capped itself at 45s while Doctor, Gateway
start, and status each run in sequence under their own 30s deadlines. On a
loaded runner every child finished within its deadline and Vitest still
killed the test 37ms past the cap. Derive the budget from the child
deadlines through getCliProcessTestTimeout like the rest of the file.
@fuller-stack-dev
fuller-stack-dev merged commit 27aa074 into main Oct 20, 2026
153 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/doctor-transcript-scan-reuse-20261019 branch October 20, 2026 17:28
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…ice (openclaw#177933)

* perf(doctor): reuse clean transcript-label scans within one update

The pre-plugin and post-plugin Doctor processes of one update both scanned
every retained transcript for labels. A complete, clean scan now returns a
receipt through the existing Doctor result channel; the installed driver
keeps it for that operation only and passes it to the post-plugin Doctor.
Reuse requires unchanged physical database generations, native write tokens
and file-family observations. Any missing, stale, invalid or oversized
receipt falls back to a full scan. The three legacy-cron substeps are now
timed separately.

* fix(doctor): bind transcript-scan reuse to the canonical database owner

The backup inventory records canonical database paths, but Doctor can
discover a database through a symlinked state directory, so a clean scan
was never reused. Reuse now matches by the canonical owner, and the scan,
its read connection and any repair use that admitted owner instead of the
mutable alias. A scan whose alias changes while it runs is not certified.
Routine missing, stale, empty or oversized hints rescan quietly; malformed
hints still warn.

* test(update): load the Doctor scan-receipt owner in wrapper and restart checks

update-doctor-result now imports the scan-receipt schema at module load.
The PR wrapper's runtime inventory did not list that module, and the
production restart fixture stubbed it, so its schema was not callable.
Both now include the real module.

* test(doctor): budget the cron readiness test for its child deadlines

The cron readiness process test capped itself at 45s while Doctor, Gateway
start, and status each run in sequence under their own 30s deadlines. On a
loaded runner every child finished within its deadline and Vitest still
killed the test 37ms past the cap. Derive the budget from the child
deadlines through getCliProcessTestTimeout like the rest of the file.
steipete added a commit that referenced this pull request Oct 23, 2026
Prune 70 stale max-lines entries (508 -> 438). Reconcile the counted OPENCLAW_* budget from 452 -> 461 and rename the internal agent FTS schema constant.

Record FACTORY_GITHUB_PROOF, FACTORY_ACTOR_ID, FACTORY_SESSION_KEY (#173668), IMAGE_ACTIVATION_CAPTURE_MARKER (#173711), UPDATE_DOCTOR_HISTORICAL_SCANS (#177933), SESSION_WATCHDOG (#176915), PACKAGE_PERMISSIONS_REPAIRED (#175423), PLUGIN_NPM_ROOTS_FALLBACK (#176121), DISABLE_CRON_HOST_EXECUTION and DISABLE_GATEWAY_LOCAL_TERMINALS (#177855), and the removal of DEVICE_NAME_PREFIX (#178345). All names above use the OPENCLAW_ prefix. AGENT_FTS_SCHEMAS is an internal constant, not an environment variable.
steipete added a commit that referenced this pull request Oct 23, 2026
* fix(ci): block baseline inventory drift in CI and keep shard size advisory

The max-lines suppression inventory and the OPENCLAW_* budget used the limit
severity policy, so GitHub Actions only annotated a tree that disagreed with
its own inventory. Main absorbed moved suppressions, stale entries, and
unrecorded env names with green CI, and every later local ratchet run failed
on debt the branch did not create.

Inventory/tree consistency (unlisted suppression, stale entry, name count
different from the budget) now blocks everywhere, like the sibling shrink
ratchets. Growth relative to the merge base keeps the limit policy so
owner-approved growth still lands with a CI warning.

The core tsgo shard root budget is a shared cost signal its contract marks
advisory; routing it through the limit reporter made it locally fatal. It now
warns everywhere.

Proof: new ratchet and env-budget regressions fail on the base scripts and
pass with the fix; the real boundary check on main's shard layout exits 0 with
four advisory warnings instead of failing.

* ci(tsgo): rebalance core test shards under the root budget

agents-tools (722), gateway-root (725), infra (728), and plugins-platform
(728) exceeded the advisory 720-root limit. Move whole test globs to shards
with headroom: src/media to messaging, src/acp to gateway-other,
src/security to config-cli, and root src/gateway/github* to gateway-methods.
The largest shard is now 719 roots and exactly-once ownership holds.

Messaging test-root selection of the shard guard now includes src/media.

* ci(tsgo): move agents CLI backend tests into the commands shard

Newer main tests pushed agents-root to 722 roots. Root-level
src/agents/cli-*.test.ts files join the commands shard, which already owns
src/agents/command and CLI program tests: agents-root 693, commands 516.

* test(ui): split chat message rendering coverage

Preserve current main coverage across grouping, markdown, tools, attachments, and images, sharing render lifecycle and attachment fixtures. Keep all 59 direct cases and eight parameterized declarations, expanding to the same 79 passing tests.

The image disclosure case now waits for its lazy renderer instead of depending on an earlier image test. All seven files have line-cap headroom; UI types and scoped lint pass. Independent review found no actionable P0-P2 defects.

* chore(ci): reconcile max-lines baseline and env budget with main

Prune 70 stale max-lines entries (508 -> 438). Reconcile the counted OPENCLAW_* budget from 452 -> 461 and rename the internal agent FTS schema constant.

Record FACTORY_GITHUB_PROOF, FACTORY_ACTOR_ID, FACTORY_SESSION_KEY (#173668), IMAGE_ACTIVATION_CAPTURE_MARKER (#173711), UPDATE_DOCTOR_HISTORICAL_SCANS (#177933), SESSION_WATCHDOG (#176915), PACKAGE_PERMISSIONS_REPAIRED (#175423), PLUGIN_NPM_ROOTS_FALLBACK (#176121), DISABLE_CRON_HOST_EXECUTION and DISABLE_GATEWAY_LOCAL_TERMINALS (#177855), and the removal of DEVICE_NAME_PREFIX (#178345). All names above use the OPENCLAW_ prefix. AGENT_FTS_SCHEMAS is an internal constant, not an environment variable.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
…aw#179181)

* fix(ci): block baseline inventory drift in CI and keep shard size advisory

The max-lines suppression inventory and the OPENCLAW_* budget used the limit
severity policy, so GitHub Actions only annotated a tree that disagreed with
its own inventory. Main absorbed moved suppressions, stale entries, and
unrecorded env names with green CI, and every later local ratchet run failed
on debt the branch did not create.

Inventory/tree consistency (unlisted suppression, stale entry, name count
different from the budget) now blocks everywhere, like the sibling shrink
ratchets. Growth relative to the merge base keeps the limit policy so
owner-approved growth still lands with a CI warning.

The core tsgo shard root budget is a shared cost signal its contract marks
advisory; routing it through the limit reporter made it locally fatal. It now
warns everywhere.

Proof: new ratchet and env-budget regressions fail on the base scripts and
pass with the fix; the real boundary check on main's shard layout exits 0 with
four advisory warnings instead of failing.

* ci(tsgo): rebalance core test shards under the root budget

agents-tools (722), gateway-root (725), infra (728), and plugins-platform
(728) exceeded the advisory 720-root limit. Move whole test globs to shards
with headroom: src/media to messaging, src/acp to gateway-other,
src/security to config-cli, and root src/gateway/github* to gateway-methods.
The largest shard is now 719 roots and exactly-once ownership holds.

Messaging test-root selection of the shard guard now includes src/media.

* ci(tsgo): move agents CLI backend tests into the commands shard

Newer main tests pushed agents-root to 722 roots. Root-level
src/agents/cli-*.test.ts files join the commands shard, which already owns
src/agents/command and CLI program tests: agents-root 693, commands 516.

* test(ui): split chat message rendering coverage

Preserve current main coverage across grouping, markdown, tools, attachments, and images, sharing render lifecycle and attachment fixtures. Keep all 59 direct cases and eight parameterized declarations, expanding to the same 79 passing tests.

The image disclosure case now waits for its lazy renderer instead of depending on an earlier image test. All seven files have line-cap headroom; UI types and scoped lint pass. Independent review found no actionable P0-P2 defects.

* chore(ci): reconcile max-lines baseline and env budget with main

Prune 70 stale max-lines entries (508 -> 438). Reconcile the counted OPENCLAW_* budget from 452 -> 461 and rename the internal agent FTS schema constant.

Record FACTORY_GITHUB_PROOF, FACTORY_ACTOR_ID, FACTORY_SESSION_KEY (openclaw#173668), IMAGE_ACTIVATION_CAPTURE_MARKER (openclaw#173711), UPDATE_DOCTOR_HISTORICAL_SCANS (openclaw#177933), SESSION_WATCHDOG (openclaw#176915), PACKAGE_PERMISSIONS_REPAIRED (openclaw#175423), PLUGIN_NPM_ROOTS_FALLBACK (openclaw#176121), DISABLE_CRON_HOST_EXECUTION and DISABLE_GATEWAY_LOCAL_TERMINALS (openclaw#177855), and the removal of DEVICE_NAME_PREFIX (openclaw#178345). All names above use the OPENCLAW_ prefix. AGENT_FTS_SCHEMAS is an internal constant, not an environment variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant