Skip to content

refactor(import): register transcript import per agent - #140

Merged
Stephen Belanger (Qard) merged 2 commits into
mainfrom
refactor/register-import
Oct 6, 2026
Merged

Stephen Belanger (Qard) merged 2 commits into
mainfrom
refactor/register-import

Conversation

@Qard

@Qard Stephen Belanger (Qard) commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Based on main now that #139 has merged. This is the last PR of the registration series.

Transcript import matched on ImportSource in seven places: roots, session id, filename match, envelope construction, tail state construction (twice), and polling. The generic TranscriptTail also had about 60 lines of Cursor-only snapshot and rewrite handling inline.

Each importable agent now implements a capability trait and supplies its own tail:

pub(crate) trait TranscriptImport: Agent {
    fn discover(&self, home: &Path) -> anyhow::Result<Vec<PathBuf>>;
    fn find(&self, home: &Path, session_id: &str) -> anyhow::Result<PathBuf>;
    fn tail(&self) -> Box<dyn TailSession>;
}

pub(crate) trait TailSession: Send {
    fn envelopes(&mut self, path: &Path, records: &IncrementalRecords) -> anyhow::Result<Vec<Envelope>>;
    fn poll(&mut self, events: Vec<Envelope>, len: u64, finalize: bool) -> anyhow::Result<Vec<Envelope>>;
    fn keeps_translator_on_rewrite(&self) -> bool { false }
    fn rewritten(&mut self, previous: &[Value], current: &[Value]) {}
    fn tolerates_incomplete_final_record(&self) -> bool { false }
}
  • Registration. The Codex, Claude Code, Cursor and Antigravity agents register TranscriptImport.
  • Agent tails. Each agent's existing Tail struct implements TailSession.
  • Cursor tail. Cursor's tail owns the private transcript snapshot. It reports that it keeps its translator when the transcript is rewritten and that it tolerates an incomplete final record. Its rewritten hook computes which records survived a rewrite.
  • Generic tailer. TranscriptTail holds a Box<dyn TailSession> and no longer mentions any agent.

Discovery is internal to each agent. Callers only need discover, find and tail, so each agent's search roots and filename rules are private to its module. The shared directory walk, session grouping and error messages live in a small TranscriptLayout (roots, a session-id rule and a filename rule) that each agent builds privately. Tests exercise each agent's layout with temporary roots, so they stay independent of the CODEX_HOME and CLAUDE_CONFIG_DIR overrides.

Behaviour

None. Search paths, matching and error messages are unchanged. Cursor's snapshot is still recreated after a rewrite and receives only the records that changed. Other agents still get a fresh translator after a rewrite.

Testing

  • cargo clippy --all-features --all-targets -D warnings is clean.
  • cargo test --all-features --no-fail-fast: everything passes, including the Cursor attach/rewrite import tests, except trace_runtime::tests::doctor_reports_a_daemon_that_{cannot_authenticate_the_route,resolves_other_credentials}. Those fail the same way on main in my local environment.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T12:49:52.469541Z fa4201a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Qard
Stephen Belanger (Qard) force-pushed the refactor/register-translators branch from 4a46d82 to 6184632 Compare October 6, 2026 14:04
@Qard
Stephen Belanger (Qard) force-pushed the refactor/register-translators branch from 6184632 to 86eb942 Compare October 6, 2026 14:48
@Qard
Stephen Belanger (Qard) force-pushed the refactor/register-translators branch from 86eb942 to b6fe0b1 Compare October 6, 2026 15:03
@Qard
Stephen Belanger (Qard) force-pushed the refactor/register-translators branch from b6fe0b1 to ed5dc88 Compare October 6, 2026 16:59
@Qard
Stephen Belanger (Qard) force-pushed the refactor/register-import branch 3 times, most recently from c4c4589 to beb70d1 Compare October 6, 2026 17:20
Base automatically changed from refactor/register-translators to main October 6, 2026 17:23
Transcript import dispatched on ImportSource in seven places, and the
generic TranscriptTail carried Cursor's snapshot and rewrite handling
inline. Each importable agent now implements `TranscriptImport` (roots,
session ids, filename matching) and supplies a `TailSession` that turns
records into synthetic hook events. The Codex, Claude Code, Cursor and
Antigravity agents register it.

Cursor's tail owns its private transcript snapshot and declares that it
keeps its translator across rewrites and tolerates an incomplete final
record, so TranscriptTail no longer special-cases any agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TranscriptImport exposed each agent's search roots and filename rules
because the shared discovery code in transcript_import walked the
directories itself and called back into the agent for policy. The trait
now offers only what callers need: `discover`, `find` and `tail`.

The shared directory walk, session grouping and error messages move
into a small `TranscriptLayout` that each agent builds privately from
its roots and naming rules. Those rules are now private to the agent's
module. Tests exercise each agent's layout with temporary roots, which
keeps them independent of the CODEX_HOME and CLAUDE_CONFIG_DIR
overrides. Search paths, matching and error messages are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Qard
Stephen Belanger (Qard) merged commit d334494 into main Oct 6, 2026
20 checks passed
@Qard
Stephen Belanger (Qard) deleted the refactor/register-import branch October 6, 2026 18:14
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.

2 participants