Skip to content

Commit b64258e

Browse files
committed
fix(agent-challenge): owned CVM teardown, fail-loud list, staging stack
Rebase the safety-critical selfdeploy/staging work onto current main without the older 38-commit stack that conflicted with PR #49. - Fail-loud Phala CVM listing via GET /cvms/paginated + X-Phala-Version 2026-06-23; unknown envelopes raise instead of under-reporting as 0 - Loopback http:// only with SELFDEPLOY_ALLOW_INSECURE_LOOPBACK=1 - Staging compose/scripts/docs with owned-only teardown (never account-sweep) - AGENTS.md points operators at the local staging loop first Dropped changes main already covers (shape mismatch formatter, eval default tdx.xlarge, HTTP delete_cvm). Compose pre-artifact pin matching deferred: main's generator does not yet include artifact envs and cannot reproduce daf0 without a broader compose delta.
1 parent 2bfa110 commit b64258e

27 files changed

Lines changed: 3260 additions & 65 deletions

AGENTS.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ UV_CACHE_DIR=/var/tmp/uv-cache uv run pytest tests/unit \
8080
-k "sealer or aggregation or weights" -q
8181
```
8282

83+
## Agent Challenge local staging (before live/prod)
84+
85+
Prefer the isolated AC staging loop before production-facing gate changes:
86+
87+
```bash
88+
packages/challenges/agent-challenge/scripts/staging/run_staging.sh
89+
```
90+
91+
Details: [`packages/challenges/agent-challenge/docs/staging.md`](packages/challenges/agent-challenge/docs/staging.md)
92+
(host loopback `127.0.0.1:18082`, project `ac-staging`; not master embed `:18081`).
93+
94+
- **One command** above is the iteration loop. Driving the **prod** validator over SSH is a last resort and must never be the day-to-day loop.
95+
- Any keypair works for local submit/sign: AC verifies signatures only (no metagraph membership check).
96+
- CVMs are **real** Phala TDX machines (billable). Staging tears down **only CVMs this run owns** (`work/owned_cvms.txt` + per-run track). It never account-sweeps foreign/prod CVMs. Always tear down owned CVMs before you leave.
97+
98+
Real Phala TDX CVMs + dual attestation flags; always tear down to a verified CVM count of 0 via paginated list (never trust bare `GET /cvms` empty arrays).
99+
83100
## Runtime topology (production)
84101

85102
Supported install is **Docker Compose master + PostgreSQL only**:
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Local Agent Challenge staging stack — isolated from prod.
2+
# Host port 18082 (prod embed uses 18081 inside master). Named volume + project
3+
# prefix keep DB/artifacts off any prod path.
4+
#
5+
# Build from monorepo root:
6+
# docker compose -f packages/challenges/agent-challenge/docker-compose.staging.yml build
7+
# Or use scripts/staging/run_staging.sh (preferred).
8+
9+
name: ac-staging
10+
11+
services:
12+
agent-challenge:
13+
image: ghcr.io/baseintelligence/agent-challenge:staging-local
14+
build:
15+
context: .
16+
dockerfile: Dockerfile
17+
target: runtime
18+
additional_contexts:
19+
monorepo: ../../..
20+
container_name: ac-staging-validator
21+
restart: "no"
22+
ports:
23+
- "127.0.0.1:18082:8000"
24+
volumes:
25+
- ac_staging_data:/data
26+
- ./scripts/staging/config/review_evidence_encryption_key:/run/secrets/base/review_evidence_encryption_key:ro
27+
- ./scripts/staging/config/challenge_token:/run/secrets/base/challenge_token:ro
28+
# Frozen Terminal-Bench 2.1 digest (eval/prepare fails closed without this).
29+
- ./golden:/app/golden:ro
30+
- ./golden:/opt/agent-challenge/golden:ro
31+
# dcap-qvl is baked into the runtime image; host bind is optional fallback
32+
- /root/.cargo/bin/dcap-qvl:/usr/local/bin/dcap-qvl:ro
33+
env_file:
34+
- ./scripts/staging/config/challenge.env
35+
environment:
36+
CHALLENGE_DATABASE_URL: sqlite+aiosqlite:////data/agent-challenge.sqlite3
37+
CHALLENGE_DATA_DIR: /data
38+
CHALLENGE_ARTIFACT_ROOT: /data/agents
39+
CHALLENGE_SHARED_TOKEN_FILE: /run/secrets/base/challenge_token
40+
CHALLENGE_REVIEW_EVIDENCE_ENCRYPTION_KEY_FILE: /run/secrets/base/review_evidence_encryption_key
41+
CHALLENGE_COMBINED_WORKER: "true"
42+
CHALLENGE_DOCKER_ENABLED: "false"
43+
CHALLENGE_RAW_WEIGHT_PUSH_ENABLED: "false"
44+
CHALLENGE_PHALA_ATTESTATION_ENABLED: "true"
45+
CHALLENGE_ATTESTED_REVIEW_ENABLED: "true"
46+
# Prod path: terminal-bench + frozen digest (default package backend is swe_forge).
47+
CHALLENGE_BENCHMARK_BACKEND: terminal_bench
48+
CHALLENGE_TERMINAL_BENCH_EXECUTION_BACKEND: own_runner
49+
CHALLENGE_OWN_RUNNER_DIGEST_MANIFEST: /app/golden/dataset-digest.json
50+
# Eval result signer — substrate dev URI (local only; never production wallet)
51+
CHALLENGE_EVAL_RESULT_SIGNER_URI: "//Alice"
52+
CHALLENGE_LOG_LEVEL: INFO
53+
# Shortest viable eval for spend control (still real tasks)
54+
CHALLENGE_EVALUATION_TASK_COUNT: "1"
55+
CHALLENGE_EVAL_K: "1"
56+
healthcheck:
57+
test:
58+
[
59+
"CMD",
60+
"python",
61+
"-c",
62+
"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=3)",
63+
]
64+
interval: 5s
65+
timeout: 5s
66+
retries: 30
67+
start_period: 15s
68+
69+
volumes:
70+
ac_staging_data:
71+
name: ac-staging-data

packages/challenges/agent-challenge/docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ inside the package.
1010
| Interactive API | `https://chain.joinbase.ai/challenges/agent-challenge/docs` |
1111
| Package product pin | [`../README.md`](../README.md) |
1212
| Self-deploy CLI accuracy fixtures | [`miner/self-deploy.md`](miner/self-deploy.md), [`validator/self-deploy.md`](validator/self-deploy.md) |
13+
| Local staging loop | [`staging.md`](staging.md) |
14+
| Prod compose pin upgrade | [`prod-compose-upgrade.md`](prod-compose-upgrade.md) |
1315

1416
**API truth is OpenAPI** (and the in-process challenge app `/openapi.json`).
1517
Audience essays (lifecycle dumps, route catalogs, architecture novels) were

0 commit comments

Comments
 (0)