@antoneeo/kb-agentic-skill 1.35.0 → 1.35.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  Every significant change to this skill is recorded here.
4
4
 
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [1.35.1] - 2026-11-04
9
+
10
+ ### What's new
11
+
12
+ **Codex hook checks can recognize the work the agent is doing.** The shared validator recognizes supported native Codex patches and transcript records, and gives more accurate orientation-hook diagnostics when definitions are disabled or cannot be verified. Existing hook setup and opt-outs are preserved.
13
+
14
+ #### What to do
15
+
16
+ Run `npm install -g @antoneeo/kb-agentic-skill@latest`, then `kb-agentic-install-skill`, and restart your agent sessions so they load the updated validator. Check that `npm ls -g @antoneeo/kb-agentic-skill` shows 1.35.1. Any configured Codex hooks still require their normal client trust review.
17
+
18
+ ### Changed
19
+
20
+ - Update the shared validator for Codex event recognition, attributed hook discovery and disabled/unverified configuration handling.
21
+
5
22
  ## [1.35.0] - 2026-11-01
6
23
 
7
24
  ### What's new
package/README.md CHANGED
@@ -6,17 +6,13 @@ The sibling of [`@antoneeo/agentic-sdlc-skill`](https://www.npmjs.com/package/@a
6
6
 
7
7
  <!-- whats-new:begin -->
8
8
  <!-- generated by scripts/whats_new.js from distributions/kb-agentic-skill/CHANGELOG.md: edit the CHANGELOG, then run node scripts/whats_new.js --write -->
9
- ## What's new in 1.35.0
9
+ ## What's new in 1.35.1
10
10
 
11
- **Branches that add review rows merge without a conflict.** When two branches both add rows to the review log and your project has no merge rule for that file, merging them stops on a conflict you resolve by hand. The check the agent runs when it closes a piece of work now notices the missing rule and prints the exact line to add to `.gitattributes`, so the agent sees what to fix while it works, without anyone reading release notes. Nothing changes at session start, and the note never makes a check fail.
11
+ **Codex hook checks can recognize the work the agent is doing.** The shared validator recognizes supported native Codex patches and transcript records, and gives more accurate orientation-hook diagnostics when definitions are disabled or cannot be verified. Existing hook setup and opt-outs are preserved.
12
12
 
13
13
  #### What to do
14
14
 
15
- **1. Update (everyone).** The changes arrive only with the update.
16
- 1. Run `npm install -g @antoneeo/kb-agentic-skill@latest`, then `kb-agentic-install-skill`.
17
- 2. Close and reopen your agent sessions: the new version loads only at startup.
18
-
19
- To check: `npm ls -g @antoneeo/kb-agentic-skill` shows 1.35.0.
15
+ Run `npm install -g @antoneeo/kb-agentic-skill@latest`, then `kb-agentic-install-skill`, and restart your agent sessions so they load the updated validator. Check that `npm ls -g @antoneeo/kb-agentic-skill` shows 1.35.1. Any configured Codex hooks still require their normal client trust review.
20
16
 
21
17
  Full history: [CHANGELOG](https://github.com/Antoneeo/agentic-sdlc-skill/blob/main/distributions/kb-agentic-skill/CHANGELOG.md)
22
18
  <!-- whats-new:end -->
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kb-agentic-skill",
3
- "version": "1.35.0",
3
+ "version": "1.35.1",
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.35.0",
3
+ "version": "1.35.1",
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
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: kb-agentic
3
- version: 1.35.0
3
+ version: 1.35.1
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
@@ -35,6 +35,7 @@ but are deprecated: new documents should use the English forms.
35
35
  Standard library only (Python >= 3.8). Windows and POSIX compatible.
36
36
  """
37
37
  import argparse
38
+ import base64
38
39
  import hashlib
39
40
  import json
40
41
  import os
@@ -2317,6 +2318,29 @@ ORIENT_HOOK_CONFIG_CAP = 1024 * 1024 # settings are tiny; cap pathological file
2317
2318
  _ORIENT_HOOK_CMD_RE = re.compile(r" orient(\s|$)")
2318
2319
  _ORIENT_HOOK_TOKEN_RE = re.compile(r'"([^"]*)"|(\S+)')
2319
2320
 
2321
+ # Same fixed, versioned carrier as scripts/lib.js; only JSON data is decoded.
2322
+ _CODEX_HOOK_WRAPPER = "import base64,json,subprocess,sys;d=json.loads(base64.b64decode(sys.argv[2]));subprocess.run([sys.executable,d['validator'],*d['argv']],input=sys.stdin.buffer.read())"
2323
+
2324
+
2325
+ def _decode_hook_invocation(command):
2326
+ middle = ' -c "' + _CODEX_HOOK_WRAPPER + '" agentic-sdlc-hook-v1 '
2327
+ if not isinstance(command, str) or middle not in command:
2328
+ return None
2329
+ prefix, encoded = command.split(middle, 1)
2330
+ if not re.fullmatch(r'[\w.-]+|"[^"$`\r\n]+"', prefix):
2331
+ return None
2332
+ try:
2333
+ data = json.loads(base64.b64decode(encoded, validate=True))
2334
+ if (not isinstance(data, dict) or data.get("client") != "codex"
2335
+ or not isinstance(data.get("validator"), str)
2336
+ or not isinstance(data.get("argv"), list) or not data["argv"]
2337
+ or not all(isinstance(a, str) for a in data["argv"])
2338
+ or data["argv"][0] not in ("orient", "remind", "verdict", "constraints")):
2339
+ return None
2340
+ return data
2341
+ except (ValueError, TypeError):
2342
+ return None
2343
+
2320
2344
 
2321
2345
  def _orient_entries_in(p):
2322
2346
  """Yield the SessionStart commands invoking an orient entry point from ONE
@@ -2327,11 +2351,20 @@ def _orient_entries_in(p):
2327
2351
  try:
2328
2352
  if not p.is_file() or p.stat().st_size > ORIENT_HOOK_CONFIG_CAP:
2329
2353
  return
2330
- data = json.loads(p.read_text(encoding="utf-8-sig"))
2354
+ if p.suffix == ".toml":
2355
+ import tomllib
2356
+ data = tomllib.loads(p.read_text(encoding="utf-8-sig"))
2357
+ else:
2358
+ data = json.loads(p.read_text(encoding="utf-8-sig"))
2331
2359
  except Exception:
2332
2360
  return
2333
2361
  if not isinstance(data, dict):
2334
2362
  return
2363
+ features = data.get("features")
2364
+ if p.name in ("hooks.json", "config.toml") and (
2365
+ isinstance(features, dict) and features.get("hooks") is False
2366
+ or data.get("allow_managed_hooks_only") is True):
2367
+ return
2335
2368
  hooks = data.get("hooks")
2336
2369
  groups = hooks.get("SessionStart") if isinstance(hooks, dict) else None
2337
2370
  if groups is None:
@@ -2341,12 +2374,20 @@ def _orient_entries_in(p):
2341
2374
  for group in groups:
2342
2375
  if not isinstance(group, dict):
2343
2376
  continue
2377
+ codex = p.name in ("hooks.json", "config.toml")
2378
+ if codex and group.get("enabled") is False:
2379
+ continue
2344
2380
  inner = group.get("hooks")
2345
2381
  for h in inner if isinstance(inner, list) else [group]:
2382
+ if codex and (not isinstance(h, dict) or h.get("enabled") is False or h.get("type") != "command"):
2383
+ continue
2346
2384
  cmd = h.get("command") if isinstance(h, dict) else None
2347
- if (isinstance(cmd, str)
2348
- and any(n in cmd for n in ORIENT_HOOK_ENTRY_POINTS)
2349
- and _ORIENT_HOOK_CMD_RE.search(cmd)):
2385
+ if isinstance(h, dict) and p.name in ("hooks.json", "config.toml") and os.name == "nt":
2386
+ cmd = h.get("commandWindows") or h.get("command_windows") or cmd
2387
+ invocation = _decode_hook_invocation(cmd)
2388
+ if ((invocation and invocation["argv"][0] == "orient") or
2389
+ (isinstance(cmd, str) and any(n in cmd for n in ORIENT_HOOK_ENTRY_POINTS)
2390
+ and _ORIENT_HOOK_CMD_RE.search(cmd))):
2350
2391
  yield cmd
2351
2392
 
2352
2393
 
@@ -2365,17 +2406,69 @@ def _orient_user_settings_path():
2365
2406
  return (Path(cfg) if cfg else Path.home() / ".claude") / "settings.json"
2366
2407
 
2367
2408
 
2409
+ def _codex_hook_config(root):
2410
+ """Observable Codex policy across sources; no trust or execution assertion."""
2411
+ home = Path(os.environ.get("CODEX_HOME") or Path.home() / ".codex")
2412
+ disabled, unverified, disabled_entries = False, False, False
2413
+ for directory in (home, Path(root) / ".codex"):
2414
+ for name in ("hooks.json", "config.toml"):
2415
+ p = directory / name
2416
+ if not p.exists():
2417
+ continue
2418
+ try:
2419
+ if not p.is_file() or p.stat().st_size > ORIENT_HOOK_CONFIG_CAP:
2420
+ raise ValueError("unreadable configuration")
2421
+ text = p.read_text(encoding="utf-8-sig")
2422
+ if p.suffix == ".toml":
2423
+ import tomllib
2424
+ data = tomllib.loads(text)
2425
+ else:
2426
+ data = json.loads(text)
2427
+ if not isinstance(data, dict):
2428
+ raise ValueError("unknown configuration shape")
2429
+ features = data.get("features", {})
2430
+ hooks = data.get("hooks", {})
2431
+ if not isinstance(features, dict) or not isinstance(hooks, dict):
2432
+ raise ValueError("unknown policy or hooks shape")
2433
+ disabled |= features.get("hooks") is False or data.get("allow_managed_hooks_only") is True
2434
+ groups = hooks.get("SessionStart", data.get("SessionStart", []))
2435
+ if not isinstance(groups, list):
2436
+ raise ValueError("unknown hook groups")
2437
+ for group in groups:
2438
+ if not isinstance(group, dict):
2439
+ raise ValueError("unknown hook group")
2440
+ inner = group.get("hooks", [group])
2441
+ if not isinstance(inner, list) or not all(isinstance(h, dict) for h in inner):
2442
+ raise ValueError("unknown handlers")
2443
+ disabled_entries |= group.get("enabled") is False or any(h.get("enabled") is False for h in inner)
2444
+ except Exception:
2445
+ unverified = True
2446
+ policy = "disabled-by-policy" if disabled else "unverified" if unverified else "enabled"
2447
+ return {"policy": policy, "disabled_entries": disabled_entries}
2448
+
2449
+
2368
2450
  def _orient_hook_commands(root):
2369
2451
  """Yield (command, at_user_level, place) across every known client config:
2370
2452
  the three project-relative files, then the machine-global user settings --
2371
2453
  the file the installer wires (F-042), without which a fixed machine's
2372
2454
  projects would read as unwired forever. `place` is a display label, never a
2373
2455
  home path (F-075 prints it)."""
2456
+ codex_policy = _codex_hook_config(root)["policy"]
2374
2457
  for rel in ORIENT_HOOK_CONFIG_FILES:
2458
+ if rel.startswith(".codex/") and codex_policy != "enabled":
2459
+ continue
2375
2460
  for cmd in _orient_entries_in(Path(root) / rel):
2376
2461
  yield cmd, False, rel
2377
2462
  for cmd in _orient_entries_in(_orient_user_settings_path()):
2378
2463
  yield cmd, True, "user settings"
2464
+ if codex_policy != "enabled":
2465
+ return
2466
+ home = Path(os.environ.get("CODEX_HOME") or Path.home() / ".codex")
2467
+ for name in ("hooks.json", "config.toml"):
2468
+ for cmd in _orient_entries_in(home / name):
2469
+ yield cmd, True, "codex user " + name
2470
+ for cmd in _orient_entries_in(Path(root) / ".codex" / name) if name == "config.toml" else ():
2471
+ yield cmd, False, ".codex/" + name
2379
2472
 
2380
2473
 
2381
2474
  def _orient_entry_live(root, cmd, at_user_level):
@@ -2386,7 +2479,8 @@ def _orient_entry_live(root, cmd, at_user_level):
2386
2479
  tokens resolve against the project root (the vendored-validator
2387
2480
  convention); a USER-level relative token has no cwd to resolve against and
2388
2481
  is treated as cannot-tell."""
2389
- token = None
2482
+ invocation = _decode_hook_invocation(cmd)
2483
+ token = invocation["validator"] if invocation else None
2390
2484
  for m in _ORIENT_HOOK_TOKEN_RE.finditer(cmd):
2391
2485
  tok = m.group(1) if m.group(1) is not None else m.group(2)
2392
2486
  if any(tok.endswith(n) for n in ORIENT_HOOK_ENTRY_POINTS):
@@ -2413,7 +2507,7 @@ def orient_wiring(root):
2413
2507
  for cmd, at_user_level, place in _orient_hook_commands(root):
2414
2508
  if not _orient_entry_live(root, cmd, at_user_level):
2415
2509
  continue
2416
- client = "codex" if place.startswith(".codex") else "claude"
2510
+ client = "codex" if place.startswith((".codex", "codex ")) else "claude"
2417
2511
  out.setdefault(client, {}).setdefault(cmd.strip(), place)
2418
2512
  return out
2419
2513
 
@@ -2447,6 +2541,13 @@ def print_orient_hook_note(root):
2447
2541
  does): the note is check-layer behaviour, whoever owns the check."""
2448
2542
  try:
2449
2543
  state = orient_hook_state(root)
2544
+ codex = _codex_hook_config(root)
2545
+ if codex["policy"] != "enabled" or codex["disabled_entries"]:
2546
+ detail = codex["policy"] if codex["policy"] != "enabled" else "disabled definitions present"
2547
+ print(f"[note] Codex hook configuration: {detail}. Disabled or unverified "
2548
+ "definitions are excluded from wiring counts; trust and native delivery are not verified.")
2549
+ if state == "unwired":
2550
+ return
2450
2551
  if state == "unwired":
2451
2552
  print("[note] agent sessions start without automatic orientation on this "
2452
2553
  "machine (no session-orientation hook found at project or user level). "
@@ -2700,6 +2801,192 @@ _DECLARATION_RE = re.compile(
2700
2801
  _GUIDE_NAME_RE = re.compile(r"GUIDE_[A-Za-z0-9_-]+\.md")
2701
2802
 
2702
2803
 
2804
+ def _hint_path(value, cwd):
2805
+ if not isinstance(value, str) or not value:
2806
+ return None
2807
+ p = Path(value)
2808
+ if not p.is_absolute():
2809
+ if not cwd or not Path(cwd).is_absolute():
2810
+ return None
2811
+ p = Path(cwd) / p
2812
+ return str(p.resolve())
2813
+
2814
+
2815
+ def hook_edits(payload):
2816
+ """Parse the complete native apply_patch syntax without executing it.
2817
+
2818
+ Unknown or incomplete input yields no partial target set. Move checks both
2819
+ the old and new paths; file membership is evaluated by the existing gate.
2820
+ """
2821
+ command = (payload.get("tool_input") or {}).get("command")
2822
+ if not isinstance(command, str) or len(command.encode("utf-8")) > VERDICT_LINE_MAX:
2823
+ return None
2824
+ lines = command.strip().splitlines()
2825
+ if not lines or lines[0] != "*** Begin Patch" or lines[-1] != "*** End Patch":
2826
+ return None
2827
+ edits, current, mode, changed = [], None, None, False
2828
+ for line in lines[1:-1]:
2829
+ match = re.fullmatch(r"\*\*\* (Add|Update|Delete) File: (.+)", line)
2830
+ if match:
2831
+ if current is not None and mode != "Delete" and not changed:
2832
+ return None
2833
+ mode, value = match.groups()
2834
+ target = _hint_path(value, payload.get("cwd"))
2835
+ if not target:
2836
+ return None
2837
+ current = {"path": target, "new_text": ""}
2838
+ edits.append(current)
2839
+ changed = False
2840
+ elif line.startswith("*** Move to: ") and current is not None and mode == "Update" and not changed:
2841
+ target = _hint_path(line[len("*** Move to: "):], payload.get("cwd"))
2842
+ if not target:
2843
+ return None
2844
+ current = {"path": target, "new_text": ""}
2845
+ edits.append(current)
2846
+ elif current is not None and mode != "Delete" and (
2847
+ line.startswith(("+", "-", " ", "@@")) or line == "*** End of File"):
2848
+ if mode == "Add" and not line.startswith("+"):
2849
+ return None
2850
+ if line.startswith(("+", "-")):
2851
+ changed = True
2852
+ if line.startswith("+"):
2853
+ current["new_text"] += line[1:] + "\n"
2854
+ else:
2855
+ return None
2856
+ if current is not None and mode != "Delete" and not changed:
2857
+ return None
2858
+ return edits or None
2859
+
2860
+
2861
+ def shell_read_paths(command, cwd, workdir=None):
2862
+ """Literal Get-Content/cat reads only: no shell expansion or execution."""
2863
+ if not isinstance(command, str) or re.search(r"[$`\r\n;|&<>\x00]", command):
2864
+ return None
2865
+ token_re = re.compile(r"\s*(?:'([^']*)'|\"([^\"]*)\"|([^\s'\"]+))")
2866
+ tokens, pos = [], 0
2867
+ while pos < len(command.rstrip()):
2868
+ match = token_re.match(command, pos)
2869
+ if not match:
2870
+ return None
2871
+ token = next(x for x in match.groups() if x is not None)
2872
+ tokens.append(token)
2873
+ pos = match.end()
2874
+ if not tokens or tokens[0].lower() not in ("get-content", "cat"):
2875
+ return None
2876
+ paths, i = [], 1
2877
+ while i < len(tokens):
2878
+ token = tokens[i]
2879
+ if tokens[0].lower() == "get-content" and token.lower() in ("-literalpath", "-path", "-raw"):
2880
+ if token.lower() != "-raw" and i + 1 == len(tokens):
2881
+ return None
2882
+ elif tokens[0].lower() == "get-content" and token.lower() == "-totalcount":
2883
+ i += 1
2884
+ if i == len(tokens) or not tokens[i].isdigit():
2885
+ return None
2886
+ elif tokens[0] == "cat" and token == "--":
2887
+ pass
2888
+ elif token.startswith("-") or re.search(r"[*?\[\],]", token):
2889
+ return None
2890
+ else:
2891
+ base = _hint_path(workdir, cwd) if workdir else cwd
2892
+ resolved = _hint_path(token, base)
2893
+ if not resolved:
2894
+ return None
2895
+ paths.append(resolved)
2896
+ i += 1
2897
+ return paths or None
2898
+
2899
+
2900
+ def _codex_literal_calls(code):
2901
+ """Recognize a small non-executable JS carrier grammar, otherwise nothing."""
2902
+ if not isinstance(code, str):
2903
+ return []
2904
+ calls, pos = [], 0
2905
+ pattern = re.compile(r"\s*(?:text\(\s*)?await\s+tools\.exec_command\((\{.*?\})\)\s*\)?\s*;?", re.DOTALL)
2906
+ field = re.compile(r'\s*(?:"(cmd|workdir)"|(cmd|workdir))\s*:\s*("(?:[^"\\]|\\.)*")\s*(,|$)')
2907
+ while pos < len(code.rstrip()):
2908
+ match = pattern.match(code, pos)
2909
+ if not match:
2910
+ return []
2911
+ obj, off, args = match[1][1:-1], 0, {}
2912
+ while off < len(obj.rstrip()):
2913
+ item = field.match(obj, off)
2914
+ if not item or (item[1] or item[2]) in args:
2915
+ return []
2916
+ try:
2917
+ args[item[1] or item[2]] = json.loads(item[3])
2918
+ except ValueError:
2919
+ return []
2920
+ off = item.end()
2921
+ if "cmd" not in args:
2922
+ return []
2923
+ calls.append(args)
2924
+ pos = match.end()
2925
+ return calls
2926
+
2927
+
2928
+ def transcript_events(path):
2929
+ """Yield legacy assistant blocks, plus normalized recognized Codex blocks.
2930
+
2931
+ This is read-only and bounded by the existing transcript limits. Historical
2932
+ cwd is taken from host metadata, never guessed from the present process.
2933
+ """
2934
+ cwd = None
2935
+ with Path(path).open("rb") as fh:
2936
+ for raw in fh:
2937
+ if len(raw) > VERDICT_LINE_MAX:
2938
+ continue
2939
+ try:
2940
+ entry = json.loads(raw.decode("utf-8", errors="replace"))
2941
+ except ValueError:
2942
+ continue
2943
+ if not isinstance(entry, dict):
2944
+ continue
2945
+ if entry.get("type") == "assistant":
2946
+ yield entry
2947
+ continue
2948
+ data = entry.get("payload")
2949
+ if not isinstance(data, dict):
2950
+ continue
2951
+ if entry.get("type") in ("session_meta", "turn_context"):
2952
+ if isinstance(data.get("cwd"), str):
2953
+ cwd = data["cwd"]
2954
+ continue
2955
+ if entry.get("type") != "response_item":
2956
+ continue
2957
+ blocks = []
2958
+ if data.get("type") == "message" and data.get("role") == "assistant":
2959
+ blocks = [{"type": "text", "text": x.get("text", "")}
2960
+ for x in (data.get("content") if isinstance(data.get("content"), list) else []) if isinstance(x, dict) and x.get("type") == "output_text"]
2961
+ elif data.get("type") in ("function_call", "custom_tool_call"):
2962
+ name = data.get("name")
2963
+ calls = []
2964
+ if name in ("exec_command", "Bash"):
2965
+ try:
2966
+ args = json.loads(data.get("arguments", "{}"))
2967
+ except (ValueError, TypeError):
2968
+ args = None
2969
+ if isinstance(args, dict):
2970
+ calls = [args]
2971
+ elif name == "exec":
2972
+ calls = _codex_literal_calls(data.get("input"))
2973
+ elif name == "apply_patch":
2974
+ command = data.get("input")
2975
+ if command is None:
2976
+ try:
2977
+ command = json.loads(data.get("arguments", "{}" )).get("command")
2978
+ except (ValueError, TypeError, AttributeError):
2979
+ pass
2980
+ for edit in hook_edits({"tool_input": {"command": command}, "cwd": cwd}) or []:
2981
+ blocks.append({"type": "tool_use", "name": "Write", "input": {"file_path": edit["path"]}})
2982
+ for args in calls:
2983
+ for target in shell_read_paths(args.get("cmd", args.get("command")), cwd, args.get("workdir")) or []:
2984
+ blocks.append({"type": "tool_use", "name": "Read", "input": {"file_path": target}})
2985
+ if blocks:
2986
+ yield {"type": "assistant", "isSidechain": bool(entry.get("agent_id") or data.get("agent_id")),
2987
+ "message": {"content": blocks}}
2988
+
2989
+
2703
2990
  def transcript_facts(path):
2704
2991
  """What the session transcript shows about the verdict duty, or None when it
2705
2992
  cannot be read within the bounds.
@@ -2714,14 +3001,7 @@ def transcript_facts(path):
2714
3001
  p = Path(path)
2715
3002
  if not p.is_file() or p.stat().st_size > VERDICT_MAX_BYTES:
2716
3003
  return None
2717
- with p.open("rb") as fh:
2718
- for raw in fh:
2719
- if len(raw) > VERDICT_LINE_MAX or b'"assistant"' not in raw:
2720
- continue
2721
- try:
2722
- entry = json.loads(raw.decode("utf-8", errors="replace"))
2723
- except ValueError:
2724
- continue
3004
+ for entry in transcript_events(p):
2725
3005
  if not isinstance(entry, dict) or entry.get("type") != "assistant":
2726
3006
  continue
2727
3007
  content = (entry.get("message") or {}).get("content")
@@ -2755,6 +3035,13 @@ def transcript_facts(path):
2755
3035
  def verdict_reason(payload, root=None, docs_name=None):
2756
3036
  """The refusal line for this edit event, or None when the edit may proceed.
2757
3037
  Without a root, the project is the one holding the edited file (hook_project)."""
3038
+ if payload.get("tool_name") == "apply_patch" and not payload.get("agent_id"):
3039
+ for edit in hook_edits(payload) or []:
3040
+ reason = verdict_reason({**payload, "tool_name": "Edit", "tool_input": {
3041
+ "file_path": edit["path"], "new_string": edit["new_text"]}}, root, docs_name)
3042
+ if reason:
3043
+ return reason
3044
+ return None
2758
3045
  if payload.get("tool_name") not in VERDICT_EDIT_TOOLS or payload.get("agent_id"):
2759
3046
  return None
2760
3047
  tool_input = payload.get("tool_input") or {}
@@ -3113,14 +3400,7 @@ def transcript_work(path):
3113
3400
  p = Path(path)
3114
3401
  if not p.is_file() or p.stat().st_size > VERDICT_MAX_BYTES:
3115
3402
  return None
3116
- with p.open("rb") as fh:
3117
- for raw in fh:
3118
- if len(raw) > VERDICT_LINE_MAX or b'"assistant"' not in raw:
3119
- continue
3120
- try:
3121
- entry = json.loads(raw.decode("utf-8", errors="replace"))
3122
- except ValueError:
3123
- continue
3403
+ for entry in transcript_events(p):
3124
3404
  if not isinstance(entry, dict) or entry.get("type") != "assistant":
3125
3405
  continue
3126
3406
  content = (entry.get("message") or {}).get("content")
@@ -3175,6 +3455,17 @@ def constraints_hook_context(payload, root=None, docs_name=None):
3175
3455
  a subagent, on a file of a project whose open L3 code unit binds it (or the
3176
3456
  unit's own ANALYSIS, about to name a path a P row binds -- UC6), by a session
3177
3457
  that worked on that unit and last declared L3."""
3458
+ if payload.get("tool_name") == "apply_patch" and not payload.get("agent_id"):
3459
+ lines = []
3460
+ for edit in hook_edits(payload) or []:
3461
+ context = constraints_hook_context({**payload, "tool_name": "Edit", "tool_input": {
3462
+ "file_path": edit["path"], "new_string": edit["new_text"]}}, root, docs_name)
3463
+ for line in (context or "").splitlines():
3464
+ if line not in lines:
3465
+ lines.append(line)
3466
+ if len(lines) > CONSTRAINTS_HOOK_LINES:
3467
+ lines = lines[:CONSTRAINTS_HOOK_LINES - 1] + [lines[-1]]
3468
+ return "\n".join(lines) or None
3178
3469
  if payload.get("tool_name") not in VERDICT_EDIT_TOOLS or payload.get("agent_id"):
3179
3470
  return None
3180
3471
  tool_input = payload.get("tool_input") or {}
@@ -3865,6 +4156,10 @@ def cmd_orient(args):
3865
4156
  for client, entries in sorted(orient_wiring(root).items()):
3866
4157
  if len(entries) > 1:
3867
4158
  places = ", ".join(sorted(set(entries.values())))
4159
+ if client == "codex":
4160
+ tail.append(f"[note] Codex has {len(entries)} configured orientation definitions "
4161
+ f"({places}); trust and runtime policy determine delivery. Keep one equivalent definition.")
4162
+ continue
3868
4163
  tail.append(f"[note] session orientation is wired {len(entries)} times for one "
3869
4164
  f"client ({places}): each session receives every copy. Keep one "
3870
4165
  "entry and remove the others.")
@@ -1,308 +1,308 @@
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 owner interview below asks for it — and a mechanism
51
- ("a dashboard") is not an acceptable answer to a benefit question ("never lose
52
- the thread"); ask again until the answer names what the actor obtains.
53
-
54
- The deletion test decides **which** rules exist. Everything below decides **how**
55
- to write a rule so it holds once you know it must exist.
56
-
57
- ## The owner interview (before any Vision text)
58
-
59
- A Vision is the **owner's** statement of what is to be obtained. Nothing in this
60
- file after this section can detect a Vision the author wrote alone: the blind
61
- check (§6) tests whether the rules survive a hostile reader, never whether they
62
- are the owner's. So every Vision is born from an interview of the owner, and its
63
- north star is approved **before** a line of it is drafted.
64
-
65
- **Scope — every Vision, in every mode:** `project_vision.md`, a feature
66
- `VISION_*.md`, a lens Vision (course, marketing), and the devPNT M-VISION in
67
- Hybrid; also an ANALYSIS `## Feature Vision` that states a benefit no existing
68
- Vision names (one that cites an approved Vision's benefit is alignment, not a
69
- Vision). An amendment re-runs the questions whose answers it changes, and Gate 1
70
- again when the north star changes. **There is no skip path**: one sentence from
71
- the user plus a spike is not a complete spec — that exact shortcut produced a
72
- Vision with an imported prohibition, no north star and a missing actor, and four
73
- downstream artifacts built on it (field case, 2026-10). A reply already on record
74
- in the owner's words is read back for confirmation, never re-asked as an open
75
- question; an answer the author derived (from a spike, the code, another Vision)
76
- is never an answer — it is a proposal the owner confirms or rejects.
77
-
78
- **The questions, in this order.** Each is repeated until its answer has the form
79
- stated; the wrong form is named so it can be recognized and asked again.
80
-
81
- | # | Question | Right form | Wrong form — ask again |
82
- |---|---|---|---|
83
- | 1 | **Problem** — which concrete case today does not get the expected result? | one real case, with an example | a missing feature ("there is no drawing tool") |
84
- | 2 | **Benefit** — once solved, who obtains what? | a result for a named actor | a function or mechanism ("a renderer") |
85
- | 3 | **Actors** — who receives the benefit, who acts, who has the initiative? | all three named, initiative included | only the one who asks — the actor who acts unprompted goes missing |
86
- | 4 | **Success** — what observable signal shows the benefit arrived? | a signal with its starting value | a feeling, or a signal with no baseline |
87
- | 5 | **Boundaries** — what does this NOT pursue? | scope excluded from this work | a ban on behaviour ("X must never happen") — that is a constraint (6) or an obligation (2, 4) |
88
- | 6 | **Known constraints** — each with its provenance: owner, a quoted line of a higher Vision, or author inference | every constraint sourced; every inference asked here | a constraint written in silently, or imported from a higher Vision without asking whether it applies here |
89
-
90
- A **Non-Goal bounds scope**: it rejects a proposal that pursues what it names; it
91
- is not a ban on behaviour that already exists, and it creates no obligation.
92
- Obligations come from the Benefit and the Success Signals.
93
-
94
- **Gate 1 — north star.** One or two sentences, in the owner's words, explicitly
95
- approved by the owner. The author may compose a wording from the answers; the
96
- approval is of that exact text, recorded verbatim in the request record
97
- (`audit/requests/REQUEST_[unit].md`; a Vision written outside any unit, such as
98
- the project Vision after bootstrap, records its interview in
99
- `audit/requests/REQUEST_project_vision.md`). **Without it no Vision text is written** —
100
- not a DRAFT, not a reconstruction: bootstrap writes a stub awaiting the
101
- interview, and what the agent observed goes to `strategic/`.
102
- Unattended, the unit is `BLOCKED on the user` (`elicitation.md` Unattended path).
103
-
104
- **Gate 2 — the full Vision**, written from the answers. Every section traces to
105
- an answer or a stated provenance (`REQUEST_[unit].md#R<n>`); every rule carries
106
- its provenance; an author inference the owner did not confirm is not in it. The
107
- blind check (§6) verifies that it holds; the approved north star verifies that it
108
- is the owner's. Promotion to APPROVED still needs the owner's explicit
109
- confirmation — Gate 2 is that confirmation, given on the written text.
110
-
111
- ## 0. The one-line test
112
-
113
- > Could a reader who has never seen this project rule ACCEPT or REJECT on a
114
- > proposed change, quoting one line of this document, without asking anyone
115
- > anything?
116
-
117
- If a section cannot contribute to that, it is background — keep it if it helps a
118
- human, but know it carries no gate weight.
119
-
120
- ## 1. The nine properties of a rule that holds
121
-
122
- Each is stated as a drafting action, with the attack it defeats.
123
-
124
- 1. **Key the rule to a property observable in the artifact — never to intent,
125
- commitment, plan or purpose.** Test while drafting: *could I verify compliance
126
- by reading the diff, without asking the author what they meant?*
127
- → Defeats: the proposer simply promises the opposite. A rule that forbids
128
- "committing to track someone's format" is satisfied by saying "we commit to
129
- nothing"; a rule that forbids "code in this repo that parses a format we do
130
- not define" is not.
131
- 2. **Write it as one yes/no question with BOTH branches answered.**
132
- → Defeats: a gate that can only reject. A prohibition-only Vision rejects the
133
- work it wants (new client support, packaging, bug fixes) and is abandoned.
134
- 3. **Phrase the question counterfactually about capability, not about the status
135
- quo** — "could the user obtain this…", not "does the product currently do it".
136
- → Defeats: "we never shipped it, so nothing is being taken away."
137
- 4. **Enumerate the near-miss verbs, not just the headline one** — charge / count /
138
- cap / condition / gate / degrade / delay / require-signup.
139
- → Defeats: the soft form. A generous cap, a free-but-registered tier, a
140
- zero-cost counter — all are the same harm and none is the headline verb.
141
- 5. **Define every term the rule turns on by EFFECT, and close the list.** A
142
- definition that enumerates mechanisms is a list of the ways you already thought
143
- of; end it with "…and anything else the user must give, accept or obtain from
144
- us."
145
- → Defeats: the third mechanism. "Charge = payment or account" is walked past by
146
- "requires opting into telemetry".
147
- 6. **Enumerate the FORMS a violation can take, then state a closure rule** —
148
- "anything not named here is out unless it is X".
149
- → Defeats: the unnamed variant. "A step, a required field, a check, or a cost
150
- that varies but is never zero" kills "auto-filled, zero human input", because
151
- the form is still a required field.
152
- 7. **State the subject predicate of any enumerated test in checkable terms.** If
153
- the test applies to "a record of work", say what makes something one.
154
- → Defeats: denying the subject. The proposer agrees with every item on your
155
- list and asserts the list does not apply.
156
- 8. **Give one IN and one OUT example on the same axis, differing in a single
157
- variable.** The pair carries the discriminator; without it the reader invents
158
- one.
159
- → Defeats: the borderline case, which is where every real argument happens.
160
- 9. **Name the re-descriptions you expect, inside the rule's own sentence** —
161
- "in any presentation", "however the code got here", "not by a component that
162
- does not exist yet", "storing it as Markdown changes nothing".
163
- → Defeats: relabeling. A board called a "view" is still a board.
164
-
165
- ## 2. The five clauses a Vision needs around its rules
166
-
167
- Rules do not hold alone. These structural clauses were the difference between a
168
- rule that survived and the same rule leaking.
169
-
170
- - **Supremacy clause** — on any rule a second layer, product, tier or future
171
- component could route around: *"these bind the product as a whole; shipping a
172
- forbidden thing in the paid layer does not put it out of reach."*
173
- - **Exceptions attached to the rule they limit, in the same bullet, phrased
174
- affirmatively.** An exception in another section is a leak; an exception phrased
175
- only as a negation produces CANNOT DECIDE. *"This rule does not reach X;
176
- supporting one more X is squarely wanted."*
177
- - **Anti-abuse clause on every exemption, naming the only permitted outcomes.**
178
- A maintenance exemption without one lets any forbidden thing that already
179
- shipped be maintained forever, and any new one be framed as a fix to it:
180
- *"work framed as a fix to something that should never have shipped is not
181
- exempt — it is the removal of that thing, or it is out."*
182
- - **Stated defaults, per path including the exempt path** — "anything unreached is
183
- out"; "an exempt fix that preserves a forbidden thing is out". A test that says
184
- "admitted only if" gives new capability a default; exempt work has none unless
185
- you write one.
186
- - **Precedence, when two sentences can both apply.** Two adjacent statements
187
- pointing opposite ways are decided by whichever the reader reaches first.
188
-
189
- ## 3. Only prohibitions can reject; only positives can admit
190
-
191
- This is the most common structural failure and it is invisible from the inside.
192
-
193
- - **A Goal cannot reject anything.** If the admission test says "advances a Goal
194
- and violates no Non-Goal", then rejection power lives *only* in the Non-Goals
195
- (and the Invariants, where the Vision has them).
196
- - **A Non-Goal rejects scope, not behaviour.** It turns away a proposal that
197
- pursues what it names; it never forbids a behaviour the product already has, and
198
- it never creates an obligation — obligations come from the Benefit and the
199
- Success Signals. A behaviour the product must never have is an Invariant, or a
200
- constraint with its provenance (§The owner interview, question 6). Written as a
201
- Non-Goal, it reads as a ban the owner never stated.
202
- A Goal that says "scale cost to risk in both directions" cannot stop cost
203
- inflation — you need a prohibition for that.
204
- - **A prohibition scoped to one rung of your own scale protects only that rung.**
205
- Banning ceremony on trivial edits invites the same ceremony one level up.
206
- - **A criterion phrased as an already-true state cannot be advanced.** "The check
207
- is CLEAN at every closure" is a state, so "advances this signal" is meaningless
208
- and any proposal citing it is undecidable. Give every positive criterion a
209
- **baseline with headroom**: a current value and date, or an explicit list of
210
- improvement categories that count.
211
- - **Give recurring legitimate work an explicit authorization clause**, or it will
212
- be rejected by your own test: packaging and installation, the product's own
213
- tests, reducing what the agent must read, supporting one more client. Each needs
214
- a home in the positive sources — otherwise "moves nothing this document commits
215
- to" fires on exactly the maintenance the product needs.
216
-
217
- ## 4. Minimum operable sections
218
-
219
- A Vision is a gate. These are the load-bearing parts; anything else is
220
- orientation for humans and should be recognized as such.
221
-
222
- | Section | Must contain | Enables |
223
- |---|---|---|
224
- | Authority & scope | what it binds (all layers, tiers, future components), that packaging is irrelevant, precedence among its own sections, the approval line | both |
225
- | Defaults | the default ruling for anything unreached, stated per path | both |
226
- | Admission test | one sentence naming *exactly which* sections are positive sources and *exactly which* are prohibitions | ACCEPT |
227
- | Positive sources | Goals / Actor commitments / Success Signals — each with a baseline and headroom, checkable against a named artifact | ACCEPT |
228
- | Prohibitions | property-based, closed enumerations, named re-descriptions, in/out pairs | REJECT |
229
- | Invariants | the decision question with both branches answered, plus an anti-laundering clause | both |
230
- | Exemptions | each with its anti-abuse clause | prevents laundering |
231
- | Definitions & imported facts | terms defined by effect; **any fact from another document a ruling depends on, restated here** with the reason | standalone use |
232
- | Pointers | what deliberately lives elsewhere, so an absence reads as intentional | prevents false CANNOT DECIDE |
233
-
234
- **Imported facts matter more than they look.** If a ruling needs your triage
235
- levels, your risk tiers or your lifecycle states, restate the boundaries in the
236
- Vision — routing the reader to another file breaks the cold-read premise the
237
- whole gate rests on. Keep the procedure elsewhere; bring the boundaries here.
238
-
239
- **Keep competitive positioning OUT.** A Vision defined by comparison to another
240
- product rots silently: the comparison target moves and no one edits your document.
241
- Put it in a dated snapshot elsewhere and point to it.
242
-
243
- ## 5. What no wording can fix — use a mechanism instead
244
-
245
- Five failure classes are structural. Prose cannot close them; do not try.
246
-
247
- | Failure | Mechanism |
248
- |---|---|
249
- | "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 |
250
- | **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 |
251
- | 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 |
252
- | Structural compliance without truth — every rule satisfied, the artifact still wrong | Independent review; a Vision cannot detect this |
253
- | An accepted change silently falsifying the Vision | Require the amendment in the same change; check cross-document facts mechanically |
254
-
255
- And the sixth, which is why this file exists:
256
-
257
- **Adversarial re-description is unbounded.** Every patch names the evasions seen so
258
- far; a new one always exists. Patch-after-defeat is a treadmill. The only thing
259
- that converts it into a ratchet is a **standing battery**: keep every attack
260
- proposal that ever worked as a fixture and re-run the whole set against every
261
- Vision edit. A Vision without a battery decays the moment someone motivated reads
262
- it.
263
-
264
- ## 6. The blind check (procedure)
265
-
266
- Run this **before promoting any Vision to APPROVED, and before any amendment of an
267
- approved one**. It runs on a Vision that already passed Gate 1 (§The owner
268
- interview): it tests whether the rules hold against a hostile reader, and it
269
- cannot see whether they are the owner's — a Vision the author wrote alone passes
270
- it cleanly. Not for DRAFT edits — promotion is when authority is granted, and
271
- it is rare, so the cost lands where it buys most.
272
-
273
- 1. **Give the reviewer the document text and nothing else.** Not a path — the
274
- text, pasted. Forbid opening files, searching, and web access explicitly. A
275
- term the reviewer cannot resolve is then a property of the document, not of
276
- their tooling.
277
- 2. **Fresh context, and a different model from the author where the client allows
278
- it.** Author self-review is structurally blind to its own omissions.
279
- 3. **Hand them a battery, not an open question.** Concrete proposals to rule on:
280
- - the standing fixtures (every attack that ever worked — see §5);
281
- - **reject-side** proposals aimed at each prohibition;
282
- - **accept-side** proposals the document plainly wants (a bug fix, packaging
283
- work, supporting one more client, a documentation improvement). *A gate that
284
- can only reject is half a gate, and the accept side is where most Visions
285
- fail without anyone noticing.*
286
- 4. **Ask for the mechanism, not just the verdict.** For each ruling: the exact
287
- quoted line, or precisely what the document fails to say. Then: *which rules
288
- could you not get around, and what structural property defeated you?* That
289
- answer is worth more than the findings.
290
- 5. **Ask for rewords.** "Slip a bad proposal past this document, including one
291
- dressed in its own approving vocabulary." A rule nobody can reword is done; a
292
- rule that falls to the first attempt was never a rule.
293
- 6. **Every finding is answered — fixed, or refused with reasoning** (`review.md`
294
- §Receiving). Add every successful reword to the standing battery, whether or
295
- not you fix it this round.
296
-
297
- Three lenses are worth running for a product-level Vision: **comprehension** (what
298
- is this, what could you not resolve), **gate operability** (the battery above),
299
- **durability** (what rots, what is unfalsifiable, what is a time bomb). For a
300
- feature-level Vision or an M-VISION, the gate lens alone is usually enough.
301
-
302
- ## 7. Cost, honestly
303
-
304
- A first draft written against §1–§4 will still have findings — the checklist
305
- removes the structural classes, not judgement errors. Expect one blind round to
306
- find real things and a second to confirm. What it should NOT take is five rounds
307
- of discovering the same class of defect in a new disguise; that is the specific
308
- 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 owner interview below asks for it — and a mechanism
51
+ ("a dashboard") is not an acceptable answer to a benefit question ("never lose
52
+ the thread"); ask again until the answer names what the actor obtains.
53
+
54
+ The deletion test decides **which** rules exist. Everything below decides **how**
55
+ to write a rule so it holds once you know it must exist.
56
+
57
+ ## The owner interview (before any Vision text)
58
+
59
+ A Vision is the **owner's** statement of what is to be obtained. Nothing in this
60
+ file after this section can detect a Vision the author wrote alone: the blind
61
+ check (§6) tests whether the rules survive a hostile reader, never whether they
62
+ are the owner's. So every Vision is born from an interview of the owner, and its
63
+ north star is approved **before** a line of it is drafted.
64
+
65
+ **Scope — every Vision, in every mode:** `project_vision.md`, a feature
66
+ `VISION_*.md`, a lens Vision (course, marketing), and the devPNT M-VISION in
67
+ Hybrid; also an ANALYSIS `## Feature Vision` that states a benefit no existing
68
+ Vision names (one that cites an approved Vision's benefit is alignment, not a
69
+ Vision). An amendment re-runs the questions whose answers it changes, and Gate 1
70
+ again when the north star changes. **There is no skip path**: one sentence from
71
+ the user plus a spike is not a complete spec — that exact shortcut produced a
72
+ Vision with an imported prohibition, no north star and a missing actor, and four
73
+ downstream artifacts built on it (field case, 2026-10). A reply already on record
74
+ in the owner's words is read back for confirmation, never re-asked as an open
75
+ question; an answer the author derived (from a spike, the code, another Vision)
76
+ is never an answer — it is a proposal the owner confirms or rejects.
77
+
78
+ **The questions, in this order.** Each is repeated until its answer has the form
79
+ stated; the wrong form is named so it can be recognized and asked again.
80
+
81
+ | # | Question | Right form | Wrong form — ask again |
82
+ |---|---|---|---|
83
+ | 1 | **Problem** — which concrete case today does not get the expected result? | one real case, with an example | a missing feature ("there is no drawing tool") |
84
+ | 2 | **Benefit** — once solved, who obtains what? | a result for a named actor | a function or mechanism ("a renderer") |
85
+ | 3 | **Actors** — who receives the benefit, who acts, who has the initiative? | all three named, initiative included | only the one who asks — the actor who acts unprompted goes missing |
86
+ | 4 | **Success** — what observable signal shows the benefit arrived? | a signal with its starting value | a feeling, or a signal with no baseline |
87
+ | 5 | **Boundaries** — what does this NOT pursue? | scope excluded from this work | a ban on behaviour ("X must never happen") — that is a constraint (6) or an obligation (2, 4) |
88
+ | 6 | **Known constraints** — each with its provenance: owner, a quoted line of a higher Vision, or author inference | every constraint sourced; every inference asked here | a constraint written in silently, or imported from a higher Vision without asking whether it applies here |
89
+
90
+ A **Non-Goal bounds scope**: it rejects a proposal that pursues what it names; it
91
+ is not a ban on behaviour that already exists, and it creates no obligation.
92
+ Obligations come from the Benefit and the Success Signals.
93
+
94
+ **Gate 1 — north star.** One or two sentences, in the owner's words, explicitly
95
+ approved by the owner. The author may compose a wording from the answers; the
96
+ approval is of that exact text, recorded verbatim in the request record
97
+ (`audit/requests/REQUEST_[unit].md`; a Vision written outside any unit, such as
98
+ the project Vision after bootstrap, records its interview in
99
+ `audit/requests/REQUEST_project_vision.md`). **Without it no Vision text is written** —
100
+ not a DRAFT, not a reconstruction: bootstrap writes a stub awaiting the
101
+ interview, and what the agent observed goes to `strategic/`.
102
+ Unattended, the unit is `BLOCKED on the user` (`elicitation.md` Unattended path).
103
+
104
+ **Gate 2 — the full Vision**, written from the answers. Every section traces to
105
+ an answer or a stated provenance (`REQUEST_[unit].md#R<n>`); every rule carries
106
+ its provenance; an author inference the owner did not confirm is not in it. The
107
+ blind check (§6) verifies that it holds; the approved north star verifies that it
108
+ is the owner's. Promotion to APPROVED still needs the owner's explicit
109
+ confirmation — Gate 2 is that confirmation, given on the written text.
110
+
111
+ ## 0. The one-line test
112
+
113
+ > Could a reader who has never seen this project rule ACCEPT or REJECT on a
114
+ > proposed change, quoting one line of this document, without asking anyone
115
+ > anything?
116
+
117
+ If a section cannot contribute to that, it is background — keep it if it helps a
118
+ human, but know it carries no gate weight.
119
+
120
+ ## 1. The nine properties of a rule that holds
121
+
122
+ Each is stated as a drafting action, with the attack it defeats.
123
+
124
+ 1. **Key the rule to a property observable in the artifact — never to intent,
125
+ commitment, plan or purpose.** Test while drafting: *could I verify compliance
126
+ by reading the diff, without asking the author what they meant?*
127
+ → Defeats: the proposer simply promises the opposite. A rule that forbids
128
+ "committing to track someone's format" is satisfied by saying "we commit to
129
+ nothing"; a rule that forbids "code in this repo that parses a format we do
130
+ not define" is not.
131
+ 2. **Write it as one yes/no question with BOTH branches answered.**
132
+ → Defeats: a gate that can only reject. A prohibition-only Vision rejects the
133
+ work it wants (new client support, packaging, bug fixes) and is abandoned.
134
+ 3. **Phrase the question counterfactually about capability, not about the status
135
+ quo** — "could the user obtain this…", not "does the product currently do it".
136
+ → Defeats: "we never shipped it, so nothing is being taken away."
137
+ 4. **Enumerate the near-miss verbs, not just the headline one** — charge / count /
138
+ cap / condition / gate / degrade / delay / require-signup.
139
+ → Defeats: the soft form. A generous cap, a free-but-registered tier, a
140
+ zero-cost counter — all are the same harm and none is the headline verb.
141
+ 5. **Define every term the rule turns on by EFFECT, and close the list.** A
142
+ definition that enumerates mechanisms is a list of the ways you already thought
143
+ of; end it with "…and anything else the user must give, accept or obtain from
144
+ us."
145
+ → Defeats: the third mechanism. "Charge = payment or account" is walked past by
146
+ "requires opting into telemetry".
147
+ 6. **Enumerate the FORMS a violation can take, then state a closure rule** —
148
+ "anything not named here is out unless it is X".
149
+ → Defeats: the unnamed variant. "A step, a required field, a check, or a cost
150
+ that varies but is never zero" kills "auto-filled, zero human input", because
151
+ the form is still a required field.
152
+ 7. **State the subject predicate of any enumerated test in checkable terms.** If
153
+ the test applies to "a record of work", say what makes something one.
154
+ → Defeats: denying the subject. The proposer agrees with every item on your
155
+ list and asserts the list does not apply.
156
+ 8. **Give one IN and one OUT example on the same axis, differing in a single
157
+ variable.** The pair carries the discriminator; without it the reader invents
158
+ one.
159
+ → Defeats: the borderline case, which is where every real argument happens.
160
+ 9. **Name the re-descriptions you expect, inside the rule's own sentence** —
161
+ "in any presentation", "however the code got here", "not by a component that
162
+ does not exist yet", "storing it as Markdown changes nothing".
163
+ → Defeats: relabeling. A board called a "view" is still a board.
164
+
165
+ ## 2. The five clauses a Vision needs around its rules
166
+
167
+ Rules do not hold alone. These structural clauses were the difference between a
168
+ rule that survived and the same rule leaking.
169
+
170
+ - **Supremacy clause** — on any rule a second layer, product, tier or future
171
+ component could route around: *"these bind the product as a whole; shipping a
172
+ forbidden thing in the paid layer does not put it out of reach."*
173
+ - **Exceptions attached to the rule they limit, in the same bullet, phrased
174
+ affirmatively.** An exception in another section is a leak; an exception phrased
175
+ only as a negation produces CANNOT DECIDE. *"This rule does not reach X;
176
+ supporting one more X is squarely wanted."*
177
+ - **Anti-abuse clause on every exemption, naming the only permitted outcomes.**
178
+ A maintenance exemption without one lets any forbidden thing that already
179
+ shipped be maintained forever, and any new one be framed as a fix to it:
180
+ *"work framed as a fix to something that should never have shipped is not
181
+ exempt — it is the removal of that thing, or it is out."*
182
+ - **Stated defaults, per path including the exempt path** — "anything unreached is
183
+ out"; "an exempt fix that preserves a forbidden thing is out". A test that says
184
+ "admitted only if" gives new capability a default; exempt work has none unless
185
+ you write one.
186
+ - **Precedence, when two sentences can both apply.** Two adjacent statements
187
+ pointing opposite ways are decided by whichever the reader reaches first.
188
+
189
+ ## 3. Only prohibitions can reject; only positives can admit
190
+
191
+ This is the most common structural failure and it is invisible from the inside.
192
+
193
+ - **A Goal cannot reject anything.** If the admission test says "advances a Goal
194
+ and violates no Non-Goal", then rejection power lives *only* in the Non-Goals
195
+ (and the Invariants, where the Vision has them).
196
+ - **A Non-Goal rejects scope, not behaviour.** It turns away a proposal that
197
+ pursues what it names; it never forbids a behaviour the product already has, and
198
+ it never creates an obligation — obligations come from the Benefit and the
199
+ Success Signals. A behaviour the product must never have is an Invariant, or a
200
+ constraint with its provenance (§The owner interview, question 6). Written as a
201
+ Non-Goal, it reads as a ban the owner never stated.
202
+ A Goal that says "scale cost to risk in both directions" cannot stop cost
203
+ inflation — you need a prohibition for that.
204
+ - **A prohibition scoped to one rung of your own scale protects only that rung.**
205
+ Banning ceremony on trivial edits invites the same ceremony one level up.
206
+ - **A criterion phrased as an already-true state cannot be advanced.** "The check
207
+ is CLEAN at every closure" is a state, so "advances this signal" is meaningless
208
+ and any proposal citing it is undecidable. Give every positive criterion a
209
+ **baseline with headroom**: a current value and date, or an explicit list of
210
+ improvement categories that count.
211
+ - **Give recurring legitimate work an explicit authorization clause**, or it will
212
+ be rejected by your own test: packaging and installation, the product's own
213
+ tests, reducing what the agent must read, supporting one more client. Each needs
214
+ a home in the positive sources — otherwise "moves nothing this document commits
215
+ to" fires on exactly the maintenance the product needs.
216
+
217
+ ## 4. Minimum operable sections
218
+
219
+ A Vision is a gate. These are the load-bearing parts; anything else is
220
+ orientation for humans and should be recognized as such.
221
+
222
+ | Section | Must contain | Enables |
223
+ |---|---|---|
224
+ | Authority & scope | what it binds (all layers, tiers, future components), that packaging is irrelevant, precedence among its own sections, the approval line | both |
225
+ | Defaults | the default ruling for anything unreached, stated per path | both |
226
+ | Admission test | one sentence naming *exactly which* sections are positive sources and *exactly which* are prohibitions | ACCEPT |
227
+ | Positive sources | Goals / Actor commitments / Success Signals — each with a baseline and headroom, checkable against a named artifact | ACCEPT |
228
+ | Prohibitions | property-based, closed enumerations, named re-descriptions, in/out pairs | REJECT |
229
+ | Invariants | the decision question with both branches answered, plus an anti-laundering clause | both |
230
+ | Exemptions | each with its anti-abuse clause | prevents laundering |
231
+ | Definitions & imported facts | terms defined by effect; **any fact from another document a ruling depends on, restated here** with the reason | standalone use |
232
+ | Pointers | what deliberately lives elsewhere, so an absence reads as intentional | prevents false CANNOT DECIDE |
233
+
234
+ **Imported facts matter more than they look.** If a ruling needs your triage
235
+ levels, your risk tiers or your lifecycle states, restate the boundaries in the
236
+ Vision — routing the reader to another file breaks the cold-read premise the
237
+ whole gate rests on. Keep the procedure elsewhere; bring the boundaries here.
238
+
239
+ **Keep competitive positioning OUT.** A Vision defined by comparison to another
240
+ product rots silently: the comparison target moves and no one edits your document.
241
+ Put it in a dated snapshot elsewhere and point to it.
242
+
243
+ ## 5. What no wording can fix — use a mechanism instead
244
+
245
+ Five failure classes are structural. Prose cannot close them; do not try.
246
+
247
+ | Failure | Mechanism |
248
+ |---|---|
249
+ | "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 |
250
+ | **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 |
251
+ | 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 |
252
+ | Structural compliance without truth — every rule satisfied, the artifact still wrong | Independent review; a Vision cannot detect this |
253
+ | An accepted change silently falsifying the Vision | Require the amendment in the same change; check cross-document facts mechanically |
254
+
255
+ And the sixth, which is why this file exists:
256
+
257
+ **Adversarial re-description is unbounded.** Every patch names the evasions seen so
258
+ far; a new one always exists. Patch-after-defeat is a treadmill. The only thing
259
+ that converts it into a ratchet is a **standing battery**: keep every attack
260
+ proposal that ever worked as a fixture and re-run the whole set against every
261
+ Vision edit. A Vision without a battery decays the moment someone motivated reads
262
+ it.
263
+
264
+ ## 6. The blind check (procedure)
265
+
266
+ Run this **before promoting any Vision to APPROVED, and before any amendment of an
267
+ approved one**. It runs on a Vision that already passed Gate 1 (§The owner
268
+ interview): it tests whether the rules hold against a hostile reader, and it
269
+ cannot see whether they are the owner's — a Vision the author wrote alone passes
270
+ it cleanly. Not for DRAFT edits — promotion is when authority is granted, and
271
+ it is rare, so the cost lands where it buys most.
272
+
273
+ 1. **Give the reviewer the document text and nothing else.** Not a path — the
274
+ text, pasted. Forbid opening files, searching, and web access explicitly. A
275
+ term the reviewer cannot resolve is then a property of the document, not of
276
+ their tooling.
277
+ 2. **Fresh context, and a different model from the author where the client allows
278
+ it.** Author self-review is structurally blind to its own omissions.
279
+ 3. **Hand them a battery, not an open question.** Concrete proposals to rule on:
280
+ - the standing fixtures (every attack that ever worked — see §5);
281
+ - **reject-side** proposals aimed at each prohibition;
282
+ - **accept-side** proposals the document plainly wants (a bug fix, packaging
283
+ work, supporting one more client, a documentation improvement). *A gate that
284
+ can only reject is half a gate, and the accept side is where most Visions
285
+ fail without anyone noticing.*
286
+ 4. **Ask for the mechanism, not just the verdict.** For each ruling: the exact
287
+ quoted line, or precisely what the document fails to say. Then: *which rules
288
+ could you not get around, and what structural property defeated you?* That
289
+ answer is worth more than the findings.
290
+ 5. **Ask for rewords.** "Slip a bad proposal past this document, including one
291
+ dressed in its own approving vocabulary." A rule nobody can reword is done; a
292
+ rule that falls to the first attempt was never a rule.
293
+ 6. **Every finding is answered — fixed, or refused with reasoning** (`review.md`
294
+ §Receiving). Add every successful reword to the standing battery, whether or
295
+ not you fix it this round.
296
+
297
+ Three lenses are worth running for a product-level Vision: **comprehension** (what
298
+ is this, what could you not resolve), **gate operability** (the battery above),
299
+ **durability** (what rots, what is unfalsifiable, what is a time bomb). For a
300
+ feature-level Vision or an M-VISION, the gate lens alone is usually enough.
301
+
302
+ ## 7. Cost, honestly
303
+
304
+ A first draft written against §1–§4 will still have findings — the checklist
305
+ removes the structural classes, not judgement errors. Expect one blind round to
306
+ find real things and a second to confirm. What it should NOT take is five rounds
307
+ of discovering the same class of defect in a new disguise; that is the specific
308
+ waste this file exists to prevent.