Add parent/child thread delegation primitives#1779
Closed
ratulsarna wants to merge 5 commits intopingdotgg:mainfrom
Closed
Add parent/child thread delegation primitives#1779ratulsarna wants to merge 5 commits intopingdotgg:mainfrom
ratulsarna wants to merge 5 commits intopingdotgg:mainfrom
Conversation
Extend OrchestrationThread, ThreadCreateCommand, ThreadTurnStartBootstrapCreateThread, and ThreadCreatedPayload with a nullable parentThreadId field. Uses Schema.withDecodingDefault so historical events and snapshots that lack the field decode to null.
Validate parentThreadId on thread.create: parent must exist, be in the same project, not be deleted, and not be the child itself. Archived parents are allowed. Normalize parentThreadId via ?? null to handle internal callers that omit the field. Propagate parentThreadId through the bootstrap create-and-start dispatch path in ws.ts.
Add migration 020 for parent_thread_id column on projection_threads. Update repository schema, SQL INSERT/UPDATE/SELECT queries, projection pipeline, in-memory projector, and snapshot query to carry parentThreadId end-to-end. Existing rows without the column default to null.
Add parentThreadId to Thread and SidebarThreadSummary interfaces. Map it through snapshot sync, event-driven thread.created handling, sidebar summary construction, and sidebar equality checks. Update all thread construction call sites and test fixtures to include the field.
Add parentThreadId: null to all server-side thread.create command builders, snapshot fixtures, and bootstrap createThread metadata in test files that were not covered by earlier task slices.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
Author
|
Sorry about this. |
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
parentThreadIdas first-class state on threads, enabling one thread to create and link to a child thread within the same projectparentThreadIdend-to-end: contracts → decider → projector → SQLite projection → snapshot query → web storeImplementation areas
packages/contracts):OrchestrationThread,ThreadCreateCommand, bootstrap metadata,ThreadCreatedPayloadwith decode defaultsapps/server): parent validation withrequireThreadNotDeletedhelper,?? nullnormalization for internal callersapps/server): migration 020, repository/service schema, pipeline, projector, snapshot queryapps/web):ThreadandSidebarThreadSummarytypes, snapshot sync, event handler, sidebar equality checkapps/server):ws.tsdispatch propagatesparentThreadIdfrom bootstrap metadataValidation
bun fmt: passbun lint: passbun typecheck: pass (7/7 packages)bun run test: pass (61 files, 659 tests)Design decisions
parentThreadIdlives on the child thread only — nochildThreadIdsmirror, no relationship tableimplementationThreadId/sourceProposedPlan(coexist for now)Note
Add parent/child thread delegation primitives across contracts, store, and persistence
parentThreadId: ThreadId | nullto theThread,SidebarThreadSummary,OrchestrationThread,ThreadCreateCommand, andThreadCreatedPayloadtypes/schemas in orchestration.ts and types.ts, defaulting tonullfor historical records.parent_thread_idcolumn toprojection_threads, and updates the repository upsert/select queries accordingly.thread.createdecider: rejects self-parenting, missing/deleted parents, and cross-project parents; addsrequireThreadNotDeletedto commandInvariants.ts.parentThreadIdthrough the full stack: projector, snapshot query, projection pipeline, client store mapping, sidebar summaries, and thread creation bootstrap in the WebSocket layer.sidebarThreadSummariesEqualnow includesparentThreadIdin its equality check, so sidebar updates will trigger wheneverparentThreadIdchanges.Macroscope summarized add129b.