feat(stage): add opt-in bounded CI editorial test principal

This commit is contained in:
devops authored and devops committed 2026-10-24 13:04:35 +00:00
1 parent ed77f87ab5
commit e036c5d436
15 files changed
+340 -1

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
# Temporary Stage editorial reviewer (disabled by default)
Authority: repository write/CI-dispatch permission plus the existing authenticated,
pinned Stage deployment SSH boundary. This is a narrowly scoped seed operation,
not an API-key actor, owner JWT, or a public bootstrap endpoint. The destructive
legacy seed is not used. `AdminService` shares its normal hashing/persistence and
relational cleanup implementation with the internal command; normal user mutation
role checks remain unchanged. The canonical default administrator is untouched.
## Activation after independent review
1. Promote this commit through the normal Git/CI Stage deployment. Do not run the
seed command against an old image: the embedded immutable SHA must match.
Apply the additive migration through the existing migration deployment step.
2. Dispatch **Owner authorized Stage test principal** on develop with `approval`
exactly `owner-authorized-stage-editorial`, unique `session` such as
`editorial-20261024-a`, `ttl` explicitly 600 (maximum 3600), and `action=open`.
The workflow uses existing DEPLOY_KEY / pinned DEPLOY_KNOWN_HOSTS only.
3. CI reports only `/app/private-stage-test/<session>.json` inside
`canino_backend_stage`. This mode-0600 file in a mode-0700 directory contains
the process-generated password and real persisted-account login tokens.
Consume it only from an approved in-container CI HTTP process; never print,
download, publish as an artifact, or type it into a browser. No owner secret is
needed. Audit records contain events, session and SHA, never credentials.
4. Use this independent reviewer for Gate1 only; the proposer/PMO must be a
distinct actor. Existing self-review checks are not changed. This session does
NOT authorize Gate2, publication, release, general admin APIs, worker identity
replacement, or budget increases. Approve a separate explicit bounded test
budget before running inference; unknown prior reservations remain retained.
5. Dispatch the same workflow/session/ttl with `action=close` immediately after
tests. This revokes persisted authentication BEFORE relational deletion and
removes the private credential file. Close is idempotent when absent.
A host systemd timer is armed before creation for independent TTL cleanup even
if CI disappears. Persisted expiry is checked at login, refresh, and every JWT
request, so killing the timer cannot extend access. Failed cleanup leaves revoked
credentials. Cleanup timer is pinned to the creation SHA: finish/close before
redeploy; if redeployed, use the approved CI recovery session with its recorded
ownership rather than changing an unrelated account. A collision with the exact
ID, email or mobile fails closed; an owned retry with the same secret cannot
extend expiry. The test principal is limited in JWT strategy to task reads,
proposal creation, Gate1 decisions and editorial failure. All other paths deny.
## Verification
Unit guards and existing independent self-review/role tests run with Jest.
`stage-test-principal.integration.spec.ts` is opt-in via
`STAGE_PRINCIPAL_DISPOSABLE_TEST=true` and requires a database URL ending in
`/principal_disposable`; use a new isolated Postgres and Redis, then remove both.
It verifies real account persistence/hash, signed access/refresh login tokens,
collision refusal, nonrenewing retries, request scope, expiry, deletion/revocation.
Never run it against Stage or Production.