Skip to content

feat(sessions): git-anchored session/LCM correlation - #281

Merged
ScriptedAlchemy merged 3 commits into
masterfrom
feat/session-git-correlation
Jul 4, 2026
Merged

feat(sessions): git-anchored session/LCM correlation#281
ScriptedAlchemy merged 3 commits into
masterfrom
feat/session-git-correlation

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Jul 4, 2026

Copy link
Copy Markdown
Owner

First-class correlation between sessions/LCM messages and git artifacts: query all sessions/messages for a branch, worktree, or commit ("the conversations that produced this commit").

What's in it

  • Schema: span-based attribution tables (session_git_spans, commit_sessions) in the per-project session store, version-gated migration
  • Live attribution: hook-route metadata records spans per session (mid-session branch/worktree switches produce distinct spans); linked worktrees resolve via git-common-dir identity — a real defect the build's review caught: sibling-path worktrees previously dropped spans silently
  • Commit attribution: on ingest, commits landing inside a session's active span on that branch/worktree get commit_sessions rows
  • Backfill: tracedecay sessions git-backfill — reflog-segmented historical attribution from existing hook analytics + session timestamps; idempotent; interior branch segments seeded correctly (second review-caught defect)
  • Query surface: new tracedecay_sessions_for MCP tool (git_ref: branch|worktree|commit) + branch/worktree/commit filter pushdown on tracedecay_message_search and tracedecay_lcm_grep

Status: assembled onto current master, ready for review pending CI

Gates: git_correlation 21/21 · backfill 3/3 · full mcp_suite 313/313 · clean squash (zero conflicts). Built by the Fable-foundation → Opus-implement → review → fix pipeline (workflow wf_f46d3a1c-ccb); two review-caught product defects fixed pre-merge.

Follow-up (designed, separate PR): layer-2 workflow indexing

Workflows attach to parent threads, agents attach to workflows, joined to these git spans (tracedecay_workflows tool); absorbs codex/workflow-state-tool. Fact 38.

Recovery context

Session 2c51d204-3565-4a10-833d-d8fbd51620c3 · workflow wf_f46d3a1c-ccb · facts 20/30/38/39 (tracedecay tool fact_store --action get --fact-id 39 = full manifest)

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e9b5043

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 added a commit that referenced this pull request Jul 4, 2026
Resume-packet renderer (48af578). Candidate input for the session-
intelligence work in PR #281. Next: review, rebase, own PR. Fact 35.

Recovery: orchestrating Claude session 2c51d204-3565-4a10-833d-d8fbd51620c3 (project /home/zack/projects/tracedecay); replay: tracedecay tool lcm_load_session --provider claude --session-id 2c51d204-3565-4a10-833d-d8fbd51620c3
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ScriptedAlchemy added a commit that referenced this pull request Jul 4, 2026
Unfinished-workflow-evidence CLI (7fcca35) becomes a subcommand of the
workflow/thread indexing feature. Design: fact 38; feature branch:
feat/session-git-correlation (PR #281).

Recovery: orchestrating Claude session 2c51d204-3565-4a10-833d-d8fbd51620c3 (project /home/zack/projects/tracedecay); replay: tracedecay tool lcm_load_session --provider claude --session-id 2c51d204-3565-4a10-833d-d8fbd51620c3
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ScriptedAlchemy added a commit that referenced this pull request Jul 4, 2026
Cross-session workflow guidance docs (2e8e85e). Overlaps the session-
intelligence feature (PR #281, facts 20/30/38); fold or land separately.

Recovery: orchestrating Claude session 2c51d204-3565-4a10-833d-d8fbd51620c3 (project /home/zack/projects/tracedecay); replay: tracedecay tool lcm_load_session --provider claude --session-id 2c51d204-3565-4a10-833d-d8fbd51620c3
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ScriptedAlchemy

ScriptedAlchemy commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

Full recovery manifest (all session + workflow ids)

Main orchestrating session: 2c51d204-3565-4a10-833d-d8fbd51620c3 (claude, /home/zack/projects/tracedecay) — tracedecay tool lcm_load_session --provider claude --session-id 2c51d204-3565-4a10-833d-d8fbd51620c3

Workflow runs (transcripts: session dir → subagents/workflows/<run_id>/):

Run Purpose Status
wf_785c5851-aee plugin-suite wave 1 (grep, telemetry, Claude surfaces, steering) completed; E/F/H died on session limit
wf_7f23bed7-803 triple-plugin completion (all 8 tasks + review + verify) wave 1 cached; resumed
wf_bcfa3aa1-ac9 / wf_2ede3e1d-75a / wf_d002080a-6e2 auto-sync D1–D7 (attempts 1/2/3) 3rd attempt active
wf_d0bf6fa4-48f 36-scenario eval corpus (sonnet+codex) done → fact 28
wf_d0ae2099-bfe obscure-tool evals + missed-opportunity hunt done → fact 33
wf_f46d3a1c-ccb session-git-correlation build (this feature) active

Research agents (task transcripts in the session's tasks/ dir): a24542ee4f08eee98 markdown audit→fact 24 · a143ce24edd3525f7 adoption research→fact 21 · a07f2677c93ebc313 rstest diagnosis→fact 23 · af4d3dac14e17f59c eval baseline+opus rerun→fact 25 · a3cfc66f0ca02f263 freshness design→fact 22 · ab49d9ae2d3a5f72d skill-pattern study (children af2210c6ae0c73588, af50cc51138da9bb2)→fact 29 · a546e5bb4d17b8ac6 hermetic harness

Durable decisions: facts 17–39 in this project's fact store (tracedecay tool fact_store --action search --query 'recovery manifest' → fact 39 has this table).

Query sessions and messages by branch, worktree, or commit: span-based
attribution tables (session_git_spans, commit_sessions) in the per-
project session store; live span recording from hook-route metadata
(incl. linked-worktree resolution via git-common-dir identity); commit
attribution on ingest; historical backfill CLI (sessions git-backfill,
reflog-segmented, idempotent); tracedecay_sessions_for MCP tool plus
branch/worktree/commit filters on message_search and lcm_grep.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ScriptedAlchemy
ScriptedAlchemy force-pushed the feat/session-git-correlation branch from 564af78 to 4888ad5 Compare July 4, 2026 16:02
@ScriptedAlchemy
ScriptedAlchemy marked this pull request as ready for review July 4, 2026 16:02
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@ScriptedAlchemy ScriptedAlchemy changed the title feat(sessions): git-anchored session/LCM correlation — query sessions by branch, worktree, or commit (WIP) feat(sessions): git-anchored session/LCM correlation Jul 4, 2026
@ScriptedAlchemy
ScriptedAlchemy merged commit 14d4d53 into master Jul 4, 2026
16 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the feat/session-git-correlation branch July 4, 2026 17:17
ScriptedAlchemy added a commit that referenced this pull request Jul 4, 2026
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>
ScriptedAlchemy added a commit that referenced this pull request Jul 5, 2026
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>
ScriptedAlchemy added a commit that referenced this pull request Jul 5, 2026
…telligence) (#284)

* feat(sessions): index workflow runs and their agents

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>

* test: set directory mtime cross-platform in workflow_ingest tests

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>

* chore: deslop workflow indexing comments

* refactor(workflow): dedup helpers and hoist loop-invariant resolution

/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>

* refactor: split workflow session tests

* refactor(sessions): simplify workflow indexing reuse and dedup

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.

* refactor(sessions): dedupe workflow args

* refactor(sessions): extract workflow scope EXISTS predicate

* fix(workflow): satisfy branch quality gates

* fix(test): normalize CI path assertions

* fix(test): normalize Windows command paths

* fix(test): normalize Cursor hook paths

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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