Skip to main content

cma-admin

cma-admin provisions and runs the SABLE Claude Managed Agent (CMA), and is the only Edge Function with prompt-control actions. It runs as an Edge Function because Chris's ANTHROPIC_API_KEY and the SPINE_MCP_TOKEN (for the vault) live in Edge secrets — never in web code. Every action is admin/lead gated.

Actions​

ActionPayloadPurpose
provision{ system }Create the vault (plus a static-bearer credential pointed at spine-mcp), an environment, and the SABLE agent; returns ids
run{ agent_id, environment_id, vault_id, message, maxMs? }Create a session, send a message, poll to a result
poll{ session_id, maxMs? }Continue polling a running session
get_prompt—Return the live SABLE system prompt, split into base + learned rules
set_base_prompt{ base }Update the base prompt, then re-attach approved learned rules
stage_prompt{ base, message? }Test a candidate base prompt through agent_with_overrides without promoting it
prompt_versions—List stored base-prompt versions for rollback/diff
rollback_prompt{ version_row_id | agent_version }Restore a prior base prompt
apply_prompt_rules—Fold approved prompt_update rows into the learned-rules block
get_model_config—Return the live agent's model and effort, plus the models the board can use: read live from the Models API (Claude 4.5 and later, the Managed Agents floor), each with its own effort levels
set_model_config{ model_id, effort? }Update the live agent's model/effort — any admin/lead, for benchmarking
stage_model{ model_id, message? }Run the board once on another model through agent_with_overrides and the staging vault, without changing the live agent. Runs at the live agent's effort (the API ignores effort in a session override). The poll reports model and cost_usd; the run is metered with meta.test = "model"
teardown{ agent_id?, environment_id? }Archive resources (cleanup)

The prompt-owner gate sits above this function​

cma-admin enforces admin/lead access for every action, but promoting or rolling back the live prompt additionally requires being on the SABLE_PROMPT_OWNER allowlist — a stricter gate checked before set_base_prompt/rollback_prompt actually apply. See Security Posture for the full reasoning, and Prompt Control for the product-level workflow this function backs.

What the agent can and can't do​

The agent's only tools are the spine-mcp MCP server, and only its always_allow (read) tools — no sandbox bash, no file writes. Restricted content never reaches the agent because spine-mcp excludes it before the agent ever sees it, not because the agent is instructed to avoid it. Writes via always_ask are a later phase, not yet wired to this function.

Where the code lives​

  • supabase/functions/cma-admin/index.ts, prompt-blocks.ts, report.ts
  • supabase/functions/_shared/rule_merge.js — mergeRules, the near-duplicate learned-rule folding described in docs/2026-09-08-where-we-are.md (PR #196)
  • web/api/sable-prompt.js, _prompt_owner.js
  • docs-site/docs/product/prompt-control.md, docs/product/prompt-maintenance.md