Skip to content

Add per-task state record (status + session links)#38

Merged
drabaioli merged 10 commits into
mainfrom
task_state_tracking
Jun 30, 2026
Merged

Add per-task state record (status + session links)#38
drabaioli merged 10 commits into
mainfrom
task_state_tracking

Conversation

@drabaioli

Copy link
Copy Markdown
Owner

What

Adds a per-task state record — a <branch>.state.json sibling of the handoff file — that records where a task sits in its lifecycle (stage/status) and which Claude Code sessions have worked it (an append-only sessions chain with claude --resume links). It is an additive, advisory, local-only sibling of the handoff: same per-repo directory, same <branch> basename, same branch-scoped/ephemeral lifecycle.

The motivating consumer is an external dashboard (cdd-dash); this PR only lands the producer side. Consuming the record (teaching cdd-worktree-list/cdd-dash to read it) and multi-machine resume (issue #22) are tracked as follow-ups.

How

Process-first, then template (drift clean):

  • Process doc claude-driven-development.md: new §2.13 (schema, vocabulary, writer/consumer contract), plus updates to §2.6 (handoff has a state sibling), §2.8 (helper deletes it), §3.3 (implementation session writes it).
  • Slash commands (repo + template copies): /cdd-next-step seeds the record; the implementation session updates it twice (plan-approved, implementation-done) via a standing handoff instruction; /cdd-merge-base, /cdd-pre-pr, /cdd-process-pr advance it at their stage transitions.
  • tools/cdd-worktree.sh: cdd-worktree-done deletes the state record alongside the handoff iff the branch was deleted.
  • settings.json (repo + template): allow Write to the handoff dir, rm *.state.json, hostname, date -u*.
  • Docs: architecture overview, feature doc, BOOTSTRAP.md reconciled; roadmap gains Phase 13: Task state & observability.

Verification

  • bash -n (scripts/tools/demo) ✓ · command-set drift ✓ clean · install smoke ✓ · end-to-end bootstrap smoke ✓ · demo seed-overlay smoke ✓
  • Rendered template settings.json substitutes correctly and picks up the new allows.

Notes

  • The state-file deletion in cdd-worktree-done ships untested: that function is fully interactive (read prompts, git worktree remove, gh, branch deletion) and has no existing harness; the new logic is two lines mirroring the adjacent handoff deletion. Recorded as an "untested-with-reason" outcome; a non-interactive harness for it is a possible future task.

drabaioli and others added 2 commits June 29, 2026 12:41
Introduce a small JSON file colocated with the handoff at
~/.cdd/handoffs/<repo>/<branch>.state.json, written by the slash commands at
their stage transitions and read by external consumers (cdd-dash). It captures
a task's stage + finer status, the PR number once opened, and the append-only
chain of Claude Code sessions that worked it (each session link is
`claude --resume <id>`, derived from $CLAUDE_CODE_SESSION_ID).

The record is advisory and reconstructible: a local cache describing work on
this machine, explicitly not a cross-machine transfer mechanism (issue #22) and
not an event history (snapshot + timestamps only). It is an additive sibling of
the handoff and fits the frozen worktree-helper contract without enlarging it —
the helper only deletes it.

- Process doc: new §2.13 documenting the schema, stage/status vocabulary,
  session mechanism, and non-goals; pointers from §2.6/§2.8/§3.3.
- Commands (repo + template copies, drift-checked parity): /cdd-next-step seeds
  the record and instructs the implementation session to write plan_approved /
  implementation_done; /cdd-merge-base, /cdd-pre-pr (checks_passed + pr_open),
  and /cdd-process-pr record their transitions. In-worktree writers derive the
  path at runtime (drift-free); next-step uses its existing hardcoded-slug path.
- cdd-worktree.sh: cdd-worktree-done deletes the .state.json sibling alongside
  the handoff (only when the branch is deleted); the stale sweep in
  /cdd-next-step removes it too.
- settings.json (both copies): allow Write to the handoff dir, rm of
  *.state.json, and hostname / date -u for stamping.

cdd-dash consumption is a mechanical follow-up in that repo; no roadmap change
(off-roadmap, intent-driven).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pre-PR reconciliation: the state-record feature was off-roadmap
intent-driven work with no existing checkbox. Record the landed item
plus its named downstream follow-ups (consume the record in
cdd-worktree-list/cdd-dash; multi-machine resume, issue #22).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread .claude/commands/cdd-merge-base.md Outdated
Comment thread .claude/commands/cdd-merge-base.md Outdated
Comment thread doc/knowledge_base/claude-driven-development.md Outdated
Comment thread .claude/commands/cdd-next-step.md Outdated
Comment thread .claude/commands/cdd-next-step.md Outdated
Comment thread doc/knowledge_base/claude-driven-development.md Outdated
Comment thread doc/knowledge_base/claude-driven-development.md Outdated
Comment thread doc/knowledge_base/claude-driven-development.md
Comment thread doc/knowledge_base/claude-driven-development.md Outdated
Comment thread doc/knowledge_base/roadmap.md Outdated
drabaioli and others added 6 commits June 29, 2026 22:12
Record the investigation outcome: a dual-mode cdd-state helper for
atomic writes plus a gh-pr-create PostToolUse hook for the one
outcome-bearing transition. Note that a fully guaranteed
UserPromptSubmit/Expansion trigger fires at invocation only, so it
cannot capture outcomes (checks_passed, PR number) the model produces
mid-run.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the prompt-driven JSON hand-editing with tools/cdd-state.sh, a
dual-mode self-installing helper (like cdd-worktree.sh): cdd-state seed
<branch> creates the record, cdd-state set <stage> [--pr NN] advances it.
Writes are atomic (temp-file + rename) and well-formed, so the
malformed-JSON / wrong-field failure mode of hand-editing is gone; the
model still decides when. Absent jq or an absent record, it no-ops.

Simplify the schema per review: squash stage+status into a single stage
enum, trim session entries to {id, stage}, and drop the url, machine,
created_at, updated_at, recorded_at fields (all speculative / no current
consumer). Every command's verbose state paragraph collapses to one
cdd-state line, which also removes the process-doc references from the
prompts. settings.json swaps the Write/hostname/date allows for
Bash(cdd-state*).

Addresses PR #38 review: #3494362739, #3494407885, #3494415079,
#3494288014, #3494420020, #3494418136, #3494308377, #3493923487,
#3494324754.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…n motivation

Process doc §2.13 rewritten around the session resume-chain (find/resume
the session that worked a branch) as the primary payoff; cdd-dash is one
downstream consumer, not the justification. Documents the cdd-state
helper, the single stage enum, and the slimmed schema. §2.8 gains a note
on the companion helper; the frozen three-command worktree contract is
unchanged.

Roadmap: mark the helper done (Phase 13a), narrow the remaining
hardening to the gh-pr-create PostToolUse hook, and scope the consume
item to cdd-dash (cdd-worktree-list infers fine, doesn't need the
record). Architecture/feature/BOOTSTRAP updated for the second
self-installing helper and the settings allow change.

Addresses PR #38 review: #3494396840, #3494425533, #3494430578,
#3494436426.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The repo's own .claude/settings.json now mirrors the template: drop the
unused Write/hostname/date allows and add Bash(cdd-state*), so this
repo's CDD sessions can run the state helper without a prompt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…UDE.md

Merging main brought in scripts/prompt-seam-check.sh (#37), whose check-1
regex extracts /cdd-state from file paths like tools/cdd-state.sh — the
same false positive /cdd-worktree is whitelisted for. Add /cdd-state to
the whitelist, and list cdd-state.sh in CLAUDE.md's bash -n line and
tools/ row.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread doc/knowledge_base/roadmap.md Outdated
drabaioli and others added 2 commits June 30, 2026 19:20
Trim the completed state-record item to a summary plus a pointer to
process doc §2.13 (which holds the full design/schema, so no info is
lost), and tighten the PR-number-hook follow-up.

Addresses PR #38 review: #3500597168.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Capture the deferred cleanup surfaced in PR #38 review: commands point at
the large process doc ~14 times, loading it into context each run. Record
as a tracked efficiency task rather than expanding this PR.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@drabaioli drabaioli merged commit 5f3fd86 into main Jun 30, 2026
1 check passed
@drabaioli drabaioli deleted the task_state_tracking branch June 30, 2026 17:27
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