Skip to content

feat(lint): enforce import ordering and deduplication - #124730

Merged
steipete merged 2 commits into
mainfrom
steipete/import-rules-campaign
Aug 16, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/import-rules-campaign

Conversation

@steipete

@steipete steipete commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The oxlint import plugin was active, but import/no-duplicates and import/first remained disabled because the repository still had 347 duplicate-import findings and 1,956 import-placement findings. That left new duplicate imports and late production imports unguarded.

Why This Change Was Made

This cleans duplicate imports across every existing oxlint lane, hoists production imports while preserving module-request order, and enables both rules at error. import/first stays disabled for test files because 1,430 of 1,553 test findings (92.1%) follow Vitest's intentionally hoisted vi.mock/vi.unmock setup; one production file retains a narrow exception for an explicit maintenance side-effect import.

When duplicate side-effect and binding imports were consolidated, the surviving binding import was kept in the original first module-request slot. A documented oxfmt-ignore barrier protects those 22 test-harness setup imports from the formatter's import sorter.

User Impact

No user-visible runtime behavior changes. Contributors now get immediate lint failures for duplicate imports in oxlint-covered files and for imports placed after production statements.

Evidence

  • import/no-duplicates: 347 findings before (245 production, 102 test) → 0.
  • import/first: 1,956 findings before (403 production, 1,553 test) → 0 in the enabled scope. The remaining forced-rule survey has one documented production exception and 1,545 test findings covered by the Vitest override.
  • pnpm lint — green across core, plugin, and scripts oxlint lanes plus Control UI i18n/style checks.
  • node scripts/run-vitest.mjs test/scripts/oxlint-config.test.ts — 12 passed.
  • Five risk-ranked production surfaces plus representative dedupe cases — 9 routed shards, 369 passed, 1 skipped.
  • Former side-effect import barriers — 6 routed shards, 198 passed; Zalouser-specific regression proof — 5 files, 72 passed.
  • Branch-mode autoreview — clean, no accepted/actionable findings.
  • node scripts/check-changed.mjs reached Testbox in run 31962427151 but the delegated checkout reported no reachable origin/main ancestor and stopped on assertion-ratchet entries in two files outside this diff. Exact-head PR CI remains the authoritative broad gate.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser app: web-ui App: web-ui gateway Gateway runtime extensions: memory-core Extension: memory-core cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling channel: feishu Channel integration: feishu channel: twitch Channel integration: twitch extensions: openai extensions: minimax extensions: byteplus extensions: volcengine labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 18:11
@steipete
steipete requested a review from a team as a code owner August 16, 2026 18:11
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 16, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 2:29 PM ET / 18:29 UTC.

ClawSweeper review

What this changes

The PR enables Oxlint errors for duplicate imports and production import placement, while reorganizing existing imports across the current source, plugin, UI, and script lint lanes.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-owned lint-policy PR open for normal merge handling: its narrowed enforcement claim matches the existing Oxlint lanes, but the local partial clone could not materialize the PR head for a complete 456-file diff review.

Priority: P3
Reviewed head: 8634cf9d558f9f294149e624cc2aaf554a3d3834

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The stated validation and sampled semantic checks support the lane-scoped change, while unavailable exact-head source limits confidence in the full mechanical rewrite.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored lint-policy change is appropriately evidenced by lint and targeted configuration-test results rather than a user-facing runtime flow.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored lint-policy change is appropriately evidenced by lint and targeted configuration-test results rather than a user-facing runtime flow.
Evidence reviewed 6 items Current lint entry point: The default lint command delegates to the shard runner, which targets core, extensions, and scripts rather than root test files.
Delimited enforcement scope: The current core, extension, script, and aggregate Oxlint tsconfigs include src, ui, packages, extensions, and scripts, but not root test/.
Existing root-test boundary: Changed-check coverage explicitly routes root test/support changes to tooling and script lint, without a root-test execution lane; the script lint target itself is scripts only.
Findings None None.
Security None None.

How this fits together

The lint wrapper sends repository source through three Oxlint shards before CI accepts changes. These rules reject duplicate imports and production imports placed after executable code in the lanes that the wrapper targets.

flowchart LR
  A[Source and plugin files] --> B[Oxlint configuration]
  B --> C[Import rules]
  C --> D[Core plugin and script shards]
  D --> E[CI lint jobs]
  E --> F[Contributor feedback]
Loading

Before merge

  • Resolve merge risk (P1) - Default CI leaves root test/** outside Oxlint; that is consistent with the PR's narrowed claim, but it would not provide repository-wide duplicate-import enforcement.
  • Resolve merge risk (P1) - The review environment could not load the exact PR head, so a complete mechanical import-order audit still needs an exact-head-capable checkout or CI artifact.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Rule activation 2 enabled; 1 production-file exception; 1 test-pattern override The PR changes automated acceptance criteria while preserving intentional test setup and one documented production ordering case.
Production versus test LOC not classifiable locally; PR reports +1,256/-1,102 across 456 files The promisor checkout could not materialize the PR head needed to separate mechanical production and test changes accurately.

Stored data model

Persistent data-model change detected: durable storage schema: src/worker/worker-connection.test.ts, persistent cache schema: src/state/openclaw-state-db.ts, serialized state: extensions/browser/src/browser/session-tab-process-state.ts, serialized state: src/state/openclaw-state-db.ts, serialized state: src/state/user-profiles.test.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Accept lane-scoped enforcement (recommended)
    Merge with the documented boundary that default lint enforces these rules only in the existing Oxlint lanes.
  2. Extend root-test coverage
    Add a type-aware root-test Oxlint shard and changed-lane contract if repository-wide duplicate-import enforcement is required.

Technical review

Best possible solution:

Land only as enforcement for the existing Oxlint lanes; add a dedicated root-test lint lane later if maintainers want duplicate-import checks across all tests.

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

Not applicable: this is a lint-policy change, and the relevant check is the configured lint-lane topology rather than a runtime reproduction.

Is this the best way to solve the issue?

Yes for the stated lane-scoped goal: the current wrappers and CI target the same lanes named by the PR, and the prior root-test coverage request was explicitly narrowed rather than silently dropped.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9d0c1f8f8c59.

Labels

Label justifications:

  • P3: This is low-risk developer-tooling cleanup with no claimed user-visible runtime change.
  • merge-risk: 🚨 automation: The change alters lint rules and exceptions that determine what CI accepts in the configured source lanes.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored lint-policy change is appropriately evidenced by lint and targeted configuration-test results rather than a user-facing runtime flow.

Evidence

What I checked:

  • Current lint entry point: The default lint command delegates to the shard runner, which targets core, extensions, and scripts rather than root test files. (scripts/run-lint.mts:34, 9d0c1f8f8c59)
  • Delimited enforcement scope: The current core, extension, script, and aggregate Oxlint tsconfigs include src, ui, packages, extensions, and scripts, but not root test/. (config/tsconfig/oxlint.json:3, 9d0c1f8f8c59)
  • Existing root-test boundary: Changed-check coverage explicitly routes root test/support changes to tooling and script lint, without a root-test execution lane; the script lint target itself is scripts only. (test/scripts/changed-lanes.test.ts:2042, 9d0c1f8f8c59)
  • Current lint-policy provenance: Blame attributes the existing deferred import-rule configuration and its config test baseline to the current lint-policy commit by steipete. (.oxlintrc.json:68, 468d621f9a75)
  • Prior review response: The author explicitly limited the PR claim to existing Oxlint-covered lanes and documented the decision not to add a root test shard, satisfying the prior review's stated scope alternative. (8634cf9d558f)
  • Review-environment limitation: The checkout is a promisor clone and could not retrieve the PR head because DNS resolution for GitHub failed; branch-only inspection therefore relies on the supplied patches and PR evidence.

Likely related people:

  • steipete: Current-main blame and recent history attribute the deferred import-rule baseline and its configuration test to this contributor. (role: recent lint-policy contributor; confidence: high; commits: 468d621f9a75; files: .oxlintrc.json, test/scripts/oxlint-config.test.ts)

Rank-up moves

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

  • Repeat the complete diff scan from an environment that can materialize the exact PR head before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-16T18:20:53.658Z sha 8634cf9 :: found issues before merge. :: [P2] Lint test files before claiming duplicate enforcement

@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper finding addressed by narrowing the PR wording to the existing oxlint-covered lanes.

Rank-up move skipped: adding a new type-aware test/** shard would expand CI topology and cost beyond this campaign, whose surveyed and requested scope is the existing core, plugin, and scripts lint lanes. Colocated test files in those lanes remain covered (import/no-duplicates: 102 findings cleaned), while the root test/** tree keeps its existing ownership boundary. Exact-head lint and CI are green.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 8634cf9d558f9f294149e624cc2aaf554a3d3834:

  • Counts: import/no-duplicates 347 → 0 (245 production, 102 test); import/first 1,956 → 0 in the enabled scope (403 production findings cleaned except one documented side-effect exception; 1,553 test findings excluded after 1,430/1,553, 92.1%, proved vi.mock/vi.unmock-adjacent).
  • Full lint: pnpm lint passed core, plugin, and scripts oxlint shards plus Control UI i18n/style checks.
  • Config contract: node scripts/run-vitest.mjs test/scripts/oxlint-config.test.ts — 12 passed.
  • Risk-ranked production + representative dedupe proof: 9 routed Vitest shards — 369 passed, 1 skipped.
  • Former side-effect import barriers: 6 routed Vitest shards — 198 passed; Zalouser focused rerun — 5 files, 72 passed. Binding imports stay in their original first module-request slot behind documented oxfmt-ignore barriers.
  • Exact-head CI: green, run https://github.com/openclaw/openclaw/actions/runs/31963864673.
  • Branch autoreview: clean, no accepted/actionable findings.
  • LOC: total +1,256/-1,102 across 456 files; production +964/-845, tests +272/-238, tooling/config +20/-19. Growth is formatter-owned import layout, not runtime capability.
  • node scripts/check-changed.mjs delegated to Testbox run https://github.com/openclaw/openclaw/actions/runs/31962427151 but stopped because that transient checkout reported no reachable origin/main ancestor and surfaced assertion-ratchet entries in two files outside this diff. Exact-head PR CI is green.
  • ClawSweeper: root test/** shard expansion intentionally skipped as a separate CI-topology/cost change; PR wording is limited to existing oxlint-covered lanes. Rationale: feat(lint): enforce import ordering and deduplication #124730 (comment).

No changelog or live-provider proof is needed for this internal lint-policy campaign.

@steipete
steipete merged commit 568b920 into main Aug 16, 2026
323 checks passed
@steipete
steipete deleted the steipete/import-rules-campaign branch August 16, 2026 18:44
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
* refactor(imports): dedupe and hoist imports

* feat(lint): enforce import/no-duplicates and import/first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: linux app: web-ui App: web-ui channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: raft Channel integration: Raft channel: signal Channel integration: signal channel: slack Channel integration: slack channel: synology-chat channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: twitch Channel integration: twitch channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser cli CLI command changes commands Command implementations extensions: baseten Extension: baseten extensions: browser extensions: byteplus extensions: canvas extensions: chutes extensions: codex extensions: copilot extensions: diagnostics-prometheus extensions: diffs extensions: google extensions: lmstudio extensions: memory-core Extension: memory-core extensions: memory-wiki extensions: minimax extensions: mistral extensions: oc-path extensions: ollama extensions: onepassword 1Password plugin extensions: openai extensions: opencode-go extensions: openshell extensions: perplexity extensions: qa-lab extensions: volcengine extensions: xai gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. plugin: google-meet plugin: logbook Logbook automatic work journal plugin plugin: mxc plugin: workboard rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant