interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / formal / invariants / sequence-stale-id-v1.toml

116 lines · 6125 bytes Raw Blame History
1schema_version = 0
2id = "AIEN.INV.SEQUENCE.STALE_ID.V1"
3version = 1
4status = "SEEDED"
5
6statement = """
7A sequence id is a pair (slot, generation). An id resolves to a live record only when its slot exists, the slot's current \
8generation equals the id's generation, and the slot holds a record. Freeing a live id removes the record and changes the \
9slot's generation, so the freed id and every copy of it stop resolving; freeing a stale, unknown or already freed id changes \
10nothing and reports failure. Generation 0 is never issued. Allocation is refused exactly when every slot is occupied, so the \
11active count never exceeds the capacity, rises by one on a successful allocation or fork and falls by one on a successful free. \
12Fork from an id that does not resolve is refused. Re-allocating a just freed slot never returns the freed id. The generation field \
13is finite (u32): after exactly 2^32 - 1 frees of one slot the generation repeats, so a stale id from before the cycle would resolve \
14again. This limitation is part of the invariant and is NOT eternal ABA freedom."""
15
16assumptions = [
17 "Single scheduler thread owns the arena (no concurrency model; the Rust arena has no locks).",
18 "Generation arithmetic is the u32 rule next = max((g + 1) mod 2^32, 1); the model carries it exactly.",
19 "Record contents are not modelled, only whether a record is present.",
20 "Callers do not keep an id across 2^32 - 1 frees of its slot; the code does not enforce this, and the runtime arena has no retire path (the scheduler arena retires the slot at u32::MAX instead).",
21]
22
23semantic_types = ["SequenceId", "SequenceArena", "SlotGeneration", "ActiveCount", "Capacity"]
24
25oracle_models = ["lean"]
26
27evidence_requirements = [
28 "positive corpus: first allocation, free then reuse with a new generation, live fork",
29 "negative corpus: never allocated, stale after free, stale free refused, wrong generation, generation zero, slot out of range, stale fork, capacity exhausted",
30 "deliberate mutants that must not survive: free keeps generation, resolution ignores generation, wrap yields generation 0, free keeps active count, fork skips the parent check",
31 "the generation wrap limitation stated as a theorem (iterGen genMax g = g) next to the no-reuse-before-wrap theorem",
32 "existing implementation unit tests and the PREFILL-E2E runtime tests keep passing",
33]
34
35required_counterexamples = [
36 "free_keeps_generation",
37 "resolution_ignores_generation",
38 "wrap_to_generation_zero",
39 "free_keeps_active_count",
40 "fork_from_stale_parent",
41]
42
43omega_takeover_condition = """
44Omega expresses the arena rules as native propositions over (slot, generation) records, accepts the positive corpus, rejects the \
45negative corpus, kills the required counterexample mutants, states the finite-generation limitation as an explicit assumption, and \
46emits a canonical proof/evidence identity that the gates consume, with Lean absent."""
47
48[[positive_examples]]
49name = "free_then_reuse"
50description = "Allocate (0,1), free it, allocate again: the slot comes back as (0,2). The old id (0,1) does not resolve."
51
52[[positive_examples]]
53name = "live_fork"
54description = "Fork from a live parent id succeeds and returns a new live id."
55
56[[negative_examples]]
57name = "stale_id_after_free"
58description = "An id used after its record was freed does not resolve, and freeing it again is refused."
59
60[[negative_examples]]
61name = "wrong_generation"
62description = "Right slot, generation that is not the slot's current one: does not resolve."
63
64[[negative_examples]]
65name = "capacity_exhausted"
66description = "Allocation when every slot is occupied is refused."
67
68[[counterexamples]]
69name = "free_keeps_generation"
70description = "Free leaves the generation unchanged, so a reallocated slot reissues the freed id."
71
72[[counterexamples]]
73name = "resolution_ignores_generation"
74description = "get resolves any id whose slot holds a record, whatever generation it carries."
75
76[[counterexamples]]
77name = "wrap_to_generation_zero"
78description = "The generation wrap produces 0, which the scheduler arena treats as invalid."
79
80[[counterexamples]]
81name = "free_keeps_active_count"
82description = "Free forgets to lower the active count, so capacity accounting drifts."
83
84[[counterexamples]]
85name = "fork_from_stale_parent"
86description = "Fork allocates a child even though the parent id does not resolve."
87
88[[implementation_surfaces]]
89repo = "aien-dev/sovereign-core"
90path = "crates/aien-runtime/src/sequence.rs"
91kind = "production"
92observed_at = "dd1fe323d5fc774ff0fe6faaadebfea6450563c0"
93note = "SequenceArena: new (line 76 onward), allocate (98), fork (131), get (178), free (197, wrapping_add(1).max(1) at 202), active_count."
94
95[[implementation_surfaces]]
96repo = "aien-dev/sovereign-core"
97path = "crates/aien-scheduler/src/sequence.rs"
98kind = "production"
99observed_at = "dd1fe323d5fc774ff0fe6faaadebfea6450563c0"
100note = "Second SequenceArena: free_sequence (512) retires the slot at u32::MAX (523) instead of wrapping. Modelled only as the pure rule retireNext."
101
102[[observations]]
103surface = "crates/aien-runtime/src/sequence.rs"
104text = """
105free (197 to 209) bumps the generation with wrapping_add(1).max(1), so the runtime arena has no retire path: a slot freed 2^32 - 1 times \
106reissues an old id. get (178) resolves on slot-in-range, equal generation and a present record. allocate and fork pop a free slot and \
107hand out its current generation. active_count is incremented on both and decremented with saturating_sub on free; the model proves the \
108subtraction never saturates for a well formed arena."""
109
110[[observations]]
111surface = "crates/aien-scheduler/src/sequence.rs"
112text = """
113divergence between the two arenas: the scheduler arena retires a slot when its generation reaches u32::MAX (free_sequence, 512 to 523) \
114and never reuses it, so it has no ABA window at the cost of capacity; the runtime arena wraps. Both are in production code in the same \
115workspace. Recorded, not asserted either way. insert_with_id in the scheduler arena also accepts a caller supplied generation and sets the \
116slot generation to it, which the model does not cover."""