Repository navigation
perf: avoid redundant update Doctor close probes - #186251
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 removes redundant SQLite close probes and permits companion migrations to reuse the Doctor session’s existing admission. Example: Doctor previously admitted companion.sqlite, then its own work inserted retained.value = 9 before another companion migration.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it makes a focused improvement using the existing Doctor settlement owner, and no actionable introduced defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherUpdate Doctor receives captured database generations, performs migrations under maintenance custody, and returns settled write receipts used by subsequent Doctor passes and rollback. flowchart LR
A[Installed updater capture] --> B[Doctor maintenance custody]
B --> C[SQLite migration admission]
C --> D[Companion migration]
D --> E[Resource closure]
E --> F[Session settlement]
F --> G[Update and rollback receipts]
Technical reviewBest possible solution: Use session settlement as the final receipt owner while retaining first-open validation, native exclusion, per-operation publication, and untouched-path refusal. Do we have a high-confidence way to reproduce the issue? The baseline installs a generation-reading close observer and unconditionally rejects changed companions; the added owner cases exercise both paths, with baseline failures reported in the body, but no target code was executed during this read-only review. Is this the best way to solve the issue? The patch is the smallest complete fix found: delete the redundant observer and reuse the existing session admission fact without adding state, wrappers, or another settlement path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 451ec41c26c6. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -37, Tests +67. Total +30 across 2 files. Added test files: 0. View PR surface stats
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 October 27, 2026, 4:01 PM ET / 20:01 UTC. |
Remove migration-specific native-close generation and authority probes now that Doctor session settlement publishes the final postimage for every captured SQLite path it opened. Admit later companions on already-opened paths while preserving first-open and untouched-path validation, native exclusion, and credential authority checks. Owner work-count regressions and exact-head CI, including all three PostgreSQL conformance shards, pass. Native count comparison remains a maintainer-approved post-merge follow-up.
What Problem This Solves
Update Doctor repeats database-generation and custody checks when each migrated SQLite handle closes, even though its session already publishes the final state of every captured database it opened. A later companion migration can also reject that session's own changes.
User Impact
Updates perform fewer database probes. First-open validation, untouched-database refusal, migration exclusion, credential authority checks, and automatic rollback receipts remain intact.
Why This Change Was Made
Remove the migration-specific native-close observer and use the existing opened-path fact for companion admission, matching the session settlement introduced in #185789. Keep per-operation publication and credential provenance, native locks, created-file checks, and the separate handoff/lease store unchanged.
The accepted edge remains the one documented in #177831: raw outside writes to databases opened during the Doctor session may be included in its settled postimage. Captured databases the session never opened must still match.
Evidence
Acceptance rule, recorded before native measurement: one matched synthetic native-update count pair on macOS, using the same current-main installed driver for both arms and distinct baseline/candidate descendants. Each arm runs a cold update and a subsequent warm update through both finalization Doctor passes, exact target activation, and real loopback Gateway readiness. Report each full Doctor pass's SQL/requests and canary/final Gateway MAIN separately. Win requires zero close-triggered generation/authority work, fewer full-pass SQL statements, valid final receipts, and no added worker-request work or runtime Gateway MAIN. Any adverse count cell of 20% or more stops the change. This is n=1 count evidence; no latency or timing claim.
The maintainer-approved post-merge native count pair is complete. Both synthetic updates activated their exact target, preserved the plugin payload, completed retirement after deferral, and stopped all owned processes. Every full finalization Doctor pass executes fewer SQL statements, with identical requests and worker SQL. No compared cell worsened by 20% or more, and all Gateway MAIN counts are identical. This is one count sample per arm, with no latency or CPU claim.
The reductions are on process-main threads; full-pass worker SQL stays 799/684/716/706, and each request-operation count is unchanged. The separate preflight Doctors stay 2,748/2,460 SQL and 101/100 requests. Whole-update SQL is 110,940 → 109,176 cold and 98,735 → 96,874 warm; requests are 153,224 → 153,224 and 153,178 → 153,177. The small worker/request differences outside the full Doctors are not claimed as savings from this change.
Gateway MAIN stays cold canary/final 46/89 and warm canary/final 96/75. Whole Gateway lineage SQL/requests are cold canary 230/35 → 230/35, cold final 656/144 → 674/145, warm canary 256/32 → 256/32, and warm final 574/148 → 568/143. The cold final increase is 18 worker SQL (+3.56% worker SQL, +2.74% total SQL) and one request (+0.69%); it is disclosed without attributing it to this deletion.
Frozen observer/parser verification passed in both arms. Baseline OS process-ID reuse was normalized using recorded process starts and SQL manifests; global SQL/request/prepare/error counts stayed exactly unchanged, and an independent attribution audit passed. Both final analyses have complete source attribution reconciliation and zero duplicate request IDs. Raw captures and synthetic runtime copies are removed after retaining compact count evidence.
The owner regression is red on the baseline: native close performs an unwanted generation read, and a companion already opened by the session is rejected. The consolidated candidate cases pass: no close-triggered generation/authority work, valid final receipt, changed opened-companion admission, and changed untouched-companion refusal. All 18 non-retirement cases pass across the focused runs. The existing native-parent retirement/credential case passed; the worker-parent case hit the unchanged 120-second limit on both the candidate and exact base (reported 139/144 seconds versus 165 seconds). No timeout or retry changes are included. Prior-head CI job 122440037186 passed all 20 attribution-owner cases, including native and worker retirement, both no-close-probe modes, untouched-companion refusal, created-family and credential coverage. The containing group passed 2 files / 38 tests with exit 0; this resolves the local worker-parent proof gap without changing its deadline. Two isolated production reviews were clean; a further isolated review of the final test-only consolidation was also clean. All three completed source verification with no actionable P0–P2 findings.
Production: +2/−39 lines (net −37); tests: +168/−168 (net 0). All original boundary cases remain; consolidation removes redundant setup and combines the new assertions into existing custody cases. Formatting and whitespace checks pass. Production Knip has the exact same single unused-export finding on base and candidate (
extensions/knowledge/src/scribes-catalog.ts: runPrompt); the reviewed-head all-exports scan also exactly matches base, with onlyui/src/pages/activity/activity-page.test-support.ts: settleActivityreported. Neither scan adds a finding. Local type-aware lint cannot admit declarations from the required external virtual store (Declaration input escapes checkout); the exact-head CI lint/type/declaration jobs cover that environment gap.Exact-head CI run 40593068545 passed for
516f07d006b6f40ecf20d296e479711f0d405e43: 43 checks passed, 26 skipped, zero failed/pending. All three PostgreSQL conformance shards actually executed and passed (1/3, 2/3, 3/3). The owner job again passed all 20 attribution cases (combined 2 files / 38 tests). Lint, production/test types, source contracts and architecture checks passed; Madge reports zero cycles, SQLite T1 is 168→168, compatibility 15→15, and the dialect ratchet has no growth. Earlier corrected-head run 40590282500 passed all three PostgreSQL shards and the test-cleanup lint correction; its only lint errors were five inherited UI diagnostics. Main's fix for those diagnostics was then merged cleanly. The integration changes neither file in this PR; no inherited-failure waiver is currently requested.The matched native proof uses common installed driver
364c0d4ebcd400ee4285eb989ed60d2a8b000b93, identical-tree baseline descendant5145cd649ba992e59e7b22caf24072548d36d5a2, and candidate targetb6193a123a6676fc9f7a418061851de5e1412270. The changed production file is byte-identical at the reviewed, measured and integrated heads. Main integration also brought unrelated Doctor heartbeat and port-memory changes, so the measured target is reported separately; whole-tree equivalence to the integrated head is not claimed.The test-only promise cleanup correction uses explicit nested
try/finally, passes four focused regression cases, and has a clean isolated delta review. Open-PR overlap index currently finds no other PR touching either changed file.