Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/omega-mv/blob/main/spec/r16-operator-emergency-stop.md
# omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
Sign in to star 1 stars 0 watching
About Files History Releases Proposed changes Issues For developers
branch `main` Branches Tags History
`omega-mv / spec / r16-operator-emergency-stop.md`
189 lines · 12332 bytes Raw Blame History Rendered
1 # R16 G6: operator emergency stop (contract)
2
3 Status: runtime control IMPLEMENTED and host-tested; WIRED into the production R13
4 program with an outside operator entry point (`docs/r16-operator-control.md`,
5 CAND-3 lane ESTOP). G6 item `operator_emergency_controls_passing` is operated
6 only by execution: the host integration test `make test-r16-operator-host` and its
7 mutants `make test-r16-operator-mutants`, plus the silicon run
8 `make test-r16-operator-silicon`. It is not PASS until a silicon receipt from the
9 candidate exists. See "Not done" at the end.
10
11 Source: `src/runtime/rx_world.c` (`rx_world_emergency_stop`,
12 `rx_world_emergency_resume`, `rx_world_set_halt_dir`, `rx_world_halt_status`),
13 `src/runtime/rx_generation.c` (`rx_gen_promote` mark check),
14 `src/runtime/rx_world.h` (contract comment). Tests: `make test-rx-emergency`
15 (`tests/runtime/rx_emergency.c` plus `tests/runtime/rx_emergency_mutants.sh`) and
16 `make test-r12` (`t_emergency_stop` in `tests/runtime/rx_r12_resident.c`).
17
18 ## 1. What it is
19
20 One deterministic operator control over a running reaction world: **stop**
21 (nothing new commits, nothing from outside publishes, no generation is proposed
22 or promoted) and **resume** (the world continues from exactly the state it held,
23 and the work the stop refused runs again). ADR 0016 §57: "Do not remove
24 deterministic operator control." This is that control for the R16 world. It is
25 not a kill switch for the process and not a rollback: the world's state is kept,
26 not changed.
27
28 ## 2. Authority
29
30 A stop or resume is accepted only when all three hold, checked under the world
31 lock in this order:
32
33 1. **Caller credential.** `subject` is enrolled (`rx_world_enroll_caller`) and
34 `cred` passes the constant-time caller check (absent, unknown, revoked, stale
35 and forged credentials are refused: `RX_ERR_IDENTITY`). This holds whether or
36 not the world has bound its callers.
37 2. **Not a reaction.** `subject` is not the subject of any reaction ever added to
38 the world: no reaction can stop or resume the world it runs in
39 (`RX_ERR_AUTHORITY`). ADR 0016 I9: intelligence cannot promote itself past
40 authority policy; the same applies to pausing or un-pausing.
41 3. **Capability.** `cap` is a live capability for `subject` on
42 `RX_WORLD_RES_CONTROL` (0x906) with right `RX_WORLD_RIGHT_HALT`, validated by
43 the world's authority (rx_caproot or the native Aienux authority). The right
44 is `RX_RIGHT_EPOCH`: privileged, never delegable. The right that may void every
45 capability may also pause the world. Wrong right, wrong resource, another
46 subject's capability or a revoked capability: `RX_ERR_AUTHORITY`.
47
48 Authority is never a boolean anyone can set (ADR 0016 §57, "Do not encode
49 authority as editable booleans"). `w->halted` is the world's *state*, written
50 only by the two authorized calls and by restart restoration (§4). Every refused
51 attempt leaves the world digest, the crumb log and the stop state unchanged (E1).
52 A forged resume is refused before the world says whether it is stopped (E1).
53
54 ## 3. What a stop does
55
56 Taken under `mu` then `callers_mu` (the C7 order), so work already committing
57 finishes first, and nothing lands between the check and the state change.
58
59 | Path | Under a stop | Evidence |
60 |---|---|---|
61 | Workers | take no work (`worker_main` waits); resume broadcasts | E3, mutant M2 |
62 | An activation computing when the stop lands | its result is refused at commit: CANCELLED, `RX_ERR_HALTED`, crumb; it is re-armed and runs again on resume, committing exactly once | E3, mutant M1 |
63 | Outside publication (`rx_world_publish_external`) | refused, `RX_ERR_HALTED`, world unchanged | E2, E4, mutant M3 |
64 | Resident seat result (`rx_resident_accept`) | not published: the output window is re-projected from the world, the activation ends CANCELLED and runs again on resume; the claim closes | R12 `t_emergency_stop` (manual mutant: removing the guard fails 5 checks) |
65 | Object create and retire (`rx_world_create`, `rx_world_retire`) | refused, `RX_ERR_HALTED`, world unchanged (digest, crumbs) | E7, mutants M11, M12 |
66 | Sequential activation (`rx_world_seq_activate_timed_locked`) | refused, `RX_ERR_HALTED` | code review only |
67 | Caller check (`rx_world_caller_check_fn`) | refuses with `RX_CALLER_ERR_HALTED` (CHECK and HOLD; RELEASE unaffected) | E5, mutant M4 |
68 | Generation store bound to the world | `rx_gen_propose` / `rx_gen_promote` refuse with `RX_GEN_ERR_HALTED`; a promotion is re-checked after its HOLD, right before the flip, so a stop during its live barrier or its disk writes refuses it; active generation unchanged in memory and on disk | E5 |
69
70 A refused activation is not spent: it does not count toward the reaction's
71 episode activation budget, so a reaction woken by another reaction's commit is
72 not quarantined by its own refusal and does run on resume (E7, mutant M10; the
73 same correction on the seat-result path is in code, covered by no test that sets
74 a budget).
75
76 A second stop answers `RX_HALT_ALREADY` and changes nothing (E2). A resume of a
77 running world answers `RX_HALT_NOT_STOPPED`, with no crumb (E1).
78
79 The stop is in force in memory **before** any disk work (mutant M9). Under racing
80 publishers and two operators, the crumb log never shows an EXTERNAL or COMMIT
81 between a STOP and its RESUME, each accepted stop has exactly one STOP crumb,
82 and the chain verifies (E4).
83
84 ## 4. Durability and restart
85
86 With `rx_world_set_halt_dir(w, dir)` set (normally the generation store's
87 directory):
88
89 * A stop writes `
/OPERATOR_HALT`: a fixed text record (`aien-operator-halt
90 v1`, seq, subject, capability, reason, time, the STOP crumb id) followed by
91 `sha256 ` over every byte before it. Written to a partial file, fsynced,
92 renamed, directory fsynced. If the write fails, the stop still holds in memory
93 and `durable` < 0 reports the errno (never hidden); `durable` = 0 means no
94 directory was set (E2).
95 * A world that starts over a directory holding the mark starts **stopped**
96 (`restored`, STOP crumb). A mark that does not verify (one byte changed) or
97 cannot be read also starts it stopped (`RX_ERR_TORN` / `RX_ERR_IO`): the mark
98 fails closed (E6, mutant M7).
99 * A mark that is not a regular file (a symlink, dangling or not, a FIFO, a
100 directory) is never followed or blocked on: it is read with `O_NOFOLLOW |
101 O_NONBLOCK` and reported `RX_ERR_TORN`, so the world starts stopped, and the
102 store (which tests for any entry with `lstat`) agrees. Resume keeps a record and
103 removes the entry, so the store is never blocked for good (E7, mutant M13).
104 * A generation store refuses promotion while the mark exists, even when it is
105 not bound to any world (`RX_GEN_ERR_HALTED`; an unreadable directory is
106 `RX_GEN_ERR_IO`) (E6, mutant M6). It checks its *own* directory, on entry
107 and again right before the flip; an unbound store over a directory other than
108 the world's halt directory does not see the mark. Set the halt directory to the
109 store's directory.
110 * Resume first writes the sealed resumed record
111 `OPERATOR_HALT.resumed..`: the original bytes, then `resumed_by`,
112 `resume_cap` and `resume_t_ns`, then a new seal. It is linked in without
113 overwriting anything, and only then is the mark removed. If either step fails,
114 resume returns `RX_ERR_IO` and the world **stays stopped** (E6, mutant M8).
115
116 The mark is the durable stop *state*. The canonical evidence is the crumb log
117 (OPERATOR_STOP and OPERATOR_RESUME crumbs, with the resume caused by its stop),
118 per ADR 0016 §57 "Do not use text logs as canonical evidence". These two kinds
119 have no Cortex kind and are not linked into Cortex (`rx_cortex_record.c`).
120
121 ## 5. ADR 0016 invariants
122
123 | Invariant | How the stop keeps it |
124 |---|---|
125 | I2 stale generations cannot mutate current state | a refused activation re-runs on resume against the state *then*; the seat result path re-projects from the world |
126 | I4 revoked authority cannot execute | a revoked control capability or caller is refused (E1); the stop adds a refusal, never a permission |
127 | I6 concurrent publication cannot create torn objects | a stop is taken under the world lock; a commit either finishes before it or is refused whole (E3, E4) |
128 | I7 causal history for meaningful committed changes | STOP and RESUME are crumbs; refused activations leave CANCELLED crumbs with `RX_ERR_HALTED` |
129 | I8 generation recovery produces a coherent world | no promotion completes under a stop, including one already past its barrier (E5); restart restores the stop (E6) |
130 | I11 GPU failure cannot destroy durable identity | a seat result under a stop is dropped and re-projected, never half-published (R12 `t_emergency_stop`) |
131 | I15 irreversible effects remain attributable | every stop, resume and refusal names its subject, capability and reason |
132
133 ## 6. Tests and what they prove
134
135 `make test-rx-emergency` (host CPU, real rx_caproot authority, worker pool,
136 generation store; built with the normal flags; E1 to E6 in the file header):
137
138 * E1 refusals: seven refused stops, each with its code, nothing changed.
139 * E2/E3: stop, second stop, refused publication, in-flight refusal, queued work
140 not taken, resume, each activation commits exactly once.
141 * E4 race: four workers, two operators, publishers; crumb-log ordering.
142 * E5 promotion under a stop (live barrier and disk-write windows), proposal
143 refused, control promotion after resume.
144 * E6 durable mark, restart, torn mark, unbound store, read-only directory resume.
145 The read-only case is skipped when the test runs as root (root ignores the
146 permission).
147 * E7 budget: a stop while a downstream reaction computes, budget 1; object
148 create and retire under a stop; a dangling symlink mark.
149 * `rx_emergency_mutants.sh`: thirteen single-guard mutants (M1 to M13 above),
150 each applied to a temporary copy; the test must fail against every one (at
151 least one failed check, not a crash or a timeout) and pass against the
152 unmutated copy. A mutant whose pattern does not match exactly once fails the
153 script.
154
155 `make test-r12` `t_emergency_stop` (native Aienux authority, resident seat
156 stand-in): a seat result that lands after the stop is refused, canonical B and
157 B's window keep the world's value, the dependent does not run, no claim is posted
158 under the stop; after resume the seat runs again and B = X + Y, C = X + Y + 1.
159
160 ## 7. Not done
161
162 1. **Production wiring: DONE (CAND-3).** The production R13 program sets the
163 generation store's directory as the halt directory before any object exists,
164 restores a durable stop before it accepts work, and serves an owner-only
165 operator socket (`src/runtime/rx_operator.c`, client `build/rx_operator`). The
166 interface contract is `docs/r16-operator-control.md`. The old string-presence
167 check (`rx_world_set_halt_dir` text in the R13 source) is gone: the G6 item now
168 needs the operator integration test, its mutants and the silicon run to pass.
169 Found by the integration test and fixed with it: a durable promotion or
170 proposal that the store refused because of a stop (`RX_GEN_ERR_HALTED`) was
171 recorded as the final outcome, so the positive episode never promoted after
172 the resume. `src/runtime/rx_living.c` now treats that refusal as "run again
173 after the resume" (`halted_wait`).
174 2. **Silicon.** The silicon run of the operator test (`make
175 test-r16-operator-silicon`, resident GB10 seat, no SIGKILL phase) is the only
176 chip evidence; until it has passed on the candidate the item is not PASS.
177 3. **Mark authenticity.** The seal is an unkeyed sha256: it detects a damaged
178 mark, not a forged one. A forged mark can only stop the world (fail closed).
179 Removing the mark while no world runs bypasses the restart restoration;
180 protecting the directory is the operating system's job and is not tested
181 here.
182 4. **Outside executors.** A stop does not reach a durable executor already
183 performing an effect outside the world. Its result is not published until
184 resume, and the effect stays attributable through its crumbs.
185 5. **Sequential activation** under a stop is refused in code but has no test.
186 6. **Disk work under the locks.** The stop writes its mark (fsync included) while
187 holding the world lock and the caller lock. The stop is already in force in
188 memory; a slow disk delays readers and caller checks for that time, never the
189 stop itself.