Sandbox origin URL still carries an embedded FORGEJO_TOKEN after #195 landed (seen by the #237 worker) #246

Closed
opened 2026-10-16 15:57:44 +00:00 by ben · 3 comments
Owner

Filed from the #237 stall (Ben's Claude Code session, 2026-10-16).

Symptom

The #237 worker (swarm run on 2026-10-15 ~17:00Z, after #195 closed at 05:48Z) reported: "this sandbox's origin carries an embedded token in its URL, which contradicts the credential-free-origin contract in the landing guidance." So at least one path that configures the worker's origin was not covered by #195's change, or the shared workdir on that host still carried the old set-url and was never cleaned (#195's one-off host cleanup step).

To check

  • Which host ran #237 (run id is on the swarm-claim comment on #237) and whether $HOME/swarm/Matou/dev-factory/.git/config on it still has https://swarm:<token>@… as origin.
  • Whether .sandcastle/git-setup.sh at the pin the swarm was running (self-pin is behind, #131) predates #195.
  • swarm.yml / triage.yml inline set-url lines listed in #195.

Acceptance

git remote get-url origin inside a fresh worker sandbox and on each host's shared workdir prints a URL with no credential; a test asserts the harness never writes a token into a remote URL.

#195 (closed), #222 (open, protected-path half of #195), #131/#132 (self-pin behind).

_Filed from the #237 stall (Ben's Claude Code session, 2026-10-16)._ ## Symptom The #237 worker (swarm run on 2026-10-15 ~17:00Z, after #195 closed at 05:48Z) reported: "this sandbox's `origin` carries an embedded token in its URL, which contradicts the credential-free-origin contract in the landing guidance." So at least one path that configures the worker's `origin` was not covered by #195's change, or the shared workdir on that host still carried the old `set-url` and was never cleaned (#195's one-off host cleanup step). ## To check - Which host ran #237 (run id is on the `swarm-claim` comment on #237) and whether `$HOME/swarm/Matou/dev-factory/.git/config` on it still has `https://swarm:<token>@…` as `origin`. - Whether `.sandcastle/git-setup.sh` at the pin the swarm was running (self-pin is behind, #131) predates #195. - `swarm.yml` / `triage.yml` inline `set-url` lines listed in #195. ## Acceptance `git remote get-url origin` inside a fresh worker sandbox and on each host's shared workdir prints a URL with no credential; a test asserts the harness never writes a token into a remote URL. ## Related #195 (closed), #222 (open, protected-path half of #195), #131/#132 (self-pin behind).

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: ready-for-session, not ready-for-agent and not ready-for-human.

  • Why not ready-for-agent: the remaining work touches protected paths that the swarm queue must not — the inline set-url lines in .forgejo/ workflows (swarm.yml/triage.yml, per #195), plus a one-off cleanup of a host's shared workdir .git/config (host standing / a live door). Both are ready-for-session territory by the triage-label contract.
  • Why not ready-for-human: this is a two-way door, not a one-way one. Stripping an embedded token out of a remote URL is a security-posture narrowing, not a widening; the fix is revertible by a later commit and provable by a test asserting the harness never writes a credential into a remote URL. The host-workdir cleanup is reachable by any host's session-runner standing — it needs a session, not Ben's hands specifically. If cleanup surfaces a token that must be rotated, that rotation is the one-way-door residue — split it to its own ready-for-human ticket at that point; it is not this ticket's blocker.

Verification (confirmed against the code): git-setup.sh already strips credentials — its origin url comes from git_cred_strip_url(...) before git remote set-url origin "$url", so #195's harness fix is present at HEAD. That narrows the residue to exactly the two surfaces the body names: (a) the .forgejo/ workflow set-url lines (vendored YAML copies that only change when consumers re-vendor), and (b) whether the host that ran #237 still carries a stale https://swarm:<token>@… origin in its shared .git/config from before #195.


Agent Brief (session)

Category: bug
Summary: Close the residual paths by which a worker's origin can still carry an embedded FORGEJO_TOKEN after #195, and assert it can never recur.

Current behavior:
git-setup.sh writes a credential-free origin (confirmed at HEAD). But the #237 worker (swarm run 2026-10-15 ~17:00Z, after #195 closed at 05:48Z) still reported a token embedded in origin's URL. Two unclosed paths remain: the inline set-url lines in the .forgejo/ workflows (swarm.yml/triage.yml) listed in #195, and the one-off host cleanup of shared workdir .git/config that #195 did as a manual step (so a host never re-cleaned still carries https://swarm:<token>@…).

Desired behavior:
No path the harness controls writes a credential into a remote URL — git remote get-url origin inside a fresh worker sandbox, and in each host's shared workdir, prints a URL with no embedded credential. The credential-free posture is enforced by a test so the regression cannot silently return.

Key interfaces / surfaces:

  • The .forgejo/ workflow set-url lines (swarm.yml/triage.yml) — route them through the same git_cred_strip_url / token-free credential-helper posture git-setup.sh uses, or delete them in favour of git-setup.sh's own path. These are .forgejo/ protected files — session work.
  • Host shared workdir cleanup: on the host that ran #237 (run id is on #237's swarm-claim comment), inspect $HOME/swarm/Matou/dev-factory/.git/config and rewrite any credentialed origin to the credential-free form. Note whether the self-pin lag (#131/#132) left that host on a pre-#195 git-setup.sh.
  • A test (nearest existing harness/git suite) asserting the harness never emits a token into a remote URL — e.g. scan the configured origin after setup for a user:token@ form and fail if present.

Acceptance criteria:

  • git remote get-url origin in a fresh worker sandbox prints a URL with no embedded credential.
  • The host that ran #237 has its shared workdir origin confirmed credential-free (cleaned if it was not).
  • The .forgejo/ workflow set-url lines no longer write a credentialed URL (routed through the strip/helper path or removed).
  • A test asserts the harness never writes a token into a remote URL; the offline suite is green.

Out of scope:

  • Token rotation — if cleanup reveals a token that must be rotated, that is a separate ready-for-human one-way-door ticket; this ticket only removes the embedding and asserts it cannot recur.
  • The self-pin lag itself (#131/#132) — related, tracked separately.
  • The protected-path half of #195 (#222, open) — separate ticket.

Why session (not swarm worker): edits land in .forgejo/ and require inspecting/cleaning a live host's workdir — both outside what the swarm queue (ready-for-agent only) may claim.

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** `ready-for-session`, not `ready-for-agent` and not `ready-for-human`. - **Why not `ready-for-agent`:** the remaining work touches protected paths that the swarm queue must not — the inline `set-url` lines in `.forgejo/` workflows (`swarm.yml`/`triage.yml`, per #195), plus a one-off cleanup of a host's shared workdir `.git/config` (host standing / a live door). Both are `ready-for-session` territory by the triage-label contract. - **Why not `ready-for-human`:** this is a two-way door, not a one-way one. Stripping an embedded token out of a remote URL is a security-posture **narrowing**, not a widening; the fix is revertible by a later commit and provable by a test asserting the harness never writes a credential into a remote URL. The host-workdir cleanup is reachable by any host's `session-runner` standing — it needs a session, not Ben's hands specifically. If cleanup surfaces a token that must be **rotated**, that rotation is the one-way-door residue — split it to its own `ready-for-human` ticket at that point; it is not this ticket's blocker. **Verification (confirmed against the code):** `git-setup.sh` already strips credentials — its `origin` url comes from `git_cred_strip_url(...)` before `git remote set-url origin "$url"`, so #195's harness fix is present at HEAD. That narrows the residue to exactly the two surfaces the body names: (a) the `.forgejo/` workflow `set-url` lines (vendored YAML copies that only change when consumers re-vendor), and (b) whether the host that ran #237 still carries a stale `https://swarm:<token>@…` origin in its shared `.git/config` from before #195. --- ## Agent Brief (session) **Category:** bug **Summary:** Close the residual paths by which a worker's `origin` can still carry an embedded `FORGEJO_TOKEN` after #195, and assert it can never recur. **Current behavior:** `git-setup.sh` writes a credential-free `origin` (confirmed at HEAD). But the #237 worker (swarm run 2026-10-15 ~17:00Z, after #195 closed at 05:48Z) still reported a token embedded in `origin`'s URL. Two unclosed paths remain: the inline `set-url` lines in the `.forgejo/` workflows (`swarm.yml`/`triage.yml`) listed in #195, and the one-off host cleanup of shared workdir `.git/config` that #195 did as a manual step (so a host never re-cleaned still carries `https://swarm:<token>@…`). **Desired behavior:** No path the harness controls writes a credential into a remote URL — `git remote get-url origin` inside a fresh worker sandbox, and in each host's shared workdir, prints a URL with no embedded credential. The credential-free posture is enforced by a test so the regression cannot silently return. **Key interfaces / surfaces:** - The `.forgejo/` workflow `set-url` lines (`swarm.yml`/`triage.yml`) — route them through the same `git_cred_strip_url` / token-free credential-helper posture `git-setup.sh` uses, or delete them in favour of `git-setup.sh`'s own path. These are `.forgejo/` protected files — session work. - Host shared workdir cleanup: on the host that ran #237 (run id is on #237's `swarm-claim` comment), inspect `$HOME/swarm/Matou/dev-factory/.git/config` and rewrite any credentialed `origin` to the credential-free form. Note whether the self-pin lag (#131/#132) left that host on a pre-#195 `git-setup.sh`. - A test (nearest existing harness/git suite) asserting the harness never emits a token into a remote URL — e.g. scan the configured `origin` after setup for a `user:token@` form and fail if present. **Acceptance criteria:** - [ ] `git remote get-url origin` in a fresh worker sandbox prints a URL with no embedded credential. - [ ] The host that ran #237 has its shared workdir `origin` confirmed credential-free (cleaned if it was not). - [ ] The `.forgejo/` workflow `set-url` lines no longer write a credentialed URL (routed through the strip/helper path or removed). - [ ] A test asserts the harness never writes a token into a remote URL; the offline suite is green. **Out of scope:** - Token **rotation** — if cleanup reveals a token that must be rotated, that is a separate `ready-for-human` one-way-door ticket; this ticket only removes the embedding and asserts it cannot recur. - The self-pin lag itself (#131/#132) — related, tracked separately. - The protected-path half of #195 (#222, open) — separate ticket. **Why session (not swarm worker):** edits land in `.forgejo/` and require inspecting/cleaning a live host's workdir — both outside what the swarm queue (`ready-for-agent` only) may claim.

Close-report (#246)

Landed: commit 18ae29e on main — a standing guard tests/no-token-in-git-url-test.sh plus the STATUS/journal surface update.

Root cause (confirmed, not a #195 gap). The #237 worker's sighting (2026-10-15 ~17:00Z) was caused by the running self-copy's pin PREDATING #195 — the .sandcastle/git-setup.sh that tick executed still wrote the old https://swarm:<token>@… into the shared .git/config. The #195 harness source was already correct: git-setup.sh runs git_cred_strip_url every tick, git-cred-lib.sh persists only a token-FREE helper (a cat <secret> pointer), and swarm.yml / triage.yml / main.mts all build a credential-free URL and inject auth per-invocation. The #222 re-vendor (FACTORY_REF = 0d638e1, 2026-10-16) brought #195 into the running copy; a subsequent tick's set-url scrubbed the credential.

Acceptance — proof.

  • git remote get-url origin prints a URL with no credential, on the host shared workdir and in a fresh worker sandbox. Verified on this host: ~/swarm/Matou/dev-factory origin = https://git.matou.nz/Matou/dev-factory.git (no userinfo), with only the token-free helper persisted in .git/config. A fresh sandbox inherits that mounted, credential-free .git and main.mts never re-embeds a token, so its origin is credential-free too. The scrub is automatic every tick — proven offline by tests/git-setup-test.sh fixtures 1b (credential-free remote + helper seam) and 1c (a pre-seeded credentialed origin is reset credential-free on the next run).
  • A test asserts the harness never writes a token into a remote URL. tests/no-token-in-git-url-test.sh (86 checks): scans the harness surface (root *.sh + *.mts, onboarding/*.sh, .forgejo/workflows/*.yml, onboarding/templates/workflows/*.tmpl when present) for a URL whose userinfo carries a credential (user:pass@ or a $VAR@ expansion) and reds on any non-comment reintroduction; full-line #/// comments are exempt (git-cred-lib.sh's header quotes the old shape to explain the fix). Asserts it scanned >0 files (the park-wiring rc-2 "green because it read nothing" lesson) and carries its own positive/negative controls. Vendored via tests/** → a consumer re-runs it over its byte-identical harness and its own rendered workflow YAMLs; run by ci.yml, shellcheck-clean (v0.11.0, -S warning -x).

Tests. Full offline suite: 97 suites, all green except tests/rehearsal-heal-lib-test.sh — a known host-env leak (CLAUDE_ACCOUNT_FP is set in the session-runner host env; the test is non-hermetic and expects it unset). It passes with a clean env (env -u CLAUDE_ACCOUNT_FP … → 34 cases OK) and is green in CI. Unrelated to this ticket; this change is additive (one new test + docs).

Observation (NOT this ticket, pull-only). Other consumers' shared workdirs on this host (idss, matou-app, matou-website, pregnancy-navigator, coa, ai-company-os) still carry a credentialed origin because their own FACTORY_REF pins are behind #195. Each cleans automatically when its pin bump past #195 lands a tick — their concern, not dev-factory's.

Ruled by agent under ADR 0174 — veto anytime.

## Close-report (#246) **Landed:** commit `18ae29e` on `main` — a standing guard `tests/no-token-in-git-url-test.sh` plus the STATUS/journal surface update. **Root cause (confirmed, not a #195 gap).** The #237 worker's sighting (2026-10-15 ~17:00Z) was caused by the running self-copy's pin PREDATING #195 — the `.sandcastle/git-setup.sh` that tick executed still wrote the old `https://swarm:<token>@…` into the shared `.git/config`. The #195 harness source was already correct: `git-setup.sh` runs `git_cred_strip_url` every tick, `git-cred-lib.sh` persists only a token-FREE helper (a `cat <secret>` pointer), and `swarm.yml` / `triage.yml` / `main.mts` all build a credential-free URL and inject auth per-invocation. The #222 re-vendor (`FACTORY_REF` = `0d638e1`, 2026-10-16) brought #195 into the running copy; a subsequent tick's `set-url` scrubbed the credential. **Acceptance — proof.** - *`git remote get-url origin` prints a URL with no credential, on the host shared workdir and in a fresh worker sandbox.* Verified on this host: `~/swarm/Matou/dev-factory` `origin` = `https://git.matou.nz/Matou/dev-factory.git` (no userinfo), with only the token-free helper persisted in `.git/config`. A fresh sandbox inherits that mounted, credential-free `.git` and `main.mts` never re-embeds a token, so its `origin` is credential-free too. The scrub is automatic every tick — proven offline by `tests/git-setup-test.sh` fixtures 1b (credential-free remote + helper seam) and 1c (a pre-seeded credentialed origin is reset credential-free on the next run). - *A test asserts the harness never writes a token into a remote URL.* `tests/no-token-in-git-url-test.sh` (86 checks): scans the harness surface (root `*.sh` + `*.mts`, `onboarding/*.sh`, `.forgejo/workflows/*.yml`, `onboarding/templates/workflows/*.tmpl` when present) for a URL whose userinfo carries a credential (`user:pass@` or a `$VAR@` expansion) and reds on any non-comment reintroduction; full-line `#`/`//` comments are exempt (git-cred-lib.sh's header quotes the old shape to explain the fix). Asserts it scanned >0 files (the park-wiring rc-2 "green because it read nothing" lesson) and carries its own positive/negative controls. Vendored via `tests/**` → a consumer re-runs it over its byte-identical harness and its own rendered workflow YAMLs; run by `ci.yml`, shellcheck-clean (v0.11.0, `-S warning -x`). **Tests.** Full offline suite: **97 suites, all green except `tests/rehearsal-heal-lib-test.sh`** — a known host-env leak (`CLAUDE_ACCOUNT_FP` is set in the session-runner host env; the test is non-hermetic and expects it unset). It passes with a clean env (`env -u CLAUDE_ACCOUNT_FP … → 34 cases OK`) and is green in CI. Unrelated to this ticket; this change is additive (one new test + docs). **Observation (NOT this ticket, pull-only).** Other consumers' shared workdirs on this host (`idss`, `matou-app`, `matou-website`, `pregnancy-navigator`, `coa`, `ai-company-os`) still carry a credentialed `origin` because their own `FACTORY_REF` pins are behind #195. Each cleans automatically when its pin bump past #195 lands a tick — their concern, not dev-factory's. Ruled by agent under ADR 0174 — veto anytime.

Second session — duplicate pick, reconciled

This ready-for-session ticket was picked by a second standing session on matou-workstation at roughly the same time (~05:25Z) as the session that landed 18ae29e and closed it at 05:44Z — a double-pick race. I worked it independently before seeing the close, and reached the same root cause and the same fix, which confirms 18ae29e:

  • Not a #195 gap. The running self-copy pin predated #195, so that tick's git-setup.sh still wrote https://swarm:<token>@…. The #195 harness source is credential-free — I scanned the whole remote-configuring surface (root *.sh/*.mts, git-cred-lib.sh, heal.sh, land-pr.sh/landing-lib.sh, main.mts, the rendered .forgejo/workflows/*.yml, and their onboarding/templates/workflows/*.tmpl) and found 0 code lines that embed a credential in a remote URL; every write builds a bare URL and injects auth per-invocation, and git_cred_strip_url scrubs any seeded credential each tick.
  • This host's dev-factory workdir is already credential-free: ~/swarm/Matou/dev-factory origin = https://git.matou.nz/Matou/dev-factory.git, token-free helper persisted (pin 0d638e1, post-#195).
  • Residue (pull-only, as the close-report noted): the other consumers' workdirs on this host (idss, matou-app, matou-website, pregnancy-navigator, coa, Tupu/ai-company-os) still carry a credentialed origin — confirmed their FACTORY_REF pins (7d40af32, 87e1b556, 1ab59e92) all predate #195 (cfb82ba), so their pinned git-setup.sh re-writes the token-URL each tick. Each self-heals when its own pin bump past #195 lands; dev-factory is pull-only and cannot fix it from here.

So I am not landing a duplicate — my equivalent local test (no-token-in-remote-url-test.sh) was discarded in favour of the already-merged tests/no-token-in-git-url-test.sh. The only loose end was this stale ready-for-session label on an already-closed ticket; I am removing it so the queue surface is consistent (the runner filters state=open, so it was never at risk of re-dispatch).

Ruled by agent under ADR 0174 — veto anytime. Two-way door: a label removal on a closed ticket, trivially reversible; the underlying fix is unchanged.

## Second session — duplicate pick, reconciled This `ready-for-session` ticket was picked by a second standing session on `matou-workstation` at roughly the same time (~05:25Z) as the session that landed `18ae29e` and closed it at 05:44Z — a double-pick race. I worked it independently before seeing the close, and reached the **same root cause and the same fix**, which confirms `18ae29e`: - **Not a #195 gap.** The running self-copy pin predated #195, so that tick's `git-setup.sh` still wrote `https://swarm:<token>@…`. The #195 harness source is credential-free — I scanned the whole remote-configuring surface (root `*.sh`/`*.mts`, `git-cred-lib.sh`, `heal.sh`, `land-pr.sh`/`landing-lib.sh`, `main.mts`, the rendered `.forgejo/workflows/*.yml`, and their `onboarding/templates/workflows/*.tmpl`) and found **0 code lines** that embed a credential in a remote URL; every write builds a bare URL and injects auth per-invocation, and `git_cred_strip_url` scrubs any seeded credential each tick. - **This host's dev-factory workdir is already credential-free:** `~/swarm/Matou/dev-factory` origin = `https://git.matou.nz/Matou/dev-factory.git`, token-free helper persisted (pin `0d638e1`, post-#195). - **Residue (pull-only, as the close-report noted):** the other consumers' workdirs on this host (`idss`, `matou-app`, `matou-website`, `pregnancy-navigator`, `coa`, `Tupu/ai-company-os`) still carry a credentialed origin — confirmed their `FACTORY_REF` pins (`7d40af32`, `87e1b556`, `1ab59e92`) all predate #195 (`cfb82ba`), so their pinned `git-setup.sh` re-writes the token-URL each tick. Each self-heals when its own pin bump past #195 lands; dev-factory is pull-only and cannot fix it from here. So I am **not** landing a duplicate — my equivalent local test (`no-token-in-remote-url-test.sh`) was discarded in favour of the already-merged `tests/no-token-in-git-url-test.sh`. The only loose end was this stale `ready-for-session` label on an already-closed ticket; I am removing it so the queue surface is consistent (the runner filters `state=open`, so it was never at risk of re-dispatch). **Ruled by agent under ADR 0174 — veto anytime.** Two-way door: a label removal on a closed ticket, trivially reversible; the underlying fix is unchanged.
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/dev-factory#246
No description provided.