Repository navigation
refactor(cli): share message payload projections - #135319
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 12:10 PM ET / 16:10 UTC. ClawSweeper reviewWhat this changesThe PR moves repeated direct-then-nested message-ID projection into the shared outbound result contract and simplifies terminal payload formatting with regression coverage. Merge readinessKeep open. This maintainer-authored refactor cleanly consolidates duplicated CLI payload projection without changing delivery, authorization, configuration, or persistence behavior; no blocking correctness or security finding was found. Exact-head hosted CI is still incomplete. Priority: P3 Review scores
Verification
How this fits togetherThe message CLI invokes the outbound action runner, which returns a channel payload that is rendered either as machine-readable JSON or terminal text. The new shared resolver sits at that result boundary so both presentation paths select the same message ID. flowchart LR
A[Operator message command] --> B[Outbound action runner]
B --> C[Channel action payload]
C --> D[Shared message ID projection]
D --> E[CLI JSON output]
D --> F[Terminal text output]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -27, Tests +112, Other 0. Total +85 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single shared message-ID projection in the outbound result contract, retain the focused JSON and text boundary coverage, and merge only after exact-head CI passes. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors established CLI payload projection rather than reporting a separate current bug. Is this the best way to solve the issue? Yes. The outbound result contract is the common owner for the duplicated payload interpretation, while JSON and terminal-specific rendering remain in their respective callers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1b236dfc8625. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* refactor: consolidate command and cron preparation paths Keep one sub-CLI metadata/registration catalog, common cron payload updates, canonical agent migration visitors, and shared account-state projection. Trust typed internal adapters while retaining external validation, effect authority, cancellation settlement, supported migrations and path containment. Wave-5 y10: BELOW-500, 353 net production lines removed (+440/-793 in 19 files). Branch-only handoff for the coordinator's bundle; no standalone PR. Best-effort tradeoffs accepted: - Cron mid-setup reload recovery (#146582): synthetic retirement, no human incident. Setup may fail; the next invocation refreshes the cache. - Recursive shared preparation retry (#102494/#138337): synthetic concurrent callers; production serializes same-job work. Duplicate direct callers may share cancellation. Failed-owner eviction preserves the next sequential run. - Progress publication generation (#143621): synthetic held update/reset. Presentation dedupe may briefly be stale until a subsequent render/reset. - Doctor adapter schema mirror (#69919): malformed synthetic hooks. Invalid executable adapters fail visibly; missing-hook fallbacks and config checks stay. - Setup adapter schema mirror (#165492): typed internal union. Invalid internal adapters fail when used; both supported wizard forms remain. - Injected process schema mirror (#84381): malformed injection was not human SIGTERM report #71710. Invalid adapters fail registration; cancellation stays. - Loaded registry row revalidation/copy (#114942/#158830/#114476): rows already admitted/normalized. Corrupt trusted rows can fail; first-wins authority stays. - Custom compatibility duplicate check (#14223): all callers parse/type it. Hand-crafted invalid JS uses the default branch; external flags still reject it. - Log probe identity matching (#88159, superseded by #168587): abort now joins the sole probe, so replacement cannot race its result. Recovery/settlement stay. - Whole-config deep copy (#71218): no detached-copy incident. Structural copy updates agents/defaults; unrelated future mutation must respect config ownership. - Repeated plugin-root probes (#70012): no disappearing-root incident. Resolve roots once; root replacement can fail discovery. Symlink containment stays. - Second payload getter read (#135319): synthetic review/corpus, not a human report. Ordinary decoded records are read once; stateful accessors may differ. Proof: fresh independent review clean; core types, targeted lint/format, runtime and static cycles, assertion/line-cap ratchets, and suppression suite passed. Focused CLI cohort: 8 files / 41 tests passed. Earlier unchanged account/setup and cold-import checks passed. Cron and commands cohorts were interrupted after partial results; complete owner tests, payload merging, test-graph types, broad check-changed and build/smoke remain unproved at commit preparation. Unattributed local 120-second timeouts retained: two root-command-descriptions catalog cases and agent-via-gateway's Gateway attempt-budget case. No timeout, retry, skip or kept-behavior expectation changes. Env-name budget mismatch (455 vs 454) also exists at original HEAD and pinned main 7dccff5. All runtime proof used isolated HOME/OpenClaw/XDG state; Phase E untouched. * refactor: consolidate cron payload and lazy CLI paths Share daemon and cron method forwarding through the existing lazy binder, remove the cron CLI reexport shim, and consolidate normalization and merge handling without changing public fields, explicit clears, or effect authority. Remove the obsolete bundled discovery reentry mechanism and impossible Doctor issue helper. The full lane now removes 475 net production lines. Best-effort tradeoffs accepted: - Unknown Doctor issue variants supplied by hand-crafted JavaScript return the invalid value rather than a custom error. Typed local producers and exhaustive switches remain; reporting feature #95979 cites no human unknown-kind incident. - Synchronous bundled-module self-discovery may fail through the existing loader diagnostic instead of returning empty inventory. Commit 65f18d6 only pins injected Jiti reentry, not a human incident; ordinary caches remain. - Cron defaults trust staggerMs normalized earlier in the same synchronous call. No await or mutation boundary intervenes; externally supplied invalid values remain rejected by the normalizer. * fix(channels): retain replacement preview deduplication Withdraw the progress compositor generation removal after the Mattermost retiring-publication case failed CI and bounded serial head/base replays remained inconclusive under load. Restore that file exactly to the branch base and keep all Mattermost tests unchanged, following the campaign fallback. Prune the single obsolete mock-export allowance left by the removed bundled discovery reentry fixture. The local mock ratchet passes with 9586 factories. The remaining lane reduction is 471 net production lines across 25 paths.
…#173036) * refactor: consolidate command and cron preparation paths Keep one sub-CLI metadata/registration catalog, common cron payload updates, canonical agent migration visitors, and shared account-state projection. Trust typed internal adapters while retaining external validation, effect authority, cancellation settlement, supported migrations and path containment. Wave-5 y10: BELOW-500, 353 net production lines removed (+440/-793 in 19 files). Branch-only handoff for the coordinator's bundle; no standalone PR. Best-effort tradeoffs accepted: - Cron mid-setup reload recovery (openclaw#146582): synthetic retirement, no human incident. Setup may fail; the next invocation refreshes the cache. - Recursive shared preparation retry (openclaw#102494/openclaw#138337): synthetic concurrent callers; production serializes same-job work. Duplicate direct callers may share cancellation. Failed-owner eviction preserves the next sequential run. - Progress publication generation (openclaw#143621): synthetic held update/reset. Presentation dedupe may briefly be stale until a subsequent render/reset. - Doctor adapter schema mirror (openclaw#69919): malformed synthetic hooks. Invalid executable adapters fail visibly; missing-hook fallbacks and config checks stay. - Setup adapter schema mirror (openclaw#165492): typed internal union. Invalid internal adapters fail when used; both supported wizard forms remain. - Injected process schema mirror (openclaw#84381): malformed injection was not human SIGTERM report openclaw#71710. Invalid adapters fail registration; cancellation stays. - Loaded registry row revalidation/copy (openclaw#114942/openclaw#158830/openclaw#114476): rows already admitted/normalized. Corrupt trusted rows can fail; first-wins authority stays. - Custom compatibility duplicate check (openclaw#14223): all callers parse/type it. Hand-crafted invalid JS uses the default branch; external flags still reject it. - Log probe identity matching (openclaw#88159, superseded by openclaw#168587): abort now joins the sole probe, so replacement cannot race its result. Recovery/settlement stay. - Whole-config deep copy (openclaw#71218): no detached-copy incident. Structural copy updates agents/defaults; unrelated future mutation must respect config ownership. - Repeated plugin-root probes (openclaw#70012): no disappearing-root incident. Resolve roots once; root replacement can fail discovery. Symlink containment stays. - Second payload getter read (openclaw#135319): synthetic review/corpus, not a human report. Ordinary decoded records are read once; stateful accessors may differ. Proof: fresh independent review clean; core types, targeted lint/format, runtime and static cycles, assertion/line-cap ratchets, and suppression suite passed. Focused CLI cohort: 8 files / 41 tests passed. Earlier unchanged account/setup and cold-import checks passed. Cron and commands cohorts were interrupted after partial results; complete owner tests, payload merging, test-graph types, broad check-changed and build/smoke remain unproved at commit preparation. Unattributed local 120-second timeouts retained: two root-command-descriptions catalog cases and agent-via-gateway's Gateway attempt-budget case. No timeout, retry, skip or kept-behavior expectation changes. Env-name budget mismatch (455 vs 454) also exists at original HEAD and pinned main 89f8219. All runtime proof used isolated HOME/OpenClaw/XDG state; Phase E untouched. * refactor: consolidate cron payload and lazy CLI paths Share daemon and cron method forwarding through the existing lazy binder, remove the cron CLI reexport shim, and consolidate normalization and merge handling without changing public fields, explicit clears, or effect authority. Remove the obsolete bundled discovery reentry mechanism and impossible Doctor issue helper. The full lane now removes 475 net production lines. Best-effort tradeoffs accepted: - Unknown Doctor issue variants supplied by hand-crafted JavaScript return the invalid value rather than a custom error. Typed local producers and exhaustive switches remain; reporting feature openclaw#95979 cites no human unknown-kind incident. - Synchronous bundled-module self-discovery may fail through the existing loader diagnostic instead of returning empty inventory. Commit ca10460 only pins injected Jiti reentry, not a human incident; ordinary caches remain. - Cron defaults trust staggerMs normalized earlier in the same synchronous call. No await or mutation boundary intervenes; externally supplied invalid values remain rejected by the normalizer. * fix(channels): retain replacement preview deduplication Withdraw the progress compositor generation removal after the Mattermost retiring-publication case failed CI and bounded serial head/base replays remained inconclusive under load. Restore that file exactly to the branch base and keep all Mattermost tests unchanged, following the campaign fallback. Prune the single obsolete mock-export allowance left by the removed bundled discovery reentry fixture. The local mock ratchet passes with 9586 factories. The remaining lane reduction is 471 net production lines across 25 paths.
Message JSON and terminal output repeated payload-ID projection, alias selection and primitive summarization. They now share the payload projector and use smaller formatting helpers, retaining direct-before-nested IDs, trimming, table output and delivery outcomes.
The alias helper preserves the original short-circuit behavior, including returning a getter's second truthy read. An initial review caught a candidate regression here; the final implementation and maintained changing-getter test preserve the original behavior. Transport, authorization and stored data are unchanged.
Production: +65/-92 = -27 lines, including assertion-baseline bookkeeping. Tests: +128/-16 = +112 lines.
Validation: all56 final maintained message/formatter tests pass. Two additional immutable-corpus tests reproduce31,875 baseline bytes across14 JSON cases,29 formatter cases and3 getter scenarios. Those tests supply action results at the command boundary; they do not claim live provider I/O. Final type, lint, format and assertion checks pass, and a fresh isolated Codex high/P2 review is clean.
The actual source CLI rebuilt the dirty source and completed
message send --channel telegram --target 1 --message probe --dry-run --jsonwith networking denied. Exit0 and all222 output bytes match baseline:{"action":"send","channel":"telegram","dryRun":true,"handledBy":"core","payload":{"channel":"telegram","to":"telegram:1","via":"direct","mediaUrl":null,"dryRun":true}}The earlier full selected gate, including all three dead-code scans, and full normal build passed before the final getter/formatter correction. Fresh final checks and the source CLI rebuild cover the final bytes; exact-head hosted CI is required before landing. Failed setup/lint attempts and the original review finding are retained. Random terminal startup banners are not claimed byte-identical.
Maintainer landing review: retain the shared outbound-result projection and separate JSON/terminal presentation owners. Root read the full latest ClawSweeper review; its pending-CI risk is resolved by all216 exact-head jobs passing or intentionally skipping in33529478269, including the required gate. The final getter-order correction passes the baseline corpus and56 maintained tests; the actual source CLI rebuilt and returned the exact222-byte dry-run JSON under network denial. Production−27, assertion metadata net0, tests+112. No transport, authorization or persistence behavior changes.