token-sync.yml should write the host's factory-owned env file, not rehearsal-env.sh (dev-factory #37) #719
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#719
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?
Filed from
Matou/dev-factory(pull-only, ADR 0001 — no push from there), as aconsequence of dev-factory #37:
matou-workstation's host env file has beensplit into a factory-owned shared file and a per-repo product file.
What changed on the host (already live, 2026-08-24)
/home/dev/swarm/host-env.sh— the shared env every factory-managed cronline sources (
PATH,FORGEJO_TOKEN,CLAUDE_CODE_OAUTH_TOKEN/_B, theMATTERMOST_*trio). This is what the host registry'senvdirective names./home/dev/swarm/idss-env.sh— this repo's own host env(
DIGITALOCEAN_ACCESS_TOKEN,IDSS_BROKER_URL,IDSS_PAYLOAD_DIR,REHEARSAL_DRIVE_ISSUE,REHEARSAL_DRIVE_TARGET,ELECTRON_OVERRIDE_DIST_PATH), sourced after the shared one. The registrygained a
repo-env <owner/repo> <file>directive for exactly this, so idss'ssession-runner tick sources both layers and no other repo's tick sees these
variables. The rehearsal-executor cron line now reads
. /home/dev/swarm/host-env.sh && . /home/dev/swarm/idss-env.sh && …./home/dev/swarm/rehearsal-env.shis no longer a file: it is a symlink tohost-env.sh, kept purely as a compatibility shim for this repo'stoken-sync.yml.What this repo owns
.forgejo/workflows/token-sync.ymlhard-codesenv_file: /home/dev/swarm/rehearsal-env.sh(and/home/swarm/swarm/rehearsal-env.shforelitebook-03). It writes the orgClaude + Mattermost secrets — all of them shared host state — so it should
name the host's factory-owned env file directly. Verified before the cutover
that its exact write path (
open(f, "w").write(s)) writes through asymlink, preserving the link, the file's comments and mode 600, so token
rotation keeps working unchanged until this lands. When it does, the symlink
should be deleted (
rm /home/dev/swarm/rehearsal-env.sh).elitebook-03is untouched — no door from the machine this was done on.Its
/home/swarm/swarm/rehearsal-env.shis still the single product-flavouredfile, and its enrolment (dev-factory #6) is still owed.
scripts/rehearsal-executor.sh:16'sexample cron line,
scripts/rehearsal-cycle.sh:47/87/159/180,docs/PROCESS.md,docs/GOTCHAS.md.Nothing here is urgent: every live loop on
matou-workstationwas re-run undera cron-like
env -i /bin/shafter the cutover and carries exactly the variablesit did before.
Ruled by agent under ADR 0174 — veto anytime
Ruling:
enhancement+ready-for-session(notready-for-agent).Why this is a two-way door: the repo-side edits (
token-sync.yml'senv_filefor thematou-workstationleg, plus the stale-path comments inscripts/rehearsal-executor.sh,scripts/rehearsal-cycle.sh,docs/PROCESS.md,docs/GOTCHAS.md) are ordinary revertible commits. But theissue's own completion step —
rm /home/dev/swarm/rehearsal-env.shon thelive
matou-workstationcron host, done only after confirming the newworkflow leg has written a correct
host-env.sh— needs host standing asandboxed swarm worker doesn't have (no door to that machine). That's exactly
the "host credentials, live-infrastructure operations" class
ready-for-sessionexists for (
docs/agents/triage-labels.md), not aready-for-humanone-waydoor: there's no personal-credential, security-widening, trust-surface-accept,
data-destruction, or physical-hardware element here, and the filer already
did the hard part (verified the write-through-symlink behavior pre-cutover).
What proves it: the compat symlink means nothing is broken today (filer's
own "nothing here is urgent" note); a session can land the workflow-file
commit, dispatch
token-synconce to confirm the new leg writeshost-env.shwith the right fingerprint, then remove the old symlink —each step independently revertible (re-add the symlink, revert the commit) and
each verifiable by the workflow's own sha256-fingerprint output.
Agent Brief (for the session that picks this up)
Category: enhancement
Summary: Point
token-sync.yml'smatou-workstationleg at thehost's factory-owned shared env file instead of the compatibility symlink,
update stale-path references, then retire the symlink on the host.
Current behavior:
token-sync.ymlwrites the org Claude/Mattermosttokens into
/home/dev/swarm/rehearsal-env.shonmatou-workstation, whichis now only a compatibility symlink to the factory-owned
/home/dev/swarm/host-env.sh(perMatou/dev-factory#37). Theelitebook-03leg is unaffected — that host hasn't been migrated and itsrehearsal-env.shis still the one real file.Desired behavior: The
matou-workstationmatrix entry'senv_filenames
/home/dev/swarm/host-env.shdirectly. Comments/docs referencing theold symlink path as if it were the canonical file
(
scripts/rehearsal-executor.sh's example cron line,scripts/rehearsal-cycle.sh's comments,docs/PROCESS.md,docs/GOTCHAS.md) are updated to name the real file. Once a livetoken-syncdispatch confirms the new leg writes the right tokenfingerprints into
host-env.sh, the now-unused/home/dev/swarm/rehearsal-env.shsymlink is deleted on the host.Acceptance criteria:
token-sync.yml'smatou-workstationleg writes to/home/dev/swarm/host-env.sh; theelitebook-03leg is untouched(or explicitly left, with a one-line reason, if still accurate)
workflow_dispatchoftoken-synconmatou-workstationconfirms (via its existing fingerprint-print step) the new file
receives the current org token
/home/dev/swarm/rehearsal-env.shis removed frommatou-workstationonly after that confirmation
Out of scope:
elitebook-03(its own migration is dev-factory #6, tracked separately)shipped
Ruled by agent under ADR 0174 — veto anytime
Ruling 1 — the
matou-workstationleg names the SHARED file, not the product one.Everything
token-syncwrites (the org Claude primary/standby, theMATTERMOST_*trio) is shared host state consumed by every factory-managed cron line on the
box — dev-factory's session-runner tick, the backstop, idss's own lines. So the
leg names
/home/dev/swarm/host-env.sh(the registry'senvdirective), never/home/dev/swarm/idss-env.sh(therepo-env Matou/idssproduct file). Writingthe tokens into the product file would have been the tidy-looking wrong answer:
idss's own crons would keep working and every other repo's line on the host would
silently lose its Claude token.
Why it is a two-way door: a one-line matrix value in a revertible commit, on
a host file that is backed up in place before the write, with the old value one
git revertaway. No personal credential (the org secret is the source of truthand is unchanged), no posture widening (the file keeps mode 600, same owner, same
key set), no member-facing trust accept, no spend, nothing destroyed.
What proves it: a new offline guard,
scripts/tests/token-sync-env-file-test.sh,red before / green after — it reds on the removed-symlink path and on the
product-file path, and also if anything under
scripts/,.forgejo/or the tworunbook docs re-introduces the literal
/home/dev/swarm/rehearsal-env.sh. Plusthe live dispatch below.
Ruling 2 —
elitebook-03is left exactly as it was. Its leg still names/home/swarm/swarm/rehearsal-env.sh. That host is not factory-enrolled yet(dev-factory #6 still owed) and there is no door to it from
matou-workstation,so its single un-split file is still the one real file it has. The new guard pins
this deliberately, so a well-meaning sweep cannot "finish the job" and break the
second executor's only token source. Its leg went
successon this dispatch, sothat host is unaffected and still syncing.
Ruling 3 — the factory-vendored
.sandcastle/copies are fixed UPSTREAM, nothere.
session-runner.sh's example crontab andrehearsal-report.sh'sauth-refusal alarm text both still name the old path, but both are vendored
byte-for-byte from
Matou/dev-factory(.sandcastle/FACTORY_MANIFEST, enforcedby
check-harness-drift.sh— editing them here reds the drift alarm). Filed asMatou/dev-factory#44 with the exact lines and the live crontab line to replace
them with. The guard's scope excludes
.sandcastle/for exactly this reason, andsays so in a comment.
Close report — #719
Landed:
020bd30e(repo side) +28d0dff9(live cutover + GOTCHAS #73).Acceptance criteria
token-sync.yml'smatou-workstationleg writes/home/dev/swarm/host-env.sh; theelitebook-03leg is untouched. Its leg still names/home/swarm/swarm/rehearsal-env.shand wentsuccesson both dispatches — that host is not factory-enrolled yet (dev-factory #6), so its single un-split file is still the one real file it has.scripts/rehearsal-executor.sh(its example cron line now shows the split source, matching the live crontab),scripts/rehearsal-cycle.sh(all four sites),docs/PROCESS.md("Adding an executor host" step 2 now describes both layers and the registry directives that name them; step 5 says name the SHARED file in the matrix),docs/GOTCHAS.md#53 (its cross-host verification command now reads both layouts —idss-env.shandrehearsal-env.sh,grep -hskipping the absent one — and picks upREHEARSAL_DRIVE_QUEUE, which did not exist when it was written). Two more the filing did not list but which named the old path and would have gone stale:scripts/lib/gateway-image-rebuild-lib.shandscripts/lib/rehearsal-queue-lib.sh.workflow_dispatchconfirms the new file receives the current org token. Twice — see below.The live cutover, in the ticket's own order
host-env.shenv-backups/host-env.sh.bak-719-20260824T010840Z19310, legsync (/home/dev/swarm/host-env.sh, matou-workstation)success. The leg name carries the matrix value, so it names the path it wrote. File came back byte-identical to the backup: all six value fingerprints unchanged, mode600, ownerdev:dev, all 20 comment lines intactrm /home/dev/swarm/rehearsal-env.sh19318successwith the symlink already removed — same six fingerprints, andhost-env.sh's new #719 comment survived the workflow's rewrite. This is the decisive one: the writer no longer needs the shim19303/19319successboth times, untouchedenv -i /bin/shre-source of the real crontab linesFingerprints are
sha256 | cut -c1-16of each value, never the value; they were recorded before dispatch 1 and re-checked after each — the org secrets already matched what was on the box, which is why the first write was a no-op byte-wise.Residue found and cleared (not in the filing)
Four host-local one-off helper scripts still sourced the symlink directly —
confirm-phase2-verify.sh,confirm-phase3-widened.sh,phase2-prove-658.sh,phase2-reconfirm.sh. They were already half-broken by the #37 split before this ticket: the shim resolved to the shared layer alone, so a re-run would have got noDIGITALOCEAN_ACCESS_TOKENand noREHEARSAL_DRIVE_*. All four now source both layers, each backed up in place. Nothing else on the host referenced the name — zero crontab hits, no systemd unit.Guarded, so neither mistake is silent
New
scripts/tests/token-sync-env-file-test.sh(red before green — the red wasenv_file is '/home/dev/swarm/rehearsal-env.sh', want '/home/dev/swarm/host-env.sh'). It reds on both ways to get this wrong: re-pointing the leg at the removed symlink (the leg then fails its own[ -w "$f" ]guard, no token lands, the host limit-parks on its first reporter call — #659's 4-day phase-3 stall), and "tidying" it into the repo'srepo-envproduct file (every other factory-managed line on the host silently loses its Claude token). It also pins elitebook-03's path so a well-meaning sweep cannot break the second executor's only token source, and reds if anything underscripts/,.forgejo/or the two runbook docs re-introduces the literal old path. GOTCHAS #73 records the hazard in prose for whoever edits a host registry next.Left open, deliberately, and routed
.sandcastle/session-runner.sh(its example crontab) and.sandcastle/rehearsal-report.sh(the auth-refusal alarm text an operator reads during an incident to find the token source) both still name the old path. They are vendored byte-for-byte fromMatou/dev-factory(FACTORY_MANIFEST, enforced bycheck-harness-drift.sh— editing them here reds the drift alarm), so the fix belongs upstream: filed as Matou/dev-factory#44 with the exact lines and the live crontab line to replace them with. The new guard's scope excludes.sandcastle/for exactly this reason and says so in a comment. Unrelated but noted while there:FACTORY_REFis 32 commits behind dev-factorymain(a NOTE, not a failure) — bumping it is the natural moment to pull #44's fix in.Green at close:
token-sync-env-file4/4, all 14scripts/tests/*,check-harness-driftOK,.sandcastlesession-runner-test10 groups andrehearsal-report-test32 cases.Ruled by agent under ADR 0174 — veto anytime. Two-way doors throughout: the host file was backed up before every write and the symlink is one
ln -s host-env.sh rehearsal-env.shfrom restored; the org secret is unchanged and still the source of truth; mode, owner and key set are unchanged, so nothing was widened; no personal credential, no member-facing trust accept, no spend, nothing destroyed.