Skip to content

feat: unify module-map paths file/folder semantics across callers#85

Merged
benwu95 merged 2 commits into
mainfrom
benwu95/feat/support-file-module-paths
Jul 9, 2026
Merged

feat: unify module-map paths file/folder semantics across callers#85
benwu95 merged 2 commits into
mainfrom
benwu95/feat/support-file-module-paths

Conversation

@benwu95

@benwu95 benwu95 commented Jul 9, 2026

Copy link
Copy Markdown
Owner

摘要

module-map.yamlpaths 欄位一致支援三種條目形式,跨所有 caller(drift 引擎 + knowledge 產生):

  • 檔案(如 src/lib/config.ts)→ 只掃描/歸屬該檔本身
  • 資料夾(如 src/lib)→ 掃描整個子樹
  • glob(如 **/auth/**dir/**)→ 原樣保留(既有寫法不受影響)

核心為 lib 新增的單一 stat-based 路徑分類器 classifyModulePath + moduleScanPatterns,作為「一個 paths 條目如何被掃描」的唯一事實來源;drift 與 knowledge 掃描端共用同一語義。歸屬 matcher(makePathMatcher / fileMatchesModulePath)原本就以 p === literal 精確匹配檔案,維持不動。

修正的既有缺陷

  • drift importScanPattern 先前把每個 literal 一律展開成 <prefix>/**/*.ext,使檔案條目變成 <file>/**prospec check 實測 ENOTDIR crash。現在檔案條目直接掃該檔;非源碼檔條目不產生 import 邊。
  • knowledge getModuleInfos / updateModuleReadme裸資料夾條目(如 src/lib)經 fast-glob(onlyFiles)掃到 0 檔;現在經 moduleScanPatterns 展開為子樹。

測試

  • 16 個新測試案例(分類器四態、moduleScanPatterns 映射、drift 檔案條目/非源碼檔/glob 回歸、knowledge 子樹掃描 wiring),全數 mutation-verified
  • 全套件 2112 綠、pnpm typecheck 0 error、prospec check 11/11
  • 另為一個 git-subprocess 密集的 contract test 調高 timeout(平行套件負載下的既有 5s flake headroom)

SDD

透過 prospec 完整流程走完(story → plan → tasks → implement → review → verify grade S → archive);REQ-LIB-029 / REQ-TESTS-050 / REQ-KNOW-004 / REQ-LIB-014 已畢業進 drift-detection.mdai-knowledge.md

benwu95 added 2 commits July 9, 2026 13:11
- add classifyModulePath + moduleScanPatterns to lib/scanner as the single
  source for reading a paths entry as file / dir / glob / missing
- drift importScanPattern scans a single-file entry as the file itself and
  treats a non-source file entry as carrying no import edges (also removes a
  prior ENOTDIR on file entries)
- knowledge getModuleInfos + updateModuleReadme scan via moduleScanPatterns,
  fixing bare-directory entries that previously matched zero files
- preserve existing glob forms (** and dir/**) and repo-escape clamping
- tests: file/dir/glob classification, drift file-entry edges, knowledge
  subtree scan (all mutation-verified)
- raise one git-heavy mcp contract test timeout for parallel-suite headroom
- sync declared test counts (2096 -> 2112)
- graduate REQ-LIB-029 + REQ-TESTS-050 and US-361 into ai-knowledge.md; MODIFY
  REQ-KNOW-004 (module README scan via moduleScanPatterns)
- MODIFY REQ-LIB-014 in drift-detection.md (single-file import-edge scanning)
- record _archived-history summary; bump product.md last_updated
- refresh raw-scan.md snapshot
- harvest lessons ledger (parallel-load test-timeout flake x5; new review-fix
  verification lesson)
@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/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/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, 2 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% 3177 / 3284
statements 96.14% 3488 / 3628
functions 96.17% 578 / 601
branches 93.6% 1946 / 2079

@benwu95 benwu95 merged commit 4c5d33c into main Jul 9, 2026
4 checks passed
@benwu95 benwu95 deleted the benwu95/feat/support-file-module-paths branch July 9, 2026 05:39
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