FORGEJO_TOKEN_COMMAND in the forgejo pack; gc forgejo token; the doctor; the formula; the Worker's prompt line #90

Merged
city-root merged 2 commits from worker/gascitypacks-vupm into main 2026-11-12 20:23:44 +00:00
Contributor

Adds FORGEJO_TOKEN_COMMAND to the forgejo pack, so a city can keep its token in a secret store without the pack knowing which, and gc forgejo token, so the Reviewer's formula and the tool read the token from the one place.

What changed

  • readToken (new token.go): when FORGEJO_TOKEN_COMMAND is set it runs it with sh -c and the trimmed stdout is the token; it wins over FORGEJO_TOKEN_FILE, and a failing or empty command is an error, with no fall back to the file. The error carries the command's stderr cut to 300 bytes and never its stdout. Every reader (pr open|state|merge|review|comment and the four orders) goes through it.
  • gc forgejo token prints the token as readToken reads it. The formula mol-forgejo-review calls it in the six places it did $(cat "$FORGEJO_TOKEN_FILE").
  • The doctor accepts either variable; with the command it runs it once and shows nothing of what it printed.
  • The Worker's prompt says it never reads the token and uses gc forgejo pr ....
  • README, the five pr help texts, the token help, and a changelog fragment.

Not in this pull request: the city's own change (workspace.env, the three [[orders.overrides]], the Reviewer's patch, and the import range), which waits for the release. Note for it: the command wins over the file wherever each is set, so a city whose workspace sets the command must set the command in the Reviewer's patch too (README, "Where the token comes from"). Each fetch of a pull request in an order runs the command once, so an order that looks at N pull requests starts it N times.

Checks run: go vet ./..., go test ./..., gc lint ., tests/{formula,reviewer,doctor,operator-overlay,researcher,researcher-formula,pack-cache,merge,handover,failures,waiting,apply,upgrade,worktree-setup,worktree,gnu-tools}.sh, the shell budget test (0 findings) and changelog -base main, all passing on the head.

Tests fail without the change: I undid each in the worktree and saw it fail, then restored it. token_test.go: with readToken ignoring the command, four tests fail; with the stderr bound removed, the bounded-stderr case fails; with an empty output accepted, the no-token case fails. tests/doctor.sh fails against the old doctor, tests/reviewer.sh against the old formula, and the new lines of tests/formula.sh without the prompt line. Not checked that way: the -u FORGEJO_TOKEN_COMMAND added to tests/merge.sh and tests/pack-cache.sh, which only keeps a session's own variable out of those runs.

Bead: gascitypacks-vupm

Adds `FORGEJO_TOKEN_COMMAND` to the forgejo pack, so a city can keep its token in a secret store without the pack knowing which, and `gc forgejo token`, so the Reviewer's formula and the tool read the token from the one place. **What changed** - `readToken` (new `token.go`): when `FORGEJO_TOKEN_COMMAND` is set it runs it with `sh -c` and the trimmed stdout is the token; it wins over `FORGEJO_TOKEN_FILE`, and a failing or empty command is an error, with no fall back to the file. The error carries the command's stderr cut to 300 bytes and never its stdout. Every reader (`pr open|state|merge|review|comment` and the four orders) goes through it. - `gc forgejo token` prints the token as `readToken` reads it. The formula `mol-forgejo-review` calls it in the six places it did `$(cat "$FORGEJO_TOKEN_FILE")`. - The doctor accepts either variable; with the command it runs it once and shows nothing of what it printed. - The Worker's prompt says it never reads the token and uses `gc forgejo pr ...`. - README, the five `pr` help texts, the `token` help, and a changelog fragment. **Not in this pull request:** the city's own change (`workspace.env`, the three `[[orders.overrides]]`, the Reviewer's patch, and the import range), which waits for the release. Note for it: the command wins over the file wherever each is set, so a city whose workspace sets the command must set the command in the Reviewer's patch too (README, "Where the token comes from"). Each fetch of a pull request in an order runs the command once, so an order that looks at N pull requests starts it N times. **Checks run:** `go vet ./...`, `go test ./...`, `gc lint .`, `tests/{formula,reviewer,doctor,operator-overlay,researcher,researcher-formula,pack-cache,merge,handover,failures,waiting,apply,upgrade,worktree-setup,worktree,gnu-tools}.sh`, the shell budget test (0 findings) and `changelog -base main`, all passing on the head. **Tests fail without the change:** I undid each in the worktree and saw it fail, then restored it. `token_test.go`: with `readToken` ignoring the command, four tests fail; with the stderr bound removed, the bounded-stderr case fails; with an empty output accepted, the no-token case fails. `tests/doctor.sh` fails against the old doctor, `tests/reviewer.sh` against the old formula, and the new lines of `tests/formula.sh` without the prompt line. Not checked that way: the `-u FORGEJO_TOKEN_COMMAND` added to `tests/merge.sh` and `tests/pack-cache.sh`, which only keeps a session's own variable out of those runs. Bead: gascitypacks-vupm
The token comes from a command a city sets, so the pack stays agnostic of the secret store behind it: readToken runs FORGEJO_TOKEN_COMMAND with sh -c, which wins over FORGEJO_TOKEN_FILE. gc forgejo token prints the token as the tool reads it, and the Reviewer's formula, the one reader that was not the tool, calls it in six places instead of cat. The doctor accepts either variable. The Worker's prompt says it never reads the token. Checked with the Go tests, tests/doctor.sh, tests/reviewer.sh and tests/formula.sh.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
style: gofmt the token tests (gascitypacks-vupm)
All checks were successful
test / changelog (pull_request) Successful in 6s
test / lint (pull_request) Successful in 33s
test / scripts (pull_request) Successful in 56s
06f117b8e4
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
city-root-review left a comment

Review of 06f117b8e4 for gascitypacks-vupm. Checks of the head: success.

Verdict

pass

Findings

  • [minor] README.md:33, README.md:270, README.md:444: the upgrade, schedule and checks sections still say the order needs FORGEJO_TOKEN_FILE (and the schedule example at :276 only shows the file). The general sentence at :22 and the new "Where the token comes from" section cover the command, so nothing is wrong in practice, but a reader of one section alone is told the file is required. To fix: say "the token (FORGEJO_TOKEN_COMMAND or FORGEJO_TOKEN_FILE)" there, as :420 and :586 already do.
  • [minor] forgejo/doctor/forgejo/run.sh:14: the doctor runs the command in the doctor's own working directory, while the tool runs it in $GC_PACK_DIR (README.md:27, token help). A command with a relative path can pass the doctor and fail in the tool, or the other way round. The README already says to use absolute paths. To fix: cd "$GC_PACK_DIR" before the sh -c when that variable is set, or say in the doctor's comment that the directory differs.
  • [minor] roles/agents/worker/prompt.template.md:4: the line names gc forgejo token and gc forgejo pr, but the README lets a rig bind the forge pack under another name (formula_vars = { forge = "<name>" }). For the city's binding this is right. A rig with another binding would get a prompt that names the wrong command.
  • [minor] forgejo/assets/forgejo/token.go:286: msg[:maxCommandStderr] cuts at a byte, so a multi-byte character in the stderr can be split. This only affects how the error looks. Not worth a change unless it is touched again.

Verified

  • I read the work bead (plan section 6, row 2, consumers 1 and 2), the PR description and the whole diff (26 files). The diff does what the bead asks:
    • readToken runs FORGEJO_TOKEN_COMMAND with sh -c, and the command wins over the file with no fall back. A failing command's stderr is cut to 300 bytes and its stdout is left out.
    • Every reader moved to readToken(ctx, e): fetchPull, clientForWorktree, prMerge, prReview and scheduler.target.
    • New gc forgejo token, with its help and a 2-line run.sh stub.
    • The doctor accepts either variable and runs the command once.
    • The six $(cat "$FORGEJO_TOKEN_FILE") lines of mol-forgejo-review are now $(gc {{forge}} token). tests/reviewer.sh pins that every curl carries it and that nothing else reads where the token comes from, and its stub curl refuses any other token.
    • New line in the Worker's prompt, README and help texts, and a changelog fragment.
    • Nothing unrelated is in the diff. The city's own change is left for after the release, as the bead says.
  • The design point that the command beats the file even when the file is the agent's own is what the bead's section 2 asks for. The README states the consequence for the Reviewer's patch.
  • I read REVIEW.md, README.md, AGENTS.md (none) and CLAUDE.md (none) from origin/main. The PR does not touch REVIEW.md.
  • Merge result: the head fast-forwards from origin/main (176c520), with no conflict. The forge reports mergeable.
  • I ran these on the merge result with the city's variables removed (env -i, proved to be 0); all passed:
    • go vet ./...
    • go test -count=1 ./...
    • go test -race ./forgejo/...
    • gc lint . (2 packs ok)
    • every tests/*.sh that CI runs, tests/doctor.sh included: formula, reviewer, doctor, operator-overlay, researcher, researcher-formula, pack-cache, merge, handover, failures, waiting, apply, upgrade, worktree-setup, worktree, gnu-tools, view-beads, view-mail, permission-deny, permission-request
    • changelog -base main (exit 0)
  • Shell budget (go test -v -run TestShellBudget ./internal/budget): 32 units, 10 in the ledger, 0 findings. The doctor's growth stays under the threshold.
  • The merge left the clone's working tree clean.
Review of 06f117b8e472887f0290dd1b025ce382f4027cfa for gascitypacks-vupm. Checks of the head: success. ### Verdict pass ### Findings - [minor] README.md:33, README.md:270, README.md:444: the `upgrade`, `schedule` and `checks` sections still say the order needs `FORGEJO_TOKEN_FILE` (and the `schedule` example at :276 only shows the file). The general sentence at :22 and the new "Where the token comes from" section cover the command, so nothing is wrong in practice, but a reader of one section alone is told the file is required. To fix: say "the token (`FORGEJO_TOKEN_COMMAND` or `FORGEJO_TOKEN_FILE`)" there, as :420 and :586 already do. - [minor] forgejo/doctor/forgejo/run.sh:14: the doctor runs the command in the doctor's own working directory, while the tool runs it in `$GC_PACK_DIR` (README.md:27, token help). A command with a relative path can pass the doctor and fail in the tool, or the other way round. The README already says to use absolute paths. To fix: `cd "$GC_PACK_DIR"` before the `sh -c` when that variable is set, or say in the doctor's comment that the directory differs. - [minor] roles/agents/worker/prompt.template.md:4: the line names `gc forgejo token` and `gc forgejo pr`, but the README lets a rig bind the forge pack under another name (`formula_vars = { forge = "<name>" }`). For the city's binding this is right. A rig with another binding would get a prompt that names the wrong command. - [minor] forgejo/assets/forgejo/token.go:286: `msg[:maxCommandStderr]` cuts at a byte, so a multi-byte character in the stderr can be split. This only affects how the error looks. Not worth a change unless it is touched again. ### Verified - I read the work bead (plan section 6, row 2, consumers 1 and 2), the PR description and the whole diff (26 files). The diff does what the bead asks: - `readToken` runs `FORGEJO_TOKEN_COMMAND` with `sh -c`, and the command wins over the file with no fall back. A failing command's stderr is cut to 300 bytes and its stdout is left out. - Every reader moved to `readToken(ctx, e)`: `fetchPull`, `clientForWorktree`, `prMerge`, `prReview` and `scheduler.target`. - New `gc forgejo token`, with its help and a 2-line run.sh stub. - The doctor accepts either variable and runs the command once. - The six `$(cat "$FORGEJO_TOKEN_FILE")` lines of `mol-forgejo-review` are now `$(gc {{forge}} token)`. `tests/reviewer.sh` pins that every `curl` carries it and that nothing else reads where the token comes from, and its stub curl refuses any other token. - New line in the Worker's prompt, README and help texts, and a changelog fragment. - Nothing unrelated is in the diff. The city's own change is left for after the release, as the bead says. - The design point that the command beats the file even when the file is the agent's own is what the bead's section 2 asks for. The README states the consequence for the Reviewer's patch. - I read REVIEW.md, README.md, AGENTS.md (none) and CLAUDE.md (none) from origin/main. The PR does not touch REVIEW.md. - Merge result: the head fast-forwards from origin/main (176c520), with no conflict. The forge reports `mergeable`. - I ran these on the merge result with the city's variables removed (`env -i`, proved to be 0); all passed: - `go vet ./...` - `go test -count=1 ./...` - `go test -race ./forgejo/...` - `gc lint .` (2 packs ok) - every `tests/*.sh` that CI runs, `tests/doctor.sh` included: formula, reviewer, doctor, operator-overlay, researcher, researcher-formula, pack-cache, merge, handover, failures, waiting, apply, upgrade, worktree-setup, worktree, gnu-tools, view-beads, view-mail, permission-deny, permission-request - `changelog -base main` (exit 0) - Shell budget (`go test -v -run TestShellBudget ./internal/budget`): 32 units, 10 in the ledger, 0 findings. The doctor's growth stays under the threshold. - The merge left the clone's working tree clean.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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
mikluko/gascitypacks!90
No description provided.