prizmkit 1.0.124 → 1.0.125

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "frameworkVersion": "1.0.124",
3
- "bundledAt": "2026-03-27T18:24:06.959Z",
4
- "bundledFrom": "a7ba656"
2
+ "frameworkVersion": "1.0.125",
3
+ "bundledAt": "2026-03-27T19:33:35.398Z",
4
+ "bundledFrom": "ae0bada"
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.124",
2
+ "version": "1.0.125",
3
3
  "skills": {
4
4
  "prizm-kit": {
5
5
  "description": "Full-lifecycle dev toolkit. Covers spec-driven development, Prizm context docs, code quality, debugging, deployment, and knowledge management.",
@@ -44,21 +44,22 @@ PRECONDITION: No .prizm-docs/ directory exists, or user confirms overwrite.
44
44
 
45
45
  STEPS:
46
46
  1. Detect project type by scanning for build system files (go.mod, package.json, requirements.txt, Cargo.toml, pom.xml, *.csproj). Identify primary language, framework, build command, test command, and entry points.
47
- 2. Discover modules in TWO tiers flat structures lose nesting relationships, and when two modules share an identically-named sub-module (e.g., `utils/`), flattening creates ambiguous paths:
48
- - TOP-LEVEL modules: directories directly under project root (or under src/ for src-based layouts) that contain 3+ source files OR contain sub-directories with 3+ source files. These go into MODULE_INDEX.
49
- - SUB-MODULES: directories INSIDE a top-level module that contain 3+ source files. Listed in the parent L1 doc's SUBDIRS section only.
47
+ 2. Discover modules using semantic MODULE_DISCOVERY_CRITERIA (see PRIZM-SPEC Section 9.1 Step 2):
48
+ - A directory qualifies as a module if it contains source files forming a logical unit, contains entry/config/interface files, contains qualifying sub-modules, or is referenced by multiple modules as a dependency.
49
+ - TOP-LEVEL modules: directories directly under project root (or under src/ for src-based layouts) that qualify.
50
+ - SUB-MODULES: directories INSIDE a top-level module that qualify. Listed in the parent L1 doc's SUBDIRS section.
50
51
  - HIERARCHY RULE: directory X inside top-level module M maps to .prizm-docs/<M>/<X>.prizm, never to .prizm-docs/<X>.prizm.
51
- - Exclude .git/, node_modules/, vendor/, build/, dist/, __pycache__/, target/, bin/, .claude/, .codebuddy/, .prizmkit/, .prizm-docs/, dev-pipeline/. If top-level module count > 30, ask user for include/exclude patterns.
52
+ - Exclude .git/, node_modules/, vendor/, build/, dist/, __pycache__/, target/, bin/, .claude/, .codebuddy/, .prizmkit/, .prizm-docs/, dev-pipeline/. If total module count > 30, ask user for include/exclude patterns.
52
53
  3. Create .prizm-docs/ directory structure mirroring the source tree exactly. For each top-level module M that has sub-modules, create the subdirectory .prizm-docs/<M>/.
53
- 4. Generate root.prizm (L0) with PROJECT, LANG, FRAMEWORK, BUILD, TEST, ENTRY, MODULE_INDEX listing only top-level modules with arrow pointers to .prizm-docs/<M>.prizm (sub-modules stay out of MODULE_INDEX to keep L0 compact and within the 4KB limit), RULES extracted from CODEBUDDY.md/CLAUDE.md/README/linter configs, and PATTERNS. Set PRIZM_VERSION: 2, UPDATED: today's date. Max 4KB.
54
- 5. Generate L1 .prizm files for ALL modules (top-level and sub-modules), each at its correct mirrored path:
54
+ 4. Generate root.prizm (L0) with PROJECT, LANG, FRAMEWORK, BUILD, TEST, ENTRY, MODULE_INDEX with multi-level entries as needed for efficient navigation (constrained by 4KB limit), RULES extracted from CODEBUDDY.md/CLAUDE.md/README/linter configs, PATTERNS, and CROSS_CUTTING (cross-module concerns spanning 2+ modules). Set PRIZM_VERSION: 4. Max 4KB. No UPDATED timestamp git tracks modification times.
55
+ 5. Generate L1 .prizm files (structural index only) for ALL modules, each at its correct mirrored path:
55
56
  - Top-level module M → write .prizm-docs/<M>.prizm (include SUBDIRS section with pointers to sub-module docs)
56
57
  - Sub-module S inside M → write .prizm-docs/<M>/<S>.prizm
57
- Each L1 includes MODULE (full relative path), FILES count, RESPONSIBILITY, SUBDIRS with pointers (for top-level only), KEY_FILES (5-10 most important), INTERFACES (public/exported only), DEPENDENCIES (imports, imported-by, external), RULES, DATA_FLOW. Max 3KB each.
58
- 6. Skip L2 docs during init — L2 is created lazily on first file modification or when AI needs deep understanding (ON_DEEP_READ trigger). This saves significant upfront token cost on large projects.
58
+ Each L1 includes MODULE (full relative path), FILES count, RESPONSIBILITY, SUBDIRS with pointers, KEY_FILES (5-10 most important), DEPENDENCIES (imports, imported-by, external), RULES (1-3 most critical only). L1 does NOT include INTERFACES, DATA_FLOW, TRAPS, or DECISIONS (those are L2, generated lazily). Max 4KB each.
59
+ 6. Skip L2 docs during init — L2 is created lazily on first file modification or when AI needs deep understanding (ON_DEEP_READ trigger). L2 contains behavioral detail: INTERFACES, DATA_FLOW, TRAPS, DECISIONS, full RULES, domain-specific sections.
59
60
  7. Create changelog.prizm with initial entry: `- YYYY-MM-DD | root | add: initialized prizm documentation framework`
60
61
  8. Configure UserPromptSubmit hook in platform settings per ${SKILL_DIR}/assets/PRIZM-SPEC.md Section 11.
61
- 9. Validate all generated docs: size limits (L0 <= 4KB, L1 <= 3KB), pointer resolution (every -> reference resolves), no circular dependencies, UPDATED timestamps set, KEY: value format compliance, no anti-patterns (prose, code blocks, markdown headers).
62
+ 9. Validate all generated docs: size limits (L0 <= 4KB, L1 <= 4KB), pointer resolution (every -> reference resolves), no circular dependencies, KEY: value format compliance, no anti-patterns (prose, code blocks, markdown headers), L1 does not contain INTERFACES/DATA_FLOW/TRAPS/DECISIONS, no UPDATED timestamps (git is authority).
62
63
  10. Report summary: modules discovered, L1 docs generated, files excluded, warnings.
63
64
 
64
65
  OUTPUT: List of generated files, module count, and validation results.
@@ -72,12 +73,12 @@ PRECONDITION: .prizm-docs/ exists with root.prizm.
72
73
  STEPS:
73
74
  1. Get changed files via `git diff --cached --name-status`. If nothing staged, use `git diff --name-status`. If no git changes at all, do full rescan comparing code against existing docs.
74
75
  2. Map changed files to modules by matching against MODULE_INDEX in root.prizm. Group changes by module.
75
- 3. Classify each change: A (added) -> new KEY_FILES/INTERFACES entries. D (deleted) -> remove entries, update counts. M (modified) -> check interface/dependency changes. R (renamed) -> update all path references.
76
- 4. Update affected docs: L2 first (KEY_FILES, INTERFACES, DEPENDENCIES, CHANGELOG, UPDATED), then L1 (FILES count, KEY_FILES, INTERFACES, DEPENDENCIES, UPDATED), then L0 (MODULE_INDEX counts, UPDATED) only if structural change.
77
- 5. Skip updates if: only internal implementation changed (no interface/dependency change), only comments/whitespace/formatting, only test files changed, only .prizm files changed, bug fixes to existing features (bugs are incomplete features being refined no new module/interface created, no doc update needed).
78
- 6. If new directory with 3+ source files appears and matches no module: create L1 immediately, add to MODULE_INDEX, defer L2.
76
+ 3. Classify each change: A (added) -> new KEY_FILES entries. D (deleted) -> remove entries, update counts. M (modified) -> check dependency changes. R (renamed) -> update all path references.
77
+ 4. Update affected docs: L2 first (KEY_FILES, INTERFACES, DATA_FLOW, DEPENDENCIES, TRAPS, CHANGELOG), then L1 (FILES count, KEY_FILES, DEPENDENCIES — L1 does NOT contain INTERFACES/DATA_FLOW/TRAPS/DECISIONS), then L0 (MODULE_INDEX counts, CROSS_CUTTING) only if structural change. No UPDATED timestamps — git tracks modification times.
78
+ 5. Skip updates if: only internal implementation changed (no interface/dependency change), only comments/whitespace/formatting, only .prizm files changed. DO NOT skip test file changes or bug fixesthey may reveal TRAPS worth capturing in L2.
79
+ 6. If new directory qualifies as a module (per MODULE_DISCOVERY_CRITERIA) and matches no existing module: create L1 immediately, add to MODULE_INDEX, defer L2.
79
80
  7. Append entries to changelog.prizm using format: `- YYYY-MM-DD | <module-path> | <verb>: <description>`
80
- 8. Enforce size limits: L0 > 4KB -> consolidate. L1 > 3KB -> move details to L2. L2 > 5KB -> split or archive.
81
+ 8. Enforce size limits: L0 > 4KB -> consolidate. L1 > 4KB -> trim KEY_FILES descriptions, ensure RULES <= 3 entries. L2 > 5KB -> split or archive.
81
82
  9. Stage updated .prizm files via `git add .prizm-docs/`
82
83
 
83
84
  OUTPUT: List of updated/created/skipped docs with reasons.
@@ -89,13 +90,13 @@ Check freshness of all .prizm docs.
89
90
  PRECONDITION: .prizm-docs/ exists with root.prizm.
90
91
 
91
92
  STEPS:
92
- 1. Read root.prizm UPDATED timestamp.
93
- 2. Count commits since that timestamp via `git log --since="<timestamp>" --oneline | wc -l`.
94
- 3. For each L1/L2 doc, compare UPDATED timestamp against latest git modification of source files in that module via `git log -1 --format="%ai" -- <module-path>/`.
95
- 4. Classify each doc as: FRESH (updated after latest source change), STALE (source changed since last update), MISSING (module exists but no .prizm doc).
93
+ 1. Get last git modification time of root.prizm via `git log -1 --format="%ai" -- .prizm-docs/root.prizm`.
94
+ 2. Count commits since that time via `git log --since="<timestamp>" --oneline | wc -l`.
95
+ 3. For each L1/L2 doc, compare git modification time of the .prizm file (`git log -1 --format="%ai" -- <prizm-file>`) against latest git modification of source files in that module (`git log -1 --format="%ai" -- <module-path>/`).
96
+ 4. Classify each doc as: FRESH (prizm file updated after latest source change), STALE (source changed more recently than prizm file), MISSING (module exists but no .prizm doc).
96
97
  5. Flag any docs exceeding size limits.
97
98
 
98
- OUTPUT: Freshness report table with columns: DOC_PATH | LEVEL | STATUS | LAST_UPDATED | SOURCE_LAST_MODIFIED.
99
+ OUTPUT: Freshness report table with columns: DOC_PATH | LEVEL | STATUS | PRIZM_LAST_MOD | SOURCE_LAST_MOD.
99
100
 
100
101
  ## Operation: Rebuild
101
102
 
@@ -124,8 +125,8 @@ STEPS:
124
125
  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]). Note: [REVIEW] preceding severity (e.g., `[REVIEW][HIGH]`) is a valid temporary staleness marker, not a format violation.
125
126
  2. SIZE CHECK: Verify size limits: L0 <= 4KB, L1 <= 3KB, L2 <= 5KB. Report files exceeding limits with current size.
126
127
  3. POINTER CHECK: Verify all arrow (->) references resolve to existing .prizm files. Report broken pointers.
127
- 4. TIMESTAMP CHECK: Verify all docs have UPDATED field. Flag docs with UPDATED older than 30 days as potentially stale.
128
- 5. COMPLETENESS CHECK: Verify root.prizm has all required fields (PRIZM_VERSION, PROJECT, LANG, MODULE_INDEX). Verify L1 docs have MODULE, FILES, RESPONSIBILITY, INTERFACES, DEPENDENCIES. Verify L2 docs have MODULE, FILES, KEY_FILES, DEPENDENCIES.
128
+ 4. STALENESS CHECK: Compare git modification time of each .prizm file against source directory. Flag docs where source was modified more recently.
129
+ 5. COMPLETENESS CHECK: Verify root.prizm has all required fields (PRIZM_VERSION, PROJECT, LANG, MODULE_INDEX). Verify L1 docs have MODULE, FILES, RESPONSIBILITY, DEPENDENCIES (no INTERFACES/TRAPS/DECISIONS). Verify L2 docs have MODULE, FILES, KEY_FILES, DEPENDENCIES, INTERFACES, TRAPS.
129
130
  6. ANTI-PATTERN CHECK: Flag duplicate information across levels, implementation details in L0/L1, TODO items, session-specific context.
130
131
  7. RULES HIERARCHY CHECK: Verify L1/L2 RULES do not contradict root.prizm RULES. L1/L2 may only supplement with module-specific exceptions.
131
132
 
@@ -1,4 +1,4 @@
1
- PRIZM_SPEC_VERSION: 3
1
+ PRIZM_SPEC_VERSION: 4
2
2
  PURPOSE: AI-only documentation framework for vibe coding projects
3
3
  AUDIENCE: AI agents (not humans)
4
4
  FORMAT: KEY: value pairs, ALL CAPS section headers, arrow pointers
@@ -35,13 +35,14 @@ LEVELS:
35
35
  FILE: .prizm-docs/root.prizm
36
36
  CONTAINS: project meta, module index with pointers, build commands, tech stack, top rules
37
37
 
38
- - L1: Module index. Loaded ON DEMAND when AI works in a module area. Max 3KB each.
38
+ - L1: Structural index. Loaded ON DEMAND when AI works in a module area. Max 4KB each.
39
39
  FILE: .prizm-docs/<mirrored-path>.prizm (mirrors source directory structure)
40
- CONTAINS: module responsibility, subdirs with pointers, key files, interfaces, dependencies, rules
40
+ CONTAINS: module responsibility, subdirs with pointers, key files, dependency graph, critical rules summary (1-3 only)
41
+ DOES NOT CONTAIN: interface signatures, data flow, TRAPS, DECISIONS (those belong in L2)
41
42
 
42
- - L2: Detail doc. Loaded when AI modifies files in that sub-module OR needs deep understanding. Max 5KB each.
43
+ - L2: Behavioral detail. Loaded when AI modifies files in that module OR needs deep understanding. Max 5KB each.
43
44
  FILE: .prizm-docs/<mirrored-path>/<submodule>.prizm
44
- CONTAINS: full file inventory, domain-specific sections, decisions log, traps, rejected approaches
45
+ CONTAINS: interface signatures, data flow, full rules, TRAPS, DECISIONS, domain-specific sections, rejected approaches
45
46
 
46
47
  - Changelog: Append-only change log. Loaded at L0. No size limit but keep last 50 entries.
47
48
  FILE: .prizm-docs/changelog.prizm
@@ -93,6 +94,8 @@ EXAMPLE (Python project):
93
94
  services.prizm # L1 for app/services/
94
95
  services/
95
96
  payment.prizm # L2 for app/services/payment/
97
+ cross-cutting/ # Optional: cross-module concern details
98
+ auth.prizm # L2-style doc for cross-cutting auth concern
96
99
 
97
100
  ## 2.3 Git Configuration
98
101
 
@@ -107,14 +110,13 @@ RATIONALE: .prizm-docs/ is shared project knowledge that all team members (human
107
110
 
108
111
  TEMPLATE:
109
112
 
110
- PRIZM_VERSION: 2
113
+ PRIZM_VERSION: 4
111
114
  PROJECT: <name>
112
115
  LANG: <primary language>
113
116
  FRAMEWORK: <primary framework or "none">
114
117
  BUILD: <build command>
115
118
  TEST: <test command>
116
119
  ENTRY: <entry point file(s)>
117
- UPDATED: <YYYY-MM-DD>
118
120
 
119
121
  ARCHITECTURE: <layer1> -> <layer2> -> <layer3> -> ...
120
122
  LAYERS:
@@ -127,6 +129,8 @@ TEMPLATE:
127
129
 
128
130
  MODULE_INDEX:
129
131
  - <source-path>: <file-count> files. <one-line description>. -> .prizm-docs/<mirrored-path>.prizm
132
+ (Multi-level entries allowed for efficient navigation. No hard depth limit — constrained by L0 4KB.
133
+ If navigating from L0 to a target module requires 3+ hops, add intermediate entries here.)
130
134
 
131
135
  ENTRY_POINTS:
132
136
  - <name>: <file-path> (<protocol/port if applicable>)
@@ -139,26 +143,31 @@ TEMPLATE:
139
143
  PATTERNS:
140
144
  - <pattern-name>: <one-line description of code pattern used across project>
141
145
 
146
+ CROSS_CUTTING:
147
+ - <concern-name>: <one-line description>. Modules: <affected-module-list>.
148
+ (Optional: -> .prizm-docs/cross-cutting/<name>.prizm for detailed cross-cutting doc.
149
+ Only record concerns spanning 2+ modules. Single-module patterns go in that module's RULES.)
150
+
142
151
  DECISIONS:
143
- - [YYYY-MM-DD] <project-level architectural decision and rationale>
152
+ - <project-level architectural decision and rationale>
144
153
  - REJECTED: <rejected approach + why>
145
154
 
146
155
  CONSTRAINTS:
147
156
  - Max 4KB (roughly 100 lines)
148
157
  - Every line must be a KEY: value pair or a list item
149
158
  - MODULE_INDEX must have arrow pointer (->) for every entry
159
+ - MODULE_INDEX may list entries at any depth needed for efficient navigation (no hard depth limit)
150
160
  - RULES limited to 5-10 most critical conventions
151
161
  - No prose paragraphs
152
162
  - root.prizm RULES are AUTHORITATIVE: they override any conflicting L1/L2 RULES
153
163
 
154
- ## 3.2 L1: module.prizm
164
+ ## 3.2 L1: module.prizm (Structural Index)
155
165
 
156
166
  TEMPLATE:
157
167
 
158
168
  MODULE: <source-path>
159
169
  FILES: <count>
160
170
  RESPONSIBILITY: <one-line>
161
- UPDATED: <YYYY-MM-DD>
162
171
 
163
172
  SUBDIRS:
164
173
  - <name>/: <one-line description>. -> .prizm-docs/<child-path>.prizm
@@ -166,37 +175,23 @@ TEMPLATE:
166
175
  KEY_FILES:
167
176
  - <filename>: <role/purpose>
168
177
 
169
- INTERFACES:
170
- - <function/method signature>: <what it does>
171
-
172
178
  DEPENDENCIES:
173
179
  - imports: <internal modules this module uses>
174
180
  - imported-by: <internal modules that depend on this>
175
181
  - external: <third-party packages used>
176
182
 
177
183
  RULES:
178
- - MUST: <module-specific mandatory rule>
179
- - NEVER: <module-specific prohibition>
180
- - PREFER: <module-specific preference>
181
-
182
- TRAPS:
183
- - [CRITICAL|HIGH|LOW] <what looks safe but is dangerous> | FIX: <correct approach>
184
-
185
- DECISIONS:
186
- - <what was decided> — <rationale>
187
-
188
- DATA_FLOW:
189
- - <numbered step describing how data moves through this module>
184
+ - MUST: <1-3 most critical module-specific rules only — full list in L2>
190
185
 
191
186
  CONSTRAINTS:
192
- - Max 3KB
193
- - INTERFACES lists only PUBLIC/EXPORTED signatures
187
+ - Max 4KB
188
+ - L1 is a STRUCTURAL INDEX — it answers "what exists here" not "how it works"
189
+ - DOES NOT CONTAIN: INTERFACES, DATA_FLOW, TRAPS, DECISIONS (those belong in L2)
190
+ - RULES: summary only, max 3 entries of the most critical constraints. Full rules in L2.
194
191
  - DEPENDENCIES has 3 sub-categories (imports, imported-by, external)
195
- - SUBDIRS entries must have arrow pointer (->) if L2 doc exists
192
+ - SUBDIRS entries must have arrow pointer (->) if child doc exists
196
193
  - KEY_FILES lists only the most important files (max 10-15)
197
194
  - RULES may only SUPPLEMENT root.prizm RULES with module-specific exceptions, never contradict them
198
- - TRAPS entries MUST have severity prefix ([CRITICAL], [HIGH], or [LOW]). [REVIEW] may precede severity as a temporary staleness marker.
199
- - TRAPS optional fields: append `| REF: <7-char-hash>` for traceability, `| STALE_IF: <glob>` for auto-expiry detection
200
195
 
201
196
  TRAPS_FORMAT_REFERENCE (spec-only — do NOT include this block in generated .prizm files):
202
197
  - Severity levels: CRITICAL = data loss/security/financial/crash, HIGH = functional failure/silent error, LOW = naming/minor quality
@@ -206,14 +201,19 @@ TRAPS_FORMAT_REFERENCE (spec-only — do NOT include this block in generated .pr
206
201
  - Minimal valid format: `- [SEVERITY] <description> | FIX: <approach>`
207
202
  - Full format: `- [SEVERITY] <description> | FIX: <approach> | REF: <hash> | STALE_IF: <glob>`
208
203
 
209
- ## 3.3 L2: detail.prizm
204
+ ## 3.3 L2: detail.prizm (Behavioral Detail)
210
205
 
211
206
  TEMPLATE:
212
207
 
213
208
  MODULE: <source-path>
214
209
  FILES: <comma-separated list of all files>
215
210
  RESPONSIBILITY: <one-line>
216
- UPDATED: <YYYY-MM-DD>
211
+
212
+ INTERFACES:
213
+ - <function/method signature>: <what it does>
214
+
215
+ DATA_FLOW:
216
+ - <numbered step describing how data moves through this module>
217
217
 
218
218
  <DOMAIN-SPECIFIC SECTIONS>
219
219
  (AI generates these based on what the module does. Examples below.)
@@ -225,16 +225,22 @@ TEMPLATE:
225
225
  - uses: <external lib>: <why/how used>
226
226
  - imports: <internal module>: <which interfaces consumed>
227
227
 
228
- DECISIONS:
229
- - [YYYY-MM-DD] <decision made within this module and rationale>
230
- - REJECTED: <approach that was tried/considered and abandoned + why>
228
+ RULES:
229
+ - MUST: <module-specific mandatory rule>
230
+ - NEVER: <module-specific prohibition>
231
+ - PREFER: <module-specific preference>
232
+ (Full rules list — L1 only has a 1-3 item summary of these)
231
233
 
232
234
  TRAPS:
233
235
  - [CRITICAL|HIGH|LOW] <gotcha: something that looks correct but is wrong or dangerous> | FIX: <correct approach>
234
236
  - [CRITICAL|HIGH|LOW] <non-obvious coupling, race condition, or side effect> | FIX: <approach>
235
237
 
238
+ DECISIONS:
239
+ - <decision made within this module> — <rationale>
240
+ - REJECTED: <approach that was tried/considered and abandoned + why>
241
+
236
242
  CHANGELOG:
237
- - YYYY-MM-DD | <verb>: <description of recent change to this module>
243
+ - <verb>: <description of recent change to this module>
238
244
 
239
245
  DOMAIN_SPECIFIC_SECTION_EXAMPLES:
240
246
  - For state machines: STATES, TRIGGERS, TRANSITIONS
@@ -245,6 +251,10 @@ DOMAIN_SPECIFIC_SECTION_EXAMPLES:
245
251
 
246
252
  CONSTRAINTS:
247
253
  - Max 5KB
254
+ - L2 is the BEHAVIORAL DETAIL — it answers "how it works, what can go wrong, what was decided"
255
+ - INTERFACES: lists only PUBLIC/EXPORTED signatures (moved here from L1 in V4)
256
+ - DATA_FLOW: describes how data moves through the module (moved here from L1 in V4)
257
+ - RULES: full module-specific rules list (L1 only has a 1-3 item summary)
248
258
  - DOMAIN-SPECIFIC SECTIONS are flexible, not prescribed
249
259
  - DECISIONS is append-only (never delete, archive if >20 entries)
250
260
  - TRAPS section is CRITICAL for preventing AI from making known mistakes
@@ -260,17 +270,18 @@ CONSTRAINTS:
260
270
  TEMPLATE:
261
271
 
262
272
  CHANGELOG:
263
- - YYYY-MM-DD | <module-path> | <verb>: <one-line description>
273
+ - <module-path> | <verb>: <one-line description>
264
274
 
265
275
  VERBS: add, update, fix, remove, refactor, rename, deprecate
266
276
  RETENTION: Keep last 50 entries. Archive older entries to changelog-archive.prizm if needed.
277
+ TEMPORAL_INFO: Git commit history is the authoritative source for when changes happened. No dates in changelog entries — git log on .prizm-docs/changelog.prizm provides the timeline.
267
278
 
268
279
  EXAMPLE:
269
280
  CHANGELOG:
270
- - 2026-03-02 | internal/logic/timer | add: retry logic with exponential backoff
271
- - 2026-03-01 | internal/service/sso | update: create_robot handler validates chatbot config
272
- - 2026-02-28 | internal/model/chatbot | add: DeepSeek provider model definition
273
- - 2026-02-27 | internal/repo/rpc | fix: Hunyuan API timeout not respected
281
+ - internal/logic/timer | add: retry logic with exponential backoff
282
+ - internal/service/sso | update: create_robot handler validates chatbot config
283
+ - internal/model/chatbot | add: DeepSeek provider model definition
284
+ - internal/repo/rpc | fix: Hunyuan API timeout not respected
274
285
 
275
286
  ---
276
287
 
@@ -280,10 +291,10 @@ HEADERS: ALL CAPS followed by colon (MODULE:, FILES:, RESPONSIBILITY:, etc.)
280
291
  VALUES: Single space after colon, value on same line (KEY: value)
281
292
  LISTS: Dash-space prefix for items within a section (- item)
282
293
  POINTERS: Arrow notation (->) to reference other .prizm files
283
- DATES: [YYYY-MM-DD] in square brackets for timestamps
284
- CHANGELOG_SEPARATOR: Pipe (|) between date, module, and description
294
+ CHANGELOG_SEPARATOR: Pipe (|) between module and description
285
295
  NESTING: Indent 2 spaces for sub-keys within a section
286
296
  COMMENTS: None. Every line carries information. No comments in .prizm files.
297
+ TIMESTAMPS: No date/time fields in .prizm files. Git is the authoritative source for temporal information. Use `git log` or `git blame` on .prizm files when needed.
287
298
 
288
299
  ---
289
300
 
@@ -327,37 +338,54 @@ ON_SESSION_START:
327
338
 
328
339
  ON_TASK_RECEIVED:
329
340
  IF task references specific file or directory:
330
- LOAD: L1 for the containing module
341
+ LOAD: L1 for the containing module (structural index: files, deps, key rules)
331
342
  IF task is broad (e.g., "refactor auth", "improve performance"):
332
343
  LOAD: L1 for all matching modules from MODULE_INDEX
333
344
  IF task is exploratory (e.g., "explain the codebase", "how does X work"):
334
345
  LOAD: L0 only, then navigate via pointers as needed
335
346
  IF task is cross-cutting (e.g., "add logging everywhere"):
336
- LOAD: L1 for affected modules, check DEPENDENCIES.imported-by
347
+ LOAD: L1 for affected modules, check DEPENDENCIES.imported-by and CROSS_CUTTING in root.prizm
337
348
 
338
349
  ON_FILE_MODIFICATION:
339
350
  BEFORE editing any source file:
340
- LOAD: L2 for the containing sub-module (if exists and not already loaded)
341
- READ: TRAPS section (prevent known mistakes)
342
- READ: DECISIONS section (understand prior choices)
343
- READ: REJECTED entries (avoid re-proposing failed approaches)
351
+ TARGETED LOAD from L2 (NEVER read the entire L2 file use grep to extract only needed sections):
352
+ 1. Use Grep tool to search for "^TRAPS:" in the L2 doc, read that section (prevent known mistakes)
353
+ 2. Use Grep tool to search for "^DECISIONS:" and "^REJECTED:", read those sections (understand prior choices)
354
+ 3. Use Grep tool to search for "^INTERFACES:" if you need to understand the public API contract
355
+ Only load additional L2 sections if the task specifically requires them.
356
+ IF L2 does not exist: GENERATE L2 from source code analysis, then extract needed sections
344
357
 
345
358
  ON_DEEP_READ:
346
359
  WHEN AI needs deep understanding of a module WITHOUT modifying it:
347
- LOAD: L2 for the containing sub-module (if exists)
348
- IF L2 does not exist: GENERATE L2 from source code analysis, then load it
360
+ TARGETED LOAD from L2 using grep (same approach as ON_FILE_MODIFICATION)
361
+ IF L2 does not exist: GENERATE L2 from source code analysis, then extract needed sections
349
362
  USE_CASES: code review, architecture analysis, dependency tracing, explaining complex logic
350
- RATIONALE: Deep reads benefit from the same structured context as modifications
351
363
 
352
364
  ## 6.2 Loading Rules
353
365
 
354
366
  NEVER: Load all L1 and L2 docs at session start (defeats progressive loading)
367
+ NEVER: Read entire L2 files — always use grep/search to extract only the sections you need
355
368
  NEVER: Load L2 for modules not being modified or deeply analyzed (wastes context window)
356
369
  NEVER: Skip L0 (it is the map for everything else)
357
370
  PREFER: Load L1 before L2 (understand module context before diving into details)
358
- PREFER: Load minimum docs needed for the task
371
+ PREFER: Load minimum docs and minimum sections needed for the task
359
372
  BUDGET: Typical task should consume 3000-5000 tokens of prizm docs total
360
373
 
374
+ ## 6.3 L2 Targeted Loading Protocol
375
+
376
+ L2 docs can be up to 5KB. Loading them in full defeats the purpose of progressive loading.
377
+ Use targeted grep to extract only the sections relevant to your current task:
378
+
379
+ COMMAND_PATTERN:
380
+ Grep tool with pattern "^SECTION_NAME:" and context lines (-A flag) to read a specific section.
381
+ Stop reading at the next ALL-CAPS section header.
382
+
383
+ EXAMPLES:
384
+ - Before editing a file: grep for "^TRAPS:" and "^DECISIONS:" sections
385
+ - Before changing an API: grep for "^INTERFACES:" section
386
+ - Before modifying data handling: grep for "^DATA_FLOW:" section
387
+ - For full module understanding (rare): read the entire L2 (only when task explicitly requires comprehensive analysis)
388
+
361
389
  ---
362
390
 
363
391
  # SECTION 7: AUTO-UPDATE PROTOCOL
@@ -393,28 +421,31 @@ ALGORITHM: prizm_update
393
421
  a. IF L2 doc exists for this module:
394
422
  UPDATE: KEY_FILES (add/remove/modify)
395
423
  UPDATE: INTERFACES (if signatures changed)
424
+ UPDATE: DATA_FLOW (if data flow changed)
396
425
  UPDATE: DEPENDENCIES (if imports changed)
426
+ UPDATE: TRAPS (if new pitfalls discovered)
397
427
  APPEND: CHANGELOG entry
398
- UPDATE: UPDATED timestamp
399
428
  b. IF L1 doc exists:
400
429
  UPDATE: FILES count
401
430
  UPDATE: KEY_FILES (if major files added/removed)
402
- UPDATE: INTERFACES (if public API changed)
403
431
  UPDATE: DEPENDENCIES (if module-level deps changed)
404
- UPDATE: UPDATED timestamp
432
+ (NOTE: L1 does NOT contain INTERFACES/DATA_FLOW/TRAPS/DECISIONS — those are in L2 only)
405
433
  c. UPDATE root.prizm (L0):
406
434
  UPDATE: MODULE_INDEX file counts
435
+ UPDATE: CROSS_CUTTING (if cross-module concerns changed)
407
436
  ONLY IF: module added, removed, or project-wide structural change
408
- UPDATE: UPDATED timestamp
409
437
 
410
438
  5. SKIP_CONDITIONS:
411
439
  SKIP if: Only internal implementation changed (no interface/dependency change)
412
440
  SKIP if: Only comments, whitespace, or formatting changed
413
- SKIP if: Only test files changed (unless test patterns doc exists)
414
441
  SKIP if: Only .prizm files changed (avoid circular updates)
415
442
 
443
+ DO NOT SKIP (may reveal TRAPS worth capturing in L2):
444
+ - Test file changes that expose edge cases, boundary conditions, or regression patterns
445
+ - Bug fixes that reveal non-obvious failure modes (the root cause is itself a TRAP)
446
+
416
447
  6. CREATE_NEW_DOCS:
417
- IF new directory with 3+ source files appears AND matches no existing module:
448
+ IF new directory qualifies as a module (see MODULE_DISCOVERY_CRITERIA, Section 9.1 Step 2) AND matches no existing module:
418
449
  CREATE: L1 doc immediately
419
450
  ADD: entry to MODULE_INDEX in root.prizm
420
451
  DEFER: L2 creation to first modification or deep read
@@ -422,7 +453,7 @@ ALGORITHM: prizm_update
422
453
  7. SIZE_ENFORCEMENT:
423
454
  AFTER each update, check file sizes:
424
455
  L0 > 4KB: Consolidate MODULE_INDEX entries, remove lowest-value RULES
425
- L1 > 3KB: Move implementation details to L2, keep only signatures in INTERFACES
456
+ L1 > 4KB: Move detailed KEY_FILES descriptions to L2, trim RULES to top 3
426
457
  L2 > 5KB: Split into sub-module docs or archive old CHANGELOG entries
427
458
 
428
459
  8. STAGE_DOCS:
@@ -432,7 +463,7 @@ ALGORITHM: prizm_update
432
463
  ## 7.3 Changelog Update
433
464
 
434
465
  ALWAYS append to .prizm-docs/changelog.prizm after any doc update.
435
- FORMAT: - YYYY-MM-DD | <module-path> | <verb>: <one-line description>
466
+ FORMAT: - <module-path> | <verb>: <one-line description>
436
467
  VERBS: add, update, fix, remove, refactor, rename, deprecate
437
468
 
438
469
  ---
@@ -444,8 +475,8 @@ WHAT_NOT_TO_PUT_IN_PRIZM_DOCS:
444
475
  NEVER: Prose paragraphs or explanatory text (use KEY: value or bullet lists)
445
476
  NEVER: Code snippets longer than 1 line (reference file_path:line_number instead)
446
477
  NEVER: Human-readable formatting (emoji, ASCII art, markdown tables, horizontal rules)
447
- NEVER: Duplicate information across levels (L0 summarizes, L1 details, L2 deep-dives)
448
- NEVER: Implementation details in L0 or L1 (those belong in L2 only)
478
+ NEVER: Duplicate information across levels (L0 summarizes, L1 indexes structure, L2 details behavior)
479
+ NEVER: Implementation details or behavioral detail in L0 or L1 (INTERFACES, DATA_FLOW, TRAPS, DECISIONS belong in L2 only)
449
480
  NEVER: Stale information (update or delete, never leave outdated entries)
450
481
  NEVER: Full file contents or large code blocks (summarize purpose and interfaces)
451
482
  NEVER: TODO items or future plans (those belong in issue trackers)
@@ -490,23 +521,33 @@ STEPS:
490
521
  2. DISCOVER_MODULES:
491
522
  SCAN source directories, preserving the tree structure (DO NOT FLATTEN):
492
523
 
493
- a. IDENTIFY TOP-LEVEL modules: directories directly under project root (or directly under src/ for src-based layouts) that either:
494
- - Contain 3+ source files of the primary language, OR
495
- - Contain sub-directories that each have 3+ source files
524
+ MODULE_DISCOVERY_CRITERIA a directory qualifies as a module if ANY of the following is true:
525
+ - Contains source files that collectively form a logical unit (shared responsibility)
526
+ - Contains entry points, configuration files, or interface definitions
527
+ - Contains sub-directories that themselves qualify as modules
528
+ - Is referenced by multiple other modules as a dependency
529
+
530
+ A directory does NOT qualify if ALL of the following are true:
531
+ - Contains only generated/derived files (build output, compiled assets)
532
+ - Contains only vendored/third-party code
533
+ - Is in the EXCLUDE list
534
+
535
+ a. IDENTIFY TOP-LEVEL modules: directories directly under project root (or directly under src/ for src-based layouts) that qualify per MODULE_DISCOVERY_CRITERIA.
496
536
  RESULT: top_modules = [src, internal, app, lib, ...]
497
537
 
498
- b. IDENTIFY SUB-MODULES: for each top-level module M, find directories INSIDE M that contain 3+ source files
538
+ b. IDENTIFY SUB-MODULES: for each top-level module M, find directories INSIDE M that qualify per MODULE_DISCOVERY_CRITERIA.
499
539
  RESULT: sub_modules[M] = [scripts, lib, templates, ...] (relative names, not full paths)
500
540
 
501
541
  c. HIERARCHY RULE: if directory X lives inside top-level module M, X is a sub-module of M — NOT a separate top-level module.
502
542
  WRONG: src/routes/ treated as top-level module -> .prizm-docs/routes.prizm
503
543
  CORRECT: src/routes/ is a sub-module of src -> .prizm-docs/src/routes.prizm
504
544
 
505
- d. MODULE_INDEX in root.prizm lists ONLY top-level modules from step 2a.
506
- Sub-modules appear in their parent's L1 doc SUBDIRS section, not in MODULE_INDEX.
545
+ d. MODULE_INDEX in root.prizm lists modules at the depth needed for efficient navigation.
546
+ Multi-level entries are allowed (no hard depth limit). If navigating from L0 to a commonly-used module would require 3+ hops via SUBDIRS pointers, add an intermediate entry to MODULE_INDEX.
547
+ The 4KB L0 size limit naturally constrains how many entries can be listed.
507
548
 
508
549
  - EXCLUDE: .git/, node_modules/, vendor/, build/, dist/, __pycache__/, target/, bin/, .claude/, .codebuddy/, .prizmkit/, .prizm-docs/, dev-pipeline/
509
- IF top-level module count > 30: ASK user for include/exclude patterns
550
+ IF total module count > 30: ASK user for include/exclude patterns
510
551
 
511
552
  3. CREATE_DIRECTORY_STRUCTURE:
512
553
  Create .prizm-docs/ directory
@@ -520,46 +561,42 @@ STEPS:
520
561
 
521
562
  4. GENERATE_ROOT (L0):
522
563
  Fill: PROJECT, LANG, FRAMEWORK, BUILD, TEST, ENTRY from step 1
523
- Build: MODULE_INDEX — list ONLY top-level modules from step 2a, one entry per module with pointer to .prizm-docs/<M>.prizm
524
- NEVER list sub-modules in MODULE_INDEX (sub-modules are navigated via L1 SUBDIRS pointers)
564
+ Build: MODULE_INDEX — list modules at the depth needed for efficient navigation, with arrow pointers
525
565
  Extract: RULES from existing README, .editorconfig, linter configs
526
566
  Extract: PATTERNS from common code patterns observed in step 2
527
- Set: PRIZM_VERSION: 2, UPDATED: today's date
567
+ Extract: CROSS_CUTTING identify patterns/constraints that span 2+ modules
568
+ Set: PRIZM_VERSION: 4
528
569
 
529
- 5. GENERATE_L1_DOCS:
530
- FOR EACH top-level module M in MODULE_INDEX:
531
- SCAN M directory:
570
+ 5. GENERATE_L1_DOCS (structural index only):
571
+ FOR EACH module in MODULE_INDEX:
572
+ SCAN the module directory:
532
573
  - Count all source files (direct files only, not recursive)
533
- - Identify exported/public interfaces (language-specific: exported funcs in Go, export in JS/TS, public in Java, pub in Rust)
534
574
  - Trace import/require/use statements for DEPENDENCIES
535
- - List sub-modules from step 2b in SUBDIRS with pointers: .prizm-docs/<M>/<sub>.prizm
575
+ - List sub-modules in SUBDIRS with pointers
536
576
  - Identify 5-10 most important files for KEY_FILES
537
- WRITE: .prizm-docs/<M>.prizm
577
+ - Identify 1-3 most critical module-specific rules for RULES summary
578
+ DO NOT include INTERFACES, DATA_FLOW, TRAPS, or DECISIONS (those are L2, generated lazily)
579
+ WRITE: .prizm-docs/<mirrored-path>.prizm
538
580
 
539
- FOR EACH sub-module S of top-level module M:
540
- SCAN M/S directory:
541
- - Count all source files in S
542
- - Identify exported/public interfaces within S
543
- - Trace dependencies within S
544
- - Identify key files in S
545
- WRITE: .prizm-docs/<M>/<S>.prizm
546
- NOTE: This is still an L1 doc (module index level), written at the mirrored sub-path
581
+ FOR EACH sub-module S of a parent module M:
582
+ SCAN M/S directory with same structural-index approach as above
583
+ WRITE: .prizm-docs/<M>/<S>.prizm (L1 structural index at the mirrored sub-path)
547
584
 
548
585
  6. SKIP_L2:
549
586
  DO NOT generate L2 docs during initialization.
550
- RATIONALE: L2 requires deep code understanding. Generating shallow L2 docs during init would produce misleading content and create false confidence. L2 docs are generated lazily when AI first modifies files in a sub-module or performs a deep read (ON_DEEP_READ trigger).
587
+ RATIONALE: L2 contains behavioral detail (INTERFACES, DATA_FLOW, TRAPS, DECISIONS) that requires deep code understanding. Generating shallow L2 docs during init would produce misleading content. L2 docs are generated lazily when AI first modifies files in a module or performs a deep read (ON_DEEP_READ trigger).
551
588
 
552
589
  7. CREATE_CHANGELOG:
553
590
  Write .prizm-docs/changelog.prizm with single entry:
554
- - YYYY-MM-DD | root | add: initialized prizm documentation framework
591
+ - root | add: initialized prizm documentation framework
555
592
 
556
593
  8. VALIDATE:
557
- CHECK: All generated files are within size limits (L0 <= 4KB, L1 <= 3KB)
594
+ CHECK: All generated files are within size limits (L0 <= 4KB, L1 <= 4KB)
558
595
  CHECK: Every MODULE_INDEX pointer resolves to an existing .prizm file
559
596
  CHECK: No circular dependencies in DEPENDENCIES sections
560
- CHECK: UPDATED timestamps are set on all files
561
597
  CHECK: KEY: value format compliance (no prose, no code blocks, no markdown headers)
562
598
  CHECK: No anti-patterns per Section 8
599
+ CHECK: L1 docs do not contain INTERFACES/DATA_FLOW/TRAPS/DECISIONS
563
600
 
564
601
  9. CONFIGURE_HOOK:
565
602
  Add UserPromptSubmit hook to .codebuddy/settings.json (see Section 11)
@@ -621,7 +658,7 @@ STEPS:
621
658
 
622
659
  2. SIZE_CHECK:
623
660
  VERIFY: root.prizm <= 4KB
624
- VERIFY: All L1 files <= 3KB
661
+ VERIFY: All L1 files <= 4KB
625
662
  VERIFY: All L2 files <= 5KB
626
663
  REPORT: Files exceeding limits with current size and limit
627
664
 
@@ -630,21 +667,22 @@ STEPS:
630
667
  VERIFY: Target file exists on disk
631
668
  REPORT: Broken pointers with source file, line, and missing target
632
669
 
633
- 4. TIMESTAMP_CHECK:
670
+ 4. STALENESS_CHECK:
634
671
  FOR EACH .prizm file:
635
- VERIFY: UPDATED field exists
636
- FLAG: Docs with UPDATED older than 30 days as potentially stale
637
- COMPARE: UPDATED against git log for corresponding source directory
672
+ COMPARE: git last-modified time of .prizm file vs git last-modified time of corresponding source directory
673
+ COMMAND: `git log -1 --format="%ai" -- <prizm-file>` vs `git log -1 --format="%ai" -- <source-dir>/`
674
+ FLAG: Docs where source was modified more recently than the .prizm file as potentially stale
638
675
 
639
676
  5. COMPLETENESS_CHECK:
640
677
  root.prizm MUST have: PRIZM_VERSION, PROJECT, LANG, MODULE_INDEX, RULES
641
- L1 docs MUST have: MODULE, FILES, RESPONSIBILITY, INTERFACES, DEPENDENCIES
642
- L2 docs MUST have: MODULE, FILES, KEY_FILES, DEPENDENCIES, TRAPS
678
+ L1 docs MUST have: MODULE, FILES, RESPONSIBILITY, DEPENDENCIES
679
+ L1 docs MUST NOT have: INTERFACES, DATA_FLOW, TRAPS, DECISIONS (those belong in L2)
680
+ L2 docs MUST have: MODULE, FILES, KEY_FILES, DEPENDENCIES, INTERFACES, TRAPS
643
681
  REPORT: Missing required fields per file
644
682
 
645
683
  6. ANTI_PATTERN_CHECK:
646
684
  FLAG: Duplicate information across levels (same content in L0 and L1)
647
- FLAG: Implementation details in L0 or L1 (belong in L2 only)
685
+ FLAG: Behavioral detail in L1 (INTERFACES, DATA_FLOW, TRAPS, DECISIONS belong in L2 only)
648
686
  FLAG: TODO items or future plans in any .prizm file
649
687
  FLAG: Session-specific context or conversation history
650
688
 
@@ -845,6 +883,18 @@ V3 (2026-03-25): Knowledge quality and resilience
845
883
  - Added V2→V3 migration: auto-tag legacy TRAPS with [LOW] default severity
846
884
  - Updated PRIZM_SPEC_VERSION to 3
847
885
 
886
+ V4 (2026-03-28): L1/L2 boundary clarification and doc quality
887
+ - L1 redefined as structural index: removed INTERFACES, DATA_FLOW, TRAPS, DECISIONS from L1 template
888
+ - L1 RULES now summary only (1-3 critical rules); full RULES list in L2
889
+ - L1 size limit raised from 3KB to 4KB
890
+ - MODULE_INDEX allows multi-level entries; no hard depth limit, constrained by L0 4KB
891
+ - Module discovery changed from "3+ source files" to semantic MODULE_DISCOVERY_CRITERIA
892
+ - Added CROSS_CUTTING section to root.prizm for cross-module architectural knowledge
893
+ - Added cross-cutting/ subdirectory in .prizm-docs/ for detailed cross-cutting concern docs
894
+ - Relaxed update skip conditions: test files and bug fixes can generate TRAPS
895
+ - Added V3→V4 migration: move INTERFACES/DATA_FLOW/TRAPS/DECISIONS from L1 to L2
896
+ - Updated PRIZM_SPEC_VERSION to 4
897
+
848
898
  ---
849
899
 
850
900
  # SECTION 15: CONFLICT RESOLUTION
@@ -862,13 +912,14 @@ APPEND_ONLY_SECTIONS:
862
912
  - CHANGELOG (in L2 docs): Append-only. Keep all entries from both sides.
863
913
 
864
914
  LATEST_WINS_SECTIONS:
865
- - UPDATED: Take the more recent timestamp
866
915
  - FILES: Take the higher count (or recount from source)
867
- - KEY_FILES: Take the version from the branch with more recent UPDATED timestamp
868
- - INTERFACES: Take the version from the branch with more recent UPDATED timestamp
869
- - DEPENDENCIES: Take the version from the branch with more recent UPDATED timestamp
916
+ - KEY_FILES: Take the version from the branch with more recent git commit timestamp
917
+ - INTERFACES: Take the version from the branch with more recent git commit timestamp (L2 only)
918
+ - DATA_FLOW: Take the version from the branch with more recent git commit timestamp (L2 only)
919
+ - DEPENDENCIES: Take the version from the branch with more recent git commit timestamp
870
920
  - MODULE_INDEX: Merge entries from both sides, take latest counts, keep all pointers
871
- - RULES: Take the version from the branch with more recent UPDATED timestamp
921
+ - CROSS_CUTTING: Merge entries from both sides, keep all concerns
922
+ - RULES: Take the version from the branch with more recent git commit timestamp
872
923
  - TRAPS: Union of both sides (traps are safety-critical, never discard)
873
924
 
874
925
  ## 15.3 Conflict Resolution Algorithm
@@ -883,8 +934,8 @@ ALGORITHM: prizm_merge_conflict
883
934
  IF section is APPEND_ONLY (DECISIONS, REJECTED, CHANGELOG):
884
935
  MERGE: Concatenate entries from both versions, deduplicate by content, sort by date
885
936
  IF section is LATEST_WINS:
886
- COMPARE: UPDATED timestamps from both versions
887
- TAKE: Version with more recent UPDATED timestamp
937
+ COMPARE: git commit timestamps from both branches
938
+ TAKE: Version from the more recent commit
888
939
  IF section is TRAPS:
889
940
  UNION: Keep all entries from both versions, deduplicate by content
890
941
  c. REASSEMBLE: Write merged sections back to file
@@ -908,8 +959,8 @@ BEST_PRACTICE: Coordinate on MODULE_INDEX changes (adding/removing modules) to a
908
959
 
909
960
  ## 16.1 Migration Principles
910
961
 
911
- BACKWARD_COMPATIBLE: V3 can parse V2 docs without errors, but Validate will flag TRAPS entries missing severity prefixes and auto-migration (Section 16.3) will add [LOW] defaults
912
- FORWARD_COMPATIBLE: V2 tools will ignore V3-only fields they do not recognize
962
+ BACKWARD_COMPATIBLE: V4 can parse V3 docs without errors, but Validate will flag L1 docs containing INTERFACES/DATA_FLOW/TRAPS/DECISIONS and auto-migration (Section 16.4) will move them to L2
963
+ FORWARD_COMPATIBLE: V3 tools will ignore V4-only fields (CROSS_CUTTING) they do not recognize
913
964
  MIGRATION_TRIGGER: AI detects PRIZM_VERSION in root.prizm and applies migration if needed
914
965
 
915
966
  ## 16.2 V1 to V2 Migration
@@ -960,7 +1011,45 @@ ALGORITHM: prizm_migrate_v2_to_v3
960
1011
  4. UPDATE_CHANGELOG:
961
1012
  APPEND: - YYYY-MM-DD | root | update: migrated from PRIZM_VERSION 2 to 3 (TRAPS severity prefixes added)
962
1013
 
963
- ## 16.4 Future Version Migration Pattern
1014
+ ## 16.4 V3 to V4 Migration
1015
+
1016
+ TRIGGER: Automatic on first prizmkit-prizm-docs Update or Validate operation after spec upgrade
1017
+
1018
+ ALGORITHM: prizm_migrate_v3_to_v4
1019
+
1020
+ 1. UPDATE_VERSION:
1021
+ Change: PRIZM_VERSION: 3 -> PRIZM_VERSION: 4
1022
+ In: root.prizm
1023
+
1024
+ 2. MIGRATE_L1_CONTENT_TO_L2:
1025
+ FOR EACH L1 .prizm file:
1026
+ IF file contains INTERFACES, DATA_FLOW, TRAPS, or DECISIONS sections:
1027
+ IF corresponding L2 doc exists at the child path:
1028
+ MERGE: Append sections into L2 doc (do not overwrite existing L2 content)
1029
+ ELSE:
1030
+ CREATE: New L2 doc with moved sections + MODULE/FILES/RESPONSIBILITY from L1
1031
+ REMOVE: Those sections from L1 file
1032
+ IF file has RULES with > 3 entries:
1033
+ KEEP: Top 3 most critical entries in L1 RULES
1034
+ MOVE: Full RULES list to L2 RULES section
1035
+ RATIONALE: L1 is now a structural index only. Behavioral detail belongs in L2.
1036
+
1037
+ 3. UPDATE_SIZE_REFS:
1038
+ All internal size checks: L1 <= 3KB -> L1 <= 4KB
1039
+
1040
+ 4. ADD_CROSS_CUTTING:
1041
+ IF root.prizm does not have CROSS_CUTTING section:
1042
+ ADD: Empty CROSS_CUTTING section after PATTERNS
1043
+ RATIONALE: Placeholder for future cross-module concern entries.
1044
+
1045
+ 5. VALIDATE:
1046
+ Run full Validate operation
1047
+ REPORT: Migration results — L1 sections moved to L2, RULES trimmed, files updated
1048
+
1049
+ 6. UPDATE_CHANGELOG:
1050
+ APPEND: - YYYY-MM-DD | root | update: migrated from PRIZM_VERSION 3 to 4 (L1/L2 boundary redefined, CROSS_CUTTING added)
1051
+
1052
+ ## 16.5 Future Version Migration Pattern
964
1053
 
965
1054
  FOR any future version N to N+1:
966
1055
 
@@ -59,21 +59,21 @@ git diff --name-status
59
59
 
60
60
  **1d.** Update affected docs (bottom-up: L2 → L1 → L0):
61
61
 
62
- - **L2** (if exists): Update KEY_FILES, INTERFACES, DEPENDENCIES, CHANGELOG, UPDATED timestamp
63
- - **L1**: Update FILES count, KEY_FILES (if major files added/removed), INTERFACES (if public API changed), UPDATED timestamp
64
- - **L0 root.prizm**: Update MODULE_INDEX file counts only if counts changed. Update UPDATED only if structural change (module added/removed).
62
+ - **L2** (if exists): Update KEY_FILES, INTERFACES, DATA_FLOW, DEPENDENCIES, CHANGELOG, TRAPS, DECISIONS
63
+ - **L1**: Update FILES count, KEY_FILES (if major files added/removed), DEPENDENCIES (if module-level deps changed). **L1 does NOT contain INTERFACES, DATA_FLOW, TRAPS, or DECISIONS** — those belong in L2 only.
64
+ - **L0 root.prizm**: Update MODULE_INDEX file counts only if counts changed. Update CROSS_CUTTING if cross-module concerns changed. Update only if structural change (module added/removed).
65
65
 
66
66
  **1d-migrate.** Legacy TRAPS format migration (opportunistic):
67
67
  While updating an affected L1/L2 doc, if you encounter TRAPS entries **without** a severity prefix (e.g., `- foo | FIX: bar` instead of `- [LOW] foo | FIX: bar`), prepend `[LOW]` as a conservative default. This clears legacy format debt incrementally — only in files already being touched, never as a bulk operation.
68
68
 
69
- **1e.** If new directory with 3+ source files matches no existing module: create L1 doc immediately, add to MODULE_INDEX, defer L2.
69
+ **1e.** If new directory qualifies as a module (per MODULE_DISCOVERY_CRITERIA in PRIZM-SPEC Section 9.1 Step 2) and matches no existing module: create L1 doc immediately, add to MODULE_INDEX, defer L2.
70
70
 
71
71
  **1f.** Enforce size limits:
72
72
  - L0 > 4KB → consolidate MODULE_INDEX
73
- - L1 > 3KBmove details to L2
73
+ - L1 > 4KBtrim KEY_FILES descriptions, ensure RULES <= 3 entries
74
74
  - L2 > 5KB → archive old CHANGELOG entries
75
75
 
76
- **SKIP structural sync if**: only internal implementation changed (no interface/dependency impact), only comments/whitespace, only test files, only .prizm files, bug fixes with no interface change.
76
+ **SKIP structural sync if**: only internal implementation changed (no interface/dependency impact), only comments/whitespace, only .prizm files. **DO NOT skip** test file changes or bug fixes they may reveal TRAPS worth capturing in L2.
77
77
 
78
78
  **1g. TRAPS staleness check** (only when an L2 doc's TRAPS section has > 10 entries):
79
79
 
@@ -95,7 +95,7 @@ Extract TRAPS, RULES, and DECISIONS from development work and inject into `.priz
95
95
  ### When to run Job 2
96
96
 
97
97
  - Feature completion (spec + plan + implementation done)
98
- - Bugfix with a genuinely new pitfall discovered
98
+ - Bugfix that reveals a non-obvious failure mode (the root cause is itself a TRAP)
99
99
  - Refactor that revealed structural insights
100
100
  - **Skip for**: trivial fixes, config changes, dependency bumps
101
101
 
@@ -143,8 +143,9 @@ When writing TRAPS:
143
143
  **QUALITY GATE**: Every item must answer: "If a new AI session reads only `.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.
144
144
 
145
145
  **2c.** Inject into the correct `.prizm-docs/` file:
146
- - Module-level TRAPS/RULES/DECISIONS → the affected L1 or L2 `.prizm` file's corresponding section
146
+ - Module-level TRAPS/RULES/DECISIONS → the affected **L2** `.prizm` file's corresponding section (TRAPS/DECISIONS/RULES belong in L2, not L1)
147
147
  - Project-level RULES/PATTERNS → `root.prizm`
148
+ - Cross-module concerns spanning 2+ modules → `root.prizm` CROSS_CUTTING section
148
149
 
149
150
  **RULE**: Only add genuinely new information. Never duplicate existing entries. Never rewrite entire files.
150
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prizmkit",
3
- "version": "1.0.124",
3
+ "version": "1.0.125",
4
4
  "description": "Create a new PrizmKit-powered project with clean initialization — no framework dev files, just what you need.",
5
5
  "type": "module",
6
6
  "bin": {