Repository navigation
bt-daemon: import through the daemon and remove the delivery ledger - #291
Conversation
Every translator is now serializable, and AgentTranslator requires a new TranslatorState trait with a blanket implementation for serde types. A translator's saved state is everything it still needs from events it has consumed to translate later ones, so a later pipeline can persist it instead of replaying those events. Sink-only row fields that wire JSON omits are preserved through a shared SinkFields codec, which the stored SpanOp codec now also uses. serde_json round-trips floats exactly so restored state matches what was saved. OpenCode v2 message parts the translator does not model are kept as raw JSON rather than rejected. A test resumes every agent's native stream from saved state after each event and requires output identical to an uninterrupted run; the shared native streams now include an OpenCode v2 session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Transcript import is now a daemon client. It starts or upgrades the daemon as hook capture does, captures every synthesized event over one connection, and finishes each session with import.finish, which flushes or finalizes its routes and reports their root span and distinct span count. A rewritten transcript restarts translation with import.reset, a Reset control stored in the journal so replay resets the translator at the same point. Imports and hooks share one pipeline. With the daemon the only process that delivers, the delivery ledger and its cross-process locks, NDJSON log, checkpoint and origins index are gone. Translation already stamps stored origins; tags are deduplicated while routed rows are prepared. Legacy ledger directories are deleted. A legacy delivery checkpoint now advances its route's head past the output it covered and discards origins rebuilt for those spans, which the ledger previously did by remembering completed spans. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6483b236b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| env.route = Some(self.route.clone()); | ||
| env.config = None; | ||
| self.client.log(&env).await?; |
There was a problem hiding this comment.
Replay historical Codex output for a newly selected destination
When a Codex session has already been delivered through this daemon, importing it into another project or experiment now reuses the existing source translator. That translator retains its transcript offsets, so the imported lifecycle events do not regenerate the historical turn, model, or tool rows. Meanwhile, SpanJournal::prune deletes acknowledged operations and subscribe starts the new route at the publication floor; observe_history only restores correlation metadata, not sink output. Consequently, the import can report success while the new destination receives only late root updates instead of the session. Preserve or explicitly regenerate the historical output when importing into a new route.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 611c4da. Each import run now captures into its own daemon-side session and translates the native session from fresh state under the native session's identity. A new destination receives the whole session, and a repeated import reproduces the original span ids. Covered by importing_into_another_destination_delivers_the_whole_session and repeating_a_claude_import_reuses_its_span_ids in tests/replay.rs, which both fail without the change.
| Self::emit_translator_batches(live, ops).await?; | ||
| env.route = Some(self.route.clone()); | ||
| env.config = None; | ||
| self.client.log(&env).await?; |
There was a problem hiding this comment.
Make repeated Claude imports reuse their original span identities
Importing the same completed Claude transcript twice while the daemon remains running now feeds every synthetic UserPromptSubmit into the same existing translator. ClaudeTranslator::open_turn increments turn_count unconditionally, and ensure_root increments root_generation after the earlier SessionEnd, so the second import creates a new trace and new turn IDs for the same historical work rather than updating the original spans. Previously, each import started with a fresh translator and therefore reproduced the original deterministic IDs. Add replay-aware identity handling so repeated imports, including imports after live capture, do not duplicate historical turns and traces.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 611c4da. Each import run now captures into its own daemon-side session and translates the native session from fresh state under the native session's identity. A new destination receives the whole session, and a repeated import reproduces the original span ids. Covered by importing_into_another_destination_delivers_the_whole_session and repeating_a_claude_import_reuses_its_span_ids in tests/replay.rs, which both fail without the change.
This branch already contained its own translator-state and import changes, so conflicts take this branch's side. Keeps #289's save-and-restore test for every agent alongside this branch's recovery tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match the crate's convention: derives name Serialize and Deserialize through a use serde import rather than serde:: paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sign/import-through-daemon # Conflicts: # bt-daemon/src/transcript_import/pipeline.rs
Imports shared the live session's translator, so importing a session into a new destination delivered almost none of its history, and repeating a Claude import opened new turns and a new trace for the same work. Each import run now captures into its own daemon-side session (the native id with a per-run suffix) with its own journal, storage and delivery, while translation, span metadata, sinks and span plugins use the native session id. A run therefore reproduces the native session's deterministic ids and delivers every span to its destination. Repeating an import re-delivers its rows under the same ids; an older import may replace newer content on spans it shares with what a destination already holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each import run's translator uses the native session's namespace here too, while its events and ops live in the run's own session storage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-daemon # Conflicts: # bt-daemon/src/transcript_import/pipeline.rs
Second PR in the stack that splits #276. Its base was #289, which has since merged into
main.Why
On
main,bt trace importtranslates and delivers in its own process, while the daemon delivers live sessions. The two coordinate through the destination-scoped delivery ledger. That ledger has its own NDJSON log, a JSON checkpoint, a SQLite origins index outside session storage, and OS file locks shared between processes. Once the daemon is the only process that delivers, none of that is needed.Changes
event.logover a single connection.import.finishwaits for the session's routes to deliver and reports their root span and distinct span count. Withfinalize: false, it only flushes, which is what--attachdoes when it detaches.import.resetrestarts translation from fresh state when the transcript was rewritten. It's stored as aResetcontrol in the journal, so replay resets the translator at the same point.delivery_ledgermodule, its origins index and its use in the consumer are gone.unique_tags).delivery-ledgerdirectories.delivery_checkpoint. Translation now advances that route's head past the output the checkpoint covered, and discards the origins rebuilt for those spans.main, the ledger prevented that by remembering each destination's completed spans.Tests
replay.rs,cursor_pipeline.rs,distributed_tracing.rs,muse_attach.rsandroot_provenance.rsnow run against a daemon (tests/support/import_daemon.rs). Their ledger-state assertions are removed.legacy_acknowledged_spans_receive_late_updates_without_inventing_originscovers the legacy checkpoint fix.importing_into_another_destination_delivers_the_whole_sessionandrepeating_a_claude_import_reuses_its_span_idscover the two review findings. Both fail without isolated runs. Four Muse import tests frommainnow check identity (same span ids, one trace) rather than "nothing re-sent".cargo fmt --checkpasses.🤖 Generated with Claude Code