Repository navigation
refactor(gateway): split worker environment service by ownership - #122138
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 1:54 PM ET / 17:54 UTC. ClawSweeper reviewWhat this changesThe PR splits Gateway worker-environment lifecycle, credential delivery, access, and worker-turn RPC handling into owner-specific modules while retaining a coordinating facade. Merge readinessNo concrete patch-introduced defect was found in the authority or lifecycle split. This maintainer-owned, security- and availability-sensitive refactor should remain open for exact-head CI completion and maintainer approval. Priority: P2 Review scores
Verification
How this fits togetherGateway provisions remote worker environments, issues their credentials, admits worker RPCs, and manages their teardown. Session placement requests flow through the facade to provider, tunnel, state-store, and worker-turn owners. flowchart LR
A[Gateway session placement] --> B[Worker environment facade]
B --> C[Provider lifecycle]
B --> D[Credential broker]
B --> E[Environment access]
B --> F[Worker turn RPC]
C --> G[Provider and state store]
D --> G
E --> G
F --> G
Decision needed
Why: Source review found the expected authority and lifecycle fences, but the change redistributes security- and availability-critical behavior across new owners and carries the repository’s maintainer label. Before merge
Agent review detailsSecurityNone. PR surfaceSource +846, Tests -229, Other -2. Total +615 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the facade as the sole owner of serialization and shutdown, with the extracted modules retaining their current narrow owner boundaries, then merge after exact-head validation and maintainer sign-off. Do we have a high-confidence way to reproduce the issue? Not applicable: this is an internal ownership refactor, not a report of a separately reproducible user failure. Is this the best way to solve the issue? Yes: the split follows the existing owner boundaries while the facade retains shared serialization and shutdown; source review found no narrower change that would make the monolith independently reviewable. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d9766c3d5723. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
c7a2399 to
9bfa22e
Compare
9bfa22e to
4e9b4bc
Compare
b56726b to
d90c587
Compare
|
Merged via squash.
|
…nclaw#122138) * refactor(gateway): split worker environment service by ownership * refactor(gateway): derive environment intent at the contract owner * chore(lint): ratchet max-lines baseline after worker-service split * style(gateway): prune unused symbols after worker-service split * refactor(gateway): narrow worker-service seam exports * chore(plugin-sdk): refresh API baseline
What Problem This Solves
src/gateway/worker-environments/service.tsmixed provider lifecycle, credential delivery, tunnel/desktop access, and security-sensitive worker-turn authority in one 2,036-line composition root. That ownership blur made worker admission, placement, terminal-fence, and turn-claim logic harder to review safely.Why This Change Was Made
The service is split by ownership while keeping shared
KeyedAsyncQueueserialization, active-operation tracking, reconciliation scheduling, and shutdown draining in the facade. Worker authority checks and their inline invariant comments move intact intoworker-turn-rpc.ts; placement gate types move to their owner. Desktop observation remains a dynamic import insideenvironment-access.ts.A pure
deriveEnvironmentIntentnow owns both deterministic IDs inservice-contract.ts. All consumers use it directly, the former service export is removed without a compatibility alias, and the last production static value import ofservice.tsis gone.User Impact
No intended user-visible behavior change. The split preserves provisioning, reconciliation, credential, tunnel/desktop, admission, placement, ACK, inference, session-tool, and shutdown semantics while making their owners independently reviewable. Every implementation module is below the 700-line production limit, and both prior max-lines exceptions are removed.
Evidence
pnpm build— passed; no[INEFFECTIVE_DYNAMIC_IMPORT]warning.provider-provisioning.test.tspassed 33/33.src/worker/worker.fault-injection.test.ts— 7/7 passed.pnpm check:import-cycles— 0 runtime value cycles.pnpm check:madge-import-cycles— 0 cycles.pnpm lint:tmp:export-name-collisions— passed.pnpm check:wrapper-shadowing— passed, 30/30 baseline.pnpm plugin-sdk:surface:check— passed, 152 public entrypoints / 4,866 exports.pnpm check:max-lines-ratchet --base origin/main— passed, baseline shrank by two entries.pnpm check:test-types— core test types passed after correcting the shared fixture declaration; extensions lane could not acquire the shared local check lock before the repository timeout.node scripts/check-changed.mjs— formatting, max-lines, dependency, wildcard-export, duplicate-coverage, and preliminary architecture gates passed; it stopped on broad unrelated Plugin SDK API hash drift across 16 untouched entrypoints. The dedicated Plugin SDK surface guard is green, so no unrelated baseline was regenerated.Raw
git diff --numstat origin/mainclassification:The positive production delta is the explicit narrow injected interfaces and composition wiring required to preserve one shared lock/drain owner without introducing a shared-context back-module. Authority bodies themselves were moved, not expanded or simplified.