From 5106484c5ef6e90df88d8f615cbe8e5b1849fac1 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Wed, 28 Oct 2026 09:01:31 -0500 Subject: [PATCH 1/2] fix(agora): require bounded nginx worker handover before live gates --- .crumb | 14 ++++++------ om/agora/deploy/DEPLOY.md | 43 ++++++++++++++++++++++++++++++++++++ public/.crumb | 6 ++--- public/data/.crumb | 4 ++-- scripts/test-agora-deploy.py | 38 +++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+), 12 deletions(-) diff --git a/.crumb b/.crumb index f94efe86..508a1b83 100644 --- a/.crumb +++ b/.crumb @@ -24,7 +24,7 @@ }, { "digest": "bd4707663ced2ce5424d12b3ff8681d97b270d5605469126d0b3052b0c9e1f3d", - "last_commit": "919b8a5", + "last_commit": "6e76cd8", "name": "crates", "purpose": "Native Rust website crates" }, @@ -66,7 +66,7 @@ }, { "digest": "0c0b489700618c0945a7853d9228f790eaadea709f4b9832255a32f0031dffb4", - "last_commit": "a30a957", + "last_commit": "6e76cd8", "name": "public", "purpose": "Static public website assets" }, @@ -78,14 +78,14 @@ } ], "children_root": "sha256:dda6036f5cc4a440fe7d501f49197693d86ac0baaed26856465ae6b8cfeb59ac", - "compiled_at": "2026-10-28T13:30:28Z", + "compiled_at": "2026-10-28T14:01:14Z", "compiler": "crumb-compile/1", - "digest": "sha256:ffccb19acbda4c9809f8c2179b766745eb556c460d3d91c8339bc23de758378a", + "digest": "sha256:f14e6f1b4499e54bbf49dd1528e493764fe60d697562b51004befe4660654f02", "evidence_files": 6, "evidence_root": "sha256:7fde48972a09dd4b0f7206aca4e313cd02c8cd195ec602e3924e59246c016aa5", - "files": 782, - "generated_at_commit": "919b8a5e98f6e31b7d8240bc3dcb187dadcc29b3", - "source_tree": "sha256:b9dfd5f62099bd40d3af50efc45bf2255605159d74e3df17b74bb8e80dbe509f" + "files": 786, + "generated_at_commit": "6e76cd86d75dbcb603064575b530bcd2def5fdac", + "source_tree": "sha256:554246c38065c63e65b61a995bf54324fa492772004fa5d0bce3c34d99451c44" }, "progress": { "initial_edits": "Dashboard draft predates explicit Crumb reminder; subsequent integration is claimed and recorded.", diff --git a/om/agora/deploy/DEPLOY.md b/om/agora/deploy/DEPLOY.md index a5d0b430..1526373c 100644 --- a/om/agora/deploy/DEPLOY.md +++ b/om/agora/deploy/DEPLOY.md @@ -79,6 +79,39 @@ complete candidate configuration with `nginx -t` before reloading. Do not restar nginx or touch unrelated model routes. If any prerequisite fails, leave routing disabled rather than broadening the allow list or trusting arbitrary headers. +### Reload adoption barrier + +`nginx -t`, `nginx -T`, and a successful reload command do not prove that the +running master has adopted the candidate. Reload sends a signal asynchronously. +A fresh TLS connection can still reach an old worker and fall through to Pages. +Do not change the location hierarchy or add a fixed sleep to mask that race. + +Before reload, record the actual master PID, executable, command line and its +worker PIDs. Confirm the service uses the same executable/configuration that +passed `nginx -t`; an alternate `-c` or `-p` must be accounted for. After reload, +use a bounded 30-second observation loop: require at least one new worker PID +and require every captured old worker PID to have exited. Record both sets. +Signal-command completion alone is not the barrier. A timeout is FAIL and +requires rollback, not an extension of the deadline. Long-lived old connections +can prevent this deliberately strict retirement condition from passing. + +Only after worker handover, send one non-mutating GET challenge through the +actual public TLS/SNI path. Require HTTP 200, `Cache-Control: no-store`, and +exactly one independently observed backend request. Configure that observation +before the request without logging bodies, keys or visitor identities. No +temporary firewall rules are authorized by this guide; use an explicitly +approved observation mechanism. A missing observation or unexpected response +is FAIL. Only then begin the remaining identity, route, privacy and browser +gates. Never retry a failed acceptance request as though it had passed. + +The local oracle includes a missing-reload negative control, actual old-worker +retirement, and a post-barrier challenge with exact upstream count. When +diagnosing a host-specific failure, also replay the complete `nginx -T` +configuration in isolation, including its SNI/PROXY topology and sibling +locations; replace only host paths, ports, certificates and external upstreams +with local fixtures. Do not publish private captured configuration. + + ## Required deployment checks Record observed outputs, not just the commands: @@ -109,6 +142,16 @@ Record observed outputs, not just the commands: secret-bearing response logging, early header logging, live TLS/SNI identity and actual systemd BPF enforcement require separate live inspection/evidence. +The 2026-10-28 activation was rolled back after an immediate post-reload public +challenge returned the Pages 404. Replaying the complete captured hub +configuration returned 200 through both the PROXY listener and the SNI router. +Reloading from the preceding configuration reproduced an immediate old-worker +Pages 404 followed by 200 after handover. This establishes the reload race +mechanism, not a retrospective proof of the production cause: historical +worker lifecycle and per-request upstream counts were not captured. No +registration location change follows from that observation. + + Ownership and API consent remain self-attested. Browser consent does not become a cryptographic ownership proof. Browser-local recovery keys are accessible to scripts executing on the same origin, including third-party scripts permitted diff --git a/public/.crumb b/public/.crumb index 01e0507c..d9ad78c2 100644 --- a/public/.crumb +++ b/public/.crumb @@ -26,7 +26,7 @@ }, { "digest": "f7663e11702c9495ea6de2f05d8ec832561970a0892403abbec155cf018405c5", - "last_commit": "a30a957", + "last_commit": "6e76cd8", "name": "js", "purpose": "Browser interactions using public data only" }, @@ -50,13 +50,13 @@ } ], "children_root": "sha256:017a106a507f91f5bf2d7add0a634e0837104caef1a81b55883bef695e541d04", - "compiled_at": "2026-10-28T11:42:16Z", + "compiled_at": "2026-10-28T14:01:14Z", "compiler": "crumb-compile/1", "digest": "sha256:0c0b489700618c0945a7853d9228f790eaadea709f4b9832255a32f0031dffb4", "evidence_files": 1, "evidence_root": "sha256:63bece7cb299b29d19622dcb0de4cbaa623357b117d8c7643a562de286c4b2fb", "files": 156, - "generated_at_commit": "a30a9578f8e0171238c4a194bab45a17c28b7b99", + "generated_at_commit": "6e76cd86d75dbcb603064575b530bcd2def5fdac", "source_tree": "sha256:2d8b3b1092db12efd2b4cec706e77788294643f25a7e0600721e6cf68b8bc7e3" } }, diff --git a/public/data/.crumb b/public/data/.crumb index d07750a5..8ceed6a1 100644 --- a/public/data/.crumb +++ b/public/data/.crumb @@ -10,13 +10,13 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-27T17:25:31Z", + "compiled_at": "2026-10-28T14:01:14Z", "compiler": "crumb-compile/1", "digest": "sha256:c8b477d42287dc3ace90ab02916bf3c7431cc1020acde5c63fc8255650df3edd", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 5, - "generated_at_commit": "d877b71d12b95624a6926bc4299f5505f72a6327", + "generated_at_commit": "6e76cd86d75dbcb603064575b530bcd2def5fdac", "source_tree": "sha256:ed807bb74a1922e254814d805f584bd8da5432f4c68ca851b9b44aba46b6bf43" } }, diff --git a/scripts/test-agora-deploy.py b/scripts/test-agora-deploy.py index fc858f73..533a3c65 100755 --- a/scripts/test-agora-deploy.py +++ b/scripts/test-agora-deploy.py @@ -6,6 +6,7 @@ No live configuration, profile data or recovery material is read or changed. import http.server import os from pathlib import Path +import signal import socket import subprocess import sys @@ -34,6 +35,28 @@ def port(): s.bind(('127.0.0.1', 0)) return s.getsockname()[1] +def workers(master): + """Observe actual Linux nginx workers, not signal-command completion.""" + children = Path(f'/proc/{master}/task/{master}/children').read_text().split() + result = set() + for child in children: + try: + command = Path(f'/proc/{child}/cmdline').read_bytes() + except FileNotFoundError: + continue + if command.startswith(b'nginx: worker process'): + result.add(child) + return result + +def handover(master, previous, timeout=30): + deadline = time.monotonic() + timeout + while time.monotonic() < deadline: + current = workers(master) + if current and previous.isdisjoint(current): + return current + time.sleep(.01) + raise TimeoutError('nginx worker generation did not retire before deadline') + with tempfile.TemporaryDirectory(prefix='agora-nginx-') as td: tmp = Path(td) backend = http.server.ThreadingHTTPServer(('127.0.0.1', 0), Upstream) @@ -140,6 +163,21 @@ location / {{ return 200 'logging control'; }} for sentinel in ['public-privacy-sentinel', 'public-accepted-profile-sentinel', 'synthetic-recovery-sentinel']: assert sentinel not in debug, 'synthetic request body leaked to debug log' assert not list((tmp / 'body').glob('*')), 'retained temporary request body' + # A delivered HUP is not configuration readiness. A withheld HUP must + # fail the barrier; a real reload must retire every captured worker. + previous = workers(proc.pid) + assert previous, 'INVALID: no initial nginx workers observed' + try: + handover(proc.pid, previous, timeout=.1) + except TimeoutError: + pass + else: + raise AssertionError('worker barrier accepted a missing reload') + os.kill(proc.pid, signal.SIGHUP) + current = handover(proc.pid, previous) + assert current and previous.isdisjoint(current) + expect('/agora/api/challenge', 200, identity='198.51.100.10') + print('AGORA RELOAD PASS bounded worker-generation handover, missing-reload negative control, then GET challenge 200/no-store/exactly one upstream hit') print('AGORA DEPLOY PASS exact routes/methods, no upstream on refusal, non-PROXY refusal, spoof identity/quota, response privacy headers, API access-log exclusion. Synthetic request-body sentinels absent from observed debug log; debug active. Suppression causality not established (override-removal mutant survived). No retained body files; transient spill and secret-bearing response logs not qualified.') finally: proc.terminate() From b90f37d2c0645c79dc373d3a90d4dd190499ecc1 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Wed, 28 Oct 2026 09:12:10 -0500 Subject: [PATCH 2/2] fix(agora): move reload regression into seeded Omega with refusal mutants --- .crumb | 8 +- om/agora/check.sh | 22 +- om/agora/deploy/DEPLOY.md | 12 +- om/agora/deploy/reload.evidence.json | 82 ++++++ om/agora/reload-check.om | 361 +++++++++++++++++++++++++++ scripts/test-agora-deploy.py | 38 --- 6 files changed, 478 insertions(+), 45 deletions(-) create mode 100644 om/agora/deploy/reload.evidence.json create mode 100644 om/agora/reload-check.om diff --git a/.crumb b/.crumb index 508a1b83..8323ff2f 100644 --- a/.crumb +++ b/.crumb @@ -78,14 +78,14 @@ } ], "children_root": "sha256:dda6036f5cc4a440fe7d501f49197693d86ac0baaed26856465ae6b8cfeb59ac", - "compiled_at": "2026-10-28T14:01:14Z", + "compiled_at": "2026-10-28T14:12:10Z", "compiler": "crumb-compile/1", - "digest": "sha256:f14e6f1b4499e54bbf49dd1528e493764fe60d697562b51004befe4660654f02", + "digest": "sha256:b5722e5f18abba473e0222a3153802b83c909e3751a87312c343064314d20a77", "evidence_files": 6, "evidence_root": "sha256:7fde48972a09dd4b0f7206aca4e313cd02c8cd195ec602e3924e59246c016aa5", "files": 786, - "generated_at_commit": "6e76cd86d75dbcb603064575b530bcd2def5fdac", - "source_tree": "sha256:554246c38065c63e65b61a995bf54324fa492772004fa5d0bce3c34d99451c44" + "generated_at_commit": "5106484c5ef6e90df88d8f615cbe8e5b1849fac1", + "source_tree": "sha256:f45a040130a1047c88c3581c367cb51446f8a02a8e930688e1fe0f563f17b909" }, "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 b8b04494..f7ee8384 100755 --- a/om/agora/check.sh +++ b/om/agora/check.sh @@ -3,7 +3,8 @@ # (test/run.sh) on the real server, then mutants that remove one check each; every # mutant must compile and must fail the scenario, which proves the check exists. # OMEGA_OMC names the pinned omc (sha256 in omc.sha256); it overrides the path, never the pin. -# Exit 2: missing compiler or tool (curl, sha256sum; jq is the net.sh JSON oracle; openssl issues the +# NGINX_BIN selects the unchanged nginx verification oracle (default nginx). +# Exit 2: missing compiler or tool (nginx, curl, sha256sum; jq is the net.sh JSON oracle; openssl issues the # net.sh test PKI and socat terminates TLS in front of its nodes); 3: wrong pin; # 4: vendored unit hash mismatch (http sha256 json jsonw, the om/tls units under tls/ and its notice); # 5: scenario failed on the real server; 6: a mutant survived or did not apply; @@ -93,6 +94,25 @@ if [ "$survived" -ne 0 ]; then exit 6 fi printf 'PASS agora core: scenario on the real server, 7 of 7 mutants killed\n' +# 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; } +build reload-check.om "$tmp/reload" +mkdir "$tmp/reload.d" +"$tmp/reload" "$nginx" "$tmp/reload.d" +for mode in barrier-off old-retirement-off; do + case "$mode" in + barrier-off) edit='s/^if and gt cur 0 ne cur old$/if gt cur 0/; s/^if eq killpid old 0 -3$/if true/'; expected=11 ;; + old-retirement-off) edit='s/^if eq killpid old 0 -3$/if true/'; expected=14 ;; + esac + sed "$edit" reload-check.om > "$tmp/$mode.om" + build "$tmp/$mode.om" "$tmp/$mode" + mkdir "$tmp/$mode.d" + result=0 + "$tmp/$mode" "$nginx" "$tmp/$mode.d" || result=$? + [ "$result" -eq "$expected" ] || { printf 'FAIL reload mutant %s: expected %s, observed %s\n' "$mode" "$expected" "$result"; exit 6; } + printf 'PASS reload mutant %s rejected with %s\n' "$mode" "$result" +done # The network programs (aien-agora, agora-sync, agora-edge) and their mutants. if ! sh "$here/test/net.sh" "$omc" "$tmp"; then exit 7 diff --git a/om/agora/deploy/DEPLOY.md b/om/agora/deploy/DEPLOY.md index 1526373c..1ae5f3dc 100644 --- a/om/agora/deploy/DEPLOY.md +++ b/om/agora/deploy/DEPLOY.md @@ -104,8 +104,16 @@ approved observation mechanism. A missing observation or unexpected response is FAIL. Only then begin the remaining identity, route, privacy and browser gates. Never retry a failed acceptance request as though it had passed. -The local oracle includes a missing-reload negative control, actual old-worker -retirement, and a post-barrier challenge with exact upstream count. When +The native `om/agora/reload-check.om` oracle includes missing-reload and +old-worker-alive failure controls, actual old-worker retirement, and a +post-barrier challenge with exact upstream count. It launches only isolated +loopback nginx workers through Omega's process facilities, observes Linux +`/proc`, uses monotonic deadlines and performs its own HTTP request. Run +`OMEGA_OMC=/path/to/pinned/omc NGINX_BIN=/path/to/nginx sh om/agora/check.sh`; +the existing conductor compiles the Omega unit and requires both barrier-off +and old-retirement-off source mutants to fail with their expected exits. +Local oracle nginx version: 1.24.0; it is an unchanged verification oracle, +not an implementation substituted for Omega. When diagnosing a host-specific failure, also replay the complete `nginx -T` configuration in isolation, including its SNI/PROXY topology and sibling locations; replace only host paths, ports, certificates and external upstreams diff --git a/om/agora/deploy/reload.evidence.json b/om/agora/deploy/reload.evidence.json new file mode 100644 index 00000000..daf061d8 --- /dev/null +++ b/om/agora/deploy/reload.evidence.json @@ -0,0 +1,82 @@ +{ + "status": "EXERCISED_HOST_ONLY", + "compiler": { + "source_pin": "omega-mv@e5b32567", + "sha256": "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f" + }, + "platform": "Linux AArch64", + "oracle": "nginx 1.24.0, unchanged external verification binary", + "source": "om/agora/reload-check.om", + "compose_command": "{ printf \"om2\\n\"; cat om/agora/http.om om/agora/reload-check.om; } | \"$OMEGA_OMC\" > \"$TMP/reload\"; chmod 700 \"$TMP/reload\"", + "run_command": "\"$TMP/reload\" \"$NGINX_BIN\" \"$EMPTY_SCRATCH\"", + "expected_real_exit": 0, + "observed_stdout": "AGORA RELOAD OMEGA PASS barrier; missing-reload and old-worker-alive refused; readiness 200/no-store/one upstream hit", + "controls": [ + { + "name": "real", + "source_sha256": "2b98ff8480641d6567a51c47f7f8a82229f0fda0b0164b0e3d50678430bfae48", + "binary_sha256": "829a785aa82251224e96775cc10204d3bd48764375621fe7cf9124c77e102e1a", + "compile_exit": 0, + "expected_exit": 0, + "observed_exit": 0 + }, + { + "name": "barrier-off", + "source_sha256": "07a1ffe3482cd24092a4322a931337f8322447650c6ac0d068b94d3a864b4d54", + "binary_sha256": "4e63145f3b88401c498df364b86864f3549ca23b06bff5df2b185dabaa386c5a", + "compile_exit": 0, + "expected_exit": 11, + "observed_exit": 11 + }, + { + "name": "old-retirement-off", + "source_sha256": "b7c8c8dd597d7d29cfad8b78e8580f6f14395dfb319ccfe1406f6fc8bc009193", + "binary_sha256": "28edbbf9b5c8bdd9b2d7f5dee6db1e382050f5e0ceb0dde2ea377d6c1d51723a", + "compile_exit": 0, + "expected_exit": 14, + "observed_exit": 14 + }, + { + "name": "readiness-status-off", + "source_sha256": "8f76a7bc804fe7e431ecdd4594fbb192ff71d0d86cf6de5f23ed1402c04dfcf7", + "binary_sha256": "e670d12b02cec0214153d41bd9444e1d39b47d683d26e34bee502fb9dfd62ba9", + "compile_exit": 0, + "expected_exit": 17, + "observed_exit": 17 + }, + { + "name": "upstream-count-wrong", + "source_sha256": "82835522058e755e1aec303b396733dd4b8d8f579d50ee747efbfb3b13db01e4", + "binary_sha256": "afa3a936039263b0f49b06510c16cb3f375d9720d4fbb95e64ced68cc278ae13", + "compile_exit": 0, + "expected_exit": 20, + "observed_exit": 20 + } + ], + "mutations": { + "barrier-off": [ + "if and gt cur 0 ne cur old -> if gt cur 0", + "if eq killpid old 0 -3 -> if true" + ], + "old-retirement-off": [ + "if eq killpid old 0 -3 -> if true" + ], + "readiness-status-off": [ + "expected HTTP/1.1 200 OK -> HTTP/1.1 599 BAD" + ], + "upstream-count-wrong": [ + "expected lines 1 -> lines 2" + ] + }, + "wolfram": { + "query": "UnitConvert[Quantity[{30,0.1,0.01},\"Seconds\"],\"Nanoseconds\"]", + "result": "{Quantity[30000000000,\"Nanoseconds\"],Quantity[1.*^8,\"Nanoseconds\"],Quantity[1.*^7,\"Nanoseconds\"]}", + "provenance": "WolframLanguageEvaluator output relayed by Main, 2026-10-28" + }, + "limits": [ + "One-worker isolated fixture; not a general production worker enumerator", + "No live service changes in this receipt", + "Historical production reload cause remains inference", + "Production logging, browser, durability and deployment NOT_RUN in this receipt" + ] +} diff --git a/om/agora/reload-check.om b/om/agora/reload-check.om new file mode 100644 index 00000000..adb34596 --- /dev/null +++ b/om/agora/reload-check.om @@ -0,0 +1,361 @@ +note Native Linux nginx reload oracle. Compose after the pinned http.om. +note argv: nginx executable, existing empty scratch directory. Loopback only. +note WolframLanguageEvaluator relayed by Main: UnitConvert[Quantity[{30,0.1,0.01},"Seconds"],"Nanoseconds"] -> {30000000000,1.*^8,1.*^7} nanoseconds. +note nginx is an unchanged external verification oracle, not a production dependency added here. +global rc_s ulong 8 +global rc_b uchar 16384 +global rc_p uchar 4096 +global rc_r uchar 4096 +global rc_x uchar 4096 +text rc_pre "/proc/" +text rc_mid "/task/" +text rc_ch "/children" +text rc_cf "/nginx.conf" +text rc_hit "/hits.log" +text rc_flag "-c" +text rc_g "-g" +text rc_off "daemon off;" +text rc_cfg "worker_processes 1;\nerror_log stderr error;\npid " +text rc_pid "/pid;\nevents { worker_connections 64; }\nhttp { access_log off;\nclient_body_temp_path " +text rc_tmp "/body;\nproxy_temp_path " +text rc_tmp2 "/proxy;\nfastcgi_temp_path " +text rc_fc "/fastcgi;\nuwsgi_temp_path " +text rc_uw "/uwsgi;\nscgi_temp_path " +text rc_sc "/scgi;\nserver { listen 127.0.0.1:" +text rc_route "; location = /agora/api/challenge { add_header Cache-Control no-store always; proxy_pass http://127.0.0.1:" +text rc_srv "; } }\nserver { listen 127.0.0.1:" +text rc_log "; access_log " +text rc_tail "; location / { return 200 'synthetic readiness'; } } }\n" +text rc_req "GET /agora/api/challenge HTTP/1.0\nHost: localhost\n\n" +text rc_ok "HTTP/1.1 200 OK" +text rc_nost "Cache-Control: no-store" +text rc_pass "AGORA RELOAD OMEGA PASS barrier; missing-reload and old-worker-alive refused; readiness 200/no-store/one upstream hit\n" + +fn rc_ck yes bool to void +if not yes +exit 80 +end +end +fn rc_emit t view uchar * to void +for i ulong len t +put rc_b get rc_s 0 get t i +put rc_s 0 add get rc_s 0 1 +end +end +fn rc_dec v ulong to void +d = new uchar 20 0 +n = ulong 20 +x = v +for i ulong 20 +n = sub n 1 +put d n uchar add rem x 10 48 +x = div x 10 +if eq x 0 +break +end +end +while lt n 20 bound 20 +put rc_b get rc_s 0 get d n +put rc_s 0 add get rc_s 0 1 +n = add n 1 +end +end +fn rc_path t view uchar * to ulong +put rc_s 0 0 +n = argread 2 rc_b 0 len rc_b +rc_ck gt n 0 +put rc_s 0 ulong n +rc_emit t +for i ulong get rc_s 0 +put rc_p i get rc_b i +end +ret get rc_s 0 +end +fn rc_file t view uchar * to long +n = rc_path t +ret fopen rc_p 0 n 0 0 +end +fn rc_child master int to int +put rc_s 0 0 +rc_emit rc_pre +rc_dec ulong master +rc_emit rc_mid +rc_dec ulong master +rc_emit rc_ch +fd = int fopen rc_b 0 get rc_s 0 0 0 +if lt fd 0 +ret -1 +end +n = read fd rc_r 0 len rc_r +c = fclose fd +if le n 0 +ret -1 +end +pid = ulong 0 +count = ulong 0 +for i ulong ulong n +v = get rc_r i +if and ge v 48 le v 57 +pid = add mul pid 10 ulong sub v 48 +else +if gt pid 0 +count = add count 1 +put rc_s 7 pid +pid = 0 +end +end +end +if eq count 0 +ret -1 +end +ret int get rc_s 7 +end +fn rc_wait master int old int limit long to bool +start = monons +if lt start 0 +ret false +end +while true bound 999999 +now = monons +if or lt now 0 ge sub now start limit +ret false +end +cur = rc_child master +if and gt cur 0 ne cur old +note MUTANT_OLD: a new worker alone is not readiness. +if eq killpid old 0 -3 +ret true +end +end +r = sleepns 10000000 +if lt r 0 +ret false +end +end +ret false +end +fn rc_pack t view uchar * to void +pos = get rc_s 1 +put rc_x pos uchar and len t 255 +put rc_x add pos 1 uchar shr len t 8 +pos = add pos 2 +for i ulong len t +put rc_x add pos i get t i +end +put rc_s 1 add pos len t +end +fn rc_spawn to int +aa = new uchar 4096 0 +put rc_x 0 5 +put rc_s 1 2 +n = argread 1 aa 0 len aa +rc_ck gt n 0 +rc_pack view part aa 0 ulong n +rc_pack rc_flag +plen = rc_path rc_cf +for i ulong plen +put aa i get rc_p i +end +rc_pack view part aa 0 plen +rc_pack rc_g +rc_pack rc_off +child = fork +if eq child 0 +r = execprog rc_x 0 get rc_s 1 +exit 81 +end +ret int child +end +fn rc_port to ulong +a = new uchar 16 0 +r = haddr4 a 2130706433 0 +rc_ck eq r 0 +fd = int hlisten a 16 +rc_ck ge fd 0 +prt = hport a +r = fclose fd +rc_ck eq r 0 +ret prt +end +fn rc_config front ulong back ulong to void +aa = new uchar 4096 0 +plen = rc_path rc_cf +fd = int fopen rc_p 0 plen 578 384 +rc_ck ge fd 0 +put rc_s 0 0 +rc_emit rc_cfg +n = argread 2 aa 0 len aa +rc_emit view part aa 0 ulong n +rc_emit rc_pid +rc_emit view part aa 0 ulong n +rc_emit rc_tmp +rc_emit view part aa 0 ulong n +rc_emit rc_tmp2 +rc_emit view part aa 0 ulong n +rc_emit rc_fc +rc_emit view part aa 0 ulong n +rc_emit rc_uw +rc_emit view part aa 0 ulong n +rc_emit rc_sc +rc_dec front +rc_emit rc_route +rc_dec back +rc_emit rc_srv +rc_dec back +rc_emit rc_log +rc_emit view part aa 0 ulong n +rc_emit rc_hit +rc_emit rc_tail +n = write fd rc_b 0 get rc_s 0 +rc_ck eq n long get rc_s 0 +rc_ck eq fclose fd 0 +end +fn rc_has needle view uchar * n ulong to bool +if lt n len needle +ret false +end +for i ulong add sub n len needle 1 +same = true +for j ulong len needle +if ne get rc_r add i j get needle j +same = false +end +end +if same +ret true +end +end +ret false +end +fn rc_request prt ulong to bool +a = new uchar 16 0 +r = haddr4 a 2130706433 prt +fd = int socknew 2 1 0 +if lt fd 0 +ret false +end +r = connect fd a 0 16 +if lt r 0 +r = fclose fd +ret false +end +n = ulong 0 +for i ulong len rc_req +if eq get rc_req i 10 +put rc_b n 13 +n = add n 1 +end +put rc_b n get rc_req i +n = add n 1 +end +r = send fd rc_b 0 n 0 +if ne r long n +r = fclose fd +ret false +end +n = 0 +while lt n len rc_r bound 4096 +r = waitio fd 1 100000000 +if le r 0 +break +end +r = recv fd rc_r n sub len rc_r n 0 +if le r 0 +break +end +n = add n ulong r +end +r = fclose fd +ret and rc_has rc_ok n rc_has rc_nost n +end +fn rc_test master int front ulong to int +old = int -1 +for i ulong 100 +old = rc_child master +if gt old 0 +break +end +r = sleepns 10000000 +end +if le old 0 +ret 10 +end +put rc_s 5 ulong old +note MUTANT_NEW: absent reload must not pass even though the old worker is alive. +if rc_wait master old 100000000 +ret 11 +end +if ne killpid old 19 0 +ret 12 +end +if ne killpid master 1 0 +ret 13 +end +note The old worker is stopped before HUP, so cannot retire; a new child is not enough. +if rc_wait master old 100000000 +ret 14 +end +nextpid = rc_child master +if or le nextpid 0 eq nextpid old +ret 21 +end +if ne killpid old 18 0 +ret 15 +end +if not rc_wait master old 30000000000 +ret 16 +end +if not rc_request front +ret 17 +end +fd = int rc_file rc_hit +if lt fd 0 +ret 18 +end +n = read fd rc_r 0 len rc_r +r = fclose fd +if le n 0 +ret 19 +end +lines = ulong 0 +for i ulong ulong n +if eq get rc_r i 10 +lines = add lines 1 +end +end +if ne lines 1 +ret 20 +end +ret 0 +end +fn main to int +if ne argcnt 3 +ret 90 +end +front = rc_port +back = rc_port +rc_config front back +master = rc_spawn +if le master 0 +ret 91 +end +result = rc_test master front +old = int get rc_s 5 +if gt old 0 +r = killpid old 18 +end +r = killpid master 15 +status = new uchar 4 0 +r = waitpid master status 0 4 0 +if ne r long master +ret 92 +end +if ne result 0 +ret result +end +r = write 1 rc_pass 0 len rc_pass +if ne r long len rc_pass +ret 93 +end +ret 0 +end diff --git a/scripts/test-agora-deploy.py b/scripts/test-agora-deploy.py index 533a3c65..fc858f73 100755 --- a/scripts/test-agora-deploy.py +++ b/scripts/test-agora-deploy.py @@ -6,7 +6,6 @@ No live configuration, profile data or recovery material is read or changed. import http.server import os from pathlib import Path -import signal import socket import subprocess import sys @@ -35,28 +34,6 @@ def port(): s.bind(('127.0.0.1', 0)) return s.getsockname()[1] -def workers(master): - """Observe actual Linux nginx workers, not signal-command completion.""" - children = Path(f'/proc/{master}/task/{master}/children').read_text().split() - result = set() - for child in children: - try: - command = Path(f'/proc/{child}/cmdline').read_bytes() - except FileNotFoundError: - continue - if command.startswith(b'nginx: worker process'): - result.add(child) - return result - -def handover(master, previous, timeout=30): - deadline = time.monotonic() + timeout - while time.monotonic() < deadline: - current = workers(master) - if current and previous.isdisjoint(current): - return current - time.sleep(.01) - raise TimeoutError('nginx worker generation did not retire before deadline') - with tempfile.TemporaryDirectory(prefix='agora-nginx-') as td: tmp = Path(td) backend = http.server.ThreadingHTTPServer(('127.0.0.1', 0), Upstream) @@ -163,21 +140,6 @@ location / {{ return 200 'logging control'; }} for sentinel in ['public-privacy-sentinel', 'public-accepted-profile-sentinel', 'synthetic-recovery-sentinel']: assert sentinel not in debug, 'synthetic request body leaked to debug log' assert not list((tmp / 'body').glob('*')), 'retained temporary request body' - # A delivered HUP is not configuration readiness. A withheld HUP must - # fail the barrier; a real reload must retire every captured worker. - previous = workers(proc.pid) - assert previous, 'INVALID: no initial nginx workers observed' - try: - handover(proc.pid, previous, timeout=.1) - except TimeoutError: - pass - else: - raise AssertionError('worker barrier accepted a missing reload') - os.kill(proc.pid, signal.SIGHUP) - current = handover(proc.pid, previous) - assert current and previous.isdisjoint(current) - expect('/agora/api/challenge', 200, identity='198.51.100.10') - print('AGORA RELOAD PASS bounded worker-generation handover, missing-reload negative control, then GET challenge 200/no-store/exactly one upstream hit') print('AGORA DEPLOY PASS exact routes/methods, no upstream on refusal, non-PROXY refusal, spoof identity/quota, response privacy headers, API access-log exclusion. Synthetic request-body sentinels absent from observed debug log; debug active. Suppression causality not established (override-removal mutant survived). No retained body files; transient spill and secret-bearing response logs not qualified.') finally: proc.terminate()