[v0.8 Core 3] reconstruct managed session catalog - #1333
Conversation
Reconstruct the unique net delta from PR #1261, excluding propagation merges.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b37fc98. Configure here.
Scope live family catalogs, anchor relative parent paths, and retain legacy rename compatibility without weakening authority-aware requests.
jonaowen
left a comment
There was a problem hiding this comment.
This cannot be an authority boundary yet.
- The catalog path is unusable on Windows: Node exposes neither
O_DIRECTORYnorO_NOFOLLOW; Python exposes neither constant and nodir_fdsupport. The helper necessarily fails, andpython3is not a reliable Windows launcher. Add a supported root-bound Windows implementation with real reparse/fd-handle tests. - Worker ACL construction still independently scans through
SessionManager.listAll/ passive registries / pathname reads that follow links and accept registry-controlled paths. Messaging/observe/roster authority must consume the same verified snapshot or an equivalent root-bound traversal; hostile external/../symlink/replacement/forged-sessionDir tests are required. - The walk has no aggregate work budget: up to 10,000 synchronous Python launches, each allowing 128 MiB and 5 s, can block the supervisor for hours. Bound aggregate bytes, reads/processes, and elapsed time (prefer one bounded traversal), with deterministic exhaustion tests.
- The peer-summary semantic change is not versioned. One legacy/malformed peer lacking depth/topology makes the entire catalog throw and disables unrelated valid local families, while schema 17 gates only saved rename. Capability/version the peer shape or quarantine unverifiable peers; test old/new worker-supervisor combinations.
- Direct parent/child reach does not uniquely resolve a path claim through the catalog. Two rows with different IDs but one canonical path can both become a path-only child's parent; merge logic rejects duplicate IDs, not duplicate paths. Reject duplicate canonical authority paths globally or require unique parent resolution, including Windows case variants.
The new test suite has no Windows path and protocol tests do not exercise mixed peers.
|
Opened #1370 against this branch. Running this PR's family walk against a real ~/.prime/agent profile surfaced two independent real-data blockers, both now fixed there with regression tests that fail on the current head:
#1370 also fixes the perf profile: header-only reads instead of whole-file base64 round-trips, and one looped openat helper per walk instead of one The PR description also sketches a supervisor-owned spawn-ledger alternative that would make this class of bug structurally impossible — worth a read before more validation is layered onto re-derived writer-owned files. |

Replacement scope
This PR reconstructs and supersedes the unique implementation delta reviewed in #1261 without rewriting that historical branch. The original PR remains the immutable discussion record: #1261
core02-host-request-dispatcherv080/core-split-c3-managed-catalogb37fc9895f105341355e680a81097e674bd159f877b188b92dc91365cb2bc41bdb46a50669d104a8) is the shared foundation. For reconstructed deltas it is a proven tree-compatible base, not an ancestry claim about the historical PR stack.Validation
tsgo --noEmit: passNo original PR was retargeted, closed, merged, or otherwise mutated.
Note
High Risk
Changes agent-to-agent authorization, session catalog trust boundaries, and fail-closed behavior across daemon/supervisor paths; mis-merged topology or stricter family walks could deny legitimate messaging or rename flows.
Overview
Replaces ad-hoc sibling listing with
listCatalogFamilySessions, which walks RLM registries from managedO_NOFOLLOWdirectory roots using descriptor-relative reads (Python openat helper), validates header/registry topology, and fails closed on symlinks, cycles, and hostile artifacts. Siblings and a new catalogfamilyRPC are derived from that graph;readSessionInfoFromBufferavoids reopening paths after authorized reads.Daemon worker and supervisor now build frozen
agentFamilyCatalogEntries/familyCatalogEntriesfrom persisted scans, artifact-resident passive children, and live workers, merging only compatible topology claims. Agent-origin messaging, observation, rosters, and cross-workersend_messageauthorize against that snapshot (including post-wake session-id checks); CLI sends stay deliverable but relationship labels are advisory when the catalog is ambiguous or unavailable.agent-messagestightens nuclear-family rules: siblings/parent edges require a catalog-resolved unique parent; contradictory id/path parent claims are rejected; name reservation gains a weaker direct-parent fallback that does not broaden reach.Daemon schema revision 17 adds optional
sessionDiron detachedrename_saved_sessionso inactive renames use the correct catalog authority root.Reviewed by Cursor Bugbot for commit 8b21a40. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Reconstruct managed session catalog with secure family traversal and sessionDir-scoped authorization
listCatalogFamilySessionsindaemon-catalog-process.ts, which enumerates the full session family graph using descriptor-relative, O_NOFOLLOW file reads via an embedded Python helper to mitigate path traversal and TOCTOU races.daemon-mode.tswithagentFamilyCatalogEntries, an immutable merged cross-source catalog snapshot used for all authorization decisions (observe, getAgent, sendMessage).sessionDir, propagated through the daemon supervisor and protocol commands.agent-messages.ts:sameAgentFamilyParentnow requires catalog-resolved unique parents; malformed remote peer topology is rejected early withAGENT_FAMILY_REACH_ERROR.rename_saved_sessionwith an optionalsessionDirfield; commands without it remain legacy-compatible.listSavedSessionSiblingsnow throws if the target session is not found in the authoritative family, and cross-worker delivery is denied if the woken target's identity does not match the pre-authorized snapshot.Macroscope summarized 8b21a40.