- Python 76%
- JavaScript 17.6%
- CSS 5.4%
- Shell 0.6%
- HTML 0.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
CI / Sanity check (ubuntu-latest) (push) Successful in 28s
# feat: roster serves TLS on both surfaces, with required material ## What this is Part of the fleet **app-tier TLS** change. Design and plan live in the `starfleet` docs repo: - `docs/superpowers/specs/2026-10-17-app-tier-tls-design.md` - `docs/superpowers/plans/2026-10-17-app-tier-tls.md` - `docs/superpowers/plans/2026-10-17-app-tier-tls-runbook.md` (the live cutover) Roster served plain HTTP on `:4020` (API + admin UI) and `:4021` (MCP). The admin UI carried a bearer token in `localStorage` over cleartext, and the MCP surface was reached over cleartext. Nothing in the roster docs mentioned transport security — the plaintext default was by omission, not by decision. After this branch roster can only serve TLS, and a missing **or partial** `tls_cert`/`tls_key` pair is a startup error naming the missing key rather than a silent plaintext fallback. ## Change **Config.** `[api] tls_cert` / `tls_key` and a new `[trust] ca_bundle`, mapped to `api_tls_cert`, `api_tls_key`, `trust_ca_bundle`, all joined to `_PATH_FIELDS`. Parsing stays validation-free — `load_config` is used by non-serving commands, so the required-pair check lives in the serve paths. **One assembly point.** `server_kwargs(cfg)` builds the uvicorn kwargs and raises `ConfigError` naming `tls_cert` or `tls_key` on an incomplete pair. Both `serve()` and `mcp_server.main()` consume it, so the two surfaces cannot diverge — and it is evaluated **before** `roster.start()`, so a bad pair no longer fires a scheduler tick first. **The MCP surface needed real work.** The installed `mcp` SDK's `run_streamable_http_async` builds its own `uvicorn.Config` and exposes **no** ssl arguments, so it cannot serve TLS. It now builds `streamable_http_app(...)` and runs our own `uvicorn.Config`, preserving every other transport default of the helper it replaced — including `host=`, without which DNS-rebinding protection would auto-enable for `127.0.0.1` while bound to `0.0.0.0` and 403 real LAN clients. **Outbound trust.** New `trust.py::resolve_ca_bundle` resolves `--ca-bundle` → `$STARFLEET_CA_BUNDLE` → `[trust] ca_bundle` → `ConfigError` naming all three, and **validates** the resolved bundle with `load_verify_locations`. A path that is missing or is not a PEM therefore fails at resolution, naming the setting and the path — not at the first request, where it would look like "the server is down" (and, for the MCP process, only after it had already bound its socket). `RosterClient` gained a `ca_bundle` parameter; `delivery.py`'s crew POST uses the resolved bundle; the MCP process talks to the API over `https://127.0.0.1:<api_port>`. **Two config hazards fixed.** `Config.expand()` now leaves an empty path value empty — the new TLS fields are the first empty-default `_PATH_FIELDS` members, and `Path("")` becomes `"."`, which would have made the required-pair check unfirable. And `serve()`/`mcp_server.main()` now expand the loaded config at all: they never did, and a `~/.config/…` cert path would have reached uvicorn raw. **CLI.** `--ca-bundle` (global to the client subcommands, as in crew); the default `--url` is now `https://127.0.0.1:4020`. `main()` catches `ConfigError` for **every** command, so a missing or unreadable CA prints a clean `error: …` and exits 1 instead of a stack trace — `serve`/`mcp` still refuse to start, which is the intended loud failure; only the presentation changed. **Docs.** README (TLS section, CA resolution order, `https` URLs) and `roster.toml.example`. ## Verification Sandbox suite at the branch head: **235 passed**, `ruff check` / `ruff format --check` / `mypy src/` clean. ```bash cd $HOME/dev/starfleet/roster export UV_CACHE_DIR=/tmp/opencode/uv-cache # ~/.cache/uv is read-only in the sandbox uv sync --quiet # host-made .venv is unusable in-sandbox env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy \ uv run ruff check src/ tests/ && uv run ruff format --check src/ tests/ \ && uv run mypy src/ && uv run pytest tests/ -q ``` Verification is proven by real TLS, not mocks: one test stands up a self-signed TLS peer and asserts both the positive control (trusting the peer's own cert succeeds) and the negative (a different bundle refuses the handshake); another serves the real `streamable_http_app` under a real `uvicorn.Server` with a self-signed leaf and completes a handshake against `/mcp`. Tests that asserted plaintext behaviour were **inverted, not deleted**. ## Cross-repo / ops - `crew` and `communicator-esp32` carry the sibling pieces. - The live cutover is **not** part of this branch; it is the runbook in the `starfleet` docs repo, deliberately ordered **server-first** so the OpenCode MCP URL is flipped only after roster serves TLS. ## Deferred minors (triaged ship) - The MCP surface's uvicorn log level is hardcoded to `info` (equals the SDK's effective default today). - Client commands that need no config now read the default config path to reach the `[trust] ca_bundle` tier. - No `--ca-bundle` on `serve`; env and config cover the delivery POST. - `delivery.py` requires a resolvable CA even when the target URL is plaintext — one contract beats a conditional one. - `selftest`'s mid-poll API loss now prints `error:` rather than `selftest FAIL:`; `doctor`'s newly clean error path is untested. - The mandated TLS tests inherit the certificate helper's `pytest.skip` when `openssl` is absent (green-by-skip on such a machine). - `verify=<str>` is deprecated in httpx 0.28.1 — this is a **plan** flaw (the plan mandated the string form); verification is on today, but a future httpx bump removes the form. Migration is to pass an `ssl.SSLContext`. Co-authored-by: Troed Sångberg <github@troed.se> Reviewed-on: #5 |
||
| .forgejo/workflows | ||
| docs/superpowers | ||
| scripts | ||
| src/roster | ||
| systemd | ||
| tests | ||
| .gitignore | ||
| AGENTS.md | ||
| deploy.sh | ||
| LICENSE | ||
| pyproject.toml | ||
| README.md | ||
| roster.toml.example | ||
| uv.lock | ||
roster
Resident scheduler for the home network. script, llm and agent jobs,
created by you from the CLI or by LLM agents over MCP; results land in
output files, ntfy, Matrix, and crew.
Design doc: docs/superpowers/specs/2026-08-24-roster-design.md.
Architecture
Two systemd user units on the server host:
roster serve— FastAPI JSON API on :4020 (HTTPS) plus the 30 s tick loop. Owns the SQLite store (WAL) and runs every job.roster mcp— streamable-HTTP MCP server on :4021 (HTTPS) whose nine tools are thin HTTPS calls to the API (including an ad-hocnotify).
The CLI is a thin client too. One mutation path: everything goes through the service process.
Job types:
| type | runs |
|---|---|
script |
an allowlisted executable under [scripts] dir (optional gate script first) |
llm |
one chat completion against an OpenAI-compatible endpoint |
agent |
opencode run --agent <name> on the workstation over SSH |
Schedules: interval (30m, 2h), cron (5-field), at (one-shot;
fires immediately when the time is now/past).
Semantics worth knowing: catch-up window 900 s (older due events are
recorded as skipped(misfire)); no overlapping runs; unreachable LLM
endpoint defers instead of failing (one alert per episode, completion notes
"after N deferrals"); 3 consecutive failures alert once; [SILENT] in
llm/agent output suppresses ntfy and Matrix but not the file.
TLS
Both surfaces serve HTTPS only, and TLS material is required: [api] tls_cert
and [api] tls_key must both be set in roster.toml, or the process refuses
to start naming the missing key. Point them at PEM files readable by the
service on the server host (deploy.sh copies config, scripts and units but not
the certificates); the certificate must cover the host names clients use.
Outbound calls (CLI, MCP, crew delivery) verify the fleet's private CA. The CA
bundle is resolved in this order: an explicit --ca-bundle flag, then
$STARFLEET_CA_BUNDLE, then [trust] ca_bundle in roster.toml. When none is
set roster fails loudly rather than falling back to the system trust store. The
CLI's default URL is https://127.0.0.1:4020; roster mcp talks to
https://127.0.0.1:<api_port> using the same resolved bundle.
Where jobs run
Jobs execute on the machine hosting the roster API (the deploy target), never on the machine running the CLI or an MCP client. Consequences:
script_pathandgatemust be executables inside[scripts] diron the server host; the API rejects anything else, naming both the given path and the allowed dir.- An MCP client on another machine only talks HTTPS to the server host —
copy scripts into its scripts dir (e.g.
scp) before scheduling. - CLI and MCP clients surface the API's detail message on errors
(e.g.
roster API 422: script path '...' is outside the allowlist dir '...'), so a rejection tells you exactly which path to move.
Quickstart
uv sync --group dev
cp roster.toml.example ~/.config/roster/roster.toml # then edit ntfy_url/token
mkdir -p ~/.config/roster/scripts
export SERVER_HOST=... SERVER_USER=... SERVER_REPO_DIR=... # deploy target
./deploy.sh # installs + starts both units
roster selftest
roster add --id ping --type script --interval 30m \
--script-path ~/.config/roster/scripts/sample_ping.sh
roster list
roster runs ping
CLI
roster add | list | show | update | pause | resume | run | rm | runs,
roster notify (ad-hoc Matrix message), plus serve, mcp, selftest,
doctor [--reset-locks].
MCP clients
Computer (mcp.json):
{ "type": "http", "url": "https://<server-host>:4021/mcp" }
Workstation opencode: add the same URL as a remote MCP server. Agents can
then schedule work; allow_agent_scheduling = false rejects all mutating
requests from non-CLI clients.
Matrix
Matrix is a delivery target like ntfy, configured server-side under
[delivery] (matrix_homeserver, matrix_user, matrix_password,
matrix_room). Roster maintains its own login (token cached at
~/.local/share/roster/matrix_token, transparent re-login on expiry) using
a dedicated bot account — no E2EE, plain rooms only, messages sent as
m.notice.
Setup
- Create a dedicated bot account for roster in the Matrix admin UI
(Settings -> Users -> Add user; e.g. localpart
computer). - Create a plain room (no E2EE) and invite the bot from your account. Roster auto-joins the room on first send, so no manual join is needed.
- In
roster.tomlunder[delivery]:matrix_homeserver— full homeserver URL with scheme, e.g."https://matrix.example.org"(a bare hostname fails at runtime).matrix_user— the bot's localpart ("computer") or full ID ("@computer:example.org").matrix_password— the bot account password.matrix_room— the room's ID,!opaque:serverform (in Element: room settings -> copy room ID). Must be a room the bot is invited to.
Per job: include matrix in delivery (CLI --delivery file,matrix,
MCP delivery: ["matrix"]); an optional matrix_room in the job spec
overrides the default room. Failures are recorded in the run file and never
fail the job.
Ad-hoc notifications, independent of any job:
roster notify "deploy done" --title "roster" # CLI
POST /notify {"text": "...", "title": "...", "room": "..."} # API
notify(text, title?, room?) # MCP tool
Crew delivery
Crew is a delivery target like Matrix, configured server-side under
[delivery] (crew_url, crew_token). On a completed run roster POSTs
{"user_id", "context_key", "content", "fetched_at"} to crew's
/internal/context endpoint with Authorization: Bearer <crew_token> —
content is truncated to 8000 chars and fetched_at is ISO-8601 UTC; crew
stores it as that user's latest context under the given key.
Per job: include crew in delivery (MCP/API delivery: ["crew"]). Script
jobs only, and they must set crew_user_id and crew_context_key —
validation rejects crew jobs without them; llm and agent jobs reject those
fields. Unlike ntfy and Matrix, [SILENT] does not suppress crew delivery
(the delivery is the job's purpose); empty output skips it. Failures are
noted on the run and never change its status.
In roster.toml under [delivery]:
crew_url— full URL of crew's ingest endpoint, e.g."https://<crew-host>:<port>/internal/context". The host must be a name crew's TLS leaf covers (its LAN IP or short hostname) — roster verifies it — so not the fully-qualified name unless crew's leaf carries it.crew_token— crew's[ingest] token(an empty token sends no auth header, which crew treats as trust-the-LAN).
Crew provisions these jobs itself through the normal HTTPS API — the roster side is only the URL/token above.
Script jobs also take an optional env field, a mapping of strings to
strings merged into the script's environment — handy for user parameters
(e.g. which city a weather script should fetch).
Operations
journalctl --user -u roster -n 100 # engine/API logs
journalctl --user -u roster-mcp -n 100 # MCP logs
roster doctor # integrity check
roster doctor --reset-locks # repair stale running rows
Admin UI
roster serve also serves a small operator console at
https://<serve-host>:4020/admin — no build step, no extra dependency. It
uses the bearer token from [api] token; the token is stored only in the
browser (localStorage key roster_token) and sent as a bearer header. The
console lists, creates, edits, pauses/resumes, runs and deletes jobs, shows
per-job run history, sends an ad-hoc notification, and reports health. It
polls the API for freshness; there is no push transport.