Unify forge-token secret prefix: FORGEJO_TOKEN_* → FORGE_TOKEN_* #867
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Depends on
#849 Cleanup: delete
db.ts, lint-ban raw SQL outside DB layer, update docs
charles/claude-hooks
Reference
charles/claude-hooks#867
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As a maintainer, I want every per-type Forgejo PAT in the
secrettable renamed to a forge-neutralFORGE_TOKEN_<TYPE>prefix, so that the multi-forge story (#29) doesn't carry a Forgejo-specific name for what is now a generic forge credential and so the dashboard stops accumulating two parallel sets of token rows whenever a re-seed runs.Context
Live
secrettable on the desktop today carried two parallel sets of forge-token rows for every agent type:FORGEJO_TOKEN_<TYPE>— seeded 2026-05-01 from token files; the live name (defaults.ts:95references${SECRET:FORGEJO_TOKEN_$$TYPE_UPPER$$},onboarding-apply.ts:363writes under this prefix).FORGE_TOKEN_<TYPE>— written 2026-05-03 by the TOK-1 (#757/#764) one-shot env→DB migration. Orphaned: no code path reads them; the cleanup got dropped when the Drizzle nuke (#854) deleted the 17 hand-rolled migrations.The 6 stale
FORGE_TOKEN_*rows were deleted manually 2026-05-05. This issue prevents recurrence by collapsing onto one canonical prefix — and the forge-neutralFORGE_TOKEN_*is the one to keep, lined up with the env var nameFORGE_TOKENalready injected into agent containers (render-for-instance.ts:200).Acceptance criteria
Code rename
apps/server/src/domain/agent-config/defaults.ts:95— flip theFORGE_TOKENenv-var template from${SECRET:FORGEJO_TOKEN_$$TYPE_UPPER$$}to${SECRET:FORGE_TOKEN_$$TYPE_UPPER$$}.apps/server/src/http/handlers/onboarding-apply.ts:363—secretNameForTypereturnsFORGE_TOKEN_<TYPE>(update the JSDoc on line 358-359 too).apps/server/src/infrastructure/container/container.ts:34— comment block updated to referenceFORGE_TOKEN_<TYPE>.FORGEJO_TOKEN_<TYPE>references inapps/orpackages/outside of (a) the legacy-rename literals indb.ts:688-689(those are migration breadcrumbs, see next section) and (b) test fixtures pinned to the legacy literal.Migration
FORGEJO_TOKEN_<TYPE>row insecretto a same-valueFORGE_TOKEN_<TYPE>row, then delete theFORGEJO_TOKEN_<TYPE>row. Idempotent — re-running on a fresh boot is a no-op.db.ts:688-689are extended (or renamed) so the boss→code-lead and foreman→architect literal renames still apply against the new prefix. Equivalent rows for both prefixes are accepted (operator may have either).Tests
FORGEJO_TOKEN_DEV='abc'+FORGEJO_TOKEN_REVIEWER='xyz'→ run migration → expect rows underFORGE_TOKEN_DEV='abc'+FORGE_TOKEN_REVIEWER='xyz', with the original rows gone.FORGEJO_TOKEN_DEV='old'+FORGE_TOKEN_DEV='new'→ migration leavesFORGE_TOKEN_DEV='new'(target row wins; legacy row dropped without overwriting). Logs the conflict.onboarding-apply.tstest fixture asserts the new prefix.Docs
docs/credentials.mdupdated to reference the canonicalFORGE_TOKEN_<TYPE>name.Out of scope
FORGE_TOKENSJSON env var) — already in place; this is just a rename of the per-type secret row.FORGE_TOKEN_INSTANCE_<NAME>) — already on the new prefix; nothing to rename.WEBHOOK_SECRET_FORGEJO) — forge-specific by design (different webhook secrets per forge).FORGEJO_OAUTH_CLIENT_SECRET) — also per-forge by design (the operator_oauth_tokens table will eventually carry aclient_secret_refper forge, see PR D series).References
defaults.ts:95— current env-var template.onboarding-apply.ts:358-363— current secret-name builder.db.ts:688-689— legacy-rename pairs (boss→code-lead, foreman→architect).render-for-instance.ts:200—FORGE_TOKENenv var (forge-neutral) injected at dispatch.FORGE_TOKEN_<TYPE>.DELETEagainst 6 orphanFORGE_TOKEN_*rows.db.ts, lint-ban raw SQL outside DB layer, update docsCorrection (2026-05-05) — both prefixes were live, not just one.
Live audit shows two consumers:
FORGE_TOKEN_<TYPE>(IDs 7-12)agent_type.token_secret_idnumeric FK — resolves the agent's ownforgejo_tokenviagetAgentTokenSync(resolver.ts:924)FORGEJO_TOKEN_<TYPE>(IDs 1-6)defaults.ts:95${SECRET:FORGEJO_TOKEN_$$TYPE_UPPER$$}template — interpolated into the agent container'sFORGE_TOKENenv var by the secret-templating layerSame token value, two consumers, two prefix conventions. Deleting either set breaks one path silently (the FK consumer crashed dispatch entirely on 2026-05-05; the env-var consumer would degrade per-container shell access).
Updated AC (replaces "Migration" + "Code rename"):
FORGE_TOKEN_<TYPE>is the better choice (forge-neutral, lined up with theFORGE_TOKENenv var name).FORGEJO_TOKEN_<TYPE>row toFORGE_TOKEN_<TYPE>(target wins on conflict — drop the legacy row), then update both consumers to read the canonical name.defaults.ts:95env-var template:${SECRET:FORGEJO_TOKEN_$$TYPE_UPPER$$}→${SECRET:FORGE_TOKEN_$$TYPE_UPPER$$}.onboarding-apply.ts:363secretNameForType: returnsFORGE_TOKEN_<TYPE>.secrettable FK constraint: addON DELETE RESTRICTtoagent_type.token_secret_id(andagent_token_override.secret_idif it lacks one) so a future operator deletion gets a 409 instead of silently corrupting dispatch.🦵 @charles kicked the queue — re-running implement on @dev.
🦵 @operator kicked the queue — re-running implement on @dev.
🦵 @charles kicked the queue — re-running implement on @dev.