Skip to content

feat: portable multi-run state architecture (v0.2.0)#1

Merged
quaat merged 1 commit into
mainfrom
v0.2.0
Jun 12, 2026
Merged

feat: portable multi-run state architecture (v0.2.0)#1
quaat merged 1 commit into
mainfrom
v0.2.0

Conversation

@quaat

@quaat quaat commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • New scripts/state.py — shared module for git-root discovery, XDG state-home resolution, hashed repository identity, RunStateLock (fcntl.flock), atomic writes, schema v1→v2 migration, and drift detection
  • Refactored scripts/controller.py — all mutating commands use lock+reload; new commands list-runs, show-run, migrate-legacy-state, archive-run, accept-drift; --state-dir/--run-id global options; init --reuse errors when multiple active runs exist
  • Refactored scripts/stop_gate.py — uses shared resolver; _block_and_exit atomically reloads state inside the lock before incrementing stop_gate_blocks
  • New tests/test_state.py — 25 tests covering all 12 acceptance criteria (nested dirs, worktrees, credential stripping, XDG precedence, concurrent runs, drift, migration, concurrency, etc.)
  • Updated tests/test_controller.py — regression tests for review-budget exhaustion and --reuse ambiguity
  • Docs — README and all skill MDs updated with XDG, multi-run, migration, drift, and shell examples

Test plan

  • python3 -m pytest tests/test_state.py tests/test_controller.py -q → 31 passed
  • .venv/bin/ruff check → all checks passed
  • python3 -m py_compile scripts/state.py scripts/controller.py scripts/stop_gate.py → clean
  • controller.py status from repo root and a nested subdirectory resolves the same run
  • controller.py migrate-legacy-state imports .ai/autonomous-development/ without deleting originals
  • Stop gate bounded-block behavior works end-to-end with CLAUDE_AUTONOMOUS_STATE_HOME set

🤖 Generated with Claude Code

Upgrade the plugin from a CWD-relative single-run state model to a
portable, configurable, multi-run architecture:

- scripts/state.py: new shared module — git-root discovery, XDG state
  home resolver, hashed repo identity, RunStateLock (fcntl.flock),
  atomic writes, schema v1→v2 migration, drift detection
- scripts/controller.py: imports state.py; all mutating commands use
  RunStateLock + reload; new commands: list-runs, show-run,
  migrate-legacy-state, archive-run, accept-drift; --state-dir and
  --run-id global options; init --reuse errors on ambiguous active runs
- scripts/stop_gate.py: uses shared resolver; _block_and_exit atomically
  reloads state inside the lock before incrementing stop_gate_blocks
- tests/test_state.py: 25 new tests covering all acceptance criteria
- tests/test_controller.py: regression tests for budget exhaustion and
  --reuse ambiguity; --state-dir wired through run_controller helper
- docs: README and all skill MDs updated with XDG, multi-run, migration,
  drift, and shell examples

All 31 tests pass. Ruff clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@quaat
quaat merged commit 63da63d into main Jun 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant