Define and implement multi-repo onboarding mechanism (WP-0006-T07)

specs/TrustServiceOnboarding.md defines the mechanism: a Phase Manifest
file is committed to the declaring repo (durable, independently
foldable forever) and separately registered with the hosted service;
once registered, the Ledger's live authoritative copy is the hosted
service only, not a second competing file. Licensor token bootstrapping
is explicitly out of scope here (a WP-0008-T01 governance action).

scripts/trf_onboard.py: a dependency-light CLI (stdlib urllib +
target_revenue.validation only, no FastAPI/psycopg needed to onboard a
Phase) with validate/register-phase/append-entry/status subcommands.
The Licensor token is read only from a named environment variable,
never accepted as a literal argument.

tests/test_trf_onboard.py (4 tests, no network/Docker) proves
invalid-manifest and missing-token-env cases fail before any HTTP
attempt, by monkeypatching the request function to raise if called.
tests/test_onboarding_hosted.py (1 Docker-gated test) runs an actual
uvicorn server on a real socket and drives the full
register -> append -> status round trip through the CLI as an external
repo would invoke it.
This commit is contained in:
tegwick 2026-07-29 22:00:34 +02:00
parent 45b9fbd765
commit ee4cf14cbc
6 changed files with 530 additions and 2 deletions

View file

@ -273,7 +273,7 @@ passing under the Docker-gated suite; no stray containers left running.
```task
id: TREV-WP-0006-T07
status: todo
status: done
priority: medium
state_hub_task_id: "44c5846e-1f37-41fe-8ac0-fc7d88628e9f"
```
@ -287,6 +287,32 @@ Trust Service (the registration call). Coordinate with
the actual first repos — this task defines the mechanism, not the pilot
selection.
**Result:** `specs/TrustServiceOnboarding.md` defines the mechanism: a
Phase Manifest file is committed to the declaring repo (durable,
git-history-backed, independently foldable forever) *and* registered with
the hosted service (the multi-tenant, publicly-servable copy); once
registered, the Ledger's live authoritative copy is the hosted service
only, not a second competing file — a repo may keep periodic exports for
its own offline re-verification, but those are copies, not a source of
truth. Licensor token bootstrapping is explicitly out of this mechanism's
scope (a WP-0008-T01 governance action). `scripts/trf_onboard.py`
implements it as a dependency-light CLI (stdlib `urllib` + the existing
`target_revenue.validation`, no FastAPI/psycopg required to onboard a
Phase) with four subcommands: `validate` (offline only, no network),
`register-phase` (validates offline before ever attempting the network
call), `append-entry`, and `status` (public, no token). The Licensor API
token is read only from an environment variable named on the command
line, never accepted as a literal argument or committed. `tests/test_trf_onboard.py`
(4 tests, no network, no Docker) proves both invalid-manifest and
missing-token-env cases fail before any HTTP attempt is made — asserted by
monkeypatching the request function to raise if called at all.
`tests/test_onboarding_hosted.py` (1 Docker-gated test) is the one test in
the suite that runs an actual `uvicorn` server on a real socket (rather
than FastAPI's in-process TestClient, since the CLI genuinely speaks HTTP)
and drives the full register → append → status round trip through the CLI
exactly as an external repo would invoke it. Full suite: 49 passing
offline, 71 passing with Docker; no stray containers left running.
## Conformance test suite at hosted scale
```task