Skip to content

refactor(plugins): derive private config types from schemas - #130414

Merged
steipete merged 2 commits into
mainfrom
codex/cleanup20k-private-schema-input-types-20260826
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/cleanup20k-private-schema-input-types-20260826

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Maintainer-requested cleanup of duplicate private configuration types in the Diffs, OpenShell, and MXC plugins. Hand-maintained input shapes repeat information already owned by the runtime schemas, while assertions hide the schemas' inferred result types.

Why This Change Was Made

Diffs derives its private input shape from the existing Zod schema. OpenShell and MXC use their already-validated parse results directly and delete the unused private type copies. Runtime schema definitions, defaults, legacy aliases, normalization, permissions, manifests, and exported resolved types are unchanged. The assertion-safety baseline shrinks by exactly the three removed casts.

The first hosted CI run also exposed a pre-existing timing-dependent file-transfer test. Its parent process tried to observe a short-lived child's working directory through 200 polling attempts and 5,000 padding files. The assertion failed before the test retargeted the symlink; it did not observe an unsafe directory listing. The repaired test preserves the entire real worker program, prefixes a child-local wrapper that performs the real chdir and then retargets the fixture symlink synchronously, and checks the actual retarget plus the approved-only listing. All canonical-path, inode, enumeration, and metadata checks still execute unchanged. The child is joined and cleaned up before fixture removal.

Test provenance: the polling-based regression was introduced in #129762, authored and merged by @joshavant on August 26, 2026 (424521a3d3924c943f441da1b799f3563450662f). The regression's security invariant is retained; only its race-prone scheduling is replaced.

The separate Windows packaging failure was already fixed by #130387. This branch was rebased onto a main revision containing that fix; no duplicate packaging repair is included.

Production: +4/-61, net -57 lines. Test-only CI repair: +35/-30, net +5. Assertion baseline: +1/-3, net -2, excluded from production. No generated, lockfile, dependency, or documentation changes. Exported input types in other plugins were explicitly excluded because stricter consumer compiler settings could make their optional-property contract observable.

User Impact

No user-visible or public API change. Operators retain the exact same accepted configuration, errors, defaults, and security settings. This is AI-assisted internal maintenance.

Evidence

  • Existing configuration tests pass before and after: Diffs 33, OpenShell 18, MXC 8 assertions. These include manifest/schema equality, legacy Diffs aliases, viewer URL restrictions, managed OpenShell paths, MXC containment/network settings, and timeout bounds.
  • Complete before/after TypeScript output is byte-identical for both JavaScript and public declarations in all three modules, including with strict and exactOptionalPropertyTypes enabled. Declaration sizes are 1,144 / 645 / 726 bytes respectively; emission diagnostics are zero.
  • An in-memory semantic TypeScript program using the pinned, installed Zod 4.4.3 declarations proves equality and bidirectional assignability of the old and inferred private shapes under repository compiler settings, with zero diagnostics. Stricter exact-optional private-field widening does not escape into any public declaration.
  • Real Linux Node 24.19.0 proof: Blacksmith Testbox run 33023814464, lease tbx_01m106s7cymkmzcevn49bhc1xf, wrapper terminal exit 0. Six focused files passed all 88 assertions, including both Linux-only directory-binding cases and directory-fetch/invocation-policy siblings.
  • The same exact Linux candidate passed 20 real-child retarget iterations. An in-memory negative control changed enumeration and metadata reads to absolute paths under the same retarget hook; it returned the replacement secret and a standalone exact-entry assertion rejected it. The unchanged Vitest predicates also reject that result; this was not a literal mutated Vitest run. This proves test sensitivity, not an observed production vulnerability. The original worker program bytes are preserved.
  • Exact remote source identity: public base 02a60e0d871480b7c9db87cb59eec5583e2ec3ce, candidate tree b12a89187f9a7b241ba47861f30d3f5470293144, full five-file patch SHA-256 09b1690fc0dc475ea145217c87b952b74b714c1286779e691dc604ca310f1b46. The canonical complete dependency fingerprint matched the hydrated install, all workspace package source trees matched, and all 772 actual Vitest workspace/SDK aliases resolved into the owned candidate. The temporary remote worktree was removed and the lease stopped after success.
  • Assertion-safety ratchet passed on the exact Linux candidate: 4,238 governed files / 13,245 grandfathered assertions. Formatting and git diff --check pass.
  • Complete five-file pre-commit Codex review finished successfully with no actionable findings (confidence 0.98). Its single, untruncated pass included the full patch and 19 complete owner, caller, worker, test, and contract files. Commit 7e280b0d1264d420f0bb01f4eb39670356406802 preserves the reviewed full candidate tree exactly. A separate authenticated read-only Codex review of that published head also finished successfully with no findings (confidence 0.98), covering the complete five-file patch, 26 whole context files, and both actual Linux proof datasets. Source identity remained unchanged after review exit.
  • Ordinary pull-request CI run 33025280107 completed successfully on exact head 7e280b0d1264d420f0bb01f4eb39670356406802, including both Windows test lanes, all three changed-plugin configuration lanes, assertion-baseline ratchets, production/test types, lint, dependencies, package boundaries, and openclaw/ci-gate.

Focused command: OPENCLAW_VITEST_MAX_WORKERS=3 node scripts/run-vitest.mjs extensions/diffs/src/config.test.ts extensions/openshell/src/config.test.ts extensions/mxc/test/config.test.ts extensions/file-transfer/src/node-host/dir-list.test.ts extensions/file-transfer/src/node-host/dir-fetch.test.ts extensions/file-transfer/src/shared/node-invoke-policy.dir-list.test.ts. Ratchet command: node --import tsx scripts/check-assertion-safety-ratchet.mts --base 02a60e0d871480b7c9db87cb59eec5583e2ec3ce.

ClawSweeper's earlier replay showed all 33 + 18 + 8 configuration tests passing, but its output matcher incorrectly expected one aggregate 59 passed line. The repository wrapper prints per-shard totals and a final shard summary. No test output was rewritten to satisfy that matcher. Its rank-up request to investigate the failed Windows and changed-extension jobs is addressed by the canonical Windows fix and deterministic test repair above; the new exact-head normal CI must still be green before native preparation and merge.

Local shared dependency drift previously prevented full declaration preparation; no local dependency reconciliation was performed. Clean installed hosted lint/type gates remain required. No new live-provider behavior or package boundary is introduced, and emitted runtime code and public declarations are unchanged.

Latest ClawSweeper review (August 27, 00:03 UTC) reviewed this exact head and found no actionable patch or security findings; its rank-up request to finish exact-head hosted CI is now satisfied by the successful run above. Its newer live replay printed all 73 assertions passing across four files and a final successful three-shard summary in 31.93 seconds, but its terminal harness had a 30-second wait and expected an individual test name not printed by the normal reporter. The independent 88-assertion Linux run and exact-head hosted CI provide completed proof; no output, timeout, or assertion was altered for that replay. Its generic stored-data warning points only to test-fixture serialization in dir-list.test.ts: no production persistence, schema, migration, or upgrade contract changed.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 8:03 PM ET / August 27, 2026, 00:03 UTC.

ClawSweeper review

What this changes

This PR derives Diffs’ private config input from its Zod schema, removes redundant parsed-value casts in OpenShell and MXC, and makes a Linux file-transfer binding test deterministic.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still contains the duplicated private config types and casts, while this member-authored, maintainer-labeled PR removes them without changing the resolved runtime shapes; exact-head hosted checks are still incomplete.

Priority: P3
Reviewed head: 7e280b0d1264d420f0bb01f4eb39670356406802

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused net-negative cleanup with a credible deterministic test repair; completion of exact-head CI remains the outstanding merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored maintenance PR is exempt from the external-contributor proof gate; the PR body nevertheless supplies a redacted hosted Linux test run for the changed test path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored maintenance PR is exempt from the external-contributor proof gate; the PR body nevertheless supplies a redacted hosted Linux test run for the changed test path.
Evidence reviewed 7 items Current main does not already contain the cleanup: Current main still defines the hand-maintained Diffs input type and casts parsed schema output, so the central refactor remains unmerged.
Schema-derived config remains private and preserves the resolver boundary: The PR uses the existing Diffs schema input type and forwards successful parsed data to the existing shape resolver; runtime callers continue to consume only resolver outputs.
OpenShell and MXC retain their existing validated-config flow: Both resolvers still parse through their existing strict schemas before applying defaults, and their runtime callers keep using resolved config objects.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/diffs/src/config.test.ts extensions/openshell/src/config.test.ts extensions/mxc/test/config.test.ts extensions/file-transfer/src/node-host/dir-list.test.ts

Result: FAIL (failed) — step 1 run node scripts/run-vitest.mjs extensions/diffs/src/config.test.ts extensions/openshell/src/config.test.ts extensions/mxc/test/config.test.ts extensions/file-transfer/src/node-host/dir-list.test.ts: previous terminal command was still running after 30 seconds: "node scripts/run-vitest.mjs extensions/diffs/src/config.test.ts extensions/openshell/src/config.test.ts extensions/mxc/test/config.test.ts extensions/file-transfer/src/node-host/dir-list.test.ts"

[test] starting test/vitest/vitest.extension-diffs.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130414-gKjrWy/target

 ✓  extension-diffs  extensions/diffs/src/config.test.ts (33 tests) 445ms

 Test Files  1 passed (1)
      Tests  33 passed (33)
   Start at  00:04:22
   Duration  8.39s (transform 6.13s, setup 942ms, import 6.64s, tests 445ms, environment 0ms)

[test] starting test/vitest/vitest.extension-misc.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130414-gKjrWy/target

 ✓  extension-misc  extensions/openshell/src/config.test.ts (18 tests) 53ms

 Test Files  1 passed (1)
      Tests  18 passed (18)
   Start at  00:04:31
   Duration  7.65s (transform 5.88s, setup 942ms, import 6.30s, tests 53ms, environment 0ms)

[test] starting test/vitest/vitest.extensions.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130414-gKjrWy/target

 ✓  extensions  extensions/file-transfer/src/node-host/dir-list.test.ts (14 tests) 839ms
 ✓  extensions  extensions/mxc/test/config.test.ts (8 tests) 24ms

 Test Files  2 passed (2)
      Tests  22 passed (22)
   Start at  00:04:39
   Duration  8.43s (transform 8.24s, setup 2.21s, import 7.58s, tests 863ms, environment 0ms)

[test] passed 3 Vitest shards in 31.93s

Assertions:

  • FAIL expect_output: keeps enumeration bound after the checked path is retargeted

How this fits together

Bundled plugins validate operator configuration with schemas before resolving the values consumed by their runtime hooks. The file-transfer node worker binds a directory as its working directory before it enumerates entries, and the accompanying test verifies that a symlink retarget cannot redirect that enumeration.

flowchart LR
A[Plugin configuration] --> B[Plugin schema]
B --> C[Validated configuration]
C --> D[Resolved plugin settings]
D --> E[Plugin runtime]
F[Approved directory] --> G[Bound directory worker]
G --> H[Directory entries]
I[Symlink retarget test] --> G
Loading

Before merge

  • Resolve merge risk (P1) - The supplied exact-head CI state is incomplete, so the deterministic test and type cleanup still need the normal hosted checks to finish green before merge.
  • Complete next step (P2) - This is a maintainer-authored protected-label PR awaiting normal exact-head CI, not a ClawSweeper repair candidate.
Agent review details

Security

None.

PR surface

Source -57, Tests +5, Other -2. Total -54 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 4 61 -57
Tests 1 35 30 +5
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 3 -2
Total 5 40 94 -54

Review metrics

Metric Value Why it matters
Production versus test delta production +4/-61 (net -57); tests +35/-30 (net +5); assertion baseline +1/-3 (net -2) The production change is net-negative private-type cleanup; the only growth is a deterministic regression-test harness.

Stored data model

Persistent data-model change detected: serialized state: extensions/file-transfer/src/node-host/dir-list.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the schema-owned private typing and deterministic binding regression coverage, then merge after the current head passes its required hosted checks.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the schema-owned private typing and deterministic binding regression coverage, then merge after the current head passes its required hosted checks.

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

Not applicable to the central private-type cleanup. The accompanying Linux test race has a source-backed deterministic replacement and supplied hosted-run evidence, but this read-only checkout has no installed dependencies to rerun it locally.

Is this the best way to solve the issue?

Yes. Deriving private input types from the existing schema and using parsed values directly removes duplicated declarations without adding a public configuration or compatibility surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against cb1d892b3d9a.

Labels

Label justifications:

  • P3: This is a low-risk internal cleanup with an accompanying test-stability repair and no stated user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored maintenance PR is exempt from the external-contributor proof gate; the PR body nevertheless supplies a redacted hosted Linux test run for the changed test path.

Evidence

What I checked:

  • Current main does not already contain the cleanup: Current main still defines the hand-maintained Diffs input type and casts parsed schema output, so the central refactor remains unmerged. (extensions/diffs/src/config.ts:24, cb1d892b3d9a)
  • Schema-derived config remains private and preserves the resolver boundary: The PR uses the existing Diffs schema input type and forwards successful parsed data to the existing shape resolver; runtime callers continue to consume only resolver outputs. (extensions/diffs/src/config.ts:24, 7e280b0d1264)
  • OpenShell and MXC retain their existing validated-config flow: Both resolvers still parse through their existing strict schemas before applying defaults, and their runtime callers keep using resolved config objects. (extensions/openshell/src/config.ts:175, 7e280b0d1264)
  • Directory-binding test exercises the production worker contract: The revised test retargets only after the worker's real chdir hook, then asserts the worker returned the approved entry and not the replacement entry; the worker performs identity checks before relative enumeration. (extensions/file-transfer/src/node-host/dir-list.test.ts:81, 7e280b0d1264)
  • Existing configuration contracts are covered by focused tests: The Diffs, OpenShell, and MXC suites assert schema validation, defaults, legacy aliases, managed paths, and timeout or containment behavior around the unchanged resolvers. (extensions/diffs/src/config.test.ts:76, 7e280b0d1264)
  • Feature-history routing: History shows sustained work by steipete in Diffs and OpenShell config surfaces, Paul Campbell in MXC configuration, and the linked file-transfer binding work was merged as commit 424521a. (extensions/diffs/src/config.ts:24, 424521a3d392)

Likely related people:

  • steipete: History shows repeated Diffs and OpenShell configuration work, including current-main refactors on these surfaces. (role: recent area contributor; confidence: high; commits: 236a6b815c18, c9ab095099f9; files: extensions/diffs/src/config.ts, extensions/openshell/src/config.ts)
  • Paul Campbell: The MXC configuration and sandbox feature history identifies Paul Campbell as the contributor for its introduction and subsequent configuration work. (role: MXC feature contributor; confidence: high; commits: 008f04a65650, 9f8d81bd1a95; files: extensions/mxc/src/config.ts)
  • joshavant: The deterministic test repair follows the directory-binding coverage merged in the linked file-transfer PR. (role: related security-test contributor; confidence: medium; commits: 424521a3d392; files: extensions/file-transfer/src/node-host/dir-list.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the required exact-head hosted checks to complete green.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-26T21:19:02.833Z sha 1ece994 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T22:01:57.593Z sha 1ece994 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
Replace race-prone child-cwd polling with a synchronous fixture retarget after the real chdir, preserving the full worker and security assertions. Shrink the assertion-safety baseline for the three casts removed by the schema cleanup.
@steipete
steipete force-pushed the codex/cleanup20k-private-schema-input-types-20260826 branch from 1ece994 to 7e280b0 Compare August 26, 2026 23:56
@steipete steipete self-assigned this Aug 26, 2026
@steipete
steipete merged commit 162e8d1 into main Aug 27, 2026
145 of 147 checks passed
@steipete
steipete deleted the codex/cleanup20k-private-schema-input-types-20260826 branch August 27, 2026 00:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…#130414)

* refactor(plugins): derive private config types from schemas

* test(ci): make directory binding proof deterministic

Replace race-prone child-cwd polling with a synchronous fixture retarget after the real chdir, preserving the full worker and security assertions. Shrink the assertion-safety baseline for the three casts removed by the schema cleanup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: diffs extensions: openshell maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. plugin: mxc rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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