Relationships
#2908 Run from a git worktree: definitions from the worktree, state from the shared repo
Opened by skunk-ape · 10/1/2026
What happens
swamp treats one directory as both the source of definitions (workflows, models) and the home of state (.swamp/). --repo-dir sets both at once.
A git worktree splits them. The definitions you want are the worktree's (the change under work), but the state lives in the main checkout's .swamp/, since the worktree is not an initialized swamp repo. So from a worktree you pass --repo-dir <main checkout>, and swamp then also reads definitions from the main checkout.
To get the worktree's workflows back you set SWAMP_WORKFLOWS_DIR to an absolute path into the worktree. A relative path resolves against --repo-dir, so it silently runs the main checkout's workflows instead.
Why it matters
swamp-extensions' pre-PR verification (verification/workflow-verify*.yaml) must run the change's own workflow files: build-attestation and CI's validate-attestation pin them. Every agent session works from a worktree, so issue-lifecycle and the gatorwalk-factory verify stage both carry hand-written instructions to build an absolute path and add --repo-dir. Getting it wrong fails late, at attestation, not at the run.
gatorwalk-factory works around it for now (swamp-club #2773) by computing both paths with git in the stage command, which couples the factory definition to git.
Fix direction
Preferred: a worktree (or any directory) can be a swamp repo whose state lives elsewhere. Definitions come from the directory you run in; models, data and run history come from the shared repo. No --repo-dir, no SWAMP_WORKFLOWS_DIR. Worth checking first whether a datastore configuration can already point a worktree at the main checkout's state.
Fallback: resolve a relative SWAMP_WORKFLOWS_DIR against the working directory rather than --repo-dir. That removes the absolute path; --repo-dir is still needed.
Done when
From a worktree of a swamp repo, swamp workflow run <name> runs the worktree's definition of that workflow and records the run in the shared repo's state, with no absolute paths supplied by hand.
Open
No activity in this phase yet.
Sign in to post a ripple.