Repository navigation
refactor(workers): reuse environment write results - #168939
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 changesThis PR reuses SQLite write results and passes environment records directly to the existing shape validator. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored cleanup preserves the store contracts while removing redundant reads and forwarding; no actionable introduced defect was found. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway worker-environment requests enter the SQLite worker transaction owner, which returns mutation results and publishes committed environment, credential, and attachment facts to the host projection. flowchart LR
A[Gateway callers] --> B[Environment store facade]
B --> C[SQLite worker transaction]
C --> D[Mutation kernel]
D --> E[SQLite state]
C --> F[Committed projection]
F --> A
Technical reviewBest possible solution: Land the focused refactor through the existing workflow once required checks pass. Do we have a high-confidence way to reproduce the issue? This is a refactor rather than a bug report; source inspection confirms the redundant read-back and forwarding paths. Is this the best way to solve the issue? Reusing existing write results and validation ownership is a focused solution that preserves transactional checks and read-time rejection. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f2e649da67fa. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -14. Total -14 across 7 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel 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 Reviewed October 11, 2026, 2:34 AM ET / 06:34 UTC. |
## What Problem This Solves Worker-environment writes immediately read back rows that are already available, and shape validation carries a redundant positional forwarding wrapper. ## User Impact No intended behavior change. Attachment identity, credential epochs, mutation row-count checks, and read-time rejection of invalid native overlays remain enforced. No schema or migration change. ## Why This Change Was Made Attachment creation and closure use SQLite RETURNING for their result rows. Credential renewal and duplicate-owner recovery use the existing update operation when the returned environment would be discarded. Shape validation accepts its record directly, eliminating duplicated field forwarding while retaining each validation point. Production delta: **−14 LOC across seven files**. Four redundant SELECT paths are removed; no new cache is introduced and no latency improvement is claimed. ## Evidence - 60 tests passed across store, worker-store, projection and attachment-service suites on isolated AWS; `--maxWorkers=1`, 113.86 s wall. - Independent Codex review: clean through P1. - Core and scoped Gateway test typechecks, type-aware lint and export collision checks passed. Production Knip scan passed. Full-tree Knip reports the untouched `src/cli/run-main.test-support.ts: readActiveGatewayLockPortMock`; identically reproduced on exact main `0a0692029c638adccf1e2f6aa95e03927fc96c94`. No candidate-only finding. - No tests changed; no new timers, worker pins or fixtures. AWS proof run: `run_e600d416555d0306cbaad6cce3dd9830`; exact-main Knip run: `run_7dff59f73ced96d99e632b4a80c329ae`. ## CI disposition The failed stopped-inspection case in CI run 38118128965 is inherited from main: exact main `daeb6fb26d519d98824fd192ae7c64c9165a1780` reproduces it on AWS. Its test injector still matches `git cat-file blob` after openclaw#168921 switched the reader to `--batch`; none of this PR’s seven files changes that path. A separate test-only repair passed all 12 tests in the file (33.83 s wall), scoped types, and type-aware lint. Landing uses the authorized inherited-CI exception. Native allocation stalled over 16 minutes without dispatching a merge, so submission uses an exact-head REST squash.
What Problem This Solves
Worker-environment writes immediately read back rows that are already available, and shape validation carries a redundant positional forwarding wrapper.
User Impact
No intended behavior change. Attachment identity, credential epochs, mutation row-count checks, and read-time rejection of invalid native overlays remain enforced. No schema or migration change.
Why This Change Was Made
Attachment creation and closure use SQLite RETURNING for their result rows. Credential renewal and duplicate-owner recovery use the existing update operation when the returned environment would be discarded. Shape validation accepts its record directly, eliminating duplicated field forwarding while retaining each validation point.
Production delta: −14 LOC across seven files. Four redundant SELECT paths are removed; no new cache is introduced and no latency improvement is claimed.
Evidence
--maxWorkers=1, 113.86 s wall.src/cli/run-main.test-support.ts: readActiveGatewayLockPortMock; identically reproduced on exact maineec5e318ecaa95def03d5c27254d12db149856fa. No candidate-only finding.run_e600d416555d0306cbaad6cce3dd9830; exact-main Knip run:run_7dff59f73ced96d99e632b4a80c329ae.CI disposition
The failed stopped-inspection case in CI run 38118128965 is inherited from main: exact main
38ced6eb78481f61e55f45a5c74d334cb8e8a2a8reproduces it on AWS. Its test injector still matchesgit cat-file blobafter #168921 switched the reader to--batch; none of this PR’s seven files changes that path. The test-only repair landed in #168975 and passed all 12 tests in the file (33.83 s wall), scoped types, and type-aware lint. Landing uses the authorized inherited-CI exception. Native allocation stalled over 16 minutes without dispatching a merge, so submission uses an exact-head REST squash.