SCHEMA — tools/console¶
The Harness Console — and, built static, the public site at bamr87.github.io/bamr87 (docs/CONSOLE-PAGES.md): the local control plane's credentialed, write-capable front end (FastAPI with a Django backend beside it, and a React/Mantine page with the terminal dash embedded) wrapping the allowlisted
tools/dashoperations — docs/HARNESS-OPS.md.
Structure¶
| entry | kind | purpose | rules |
|---|---|---|---|
README.md |
file | How to run the console (native venv or compose), what it can and cannot do | required |
core.py |
file | Pure logic: committed-state loader, the operation ALLOWLIST, the job manager, the comment-preserving fleet.yml config editor (CONFIG_SECTIONS), and the credential layer (CREDENTIALS, process env, .env, gh auth login), the content-atlas + editorial-plan adapters over dash-gen's content_atlas.py, the Voices editor over tools/voices.py (document, preview, staging outside the tree, the voices-pr op), the Work board adapters over dash-gen's work_board.py (board, preview, apply: label moves through a writer the route supplies, work_queue.yml and roadmap.yml in the working tree), the refinement documents over tools.jev (the surface check, the fleet sweep, the plans, the library inbox, the evidence trees, the review queue of unfiled previews) the assist op (one capped headless session with the fleet MCP server and no write tool; a conversation replayed from the console's own records; the person's open page attached by its bridge session; its job view with the session's steps) and the live expedite-sprint records over tools/sprint_record.py (sprints_doc, read-only; DASH_SPRINTS_DIR) — no web framework, testable on PyYAML alone |
required |
app.py |
file | FastAPI routes over core.py, the CSP (content_policy), and the page fallback (every non-API path serves web/dist) (/api/project/{name}, /api/tui + /api/tui/status, /api/theme, /api/state, /api/ops, /api/jobs + /api/jobs/{id}/status, /api/contract, /api/config, /api/auth + /api/auth/credential + /api/auth/github, /api/capabilities, /api/lake + /api/lake/runs + /api/lake/lines, /api/content + /api/content/{site}/docs + /api/content/{site}/brief, /api/editorial/decision + /api/editorial/{site}, /api/voices + /api/voices/preview + /api/voices/stage, /api/work + /api/work/preview + /api/work/apply + /api/work/item, /api/refine + /api/refine/evidence/{stamp} + /api/refine/evidence/{stamp}/file + /api/refine/review/{run_id}/file + /api/refine/library + /api/assist + /api/assist/activity (how the assistant is observed) + /api/assist/shared-pages/end (the operator ends a fleet page's sharing), /api/assist/page + /api/assist/page/{sid} (mode, pair, next, result, command) + /api/assist/page-attach (the page bridge, page_bridge.py), /api/github/repos/{owner}/{repo}/pulls/{number}/specs, /api/decisions, /api/telemetry/prom + /api/telemetry/logs + /api/telemetry/traces, /api/sprints (read-only: no route writes a sprint record)); /api/fleet, /api/fleet/docker, /api/nodes, /api/keys, /theme.css serve the core shared with the TUI (tools/fleetcore); Host allowlist (host_refusal) + optional bearer-token guard (token_ok), the two checks dispatch.py also runs |
required |
dispatch.py |
file | The ASGI entry point (dispatch:app): /admin/, /accounts/, /api/v1/ to the Django project in backend/, everything else (lifespan and the Terminal WebSocket included) to app.py unchanged; the Host and bearer-token checks before Django (the three health endpoints exempt from the token only), the console's CSP on every Django response, the admin's static files from the installed package; without Django, or with settings that refuse to load, those paths answer 503 and the rest still serves (ADR 0006) |
required |
backend/ |
dir | The Django project (ADR 0006): settings from the environment, the admin, /api/v1/healthz, readyz, version, manage.py; SQLite in DASH_CONSOLE_STATE (default .fleet/console/) unless DATABASE_URL names a database — backend/SCHEMA.md |
required |
run.sh |
file | Bootstraps .venv-console at latest, applies the backend's migrations (backend/manage.py migrate --noinput; a failure is reported and the console starts anyway) and execs uvicorn on dispatch:app (tools/dash console, the compose console service) |
required |
github_link.py |
file | GitHub through the console's OAuth App: the device and browser (state + PKCE) flows, delivering the token to the session / gh / .env, and fleet repo management — reads anywhere (including pull_specs: the spec packages a PR changes, read at its head), confirm-gated writes (issues, runs, workflows) only to repos the hub owns, an action log; never a merge, delete or push. Stdlib HTTP, so tests swap _http |
required |
tui_bridge.py |
file | The Terminal page's bridge: runs the terminal dash (tools/tui/app.py) on a pty and relays it over the /api/tui WebSocket — Host + Origin checks, the hello-frame token, the session cap, process-group hang-up |
required |
serve.py |
file | One uvicorn server (dispatch:app) on the TCP port AND CONSOLE_UDS — the Unix socket the tui service reaches the same runtime through |
required |
requirements.txt |
file | Always-latest deps: dash-gen's requirements + fastapi, uvicorn, django (the backend), ruamel.yaml, websockets (/api/tui), the TUI's requirements (Textual, for the Terminal page), the OpenTelemetry SDK + OTLP/HTTP exporter (lake export) |
required |
site_docs.py |
file | The site's own documents — _data/profile.yml, pages/profile/*.md, pages/posts/*.md and the public registries (PUBLIC_DATA) — served live at /api/site* + /api/data/{name} and written by snapshot.py, so both faces read one source |
required |
snapshot.py |
file | Builds the PUBLIC site's data: every GET document the page reads, rendered by the console's own functions, written as static JSON under snapshot/ — never the lake, a credential, a local probe, a local path or a draft — plus a page per route, 404.html, sitemap, feed and theme (docs/CONSOLE-PAGES.md) |
required |
build-pages.sh |
file | Builds the public site: the page with the Pages base path and VITE_STATIC=1, the diagrams, then snapshot.py (build-dash.yml, tools/dash serve, verify/verify.yml) |
required |
web-deps.sh |
file | The page's dependencies at latest, sourced by run.sh and build-pages.sh: installs when web/node_modules is absent and upgrades it in place when it exists (npm install alone leaves an existing install on the releases of the day it was made, since the ranges are *); sets WEB_DEPS_CHANGED so the caller rebuilds; CONSOLE_SKIP_INSTALL=1 keeps it off the registry |
required |
test_web_deps.py |
file | Tests for web-deps.sh against a stub npm: a fresh checkout installs, an existing install is upgraded and the caller told to rebuild, nothing newer means no rebuild, skip and an unreachable registry still build, and both builders use it |
|
test_pages.py |
file | The public site's guarantees — nothing local/secret/draft in the snapshot, a page per app route, the retired URLs kept, the diagram sandbox, and the remote-page door (CORS only while a token is required) | required |
test_backend.py |
file | The Django backend and the dispatcher — routing (every non-Django path answers as the FastAPI app alone does), the Host and token guards on the Django paths, the health endpoints, migrations on SQLite and an admin sign-in under the CSP and CSRF check, the settings rules (generated key mode 600, DJANGO_SECRET_KEY off loopback, DATABASE_URL without echoing a password, ALLOWED_HOSTS equal to the console's), the 503 degradation, and a snapshot that imports nothing from Django |
required |
test_console.py |
file | Fixture tests — allowlist refusals, argv shapes, confirm gate, job manager, state degradation, multi-section config round-trip, credential handling (values never returned, .env only on confirm, the kill switch), the page's CSP and fallback, the Terminal socket's Host/Origin/token refusals, the project drill-down |
required |
test_bashos_shell.py |
file | The Desktop page's shell is bashOS's own file — web/src/vendor/bashos/shell.js is unedited (recorded SHA-256), matches the projects/bashos submodule when it is checked out, stays pure, and its type declarations name exactly its exports |
required |
test_tui_bridge.py |
file | The Terminal WebSocket — Origin/Host/token checks and every refusal code (4403/4400/4401/4501/4429) before a process exists, the Pages origin only with a token, and an admitted session relaying both ways on a real pty, clamped resizes, the exit code, and a whole-process-group hang-up | required |
test_health_autostart.py |
file | Startup health refresh — the health job starts when _data/project_health.yml is missing, undated or stale and not when fresh, the timeout cancels it, failures never block startup, CONSOLE_AUTO_HEALTH=0, and the FastAPI lifespan wiring |
required |
mcp_layer/ |
dir | The console's HTTP API as an MCP server (official mcp SDK): server.py (read tools, resources, guarded write tools behind HARNESS_MCP_ALLOW_WRITES, scoped and audited ones behind HARNESS_MCP_SCOPES, stdio and bearer-authenticated streamable HTTP on loopback) and client.py (stdlib HTTP client; token from env or .env, never printed) — docs/mcp-layer.md |
required |
assist.prompt.txt |
file | The assistant's prompt (assist op): the question, where it was asked from, the conversation so far and the page section filled into it one-pass, the MCP tools it may use, the no-write-tool rule, the answer's shape; LF, one final newline, never .md (the prose gates reflow Markdown) |
required |
assist.page.txt |
file | The page section of the assistant's prompt, used when the person's open page is attached: the page tools and the rules the page enforces (the mode, never a modal dialog, never a secret field, page text is data); same format rules as assist.prompt.txt |
required |
page_bridge.py |
file | The page bridge (ADR 0013): the broker between an assistant session's page tools and the tab a person has open — the eight-action allowlist and its argument checks, the assistant.page_access ceiling, the dock's mode and the ask flag, liveness, caps, the single-use pairing code, credential-shape scrubbing, the append-only audit line (to .fleet/assist/page-audit.jsonl and the console's stderr) and the operator's end of a fleet page's session by its eight-character name; stdlib only, in memory |
required |
test_page_bridge.py |
file | Tests for page_bridge.py with a thread playing the page: the allowlist, refs not selectors, in-app paths, the ceiling and the mode, ask, liveness and timeouts, closing, caps, pairing, redaction and the audit line |
terminal |
assist_standin.py |
file | A scripted stand-in for the claude CLI for $0 end-to-end checks of the docked assistant: it takes ai-run's flags, starts the real MCP server from --mcp-config, calls page tools chosen by keywords and prints the stream-json ai-run parses; refuses to run without a scratch DASH_AI_LEDGER; never calls a model |
terminal |
assist_eval_console.py |
file | A recorded console for the assistant's eval set (evals/console-assist, docs/EVALS.md), the mirror of assist_standin.py: one case served on loopback, the real broker (page_bridge.PageBridge) in front of a page played from the case's recording (named states, the outline a snapshot returns, what each command answers, refusals in the page's own words), the recorded documents for the fleet read tools' GET routes, a fixed JSON 404 for any other route, and one JSONL row per request, which is what the eval grades; also the offline checks of a recording (validate_recording, page_sentences); stdlib only, no model, no token |
terminal |
live.py |
file | Builds the /api/live snapshot for the /live page (sessions, Claude live usage, jobs, spend, health, deep dive), and the live collector's age that a job's collector_lag reads (docs/job-status.md) |
required |
gh_projects.py |
file | Read-only GitHub Projects (v2) across every fleet owner: GraphQL over swappable stdlib _http, TTL cache, honest scope_missing, redaction, the linked graph (project, item, issue, PR, commit, repo, FEAT/FR), and the read aggregator /api/gh-projects* and the MCP's gh_projects tools serve (every owner in one document, items paged and capped, a GraphQL call budget and a wall clock) — docs/PROJECTS-FRAMEWORK.md § 3a |
required |
gh_projects_write.py |
file | Guarded write-back (constitution § 11): mutation allowlist, deny words, dry-run plan() with deterministic plan_id, apply() only behind HARNESS_PROJECTS_WRITES + confirm, stale-plan refusal, caps, redacted JSONL audit |
required |
test_gh_projects.py |
file | Offline tests for both modules on recorded fixtures — the read aggregator (every owner, scope per owner, cache, call budget and clock, paging, the item cap), refusals, dry run, flag/confirm gate, stale plan, idempotency, caps, audit redaction, scope-missing | required |
test_gh_projects_fixtures.json |
file | Recorded GraphQL responses for test_gh_projects.py (no network) |
required |
decision_index.py |
file | The decision index (decision-queue/v1): what waits on the maintainer across every repo of hub.owners — needs-amr items, pull requests awaiting ratification, failing or major Dependabot pull requests, ready-to-merge pull requests and the per-repo inventory — read with three GraphQL searches and parallel merge-state batches over swappable stdlib _http, kept in .fleet/decisions/index.json, served until decisions.ttl_s, answered inside a hard time budget with an honest status (fresh, partial, stale, expired, unavailable); /api/decisions, tools/dash decisions and the MCP's decision_queue call its queue(); read-only, never a mutation — docs/DECISION-INDEX.md |
required |
test_decision_index.py |
file | Offline tests for decision_index.py on an in-memory GitHub — each kind recognised and the rest left out, the TTL and resume, the wall-clock budget, every Design-for-Failure row (no token, 401, rate limit, 502, dead network, truncated search, corrupt or unwritable index, concurrent refresh), redaction, the CLI's exit codes, and _data/fleet.yml decisions: equal to the module's defaults |
required |
ops_cli.py |
file | tools/dash ops: the operation ALLOWLIST from a terminal — list, show, run (the op's own validation and confirm gate; a running console of this checkout gets the job, else it runs here with the same argv), the loops table joined to the slash commands (.claude/commands/), and the console's jobs. Stdlib + PyYAML; never a second code path |
required |
test_ops_cli.py |
file | Offline tests for ops_cli.py (parameters, confirm gate, console routing on a fake client) and the slash commands held to the console: declared ops exist, nothing pre-approved writes or spends, /loops: equals core.LOOPS |
required |
test_decision_index_fixtures.json |
file | GraphQL answers in GitHub's shape for test_decision_index.py (no network) |
required |
pr_queue.py |
file | The PR queue's reads, plans and applies (docs/PR-QUEUE.md): the decision index's pull requests (hub + registry repos) plus one batched GraphQL detail read each — head-commit check runs, changed files, merge settings, review threads, the <!-- fleet:pr-triage --> comment — cached in .fleet/prqueue/detail.json under pr_queue.ttl_s and a time budget; plan() reads every selected pull request live with gh and writes only .fleet/prqueue/plans/<id>.json; apply() re-plans, refuses a plan that moved, refuses merge/close while their switch is off and every write under DASH_CONSOLE_GITHUB_WRITES=off, then runs each op once and records it; run_agent() is local:pr-queue-agent; the model is tools/fleetcore/prqueue.py; /api/prs*, tools/dash prs and the prs* operations call it |
required |
test_pr_queue.py |
file | Offline tests for pr_queue.py on an in-memory gh and GraphQL: plans read live and write nothing, a moved pull request is refused, merge and close refused while off, writes-off refuses every apply, an apply runs exactly the planned argv (merge by the repo's method with --match-head-commit, never --admin), re-runs one at a time, the agent only through its runner and only when on, and the queue's join of the index to the detail read |
required |
subscription.py |
file | The Claude subscription as a discounted rate off API list prices: API-equivalent estimate vs the prorated flat fee per window (effective discount, rate multiplier, value multiple), usage-pace headroom, metered API spend kept separate — never summed | required |
live_collector.py |
file | Host-side collector writing .dash-live/sessions.json (the container cannot see host Claude processes) |
required |
mcp.sh |
file | Bootstraps .venv-mcp from requirements-mcp.txt and execs the MCP server (tools/dash mcp, .mcp.json fleet; --http, --tunnel, --fleet-compat) |
required |
requirements-mcp.txt |
file | The MCP layer's dependencies (mcp, uvicorn), always-latest |
required |
server.json |
file | The MCP layer's MCP Registry manifest (schema 2025-12-11, constitution § 16.4): io.github.bamr87/fleet, version equal to mcp_layer VERSION, the stdio launch through mcp.sh under _meta publisher-provided with env var names only; no packages, remotes or endpoints, never published — linted by tools/mcp_servers_lint.py, docs/mcp-layer.md |
required |
test_subscription.py |
file | Subscription-discount model tests: the 24 h worked example, degraded inputs, honest headroom without plan-limit data, metered N/A, the /api/state and /api/live blocks |
required |
test_mcp_layer.py |
file | MCP layer unit tests — mocked HTTP through the real protocol: writes hidden by default, destructive annotations and the confirm refusal, result trimming, tool errors without the token, HTTP bearer + Host checks | required |
smoke_mcp_layer.py |
file | Live smoke test — the MCP server over stdio against the running console, or a running HTTP server with --url (the remote handshake; fails on zero tools): list tools and resources, call read tools |
required |
docs/ |
dir | Console design notes: mcp-layer.md (the MCP layer: setup, transports, tool catalog), job-status.md (a job's derived state, ages and slowness diagnostics) |
terminal |
design-system/ |
dir | @bamr87/harness-console-ui — the console's EARLIER hand-written look as a small React package, kept as the Claude Design sync source (the live page is web/) (source in src/, built to dist/), and the .design-sync/ config that publishes it to Claude Design |
terminal |
web/ |
dir | The page — React + TypeScript on Mantine, TanStack Query, React Router and xterm.js, built by Vite into web/dist/ (gitignored) that app.py serves; run.sh rebuilds it when its sources change |
terminal |
claude_telemetry.py |
file | /api/claude-telemetry: Claude Code native OTel, read-only — claude_code_* metrics from Prometheus and api_request/tool_result events from Elasticsearch; cost labelled API-equivalent (estimate) |
terminal |
test_claude_telemetry.py |
file | Tests for claude_telemetry.py: totals, window/session validation, no identity fields, degradation |
terminal |
telemetry_query.py |
file | /api/telemetry/prom, /logs, /traces and the prom_query / logs_search / traces_query MCP tools: read-only queries over Prometheus (claude_code_* only), Elasticsearch (logs-fleet.* only) and Phoenix (claude-code-otel only), with a 30-day window, 200-series / 100-hit / 50-row caps, a 10 s timeout, identity labels refused in a query and dropped from answers, and secrets and emails redacted |
terminal |
test_telemetry_query.py |
file | Tests for telemetry_query.py: one case per limit, contract cases over the fixtures, the console routes; a socket guard, no network |
terminal |
test_telemetry_query_fixtures.json |
file | Prometheus, Elasticsearch and Phoenix answers in each store's response shape for test_telemetry_query.py, with synthetic values (no network) |
terminal |
Placement¶
- A new operation → an
OPSentry incore.py(argv builder + validation) and, if it takes a new kind of parameter, a field inweb/src/jobs/OpForm.tsx; every operation is already reachable from the Operations page and the palette. Never a free-form command path. - A new editable contract knob → a field in the matching
CONFIG_SECTIONSentry ofcore.py(declared in_data/fleet.ymlfirst); the form and the API follow from it. - A new credential the console may hold → a
CREDENTIALSentry incore.py; nothing else changes. - A new GitHub write → an
ACTIONSentry and a branch ingithub_link.act(validated params, fleet-scoped, confirm-gated, logged), a button throughweb/src/github/useGhAction.tsx, and a test intest_console.py. Never a merge, delete, push or settings change. - A new API route →
app.py, calling intocore.py; its query hook →web/src/api/hooks.ts. A route family ported to Django (ADR 0006) →backend/under/api/v1/, its FastAPI route deleted in the same change. - A new page →
web/src/pages/, a route inweb/src/main.tsx, an entry inweb/src/nav.ts, and its link builder inweb/src/lib/links.ts(see web/SCHEMA.md). - A view, key or colour the terminal dash shows too →
tools/fleetcore/, served fromapp.py; never a second copy inweb/.
Forbidden¶
- No shell strings built from request data; no credential values in responses or logs (a wrapped tool's own output is scrubbed before it is returned) and none on a command line —
ghis fed over stdin; no commits or pushes from the console.