fix: generate one path-scoped Language Policy so the Constitution and entry config agree - #91
Merged
Merged
Conversation
- add lib/language-policy: resolveLanguageScope derives the native/English path sets and named exceptions from paths.base_dir + knowledge.base_path - languagePolicyRule now takes a LanguageScope and states the rule by path, so a verify audit decides by file location instead of re-reading what "AI-generated documents" covers; an English project gets a condensed form - entry.md.hbs renders the same injected scope instead of a hand-written path list, so CONSTITUTION.md and CLAUDE.md/AGENTS.md cannot declare conflicting scopes (the #67 alignment reached this repo's files but not the generator) - upgrade reports staleLanguagePolicy for a project still carrying the old seeded wording; the command still never edits CONSTITUTION.md - prospec-upgrade gains Step 2.5: diff the Language Policy section and rewrite it only on consent — the one seeded wording the skill may migrate - promotion-format declares the ledger description column as an in-zone exception, so downstream ledgers inherit it - pin the scope with unit + cross-document contract assertions (mutation-verified); the previous tests asserted no scope at all
- README (both languages) scope artifact_language to change artifacts and
their archived summaries, and name the English trust zone; the two files
previously disagreed ("AI-generated documents" vs change specs/tasks)
- CONSTITUTION.md drops the same-sentence clash between "archived summaries
in Traditional Chinese" and "specs in English": _archived-history follows
the change narrative, specs/features stays English
- record the named in-zone exceptions (alias/keyword data, ledger
description, playbook evidence quotes, user-managed glossary)
- sync factual test counts after the new suites
- entryLanguageContext feeds both entry-config render sites, so `prospec init` alone no longer writes empty path lists beside a fully-scoped Constitution - resolve scope paths with path.posix.join and a '.' fallback, so a repo-root base_dir stops emitting root-anchored paths - scope specs/product.md to English; it belonged to neither zone - upgrade reports the stale seed with the rendered replacement rule, since no template carries the rule text; the English gate now keys off the seed's own language so a switched-language project still migrates - prospec-upgrade Step 2.5 reads that block instead of an impossible print-template retrieval; the shared language-policy partial goes path-scoped - pin the invariant with cross-document contract tests, a bundle-sync guard and heading-boundary cases; four mutations verified they bite - sync module Knowledge for lib/types/services/templates/tests
Prospec Check |
Test Coverage
|
- move approval/scoring/retirement provenance out of `status` into `description` as a `| **Promotion**:` / `| **Retired**:` suffix, verbatim (10 rows; every chunk verified preserved) - document `retired` in promotion-format's status set — the data used it three times, and mapping it onto `promoted`/`declined` would have misstated state - state in promotion-format that provenance belongs in `description`, never appended to `status`, so the closed set every consumer reads stays closed - narrow the Language Policy's ledger exception back to `description` only, in the generator, the Constitution, the ledger header and the graduated specs — with status now ASCII, claiming an exception for it would overstate
Owner
Author
|
補一個 follow-up commit(
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
prospec init在同一次執行裡寫出兩份互相矛盾的[MUST]Language Policy:languagePolicyRule()seed 進CONSTITUTION.md的措辭要求「change artifacts and AI Knowledge」都用專案語言,而同一次agent sync由entry.md.hbs產生的CLAUDE.md/AGENTS.md卻宣告 Knowledge base「always remain in English — exempt」。因為
/prospec-verify只稽核 Constitution 且 MUST→FAIL,非英文專案照 L0 的CLAUDE.md寫英文 Knowledge,第一次 verify 就吃 MUST 違反;照 Constitution 寫母語,則每個 session 載入的 L0 都在反對該產出。沒有任何檔案宣告兩者優先順序。issue #67 的 US-360/REQ-TEMPLATES-141 已決定豁免並要求「三方對齊」,但只落在 prospec 自身的
CONSTITUTION.md與entry.md.hbs,漏了產生器 —— 所以每個下游prospec init專案至今仍拿到互相矛盾的兩份文件。做法
把語言範圍變成資料:新增
src/lib/language-policy.ts的resolveLanguageScope(),由paths.base_dir/knowledge.base_path推導母語集、英文集與具名例外集;languagePolicyRule(scope)與 entry config 的entryLanguageContext(scope)都從這一份渲染。散文措辭兩邊仍不同(一份是[MUST]規則、一份是 agent 指令),但路徑集合同源,並由 contract test 釘死兩份產出的路徑集字面相等。.prospec/changes/**、.prospec/archive/**、specs/_archived-history/**;英文適用CONSTITUTION.md、README.md、index.md、specs/product.md、specs/features/**、knowledge basedescription+status欄、_playbook.md逐字引用證據、user-managed_glossary.md)只寫在 Constitution,不進 L0prospec upgrade對帶舊措辭的既有專案報告 stale 訊號,並附上以該專案路徑渲染好的替代條文;指令本身仍不修改CONSTITUTION.md,改寫由/prospec-upgrade新增的 Step 2.5 徵詢同意後執行_language-policy.hbs改為「按文件路徑指派語言」—— 原本「所有產出文件同一語言」的指示,正是 feature spec 曾漂移成繁中、要靠一整個 change 翻回英文的成因Review 揪出的三個關鍵缺陷
六個獨立 lens 平行審查 + 每個 critical 派獨立 verifier 重現,兩輪共 8 critical 全修:
entry.md.hbs有兩個 render site,第一輪只接了agent sync。更糟的是 init 只寫AGENTS.md,而agent sync只重寫「已設定 agent 的 configPath」,所以 claude-only 專案那份空括號檔案會永久留著print-template init/constitution.md.hbs取條文,但該範本只迴圈輸出注入的規則、本身沒有條文文字,且print-template回傳未渲染原始碼find(...)!讓not.toContain(undefined)恆過(把知識庫從英文區整段刪掉仍綠);只比對字面 glob 則讓「以 prose 重述同一矛盾」溜過另有 round 2 揪出的新 critical:英文短路原按當前 config 語言判斷,於是「先以日文 init、後改
artifact_language: English」的專案訊號被吞;改為按 seed 自身語言判斷。驗證
init單獨執行的 entry config 已帶完整路徑集;init+agent sync兩份文件路徑集字面一致;英文專案取單一區塊分支prospec upgrade印出訊號 + 完整替代條文,CONSTITUTION.md未被修改;CONSTITUTION.md為目錄(EISDIR)時仍 exit 0 並印出完整報告prospec check0 fail13 條 REQ 已畢業至 project-setup、agent-integration、ai-knowledge、feedback-promotion 四份 feature spec。