feat(tape): add explicit subagent tape lineage#1980
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThe change replaces subagent Tape merge/discard operations with frozen-head Tape links, adds authorized cross-Tape search and context retrieval, hardens fork merge persistence, and updates orchestration, routes, tools, tests, and architecture documentation. ChangesSubagent Tape lineage
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/shared/contracts/routes/sessions.routes.ts (1)
370-371: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
EntityIdSchemafor session IDs.For consistency with other session ID validations in this file (e.g.,
sessionId,parentSessionId,targetMessageId), prefer usingEntityIdSchemainstead of defining an inline string schema.♻️ Proposed fix to reuse the schema
- maxTotalBytes: z.number().int().min(0).max(65536).optional(), - sourceSessionId: z.string().trim().min(1).optional() + maxTotalBytes: z.number().int().min(0).max(65536).optional(), + sourceSessionId: EntityIdSchema.optional()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/shared/contracts/routes/sessions.routes.ts` around lines 370 - 371, Update the sourceSessionId field in the relevant route schema to reuse EntityIdSchema instead of the inline trimmed non-empty string validation, matching the existing sessionId, parentSessionId, and targetMessageId definitions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/presenter/agentRuntimePresenter/index.ts`:
- Around line 1588-1592: Update the condition before TapeService.search in the
presenter method to call ensureSessionTapeReady for both the default/current
scope and the current_and_linked scope. Preserve the existing behavior for other
scopes, then execute search with the provided sessionId, query, and options.
In `@src/main/presenter/agentRuntimePresenter/tapeService.ts`:
- Around line 475-487: The consistency check in
assertSubagentTapeLinkReceiptMatchesInput must compare every normalized
persisted field, not only session IDs and outcome. Include slotId, taskTitle,
resultSummary, and all other frozen metadata fields represented by
SubagentTapeLinkReceipt and SubagentTapeLinkInput; reject any mismatch while
preserving idempotent acceptance for identical data. Add mismatch tests covering
changed frozen metadata, including the corresponding retry paths.
In `@src/main/presenter/sqlitePresenter/tables/deepchatTapeEntries.ts`:
- Around line 965-974: Update the fallback query construction around
serializeDeepChatTapeReadSources and queryPattern to use the same tokenized
search predicate as projection search, rather than only matching the full
normalized query as one contiguous substring. Preserve the existing candidate
payload, metadata, and name fields and bind parameters for every generated token
clause. Add coverage comparing projected and raw fallback searches, including
multi-term queries such as “alpha beta,” to ensure equivalent results.
In `@test/main/presenter/sqlitePresenter/deepchatTapeEntriesTable.test.ts`:
- Around line 108-111: Update the assertion for rebuiltIncarnation in the
deepchat tape entries test to first verify it is defined or otherwise present,
then retain the existing assertion that it differs from firstIncarnation. Ensure
the test cannot pass when rebuilt metadata is omitted.
---
Nitpick comments:
In `@src/shared/contracts/routes/sessions.routes.ts`:
- Around line 370-371: Update the sourceSessionId field in the relevant route
schema to reuse EntityIdSchema instead of the inline trimmed non-empty string
validation, matching the existing sessionId, parentSessionId, and
targetMessageId definitions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 93b5fa7b-cc17-4dd2-907a-85dfc42bfc60
📒 Files selected for processing (44)
docs/FLOWS.mddocs/architecture/agent-system-layered-runtime/migration-and-validation.mddocs/architecture/agent-system-layered-runtime/modules/shared-data-and-io.mddocs/architecture/agent-system-layered-runtime/modules/tape-and-observability.mddocs/architecture/deepchat-tape-baseline/spec.mddocs/architecture/retire-agent-session-presenter/spec.mddocs/architecture/session-application-coordinators/spec.mddocs/architecture/session-management.mddocs/architecture/subagent-run-guardrails/spec.mddocs/architecture/subagent-tape-lineage/plan.mddocs/architecture/subagent-tape-lineage/spec.mddocs/architecture/subagent-tape-lineage/tasks.mdsrc/main/agent/manager/deepChatAgentBackend.tssrc/main/agent/manager/directAcpAgentBackend.tssrc/main/agent/manager/sessionHandles.tssrc/main/agent/shared/agentSharedData.tssrc/main/presenter/agentRuntimePresenter/index.tssrc/main/presenter/agentRuntimePresenter/tapeService.tssrc/main/presenter/index.tssrc/main/presenter/sessionApplication/agentAssignmentCoordinator.tssrc/main/presenter/sessionApplication/ports.tssrc/main/presenter/sqlitePresenter/tables/deepchatTapeEntries.tssrc/main/presenter/sqlitePresenter/tables/deepchatTapeSearchProjection.tssrc/main/presenter/sqlitePresenter/tables/newSessions.tssrc/main/presenter/toolPresenter/agentTools/agentTapeTools.tssrc/main/presenter/toolPresenter/agentTools/subagentOrchestratorTool.tssrc/main/presenter/toolPresenter/index.tssrc/main/presenter/toolPresenter/runtimePorts.tssrc/shared/contracts/routes/sessions.routes.tssrc/shared/types/agent-interface.d.tstest/main/agent/manager/agentManager.test.tstest/main/agent/manager/deepChatAgentBackend.test.tstest/main/agent/manager/directAcpAgentBackend.test.tstest/main/presenter/agentRuntimePresenter/agentRuntimePresenter.test.tstest/main/presenter/agentRuntimePresenter/tapeService.test.tstest/main/presenter/sessionApplication/agentAssignmentCoordinator.test.tstest/main/presenter/sessionApplication/projectionCoordinator.test.tstest/main/presenter/sessionApplication/sessionApplication.integration.test.tstest/main/presenter/sqlitePresenter/deepchatTapeEntriesTable.test.tstest/main/presenter/sqlitePresenter/newSessionsTable.test.tstest/main/presenter/toolPresenter/agentTools/agentTapeTools.test.tstest/main/presenter/toolPresenter/agentTools/subagentOrchestratorTool.test.tstest/main/presenter/toolPresenter/toolPresenter.test.tstest/main/routes/dispatcher.test.ts
Summary
Changes
mergeSubagentTape/discardSubagentTapeflows with typedlinkSubagentTape.subagent/tape_linkedevents for completed, errored, and cancelled tasks.current,linked_subagents, andcurrent_and_linkedTape view scopes.sessionIdto search results andsourceSessionIdto context expansion.fork/mergerecords as compatible read-only links; legacyfork/discardremains audit-only.Summary by CodeRabbit
scope(current, linked, both) and includessessionIdin results.sourceSessionIdfor linked recall.