]> git.giacomolli.uk - onechat/commit
Add the view and save it across restarts
authorAnderson A. Giacomolli <agiacomolli@gmail.com>
Fri, 6 Nov 2026 14:36:37 +0000 (11:36 -0300)
committerAnderson A. Giacomolli <agiacomolli@gmail.com>
Fri, 6 Nov 2026 14:36:37 +0000 (11:36 -0300)
commit9f17bfb1173524553fff5301b0664267b430e6e3
tree7c4ce36a123849e8052b2a7ccc1e1956e666b720
parentc220fd0ce751005b675283b5c778d74bf5b8f630
Add the view and save it across restarts

The view is a list of tree nodes that covers the whole chat, oldest
first. Each new message appends its leaf as a line. Once the node text
of the view goes above 128,000 bytes, one batch merges the most due
sibling pairs until it is at most 64,000 bytes. Due is (T - last) / 2^l,
measured from the last message of the pair, and the oldest pair wins a
tie. A batch merges only pairs whose parent is built, and it continues
at each new message until it gets to 64,000 bytes. With the length of
Taelin's push list as the budget, the merges match the push for t = 0 to
20,000.

The memory core logs each message, builds the nodes that need no model
call, appends to the view, and writes view.json atomically after each
change. view.json holds the lines and the batch state, and the start
loads it as it is. The core never builds the view again from the log: a
chat with messages and no view.json does not open. The start only
appends the messages that a crash left out of the view.

A line whose node is not built renders as a pending mark, so the view
never holds a part of an unsummarized message.

Issue: beb9a70
memory.go [new file with mode: 0644]
memory_test.go [new file with mode: 0644]
view.go [new file with mode: 0644]
view_test.go [new file with mode: 0644]