Skip to content

fix(knowledge): stop leaking internal budget symbol into generated skills#80

Merged
benwu95 merged 3 commits into
mainfrom
benwu95/fix/skill-md-budget-symbol-leak
Jul 6, 2026
Merged

fix(knowledge): stop leaking internal budget symbol into generated skills#80
benwu95 merged 3 commits into
mainfrom
benwu95/fix/skill-md-budget-symbol-leak

Conversation

@benwu95

@benwu95 benwu95 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

問題

prospec agent sync 產生、寫入下游專案的 SKILL.md(及 AI 依 knowledge-generate 產生的 index.md)在說明知識分層 token 預算時,引用了 prospec 套件內部的 TypeScript 常數 DEFAULT_KNOWLEDGE_TOKEN_BUDGET。下游專案看不到、也無從解析這個符號,只能看到模板裡寫死的數字;那些數字既不反映該專案在 .prospec.yaml 覆寫的值,也可能與常數漂移。

方案

  • resolveKnowledgeTokenBudget 提升為 lib/config 的 canonical 單一來源 resolver(與 resolveBasePaths 同類);check.serviceagent-sync 皆 import,無 service→service 耦合(PB-006/PB-007)。
  • KnowledgeSizeBudget 型別移至 types/config(與 DEFAULT_KNOWLEDGE_TOKEN_BUDGET/TokenBudget 同居)。
  • agent-sync 於共用 template context 注入 resolved 的 l1_per_file/l2_per_module/readme_max_lines
  • knowledge-loading skill 模板(_knowledge-loading-rules partial、prospec-knowledge-generateprospec-knowledge-update)全部預算數字改以 {{...}} 變數渲染,並將來源改指向下游可見/可執行的 .prospec.yaml knowledge.token_budgetprospec check knowledge-size,不再具名內部常數。
  • 對齊 dogfood 文件(index.mdREADMEREADME.zh-TW、module READMEs)並重新產生 agent skills;pnpm counts 同步事實計數。

效果

下游讀者看到的是自己專案的實際預算值,權威來源是他們能編輯的 .prospec.yaml 與能執行的 prospec check knowledge-size——不再是無從解析的內部符號。

測試 / 品質

  • 新增 skill-format 契約(rendered skill 無 DEFAULT_KNOWLEDGE_TOKEN_BUDGET、數字來自注入 context)與 agent-sync 注入單元測試(override 命中),皆 mutation-verified。
  • pnpm test 2086 passed、typecheck/lint 綠、prospec check 11/11 PASS。
  • 對抗式 review:0 critical / 1 major(遷移型別後測試檔殘留 dangling import type → latent TS2459,因 tsconfig 排除 tests 而三閘皆漏)已於 review loop 修復。
  • verify grade S

SDD

透過 Prospec SDD 全流程完成:story → plan → tasks → implement → review → verify(S)→ archive;6 個 REQ 已 graduate 進 drift-detection / agent-integration / ai-knowledge feature specs。

benwu95 added 2 commits July 6, 2026 17:38
…ills

- move resolveKnowledgeTokenBudget to lib/config (canonical single-source
  resolver, sibling of resolveBasePaths); check.service imports it
- move KnowledgeSizeBudget interface to types/config (budget contract home)
- agent-sync injects resolved l1_per_file/l2_per_module/readme_max_lines
  into the shared skill template context
- knowledge-loading skill templates render budgets from {{...}} variables and
  cite .prospec.yaml knowledge.token_budget + `prospec check knowledge-size`
  instead of DEFAULT_KNOWLEDGE_TOKEN_BUDGET, which downstream cannot resolve
- align dogfood docs (index.md, README, README.zh-TW, module READMEs) and
  regenerate agent skills; re-sync factual test counts
- add contract + unit tests (no-symbol + numbers-from-config), mutation-verified
- graduate REQ-LIB-028 / REQ-AGNT-035 / REQ-TESTS-049 (ADDED) and
  REQ-TYPES-061 / REQ-SERVICES-065 / REQ-KNOW-013 (MODIFIED) into the
  drift-detection, agent-integration, and ai-knowledge feature specs
- add _archived-history summary; refresh raw-scan.md
- harvest lessons: relocation-reference-sweep-completeness → freq 3
  (suggest-promote); add typecheck-excludes-tests observation
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Prospec Check

Prospec drift check (structural — deterministic, zero LLM)

  PASS  req-references
  PASS  file-paths
  PASS  import-direction
  PASS  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

Knowledge coverage: 6/6 modules documented

Checked 8/11 checks: 0 fail, 0 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 6, 2026

Copy link
Copy Markdown

Test Coverage

Metric Coverage Covered / Total
lines 96.95% 3152 / 3251
statements 96.32% 3457 / 3589
functions 96.46% 573 / 594
branches 93.67% 1924 / 2054

…eck enum)

- PB-008: relocating a symbol/type/artifact must sweep every reference
  site incl. test-file imports (tsconfig excludes tests → type-only
  import breaks escape typecheck) and wording; freq=3, modules=5
- PB-009: adding a drift check must sync the root-README check
  enumeration (pnpm counts covers numbers, not that prose list);
  freq=3, modules=2
- flip both lessons-ledger entries to promoted with provenance
@benwu95 benwu95 merged commit 9e00730 into main Jul 6, 2026
4 checks passed
@benwu95 benwu95 deleted the benwu95/fix/skill-md-budget-symbol-leak branch July 6, 2026 09:58
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