✨ feat(derive): project transcript-only sessions - #332
Merged
Conversation
Normalize the selected causal transcript history into canonical turn chains when a session has no captured main-conversation wire calls. Feed those calls through the shared deriver seam so deduplication, tools, attachments, and spans preserve wire semantics while retaining transcript provenance. Materialize historical session identity and enqueue projection in the same transaction as the immutable transcript row. Imported sessions can then become browsable asynchronously without claiming projection has already completed.
Contributor
|
| Filename | Overview |
|---|---|
| pkg/derive/transcript_projection.go | Adds transcript branch selection, normalization, fragment coalescing, stable identities, and mixed-source fallback preparation without an accepted defect. |
| pkg/derive/deriver.go | Introduces a shared wire/transcript chain fold and session-scoped authoritative-wire probing while preserving existing derivation behavior. |
| pkg/derive/spans.go | Extends trace and span projection with transcript identities, provenance, timing, and prompt fallback handling. |
| pkg/storage/postgres/derive.go | Selects current transcript versions, probes wire authority, merges calls chronologically, and relies on existing transactional pruning. |
| pkg/storage/postgres/raw_turns.go | Materializes transcript session identity and timestamps in the same transaction as raw persistence and queue marking. |
| pkg/storage/postgres/queries/sessions.sql | Adds an idempotent transcript-session upsert that widens observed time bounds and preserves existing optional metadata. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
U[Transcript upload] --> T[Atomic raw row and session upsert]
T --> Q[Dirty derive queue]
Q --> P{Parsed main wire call exists?}
P -- No --> F[Select active transcript branches]
F --> N[Normalize transcript TurnChains]
P -- Yes --> W[Use authoritative wire conversation]
N --> M[Chronologically merge shadow and compaction wire calls]
W --> D[Shared derivation fold]
M --> D
D --> R[Transactional trace and span projection]
R --> X[Prune obsolete transcript projection]
Reviews (1): Last reviewed commit: "✨ feat(derive): project transcript-only ..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
How it works
Transcript records are normalized into canonical full-history
TurnChains and merged chronologically with any shadow or compaction wire calls. Both sources enter the sharedDeriver.addChainTurnfold, so node deduplication, tool attachment, reporting, and span construction follow the same path.The raw transcript row, historical session identity, and derive queue entry are committed atomically. Projection remains asynchronous and reports its provenance at trace level.
Relationship to #330
This supersedes draft #330 while retaining its central architectural approach: canonical
TurnChainconstruction and a sharedaddChainTurnderivation seam. It extends that design with active-branch resolution, fragment coalescing, stable identities, mixed shadow-call ordering, late-wire replacement, atomic session materialization, and broader corpus and PostgreSQL coverage.Behavior matrix
Test plan
GOEXPERIMENT=jsonv2git diff --checkPart of PCC-1278