Short contract for agents and operators. Prefer linking over restating runbooks.
Product: Cortex (CortexLM/cortex) — Bittensor subnet control plane for decentralized collaborative AI research via multiple challenges. Naming split (Cortex vs leftover base / BASE_*): docs/NAMING.md.
| Path | Role |
|---|---|
bins/ |
Runnable processes (validator, gateway, updater, challenges, …) |
crates/ |
Libraries shared by binaries |
xtask/ |
Repo gates and maintenance tasks |
deploy/ |
Compose matrix, Terraform, pins, secrets helpers, remote deploy |
docs/ |
Architecture, frozen specs, runbooks, completeness |
config/ |
Shared non-secret configuration |
Working branch: main. Prod ships from annotated tags v*.*.* cut on main.
- Digest-only images in deploy paths — no floating tags in prod pins/compose.
- Secrets via age + files under
deploy/env//deploy/secrets/— never baked into images or cloud-init. - Gateway runs on master only (
--profile master/role-master.yml). Validators point at the master gateway over VPC. evil-gatewayis test-only — never enable on prod hosts; assert withdeploy/scripts/assert-evil-gateway-not-default.sh.- Platform is DigitalOcean Droplets + Docker Compose, not App Platform / DOKS.
- Do not rename
BASE_*env vars, deployed paths, or crypto domain tags. They are measured into miner CVMapp-compose.jsonand live on droplets / RTMR3 pin continuity.CORTEX_*is an accepted alias incrates/configonly. Seedocs/NAMING.md. - Frozen specs (
docs/BUNDLE_SPEC.md,docs/DESIGN_CHALLENGE.md) are pinned by xtask. Do not weaken gates or rewrite incentive / scoring / consensus semantics. unsafe_code = forbid. Nounwrap/expectin non-test code.
| Key | Who | Needed for |
|---|---|---|
gateway_sk |
Gateway | Bundle seal signatures (POST /v1/admin/seal) |
gateway_admin_token |
Gateway + seal scripts | Bearer for /v1/admin/* (seal, backends, attest-grant). Required when BASE_GATEWAY_REQUIRE_OWNER=1 |
prism_sk / design_sk |
Challenge / smoke | Signed leaves (POST /v1/weights/raw); pubs must match trust root |
Gateway owner wallet + BASE_GATEWAY_REQUIRE_OWNER |
Gateway | Master-only identity check (live/prod). Not required to seal or serve /v1/weights/latest |
| Validator wallet | Validator | On-chain weight submit only — validators fetch sealed weights; they do not need a gateway wallet |
GET /v1/weights/latest is fail-closed: with no sealed bundle (or decode error) the gateway serves a burn vector (uid 0 = 100%, sealed: false) rather than 404. A missing gateway wallet is unrelated.
Each live challenge has a separate public GitHub repo for miners. Those repos must contain only human miner documentation plus example / test harness code — never control-plane, gateway, validator, or orchestrator source. Public repos use a docs/ layout (hero README + banner under assets/).
| Challenge | Public repo | Role |
|---|---|---|
| Design | BaseIntelligence/design-challenge |
Miner docs + baseline harness |
| Prism | BaseIntelligence/prism |
Miner docs + recipe examples (publish / keep in sync; no control-plane code) |
Those public URLs are historical org names; this control-plane repo is CortexLM/cortex. Monorepo mirror for CI and operators: docs/external-miner/. Frozen contracts stay in this repo (docs/DESIGN_CHALLENGE.md, docs/PRISM.md, …).
When a challenge product or public API changes, agents must update:
- The challenge’s public miner repo (README / examples), and
docs/external-miner/in this monorepo as needed.
Do not leave miner-facing docs stale after shipping API, quota, round, or scoring changes.
When verifying a challenge (local-e2e, staging, or focused tests), simulate a submission end-to-end — do not stop at process healthz. Challenges evaluate on master only; the validator has no challenge exec (fetch sealed weights only).
- Happy-path harness / intake POST (or equivalent) through the challenge service on master.
- Edge / failure probes: bad harness, sanitize reject, quota, wrong routes/auth.
- Design — baseline: submit the reference agent at
docs/external-miner/examples/design-baseline/(agent.py+pyproject.toml). AfterPOST /v1/harness, pollGET /v1/runs/{id}+/events+/logs?since=untilawaiting_admin/ terminal; assertGET /v1/runs/{id}/pageslistsindex.html,pricing.html,components.htmlandGET /v1/view/{run_id}/{page}returns 200; probeGET /v1/statsandGET /v1/dashboard. - Design — cheat: submit a malicious/copy harness; expect agentic
cheat/suspicious→Score(0)(not admin-eligible). Poll events/logs the same way. - Design — admin winners: with operator bearer (
deploy/secrets/design/annotator_tokens),GET /v1/admin/rounds/{id}/candidatesthenPOST /v1/admin/rounds/{id}/winnerswith 1 or 2 clean harness ids (SCORE_MAXorSCORE_MAX/2). - Leaf emission →
POST /v1/weights/raw→ seal →GET /v1/weights/latestwithsealed: true(burn fallback alone is not a real seal).
Never host Sim in staging/prod — Docker sandbox only there. SimSandbox / BASE_ALLOW_HOST_SIM=1 is CI/local opt-in only; do not treat stub pages (sim-install-ok / sim-run-ok without executing agent.py) as proof. Prefer DESIGN_FORCE_SIM=false + OpenRouter when deploy/secrets/openrouter/api_key is present.
Local smoke automates the weights seal step via weights-smoke inside ./deploy/scripts/local-e2e.sh --smoke (see deploy/AGENTS.md and docs/runbooks/local-testnet-e2e.md).
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
cargo deny check
cargo run -p xtask -- loc-cap
cargo run -p xtask -- consensus-lint
cargo run -p xtask -- spec-check
cargo run -p xtask -- design-check
cargo run -p xtask -- external-docs-checkCommit subjects: type(scope): summary (lowercase, ≤72 chars). Hooks: ./scripts/install-githooks.sh.
Match CI (.github/workflows/ci.yml):
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warnings- tests +
cargo deny cargo run -p xtask -- loc-capcargo run -p xtask -- consensus-lintcargo run -p xtask -- spec-checkcargo run -p xtask -- design-checkcargo run -p xtask -- external-docs-check
| Need | Start here |
|---|---|
| System map / process topology | docs/ARCHITECTURE.md |
Cortex vs leftover base names |
docs/NAMING.md |
| Deploy / Compose / DO topology | deploy/README.md + deploy/AGENTS.md |
| Local full-subnet test (master+gateway+validator on testnet 541 + tunnel) | docs/runbooks/local-testnet-e2e.md · deploy/AGENTS.md § Local testnet E2E · ./deploy/scripts/local-e2e.sh --help |
| Doc authority vs evidence | docs/AGENTS.md |
| Component status | docs/COMPLETENESS.md |
| Frozen contracts | docs/BUNDLE_SPEC.md, docs/DESIGN_CHALLENGE.md, docs/PRISM.md |
| Miner HTTP submit | docs/external-miner/ · public: design-challenge, prism |
| Threat / operator checklist | docs/THREAT_MODEL.md, docs/OPERATOR_SECURITY.md |
deploy/env/*.env(materialized secrets)deploy/secrets/**(except documentedREADME.mdplaceholders)deploy/terraform/*.tfstate*/terraform.tfvars/ local.terraform/- Age identities, wallets,
receipt_sk,*.pem/*.key/*.age - Treating
docs/evidence/ordocs/spikes/as product code or normative spec