0%

Boundary Hygiene Lint

Goal

A sibling to crate-dag-lint.py asserting concrete ori_llvm:: or ori_backend:: imports outside the one designated CodegenBackendChoice adapter/dispatch module do not exist in oric. Platform linking, packaging, execution, and diagnostics consume ori_codegen::EmittedArtifact and shared toolchain types; they do not form an exempt second concrete-backend boundary.

Context

plans/canonical-consumer-boundary’s crate-dag-lint.py + consumer_registration_check.py (both read in full during research) are the direct structural template: doc-comment-exclusion via //-stripping so a rustdoc cross-reference never counts, fail-closed-on-empty-parse, two-directional check (stale-entry + unregistered-consumer shape, adapted here to scattered-import-outside-boundary + boundary-module-drift shapes).

Implementation sketch

  1. Author compiler_repo/scripts/backend-boundary-lint.py, reusing crate-dag-lint.py’s doc-comment-stripping (_references_module) and fail-closed-on-empty-parse discipline.
  2. Check every ori_llvm:: or ori_backend:: import in compiler_repo/compiler/oric/src/**; anything outside the designated adapter/dispatch module fires a violation.
  3. Check that linker, sysroot, packaging, process-launch, cache, and diagnostic code accepts only EmittedArtifact/shared toolchain data and never matches concrete backend identity.
  4. Wire --self-test covering a synthetic positive plus negative fixtures for an out-of-boundary LLVM import, native-backend import, and post-dispatch backend match.
  5. Wire --warn-only into lefthook.yml + test-all.sh (bedding-in mode, mirroring crate-dag-lint.py’s own rollout).

Spec references

plans/canonical-consumer-boundary/content/consumer-registration-lint--s-e26ee405.md (direct precedent).

Work items

  • Author backend-boundary-lint.py with two-directional concrete-import and post-dispatch-match checks plus positive/negative --self-test fixtures; wire --warn-only into lefthook + test-all.sh.