Skip to content

refactor(workers): reuse environment write results - #168939

Merged
steipete merged 1 commit into
mainfrom
codex/worker-store-reads-r4
Oct 11, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/worker-store-reads-r4

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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 eec5e318ecaa95def03d5c27254d12db149856fa. 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 38ced6eb78481f61e55f45a5c74d334cb8e8a2a8 reproduces it on AWS. Its test injector still matches git cat-file blob after #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.

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Oct 11, 2026
@steipete
steipete marked this pull request as ready for review October 11, 2026 06:27
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses SQLite write results and passes environment records directly to the existing shape validator.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent; validation evidence is limited to reported tests and checks rather than a shipped-entry-point artifact.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored internal refactor is outside the ordinary contributor proof gate; supplied validation consists of reported focused tests and static checks, with no shipped-entry-point execution claimed by this review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
Reason: The maintainer-authored direction reduces unnecessary store work while keeping result shapes, validation points, and authority ownership intact.

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
Reviewed head: b23e3b48d0d0f48b68cc0d5f2e9658c187671e44

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway 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
Loading

Technical review

Best 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

  • Committed environment projection and shape validation keeps the original intent (c768bd1: Move inventory SQL into workers while preserving validated committed facts and transactional authority.)
  • Direct attachment and transition kernels keeps the original intent (052efb3: Bind kernels directly to the existing worker transaction while retaining identity predicates and host admission.)
  • Discarded environment update results keeps the original intent (c768bd1: Share guarded mutations and validated environment results; callers that discard the result can use the same guarded update directly.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c768bd1 adds src/gateway/worker-environments/store-mutations.ts:72 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c768bd125a14; files: src/gateway/worker-environments/store-mutations.ts)

PR surface

Source -14. Total -14 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 45 59 -14
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 45 59 -14

Review metrics

Metric Value Why it matters
Production versus tests Production +45/-59 LOC; tests +0/-0 LOC The net reduction removes redundant reads and forwarding without adding a parallel owner or test maintenance.

Labels

Label changes:

  • add P3: This is an internal cleanup with no intended user-visible behavior change or demonstrated urgent defect.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is an internal cleanup with no intended user-visible behavior change or demonstrated urgent defect.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 11, 2026, 2:34 AM ET / 06:34 UTC.

@steipete
steipete merged commit 4ea3e6b into main Oct 11, 2026
192 of 203 checks passed
@steipete
steipete deleted the codex/worker-store-reads-r4 branch October 11, 2026 07:56
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant