Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
59a3778
feat(ring-69): extract tri-core/hunt/exp/canon/ledger as public crates
Apr 28, 2026
dbc5ec8
feat(ring-69): add seed policy DB lock + smoke-first experiments (E.2…
Apr 28, 2026
2ce08b4
feat(ring-69): add golden float family experiments + champion exact r…
Apr 28, 2026
9fd0b13
feat(ring-69): phase e.gf golden float sweep - 20 experiments enqueued
Apr 28, 2026
2166fa8
chore(ring-69): cleanup duplicate experiments (IDs 114, 115 removed)
Apr 28, 2026
95d40aa
chore(ring-69): skip duplicate constraint fix - deploy correct experi…
Apr 28, 2026
71e094e
feat(mcp): multi-account token routing + batch-deploy + snapshot auth…
Apr 28, 2026
23f1535
feat(ring-69): phase e.gf v2 - 18-service format comparison
Apr 28, 2026
fb72f06
wip(ring-69): fixes for GF8/32/64 benchmark + compilation fixes
Apr 28, 2026
29f21bf
feat(mcp): add fleet_health + seed_list tools for multi-account monit…
Apr 28, 2026
40cc64b
fix(zig-69): update format_benchmark for GF8/GF32/GF64
Apr 28, 2026
8a55d7c
chore(release): tag v0.0.1-mcp + 80 new experiments seeded
Apr 28, 2026
cc9d183
feat(mcp): add experiment_queue_status, worker_status, service_batch_…
Apr 28, 2026
04ac1a2
fix(mcp): move new tools into #[tool_router] impl block
Apr 28, 2026
209bd09
fix(mcp): use tokio-postgres-rustls for Neon TLS connection
Apr 28, 2026
009b1c5
fix(mcp): strip unsupported libpq params from Neon URL + add 10s conn…
Apr 28, 2026
3eaaaef
fix(mcp): install rustls aws-lc-rs crypto provider for Neon TLS
Apr 28, 2026
aebcb83
feat(bench): add MLP inference test with Gaussian weights
Apr 28, 2026
0a5d1aa
fix(bench): fix RNG overflow + add uniform range test
Apr 28, 2026
d566200
docs: deep investigation improvement plan for trios-railway-mcp
Apr 28, 2026
c1e3d9e
feat(mcp): add legacy SSE transport alongside Streamable HTTP
Apr 29, 2026
c08762b
feat(mcp): extend account support to ACC0-ACC7, add project 475a2290 …
May 1, 2026
f4d3f20
refactor(mcp): load ALLOWED_PROJECT_IDS from env var, fix whitelist, …
May 1, 2026
d2b9b34
fix(mcp): update SQL table names after migration 0004 rename
May 1, 2026
3fa3e22
fix(mcp): multi-account dispatch for redeploy/delete + jsonb cast for…
May 1, 2026
15481b5
fix(mcp): proper jsonb serialization for experiment_queue_insert
May 1, 2026
175557d
chore: update Cargo.lock for postgres-types with-serde_json-1 feature
May 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
.DS_Store
artifacts/
.trinity/experience/*.trinity
node_modules
.env
.env.*
14 changes: 14 additions & 0 deletions .swarm/model-router-state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"totalDecisions": 1,
"modelDistribution": {
"haiku": 0,
"sonnet": 0,
"opus": 1,
"inherit": 0
},
"avgComplexity": 0.3491,
"avgConfidence": 0.5667897877176604,
"circuitBreakerTrips": 0,
"lastUpdated": "2026-04-28T13:22:07.583Z",
"learningHistory": []
}
44 changes: 44 additions & 0 deletions .trinity/experience/trios_railway_20260428.trinity
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{"ts":"2026-04-28T13:59:15.785975+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10001 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=f3350520 service=0ea4bae6 sha=ffeab10fa390cdb9 ts=2026-04-28T13:59:15.785966+00:00"}
{"ts":"2026-04-28T14:00:45.339793+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10002 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=f3350520 service=a1cc0d19 sha=0087cc47da964143 ts=2026-04-28T14:00:45.339782+00:00"}
{"ts":"2026-04-28T14:00:58.339816+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10005 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=f3350520 service=e089a9ef sha=20d579d201eb2f33 ts=2026-04-28T14:00:58.334833+00:00"}
{"ts":"2026-04-28T14:01:01.300041+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10004 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=f3350520 service=fed11150 sha=be68cbec7a8bd7d0 ts=2026-04-28T14:01:01.300033+00:00"}
{"ts":"2026-04-28T14:01:04.501230+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10003 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=f3350520 service=107ce4a1 sha=a90d4d2cd2edc5e4 ts=2026-04-28T14:01:04.500749+00:00"}
{"ts":"2026-04-28T14:02:38.266221+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10007 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=f3350520 service=12a7264d sha=b8335e7766dd9d80 ts=2026-04-28T14:02:38.266204+00:00"}
{"ts":"2026-04-28T14:02:40.434357+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10010 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=f3350520 service=93dc7905 sha=9237d8954d63bfdd ts=2026-04-28T14:02:40.434356+00:00"}
{"ts":"2026-04-28T14:02:41.686106+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10006 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=f3350520 service=2dccf15c sha=6454c3d8aea6c60c ts=2026-04-28T14:02:41.685935+00:00"}
{"ts":"2026-04-28T14:02:44.647024+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10008 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=f3350520 service=3cea78f1 sha=2cac57e099c149cd ts=2026-04-28T14:02:44.647019+00:00"}
{"ts":"2026-04-28T14:02:45.301646+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10009 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=f3350520 service=7da9712c sha=6091d12e32c9e206 ts=2026-04-28T14:02:45.301465+00:00"}
{"ts":"2026-04-28T14:12:45.331399+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10001 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=da1fb0c7 service=6b834e57 sha=791b987efdfb196c ts=2026-04-28T14:12:45.331383+00:00"}
{"ts":"2026-04-28T14:13:44.708989+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10005 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=da1fb0c7 service=2b674f13 sha=b0455f77937a2288 ts=2026-04-28T14:13:44.708974+00:00"}
{"ts":"2026-04-28T14:13:52.987466+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10009 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=da1fb0c7 service=7a24f811 sha=78b2a8c72029d12c ts=2026-04-28T14:13:52.987435+00:00"}
{"ts":"2026-04-28T14:45:38.098704+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#5","task":"deploy igla-gf-seed10001-v2 image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=da1fb0c7 service=5c6feec3 sha=c6c999c800ad6cca ts=2026-04-28T14:45:38.098694+00:00"}
{"ts":"2026-04-28T17:11:54.619735+00:00","agent":"GENERAL","soul_name":"RailRangerOne","issue":"#81","task":"deploy trios-railway-mcp image=ghcr.io/ghashtag/trios-trainer-igla:latest","status":"OK","phi_step":"PUSH","triplet":"RAIL=deploy @ project=e4fe33bb service=db786a4b sha=f4dfdaaa8d6b68ef ts=2026-04-28T17:11:54.619657+00:00"}
{"ts":"2026-04-28T19:16:53.350965+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-e1-champion-reproduce image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=3","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=8ab06401 service=78c220c9 sha=2a52151b45c81736 ts=2026-04-28T19:16:53.350935+00:00"}
{"ts":"2026-04-28T19:16:57.737376+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-e6-hybrid-001-test image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=3","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=8ab06401 service=cb47a5fb sha=60f0f2cb03d1db15 ts=2026-04-28T19:16:57.737372+00:00"}
{"ts":"2026-04-28T19:16:59.371093+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-44-e3-quorum-seed44 image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=3","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=8ab06401 service=f1e2e1b8 sha=ab755366a495b68e ts=2026-04-28T19:16:59.371088+00:00"}
{"ts":"2026-04-28T19:17:00.244950+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-43-e2-quorum-seed43 image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=3","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=8ab06401 service=4298bb84 sha=2c415f5d53ec6907 ts=2026-04-28T19:17:00.244941+00:00"}
{"ts":"2026-04-28T19:17:58.529215+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-e4-capacity-push-h1536 image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=3","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=8ab06401 service=49c2809e sha=ecbcf7b898af0207 ts=2026-04-28T19:17:58.529207+00:00"}
{"ts":"2026-04-28T19:18:04.988072+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-e5-gf16-storage-test image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=3","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=8ab06401 service=e864e380 sha=47e02ef323406ef6 ts=2026-04-28T19:18:04.988062+00:00"}
{"ts":"2026-04-28T19:18:06.435117+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-e7-lr-phi-optimal image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=3","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=8ab06401 service=fb85dca3 sha=1b3d39663353d0b5 ts=2026-04-28T19:18:06.435084+00:00"}
{"ts":"2026-04-28T19:46:00.000000+00:00","agent":"GENERAL","soul_name":"ReleaseCannon","issue":"#81","task":"release build MCP v0.0.1 + insert 80 experiments (seeds 100-129, GF16/FP32/BF16/GF8/GFTernary) across all 4 accounts","status":"OK","phi_step":"RELEASE","triplet":"RAIL=release @ project=multi sha=40cc64b ts=2026-04-28T19:46:00Z"}
{"ts":"2026-04-28T19:52:01.010012+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-gf8-ultra-low-power-test image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=0","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=da1fb0c7 service=fcd0a544 sha=fbd6badfb736fb0d ts=2026-04-28T19:52:01.009993+00:00"}
{"ts":"2026-04-28T19:52:05.799801+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-gf32-fp32-dropin-test image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=0","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=da1fb0c7 service=65c95586 sha=afe752b39b857dab ts=2026-04-28T19:52:05.799785+00:00"}
{"ts":"2026-04-28T19:52:10.757223+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-gf64-double-precision-test image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=0","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=da1fb0c7 service=b1d51dd6 sha=8e5c07434cd7bbbd ts=2026-04-28T19:52:10.757189+00:00"}
{"ts":"2026-04-28T19:52:12.869337+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-gfternary-bulk-quantization image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=0","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=da1fb0c7 service=10fa979c sha=d0698f0d3b3fe32b ts=2026-04-28T19:52:12.869321+00:00"}
{"ts":"2026-04-28T19:52:34.379252+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-gf16-production-baseline image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=0","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=da1fb0c7 service=52d21b16 sha=9b845001698f4ef6 ts=2026-04-28T19:52:34.379240+00:00"}
{"ts":"2026-04-28T19:59:24.810706+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-e1-champion-reproduce image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=2","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=f3350520 service=038512b0 sha=3ce8b4a8bdd93e7f ts=2026-04-28T19:59:24.810681+00:00"}
{"ts":"2026-04-28T19:59:25.040152+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-e6-hybrid-001-test image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=2","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=f3350520 service=c13fa4a2 sha=0824deed76495e46 ts=2026-04-28T19:59:25.040147+00:00"}
{"ts":"2026-04-28T19:59:32.472199+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-43-e2-quorum-seed43 image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=2","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=f3350520 service=2649dc47 sha=2ff6637e0cd98374 ts=2026-04-28T19:59:32.472185+00:00"}
{"ts":"2026-04-28T19:59:33.482631+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-44-e3-quorum-seed44 image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=2","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=f3350520 service=600388d8 sha=dd6d63bf64177f5e ts=2026-04-28T19:59:33.482626+00:00"}
{"ts":"2026-04-28T20:00:10.493713+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-e4-capacity-push-h1536 image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=2","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=f3350520 service=ccfa2d1e sha=6bb640bf7628e4e1 ts=2026-04-28T20:00:10.493706+00:00"}
{"ts":"2026-04-28T20:00:26.258749+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-e5-gf16-storage-test image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=2","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=f3350520 service=b9b28339 sha=22c06463ec5bf677 ts=2026-04-28T20:00:26.258741+00:00"}
{"ts":"2026-04-28T20:00:37.106610+00:00","agent":"GENERAL","soul_name":"BatchDeployer","issue":"#81","task":"batch-deploy trios-train-seed-42-e7-lr-phi-optimal image=ghcr.io/ghashtag/trios-trainer-igla:latest acc=2","status":"OK","phi_step":"PUSH","triplet":"RAIL=batch-deploy @ project=f3350520 service=4fd2185c sha=e6c206b73788e231 ts=2026-04-28T20:00:37.106606+00:00"}

## Fleet-wide NEON_DATABASE_URL injection — 2026-04-28T23:02Z

- Upserted NEON_DATABASE_URL on 48 services across 4 accounts (ACC0:10, ACC1:8, ACC2:20, ACC3:10)
- Redeployed all 48 services to pick up new env var
- Worker status: acc0=2 alive/129 total, acc1=0/96, acc2=0/102, acc3=0/25
- Queue: 107 pending, 91 done, 2 running, 258 pruned, 1 failed
- Containers starting up; worker registration depends on trios-trainer-igla code
- Agent: GENERAL
36 changes: 36 additions & 0 deletions .trinity/p0_apply_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
# P0: Apply all P0 fixes (prune mocks, NaN guard, replay quorum)
# Total time: ~30 minutes
# Issue: trios-railway#81 (R5-honest - Bomb 1,2,3)

set -e

echo "=========================================="
echo "P0: Apply All Fixes (30 minutes)"
echo "=========================================="
echo ""

# Step 1: Prune mock rows
echo "[P0.a] Pruning 12 mock rows from experiment_queue..."
psql "$NEON_DATABASE_URL" < .trinity/p0_prune_mocks.sql
echo "✓ Mock pruning complete"
echo ""

# Step 2: NaN guard
echo "[P0.b] Adding NaN guard for final_bpb >= 1e10..."
psql "$NEON_DATABASE_URL" < .trinity/p0_nan_guard.sql
echo "✓ NaN guard active"
echo ""

# Step 3: Replay E0058 quorum
echo "[P0.c] Enqueuing E0058 replay on sanctioned seeds (Fibonacci F17-F19)..."
psql "$NEON_DATABASE_URL" < .trinity/p0_replay_e0058_quorum.sql
echo "✓ E0058 replay enqueued (3 experiments, seeds 1597/2584/4181)"
echo ""

echo "=========================================="
echo "P0 Complete: Leaderboard clean + NaN guard active + E0058 replay queued"
echo "=========================================="
echo ""
echo "Next: Monitor E0058 replay experiments for 1K baseline"
echo "Then: P1 Attention backward fix (CRITICAL BLOCKER - 12h deadline)"
96 changes: 96 additions & 0 deletions .trinity/p0_nan_guard.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
-- P0.b: NaN guard for final_bpb >= 1e10
-- Issue: trios-railway#81 (R5-honest - Bomb 3)
-- Mark experiments with infinite/NaN final_bpb as failed immediately
-- This prevents mock-run distortion (bpb(t) = 1.65+1.85·exp(-0.0025·t) from appearing as valid results

-- ============================================================================
-- Add status column if missing (idempotent)
-- ============================================================================

DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'experiment_queue' AND column_name = 'status'
) THEN
ALTER TABLE experiment_queue ADD COLUMN status TEXT DEFAULT 'pending';
RAISE NOTICE 'Added status column to experiment_queue';
END IF;
END $$;

-- ============================================================================
-- NaN guard function
-- ============================================================================

CREATE OR REPLACE FUNCTION mark_nan_as_failed() RETURNS TRIGGER AS $$
BEGIN
-- Guard 1: final_bpb is NULL or not present
IF NEW.final_bpb IS NULL THEN
NEW.status := 'failed';
INSERT INTO seed_policy_violations (attempted_by, seed, priority, canon_name, error_class, raw_payload)
VALUES (
'nan-guard-trigger',
NEW.seed,
NEW.priority,
NEW.canon_name,
'FINAL_BPB_NULL',
jsonb_build_object('reason', 'final_bpb missing', 'status', 'failed')
);
RAISE NOTICE 'NaN guard triggered: final_bpb is NULL for %', NEW.canon_name;
END IF;

-- Guard 2: final_bpb >= 1e10 (effectively infinite)
IF NEW.final_bpb >= 1e10 THEN
NEW.status := 'failed';
INSERT INTO seed_policy_violations (attempted_by, seed, priority, canon_name, error_class, raw_payload)
VALUES (
'nan-guard-trigger',
NEW.seed,
NEW.priority,
NEW.canon_name,
'FINAL_BPB_INFINITE',
jsonb_build_object(
'final_bpb', NEW.final_bpb,
'threshold', 1e10,
'reason', 'final_bpb >= 1e10 indicates divergence or NaN'
)
);
RAISE NOTICE 'NaN guard triggered: final_bpb=% for % (threshold=1e10)', NEW.final_bpb, NEW.canon_name;
END IF;

RETURN NEW;
END;
$$ LANGUAGE plpgsql;

-- ============================================================================
-- Drop trigger if exists (idempotent)
-- ============================================================================

DROP TRIGGER IF EXISTS trg_nan_guard ON experiment_queue;

-- ============================================================================
-- Create trigger (fires on INSERT and UPDATE)
-- ============================================================================

CREATE TRIGGER trg_nan_guard
BEFORE INSERT OR UPDATE ON experiment_queue
FOR EACH ROW EXECUTE FUNCTION mark_nan_as_failed();

-- ============================================================================
-- Verification
-- ============================================================================

DO $$
BEGIN
RAISE NOTICE '========================================';
RAISE NOTICE 'P0.b: NaN GUARD APPLIED';
RAISE NOTICE '========================================';
RAISE NOTICE 'Function: mark_nan_as_failed()';
RAISE NOTICE 'Trigger: trg_nan_guard ON experiment_queue';
RAISE NOTICE 'Guard 1: final_bpb IS NULL → status=failed';
RAISE NOTICE 'Guard 2: final_bpb >= 1e10 → status=failed';
RAISE NOTICE '';
RAISE NOTICE 'Test: UPDATE final_bpb=1e11 should trigger guard';
RAISE NOTICE 'Test: UPDATE final_bpb=1.5 should NOT trigger guard';
RAISE NOTICE '========================================';
END $$;
Loading
Loading