@antoneeo/kb-agentic-skill 1.22.0 → 1.23.0

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Every significant change to this skill is recorded here.
4
4
 
5
+ ## [1.23.0] - 2026-10-17
6
+
7
+ ### Changed
8
+ - F-068: on a live front, a new source or statement inside the declared `scope:` of an open unit (HANDOFF frontmatter) enters as an *ingestion step* of that unit: request entry, artifact or note, claim rows, reconciliation, `graph` until clean, one resume line. It does not reopen the full L3 cycle. Alignment (cascade on dependents, `stale`, registry, `index`, the `check` gate, commit) runs once, at an explicit closure the practitioner asks for or at session end. Two exceptions stay immediate: an in-flight draft is updated in the same step, and a sentence already delivered that a new fact falsifies is flagged in the same reply. Without isolation, a save commit marked `ingestion step` is allowed after a clean `graph`. Row locators come from `anchor`, ids from `claim-id --fill`. The Phase-5 instruction to update `handoff.md` by hand is gone: the registry is generated.
9
+ - F1: closing the last open workstream now empties the generated registry `audit/handoff.md` instead of leaving its stale row behind: with zero `HANDOFF_*.md` sources `index` rewrites it empty (keeping `project_notes.md`), and `validate` reports a generated registry that still has rows but no sources as an error.
10
+ - F-069: `graph`, `check`, `stale` and the session-start count are faster on a mature knowledge base, with byte-identical output. Citations of superseded claim ids are found with one pass per living document instead of one scan per (document, id) pair, and one check run reads and resolves each cited extraction once instead of once per claim row. On a synthetic ledger of 2183 rows and 1000 living documents, `graph` drops from 14 s to 4 s. No new flag.
11
+
5
12
  ## [1.22.0] - 2026-10-13
6
13
 
7
14
  ### Changed
package/README.md CHANGED
@@ -46,7 +46,7 @@ Deliberately absent: any per-node coverage or completion state. `gaps:` says wha
46
46
 
47
47
  ## Key features
48
48
 
49
- - **Risk-proportional triage, measured in knowledge and never in files**: one claim row → propagating a fact already settled → a new knowledge unit (a source ingested, a node created or superseded, the hierarchy moved). Carrying one settled fact into eight documents is small; one claim that re-parents a node is not. A **Write Triggers** table maps each knowledge event to exactly one destination.
49
+ - **Risk-proportional triage, measured in knowledge and never in files**: one claim row → propagating a fact already settled → a new knowledge unit (a source ingested, a node created or superseded, the hierarchy moved). Carrying one settled fact into eight documents is small; one claim that re-parents a node is not. On a live front, a new source or statement within an open unit's declared scope is an **ingestion step** of that unit — recorded on the ledger at once — while the rewrite of dependent documents, the registry and the full check run once, at a closure the practitioner calls. A **Write Triggers** table maps each knowledge event to exactly one destination.
50
50
  - **Portable knowledge**: `export` bundles a subgraph together with the bytes its claims cite — a closure, not a selection, because a claim whose source cannot be reopened is model knowledge arriving by another route. `import` merges it into another project **additively**: it never overwrites a node and never deletes, and claims already present are recognised by id rather than by comparing text, since the same artifact cited at the same span mints the same id in every project. Knowledge crosses the project boundary; **authority does not** — an imported ruling arrives as `prov: IMPORTED`, keeps its original `basis:`, and cannot settle a local disagreement until you re-ratify it.
51
51
  - **Several people, one project**: the workstream registry (`audit/handoff.md`) is **generated** from one file per open workstream, so two people opening or closing two workstreams on two branches edit two different files and their merge is clean. Row-per-workstream alone was not enough — a file-global `Date:` header defeats row-level ownership — so the header is derived from the sources and no writer touches it. The generated view can still conflict; that conflict is resolved by re-running `index`, never by hand, and `validate` refuses CLEAN until the file matches its sources. The append-only review log gets `merge=union` (a built-in driver, no per-clone configuration). It all works with no VCS at all: it is files and a generator.
52
52
  - **Vision-guided governance**: Standalone projects use `ai_docs/vision/`; Hybrid projects use devPNT `M-VISION` as the milestone north star. `DRAFT` informs, `APPROVED` binds, promotion is the user's alone.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kb-agentic-skill",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "description": "Knowledge-Base & Document-First protocol with risk triage, Vision governance, signal distillation and optional devPNT integration.",
5
5
  "author": "Antonio Pinto (https://github.com/Antoneeo)"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antoneeo/kb-agentic-skill",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "description": "Knowledge-Base & Document-First protocol for Claude Code, Gemini CLI, Google Antigravity and Codex with risk triage, Vision governance, signal distillation and optional devPNT integration.",
5
5
  "keywords": [
6
6
  "claude-code",
package/scripts/init.js CHANGED
@@ -196,16 +196,16 @@ in the skill's \`routing.md\`: it decides which lens's method and validation rul
196
196
  that unit. L1 never reaches it. Never refer to a document whose meaning differs by lens
197
197
  ("threat model", "vision", \`principles.md\`, \`handoff.md\`) by its bare name.
198
198
 
199
- Select the owning lens by the unit's purpose, then apply only its risk scale.
200
- The project's always-on pointer stays intact: consult the selected skill rather than
201
- merging multiple mandatory ladders. All lenses already carry shared project memory
202
- (\`memory.md\`); another installation is not needed for cross-domain recall.
199
+ Select the owning lens by the unit's purpose, then apply only its risk scale.
200
+ The project's always-on pointer stays intact: consult the selected skill rather than
201
+ merging multiple mandatory ladders. All lenses already carry shared project memory
202
+ (\`memory.md\`); another installation is not needed for cross-domain recall.
203
203
  This file is NOT auto-loaded by any client: it is a note for you, deliberately additive.
204
- Delete this note once the routing pointer is integrated.
204
+ Delete this note once the routing pointer is integrated.
205
205
  `, 'multi-lens routing note');
206
206
  if (wrote && protocolPreexisting) {
207
207
  console.log(' ⚠️ A protocol pointer already existed and was NOT overwritten.');
208
- console.log(' Integrate the routing pointer from AGENTIC_MULTI_LENS.md; keep one risk scale per unit.');
208
+ console.log(' Integrate the routing pointer from AGENTIC_MULTI_LENS.md; keep one risk scale per unit.');
209
209
  }
210
210
  }
211
211
 
@@ -47,8 +47,8 @@ The consolidated view is `sdlc_check.py stale` (the overlay intercepts
47
47
  the spine command, preserves its output, flags and exit code --
48
48
  `--hybrid` included -- and appends `## claims` only when nonempty). The
49
49
  orient append prints one count line at session start, only when dirty
50
- and always fail-open. Event-driven by design: reconciliation §2 runs
51
- `stale` after recording a supersession; nothing polls per turn.
50
+ and always fail-open. Event-driven by design: reconciliation §2 runs `stale` at the unit's
51
+ closure, once for every supersession since the last one; nothing polls per turn.
52
52
 
53
53
  ## 2. Check in CI (recommended for teams)
54
54
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: kb-agentic
3
- version: 1.22.0
3
+ version: 1.23.0
4
4
  description: Knowledge-Base & Document-First protocol with risk-proportional triage, Vision as a guide, Signal Distillation, a complete Standalone mode and optional symbiosis with devPNT. Use for user documentation, knowledge extraction, SOPs, research notes, decision logs, knowledge management — and for answering project questions from the claim ledger and topic graph.
5
5
  author: Antonio Pinto (https://github.com/Antoneeo)
6
6
  copyright: (c) 2026 Antonio Pinto
@@ -70,7 +70,8 @@ Cross-cutting rules:
70
70
  - **Domain routing (multi-lens installs only).** After the level is set, and only when a sibling lens skill of this family is installed (`agentic-sdlc`, `mkt-agentic-sdlc`, `course-creator`), run the router in `routing.md` for every L2, L3 and Spike: it decides which lens's method and validation rules govern this unit of work. L1 never reaches it, and a single-lens install never reads the file — detection fails open. In such a project, never refer to a document whose meaning differs by lens ("threat model", "vision", `principles.md`, `handoff.md`) by its bare name: qualify it with its domain, or name its path.
71
71
  - Personal data, credentials, security-sensitive processes, authN/authZ specs are high-risk: never L1.
72
72
  - **Escalation triggers — ANY of these makes it L3, whatever the file count:** the change touches the topic hierarchy (`parents:`, a `GENERALIZES` verdict, a re-parent); it touches more than one node's frontmatter; it creates or supersedes a node other nodes reference. Re-shaping the graph is a unit of change, never a side effect of placing one claim.
73
- - Adding one claim row to an existing topic is L1: the `id` may be left empty (the validator fills it — `claim-id --fill`), and no check errors on a hand-written row.
73
+ - Adding one claim row to an existing topic is L1. The locator comes from `anchor <path> <phrase>`, not from counting lines by hand except for a form `anchor` does not produce; the `id` is left empty and filled by `claim-id --fill` once, after the row is complete (`qty` included), and no check errors on a hand-written row. `graph` verifies that the span exists and that the id matches locator and `qty` — never that the span says what the claim says — so such a hand-counted locator is re-read at its span before the row is written.
74
+ - **An open unit absorbs.** A unit is open while its `audit/HANDOFF_*.md` exists, in the checkout its `branch:` names (from another checkout, its row in the registry says so); its scope is the `scope:` field of that HANDOFF's frontmatter — the file every open unit has by construction (a unit opened on a live front declares a front-wide scope there). A source or practitioner statement the scope covers is not a new unit: work in that checkout, declare `ingestion step of <unit>` in place of a new triage, and do only this — the request-record entry; the `given/` artifact with sidecar, or the note; the claim rows; the reconciliation classification, recording any supersession or contested set at once and presenting its escalations at the end of the step (a step is a run for `reconciliation.md` §4); `graph`, fixed until clean; one resume line in the HANDOFF body ("alignment pending since <date>: <what landed>"), frontmatter untouched. The step reply states what landed on the ledger, any escalation, any immediate exception (Phase 4), and that alignment is pending — this is how the practitioner knows the dependent documents lag. A step does not rewrite dependent documents, run `stale`, edit HANDOFF frontmatter or the registry, run `index` or `check`, or commit — that is the closure's work (Phase 5). One exception: on a project with no branch isolation (every session in one shared checkout), the step may end with a save commit once `graph` is clean, its message marked `ingestion step`, so history protects the work; such a commit has not passed the closure gate, which stays mandatory before the closure commit and before any push or integration. Without isolation the residual risk is higher — the save commit lands on the shared line itself, where other sessions read it before any closure gate, and another session's `index` or a sync tool can pick up uncommitted step files — and the step reply says so once per session. When coverage is doubtful, or two open units' scopes both cover it, ask one question before ingesting, naming the candidate units. When the step would fire an escalation trigger the approved ANALYSIS did not plan, stop, declare it, and amend the ANALYSIS with the practitioner's approval before continuing. No open unit, or outside every scope: triage as usual.
74
75
  - If a bigger impact emerges during L1/L2 work, stop, reclassify and declare it.
75
76
  - When in doubt, pick the higher level.
76
77
  - **Doubts asked, questions legal.** A real doubt is asked when it emerges, before its answer is written; every question passes the legality test of the question discipline (`elicitation.md`): searched first with the search named, and the blocked decision named. Claim-conflict escalations additionally carry their own mandated form and are batched at run end (`reconciliation.md` §4).
@@ -85,8 +86,8 @@ Triage decides IF documentation is due; this table decides WHICH document each e
85
86
  | `solutions/ANALYSIS_[topic].md` | Every L3, after elicitation and before any drafting. On topic match with an existing analysis, update that one instead of a new file. | 3 |
86
87
  | `solutions/SPIKE_[topic].md` | Closing any Spike — including a negative outcome. | — |
87
88
  | `vision/features/VISION_[feature].md` | Multi-milestone topic at analysis time, or retroactive trigger (second ANALYSIS on same theme). | 3 |
88
- | `audit/handoff.md` (workstream registry) | **Never by hand — generated by `sdlc_check.py index` from the `HANDOFF_*.md` sources**, and `validate` errors when the two disagree. Regenerate at every L3 closure and at session end; the `Date:` header is derived, so no writer touches it. Inventory for lookup, never a work board. | 5 / session end |
89
- | `audit/HANDOFF_[topic].md` | **One per OPEN workstream, with or without volatile state** — it is the authored home of that workstream's registry row (frontmatter `workstream`/`level`/`branch`/`status`/`since`/`next`/`details`/`updated`), so no file means no row. Carries the resume logistics too; the ANALYSIS Diary keeps the durable narrative (DRY). DELETED at closure — deleting it *is* removing the row. | 4 / 5 / session end |
89
+ | `audit/handoff.md` (workstream registry) | **Never by hand — generated by `sdlc_check.py index` from the `HANDOFF_*.md` sources**, and `validate` errors when the two disagree. Regenerate at every L3 closure (alignment or unit, Phase 5) and at session end — never at an ingestion step; the `Date:` header is derived, so no writer touches it. Inventory for lookup, never a work board. | 5 / session end |
90
+ | `audit/HANDOFF_[topic].md` | **One per OPEN workstream, with or without volatile state** — it is the authored home of that workstream's registry row (frontmatter `workstream`/`level`/`branch`/`status`/`since`/`next`/`details`/`updated`, plus `scope` for a unit that absorbs ingestion steps), so no file means no row. Carries the resume logistics too; the ANALYSIS Diary keeps the durable narrative (DRY). Frontmatter updated at a closure or session end, never at an ingestion step (a step adds only its body resume line). DELETED at unit closure — deleting it *is* removing the row. | 4 / 5 / session end |
90
91
  | `audit/project_notes.md` | A note true for the whole project rather than one workstream. Appended verbatim to the generated registry, so regenerating cannot destroy notes that belong to no workstream. | 5 / session end |
91
92
  | `audit/handoff.md` — converting an existing project | **Lazily, at the first write — and then ALL AT ONCE.** Converting one row at a time is the state that loses the others, so `index` refuses to write while anything in the file is unaccounted for and names it. Until the first source exists nothing generates and nothing errors. | 5 / session end |
92
93
  | `audit/audit_plan.md` (Standalone) | Bootstrap, and whenever a mapped area changes state (`sdlc_check.py mark`). | 1 |
@@ -140,21 +141,25 @@ Use this mode when `devpnt_*` tools are available and point at the current proje
140
141
  - **Design review gate (end of Phase 3, before any drafting):** the analysis is reviewed by somebody other than its author — a subagent with fresh context, or a declared self-pass when no higher rung is usable — a permission-gated rung is asked about, never silently skipped (`review.md`). Follow `review.md`; log the outcome in `audit/reviews/REVIEW_LOG.md`. A knowledge structure reviewed only by the person who chose it is not reviewed.
141
142
 
142
143
  ### 4. Knowledge Processing & Distillation
143
- - **Isolate the work (Branch/worktree hygiene).** Distillation rewrites existing notes — full re-read per `## Revision` — and does it on a branch or a worktree, never directly on the shared corpus, so a half-finished reconciliation is never what the next reader finds.
144
+ - **Isolate the work (Branch/worktree hygiene).** Distillation rewrites existing notes — full re-read per `## Revision` — and does it on a branch or a worktree, never directly on the shared corpus, so a half-finished reconciliation is never what the next reader finds. Where a project does not isolate (one shared checkout), that is a departure from this rule, not a second mode: Rule Zero's step save commit and its declared residual apply.
144
145
  - Before drafting (L2/L3; L1 exempt), **consult the guide router** for a guide covering the task and read it first (the consult trigger, `guides.md` §0). A targeted description match, not a blanket read. Its result is the router verdict already declared with the triage level (Rule Zero).
145
146
  - Execute knowledge extraction using **Signal Distillation** (`distillation.md`).
146
147
  - **Opt-in subagent execution**: for an L3 with an approved analysis, the work MAY be executed via subagents per `dispatch.md`; default stays same-session. `dispatch.md` also carries the family-wide **delegation boundary** (what may be delegated at all, and what never may) — that section is not gated by the opt-in trigger and applies at any level, dispatch or no dispatch.
147
148
  - Handle conflicting or outdated information via **Reconciliation** (`reconciliation.md`). Mark obsolete files `status: SUPERSEDED`.
149
+ - **New information on an open unit arrives as ingestion steps** (Rule Zero, *An open unit absorbs*), and the dependent documents wait for the closure — with two exceptions that never wait: a communication draft in progress whose sentence a new fact changes is updated in the same step, and a new fact that makes false a sentence already delivered to the practitioner in this session is flagged in the same reply, naming the sentence and the fact. Across sessions what was delivered is unknowable; the HANDOFF resume line and the request record are what the next session reads.
148
150
 
149
151
  ### 5. Closure & Indexing
150
- - Run verification checks (`sdlc_check.py check --root <project_root>`).
151
- - If the session recorded any supersession, run `sdlc_check.py stale`: its
152
- `## claims` section is the revision worklist (superseded-cited documents,
153
- expired windows, superseded derivation chains), worked per `## Revision`
154
- -- one document, one full re-read.
155
- - If the work was governed by user-provided indications and is reusable, **PROPOSE distilling a guide** (proactive trigger, `guides.md` §1) — a proposal for the user, never a silent write, never from model knowledge.
156
- - Update `audit/handoff.md`.
157
- - Regenerate manifests: `python <skill_dir>/scripts/sdlc_check.py index --root <project_root>`.
152
+ - **Phase 5 fires only on the practitioner's request** ("allinea", "chiudi") or on a session-closing signal (the Capture Moment's); propose it when the planned work is done. A unit that absorbed no ingestion step closes as before, when its planned work is done. It covers everything since the last closure, enumerated from the request-record entries since then and the uncommitted changes on the unit's branch, and runs once, in this order:
153
+ - the Capture Moment sweep;
154
+ - `sdlc_check.py stale`: its `## claims` section is the revision worklist (superseded-cited documents, expired windows, superseded derivation chains);
155
+ - the revision, per `## Revision` — one document, one full re-read — of every document that worklist names and every document the enumerated entries affect;
156
+ - if the work was governed by user-provided indications and is reusable, **PROPOSE distilling a guide** (proactive trigger, `guides.md` §1) — a proposal for the user, never a silent write, never from model knowledge;
157
+ - the HANDOFF update (below), then `python <skill_dir>/scripts/sdlc_check.py index --root <project_root>`;
158
+ - the closure gate, `sdlc_check.py check --root <project_root>` — the only gate command: it already runs `validate`, `graph` and `corpus`, so those are not run separately before it. Its stale stage is the spine's and does not print the kb `## claims` worklist (expired windows above all), which is why the `stale` step above stays — then the commit.
159
+ - **Alignment closure** — the unit stays open: update the HANDOFF frontmatter and body to current state; commit on the unit's branch and propose its integration, so the day's ledger reaches the shared line the same day; the integration choice is the practitioner's.
160
+ - **Unit closure** — the practitioner declares the work done: run the closure review (`review.md`) before DONE, then delete the HANDOFF; deleting it *is* removing the registry row, and the registry is never edited by hand. When it was the last one, `index` empties the generated registry.
161
+ - When the closure gate is red: no commit; the unit stays open; name the failing checks, fix, re-run.
162
+ - The closure reply states the closure-gate result, the documents revised, and the commit — or, when red, that nothing was committed.
158
163
  - Mark output clean and complete.
159
164
 
160
165
  ## Operative Guides & Router
@@ -233,10 +238,14 @@ Capture today is what makes recall honest tomorrow: a captured elicited or ruled
233
238
  is exactly the non-DERIVED ground the re-touch rule above walks to. The rails all
234
239
  exist — this section adds only the MOMENT.
235
240
 
236
- - **When — user-signed closings, once per session.** Phase 5 of a governed unit, or
241
+ - **When — user-signed closings, once per session** — and at every Phase 5, so
242
+ also again at the session's closing when an alignment closure already ran earlier
243
+ in it; the sweep is idempotent, so a later run only adds what came after the
244
+ earlier one. Phase 5 of a governed unit, or
237
245
  any closing signal from the user in an un-governed session ("chiudiamo", "we're
238
- done"); the session-end pass that updates `handoff.md`/`project_notes.md` then runs
239
- at that same closing. Never per-turn, never a standing interruption. **Declared
246
+ done"); the session-end pass that updates the `HANDOFF_*.md` files and
247
+ `project_notes.md`, then regenerates the registry with `index`, runs at that same
248
+ closing. Never per-turn, never a standing interruption. **Declared
240
249
  residual**: an unsignaled end (the user simply stops writing) captures nothing —
241
250
  the phase-4 duty (a decision stated mid-session owes its note WHEN SAID) is the
242
251
  protection for sessions that never close, and the orient's recency line makes the
@@ -41,14 +41,18 @@ dangling ids are errors, duplicates are errors.
41
41
  is now the assertion, and no row lingers contested against rows that no longer
42
42
  contest it.
43
43
 
44
- 3. **The cascade runs.** Recording a supersession ends by running
45
- `sdlc_check.py stale`: its `## claims` section lists every living
46
- document still citing the fallen id without naming its successor(s)
47
- and every derivation resting on a superseded source -- the revision
48
- worklist, worked per the kb `## Revision` doctrine, one document at a
49
- time. The citation warn also stands in `check` until each document is
50
- revised (or an append-only correction naming the successors lands),
51
- so the worklist cannot be silently forgotten.
44
+ 3. **The cascade runs.** The supersession is recorded in the ledger at
45
+ once; the cascade runs at the unit's next closure (`SKILL.md` Phase 5),
46
+ once for every supersession since the last one: `sdlc_check.py stale`,
47
+ whose `## claims` section lists every living document still citing the
48
+ fallen id without naming its successor(s) and every derivation resting
49
+ on a superseded source -- the revision worklist, worked per the kb
50
+ `## Revision` doctrine, one document at a time. The list is derived from
51
+ the ledger's state, so running it later loses nothing; meanwhile the
52
+ citation warn stands in `check` until each document is revised (or an
53
+ append-only correction naming the successors lands), so the worklist
54
+ cannot be silently forgotten. What does not wait for the closure is
55
+ named once, in `SKILL.md` Phase 4 (the two immediate exceptions).
52
56
 
53
57
  **No basis, no ruling.** A preference is not a fact; the validator refuses a ruling note
54
58
  without `basis:` exactly as it refuses a DERIVED note without `derived_from:`. If the
@@ -336,6 +336,17 @@ def kb_check_claims(root):
336
336
  if rel not in fm_cache:
337
337
  fm_cache[rel] = _note_frontmatter(root, rel)
338
338
  return fm_cache[rel]
339
+ # F-069: the same per-run memo for the source paths themselves -- each
340
+ # distinct path is resolved and stat'ed once, and each cited extraction
341
+ # read once (loc_cache, owned here, dropped when this call returns).
342
+ src_cache = {}
343
+ loc_cache = {}
344
+
345
+ def _resolved(path_s):
346
+ if path_s not in src_cache:
347
+ t = sdlc_core.confine_under(root, path_s)
348
+ src_cache[path_s] = (t, t is not None and t.is_file())
349
+ return src_cache[path_s]
339
350
  per_file_rows = []
340
351
  for p in sorted(topics.glob("*.md")):
341
352
  rel = "topics/" + p.name
@@ -357,16 +368,16 @@ def kb_check_claims(root):
357
368
  errors.append("%s: source %r has no locator" % (where, src))
358
369
  continue
359
370
  path_s, loc = src.rsplit("#", 1)
360
- target = sdlc_core.confine_under(root, path_s)
371
+ target, is_file = _resolved(path_s)
361
372
  if target is None:
362
373
  errors.append("%s: source %r escapes the docs root" % (where, src))
363
374
  continue
364
- if not target.is_file():
375
+ if not is_file:
365
376
  errors.append("%s: source %r does not resolve — a claim whose "
366
377
  "origin cannot be reopened is model knowledge"
367
378
  % (where, src))
368
379
  continue
369
- kb_check_locator(target, loc, where, errors)
380
+ kb_check_locator(target, loc, where, errors, loc_cache)
370
381
  # --- provenance ---
371
382
  prov = row["prov"]
372
383
  # Resolved ONCE, for every provenance: the non-GIVEN classes read it
@@ -556,8 +567,14 @@ def kb_check_claims(root):
556
567
  return errors, warnings, notes
557
568
 
558
569
 
559
- def kb_check_locator(target, loc, where, errors):
560
- """A locator must address an existing span of the stored bytes."""
570
+ def kb_check_locator(target, loc, where, errors, cache=None):
571
+ """A locator must address an existing span of the stored bytes.
572
+
573
+ `cache` is an optional dict the CALLER owns for one run (F-069): keyed by
574
+ the path actually read, it holds only what the checks compare against --
575
+ page lengths, a line count, or False for a missing extraction -- never the
576
+ text. Findings are still appended per call, so per row. Without it, every
577
+ call reads the file, as before."""
561
578
  m = LOC_PAGE_RE.match(loc)
562
579
  if m:
563
580
  page, a, b = int(m.group(1)), int(m.group(2)), int(m.group(3))
@@ -566,17 +583,24 @@ def kb_check_locator(target, loc, where, errors):
566
583
  return
567
584
  # offsets address the stored extraction (<stem>.txt beside the original)
568
585
  ext = target if target.suffix == ".txt" else target.with_suffix(".txt")
569
- if not ext.is_file():
586
+ key = ("p", ext)
587
+ if cache is None or key not in cache:
588
+ lengths = ([len(pg) for pg in sdlc_core.read_text(ext).split("\f")]
589
+ if ext.is_file() else False)
590
+ if cache is not None:
591
+ cache[key] = lengths
592
+ else:
593
+ lengths = cache[key]
594
+ if lengths is False:
570
595
  errors.append("%s: no stored extraction %s for locator %r — offsets "
571
596
  "must address kept bytes" % (where, ext.name, loc))
572
597
  return
573
- pages = sdlc_core.read_text(ext).split("\f")
574
- if page < 1 or page > len(pages):
598
+ if page < 1 or page > len(lengths):
575
599
  errors.append("%s: locator %r addresses page %d of %d" %
576
- (where, loc, page, len(pages)))
577
- elif b > len(pages[page - 1]):
600
+ (where, loc, page, len(lengths)))
601
+ elif b > lengths[page - 1]:
578
602
  errors.append("%s: locator %r spans past the end of page %d "
579
- "(%d chars)" % (where, loc, page, len(pages[page - 1])))
603
+ "(%d chars)" % (where, loc, page, lengths[page - 1]))
580
604
  return
581
605
  m = LOC_LINE_RE.match(loc)
582
606
  if m:
@@ -584,7 +608,13 @@ def kb_check_locator(target, loc, where, errors):
584
608
  if a > b or a < 1:
585
609
  errors.append("%s: locator %r has an invalid line range" % (where, loc))
586
610
  return
587
- n = sdlc_core.read_text(target).count("\n") + 1
611
+ key = ("L", target)
612
+ if cache is None or key not in cache:
613
+ n = sdlc_core.read_text(target).count("\n") + 1
614
+ if cache is not None:
615
+ cache[key] = n
616
+ else:
617
+ n = cache[key]
588
618
  if b > n:
589
619
  errors.append("%s: locator %r spans past line %d" % (where, loc, n))
590
620
  return
@@ -1085,12 +1115,18 @@ KB_GENERATED_RE = re.compile(r"GENERATED by \S+ index - do not edit by hand")
1085
1115
  KB_HEX12_RE = re.compile(r"^[0-9a-f]{12}$")
1086
1116
 
1087
1117
 
1088
- def _kb_hex_bounded(text, cid):
1089
- """True when cid appears NOT embedded in a longer hex run: a git hash
1090
- sharing a substring must never count as a citation (either side, either
1091
- case). cid is pre-validated 12-hex, so it is regex-safe by construction."""
1092
- return re.search(r"(?<![0-9a-fA-F])%s(?![0-9a-fA-F])" % cid,
1093
- text) is not None
1118
+ # A citation of a claim id is a run of exactly its 12 lowercase hex characters
1119
+ # NOT embedded in a longer hex run: a git hash sharing a substring must never
1120
+ # count as a citation (either side, either case). Two such bounded runs cannot
1121
+ # overlap, so findall returns every one of them.
1122
+ KB_HEX_TOKEN_RE = re.compile(r"(?<![0-9a-fA-F])[0-9a-f]{12}(?![0-9a-fA-F])")
1123
+
1124
+
1125
+ def _kb_hex_tokens(text):
1126
+ """The ids a text cites, extracted in one pass (F-069). Callers test
1127
+ membership instead of scanning the text once per id: that per-(document,
1128
+ id) scan made the time cycle grow with superseded ids x living documents."""
1129
+ return frozenset(KB_HEX_TOKEN_RE.findall(text))
1094
1130
 
1095
1131
 
1096
1132
  def _kb_df_entries(value):
@@ -1172,19 +1208,23 @@ def kb_time_cycle(docs):
1172
1208
  if (meta.get("status") or "").strip() == "SUPERSEDED":
1173
1209
  continue
1174
1210
  living.append((rel, text))
1175
- for rel, text in living:
1176
- for old in sorted(superseded):
1177
- if _kb_hex_bounded(text, old):
1178
- succs = superseded[old]
1179
- missing = tuple(x for x in succs
1180
- if not _kb_hex_bounded(text, x))
1181
- if missing:
1182
- cited.append((rel, old, missing, succs))
1211
+ # One token pass per living document, and none at all on a KB with no
1212
+ # supersession and no validity window (the orient line runs this at every
1213
+ # session start).
1214
+ tokens = ({rel: _kb_hex_tokens(text) for rel, text in living}
1215
+ if superseded or windows else {})
1216
+ for rel, _text in living:
1217
+ cites = tokens[rel] if tokens else frozenset()
1218
+ for old in cites.intersection(superseded):
1219
+ succs = superseded[old]
1220
+ missing = tuple(x for x in succs if x not in cites)
1221
+ if missing:
1222
+ cited.append((rel, old, missing, succs))
1183
1223
  today = _dt.date.today().isoformat()
1184
1224
  for topic_rel, rid, until in sorted(windows):
1185
1225
  if until <= today:
1186
- by = tuple(rel for rel, text in living
1187
- if rel != topic_rel and _kb_hex_bounded(text, rid))
1226
+ by = tuple(rel for rel, _text in living
1227
+ if rel != topic_rel and rid in tokens[rel])
1188
1228
  expired.append((topic_rel, rid, until, by))
1189
1229
  rev = {}
1190
1230
  node_meta = {}
@@ -834,6 +834,10 @@ def build_registry(root):
834
834
  return ""
835
835
  stamp = max(str(m.get("updated") or m.get("since") or "").strip() or "0000-00-00"
836
836
  for _p, m in rows)
837
+ return _render_registry(root, rows, stamp)
838
+
839
+
840
+ def _render_registry(root, rows, stamp):
837
841
  lines = ["# Handoff — workstream registry",
838
842
  f"Date: {stamp} (UTC)",
839
843
  "",
@@ -867,6 +871,35 @@ def parse_registry_rows(text):
867
871
  return ids
868
872
 
869
873
 
874
+ def is_generated_registry(text):
875
+ # "Ours" = written by ANY family entry point: the header is WRITTEN with
876
+ # entry_script(), so recognition must not hard-code one distribution's
877
+ # script name (a registry generated by mkt_check.py is just as generated).
878
+ return bool(re.search(r"GENERATED by \S+ index - do not edit by hand", text))
879
+
880
+
881
+ def generated_registry_rows(text):
882
+ """Workstream rows of a generated registry, ignoring the project notes
883
+ (free text that may carry tables of its own)."""
884
+ return parse_registry_rows(text.split("\n## Project-wide notes", 1)[0])
885
+
886
+
887
+ def build_empty_registry(root, existing):
888
+ """The generated registry once the last source is gone (F1, found by F-068).
889
+
890
+ Only for a registry that is already ours: a hand-written handoff with no
891
+ sources is a project that never converted, and stays untouched. The Date is
892
+ kept while the view is already empty -- re-running index on a clean tree
893
+ must not change it -- and becomes today's when rows are being dropped:
894
+ there is no source left whose `updated:` could date the closure."""
895
+ m = re.search(r"Date:\s*(\d{4}-\d{2}-\d{2})", existing)
896
+ if m and not generated_registry_rows(existing):
897
+ stamp = m.group(1)
898
+ else:
899
+ stamp = datetime.now(timezone.utc).strftime("%Y-%m-%d")
900
+ return _render_registry(root, [], stamp)
901
+
902
+
870
903
  def registry_conversion_blockers(root):
871
904
  """What stops `index` from writing over a hand-written handoff.md.
872
905
 
@@ -879,10 +912,7 @@ def registry_conversion_blockers(root):
879
912
  if not hand.is_file():
880
913
  return []
881
914
  text = read_text(hand)
882
- # "Already ours" = written by ANY family entry point: the header is WRITTEN
883
- # with entry_script(), so recognition must not hard-code one distribution's
884
- # script name (a registry generated by mkt_check.py is just as generated).
885
- if re.search(r"GENERATED by \S+ index - do not edit by hand", text):
915
+ if is_generated_registry(text):
886
916
  return []
887
917
  blockers = []
888
918
  known = {str(m.get("workstream")).strip() for _p, m in list_workstreams(root)}
@@ -1015,10 +1045,21 @@ def cmd_index(root):
1015
1045
  def rc_registry(root):
1016
1046
  """Write the generated workstream registry, or refuse and say why (F-028)."""
1017
1047
  ws = list_workstreams(root)
1048
+ hand = ai_path(root, "audit", "handoff.md")
1018
1049
  if not ws:
1019
- return 0 # no sources: a hand-written handoff is untouched
1050
+ # No sources: a hand-written handoff is untouched; a generated one is
1051
+ # emptied, or the last closed workstream would stay listed forever.
1052
+ if not hand.is_file():
1053
+ return 0
1054
+ existing = read_text(hand)
1055
+ if not is_generated_registry(existing):
1056
+ return 0
1057
+ empty = build_empty_registry(root, existing)
1058
+ if norm_text(existing) != norm_text(empty):
1059
+ hand.write_text(empty, encoding="utf-8")
1060
+ print(f"[ok] workstream registry emptied (no open workstreams): {hand}")
1061
+ return 0
1020
1062
  blockers = registry_conversion_blockers(root)
1021
- hand = ai_path(root, "audit", "handoff.md")
1022
1063
  if blockers:
1023
1064
  print(f"[ERROR] {docs_dir()}/audit/handoff.md NOT regenerated -- it still holds "
1024
1065
  "state no source accounts for:")
@@ -1496,6 +1537,12 @@ def cmd_validate(root, strict=False, hybrid=False):
1496
1537
  "workstream — decide which file owns it")
1497
1538
  else:
1498
1539
  seen[wid] = p.name
1540
+ elif hand.is_file():
1541
+ text = read_text(hand)
1542
+ if is_generated_registry(text) and generated_registry_rows(text):
1543
+ errors.append(f"{docs_dir()}/audit/handoff.md lists workstreams no HANDOFF_*.md "
1544
+ "source exists for any more: run 'sdlc_check.py index' to drop "
1545
+ "the closed rows")
1499
1546
  if hand.is_file():
1500
1547
  m = re.search(r"(?:Date|Data):\s*(\d{4}-\d{2}-\d{2})", read_text(hand))
1501
1548
  if not m:
@@ -573,9 +573,10 @@ status: PROGRESS
573
573
  since: 2026-06-10
574
574
  next: wire the callback tests
575
575
  details: ANALYSIS_login_sso.md
576
+ scope: every source and statement on the SSO login front
576
577
  updated: 2026-06-11
577
578
  ---
578
- # HANDOFF: [topic] (ephemeral — deleted at closure)
579
+ # HANDOFF: [topic] (ephemeral — deleted at unit closure)
579
580
 
580
581
  ## Resume state
581
582
  <!-- uncommitted files, half-run migrations, env vars, running services -->
@@ -587,11 +588,16 @@ updated: 2026-06-11
587
588
  <!-- traps discovered this session that bite on resume (locks, CRLF, flaky test) -->
588
589
  ```
589
590
 
590
- `updated:` is the date this file last changed, and the newest one across all sources
591
+ `updated:` is the date this file last changed — an ingestion step's body resume line
592
+ excepted, which leaves the frontmatter alone until the next closure refreshes it
593
+ (`SKILL.md` Rule Zero, *An open unit absorbs*) — and the newest one across all sources
591
594
  becomes the registry's `Date:` header — which is why no writer ever edits that header
592
595
  and why two concurrent writers no longer collide on it. `details:` holds the *other*
593
596
  pointers (the ANALYSIS, a review log entry); the generator prepends this file's own
594
- name, so nothing points at itself by hand.
597
+ name, so nothing points at itself by hand. `scope:` is what an ingestion step is
598
+ tested against (`SKILL.md` Rule Zero, *An open unit absorbs*): the topics, front or
599
+ counterpart the unit covers — on a live front, front-wide ("K-02: every source and
600
+ statement on X"). The registry does not show it.
595
601
 
596
602
  ## ai_docs/audit/project_notes.md — the registry's project-wide notes (source)
597
603
 
@@ -1,245 +1,245 @@
1
- # Writing a Vision that a cold reviewer can actually apply
2
-
3
- Support file for `ai_docs/vision/project_vision.md`, `vision/features/VISION_*.md`
4
- and (Hybrid) the devPNT M-VISION. Read it when writing or amending any of them.
5
- The template lives in `templates.md`; this file is the *why it works*.
6
-
7
- **The problem this solves.** A Vision's job is to be read cold — by a later
8
- session, by a reviewer, by another agent — and to produce a ruling on a proposed
9
- change. Most Visions cannot do that: they read as intent to whoever wrote them and
10
- as ambiguity to everyone else, and the gap is invisible until something wrong gets
11
- through. Writing one and then discovering the holes by adversarial rounds works,
12
- but it costs several rewrites. The checklist below exists so a Vision is
13
- verifiable on the **first** draft.
14
-
15
- Everything here was derived empirically: six blind adversarial rounds against one
16
- real Vision, reviewers with no repository access, ~25 attack proposals. Rules that
17
- survived every attack and rules that fell were compared for structure. What
18
- follows is that difference.
19
-
20
- ## What a Vision IS
21
-
22
- A Vision states **what is to be obtained — the benefit — while leaving the most
23
- degrees of freedom possible. It binds nothing that does not obstruct that
24
- benefit.**
25
-
26
- Four consequences, each operational:
27
-
28
- - **State the benefit, not the mechanism.** What the actor *obtains*, never how —
29
- and concrete enough that an obstacle to it is *recognizable*. This is the test a
30
- North Star must pass: from "best-in-class" no constraint is derivable and none
31
- is refutable, because nothing recognizably obstructs it. From "everything the
32
- methodology produces stays usable in full without paying", a metering ban
33
- follows and can be checked.
34
- - **The deletion test — the generative rule for every constraint.** Remove the
35
- rule: is the benefit still reachable? If **yes**, delete the rule — it was
36
- spending a degree of freedom on nothing. If **no**, keep it, and its sentence
37
- must name the obstacle it removes. This is also the stop rule: when nothing on
38
- the table would obstruct the benefit, the Vision needs no new rule.
39
- - **Constraints accumulate as the work reveals obstacles.** The first draft is the
40
- benefit plus the few constraints already known — usually almost none, and that
41
- is correct (`DRAFT` informs, `APPROVED` binds). Each constraint added later
42
- *sharpens* the Vision without shrinking it more than the obstacle requires.
43
- - **A constraint never obstructs the Vision.** A proposed rule that conflicts with
44
- the benefit is not a constraint to negotiate in place — it is a Vision
45
- **amendment**, and amending is the owner's decision, never a side effect of a
46
- downstream edit.
47
-
48
- Extracting the benefit from a discussion is real work: a discourse arrives with
49
- solutions, preferences and constraints tangled together, and the Vision is the
50
- distilled benefit only. The elicitation round (`elicitation.md`) asks for it first
51
- — and a mechanism ("a dashboard") is not an acceptable answer to a benefit
52
- question ("never lose the thread"); ask again until the answer names what the
53
- actor obtains.
54
-
55
- The deletion test decides **which** rules exist. Everything below decides **how**
56
- to write a rule so it holds once you know it must exist.
57
-
58
- ## 0. The one-line test
59
-
60
- > Could a reader who has never seen this project rule ACCEPT or REJECT on a
61
- > proposed change, quoting one line of this document, without asking anyone
62
- > anything?
63
-
64
- If a section cannot contribute to that, it is background — keep it if it helps a
65
- human, but know it carries no gate weight.
66
-
67
- ## 1. The nine properties of a rule that holds
68
-
69
- Each is stated as a drafting action, with the attack it defeats.
70
-
71
- 1. **Key the rule to a property observable in the artifact — never to intent,
72
- commitment, plan or purpose.** Test while drafting: *could I verify compliance
73
- by reading the diff, without asking the author what they meant?*
74
- → Defeats: the proposer simply promises the opposite. A rule that forbids
75
- "committing to track someone's format" is satisfied by saying "we commit to
76
- nothing"; a rule that forbids "code in this repo that parses a format we do
77
- not define" is not.
78
- 2. **Write it as one yes/no question with BOTH branches answered.**
79
- → Defeats: a gate that can only reject. A prohibition-only Vision rejects the
80
- work it wants (new client support, packaging, bug fixes) and is abandoned.
81
- 3. **Phrase the question counterfactually about capability, not about the status
82
- quo** — "could the user obtain this…", not "does the product currently do it".
83
- → Defeats: "we never shipped it, so nothing is being taken away."
84
- 4. **Enumerate the near-miss verbs, not just the headline one** — charge / count /
85
- cap / condition / gate / degrade / delay / require-signup.
86
- → Defeats: the soft form. A generous cap, a free-but-registered tier, a
87
- zero-cost counter — all are the same harm and none is the headline verb.
88
- 5. **Define every term the rule turns on by EFFECT, and close the list.** A
89
- definition that enumerates mechanisms is a list of the ways you already thought
90
- of; end it with "…and anything else the user must give, accept or obtain from
91
- us."
92
- → Defeats: the third mechanism. "Charge = payment or account" is walked past by
93
- "requires opting into telemetry".
94
- 6. **Enumerate the FORMS a violation can take, then state a closure rule** —
95
- "anything not named here is out unless it is X".
96
- → Defeats: the unnamed variant. "A step, a required field, a check, or a cost
97
- that varies but is never zero" kills "auto-filled, zero human input", because
98
- the form is still a required field.
99
- 7. **State the subject predicate of any enumerated test in checkable terms.** If
100
- the test applies to "a record of work", say what makes something one.
101
- → Defeats: denying the subject. The proposer agrees with every item on your
102
- list and asserts the list does not apply.
103
- 8. **Give one IN and one OUT example on the same axis, differing in a single
104
- variable.** The pair carries the discriminator; without it the reader invents
105
- one.
106
- → Defeats: the borderline case, which is where every real argument happens.
107
- 9. **Name the re-descriptions you expect, inside the rule's own sentence** —
108
- "in any presentation", "however the code got here", "not by a component that
109
- does not exist yet", "storing it as Markdown changes nothing".
110
- → Defeats: relabeling. A board called a "view" is still a board.
111
-
112
- ## 2. The five clauses a Vision needs around its rules
113
-
114
- Rules do not hold alone. These structural clauses were the difference between a
115
- rule that survived and the same rule leaking.
116
-
117
- - **Supremacy clause** — on any rule a second layer, product, tier or future
118
- component could route around: *"these bind the product as a whole; shipping a
119
- forbidden thing in the paid layer does not put it out of reach."*
120
- - **Exceptions attached to the rule they limit, in the same bullet, phrased
121
- affirmatively.** An exception in another section is a leak; an exception phrased
122
- only as a negation produces CANNOT DECIDE. *"This rule does not reach X;
123
- supporting one more X is squarely wanted."*
124
- - **Anti-abuse clause on every exemption, naming the only permitted outcomes.**
125
- A maintenance exemption without one lets any forbidden thing that already
126
- shipped be maintained forever, and any new one be framed as a fix to it:
127
- *"work framed as a fix to something that should never have shipped is not
128
- exempt — it is the removal of that thing, or it is out."*
129
- - **Stated defaults, per path including the exempt path** — "anything unreached is
130
- out"; "an exempt fix that preserves a forbidden thing is out". A test that says
131
- "admitted only if" gives new capability a default; exempt work has none unless
132
- you write one.
133
- - **Precedence, when two sentences can both apply.** Two adjacent statements
134
- pointing opposite ways are decided by whichever the reader reaches first.
135
-
136
- ## 3. Only prohibitions can reject; only positives can admit
137
-
138
- This is the most common structural failure and it is invisible from the inside.
139
-
140
- - **A Goal cannot reject anything.** If the admission test says "advances a Goal
141
- and violates no Non-Goal", then rejection power lives *only* in the Non-Goals.
142
- A Goal that says "scale cost to risk in both directions" cannot stop cost
143
- inflation — you need a prohibition for that.
144
- - **A prohibition scoped to one rung of your own scale protects only that rung.**
145
- Banning ceremony on trivial edits invites the same ceremony one level up.
146
- - **A criterion phrased as an already-true state cannot be advanced.** "The check
147
- is CLEAN at every closure" is a state, so "advances this signal" is meaningless
148
- and any proposal citing it is undecidable. Give every positive criterion a
149
- **baseline with headroom**: a current value and date, or an explicit list of
150
- improvement categories that count.
151
- - **Give recurring legitimate work an explicit authorization clause**, or it will
152
- be rejected by your own test: packaging and installation, the product's own
153
- tests, reducing what the agent must read, supporting one more client. Each needs
154
- a home in the positive sources — otherwise "moves nothing this document commits
155
- to" fires on exactly the maintenance the product needs.
156
-
157
- ## 4. Minimum operable sections
158
-
159
- A Vision is a gate. These are the load-bearing parts; anything else is
160
- orientation for humans and should be recognized as such.
161
-
162
- | Section | Must contain | Enables |
163
- |---|---|---|
164
- | Authority & scope | what it binds (all layers, tiers, future components), that packaging is irrelevant, precedence among its own sections, the approval line | both |
165
- | Defaults | the default ruling for anything unreached, stated per path | both |
166
- | Admission test | one sentence naming *exactly which* sections are positive sources and *exactly which* are prohibitions | ACCEPT |
167
- | Positive sources | Goals / Actor commitments / Success Signals — each with a baseline and headroom, checkable against a named artifact | ACCEPT |
168
- | Prohibitions | property-based, closed enumerations, named re-descriptions, in/out pairs | REJECT |
169
- | Invariants | the decision question with both branches answered, plus an anti-laundering clause | both |
170
- | Exemptions | each with its anti-abuse clause | prevents laundering |
171
- | Definitions & imported facts | terms defined by effect; **any fact from another document a ruling depends on, restated here** with the reason | standalone use |
172
- | Pointers | what deliberately lives elsewhere, so an absence reads as intentional | prevents false CANNOT DECIDE |
173
-
174
- **Imported facts matter more than they look.** If a ruling needs your triage
175
- levels, your risk tiers or your lifecycle states, restate the boundaries in the
176
- Vision — routing the reader to another file breaks the cold-read premise the
177
- whole gate rests on. Keep the procedure elsewhere; bring the boundaries here.
178
-
179
- **Keep competitive positioning OUT.** A Vision defined by comparison to another
180
- product rots silently: the comparison target moves and no one edits your document.
181
- Put it in a dated snapshot elsewhere and point to it.
182
-
183
- ## 5. What no wording can fix — use a mechanism instead
184
-
185
- Five failure classes are structural. Prose cannot close them; do not try.
186
-
187
- | Failure | Mechanism |
188
- |---|---|
189
- | "Advances a Goal" is a claim about the world, not the text | Measure it: run the ruling battery before and after, admit on measured improvement |
190
- | **Cumulative ratchet** — each addition defensible, the sum is the ceremony the Vision forbids | A measured budget: steps per level, tokens the agent loads, artifacts per change; add-one-remove-one |
191
- | Facts the proposal never states ("a quota of *what*?") | A proposal template that demands them, and a stated rule that omission resolves against the proposal |
192
- | Structural compliance without truth — every rule satisfied, the artifact still wrong | Independent review; a Vision cannot detect this |
193
- | An accepted change silently falsifying the Vision | Require the amendment in the same change; check cross-document facts mechanically |
194
-
195
- And the sixth, which is why this file exists:
196
-
197
- **Adversarial re-description is unbounded.** Every patch names the evasions seen so
198
- far; a new one always exists. Patch-after-defeat is a treadmill. The only thing
199
- that converts it into a ratchet is a **standing battery**: keep every attack
200
- proposal that ever worked as a fixture and re-run the whole set against every
201
- Vision edit. A Vision without a battery decays the moment someone motivated reads
202
- it.
203
-
204
- ## 6. The blind check (procedure)
205
-
206
- Run this **before promoting any Vision to APPROVED, and before any amendment of an
207
- approved one**. Not for DRAFT edits — promotion is when authority is granted, and
208
- it is rare, so the cost lands where it buys most.
209
-
210
- 1. **Give the reviewer the document text and nothing else.** Not a path — the
211
- text, pasted. Forbid opening files, searching, and web access explicitly. A
212
- term the reviewer cannot resolve is then a property of the document, not of
213
- their tooling.
214
- 2. **Fresh context, and a different model from the author where the client allows
215
- it.** Author self-review is structurally blind to its own omissions.
216
- 3. **Hand them a battery, not an open question.** Concrete proposals to rule on:
217
- - the standing fixtures (every attack that ever worked — see §5);
218
- - **reject-side** proposals aimed at each prohibition;
219
- - **accept-side** proposals the document plainly wants (a bug fix, packaging
220
- work, supporting one more client, a documentation improvement). *A gate that
221
- can only reject is half a gate, and the accept side is where most Visions
222
- fail without anyone noticing.*
223
- 4. **Ask for the mechanism, not just the verdict.** For each ruling: the exact
224
- quoted line, or precisely what the document fails to say. Then: *which rules
225
- could you not get around, and what structural property defeated you?* That
226
- answer is worth more than the findings.
227
- 5. **Ask for rewords.** "Slip a bad proposal past this document, including one
228
- dressed in its own approving vocabulary." A rule nobody can reword is done; a
229
- rule that falls to the first attempt was never a rule.
230
- 6. **Every finding is answered — fixed, or refused with reasoning** (`review.md`
231
- §Receiving). Add every successful reword to the standing battery, whether or
232
- not you fix it this round.
233
-
234
- Three lenses are worth running for a product-level Vision: **comprehension** (what
235
- is this, what could you not resolve), **gate operability** (the battery above),
236
- **durability** (what rots, what is unfalsifiable, what is a time bomb). For a
237
- feature-level Vision or an M-VISION, the gate lens alone is usually enough.
238
-
239
- ## 7. Cost, honestly
240
-
241
- A first draft written against §1–§4 will still have findings — the checklist
242
- removes the structural classes, not judgement errors. Expect one blind round to
243
- find real things and a second to confirm. What it should NOT take is five rounds
244
- of discovering the same class of defect in a new disguise; that is the specific
245
- waste this file exists to prevent.
1
+ # Writing a Vision that a cold reviewer can actually apply
2
+
3
+ Support file for `ai_docs/vision/project_vision.md`, `vision/features/VISION_*.md`
4
+ and (Hybrid) the devPNT M-VISION. Read it when writing or amending any of them.
5
+ The template lives in `templates.md`; this file is the *why it works*.
6
+
7
+ **The problem this solves.** A Vision's job is to be read cold — by a later
8
+ session, by a reviewer, by another agent — and to produce a ruling on a proposed
9
+ change. Most Visions cannot do that: they read as intent to whoever wrote them and
10
+ as ambiguity to everyone else, and the gap is invisible until something wrong gets
11
+ through. Writing one and then discovering the holes by adversarial rounds works,
12
+ but it costs several rewrites. The checklist below exists so a Vision is
13
+ verifiable on the **first** draft.
14
+
15
+ Everything here was derived empirically: six blind adversarial rounds against one
16
+ real Vision, reviewers with no repository access, ~25 attack proposals. Rules that
17
+ survived every attack and rules that fell were compared for structure. What
18
+ follows is that difference.
19
+
20
+ ## What a Vision IS
21
+
22
+ A Vision states **what is to be obtained — the benefit — while leaving the most
23
+ degrees of freedom possible. It binds nothing that does not obstruct that
24
+ benefit.**
25
+
26
+ Four consequences, each operational:
27
+
28
+ - **State the benefit, not the mechanism.** What the actor *obtains*, never how —
29
+ and concrete enough that an obstacle to it is *recognizable*. This is the test a
30
+ North Star must pass: from "best-in-class" no constraint is derivable and none
31
+ is refutable, because nothing recognizably obstructs it. From "everything the
32
+ methodology produces stays usable in full without paying", a metering ban
33
+ follows and can be checked.
34
+ - **The deletion test — the generative rule for every constraint.** Remove the
35
+ rule: is the benefit still reachable? If **yes**, delete the rule — it was
36
+ spending a degree of freedom on nothing. If **no**, keep it, and its sentence
37
+ must name the obstacle it removes. This is also the stop rule: when nothing on
38
+ the table would obstruct the benefit, the Vision needs no new rule.
39
+ - **Constraints accumulate as the work reveals obstacles.** The first draft is the
40
+ benefit plus the few constraints already known — usually almost none, and that
41
+ is correct (`DRAFT` informs, `APPROVED` binds). Each constraint added later
42
+ *sharpens* the Vision without shrinking it more than the obstacle requires.
43
+ - **A constraint never obstructs the Vision.** A proposed rule that conflicts with
44
+ the benefit is not a constraint to negotiate in place — it is a Vision
45
+ **amendment**, and amending is the owner's decision, never a side effect of a
46
+ downstream edit.
47
+
48
+ Extracting the benefit from a discussion is real work: a discourse arrives with
49
+ solutions, preferences and constraints tangled together, and the Vision is the
50
+ distilled benefit only. The elicitation round (`elicitation.md`) asks for it first
51
+ — and a mechanism ("a dashboard") is not an acceptable answer to a benefit
52
+ question ("never lose the thread"); ask again until the answer names what the
53
+ actor obtains.
54
+
55
+ The deletion test decides **which** rules exist. Everything below decides **how**
56
+ to write a rule so it holds once you know it must exist.
57
+
58
+ ## 0. The one-line test
59
+
60
+ > Could a reader who has never seen this project rule ACCEPT or REJECT on a
61
+ > proposed change, quoting one line of this document, without asking anyone
62
+ > anything?
63
+
64
+ If a section cannot contribute to that, it is background — keep it if it helps a
65
+ human, but know it carries no gate weight.
66
+
67
+ ## 1. The nine properties of a rule that holds
68
+
69
+ Each is stated as a drafting action, with the attack it defeats.
70
+
71
+ 1. **Key the rule to a property observable in the artifact — never to intent,
72
+ commitment, plan or purpose.** Test while drafting: *could I verify compliance
73
+ by reading the diff, without asking the author what they meant?*
74
+ → Defeats: the proposer simply promises the opposite. A rule that forbids
75
+ "committing to track someone's format" is satisfied by saying "we commit to
76
+ nothing"; a rule that forbids "code in this repo that parses a format we do
77
+ not define" is not.
78
+ 2. **Write it as one yes/no question with BOTH branches answered.**
79
+ → Defeats: a gate that can only reject. A prohibition-only Vision rejects the
80
+ work it wants (new client support, packaging, bug fixes) and is abandoned.
81
+ 3. **Phrase the question counterfactually about capability, not about the status
82
+ quo** — "could the user obtain this…", not "does the product currently do it".
83
+ → Defeats: "we never shipped it, so nothing is being taken away."
84
+ 4. **Enumerate the near-miss verbs, not just the headline one** — charge / count /
85
+ cap / condition / gate / degrade / delay / require-signup.
86
+ → Defeats: the soft form. A generous cap, a free-but-registered tier, a
87
+ zero-cost counter — all are the same harm and none is the headline verb.
88
+ 5. **Define every term the rule turns on by EFFECT, and close the list.** A
89
+ definition that enumerates mechanisms is a list of the ways you already thought
90
+ of; end it with "…and anything else the user must give, accept or obtain from
91
+ us."
92
+ → Defeats: the third mechanism. "Charge = payment or account" is walked past by
93
+ "requires opting into telemetry".
94
+ 6. **Enumerate the FORMS a violation can take, then state a closure rule** —
95
+ "anything not named here is out unless it is X".
96
+ → Defeats: the unnamed variant. "A step, a required field, a check, or a cost
97
+ that varies but is never zero" kills "auto-filled, zero human input", because
98
+ the form is still a required field.
99
+ 7. **State the subject predicate of any enumerated test in checkable terms.** If
100
+ the test applies to "a record of work", say what makes something one.
101
+ → Defeats: denying the subject. The proposer agrees with every item on your
102
+ list and asserts the list does not apply.
103
+ 8. **Give one IN and one OUT example on the same axis, differing in a single
104
+ variable.** The pair carries the discriminator; without it the reader invents
105
+ one.
106
+ → Defeats: the borderline case, which is where every real argument happens.
107
+ 9. **Name the re-descriptions you expect, inside the rule's own sentence** —
108
+ "in any presentation", "however the code got here", "not by a component that
109
+ does not exist yet", "storing it as Markdown changes nothing".
110
+ → Defeats: relabeling. A board called a "view" is still a board.
111
+
112
+ ## 2. The five clauses a Vision needs around its rules
113
+
114
+ Rules do not hold alone. These structural clauses were the difference between a
115
+ rule that survived and the same rule leaking.
116
+
117
+ - **Supremacy clause** — on any rule a second layer, product, tier or future
118
+ component could route around: *"these bind the product as a whole; shipping a
119
+ forbidden thing in the paid layer does not put it out of reach."*
120
+ - **Exceptions attached to the rule they limit, in the same bullet, phrased
121
+ affirmatively.** An exception in another section is a leak; an exception phrased
122
+ only as a negation produces CANNOT DECIDE. *"This rule does not reach X;
123
+ supporting one more X is squarely wanted."*
124
+ - **Anti-abuse clause on every exemption, naming the only permitted outcomes.**
125
+ A maintenance exemption without one lets any forbidden thing that already
126
+ shipped be maintained forever, and any new one be framed as a fix to it:
127
+ *"work framed as a fix to something that should never have shipped is not
128
+ exempt — it is the removal of that thing, or it is out."*
129
+ - **Stated defaults, per path including the exempt path** — "anything unreached is
130
+ out"; "an exempt fix that preserves a forbidden thing is out". A test that says
131
+ "admitted only if" gives new capability a default; exempt work has none unless
132
+ you write one.
133
+ - **Precedence, when two sentences can both apply.** Two adjacent statements
134
+ pointing opposite ways are decided by whichever the reader reaches first.
135
+
136
+ ## 3. Only prohibitions can reject; only positives can admit
137
+
138
+ This is the most common structural failure and it is invisible from the inside.
139
+
140
+ - **A Goal cannot reject anything.** If the admission test says "advances a Goal
141
+ and violates no Non-Goal", then rejection power lives *only* in the Non-Goals.
142
+ A Goal that says "scale cost to risk in both directions" cannot stop cost
143
+ inflation — you need a prohibition for that.
144
+ - **A prohibition scoped to one rung of your own scale protects only that rung.**
145
+ Banning ceremony on trivial edits invites the same ceremony one level up.
146
+ - **A criterion phrased as an already-true state cannot be advanced.** "The check
147
+ is CLEAN at every closure" is a state, so "advances this signal" is meaningless
148
+ and any proposal citing it is undecidable. Give every positive criterion a
149
+ **baseline with headroom**: a current value and date, or an explicit list of
150
+ improvement categories that count.
151
+ - **Give recurring legitimate work an explicit authorization clause**, or it will
152
+ be rejected by your own test: packaging and installation, the product's own
153
+ tests, reducing what the agent must read, supporting one more client. Each needs
154
+ a home in the positive sources — otherwise "moves nothing this document commits
155
+ to" fires on exactly the maintenance the product needs.
156
+
157
+ ## 4. Minimum operable sections
158
+
159
+ A Vision is a gate. These are the load-bearing parts; anything else is
160
+ orientation for humans and should be recognized as such.
161
+
162
+ | Section | Must contain | Enables |
163
+ |---|---|---|
164
+ | Authority & scope | what it binds (all layers, tiers, future components), that packaging is irrelevant, precedence among its own sections, the approval line | both |
165
+ | Defaults | the default ruling for anything unreached, stated per path | both |
166
+ | Admission test | one sentence naming *exactly which* sections are positive sources and *exactly which* are prohibitions | ACCEPT |
167
+ | Positive sources | Goals / Actor commitments / Success Signals — each with a baseline and headroom, checkable against a named artifact | ACCEPT |
168
+ | Prohibitions | property-based, closed enumerations, named re-descriptions, in/out pairs | REJECT |
169
+ | Invariants | the decision question with both branches answered, plus an anti-laundering clause | both |
170
+ | Exemptions | each with its anti-abuse clause | prevents laundering |
171
+ | Definitions & imported facts | terms defined by effect; **any fact from another document a ruling depends on, restated here** with the reason | standalone use |
172
+ | Pointers | what deliberately lives elsewhere, so an absence reads as intentional | prevents false CANNOT DECIDE |
173
+
174
+ **Imported facts matter more than they look.** If a ruling needs your triage
175
+ levels, your risk tiers or your lifecycle states, restate the boundaries in the
176
+ Vision — routing the reader to another file breaks the cold-read premise the
177
+ whole gate rests on. Keep the procedure elsewhere; bring the boundaries here.
178
+
179
+ **Keep competitive positioning OUT.** A Vision defined by comparison to another
180
+ product rots silently: the comparison target moves and no one edits your document.
181
+ Put it in a dated snapshot elsewhere and point to it.
182
+
183
+ ## 5. What no wording can fix — use a mechanism instead
184
+
185
+ Five failure classes are structural. Prose cannot close them; do not try.
186
+
187
+ | Failure | Mechanism |
188
+ |---|---|
189
+ | "Advances a Goal" is a claim about the world, not the text | Measure it: run the ruling battery before and after, admit on measured improvement |
190
+ | **Cumulative ratchet** — each addition defensible, the sum is the ceremony the Vision forbids | A measured budget: steps per level, tokens the agent loads, artifacts per change; add-one-remove-one |
191
+ | Facts the proposal never states ("a quota of *what*?") | A proposal template that demands them, and a stated rule that omission resolves against the proposal |
192
+ | Structural compliance without truth — every rule satisfied, the artifact still wrong | Independent review; a Vision cannot detect this |
193
+ | An accepted change silently falsifying the Vision | Require the amendment in the same change; check cross-document facts mechanically |
194
+
195
+ And the sixth, which is why this file exists:
196
+
197
+ **Adversarial re-description is unbounded.** Every patch names the evasions seen so
198
+ far; a new one always exists. Patch-after-defeat is a treadmill. The only thing
199
+ that converts it into a ratchet is a **standing battery**: keep every attack
200
+ proposal that ever worked as a fixture and re-run the whole set against every
201
+ Vision edit. A Vision without a battery decays the moment someone motivated reads
202
+ it.
203
+
204
+ ## 6. The blind check (procedure)
205
+
206
+ Run this **before promoting any Vision to APPROVED, and before any amendment of an
207
+ approved one**. Not for DRAFT edits — promotion is when authority is granted, and
208
+ it is rare, so the cost lands where it buys most.
209
+
210
+ 1. **Give the reviewer the document text and nothing else.** Not a path — the
211
+ text, pasted. Forbid opening files, searching, and web access explicitly. A
212
+ term the reviewer cannot resolve is then a property of the document, not of
213
+ their tooling.
214
+ 2. **Fresh context, and a different model from the author where the client allows
215
+ it.** Author self-review is structurally blind to its own omissions.
216
+ 3. **Hand them a battery, not an open question.** Concrete proposals to rule on:
217
+ - the standing fixtures (every attack that ever worked — see §5);
218
+ - **reject-side** proposals aimed at each prohibition;
219
+ - **accept-side** proposals the document plainly wants (a bug fix, packaging
220
+ work, supporting one more client, a documentation improvement). *A gate that
221
+ can only reject is half a gate, and the accept side is where most Visions
222
+ fail without anyone noticing.*
223
+ 4. **Ask for the mechanism, not just the verdict.** For each ruling: the exact
224
+ quoted line, or precisely what the document fails to say. Then: *which rules
225
+ could you not get around, and what structural property defeated you?* That
226
+ answer is worth more than the findings.
227
+ 5. **Ask for rewords.** "Slip a bad proposal past this document, including one
228
+ dressed in its own approving vocabulary." A rule nobody can reword is done; a
229
+ rule that falls to the first attempt was never a rule.
230
+ 6. **Every finding is answered — fixed, or refused with reasoning** (`review.md`
231
+ §Receiving). Add every successful reword to the standing battery, whether or
232
+ not you fix it this round.
233
+
234
+ Three lenses are worth running for a product-level Vision: **comprehension** (what
235
+ is this, what could you not resolve), **gate operability** (the battery above),
236
+ **durability** (what rots, what is unfalsifiable, what is a time bomb). For a
237
+ feature-level Vision or an M-VISION, the gate lens alone is usually enough.
238
+
239
+ ## 7. Cost, honestly
240
+
241
+ A first draft written against §1–§4 will still have findings — the checklist
242
+ removes the structural classes, not judgement errors. Expect one blind round to
243
+ find real things and a second to confirm. What it should NOT take is five rounds
244
+ of discovering the same class of defect in a new disguise; that is the specific
245
+ waste this file exists to prevent.