|
| 1 | +# How the conformance vectors are built, and how the set is checked for holes |
| 2 | + |
| 3 | +*Informative. This page describes method, not requirements, and carries no RFC 2119 |
| 4 | +keywords.* |
| 5 | + |
| 6 | +A conformance suite makes a promise: an implementation that passes it has done the |
| 7 | +things the specification asks for. That promise is only as good as the suite's |
| 8 | +coverage, and coverage is usually assumed rather than established. A suite that never |
| 9 | +exercises a rule certifies implementations that skip that rule entirely — silently, |
| 10 | +and with a green badge. |
| 11 | + |
| 12 | +This page describes how the action-receipt vectors in |
| 13 | +`examples/action-receipts/conformance/` |
| 14 | +are built, and how the set itself is checked. The checking part found seven rules in |
| 15 | +the receipt verifier with no vector behind them. |
| 16 | + |
| 17 | +## 1. Vectors are data, not tests |
| 18 | + |
| 19 | +Each vector is a JSON file stating the inputs, the trust anchors, and the outcome any |
| 20 | +conformant verifier must produce: |
| 21 | + |
| 22 | +```jsonc |
| 23 | +{ |
| 24 | + "context": { /* what the verifier is told: session, call, freshness policy */ }, |
| 25 | + "action": { /* the action and its canonical reference */ }, |
| 26 | + "trusted_issuer_keys": { /* the pinned key set — nothing self-authenticates */ }, |
| 27 | + "receipt": { /* the artifact under test, genuinely signed */ }, |
| 28 | + "expected": { "status": "...", "failures": [...], "warnings": [...] } |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +Nothing in a vector names a language, a function, or an API. An implementation writes a |
| 33 | +small adapter that feeds the JSON to its own verifier and compares against `expected`; |
| 34 | +the vectors themselves are portable. |
| 35 | + |
| 36 | +This is worth stating because it is easy to get wrong. One set I wrote began as tests |
| 37 | +against a single library's function signature. Those tests were correct, and they were |
| 38 | +not conformance vectors: no second implementation could run them. The shape matters |
| 39 | +more than the assertions, and the two are easy to confuse while the assertions are |
| 40 | +passing. |
| 41 | + |
| 42 | +**Every artifact in a vector is genuinely signed, including in the negative cases.** |
| 43 | +A vector that expects a rejection must reject for the reason it names. If its signature |
| 44 | +were malformed, the rejection would come from the signature check instead, the vector |
| 45 | +would pass, and it would have stopped testing the rule in its own filename. |
| 46 | + |
| 47 | +## 2. The set is checked against the verifier, automatically |
| 48 | + |
| 49 | +The interesting question is not whether the vectors pass. It is whether they cover |
| 50 | +what the verifier does. Three questions, in increasing strength: |
| 51 | + |
| 52 | +**Are there dead expectations?** A vector naming a failure code that nothing can emit |
| 53 | +holds an assertion that can never fail. Usually it means a rule was renamed or removed |
| 54 | +and the vector was left behind. |
| 55 | + |
| 56 | +**Is every rule exercised?** For each code the verifier can emit, is there a vector that |
| 57 | +expects it? A rule with no vector is a check an implementation can omit while passing. |
| 58 | + |
| 59 | +**Is every rule load-bearing — twice?** The strongest form: *delete the rule and count |
| 60 | +the vectors that notice.* A rule can be named by a vector and still not be load-bearing — |
| 61 | +if another rule fires on the same input, removing it changes no outcome and nothing |
| 62 | +distinguishes an implementation that performs the check from one that skips it. And one |
| 63 | +load-bearing vector is existence, not margin: any change that weakens or retires that |
| 64 | +single vector silently removes the rule's coverage. So the floor is two |
| 65 | +([#124](https://github.com/agentrust-io/trace-spec/issues/124)), and a ratchet keeps |
| 66 | +anything above the floor from quietly decaying back toward it. |
| 67 | + |
| 68 | +**Are the two vectors different tests, or two copies?** Two identical vectors have |
| 69 | +margin two and prove nothing extra. #124's definition: vectors are independent if a |
| 70 | +single implementation defect causes one to pass and the other to fail. That is made |
| 71 | +executable by declaring, for every rule, at least one *weakened* variant of its check — |
| 72 | +a plausible implementation shortcut: comparing digest prefixes, case-normalising |
| 73 | +identifiers, granting clock tolerance, validating signature structure without |
| 74 | +cryptography. The suite fails unless some declared defect deviates one of the rule's |
| 75 | +vectors while leaving another undisturbed. The declaration is itself fail-closed: a |
| 76 | +rule with no declared defect fails, so "what bug would your second vector catch that |
| 77 | +your first would not?" is answered when the rule is added. |
| 78 | + |
| 79 | +The strong criteria subsume the first two questions, which are kept because they are |
| 80 | +cheap and their failure messages are more direct. |
| 81 | + |
| 82 | +### The inventory is the registry the verifier consumes |
| 83 | + |
| 84 | +The obvious implementation is a list of rules kept next to the tests. That list is |
| 85 | +guaranteed to drift: it is correct only until someone adds a rule and forgets it, and |
| 86 | +the failure is silent in exactly the direction that matters. |
| 87 | + |
| 88 | +The first replacement recovered the inventory from the verifier's source with `ast` — |
| 89 | +every string literal appended to a failure or warning list. The |
| 90 | +[#124 review](https://github.com/agentrust-io/trace-spec/issues/124) identified that |
| 91 | +this has the mirror failure mode: a rule written as `extend([...])`, `+=`, an f-string |
| 92 | +or a named constant is invisible to the walk, and the suite reports complete coverage |
| 93 | +over an inventory that is quietly missing entries. |
| 94 | + |
| 95 | +The resolution, from the same review: the verifier itself consumes an explicit registry |
| 96 | +of named rules, and the registry *is* the inventory. A check that is not registered |
| 97 | +never runs, so it cannot exist outside the inventory; a residual guard fails on any |
| 98 | +code that would emit around the registry. Mutation follows the same principle — a rule |
| 99 | +is deleted by rebuilding the registry without its entry, or weakened by substituting |
| 100 | +its check, never by pattern-matching source text. If no vector's outcome changes under |
| 101 | +a deletion, that rule has no vector standing behind it. |
| 102 | + |
| 103 | +## 3. Fixtures and their checker cannot vouch for each other |
| 104 | + |
| 105 | +A green run proves the vectors and the verifier agree. Both are usually written by the |
| 106 | +same person in the same sitting, so agreement is close to guaranteed and says little. |
| 107 | +The failure it cannot see: a shared helper that canonicalizes or decodes incorrectly, |
| 108 | +used both to generate the fixtures and to check them. Everything agrees, and agrees with |
| 109 | +nothing else in the world. |
| 110 | + |
| 111 | +So every signature is re-derived through a path that shares no code with either: it |
| 112 | +imports nothing from the library, reuses no helper from the vector modules, and |
| 113 | +reconstructs each signing input from the JSON directly. Any vector whose signature is |
| 114 | +not re-derived by that path is a failure unless it is explicitly declared |
| 115 | +signature-free with a reason — the "missing receipt" case is the only one, since the |
| 116 | +absence of a receipt is the thing it tests. |
| 117 | + |
| 118 | +## 4. What this found |
| 119 | + |
| 120 | +Seven rules in the receipt verifier had no vector at all: |
| 121 | + |
| 122 | +| Rule | What an implementation could have skipped | |
| 123 | +|---|---| |
| 124 | +| `action_ref_invalid` | Recomputing the action reference instead of trusting the declared value | |
| 125 | +| `call_id_mismatch` | Checking that the receipt is bound to *this* call | |
| 126 | +| `session_id_mismatch` | Checking that it is bound to *this* session | |
| 127 | +| `evidence_hash_mismatch` | Recomputing the evidence digest, so a swapped evidence body passes | |
| 128 | +| `issuer_key_unknown` | Consulting the pinned key set at all | |
| 129 | +| `receipt_from_future` | Rejecting a receipt issued after the verification time | |
| 130 | +| `decision_invalid` | Refusing to read an unrecognised decision verb as accept or reject | |
| 131 | + |
| 132 | +Each is a check a conforming implementation could have omitted entirely while passing |
| 133 | +the published suite. Two are load-bearing for the trust model rather than merely tidy: |
| 134 | +without `issuer_key_unknown` a receipt authenticates itself — a signature verifies |
| 135 | +against whatever key it names, and only the pinned set says which keys the verifier can |
| 136 | +check, so a receipt under an unpinned key is surfaced as unverified rather than valid or |
| 137 | +invalid — and without `evidence_hash_mismatch` the signature covers a digest whose |
| 138 | +document may have been replaced. |
| 139 | + |
| 140 | +## 5. The checker's own false positives |
| 141 | + |
| 142 | +Three of its first findings were bugs in the checker, not in the suite. They are |
| 143 | +recorded because a completeness checker that reports the wrong thing is worse than |
| 144 | +none: it converts attention into noise, and the next person stops reading it. |
| 145 | + |
| 146 | +| Symptom | Cause | |
| 147 | +|---|---| |
| 148 | +| Every rule reported as non-load-bearing | Mutants were executed into a bare namespace, so `@dataclass` raised before a single vector ran. It read as "every rule matters" while testing nothing. | |
| 149 | +| A real outcome reported as unreachable | The scanner walked an entire conditional expression and collected the literal being *compared against* as if it were an outcome. | |
| 150 | +| A real warning reported as emitted by no rule | It scanned inline `failures=[...]` arguments but not `warnings=[...]`. | |
| 151 | + |
| 152 | +The pattern in all three: the check failed *open* — it reported a problem where there |
| 153 | +was none, which is survivable, rather than passing where there was one, which is not. |
| 154 | +That direction was not designed in, and a checker of this kind should be built so that |
| 155 | +its own breakage is loud. Hence the guard that asserts the inventory was non-empty |
| 156 | +before any conclusion is drawn from it. |
| 157 | + |
| 158 | +## 6. What this does not establish |
| 159 | + |
| 160 | +- **Not that the rules are right.** Completeness is a property of the vectors relative |
| 161 | + to the verifier. If the verifier implements the wrong rule, a complete set pins the |
| 162 | + wrong rule down precisely. |
| 163 | +- **Not that the specification is complete.** A rule absent from both the verifier and |
| 164 | + the vectors is invisible to this method. Only reading the specification finds it. |
| 165 | +- **Not that an implementation is correct.** Passing shows it agrees on these inputs. |
| 166 | + Behaviour on inputs no vector describes is unconstrained. |
| 167 | +- **Not that the vectors are adversarial enough.** Two independent vectors per rule is |
| 168 | + a floor, not a proof of adversarial coverage: independence is demonstrated against |
| 169 | + the *declared* defects, and a shortcut nobody thought to declare is a shortcut the |
| 170 | + pair may still share. The declaration requirement makes the blind spot enumerable, |
| 171 | + not empty. |
| 172 | + |
| 173 | +The method answers one question — *could an implementation skip this check and still |
| 174 | +pass?* — and answers it mechanically. That is narrower than "is the suite good", and it |
| 175 | +is the part that was previously left to assumption. |
| 176 | + |
| 177 | +## Reproducing |
| 178 | + |
| 179 | +```bash |
| 180 | +pip install -e ".[dev]" |
| 181 | +pytest tests/test_vector_completeness.py -v # the completeness checks |
| 182 | +pytest tests/test_fixture_signatures_independent.py # the independent signature path |
| 183 | +``` |
| 184 | + |
| 185 | +Signing keys are derived from published seeds, so every vector set regenerates |
| 186 | +byte-for-byte and only public JWKs appear in the files. They are deliberately |
| 187 | +deterministic test keys with no standing. |
0 commit comments