@antoneeo/course-creator 0.1.0-beta.1

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 (34) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +5 -0
  4. package/README.md +25 -0
  5. package/gemini-extension.json +6 -0
  6. package/package.json +52 -0
  7. package/scripts/init.js +62 -0
  8. package/scripts/lib.js +734 -0
  9. package/scripts/postinstall.js +16 -0
  10. package/scripts/preuninstall.js +12 -0
  11. package/skills/course-creator/ENFORCEMENT.md +272 -0
  12. package/skills/course-creator/LICENSE +202 -0
  13. package/skills/course-creator/NOTICE +5 -0
  14. package/skills/course-creator/SKILL.md +95 -0
  15. package/skills/course-creator/dispatch.md +140 -0
  16. package/skills/course-creator/elicitation.md +196 -0
  17. package/skills/course-creator/feedback.md +7 -0
  18. package/skills/course-creator/guides.md +291 -0
  19. package/skills/course-creator/learning_design.md +79 -0
  20. package/skills/course-creator/memory.md +88 -0
  21. package/skills/course-creator/review.md +450 -0
  22. package/skills/course-creator/routing.md +118 -0
  23. package/skills/course-creator/scripts/course_check.py +479 -0
  24. package/skills/course-creator/scripts/entry_point.py +25 -0
  25. package/skills/course-creator/scripts/knowledge.py +2089 -0
  26. package/skills/course-creator/scripts/sdlc_check.py +73 -0
  27. package/skills/course-creator/scripts/sdlc_core.py +2707 -0
  28. package/skills/course-creator/scripts/shared_files.py +215 -0
  29. package/skills/course-creator/scripts/shared_manifest.json +27 -0
  30. package/skills/course-creator/simulation.md +47 -0
  31. package/skills/course-creator/slide_content.md +78 -0
  32. package/skills/course-creator/source_check.md +28 -0
  33. package/skills/course-creator/templates.md +222 -0
  34. package/skills/course-creator/vision.md +245 -0
@@ -0,0 +1,140 @@
1
+ # Subagent Execution Discipline
2
+
3
+ Opt-in orchestration for L3 work with an approved design: the orchestrator
4
+ drives a `PLAN_[feature].md` through subagents instead of implementing every
5
+ task in the same session. Default stays same-session; this is an escalation,
6
+ never a requirement.
7
+
8
+ ## Trigger
9
+
10
+ Only for L3 (an approved E-TDD in Hybrid, or an ANALYSIS Action Plan in
11
+ Standalone). Never for L1/L2 — the plan/ledger machinery is overhead a small
12
+ change does not need. The plan is always `derived-from` the accepted design:
13
+ it is never independently authored, exactly like an E-TDD is never authored
14
+ without an E-ISP.
15
+
16
+ ## The loop
17
+
18
+ 1. `sdlc_check.py plan validate PLAN_[feature].md` — zero-execution schema +
19
+ confinement + ledger cross-check. Non-zero exit = **no dispatch**. This is
20
+ the hard gate: "no valid plan, no dispatch."
21
+ 2. For each task, in plan order:
22
+ - Read the task's status from the sidecar ledger
23
+ (`PLAN_[feature].ledger.json`). `status: done` (exact sentinel) → skip,
24
+ never re-dispatch. Anything else (pending, failed, missing, or a
25
+ corrupt-but-parseable entry) → treat as pending and dispatch.
26
+ - `sdlc_check.py plan brief PLAN_[feature].md --task <id>` — prints the
27
+ task block, the `produces` of prior-order tasks (interfaces), and
28
+ `guides` pointers (paths, never pasted content) to stdout.
29
+ - Spawn the subagent with that brief plus the return-doubts line as its
30
+ entire context window. The line: "An open point whose answer changes the
31
+ work is not yours to decide: return it in your final output with what you
32
+ searched." The orchestrator treats them as its own candidate doubts
33
+ (`elicitation.md` §When a doubt emerges).
34
+ - Run `task.verify` out of band (the orchestrator executes it — the
35
+ validator only ever prints it, never runs it) plus the one-shot review
36
+ below.
37
+ - Write `{status, verify_result, timestamp}` back to the ledger. The
38
+ validator never writes the ledger — single-writer, orchestrator-owned.
39
+
40
+ **Guide consumption under dispatch.** Selecting each task's `guides` field IS the
41
+ consult trigger (`guides.md` §0) applied at plan-authoring time: the orchestrator
42
+ runs the router lookup (project router `ai_docs/reference/INDEX.md` + the agent-KB
43
+ router) when populating `guides`. A dispatched context-free subagent does **NOT**
44
+ run its own router consult — it reads the guide pointers handed to it in the
45
+ brief. The router verdict (Rule Zero) is therefore declared ONCE, by the
46
+ orchestrator, when it authors the plan; a dispatched subagent does not declare
47
+ one. (Proactive guide-creation stays at closure — the same broad final pass
48
+ below — so it needs no separate dispatch hook.)
49
+
50
+ ## Model tiers (client-relative, no provider names)
51
+
52
+ - Default dispatch: **economy** implementer tier. This is legal precisely
53
+ because a dispatched task carries `task.verify` — the threshold signal that
54
+ makes a wrong cheap answer visible. **The floor that governs every role, and
55
+ the rule that a tier may be lowered only where such a signal exists, is
56
+ `review.md` §The capability floor** — cited, never restated here.
57
+ - After **two** consecutive `verify_result: fail` on the same task: escalate
58
+ to the **deep** tier for the retry (ADR 2026-07-02). Do not escalate on the
59
+ first failure — a single fail is often a brief or environment issue, not a
60
+ capability gap.
61
+
62
+ ## What may be delegated at all
63
+
64
+ The sections above govern the opt-in PLAN loop; **this one is family-wide** and
65
+ applies to any pass, at any level, dispatch or no dispatch. Delegation is not a
66
+ token-saving technique — a second context re-reads, re-briefs and reports back,
67
+ so the total spend goes UP. What it buys is a main context that stays clean, and
68
+ independence where independence is the point. Judge a pass on two axes:
69
+
70
+ | | output falsifiable cheaply (`file:line`, an assertion result, a diff) | output is judgement |
71
+ |---|---|---|
72
+ | **reads ≫ report** | **delegate** — the whole win lives here | **never**: the biggest apparent win is where plausible-but-wrong enters |
73
+ | **reads ≈ report** | keep it: the brief costs more than the pass | keep it |
74
+
75
+ - **Delegate**: locating and verifying (a pass that returns citable facts and
76
+ discards its exploration trace), executing a probe or battery and reporting
77
+ the assertion table, and every independent review — the last for correctness,
78
+ not economy, and it is mandatory regardless of what it costs.
79
+ - **Never delegate**: authoring a governed artifact (Vision, ANALYSIS/E-ISP,
80
+ threat model, use cases, the Interface Contract), the triage level and router
81
+ verdict, a reconciliation or scope decision, and any pass whose result the
82
+ orchestrator must hold across many later turns — delegating that one just
83
+ moves the reading into the main context via the report.
84
+ - **The delegability condition**: a task whose brief cannot be expressed as
85
+ **pointers** — paths, ids, a command — is **not delegable** yet; a brief that
86
+ must carry the content pays those tokens twice, once to write it and once to
87
+ read it. `plan brief` is this rule already realized for the PLAN loop (it
88
+ prints `guides` as paths, never pasted content); the condition generalizes it.
89
+
90
+ **Declared residual**, so the silence is not read as prohibition: this section
91
+ settles the CLASSIFICATION. *When* to reach for a delegated search or
92
+ orientation pass — the trigger, its brief format and its output contract — is a
93
+ separate unit and is not answered here; until it lands, reaching for one is the
94
+ orchestrator's judgement against the table above, not a rule.
95
+
96
+ ## Review slots — one-shot, not iterative
97
+
98
+ Exactly three review touches per task, never a loop:
99
+
100
+ 1. Inline self-review by the implementer subagent before it reports done
101
+ (the standard critical-review pass, not a separate call).
102
+ 2. One reviewer pass per task (Hybrid: reuse the devPNT code-review gate;
103
+ Standalone: the `review.md` discipline).
104
+ 3. One broad final pass over the whole plan at closure, after all tasks are
105
+ DONE — catches cross-task drift a per-task review cannot see.
106
+
107
+ If a review FAILs, fix and re-run `verify` — that is a normal loop iteration
108
+ via the ledger's fail path, not an extra review slot.
109
+
110
+ **The scoped re-review is a round INSIDE slot 2 or 3, never a fourth slot.**
111
+ `review.md` §Receiving requires every review-driven correction to be
112
+ re-reviewed against the correction alone — that round belongs to the slot whose
113
+ findings caused it, and is bounded by the same cap of 3 rounds. "Never a loop"
114
+ bounds the SLOTS (no unbounded re-reviewing of a task), not the rounds inside
115
+ one slot: a fix nobody looked at is the defect the round exists to catch. Slot 1
116
+ is the implementer's own pass, not an independent review, so its fixes carry no
117
+ re-review round. The ledger records the round on the task's fail path as usual.
118
+
119
+ ## Ledger protocol summary
120
+
121
+ Read → skip-if-done → dispatch-if-pending → write. The ledger is the only
122
+ memory the loop needs across sessions or context compaction: a resumed
123
+ orchestrator re-reads it and picks up exactly where it left off, never
124
+ re-running a DONE task.
125
+
126
+ ## Degradation
127
+
128
+ No subagent-spawning tool available — absent, or permission-gated with no grant
129
+ in context (`review.md`'s gated-rung stop owns the asking; task dispatch never
130
+ asks; the broad final pass IS `review.md` moment 2 and asks there) → the
131
+ orchestrator runs each task in the same session, against the same plan and ledger,
132
+ with the same one-shot review slots. No capability is lost, only the parallelism/isolation subagents would
133
+ have added.
134
+
135
+ ## Hybrid note
136
+
137
+ The plan's `derived-from` points at the accepted E-TDD document key. Per-task
138
+ review reuses the devPNT independent reviewers (§4.6 code review gate) rather
139
+ than restating review doctrine — see `review.md` for the single definition
140
+ both modes share.
@@ -0,0 +1,196 @@
1
+ # Spec Elicitation
2
+
3
+ `## The question discipline` below governs EVERY doubt and EVERY question to the
4
+ practitioner — any phase, any level, inside or outside the round. The rest of the
5
+ file is the spec elicitation round: it applies when an L3 request enters phase 3 (Request
6
+ Analysis), BEFORE drafting the ANALYSIS document (Standalone) or the D-UC/E-ISP
7
+ (Hybrid).
8
+
9
+ Skip path: if the spec is already complete — an approved Vision or explicit
10
+ user requirements already answer goal, scope, and constraints — skip the
11
+ round and add a one-line note in the analysis stating why it was skipped.
12
+ Do not run the round as a formality when the answers are already on record.
13
+
14
+ Unattended path: when the user is not reachable (a scheduled or autonomous run,
15
+ and a bootstrap Vision is `DRAFT` by mandate, so the skip path above cannot
16
+ apply on a project's first L3) and a real doubt remains, do not stall and do not
17
+ invent consensus. Write it as a **declared assumption** (§Ask before the write)
18
+ in the artifact it touches. At L3, mark the ANALYSIS `BLOCKED on the user` and
19
+ stop before implementation; below L3, proceed and list the assumption in the
20
+ reply. An assumption on the record is reviewable; a guess folded silently into a
21
+ design is not.
22
+
23
+ ## The question discipline
24
+
25
+ A doubt kept silent is decided by the agent alone and reaches the documents
26
+ looking settled; a useless question wastes the practitioner's attention. This
27
+ section rules on both. The process *plans* questions in two places — the round
28
+ below, and the Capture Moment sweep at a user-signed closing (`SKILL.md`) — each
29
+ a planned occasion that keeps its own form.
30
+
31
+ ### When a doubt emerges
32
+
33
+ A **candidate doubt** is an open point whose answer changes what you write or
34
+ record. The usual signals — they illustrate, they do not close the definition:
35
+
36
+ | Thought | What it means |
37
+ |---|---|
38
+ | "They probably mean…", "I'll assume…" | you are choosing between readings of the request |
39
+ | "The request doesn't say, so I'll fill it in" | a gap in scope, a non-goal, an acceptance criterion or a priority |
40
+ | "Either would work, I'll pick one" | equivalent in effect: yours, pick and do not ask; different in effect: weigh them below |
41
+ | "I'll note it as an assumption and move on" | with the practitioner reachable, that note is where doubts go to be forgotten |
42
+ | "It's reversible, it can be fixed later" | later is after the documents built on it exist |
43
+
44
+ - **A fact, or information only the practitioner holds** (a date, a figure, a
45
+ constraint): settled only by evidence, cited — never settled by a weighing. Left
46
+ open by the corpus and changing the work, it is a real doubt.
47
+ - **A choice** — a reading of intent, a structuring trade-off: cite the
48
+ practitioner's statement that settles it (the request, an APPROVED Vision, an
49
+ earlier reply); failing one, weigh the pros and cons of each option, stating each
50
+ rejected option at its strongest — the need it serves best; a weighing won against
51
+ a weak version of the alternative is not a weighing. One clearly outweighs: take
52
+ it and write the weighing with the choice — "I take X over Z: pro …, contro …".
53
+ Balanced, or turning on a priority of theirs not on record: a **real doubt** — and
54
+ it turns on one whenever the options serve different needs of the actor, each
55
+ better at one the actor would notice in using the result (a quick answer against
56
+ a complete record) and
57
+ none good enough at both, and nothing the practitioner wrote ranks those needs —
58
+ however clear your own ranking feels. "The more natural reading" with no pros and
59
+ cons written is not a weighing. Reserved approvals never enter this test
60
+ (§The form of a question).
61
+
62
+ ### Ask before the write
63
+
64
+ A real doubt that passes the legality test below is **owed**, not merely allowed:
65
+ the test separates a doubt from a search not yet run, it never licenses silence.
66
+ Ask it before the first write that would embed its answer, grouped with every
67
+ doubt open at that point, in one numbered set, with the client's
68
+ structured-question facility where it has one. Never defer a doubt to the
69
+ deliverable, where the practitioner must find it inside the document; never drip
70
+ one question per turn. Fold every answer into the artifact, citing the reply; an
71
+ intent choice with neither a source nor a weighing is a finding (`review.md`
72
+ §Reviewing).
73
+
74
+ **Declared assumptions exist only where no question can be asked:**
75
+
76
+ - **Unattended** — the practitioner is not reachable (the Unattended path above).
77
+ - **Delegated** — their own words handed you this choice; quote them. A general
78
+ "go ahead" is not a delegation.
79
+
80
+ Each states **what it is taken from** and **the alternative it excludes**, and is
81
+ listed where the practitioner will read it — an assumption nobody is shown is a
82
+ silent decision. A dispatched subagent returns its open points in its final output
83
+ (`dispatch.md`); the orchestrator treats them as its own candidate doubts
84
+ (§When a doubt emerges).
85
+
86
+ ### The legality test
87
+
88
+ Everywhere, a question is legal only when BOTH hold:
89
+
90
+ 1. **Searched first, and the search is named — with its result.** The answer is
91
+ not on record and not derivable from the corpus, the topic graph, `ai_docs/`,
92
+ the Vision or the conversation — and the question states the terms, tools and
93
+ areas you searched **and what they returned**. Same standard as a router
94
+ verdict or a taxonomy-pass MISSING, and it carries their floors: a search
95
+ whose scope does not cover the question is not a search; a hit you did not
96
+ open narrows nothing; and **never fake the search** — "I looked and found
97
+ nothing" that names no terms and no areas is a search not run. A question the
98
+ corpus can answer is a search outsourced to the practitioner.
99
+ 2. **It names what is blocked.** The question states the specific decision or
100
+ fact that cannot be resolved without the reply — what you will do differently
101
+ depending on the answer. If nothing downstream changes, there is no question.
102
+
103
+ Never legal:
104
+
105
+ - **Generic confirmation** — "shall I proceed?", "is this OK?". The process
106
+ authorizes proceeding; if a real risk motivates the ask, name the risk and the
107
+ fork — that is a blocking question and carries the form below.
108
+ - **Preference-fishing** — asking the practitioner to pick among options that
109
+ are equivalent in their effect on the benefit and already decided by the
110
+ project's conventions. Cheapness to undo is NOT the test.
111
+ - **Re-asking the record** — goal, scope or constraints that an APPROVED
112
+ Vision, an earlier reply, or the request itself already states; or a fact a
113
+ claim row already carries with its source.
114
+
115
+ What questions are FOR — what the practitioner uniquely owns: the benefit,
116
+ priorities between conflicting goods, non-goals, acceptance, the approvals
117
+ doctrine reserves to them, and **rulings on contested claims — where their
118
+ answer counts only as a fact they know (`basis:`), never as a preference**
119
+ (`source_check.md` §Source conflicts). Facts about intent come from the practitioner; facts
120
+ about the documents come from the corpus. **Precedence:** a choice the
121
+ practitioner uniquely owns is never preference-fishing; the list above reaches
122
+ choices that are *not* theirs.
123
+
124
+ ### The form of a question
125
+
126
+ The approvals reserved above and every stop the doctrine mandates are asked
127
+ whatever you expect the answer: **legal by mandate**, never weighed, never
128
+ re-argued here. Unattended, they are never assumed: the work holds, unless the
129
+ mandating rule prescribes its own unattended handling (`review.md`'s gated rung
130
+ does).
131
+
132
+ **Only `review.md`'s round cap prescribes its own hand-over**, the artifact plus
133
+ the open findings. That list is closed. Source conflicts follow `source_check.md` §Source conflicts
134
+ and use the general blocking form below; no unavailable KB procedure is needed
135
+ for a Standalone course. A question outside the
136
+ planned occasions carries the **blocking form**, one line per element:
137
+
138
+ - the fork: the options, each with its pros and cons, and what each implies for
139
+ the work;
140
+ - the evidence: what you searched, read or tried, and what it leaves undecided;
141
+ - why no assumption survives — why the weighing does not settle it, and what a
142
+ wrong pick costs; a reserved approval or a mandated stop cites the approval or
143
+ the mandate instead;
144
+ - why it is the practitioner's call;
145
+ - what stays blocked until answered.
146
+
147
+ ## The round
148
+
149
+ Ask ONE structured set of questions, not a drip of follow-ups. Keep each
150
+ question short and numbered; offer concrete options where a real choice
151
+ exists, each with its pros and cons (this narrows the reply and speeds up the
152
+ round). Cover:
153
+
154
+ 1. **Goal / benefit** — what problem this closes and why now. The answer must
155
+ name what the actor *obtains*, not a mechanism: "a dashboard" is not an
156
+ answer to "never lose the thread" — ask again until it is a benefit
157
+ (`vision.md`: the Vision is the distilled benefit; solutions and preferences
158
+ are what gets filtered out).
159
+ 2. **Actors** — who interacts with this: their role, primary goal, and what
160
+ "good UX" means to them. These become the Vision's `## Actors`; each
161
+ use-case below attaches to one (actor = who they are, use-case = what
162
+ they do). Skip only when an approved Vision already names them.
163
+ 3. **Scope boundaries** — what is explicitly included in this unit of work.
164
+ 4. **Non-goals** — what is explicitly excluded, so scope does not silently
165
+ creep in later.
166
+ 5. **Constraints** — technical, compatibility, and security constraints that
167
+ bound the solution space.
168
+ 6. **Acceptance signals** — how you and the user will both recognize the
169
+ work is done and correct.
170
+
171
+ ## Reflect
172
+
173
+ Fold the answers into the ANALYSIS `## Objective` / `## Vision-Alignment`
174
+ sections (Standalone) or into the D-UC/E-ISP (Hybrid) — do not leave them
175
+ sitting only in the chat transcript. The written document, not the
176
+ conversation, is what the next session and the next reviewer will read.
177
+
178
+ Run a second round only when an answer opens a real fork in the design (a
179
+ genuinely new question the first round could not have anticipated). Do not
180
+ run a second round to double-check answers that were already clear.
181
+
182
+ ## Anti-patterns
183
+
184
+ - **Interrogation**: an endless list of questions, or drip-feeding one
185
+ question at a time across many turns instead of one structured round.
186
+ - **Asking what the approved vision already answers**: re-asking goal or
187
+ non-goals that a `Status: APPROVED` Vision or M-VISION already states.
188
+ - **Deferring a doubt into the document**: writing a guess into the artifact
189
+ and leaving the practitioner to find it there.
190
+ - **Collecting answers without folding them in**: getting replies in chat
191
+ and proceeding to design without writing them into the analysis document —
192
+ the next reader has no record of why the scope is what it is.
193
+
194
+ ## Course-specific elicitation
195
+
196
+ Ask which explanation should become possible for the named learner, what they already know with evidence, where they will use the knowledge, which surfaces they use today, and, when a tool or agent is involved, which acts are theirs and which the tool performs for them. Distinguish an unknown fact from an unknown learner prerequisite. Ask for the benefit before selecting modules.
@@ -0,0 +1,7 @@
1
+ # Feedback, improvement and efficacy
2
+
3
+ Read when feedback from a real learner or observed use arrives. The feedback channel is chosen in `D-IC.md`; do not create or imply a service. A learner can also report an issue through another identified route. Recover course version and module from context; ask only if still missing, then record the smallest context needed to understand the observation in `FEEDBACK_REPORT.md`.
4
+
5
+ Classify the report: unclear explanation, missing prerequisite, wrong or stale fact, delivery barrier, weak check, indistinguishable learning value, incomplete source content, or an issue outside the course's promise. Trace it to the learner profile, concept, module objective, source and check. Propose a correction and state what evidence would show improvement. A single concrete report can justify a correction. If it exposes a reproducible defect in **the course-creation method**, distill the reasoning into a guide or propose a change to `course-creator` under Agentic SDLC; never rewrite the skill automatically.
6
+
7
+ An efficacy claim needs criteria for the learner's understanding or use, observations from sufficiently comparable real learners, contrary outcomes and limits. No formal pilot is mandatory; naturally arriving feedback may supply evidence. An isolated positive comment and a simulated PASS do not. Keep the visible label `efficacy not verified` until the evidence supports a narrower, explicit statement. Review privacy and retention before storing learner details; no continuing personal register is part of this method.
@@ -0,0 +1,291 @@
1
+ # Operative Guides — pipeline
2
+
3
+ Support file for `ai_docs/reference/GUIDE_[topic].md`. Read this only when the
4
+ trigger below fires; the template lives in `templates.md`.
5
+
6
+ **The training model (what a guide IS).** A guide TRAINS the agent on a topic
7
+ the user cares about, the way training works for a person: you study the
8
+ material once, you carry a SYNTHESIS in your head, and you go back to the book
9
+ when a task needs detail. Two levels, both produced by this pipeline:
10
+ - **The guide = the synthesis** — compact and dense: core principles, decision
11
+ rules, the map of what exists, where people go wrong. Small enough that a
12
+ reader takes it in WHOLE before acting (that is the "preparation").
13
+ - **The snapshot = the book** (`.sources/`, verbatim) — the details live here,
14
+ reachable on demand.
15
+ - **The fidelity markers are the bridge**: `[source: <snapshot>#anchor]` both
16
+ proves provenance AND tells the reader where in the book the full detail is.
17
+ A guide that restates the source at length is as wrong as a fragmented one:
18
+ completeness is guaranteed by the book level, economy by the synthesis level.
19
+
20
+ **Two source kinds.** A guide's `source_kind` is either `document` (the default —
21
+ distilled from USER-PROVIDED indications; operative, "how to act") or `code`
22
+ (distilled from the project's own code; a comprehension map of a complex component,
23
+ "how it works"). Both are **source-faithful and snapshot-anchored** — the machinery
24
+ below (snapshot, `source_hash`, fidelity markers, router, `stale`) is identical; only
25
+ what is gathered into `.sources/` differs (a handed document vs verbatim code
26
+ excerpts). Where a rule applies to only one kind, it says so.
27
+
28
+ ## 0. Consuming a guide (consult before acting)
29
+
30
+ Guides only pay off if they reach the work they govern. **Before operative work,
31
+ proportional to triage** — L1 is exempt; engaged for L2/L3 — ask: *does a guide
32
+ already cover how to do this well?*
33
+
34
+ - **Scan the router, not the guides.** Read the when-to-consult descriptions in
35
+ the guide router `ai_docs/reference/INDEX.md` **and** the agent-KB router
36
+ `~/.agentic-sdlc/ai_docs/reference/INDEX.md` (if present). Match by topic.
37
+ - **On a match, read that guide's synthesis whole** before acting (the snapshot
38
+ stays on demand via the section markers). No match → proceed normally.
39
+ - **Targeted match, never blanket.** Open only the guide whose description fits
40
+ the task — never load every guide, which would reintroduce the exact token
41
+ cost the "point to them" model exists to avoid. The two-level model (compact
42
+ synthesis / verbatim snapshot) already bounds a single guide's cost.
43
+ - **Declare the router verdict.** The lookup result travels with the triage
44
+ level (`SKILL.md` Rule Zero) as one line — `router: no match`, or
45
+ `router: GUIDE_x.md → read`. This is what makes the consult reliable: an
46
+ undeclared lookup is indistinguishable from a skipped one, to the user, to a
47
+ later reviewer, and to you in the next session. Declaring `no match` on a repo
48
+ with no matching guide is the correct, expected output — not noise.
49
+ - **Three legal verdicts, not two.** `GUIDE_x.md → read`, `no match` (the router
50
+ was read; nothing fitted — including a project whose router is an empty stub,
51
+ which is the normal state before the first guide exists), and
52
+ `router: absent (no router file)` for the case where `ai_docs/reference/INDEX.md`
53
+ does not exist at all. That third value exists so the honest answer is always
54
+ available: a required declaration with no truthful value gets faked or dropped,
55
+ and it takes the rest of Rule Zero with it. Regenerate the router
56
+ (`sdlc_check.py index`) when you report `absent`.
57
+ - **Never fake the verdict.** `no match` means the router was read and nothing
58
+ fitted. A verdict that is always `no match` certifies a lookup that did not
59
+ happen and is worse than silence; a verdict listing the catalogue means the
60
+ match was not targeted (T7). Two guides are legitimate only when they cover
61
+ distinct concerns — typically an operative guide plus the comprehension map of
62
+ the component being touched; three is a smell, not a thorough lookup.
63
+ - **Check a `code` guide against the code before you trust it.** No check can do
64
+ this for you (§6): the reader is the only one who sees that the map and the
65
+ component have parted. A divergence you observe is yours to close in the same
66
+ unit of work.
67
+ - **Under subagent dispatch** the consult happens at plan-authoring time (the
68
+ orchestrator populates each task's `guides` field); a context-free subagent
69
+ reads the pointers it was handed and does not run its own router lookup. See
70
+ `dispatch.md`.
71
+
72
+ ## 1. When to trigger
73
+
74
+ Trigger test is origin + purpose, not content taxonomy (no "is this technical
75
+ enough" judgement call):
76
+ - **Origin**: the user hands you indications to follow — a document to adhere
77
+ to, a pasted policy, "do it this way", a style guide, a runbook.
78
+ - **Purpose**: the material is meant to GOVERN how the agent operates, not
79
+ just inform a one-off answer.
80
+
81
+ Both hold → this is guide material. Either is missing (e.g. the user pastes
82
+ background context with no operative intent, or asks a one-off question) →
83
+ this is not a guide; answer normally, do not create a file.
84
+
85
+ Never manufacture a guide from model knowledge. If the user asks for "a guide
86
+ on X" without handing over source material, ask for the source first — a
87
+ guide with no `distilled_from` is not this pipeline's output.
88
+
89
+ ### Proactive trigger (after reusable success)
90
+
91
+ The trigger above is reactive (the user hands material over). It has a proactive
92
+ twin: **after completing work that was governed by user-provided indications and
93
+ is plausibly reusable** — it would prepare a future task — **PROPOSE** distilling
94
+ a guide.
95
+
96
+ - It is a **proposal to the user**, routed into this same pipeline (§2 onward):
97
+ the user confirms topic/scope before any file is written.
98
+ - **Never a silent write, never from model knowledge.** If the work was not
99
+ governed by user-provided material there is nothing to distill — do not invent
100
+ a guide from general knowledge (the `distilled_from` fidelity constraint, §3,
101
+ is absolute). This adds a moment to PROPOSE, not a new writer.
102
+
103
+ ### Comprehension trigger (code source, autonomous — a duty, not a proposal)
104
+
105
+ The two triggers above are for `source_kind: document` (the user hands material
106
+ over). There is a third, for `source_kind: code`: while doing L2/L3 work, when you
107
+ recognize that a component / feature / abstraction layer is **high-complexity** and
108
+ no CURRENT guide already covers it, it is your **duty to WRITE a comprehension
109
+ guide** — autonomously, no proposal, no human gate. The next session (or another
110
+ agent) must not have to re-derive the model you just paid to build, and then break
111
+ the component from partial understanding.
112
+
113
+ - **Why autonomous is allowed here** (it is NOT for `document` guides): a
114
+ comprehension guide is **additive, code-anchored and reversible** (git). It changes
115
+ no code, plan or governed artifact — so the skill-wide "propose, never a silent
116
+ write" rule is relaxed for THIS kind only. The anti-hallucination floor still holds:
117
+ §3 fidelity is absolute — every claim traces to a verbatim code excerpt in the
118
+ snapshot, never to your assumption about what the code does.
119
+ - **Recognize "high-complexity" by concrete signals** (any strong combination, not a
120
+ vibe): you had to trace one behavior across several files/modules (summaries were
121
+ not enough); high fan-in / large blast radius (many consumers); non-obvious control
122
+ or data flow (state machine, async/eventing, DI/plugin indirection, metaprogramming,
123
+ cross-cutting invariants); the area was already broken once — or **repeatedly
124
+ across sessions** — from partial understanding (handoff / diary / git shows it);
125
+ the "why" is not reconstructable from a single file.
126
+ - **Guard-rails (autonomous is not unconstrained).** Search first (§2.0 — one CURRENT
127
+ guide per topic, both routers). Honor the fidelity floor (§3). RECOMMEND the
128
+ independent guide-vs-source review (§5) — it matters more here, since no human gated
129
+ creation. Announce the autonomous write in the closure / handoff so it is visible.
130
+ - **When it fires.** As soon as you recognize the signal, during the work. The
131
+ Phase-5 **Comprehension checkpoint** (`SKILL.md` §5) is the backstop that asks the
132
+ question out loud before closure — a safety net for a signal you noticed and did not
133
+ act on, never a licence to defer. Writing it at closure is still far better than not
134
+ writing it: the model you built is complete now and gone next session.
135
+
136
+ ## 2. Pipeline
137
+
138
+ 0. **Search before creating (DRY — one CURRENT guide per topic).** Before
139
+ proposing anything, read `ai_docs/reference/INDEX.md` and grep
140
+ `reference/GUIDE_*.md` for topic overlap with the new material. Never end
141
+ up with two CURRENT guides on the same topic. Search BOTH routers: project
142
+ `ai_docs/reference/INDEX.md` AND the agent KB router
143
+ `~/.agentic-sdlc/ai_docs/reference/INDEX.md` (if present) — one CURRENT
144
+ guide per topic PER SCOPE; a project guide on a KB topic requires the
145
+ explicit `overrides:` declaration. On overlap, pick by provenance:
146
+ - **Same source, evolved** → UPDATE the existing guide in place: new
147
+ snapshot, new `source_hash`, same file (history lives in git).
148
+ - **Different source replacing the old one** → NEW guide + mark the old
149
+ one `status: SUPERSEDED` (its provenance chain must stay honest — do not
150
+ graft a new source onto a guide distilled from another).
151
+ - **Different source, partial overlap** → flag it to the user explicitly:
152
+ the current frontmatter binds ONE source per guide (`distilled_from`/
153
+ `source_hash` are singular), so a clean multi-source merge is not yet
154
+ supported — regenerate from the prevailing source and mark what the
155
+ merge drops, or keep the topics separate if they truly are.
156
+ Semantic overlap is NOT mechanically detectable: this step is agent
157
+ discipline plus the human reviewing the router — say what you found.
158
+ **Also verify the handed SOURCE itself is current**: check its lifecycle
159
+ (status/supersedes headers) and search the project for a newer version of
160
+ the same document before snapshotting. A user may hand you a path that a
161
+ migrated copy has since superseded — distilling from it produces a guide
162
+ that is born stale. If you find a newer version, surface it and distill
163
+ from that one. (Learned the hard way on first field use, 2026-07-02.)
164
+ 1. **Decompose into PREPARATION units — and weigh the fragmentation risk.**
165
+ A guide's goal is to PREPARE an agent for a situation: everything that
166
+ situation needs must arrive in ONE guide. The risk is asymmetric — extra
167
+ context injected costs tokens (cheap, recoverable); missing context makes
168
+ the agent invent or fail (the exact failure this pipeline exists to
169
+ prevent). Every split is a bet that no future task will cross the cut.
170
+ Therefore:
171
+ - **Default = one guide per source/domain.** Split ONLY when the resulting
172
+ guides would be consulted in DISJOINT situations — no plausible task
173
+ needs two of them at once.
174
+ - **Run the split test per proposed fragment and DECLARE it** in the
175
+ proposal: "which tasks consult this fragment, and would any of those
176
+ tasks also need another fragment?" Any overlap → merge, do not split.
177
+ - Heterogeneous sources (unrelated policies handed over together) are the
178
+ legitimate split case; a single coherent document about one subsystem
179
+ almost never is.
180
+ - **Also decide SCOPE per proposed guide**: project-scope
181
+ (`ai_docs/reference/`) or agent-scope (`~/.agentic-sdlc/ai_docs/reference/`,
182
+ governs the agent across ALL projects; origin+purpose test unchanged,
183
+ scope is a LOCATION decision by the user, never a content taxonomy; KB
184
+ created lazily with `.sources/` on the first agent-scope guide).
185
+ 2. **User confirms** the topic decomposition — including the fragmentation-risk
186
+ assessment and scope decision — before any file is written. **`source_kind: code`
187
+ skips this gate**: the comprehension guide is written autonomously (§1
188
+ comprehension trigger). Still run the fragmentation/scope judgement yourself — just
189
+ do not block on confirmation.
190
+ 3. **Snapshot each source verbatim** into
191
+ `ai_docs/reference/.sources/<slug>-<hash8>.md`:
192
+ - `slug` derives from the topic (lowercase, hyphenated).
193
+ - `hash8` = first 8 hex chars of the snapshot file's own SHA-256 (compute
194
+ the snapshot first, hash it, then name it — the hash is of the file you
195
+ just wrote, not of the original source).
196
+ - The hash is computed over LF-normalized content (CRLF → LF), exactly as
197
+ `sdlc_check.py` does in `sha256_file` — so recorded hashes survive
198
+ checkouts that rewrite line endings (e.g. Windows `core.autocrlf=true`).
199
+ - Recommended for consumer projects: add
200
+ `ai_docs/reference/.sources/** -text` to `.gitattributes` so git never
201
+ rewrites snapshot bytes at all (keeps snapshots byte-verbatim; the
202
+ normalized hash stays stable either way).
203
+ - The snapshot is verbatim: no paraphrasing, no reformatting beyond what is
204
+ needed to save it as markdown.
205
+ - **For `source_kind: code`** the snapshot is the verbatim CODE EXCERPTS the guide
206
+ explains — the specific functions / classes / regions of the real files, each
207
+ labelled with its `path:symbol` (or `path:startLine-endLine`) — assembled into
208
+ the one `.sources/<slug>-<hash8>.md` and hashed identically. Copy the code
209
+ verbatim (no paraphrase); include ONLY the regions the guide covers, not whole
210
+ files, so `stale` tracks the code that matters. `distilled_from` records those
211
+ code paths.
212
+ 4. **Source-anchored SYNTHESIS (not restatement).** Select and compress what
213
+ the source says into the operative essence — decision rules, invariants,
214
+ the "where people go wrong" list — and POINT INTO the snapshot for the
215
+ detail (`[source: <snapshot>#anchor]` doubles as the detail-lookup
216
+ pointer: "full checklist → snapshot §7"). Every claim must still trace to
217
+ a specific point in the snapshot; do not extract from memory of the
218
+ conversation — re-read the snapshot while writing each section. Selection
219
+ and compression are allowed and expected; ADDITION is not (that stays
220
+ summarize-and-expand, forbidden). A guide approaching the source's own
221
+ length is a paraphrase, not a synthesis — wrong output.
222
+ 5. **Render per template** (`templates.md` → `## ai_docs/reference/GUIDE_[topic].md`):
223
+ frontmatter with `source_kind` (`document` | `code`), `source`, `distilled_from`,
224
+ `source_hash` (the snapshot's SHA-256, matching what you just computed), optional
225
+ `source_version`; body sections chosen from the repertoire (a `code` guide uses the
226
+ comprehension repertoire — how it works / control & data flow / invariants / where
227
+ it breaks), each with a fidelity marker.
228
+ **Write for the two-level read**: the guide (synthesis) is small enough to
229
+ be read WHOLE before acting; the snapshot (book) is where size lives and
230
+ where readers grep/partial-read on demand, following the section markers.
231
+ Use the repertoire's stable, self-describing headings, keep one concern per
232
+ `##` section, and make the frontmatter `description` the "should I open
233
+ this file at all" answer. This is why one synthesis + one book beats
234
+ several fragments: the synthesis guarantees the whole picture, the book
235
+ guarantees the details, the markers connect them.
236
+ 6. **Run `sdlc_check.py index`** so both `ai_docs/INDEX.md` and
237
+ `ai_docs/reference/INDEX.md` (the guide router) regenerate.
238
+
239
+ ## 3. Fidelity rules (mandatory, the D5 constraint)
240
+
241
+ "The source" below means the SNAPSHOT — a handed document for `source_kind: document`,
242
+ verbatim code excerpts for `source_kind: code`. The constraint is identical for both:
243
+ never from UNVERIFIED knowledge. A code guide's every claim traces to the actual code
244
+ in the snapshot, never to your assumption about what the code does.
245
+
246
+ - Only what the source supports goes in the guide. If the source is silent on
247
+ something a reader might expect, mark the section `[not covered by source]`
248
+ — never fill the gap from general knowledge.
249
+ - Every `##` section body carries exactly one kind of marker: `[source:
250
+ <snapshot>#<anchor-or-line>]` for content traceable to the snapshot, or the
251
+ literal `[not covered by source]` for an acknowledged gap. A section with
252
+ neither is a validator warning.
253
+ - `summarize-and-expand` is forbidden: do not take a short source note and
254
+ "helpfully" expand it into a longer procedure using inferred steps. If the
255
+ source says one sentence, the guide section says that one sentence
256
+ (source-anchored), not an elaborated version of it.
257
+ - When in doubt about whether something is "supported" by the source, treat it
258
+ as not covered rather than stretching the marker to fit.
259
+
260
+ ## 4. Ingestion bound (T9)
261
+
262
+ If a source document exceeds roughly 2000 lines, do not silently truncate or
263
+ skim it. Stop and ask the user to either split it into smaller documents or
264
+ select the specific sections relevant to the guide being built. Silent
265
+ truncation produces a guide that looks complete but is missing unreviewed
266
+ material — worse than asking.
267
+
268
+ ## 5. Review
269
+
270
+ Before the guide is used operatively for the first time, recommend an
271
+ independent guide-vs-source review (a fresh pass comparing the rendered guide
272
+ against the snapshot, checking every marker) — process control per the
273
+ threat model (P-TM). This is a recommendation to the user, not a hard gate:
274
+ state it explicitly when handing off a newly created guide.
275
+
276
+ ## 6. Maintenance
277
+
278
+ - **Source changed**: new snapshot, regenerate the guide from it (new
279
+ `source_hash`); a guide REPLACING another is `status: SUPERSEDED` on the old
280
+ one. `sdlc_check.py stale` (also under `--hybrid`) reports `[stale]` when a
281
+ guide's recorded hash and its snapshot file diverge — the signal to regenerate.
282
+ - **`source_kind: code` freshness is NOT mechanized.** `stale` compares the guide
283
+ to its snapshot, and a code snapshot is a frozen copy — so a map whose component
284
+ was rewritten reports FRESH forever (measured 2026-09-06: +388/-71 lines in the
285
+ guided module, `stale` silent). The duty is therefore the author's, twice: when
286
+ you MODIFY code a comprehension guide describes, refresh the guide in the same
287
+ closure (docs travel with the code); when you merely READ one, check it against
288
+ the code before trusting it. Too large to absorb → mark it `SUPERSEDED` rather
289
+ than leave a confident-wrong map badged CURRENT, which is worse than none.
290
+ - **Agent-global KB guides** use the same pipeline and validator via
291
+ `--root ~/.agentic-sdlc`; freshness via the same `stale` engine.