diff --git a/.github/workflows/rx-host.yml b/.github/workflows/rx-host.yml index 139c601dc..5ba3bd358 100644 --- a/.github/workflows/rx-host.yml +++ b/.github/workflows/rx-host.yml @@ -35,6 +35,8 @@ on: - 'aienos.lock' - 'argus.lock' - 'tools/r16_authpath.sh' + - 'tools/r16_prod_hygiene.sh' + - 'tools/r16_prod_refuses.sh' - 'tools/ci_declare_skip.sh' # Every push to main re-tests the merge result, whatever it touched (no path # filter): a merge can break the runtime through files outside the PR filter. @@ -217,7 +219,10 @@ jobs: # The hosted runner is not the DGX Spark: whether an Omega realization beats # the reference there is recorded, not required. The chain itself is required. runs-on: ubuntu-24.04-arm - timeout-minutes: 10 + timeout-minutes: 15 + env: + # Lane 32: the production R13 program links the pinned ARGUS (argus.lock). + ARGUS_REPO: ${{ github.workspace }}/aienos-argus steps: - uses: actions/checkout@v4 with: @@ -234,14 +239,23 @@ jobs: sha=$(awk 'NF && $1 !~ /^#/ {print $1; exit}' aienos.lock) test -n "$sha" echo "sha=$sha" >> "$GITHUB_OUTPUT" + g=$(awk 'NF && $1 !~ /^#/ {print $1; exit}' argus.lock) + test -n "$g" + echo "argus=$g" >> "$GITHUB_OUTPUT" - name: Checkout pinned AIENOS authority uses: actions/checkout@v4 with: repository: aien-dev/aienos ref: ${{ steps.aienos.outputs.sha }} path: aienos-src + - name: Checkout pinned ARGUS sources (aienos native/argus, argus.lock; linked into the production R13 program) + uses: actions/checkout@v4 + with: + repository: aien-dev/aienos + ref: ${{ steps.aienos.outputs.argus }} + path: aienos-argus - name: Keep dependency checkouts out of Omega tree status - run: printf 'physics-src/\naienos-src/\n' >> .git/info/exclude + run: printf 'physics-src/\naienos-src/\naienos-argus/\n' >> .git/info/exclude - name: Program identity binds the canonical semantic body (OMEGA_PROGRAM_ID) # AArch64 job: the Visor objects this test links only build on AArch64 hosts # (visor_realization.c k_diff_inputs is aarch64-only, pre-existing). @@ -282,11 +296,11 @@ jobs: grep -q '"tree_dirty": false,' "$receipt" sha256sum "$receipt" cat "$receipt" - - name: R13 living system builds (its run needs both GB10 core classes and the resident seat) + - name: R13 living system builds, production program (ARGUS linked) and AIEN_TEST_BUILD test variant (runs need both GB10 core classes and the resident seat) env: PHYSICS_DIR: ${{ github.workspace }}/physics-src AIENOS_R7_DIR: ${{ github.workspace }}/aienos-src - run: make build/rx_r13_living_host + run: make build/rx_r13_living_host build/rx_r13_living_testbuild_host - name: R14 living recovery builds (its run needs the R13 body, both GB10 core classes and, for the gate, the resident seat) env: PHYSICS_DIR: ${{ github.workspace }}/physics-src @@ -313,6 +327,38 @@ jobs: grep -qx 'R16-G3 static: R16_G3_LINKMAP=STATIC_PASS mode=silicon (checks 1-3 of 5 on this build; not the gate)' build/r16-g3-linkmap-silicon.log grep -qx 'R16 gate: R16_G3_AUTHPATH=NOT_RUN (checks 4-5, exec trace and living run, not run in static-only mode)' build/r16-g3-linkmap-silicon.log echo "- R16-G3 silicon build link map (runner build, not run): checks 1-3 STATIC_PASS; gate NOT_RUN (needs the GB10 seat)" >> "$GITHUB_STEP_SUMMARY" + - name: Production program hygiene, host (no test pieces in the link map or strings; ARGUS linked and observing in a host run) + # Lane 32: the production R13 program carries no AIEN_TEST_BUILD piece + # (Fabric loopback, HMAC stand-in, fixed test keys, Fabric living phase, + # composition fault and rogue hooks) and links the pinned ARGUS. The + # --argus-probe run proves ARGUS is present and observing on this host. + env: + PHYSICS_DIR: ${{ github.workspace }}/physics-src + AIENOS_R7_DIR: ${{ github.workspace }}/aienos-src + run: | + make test-prod-hygiene | tee build/prod-hygiene-host.log + grep -q '^R16 prod: PROD_HYGIENE=PASS mode=host ' build/prod-hygiene-host.log + echo "- Production hygiene host: PROD_HYGIENE=PASS (no test pieces; ARGUS linked and observing)" >> "$GITHUB_STEP_SUMMARY" + - name: Production program hygiene, silicon build (static checks only; the binary is built here and never run) + env: + PHYSICS_DIR: ${{ github.workspace }}/physics-src + AIENOS_R7_DIR: ${{ github.workspace }}/aienos-src + R16_PROD_NO_RUN: '1' + run: | + make test-prod-hygiene-silicon | tee build/prod-hygiene-silicon.log + grep -q '^R16 prod: PROD_HYGIENE=PASS mode=silicon ' build/prod-hygiene-silicon.log + echo "- Production hygiene silicon build: static checks PASS; ARGUS probe run NOT_RUN (Spark check)" >> "$GITHUB_STEP_SUMMARY" + - name: Negative build test (EXPECTED FAILURE, compiling the production program with any test piece must fail) + # Every case compiles a test piece with the production flags and must be + # refused by its build-time guard; three controls must compile; make must + # refuse AIEN_TEST_BUILD in CFLAGS for the production binary. + env: + PHYSICS_DIR: ${{ github.workspace }}/physics-src + AIENOS_R7_DIR: ${{ github.workspace }}/aienos-src + run: | + make test-prod-refuses-test-pieces | tee build/prod-refuses.log + grep -q '^R16 prod: PROD_REFUSES_TEST_PIECES=PASS ' build/prod-refuses.log + echo "- Negative build test: every test piece refused in the production build (expected failures observed)" >> "$GITHUB_STEP_SUMMARY" - name: Empirical optimizer (OMEGA_EMPIRICAL_OPTIMIZER; the gate is claimed only on the DGX Spark) env: OMEGA_CANDIDATE_COMMIT: ${{ github.sha }} @@ -372,6 +418,12 @@ jobs: run: tools/ci_declare_skip.sh test-r14-host spark-only "needs both Spark core classes (X925 + A725); the build is checked in omega-faculty-arm" - name: R13 living system silicon (SKIP chip-only) run: tools/ci_declare_skip.sh test-r13-silicon chip-only "needs the GB10 resident seat and both Spark core classes; qualified only by a candidate-bound Spark receipt" + - name: R13 test-build variant host run (SKIP spark-only) + run: tools/ci_declare_skip.sh test-r13-testbuild-host spark-only "needs both Spark core classes (X925 + A725); the test-build variant (AIEN_TEST_BUILD) is built in omega-faculty-arm" + - name: R13 test-build variant silicon (SKIP chip-only) + run: tools/ci_declare_skip.sh test-r13-testbuild-silicon chip-only "needs the GB10 resident seat and both Spark core classes; qualified only by a candidate-bound Spark receipt" + - name: Production hygiene silicon ARGUS probe run (SKIP chip-only) + run: tools/ci_declare_skip.sh test-prod-hygiene-silicon chip-only "the probe run of the silicon production binary is a Spark check; its static link map and strings checks run in omega-faculty-arm" - name: R14 living recovery silicon (SKIP chip-only) run: tools/ci_declare_skip.sh test-r14-silicon chip-only "needs the GB10 resident seat and both Spark core classes; qualified only by a candidate-bound Spark receipt" - name: R15 G7 and parity host runs (SKIP spark-only) diff --git a/Makefile b/Makefile index 5b134d1b7..4a3ebd54b 100644 --- a/Makefile +++ b/Makefile @@ -503,21 +503,37 @@ test-r12-silicon: $(RX_R12_SILICON) # of the canonical living build, so every R13/R14/R15/R16 binary links them. # rx_graph.o, rx_capq.o and rx_skillroute.o keep their own no-mint symbol # checks; the living host build depends on them so the checks run with it. -# Lane 13: Fabric F5-0 (src/fabric, mk/fabric.mk) in the living build; the R13 -# host test runs a second simulated machine whose Skill the composition uses -# (tests/fabric/fab_living_phase.h). Its purity check runs in test-fabric-living. -RX_FABRIC_LIVING_SRCS = src/fabric/fabric.c src/fabric/fab_hmac.c src/fabric/fab_loopback.c \ - src/fabric/fab_dispatch.c RX_COMPOSE_LIVING_SRCS = src/runtime/aien_machine_id.c src/runtime/rx_jspace.c \ src/runtime/rx_cortex.c src/runtime/rx_cortex_record.c src/runtime/rx_graph.c \ - src/runtime/rx_capq.c src/runtime/rx_skillroute.c src/runtime/rx_compose.c \ - $(RX_FABRIC_LIVING_SRCS) + src/runtime/rx_capq.c src/runtime/rx_skillroute.c src/runtime/rx_compose.c RX_COMPOSE_LIVING_CHECKS = $(OUT_DIR)/rx_graph.o $(OUT_DIR)/rx_capq.o $(OUT_DIR)/rx_skillroute.o \ - src/runtime/rx_compose.h tests/runtime/rx_compose_fixture.h src/fabric/fab_dispatch.h \ - tests/fabric/fab_living_phase.h + src/runtime/rx_compose.h + +# Lane 32: ONE test-build flag, AIEN_TEST_BUILD, off by default. It alone +# admits the test-only pieces: the Fabric F5-0 loopback transport, the HMAC +# stand-in authenticator and the in-process dispatcher (src/fabric, Lane 13), +# the Fabric living phase with its fixed test keys (tests/fabric/ +# fab_living_phase.h), the composition fixture and the rx_compose fault and +# rogue-candidate hooks (RXC_TEST_HOOKS, implied by the flag; alone it is an +# #error). Their headers refuse to compile without it. The PRODUCTION program +# (rx_r13_living_host/_silicon, test-r13-host/-silicon) never sets it, links +# ARGUS and is checked by test-prod-hygiene; the TEST BUILD variant +# (rx_r13_living_testbuild_*, test-r13-testbuild-*) carries the composition +# and Fabric phases and reports R13_LIVING_SYSTEM_TEST_BUILD, never the gate. +# docs/r16-production-entry-point.md has the table. +AIEN_TEST_FLAGS = -DAIEN_TEST_BUILD=1 +RX_FABRIC_TEST_SRCS = src/fabric/fabric.c src/fabric/fab_hmac.c src/fabric/fab_loopback.c \ + src/fabric/fab_dispatch.c +RX_R13_TEST_CHECKS = tests/runtime/rx_compose_fixture.h src/fabric/fab_dispatch.h \ + src/fabric/fab_loopback.h src/fabric/fab_hmac.h tests/fabric/fab_living_phase.h +# The production build refuses the flag outright. +RX_PROD_REFUSE_TEST = $(if $(findstring AIEN_TEST_BUILD,$(CFLAGS))$(findstring RXC_TEST_HOOKS,$(CFLAGS)),\ + $(error the production program never builds with AIEN_TEST_BUILD or RXC_TEST_HOOKS in CFLAGS)) # R13 host uses the R12 processor stand-in and cannot claim the silicon gate. # R13 silicon runs the same world against the physical resident GB10 seat. +# RX_R13_SRCS is the PRODUCTION source set (no test piece); the R14/R15 rigs +# filter rx_r13_living.c out of it. RX_R13_SRCS = src/runtime/rx_caproot.c src/runtime/rx_world.c \ src/runtime/rx_coherent.c src/runtime/rx_native_bind.c \ src/runtime/rx_aegis.c src/runtime/rx_aien.c src/runtime/rx_omega.c \ @@ -529,26 +545,27 @@ RX_R13_SRCS = src/runtime/rx_caproot.c src/runtime/rx_world.c \ src/omega_verify.c src/omega_matvec.c src/omega_matvec_quad.c \ $(RX_COMPOSE_LIVING_SRCS) \ tests/runtime/rx_r13_living.c +RX_R13_TEST_SRCS = $(RX_R13_SRCS) $(RX_FABRIC_TEST_SRCS) +RX_R13_SILICON_EXTRA = src/runtime/rx_resident_gpu.c src/omega_blackwell_codegen.c \ + src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c src/omega_blackwell_matmul.c \ + $(PHYSICS_DIR)/m16/m16_native.c $(PHYSICS_DIR)/nvrm/nvrm.c +# Production program (rules after the ARGUS block below: they link ARGUS). RX_R13_HOST = $(OUT_DIR)/rx_r13_living_host RX_R13_SILICON = $(OUT_DIR)/rx_r13_living_silicon +# Test-build variant (no ARGUS). +RX_R13_TEST_HOST = $(OUT_DIR)/rx_r13_living_testbuild_host +RX_R13_TEST_SILICON = $(OUT_DIR)/rx_r13_living_testbuild_silicon -$(RX_R13_HOST): $(RX_R13_SRCS) src/runtime/rx_living.h $(RX_COMPOSE_LIVING_CHECKS) $(AIENOS_CAP_LIB) | $(OUT_DIR) - $(CC) $(CFLAGS) -DRXC_TEST_HOOKS -pthread -o $@ $(RX_R13_SRCS) $(AIENOS_CAP_LIB) -lm +$(RX_R13_TEST_HOST): $(RX_R13_TEST_SRCS) src/runtime/rx_living.h $(RX_COMPOSE_LIVING_CHECKS) \ + $(RX_R13_TEST_CHECKS) $(AIENOS_CAP_LIB) | $(OUT_DIR) + $(CC) $(CFLAGS) $(AIEN_TEST_FLAGS) -pthread -o $@ $(RX_R13_TEST_SRCS) $(AIENOS_CAP_LIB) -lm -# Lane 17: the Fabric phase (fab_living_phase.h) runs in the silicon binary too; -# its Fabric part is CPU-only loopback, so it links unchanged. The composition -# phase stays host-only: it needs the -DRXC_TEST_HOOKS rogue-candidate hook. -$(RX_R13_SILICON): $(RX_R13_SRCS) src/runtime/rx_resident_gpu.c \ - src/runtime/rx_living.h $(RX_COMPOSE_LIVING_CHECKS) \ - src/omega_blackwell_codegen.c src/omega_blackwell_encoder.c \ - src/omega_blackwell_qmd.c src/omega_blackwell_matmul.c \ - $(PHYSICS_DIR)/m16/m16_native.c $(PHYSICS_DIR)/nvrm/nvrm.c \ - $(AIENOS_CAP_LIB) | $(OUT_DIR) - $(CC) $(CFLAGS) -DR13_SILICON -pthread -o $@ $(RX_R13_SRCS) \ - src/runtime/rx_resident_gpu.c src/omega_blackwell_codegen.c \ - src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c \ - src/omega_blackwell_matmul.c $(PHYSICS_DIR)/m16/m16_native.c \ - $(PHYSICS_DIR)/nvrm/nvrm.c $(AIENOS_CAP_LIB) -ldl -lm +# Lane 17: the Fabric phase runs in the silicon test build too; its Fabric part +# is CPU-only loopback. The composition phase stays host-only. +$(RX_R13_TEST_SILICON): $(RX_R13_TEST_SRCS) $(RX_R13_SILICON_EXTRA) src/runtime/rx_living.h \ + $(RX_COMPOSE_LIVING_CHECKS) $(RX_R13_TEST_CHECKS) $(AIENOS_CAP_LIB) | $(OUT_DIR) + $(CC) $(CFLAGS) $(AIEN_TEST_FLAGS) -DR13_SILICON -pthread -o $@ $(RX_R13_TEST_SRCS) \ + $(RX_R13_SILICON_EXTRA) $(AIENOS_CAP_LIB) -ldl -lm test-r13-host: $(RX_R13_HOST) ./$(RX_R13_HOST) @@ -556,6 +573,12 @@ test-r13-host: $(RX_R13_HOST) test-r13-silicon: $(RX_R13_SILICON) ./$(RX_R13_SILICON) +test-r13-testbuild-host: $(RX_R13_TEST_HOST) + ./$(RX_R13_TEST_HOST) + +test-r13-testbuild-silicon: $(RX_R13_TEST_SILICON) + ./$(RX_R13_TEST_SILICON) + # OMEGA_BRANCH_STATE_REUSE: J-Space branches sharing one semantic prefix, # shared-state realization versus independent recomputation, FORGE placement. RX_BRANCH_REUSE_SRCS = src/runtime/rx_jspace.c src/sha256.c src/omega_evidence.c \ @@ -741,6 +764,8 @@ test-r16-inventory: $(R16_INVENTORY) # R16-G3: the authoritative path with the legacy orchestrators unavailable. # Link map, shared libraries, embedded names and an exec trace of the R13 # living system and the R14 recovery run, legacy programs stubbed on PATH. +# The R13 binary is the PRODUCTION program (Lane 32: no test piece, ARGUS +# linked); its source list includes the pinned ARGUS sources. # Host mode uses the processor stand-in and cannot claim the gate. The silicon # target starts the GB10 seat: run it only as part of the qualification # ladder, detached, never under `timeout` and never killed. @@ -748,11 +773,11 @@ R16_STAMP := $(shell date -u +%Y%m%dT%H%M%SZ) .PHONY: test-r16-authpath test-r16-authpath-silicon test-r16-authpath: $(RX_R13_HOST) $(RX_R14_HOST) sh tools/r16_authpath.sh host $(RX_R13_HOST) $(RX_R14_HOST) \ - $(OUT_DIR)/r16/authpath/host-$(R16_STAMP) $(RX_R13_SRCS) $(AIENOS_CAP_LIB) + $(OUT_DIR)/r16/authpath/host-$(R16_STAMP) $(RX_R13_SRCS) $(RX_PROD_ARGUS_SRCS) $(AIENOS_CAP_LIB) test-r16-authpath-silicon: $(RX_R13_SILICON) $(RX_R14_SILICON) sh tools/r16_authpath.sh silicon $(RX_R13_SILICON) $(RX_R14_SILICON) \ - $(OUT_DIR)/r16/authpath/silicon-$(R16_STAMP) $(RX_R13_SRCS) \ + $(OUT_DIR)/r16/authpath/silicon-$(R16_STAMP) $(RX_R13_SRCS) $(RX_PROD_ARGUS_SRCS) \ src/runtime/rx_resident_gpu.c src/omega_blackwell_codegen.c \ src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c \ src/omega_blackwell_matmul.c $(PHYSICS_DIR)/m16/m16_native.c \ @@ -766,11 +791,11 @@ test-r16-authpath-silicon: $(RX_R13_SILICON) $(RX_R14_SILICON) .PHONY: test-r16-authpath-linkmap test-r16-authpath-linkmap-silicon test-r16-authpath-linkmap: $(RX_R13_HOST) $(RX_R14_HOST) R16_G3_STATIC_ONLY=1 sh tools/r16_authpath.sh host $(RX_R13_HOST) $(RX_R14_HOST) \ - $(OUT_DIR)/r16/authpath/linkmap-host-$(R16_STAMP) $(RX_R13_SRCS) $(AIENOS_CAP_LIB) + $(OUT_DIR)/r16/authpath/linkmap-host-$(R16_STAMP) $(RX_R13_SRCS) $(RX_PROD_ARGUS_SRCS) $(AIENOS_CAP_LIB) test-r16-authpath-linkmap-silicon: $(RX_R13_SILICON) $(RX_R14_SILICON) R16_G3_STATIC_ONLY=1 sh tools/r16_authpath.sh silicon $(RX_R13_SILICON) $(RX_R14_SILICON) \ - $(OUT_DIR)/r16/authpath/linkmap-silicon-$(R16_STAMP) $(RX_R13_SRCS) \ + $(OUT_DIR)/r16/authpath/linkmap-silicon-$(R16_STAMP) $(RX_R13_SRCS) $(RX_PROD_ARGUS_SRCS) \ src/runtime/rx_resident_gpu.c src/omega_blackwell_codegen.c \ src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c \ src/omega_blackwell_matmul.c $(PHYSICS_DIR)/m16/m16_native.c \ @@ -1115,6 +1140,47 @@ $(ARGUS_LIB_SRCS): $(ARGUS_STAMP) # RX_ARGUS=0 links no ARGUS code at all. ARGUS_RX = $(if $(filter 0,$(RX_ARGUS)),,src/runtime/rx_argus.c $(ARGUS_LIB_SRCS)) ARGUS_LINK_FLAGS = $(if $(filter 0,$(RX_ARGUS)),,$(ARGUS_AUTH_FLAGS)) + +# ---- Lane 32: the PRODUCTION R13 program, ARGUS linked ---------------------- +# Built without AIEN_TEST_BUILD (RX_PROD_REFUSE_TEST) and with ARGUS pinned by +# argus.lock, the way the ARGUS suites build it, in the mode the ARGUS-1 +# decisions intend: observe and record. RX_ARGUS=2 (consumer thread ingesting +# into argus_core), authority observer (the authority announces its own +# mints/revokes through the aienos_cap_start link wrap). ARGUS holds no +# capability and the pinned ARGUS has no response path, so it never blocks a +# request and never expands its own authority. These flags are fixed here, not +# taken from the overridable RX_ARGUS/ARGUS_AUTH. The program refuses to run +# unobserved (rx_r13_living.c argus_check_start). +RX_PROD_ARGUS_FLAGS = -DRX_ARGUS=2 -DRX_ARGUS_AUTHORITY_OBSERVER -I$(ARGUS_SRC) \ + -Wl$(comma)--wrap=aienos_cap_start +RX_PROD_ARGUS_SRCS = src/runtime/rx_argus.c $(ARGUS_LIB_SRCS) + +$(RX_R13_HOST): $(RX_R13_SRCS) src/runtime/rx_living.h src/runtime/rx_argus.h $(RX_COMPOSE_LIVING_CHECKS) \ + $(ARGUS_STAMP) $(AIENOS_CAP_LIB) | $(OUT_DIR) + $(RX_PROD_REFUSE_TEST) + $(CC) $(CFLAGS) $(RX_PROD_ARGUS_FLAGS) -pthread -o $@ $(RX_R13_SRCS) $(RX_PROD_ARGUS_SRCS) \ + $(AIENOS_CAP_LIB) -lm + +$(RX_R13_SILICON): $(RX_R13_SRCS) $(RX_R13_SILICON_EXTRA) src/runtime/rx_living.h src/runtime/rx_argus.h \ + $(RX_COMPOSE_LIVING_CHECKS) $(ARGUS_STAMP) $(AIENOS_CAP_LIB) | $(OUT_DIR) + $(RX_PROD_REFUSE_TEST) + $(CC) $(CFLAGS) $(RX_PROD_ARGUS_FLAGS) -DR13_SILICON -pthread -o $@ $(RX_R13_SRCS) \ + $(RX_PROD_ARGUS_SRCS) $(RX_R13_SILICON_EXTRA) $(AIENOS_CAP_LIB) -ldl -lm + +# Production hygiene (link map + strings + ARGUS present; host run of the +# ARGUS probe where the binary can run) and the negative build test: compiling +# the production program with any test piece must FAIL (tools/r16_prod_hygiene.sh). +.PHONY: test-prod-hygiene test-prod-hygiene-silicon test-prod-refuses-test-pieces +test-prod-hygiene: $(RX_R13_HOST) + sh tools/r16_prod_hygiene.sh host $(RX_R13_HOST) + +test-prod-hygiene-silicon: $(RX_R13_SILICON) + sh tools/r16_prod_hygiene.sh silicon $(RX_R13_SILICON) + +test-prod-refuses-test-pieces: $(ARGUS_STAMP) $(AIENOS_CAP_LIB) $(RX_R13_HOST) + CC="$(CC)" CFLAGS="$(CFLAGS)" ARGUS_SRC="$(ARGUS_SRC)" OUT="$(OUT_DIR)/prod-refuses" MAKE="$(MAKE)" PROD_BIN="$(RX_R13_HOST)" \ + sh tools/r16_prod_refuses.sh + ARGUS_R7 = $(ARGUS_OUT)/rx_r7_native_test ARGUS_R8 = $(ARGUS_OUT)/rx_r8_aegis_test ARGUS_R9 = $(ARGUS_OUT)/rx_r9_barrier_test @@ -1437,9 +1503,10 @@ RX_COMPOSE_DEPS = $(RX_COMPOSE_SRCS) $(OUT_DIR)/rx_cortex.o $(RX_SKILLROUTE_OBJ) src/runtime/rx_world.h src/runtime/rx_jspace.h src/runtime/aienos_cap.h $(AIENOS_CAP_LIB) RX_COMPOSE_LINK = $(OUT_DIR)/rx_cortex.o $(RX_SKILLROUTE_OBJ) $(RX_CAPQ_OBJ) $(RX_GRAPH_OBJ) \ $(AIENOS_CAP_LIB) -lm -# RXC_TEST_HOOKS: the composition fault points and rogue-candidate hook -# (rx_compose.h) exist only in the unit test and the R13 host test; the gate -# and every other build compile them out. +# Test build ($(AIEN_TEST_FLAGS), Lane 32): the composition fault points and +# rogue-candidate hook (rx_compose.h, RXC_TEST_HOOKS) exist only in the unit +# tests and the R13 test-build variant; the gate, the production program and +# every other build compile them out. RX_COMPOSE_TEST = $(OUT_DIR)/rx_compose_test RX_COMPOSE_GATE = $(OUT_DIR)/rx_composition_gate # Attach hygiene (one per World, close waits for its own steps, inert @@ -1448,7 +1515,7 @@ RX_COMPOSE_ATTACH_TEST = $(OUT_DIR)/rx_compose_attach_test RX_COMPOSE_ATTACH_ASAN = $(OUT_DIR)/rx_compose_attach_test_asan $(RX_COMPOSE_TEST): $(RX_COMPOSE_DEPS) tests/runtime/rx_compose_test.c | $(OUT_DIR) - $(CC) $(CFLAGS) -DRXC_TEST_HOOKS -pthread -o $@ $(RX_COMPOSE_SRCS) tests/runtime/rx_compose_test.c \ + $(CC) $(CFLAGS) $(AIEN_TEST_FLAGS) -pthread -o $@ $(RX_COMPOSE_SRCS) tests/runtime/rx_compose_test.c \ $(RX_COMPOSE_LINK) $(RX_COMPOSE_GATE): $(RX_COMPOSE_DEPS) tests/runtime/rx_composition_gate.c | $(OUT_DIR) @@ -1456,11 +1523,11 @@ $(RX_COMPOSE_GATE): $(RX_COMPOSE_DEPS) tests/runtime/rx_composition_gate.c | $(O $(RX_COMPOSE_LINK) $(RX_COMPOSE_ATTACH_TEST): $(RX_COMPOSE_DEPS) tests/runtime/rx_compose_attach_test.c | $(OUT_DIR) - $(CC) $(CFLAGS) -DRXC_TEST_HOOKS -pthread -o $@ $(RX_COMPOSE_SRCS) \ + $(CC) $(CFLAGS) $(AIEN_TEST_FLAGS) -pthread -o $@ $(RX_COMPOSE_SRCS) \ tests/runtime/rx_compose_attach_test.c $(RX_COMPOSE_LINK) $(RX_COMPOSE_ATTACH_ASAN): $(RX_COMPOSE_DEPS) tests/runtime/rx_compose_attach_test.c | $(OUT_DIR) - $(CC) $(CFLAGS) -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all -DRXC_TEST_HOOKS \ + $(CC) $(CFLAGS) -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all $(AIEN_TEST_FLAGS) \ -pthread -o $@ $(RX_COMPOSE_SRCS) tests/runtime/rx_compose_attach_test.c $(RX_COMPOSE_LINK) test-composition: $(RX_COMPOSE_TEST) $(RX_COMPOSE_ATTACH_TEST) diff --git a/docs/r16-production-entry-point.md b/docs/r16-production-entry-point.md index 5c4d53053..8e1935bc6 100644 --- a/docs/r16-production-entry-point.md +++ b/docs/r16-production-entry-point.md @@ -26,10 +26,58 @@ credential, and work can no longer be added already done. | what | sources | make target | |---|---|---| -| living system, host seat | `$(RX_R13_SRCS)` (omega `src/`, `src/runtime/`, `tests/runtime/rx_r13_living.c`) + `libaienos_capability.a` | `test-r13-host` | -| living system, GB10 seat | the same + `rx_resident_gpu.c`, the Blackwell encoder/codegen and the physics seat (`m16_native.c`, `nvrm.c`) | `test-r13-silicon` | +| living system, host seat (production program) | `$(RX_R13_SRCS)` (omega `src/`, `src/runtime/`, `tests/runtime/rx_r13_living.c`) + `libaienos_capability.a` + pinned ARGUS (`rx_argus.c`, `argus.lock`); no test pieces | `test-r13-host` | +| living system, GB10 seat (production program) | the same + `rx_resident_gpu.c`, the Blackwell encoder/codegen and the physics seat (`m16_native.c`, `nvrm.c`) | `test-r13-silicon` | | recovery | `tests/runtime/rx_r14_recovery.c` on the same sources | `test-r14-host`, `test-r14-silicon` | -| proof that no legacy orchestrator is in the path (G3) | link map, strings and exec trace of the two binaries above | `test-r16-authpath`, `test-r16-authpath-silicon` | +| proof that no legacy orchestrator is in the path (G3) | link map, strings and exec trace of the production binaries above | `test-r16-authpath`, `test-r16-authpath-silicon` | + +### Production program and test build (Lane 32) + +Test-only pieces build only with one flag, `AIEN_TEST_BUILD` (`-DAIEN_TEST_BUILD=1`, +Makefile `$(AIEN_TEST_FLAGS)`), which is off by default. The flag gates: + +- the Fabric F5-0 loopback transport (`src/fabric/fab_loopback.[ch]`), the HMAC + stand-in authenticator (`fab_hmac.[ch]`), the Fabric dispatcher + (`fab_dispatch.[ch]`) and the fixed test keys they carry (`fl-key-*`); +- the R13 Fabric living phase (`tests/fabric/fab_living_phase.h`); +- the composition fault, rogue-candidate and hold hooks (`RXC_TEST_HOOKS` in + `rx_compose.[ch]`; the flag turns them on) and the R13 composition phase that + uses them with `tests/runtime/rx_compose_fixture.h`. + +The build refuses these pieces without the flag: each test header stops with +`#error`, `RXC_TEST_HOOKS` without the flag is an `#error`, the production +rules stop if `CFLAGS` carries either flag, and the production R13 source stops +unless ARGUS is linked (`RX_ARGUS=2`, authority observer). + +| program | binary | make target | flag | ARGUS | Fabric and composition phases | receipt / gate key | +|---|---|---|---|---|---|---| +| production, host seat | `build/rx_r13_living_host` | `test-r13-host` | off | linked | NOT_RUN, with the reason in the receipt | `R13/rx_living_receipt.json`, `R13_LIVING_SYSTEM` | +| production, GB10 seat | `build/rx_r13_living_silicon` | `test-r13-silicon` | off | linked | NOT_RUN, with the reason | same | +| test build, host seat | `build/rx_r13_living_testbuild_host` | `test-r13-testbuild-host` | on | not linked | run | `R13/rx_living_test_build_receipt.json`, `R13_LIVING_SYSTEM_TEST_BUILD` | +| test build, GB10 seat | `build/rx_r13_living_testbuild_silicon` | `test-r13-testbuild-silicon` | on | not linked | Fabric run; composition NOT_RUN (host-seat fixture) | same | + +A phase that cannot run in the production program is reported NOT_RUN with its +reason, never PASS. The Fabric phase returns once a real transport exists +(after TRUST-1); the composition phase needs the rogue-candidate hook. + +ARGUS mode in production: observe and record (`RX_ARGUS=2`, authority +observer, consumer `ingest`), pinned by `argus.lock` like the ARGUS suites. +ARGUS holds no capability and the pinned ARGUS has no response path, so it +never blocks, never revokes on its own and never expands its own authority +(ARGUS-1 decisions: one narrow revoke is the only automatic response, and it +is not in the pinned ARGUS yet). The production R13 run fails closed if ARGUS +is not active, is not ingesting, or saw no authority event; the receipt +carries the ARGUS counts. The R14 recovery and R15 rigs reuse the production +sources (`$(filter-out ...,$(RX_R13_SRCS))`) without ARGUS. + +Checks: `make test-prod-hygiene` (link map and strings of the production +binary hold no test piece; ARGUS symbols present; `--argus-probe` host run +prints `ARGUS_OBSERVING=PASS`; with `RX_ARGUS_AUTO=0` the probe fails), +`make test-prod-hygiene-silicon` (the same on the GB10 build), and +`make test-prod-refuses-test-pieces` (negative build test: compiling the +production program with each test piece must FAIL). R16-G3 +(`test-r16-authpath`) inspects the production program and runs the hygiene +static checks as its check 2b. ## Legacy and reference paths (not production) diff --git a/mk/fabric.mk b/mk/fabric.mk index 6f98ba7c5..eaeb9a49a 100644 --- a/mk/fabric.mk +++ b/mk/fabric.mk @@ -2,8 +2,12 @@ # advertisement, leases and loss detection keyed by AienMachineId, over the # in-process loopback transport. Files under src/fabric/ and tests/fabric/. # Picked up by `-include mk/*.mk`. Not part of `all` or `test` (that runs only -# the omegatool gates); CI runs test-fabric and test-fabric-living (rx-host.yml) -# and the living build links the Fabric (RX_FABRIC_LIVING_SRCS). It uses the Capability Graph only +# the omegatool gates); CI runs test-fabric and test-fabric-living (rx-host.yml). +# Lane 32: every Fabric build here is a TEST build (-DAIEN_TEST_BUILD=1): the +# loopback transport, HMAC stand-in and dispatcher refuse to compile without +# it, and only the R13 test-build variant links them (RX_FABRIC_TEST_SRCS); the +# production program carries no Fabric until a real transport exists (TRUST-1). +# It uses the Capability Graph only # through src/runtime/rx_capq.h and links the same objects test-capability-graph # links (rx_capq.o, rx_graph.o, the pinned AIENOS capability library). # @@ -14,12 +18,13 @@ # COMPOSITION-2 causal path (rx_compose) through the Fabric # dispatcher (fab_dispatch.c); lease loss, forgery and wrong # machine refused; plain and ASan/UBSan, two runs each. The -# same scenario runs inside the R13 living World. +# same scenario runs inside the R13 test-build variant. ifndef FABRIC_MK FABRIC_MK := 1 .PHONY: test-fabric test-fabric-living fabric-purity fabric-receipt FAB_DIR = $(OUT_DIR)/fabric -FAB_CFLAGS = -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 -Isrc -Isrc/runtime -Isrc/fabric +FAB_CFLAGS = -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 -Isrc -Isrc/runtime -Isrc/fabric \ + -DAIEN_TEST_BUILD=1 FAB_ASAN = -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all FAB_SRCS = src/fabric/fabric.c src/fabric/fab_hmac.c src/fabric/fab_loopback.c FAB_LIVING_SRCS = $(FAB_SRCS) src/fabric/fab_dispatch.c diff --git a/src/fabric/fab_dispatch.c b/src/fabric/fab_dispatch.c index 998d7c40d..b84e6c55a 100644 --- a/src/fabric/fab_dispatch.c +++ b/src/fabric/fab_dispatch.c @@ -3,6 +3,11 @@ #include +/* Link-map marker (test build only): tools/r16_prod_hygiene.sh refuses any + * production binary that carries an aien_test_build_* symbol. */ +__attribute__((used)) const char aien_test_build_fab_dispatch[] = + "AIEN_TEST_BUILD piece: Fabric F5-0 in-process simulated-machine dispatcher"; + int fab_dispatch_init(FabDispatch *d, FabNode *node) { if (!d || !node || !node->cfg.catalog) return FAB_E_ARG; memset(d, 0, sizeof *d); diff --git a/src/fabric/fab_dispatch.h b/src/fabric/fab_dispatch.h index 03ac2d578..6d9e7c42f 100644 --- a/src/fabric/fab_dispatch.h +++ b/src/fabric/fab_dispatch.h @@ -37,6 +37,12 @@ #ifndef FAB_DISPATCH_H #define FAB_DISPATCH_H +/* Lane 32: test-build only. The production program (docs/r16-production-entry-point.md) + * never compiles this; the build refuses it without -DAIEN_TEST_BUILD=1. */ +#ifndef AIEN_TEST_BUILD +#error "fab_dispatch.h (in-process simulated-machine dispatcher) is test and simulation only: build with -DAIEN_TEST_BUILD=1, never in the production program" +#endif + #include "fabric.h" #include "runtime/rx_skillroute.h" diff --git a/src/fabric/fab_hmac.c b/src/fabric/fab_hmac.c index b920cf391..aad0cbdd8 100644 --- a/src/fabric/fab_hmac.c +++ b/src/fabric/fab_hmac.c @@ -5,6 +5,11 @@ #include +/* Link-map marker (test build only): tools/r16_prod_hygiene.sh refuses any + * production binary that carries an aien_test_build_* symbol. */ +__attribute__((used)) const char aien_test_build_fab_hmac[] = + "AIEN_TEST_BUILD piece: Fabric F5-0 HMAC stand-in (not a real signature)"; + void fab_hmac_sha256(const uint8_t *key, size_t key_len, const uint8_t *msg, size_t msg_len, uint8_t out[32]) { uint8_t k[SHA256_BLOCK_SIZE], pad[SHA256_BLOCK_SIZE], inner[SHA256_DIGEST_SIZE]; diff --git a/src/fabric/fab_hmac.h b/src/fabric/fab_hmac.h index 33c9df318..62ffe4dd0 100644 --- a/src/fabric/fab_hmac.h +++ b/src/fabric/fab_hmac.h @@ -6,6 +6,12 @@ #ifndef FAB_HMAC_H #define FAB_HMAC_H +/* Lane 32: test-build only. The production program (docs/r16-production-entry-point.md) + * never compiles this; the build refuses it without -DAIEN_TEST_BUILD=1. */ +#ifndef AIEN_TEST_BUILD +#error "fab_hmac.h (HMAC stand-in for a real per-machine signature) is test and simulation only: build with -DAIEN_TEST_BUILD=1, never in the production program" +#endif + #include #include diff --git a/src/fabric/fab_loopback.c b/src/fabric/fab_loopback.c index baf4734f7..19a9a4921 100644 --- a/src/fabric/fab_loopback.c +++ b/src/fabric/fab_loopback.c @@ -5,6 +5,11 @@ #include +/* Link-map marker (test build only): tools/r16_prod_hygiene.sh refuses any + * production binary that carries an aien_test_build_* symbol. */ +__attribute__((used)) const char aien_test_build_fab_loopback[] = + "AIEN_TEST_BUILD piece: Fabric F5-0 loopback transport and HMAC stand-in authenticator"; + static FabLoopBox *box_of(FabLoop *l, const AienMachineId *id) { for (uint32_t i = 0; i < l->n; i++) if (aien_mid_equal(&l->box[i].id, id)) return &l->box[i]; diff --git a/src/fabric/fab_loopback.h b/src/fabric/fab_loopback.h index e46916c97..01b134243 100644 --- a/src/fabric/fab_loopback.h +++ b/src/fabric/fab_loopback.h @@ -17,6 +17,12 @@ #ifndef FAB_LOOPBACK_H #define FAB_LOOPBACK_H +/* Lane 32: test-build only. The production program (docs/r16-production-entry-point.md) + * never compiles this; the build refuses it without -DAIEN_TEST_BUILD=1. */ +#ifndef AIEN_TEST_BUILD +#error "fab_loopback.h (Fabric loopback transport + HMAC stand-in authenticator) is test and simulation only: build with -DAIEN_TEST_BUILD=1, never in the production program" +#endif + #include "fabric.h" #define FAB_LOOP_NODES 8u diff --git a/src/runtime/rx_compose.c b/src/runtime/rx_compose.c index f7477a166..4a5f6b3c0 100644 --- a/src/runtime/rx_compose.c +++ b/src/runtime/rx_compose.c @@ -50,10 +50,14 @@ static uint64_t ref_pack(JsBranchRef r) { return js_branch_ref_pack(r); } static JsBranchRef ref_unpack(uint64_t v) { return js_branch_ref_unpack(v); } static int ref_eq(JsBranchRef a, JsBranchRef b) { return a.id == b.id && a.gen == b.gen; } -/* One fault point (test builds only, -DRXC_TEST_HOOKS). Fires once; +/* One fault point (test builds only, -DAIEN_TEST_BUILD=1). Fires once; * candidate-side points fire only for fault_k. Returns 1 when the caller must - * fail in process. Without RXC_TEST_HOOKS it never fires. */ + * fail in process. Without the test build it never fires. */ #ifdef RXC_TEST_HOOKS +/* Link-map marker: the production hygiene check (tools/r16_prod_hygiene.sh) + * refuses any binary that carries an aien_test_build_* symbol. */ +__attribute__((used)) const char aien_test_build_rx_compose_hooks[] = + "AIEN_TEST_BUILD piece: rx_compose test hooks (fault points, rogue candidate, hold point)"; static int fault(RxCompose *c, int point, uint32_t k) { if (c->test.fault_point != point) return 0; if ((point == RXC_FP_BEFORE_FORK || point == RXC_FP_CANDIDATE) && k != c->test.fault_k) diff --git a/src/runtime/rx_compose.h b/src/runtime/rx_compose.h index 463b33219..831424325 100644 --- a/src/runtime/rx_compose.h +++ b/src/runtime/rx_compose.h @@ -31,6 +31,16 @@ #ifndef RX_COMPOSE_H #define RX_COMPOSE_H +/* Lane 32: ONE test-build flag. AIEN_TEST_BUILD (off by default, never set for + * the production program) turns on the composition test hooks below; a bare + * RXC_TEST_HOOKS without it is refused at build time. */ +#if defined(RXC_TEST_HOOKS) && !defined(AIEN_TEST_BUILD) +#error "RXC_TEST_HOOKS (composition fault and rogue-candidate hooks) needs -DAIEN_TEST_BUILD=1; it never goes in the production program" +#endif +#if defined(AIEN_TEST_BUILD) && !defined(RXC_TEST_HOOKS) +#define RXC_TEST_HOOKS 1 +#endif + #include "aien_machine_id.h" #include "aienos_cap.h" #include "rx_cortex.h" @@ -205,9 +215,10 @@ typedef struct RxCompose { uint32_t subj_cand[RXC_K], subj_aegis, subj_commit; uint64_t res[5]; RxObjRef obj[5]; - /* Test hooks. They fire only in builds compiled with -DRXC_TEST_HOOKS - * (the composition unit test and the R13 host test); in every other - * build they are ignored and the _exit path does not exist. */ + /* Test hooks. They fire only in builds compiled with -DAIEN_TEST_BUILD=1 + * (the composition unit tests and the R13 test-build variant); in every + * other build, the production program included, they are ignored and + * the _exit path does not exist. */ struct RxcTestHooks { int fault_point; /* RXC_FP_* */ int fault_crash; /* 1: _exit(RXC_CRASH_EXIT); 0: fail in process */ diff --git a/tests/fabric/fab_living_phase.h b/tests/fabric/fab_living_phase.h index 24041e89e..0bdb269b5 100644 --- a/tests/fabric/fab_living_phase.h +++ b/tests/fabric/fab_living_phase.h @@ -45,6 +45,12 @@ #ifndef FAB_LIVING_PHASE_H #define FAB_LIVING_PHASE_H +/* Lane 32: test-build only. The production program (docs/r16-production-entry-point.md) + * never compiles this; the build refuses it without -DAIEN_TEST_BUILD=1. */ +#ifndef AIEN_TEST_BUILD +#error "fab_living_phase.h (Fabric living test phase with fixed test keys) is test and simulation only: build with -DAIEN_TEST_BUILD=1, never in the production program" +#endif + #include "fabric/fab_dispatch.h" #include "fabric/fab_hmac.h" #include "fabric/fab_loopback.h" @@ -53,6 +59,11 @@ #include #include +/* Link-map marker (test build only): tools/r16_prod_hygiene.sh refuses any + * production binary that carries an aien_test_build_* symbol. */ +__attribute__((used)) static const char aien_test_build_fab_living_phase[] = + "AIEN_TEST_BUILD piece: Fabric living test phase (fixed test keys fl-key-*)"; + enum { FL_OP_REMOTE_ONLY = 2 }; enum { FL_SKILL_LOCAL = 7, FL_SKILL_REMOTE = 9, FL_SKILL_ONLY = 10 }; #define FL_MS 1000ull diff --git a/tests/fabric/fabric_living_test.c b/tests/fabric/fabric_living_test.c index 0e6ba9e15..0db42af5b 100644 --- a/tests/fabric/fabric_living_test.c +++ b/tests/fabric/fabric_living_test.c @@ -3,7 +3,8 @@ * (Lane 13). Runs the scenario of fab_living_phase.h on a composition that * owns its World and authority, twice in fresh directories, and requires * equal Cortex record and Fabric state digests (deterministic). - * The same scenario runs inside the R13 living World (rx_r13_living.c). + * The same scenario runs inside the R13 test-build variant (rx_r13_living.c + * built with -DAIEN_TEST_BUILD=1; the production program has no Fabric). * One worker, as the COMPOSITION-2 gate: with more, the candidates finish in * varying order and the record order (not its content) varies. * Prints FABRIC_LIVING_PASS on success. diff --git a/tests/runtime/rx_r13_living.c b/tests/runtime/rx_r13_living.c index 85d42c490..25511d49e 100644 --- a/tests/runtime/rx_r13_living.c +++ b/tests/runtime/rx_r13_living.c @@ -1,10 +1,24 @@ /* R13: one world; after the goal, only production requests and observation. */ #include "runtime/rx_living.h" #include "runtime/rx_resident_gpu.h" +#include "runtime/aien_machine_id.h" +/* Lane 32: two programs from this file (docs/r16-production-entry-point.md). + * PRODUCTION (default, no flag): no test pieces. ARGUS is linked and observes + * (RX_ARGUS=2, authority observer, consumer ingest), pinned by argus.lock; the + * composition and Fabric phases are reported NOT_RUN with their reason. + * TEST BUILD (-DAIEN_TEST_BUILD=1, test-r13-testbuild-*): adds the composition + * phase (rx_compose test hooks, host only) and the Fabric F5-0 phase (loopback + * transport, HMAC stand-in, fixed test keys); its gate line is + * R13_LIVING_SYSTEM_TEST_BUILD and it never claims R13_LIVING_SYSTEM. */ +#ifdef AIEN_TEST_BUILD #include "rx_compose_fixture.h" -/* Fabric F5-0 runs in both builds (Lane 17): the Fabric path is CPU-only - * loopback and links in the host and the silicon binary alike. */ #include "../fabric/fab_living_phase.h" +#else +#include "runtime/rx_argus.h" +#if RX_ARGUS != 2 || !defined(RX_ARGUS_AUTHORITY_OBSERVER) +#error "the production R13 program links ARGUS: build with -DRX_ARGUS=2 -DRX_ARGUS_AUTHORITY_OBSERVER (Makefile RX_PROD_ARGUS_FLAGS)" +#endif +#endif #include "omega_evidence.h" #include "sha256.h" @@ -222,10 +236,12 @@ static int start(Rig *r, int mode) { /* R16 C6: every production subject gets a runtime-issued credential, * then the world refuses any registration that does not present one. */ if (rx_living_enroll_callers(&r->w, &r->keys) != RX_OK) return -1; - /* The composition phases run inside this World (rx_compose_attach): the - * host runs the composition and the Fabric phase, silicon the Fabric - * phase. Their subjects are enrolled here, before enrollment closes. */ + /* Test build only: the composition and Fabric phases run inside this + * World (rx_compose_attach); their subjects are enrolled here, before + * enrollment closes. The production program enrolls no test subject. */ +#ifdef AIEN_TEST_BUILD if (rx_compose_enroll_callers(&r->w, &r->compose_keys) != RX_OK) return -1; +#endif if (rx_world_bind_callers(&r->w) != RX_OK) return -1; if (scratch_dir(r->generation_dir, sizeof r->generation_dir, "r13-living") != 0) return -1; if (scratch_dir(r->home_dir, sizeof r->home_dir, "r13-home") != 0 || living_identity(r) != 0) @@ -1145,7 +1161,9 @@ static void stop(Rig *r) { * closed composition's reactions stay registered but inert (their objects are * retired and their rights revoked); the composition subjects 200..204 are * fixed, so one composition per World. */ -#ifndef R13_SILICON +/* Test build only (Lane 32): it needs the AIEN_TEST_BUILD rogue-candidate hook + * and the test fixture (rx_compose_fixture.h). */ +#if defined(AIEN_TEST_BUILD) && !defined(R13_SILICON) typedef struct { int ran, ok; uint64_t result1, result2; @@ -1380,9 +1398,12 @@ out: return g->ok ? 0 : -1; } -#endif /* !R13_SILICON (composition phase) */ +#endif /* AIEN_TEST_BUILD && !R13_SILICON (composition phase) */ -/* Fabric F5-0 in the living World (Lane 13; both builds since Lane 17). A second simulated +#ifdef AIEN_TEST_BUILD +/* Fabric F5-0 in the living World (Lane 13; host and silicon TEST builds since + * Lane 17; test build only since Lane 32: loopback, HMAC stand-in and fixed + * test keys never enter the production program). A second simulated * machine joins over the loopback transport and advertises a Skill; the * composition attached to this World finds it in the Capability Graph as a * CQ_SRC_FABRIC candidate, runs it through the Fabric dispatcher (an @@ -1470,6 +1491,18 @@ static void fabric_json(char *out, size_t n) { U(g->dispatch_refused[FAB_DX_DIGEST]), g->fabric_held, rec, fab); } /* end Fabric phase */ +#else /* production program: no Fabric (no real transport before TRUST-1) */ +#ifdef R13_SILICON +#define FL_BUILD "silicon" +#else +#define FL_BUILD "host" +#endif +static void fabric_json(char *out, size_t n) { + snprintf(out, n, " \"fabric_host_phase\": {\"result\": \"NOT_RUN\", \"build\": \"" FL_BUILD "\", " + "\"reason\": \"production program: Fabric F5-0 has only the loopback transport and " + "HMAC stand-in (test build only, AIEN_TEST_BUILD); no real transport before TRUST-1\"},\n"); +} +#endif /* AIEN_TEST_BUILD (Fabric phase) */ static void binary_digest(char out[65]) { strcpy(out, "unavailable"); @@ -1487,12 +1520,11 @@ static void binary_digest(char out[65]) { } #define OBJ(o) (o).id, (o).generation - -/* The composition phase in the receipt (host only: it needs the -DRXC_TEST_HOOKS - * rogue-candidate hook, which the silicon binary does not carry), then the - * Fabric phase (both builds). */ +/* The composition phase in the receipt (host TEST build only: it needs the + * AIEN_TEST_BUILD rogue-candidate hook and the test fixture), then the Fabric + * phase (test builds only). */ static void composition_json(char *out, size_t n) { -#ifndef R13_SILICON +#if defined(AIEN_TEST_BUILD) && !defined(R13_SILICON) const CompositionReceipt *c = &g_comp; if (c->ran) { snprintf(out, n, @@ -1520,19 +1552,118 @@ static void composition_json(char *out, size_t n) { c->identity_refused ? "true" : "false", c->generation_untouched ? "true" : "false", c->inforce_untouched ? "true" : "false", c->promote_holders_ok ? "true" : "false"); } else { - snprintf(out, n, " \"composition_host_phase\": {\"result\": \"NOT_RUN\"},\n"); + snprintf(out, n, " \"composition_host_phase\": {\"result\": \"NOT_RUN\", " + "\"reason\": \"phase did not run (an earlier step failed)\"},\n"); } +#elif defined(AIEN_TEST_BUILD) + snprintf(out, n, " \"composition_host_phase\": {\"result\": \"NOT_RUN\", \"reason\": " + "\"silicon test build: the composition phase runs in the host test build only\"},\n"); #else - snprintf(out, n, " \"composition_host_phase\": {\"result\": \"NOT_RUN\"},\n"); + snprintf(out, n, " \"composition_host_phase\": {\"result\": \"NOT_RUN\", \"reason\": " + "\"production program: the composition phase needs the AIEN_TEST_BUILD rogue-candidate " + "hook and test fixture (test-r13-testbuild-host)\"},\n"); #endif - /* The Fabric phase runs in both builds (Lane 17). */ + /* Then the Fabric phase (NOT_RUN with its reason in the production program). */ size_t used = strlen(out); if (used < n) fabric_json(out + used, n - used); } +/* Which program this is (Lane 32). The test build has its own receipt and + * gate key, so it can never stand in for the production R13 gate. */ +#ifdef AIEN_TEST_BUILD +#define R13_RECEIPT "R13/rx_living_test_build_receipt.json" +#define R13_GATE_KEY "R13_LIVING_SYSTEM_TEST_BUILD" +#define R13_BUILD "test (AIEN_TEST_BUILD)" +static int g_argus_ok = 1; /* ARGUS is not linked into the test build */ +static char g_argus_json[512] = + " \"argus\": {\"result\": \"NOT_RUN\", \"reason\": \"test build: ARGUS is linked into " + "the production program only\"},\n"; +#else +#define R13_RECEIPT "R13/rx_living_receipt.json" +#define R13_GATE_KEY "R13_LIVING_SYSTEM" +#define R13_BUILD "production" +static int g_argus_ok; +static char g_argus_json[1024] = + " \"argus\": {\"result\": \"FAIL\", \"reason\": \"ARGUS was not checked\"},\n"; + +/* ARGUS in the production program (ARGUS-1 decisions, 2026-09-29): observe and + * record only. ARGUS (pinned by argus.lock) receives the runtime's capability + * events and the authority's own mint/revoke announcements, runs its + * detectors and keeps findings. It holds no capability, takes no action and + * never blocks a request, so it cannot expand its own authority; the one + * narrow automatic revoke the decisions allow is not in the pinned ARGUS. + * The program refuses to run unobserved: ARGUS must be active with its + * consumer ingesting (RX_ARGUS_AUTO=0 or RX_ARGUS_CONSUMER=off/discard make + * the gate FAIL). */ +static int argus_check_start(void) { + RxArgusStats s; + rx_argus_stats(&s); + if (rx_argus_active() && s.consumer_mode == RX_ARGUS_CONSUMER_INGEST) return 0; + snprintf(g_argus_json, sizeof g_argus_json, + " \"argus\": {\"result\": \"FAIL\", \"reason\": \"ARGUS not observing at start " + "(active %d, consumer mode %d; production needs ingest)\"},\n", + rx_argus_active(), s.consumer_mode); + fprintf(stderr, "R13 ARGUS: not observing at start (active %d, consumer mode %d); " + "the production program refuses to run unobserved\n", rx_argus_active(), s.consumer_mode); + return -1; +} + +/* After every World is stopped (producers quiescent): drain, stop the + * consumer, record what ARGUS saw. Findings are recorded, never acted on. */ +static void argus_finish(void) { + RxArgusStats s; + rx_argus_stats(&s); + int mode = s.consumer_mode; + rx_argus_shutdown(); + rx_argus_stats(&s); + uint64_t obs = 0; + for (unsigned k = 0; k < 9; k++) obs += s.authority_obs[k]; + g_argus_ok = mode == RX_ARGUS_CONSUMER_INGEST && s.received > 0 && obs > 0 && + s.ingest_errors == 0; + snprintf(g_argus_json, sizeof g_argus_json, + " \"argus\": {\"result\": \"%s\", \"mode\": \"observe and record (RX_ARGUS=2, " + "authority observer, consumer ingest); no response action, holds no capability\", " + "\"argus_lock\": \"argus.lock\", \"emitted\": %llu, \"received\": %llu, " + "\"authority_observations\": %llu, \"authority_mints\": %llu, " + "\"authority_revokes\": %llu, \"findings\": %llu, \"ingest_errors\": %llu, " + "\"ring_refused\": %llu},\n", + g_argus_ok ? "OBSERVED" : "FAIL", U(s.emitted), U(s.received), U(obs), + U(s.authority_obs[AIENOS_CAP_OBS_MINT]), U(s.authority_obs[AIENOS_CAP_OBS_REVOKE]), + U(s.findings_total), U(s.ingest_errors), U(s.ring_refused)); + printf("R13 ARGUS: %s; observe and record, received %llu events, %llu authority " + "observations, %llu findings, %llu ingest errors\n", + g_argus_ok ? "observing" : "FAIL", U(s.received), U(obs), U(s.findings_total), + U(s.ingest_errors)); + const char *p = getenv("RX_ARGUS_SUMMARY"); + if (p) rx_argus_write_summary(p, getenv("RX_ARGUS_SUITE") ? getenv("RX_ARGUS_SUITE") : "r13"); +} + +/* `--argus-probe`: the host-run check that ARGUS is present and observing in + * THIS binary (test-prod-hygiene; CI cannot run the living episode, which + * needs both Spark core classes). It starts one authority through the same + * link-wrapped aienos_cap_start the living run uses, makes one observed + * authority call, stops it and requires ARGUS to have received the events. + * It runs no living episode and writes no receipt. */ +static int argus_probe(void) { + if (argus_check_start() != 0) return 1; + AienosCapAdmin *admin = NULL; + AienosCapView *view = NULL; + AienosCapRef office; + if (aienos_cap_start(&admin, &view) != 0 || aienos_cap_office(admin, &office) != 0 || + aienos_cap_advance_clock(admin, office, 1) != 0) { + fprintf(stderr, "R13 ARGUS probe: authority start failed\n"); + return 1; + } + aienos_cap_stop(admin, view); + argus_finish(); + printf("R13 ARGUS probe: ARGUS_OBSERVING=%s\n", g_argus_ok ? "PASS" : "FAIL"); + return g_argus_ok ? 0 : 1; +} +#endif + static void receipt(int tests_ok) { char path[512], commit[41] = {0}, binary[65], physics[80] = {0}; - if (omega_evidence_path("R13/rx_living_receipt.json", path, sizeof path) != 0) + if (omega_evidence_path(R13_RECEIPT, path, sizeof path) != 0) return; if (!omega_evidence_run_commit(commit)) strcpy(commit, "unknown"); if (!omega_evidence_physics_commit(physics, sizeof physics)) @@ -1545,9 +1676,9 @@ static void receipt(int tests_ok) { int controls = 1; for (uint32_t i = 0; i < 5; i++) controls &= g_controls[i]; const Receipt *g = &g_receipt; - int pass = tests_ok && controls && bound && g->silicon_observed; + int pass = tests_ok && controls && g_argus_ok && bound && g->silicon_observed; const char *gate = pass ? "PASS" - : !tests_ok || !controls ? "FAIL" + : !tests_ok || !controls || !g_argus_ok ? "FAIL" : !g->silicon_observed ? "HOST_PASS_NON_SILICON" : "SILICON_PASS_UNBOUND"; struct utsname host; @@ -1555,6 +1686,9 @@ static void receipt(int tests_ok) { uname(&host); char comp[6144]; composition_json(comp, sizeof comp); + size_t used = strlen(comp); + if (used < sizeof comp) + snprintf(comp + used, sizeof comp - used, " \"build\": \"" R13_BUILD "\",\n%s", g_argus_json); FILE *f = fopen(path, "w"); if (!f) return; fprintf(f, @@ -1571,7 +1705,7 @@ static void receipt(int tests_ok) { " \"machine_identity\": {\"node\": \"%s\", \"system\": \"%s\", " "\"release\": \"%s\", \"architecture\": \"%s\"},\n" " \"silicon_observed\": %s,\n" - " \"gate\": {\"R13_LIVING_SYSTEM\": \"%s\"},\n" + " \"gate\": {\"" R13_GATE_KEY "\": \"%s\"},\n" " \"scenario\": {\"operation\": \"omega integer matvec 64x256\", " "\"goal\": \"cost below %u%% of the confirmed incumbent, semantics preserved\", " "\"incumbent_ns\": %llu, \"target_ns\": %llu, " @@ -1664,14 +1798,28 @@ static void receipt(int tests_ok) { g_controls[2] ? "PASS" : "FAIL", g_controls[3] ? "PASS" : "FAIL", g_controls[4] ? "PASS" : "FAIL", comp); fclose(f); - printf("R13 gate: R13_LIVING_SYSTEM=%s\nR13 receipt: %s\n", gate, path); + printf("R13 gate: " R13_GATE_KEY "=%s\nR13 receipt: %s\n", gate, path); } -int main(void) { +int main(int argc, char **argv) { signal(SIGPIPE, SIG_IGN); setvbuf(stdout, NULL, _IONBF, 0); +#ifndef AIEN_TEST_BUILD + if (argc == 2 && strcmp(argv[1], "--argus-probe") == 0) return argus_probe(); +#endif + if (argc != 1) { + fprintf(stderr, "usage: %s [--argus-probe (production program only)]\n", argv[0]); + return 2; + } if (seen_fit(1u << 17) != 0) return 1; int result = 0; +#ifndef AIEN_TEST_BUILD + /* Production: ARGUS observes from the first authority on, or nothing runs. */ + if (argus_check_start() != 0) { + receipt(0); + return 1; + } +#endif static const char *names[] = {"positive", "A no AIEN", "B no promotion authority", "C revoked experiment", "D stale generation", "E failed verification"}; for (int mode = POSITIVE; mode <= FAILED_VERIFICATION; mode++) { @@ -1680,13 +1828,15 @@ int main(void) { int rc = start(r, mode); if (rc != 0) fprintf(stderr, "R13 %s: setup failed at stage %d\n", names[mode], g_stage); if (rc == 0) rc = run(r, mode); -#ifndef R13_SILICON - /* COMPOSITION-2 in the living system: host phase, after the episode, +#if defined(AIEN_TEST_BUILD) && !defined(R13_SILICON) + /* COMPOSITION-2 in the living system (host test build only), after the episode, * while the living World and its authority are still up. */ if (rc == 0 && mode == POSITIVE) rc = composition_phase(r); #endif - /* Fabric F5-0: both builds (Lane 17). */ +#ifdef AIEN_TEST_BUILD + /* Fabric F5-0: host and silicon test builds (Lane 17, Lane 32). */ if (rc == 0 && mode == POSITIVE) rc = fabric_phase(r); +#endif if (rc != 0) fprintf(stderr, "R13 %s FAILED: plan %llu search %llu GPU %llu evidence %llu " "belief %llu selection %llu candidate %llu promotion %llu in force %llu " @@ -1701,6 +1851,9 @@ int main(void) { free(r); if (rc != 0) { result = 1; break; } } +#ifndef AIEN_TEST_BUILD + argus_finish(); /* every World is stopped: producers are quiescent */ +#endif receipt(result == 0); free(g_seen); free(g_stack); diff --git a/tools/r16_authpath.sh b/tools/r16_authpath.sh index 4432d4b0b..b3b80c91a 100755 --- a/tools/r16_authpath.sh +++ b/tools/r16_authpath.sh @@ -14,6 +14,9 @@ # symbol (omegatool legacy_oracle / demonstration / gate runners, the SEQ # pulse loop, run_until_complete, Rust-mangled or aegis/sovereign names), # and neither needs a shared library beyond the C runtime. +# 2b. (Lane 32) the R13 binary is the PRODUCTION program: no test-build +# piece (AIEN_TEST_BUILD markers, Fabric loopback/HMAC stand-in, fixed +# test keys, composition hooks) and ARGUS linked (tools/r16_prod_hygiene.sh). # 3. no legacy program name is embedded in either binary as a string. # 4. exec tracing: each binary runs under strace (execve only, seccomp # filter, so nothing else is slowed) with stub programs named after the @@ -47,6 +50,11 @@ note() { echo "R16-G3 $*"; } # 1. sources ----------------------------------------------------------------- printf '%s\n' "$@" > "$out/sources.txt" +# Lane 32: the production program links ARGUS, extracted at the argus.lock +# commit into $(OUT_DIR)/argus-src//native/argus (Makefile ARGUS block). +argus_short=$(head -n 1 argus.lock 2>/dev/null | cut -c1-7) +[ -n "$argus_short" ] || fail "argus.lock is missing or empty" +argus_dir="*/argus-src/$argus_short/native/argus" for s in "$@"; do case "$s" in tools/omegatool.c|*/omegatool.c) fail "source list links omegatool: $s" ;; @@ -55,13 +63,17 @@ for s in "$@"; do src/*.c|src/runtime/*.c|tests/runtime/*.c) ;; *libaienos_capability.a) ;; */m16/m16_native.c|*/nvrm/nvrm.c) [ "$mode" = silicon ] || fail "physical seat source in a host build: $s" ;; + $argus_dir/argus_*.c) ;; # ARGUS pinned by argus.lock (git archive extract; pattern unquoted on purpose) *) fail "source outside omega src/ and tests/runtime/: $s" ;; esac done -note "sources: $# files, omega and the native AIENOS capability library only" +note "sources: $# files, omega, the native AIENOS capability library and ARGUS pinned by argus.lock only" # 2. link map ---------------------------------------------------------------- -legacy_sym='legacy_oracle|run_demonstration|omega_run_m[0-9]+_gates|omega_run_m4_gates|rx_seq_pulse|rx_seq_run_until_complete|run_until_complete|^_ZN|^_R[a-zA-Z0-9]|rust_|__rust|aegis_runtime|spark_aegis|sovereign|aien_runtime_spine|AienRuntimeSpine' +# Rust runtime symbols are rust_* or __rust_*, so "rust_" is matched only at a +# word start: a substring match also hit ARGUS trust symbols (det_trust_escalation, +# trust_rank_tab), which are C. Mangled Rust (_ZN, _R...) is still refused. +legacy_sym='legacy_oracle|run_demonstration|omega_run_m[0-9]+_gates|omega_run_m4_gates|rx_seq_pulse|rx_seq_run_until_complete|run_until_complete|^_ZN|^_R[a-zA-Z0-9]|(^|_)rust_|__rust|aegis_runtime|spark_aegis|sovereign|aien_runtime_spine|AienRuntimeSpine' for b in "$r13" "$r14"; do [ -x "$b" ] || fail "binary missing: $b" n=$(basename "$b") @@ -78,6 +90,13 @@ for b in "$r13" "$r14"; do note "link map $n: no legacy orchestrator symbol; C runtime libraries only; SEQ world hooks present (reference, refused on production worlds): $(wc -l < "$out/$n.reference-hooks")" done +# 2b. production program (Lane 32): the R13 binary must be the production +# program, not the AIEN_TEST_BUILD variant: no test piece in its link map or +# strings, ARGUS linked (tools/r16_prod_hygiene.sh, static part only here). +R16_PROD_NO_RUN=1 sh tools/r16_prod_hygiene.sh "$mode" "$r13" > "$out/prod-hygiene.out" 2>&1 \ + || fail "the R13 binary is not the production program: $(grep -E 'FAIL' "$out/prod-hygiene.out" | head -3 | tr '\n' ' ')" +note "production program: $(grep -E '^R16 prod: ' "$out/prod-hygiene.out" | head -1 | sed 's/^R16 prod: //')" + # 3. embedded program names ---------------------------------------------------- legacy_exe='spark-aegis|aegis-runtime|aien-cli|aien-runtime|aien-server|spark-dream|sovereign-core|omegatool' for b in "$r13" "$r14"; do @@ -139,7 +158,8 @@ else r14_want='R14 gate: R14_LIVING_RECOVERY=PASS' fi run_traced "$r13" r13 "$r13_want" -grep -E '^R13 (gate|costs|control E episode):' "$out/r13.out" | sed 's/^/R16-G3 /' +grep -E '^R13 (gate|costs|control E episode|ARGUS):' "$out/r13.out" | sed 's/^/R16-G3 /' +grep -q '^R13 ARGUS: observing' "$out/r13.out" || fail "R13 did not report ARGUS observing" run_traced "$r14" r14 "$r14_want" grep -E '^R14 [A-F]_[a-z_]+ +(PASS|FAIL)|^R14 gate:' "$out/r14.out" | sed 's/^/R16-G3 /' if grep -E '^R14 [A-F]_[a-z_]+ +FAIL' "$out/r14.out" > /dev/null; then diff --git a/tools/r16_prod_hygiene.sh b/tools/r16_prod_hygiene.sh new file mode 100755 index 000000000..9d53d5122 --- /dev/null +++ b/tools/r16_prod_hygiene.sh @@ -0,0 +1,69 @@ +#!/bin/sh +# Lane 32: production program hygiene (docs/r16-production-entry-point.md). +# +# Usage: tools/r16_prod_hygiene.sh host|silicon +# R16_PROD_NO_RUN=1: static checks only (link map and strings); the ARGUS +# probe is not run (used by tools/r16_authpath.sh check 2b). +# +# Checks, stopping at the first failure: +# 1. link map: no test-build piece. No aien_test_build_* marker (Fabric +# loopback transport, HMAC stand-in, in-process dispatcher, Fabric living +# phase, rx_compose test hooks), no Fabric symbol (fab_*), no Fabric +# living phase (fl_*) and no composition test fixture (fx_*). +# 2. strings: no fixed test key (fl-key-*) and no test-build marker text. +# 3. ARGUS linked: the runtime producer (rx_argus_*), the authority observer +# wrap (__wrap_aienos_cap_start) and the pinned argus_core/argus_detect. +# 4. host run (unless R16_PROD_NO_RUN=1): ` --argus-probe` starts one +# authority through the wrapped aienos_cap_start and must report +# ARGUS_OBSERVING=PASS; with RX_ARGUS_AUTO=0 (ARGUS not started) the same +# binary must refuse to run (fail closed). The probe runs no living +# episode and never starts the graphics processor. +set -u +mode=${1:-}; bin=${2:-} +if [ $# -ne 2 ] || { [ "$mode" != host ] && [ "$mode" != silicon ]; }; then + echo "usage: $0 host|silicon " >&2 + exit 2 +fi +fail() { echo "R16 prod FAIL: $*"; echo "R16 prod: PROD_HYGIENE=FAIL mode=$mode"; exit 1; } +[ -x "$bin" ] || fail "binary missing: $bin" +n=$(basename "$bin") +tmp=$(mktemp -d) || exit 2 +trap 'rm -rf "$tmp"' EXIT + +# 1. link map ------------------------------------------------------------------ +nm "$bin" > "$tmp/nm" 2>&1 || fail "nm failed on $bin" +awk '{print $NF}' "$tmp/nm" > "$tmp/syms" +grep -qx 'main' "$tmp/syms" || fail "$n has no symbol table (stripped?); cannot check its link map" +if grep -E '^(aien_test_build_|fab_|fl_|fx_)' "$tmp/syms" > "$tmp/bad-syms"; then + fail "$n links test-build pieces: $(head -5 "$tmp/bad-syms" | tr '\n' ' ')" +fi + +# 2. strings ------------------------------------------------------------------- +if strings -a "$bin" | grep -E 'fl-key-|AIEN_TEST_BUILD piece:' > "$tmp/bad-strings"; then + fail "$n embeds test keys or test-build pieces: $(head -3 "$tmp/bad-strings" | tr '\n' ' ')" +fi + +# 3. ARGUS linked ---------------------------------------------------------------- +for s in rx_argus_active rx_argus_shutdown rx_argus_stats __wrap_aienos_cap_start \ + argus_core_init argus_core_ingest argus_detect_run; do + grep -qx "$s" "$tmp/syms" || fail "$n does not link ARGUS ($s missing)" +done +printf 'link map clean, ARGUS linked (rx_argus, authority observer wrap, argus_core, argus_detect)' > "$tmp/summary" + +# 4. host run of the ARGUS probe --------------------------------------------------- +if [ "${R16_PROD_NO_RUN:-0}" != 1 ]; then + env -u RX_ARGUS_AUTO -u RX_ARGUS_CONSUMER -u RX_ARGUS_STREAM -u RX_ARGUS_SUMMARY \ + "$bin" --argus-probe > "$tmp/probe.out" 2>&1 + rc=$? + sed 's/^/R16 prod /' "$tmp/probe.out" + [ $rc -eq 0 ] && grep -q '^R13 ARGUS probe: ARGUS_OBSERVING=PASS$' "$tmp/probe.out" \ + || fail "ARGUS probe did not observe (exit $rc)" + RX_ARGUS_AUTO=0 "$bin" --argus-probe > "$tmp/probe-off.out" 2>&1 + rc=$? + if [ $rc -eq 0 ] || grep -q 'ARGUS_OBSERVING=PASS' "$tmp/probe-off.out"; then + fail "with ARGUS not started the program still ran (exit $rc): it must refuse to run unobserved" + fi + printf '; ARGUS probe observing; refuses to run unobserved' >> "$tmp/summary" +fi +echo "R16 prod: $(cat "$tmp/summary")" +echo "R16 prod: PROD_HYGIENE=PASS mode=$mode binary=$n" diff --git a/tools/r16_prod_refuses.sh b/tools/r16_prod_refuses.sh new file mode 100755 index 000000000..4111b4fe1 --- /dev/null +++ b/tools/r16_prod_refuses.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# Lane 32: negative build test. The production program must REFUSE, at build +# time, every test-only piece (docs/r16-production-entry-point.md). Each case +# compiles with the production flags (no AIEN_TEST_BUILD) and must FAIL with +# its guard's message; three controls must SUCCEED, so a failure is the guard, +# not a broken setup. Run by `make test-prod-refuses-test-pieces` (rx-host CI). +# +# Environment (set by the Makefile): CC, CFLAGS, ARGUS_SRC, OUT, MAKE, PROD_BIN. +set -u +: "${CC:=cc}" "${PROD_BIN:?}" "${CFLAGS?}" "${ARGUS_SRC:?}" "${OUT:?}" "${MAKE:=make}" +mkdir -p "$OUT" || exit 2 +INC="-Isrc -Itests/runtime -Itests/fabric -Isrc/runtime -Isrc/fabric" +ARGUSF="-DRX_ARGUS=2 -DRX_ARGUS_AUTHORITY_OBSERVER -I$ARGUS_SRC" +PROD="$ARGUSF $INC" +bad=0; n=0 +expect_fail() { # tag message-regex compile-args... + tag=$1; want=$2; shift 2; n=$((n + 1)) + # shellcheck disable=SC2086 + if $CC $CFLAGS $PROD "$@" -c -o "$OUT/$tag.o" > "$OUT/$tag.log" 2>&1; then + echo "R16 refuse FAIL: $tag compiled in the production build (it must not)"; bad=1 + elif grep -Eq "$want" "$OUT/$tag.log"; then + echo "R16 refuse: $tag refused at build time ($(grep -Eo "$want" "$OUT/$tag.log" | head -1))" + else + echo "R16 refuse FAIL: $tag failed to compile, but not on its guard ($want):" + head -5 "$OUT/$tag.log"; bad=1 + fi +} +expect_ok() { # tag compile-args... + tag=$1; shift; n=$((n + 1)) + # shellcheck disable=SC2086 + if $CC $CFLAGS "$@" -c -o "$OUT/$tag.o" > "$OUT/$tag.log" 2>&1; then + echo "R16 refuse: control $tag compiles" + else + echo "R16 refuse FAIL: control $tag does not compile:"; head -5 "$OUT/$tag.log"; bad=1 + fi +} + +guard='test and simulation only: build with -DAIEN_TEST_BUILD=1' +expect_fail fab_loopback "$guard" src/fabric/fab_loopback.c +expect_fail fab_hmac "$guard" src/fabric/fab_hmac.c +expect_fail fab_dispatch "$guard" src/fabric/fab_dispatch.c +printf '#include "fab_living_phase.h"\nint main(void) { return 0; }\n' > "$OUT/living_phase.c" +expect_fail fab_living_phase "$guard" "$OUT/living_phase.c" +expect_fail rxc_test_hooks 'RXC_TEST_HOOKS .*needs -DAIEN_TEST_BUILD=1' -DRXC_TEST_HOOKS src/runtime/rx_compose.c +# ARGUS flags left out: the production R13 source refuses to build. +n=$((n + 1)); tag=r13_without_argus +# shellcheck disable=SC2086 +if $CC $CFLAGS $INC tests/runtime/rx_r13_living.c -c -o "$OUT/$tag.o" > "$OUT/$tag.log" 2>&1; then + echo "R16 refuse FAIL: $tag compiled without ARGUS (it must not)"; bad=1 +elif grep -q "production R13 program links ARGUS" "$OUT/$tag.log"; then + echo "R16 refuse: $tag refused at build time (production R13 program links ARGUS)" +else + echo "R16 refuse FAIL: $tag failed, but not on its guard:"; head -5 "$OUT/$tag.log"; bad=1 +fi +# Controls: the production R13 source and rx_compose.c compile in the +# production build; the Fabric loopback compiles in the test build. +expect_ok r13_production $PROD tests/runtime/rx_r13_living.c +expect_ok rx_compose_production $PROD src/runtime/rx_compose.c +expect_ok fab_loopback_testbuild -DAIEN_TEST_BUILD=1 -Isrc -Isrc/runtime -Isrc/fabric src/fabric/fab_loopback.c + +# The Makefile refuses the flag in CFLAGS for the production binaries. Dry run +# (-n), only the production binary considered out of date (-W on its main +# source; the Makefile target builds it first, so no prerequisite is remade). +n=$((n + 1)) +if $MAKE --no-print-directory -n -W tests/runtime/rx_r13_living.c "CFLAGS=$CFLAGS -DAIEN_TEST_BUILD=1" "$PROD_BIN" \ + > "$OUT/make_flag.log" 2>&1; then + echo "R16 refuse FAIL: make accepted AIEN_TEST_BUILD in CFLAGS for the production program"; bad=1 +elif grep -q 'the production program never builds with AIEN_TEST_BUILD' "$OUT/make_flag.log"; then + echo "R16 refuse: make refuses AIEN_TEST_BUILD in CFLAGS for the production program" +else + echo "R16 refuse FAIL: make failed, but not on the production guard:"; head -5 "$OUT/make_flag.log"; bad=1 +fi + +if [ $bad -ne 0 ]; then + echo "R16 prod: PROD_REFUSES_TEST_PIECES=FAIL ($n cases)"; exit 1 +fi +echo "R16 prod: PROD_REFUSES_TEST_PIECES=PASS ($n cases: 6 refusals, 3 controls, 1 make guard)"