swarm credential swap: workers carry a swarm-bot machine token, never an admin PAT (#449 Q1+Q4) #506

Closed
opened 2026-08-14 02:52:41 +00:00 by ben · 6 comments
Owner

From #449 (Ben's ruling 2026-08-13, Q1+Q4): the swarm workers must carry a scoped machine-user token, not an admin PAT. Verified during the ruling: the token in the swap path is ben with is_admin=true — every worker sandbox currently holds a full forge-admin credential as a read-only file.

The swap (human hands — forge admin + org secret rotation)

  1. Confirm what the org Actions secret SWARM_FORGEJO_TOKEN currently holds (expected: the same admin PAT; verified locally in .sandcastle/.env).
  2. POST /api/v1/admin/users → machine user swarm-bot (noreply email, strong password stored in Ben's password manager, must_change_password: false).
  3. Add swarm-bot as write collaborator on Matou/ourcloud and Matou/matou-app (PUT /repos/{owner}/{repo}/collaborators/swarm-bot with {"permission":"write"}).
  4. As swarm-bot (basic auth): POST /api/v1/users/swarm-bot/tokens with scopes write:repository, write:issue — the minimum the workers use (branch push, issue close/comment/labels).
  5. Rotate the org Actions secret SWARM_FORGEJO_TOKEN to the new token (covers both repos' workflows). Update host-side manual-run residue where present (.sandcastle/secrets/forgejo_token is materialized from env per run; workstation/elitebook crontab env if any).
  6. Prove: dispatch a swarm run; a full claim→work→push→close cycle must go green on the machine token (claim comment, agent-working PUT, branch push, close-report).
  7. Afterwards: rotate Ben's personal admin PAT (it has been riding in worker sandboxes since the pool went live) — his laptop keeps a personal token for walk sessions; the swarm never sees it again.

Rollback: the old PAT stays valid until step 6, so a red at step 5 = set the secret back and diagnose.

Escalation posture this buys (Q4): without admin/org scope a worker cannot mint tokens, reach other repos, or widen itself — enforced by the credential, not by prompt. See docs/architecture/07-secrets-architecture.md (#449 rulings entry).

**From #449 (Ben's ruling 2026-08-13, Q1+Q4): the swarm workers must carry a scoped machine-user token, not an admin PAT.** Verified during the ruling: the token in the swap path is `ben` with `is_admin=true` — every worker sandbox currently holds a full forge-admin credential as a read-only file. ## The swap (human hands — forge admin + org secret rotation) 0. Confirm what the org Actions secret `SWARM_FORGEJO_TOKEN` currently holds (expected: the same admin PAT; verified locally in `.sandcastle/.env`). 1. `POST /api/v1/admin/users` → machine user `swarm-bot` (noreply email, strong password stored in Ben's password manager, `must_change_password: false`). 2. Add `swarm-bot` as **write** collaborator on `Matou/ourcloud` and `Matou/matou-app` (`PUT /repos/{owner}/{repo}/collaborators/swarm-bot` with `{"permission":"write"}`). 3. As `swarm-bot` (basic auth): `POST /api/v1/users/swarm-bot/tokens` with scopes `write:repository, write:issue` — the minimum the workers use (branch push, issue close/comment/labels). 4. Rotate the **org** Actions secret `SWARM_FORGEJO_TOKEN` to the new token (covers both repos' workflows). Update host-side manual-run residue where present (`.sandcastle/secrets/forgejo_token` is materialized from env per run; workstation/elitebook crontab env if any). 5. Prove: dispatch a swarm run; a full claim→work→push→close cycle must go green on the machine token (claim comment, `agent-working` PUT, branch push, close-report). 6. Afterwards: rotate Ben's personal admin PAT (it has been riding in worker sandboxes since the pool went live) — his laptop keeps a personal token for walk sessions; the swarm never sees it again. Rollback: the old PAT stays valid until step 6, so a red at step 5 = set the secret back and diagnose. Escalation posture this buys (Q4): without `admin`/org scope a worker cannot mint tokens, reach other repos, or widen itself — enforced by the credential, not by prompt. See `docs/architecture/07-secrets-architecture.md` (#449 rulings entry).
Author
Owner

Relabelled ready-for-session under ADR 0174: steps 0–5 are executable by a session holding the admin PAT (mint swarm-bot, collaborator grants, scoped token, org-secret rotation, green-cycle proof) and are reversible while the old PAT stays valid. The Ben residue — storing the generated password in his password manager and step 6 (rotating his personal PAT) — is one-way-door and rides the next digest.

Relabelled `ready-for-session` under ADR 0174: steps 0–5 are executable by a session holding the admin PAT (mint `swarm-bot`, collaborator grants, scoped token, org-secret rotation, green-cycle proof) and are reversible while the old PAT stays valid. The Ben residue — storing the generated password in his password manager and step 6 (rotating his personal PAT) — is one-way-door and rides the next digest.
Author
Owner

This was generated by AI during triage.

Triage: added the missing category label; state (ready-for-session, already reasoned in this thread) left as-is.

> *This was generated by AI during triage.* **Triage:** added the missing category label; state (`ready-for-session`, already reasoned in this thread) left as-is.
Author
Owner

Session-runner pass under ADR 0174 (docs/adr/0174-two-way-door-rulings-default-to-the-agent.md). Findings, then the routing.

Step 0 (confirm the org secret) — partially done, read-only. GET /api/v1/orgs/Matou/actions/secrets shows SWARM_FORGEJO_TOKEN exists, created_at: 2026-07-23T07:23:26Z, never rotated since (Forgejo's secrets API is write-only — no value readback, only created_at). Consistent with the ticket's expectation that it still holds the original admin PAT; can't be fully confirmed byte-for-byte without a human comparing it against wherever that PAT is recorded, since neither the API nor this session can read a secret's value.

Steps 1–3 (mint swarm-bot) — blocked, needs Ben, both technically and by policy.

  • Technical: this session's FORGEJO_TOKEN resolves to ben, is_admin: true — but GET /api/v1/admin/users 403s with token does not have at least one of required scope(s): [read:admin]. The account is admin; the token isn't scoped for the admin user-management API. POST /api/v1/admin/users (step 1) needs a credential with admin token scope, which nothing in this session's standing carries. This isn't a policy choice to route around — no token available to the swarm or this session can mint a forge user.
  • Policy: step 1 also asks for the new password to be "stored in Ben's password manager" — ADR 0174's one-way-door list names "the password manager" explicitly. Not something a session can do regardless of token scope.
  • Steps 2–3 are downstream of 1 (need swarm-bot to exist, then its password for the basic-auth token mint), so they inherit the same block.

Step 6 (rotate Ben's personal PAT) — one-way door by name. ADR 0174's list: "Ben's own PAT/tokens" — explicit, no ambiguity.

Steps 4–5 are genuinely two-way (org-secret rotation while the old credential stays valid is named directly in ADR 0174 as agent-executable; the claim→work→push→close proof is provable by the existing swarm cycle) but are sequentially gated behind 1–3 — there's no swarm-bot token yet to rotate in or prove against. Nothing to land this session.

Why human

Ben's hands + a one-way-door ruling: mint swarm-bot via the forge admin UI (or a session token he holds that actually carries admin scope) and its noreply-email/strong-password per step 1, store the password in his password manager, add it as write collaborator on both repos (step 2), mint its write:repository, write:issue token (step 3) — then either finish steps 4–6 himself, or drop the new token as a host-only secret (per this session's own secrets rule) so a follow-up ready-for-session pass can execute step 4 (org secret rotation) and step 5 (proof dispatch) as two-way doors, leaving only step 6 (his personal PAT rotation) for him.

Leaving this ready-for-human; relabelling now. Ruled by agent under ADR 0174 — veto anytime.

Session-runner pass under ADR 0174 (`docs/adr/0174-two-way-door-rulings-default-to-the-agent.md`). Findings, then the routing. **Step 0 (confirm the org secret) — partially done, read-only.** `GET /api/v1/orgs/Matou/actions/secrets` shows `SWARM_FORGEJO_TOKEN` exists, `created_at: 2026-07-23T07:23:26Z`, never rotated since (Forgejo's secrets API is write-only — no value readback, only `created_at`). Consistent with the ticket's expectation that it still holds the original admin PAT; can't be fully confirmed byte-for-byte without a human comparing it against wherever that PAT is recorded, since neither the API nor this session can read a secret's value. **Steps 1–3 (mint `swarm-bot`) — blocked, needs Ben, both technically and by policy.** - Technical: this session's `FORGEJO_TOKEN` resolves to `ben`, `is_admin: true` — but `GET /api/v1/admin/users` 403s with `token does not have at least one of required scope(s): [read:admin]`. The *account* is admin; the *token* isn't scoped for the admin user-management API. `POST /api/v1/admin/users` (step 1) needs a credential with `admin` token scope, which nothing in this session's standing carries. This isn't a policy choice to route around — no token available to the swarm or this session can mint a forge user. - Policy: step 1 also asks for the new password to be "stored in Ben's password manager" — ADR 0174's one-way-door list names "the password manager" explicitly. Not something a session can do regardless of token scope. - Steps 2–3 are downstream of 1 (need `swarm-bot` to exist, then its password for the basic-auth token mint), so they inherit the same block. **Step 6 (rotate Ben's personal PAT) — one-way door by name.** ADR 0174's list: "Ben's own PAT/tokens" — explicit, no ambiguity. **Steps 4–5 are genuinely two-way** (org-secret rotation while the old credential stays valid is named directly in ADR 0174 as agent-executable; the claim→work→push→close proof is provable by the existing swarm cycle) **but are sequentially gated behind 1–3** — there's no `swarm-bot` token yet to rotate in or prove against. Nothing to land this session. ## Why human Ben's hands + a one-way-door ruling: mint `swarm-bot` via the forge admin UI (or a session token he holds that actually carries `admin` scope) and its noreply-email/strong-password per step 1, store the password in his password manager, add it as write collaborator on both repos (step 2), mint its `write:repository, write:issue` token (step 3) — then either finish steps 4–6 himself, or drop the new token as a host-only secret (per this session's own secrets rule) so a follow-up `ready-for-session` pass can execute step 4 (org secret rotation) and step 5 (proof dispatch) as two-way doors, leaving only step 6 (his personal PAT rotation) for him. Leaving this `ready-for-human`; relabelling now. Ruled by agent under ADR 0174 — veto anytime.
Author
Owner

Steps 1–3 done (Ben's session, 2026-08-19): swarm-bot machine user created (private, noreply email, password in Ben's manager), write collaborator on Matou/ourcloud + Matou/matou-app, scoped token minted (write:issue,write:repository only). Proven: push=true on both repos, /api/v1/admin/* = 403.

Remaining: step 4 (rotate org Actions secret SWARM_FORGEJO_TOKEN to the swarm-bot token — awaiting Ben's go in-session), step 5 (watch the next swarm run go green on the new credential; rollback = set the secret back), step 6 (afterwards, Ben rotates his personal admin PAT).

**Steps 1–3 done (Ben's session, 2026-08-19):** `swarm-bot` machine user created (private, noreply email, password in Ben's manager), write collaborator on `Matou/ourcloud` + `Matou/matou-app`, scoped token minted (`write:issue,write:repository` only). Proven: push=true on both repos, `/api/v1/admin/*` = 403. Remaining: step 4 (rotate org Actions secret `SWARM_FORGEJO_TOKEN` to the swarm-bot token — awaiting Ben's go in-session), step 5 (watch the next swarm run go green on the new credential; rollback = set the secret back), step 6 (afterwards, Ben rotates his personal admin PAT).
Author
Owner

Step 5 PROVEN (2026-08-19 ~19:00–20:10Z): org secret rotated to the swarm-bot token in-session; subsequent swarm runs all green and issue actions now authored by swarm-bot (first proof: the 19:06 swarm-claim comment on #594). Remaining: step 6 — Ben rotates his personal admin PAT (it rode in worker sandboxes since the pool went live). Note for the rotation: the dev laptop's .sandcastle/secrets/forgejo_token holds that PAT and must be updated with the re-minted one.

**Step 5 PROVEN (2026-08-19 ~19:00–20:10Z):** org secret rotated to the swarm-bot token in-session; subsequent swarm runs all green and issue actions now authored by `swarm-bot` (first proof: the 19:06 swarm-claim comment on #594). Remaining: **step 6 — Ben rotates his personal admin PAT** (it rode in worker sandboxes since the pool went live). Note for the rotation: the dev laptop's `.sandcastle/secrets/forgejo_token` holds that PAT and must be updated with the re-minted one.
Author
Owner

Step 6 done, 2026-08-25 (interactive session) — the swap is complete end to end.

Ben regenerated the admin PAT in the Forgejo UI (regeneration invalidates the old value — the token that rode readable in every worker sandbox since the pool went live is now dead), and both laptop homes were updated in the same sitting: ~/.git-credentials and .sandcastle/secrets/forgejo_token (.sandcastle/.env carried no FORGEJO_TOKEN= line to update). Verified live: GET /user with the new credential answers as ben (admin), and git fetch auth against origin works.

Recap of the whole ticket: workers carry the scoped swarm-bot machine token via the org Actions secret (steps 1–5, proven 2026-08-19 — issue actions author as swarm-bot); the exposed admin credential is retired (step 6, today). No worker sandbox holds forge-admin anything.

**Step 6 done, 2026-08-25 (interactive session) — the swap is complete end to end.** Ben **regenerated** the admin PAT in the Forgejo UI (regeneration invalidates the old value — the token that rode readable in every worker sandbox since the pool went live is now dead), and both laptop homes were updated in the same sitting: `~/.git-credentials` and `.sandcastle/secrets/forgejo_token` (`.sandcastle/.env` carried no `FORGEJO_TOKEN=` line to update). Verified live: `GET /user` with the new credential answers as `ben` (admin), and git fetch auth against `origin` works. Recap of the whole ticket: workers carry the scoped `swarm-bot` machine token via the org Actions secret (steps 1–5, proven 2026-08-19 — issue actions author as `swarm-bot`); the exposed admin credential is retired (step 6, today). No worker sandbox holds forge-admin anything.
ben closed this issue 2026-08-26 01:34:17 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#506
No description provided.