prizmkit 1.1.154 → 1.1.156

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/codex/skill-adapter.js +1 -1
  3. package/bundled/adapters/pi/skill-adapter.js +2 -1
  4. package/bundled/dev-pipeline/.env.example +2 -6
  5. package/bundled/dev-pipeline/README.md +21 -27
  6. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +341 -15
  7. package/bundled/dev-pipeline/prizmkit_runtime/cli.py +0 -3
  8. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +1 -15
  9. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +48 -14
  10. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +50 -2
  11. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +0 -9
  12. package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +3 -3
  13. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +120 -22
  14. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +482 -0
  15. package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +64 -11
  16. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +145 -367
  17. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +91 -62
  18. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +105 -69
  19. package/bundled/dev-pipeline/scripts/prompt_framework.py +36 -41
  20. package/bundled/dev-pipeline/scripts/update-bug-status.py +1 -4
  21. package/bundled/dev-pipeline/scripts/update-checkpoint.py +61 -13
  22. package/bundled/dev-pipeline/scripts/update-feature-status.py +1 -4
  23. package/bundled/dev-pipeline/scripts/update-refactor-status.py +1 -4
  24. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +22 -27
  25. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +71 -104
  26. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +59 -111
  27. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +37 -72
  28. package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +39 -0
  29. package/bundled/dev-pipeline/templates/sections/bugfix-critical-paths.md +3 -1
  30. package/bundled/dev-pipeline/templates/sections/bugfix-phase-commit-report.md +8 -25
  31. package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +3 -3
  32. package/bundled/dev-pipeline/templates/sections/bugfix-phase-implement.md +2 -2
  33. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +3 -3
  34. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -2
  35. package/bundled/dev-pipeline/templates/sections/bugfix-reminders.md +4 -4
  36. package/bundled/dev-pipeline/templates/sections/bugfix-session-context.md +0 -1
  37. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +7 -4
  38. package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +14 -27
  39. package/bundled/dev-pipeline/templates/sections/feature-completion-summary.md +20 -0
  40. package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +8 -71
  41. package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +7 -7
  42. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +3 -3
  43. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +4 -4
  44. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +5 -17
  45. package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +3 -1
  46. package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +10 -23
  47. package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +2 -2
  48. package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +2 -2
  49. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +3 -3
  50. package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +2 -2
  51. package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +7 -7
  52. package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -1
  53. package/bundled/dev-pipeline/templates/sections/retrospective.md +12 -0
  54. package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +35 -0
  55. package/bundled/dev-pipeline/templates/session-status-schema.json +45 -62
  56. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +469 -18
  57. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +262 -175
  58. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +62 -23
  59. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +76 -28
  60. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +168 -18
  61. package/bundled/dev-pipeline/tests/test_recovery_workflow.py +111 -0
  62. package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -2
  63. package/bundled/dev-pipeline/tests/test_runtime_commit.py +608 -0
  64. package/bundled/dev-pipeline/tests/test_unified_cli.py +167 -25
  65. package/bundled/skills/_metadata.json +9 -9
  66. package/bundled/skills/app-planner/SKILL.md +3 -3
  67. package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
  68. package/bundled/skills/app-planner/references/rules/backend/derivation-rules.md +56 -64
  69. package/bundled/skills/app-planner/references/rules/backend/fixed-rules.md +85 -240
  70. package/bundled/skills/app-planner/references/rules/backend/question-bank.md +25 -25
  71. package/bundled/skills/app-planner/references/rules/backend/question-manifest.json +16 -7
  72. package/bundled/skills/app-planner/references/rules/backend/template.md +74 -92
  73. package/bundled/skills/app-planner/references/rules/database/derivation-rules.md +93 -93
  74. package/bundled/skills/app-planner/references/rules/database/fixed-rules.md +66 -173
  75. package/bundled/skills/app-planner/references/rules/database/question-bank.md +31 -26
  76. package/bundled/skills/app-planner/references/rules/database/question-manifest.json +13 -4
  77. package/bundled/skills/app-planner/references/rules/database/template.md +76 -98
  78. package/bundled/skills/app-planner/references/rules/frontend/derivation-rules.md +68 -95
  79. package/bundled/skills/app-planner/references/rules/frontend/fixed-rules.md +93 -166
  80. package/bundled/skills/app-planner/references/rules/frontend/question-bank.md +46 -36
  81. package/bundled/skills/app-planner/references/rules/frontend/question-manifest.json +11 -2
  82. package/bundled/skills/app-planner/references/rules/frontend/template.md +79 -257
  83. package/bundled/skills/app-planner/references/rules/mobile/derivation-rules.md +91 -99
  84. package/bundled/skills/app-planner/references/rules/mobile/fixed-rules.md +73 -246
  85. package/bundled/skills/app-planner/references/rules/mobile/question-bank.md +17 -17
  86. package/bundled/skills/app-planner/references/rules/mobile/question-manifest.json +17 -2
  87. package/bundled/skills/app-planner/references/rules/mobile/template.md +73 -85
  88. package/bundled/skills/app-planner/references/rules-configuration.md +133 -65
  89. package/bundled/skills/app-planner/scripts/validate-rules-configuration.py +291 -0
  90. package/bundled/skills/prizmkit/SKILL.md +17 -18
  91. package/bundled/skills/prizmkit/references/workflow-state-protocol.md +22 -18
  92. package/bundled/skills/prizmkit-code-review/SKILL.md +22 -58
  93. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +6 -6
  94. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +2 -2
  95. package/bundled/skills/prizmkit-committer/SKILL.md +82 -132
  96. package/bundled/skills/prizmkit-deploy/SKILL.md +27 -11
  97. package/bundled/skills/prizmkit-deploy/assets/deploy-document-template.md +89 -0
  98. package/bundled/skills/prizmkit-deploy/references/ci-cd-workflows.md +44 -14
  99. package/bundled/skills/prizmkit-deploy/references/cloud-platform-deploy.md +19 -3
  100. package/bundled/skills/prizmkit-deploy/references/database-setup.md +22 -12
  101. package/bundled/skills/prizmkit-deploy/references/deploy-config-schema.md +3 -1
  102. package/bundled/skills/prizmkit-deploy/references/deploy-history-schema.md +22 -6
  103. package/bundled/skills/prizmkit-deploy/references/deploy-metadata-schema.json +49 -0
  104. package/bundled/skills/prizmkit-deploy/references/live-validation-notes.md +1 -1
  105. package/bundled/skills/prizmkit-deploy/references/pending-input-schema.json +164 -0
  106. package/bundled/skills/prizmkit-deploy/references/ssh-adapter-flow.md +9 -8
  107. package/bundled/skills/prizmkit-deploy/references/ssh-execution-flow.md +6 -6
  108. package/bundled/skills/prizmkit-implement/SKILL.md +30 -66
  109. package/bundled/skills/prizmkit-implement/references/implementation-subagent-procedure.md +4 -4
  110. package/bundled/skills/prizmkit-init/SKILL.md +4 -0
  111. package/bundled/skills/prizmkit-plan/SKILL.md +21 -64
  112. package/bundled/skills/prizmkit-plan/references/artifact-identity.md +38 -0
  113. package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +4 -4
  114. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +5 -5
  115. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +75 -11
  116. package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +191 -56
  117. package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +18 -18
  118. package/bundled/skills/prizmkit-prizm-docs/references/op-rebuild.md +14 -8
  119. package/bundled/skills/prizmkit-prizm-docs/references/op-status.md +12 -5
  120. package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +23 -12
  121. package/bundled/skills/prizmkit-prizm-docs/references/op-validate.md +13 -9
  122. package/bundled/skills/prizmkit-retrospective/SKILL.md +94 -97
  123. package/bundled/skills/prizmkit-retrospective/references/knowledge-injection-steps.md +79 -37
  124. package/bundled/skills/prizmkit-retrospective/references/retrospective-result-schema.json +138 -0
  125. package/bundled/skills/prizmkit-retrospective/references/structural-sync-steps.md +111 -54
  126. package/bundled/skills/prizmkit-test/SKILL.md +64 -51
  127. package/bundled/skills/prizmkit-test/references/boundary-contract-and-test-double-guidance.md +206 -0
  128. package/bundled/skills/prizmkit-test/references/independent-test-review.md +17 -9
  129. package/bundled/skills/prizmkit-test/references/test-coverage-model.md +45 -21
  130. package/bundled/skills/prizmkit-test/references/test-report-template.md +20 -13
  131. package/bundled/skills/prizmkit-workflow/SKILL.md +35 -37
  132. package/bundled/skills/prizmkit-workflow/references/artifact-identity.md +34 -0
  133. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +22 -18
  134. package/bundled/skills/recovery-workflow/SKILL.md +2 -1
  135. package/bundled/skills/recovery-workflow/references/detection.md +4 -3
  136. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +15 -5
  137. package/bundled/templates/hooks/validate-prizm-docs.py +124 -12
  138. package/package.json +1 -1
  139. package/src/scaffold.js +33 -22
  140. package/bundled/dev-pipeline/templates/sections/bugfix-artifacts.md +0 -16
  141. package/bundled/dev-pipeline/templates/sections/bugfix-session-status.md +0 -31
  142. package/bundled/dev-pipeline/templates/sections/critical-paths-agent.md +0 -7
  143. package/bundled/dev-pipeline/templates/sections/critical-paths-lite.md +0 -7
  144. package/bundled/dev-pipeline/templates/sections/directory-convention-agent.md +0 -9
  145. package/bundled/dev-pipeline/templates/sections/directory-convention-lite.md +0 -6
  146. package/bundled/dev-pipeline/templates/sections/headless-commit-authorization.md +0 -15
  147. package/bundled/dev-pipeline/templates/sections/phase-commit.md +0 -61
  148. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +0 -24
  149. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-lite-suffix.md +0 -12
  150. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +0 -44
  151. package/bundled/dev-pipeline/templates/sections/phase-implement-lite.md +0 -25
  152. package/bundled/dev-pipeline/templates/sections/phase-plan-agent.md +0 -20
  153. package/bundled/dev-pipeline/templates/sections/phase-plan-lite.md +0 -20
  154. package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +0 -20
  155. package/bundled/dev-pipeline/templates/sections/refactor-artifacts.md +0 -17
  156. package/bundled/dev-pipeline/templates/sections/refactor-session-status.md +0 -28
  157. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-agent.md +0 -52
  158. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-lite.md +0 -52
  159. package/bundled/skills/prizmkit-code-review/references/workflow-state-protocol.md +0 -174
  160. package/bundled/skills/prizmkit-committer/references/workflow-state-protocol.md +0 -174
  161. package/bundled/skills/prizmkit-implement/references/workflow-state-protocol.md +0 -174
  162. package/bundled/skills/prizmkit-plan/references/workflow-state-protocol.md +0 -174
  163. package/bundled/skills/prizmkit-retrospective/references/workflow-state-protocol.md +0 -174
  164. package/bundled/skills/prizmkit-test/references/external-contract-mock-guidance.md +0 -119
@@ -8,16 +8,27 @@ Use this operation for manual edits, merges, rebases, branch switches, generated
8
8
 
9
9
  STEPS:
10
10
  1. Identify drift source. Prefer explicit user context; otherwise inspect git changes with `git diff --cached --name-status`, then `git diff --name-status`. If no git changes exist, run a bounded rescan comparing code structure against existing docs.
11
- 2. Map changed files to modules by matching MODULE_INDEX or MODULE_GROUPS in `root.prizm`.
12
- 3. Classify each change: A (added) -> new KEY_FILES entries; D (deleted) -> remove entries and update counts; M (modified) -> check dependency/interface/data-flow impact; R (renamed) -> update path references.
13
- 4. Update affected docs bottom-up: L2 first for INTERFACES/DATA_FLOW/DEPENDENCIES/TRAPS/DECISIONS, then L1 for FILES/KEY_FILES/SUBDIRS/DEPENDENCIES, then L0 only for structural module changes. L1 does not contain INTERFACES, DATA_FLOW, TRAPS, or DECISIONS.
14
- 5. Preserve `PROJECT_BRIEF:` in `root.prizm`; it is managed by `/prizmkit-init`.
15
- 6. Do not write CHANGELOG sections/files, UPDATED/date metadata, feature/bug/refactor/task/session/run/pipeline/workflow IDs, branch names, absolute worktree paths, or `.prizmkit/specs` / `.prizmkit/dev-pipeline` artifact paths.
16
- 7. Skip updates for comments/whitespace/formatting-only changes, `.prizm`-only changes, and test-only changes that reveal no durable boundaries, traps, interface constraints, behavior rules, or regression knowledge.
17
- 8. If a new directory qualifies as a module and matches no existing module, create L1 immediately and add it to MODULE_INDEX or MODULE_GROUPS. Create L2 only when source files contain meaningful behavior worth documenting.
18
- 9. During full rescan mode, check for missing L2 docs only for modules with meaningful source behavior. Create L2 docs when the missing detail would help future AI work; do not create empty placeholder L2 files.
19
- 10. Enforce size limits: L0 <= 4KB, L1 <= 4KB, L2 <= 5KB.
20
- 11. Validate memory hygiene and format compliance.
21
- 12. Stage updated `.prizm` files with `git add .prizmkit/prizm-docs/` only after reviewing the repair summary.
11
+ 2. Map changed files to modules through MODULE_INDEX or MODULE_GROUPS in `root.prizm`, then resolve mirrored SUBDIRS or flat-module DETAILS ownership from the relevant L1.
12
+ 3. Classify each source change as A, D, M, or R, but do not mechanically turn changes into documentation. Treat every possible file, interface, dependency, flow, trap, decision, rule, and summary as a candidate and apply the future-incorrect-modification Value Gate.
13
+ 4. Before writing any existing L2, L1, or L0 target, read that target and its resolving parent/child pointers. Build a protected set of still-valid public/wire contracts, cross-module constraints, non-obvious dependencies, traps, decisions with necessary rationale, likely-to-recur rejected alternatives, side effects, and security/data-integrity/concurrency/transaction/compatibility rules.
14
+ 5. Apply the Cleanup Gate by semantic meaning:
15
+ - update an equivalent entry in place rather than appending alternate wording
16
+ - merge synonymous entries into one shortest complete meaning
17
+ - remove stale, duplicate, source-derivable, low-value, and parent-copied material
18
+ - add only a genuinely new durable fact with no semantic equivalent
19
+ Append-only repair is prohibited.
20
+ 6. Reconcile bottom-up. L2 owns Value-Gate-qualified INTERFACES/DATA_FLOW/DEPENDENCIES/RULES/TRAPS/DECISIONS. L1 owns concise FILES/KEY_FILES/SUBDIRS/DETAILS/DEPENDENCIES summaries. L0 changes only for project-map structure. When L2 has complete behavior, L0/L1 retain only a concise summary and resolving pointer, never copied interfaces, data flow, traps, decisions, or full RULES.
21
+ 7. Preserve `PROJECT_BRIEF:` in `root.prizm`; it is managed by `/prizmkit-init`. Do not write prohibited history, date, workflow, branch, absolute-path, or runtime-artifact metadata.
22
+ 8. Skip comments/whitespace/formatting-only changes, `.prizm`-only changes, and test-only changes that reveal no durable behavior boundary or fact passing the Value Gate.
23
+ 9. If a new top-level directory qualifies as a module, create its direct-child L1 and add a concise pointer to MODULE_INDEX or MODULE_GROUPS. Use MODULE_GROUPS whenever MODULE_INDEX cannot fit within 4096B; never raise the limit for project size.
24
+ 10. Create L2 only for durable behavioral knowledge:
25
+ - a real source submodule always uses its mirrored `.prizmkit/prizm-docs/<module>/<submodule>.prizm` path
26
+ - a flat module may use `.prizmkit/prizm-docs/<module>/<concern-slug>.prizm` only when multiple stable concerns cannot safely fit one 5120B L2 after cleanup
27
+ - semantic details require the complete CONCERN terminal shape, explicit non-empty/non-overlapping FILES ownership, and one resolving L1 DETAILS entry
28
+ - ambiguous concern identity, empty normalization, mirrored-path/slug collision, or overlapping ownership blocks creation and reports the manual decision; never use task IDs or numeric suffixes
29
+ 11. Measure all affected targets by exact raw UTF-8 bytes with L0/L1 4096B and L2 5120B limits. Natural content below 80% remains unchanged; warning-range content is valid and reported. Clean, move, or safely split rewritten targets at 90% or above toward 3277-3686B for L0/L1 or 4096-4607B for L2. If a hard-limit error or repeated pressure cannot be resolved without deleting protected knowledge, block the write.
30
+ 12. Validate Value/Cleanup compliance, parent-summary boundaries, semantic ownership/identity, pointers, hierarchy, capacity, memory hygiene, and format. Warning-only capacity results pass; hard-limit or format errors fail.
31
+ 13. Report updated, created, removed, merged, protected, and skipped facts/docs with reasons plus capacity diagnostics ordered by descending utilization.
32
+ 14. Stage updated `.prizm` files with `git add .prizmkit/prizm-docs/` only after reviewing the repair summary.
22
33
 
23
- OUTPUT: List updated, created, removed, and skipped docs with reasons. Explicitly state that this was an out-of-band repair/resync, not a normal development retrospective.
34
+ OUTPUT: List updated, created, removed, merged, protected, and skipped docs/facts with reasons; sorted capacity diagnostics; ambiguity blockers; and an explicit statement that this was out-of-band repair/resync, not a normal development retrospective.
@@ -5,13 +5,17 @@ Check format compliance and consistency of all .prizm docs.
5
5
  PRECONDITION: .prizmkit/prizm-docs/ exists.
6
6
 
7
7
  STEPS:
8
- 1. FORMAT CHECK: Verify all .prizm files use KEY: value format. Flag any prose paragraphs, code blocks (```), markdown headers (##), emoji, ASCII art, or horizontal rules. Flag TRAPS entries missing severity prefix ([CRITICAL], [HIGH], or [LOW]). Flag CHANGELOG sections/files, UPDATED/date metadata, feature/bug/refactor/task/session/run/pipeline/workflow IDs, branch names, absolute worktree paths, and `.prizmkit/specs` / `.prizmkit/dev-pipeline` artifact paths as auxiliary noise. Note: [REVIEW] preceding severity (e.g., `[REVIEW][HIGH]`) is a valid temporary staleness marker, not a format violation.
9
- 2. SIZE CHECK: Verify size limits: L0 <= 4KB, L1 <= 4KB, L2 <= 5KB. Report files exceeding limits with current size.
10
- 3. POINTER CHECK: Verify all arrow (->) references resolve to existing .prizm files. Report broken pointers.
11
- 4. STALENESS CHECK: Compare git modification time of each .prizm file against source directory. Flag docs where source was modified more recently.
12
- 5. COMPLETENESS CHECK: Verify root.prizm has all required fields (PRIZM_VERSION, PROJECT, LANG, MODULE_INDEX or MODULE_GROUPS). Verify L1 docs have MODULE, FILES, RESPONSIBILITY, DEPENDENCIES (no INTERFACES/TRAPS/DECISIONS). Verify L2 docs have MODULE, FILES, KEY_FILES, DEPENDENCIES, INTERFACES, TRAPS.
13
- 6. ANTI-PATTERN CHECK: Flag duplicate information across levels, implementation details in L0/L1, TODO items, session-specific context, changelog/history sections, and workflow metadata.
14
- 7. RULES HIERARCHY CHECK: Verify L1/L2 RULES do not contradict root.prizm RULES. L1/L2 may only supplement with module-specific exceptions.
15
- 8. TRAPS STALENESS CHECK: For each L2 doc where TRAPS section has more than 8 entries, verify that TRAPS include staleness metadata (`STALE_IF:` or `REF:` fields). Flag TRAPS without any staleness metadata as `NEEDS_METADATA` these are not auto-removed, but flagged for the next `/prizmkit-retrospective` to enrich with `STALE_IF:` globs or `REF:` hashes.
8
+ 1. FORMAT CHECK: Verify all `.prizm` files use KEY: value format. Flag prose paragraphs, code blocks, markdown headers, emoji, ASCII art, horizontal rules, invalid TRAPS severity, and prohibited history/date/workflow/branch/absolute/artifact metadata. `[REVIEW]` before severity remains a valid temporary staleness marker.
9
+ 2. VALUE CHECK: Flag source-derivable signatures/structure, task or change history, test inventories, temporary conclusions, stale statements, duplicate meanings, long procedures, low-value file lists, line-count/complexity inventories, and parent copies of complete child behavior. Do not flag a still-valid public/wire contract, cross-module constraint, non-obvious dependency, trap, durable decision/rejected rationale, side effect, or security/data-integrity/concurrency/transaction/compatibility rule merely because it consumes capacity.
10
+ 3. CAPACITY CHECK: Measure exact raw UTF-8 bytes. Classify only the exact root as L0/4096B, direct children as L1/4096B, and nested mirrored or semantic documents as L2/5120B. Bands are normal below 80%, warning from 80% to below 90%, strong-warning from 90% through 100%, and error above 100%.
11
+ 4. CAPACITY REPORT: Sort all non-normal entries by exact descending utilization using integer ratio comparison, then repository-relative path for ties. Every entry includes path, level, current bytes, hard limit, band, target range (3277-3686B for L0/L1; 4096-4607B for L2), and level-appropriate trim, deduplicate, move-to-child, or semantic-split actions consistent with the canonical F-063 classifier.
12
+ 5. CAPACITY RESULT: Warning and strong-warning entries are advisory and do not fail Validate when no other violation exists. Any byte above a hard limit is an error and fails; format, pointer, hierarchy, ownership, or completeness errors also fail and are never downgraded because capacity is only a warning.
13
+ 6. POINTER/PARENT CHECK: Verify every arrow resolves. L0/L1 contain concise summaries and pointers rather than copied L2 INTERFACES/DATA_FLOW/TRAPS/DECISIONS/full RULES. SUBDIRS targets mirrored source-submodule L2. DETAILS uses exactly `- <concern-slug>: <one-line stable behavior summary> -> .prizmkit/prizm-docs/<module>/<concern-slug>.prizm` and targets one matching semantic L2.
14
+ 7. SEMANTIC IDENTITY/OWNERSHIP CHECK: For each semantic L2, verify required fields MODULE, CONCERN, FILES, RESPONSIBILITY, INTERFACES, DATA_FLOW, KEY_FILES, DEPENDENCIES, RULES, TRAPS, and DECISIONS; verify `CONCERN: <stable concern identity> | SLUG: <concern-slug>`; rerun Unicode NFKC/lowercase/kebab normalization; require non-empty explicit repository-relative FILES ownership with no sibling overlap; and require exact parent/path/slug agreement. A mirrored source-submodule path has precedence. Ambiguous identity, collision, or overlap is a validation error requiring a manual decision, not a numbered or task-named repair.
15
+ 8. COMPLETENESS CHECK: Verify root has PRIZM_VERSION, PROJECT, LANG, and exactly one of MODULE_INDEX/MODULE_GROUPS. Verify L1 has MODULE, FILES, RESPONSIBILITY, DEPENDENCIES and no behavioral sections. Verify mirrored L2 has MODULE, FILES, RESPONSIBILITY, INTERFACES, KEY_FILES, DEPENDENCIES, and TRAPS with no CONCERN field; DATA_FLOW, RULES, DECISIONS, and domain sections remain optional when no fact passes the Value Gate. In semantic L2 only, explicit `<SECTION>: none` satisfies a required behavioral section when no fact passes the Value Gate.
16
+ 9. STALENESS CHECK: Compare each document's git modification time with its mapped source directory or semantic FILES ownership. Flag source-newer documents. Without git history, use filesystem timestamps and report reduced accuracy.
17
+ 10. RULES HIERARCHY CHECK: Verify L1/L2 RULES do not contradict authoritative root RULES.
18
+ 11. TRAPS STALENESS CHECK: When an L2 TRAPS section has more than 8 entries, flag entries lacking `STALE_IF:` or `REF:` as `NEEDS_METADATA`; do not auto-remove them.
19
+ 12. SCALE CHECK: If MODULE_INDEX cannot fit within L0, require MODULE_GROUPS. Never allow a project-size override, limits above 4096B/4096B/5120B, L3/fourth-level documents, a memory state machine, or a fact scoring system.
16
20
 
17
- OUTPUT: Validation report with PASS/FAIL per check, list of issues with file paths and suggested fixes.
21
+ OUTPUT: Validation report with PASS/FAIL per check, sorted non-normal capacity entries, issue paths with actionable fixes, and an exit result. Warning-only capacity diagnostics exit successfully; any hard-limit or other validation error exits nonzero.
@@ -1,155 +1,152 @@
1
1
  ---
2
2
  name: "prizmkit-retrospective"
3
- description: "Mandatory retrospective stage after a formal requirement passes code review and testing. Synchronizes durable Prizm documentation or records that no documentation change is needed, updates workflow state, and hands off to prizmkit-committer. (project)"
3
+ description: "Synchronize durable Prizm documentation for one caller-supplied project change, or record that no documentation update is warranted. Writes retrospective-result.json and returns RETRO_COMPLETE or RETRO_BLOCKED. (project)"
4
4
  ---
5
5
 
6
6
  # PrizmKit Retrospective
7
7
 
8
- `/prizmkit-retrospective` is the mandatory documentation and durable-knowledge stage after `prizmkit-test` returns `TEST_PASS`.
8
+ `/prizmkit-retrospective` synchronizes durable project documentation for one explicitly supplied project change. It performs targeted structural synchronization and durable knowledge injection, or records `NO_DOC_CHANGE` when no update passes the Value Gate.
9
9
 
10
- It performs two jobs:
10
+ For first-time documentation setup, validation, rebuild, migration, or out-of-band repair after docs drift, use `/prizmkit-prizm-docs` independently. Retrospective consumes the established Prizm documentation policy but never invokes that Skill.
11
11
 
12
- 1. **Structural Sync** — reflect changed code structure, interfaces, dependencies, and file mappings in `.prizmkit/prizm-docs/` when the documentation system exists.
13
- 2. **Knowledge Injection** — add durable TRAPS, RULES, and DECISIONS discovered during the task when such knowledge exists.
12
+ ## Input
14
13
 
15
- The stage must always run for a formal requirement. When no documentation update is warranted, it records `NO_DOC_CHANGE` as a successful retrospective result rather than silently skipping the stage.
14
+ | Parameter | Required | Description |
15
+ |---|---|---|
16
+ | `artifact_dir` | Yes | Exact caller-supplied directory in which to write `retrospective-result.json`. |
17
+ | `change_paths` | Yes | Exact caller-supplied non-`.prizmkit/` `change_paths` whose current project changes are the only authoritative documentation input. An explicit empty list is allowed only for a caller-requested no-change determination. |
18
+ | `change_summary` | No | Supporting context only; it cannot establish a fact that the supplied project paths do not establish. |
16
19
 
17
- For first-time documentation setup, validation, rebuild, migration, or out-of-band repair after docs drift, use `/prizmkit-prizm-docs` independently.
20
+ Do not discover a different artifact directory, expand the path set, or infer prerequisite work.
18
21
 
19
- ## Formal Lifecycle Position
22
+ ## Atomic Boundary
20
23
 
21
- ```text
22
- prizmkit-plan
23
- → prizmkit-implement
24
- → prizmkit-code-review
25
- → prizmkit-test
26
- → prizmkit-retrospective
27
- → prizmkit-committer
28
- ```
29
-
30
- ## Atomic Stage Boundary
24
+ `prizmkit-retrospective` owns only targeted structural documentation synchronization, durable knowledge injection, and `{artifact_dir}/retrospective-result.json` for the supplied paths. It does not invoke another Skill, does not read or mutate caller or checkpoint state, and does not choose stage order or routing.
31
25
 
32
- `prizmkit-retrospective` owns only structural documentation synchronization, durable knowledge injection, and retrospective result recording. It writes its truthful completion status and result plus `next_stage`, then returns control. It must not invoke `prizmkit-committer` itself; the active orchestrator owns the next-stage invocation.
26
+ It does not stage, commit, reset, checkout, or stash; it does not change Git/ignore policy; and it does not directly edit generated platform outputs. All paths under `.prizmkit/` are framework-internal and remain outside automated task commits. Capacity maintenance does not add a capacity state machine, fact scoring system, routing field, caller-state field, or fourth documentation level. The stage returns `RETRO_COMPLETE` or `RETRO_BLOCKED` and stops.
33
27
 
34
28
  ## When to Use
35
29
 
36
- - After `/prizmkit-test` returns `TEST_PASS` for a formal requirement.
37
- - When workflow state resumes a previously interrupted retrospective.
38
- - When the user explicitly requests a retrospective or documentation synchronization outside a formal requirement.
30
+ - A caller supplies exact project change paths that may affect durable documentation.
31
+ - A previously interrupted synchronization is resumed with the same exact inputs.
32
+ - The user explicitly requests a retrospective for one named project change.
39
33
 
40
34
  ## When NOT to Use
41
35
 
42
- - The requirement has not passed code review and testing.
43
- - `TEST_NEEDS_FIXES` or `TEST_BLOCKED` remains unresolved.
44
- - The request is a direct edit outside the formal requirement lifecycle, unless the user explicitly asks for documentation maintenance.
45
- - First-time docs initialization or out-of-band docs repair; use `/prizmkit-prizm-docs` instead.
36
+ - Required paths are missing, unsafe, contradictory, outside the checkout, under `.prizmkit/`, or cannot be inspected.
37
+ - The caller asks this Skill to discover what work should be documented.
38
+ - First-time initialization or repository-wide out-of-band drift repair is needed.
39
+
40
+ ## Exact Input Scope and Candidate Authority
41
+
42
+ Treat only the exact caller-supplied non-`.prizmkit/` `change_paths` as authoritative project-change input.
43
+
44
+ 1. Normalize `artifact_dir` and every path exactly as supplied without broadening the set.
45
+ 2. Reject paths outside the checkout, paths under `.prizmkit/`, and paths that do not belong to the supplied project change.
46
+ 3. Inspect the current change only through exact pathspecs for the validated paths. Use narrowly required source context only when one eligible change raises a concrete ambiguity about its interface, caller, dependent, data flow, or behavior.
47
+ 4. Generated artifacts, lifecycle records, caller metadata, `change_summary`, repository-wide discovery, and existing Prizm text must not independently establish a candidate fact or expand the input scope. Existing Prizm documents are target/current-state evidence only.
48
+ 5. Map exact changes to only the affected targets and their necessary direct parent summaries or pointers. Never perform an unconditional repository-wide documentation rewrite.
49
+ 6. If exact inputs cannot safely establish candidate or target scope, prepare `RETRO_BLOCKED` with the exact blocker.
50
+
51
+ Only targeted `.prizmkit/prizm-docs/` changes and `{artifact_dir}/retrospective-result.json` are outputs.
46
52
 
47
- ## Preconditions and Artifact Identity
53
+ ## Value and Cleanup Gates
48
54
 
49
- 1. Reuse the caller's `artifact_dir`; do not select another requirement.
50
- 2. Confirm the latest review result is `PASS`.
51
- 3. Confirm the latest testing result is `TEST_PASS`.
52
- 4. Read the final source diff with `.prizmkit/` excluded, then use `spec.md`, `plan.md`, the final `review-report.md`, `test-report.md`, and `test-result.json` only as supporting context for the non-`.prizmkit/` changes.
53
- 5. If the workflow state is missing or stale, reconstruct it from those authoritative artifacts and report the reconstruction.
55
+ Before retaining any candidate from an eligible source change, ask:
54
56
 
55
- `.prizmkit/` is always excluded from retrospective project-change input scope. Do not treat any file under `.prizmkit/`—including plans, artifacts, state, evidence, or existing Prizm docs—as a changed project file from which structural or durable knowledge is inferred. Required lifecycle state/evidence writes and targeted `.prizmkit/prizm-docs/` updates remain outputs; documentation changes must be justified only by observed non-`.prizmkit/` project changes.
57
+ > Could a future AI that lacks this fact make an incorrect modification?
56
58
 
57
- ## Job 1: Structural Sync
59
+ Retain a fact only when the answer is yes and the fact is current, durable, non-obvious, actionable, source-established, and placed at its lowest owning documentation level. Preserve rejected alternatives that future sessions are likely to propose again only when their durable reasons remain source-established.
58
60
 
59
- When `.prizmkit/prizm-docs/` exists, read `${SKILL_DIR}/references/structural-sync-steps.md` and synchronize documentation with the final codebase changes.
61
+ Reject source-derivable structure or signatures, transient conclusions, historical/task/change material, duplicate meanings, stale or conflicting statements, test inventories, long procedures, parent-copied behavior, and low-value file lists or wording.
60
62
 
61
- Review only changed project files outside `.prizmkit/`:
63
+ For every existing target:
62
64
 
63
- - added, modified, deleted, and renamed source files;
64
- - structural module files, configuration, interfaces, and tests when they reveal durable project behavior;
65
- - documentation mappings affected by those non-`.prizmkit/` project changes;
66
- - stale pointers and stale traps implicated by those project changes;
67
- - format, pointer, size, and memory-hygiene constraints for any docs the retrospective updates.
65
+ 1. Read each existing target before preparing its replacement, including the resolving parent/child pointers necessary for that target.
66
+ 2. Establish the protected set of still-valid contracts, constraints, traps, rules, data flow, dependencies, decisions, side effects, and safety/integrity knowledge.
67
+ 3. Match existing and candidate facts by semantic meaning; update the canonical entry in place, merge synonymous facts, and remove obsolete, stale, derivable, duplicate, conflicting, or parent-copied material.
68
+ 4. Add only genuinely new facts that pass the Value Gate and have no equivalent canonical entry. Append-only synchronization is prohibited.
68
69
 
69
- Never use `.prizmkit/` changes themselves as structural-sync input.
70
+ Read `${SKILL_DIR}/references/knowledge-injection-steps.md` for candidate extraction and injection details.
70
71
 
71
- When `.prizmkit/prizm-docs/` does not exist, do not pretend structural sync occurred. Record `NO_DOC_CHANGE` with reason `PRIZM_DOCS_NOT_INITIALIZED` and recommend `/prizmkit-init` or `/prizmkit-prizm-docs` for a future setup. The formal lifecycle may still continue because initialization is a soft prerequisite.
72
+ ## Capacity Preflight and Structural Sync
72
73
 
73
- Do not create an L2 document merely because one was missing during implementation. Create it only when the final change contains meaningful durable module knowledge.
74
+ Read `${SKILL_DIR}/references/structural-sync-steps.md` and run its preflight for every target before replacement:
74
75
 
75
- ## Job 2: Knowledge Injection
76
+ 1. Measure the existing target's exact raw UTF-8 bytes.
77
+ 2. Build the complete candidate result, including cleanup, before replacement and measure its exact raw UTF-8 bytes.
78
+ 3. Apply hard limits of 4096B for the root project map, 4096B for a direct module index, and 5120B for a nested detail document. Classify normal below 80%, warning from 80% to below 90%, strong-warning from 90% through the hard limit, and error above the hard limit.
79
+ 4. If current or candidate content reaches at least 80%, perform the minimum safe cleanup or semantic split before final replacement. Aim for 3277–3686B for a root/module index or 4096–4607B for a detail document, preserving approximately 10% headroom; never pad naturally concise output.
80
+ 5. Never delete protected knowledge merely to satisfy a byte check. If protected knowledge cannot fit, use an unambiguous stable semantic boundary or block safely.
76
81
 
77
- When the final project change outside `.prizmkit/` reveals durable knowledge, read `${SKILL_DIR}/references/knowledge-injection-steps.md` and inject only stable product/domain knowledge into Prizm docs.
82
+ Plan and write bottom-up: create or update the most specific detail first, then synchronize its direct module index and the root project map only as concise summaries and resolving pointers. Complete `INTERFACES`, `DATA_FLOW`, `TRAPS`, `DECISIONS`, and full `RULES` remain in the owning detail rather than being copied into parents.
78
83
 
79
- Candidate knowledge includes:
84
+ A real source submodule uses mirrored detail identity. An eligible flat module may use a deterministic semantic concern detail and direct-module `DETAILS` pointer only when the structural reference's identity, ownership, collision, and complete-terminal-shape checks pass.
80
85
 
81
- - new traps, race conditions, or surprising coupling;
82
- - architectural rules or decisions;
83
- - interface or contract changes;
84
- - dependencies affecting module behavior;
85
- - observable behavior changes;
86
- - test-discovered boundaries or regression rules.
86
+ ## Safe Write, Verification, and Idempotency
87
87
 
88
- Do not write transient artifact paths, task IDs, branch names, dates, session/run metadata, or changelog material into Prizm docs.
88
+ 1. Before the first write, preserve exact pre-write bytes for every existing target in the bounded affected set and record which candidates are new.
89
+ 2. Do not replace a target whose candidate already violates format, identity, pointer, protected-knowledge, or capacity checks.
90
+ 3. Write the validated affected set bottom-up. After each write, re-read the actual file rather than trusting the proposed content.
91
+ 4. Re-read every written `.prizm` file as raw bytes, recompute its raw UTF-8 byte length, apply its exact hard limit and warning band, validate its format, and resolve every affected pointer in both directions. Validate all affected parent and child documents, not only the last file written.
92
+ 5. Review the final targeted documentation diff. Never report `RETRO_COMPLETE` after a failed check.
93
+ 6. If any post-write check fails, restore every replaced target to its exact pre-write bytes and remove any invalid newly created target so no invalid oversized final document remains. Do not use Git reset, checkout, or stash for restoration.
94
+ 7. Compare each validated candidate with current target bytes before replacement. If byte-identical, do not rewrite or reorder the document. With identical source changes and inputs and no intervening project change, a second run produces no `.prizm` content diff and returns `NO_DOC_CHANGE` with an already-synchronized reason.
89
95
 
90
- When no durable structural or knowledge change exists, return `NO_DOC_CHANGE` and explain why.
96
+ When `.prizmkit/prizm-docs/` does not exist, record `NO_DOC_CHANGE` with reason `PRIZM_DOCS_NOT_INITIALIZED` and recommend initialization as a separate action.
91
97
 
92
- ## Verification and Staging
98
+ ## Capacity Blocker Contract
93
99
 
94
- 1. Validate any updated docs using the project documentation rules.
95
- 2. Review the final diff and ensure only intended documentation changes are present.
96
- 3. Do not change the target project's Git or ignore policy. If the host or project workflow stages docs, report what was staged; otherwise leave staging to `/prizmkit-committer`.
97
- 4. Never claim documentation synchronization passed if validation failed.
100
+ If protected knowledge cannot be compressed safely and no unambiguous stable split exists, do not leave the oversized candidate as final content. Restore any earlier writes from this attempt and write `RETRO_BLOCKED` with `result: null`.
98
101
 
99
- ## Retrospective Result
102
+ The existing seven fields carry all evidence; add no new field. Put the exact target path, measured current or candidate bytes, applicable limit/band, protected knowledge that prevented trimming, and concrete recommended split boundary in `reason`. Put only checks actually attempted, including candidate capacity or pointer checks, in `validation`. Preserve the exact supplied `change_paths`; `documentation_paths` follows the schema and lists only documentation paths actually changed during the attempt. Never invent validation or claim success after restoration/validation failure.
100
103
 
101
- Write `{artifact_dir}/retrospective-result.json` for every formal requirement:
104
+ ## Result Artifact
105
+
106
+ Read `${SKILL_DIR}/references/retrospective-result-schema.json` and atomically write `{artifact_dir}/retrospective-result.json` with exactly these seven keys:
102
107
 
103
108
  ```json
104
109
  {
105
- "status": "completed",
106
- "stage_result": "RETRO_COMPLETE",
110
+ "schema_version": 1,
111
+ "outcome": "RETRO_COMPLETE",
107
112
  "result": "DOCS_UPDATED",
108
- "reason": "Durable module interfaces and traps changed",
109
- "review_verdict": "PASS",
110
- "test_verdict": "TEST_PASS"
113
+ "reason": "Durable module contract changed and affected documentation passed validation",
114
+ "change_paths": ["src/example.py"],
115
+ "documentation_paths": [".prizmkit/prizm-docs/example/module.prizm"],
116
+ "validation": ["python3 core/templates/hooks/validate-prizm-docs.py --all"]
111
117
  }
112
118
  ```
113
119
 
114
- `status=completed` is the stable lifecycle status. `stage_result=RETRO_COMPLETE` marks successful retrospective completion; `result` must be exactly `DOCS_UPDATED` or `NO_DOC_CHANGE`. Use `result=NO_DOC_CHANGE` with a concrete reason when no documentation update is warranted. This artifact is the retrospective gate evidence consumed by the committer and external automation; workflow state alone does not prove completion.
115
-
116
- ## Workflow State and Handoff
117
-
118
- Before reading or updating workflow state, read `${SKILL_DIR}/references/workflow-state-protocol.md`.
120
+ Every retrospective artifact has exactly these seven keys: `schema_version`, `outcome`, `result`, `reason`, `change_paths`, `documentation_paths`, and `validation`.
119
121
 
120
- On successful completion, update `.prizmkit/state/workflows/<requirement-slug>.json`:
122
+ A capacity or validation blocker uses the same shape without adding state:
121
123
 
122
124
  ```json
123
125
  {
124
- "stage": "retrospective",
125
- "status": "completed",
126
- "stage_result": "RETRO_COMPLETE",
127
- "completed_stages": ["plan", "implement", "code-review", "test", "retrospective"],
128
- "next_stage": "committer",
129
- "resume_from": "prizmkit-committer"
126
+ "schema_version": 1,
127
+ "outcome": "RETRO_BLOCKED",
128
+ "result": null,
129
+ "reason": "Target .prizmkit/prizm-docs/example/module.prizm candidate=5200B limit=5120B; protected public contract prevents trimming; ownership check could not prove a stable split; recommended boundary: separate transport from persistence behavior",
130
+ "change_paths": ["src/example.py"],
131
+ "documentation_paths": [],
132
+ "validation": ["candidate raw UTF-8 capacity check: 5200B > 5120B", "semantic ownership check: ambiguous"]
130
133
  }
131
134
  ```
132
135
 
133
- Use `status=completed` and `stage_result=RETRO_COMPLETE` for both successful outcomes, with `result=DOCS_UPDATED` when durable docs changed or `result=NO_DOC_CHANGE` when the stage completed without a docs update. Both result values permit the commit stage.
136
+ - `RETRO_COMPLETE` pairs only with `DOCS_UPDATED` or `NO_DOC_CHANGE`.
137
+ - `DOCS_UPDATED` requires non-empty documentation and validation lists.
138
+ - `NO_DOC_CHANGE` uses a concrete reason and truthful empty or unchanged path evidence.
139
+ - `RETRO_BLOCKED` uses `result: null`, a non-empty exact reason, the exact input paths, only truthful documentation paths, and only checks actually attempted.
134
140
 
135
- If documentation validation or synchronization cannot safely complete, return `RETRO_BLOCKED`, do not commit, and provide the exact recovery entry.
141
+ Do not add checkpoint, routing, capacity-state, caller-state, evidence-manifest, hash, or attestation fields.
136
142
 
137
- ## Output and Handoff
143
+ ## Output
138
144
 
139
- Report:
145
+ Return only:
140
146
 
141
- - `{artifact_dir}/retrospective-result.json` with `DOCS_UPDATED` or `NO_DOC_CHANGE`;
142
- - docs updated, created, or intentionally unchanged;
143
- - durable knowledge decisions;
144
- - validation evidence;
145
- - workflow state path and status;
146
- - the same `artifact_dir` for the next stage.
147
-
148
- After `RETRO_COMPLETE`:
149
-
150
- ```text
151
- RETRO_COMPLETE
152
- → /prizmkit-committer
153
- ```
147
+ - `artifact_dir` and `retrospective-result.json` path;
148
+ - `RETRO_COMPLETE` with `DOCS_UPDATED` or `NO_DOC_CHANGE`, or `RETRO_BLOCKED` with the exact blocker;
149
+ - documentation paths updated or intentionally unchanged;
150
+ - durable knowledge decisions and validation evidence.
154
151
 
155
- If workflow state names an active `orchestrator`, return `RETRO_COMPLETE`, `stage_result`, the retrospective/state paths, and `next_stage=committer` to it; do not invoke the committer independently. For direct stage use, provide the deterministic `/prizmkit-committer` invocation; a host may perform that semantic handoff on the user's behalf.
152
+ Return only the listed retrospective outputs. Do not invoke another Skill.
@@ -1,51 +1,93 @@
1
- # Knowledge Injection — Detailed Steps (2a–2c)
1
+ # Knowledge Injection — Exact-Scope Value and Cleanup Steps
2
2
 
3
- **2a.** Gather context from the **actual project files changed outside `.prizmkit/`**:
3
+ ## 1. Establish candidate fact authority
4
4
 
5
- - `git diff HEAD -- . ':(exclude).prizmkit/**'` the source of truth for eligible project changes
6
- - Current Main-Agent context for the requirement — reuse it rather than rereading artifacts by default
7
- - Targeted unchanged source, interfaces, callers, dependents, or tests only when an eligible diff raises a concrete ambiguity
8
- - The affected Prizm docs only as update targets and existing-knowledge checks, never as changed project input
5
+ Gather candidate knowledge only from actual project changes in the exact validated non-`.prizmkit/` input paths:
9
6
 
10
- Do not scan or mine any `.prizmkit/` file for retrospective knowledge. Plans, review reports, test evidence, workflow state, and existing Prizm docs may describe transient or generated material; they must not create a retrospective fact independently of an observed non-`.prizmkit/` code or project-file change.
7
+ - `git diff HEAD -- <exact validated change_paths>` using literal pathspecs is the source of truth for eligible changes; never broaden the diff to `.` or use repository-wide status/discovery to add paths.
8
+ - Current source content at those exact paths may clarify the diff.
9
+ - Narrowly required unchanged source context (an interface, direct caller, direct dependent, or test) may be read only when an eligible diff raises a concrete ambiguity that cannot be resolved from the changed path itself.
10
+ - Existing affected Prizm docs may be read only as update targets, pointer maps, protected-current-knowledge evidence, and duplicate/staleness checks.
11
11
 
12
- **2b.** Extract knowledge from what was **observed in code**, not invented:
12
+ Generated artifacts, caller metadata, and existing Prizm text must not independently establish a candidate fact, expand `change_paths`, or turn an unrelated document into a target. `change_summary` is supporting context only. Reuse current Main-Agent source understanding when available, but do not treat lifecycle artifacts, completion notes, task IDs, or prior narrative as source evidence.
13
13
 
14
- **TRAPS** (highest priority) things that look safe but break:
15
- - Minimal format: `- [SEVERITY] <description> | FIX: <approach>`
16
- - Full format: `- [SEVERITY] <description> | FIX: <approach> | REF: <hash> | STALE_IF: <glob>`
17
- - Source: actual bugs hit, surprising behavior discovered in code, non-obvious coupling
14
+ ## 2. Apply the future-incorrect-modification Value Gate
18
15
 
19
- **TRAPS severity classification**:
20
- - `[CRITICAL]`: data loss, security, financial error, system crash
21
- - `[HIGH]`: functional failure, silent error, interface incompatibility
22
- - `[LOW]`: misleading naming, non-intuitive API, minor performance issue
16
+ For every candidate, ask exactly:
23
17
 
24
- When writing TRAPS:
25
- - Severity prefix is MANDATORY (e.g., `[CRITICAL]`, `[HIGH]`, `[LOW]`)
26
- - OPTIONAL: append `| REF: <7-char-hash>` when you know the relevant commit (for traceability)
27
- - OPTIONAL: append `| STALE_IF: <glob>` when the TRAP is tightly coupled to specific files (for auto-expiry detection)
18
+ > Could a future AI that lacks this fact make an incorrect modification?
28
19
 
29
- **Consuming [REVIEW] markers** (from staleness check 1g):
30
- - If you encounter a TRAP prefixed with `[REVIEW]` (e.g., `[REVIEW][HIGH] ...`), verify whether the trap is still valid by checking the current code. If still valid: remove the `[REVIEW]` prefix, keeping the severity. If no longer relevant: delete the TRAP entry.
20
+ Retain it only when the answer is yes and current eligible source proves that it is durable, non-obvious, actionable for future modification, and owned by the target level.
31
21
 
32
- **RULES** conventions established or constraints discovered:
33
- - Format: `- MUST/NEVER/PREFER: <rule>`
34
- - Source: patterns that proved necessary during implementation
22
+ High-value candidate classes include:
35
23
 
36
- **DECISIONS** key design choices that affect future development:
37
- - Format: `- <what was decided> <rationale>`
38
- - Source: non-obvious design choices, interface conventions, cross-module contracts
39
- - Only record decisions that a future AI session would benefit from knowing
40
- - Do NOT record obvious implementation details that can be derived by reading the code
24
+ - non-obvious public interfaces and wire contracts;
25
+ - data flow, side effects, transactions, integrity boundaries, or surprising coupling;
26
+ - cross-module constraints and non-obvious dependencies;
27
+ - security, data-integrity, concurrency, transaction, and compatibility rules;
28
+ - actual traps, race conditions, failure modes, or unsafe-looking alternatives;
29
+ - architectural rules or durable decisions with rationale;
30
+ - observable behavior boundaries whose omission could cause a regression;
31
+ - rejected alternatives that future sessions are likely to propose again.
41
32
 
42
- **QUALITY GATE**: Every item must answer: "If a new AI session reads only `.prizmkit/prizm-docs/` and this entry, does it gain actionable understanding?" If not, discard. Do not record trivially observable code patterns the AI can read the code directly.
33
+ For a likely-to-recur rejected alternative, retain the alternative and its reason only when current eligible source establishes both. Do not retain a rejected option merely as design history.
43
34
 
44
- **MEMORY HYGIENE GATE**: Before writing any `.prizmkit/prizm-docs/` entry, remove or translate workflow metadata. Never write CHANGELOG sections/files, UPDATED/date metadata, feature/bug/refactor/task/session/run/pipeline/workflow IDs, branch names, absolute worktree paths, or `.prizmkit/specs` / `.prizmkit/dev-pipeline` artifact paths. If source artifacts say "fixed in B-001" or "implemented in F-003", write only the durable product/domain fact.
35
+ Reject candidates that are source-derivable structure or signatures, transient implementation conclusions, historical task/change narrative, duplicate meanings, stale/conflicting statements, test inventories, coverage lists, routine file inventories, long procedures, low-value wording, or behavior already complete in a more specific child.
45
36
 
46
- **2c.** Inject into the correct `.prizmkit/prizm-docs/` file:
47
- - Module-level TRAPS/RULES/DECISIONS → the affected **L2** `.prizm` file. If the target L2 does not exist, create it first using the L2 GENERATION TEMPLATE before injecting knowledge. (TRAPS/DECISIONS/RULES belong in L2, not L1.)
48
- - Project-level RULES/PATTERNS → `root.prizm` (respect the current format — MODULE_INDEX or MODULE_GROUPS — do not convert between them during injection)
49
- - Cross-module concerns spanning 2+ modules → `root.prizm` CROSS_CUTTING section
37
+ ## 3. Extract only observed durable knowledge
50
38
 
51
- **RULE**: Only add genuinely new information. Never duplicate existing entries. Never rewrite entire files.
39
+ ### TRAPS
40
+
41
+ Use `- [SEVERITY] <description> | FIX: <approach>` and include only source-established non-obvious failure risks.
42
+
43
+ - `[CRITICAL]`: data loss, security failure, financial error, or crash.
44
+ - `[HIGH]`: functional failure, silent error, data-integrity risk, or interface incompatibility.
45
+ - `[LOW]`: misleading naming, non-intuitive API, or minor quality/performance risk that still passes the Value Gate.
46
+
47
+ Optional `REF` or `STALE_IF` metadata is allowed only when it is durable and source-relevant. For an affected `[REVIEW]` trap, remove the marker only when exact eligible source proves it still valid; delete it only when that source proves it obsolete. Lack of narrow evidence is not permission to delete it.
48
+
49
+ ### RULES
50
+
51
+ Use `- MUST/NEVER/PREFER: <rule>`. Keep only constraints that a future modification must obey and that eligible source establishes.
52
+
53
+ ### DECISIONS and rejected alternatives
54
+
55
+ Use `- <decision> — <durable rationale>` or `- REJECTED: <likely recurring alternative> — <why it remains rejected>`. Do not record obvious implementation choices or historical deliberation.
56
+
57
+ ### Interfaces and behavior
58
+
59
+ Retain only non-obvious public/wire contracts, data flow, side effects, dependencies, and observable boundaries whose absence could cause an incorrect modification. Omit signatures and structure that direct source reading makes obvious.
60
+
61
+ ## 4. Reconcile the current target before insertion
62
+
63
+ For every bounded affected target:
64
+
65
+ 1. Read its current content and the necessary resolving direct parent/child pointers.
66
+ 2. Build the protected set defined by the structural sync procedure before removing anything.
67
+ 3. Match by semantic meaning, not exact wording.
68
+ 4. Update the canonical entry in place when source changes an equivalent or conflicting fact; merge synonyms into one concise meaning.
69
+ 5. Remove only source-proven obsolete facts plus stale, derivable, duplicate, low-value, or parent-copied material outside the protected set.
70
+ 6. Add a candidate only when it passes the Value Gate and no equivalent canonical entry remains.
71
+ 7. Preserve stable section and entry order; do not reorder unchanged entries or append alternate wording merely to make a diff.
72
+
73
+ Append-only injection is prohibited. Cleanup remains limited to the exact affected targets and their necessary direct parent summaries/pointers; do not opportunistically clean siblings.
74
+
75
+ ## 5. Place knowledge at the lowest owning level
76
+
77
+ - Module behavioral details, `INTERFACES`, `DATA_FLOW`, `TRAPS`, complete `RULES`, `DECISIONS`, and rejected alternatives belong in the most specific mirrored or deterministic semantic detail.
78
+ - A real source-submodule boundary uses mirrored detail identity first.
79
+ - A flat module uses a semantic concern detail only when the structural procedure proves stable deterministic identity, explicit non-overlapping source-file ownership, capacity need, complete terminal shape, and a resolving direct-module `DETAILS` pointer.
80
+ - A direct module index keeps concise structure, navigation, critical summaries, and pointers; it does not copy complete child behavior.
81
+ - The root project map keeps only concise navigation and genuinely project-wide/cross-module summaries. An exact eligible change must establish the project-wide fact; existing root text cannot create one.
82
+
83
+ When one eligible change truly spans multiple affected modules, place complete knowledge in the lowest owning details and retain only the shortest useful cross-module summary/pointers at root. Do not infer cross-module scope from unrelated existing documentation.
84
+
85
+ ## 6. Hand candidate results to capacity preflight
86
+
87
+ Do not write directly from extraction. Hand the complete cleaned candidate, protected set, exact target identity, and affected direct pointers to `structural-sync-steps.md` for raw UTF-8 size measurement, minimum safe cleanup or semantic split, bottom-up replacement, re-read validation, and safe restoration.
88
+
89
+ If no candidate survives the Value Gate and structural reconciliation produces no byte change, return a truthful `NO_DOC_CHANGE`. A repeated run over identical source and inputs must preserve byte-identical documentation and must not create duplicate, reorder-only, or synonym-only churn.
90
+
91
+ ## 7. Enforce memory hygiene
92
+
93
+ Before final candidate validation, remove CHANGELOG sections/files, UPDATED/date metadata, feature/bug/refactor/task/session/run/pipeline/workflow IDs, branch names, absolute worktree paths, and `.prizmkit/specs` or `.prizmkit/dev-pipeline` artifact paths. Never trade protected durable product/domain knowledge for traceability noise.