Investigate: what does iterative merging mean for compressed or branched sessions #1534

Closed
opened 2026-10-27 13:40:47 +00:00 by sam · 1 comment
Owner

INVESTIGATION - no implementation until the term is pinned down. The deleted source doc lists "iterative summary merging - multiple compression rounds" with no further detail, so the intent is unverified, and the maintainer (2026-09-22) likes the idea but cannot say whether it means branching/forking or something else.

Hypothesis to test first, with evidence: forking exists with no way back. /branch and /fork create child conversations (internal/gateway/gateway.go:408) and there is NO /merge command in internal/domain/messaging/commands.go or internal/channels/telegram/commands.go. So the term may mean folding a branch outcome back into its parent, or folding successive compression summaries into each other.

Establish which reading is right, then either split out a concrete bead or close this as ill-defined. Do not build anything under this title.


Imported from beads archie-core-qjbk · GitHub #1176 · type task · priority P3 · created 2026-09-21

INVESTIGATION - no implementation until the term is pinned down. The deleted source doc lists "iterative summary merging - multiple compression rounds" with no further detail, so the intent is unverified, and the maintainer (2026-09-22) likes the idea but cannot say whether it means branching/forking or something else. Hypothesis to test first, with evidence: forking exists with no way back. /branch and /fork create child conversations (internal/gateway/gateway.go:408) and there is NO /merge command in internal/domain/messaging/commands.go or internal/channels/telegram/commands.go. So the term may mean folding a branch outcome back into its parent, or folding successive compression summaries into each other. Establish which reading is right, then either split out a concrete bead or close this as ill-defined. Do not build anything under this title. --- _Imported from beads `archie-core-qjbk` · GitHub #1176 · type task · priority P3 · created 2026-09-21_
sam added the lowtask labels 2026-10-27 13:40:47 +00:00
sam self-assigned this 2026-10-27 13:40:47 +00:00
Author
Owner

Triaged: no code change is needed for this. No code change is justified under this title: the issue's own hypothesis is refuted by the code, and the remaining ambiguity is a decision only the maintainer can make, not something an implementation (or a test) can settle.

What I verified in the tree:

  1. Branching is reversible, so "forking exists with no way back" is false. /branch and /fork dispatch at internal/gateway/gateway.go:412-413 to handleBranch (internal/gateway/session_commands.go:487-561), which saves a new session with ParentSessionID = parent and copies the parent's last 200 messages into it (SaveMessages on the child). The parent's rows are never touched — no ReplaceMessages, no move. handleBranch only calls setActive to the child, and /sessions (gateway.go:905-918) lists every session while /resume (gateway.go:1013-1038) sets the active pointer back. So nothing is stranded and there is no lost work to "fold back". The only missing piece is a /merge command, which is confirmed absent from localCommands in internal/domain/messaging/commands.go — but absence of a feature is not a defect.

  2. The issue's file references are stale. gateway.go's branch case is at 412-413, not 408 (408 is the tail of /undo), and internal/channels/telegram/commands.go does not exist — internal/channels contains only channel.go and status/status.go.

  3. Compression is the only thing in the repository called a summary, and it has no semantic content to merge. /compress and /compact route to applyCompress → compressSessionHistory (session_commands.go:719-782), which calls CompressHistory (internal/gateway/compression.go). summariseTruncated (compression.go:213-247) emits the marker "[Earlier conversation has been summarised to stay within context limits.]" plus removed-message and token counts with the first/last 80 characters — statistics, not a summary of meaning; the code comment says LLM summarisation is "deferred to the memory provider". A repeat compression therefore cannot "merge" summaries: the stored summary is an ordinary assistant message (compressedHistory, session_commands.go:655-683) sitting at index ProtectFirst, so on the next round it falls inside the truncated span and is consumed as one more assistant turn. internal/domain/memory has no merge/consolidate/summarise path either. Nothing here is a documented-contract violation, so there is no wrong behaviour for a test to reproduce first.

  4. There is no settled design to extend. docs/prds holds only self-development-loop.md and external-agent-harness.md; neither mentions sessions, branching or compression, and the phrase "iterative summary merging" appears nowhere in the tree (consistent with the source doc having been deleted).

Conclusion: the branch-merge reading is refuted and the compression reading has nothing to operate on today, so no concrete bead can be cut from the evidence, and the issue explicitly forbids building under this title. The honest disposition is the second one the issue allows — close as ill-defined.

Open question for you, with my recommendation: do you want this closed as ill-defined (my recommendation, since the premise that justified it does not hold), or kept as a separate feature bead for a /merge that folds a branch's messages back into its parent? In the second case the deliverable would be a feasibility doc, because /merge has no design and choosing its semantics (append vs summarise, conflict handling, who owns the parent history) is your call and not something to guess at in code.

Triaged: no code change is needed for this. No code change is justified under this title: the issue's own hypothesis is refuted by the code, and the remaining ambiguity is a decision only the maintainer can make, not something an implementation (or a test) can settle. What I verified in the tree: 1. Branching is reversible, so "forking exists with no way back" is false. /branch and /fork dispatch at internal/gateway/gateway.go:412-413 to handleBranch (internal/gateway/session_commands.go:487-561), which saves a new session with ParentSessionID = parent and copies the parent's last 200 messages into it (SaveMessages on the child). The parent's rows are never touched — no ReplaceMessages, no move. handleBranch only calls setActive to the child, and /sessions (gateway.go:905-918) lists every session while /resume <session-id> (gateway.go:1013-1038) sets the active pointer back. So nothing is stranded and there is no lost work to "fold back". The only missing piece is a /merge command, which is confirmed absent from localCommands in internal/domain/messaging/commands.go — but absence of a feature is not a defect. 2. The issue's file references are stale. gateway.go's branch case is at 412-413, not 408 (408 is the tail of /undo), and internal/channels/telegram/commands.go does not exist — internal/channels contains only channel.go and status/status.go. 3. Compression is the only thing in the repository called a summary, and it has no semantic content to merge. /compress and /compact route to applyCompress → compressSessionHistory (session_commands.go:719-782), which calls CompressHistory (internal/gateway/compression.go). summariseTruncated (compression.go:213-247) emits the marker "[Earlier conversation has been summarised to stay within context limits.]" plus removed-message and token counts with the first/last 80 characters — statistics, not a summary of meaning; the code comment says LLM summarisation is "deferred to the memory provider". A repeat compression therefore cannot "merge" summaries: the stored summary is an ordinary assistant message (compressedHistory, session_commands.go:655-683) sitting at index ProtectFirst, so on the next round it falls inside the truncated span and is consumed as one more assistant turn. internal/domain/memory has no merge/consolidate/summarise path either. Nothing here is a documented-contract violation, so there is no wrong behaviour for a test to reproduce first. 4. There is no settled design to extend. docs/prds holds only self-development-loop.md and external-agent-harness.md; neither mentions sessions, branching or compression, and the phrase "iterative summary merging" appears nowhere in the tree (consistent with the source doc having been deleted). Conclusion: the branch-merge reading is refuted and the compression reading has nothing to operate on today, so no concrete bead can be cut from the evidence, and the issue explicitly forbids building under this title. The honest disposition is the second one the issue allows — close as ill-defined. Open question for you, with my recommendation: do you want this closed as ill-defined (my recommendation, since the premise that justified it does not hold), or kept as a separate feature bead for a /merge that folds a branch's messages back into its parent? In the second case the deliverable would be a feasibility doc, because /merge has no design and choosing its semantics (append vs summarise, conflict handling, who owns the parent history) is your call and not something to guess at in code.
sam closed this issue 2026-11-08 12:10:39 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1534