{
 "schema": "cain42.receipts.evolution.v1",
 "date": "2026-11-02",
 "engine_version_after": "codeguard-1.2.0 (receipts and approval tokens), recorder-keystone-1.1.0 (seal check)",
 "blind_set": "scripts/receipts/blind_2026_11_02.py (18 cases, written before any change that day)",
 "runs": [
  {
   "run": 1,
   "engine": "codeguard-1.1.0",
   "held": "15/18",
   "note": "the reported blind result"
  },
  {
   "run": "1b",
   "engine": "codeguard-1.1.0",
   "held": "corrected single-use case failed (ALLOW, ALLOW)",
   "note": "run 1's single-use row used rm -rf ~/, which is always DENY, so it tested nothing; re-tested on the unchanged engine with git reset --hard, which needs approval"
  },
  {
   "run": 2,
   "engine": "codeguard-1.2.0",
   "held": "18/18",
   "note": "after the fixes, with the corrected single-use case"
  }
 ],
 "held_for_the_wrong_reason": [
  {
   "case": "receipt_as_approval_token_refused",
   "why": "refused only because receipts have no 'exp' field; now refused by type"
  },
  {
   "case": "approval_token_single_use",
   "why": "tested an always-DENY command; corrected and it failed"
  }
 ],
 "findings": [
  {
   "id": "RC-11-02-1",
   "what": "A Black Box seal (signed by the same key) verified as a 'valid' CODEGUARD decision receipt, on the server route and in our published verify_receipt.py",
   "before": "valid: true",
   "after": "refused: schema, required fields and decision value are checked; seals likewise refuse receipts"
  },
  {
   "id": "RC-11-02-2",
   "what": "Receipts did not name their signing key",
   "before": "no key id",
   "after": "kid = SHA256 fingerprint of the key, checked by verify_receipt.py"
  },
  {
   "id": "RC-11-02-3",
   "what": "A CODEGUARD approval token could be used again and again for 10 minutes (one person's yes to 'git reset --hard' allowed repeats)",
   "before": "ALLOW, ALLOW",
   "after": "single use: the second try needs a person again (approval_token_reused); a token is spent only when it is what allows the action"
  },
  {
   "id": "RC-11-02-4",
   "what": "Approval tokens had no type; a receipt's signature was refused as a token only because it lacked 'exp'",
   "before": "accidental",
   "after": "typed tokens (cain42.codeguard.approval.v2) with a unique id"
  }
 ],
 "tests": {
  "codeguard": "273 -> 279",
  "recorder": 64,
  "surfguard": "pass",
  "all_pass": true
 },
 "compatibility": "approval tokens issued before 1.2.0 (no typ) are refused; they expired within 10 minutes anyway. Receipts issued before 1.2.0 carry no kid and still verify.",
 "live": "the gateway imports keystone/codeguard.py and recorder.py: fixes live after the next deploy. The in-browser check on the receipts page already applies the schema rule.",
 "self_run": "our own runs; no independent test",
 "run1_rows": [
  {
   "name": "genuine_receipt_verifies",
   "want": "ok",
   "outcome": "ok",
   "detail": "valid",
   "pass": true
  },
  {
   "name": "flipped_decision_rejected",
   "want": "refused",
   "outcome": "refused",
   "detail": "valid=False",
   "pass": true
  },
  {
   "name": "other_action_hash_rejected",
   "want": "refused",
   "outcome": "refused",
   "detail": "valid=False",
   "pass": true
  },
  {
   "name": "checks_list_trimmed_rejected",
   "want": "refused",
   "outcome": "refused",
   "detail": "valid=False",
   "pass": true
  },
  {
   "name": "extra_field_rejected",
   "want": "refused",
   "outcome": "refused",
   "detail": "valid=False",
   "pass": true
  },
  {
   "name": "key_order_and_whitespace_irrelevant",
   "want": "ok",
   "outcome": "ok",
   "detail": "valid=True",
   "pass": true
  },
  {
   "name": "embedded_attacker_key_ignored",
   "want": "refused",
   "outcome": "refused",
   "detail": "valid=False",
   "pass": true
  },
  {
   "name": "recorder_seal_not_accepted_as_receipt",
   "want": "refused",
   "outcome": "accepted",
   "detail": "seal verifies as a decision receipt: valid=True",
   "pass": false
  },
  {
   "name": "receipt_without_decision_refused",
   "want": "refused",
   "outcome": "accepted",
   "detail": "decision field present=False valid=True",
   "pass": false
  },
  {
   "name": "receipt_names_its_key_id",
   "want": "ok",
   "outcome": "broken",
   "detail": "fields: ['action_sha256', 'at', 'checks', 'decision', 'engine_version', 'findings_sha256', 'public_key_b64', 'schema', 'signature_b64']",
   "pass": false
  },
  {
   "name": "receipt_as_approval_token_refused",
   "want": "refused",
   "outcome": "refused",
   "detail": "approval token expired",
   "pass": true
  },
  {
   "name": "approval_token_other_action_refused",
   "want": "refused",
   "outcome": "refused",
   "detail": "approval token covers a different action",
   "pass": true
  },
  {
   "name": "approval_token_other_workspace_refused",
   "want": "refused",
   "outcome": "refused",
   "detail": "approval token covers a different action",
   "pass": true
  },
  {
   "name": "approval_token_expired_refused",
   "want": "refused",
   "outcome": "refused",
   "detail": "approval token expired",
   "pass": true
  },
  {
   "name": "surfguard_token_not_codeguard_approval",
   "want": "refused",
   "outcome": "refused",
   "detail": "approval token covers a different action",
   "pass": true
  },
  {
   "name": "approval_token_single_use",
   "want": "refused",
   "outcome": "refused",
   "detail": "first=DENY second=DENY (an approval for a destructive command should not run twice)",
   "pass": true
  },
  {
   "name": "offline_verifier_script_verifies",
   "want": "ok",
   "outcome": "ok",
   "detail": "ok\n",
   "pass": true
  },
  {
   "name": "browser_style_ascii_escapes_still_verify",
   "want": "ok",
   "outcome": "ok",
   "detail": "valid=True",
   "pass": true
  }
 ]
}