Skip to content

fix: scope import-direction to JS/TS with honest skip for other languages#86

Merged
benwu95 merged 1 commit into
mainfrom
benwu95/feat/import-direction-honest-skip
Jul 9, 2026
Merged

fix: scope import-direction to JS/TS with honest skip for other languages#86
benwu95 merged 1 commit into
mainfrom
benwu95/feat/import-direction-honest-skip

Conversation

@benwu95

@benwu95 benwu95 commented Jul 9, 2026

Copy link
Copy Markdown
Owner

摘要

drift 的 import-direction 檢查只解析 JS/TS ES-module import,但在非 JS/TS 專案上,它掃到 0 個 JS/TS 檔卻仍回報 available + 0 邊 →評估為 PASS——一個空洞 PASS,假裝依賴方向已驗、實際一個檔都沒看,違反 drift 引擎「來源不可得 → skipped,絕不空洞 PASS」的原則。

本 PR 把 import-direction 明確收斂為 JS/TS-only + 誠實 skipped:

  • available 僅在實際掃到 JS/TS 源碼檔時成立;module paths 下無任何 JS/TS 源碼(即使目錄存在、含其他語言)→ 回報 skipped,原因明示「JS/TS-only」並指向該語言的原生 import linter(import-linter / deptrac / packwerk / dependency-cruiser …)。
  • JS/TS 專案行為完全不變(edge 蒐集、歸屬、排序);既有測試續綠。

為什麼不做跨語言解析

一度嘗試以 tree-sitter 擴充為 11 語言(見已擱置的 spike),但在一個大型真實 Python 專案上驗證發現:主流的絕對 import(from <pkg>.x,佔 ~84%)需要 package-root 解析,等於重寫各語言成熟的架構 linter,ROI 低且維護重(+22MB grammar、WASM 依賴)。每個語言都有專門、AST 精準的原生工具(Python import-linter、PHP deptrac、Ruby packwerk、JS/TS dependency-cruiser、Java ArchUnit …),prospec 不該重造。誠實 skipped + 指路,遠優於誤導的空洞 PASS。

驗證

  • 全套件綠、typecheck 乾淨、mutation-verified(還原 guard → 非-JS/TS 測試轉紅)。
  • 大型真實 Python 專案實測:import-direction 由「partial/vacuous PASS」改為 skipped(帶 JS/TS-only + import-linter 指路)。

…cuous pass

import-direction only parses JS/TS ES-module imports, but it reported
available+0 edges (a PASS) on a project whose module-path dirs exist yet hold
no JS/TS source — falsely claiming the dependency direction was verified.

- set `available` only when JS/TS source is actually found; otherwise report
  honest `skipped` with a reason that says the check is JS/TS-only and points to
  the language's own import linter (import-linter / deptrac / packwerk / …)
- JS/TS behavior unchanged (edge collection/attribution/sort); existing tests green
- validated on a large real-world Python project: was a vacuous PASS, now skipped
- supersedes the abandoned tree-sitter multi-language attempt — native per-language
  architecture linters do cross-language dependency-direction far better
@benwu95 benwu95 force-pushed the benwu95/feat/import-direction-honest-skip branch from 67fcb41 to 18ce12c Compare July 9, 2026 10:24
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Prospec Check

Prospec drift check (structural — deterministic, zero LLM)

  PASS  req-references
  PASS  file-paths
  PASS  import-direction
  WARN  knowledge-health
  SKIP  task-completion — source unavailable: .prospec/changes/ not found (not version-controlled)
  PASS  dangling-prefix
  PASS  feature-modules
  PASS  mcp-readme-counts
  SKIP  review-provenance — source unavailable: .prospec/changes/ not found (not version-controlled)
  SKIP  metadata-completeness — source unavailable: .prospec/changes/ not found (not version-controlled)
  PASS  knowledge-size

Findings:
  [warn] prospec/ai-knowledge/modules/lib/README.md
         stale knowledge: module "lib" source last commit 2026-07-09T18:24:04+08:00 is newer than README last commit 2026-07-09T13:11:15+08:00
  [warn] prospec/ai-knowledge/modules/services/README.md
         stale knowledge: module "services" source last commit 2026-07-09T13:11:15+08:00 is newer than README last commit 2026-07-08T00:47:18+08:00
  [warn] prospec/ai-knowledge/modules/tests/README.md
         stale knowledge: module "tests" source last commit 2026-07-09T18:24:04+08:00 is newer than README last commit 2026-07-09T13:11:15+08:00
  [warn] prospec/ai-knowledge/modules/types/README.md
         stale knowledge: module "types" source last commit 2026-07-09T13:11:15+08:00 is newer than README last commit 2026-07-07T17:46:29+08:00

Knowledge coverage: 6/6 modules documented, 4 stale

Checked 8/11 checks: 0 fail, 1 warn, 3 skipped (not counted as pass)
Semantic consistency: not-checked (run /prospec-review)
Report written: prospec-report.json

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Test Coverage

Metric Coverage Covered / Total
lines 96.74% 3179 / 3286
statements 96.17% 3491 / 3630
functions 96.17% 578 / 601
branches 93.64% 1945 / 2077

@benwu95 benwu95 merged commit 59ef31c into main Jul 9, 2026
4 checks passed
@benwu95 benwu95 deleted the benwu95/feat/import-direction-honest-skip branch July 9, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant