Skip to content

refactor(scripts): share planning and validation cores - #168994

Merged
steipete merged 3 commits into
mainfrom
deslop/d38-scripts-lib-p2-20261007
Oct 11, 2026
Merged

steipete merged 3 commits into
mainfrom
deslop/d38-scripts-lib-p2-20261007

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Consolidates repeated planning, packaging, localization, and validation mechanics in the scripts helper library and its adjacent entrypoints.

User Impact

No user-visible change. Features, CLI flags, configuration, protocol and persisted shapes, output text, test selection, timing budgets, and cleanup behavior remain unchanged.

Why This Change Was Made

The first scripts-library pass (#168331) removed 862 production lines. This second pass revisits its rejected and partial candidates, then follows the same owners into adjacent entrypoints. Shared code now carries the source context, ordered classification rules, per-variant command settings, and admitted result state instead of repeating them at each caller.

Net production reduction: 500 lines across 22 source files (578 added / 1,078 deleted). Four existing test files add 69 net lines while replacing source-text checks with captured Docker arguments and exact generated rerun commands. Tests and proof artifacts are excluded from the production total. This uses the explicitly authorized 500–999-line exception with the coverage log below; the 3% target was not reached.

No new dependencies, suppressions, schema/config/protocol changes, SDK exports, or changelog edits. Native translation bytes and locale ownership are unchanged. The removed private helpers have no retained parallel implementation.

Evidence

Candidate: 34b31e9638f81d77e86f282d5cadc34b427d64a7, based on a8a349b15b20240d387770378072c2ca51889596. Both rebases were conflict-free; git range-diff reports all three reviewed patches identical. The last integration incorporates upstream build-input and declaration-receipt owner changes in two touched files. Initial differential comparisons used 757d73980426df41869314a063b17fc847b36511.

  • Independent review through P2: no accepted/actionable findings. The reviewed patch is unchanged by both rebases.
  • Localization differential proof: 842 synthetic extraction cases, all 4,463 current inventory entries including order/context, and all 85 generated Android resource outputs plus Kotlin bytes are deeply equal to the baseline.
  • CI/Docker differential proof: 334 complete exported results and serialized outputs are equal across shard options, catalogs, release profiles, selected lanes, and invalid-input outcomes.
  • The two modified shell tests pass against both the baseline and candidate scripts: 5/5 each. Combined one-worker command wall times: baseline 19.91s, candidate 25.60s on the loaded local host; native candidate duration 12.89s. Clean-runner cost remains to be recorded.
  • Live read-only release pagination: parent and strict-attempt APIs return the same 90 job IDs for completed run 38036917444.
  • Focused and full-directory proof passes the changed CI planner (115 cases), planner commands (8), Docker scheduler (36), native localization (46), npm-lock generator (82), npm bundle (37), release checklist (120), release summary (137), and release qualification (18). The scheduler seam assertions pass 3/3 selected cases (135.78s wall, including worker preparation). All 17 import-closure tests pass.
  • All 997 files selected by the native test/scripts plan were exercised across three invocations. Two invocations stopped admission on unreleased nested resource claims; both namespaces and claims were preserved, no remaining users were observed, and subsequent native runs covered only the missing files. The directory result is not green: the combined logs contain 377 observed failed cases in 57 files. No assertions, skips, timeouts, retry policy, or resource guards were weakened.
  • Focused sequential base/head comparison used the same 11 package-publication, timeout-grace, and declaration-cache cases: base passed 9 and failed 2; head passed all 11. The base repeated the null-status publication failure and the 120-second declaration deadline. This does not claim the original intermittent failures were fixed or satisfy a median timing qualification. The publication fixture is byte-identical to the base.
  • The configured Testbox stayed queued without a host and was stopped at the 20-minute allocation cutoff. No remote proof gate ran. Exact-head hosted CI remains the Linux and landing gate.
  • node scripts/check-changed.mjs passes after the final integration, including script types, all four root-test type graphs, dead-export scans, formatting, and lint. Both cycle checks pass with zero cycles. Focused tests of the two upstream-overlapped build modules pass, as does the exact standalone suppression command (3 cases). The focused wrapper finished in 106.53s; the suppression wrapper finished in 8.40s.
  • All 104 npm package locks validate using a task-private npm cache. The first attempt failed when npm could not read entries from the shared cache; the shared cache and lockfiles were not modified.
  • Local failure investigation: unchanged PR-tooling fixtures account for many failures; macOS Bash 3.2 rejects an empty array under nounset before the release-reuse validator starts; an unchanged UI private-server inventory is inconsistent; other failures include compiler/transport deadlines and legacy-session migration E2E failures. The staged package-runtime timeout has no changed file in its 1,057-file import closure. Intermittent deadlines remain unresolved local results, not claimed inherited failures. Every failing hosted job will be attributed separately.
Coverage and measured changes

The initial lane audit covered all 378 eligible scripts-library modules. The continuation reread the earlier rejected/partial candidates, checked intervening source changes, and examined adjacent owners. The final boundary inventory contains 388 eligible library modules after intervening main changes. The refreshed PR-tooling closure contains 11,072 paths, of which 150 are protected scripts. The 13 open deslop PRs, including the heartbeat exclusion, contribute 2,747 distinct paths. None overlap this change.

Area Net production lines removed Preservation boundary
Native/Android localization 132 One source context; shared named-argument discovery and generated resources; same parser rules, diagnostics, order and bytes.
CI/Docker planning and live wrappers 144 Ordered shard precedence, exact filename exceptions, fresh lane descriptors, timeout defaults, and Docker argument values/order.
Build/package/compiler tooling 112 Declaration steps, package identity projection, admitted compiler summaries, selected-group execution, prerequisite matching, and source-module validation.
Release/package orchestration 69 Captured vs echoed output limits, root-only package sealing, exact job pagination, canonical/legacy artifact selection, and CLI text.
Benchmark and source scanning 43 Immediate/100ms RSS sampling and finalization, existing option ownership, and binding traversal without changing scope or write attribution.

Per-file source changes:

File Net lines removed
scripts/android-app-i18n.ts 21
scripts/native-app-i18n.ts 111
scripts/bench-gateway-restart.ts 28
scripts/bench-gateway-startup.ts 25
scripts/lib/gateway-bench-probes.ts -15
scripts/lib/mock-factory-scan.mts 5
scripts/build-all.mts 13
scripts/check-extension-package-tsc-boundary.mts 8
scripts/ci-build-manifest.mjs 4
scripts/generate-npm-package-lock.mts 40
scripts/package-openclaw-for-docker.mts 37
scripts/tsdown-build.mts 10
scripts/lib/ci-node-test-plan.mts 102
scripts/lib/docker-e2e-container.sh 2
scripts/lib/docker-e2e-scenarios.mts 17
scripts/lib/live-docker-auth.sh -10
scripts/test-docker-all.mts 13
scripts/test-live-cli-backend-docker.sh 7
scripts/test-live-codex-harness-docker.sh 13
scripts/release-candidate-checklist.mts 13
scripts/release-ci-summary.mjs 45
scripts/npm-prepared-bundle.mjs 11

Negative rows are the shared implementations that replace larger duplicated callers.

Retained candidates include the CI policy-watch grouping (the previous actual prototype saved only one line), distinct process-capture/streaming runners, source custody and restore barriers, frozen publication identities, native parser differences, compiler resource/lifecycle boundaries, and mock-Gateway fixture data. These encode real differences or would add more indirection than they remove. No source-text compression or removal of proof scenarios contributes to the reduction.

Re-evaluated files retained unchanged

These are the earlier rejected/partial candidates and adjacent owners read again during this continuation. The changed-file table above records the implemented candidates; the initial lane audit covered all 378 eligible library modules. No claim is made that every current library module was reread during this second pass.

File Retained responsibility or measured reason
scripts/apple-app-i18n.ts Catalog generation is already shared; runtime bypass dictionaries are exact guards.
scripts/lib/docker-e2e-image.sh Build/package cleanup and numeric admission differ.
scripts/lib/docker-e2e-logs.sh Capture, trap restoration, and failure precedence remain distinct.
scripts/lib/live-docker-stage.sh Frozen-source and credential custody have separate lifecycles.
scripts/test-live-models-docker.sh Model-specific limits and profile-only mode differ from other runners.
scripts/test-live-gateway-models-docker.sh CLI preparation, Gemini auth, and provider forwarding differ.
scripts/test-live-subagent-announce-docker.sh Credential remapping and staged-test lookup are lane-specific.
scripts/lib/ci-policy-test-watch.mts The earlier implemented grouping prototype saved only one line; retained the clearer owner arrays.
scripts/test-live-acp-bind-docker.sh Per-agent installation and credential exclusion remain explicit.
scripts/ci-pr-fail-fast.mjs Identity, partial-rerun admission, and final-main freshness are separate authority phases.
scripts/ci-known-main-red.mjs Read bounds and failure inventories differ from the monitor.
scripts/ci-check-plan.mts Existing owners already share graph selection and lint placement.
scripts/lib/ci-static-check-evidence.mjs Native and historical receipts have different validation contracts.
scripts/lib/ci-node-test-evidence.mjs Stream completion and assertion signatures remain explicit.
scripts/lib/plugin-npm-runtime-build.mts Export backports and native-source linking differ.
scripts/lib/plugin-npm-package-manifest.mts Retry paths differ on thrown errors, spawn outcomes, and cleanup.
scripts/lib/extension-boundary-projects.mts Real SDK declarations and synthetic declarations serve different contracts.
scripts/lib/extension-boundary-inputs.mts Receipt validation and before/after lookup retain one owner each.
scripts/check-extension-plugin-sdk-boundary.mts Collection is already shared; mode-specific acceptance stays explicit.
scripts/lib/vitest-worker-compiler.mts Source normalization, importer boundaries, require lookup, and remapping are distinct adapters.
scripts/lib/tsdown-declaration-generator-inputs.mts Static inventory and dynamic-expression verification have different ownership.
scripts/profile-extension-memory.mts Completion, process settlement, and publication lifecycles differ.
scripts/profile-tsgo.mts Tracing and output artifacts differ between check modes.
scripts/full-release-artifacts.mjs Fresh/reused evidence has distinct authority and expiry semantics.
scripts/plugin-publication-artifact.mjs Transport binding, TAR validation, and bounded-reader errors differ.
scripts/full-release-publication-contract.mjs Registry states already share their roster; availability and trust policies differ.
scripts/frv-publication-status.mts Surface construction is already shared; platform markers retain distinct meanings.
scripts/release-plan-producer.mts Bootstrap code-integrity boundary must remain independent.
scripts/release-plan-producer-core.mts Verified-child inputs remain inside their integrity boundary.
scripts/bench-cli-startup.ts Native transport boundaries and historical/runtime RSS differ.
scripts/bench-sqlite-state.ts SQL and seeding describe fixed benchmark workloads.
scripts/bench-worker-runtime.ts Variants already share the phase runner; receipt types differ.
scripts/bench-workspace-computation.ts Parent/child timing and post-timing verification differ.
scripts/bench-worker-transcript-commit.ts Reservation, append, replay, and reconcile measure separate work.
scripts/bench-session-history.ts Cold, warm, SQL-trace, and iterator measurements have distinct boundaries.
scripts/bench-plugin-invocation.ts Warmup and instrumented allocation are intentionally separate passes.
scripts/bench-plugin-stream.ts Consumption is shared; timing and allocation need separate passes.
scripts/lib/benchmark-harness.mts Existing parser/report owner has a different percentile contract.
scripts/bench-agent-concurrency.ts Already uses the shared benchmark owner.
scripts/bench-agent-concurrency-runtime.mts Memory and durable-registry scenarios measure different persistence.
scripts/bench-agent-concurrency-worker.ts Spawn modes share execution; reservation and recovery semantics differ.
scripts/bench-web-fetch.ts Extractor contracts and percentile rounding differ.
scripts/bench-usage-refresh-memory.ts Input truth, setup exclusion, and fresh-worker memory boundaries are intentional.
scripts/bench-session-manager-hydration-memory.ts Reader variants already share child launch and reporting.
scripts/bench-test-changed.mts Routed execution is shared; ref collection and time parsing differ.
scripts/bench-gateway-control-ui-proof.ts Scenarios share resources; transport and cleanup assertions differ.
scripts/bench-model.ts Providers share execution; environment admission remains explicit.
scripts/bench-agent-database-holds.ts Native method descriptors and instrumentation overhead must be preserved.
scripts/bench-session-manager-write-hold.ts JSON overloads, warmup exclusion, and percentile selection differ.
scripts/bench-redaction-prefilters.ts Corpus variants already share CPU/wall measurement.
scripts/bench-session-paths.ts Alternating order is part of the measurement contract.
scripts/bench-write-diff.ts Variants share execution; reset stays outside measurement.
scripts/bench-worker-runtime.worker.ts Validation, checksum, receipts, and transfer lists differ.
scripts/control-ui-mock-dev.ts Constructors are already shared; most remaining volume is distinct fixture data.

Consolidate localization collection, build and release dispatch, Docker argument forwarding, benchmark sampling, and CI classification while preserving outputs and variant policies. Replace two source-bound assertions with the existing captured-argument boundary.
@clawsweeper

clawsweeper Bot commented Oct 11, 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.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts docker Docker and sandbox tooling size: XL labels Oct 11, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR shares script planning, localization, packaging, validation, and benchmark mechanics while preserving existing behavior.

Example: Run the Docker harness with OPENCLAW_LIVE_CODEX_HARNESS_IMAGE_PROBE empty.

  • Before: Docker receives OPENCLAW_LIVE_CODEX_HARNESS_IMAGE_PROBE=1 from the inline default.
  • After: Docker receives the same value from the shared environment-argument helper.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is coherent and source review found no defect; preservation evidence is substantial but primarily harness-based, with validation still incomplete.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored internal refactor is outside the contributor-media gate; supplied evidence reports localization and planner comparisons, captured Docker arguments, and live read-only release pagination, while explicitly retaining unresolved local failures.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
Reason: Maintainer-directed consolidation removes repeated maintenance points without introducing new product behavior or public contracts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: the consolidation has clear maintenance value, and source review found no actionable introduced defect.

Priority: P3
Reviewed head: 34b31e9638f81d77e86f282d5cadc34b427d64a7

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supplied preservation evidence is primarily differential and harness-based; the existing exact-head behavioral CI run remains unfinished.
Agent review details

How this fits together

Repository scripts consume source inventories, build options, environment settings, and GitHub evidence to produce commands, packages, localization artifacts, and validation summaries.

flowchart TD
  A[Source and operator inputs] --> B[Script entrypoints]
  B --> C[Shared planning and validation]
  C --> D[Build and package tools]
  C --> E[Docker execution]
  C --> F[Localization artifacts]
  C --> G[Release evidence summaries]
Loading

Technical review

Best possible solution:

Retain the shared cores and explicit variant policies, then land through the existing CI gate.

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

This PR addresses duplicated maintenance logic rather than a reported product bug; the pinned diff directly establishes the repeated implementations.

Is this the best way to solve the issue?

Sharing mechanics within existing owners is appropriate because ordering, validation, variant settings, and cleanup remain explicit.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native localization extraction and Android generation keeps the original intent (484c3a1: Validate native locale artifacts; subsequent Android generation preserves managed resource keys and separate surface ownership.)
  • CI test classification keeps the original intent (b4a6244: Split expensive agent test shards; ordered matching and exact filename exceptions remain intact.)
  • Declaration build caching keeps the original intent (c4887fb: Reuse compatible declarations after output cleanup while preserving canonical artifacts and cache validation.)
  • Docker timeout dispatch keeps the original intent (b34e1b3: Honor Docker harness run timeouts separately from ordinary command timeouts.)
  • Release attempt evidence pagination keeps the original intent (c28cb02: Continue failed validation on the original parent while composing exact child evidence across attempts and rejecting mismatched execution identities.)
  • Frozen npm package sealing keeps the original intent (de53081: Seal declarations after frozen prepack rebuilds and replay optional postpack cleanup even when packing fails.)
  • Mock-factory binding traversal keeps the original intent (07e2877: Prevent incomplete first-party module mocks; shared traversal preserves lexical binding and write attribution.)
  • Gateway benchmark probes keeps the original intent (887297e: Deduplicate Gateway benchmark probes; sampling still occurs immediately, every 100 ms, and at caller-owned finalization.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduction reviewed: The merge-base-to-head hunks consolidate existing mechanics while retaining shard precedence, timeout defaults, validation rules, and cleanup boundaries. (34b31e9638f8)
  • Complete body and discussion context: REST inspection recovered the omitted body suffix; supplied body identity is 08519e60020a8dfbf828550b39e5758661a4bf7345119819c4e187cd0a12cb9e. The body reports differential preservation evidence and explicitly retains unresolved local failures; the previous review projection contains no findings. (34b31e9638f8)
  • Package sealing safeguards preserved: Root packaging still runs prepack, sanitizes declarations, refreshes inventory, disables root pack hooks, and runs optional postpack in finally; other packages retain their hooks, respecting fix(release): repair frozen npm declaration sealing #157026. (scripts/npm-prepared-bundle.mjs:697, 34b31e9638f8)
  • Release validation remains strict: The shared pagination loop retains completeness and duplicate checks; artifact selection retains canonical precedence, legacy attempt-one restriction, and identity validation. (scripts/release-ci-summary.mjs:807, 34b31e9638f8)
  • Tests exercise emitted contracts: Changed shell tests capture Docker argv, including empty defaults and quoted values; scheduler tests check generated rerun commands instead of implementation spelling. (test/scripts/test-live-codex-harness-docker.test.ts:72, 34b31e9638f8)
  • Current validation state: The reviewed head is no longer a draft and is mergeable; the CI gate remains pending. Complete paginated check reads found no failure, timed-out, or action-required conclusion, so unfinished execution is not passing coverage. (34b31e9638f8)

Likely related people:

  • Peter Steinberger: Raw commit 567d7d3 adds scripts/android-app-i18n.ts:1209 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 567d7d393cef; files: scripts/android-app-i18n.ts)
  • Vincent Koc: Raw commit c03d645 adds scripts/android-app-i18n.ts:488 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c03d64558fea; files: scripts/android-app-i18n.ts)

PR surface

Tests +69, Other -500. Total -431 across 26 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 4 118 49 +69
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 22 578 1078 -500
Total 26 696 1127 -431

Review metrics

Metric Value Why it matters
Production versus test LOC Production +578/-1078, net -500; tests +118/-49, net +69. Production reduction removes duplicated mechanics; test growth strengthens emitted-argument and command preservation checks.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: Internal maintenance refactor with no intended user-visible change or urgent defect.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Complete the existing exact-head CI run and attribute any failed behavioral check before landing.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-11T08:03:27.225Z sha 34b31e9 :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 4:11 AM ET / 08:11 UTC (Revision 2).

@steipete
steipete marked this pull request as ready for review October 11, 2026 08:05
@steipete
steipete merged commit 9ef5fdf into main Oct 11, 2026
195 of 196 checks passed
@steipete
steipete deleted the deslop/d38-scripts-lib-p2-20261007 branch October 11, 2026 08:52
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
Share repeated localization, CI and Docker planning, packaging, build, and validation mechanics behind explicit variant parameters. Remove 500 net production lines while preserving commands, output, selection order, timing budgets, and cleanup behavior.

Replace internal scheduler source-spelling assertions with exact generated-command and captured-argument assertions in existing test cases. Keep the PR tooling import closure and concurrent deslop work untouched.

Validation: independent review; localization and CI/Docker differential comparisons; all 997 script test files exercised with local failures retained in the PR evidence; focused base/head comparisons; current-head changed checks, affected-module tests, suppression checks, and zero-cycle checks. Hosted CI passes on the exact published head.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 18, 2026
First-parent upstream c96fac1..d9eba8a (10 PRs: openclaw#168948 GitHub
connection authority to workers, openclaw#168975, openclaw#168772 cron receipt custody
removal, openclaw#169012, openclaw#169006, openclaw#169009, openclaw#168283 test batch d042, openclaw#168994,
openclaw#168964, openclaw#168855 approval/placement state in workers).

Conflicts:
- docs/reference/database-schemas/worker-access-inventory.md: took
  upstream, then regenerated (db:worker-inventory:gen, 633 files / 2449
  calls) instead of hand-merging.
- src/agents/embedded-agent-runner/compact-reasons.test.ts: upstream
  openclaw#168283 deleted low-value cases; kept upstream's file plus our own
  additions only (unknown_model, empty reason, closed-union check and the
  isCompactionSkipCode block).

session-reset-service.ts auto-merged: upstream's awaited placement
retirement (assertCurrent) is disjoint from our continuation-cancellation
cleanup reason.

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Docker and sandbox tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL 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