AUD-49: build the Hub skeleton (hear-route-answer)

- Three inbound routes from docs/hub-api.md: POST /ask, POST /approve, GET /health.
- Five-step pipeline in src/hub, with packages hear, understand, check, route, answer.
- Routing through OmniRoute with the capability list and routing.md. The
  never-route control check runs before any LLM call.
- One real destination: Jervis house TTS, started out of band.
- Fake /ask project (src/tests/fakeproject) for the round-trip test.
- Append-only, size-capped request log. Bearer auth, source match, rate limit.
- Tests: all packages pass, including the fake /ask round trip. Race clean.
- Dockerfile and compose updated to mount routing.md and secrets, log on tmpfs.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-10-10 17:38:24 +11:00
parent 81f9722eee
commit bf80efa25d
33 changed files with 4025 additions and 110 deletions

View File

@@ -83,6 +83,84 @@ announce ran one time.
- The house speaks the result. **DONE.**
- This file records the result. **DONE.**
## Phase 2 — Hub Skeleton (AUD-49)
This phase builds the Hub itself. The shape is frozen in `docs/hub-api.md`. The
code layout is in `docs/outline/03-code-map.md`.
### What was built
- `POST /ask`, `POST /approve`, and `GET /health`.
- The five steps: `hear` → `understand` → `check` → `route` → `answer`.
- Routing through the LLM at OmniRoute, with the capability topics and
`routing.md`.
- The never-route check runs before the LLM. A control action never reaches a
model.
- One real destination: the house speakers (Jervis `/announce`).
- A fake `/ask` project for tests and manual runs.
### Test command
```bash
docker run --rm -v "$PWD/src":/src -w /src golang:1.25-alpine go test ./...
```
Result on 2026-10-10: all packages pass, including the fake `/ask` round trip.
### Live round trip
The Hub ran on port 18788 with `HUB_PROJECTS="compass_nhs=http://127.0.0.1:9199"`
and the fake project on 9199. The real OmniRoute LLM chose the project. Jervis
spoke the reply on the house speakers.
Request:
```json
{
"text": "what does Harry have on today?",
"asker": "sam",
"source": "esp32",
"device": "kitchen-esp32",
"request_id": "01AUD49PROOF"
}
```
Response:
```json
{
"status": "ok",
"request_id": "01AUD49PROOF",
"answer": "Harry has maths and a music lesson today.",
"shape": "speech",
"speech": {"text": "Harry has maths and a music lesson today.", "target": "house"},
"route": {"kind": "project", "project": "compass_nhs"}
}
```
Hub stdout (evidence):
```text
router: model=gpt-4o-mini status=200 elapsed=1.554598547s
speakers: announced 41 chars
```
The routing LLM answered in 1.5 s (inside the 3 s cap). The house announcement
ran out of band and Jervis returned HTTP 200. Jervis has no playback telemetry,
so the HTTP 200 and the spoken reply are the strongest available proof.
### Control action proof
`"cut the kids internet"` returned `status: "refused"`, `route.kind: "refused"`,
`route.reason: "high_consequence_control"`. No LLM call ran for that request.
The unit test `TestControlActionNeverReachesLLM` asserts the zero call count.
### Deploy note
The `docker-compose.yml` mounts `routing.md` and the secrets file read-only, and
uses a `/tmp` tmpfs for the log. To deploy: build the image, then restart the
container. A `HUB_TOKEN_*` key per client must exist in the secrets file first.
## After Phase 1
Follow the build order in `AGENTS.md`. Do not start a destination before the