Populate execution-graph records from OpenCode parser (#93)#119
Merged
willwashburn merged 2 commits intomainfrom Apr 26, 2026
Merged
Populate execution-graph records from OpenCode parser (#93)#119willwashburn merged 2 commits intomainfrom
willwashburn merged 2 commits intomainfrom
Conversation
Closes the OpenCode arm of the gap that #77 closed for Claude. `parseOpencodeSession` / `parseOpencodeSessionIncremental` now return `relationships: SessionRelationshipRecord[]` and `toolResultEvents: ToolResultEventRecord[]` alongside the existing arrays. - One `root` row per session; one `subagent` row when the session payload carries `parentID`, with `relatedSessionId` pointing at the parent. - One `ToolResultEventRecord` per tool part with a resolved `state.output`, status derived from `state.status === 'error'` (errored) or `metadata.exit !== 0` (errored, bash-family); `isError` set when either condition is true; `contentLength` / `contentHash` computed from the stringified output (no raw bytes stored). - Per-`toolUseId` `callIndex` and per-pass monotonic `eventIndex` mirror the Claude convention. - `Subagent.isSidechain` continues to populate from `parentID` unchanged. - Resumed incremental passes don't re-emit events for already-seen assistant messages; relationship rows re-emit on every pass and the ledger writer dedups them by hash. - Wired through `packages/cli/src/ingest.ts` (OpenCode path) into `appendRelationships` / `appendToolResultEvents`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…on-graph-93 # Conflicts: # packages/cli/CHANGELOG.md # packages/cli/src/ingest.ts # packages/reader/CHANGELOG.md # packages/reader/src/opencode.ts
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
parseOpencodeSession/parseOpencodeSessionIncrementalnow returnrelationships: SessionRelationshipRecord[]andtoolResultEvents: ToolResultEventRecord[]alongside the existingturns/content/userTurnsarrays. Mirrors what Execution graph substrate: SessionRelationshipRecord + ToolResultEventRecord (#42) #77 did for Claude.rootrow per session, plus asubagentrow when the session payload carriesparentID(withrelatedSessionIdpointing at the parent session id). OpenCode session payloads don't expose a stable spawningcallID/subagent_type/descriptionon the child today, so the subagent row only carries what the source actually surfaces.ToolResultEventRecordper tool part with a resolvedstate.output. Status follows the same failure rules as the existingerroredCallIdsset —state.status === 'error'ORmetadata.exit !== 0(bash-family) →errored+isError: true.contentLength/contentHashare computed from the stringified output; raw bytes are never stored. Per-toolUseIdcallIndexand per-pass monotoniceventIndexmirror the Claude convention.seenMessageIdsmechanism gates the loop); relationship rows re-emit each pass and the ledger writer's hash-based dedup is the source of truth.packages/cli/src/ingest.ts(OpenCode path) wires the new arrays intoappendRelationships/appendToolResultEvents, matching the Claude path.Subagent.isSidechaincontinues to populate fromparentIDunchanged; existingTurnRecord/ContentRecordoutputs are unchanged.Test plan
pnpm run build— cleanpnpm run test:ts— 458 tests passing (+6 new)packages/reader/src/opencode.test.ts:rootrow for a non-subagent sessionsubagentrow whoserelatedSessionIdmatchesparentIDstate.status: 'error'→status: 'errored'+isError: truemetadata.exit !== 0(bash) →status: 'errored'even whenstate.status === 'completed'contentLength/contentHashpopulated for both string and structured outputsRefs
Closes #93. Refs #42, #77.
Out of scope (per issue): harness-event-stream subscription (#63), workflow / agent-tag attribution (#63), consumer CLI surfaces, fork / continuation rows, OpenCode fidelity (#89).
Generated with Claude Code