fix(workflows): prevent auto_advance config from persisting across sessions

Introduce ephemeral `workflow._auto_chain_active` flag to separate chain
propagation from the user's persistent `workflow.auto_advance` preference.

Previously, `workflow.auto_advance` was set to true by --auto chains and
only cleared at milestone completion. If a chain was interrupted (context
limit, crash, user abort), the flag persisted in .planning/config.json
and caused all subsequent manual invocations to auto-advance unexpectedly.

The fix adds a "sync chain flag with intent" step to discuss-phase,
plan-phase, and execute-phase workflows: when --auto is NOT in arguments,
the ephemeral _auto_chain_active flag is cleared. The persistent
auto_advance setting (from /gsd:settings) is never touched, preserving
the user's deliberate preference.

Closes #857

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tibsfox
2026-03-03 02:30:31 -08:00
committed by Lex Christopherson
parent 1c6f4fe11f
commit 609f7f3ede
7 changed files with 41 additions and 17 deletions

View File

@@ -205,13 +205,14 @@ Do NOT continue reading. Analysis without action is a stuck signal.
</authentication_gates>
<auto_mode_detection>
Check if auto mode is active at executor start:
Check if auto mode is active at executor start (chain flag or user preference):
```bash
AUTO_CHAIN=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
```
Store the result for checkpoint handling below.
Auto mode is active if either `AUTO_CHAIN` or `AUTO_CFG` is `"true"`. Store the result for checkpoint handling below.
</auto_mode_detection>
<checkpoint_protocol>

View File

@@ -8,7 +8,7 @@ Plans execute autonomously. Checkpoints formalize interaction points where human
2. **Claude sets up the verification environment** - Start dev servers, seed databases, configure env vars
3. **User only does what requires human judgment** - Visual checks, UX evaluation, "does this feel right?"
4. **Secrets come from user, automation comes from Claude** - Ask for API keys, then Claude uses them via CLI
5. **Auto-mode bypasses verification/decision checkpoints** — When `workflow.auto_advance` is true in config: human-verify auto-approves, decision auto-selects first option, human-action still stops (auth gates cannot be automated)
5. **Auto-mode bypasses verification/decision checkpoints** — When `workflow._auto_chain_active` or `workflow.auto_advance` is true in config: human-verify auto-approves, decision auto-selects first option, human-action still stops (auth gates cannot be automated)
</overview>
<checkpoint_types>

View File

@@ -589,17 +589,24 @@ node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" commit "docs(state): record
Check for auto-advance trigger:
1. Parse `--auto` flag from $ARGUMENTS
2. Read `workflow.auto_advance` from config:
2. **Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference):
```bash
if [[ ! "$ARGUMENTS" =~ --auto ]]; then
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
fi
```
3. Read both the chain flag and user preference:
```bash
AUTO_CHAIN=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
```
**If `--auto` flag present AND `AUTO_CFG` is not true:** Persist auto-advance to config (handles direct `--auto` usage without new-project):
**If `--auto` flag present AND `AUTO_CHAIN` is not true:** Persist chain flag to config (handles direct `--auto` usage without new-project):
```bash
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow.auto_advance true
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active true
```
**If `--auto` flag present OR `AUTO_CFG` is true:**
**If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
Display banner:
```

View File

@@ -26,6 +26,13 @@ Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelizat
**If `state_exists` is false but `.planning/` exists:** Offer reconstruct or continue.
When `parallelization` is false, plans within a wave execute sequentially.
**Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference). Must happen before any config reads (checkpoint handling also reads auto-advance flags):
```bash
if [[ ! "$ARGUMENTS" =~ --auto ]]; then
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
fi
```
</step>
<step name="handle_branching">
@@ -179,12 +186,13 @@ Plans with `autonomous: false` require user interaction.
**Auto-mode checkpoint handling:**
Read auto-advance config:
Read auto-advance config (chain flag + user preference):
```bash
AUTO_CHAIN=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
```
When executor returns a checkpoint AND `AUTO_CFG` is `"true"`:
When executor returns a checkpoint AND (`AUTO_CHAIN` is `"true"` OR `AUTO_CFG` is `"true"`):
- **human-verify** → Auto-spawn continuation agent with `{user_response}` = `"approved"`. Log `⚡ Auto-approved checkpoint`.
- **decision** → Auto-spawn continuation agent with `{user_response}` = first option from checkpoint details. Log `⚡ Auto-selected: [option]`.
- **human-action** → Present to user (existing behavior below). Auth gates cannot be automated.
@@ -405,12 +413,13 @@ STOP. Do not proceed to auto-advance or transition.
**Auto-advance detection:**
1. Parse `--auto` flag from $ARGUMENTS
2. Read `workflow.auto_advance` from config:
2. Read both the chain flag and user preference (chain flag already synced in init step):
```bash
AUTO_CHAIN=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
```
**If `--auto` flag present OR `AUTO_CFG` is true (AND verification passed with no gaps):**
**If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true (AND verification passed with no gaps):**
```
╔══════════════════════════════════════════╗

View File

@@ -191,10 +191,10 @@ mkdir -p .planning
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" commit "chore: add project config" --files .planning/config.json
```
**Persist auto-advance to config (survives context compaction):**
**Persist auto-advance chain flag to config (survives context compaction):**
```bash
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow.auto_advance true
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active true
```
Proceed to Step 4 (skip Steps 3 and 5).

View File

@@ -441,12 +441,19 @@ Route to `<offer_next>` OR `auto_advance` depending on flags/config.
Check for auto-advance trigger:
1. Parse `--auto` flag from $ARGUMENTS
2. Read `workflow.auto_advance` from config:
2. **Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference):
```bash
if [[ ! "$ARGUMENTS" =~ --auto ]]; then
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
fi
```
3. Read both the chain flag and user preference:
```bash
AUTO_CHAIN=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
```
**If `--auto` flag present OR `AUTO_CFG` is true:**
**If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
Display banner:
```

View File

@@ -451,9 +451,9 @@ Exit skill and invoke SlashCommand("/gsd:discuss-phase [X+1] --auto")
**Route B: Milestone complete (all phases done)**
**Clear auto-advance** — milestone boundary is the natural stopping point:
**Clear auto-advance chain flag** — milestone boundary is the natural stopping point:
```bash
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow.auto_advance false
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false
```
<if mode="yolo">