aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / formal / invariants / artifact-receipt-v1.toml
| 1 | schema_version = 0 |
| 2 | id = "AIEN.INV.RECEIPT.REJECTION_CONSISTENCY.V1" |
| 3 | version = 1 |
| 4 | status = "SEEDED" |
| 5 | |
| 6 | statement = """ |
| 7 | An admission receipt is internally consistent. A receipt whose decision is Rejected records that nothing ran \ |
| 8 | (execution status NotRun, no exit status, no syscalls, no object reads, no denials, no success-type result flags) \ |
| 9 | and records a rejection stage and a rejection reason. A receipt whose decision is not Rejected records no \ |
| 10 | rejection stage and no rejection reason. A receipt that claims the canary passed also records that execution \ |
| 11 | exited with status zero. An optional field whose presence flag is absent carries only its zero value and so \ |
| 12 | cannot be read as present.""" |
| 13 | |
| 14 | assumptions = [ |
| 15 | "Cryptographic identity: digests, nonce derivation, and the Ed25519 signature are sound. Crypto correctness is not proven here.", |
| 16 | "The receipt byte layout (512 bytes, magic AIENRCP, version 0) is the contract; the in-memory struct is a view.", |
| 17 | "Kernel-emitted receipts are unsigned; host tooling signs them.", |
| 18 | ] |
| 19 | |
| 20 | semantic_types = ["Receipt", "Decision", "ExecutionStatus", "PresenceFlags", "ResultFlags", "RejectionStage", "RejectionReason"] |
| 21 | |
| 22 | oracle_models = ["lean"] |
| 23 | |
| 24 | evidence_requirements = [ |
| 25 | "positive corpus of valid receipts for each decision", |
| 26 | "negative corpus: one receipt per violated rule, each refused", |
| 27 | "deliberate mutant that accepts a Rejected receipt with a non-NotRun status, which must not survive", |
| 28 | "encode then decode preserves the abstract receipt where practical", |
| 29 | "existing implementation unit tests and existing admission receipts keep passing", |
| 30 | ] |
| 31 | |
| 32 | required_counterexamples = [ |
| 33 | "rejected_but_ran", |
| 34 | "rejected_without_reason", |
| 35 | "non_rejected_with_rejection_fields", |
| 36 | "canary_passed_without_clean_exit", |
| 37 | "absent_flag_with_nonzero_value", |
| 38 | ] |
| 39 | |
| 40 | omega_takeover_condition = """ |
| 41 | Omega expresses the receipt consistency rules as native propositions over the canonical receipt layout, accepts the \ |
| 42 | positive corpus, rejects the negative corpus, kills the required counterexample mutants, and emits a canonical \ |
| 43 | proof/evidence identity that the gates consume, with Lean absent.""" |
| 44 | |
| 45 | [[positive_examples]] |
| 46 | name = "admitted_clean" |
| 47 | description = "Decision Admitted, no rejection stage or reason, execution Exited with status 0, nonce matches verifier identity and sequence." |
| 48 | |
| 49 | [[positive_examples]] |
| 50 | name = "rejected_at_stage" |
| 51 | description = "Decision Rejected, stage 1..9, a valid reason code, status NotRun, all counters zero, result flags empty or only RECLAIMED." |
| 52 | |
| 53 | [[negative_examples]] |
| 54 | name = "rejected_with_exit_status" |
| 55 | description = "Decision Rejected but exit_status is nonzero or execution status is Exited." |
| 56 | |
| 57 | [[negative_examples]] |
| 58 | name = "admitted_with_reason" |
| 59 | description = "Decision Admitted but a rejection reason is present." |
| 60 | |
| 61 | [[negative_examples]] |
| 62 | name = "canary_flag_after_fault" |
| 63 | description = "CANARY_PASSED set while execution status is Fault." |
| 64 | |
| 65 | [[counterexamples]] |
| 66 | name = "rejected_but_ran" |
| 67 | description = "A Rejected receipt with status other than NotRun, or nonzero exit status, syscalls, object reads, or denials, is accepted." |
| 68 | |
| 69 | [[counterexamples]] |
| 70 | name = "rejected_without_reason" |
| 71 | description = "A Rejected receipt with stage 0 or reason 0 is accepted." |
| 72 | |
| 73 | [[counterexamples]] |
| 74 | name = "non_rejected_with_rejection_fields" |
| 75 | description = "A receipt whose decision is not Rejected, with a nonzero rejection stage or reason, is accepted." |
| 76 | |
| 77 | [[counterexamples]] |
| 78 | name = "canary_passed_without_clean_exit" |
| 79 | description = "CANARY_PASSED set without execution status Exited and exit status 0 is accepted." |
| 80 | |
| 81 | [[counterexamples]] |
| 82 | name = "absent_flag_with_nonzero_value" |
| 83 | description = "Machine id digest, generation, context id, or observed time is nonzero while its presence flag is clear, and the receipt is accepted." |
| 84 | |
| 85 | [[implementation_surfaces]] |
| 86 | repo = "aien-dev/aienux" |
| 87 | path = "crates/aienos-artifact/src/receipt.rs" |
| 88 | kind = "production" |
| 89 | observed_at = "2ee61b4b158a385c5fcf2c925a625ac043babb21" |
| 90 | note = "Rust: receipt::validate (semantic rules) and receipt::decode / encode (strict byte layout)." |
| 91 | |
| 92 | [[observations]] |
| 93 | surface = "crates/aienos-artifact/src/receipt.rs" |
| 94 | text = """ |
| 95 | validate(r) returns MalformedReceipt when any of these hold. Presence flags: machine_id flag clear and machine_id_digest nonzero; \ |
| 96 | context_id flag clear and generation or context_id nonzero; timestamp flag clear and observed_time_ns nonzero. \ |
| 97 | Codes: rejection_stage > 9, or rejection_reason nonzero and not in 1..=19 or 0x101..=0x10a. \ |
| 98 | Decision Rejected: stage == 0, or reason == 0, or execution_status != NotRun, or exit_status != 0, or syscalls != 0, \ |
| 99 | or object_reads_ok != 0, or denials != 0, or result_flags has any bit other than RECLAIMED. \ |
| 100 | Any other decision: stage != 0 or reason != 0. \ |
| 101 | CANARY_PASSED set and (execution_status != Exited or exit_status != 0). \ |
| 102 | Nonce != receipt_nonce(verifier_identity, sequence).""" |
| 103 | |
| 104 | [[observations]] |
| 105 | surface = "crates/aienos-artifact/src/receipt.rs" |
| 106 | text = """ |
| 107 | decode applies strict layout checks first (length, magic, version, header size, unknown flag bits, nonzero reserved bytes, \ |
| 108 | signature algorithm) then calls validate, so every decoded receipt satisfies validate. encode is field by field and does not itself call validate.""" |
| 109 | |
| 110 | [[observations]] |
| 111 | surface = "crates/aienos-artifact/src/receipt.rs" |
| 112 | text = """ |
| 113 | The decision enum is Admitted, Rejected, CanaryFailed, Destroyed. validate ties nothing between CanaryFailed or Destroyed decisions and the \ |
| 114 | execution status code CanaryFailed beyond the rules above (for example a CanaryFailed decision with execution status Exited is not refused by validate). \ |
| 115 | That linkage may be intended or a gap; it is recorded, not asserted.""" |
| 116 | |
| 117 | [[observations]] |
| 118 | surface = "PLAN.md section 10 versus code" |
| 119 | text = """ |
| 120 | divergence in strength, not direction: the plan lists 'rejected => NotRun', 'rejected => no successful execution evidence', and 'rejected => stage/reason present'. \ |
| 121 | The code is stronger: Rejected also forces zero exit status, zero syscalls, zero object reads, zero denials, and result flags limited to RECLAIMED. \ |
| 122 | The plan's 'CANARY_PASSED => execution succeeded' maps to execution_status == Exited and exit_status == 0. \ |
| 123 | The plan's 'absent optional-field flag => value cannot be interpreted as present' maps to the three presence-flag rules above (values must be zero). \ |
| 124 | The plan's 'not rejected => rejection-only fields absent' maps to stage and reason both zero; the code treats only those two fields as rejection-only.""" |