wire the reseed publish step into .forgejo (protected-path residual of #601) #606

Closed
opened 2026-08-20 00:36:23 +00:00 by matou-build-agent · 3 comments

Problem

The reseed pipeline's publish half (#601, ADR 0185) needs a Forgejo Actions step that runs on green push to main and invokes scripts/bootstrap-reseed/publish.sh (build agent-x86_64 + sha256 + RELEASE → Forgejo generic package registry). That step lives in .forgejo/workflows/ — a protected path a Sandcastle agent may not edit (#445 tree-fingerprint rollback). So #601 shipped the tested publish logic but not its CI trigger; the pipeline cannot publish until this lands.

Proposed fix

Add a job/step to .forgejo/workflows/ci.yml (or a new .forgejo/workflows/publish-agent.yml) that, only when the seam job is green and on push to main:

- name: Publish agent reseed candidate
  if: github.ref == 'refs/heads/main' && success()
  env:
    FORGEJO_TOKEN: ${{ secrets.SWARM_FORGEJO_TOKEN }}   # write:package scope
    FORGEJO_SERVER: ${{ github.server_url }}
    GIT_SHA: ${{ github.sha }}
    GIT_BASE: ${{ github.event.before }}
  run: bash scripts/bootstrap-reseed/publish.sh

Notes for the session:

  • publish.sh already self-guards on the agent-affecting set (OC_BOOTSTRAP_AGENT_PATHS = agent/ go.mod go.sum internal/) and no-ops on docs-only ranges and on re-publishing an existing sha (409 idempotent) — so a paths: filter is optional, not required for correctness.
  • The PAT (SWARM_FORGEJO_TOKEN) needs write:package scope on Matou; confirm/extend it.
  • github.event.before is the diff base for the agent-affected guard; on the first run it may be the zero-sha — publish.sh tolerates a bad base by simply publishing (guard is belt-and-braces; the workflow gate is primary).

Why ready-for-session (not ready-for-human)

Per ADR 0174 / #445: a protected .forgejo/ change needs an interactive session's standing, not Ben. The change is a two-way door (a workflow step, revertible by commit; provable by the published package appearing after a green main push). A session rules on it, escalating to ready-for-human only if it finds a genuine one-way door (e.g. widening the PAT scope counts as a security-posture call — rule that explicitly).

Found while implementing #601 (the reseed pipeline). Companion residual: the droplet-side timer install remains on #601 for Ben.

## Problem The reseed pipeline's **publish half** (#601, ADR 0185) needs a Forgejo Actions step that runs on green push to `main` and invokes `scripts/bootstrap-reseed/publish.sh` (build `agent-x86_64` + sha256 + RELEASE → Forgejo generic package registry). That step lives in `.forgejo/workflows/` — a **protected path** a Sandcastle agent may not edit (#445 tree-fingerprint rollback). So #601 shipped the tested publish *logic* but not its CI trigger; the pipeline cannot publish until this lands. ## Proposed fix Add a job/step to `.forgejo/workflows/ci.yml` (or a new `.forgejo/workflows/publish-agent.yml`) that, **only when the `seam` job is green** and on `push` to `main`: ```yaml - name: Publish agent reseed candidate if: github.ref == 'refs/heads/main' && success() env: FORGEJO_TOKEN: ${{ secrets.SWARM_FORGEJO_TOKEN }} # write:package scope FORGEJO_SERVER: ${{ github.server_url }} GIT_SHA: ${{ github.sha }} GIT_BASE: ${{ github.event.before }} run: bash scripts/bootstrap-reseed/publish.sh ``` Notes for the session: - `publish.sh` already **self-guards** on the agent-affecting set (`OC_BOOTSTRAP_AGENT_PATHS` = `agent/ go.mod go.sum internal/`) and no-ops on docs-only ranges and on re-publishing an existing sha (409 idempotent) — so a `paths:` filter is optional, not required for correctness. - The PAT (`SWARM_FORGEJO_TOKEN`) needs **write:package** scope on `Matou`; confirm/extend it. - `github.event.before` is the diff base for the agent-affected guard; on the first run it may be the zero-sha — `publish.sh` tolerates a bad base by simply publishing (guard is belt-and-braces; the workflow gate is primary). ## Why ready-for-session (not ready-for-human) Per ADR 0174 / #445: a protected `.forgejo/` change needs an interactive session's standing, not Ben. The change is a two-way door (a workflow step, revertible by commit; provable by the published package appearing after a green main push). A session rules on it, escalating to `ready-for-human` only if it finds a genuine one-way door (e.g. widening the PAT scope counts as a security-posture call — rule that explicitly). Found while implementing #601 (the reseed pipeline). Companion residual: the droplet-side timer install remains on #601 for Ben.
Author
Member

Ruled by agent under ADR 0174 — veto anytime.

Landed the two-way-door part: a33d153 adds a publish job to
.forgejo/workflows/ci.yml (needs: seam, gated github.event_name == 'push' && github.ref == 'refs/heads/main' — never pull_request or
workflow_dispatch), checking out full history (fetch-depth: 0, required
so publish.sh's oc_reseed_agent_affected guard can resolve
GIT_BASE..GIT_SHA) and running scripts/bootstrap-reseed/publish.sh (#601)
inside nix develop, same PATH fix as the seam job.

Proof it actually fires, in order, on the real trigger: the push ran
ci run #7938 —
seam succeeded, then publish ran (only after seam was green, only on
this push-to-main) and succeeded. Its range (8ccebac..a33d153) touched only
.forgejo/ and STATUS.md, so oc_reseed_agent_affected correctly computed
"not agent-affecting" against full history and no-op'd before ever calling
the package API — the job order/gating/checkout-depth are proven; the actual
upload path (the part that needs write:package) is not yet exercised by
this run and will only run for real on the next agent-affecting push (touching
agent/, go.mod, go.sum, or internal/).

One-way-door residual, not ruled — routing to ready-for-human:
SWARM_FORGEJO_TOKEN is a swarm-bot machine-user PAT deliberately scoped to
write:repository + write:issue only, per Ben's explicit #449 ruling
bounding what a swarm credential can do ("without admin/org scope a worker
cannot mint tokens, touch other repos, or widen itself" —
docs/architecture/07-secrets-architecture.md). It has no write:package
scope. Forgejo PATs can't have scopes added after creation — extending it
means minting a new PAT (interactive login to the swarm-bot account) and
swapping the org secret. That's a security-posture widening of a credential
Ben named explicitly, and minting it needs an account credential this
session doesn't hold — ADR 0174's one-way-door list (personal/account
credentials + security-posture widenings), not something a session
self-authorizes.

Why human

Ben: either (a) mint a new swarm-bot PAT with write:package added and
PUT /api/v1/orgs/Matou/actions/secrets/SWARM_FORGEJO_TOKEN the new value,
or (b) rule that write:package should NOT go on the shared swarm token and
name an alternative (e.g. a narrower publish-only token as its own org
secret). Once the token is right, the wiring above needs no further changes
— the next agent-affecting push to main will publish for real. No agent
action possible past this point.

Companion residual (droplet-side timer install) remains on #601, also Ben's.

**Ruled by agent under ADR 0174 — veto anytime.** Landed the two-way-door part: `a33d153` adds a `publish` job to `.forgejo/workflows/ci.yml` (`needs: seam`, gated `github.event_name == 'push' && github.ref == 'refs/heads/main'` — never `pull_request` or `workflow_dispatch`), checking out full history (`fetch-depth: 0`, required so `publish.sh`'s `oc_reseed_agent_affected` guard can resolve `GIT_BASE..GIT_SHA`) and running `scripts/bootstrap-reseed/publish.sh` (#601) inside `nix develop`, same PATH fix as the `seam` job. **Proof it actually fires, in order, on the real trigger:** the push ran [ci run #7938](https://git.matou.nz/Matou/ourcloud/actions/runs/7938) — `seam` succeeded, then `publish` ran (only after `seam` was green, only on this push-to-main) and succeeded. Its range (`8ccebac..a33d153`) touched only `.forgejo/` and `STATUS.md`, so `oc_reseed_agent_affected` correctly computed "not agent-affecting" against full history and no-op'd before ever calling the package API — the job order/gating/checkout-depth are proven; the actual upload path (the part that needs `write:package`) is *not yet* exercised by this run and will only run for real on the next agent-affecting push (touching `agent/`, `go.mod`, `go.sum`, or `internal/`). **One-way-door residual, not ruled — routing to `ready-for-human`:** `SWARM_FORGEJO_TOKEN` is a `swarm-bot` machine-user PAT deliberately scoped to `write:repository` + `write:issue` only, per Ben's explicit #449 ruling bounding what a swarm credential can do ("without admin/org scope a worker cannot mint tokens, touch other repos, or widen itself" — `docs/architecture/07-secrets-architecture.md`). It has no `write:package` scope. Forgejo PATs can't have scopes added after creation — extending it means minting a new PAT (interactive login to the `swarm-bot` account) and swapping the org secret. That's a security-posture widening of a credential Ben named explicitly, and minting it needs an account credential this session doesn't hold — ADR 0174's one-way-door list (personal/account credentials + security-posture widenings), not something a session self-authorizes. ## Why human Ben: either (a) mint a new `swarm-bot` PAT with `write:package` added and `PUT /api/v1/orgs/Matou/actions/secrets/SWARM_FORGEJO_TOKEN` the new value, or (b) rule that `write:package` should NOT go on the shared swarm token and name an alternative (e.g. a narrower publish-only token as its own org secret). Once the token is right, the wiring above needs no further changes — the next agent-affecting push to `main` will publish for real. No agent action possible past this point. Companion residual (droplet-side timer install) remains on #601, also Ben's.
Owner

Root cause of the never-publishing publish job, and the fix (2026-08-20 session with Ben): SWARM_FORGEJO_TOKEN has no package scope — probed 401 on package PUT / 403 on read. The only agent-affecting push since wiring (ce94770, run 7960) failed exactly there; every other "publish success" was the guard's no-op. Ben minted a package-scoped PAT (identity ben) → org secret REGISTRY_FORGEJO_TOKEN; ci.yml publish job reads it (7a35076). Registry seeded by hand from the laptop: idss-agent@7a35076 (three 201s). Remaining gate for CI to take over: seam is red on main (lint debt) → #621.

**Root cause of the never-publishing publish job, and the fix (2026-08-20 session with Ben):** `SWARM_FORGEJO_TOKEN` has no package scope — probed 401 on package PUT / 403 on read. The only agent-affecting push since wiring (`ce94770`, run 7960) failed exactly there; every other "publish success" was the guard's no-op. Ben minted a package-scoped PAT (identity `ben`) → org secret `REGISTRY_FORGEJO_TOKEN`; `ci.yml` publish job reads it (`7a35076`). Registry seeded by hand from the laptop: `idss-agent@7a35076` (three 201s). Remaining gate for CI to take over: `seam` is red on main (lint debt) → #621.
Owner

Closing (Ben, 2026-08-24). The remaining gate — seam red on main (lint debt) — was cleared by #621 (fcbe3ac8, closed 2026-08-21). Today on main: seam ✅ 13:31Z (0ae4f97) → publish ✅ 13:37Z (first run instead of skipped) → publish-broker ✅ 13:38Z; seam ✅ again 13:43Z (18bda3e). The publish job now fires on every main push with the package-scoped REGISTRY_FORGEJO_TOKEN.

Caveat for the record: a publish success on a push that touches no agent files is the oc_reseed_agent_affected guard no-op. The first agent-affecting push to main will be the end-to-end proof of an automated registry publish — if that fails, reopen with the run URL.

Closing (Ben, 2026-08-24). The remaining gate — `seam` red on main (lint debt) — was cleared by #621 (`fcbe3ac8`, closed 2026-08-21). Today on main: `seam` ✅ 13:31Z (`0ae4f97`) → **`publish` ✅ 13:37Z** (first run instead of skipped) → `publish-broker` ✅ 13:38Z; `seam` ✅ again 13:43Z (`18bda3e`). The publish job now fires on every main push with the package-scoped `REGISTRY_FORGEJO_TOKEN`. Caveat for the record: a `publish` success on a push that touches no agent files is the `oc_reseed_agent_affected` guard no-op. The first agent-affecting push to main will be the end-to-end proof of an automated registry publish — if that fails, reopen with the run URL.
ben closed this issue 2026-08-24 14:02:30 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#606
No description provided.