You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f8ddc75
Browse filesBrowse the repository at this point in the historyBrowse files
feat(session): add depth/rootID as additive wire fields (nested-agents Issue 3)
Surface the session nesting level (depth) and tree root (rootID) as
convenience fields on the wire instead of forcing every client to walk
the parentID chain. Both are derived, never client-settable, and purely
additive — old clients that ignore them keep working.
Core/DB:
- Add `depth` (integer, default 1, not null) and `root_id` (text, nullable)
columns plus a `session_root_idx` to the session table.
- New migration `20260613064154_session_depth_rootid` with a one-shot
recursive-CTE backfill over the parent_id chains (root = depth 1,
root_id = topmost ancestor; orphans treated as roots; legacy deep
chains stamped, never truncated). Backfill UPDATE is idempotent.
- Map the fields through the projector, `SessionV1.SessionInfo` event
payload, `SessionSchema.Info` and `info.fromRow`.
Server/wire:
- `createNext` stamps depth/rootID from the lineage walk it already does
for the hard-cap check (root: depth 1, no rootID; child: parent chain
length + 1, rootID = root.rootID ?? root.id). fromRow/toRow round-trip
them and the Session.Info schema exposes them.
- `GET /session/:id/children?recursive=true` returns the whole descendant
subtree (via Session.descendants); the default stays direct-children only.
SDK:
- Regenerated the v2 SDK (depth/rootID on Session, recursive query param).
- Patched the v1 (`src/gen`) SDK additively by hand (it is produced by a
separate stainless pipeline not runnable in this worktree).
Tests:
- Migration backfill over a 3-level tree + orphan, with idempotency.
- createNext depth/rootID stamping (root, 3-level tree, orphaned parent).
- HTTP children recursive vs direct + depth/rootID on the wire.
- Updated existing wire-shape fixtures for the now-required depth field.
Co-Authored-By: Claude Fable 5 <[email protected]>
0 commit comments