agent-bios 0.9.9 → 0.10.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.
@@ -0,0 +1,166 @@
1
+ ---
2
+ guide_id: verification-discipline
3
+ language: en
4
+ status: active
5
+ use_when:
6
+ - deciding how much verification a change deserves, before spending on a slow or expensive run
7
+ - choosing what to run for a domain — code, ontology, config/data, spreadsheets, docs, a release
8
+ - building the case space for a check, or deciding what its expected answer should be
9
+ - a check came back green, empty, or fast, and you are about to believe it
10
+ - running independent or adversarial review, and judging what its agreement is worth
11
+ core_rules:
12
+ - a check is only evidence if it could have failed — assert a non-empty subject before any "no bad X" claim
13
+ - enumerate the case space from the artifact that defines it, and record real output instead of typing an expectation
14
+ - proportion depth to cost, risk, and information gain; a single-user tool does not warrant production assurance
15
+ - same-kind reviewers share blind spots, so their shared "clean" is an absence of objection, not verification
16
+ ---
17
+
18
+ # Verification Discipline
19
+
20
+ A scoped extension of the global Verification Discipline section. Its subject is not "did you
21
+ test it" but the harder question underneath: **could this check have failed?** Everything below
22
+ is a way of answering that before the result is believed rather than after it is quoted.
23
+
24
+ The global rules that stay always-loaded are the ones whose moment does not announce itself — you
25
+ believe you are finished, and that belief is the failure. This guide is what you open once you
26
+ know you are verifying.
27
+
28
+ ## Proportion the depth before you spend
29
+
30
+ Verification has a cost and an information yield, and they are not correlated by default. Decide
31
+ the depth first:
32
+
33
+ - Diagnose in code before running anything expensive, and replay the changed deterministic logic
34
+ over persisted real artifacts rather than re-running the whole pipeline to observe it.
35
+ - Probe at N=1 with the inputs precondition-checked. A single well-chosen case that reaches the
36
+ real path outranks a hundred that stop short of it.
37
+ - Reserve the full design-review-plus-live-verification treatment for first-of-kind work and for
38
+ changes that move authority — who may decide, who may write, what is irreversible.
39
+ - Proportion assurance to the deployment context. A single-user tool operating on its owner's own
40
+ data does not warrant production-grade assurance, and treating it as if it did buys nothing
41
+ while delaying delivery. Prefer shipping.
42
+
43
+ The failure this prevents is not under-testing. It is spending the verification budget on the
44
+ cheap half of the risk and having nothing left for the part that could actually hurt.
45
+
46
+ ## The static floor
47
+
48
+ Run the broad, cheap checks first and let them fail before anything slower starts: typecheck,
49
+ lint, build, format, schema and config validation, graph validation, workbook structure checks,
50
+ import boundaries, and security checks where they exist. These are a floor, not a verdict — they
51
+ prove the artifact is well-formed, never that it behaves.
52
+
53
+ ## Verification Menus
54
+
55
+ Pick the narrowest reliable mix that proves the changed behavior, meaning, or contract. Inside the
56
+ mix, the unit to add is the narrowest reliable runtime or semantic test that proves it — narrowest
57
+ meaning the smallest test that would fail if the change were wrong, which is not the same as the
58
+ cheapest one to write.
59
+
60
+ - Code: a layered mix of unit tests, integration tests for E2E segments, targeted E2E for changed flows, and full E2E for release or high-risk changes.
61
+ - Ontology: static graph checks, concept economy gates, changed-path integration checks, and competency-question E2E checks.
62
+ - Config or data: real parsers, schema checks, fixture validation, and sample transformations.
63
+ - Spreadsheets: static workbook checks, fixture-based output checks, cross-sheet flow checks, visual/layout checks, and real Microsoft Excel engine recalculation for formula-dependent results.
64
+ - Docs: links, terminology, current behavior alignment, and references to isolated historical notes.
65
+ - Release or distribution: after publishing to multiple independently writable channels (signed manifest, object storage, release host, embedded updater), digest-verify every referenced object against the staging original per channel — publish success and upload order are not evidence — and run the real installer/updater through its default path.
66
+ - A/B or on/off measurements: before accepting a null result, verify the arms actually received different treatment in the mechanism under test — a shared default or unconditional upstream step can silently apply the treatment to both arms.
67
+ - Model-behavior guardrails: verify by changed behavior, not recitation — a staged battery from named-trigger cases through disguised, deconfounded, category-wide, and single-variable framings; a clean pass means "no known defect", so re-run the battery when the model changes.
68
+ - Branch/version test builds against real data: explicitly separate every state sink the app touches (files, DB, OS-level stores that ignore env overrides), confirm the launch path propagates the isolation to child processes, and back up live data before the first run — a mismatched schema that drops unknown fields on write is data loss, not a no-op.
69
+ - Irreversible capture switches: when activation itself has unreproducible cost (a capture window that cannot be replayed), prove the downstream consumption path against existing samples before enabling — reversibility of the code path alone is not enough.
70
+
71
+ ## Deriving the case space
72
+
73
+ Which scenarios exist is semantic work: derive them from the diff, the user impact, the
74
+ concept impact, and the failure modes. Running them is not — tools and code execute the
75
+ cases and report the evidence. Keeping that split is what stops a suite from being a
76
+ record of what someone imagined.
77
+
78
+ A check has two authored halves, and they rot differently. The **verdict** — what the
79
+ answer should be — rots by encoding a belief that was wrong from the start. The
80
+ **space** — which cases exist — rots by staying still while the thing it covers grows.
81
+ Recording the verdict is common practice; deriving the space is the half usually left
82
+ hand-written, and a suite can have every expectation derived and still cover a set
83
+ someone typed once.
84
+
85
+ - Make the criterion falsifiable before you make it green. Prefer a signal that fails when
86
+ the mechanism is wrong — a negative or contrast control. Where no existing gate can judge
87
+ a criterion, build the executable judge or do not claim the criterion met: a criterion
88
+ nothing can fail is a description of the work, not a check on it.
89
+ - Record the verdict, do not type it. Run the real path and store what came back;
90
+ drift then shows as a diff instead of as a belief someone has to re-justify.
91
+ - Enumerate the space from the artifact that defines it — the config's entries, the
92
+ schema's fields, the router's routes, the installer's call sites. Adding one there
93
+ should widen coverage with no edit here.
94
+ - Derive the exemption rule too. If some cases legitimately have no answer, decide that
95
+ from a property the artifact carries, never from a list of names: the list is the
96
+ authored space coming back through a side door, and it absorbs the regression where
97
+ a case that should have an answer stops having one.
98
+ - Dedupe on the tuple that actually determines the outcome, and report how many
99
+ collapsed. A coverage count that hides its own truncation reads as more than it is.
100
+ - Split by cost, not by space. When the real path needs money, credentials, or a
101
+ network, run a cheap stand-in on every commit and the real one on demand — both from
102
+ the **same enumeration**, so the two can never disagree about which cases exist.
103
+ - Derivation moves authorship rather than removing it: the extractor and the invariants
104
+ are still written by hand. Give them a negative control, or the derived suite is just
105
+ a larger unfalsifiable one.
106
+ - Planting a violation to prove a control fires is a write into the working tree, and
107
+ the restore is not atomic with it: if the probe can time out, abort, or be
108
+ interrupted, a restore sitting after it never runs and the plant survives into a
109
+ commit. Plant in a copy where the shape allows it, and when it must be in place, snapshot
110
+ first and restore from the snapshot as its own step rather than trusting the probe to finish.
111
+
112
+ ## When a green means nothing
113
+
114
+ A passing check and a check that never ran look identical from outside. These are the shapes that
115
+ produce a green with no evidence behind it:
116
+
117
+ - **The empty subject.** Any "no bad X" or "all X satisfy P" claim over an empty set is
118
+ vacuously true. Assert the entity-under-test set has cardinality greater than zero **before**
119
+ the claim, and make the gate itself refuse to report clean when it judged nothing.
120
+ - **The fixture that misses the guard.** For a test touching a branch you are adding or deleting,
121
+ confirm its inputs satisfy the live branch's entry guard. A copied fixture that fails the new
122
+ guard routes silently into the about-to-be-deleted dead branch and stays green after the real
123
+ behavior breaks.
124
+ - **The permissive fallback in the checker.** A `a || b` inside a gate absorbs a wrong assumption
125
+ and keeps passing. Checker code must assert the shape it expects and fail loud.
126
+ - **The suspiciously fast or empty run.** When a check goes green unexpectedly quickly, or reports
127
+ nothing at all, dump what it actually ran over before believing it. A harness that crashed early
128
+ and one that found nothing produce the same exit code.
129
+ - **The control that went quiet.** A negative control indexing a live list stops testing when that
130
+ list empties, and says nothing about it. New controls build their own subject; resolving an item
131
+ means re-reading the controls for ones that have gone silent.
132
+
133
+ The discipline that covers all five: after adding a check, revert the fix it guards and watch the
134
+ check fail. A control that survives a faithful revert was never testing the thing it names.
135
+
136
+ ## Keeping E2E honest
137
+
138
+ E2E is where flakiness is mistaken for environment noise and then ignored. Keep it deterministic
139
+ with fixed data, resilient selectors, isolated external dependencies, and explicit waits rather
140
+ than sleeps. A flaky E2E is not a weaker test; it is a test whose result carries no information,
141
+ and a suite that people re-run until it passes has been switched off without anyone deciding to.
142
+
143
+ ## Independent review, and what agreement is worth
144
+
145
+ For non-trivial designs and high-risk changes, run independent adversarial review across distinct
146
+ lenses — ideally on the design, before implementation, when a finding is still cheap to act on.
147
+ Then re-verify each finding against real code before acting on it: a reviewer reasons from what it
148
+ was shown, and what it was shown may be wrong.
149
+
150
+ Apply the **convergence heuristic by reviewer kind** — judge the result by reviewer kind, not by count:
151
+
152
+ - Same-kind convergence is high confidence but blind-spot-sharing. Two reviewers of the same kind
153
+ agreeing that something is clean is an absence of objection, not verification.
154
+ - Different-kind divergence is the expected signal, not a problem to resolve. Act on the union of
155
+ what they found rather than the intersection.
156
+ - An orchestrated workflow's self-reported all-green is never sufficient on its own. Re-run the
157
+ diff inspection and the verification suite yourself.
158
+
159
+ The cheapest way to buy real independence is a different provider; after that a different model;
160
+ after that strictly higher effort. A reviewer run at lower effort than the work it checks buys
161
+ nothing — cheaper is not another perspective.
162
+
163
+ ## Reporting
164
+
165
+ Before calling the work done, state the checks that ran, their results, and any risk left
166
+ unverified. "Unverified" is a legitimate outcome and a useful one; silence about it is not.
@@ -226,6 +226,14 @@ def copy_filtered(src_dir, names, dest, rewrite=None, dry=False, backup=None):
226
226
  target.write_text(body, encoding="utf-8")
227
227
 
228
228
 
229
+ def hook_command_matches(command, name):
230
+ """A complete `/hooks/<name>` token: the command ends with it, or it is followed by an
231
+ argument. One matcher for the merge below AND the domain gate's settings leg — the gate
232
+ used a substring test, so `central/hooks/<name>.disabled` passed the gate while this
233
+ merge skipped it, and the install carried no hook under a green gate."""
234
+ return command.endswith("/hooks/" + name) or f"/hooks/{name} " in command + " "
235
+
236
+
229
237
  def merge_settings(claude_dir, hook_names, template_path, dry=False, owned_names=None):
230
238
  """Merge our hook registrations into the user's settings, owning by NAME.
231
239
 
@@ -254,7 +262,8 @@ def merge_settings(claude_dir, hook_names, template_path, dry=False, owned_names
254
262
  for event, entries in template.get("hooks", {}).items(): # re-add per selection
255
263
  for en in entries:
256
264
  cmds = [h.get("command", "") for h in en.get("hooks", [])]
257
- owner = next((n for n in hook_names if any(c.endswith("/hooks/" + n) or f"/hooks/{n} " in c + " " for c in cmds)), None)
265
+ owner = next((n for n in hook_names
266
+ if any(hook_command_matches(c, n) for c in cmds)), None)
258
267
  if owner is None:
259
268
  continue
260
269
  clone = json.loads(json.dumps(en))