Skip to content

ci(deadcode): replace broken export report lanes with enforced knip exports ratchet#105595

Merged
steipete merged 4 commits into
mainfrom
claude/dead-code-removal-e5a27f
Jul 12, 2026
Merged

ci(deadcode): replace broken export report lanes with enforced knip exports ratchet#105595
steipete merged 4 commits into
mainfrom
claude/dead-code-removal-e5a27f

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

OpenClaw currently has zero working symbol-level dead-code detection. The CI check-dependencies shard's advisory unused-exports lane (pnpm deadcode:ts-unused) has been silently crashing: pnpm dlx ts-unused-exports resolves the incompatible [email protected] peer and dies on startup, and the || true piping means the deadcode-reports artifact is just a stack trace. deadcode:ts-prune relies on the archived ts-prune. Meanwhile a knip production scan with --include exports,types,enumMembers finds ~1,506 unused exports and ~1,053 unused exported types on main.

Fixes #105575.

Why This Change Was Made

Knip is already the repo's pinned, configured dead-code scanner and already enforces unused files (allowlist ratchet in scripts/check-deadcode-unused-files.mjs) and unused dependencies. Extending that same enforced-ratchet pattern to unused exports replaces two dead third-party tools with the tool the repo already trusts, and stops new dead exports from landing while the existing backlog is burned down.

User Impact

None at runtime — CI/tooling only. For contributors: PRs that add new unused exports (or leave stale baseline entries behind after deleting code) now fail the check-dependencies shard with an actionable message; pnpm deadcode:exports:update regenerates the baseline after legitimate deletions.

Evidence

  • deadcode-reports artifact from main CI run 29202053366: ts-unused-exports startup crash, no report.
  • Knip 6.8.0 production export scan near e8f8738aae7: Unused exports (1506), Unused exported types (1053).
  • New enforced check passes against the checked-in baseline; unused-files check unaffected. Focused tests: test/scripts/check-deadcode-exports.test.ts, test/scripts/check-deadcode-unused-files.test.ts (output in PR checks / validation section below).

Validation on this head:

  • node scripts/run-vitest.mjs test/scripts/check-deadcode-exports.test.ts test/scripts/check-deadcode-unused-files.test.ts — 2 shards, 22 tests passed.
  • pnpm deadcode:exports[deadcode] Knip unused-export baseline matched 6031 entries. (exit 0)
  • pnpm deadcode:unused-files — allowlist matched, exit 0.
  • node scripts/run-oxlint.mjs + oxfmt format check on changed scripts — clean; actionlint .github/workflows/ci.yml — clean.
  • Autoreview (Codex gpt-5.6-sol): one accepted finding (optional entries promoted into required baseline on --update) fixed + regression-tested; remaining rerun finding was a bundle artifact (baseline committed separately for the 180k bundle cap) and is disproven by the live check above.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Jul 12, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f85715bf1d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/ci.yml
pnpm deadcode:dependencies
pnpm deadcode:unused-files
pnpm deadcode:report:ci:ts-unused
pnpm deadcode:exports

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate the export check on the new script

For workflow_dispatch compatibility runs that validate an older target_ref, this job checks out the target SHA but executes the current workflow body. Older release tags before this change already have deadcode:dependencies, so the condition on line 1600 takes this branch, but they do not have the newly added deadcode:exports script (the parent package had deadcode:dependencies/deadcode:unused-files but no deadcode:exports). That makes historical or release-candidate validation fail in check-dependencies with a missing script; guard this command on deadcode:exports being present or skip it when HISTORICAL_TARGET is true.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the claude/dead-code-removal-e5a27f branch from f85715b to 5849285 Compare July 12, 2026 18:25
@clawsweeper

clawsweeper Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 12, 2026, 2:33 PM ET / 18:33 UTC.

Summary
The PR replaces broken advisory unused-export reports with an enforced Knip baseline ratchet, shared Knip execution helpers, focused tests, and updated CI documentation.

PR surface: Tests +101, Docs 0, Config -12, Other +6276. Total +6365 across 9 files.

Reproducibility: yes. The exact workflow path can check out an older target, recognize its existing dependency script, and then call the absent new export script.

Review metrics: 1 noteworthy metric.

  • Generated enforcement baseline: 6,031 entries. This large merge-base-sensitive file becomes the source of truth for a new blocking contributor CI check.

Stored data model
Persistent data-model change detected: serialized state: scripts/check-deadcode-exports.mjs, serialized state: scripts/deadcode-knip-runner.mjs. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #105575
Summary: This PR is the direct candidate fix for the linked current-main dead-code CI bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🦐 gold shrimp
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Fix and regression-test historical-target compatibility.
  • Provide an exact-head historical-target workflow run or redacted execution transcript.
  • Regenerate and verify the baseline against the final merge base.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR shows after-change checker output on the current head, but not the changed dependency shard against a historical target; add a redacted workflow log or reproducible dispatch transcript, then update the PR body to trigger fresh review.

Risk before merge

  • [P1] Merging the current head can make historical or release-target workflow dispatches fail with a missing deadcode:exports package script before their intended validation runs.
  • [P1] The generated baseline is sensitive to base drift and needs regeneration or exact merge-result proof against the final base.

Maintainer options:

  1. Fix compatibility before merge (recommended)
    Guard the new export command for historical targets, add workflow regression coverage, and refresh the generated baseline on the final base.
  2. Defer the enforced ratchet
    Pause this PR until the new blocking lane can preserve the historical-target contract and produce final-base proof.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve historical workflow_dispatch targets that lack deadcode:exports, retain current-ref enforcement, add focused workflow guard coverage, and regenerate the export baseline against the final merge base without unrelated CI changes.

Next step before merge

  • [P1] The blocking defect has a narrow mechanical workflow guard, focused regression-test, and final-base baseline refresh path.

Security
Cleared: No concrete security or supply-chain regression was found; Knip remains version-pinned, workflow permissions are unchanged, and no new third-party action is introduced.

Review findings

  • [P1] Guard the export check for historical target refs — .github/workflows/ci.yml:1603
Review details

Best possible solution:

Keep the shared Knip ratchet, but gate the export command on the checked-out target defining it or on non-historical mode, add focused workflow-guard coverage, and regenerate the baseline against the final merge base.

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

Yes. The exact workflow path can check out an older target, recognize its existing dependency script, and then call the absent new export script.

Is this the best way to solve the issue?

No in the current head. Reusing pinned Knip and the existing ratchet pattern is the best architecture, but the workflow integration must preserve historical-target compatibility and final-base consistency.

Full review comments:

  • [P1] Guard the export check for historical target refs — .github/workflows/ci.yml:1603
    workflow_dispatch executes this current workflow while checking out older targets. Those refs can define deadcode:dependencies but not the newly added deadcode:exports, so this command fails before the target is validated. Gate it on checked-out script capability or HISTORICAL_TARGET, and add a focused workflow guard test.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: The PR addresses a normal-priority CI correctness bug but currently introduces a bounded regression in historical validation.
  • add merge-risk: 🚨 automation: The workflow diff can break supported historical-target dispatch automation after merge.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR shows after-change checker output on the current head, but not the changed dependency shard against a historical target; add a redacted workflow log or reproducible dispatch transcript, then update the PR body to trigger fresh review.

Label justifications:

  • P2: The PR addresses a normal-priority CI correctness bug but currently introduces a bounded regression in historical validation.
  • merge-risk: 🚨 automation: The workflow diff can break supported historical-target dispatch automation after merge.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR shows after-change checker output on the current head, but not the changed dependency shard against a historical target; add a redacted workflow log or reproducible dispatch transcript, then update the PR body to trigger fresh review.
Evidence reviewed

PR surface:

Tests +101, Docs 0, Config -12, Other +6276. Total +6365 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 101 0 +101
Docs 1 1 1 0
Config 2 4 16 -12
Generated 0 0 0 0
Other 5 6576 300 +6276
Total 9 6682 317 +6365

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs test/scripts/ci-workflow-guards.test.ts test/scripts/check-deadcode-exports.test.ts test/scripts/check-deadcode-unused-files.test.ts.
  • [P1] node scripts/check-workflows.mjs.
  • [P1] pnpm deadcode:exports.
  • [P1] pnpm deadcode:unused-files.
  • [P1] git diff --check.

What I checked:

  • Current-head compatibility defect: The dependency shard checks for the older deadcode:dependencies script, then unconditionally calls the newly introduced deadcode:exports script; historical targets can satisfy the first check while lacking the second script. (.github/workflows/ci.yml:1603, a94d85fbc898)
  • Historical-target contract: The check shard receives needs.preflight.outputs.compatibility_target as HISTORICAL_TARGET, confirming that the current workflow supports execution against older checked-out targets. (.github/workflows/ci.yml:1560, a94d85fbc898)
  • Review continuity: The workflow file did not change between the earlier reviewed head and the current head, so the prior missing-script finding remains unresolved. (.github/workflows/ci.yml:1603, a94d85fbc898)
  • Existing ratchet pattern: Current main already uses pinned Knip dependency detection and an enforced unused-file baseline, so a sibling export ratchet follows the repository's established architecture. (scripts/check-deadcode-unused-files.mjs:1, 26c418729714)
  • Generated gate size: The current head checks in a 6,031-entry export baseline, making synchronization with the final merge base important before enabling the blocking gate. (scripts/deadcode-exports.baseline.mjs:4, a94d85fbc898)

Likely related people:

  • steipete: Merged history connects this person to the existing strict Knip unused-file guard, its tests, and the related dead-code CI enforcement surface. (role: introduced adjacent guard behavior; confidence: high; commits: 0e7cdaff0383, 9be938689101, 306e4465ad4a; files: scripts/check-deadcode-unused-files.mjs, scripts/deadcode-unused-files.allowlist.mjs, test/scripts/check-deadcode-unused-files.test.ts)
  • vincentkoc: Recent merged work removes dead exported symbols and touches adjacent Knip configuration and dead-code guard surfaces. (role: recent dead-code and CI area contributor; confidence: medium; commits: cc344fee6589, 213198123042, 042669d8c875; files: config/knip.config.ts, scripts/check-deadcode-unused-files.mjs, scripts/deadcode-unused-files.allowlist.mjs)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Jul 12, 2026
@steipete
steipete merged commit a425807 into main Jul 12, 2026
122 of 127 checks passed
@steipete
steipete deleted the claude/dead-code-removal-e5a27f branch July 12, 2026 18:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Jul 13, 2026
wm0018 pushed a commit to wm0018/openclaw that referenced this pull request Jul 14, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI unused-exports dead-code lane is silently broken; no symbol-level dead-code enforcement

1 participant