feat(coding-agent): persist parent edges and derived depth for all sessions - #584
Merged
Merged
Conversation
This was referenced Aug 2, 2026
snimu
added a commit
that referenced
this pull request
Aug 3, 2026
… parsing, and legacy fallbacks - Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584). - Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584). - Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584). - Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584). - Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584). - Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).
snimu
force-pushed
the
feat/agent-tree-groundwork
branch
from
August 3, 2026 12:05
865918d to
405c88a
Compare
snimu
added a commit
that referenced
this pull request
Aug 3, 2026
… parsing, and legacy fallbacks - Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584). - Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584). - Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584). - Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584). - Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584). - Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).
snimu
added a commit
that referenced
this pull request
Aug 3, 2026
…ots, and depth ingestion - preserve daemon routable IDs for passive children (origin: PR #583) - recheck guarded passive hydration and heartbeat restores (origin: PR #583) - repair wrong-kind pending hydration joins (origin: PR #583) - fence passive hydration during update restart preparation (origin: PR #583) - validate persisted RLM depth before constructor ingestion (origin: PR #584) - retry attach child snapshots across session replacement (origin: PR #587) - retain effective depth for legacy parented new sessions (origin: PR #589) - coordinate parent passivation with child hydration publication (origin: PR #589)
snimu
added a commit
that referenced
this pull request
Aug 3, 2026
…on entries The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as config, which outranks the opened transcript header in AgentSession — so a nested legacy child whose header carried a deeper persisted depth woke at depth 1, weakening the host recursion gate. Registry depth stays authoritative when present; otherwise the validated header depth wins and 1 remains the last-resort default for fully legacy children. origin: PR #584 fallback restored in round-1 triage; surfaced by post-rebase bot review of PR #589.
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
… parsing, and legacy fallbacks - Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584). - Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584). - Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584). - Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584). - Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584). - Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…ots, and depth ingestion - preserve daemon routable IDs for passive children (origin: PR #583) - recheck guarded passive hydration and heartbeat restores (origin: PR #583) - repair wrong-kind pending hydration joins (origin: PR #583) - fence passive hydration during update restart preparation (origin: PR #583) - validate persisted RLM depth before constructor ingestion (origin: PR #584) - retry attach child snapshots across session replacement (origin: PR #587) - retain effective depth for legacy parented new sessions (origin: PR #589) - coordinate parent passivation with child hydration publication (origin: PR #589)
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…on entries The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as config, which outranks the opened transcript header in AgentSession — so a nested legacy child whose header carried a deeper persisted depth woke at depth 1, weakening the host recursion gate. Registry depth stays authoritative when present; otherwise the validated header depth wins and 1 remains the last-resort default for fully legacy children. origin: PR #584 fallback restored in round-1 triage; surfaced by post-rebase bot review of PR #589.
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
… parsing, and legacy fallbacks - Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584). - Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584). - Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584). - Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584). - Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584). - Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…ots, and depth ingestion - preserve daemon routable IDs for passive children (origin: PR #583) - recheck guarded passive hydration and heartbeat restores (origin: PR #583) - repair wrong-kind pending hydration joins (origin: PR #583) - fence passive hydration during update restart preparation (origin: PR #583) - validate persisted RLM depth before constructor ingestion (origin: PR #584) - retry attach child snapshots across session replacement (origin: PR #587) - retain effective depth for legacy parented new sessions (origin: PR #589) - coordinate parent passivation with child hydration publication (origin: PR #589)
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…on entries The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as config, which outranks the opened transcript header in AgentSession — so a nested legacy child whose header carried a deeper persisted depth woke at depth 1, weakening the host recursion gate. Registry depth stays authoritative when present; otherwise the validated header depth wins and 1 remains the last-resort default for fully legacy children. origin: PR #584 fallback restored in round-1 triage; surfaced by post-rebase bot review of PR #589.
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
… parsing, and legacy fallbacks - Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584). - Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584). - Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584). - Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584). - Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584). - Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…ots, and depth ingestion - preserve daemon routable IDs for passive children (origin: PR #583) - recheck guarded passive hydration and heartbeat restores (origin: PR #583) - repair wrong-kind pending hydration joins (origin: PR #583) - fence passive hydration during update restart preparation (origin: PR #583) - validate persisted RLM depth before constructor ingestion (origin: PR #584) - retry attach child snapshots across session replacement (origin: PR #587) - retain effective depth for legacy parented new sessions (origin: PR #589) - coordinate parent passivation with child hydration publication (origin: PR #589)
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…on entries The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as config, which outranks the opened transcript header in AgentSession — so a nested legacy child whose header carried a deeper persisted depth woke at depth 1, weakening the host recursion gate. Registry depth stays authoritative when present; otherwise the validated header depth wins and 1 remains the last-resort default for fully legacy children. origin: PR #584 fallback restored in round-1 triage; surfaced by post-rebase bot review of PR #589.
snimu
force-pushed
the
feat/agent-tree-groundwork
branch
from
August 4, 2026 07:49
405c88a to
dcae3e4
Compare
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
… parsing, and legacy fallbacks - Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584). - Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584). - Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584). - Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584). - Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584). - Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…ots, and depth ingestion - preserve daemon routable IDs for passive children (origin: PR #583) - recheck guarded passive hydration and heartbeat restores (origin: PR #583) - repair wrong-kind pending hydration joins (origin: PR #583) - fence passive hydration during update restart preparation (origin: PR #583) - validate persisted RLM depth before constructor ingestion (origin: PR #584) - retry attach child snapshots across session replacement (origin: PR #587) - retain effective depth for legacy parented new sessions (origin: PR #589) - coordinate parent passivation with child hydration publication (origin: PR #589)
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…on entries The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as config, which outranks the opened transcript header in AgentSession — so a nested legacy child whose header carried a deeper persisted depth woke at depth 1, weakening the host recursion gate. Registry depth stays authoritative when present; otherwise the validated header depth wins and 1 remains the last-resort default for fully legacy children. origin: PR #584 fallback restored in round-1 triage; surfaced by post-rebase bot review of PR #589.
snimu
force-pushed
the
feat/agent-tree-groundwork
branch
from
August 4, 2026 20:25
81a00da to
b4881a8
Compare
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
… parsing, and legacy fallbacks - Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584). - Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584). - Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584). - Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584). - Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584). - Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…ots, and depth ingestion - preserve daemon routable IDs for passive children (origin: PR #583) - recheck guarded passive hydration and heartbeat restores (origin: PR #583) - repair wrong-kind pending hydration joins (origin: PR #583) - fence passive hydration during update restart preparation (origin: PR #583) - validate persisted RLM depth before constructor ingestion (origin: PR #584) - retry attach child snapshots across session replacement (origin: PR #587) - retain effective depth for legacy parented new sessions (origin: PR #589) - coordinate parent passivation with child hydration publication (origin: PR #589)
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…on entries The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as config, which outranks the opened transcript header in AgentSession — so a nested legacy child whose header carried a deeper persisted depth woke at depth 1, weakening the host recursion gate. Registry depth stays authoritative when present; otherwise the validated header depth wins and 1 remains the last-resort default for fully legacy children. origin: PR #584 fallback restored in round-1 triage; surfaced by post-rebase bot review of PR #589.
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
… parsing, and legacy fallbacks - Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584). - Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584). - Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584). - Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584). - Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584). - Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…ots, and depth ingestion - preserve daemon routable IDs for passive children (origin: PR #583) - recheck guarded passive hydration and heartbeat restores (origin: PR #583) - repair wrong-kind pending hydration joins (origin: PR #583) - fence passive hydration during update restart preparation (origin: PR #583) - validate persisted RLM depth before constructor ingestion (origin: PR #584) - retry attach child snapshots across session replacement (origin: PR #587) - retain effective depth for legacy parented new sessions (origin: PR #589) - coordinate parent passivation with child hydration publication (origin: PR #589)
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…on entries The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as config, which outranks the opened transcript header in AgentSession — so a nested legacy child whose header carried a deeper persisted depth woke at depth 1, weakening the host recursion gate. Registry depth stays authoritative when present; otherwise the validated header depth wins and 1 remains the last-resort default for fully legacy children. origin: PR #584 fallback restored in round-1 triage; surfaced by post-rebase bot review of PR #589.
sethkarten
self-requested a review
August 4, 2026 21:40
sethkarten
approved these changes
Aug 4, 2026
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
… parsing, and legacy fallbacks - Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584). - Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584). - Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584). - Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584). - Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584). - Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…ots, and depth ingestion - preserve daemon routable IDs for passive children (origin: PR #583) - recheck guarded passive hydration and heartbeat restores (origin: PR #583) - repair wrong-kind pending hydration joins (origin: PR #583) - fence passive hydration during update restart preparation (origin: PR #583) - validate persisted RLM depth before constructor ingestion (origin: PR #584) - retry attach child snapshots across session replacement (origin: PR #587) - retain effective depth for legacy parented new sessions (origin: PR #589) - coordinate parent passivation with child hydration publication (origin: PR #589)
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…on entries The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as config, which outranks the opened transcript header in AgentSession — so a nested legacy child whose header carried a deeper persisted depth woke at depth 1, weakening the host recursion gate. Registry depth stays authoritative when present; otherwise the validated header depth wins and 1 remains the last-resort default for fully legacy children. origin: PR #584 fallback restored in round-1 triage; surfaced by post-rebase bot review of PR #589.
snimu
force-pushed
the
feat/agent-tree-groundwork
branch
from
August 4, 2026 22:42
6a1950b to
417eb4c
Compare
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
… parsing, and legacy fallbacks - Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584). - Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584). - Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584). - Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584). - Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584). - Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…ots, and depth ingestion - preserve daemon routable IDs for passive children (origin: PR #583) - recheck guarded passive hydration and heartbeat restores (origin: PR #583) - repair wrong-kind pending hydration joins (origin: PR #583) - fence passive hydration during update restart preparation (origin: PR #583) - validate persisted RLM depth before constructor ingestion (origin: PR #584) - retry attach child snapshots across session replacement (origin: PR #587) - retain effective depth for legacy parented new sessions (origin: PR #589) - coordinate parent passivation with child hydration publication (origin: PR #589)
snimu
added a commit
that referenced
this pull request
Aug 4, 2026
…on entries The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as config, which outranks the opened transcript header in AgentSession — so a nested legacy child whose header carried a deeper persisted depth woke at depth 1, weakening the host recursion gate. Registry depth stays authoritative when present; otherwise the validated header depth wins and 1 remains the last-resort default for fully legacy children. origin: PR #584 fallback restored in round-1 triage; surfaced by post-rebase bot review of PR #589.
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 08c8870. Configure here.
…ssions Groundwork for the recursive agent tree (Track A PR 2): every session - live, passive, or saved-only - carries its tree position without a runtime and without inference. - additive rlmDepth field in the session JSONL header (no format bump; old readers ignore it); surfaced through SessionInfo, the saved-session catalog, SessionSummary, and agent-connection types - spawn edges derive child depth = parent depth + 1 at creation; fork and branch COPY the source depth (reference edges, not structural parents): a forked root stays a root - RLM_DEPTH env seeds fresh parentless sessions; persisted header wins for resumed sessions; legacy children resolve depth via the subagent registry fallback, never chain walks at scan time - one shared saved-session-info serializer (deduped from daemon-mode/ daemon-supervisor); DAEMON_SCHEMA_REVISION 9 with regenerated id Track A PR 2 of the recursive-agent-harness plan.
- Infer legacy session depth from nested subagent artifact directories. - Persist inferred depth when opening sessions while keeping listings read-only. - Use resolved file metadata for passive rows and daemon subagent rehydration.
- Derive legacy child depth from its parent header before using anchored path inference. - Preserve authoritative registry depth for passive legacy subagents.
- Copy the recursively resolved source depth across legacy fork and branch reference edges. - Increment legacy spawn depth only for structural subagent artifact paths while retaining safe cycle and unreadable-parent fallbacks.
- Resolve relative parentSession paths from the current legacy session directory during RLM depth traversal. - Add regression coverage for relative-linked legacy sessions when the process cwd differs.
This was referenced Aug 6, 2026
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.

Every session now records two facts in its file on disk: who spawned it (its parent) and how deep it sits in the spawn tree (a root is depth 0, its children are depth 1, and so on).
Until now we could only guess at this from whatever happened to be in memory, which broke down for sessions that weren't loaded. Now it's stored once, at creation, and read back everywhere — session lists, the saved-session catalog, the UI.
Two rules that matter:
Old session files without these fields still work; we just don't know their depth and fall back to sensible defaults.
This is part 1–7 of a stack (each PR builds on the one before it):
/rlm-max-depthcommand to control how deep agents can nestTests: the full suite at the top of the stack fails only on tests that already fail on the base branch. Each branch in the stack also passes checks and its own tests independently.
Note
Persist parent edges and derived depth in session headers for all session types
rlmDepthto their headers: root sessions default to 0 (or theRLM_DEPTHenv var), child sessions increment from their parent's persisted depth.rlmDepthfrom their persisted header rather than the environment, so depth is stable across restarts.rlmDepthforward consistently.rlmDepth, and daemon protocol is bumped to schema revision 10.SavedSessionInfois consolidated into a new shared saved-session-info.ts module.RLM_DEPTHenv values now throw at root session creation instead of being silently ignored.Changes since #584 opened
SessionInfo.rlmDepthfrom optional to required and introducedresolveSessionRlmDepthutility function that computes depth from persisted header value, defaults to 0 for root sessions, or infers depth by counting nestedsub-*directory segments in the session file path [6a1950b]SessionManagerto compute and persistrlmDepthusingresolveSessionRlmDepth, includingscanSessionInfo,open, constructor existing-file handling,materializeSessionFile,createBranchedSession, andforkFrom[6a1950b]AgentDaemon.buildPassiveRlmSubagentRequestto rely solely onSessionInfo.rlmDepthand modifiedAgentDaemon.createRuntimeto inferrlmDepthusingresolveSessionRlmDepthwhen resuming from existing session files [6a1950b]agents-view-state.test.ts,daemon-session-list.test.ts, and theirmakeSessionInfofunctions to defaultrlmDepthto 0, and added comprehensive test coverage infile-operations.test.tsanddaemon-mode.test.tsvalidating depth inference from path structure [6a1950b]resolveSessionRlmDepthutility to derive child depth from parent session header when available and refined path-based depth inference [08c8870]AgentDaemon.buildSessionListWithPassiveRlmSubagentsmethod to prefer registry entry depth over session info depth [08c8870]resolveLegacySessionRlmDepthfunction incoding-agentto resolve parent session paths relative to each session file's directory [121ae3d]Macroscope summarized 842927d.
Note
Medium Risk
Changes session header semantics, fork/branch depth rules, and daemon wire schema; invalid
RLM_DEPTHnow throws at root session creation, and legacy depth inference could mis-rank edge-case trees.Overview
Persists RLM spawn depth (
rlmDepth) in session file headers and threads it through spawn, fork, branch, and resume so nesting limits no longer depend on in-memory state orRLM_DEPTHalone.New and child sessions write
parentSession+rlmDepthat creation (children get parent depth + 1; forks/branches copy the source depth).AgentSessionresolves depth from config → persisted header → env, and exposesrlmDepth.resolveSessionRlmDepthbackfills legacy files (parent chain,sub-*path segments, open-time rewrite) and makesSessionInfo.rlmDepthrequired for listings.Daemon / UI: saved-session and session-list DTOs include
rlmDepth(schema revision 10); passive subagent rows use registry depth when present; serialization moves tosaved-session-info.ts. Subagent runtime creation passes explicitrlmDepthintonewSession.Reviewed by Cursor Bugbot for commit 121ae3d. Bugbot is set up for automated code reviews on this repo. Configure here.