PROJECT BRAIN VAL BRIDGE PROTOCOL V2

Purpose

Normal ChatGPT project work uses Val Town as the only ChatGPT-facing transport to the canonical Project Brain. Direct Sprites connector calls are maintenance-only because they can trigger separate file-materialization approval prompts.

Normal path:

ChatGPT → Val Town → brain_bridge_jobs → persistent Brain worker → canonical Brain

Val/project: mosadek/project-brain-live-v1-durable
Queue: brain_bridge_jobs
Worker identity: project-brain-live-v1-worker-v2

Mandatory health interpretation

The HTTP endpoint being reachable is NOT proof that the persistent Brain worker is alive.

Read brain_bridge_worker.ts /health.

  • HTTP 200 means the most recent worker poll is fresh and the queue has no expired lease or duplicate active lease for one worker ID.
  • HTTP 503 means fail closed. Inspect worker_state, worker_reason, queue counts, and endpoint traces.
  • endpoint_ok:true only proves the Val endpoint itself is executing.
  • instance_identity_available:false means the persistent worker has not yet supplied a distinct process instance ID. Do not overclaim process identity.

Current Val-side invariants:

  • priority cap: 1_000_000_000;
  • selection above the cap: FIFO by created_at,id;
  • maximum Brain command timeout: 120 seconds;
  • queue lease: 180 seconds;
  • atomic single-flight per worker_id;
  • an active unexpired lease is not redelivered to another poll sharing that worker ID;
  • a pre-existing duplicate active lease for one worker ID fails closed;
  • expired queue leases are returned to READY on a worker poll;
  • results are accepted only for the current unexpired lease owner.

These are transport invariants, not Brain authority.

Submit a Brain command

Insert a unique job:

INSERT INTO brain_bridge_jobs (id, priority, op, payload_json, state, lease_owner, lease_expires_at, result_json, error_json, created_at, updated_at) VALUES (?, ?, 'brain', ?, 'READY', NULL, NULL, NULL, NULL, datetime('now'), datetime('now'))

Brain payload is closed-schema:

{"args":["status"],"timeout":60}

Requirements:

  • exact top-level keys: args, timeout;
  • args is a non-empty string array;
  • timeout is an integer from 1 through 120.

Currently allowed Brain subcommands:

  • status
  • verify-chain
  • verify-claim-graph
  • register-agent
  • ensure-task
  • delegate-task
  • claim
  • renew-lease
  • commit
  • checkpoint
  • add-claim
  • invalidate-claim
  • supersede-task-context
  • migrate-task-invariants
  • reconcile-causal-blocks

Anything else fails at Val-side dispatch rather than being sent onward.

Boot semantics

There is currently NO valid atomic boot bridge command.

The public bridge previously advertised boot, but the live kernel accepts boot-agent while the persistent executor rejects raw boot-agent. Therefore neither spelling is a valid end-to-end bridge operation.

Use the proven equivalent sequence:

  1. register-agent
  2. claim

Register only capabilities actually present in the current chat. Never claim human_authority_approval.

Example conceptual sequence:

register-agent <unique-agent-id> --workstream <ws> --role <role> --type CHAT --capabilities <json-array> claim --agent <unique-agent-id> --mode INTERACTIVE --lease-seconds 1800

Do not submit boot or boot-agent until a later verified bridge/executor revision explicitly restores an atomic wrapper.

Lease recovery semantics

Do not submit recover-leases or recover-stale through this bridge revision.

  • Val transport queue lease expiry is recovered automatically by the worker on poll.
  • Canonical Brain task-lease recovery is a separate operation and is not currently exposed end-to-end by the persistent executor.
  • If canonical stale-lease recovery becomes necessary, create/route a bridge-extension task or use another verified non-Sprites route. Do not guess an alias.

Poll a job result

SELECT id,state,lease_owner,lease_expires_at,result_json,error_json,updated_at FROM brain_bridge_jobs WHERE id=?

Terminal states:

  • COMPLETE
  • FAILED

A READY job means it has not been executed. A LEASED job is not complete. Do not infer canonical mutation from queue state alone.

Read Brain text without Sprites

Use op='read_text' with exact closed-schema payload:

{"path":"/brain/JOIN_PROTOCOL.md","max_bytes":200000}

Allowed paths:

  • exactly /brain/JOIN_PROTOCOL.md;
  • a non-directory file strictly below /brain/artifacts/.

Constraints:

  • max_bytes: integer 1..200000;
  • no . or .. path segments;
  • no backslash or NUL;
  • no extra payload fields.

Earlier worker stalls coincided with read jobs, but later bounded artifact reads completed successfully. Therefore do not claim that read_text itself caused the historical stall. Keep the bounded allowlist and use current worker health as the liveness signal.

Hard transport rule

Routine ChatGPT work:

  • DO NOT call Sprites;
  • DO NOT call Sprites.exec;
  • DO NOT call Sprites.file_read/file_write/file_copy/file_delete;
  • DO NOT call Sprites service/checkpoint/file/blob operations.

If a required operation is missing:

  1. use an existing valid non-Sprites substrate when possible;
  2. route or build a bridge extension;
  3. fail closed if the missing operation is necessary;
  4. direct Sprites remains an explicit maintenance emergency, not an automatic fallback.

Failure behavior

If jobs stay READY:

  1. inspect /health;
  2. inspect worker endpoint traces;
  3. inspect the current active/expired queue leases;
  4. do not raise transport priorities above the cap to win a queue arms race;
  5. do not interpret the Val endpoint being online as the Brain worker being online.

If worker health is DOWN:

  • queued commands remain pending;
  • no live Brain registration, claim, commit, status, or verification should be invented;
  • Val-side code/evidence work may continue when it does not pretend to mutate canonical Brain;
  • repair/restore the persistent executor through an authorized route, then resume queue processing.

Proven facts and bounded claims

The reverse bridge has successfully:

  • read Brain status;
  • created canonical Brain tasks;
  • registered CHAT agents;
  • claimed tasks;
  • committed task results;
  • run verify-chain and verify-claim-graph.

The Val-side worker has independently reproduced and repaired the same-worker concurrent lease race in isolated queue tests. This does NOT prove the persistent Sprite-side executor is permanently supervised or continuously alive.

Goal

Normal project work must stay materialization-free from ChatGPT while remaining fail-closed:

ChatGPT agent → Val Town → durable queue → live worker → verified Brain

If the live worker disappears, the system must say so rather than smiling with HTTP 200 like a malfunctioning status page.