Skip to content

refactor: localize single-consumer internal preparation - #180329

Merged
steipete merged 13 commits into
mainfrom
deslop/z25-90-internal-surface-20261015
Oct 22, 2026
Merged

steipete merged 13 commits into
mainfrom
deslop/z25-90-internal-surface-20261015

Conversation

@steipete

@steipete steipete commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Internal command, Gateway, and plugin operations still route through private single-consumer preparation frames and an unnecessary provider module.

User Impact

No intended user-visible change, migration, or operator action. Public SDK, CLI, configuration, protocol, and persisted-data contracts stay unchanged.

Why This Change Was Made

Keep preparation in its existing consumer: Gateway publication and embedding operations, CLI registration/output and asset publication, attendance/resolver work, and plugin setup/formatting. Shared helpers and lazy module boundaries remain. OpenCode Go replay sanitization moves into its existing stream owner; its retained behavioral assertions move to the public plugin path instead of keeping a test-only production export.

Net production LOC: 274 removed across 20 production files; 24 files total including two shrink-only ratchets. Tests shrink by 36 net lines as the sanitizer coverage moves into the existing public-path fixture and one obsolete suppression entry disappears. Moved implementation bodies receive no deletion credit. The assertion baseline tightens from nine to seven for the sessions registrar's two removed casts; the suppression allowlist drops a stale Gateway test-helper entry already removed on main by #180176. This is the reduced area slice of the original 522-line family after the import-graph-scoped CI rollback below.

Security and authority checks, cancellation and lease cleanup, native runtime/model consent and verification, Matrix visible-mention spoof protection, durable user writes, exact diagnostics and trust notices, cache identity inputs, and provider request behavior remain. The standalone session memory backend and all Phase E machinery/tests are untouched.

Best-effort tradeoffs accepted

None added. This cut removes internal frames, parameter plumbing, and redundant parsing of already-prepared pure timestamp facts, not security, durability, realistic-concurrency, integrity, or failure-handling guards. Existing best-effort policies remain unchanged.

Evidence

Focused owner and consumer tests passed serially with one worker and isolated HOME/OpenClaw/XDG state. Retained changes cover Gateway embedding/publication, stream providers, Matrix mention handling, llama.cpp setup, memory-wiki import, Zalo formatting, CLI registration/output and asset publication. Original CLI proof passed 246 cases across 13 files; final Meet/Twitch proof passed seven selected cases across two files, including the registered attendance tool and cancellation/timeout continuation. The other 56 Meet cases were deliberately unselected, not newly skipped.

Targeted native typechecks, typed lint, formatting, line-cap checks, and independent Codex review through P2 passed for each packet. Final pre-push checks cover the suppression/assertion ratchets, PR-wrapper/eager-import closure, and runtime/static cycles. Hosted CI on the pushed exact head is the broad proof; no local build, broad suite, whole-graph typecheck, live provider/service, Windows execution, or new performance measurement is claimed. Existing public-path sanitizer coverage was extended rather than adding another fixture; hosted CI supplies its CI-time measurement.

No intended visual change: plugin asset publication mechanics and output bytes are preserved; no browser UI, styling, or markup is changed.

CI attribution and scoped rollback

Initial exact-head run 39726615349 failed three leaves. Both daemon suites reproduce with the same signatures on clean actual CI main parent 67b60de: three node-daemon-runtime cases reject the stale Node 26.8.1 probe fixture, and eleven node-cli/daemon cases reject the same fixture against the new 26.12.1 security floor. Neither suite, runtime guard, nor determining runtime-selection owner was changed by this PR. They are inherited, not claimed fixed.

The global competing-WAL ownership case expected an ambiguous-hardlink refusal but CI received database is locked. One serial isolated head/main-parent replay passed on both sides, so attribution remains inconclusive. Per campaign rule 8, all 16 changed files reachable from that test's complete runtime import closure (including dynamic imports) were restored to fetched main; the other 24 PR paths are outside that closure. The dropped 248-line slice is retained on deslop/z25-parked-backup-import-closure-20261015, without a PR. No SQLite policy, assertion, timeout, retry, or skip was changed, and the passing replay is not represented as a fix. Rollback proof passed 524 focused tests across 33 files, six targeted native typechecks, and independent review through P2. The repair receives one push and fresh exact-head CI; prior-head results remain prior-head evidence.

The final initial-run leaf also timed out four Memory Core background-reload cases. The reduced PR changes none of the 11,078 files in that test's runtime import closure, including dynamic imports and its explicit native-host/Memory Core module-loader roots. This is inherited-by-import-graph attribution, not a claim that the timeout is fixed; the memory test and all backend machinery are unchanged.

@clawsweeper

clawsweeper Bot commented Oct 22, 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 22, 2026 05:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-22T05:58:40.764995Z 6a1dcd7 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 22, 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: 6a1dcd71709690b3d7b8a26aeccb4491997ed798
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/web-push-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix channel: zalouser Channel integration: zalouser gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling channel: twitch Channel integration: twitch extensions: moonshot extensions: memory-wiki plugin: google-meet extensions: opencode-go extensions: llama-cpp size: XL labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR moves private preparation logic into its existing consumers and consolidates OpenCode Go sanitizer coverage.

Example: OpenCode Go handles a kimi-k2.6 request containing replayed reasoning fields.

  • Before: A separate private sanitizer removes unsupported fields and preserves a nonempty assistant message.
  • After: The existing stream owner performs the same sanitization, covered through the plugin test path.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Source review and retained owner coverage support the refactor, but unresolved hosted validation limits confidence in readiness.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored internal refactor is outside the ordinary contributor proof gate; supplied validation describes owner and consumer tests, with no shipped-entry-point or live-provider execution claimed.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
Reason: Maintainer direction approves reducing private preparation plumbing, and the diff removes machinery without adding a competing owner, configuration option, or public contract.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this maintainer-authored refactor open; the pinned diff preserves the inspected contracts, and no actionable introduced defect was found.

Priority: P3
Reviewed head: 7cb34c28d4f1c1b86f0a3cd314dbce5885c35cf9

Before merge

  • Complete next step - Establish whether the backup ownership and daemon-runtime failures also occur on the base, then resolve the exact-head CI gate without weakening its assertions.

Findings

None.

Agent review details

How this fits together

CLI, Gateway, agent, and plugin operations consume configuration and prepared runtime facts, enforce existing boundaries, and produce requests, filesystem effects, diagnostics, or command results.

flowchart TD
  A[CLI and Gateway entry points] --> B[Existing operation owners]
  C[Configuration and prepared facts] --> B
  B --> D[Authority and validation checks]
  D --> E[Provider and filesystem operations]
  E --> F[Results and diagnostics]
Loading

Technical review

Best possible solution:

Retain the existing owners and preserved contracts while removing their private forwarding and preparation frames.

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

This is a behavior-preserving refactor, so there is no reported product defect to reproduce; review used source, retained tests, history, and hosted check annotations without executing target code.

Is this the best way to solve the issue?

The change follows existing ownership boundaries, removes the replaced private paths, and preserves distinct validation, cancellation, authority, and cleanup behavior.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Skill loading and MCP preparation keeps the original intent (b7b46ad: The skill-loading history, followed across both earlier paths, establishes root-confined file reads and later prepared-content reuse; those protections and MCP filtering/fingerprint inputs remain.)
  • OpenAI-compatible embedding preparation keeps the original intent (4d89e00: The generic core provider serves reusable OpenAI-compatible embedding endpoints; subsequent SecretRef and destination-isolation repairs remain in the localized implementation.)
  • Web Push recipient authority keeps the original intent (20a6147: Device/profile-bound delivery requires current pairing, role, scope, preference, and session authority before provider I/O; inlining retains that authority owner and its predicates.)
  • Managed llama.cpp setup keeps the original intent (9b95e87: Hardware-aware setup and later configured-model repairs preserve selected inventory, embedding intent, explicit consent, verified artifacts, and previous configuration on refusal.)
  • OpenCode Go replay sanitization keeps the original intent (d22bcfc: Kimi rejects unsupported reasoning replay fields and parts; the stream owner retains the same sanitization and nonempty reasoning-only placeholder.)
  • Gateway start repair keeps the original intent (e80fe94: Start-time repair must not retarget an installed service or discard its environment provenance; the same target comparison still precedes install planning.)
  • Worktree provisioning keeps the original intent (0f3cab7: Provisioning uses admitted source/destination operations, exclusive copies, and live mutation guards while leaving existing user-owned files untouched.)
  • Harness diagnostics and Zalo formatting keeps the original intent (e1dbb59: Prior consolidation retained lifecycle outcomes and cleanup distinctions; Zalo's parser-owned formatting contract is separately established by refactor(zalouser): compile blocks from CommonMark IR #113590, and both implementations retain their outputs.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e1de807 adds src/skills/loading/local-loader.ts:24 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e1de807e34f3; files: src/skills/loading/local-loader.ts)
  • Ayaan Zaidi: Raw commit 4f1f91d adds src/skills/loading/local-loader.ts:24 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 4f1f91ddd862; files: src/skills/loading/local-loader.ts)
  • Bob: Raw commit 4d89e00 adds src/plugins/openai-compatible-embedding-provider.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 4d89e00c5093; files: src/plugins/openai-compatible-embedding-provider.ts)

PR surface

Source -522, Tests -36, Other 0. Total -558 across 40 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 36 1233 1755 -522
Tests 3 29 65 -36
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 40 1263 1821 -558

Review metrics

Metric Value Why it matters
Production versus test LOC Production +1233/-1755, net -522; tests +29/-65, net -36. The reduction comes from removing private preparation plumbing and consolidating existing sanitizer assertions; the assertion baseline is excluded.

Labels

Label changes:

  • add P3: This is internal maintenance with no intended user-visible behavior change or established urgent regression.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is internal maintenance with no intended user-visible behavior change or established urgent regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • 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 22, 2026, 1:30 AM ET / 05:30 UTC.

@openclaw-barnacle openclaw-barnacle Bot removed the agents Agent runtime and tooling label Oct 22, 2026
@steipete
steipete merged commit b977c60 into main Oct 22, 2026
144 checks passed
@steipete
steipete deleted the deslop/z25-90-internal-surface-20261015 branch October 22, 2026 05:50
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
)

* refactor(core): inline private skill and MCP loading frames

* refactor(gateway): inline sole-use provider and publication frames

* refactor(workspace): inline sole-use preflight and provisioning frames

* refactor(plugins): inline generic embedding request frames

* refactor(providers): fold single-consumer stream frames into owners

* refactor(matrix): fold single-consumer mention frames into owner

* refactor(core): fold private usage and activation frames into callers

* refactor(runtime): fold sole-use identity and lifecycle frames into owners

* refactor(plugins): localize prepared setup and rendering context

* refactor(cli): localize single-consumer command preparation

* refactor(plugins): localize attendance and resolver preparation

* test: tighten assertion and suppression ratchets

* refactor: isolate cleanup from inconclusive backup failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant