Repository navigation
refactor: consolidate cross-directory duplicate code - #161352
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 30, 2026, 12:19 AM ET / 04:19 UTC (Revision 9). ClawSweeper reviewWhat this changesThe branch consolidates repeated parsing, tool-result, approval-display, service, channel, provider, and release-verification helpers across OpenClaw core, plugins, packages, scripts, and the Control UI. Merge readiness⛔ Blocked before merge - 7 items remain This is still a useful, unique cleanup that current main does not contain. I found no confirmed line-level defect, but the upgrade proof and resolved-head release-verifier evidence requested in the previous review remain unresolved. Priority: P3 Review scores
Verification
How this fits togetherChannel events, CLI requests, and UI actions enter the Gateway and agent runtime, which use shared helpers before invoking plugins, providers, and session or reply owners. Separate release scripts inspect publication artifacts before a release is accepted. flowchart LR
A[Channel, CLI, and UI inputs] --> B[Gateway and agent runtime]
B --> C[Shared parsing and policy]
C --> D[Plugins and providers]
D --> E[Replies and session state]
F[Release artifacts] --> G[Publication checks]
Decision needed
Why: The PR body describes a CI-only direction, while the applicable repository guidance and previous review require upgrade proof; the available discussion does not explicitly accept this specific tradeoff. Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the consolidation if an existing-state upgrade trace and resolved-head release diagnostic establish the preserved contracts, while retaining the present approval and Plugin SDK boundaries. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR claims behavior-preserving cleanup rather than a current-main product defect. Is this the best way to solve the issue? Unclear: consolidating these operations under existing owners fits the stated goal, but the upgrade and release-verifier boundaries need the evidence identified above. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3ba18eca2c85. LabelsLabel changes: No label 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 (8 earlier review cycles)
|
0f6e8d0 to
27597aa
Compare
Reuse canonical parsing, bounded-map, session-scope and service-binding owners. Share Markdown breakpoint scanning and Responses web-search detection; route lazy WebSocket consumers through the existing portable transport and remove their obsolete build rewrites. Preserve SDK, wire and persisted-state contracts.
Keep schema guards and provider-specific flattening intact. Isolate the shared web-search predicate from exported projection types so its private declaration does not enter SDK type closures.
Reuse existing listener, normalization, setup-visibility and cache-control owners. Preserve callback ordering, error propagation, string filtering and public SDK exports. Remove obsolete internal aliases and their stale test mocks.
Drop the setup-visibility cleanup group after the strict SDK comparison identified its namespace declaration in 123 reachable export closures. Preserve the existing API without acknowledgement or baseline changes.
Reuse result, numeric, string, filesystem, blocked-key, and map-eviction owners while preserving caller policy and output. Remove redundant private branches and repeated comments. Doctor inputs, transformations, warnings, and persisted state remain unchanged.
Preserve per-caller validation, ordering, diagnostics and public SDK contracts while reusing canonical owners. Correct the Discord plural reply-count diagnostic with an existing handler regression.
Drop the new SQLite scope and cache invalidation extractions after their local fixture preparation exceeded the maintainer quick-validation budget.
Drop the optional diagnostic spelling change and its unvalidated new test under the maintainer quick-validation limit. Runtime import edges are unchanged; the reverted test only removes an import edge from the verified acyclic graph.
Remove two obsolete imports, tighten assertion counts after cast removal, and load the real null-writer in the restart outcome VM fixture. The focused restart fixture passes all 19 existing native cases.
Keep the original Codex environment reader and session-runtime helpers after an unattributed worker teardown failure. Preserve the test assertions and leave worker lifecycle repairs to their owner.
db33af7 to
d56eaa6
Compare
|
Conflict-only rebase of approved head Resolved files, preserving newer main behavior:
Requested gates ran sequentially at
Host contention delayed the local scan. The unfinished second scan was stopped; that gate and the two typechecks completed on Blacksmith Testbox The coordinator-approved prior-head CI evidence and independently attributed Codex settlement timeout remain documented above; this comment does not claim new-head hosted CI. No Codex files were changed. Proceeding with the explicitly authorized pinned squash merge. |
49 upstream commits, including a Slack fallback progress card change (openclaw#161472) that regenerated the channel config baseline, and a consolidation of duplicate code (openclaw#161352) that touched extensions/feishu/src/channel.ts. Two conflicts, both in generated files: docs/.generated/config-baseline.sha256 and src/config/bundled-channel-config-metadata.generated.ts. openclaw#161472 changed Slack's entries in the channel config metadata, and this branch changes the Feishu entries, so both sides moved the same hashes and the same wrapped lines of the generated metadata. Both files were regenerated from this merge rather than hand-merged. build:docker ran in a separate detached checkout of this commit outside the nested node_modules install. The counts stay at core 2475, channel 3788, plugin 4444, as predicted, and the three generated-file checks pass there. extensions/feishu/src/channel.ts merged cleanly. openclaw#161352 replaced the local JSON action result builder with the shared textResult helper, away from the lines this branch changes. Feishu: 102 files and 1521 tests in the extension project, 17 files and 247 tests in the database-workers project. The forwarder test and the routing guards pass, 437 tests. tsgo:core, tsgo:extensions, tsgo:extensions:test, tsgo:test:root, the line-cap, max-lines and assertion-safety ratchets against upstream/main, oxlint and oxfmt on the 43 changed code files all pass.
* refactor: consolidate cross-directory duplicate code Reuse canonical parsing, bounded-map, session-scope and service-binding owners. Share Markdown breakpoint scanning and Responses web-search detection; route lazy WebSocket consumers through the existing portable transport and remove their obsolete build rewrites. Preserve SDK, wire and persisted-state contracts. * refactor: reuse allow-from projections in channel setup * refactor: share literal schema merging through an internal owner Keep schema guards and provider-specific flattening intact. Isolate the shared web-search predicate from exported projection types so its private declaration does not enter SDK type closures. * refactor: reuse shared listeners and remove forwarding helpers Reuse existing listener, normalization, setup-visibility and cache-control owners. Preserve callback ordering, error propagation, string filtering and public SDK exports. Remove obsolete internal aliases and their stale test mocks. * refactor: retain SDK-reachable setup visibility wrapper Drop the setup-visibility cleanup group after the strict SDK comparison identified its namespace declaration in 123 reachable export closures. Preserve the existing API without acknowledgement or baseline changes. * refactor: reuse canonical helpers across runtime consumers Reuse result, numeric, string, filesystem, blocked-key, and map-eviction owners while preserving caller policy and output. Remove redundant private branches and repeated comments. Doctor inputs, transformations, warnings, and persisted state remain unchanged. * refactor: consolidate shared runtime and tooling operations Preserve per-caller validation, ordering, diagnostics and public SDK contracts while reusing canonical owners. Correct the Discord plural reply-count diagnostic with an existing handler regression. * refactor: narrow consolidation to retained runtime owners Drop the new SQLite scope and cache invalidation extractions after their local fixture preparation exceeded the maintainer quick-validation budget. * refactor: keep Discord cleanup behavior neutral Drop the optional diagnostic spelling change and its unvalidated new test under the maintainer quick-validation limit. Runtime import edges are unchanged; the reverted test only removes an import edge from the verified acyclic graph. * fix: repair consolidation checks and restart fixture Remove two obsolete imports, tighten assertion counts after cast removal, and load the real null-writer in the restart outcome VM fixture. The focused restart fixture passes all 19 existing native cases. * refactor: drop unproven session-runtime clone groups Keep the original Codex environment reader and session-runtime helpers after an unattributed worker teardown failure. Preserve the test assertions and leave worker lifecycle repairs to their owner. * refactor: preserve main sandbox string filtering
What Problem This Solves
Equivalent operations across core, packages, scripts, and plugins had separate implementations or forwarding functions with no policy of their own. This sweep consolidates those operations at their existing owners.
User Impact
The refactors preserve accepted values, error text, callback and evaluation order, chunking, persisted state, wire formats, and the public plugin SDK. No intended user-visible behavior change.
Simplifications
Production measurement: 927 net production lines removed.
Retained differences include promise-observer timing, mutable schema identity, bootstrap/deployment closures, and case-distinct channel-ID normalization. Plugins use existing documented SDK seams; no public SDK export is added. Protected audit, cron, PR-tooling and wrapper-closure paths are unchanged.
Scope reductions during validation
Overlapping build-fence, channel-status, Diffs-tool, and transport changes were dropped when rebasing onto newer main behavior. The new SQLite scope/cache helper extractions and optional Discord spelling fix were dropped under the maintainer's quick-validation limit. The earlier PR-caused declaration-fixture gap no longer applies because its new build-fence dependency was dropped too.
Evidence
The maintainer's final shipping policy uses hosted CI on the exact PR head as the test gate.
e730db997a5c3e4d2425ea16f9ca261cd96afdb6.2a0a65c4ae6and that fix is included.Optional Blacksmith validation was stopped under the revised maintainer policy. Every confirmed owned lease is stopped, including
tbx_01m3qq95eg6knq0mgzz3hx9d9g; no fresh remote pass is claimed for this head.Independent Codex review covered the combined candidate at P2 severity. Two reported findings were rejected against complete source and the actual index: Discord event creation still falls through to the identical
channelIdreader, and both WebSocket consumers were already committed on the shared transport. No accepted actionable findings remained. Subsequent changes kept newer main behavior and removed clone groups rather than adding scope.Detector discovery on the earlier
0f6e8d0candidate measured 2,360 to 2,240 duplicated production lines (12-line/80-token scan). That is historical discovery evidence, not a final-head measurement after subsequent overlap removals.The final diagnostic revert restores the main-branch log text and test file. It changes no runtime import edges and only removes a test import edge from the already-verified acyclic static graph. The five passing test files are unchanged by that revert.
First CI run and repair
Run 36657935561 tested head
457f5917173a4afe161105f96b5e4bf7fb91965cand reported:check-lint-core-1,check-prod-types,check-test-typesisDeepStrictEqualandnormalizeOptionalStringimports; removed.checks-fast-baseline-ratchetschecks-node-compact-small-20Unexpected dependency call: ../../shared/null-writer.js:createNullWriter; the VM linker now loads the real leaf. All 19 existing native cases pass.checks-node-compact-small-12src/gateway/server.mcp-session-owner.test.tsin the operator-authority owner plan. The exact failing base already contained that new consumer; main fixed the expected target in #161511, commitc79a1285bab5.checks-node-changed-extensions-bundle-8run-attempt.reasoning-effort.test.tsretained worker ID 5 after its assertions passed. No independent witness was found, so this is not claimed inherited or fixed. The Codex environment-reader, session timestamp/reconciliation, and runtime-session-scope substitutions were withdrawn; the test and all assertions remain intact.openclaw/ci-gateThe repair adds no runtime import edges: obsolete imports and the unproven helper edges are removed, and the VM fixture change is one entry in its existing real-module list. The zero-cycle proof remains valid for the reduced graphs.
The final rebase onto
87abb5e76f1resolves an import/comment conflict while retaining main's newer schema logic. Main's sandbox string filtering is also retained, so the withdrawn Codex process group has no remaining diff.Final-head CI classification
Run
36665590030tested heade730db997a5c3e4d2425ea16f9ca261cd96afdb6through mergee1e27676f02bc65e91f3cb9e36cc8b7e4ab4cdb7with base4c17f2570de8f62b64512de7606022ea100269a1.preflight(job109729455976):Error: Cannot find module '/home/runner/_work/openclaw/openclaw/.ci-harness/scripts/ci-build-manifest.mjs'(MODULE_NOT_FOUND). The trusted harness export pathspec omits the manifest entrypoint. This PR changes neither.github/actions/git-owner/owner.py,.github/workflows/ci.yml, norscripts/ci-build-manifest.mjs.10b4f4b66adf8b8590da7bec97f5b4d3d7b3e4f2, failed in preflight job109730025540with the identical missing-module error. Existing repair #161569 exports the missing entrypoint from the canonical checkout owner.openclaw/ci-gate(job109729847765):checks-node-core-test-nondist-shard finished with skipped (selected=missing)and corresponding missing-selection errors because preflight could not produce its manifest.Per the coordinator's shipping order, this inherited CI failure is left to the coordinator for landing disposition. No workflow rerun or new remote proof was started.