Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Merge remote-tracking branch 'origin/feat/deepseek-session-backfill' into feat/deepseek-session-backfill

Justin D'Souza1dcc854a89ca
diff --cc cli/beacon/internal/dshsession/collect_test.go
index 347d1f7f,645dd322..ae43dbc7
--- a/cli/beacon/internal/dshsession/collect_test.go
+++ b/cli/beacon/internal/dshsession/collect_test.go
@@@ -78,38 -75,6 +78,35 @@@ func TestStoreReadsPlainAndMapsDeepSeek
}
}
+func TestMapSessionPreservesDiffWhitespace(t *testing.T) {
+ ref := SessionRef{ID: "s-diff", Path: "/tmp/session.jsonl", ModTimeUnixMS: 1}
+ records := []Record{
+ mustRecord(t, 1, record("session", map[string]interface{}{"id": "s-diff", "cwd": "/repo"})),
+ mustRecord(t, 2, record("tool/call", map[string]interface{}{"callId": "call_1", "name": "write", "arguments": map[string]interface{}{"file_path": "/repo/a.txt", "content": "line with trailing spaces \n"}})),
+ mustRecord(t, 3, record("tool/result", map[string]interface{}{"callId": "call_1", "toolName": "write", "content": "ok"})),
+ }
+ event := findAction(t, MapSession(ref, records, MapOptions{}), "file.modified")
+ if event.File == nil || !strings.Contains(event.File.Diff, "+line with trailing spaces \n+\n") {
+ t.Fatalf("diff = %q, want trailing spaces and newline preserved", event.File.Diff)
+ }
+}
+
+func TestAdvanceCursorPartialLeavesChangedFileRetryable(t *testing.T) {
+ cursor := &Cursor{LastLine: 1, SizeBytes: 100, ModTimeMS: 10}
+ ref := SessionRef{SizeBytes: 200, ModTimeUnixMS: 20}
+ mapped := []MappedEvent{
+ {SourceLine: 2, Event: schema.Event{Event: schema.EventInfo{Action: "prompt.submitted"}}},
+ {SourceLine: 3, Event: schema.Event{Event: schema.EventInfo{Action: "agent.message"}}},
+ }
- advanceCursorPartial(cursor, ref, mapped, 1)
++ advanceCursorPartial(cursor, mapped, 1)
+ if cursor.LastLine != 2 {
+ t.Fatalf("LastLine = %d, want 2", cursor.LastLine)
+ }
+ if cursor.SizeBytes == ref.SizeBytes || cursor.ModTimeMS == ref.ModTimeUnixMS {
+ t.Fatalf("partial cursor stamped changed file markers: %+v", cursor)
+ }
- if !cursor.PartialTail {
- t.Fatalf("partial cursor did not force retry: %+v", cursor)
- }
+}
+
func TestStoreReadsCompleteZstdFramesAndDefersPartialTail(t *testing.T) {
root := t.TempDir()
sessionDir := filepath.Join(root, "sessions", "z1")