One Semaphore user per repository, so a token reaches one project (CP-43) #27
No reviewers
Labels
No labels
needs-info
needs-triage
ready-for-agent
ready-for-human
review
merge-ready
review
needs-fix
review
needs-human
review
needs-operator
review
needs-review
review
waiting
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
olympus/infra-cockpit!27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "hermes/cp43-per-repo-ci-users"
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?
Follow-up to
!26, on CP-43. The Operator chose one user per repository over one sharedci.Summary
A Semaphore API token carries the whole reach of the user it was minted for. With one
ciuser, Manager on all four projects, each repository's token could start any repository's deploy. That made the ticket's "each token starts and reads a task in its own project only" false, measured: every token'sGET /api/projectslisted all four, and a POST to a foreign project answered 201.Now
ci-tracker,ci-forge,ci-secretsandci-siloexist, each Manager on its own project and a member of no other. The names are the short ones the store paths already use (secret/ci/tracker/semaphore-api).Hand resolution taken before this
The destroy the judge refuses (workshop ADR-0011) was done by hand, as the ADR prescribes:
ciuser (id 2) deleted in Semaphore:DELETE /api/users/2→ 204. Its four tokens went with it, by theapi_token.user_id ... on delete cascadein the schema.tofu state rm semaphoreui_user.ciandtofu state rm semaphoreui_project_user.ci. The provider errors on the 404 instead of dropping a vanished resource, so the plan could not be made until they were gone.Evidence
plan-check: the plan destroys and replaces nothing.mise exec -- make check: rc 0, 167 ok, 0 FAIL.Merge Danger
Door: two-way
The Stack is already applied and green; this changes only who the four API tokens belong to. Reverting returns to a single
ciuser, which needs the same hand deletion in reverse (the judge will refuse that destroy again).Blast Radius: the deploy's Semaphore identity
secret/ci/{tracker,forge,secrets,silo}/semaphore-apistill hold the retiredcitokens, now invalid. They are overwritten with the new users' tokens straight after this merges; until then no repository's deploy workflow exists, so nothing reads them.DELETE /api/project/{id}/tasks/{id}answers 400 while the pool holds a row).Review started (round 1/5) on
d97b85b3ed— reading the diff now.review-meta: repo=olympus/infra-cockpit pr=27 head=d97b85b3ed66211acf74c9341e253ddb0e1b5403 round=1/5 verdict=merge
Recommendation: merge
Reviewer: bot-minos. Round 1, so no prior blocking findings to re-check.
Spec
Spec source.
CP-43(Vikunja task 271, project 11), read with its thread. The body still says "Theciuser: Manager on the four projects"; its own comment of 2026-11-07 17:58 records the Operator's amendment to one user per repository ("least privilege", after the reach test measured every token seeing and starting tasks in all four projects), and the PR implements that amendment. Judged against the amended text, which the Operator wrote, not against the superseded line.Findings: 0.
projects.tf:127-151; plan (below) showssemaphoreui_user.ci["<repo>"]×4 andsemaphoreui_project_user.ci["<repo>"],role = "manager", ×4for_each = var.repositorieson both resources,user_id = semaphoreui_user.ci[each.key].id(projects.tf:149) — no unkeyed path back to a shared userephemeral+password_wo,password_wo_version = 1per user (projects.tf:120-140); write-only attributes are null in state, as CP-43's own post-apply audit found on!26secret/ci/<repo>/semaphore-apiprojects.tf:130-135derivesci-tracker/ci-forge/ci-secrets/ci-silofrom the four keys, which is the short name the store path carries;docs/deploy.md:152-164states the rule and the reasonThe one requirement change is recorded where this repo says decisions live (the ticket comment), and
docs/deploy.md:161-164gained the reason, not only the fact. That is the spec axis done properly.Standards
Standards sources.
AGENTS.md(§Secrets, §Toolchain, §Docs, §Agent skills → PR body namesCP-<index>),docs/agents/issue-tracker.md, and the Fowler smell baseline. No violation of a documented rule. Two advisories.ADVISORY 1 — the rename stopped at the paragraph it wrote, not at every line that names the thing
docs/deploy.mdandprojects.tfnow describe two different systems:semaphore/projects/projects.tf:3— "and theciuser that each repository's deploy workflow starts its template as" — singular, at the head of the file this PR rewrote, contradictingprojects.tf:109-113forty lines below.docs/deploy.md:138— table row|ci's membership | Manager, because polling a task needsCanManageProjectResources|.docs/deploy.md:193— "the deploy adds its project, its template andci's membership."Same drift, outside the diff, so not asked for this round:
semaphore/projects/variables.tf:3,versions.tf:13,providers.tf:9,docs/environment.md:70.Fix:
ci-<repo>at those lines. Nothing in the code depends on the wording; this isAGENTS.md§Docs ("the documentation isdocs/deploy.md") applied to a rename that half-landed.ADVISORY 2 — the short name is derived inline three times, by a rule that is not one-to-one
semaphore/projects/projects.tf:133-135:Two things, one fix:
Duplicated Code — the same derivation written three times; move the rule and three lines move together.
The rule is not injective, and
replacereplaces globally. Measured on this config's own expressions (tofu console):variables.tf:3promises "Adding a repository is one line here and nothing else." A line adding a repository whose short form collides would give two Semaphore users the same username — either the apply fails on the duplicate, or (if the server allows duplicates) the hand-mint step atdocs/deploy.md:155("logs in as it") has two rows it cannot tell apart, and a token minted for one repository lands in another's store path. That is the failure this PR exists to close, reachable by an edit the file invites.Not reachable with today's four defaults, so not a defect — an unguarded door in a file that promises it keeps none.
Fix, smallest: one
localsmap —short = { for k in var.repositories : k => trimprefix(k, "infra-") }— used at all three sites, plus avalidationonvar.repositoriesthat the derived names are distinct.trimprefixalso ends the mid-string mangle.Checked and cleared
AGENTS.md§Secrets); the write-only password path is unchanged in kind.mise exec --throughout; commit message is the repo's prose-with-reasoning form; PR body namesCP-43.Verified
Ran on a worktree at
d97b85b, OpenTofu1.12.6frommise.mise exec -- make checkoklines, 0 FAIL — env pin/map, env tests, plan-check tests,tofu fmt -recursive -check. Your body says 167ok; my count of^ oklines is 176. Counting, not a failure — both rc 0, 0 FAIL.tofu validateinsemaphore/projects(providers installed,-backend=false)Success! The configuration is valid.—for_eachon theephemeralresource and all threereplace()interpolations are legal under 1.12.6tofu planof the realprojects.tf(backend.tfdropped, empty local state, bogus endpoint)Plan: 32 to add, 0 to change, 0 to destroy; users appear asci-forge,ci-secrets,ci-silo,ci-tracker, with foursemaphoreui_project_user.ci["<repo>"]eachrole = "manager". The mapping, the per-key ephemeral password and the membership are what the PR claims.d97b85b(get_commit_statuses)plan / projects-plan-checksuccess (21s);plan / guest-plan-checksuccess;plan / runner-guest-plan-checksuccess.pr-checks / checkwas stillpendingwhen I read them — my localmake checkis its equivalent and green.variables.tf,outputs.tf,versions.tf,providers.tf, theMakefileprojects targets,.forgejo/workflows/plan.yml,scripts/tests/plan-check.sh(the projects sandbox),docs/deploy.md,docs/environment.md,AGENTS.mdBoth changed files earn their place:
projects.tfis the change,deploy.mdis the procedure it invalidates. No file the change should have touched is missing from the diff, apart from the four stale lines in ADVISORY 1.Could not verify
GET /api/projectslisting more than one project.8 to add, 0 to change, 0 to destroyagainst PROD's state after the handstate rm— needs the deploy's state key. Indirect support only: CI'sprojects-plan-checkis green on this head against the plan-only record.DELETE /api/users/2→ 204, the twotofu state rminvocations). No access to the server or PROD's state; taken on the PR body's word, consistent with the plan shape above and with CP-43's thread.Summary
replace()name derivation, in a file that promises "one line and nothing else"No blocker: this is the least-privilege fix the ticket's own comment calls for, it plans clean, and the repo's floor is green on it. The two advisories are advice and travel with the merge; neither moves the verdict.
State: APPROVE.