Repository navigation
perf: skip read-only Doctor preparation capture - #193241
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: blocked before merge. What this changesThis PR skips redundant database capture around Doctor’s initial read-only preparation while retaining capture around subsequent mutation phases. Example: A captured update prepares an existing SQLite state database in Doctor mode.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this is a focused, maintainer-directed optimization absent from current main, and source review found no definite introduced defect. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared-state repair owner receives Doctor or version-migration requests, prepares credentials and repairs, and publishes verified database changes through the updater’s existing capture owner. flowchart TD
A[Update or Doctor] --> B[Shared-state repair owner]
B --> C[Read-only preparation]
C --> D[Await credential or repair preparation]
D --> E[Captured mutation phase]
E --> F[Generation publication]
F --> G[Final capture settlement]
Technical reviewBest possible solution: Retain the narrow initial-step bypass and the existing capture owner for every subsequent mutation. Do we have a high-confidence way to reproduce the issue? Source shows the initial read-only step entering the same observation envelope as writes, and the PR reports a baseline regression observing four generation inspections rather than two; this review executed no target code. Is this the best way to solve the issue? This is the smallest complete production change: bypass only the proven read-only step and preserve the existing mutation, authority, custody, and settlement owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4ae6d6f057a4. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests -16, Other +452. Total +437 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 5, 2026, 1:25 AM ET / 06:25 UTC. |
Skip the initial generation envelope for artifact-free shared-state Doctor/version preparation. Retain WAL/journal capture and every later write-phase admission, source custody and cleanup. The matched repeat-Doctor fixture removes two generation workers, two size workers and 22 fixed inspection SQL statements per pass; requests remain unchanged. Preserve real admission/reader, outside-write refusal, cancellation and credential migration coverage. Counts only; no CPU or wall-time speedup claim.
What Problem This Solves
Captured Doctor wrapped initial shared-state Doctor/version preparation in a before/after generation envelope even when it only reads owner/schema facts before yielding. For a database without WAL or rollback journal, this launches two generation workers and two size workers unnecessarily.
Run that first synchronous preparation directly only for artifact-free Doctor/version paths. Retained WAL and journal keep the envelope because native reads can rebuild SHM or recover a journal. Every later resumption—including credential preparation and actual repairs—retains capture. Automatic, indexes and readability are unchanged.
The original baseline, first real mutation check, untouched-store final comparison, source custody, cancellation, awaited credentials/closure, and separate state/agent commits remain. Skipped preparation never accepts a new baseline or marks the path opened. No schema, dependency, SQL text, public API or configuration change.
Acceptance rule (declared before performance runs)
Use the committed scripts/perf/doctor-captured-pass.mts workload through production runPackageUpdateDoctor, with an adopted update run, original recovery capture and compiled delegated Doctor. Baseline and candidate use the same platform, Node 26.12.1 or newer, parent driver and identical already-migrated synthetic fixture (four agents, 4,096 sessions). First migration and repeat cohorts stay separate. Record the fixture's actual database bytes; no personal state or logs.
Counts first: generation/size workers, observations, copied bytes, SQL statements, requests, main-thread and total work per Doctor pass, plus source/refusal/cleanup outcomes. Win: exactly two generation and two size workers removed per eligible Doctor/version preparation, with no replacement elsewhere. Total SQL/requests and runtime MAIN must hold or improve. Preserve all migration, outside-write refusal and native update behavior.
For wall/CPU comparisons, acquire the PID-owned timing lock and require one-minute load <24. Interleave at least five samples per head, cold and warm separately; report median, p95 and min–max plus host load. Any adverse 20% cell stops the change. If lock/load waits exceed 60 minutes, use deterministic worker/SQL/copied-byte counts only, explicitly omit a speedup claim, and report the timing gap. Per-thread profiles and counts are diagnostic and lock-exempt. Frozen M/C census pairs are not required for this Doctor-only change.
Matched native update proof, red/green work-count regression, retained refusal tests, two isolated Codex reviews, PG checklist, exact-head CI including all three PostgreSQL shards and the published-driver update cell are required before landing.
Evidence
The real-capture attribution suite passes 39/39. The Doctor/version work-count regression is red on the base (four observations instead of two) and green with the change. Clean WAL-mode, retained WAL, retained journal, wrong mode, outside same/different-content writes, predecessor-stop receipts, empty-reader transitions, cancellation, credential custody, retirement and legacy credential/policy migration remain covered. The unopened clean-stop probe preserves the existing empty-reader equivalence and final receipt.
Two complete isolated Codex reviews plus the isolated production-correction review are scoped-clean. Later changes only repair committed benchmark instrumentation: propagate probe context to sanitized subprocesses and recognize native
doctor --fix. Both have red/green subprocess smoke evidence. A final test-only correction restores the original canonical retained-reader operation on clean databases inside the existing matrix, while retaining artifact-preserving current reads for recovery-artifact shapes. This preserves both the admission-read and retained-reader regressions. The expanded PERSIST-journal + canonical-live-reader combination hit a lock and is not claimed as passing coverage; the original regression used a clean database. Exact-head PG approval is recorded ford25ea5b06527663c214d83bf8bb3e783165ee7cd; the coordinator also explicitly approved native/published-driver proof carry-forward from the production-identical earlier heads. The corrected eight-case matrix passes, and its isolated review with full reader/capture/lock owner context is scoped-clean. CI then caught the test passing a boolean tolive?: true; the one-line correction preserves the literal clean-caselive: trueand omits the option elsewhere, with identical runtime behavior. Its full-context isolated review is scoped-clean. No production or workload bytes changed.Production +2 LOC; tests net 0 LOC. The workload is committed in
scripts/perf/doctor-captured-pass.mtsand the native probe inscripts/perf/doctor-retirement-measure.mts. Local lint/format and worker/dialect ratchets pass (T1 168→168; deprecated-only 15→15). Local type-aware preparation refuses the mandated external virtual-store layout; exact-head CI covers types/static checks.Corrected matched count pair
The baseline and candidate use the same migrated seven-database fixture, restored to the same absolute path. Both Control UI artifacts are ready with matching build identities; neither arm builds UI. All child processes are accounted for.
The four missing processes are exactly the two generation and two size workers. The two removed generation observations account for 22 SQL statements. The remaining SQL difference includes time-dependent maintenance-authority work and is not claimed as a fixed saving. Parent/other-flow SQL and requests remain 1,423/18. Process-main SQL across CLI/child processes is separate from Gateway runtime MAIN; no work moves onto the Gateway. This count pair makes no CPU or wall-time claim.
The explicit clean-stop probe starts Doctor and version with WAL-mode header [2,2], no WAL/SHM/journal, and the capture path unopened. The first read creates WAL=0 and SHM=32,768 while the connection stays open. At the next envelope, the path is still unopened: the committed fingerprint differs, while the existing empty-reader alternate matches the original expected fingerprint. Both real admissions and subsequent credential migration pass with no refusal/warning and an unchanged final receipt. This uses the shipped absent-versus-zero WAL-index equivalence; no skipped phase accepts or marks open the source.
Copied-byte attribution: the deleted observations each copied a 1,716,224-byte main database (3,432,448 bytes removed). The retained main image grew by 311,296 bytes, and five existing WAL-prefix copies grew by 321,360 bytes each (+32% for that component), leaving the measured whole-flow reduction at 1,514,352 bytes. The same 42 WAL-prefix writes remain. The omitted initial envelope previously checkpointed the source; preserving its absence changes later physical layout. The exact page-allocation mechanism is unproven, so the net copied-byte change is measured evidence, not a fixed per-pass saving. No replacement observation or extra request is introduced.
The coordinator explicitly accepted the +32% retained WAL-copy component as a physical-layout shift from the omitted checkpoint: 42 prefix writes remain, and whole-flow copied bytes decrease. The component increase is disclosed above; no copy-policy change or new acceptance mechanism is introduced.
Timing and remaining observations
No CPU or wall-time speedup is claimed. The optional alternating timing cohort stopped at 3 baseline / 2 candidate samples when one-minute load reached 48.06. The third baseline was 202.433s versus 104.204/108.239s earlier; this is an incomplete, loaded-host cohort.
The remaining 27 observations are inventory 3, quick-index 2, readability 2, shared-state/credential open 6, additive-agent schemas 8, legacy-schema/credential repair 6. A separately approved B2 targets only the two readability observations; index WAL/SHM makes its envelope necessary.
D copy investigation is a floor: private generation images copy main + committed WAL prefix (or whole-WAL fallback) + retained journal, never source SHM. Existing clone modes violate the established source-lock/shared-extent inspection contract. No copy-policy/dependency change is included.
Native update and exact-head CI
Exact-head normal CI 41994095575 passed, including all three PostgreSQL conformance shards, required gate, type-aware lint, source contracts and baseline ratchets.
The corrected same-snapshot native update pair passed on source-equivalent baseline target
f12f35015e9c2ca3442f086e7a3a1ecda8e24929and candidate85dbcba051f054ae3ac1cc19f4f35f7b02ee26fe(explicit production-identical carry to this head). Both activated the exact source/build identity, retained plugin payloads, accepted migration attribution, recorded genuine deferred then completed retirement, served the final real-Gateway transport and confirmed process cleanup. CLI-entry WAL was 8,272 bytes in both; all three Doctor boundaries matched (zero WAL; SHM absent/present/absent).Whole-flow SQL increases by 419: the installed Doctors remove 1,146 statements, while non-Doctor work adds 1,565. Source-attributed canary-readiness authority observations rise 315→515: seven SQL shapes each add 200 executions and BEGIN adds 199; the observed readiness authority subgroup itself increases 315→515 (+63.49%), and is not an independently observed HTTP-probe count; other outside-Doctor changes total −34. The existing readiness loop checks authority before and after each fetch, then sleeps up to 100 ms. Its recovery guard reads the exact config-machine-state key; that shape rises 600→800 (+33.3%), with the recovery-read function group rising 465→665. Those owners are byte-identical between arms. Two further adverse cells are pending/deferred migration reads 4→5 (+25%, service-installation reader), and cache_size 2→3 (+50%, an already-spawned integrity worker that emitted no SQL before baseline cleanup). These adverse cells are not proof of harmless noise. The coordinator explicitly accepted these native compatibility-cohort count movements for this exact head, with every cell disclosed here and no whole-update CPU, wall-time or count-improvement claim. Real Gateway thread-0 SQL is 96→89 across canary and final Gateways. Canary is 44→36; final startup is 47→48 and final shutdown 5→5. The extra final-startup canonical_ready SELECT comes from unchanged startup session-validation code; its admission-state difference is unexplained. The cold-only native script exits after readiness, so it does not measure sustained warm-runtime MAIN. The startup cell is disclosed here; no runtime-MAIN exception is claimed. No CPU or wall-time comparison is claimed; exit accounting is incomplete (21/20 missing exits). Earlier instrumentation attempts are invalid proof, not product failures: sanitized subprocesses lost probe context, and
doctor --fixwas initially not recognized. An initial dispatch from main was rejected before tests; it is not reused.Prior production-equivalent head
85dbcba051f054ae3ac1cc19f4f35f7b02ee26fe: normal PR run https://github.com/openclaw/openclaw/actions/runs/41988354238 passed, including all three PG shards. Supplemental run https://github.com/openclaw/openclaw/actions/runs/41988583984 has all three PG shards passing; its actual published-driver update job127122603710 passed, including published2026.10.10 activation and native-systemd2026.10.9 update. The test-only parent4eb3f6d88fddd82c2cb68928c92cb7e1ac8b3135has one test type failure at https://github.com/openclaw/openclaw/actions/runs/41992656008, corrected in final headd25ea5b06527663c214d83bf8bb3e783165ee7cd; refreshed exact-head normal CI passed at https://github.com/openclaw/openclaw/actions/runs/41994095575 . A duplicate supplemental dispatch was canceled after explicit carry-forward approval; the superseded normal run was canceled after its known test-type failure once the corrected head was pushed. Neither is passing proof. Prior-head evidence is not labeled exact-head.Earlier cleanup/discovery timeouts remain intermittent and unresolved: exact-base and current-head focused replays pass (discovery 21.037/17.459s; cleanup 76.080/56.583s). Passing replays are not fixes or inherited-failure proof. The earlier Bun restart-resume timeout also remains unresolved; final-head job127115368267 passes all five tests, including that case at50.004s. No timeout or related owner code changed.
Supplemental failures are disclosed under the coordinator's scoped disposition: cron F11 is the stale scheduled-event assertion repaired separately; plugin env-reference F4 is fixed by #193074 (absent from this base/head, present on main); Slack transcript loading is an unrelated normal-Gateway UI case; the Windows installer-shell timeout serves synthetic marker scripts and never runs OpenClaw/Doctor. The UI 2/7 run passes all 143 files/613 tests then exceeds its Actions step budget. The auth-controller fake-timer case fails its timer-count assertion on Node, then the following Bun execution passes 378/378; it mocks credential/runtime-auth exchange and does not invoke Doctor. Their failures are not described as passing or as matching-main execution where none was observed. Update/Doctor/state tests, required PR/security checks, 3PG and actual published-driver remain gates.
Open PR overlap
Exact-head
d25ea5b0audit: #192698c144b22, #192228b4f1f32 and #149882aca8f05 add no merge-tree conflict paths (2907→2907, 7→7 and92→92), as discovered through the campaign PR index. Current main also merges without conflicts.