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 Source
# R16 G6: operator emergency stop (contract)
Status: runtime control IMPLEMENTED and host-tested; WIRED into the production R13 program with an outside operator entry point (`docs/r16-operator-control.md`, CAND-3 lane ESTOP). G6 item `operator_emergency_controls_passing` is operated only by execution: the host integration test `make test-r16-operator-host` and its mutants `make test-r16-operator-mutants`, plus the silicon run `make test-r16-operator-silicon`. It is not PASS until a silicon receipt from the candidate exists. See "Not done" at the end.
Source: `src/runtime/rx_world.c` (`rx_world_emergency_stop`, `rx_world_emergency_resume`, `rx_world_set_halt_dir`, `rx_world_halt_status`), `src/runtime/rx_generation.c` (`rx_gen_promote` mark check), `src/runtime/rx_world.h` (contract comment). Tests: `make test-rx-emergency` (`tests/runtime/rx_emergency.c` plus `tests/runtime/rx_emergency_mutants.sh`) and `make test-r12` (`t_emergency_stop` in `tests/runtime/rx_r12_resident.c`).
## 1. What it is
One deterministic operator control over a running reaction world: stop (nothing new commits, nothing from outside publishes, no generation is proposed or promoted) and resume (the world continues from exactly the state it held, and the work the stop refused runs again). ADR 0016 §57: "Do not remove deterministic operator control." This is that control for the R16 world. It is not a kill switch for the process and not a rollback: the world's state is kept, not changed.
## 2. Authority
A stop or resume is accepted only when all three hold, checked under the world lock in this order:
- Caller credential. `subject` is enrolled (`rx_world_enroll_caller`) and `cred` passes the constant-time caller check (absent, unknown, revoked, stale and forged credentials are refused: `RX_ERR_IDENTITY`). This holds whether or not the world has bound its callers.
- Not a reaction. `subject` is not the subject of any reaction ever added to the world: no reaction can stop or resume the world it runs in (`RX_ERR_AUTHORITY`). ADR 0016 I9: intelligence cannot promote itself past authority policy; the same applies to pausing or un-pausing.
- Capability. `cap` is a live capability for `subject` on `RX_WORLD_RES_CONTROL` (0x906) with right `RX_WORLD_RIGHT_HALT`, validated by the world's authority (rx_caproot or the native Aienux authority). The right is `RX_RIGHT_EPOCH`: privileged, never delegable. The right that may void every capability may also pause the world. Wrong right, wrong resource, another subject's capability or a revoked capability: `RX_ERR_AUTHORITY`.
Authority is never a boolean anyone can set (ADR 0016 §57, "Do not encode authority as editable booleans"). `w->halted` is the world's state, written only by the two authorized calls and by restart restoration (§4). Every refused attempt leaves the world digest, the crumb log and the stop state unchanged (E1). A forged resume is refused before the world says whether it is stopped (E1).
## 3. What a stop does
Taken under `mu` then `callers_mu` (the C7 order), so work already committing finishes first, and nothing lands between the check and the state change.
Path Under a stop Evidence
Workers take no work (`worker_main` waits); resume broadcasts E3, mutant M2
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
Outside publication (`rx_world_publish_external`) refused, `RX_ERR_HALTED`, world unchanged E2, E4, mutant M3
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)
Object create and retire (`rx_world_create`, `rx_world_retire`) refused, `RX_ERR_HALTED`, world unchanged (digest, crumbs) E7, mutants M11, M12
Sequential activation (`rx_world_seq_activate_timed_locked`) refused, `RX_ERR_HALTED` code review only
Caller check (`rx_world_caller_check_fn`) refuses with `RX_CALLER_ERR_HALTED` (CHECK and HOLD; RELEASE unaffected) E5, mutant M4
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
A refused activation is not spent: it does not count toward the reaction's episode activation budget, so a reaction woken by another reaction's commit is not quarantined by its own refusal and does run on resume (E7, mutant M10; the same correction on the seat-result path is in code, covered by no test that sets a budget).
A second stop answers `RX_HALT_ALREADY` and changes nothing (E2). A resume of a running world answers `RX_HALT_NOT_STOPPED`, with no crumb (E1).
The stop is in force in memory before any disk work (mutant M9). Under racing publishers and two operators, the crumb log never shows an EXTERNAL or COMMIT between a STOP and its RESUME, each accepted stop has exactly one STOP crumb, and the chain verifies (E4).
## 4. Durability and restart
With `rx_world_set_halt_dir(w, dir)` set (normally the generation store's directory):
- A stop writes `
/OPERATOR_HALT`: a fixed text record (`aien-operator-halt v1`, seq, subject, capability, reason, time, the STOP crumb id) followed by `sha256 ` over every byte before it. Written to a partial file, fsynced, renamed, directory fsynced. If the write fails, the stop still holds in memory and `durable` < 0 reports the errno (never hidden); `durable` = 0 means no directory was set (E2).
- A world that starts over a directory holding the mark starts stopped (`restored`, STOP crumb). A mark that does not verify (one byte changed) or cannot be read also starts it stopped (`RX_ERR_TORN` / `RX_ERR_IO`): the mark fails closed (E6, mutant M7).
- A mark that is not a regular file (a symlink, dangling or not, a FIFO, a directory) is never followed or blocked on: it is read with `O_NOFOLLOW | O_NONBLOCK`and reported`RX_ERR_TORN`, so the world starts stopped, and the store (which tests for any entry with `lstat`) agrees. Resume keeps a record and removes the entry, so the store is never blocked for good (E7, mutant M13).
- A generation store refuses promotion while the mark exists, even when it is not bound to any world (`RX_GEN_ERR_HALTED`; an unreadable directory is `RX_GEN_ERR_IO`) (E6, mutant M6). It checks its own directory, on entry and again right before the flip; an unbound store over a directory other than the world's halt directory does not see the mark. Set the halt directory to the store's directory.
- Resume first writes the sealed resumed record `OPERATOR_HALT.resumed..`: the original bytes, then `resumed_by`, `resume_cap` and `resume_t_ns`, then a new seal. It is linked in without overwriting anything, and only then is the mark removed. If either step fails, resume returns `RX_ERR_IO` and the world stays stopped (E6, mutant M8).
The mark is the durable stop state. The canonical evidence is the crumb log (OPERATOR_STOP and OPERATOR_RESUME crumbs, with the resume caused by its stop), per ADR 0016 §57 "Do not use text logs as canonical evidence". These two kinds have no Cortex kind and are not linked into Cortex (`rx_cortex_record.c`).
## 5. ADR 0016 invariants
Invariant How the stop keeps it
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
I4 revoked authority cannot execute a revoked control capability or caller is refused (E1); the stop adds a refusal, never a permission
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)
I7 causal history for meaningful committed changes STOP and RESUME are crumbs; refused activations leave CANCELLED crumbs with `RX_ERR_HALTED`
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)
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`)
I15 irreversible effects remain attributable every stop, resume and refusal names its subject, capability and reason
## 6. Tests and what they prove
`make test-rx-emergency` (host CPU, real rx_caproot authority, worker pool, generation store; built with the normal flags; E1 to E6 in the file header):
- E1 refusals: seven refused stops, each with its code, nothing changed.
- E2/E3: stop, second stop, refused publication, in-flight refusal, queued work not taken, resume, each activation commits exactly once.
- E4 race: four workers, two operators, publishers; crumb-log ordering.
- E5 promotion under a stop (live barrier and disk-write windows), proposal refused, control promotion after resume.
- E6 durable mark, restart, torn mark, unbound store, read-only directory resume. The read-only case is skipped when the test runs as root (root ignores the permission).
- E7 budget: a stop while a downstream reaction computes, budget 1; object create and retire under a stop; a dangling symlink mark.
- `rx_emergency_mutants.sh`: thirteen single-guard mutants (M1 to M13 above), each applied to a temporary copy; the test must fail against every one (at least one failed check, not a crash or a timeout) and pass against the unmutated copy. A mutant whose pattern does not match exactly once fails the script.
`make test-r12` `t_emergency_stop` (native Aienux authority, resident seat stand-in): a seat result that lands after the stop is refused, canonical B and B's window keep the world's value, the dependent does not run, no claim is posted under the stop; after resume the seat runs again and B = X + Y, C = X + Y + 1.
## 7. Not done
- Production wiring: DONE (CAND-3). The production R13 program sets the generation store's directory as the halt directory before any object exists, restores a durable stop before it accepts work, and serves an owner-only operator socket (`src/runtime/rx_operator.c`, client `build/rx_operator`). The interface contract is `docs/r16-operator-control.md`. The old string-presence check (`rx_world_set_halt_dir` text in the R13 source) is gone: the G6 item now needs the operator integration test, its mutants and the silicon run to pass. Found by the integration test and fixed with it: a durable promotion or proposal that the store refused because of a stop (`RX_GEN_ERR_HALTED`) was recorded as the final outcome, so the positive episode never promoted after the resume. `src/runtime/rx_living.c` now treats that refusal as "run again after the resume" (`halted_wait`).
- Silicon. The silicon run of the operator test (`make test-r16-operator-silicon`, resident GB10 seat, no SIGKILL phase) is the only chip evidence; until it has passed on the candidate the item is not PASS.
- Mark authenticity. The seal is an unkeyed sha256: it detects a damaged mark, not a forged one. A forged mark can only stop the world (fail closed). Removing the mark while no world runs bypasses the restart restoration; protecting the directory is the operating system's job and is not tested here.
- Outside executors. A stop does not reach a durable executor already performing an effect outside the world. Its result is not published until resume, and the effect stays attributable through its crumbs.
- Sequential activation under a stop is refused in code but has no test.
- Disk work under the locks. The stop writes its mark (fsync included) while holding the world lock and the caller lock. The stop is already in force in memory; a slow disk delays readers and caller checks for that time, never the stop itself.