From aff9f0fcef13ffd586d1934dfbecb84f4c1de6a4 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Apr 2026 07:15:28 +0000 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20bug:=20architect=20FORGE=5FTOKEN=20o?= =?UTF-8?q?verride=20nullified=20when=20env.sh=20re-sources=20.env=20?= =?UTF-8?q?=E2=80=94=20agent=20actions=20authored=20as=20dev-bot=20(#762)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use FORGE_TOKEN_OVERRIDE (set before sourcing env.sh) instead of post-source FORGE_TOKEN reassignment in all five agent run scripts. The override mechanism in lib/env.sh:98-100 survives re-sourcing from nested shells and claude -p tool invocations. Affected scripts: architect-run.sh, planner-run.sh, gardener-run.sh, predictor-run.sh, supervisor-run.sh. Co-Authored-By: Claude Opus 4.6 (1M context) --- architect/architect-run.sh | 5 +++-- gardener/gardener-run.sh | 5 +++-- planner/planner-run.sh | 5 +++-- predictor/predictor-run.sh | 5 +++-- supervisor/supervisor-run.sh | 5 +++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/architect/architect-run.sh b/architect/architect-run.sh index ff5caaa..d23b5b4 100755 --- a/architect/architect-run.sh +++ b/architect/architect-run.sh @@ -34,10 +34,11 @@ FACTORY_ROOT="$(dirname "$SCRIPT_DIR")" # Accept project config from argument; default to disinto export PROJECT_TOML="${1:-$FACTORY_ROOT/projects/disinto.toml}" +# Set override BEFORE sourcing env.sh so it survives any later re-source of +# env.sh from nested shells / claude -p tools (#762, #747) +export FORGE_TOKEN_OVERRIDE="${FORGE_ARCHITECT_TOKEN:-}" # shellcheck source=../lib/env.sh source "$FACTORY_ROOT/lib/env.sh" -# Override FORGE_TOKEN with architect-bot's token (#747) -FORGE_TOKEN="${FORGE_ARCHITECT_TOKEN:-${FORGE_TOKEN}}" # shellcheck source=../lib/formula-session.sh source "$FACTORY_ROOT/lib/formula-session.sh" # shellcheck source=../lib/worktree.sh diff --git a/gardener/gardener-run.sh b/gardener/gardener-run.sh index 9a7ad90..29036b6 100755 --- a/gardener/gardener-run.sh +++ b/gardener/gardener-run.sh @@ -26,10 +26,11 @@ FACTORY_ROOT="$(dirname "$SCRIPT_DIR")" # Accept project config from argument; default to disinto export PROJECT_TOML="${1:-$FACTORY_ROOT/projects/disinto.toml}" +# Set override BEFORE sourcing env.sh so it survives any later re-source of +# env.sh from nested shells / claude -p tools (#762, #747) +export FORGE_TOKEN_OVERRIDE="${FORGE_GARDENER_TOKEN:-}" # shellcheck source=../lib/env.sh source "$FACTORY_ROOT/lib/env.sh" -# Use gardener-bot's own Forgejo identity (#747) -FORGE_TOKEN="${FORGE_GARDENER_TOKEN:-${FORGE_TOKEN}}" # shellcheck source=../lib/formula-session.sh source "$FACTORY_ROOT/lib/formula-session.sh" # shellcheck source=../lib/worktree.sh diff --git a/planner/planner-run.sh b/planner/planner-run.sh index 227dd94..6c5bcb2 100755 --- a/planner/planner-run.sh +++ b/planner/planner-run.sh @@ -22,10 +22,11 @@ FACTORY_ROOT="$(dirname "$SCRIPT_DIR")" # Accept project config from argument; default to disinto (planner is disinto infrastructure) export PROJECT_TOML="${1:-$FACTORY_ROOT/projects/disinto.toml}" +# Set override BEFORE sourcing env.sh so it survives any later re-source of +# env.sh from nested shells / claude -p tools (#762, #747) +export FORGE_TOKEN_OVERRIDE="${FORGE_PLANNER_TOKEN:-}" # shellcheck source=../lib/env.sh source "$FACTORY_ROOT/lib/env.sh" -# Use planner-bot's own Forgejo identity (#747) -FORGE_TOKEN="${FORGE_PLANNER_TOKEN:-${FORGE_TOKEN}}" # shellcheck source=../lib/formula-session.sh source "$FACTORY_ROOT/lib/formula-session.sh" # shellcheck source=../lib/worktree.sh diff --git a/predictor/predictor-run.sh b/predictor/predictor-run.sh index 8400418..7c5d851 100755 --- a/predictor/predictor-run.sh +++ b/predictor/predictor-run.sh @@ -23,10 +23,11 @@ FACTORY_ROOT="$(dirname "$SCRIPT_DIR")" # Accept project config from argument; default to disinto export PROJECT_TOML="${1:-$FACTORY_ROOT/projects/disinto.toml}" +# Set override BEFORE sourcing env.sh so it survives any later re-source of +# env.sh from nested shells / claude -p tools (#762, #747) +export FORGE_TOKEN_OVERRIDE="${FORGE_PREDICTOR_TOKEN:-}" # shellcheck source=../lib/env.sh source "$FACTORY_ROOT/lib/env.sh" -# Use predictor-bot's own Forgejo identity (#747) -FORGE_TOKEN="${FORGE_PREDICTOR_TOKEN:-${FORGE_TOKEN}}" # shellcheck source=../lib/formula-session.sh source "$FACTORY_ROOT/lib/formula-session.sh" # shellcheck source=../lib/worktree.sh diff --git a/supervisor/supervisor-run.sh b/supervisor/supervisor-run.sh index b27293c..e04f328 100755 --- a/supervisor/supervisor-run.sh +++ b/supervisor/supervisor-run.sh @@ -25,10 +25,11 @@ FACTORY_ROOT="$(dirname "$SCRIPT_DIR")" # Accept project config from argument; default to disinto export PROJECT_TOML="${1:-$FACTORY_ROOT/projects/disinto.toml}" +# Set override BEFORE sourcing env.sh so it survives any later re-source of +# env.sh from nested shells / claude -p tools (#762, #747) +export FORGE_TOKEN_OVERRIDE="${FORGE_SUPERVISOR_TOKEN:-}" # shellcheck source=../lib/env.sh source "$FACTORY_ROOT/lib/env.sh" -# Use supervisor-bot's own Forgejo identity (#747) -FORGE_TOKEN="${FORGE_SUPERVISOR_TOKEN:-${FORGE_TOKEN}}" # shellcheck source=../lib/formula-session.sh source "$FACTORY_ROOT/lib/formula-session.sh" # shellcheck source=../lib/worktree.sh From 66ba93a840cc2d6e4b1045781360f4ef5f00843b Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Apr 2026 07:18:42 +0000 Subject: [PATCH 2/2] fix: add allowlist entry for standard lib source block in duplicate detection The FORGE_TOKEN_OVERRIDE fix shifted line numbers in agent run scripts, causing the shared source block (env.sh, formula-session.sh, worktree.sh, guard.sh, agent-sdk.sh) to register as a new duplicate. This is intentional boilerplate shared across all formula-driven agents. Co-Authored-By: Claude Opus 4.6 (1M context) --- .woodpecker/detect-duplicates.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.woodpecker/detect-duplicates.py b/.woodpecker/detect-duplicates.py index 35f3aa8..0485833 100644 --- a/.woodpecker/detect-duplicates.py +++ b/.woodpecker/detect-duplicates.py @@ -292,6 +292,8 @@ def main() -> int: "21aec56a99d5252b23fb9a38b895e8e8": "Verification helper: check body for Decomposed from pattern", "60ea98b3604557d539193b2a6624e232": "Verification helper: append sub-issue number", "9f6ae8e7811575b964279d8820494eb0": "Verification helper: for loop done pattern", + # Standard lib source block shared across formula-driven agent run scripts + "330e5809a00b95ade1a5fce2d749b94b": "Standard lib source block (env.sh, formula-session.sh, worktree.sh, guard.sh, agent-sdk.sh)", } if not sh_files: