From 4966c5ac3f57aaf278fc9c2890fb6e90b191c4ee Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Wed, 28 Oct 2026 11:25:16 -0500 Subject: [PATCH] Gate backend startup on bounded native identity readiness Signed-off-by: Drake Stapleton --- .crumb | 10 +- om/agora/check.sh | 27 +++++ om/agora/deploy/DEPLOY.md | 38 +++++++ om/agora/deploy/startup.evidence.json | 88 ++++++++++++++++ om/agora/startup-check.om | 139 ++++++++++++++++++++++++++ 5 files changed, 297 insertions(+), 5 deletions(-) create mode 100644 om/agora/deploy/startup.evidence.json create mode 100644 om/agora/startup-check.om diff --git a/.crumb b/.crumb index 5268fe1f..f7ef4008 100644 --- a/.crumb +++ b/.crumb @@ -78,14 +78,14 @@ } ], "children_root": "sha256:dda6036f5cc4a440fe7d501f49197693d86ac0baaed26856465ae6b8cfeb59ac", - "compiled_at": "2026-10-28T15:30:17Z", + "compiled_at": "2026-10-28T16:24:08Z", "compiler": "crumb-compile/1", - "digest": "sha256:95a5f7eac79beac30f4892c0f2cde1d99c56cc9ce0fe95e270e38cc006b31898", + "digest": "sha256:842be802c288124badd195d095c8eab583b5f16c360ecf886540da77401a44a7", "evidence_files": 6, "evidence_root": "sha256:7fde48972a09dd4b0f7206aca4e313cd02c8cd195ec602e3924e59246c016aa5", - "files": 789, - "generated_at_commit": "ce80c8e1586107b1be2cdfbe3d0d98483e33a7d5", - "source_tree": "sha256:2822bd034f0c82289070bfd5688bb86142ae7e5289efd23ddcdf6d59f2477e38" + "files": 791, + "generated_at_commit": "8d9ec3a79f93270900e2a9f3b8787385ce29f904", + "source_tree": "sha256:1a37341ff319dbdc386ad786c766c80584f8ae83db2679415192514d7a493056" }, "progress": { "initial_edits": "Dashboard draft predates explicit Crumb reminder; subsequent integration is claimed and recorded.", diff --git a/om/agora/check.sh b/om/agora/check.sh index d7d3fb13..274409ee 100755 --- a/om/agora/check.sh +++ b/om/agora/check.sh @@ -94,6 +94,33 @@ if [ "$survived" -ne 0 ]; then exit 6 fi printf 'PASS agora core: scenario on the real server, 7 of 7 mutants killed\n' +# Native backend startup policy: snapshots use an absolute monotonic deadline. +for mode in real preexec-root-fail deadline-off identity-off; do + case "$mode" in + real) edit=''; expected=0 ;; + preexec-root-fail) edit='/^note MUTANT_PREEXEC:/a\ +if eq uid 0\ +ret 2\ +end'; expected=40 ;; + deadline-off) edit='s/^if or lt now 0 ge now until$/if lt now 0/'; expected=48 ;; + identity-off) edit='s/^if or ne uid 976 ne gid 964$/if false/'; expected=44 ;; + esac + if [ "$mode" = real ]; then + cp startup-check.om "$tmp/startup-$mode.om" + else + sed "$edit" startup-check.om > "$tmp/startup-$mode.om" + if cmp -s startup-check.om "$tmp/startup-$mode.om"; then + printf 'FAIL unchanged startup mutant %s\n' "$mode" + exit 6 + fi + fi + { printf 'om2\n'; cat "$tmp/startup-$mode.om"; } | "$omc" > "$tmp/startup-$mode" + chmod +x "$tmp/startup-$mode" + result=0 + "$tmp/startup-$mode" || result=$? + [ "$result" -eq "$expected" ] || { printf 'FAIL startup %s: expected %s, observed %s\n' "$mode" "$expected" "$result"; exit 6; } + printf 'PASS startup %s observed %s\n' "$mode" "$result" +done # Native reload-readiness regression; nginx remains an external loopback oracle. nginx=${NGINX_BIN:-nginx} command -v "$nginx" >/dev/null || { printf 'missing nginx oracle: %s\n' "$nginx" >&2; exit 2; } diff --git a/om/agora/deploy/DEPLOY.md b/om/agora/deploy/DEPLOY.md index 11900ec3..b18c1c21 100644 --- a/om/agora/deploy/DEPLOY.md +++ b/om/agora/deploy/DEPLOY.md @@ -109,6 +109,44 @@ as well. Check every installed file, not only the new snippet files. This procedure changes the transfer mechanism, not the approved configuration, network boundary, reload barrier or deployment acceptance gates. +### Backend startup identity barrier + +`Type=simple` reports a successful start before the child has necessarily +changed credentials or completed `exec`. An immediate root-owned pre-exec +snapshot is not evidence that the listening backend runs as root. + +After start, capture a nonzero `MainPID`. Poll for at most 10 seconds against +one absolute monotonic deadline. For the approved Spark account, require +`/proc/PID/exe` to resolve to `/opt/aien/bin/agora`, effective UID/GID 976/964, +and root `ss -ltnp` to show that **that same PID** owns the 18132 listener at +the approved bind address. Record the actual observations. Require the unit's +`MainPID` to remain the captured PID. Never accept command completion, +a matching process name, a journal line or a listener owned by another PID. + +Capture executable/credentials before and after the listener observation; +a changing snapshot is pending, not readiness. Root pre-exec snapshots +without a listener are pending within the deadline, as are the expected +post-exec credentials before bind. A completed executable with wrong +credentials, an unexpected stable identity, process/read failure or timeout +is FAIL and triggers rollback. Do not extend the deadline, rerun start, +change the service identity or activate routing to make this check pass. + +The native `om/agora/startup-check.om` unit is the startup policy authority. +Its CLI takes `deadline_ns executable_match effective_uid effective_gid +same_pid_listener` and exits 0 for pending, 1 for ready, 2 for refusal, or 90 +for malformed syntax. Checked-integer overflow also fails closed. The observer +must interpret those policy statuses, not treat exit 0 as readiness. It must +retain the same deadline throughout polling and reject any late result. + +With no arguments, the native unit replays synthetic credential snapshots +against the real monotonic clock: pre-exec root stays pending, the expected +executable/credentials/listener become ready, and a root snapshot that +persists through the full deadline is refused. This is a policy trace +fixture, not a claim that a privileged fixture process was launched. +The conductor requires preexec-root-fail, deadline-off and identity-off +mutants to fail with exits 40, 48 and 44 respectively. Actual production +`/proc` and listener ownership remain mandatory independent observations. + ### Reload adoption barrier `nginx -t`, `nginx -T`, and a successful reload command do not prove that the diff --git a/om/agora/deploy/startup.evidence.json b/om/agora/deploy/startup.evidence.json new file mode 100644 index 00000000..d49c06e4 --- /dev/null +++ b/om/agora/deploy/startup.evidence.json @@ -0,0 +1,88 @@ +{ + "schema_version": 1, + "status": "EXERCISED", + "scope": "Native startup policy and synthetic snapshot fixture on an actual monotonic deadline; no privileged fixture process launched. Production process and listener facts must be independently observed.", + "compiler": { + "repository": "aien-dev/omega-mv", + "revision": "e5b32567a7aff3ce594e3254a622a846a6cd190b", + "sha256": "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f" + }, + "unit": { + "path": "om/agora/startup-check.om", + "sha256": "214d642d9d6b708bf209b1f84ac22655904e57a1389ae2dd0a64281726846f3e", + "composition": "om2 newline, then startup-check.om", + "binary_sha256": "66ed83f561ebc498cba51e021446965e2ffe4b70a46ab84a99d4dde03bad503e", + "selftest_expected_exit": 0, + "selftest_observed_exit": 0 + }, + "deadline": { + "seconds": 10, + "nanoseconds": 10000000000, + "query": "UnitConvert[Quantity[10,\"Seconds\"],\"Nanoseconds\"]", + "raw_mounted_wolfram_output": "Out[1]= Quantity[10000000000, \"Nanoseconds\"]" + }, + "mutants": [ + { + "name": "preexec-root-fail", + "expected_exit": 40, + "observed_exit": 40 + }, + { + "name": "deadline-off", + "expected_exit": 48, + "observed_exit": 48 + }, + { + "name": "identity-off", + "expected_exit": 44, + "observed_exit": 44 + } + ], + "cli_controls": [ + { + "case": "preexec-root-pending", + "exit": 0, + "expected": 0, + "scope": "MODELED snapshot CLI, not actual process ownership" + }, + { + "case": "ready", + "exit": 1, + "expected": 1, + "scope": "MODELED snapshot CLI, not actual process ownership" + }, + { + "case": "wrong-postexec-credentials", + "exit": 2, + "expected": 2, + "scope": "MODELED snapshot CLI, not actual process ownership" + }, + { + "case": "missing-same-pid-listener", + "exit": 0, + "expected": 0, + "scope": "MODELED snapshot CLI, not actual process ownership" + }, + { + "case": "root-after-expired-deadline", + "exit": 2, + "expected": 2, + "scope": "MODELED snapshot CLI" + } + ], + "command": "NET_KEEP=1 OMEGA_OMC=/path/to/pinned/omc NGINX_BIN=/path/to/nginx sh om/agora/check.sh", + "observed": "PASS: core scenario/seven mutants; native startup original/three mutants; native reload original/four mutants; existing network gates.", + "review": { + "agent": "StartupGateReview", + "decision": "No concrete source-level correctness or safety blocker", + "decisive_point": "Real-clock root persistence repeatedly supplies modeled root snapshots while reading monons and sleeping; premature refusal or readiness fails.", + "limit": "The native policy consumes supplied facts, not proc/listener/MainPID observations. Observer correctness must be established separately." + }, + "not_claimed": [ + "actual production process ownership", + "production BPF attachment or source filtering", + "production logging privacy", + "deployment or boot enablement" + ], + "historical_receipts": "Existing reload evidence files remain unchanged." +} diff --git a/om/agora/startup-check.om b/om/agora/startup-check.om new file mode 100644 index 00000000..5ee3940e --- /dev/null +++ b/om/agora/startup-check.om @@ -0,0 +1,139 @@ +note Native startup verification policy; no production process is launched or signalled. +note With five args: deadline_ns, executable_match, effective_uid, effective_gid, same_pid_listener. +note Policy exits: 0 pending, 1 ready, 2 refused; malformed syntax exits 90 and checked-integer overflow traps. +note Without args: synthetic credential snapshots exercise the same policy against the real monotonic clock. +note WolframLanguageEvaluator: UnitConvert[Quantity[10,"Seconds"],"Nanoseconds"] -> Quantity[10000000000,"Nanoseconds"]. +global sc_argb uchar 32 +text sc_pass "AGORA STARTUP OMEGA PASS modeled pre-exec root pending; expected executable/976/964/same-PID listener accepted; root past deadline refused\n" +fn sc_arg idx ulong to long +n = argread idx sc_argb 0 len sc_argb +if or le n 0 ge n long len sc_argb +ret -1 +end +v = long 0 +for i ulong ulong n +c = get sc_argb i +if or lt c 48 gt c 57 +ret -1 +end +v = add mul v 10 long sub c 48 +end +ret v +end +fn sc_gate xe bool uid long gid long sc_own bool until long to int +now = monons +if or lt now 0 ge now until +ret 2 +end +note MUTANT_PREEXEC: a root pre-exec observation is pending, not an immediate failure. +if xe +if or ne uid 976 ne gid 964 +ret 2 +end +if sc_own +now = monons +if or lt now 0 ge now until +ret 2 +end +ret 1 +end +ret 0 +end +if sc_own +ret 2 +end +if and eq uid 0 or eq gid 0 eq gid 964 +ret 0 +end +if and eq uid 976 eq gid 964 +ret 0 +end +ret 2 +end +fn sc_root until long to bool +while true bound 999999 +now = monons +if lt now 0 +ret false +end +if ge now until +ret eq sc_gate false 0 0 false until 2 +end +state = sc_gate false 0 0 false until +if eq state 1 +ret false +end +if eq state 2 +now = monons +ret and ge now 0 ge now until +end +r = sleepns 10000000 +if lt r 0 +ret false +end +end +ret false +end +fn sc_test to int +start = monons +if lt start 0 +ret 39 +end +until = add start 10000000000 +if ne sc_gate false 0 0 false until 0 +ret 40 +end +if ne sc_gate false 976 964 false until 0 +ret 41 +end +if ne sc_gate true 976 964 false until 0 +ret 42 +end +if ne sc_gate true 976 964 true until 1 +ret 43 +end +if ne sc_gate true 0 0 true until 2 +ret 44 +end +if ne sc_gate true 976 0 true until 2 +ret 45 +end +if ne sc_gate false 976 964 true until 2 +ret 46 +end +start = monons +if lt start 0 +ret 39 +end +if not sc_root add start 10000000000 +ret 48 +end +if ne sc_gate true 976 964 true 0 2 +ret 47 +end +r = write 1 sc_pass 0 len sc_pass +if ne r long len sc_pass +ret 49 +end +ret 0 +end +fn main to int +if eq argcnt 1 +ret sc_test +end +if ne argcnt 6 +ret 90 +end +until = sc_arg 1 +xe = sc_arg 2 +uid = sc_arg 3 +gid = sc_arg 4 +sc_own = sc_arg 5 +if or lt until 0 or lt xe 0 gt xe 1 +ret 90 +end +if or lt uid 0 or lt gid 0 or lt sc_own 0 gt sc_own 1 +ret 90 +end +ret sc_gate eq xe 1 uid gid eq sc_own 1 until +end