Skip to content

refactor(core): consolidate runtime shape owners - #177169

Merged
steipete merged 2 commits into
mainfrom
deslop/z33-7-runtime-shape-owners-20261015
Oct 19, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/z33-7-runtime-shape-owners-20261015

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Measured clone groups spread small copies of error aggregation, worker transaction admission, private identity propagation, retained Gateway work, record grouping, replay scanning, cache invalidation, and Claw trust-review projection across core runtime owners. Maintaining those copies separately makes their real policy differences harder to see.

What changed

Reuse existing owners for admitted writes, canonical-path cache invalidation, transcript replay scans, artifact-envelope validation, and grouping. Move repeated pure mechanics to private core owners, migrate their consumers completely, and delete the superseded node-host error module. Grouping stays in its existing plugin-record owner; error aggregation belongs to the existing policy-free internal error-graph owner. Domain-specific authority, cancellation, source validation, error messages, transaction receipts, and shutdown settlement remain with their original owners.

This is an area-sized slice of widely imported owners, with 70 production paths (71 paths including the 48-line leaf contract suite). The separate filesystem and media families are not included. Against the pinned base, production changes are 534 added / 932 removed: 398 net production lines removed. Tests add 48 lines. This is a below-500 owner/area split under the campaign's widely imported helper rule; no unrelated cuts are added to reach a quota.

No public Plugin SDK surface, CLI/config/protocol/persisted shape, dependency, schema, durability, retention, or permission change. Plugins do not import core internals. The standalone Phase E session-memory backend and its machinery/tests are untouched.

Best-effort tradeoffs accepted

No security or durability guard is removed. Invalid internal transcript-commit input may now fail normalization or JSON serialization before opening the database rather than afterward: valid callers already supply the typed prepared input, and opening a database for malformed internal data is not a supported effect. Failure remains visible and no write occurs. All transaction/commit admission, operation labels, receipt values, FIFO ordering, and write-capable shutdown settlement remain intact.

Evidence

The preceding formatted 398-net candidate was independently reviewed with no actionable P0–P2 findings. Its wrapper-inventory gate then correctly failed on two newly introduced helper paths. The repair reuses existing retained owners without changing PR tooling or expanding its inventory; four fewer net production lines are removed and the production-path count falls by nine. Fresh complete-candidate P0–P2 review is scoped-clean. Post-repair proof passed three targeted native typechecks, all five leaf error-contract cases, all five selected wrapper/inventory cases, 28 consumer cases across four files (30 pattern-filtered), all 38 grouping cases across three files, zero runtime value cycles, zero Madge cycles, and all 14 lint-suppression cases. Formatting and diff whitespace checks passed. The author simplify pass retains the distinct policy adapters rather than widening helpers to erase them.

The earlier 304-line subset passed 340 focused cases across 39 files. For the additional 94-line subset, targeted native typechecking of 24 roots passed. Separate focused selections passed 39 cleanup cases across four files (real stdio relay, transcript stop/drain, inference lifecycle), 56 cache cases across six files, eight skill/trust cases across three files, and 103 grouping cases across eight files. The skill and grouping selections filtered 23 and 115 cases respectively; no test definitions were skipped or weakened. These overlapping proof selections are reported separately, not summed into an inflated total. All execution uses isolated state, nice -n 10, and one Vitest worker. Hosted CI on the exact published head supplies broad proof; no broad local build/typecheck/E2E was run.

The dependency-free detector completed again in one low-priority process on exact published head 12ec4aa9afab224d6019d5d9ee6f1c13348af501: 23,338 production files and 4,263,172 physical lines. The measured settled-rejection groups s-87c1d2268528 and s-e7c7ca8ad8cd are absent. Its remaining 1,977 exact and 67,689 structural groups include declarations, manifests, intentional mirrors and other unreviewed families; those counts are discovery inventory, not removable-line totals or an exhaustion claim.

Current CI repair

The corrective published head 6fe246765d821122f9a24deb6cb4a07a3d356711 completed CI 39238593580 successfully. The complete paginated exact-head inventory contains 128 successful, 49 skipped, one neutral and two cancelled checks, with none pending or failed. The cancelled runs are superseded PR-metadata dispatch/context checks; the replacement context check passed. The required CI gate, production/test typechecks, typed lint, Docker seed, PostgreSQL conformance and selected Node suites passed. This is new-head hosted proof; the earlier failed run and load-limited local provisioning attempt below remain accurately recorded, not relabeled passing.

Published-head CI 39226217144 failed. The full check inventory and failed logs are retained; it is not green. Two lint jobs name this PR's identity-carrier method references and a map-spread projection. Frozen wrapper extraction also cannot find the newly introduced retained-work helper; this affects the eager import-closure and worktree-provisioning suites. Those failures are PR-caused. The corrective change marks the closure methods receiver-independent, consumes fresh review records without an extra copy, and places the unchanged retained-work class in the existing extracted async-work owner. PR tooling, inventories, tests and suppressions are not expanded or weakened.

The seven-file correction passed fresh independent P0–P2 review, formatting, an 11-root targeted native typecheck, focused type-aware lint, all 19 eager import-closure cases, 21 selected lifecycle cases across four files, and 14 selected skill/trust projection cases across three files. Lifecycle and projection selections filtered 26 and 22 other cases, respectively; no test definition changed. Runtime value cycles and Madge cycles are both zero; all 14 suppression-audit cases passed. Local native provisioning was stopped after 711,817 ms: its first case exceeded the unchanged 120-second timeout, the second passed, and the remaining cases were not completed. That load-limited attempt is retained as incomplete proof, not a defect attribution or a pass. Corrective-head hosted CI must supply broad provisioning proof.

The PR-context jobs also rejected the former generic section headings; this body now uses the required authored problem/evidence sections. The Docker seed job reached spawn docker ENOENT, which leaves Docker proof missing rather than green. A separate update-candidate schema test failure was investigated through a serial replay of filesystem CI's exact merge and base. Both reproduce the same stale diagnostic expectation after the fixture was moved to final generation verification by #177130. The precise test-only main repair landed as 841081d after all nine schema cases, targeted native types/lint/format and independent P0–P2 review passed; the unrelated main-owned UI suppression-inventory mismatch is recorded separately. That replay does not waive any other current-head failure. All failures will be individually attributed before landing; none is waived by this note.

@clawsweeper

clawsweeper Bot commented Oct 19, 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.

@steipete
steipete marked this pull request as ready for review October 19, 2026 08:55
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T10:39:13.341215Z 6fe2467 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 6fe246765d821122f9a24deb6cb4a07a3d356711
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/inline-usage.worker.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/sandbox/registry-lifecycle.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/client-credential-store.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling size: XL labels Oct 19, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR consolidates repeated runtime mechanics into shared internal owners while preserving domain-specific policies.

Example: MCP shutdown encounters two cleanup failures.

  • Before: The transport constructs an AggregateError using its local aggregation code.
  • After: The shared error owner constructs the same AggregateError with the same failures and message.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful consolidation with focused consumer evidence, but a confirmed wrapper execution regression blocks merge.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored internal refactor is outside the ordinary contributor proof gate; supplied evidence describes consumer harnesses, while exact-head CI exposes the wrapper regression.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Repeated runtime mechanics make policy differences harder to maintain consistently.
Reason: The maintainer has approved the direction through authorship, and the consolidation removes duplicated mechanics while retaining domain policy owners.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this maintainer-authored PR open: the consolidation is useful, but its new retained-work import breaks extracted PR-wrapper execution.

Priority: P2
Reviewed head: 12ec4aa9afab224d6019d5d9ee6f1c13348af501

Before merge

  • Include the retained-work helper in the wrapper inventory (P1) - This import makes an already-inventoried wrapper dependency require src/shared/gateway-retained-work-scope.ts, but scripts/pr-lib/wrapper-components.txt does not contain that new file. Trusted wrapper extraction therefore omits it and fails with ERR_MODULE_NOT_FOUND before lease bootstrap or worktree provisioning can run. Exact-head CI confirms both failures. Add the helper to the existing inventory and rerun the wrapper closure and provisioning tests.

Findings

  • [P1] Include the retained-work helper in the wrapper inventory — src/agents/worktrees/run-end-lifecycle.ts:8
Agent review details

How this fits together

Gateway, agent, CLI, and worker owners supply domain operations to shared helpers that preserve error reporting, transaction admission, private identity propagation, and shutdown settlement.

flowchart TD
  A[Gateway and agent callers] --> B[Domain policy owners]
  C[CLI and node callers] --> B
  B --> D[Shared runtime mechanics]
  D --> E[Worker transaction owner]
  D --> F[Retained work scopes]
  D --> G[Collected errors]
Loading

Technical review

Best possible solution:

Keep the consolidation and add its retained-work helper to the existing trusted-wrapper inventory.

Do we have a high-confidence way to reproduce the issue?

Exact-head CI records the missing-module failure, and source inspection confirms the imported helper is absent from the extraction inventory; no target code was executed locally.

Is this the best way to solve the issue?

The shared owners preserve the inspected domain contracts, and completing the wrapper inventory is the smallest repair for the confirmed regression.

Full review comments:

  • [P1] Include the retained-work helper in the wrapper inventory — src/agents/worktrees/run-end-lifecycle.ts:8
    This import makes an already-inventoried wrapper dependency require src/shared/gateway-retained-work-scope.ts, but scripts/pr-lib/wrapper-components.txt does not contain that new file. Trusted wrapper extraction therefore omits it and fails with ERR_MODULE_NOT_FOUND before lease bootstrap or worktree provisioning can run. Exact-head CI confirms both failures. Add the helper to the existing inventory and rerun the wrapper closure and provisioning tests.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b8cf2f347f75.

Provenance checked

  • Worker write admission and receipts keeps the original intent (refactor(state): share admitted worker write envelopes #167552: The existing worker owner centralizes transaction and commit grants while retaining physical-store ordering and settlement.)
  • Retained Gateway work keeps the original intent (refactor(agents): settle worktree run-end snapshots through the worktree worker #164824: Accepted worktree cleanup must settle before worker teardown; the extracted scope retains that lifecycle and its cleanup-failure assertion.)
  • Sandbox and voice settlement keeps the original intent (fix(talk): settle accepted voice work before shutdown #166795: Accepted persistence survives cancellation and shutdown; caller-specific admission and reopen handling remain outside the shared scope.)
  • Private execution identity carriers keeps the original intent (916aca1: Execution lineage is carried privately without widening public spawn options; separate WeakMaps and exact object association remain.)
  • Transcript replay scanning keeps the original intent (fix(agents): preserve sessions_spawn transcript payloads #82203: Signed-thinking replay requires real matching tool results; the shared scanner preserves the replay predicate and leaves legacy normalization enabled for its original callers.)
  • Claw artifact and skill trust review keeps the original intent (feat: add Claws as ordinary agents and resources #171623: Claw Add retains exceptional trust consent and exact release identity checks; CLI-specific action identity validation remains in its adapter.)
  • Private store creation keeps the original intent (4706053: Local credential storage requires private filesystem ownership; the extraction retains directory preparation and leaves credential ACL and file admission checks with the caller.)
  • Grouping and cache invalidation keeps the original intent (216b71a: The existing grouping owner preserves insertion order; cache callers retain their original canonical-path comparison and non-open lifecycle invalidation.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test test/scripts/eager-import-closure.test.ts test/scripts/pr-worktree-provision.test.ts --maxWorkers=1
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 623d8e0 adds src/agents/worktrees/run-end-lifecycle.ts:84 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 623d8e02a5d8; files: src/agents/worktrees/run-end-lifecycle.ts)

PR surface

Source -394, Tests +48. Total -346 across 71 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 70 538 932 -394
Tests 1 48 0 +48
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 71 586 932 -346

Review metrics

Metric Value Why it matters
Production versus test LOC Production +538/-932; tests +48/-0 The net production reduction comes from shared mechanics and removed copies; the added tests independently protect rejection identity and aggregation order.

Labels

Label changes:

  • add P2: This is routine internal consolidation with a focused maintainer-tooling repair.
  • add merge-risk: 🚨 automation: The new runtime import breaks trusted-wrapper extraction and PR worktree provisioning, as confirmed by exact-head CI.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is routine internal consolidation with a focused maintainer-tooling repair.
  • merge-risk: 🚨 automation: The new runtime import breaks trusted-wrapper extraction and PR worktree provisioning, as confirmed by exact-head CI.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 execution lanes are retired.

Reviewed October 19, 2026, 5:19 AM ET / 09:19 UTC.

@steipete
steipete merged commit 7bf2329 into main Oct 19, 2026
190 of 192 checks passed
@steipete
steipete deleted the deslop/z33-7-runtime-shape-owners-20261015 branch October 19, 2026 11:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations gateway Gateway runtime merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. security-sensitive-changed size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant