From d3179fff37ce11ba8ec6a9ab92404bd5e025044c Mon Sep 17 00:00:00 2001 From: Jon Chery Date: Sat, 1 Aug 2026 12:36:40 +0000 Subject: [PATCH] =?UTF-8?q?verify(P6):=20run-platform-deadcode-and-hitl-fn?= =?UTF-8?q?=20=E2=80=94=204-layer=20verify=20PASS=20+=20ship?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VERIFY: structural — HITL fn extracted + deadcode/config; behavioral — syntax clean + CI PASS; quality — ~14 lines saved. ---ci--- project: acdl phase: 6 milestone: v1.16 status: complete phase_role: execution requirements: covered: [REQ-170] partial: [] ---/ci--- --- scripts/run_platform.sh | 88 +++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/scripts/run_platform.sh b/scripts/run_platform.sh index fd83e5c..ed69010 100755 --- a/scripts/run_platform.sh +++ b/scripts/run_platform.sh @@ -113,6 +113,38 @@ fi fail() { echo "FAIL: $*" >&2; exit 1; } +# run_hitl_gate +# REQ-108: for qa/prod/dr, call hitl_gates.attest before apply. Dev skips. +# Extracted from the two duplicated inline blocks (P6, REQ-170). +run_hitl_gate() { + local _cid="$1" _env="$2" _ctx="$3" + if [ "$_env" = "dev" ]; then + echo "Environment is $_env — autonomous (no HITL gate)." + return 0 + fi + echo "Environment is $_env — HITL attestation gate required$_ctx." + local _approver="${GITHUB_ACTOR:-${GITEA_ACTOR:-}}" + if [ -z "$_approver" ]; then + echo "WARNING: no approver identity (GITHUB_ACTOR/GITEA_ACTOR unset)" >&2 + echo " the gate would block in a real CI run. Passing for local." >&2 + fi + python3 -c " +import os, sys +sys.path.insert(0, '.') +from core.hitl_gates import attest +from core import env as _envhelper +contract_id = _envhelper.get_env('HITL_CONTRACT_ID') or os.environ['NOVA_HITL_CONTRACT_ID'] +env = _envhelper.get_env('HITL_ENV') or os.environ['NOVA_HITL_ENV'] +approver = _envhelper.get_env('HITL_APPROVER', '') or 'local-test' +ok, reason = attest(contract_id, env, approver) +if ok: + print(f'HITL PASS: {reason}') +else: + print(f'HITL BLOCK: {reason}', file=sys.stderr) + sys.exit(1) +" NOVA_HITL_CONTRACT_ID="$_cid" NOVA_HITL_ENV="$_env" NOVA_HITL_APPROVER="$_approver" +} + # --local: run the headline E2E against the local emulating tier (D-092). # No AWS credentials, no Checkov, no DynamoDB. Emulates ECS, outbox, S3 # state, and the contract-ingestor Lambda in-process. Exits 0 on success. @@ -142,8 +174,8 @@ stream() { fi } -CONTRACT_ID="11111111-1111-1111-1111-111111111111" # spike fixed UUID -WORK="/tmp/acdl_platform_run_v18" +CONTRACT_ID="${NOVA_CONTRACT_ID:-11111111-1111-1111-1111-111111111111}" # spike UUID (override via NOVA_CONTRACT_ID) +WORK="${NOVA_WORK_DIR:-/tmp/nova_platform_run}" TF_DIR="$WORK/tf" rm -rf "$WORK"; mkdir -p "$TF_DIR" @@ -325,31 +357,7 @@ if [ "$APPLY_ONLY" = "1" ]; then if [ -n "$ENVIRONMENT_OVERRIDE" ]; then RESOLVED_ENV="$ENVIRONMENT_OVERRIDE" fi - if [ "$RESOLVED_ENV" != "dev" ]; then - echo "Environment is $RESOLVED_ENV — HITL attestation gate required before apply." - APPROVER="${GITHUB_ACTOR:-${GITEA_ACTOR:-}}" - if [ -z "$APPROVER" ]; then - echo "WARNING: no approver identity (GITHUB_ACTOR/GITEA_ACTOR unset)" >&2 - echo " the gate would block in a real CI run. Passing for local." >&2 - fi - python3 -c " -import os, sys -sys.path.insert(0, '.') -from core.hitl_gates import attest -from core import env as _envhelper -contract_id = _envhelper.get_env('HITL_CONTRACT_ID') or os.environ['NOVA_HITL_CONTRACT_ID'] -env = _envhelper.get_env('HITL_ENV') or os.environ['NOVA_HITL_ENV'] -approver = _envhelper.get_env('HITL_APPROVER', '') or 'local-test' -ok, reason = attest(contract_id, env, approver) -if ok: - print(f'HITL PASS: {reason}') -else: - print(f'HITL BLOCK: {reason}', file=sys.stderr) - sys.exit(1) -" NOVA_HITL_CONTRACT_ID="$CONTRACT_ID" NOVA_HITL_ENV="$RESOLVED_ENV" NOVA_HITL_APPROVER="$APPROVER" || { echo "FAIL: HITL attestation gate blocked the apply" >&2; exit 1; } - else - echo "Environment is dev — autonomous (no HITL gate)." - fi + run_hitl_gate "$CONTRACT_ID" "$RESOLVED_ENV" " before apply" || { echo "FAIL: HITL attestation gate blocked the apply" >&2; exit 1; } echo "" echo "=== Step 5: terraform apply -auto-approve ===" @@ -441,31 +449,7 @@ RESOLVED_ENV=$(python3 -c "import yaml; print(yaml.safe_load(open('$CONTRACT')). if [ -n "$ENVIRONMENT_OVERRIDE" ]; then RESOLVED_ENV="$ENVIRONMENT_OVERRIDE" fi -if [ "$RESOLVED_ENV" != "dev" ]; then - echo "Environment is $RESOLVED_ENV — HITL attestation gate required." - APPROVER="${GITHUB_ACTOR:-${GITEA_ACTOR:-}}" - if [ -z "$APPROVER" ]; then - echo "WARNING: no approver identity (GITHUB_ACTOR/GITEA_ACTOR unset); " >&2 - echo " the gate would block in a real CI run. Passing for local." >&2 - fi - python3 -c " -import os, sys -sys.path.insert(0, '.') -from core.hitl_gates import attest -from core import env as _envhelper -contract_id = _envhelper.get_env('HITL_CONTRACT_ID') or os.environ['NOVA_HITL_CONTRACT_ID'] -env = _envhelper.get_env('HITL_ENV') or os.environ['NOVA_HITL_ENV'] -approver = _envhelper.get_env('HITL_APPROVER', '') or 'local-test' -ok, reason = attest(contract_id, env, approver) -if ok: - print(f'HITL PASS: {reason}') -else: - print(f'HITL BLOCK: {reason}', file=sys.stderr) - sys.exit(1) -" NOVA_HITL_CONTRACT_ID="$CONTRACT_ID" NOVA_HITL_ENV="$RESOLVED_ENV" NOVA_HITL_APPROVER="$APPROVER" || { echo "FAIL: HITL attestation gate blocked the promotion" >&2; exit 1; } -else - echo "Environment is dev — autonomous (no HITL gate)." -fi +run_hitl_gate "$CONTRACT_ID" "$RESOLVED_ENV" "" || { echo "FAIL: HITL attestation gate blocked the promotion" >&2; exit 1; } echo "" echo "=== Step 8: write evidence event to DynamoDB outbox ==="