Repository navigation
refactor: consolidate coercion ownership - #122299
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 8:05 PM ET / August 12, 2026, 00:05 UTC. ClawSweeper reviewWhat this changesThis PR consolidates equivalent coercion logic into canonical normalization helpers and existing Plugin SDK facades across core, bundled plugins, tooling, and the Control UI. Merge readinessKeep open for maintainer review. The prior numeric-facade blocker appears addressed, but exact-head source and the required upstream Codex contract cannot be independently inspected here, and required CI is still running. Priority: P3 Review scores
Verification
How this fits togetherNormalization converts untyped config, protocol, and stored values into safe runtime shapes. Core and the UI consume normalization-core directly, while bundled plugins must use Plugin SDK facades. flowchart LR
A[Raw configuration and protocol values] --> B[Canonical normalization helpers]
B --> C[Plugin SDK facades]
C --> D[Bundled plugins]
B --> E[Core and Control UI]
D --> F[Validated runtime behavior]
E --> F
Decision needed
Why: Repository policy requires direct Codex-source inspection when the patch changes Codex behavior based on its upstream contract; this read-only environment cannot satisfy that gate. Before merge
Agent review detailsSecurityNone. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve the single number-runtime route, then merge only after exact-head CI and direct review of the Codex-dependent migrations confirm the documented parity claims. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a refactor, so the relevant evidence is behavioral parity and public SDK contract preservation rather than reproducing a user defect. Is this the best way to solve the issue? Unclear: current-source ownership supports the one-facade direction, but the exact head and its Codex contract evidence could not be independently inspected. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 72d55fc12a47. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
657ef67 to
fd20c51
Compare
fd20c51 to
91b4d43
Compare
91b4d43 to
f878bd9
Compare
|
Land-ready proof for This remains the best-fix shape: four canonical normalization owners, five narrow exports on existing Plugin SDK subpaths, integer options retained exclusively on the existing Evidence:
ClawSweeper items and rank-up move are addressed:
Known unrelated gap: No changelog, release, version, protocol, dependency override, or SQLite schema-version action is included. |
Centralize four canonical coercion helpers, migrate exact core and plugin duplicates through narrow Plugin SDK facades, and enforce declaration and plugin-normalization ownership boundaries. The sweep adds eight focused SDK exports while deleting more production and tooling code than it adds. User-visible behavior is unchanged except for safer equivalent object and UI parsing at existing boundaries.
Register resolveIntegerOption with the canonical function owner and extend the declaration-guard fixture so future local duplicates fail validation.
Remove the unshipped duplicate string-coerce exports and route every affected plugin consumer through the existing number-runtime contract.
Make boundary and declaration diagnostics recommend the canonical numeric facade, with failing-before coverage for both guidance paths.
|
Merged via squash.
|
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
OpenClaw still had many exact local coercion helpers and inline equivalents spread across core, plugins, scripts, and the Control UI. That duplicated ownership, allowed semantics to drift, and made it easy for new plugin code to bypass the public Plugin SDK normalization boundary.
This is the third maintainer-requested consolidation sweep. A semantic scan distinguished exact duplicates from provider-, protocol-, security-, migration-, and generated-code dialects so only behavior-equivalent paths moved.
Why This Change Was Made
The change adds four canonical normalization helpers—
filterStringEntries,filterStringRecord,safeParseJsonRecord, andtoStringifiedError—and migrates exact existing-helper equivalents across core, plugins, scripts, and UI while preserving owner-specific public names where they carry meaning. It adds five narrow callable exports on existing Plugin SDK subpaths; integer-option consumers continue to use the existingnumber-runtimefacade. No new subpath, wildcard, config, protocol, storage schema, or fallback surface is introduced.The enforcement side replaces scattered declaration exceptions with a structured canonical-owner registry: 72 banned names, 68 allowed declarations pinned to function kind, and explicit non-canonical exceptions reduced from 12 to 5. A zero-baseline plugin boundary now rejects direct production imports of normalization-core and requires the matching Plugin SDK facade.
User Impact
This is behavior-neutral cleanup for operators and plugin authors. Existing parsing and validation behavior is preserved, while object and UI boundary parsing use the same reviewed canonical contracts and future duplicate helpers or plugin boundary bypasses now fail validation.
No changelog, release, version, dependency override, protocol version, or SQLite schema version is changed.
Evidence
Final head:
34bcfbdf871c0d9cc2865433a549a598fca77a2dProduction/tooling/test/generated split:
Blacksmith Testbox proof on the preceding rebased patch: Actions run 31536389870, lease
tbx_01kzsadzmhwaaem84f2zmmn52p(stopped, completed). Later current-main conflicts were limited to generated API hashes, additive SDK export budgets, and preserving #107295's deletion of the now-externalized QQBot source; focused final-head proof is listed below.node scripts/check-changed.mjs --dry-runselected 43 checks across core, UI, plugins, scripts, tests, docs, and tooling.pnpm plugin-sdk:api:check,pnpm plugin-sdk:check-exports, andpnpm plugin-sdk:surface:checkpassed: 152 public entrypoints, 4,878 public exports and 2,931 public callable exports after retaining current-main's unrelated additions, 76 public wildcard re-exports, and zero forbidden subpaths.pnpm check:coercion-helperspassed with 68 allowlisted function declarations.pnpm lint:extensions:no-normalization-core-bypasspassed with zero violations.pnpm buildpassed all nine unified build invocations, 10 postbuild phases, 35 built plugin control-plane modules, all 152 public SDK subpaths, and Control UI performance budgets.filterStringRecordreturnsundefinedfor absent, non-record, empty, or all-non-string input, so provider config omission and auth-profile fingerprint behavior are unchanged.__rawfallback claim that does not exist in base or head.resolveIntegerOptionwas exported and migrated but absent from the canonical registry. The extended table-driven test failed before the fix, then passed after308a4fdccb5registered the canonical function owner; the final integrated autoreview is clean.isRecordonly to its outer metadata and nested preview boundaries; 393 focused UI chat/history/render tests passed.number-runtime, all affected plugins use that canonical route, and boundary/declaration diagnostics now recommendnumber-runtimefor numeric coercion. Owner, contract, and enforcement proof passed 510 focused tests; both guidance regressions failed before the fix and passed after it.git diff --checkpassed.Direct upstream Codex source was re-inspected after the rebase:
openai/codexcodex-rs/protocol/src/thread_id.rs:11-53for UUID-backed thread IDs, distinct from OpenClaw agent IDs.openai/codexsdk/typescript/src/exec.ts:246-332andcodex-rs/config/src/overrides.rs:9-98for non-array config objects and dotted TOML override paths.openai/codexcodex-rs/app-server-protocol/src/protocol/v2/thread_data.rs:193-233andcodex-rs/app-server/README.md:417-455for numeric thread timestamps.openai/codexcodex-rs/app-server-protocol/src/protocol/v2/item.rs:1442-1458for approvalitemId/optionalapprovalIdrouting.openai/codexcodex-rs/login/src/success_page.rs:106-128andcodex-rs/login/src/token_data.rs:71-99for JSON-object auth/profile claims.openai/codexcodex-rs/models-manager/src/manager.rs:29,codex-rs/models-manager/src/lib.rs:12-16, andcodex-rs/protocol/src/openai_models.rs:508-522for serde-backed model catalog records.Known unrelated gap:
packages/ai/src/package.e2e.test.tshas a pre-existing external-install failure on aworkspace:*dependency. The test andpackages/ai/package.jsonwere unchanged by this sweep before rebasing, the fresh changed gate/build are green, and this PR does not weaken or alter that E2E.