1 Commits
Author SHA1 Message Date
brunoandClaude Opus 4.7 15fa67353e feat(knowledge): module-map schema + validator + Dify query cap fix (W3.5)
W3.5 implementation: enable Codex/Claude to resolve changed-files in a
PR diff to the spec module(s) and ADRs they belong to, before falling
back to text retrieval.

- platform/contracts/knowledge-module-map.schema.yaml: JSON Schema
  defining the new knowledge.module-map.yaml file business repos add at
  their root. Required fields: schema_version, service, modules.
  Each module entry has paths (fnmatch globs), excluded_paths, spec
  pointer, and adrs list. Optional fallback_adrs at the top level
  covers cross-cutting PRs.
- scripts/knowledge/validate_module_map.py: validates the yaml against
  schema + checks every spec/adrs path exists in the working tree +
  warns on duplicate path patterns + warns on dead module entries.
  CLI takes --module-map / --repo-root / --deploy-root and exits 1 on
  any error.
- scripts/knowledge/context_pack.py: cap the Dify retrieve query at
  240 chars (Dify rejects >250 with HTTP 400 invalid_param). Also
  switched from full paths to basenames in the query string for
  higher retrieval signal density.

W7 baseline on 4 recent ljwx-platform PRs after this change:
- PR #830 (12 care-elder files): 15 sections, 3 SSOT chunks, 2 from
  module-map (care-elder/module.yml + ADR-008), 13 from Dify
- 2/4 PRs returned >=1 SSOT chunk; the 0-SSOT PRs were Dependabot /
  CI script changes (correctly no spec to retrieve)
- 0 Cloudflare 1010 errors, 0 query-too-long errors

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-05-17 20:02:38 +08:00