Repository navigation
refactor: reuse plugin source captures across Doctor phases - #167535
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: needs maintainer review before merge. What this changesDoctor reuses verified plugin source snapshots across maintenance phases while keeping each phase’s module files, callbacks, and cleanup independent. Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review This PR retains useful work absent from current main, with no actionable patch findings. It addresses part of the broader Doctor latency problem and is ready for normal landing checks. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDoctor loads plugin repair contracts while checking and repairing an installation. The plugin capture subsystem supplies verified private source files to those contracts and releases them when their owners finish. flowchart TD
A[Doctor maintenance phases] --> B[Source snapshot owner]
C[Plugin files and dependency selections] --> B
B --> D{Inputs unchanged?}
D -->|Yes| E[Reuse retained snapshot]
D -->|No| F[Capture current source]
E --> G[Private files and fresh callbacks]
F --> G
G --> H[Settle cleanup and release custody]
Technical reviewBest possible solution: Keep source reuse within the existing capture owner and track remaining cold-capture and maintenance latency in the canonical issue. Do we have a high-confidence way to reproduce the issue? Yes: the published-upgrade volume scenario and recorded phase measurements establish repeated capture overhead, and current-main source supports that mechanism; this read-only review did not execute it. Is this the best way to solve the issue? Yes for the scoped optimization: reuse extends the existing capture/recovery owner while keeping callback instances, private files, admission, and cleanup independent. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 447144510b89. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +494, Tests +420, Docs +9. Total +923 across 10 files. Added test files: 1. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
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 HistoryReview history (4 earlier review cycles)
Reviewed October 9, 2026, 1:01 AM ET / 05:01 UTC (Revision 5). |
|
Merged via squash.
|
…#167535) * refactor(plugins): retain source custody across Doctor phases * refactor(plugins): keep captured source facts in verification owner
Related: #166526
What Problem This Solves
Idempotent Doctor repeatedly captures unchanged plugin sources across its original-state, config, convergence, and session-repair phases.
User Impact
Doctor reuses immutable source custody while each phase keeps private module files, fresh callbacks, and independent native admission and lease settlement. No config, schema, public SDK, or dependency change is introduced by this refactor.
The complete published-upgrade survivor now passes on the merged head: Doctor took 218s against the computed 717s budget, followed by a successful Gateway restart, readiness probes, identical history samples, and final state-survival checks. The state-derived budget comes unchanged from main's #167482; this is not a pass against the former fixed 60s threshold. Cold capture remains expensive, so the broader latency issue stays open.
Why This Change Was Made
The existing generation capture/recovery owner retains an unexecuted immutable source snapshot for one Doctor invocation. Original source, directory membership, dependency resolution, missing inputs, metadata selection, and effective symlink targets are fingerprinted before reuse; changed inputs receive a new capture. Destination hashing, containment, receipt checks, callback-generation independence, and cleanup-before-exit remain with their existing owners.
The follow-up merges main
50d7eb1b7fbc65d5552ac3c82d65dcb512e15b42without rebasing. There were no conflicts. A second deslop pass removes the redundant recovery-disposal and verifier-callback factories and deduplicates the capture argument contract. It removes 22 production lines, reducing net growth from +516 to +494. No invalidation fact or reachable integrity/lifecycle guard was deleted: each protects a distinct reproduced regression or lifetime contract.Exact-head CI then exposed a type-only cycle between file capture and source lookup. The shared
PluginCapturedSourceFacttype now lives besidePluginSourceInputin the existing verification module. This is a four-line relocation with no executable or public SDK change. Core/covering types, lint, Madge (zero cycles), and renewed independent reviews pass. The full checks/build/live scenario were repeated for the repaired head in a new clean checkout and state fixture on the same sole AWS lease; the earlier556f8eefpass remains prior-head evidence.Exact delta against merged main: production +673/-179, tests +420/-0, docs +9/-0. Detached custody, private forks, and complete invalidation facts require the remaining growth; the artifact module itself shrinks. The separate fs-safe batching change is excluded: fs-safe stays 0.24.2.
Evidence
Final head:
3e223ad15abe51e356a15b879d9f0c075f3df33f(tree2d98dfc8f9427e60282530d9cce8c40718a434b6).cbx_31fe7810a9e3, final runrun_c5afc03d04149346201112ca9f3571f4: complete proof exited 0. The published 2026.9.4 updater succeeded; all 4,800 volume sessions, 23,890 volume events, and 2,200 volume cron jobs survived.GITHUB_ACTIONS=false.3e223adhead with no findings; it keeps the broader latency issue classified as a partial fix. Exact-head CI run 37878122416 reached a terminal cancelled/fail-fast result: the sole originating failure is the inherited model-catalog type cycle described below. The PR cycle is fixed, and this branch passes Madge with zero cycles. The first follow-up run on556f8eefhad reported both cycles; it is retained as failed prior-head evidence.bindCliQuestionAnswerAuthority,prepareSessionEventTargetForHost,readSessionEntryCreationTransition, andRESTART_CONTINUATION_CONTEXT_PREFIX. The latter two also appear in the full-tree scan. These files are outside this PR. No guard or baseline exception was added. Builds retain the same existing UI gzip warning (365.2 KiB > 364.7 KiB).8879e5efca8cef5c3e223adCI remains blocked by later main, not green. Job
check-guards-architecture(113651596616) reports onlysrc/agents/prepared-model-catalog-fingerprints.ts↔src/agents/prepared-model-catalog-worker.ts. CI checked merge4603c983c08116dce9e5e72aa86f12a40478af5f, combining this PR with mainae64a98a4eb1bc45765290f5b9988c75ce7eb8ca. Both cycle files are byte-identical between that base and merge (blobsd1ca094f1b9076343ac18594df5011ed6f8f2f7fand08ea2c6e09e08328da4b26ebce5614510484f8ba). The cycle was introduced on later main by811d442afa2c1103ed10f33f3b64fb1afa7675f8; it does not exist on our pinned50d7eb1base. The originating job and aggregate CI gate failed; 25 downstream jobs were cancelled. No rerun, guard weakening, baseline exception, or green-CI claim was used. This main-side blocker remains for landing coordination.These are single-machine observations. The final head also incorporates main; no deslop or type-relocation performance improvement is claimed. The earlier fixed-budget failure and skipped restart are superseded by the complete final proof above, not relabeled as passing.
Live command and exact provenance
Final evidence excerpts:
The successful phase ledger includes
assert-volume-idempotence,gateway-restart,gateway-restart-probes,gateway-restart-volume-history, andassert-restarted-survival. Both history artifacts contain eight identical samples. Budget and timing values come from persisted-state measurements and the completed scenario artifacts.Fresh c7a.8xlarge, same baseline AMI, Node 24.21.0, pnpm 12.5.1, Docker 29.8.2, fs-safe 0.24.2; no credential hydration. Exact public parents plus the checked 877-byte repair bundle reconstructed the original commit. HEAD, tree, main ancestry, and all tracked bytes were verified before bootstrap. The supported no-sync route avoids the previously measured slow local uplink. No source/provenance guard was bypassed. External exact-head instrumentation adds only Doctor trace/timeline environment variables.
Candidate package SHA256:
84c8e4ca57f1c950269a29574252d312296db1e266527c2856433a8350a16747. Complete remote payload: 48m20.264s. Exact-head CI is terminal. The sole lease was stopped successfully; authoritative inspection reports released and the final AWS list contains no active owned lease.Historical comparison: baseline lease
cbx_922fa3782c66, runrun_210138ec8e89aaff53c86d5d9f5365b1, head8879e5ef4b98e7ff17b0ac04e7695f66f3e143b2; earlier PR leasecbx_286a1084e280, runrun_c601af015e78103d01153c766d58ec5c, headca8cef5c656ab310ae027bc6f8590191cdc88395. Those prior leases are released.Exact module/type commands and test cost
pnpm tsgo:core pnpm tsgo:core:test --ci-graphs-json '["core-test-plugins-platform","core-test-commands-doctor","core-test-other"]' node scripts/run-vitest.mjs \ src/flows/doctor-health.legacy-update.test.ts \ src/flows/doctor-health.update.test.ts \ src/flows/doctor-health.managed-settlement.test.ts \ src/flows/doctor-health.managed-approvals.test.ts \ src/flows/doctor-health.update-schema.test.ts \ src/flows/doctor-health.deletion-recovery.test.ts \ src/flows/doctor-health.update-scope.test.ts \ src/flows/doctor-health.update-budget.test.ts \ src/flows/doctor-health.readonly-config.test.ts \ src/flows/doctor-health.dangling-workshop-index.test.ts \ src/flows/doctor-health.migration-refusal.test.ts \ src/flows/doctor-health.plugin-load.test.ts \ src/flows/doctor-health.test.ts \ src/flows/doctor-health.fleet-preflight.test.ts \ src/flows/doctor-health.nocow.test.ts \ src/flows/doctor-health.managed-admission.test.ts \ src/plugins/plugin-cache.retention.test.ts \ src/plugins/doctor-contract-registry.generation.test.ts \ src/commands/doctor-config-preflight.plugin-persistence.test.ts \ src/plugins/doctor-contract-registry.test.ts \ src/plugins/plugin-lifecycle-lease.test.ts \ src/commands/doctor-config-preflight.state-migration-input.test.ts \ src/commands/doctor-config-preflight.plugin-deferral.test.ts \ src/commands/doctor-config-preflight.pristine.process.test.ts \ src/commands/doctor-maintenance.schema-preflight.test.ts \ src/plugins/doctor-contract-registry.retained-config.test.ts \ src/plugins/plugin-generation-source-lookup.test.ts \ src/commands/doctor-config-preflight.process.test.ts \ src/commands/doctor-config-preflight.pending-read.test.ts \ src/commands/doctor-config-preflight.refusal.process.test.ts \ src/commands/doctor-config-preflight.admission.process.test.ts \ src/commands/doctor-config-preflight.state-migration.test.ts \ src/commands/doctor-config-preflight.unavailable-owner.test.ts \ src/commands/doctor-config-preflight.test.ts \ src/commands/doctor-config-preflight.schema-preparation.test.ts \ src/commands/doctor-config-preflight.runtime-owners.test.ts \ src/commands/doctor-config-preflight.plugin-action-inventory.test.ts \ src/commands/doctor-config-preflight.container-upgrade.test.ts \ src/plugins/plugin-cache.test.ts \ src/plugins/plugin-module-generation.interop.test.ts \ src/plugins/plugin-module-generation.native-layout.test.ts \ src/commands/doctor-config-preflight.recovery.test.ts \ src/plugins/plugin-module-generation.sdk.test.ts \ src/plugins/doctor-contract-registry.load-paths.test.ts \ src/plugins/plugin-module-generation.disposal.test.ts \ src/plugins/plugin-module-generation.test.ts \ src/commands/doctor/shared/post-core-plugin-convergence.test.ts \ src/plugins/doctor-contract-registry.selection.test.ts \ src/commands/doctor/shared/post-core-plugin-convergence.source-checkout.test.ts \ src/commands/doctor/shared/post-core-plugin-convergence.persistence.test.ts \ src/plugins/plugin-package-metadata-capture.test.ts \ src/plugins/doctor-contract-registry.state-migrations.test.ts \ src/plugins/doctor-contract-registry.unavailable-path.test.ts \ src/plugins/plugin-generation-artifact.native-reference.test.ts \ src/plugins/plugin-generation-artifact.test.ts \ src/plugins/plugin-module-generation.update.test.ts \ src/plugins/plugin-module-generation.bun.test.ts \ src/plugins/plugin-module-generation.sibling-assets.test.ts \ src/plugins/plugin-generation-artifact.streaming.test.ts \ src/plugins/plugin-generation-artifact.admission.test.ts \ src/plugins/doctor-contract-registry.custody.test.ts \ src/plugins/doctor-contract-registry.webhook-pins.test.ts \ src/plugins/plugin-native-admission-source-index.test.ts \ src/plugins/plugin-generation-source-inspection.test.tspnpm test src/plugins/doctor-contract-registry.custody.test.ts --maxWorkers=1: 8 tests, 13.10s wall.pnpm test src/plugins/plugin-generation-artifact.streaming.test.ts --maxWorkers=1: 28 tests, 13.38s wall. CI seconds will be recorded when available; the final AWS 64-file run took 457.56s.Exact numstat against merged main