Repository navigation
refactor: move skill upload database work to the shared worker - #155283
Conversation
|
Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 9:09 AM ET / 13:09 UTC (Revision 5). ClawSweeper reviewWhat this changesMoves skill-upload staging, expiry cleanup, and installation-lease database operations into the shared SQLite worker while retaining archive installation on the Gateway host. Merge readiness✅ Ready for maintainer review The PR remains useful and has no blocking findings. The earlier expiry defect is fixed, and the updated evidence resolves the outstanding test-cost request; current main still lacks this cutover. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway accepts skill archives through upload requests and stores their chunks until installation. The upload store coordinates SQLite staging and installation leases, then supplies an archive to the existing installer. flowchart TD
A[Upload requests] --> B[Gateway validation]
B --> C[Upload store]
C --> D[Shared SQLite worker]
D --> E[Expiry and lease checks]
E --> F[Stored archive and chunks]
F --> G[Host archive installer]
G --> D
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +298, Tests +514, Docs +9. Total +821 across 15 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Complete the existing worker migration while preserving upload formats, installation policy, admitted deadlines, and exact-owner cleanup. Do we have a high-confidence way to reproduce the issue? Yes, source inspection traces registered upload requests to synchronous SQLite staging and lease operations on current main; this review did not execute a runtime reproduction. Is this the best way to solve the issue? Yes, extending the existing shared worker is the narrow ownership-preserving approach, and the patch keeps archive installation and persistent contracts with their existing owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8c001ebde933. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Preserve the reviewed upload expiry checks while retaining shared lifecycle cleanup fixes from main. Keep agent lease cleanup scoped to its owner and add creation-identity evidence to the unchanged Windows PID assertion on failure.
|
Merged via squash.
|
…law#155283) * fix(skills): move upload staging and install leases into workers * test(state): discriminate retired lease cleanup commands * fix(skills): check upload expiry after worker admission
What Problem This Solves
Skill archive uploads still performed staging, expiry cleanup, and installation lease SQL on the Gateway thread, despite exposing asynchronous methods.
User Impact
Upload database work now runs in the shared SQLite worker. Upload and installation-lease expiry are evaluated after admission, so queue waits cannot admit expired uploads or revive an expired lease. Archive contents, offsets, idempotency, install permissions, TTL durations, and storage formats retain their contracts; no migration or operator action is required.
Why This Change Was Made
The upload owner now sends finite staging and lease operations to the existing shared worker while keeping archive materialization and installation callbacks on the host. Installation joins accepted renewals before consumption or release, and failed cleanup retains recovery custody. Release checks physical database identity and the exact lease owner, including when two paths refer to the same database. Requests carry durations and immutable input facts; the worker samples the clock inside the admitted transaction for begin, chunk, claim, renewal, consumption, and expiry deletion.
Evidence
The current source is
dbf40a85ae0320a40b68c098c321565605b49cc3. It carries the previously qualifiedb6d2f51upload feature onto main6110505e6d475eff9e58029a2506177a07833728, including its shared lifecycle teardown fixes. Ten upload-owned source/test postimages remain byte-identical tob6d2f51. The shared worker contract retains both state-lease and upload cleanup operations; the retired-agent cleanup implementation and test match main exactly.Before publication, a source audit against main
875aaaffcb7571385dbaca24fa56eef2f195896ffound no overlap with the 15 changed paths and a conflict-free merge preserving every candidate postimage. Main has since added worker-generation retention, so local proof remains bound to the pinned candidate. Normal fresh-head CI run 35727378585 subsequently completed successfully on this head with all 158 jobs settled, including all five Windows jobs.A controlled real-worker FIFO proof on the preceding
3e2f3e7source reproduced late chunk acceptance, late installer entry, expired-lease renewal, and expired-lease consumption. The unchanged admission owner held an earlier real operation across the persisted deadline; no fake clock, substituted worker result, or production test seam was used. All four controls pass on the carried candidate with Node 24.21.0 and Bun 1.4.2.Current focused validation passes 102 tests across seven files, with two Windows-only cases skipped on macOS: 15 upload kernel cases, 24 store/lifecycle cases, 14 registered Gateway cases, 47 tooling cases, one retired-agent cleanup case, and one native source-import case. An initial attempt using external-volume scratch was rejected by the unchanged filesystem permission guard and stopped; the affected store/lifecycle cases passed using macOS's normal private temporary directory. No permission, assertion, or deadline was weakened. The complete selected changed-check gate and fresh independent P2 review passed. The gate includes core types, all 25 core-test type shards, root-test types, typed lint, formatting, export scans, and the selected consistency guards.
The requested current isolated test costs were measured once per file, serially, on this exact clean head with Node 24.21.0 and pnpm 12.4.0 using
pnpm test <file> --maxWorkers=1. External monotonic wall time includes the complete command, preparation, execution, and cleanup; existing compiler caches were reused. Both file hashes and the source tree were unchanged before and after each command. These are local command costs, not isolated CI seconds.src/skills/lifecycle/upload-store-commit.test.tssrc/skills/lifecycle/upload-store.test.tsBoth commands exited zero, below the roughly 120-second per-job budget. The kernel cases exercise admitted transaction deadlines and actual archive/metadata separation; the store cases use real workers to verify chunk ordering, installation authority, renewal, expiry, and materialization cleanup. SQL mocks cannot establish that these operations cross the worker boundary or preserve physical database and lease ownership. The 30.202-second store wall time includes preparation and final worker-generation verification; its entire Vitest run was 22.37 seconds. No favorable timing rerun was selected. The completed hosted CI run is linked above; its shared shard durations are not presented as isolated per-file measurements.
The earlier Windows CI run 35679715678 failed the tooling fixture's historical numeric-PID liveness assertion. A bounded native Windows diagnostic preserved that assertion and passed 47 tooling cases with one skip. Its four fake CLI processes were absent at observation, and its inner command Job recorded empty membership, leader exit, and closed output. This is non-reproduction, not proof of PID reuse or a production fix. The diagnostic guest was Windows Server 2022 with 2 CPUs; the original CI used Windows 2025 with 16 CPUs. Replaying the original ordered file group stopped on an earlier watcher test's unchanged 120-second timeout before reaching the PID case. Both leases were stopped and independently verified released.
This candidate retains only a failure diagnostic in the existing Windows test: it records the fake CLI's native creation time and includes the currently observed creation time in the unchanged PID assertion message. Production process-management code is unchanged. All five Windows jobs in the fresh-head CI run passed; this does not establish PID reuse as the cause of the historical failure. The older four-file instrumented Windows source and receipts remain separate evidence.
Earlier
3e2f3e7CI passed after a test-only cleanup-union discriminator correction. Main now types that mock to its actual agent-cleanup owner, so this carry uses main's exact implementation and test instead of retaining the superseded correction.The following source/build/runtime results are retained historical evidence for
f392014d023cc645e34540a550bfe03a7e70dfc5, before the six-file expiry correction:Historical f392014 isolated test costs
Measured once per file, serially, with
pnpm test <file> --maxWorkers=1on macOS, Node 24.21.0 and pnpm 12.4.0. External monotonic wall time includes the complete maintained command, preparation, test execution and cleanup. No retries, source edits, build command, gate suite or review repeat was used.Source before and after every command:
f392014d023cc645e34540a550bfe03a7e70dfc5, clean tree4a8ea4f672e3ef338617f6e687f394e759bceff2. The receipt includes all four file hashes before and after each command. These measurements are historical. The current expiry correction changes the commit-kernel and store test files; their new tests are covered by the separate current-source cohort above.src/gateway/server-methods/skills-upload.test.tssrc/skills/lifecycle/upload-store-commit.test.tssrc/skills/lifecycle/upload-store-lifecycle.test.tssrc/skills/lifecycle/upload-store.test.tsAll four commands exited zero. Each is below the roughly 120-second job budget. These are local command durations, not CI seconds.
The Gateway file needs the explanation required above 30 seconds of test time. Its reported case durations total 56.378 seconds: the added registered staging check is 12.006 seconds, and the thirteen pre-existing cases total 44.372 seconds in this candidate run. The pre-existing commit/replay case alone took 26.397 seconds and retains the existing full skills-handler import; the new staging case imports the narrower upload handler. The file verifies actual registered RPC dispatch, worker placement, installation, terminal invalid-upload cleanup, and replacement recovery. Mocked SQL or isolated kernels cannot prove that the registered handlers invoke the worker or that installation preserves the previous skill. This is attribution of existing suite work on the candidate, not an independently measured old-revision speed comparison.
The kernel file retains six pre-existing cases and receives the existing metadata/blob test moved from the store file. The moved first case, which includes cold database initialization, took 16.313 seconds; the other six reported case durations total 0.616 seconds. The new lifecycle file's four reported case durations total 4.765 seconds and exercise accepted renewal settlement, release/close failure recovery, and physical-path aliases with real workers. The store file retains its twenty-two remaining behavior cases after the metadata case moves; their reported durations total 12.611 seconds. No cases or assertions were weakened.
Cached worker-output preparation was included in wall time: 10.457, 7.959, 5.974, and 7.691 seconds respectively. Reporter component timings are descriptive and should not be added to external wall time. No favorable timing rerun was selected, and no test-cost change is inferred from these historical measurements.