Skip to content

feat(sessions): index workflow runs and agents (layer 2 of session intelligence)#284

Merged
ScriptedAlchemy merged 12 commits into
masterfrom
feat/workflow-thread-indexing-v2
Jul 5, 2026
Merged

feat(sessions): index workflow runs and agents (layer 2 of session intelligence)#284
ScriptedAlchemy merged 12 commits into
masterfrom
feat/workflow-thread-indexing-v2

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Layer 2 of the session-intelligence work (builds on merged #281's git spans). Indexes Claude Code workflow runs and their agents into the per-project session store, attaching them to the parent thread and — via #281's git spans — to branches/worktrees/commits.

What you can now ask

  • "what workflow runs happened in this session/thread?"
  • "what workflows ran on branch X / worktree Y / commit Z?" (a run inherits its parent session's git spans)
  • "show run wf_… — its result, phases, and agent roster"
  • "what did agent `review:bugs` in run wf_… do?" (drill to the agent, then read its messages via message_search)

What's in it

  • Schema (src/sessions/workflow_index.rs): workflow_runs + workflow_agents, version-gated migration mirroring feat(sessions): git-anchored session/LCM correlation #281; idempotent upsert; runs_for_session/run_for_id/agents_for_run + the git-span join runs_for_git_scope
  • Ingest (src/sessions/workflow_ingest.rs): discovers subagents/workflows/<run_id>/ dirs during session ingest, parses run meta + result + per-agent transcripts, idempotent + incremental (mtime watermark), fail-open. Verified against real ~/.claude: 11 runs / 79 agents ingested for the authoring session
  • Query: tracedecay_workflows MCP tool (3 modes: thread / git-ref / run-drill) + workflow_run/workflow_agent filters on message_search; taught as rung 7 in managing-session-context
  • CLI: tracedecay sessions unfinished (ported from the codex/workflow-state-tool branch)

Verification

Cherry-picked clean onto current master (resolved one skill conflict: #280 consolidated recalling-session-context into managing-session-context, so the workflow rung moved there). clippy --all-targets clean; 29 workflow tests green; full CI matrix running.

Fittingly, this makes tonight's own 11-workflow / 79-agent sprawl natively queryable instead of hand-tracked. Design: fact 38. Recovery: session `2c51d204-3565-4a10-833d-d8fbd51620c3`, workflow `wf_d8320cfc-191`.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b92790f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

Rebased/amended: fixed the tool-count lockstep (master gained tracedecay_grep from merged #280, so base 99→100 → 101 with workflows) and shortened the commit subject under 72 chars. Full local nextest: 3848/3849 pass. The one local failure (multi_mcp_coordination_test::two_mcps_on_same_project_coordinate_via_sync_lock) is an environmental 30s-timeout of #280's already-merged startup-catch-up sync under this machine's heavy load — not touched by this PR (layer-2 changes no coordination/sync code); expecting it green on CI's clean runner.

@ScriptedAlchemy ScriptedAlchemy force-pushed the feat/workflow-thread-indexing-v2 branch from fd3e0e5 to e20d7a3 Compare July 4, 2026 18:26
@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

The 3 CI failures are git_watch timing flakes inherited from merged #280's auto-sync (fifty_commit_rebase_needs_one_sync et al.) — real-clock-fragile tests that pass 3/3 in isolation locally (0.6s each) but flake under CI's parallel load. Layer-2 touches no git_watch/coordination/sync code (verified). Re-ran the failed jobs.

Separately worth flagging: these git_watch timing flakes now live in master (via #280) and will intermittently redden any PR's CI — worth a dedicated determinism fix (inject a clock / assert behavior not wall-time), which the earlier test-robustness workflow diagnosed but couldn't land while git_watch was still unmerged. I can take that as a follow-up to #283.

ScriptedAlchemy and others added 9 commits July 5, 2026 03:19
Layer 2 of session intelligence (builds on #281's git spans). Indexes
Claude Code workflow runs + agents into the session store, attached to
the parent thread and to branches/worktrees/commits. Adds the
tracedecay_workflows tool (list by thread or git ref, show a run, drill
an agent), workflow_run/agent filters on message_search, and a
'sessions unfinished' CLI. Ingest is idempotent + incremental. Tool
count 100 -> 101. Verified against ~/.claude: 11 runs / 79 agents.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The set_mtime helper opened files read-only and called set_times, which
works on Unix but panics on Windows (adjusting a directory's timestamps
needs backup-semantics access). Switch to filetime::set_file_mtime
(already a transitive dep; added as an explicit dev-dependency).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
/simplify cleanup (behavior-preserving), converged on by 4 reviewers:
- delete WorkflowStatus::from_db (redundant with the infallible from_disk
  given the status column's CHECK constraint)
- reuse crate::sessions::claude::transcript_cwd instead of a byte-copy
- promote string_arg/argument_error/tool_json_with_md to handlers/support
  and share them between session.rs and workflow_query.rs
- one shared shared::one_line_truncated (single ellipsis convention)
  replacing three divergent copies
- ProjectRootMatcher resolves the fixed project side's git worktree/common
  dir once, so the ingest loop stops re-resolving it per run

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reuse git_scope_exists_clauses for workflow git-scope queries, avoid
per-status string allocations, HashSet dedup in roster assembly, and
colocate one_line_truncated tests with shared helpers.
@ScriptedAlchemy ScriptedAlchemy force-pushed the feat/workflow-thread-indexing-v2 branch from f87166f to c6990c0 Compare July 5, 2026 03:20
@ScriptedAlchemy ScriptedAlchemy merged commit 21a07ca into master Jul 5, 2026
16 checks passed
This was referenced Jul 5, 2026
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