Skip to content

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

Mark a Cline kanban card seen only once all its events are written

Claudeefc062cd312c
diff --git a/cli/beacon/internal/clinesession/collect.go b/cli/beacon/internal/clinesession/collect.go
index 43ff9ef8..a7f581c6 100644
--- a/cli/beacon/internal/clinesession/collect.go
+++ b/cli/beacon/internal/clinesession/collect.go
@@ -178,18 +178,19 @@ func collectTrace(store *Store, ref TraceRef, state *State, opts CollectOptions,
if err := emitEvent(item.Event, opts); err != nil {
return true, err
}
- // A record can map to several events (a prompt and its session.handoff link). The cursor
- // passes a record only once its last event is written, so a failure partway through retries
- // the whole record rather than skipping what was left of it.
+ // A record can map to several events (a prompt and its session.handoff link). The cursor,
+ // and for a kanban card its content hash, passes a record only once its last event is
+ // written, so a failure partway through retries the whole record rather than skipping what
+ // was left of it.
if recordComplete(mapped, i) {
cursor.LastOrder = item.SourceOrder
- }
- if pendingHashes != nil {
- if h, ok := pendingHashes[item.SourceOrder]; ok {
- if cursor.KanbanHashes == nil {
- cursor.KanbanHashes = map[int]string{}
+ if pendingHashes != nil {
+ if h, ok := pendingHashes[item.SourceOrder]; ok {
+ if cursor.KanbanHashes == nil {
+ cursor.KanbanHashes = map[int]string{}
+ }
+ cursor.KanbanHashes[item.SourceOrder] = h
}
- cursor.KanbanHashes[item.SourceOrder] = h
}
}
if item.Event.Event.Action == "session.started" {
diff --git a/cli/beacon/internal/clinesession/partial_test.go b/cli/beacon/internal/clinesession/partial_test.go
index e58df814..2b9e6564 100644
--- a/cli/beacon/internal/clinesession/partial_test.go
+++ b/cli/beacon/internal/clinesession/partial_test.go
@@ -62,3 +62,36 @@ func TestCollectOnceRetriesARecordWhoseLinkFailedToWrite(t *testing.T) {
t.Fatalf("session.handoff events after the retry = %d, want 1", links)
}
}
+
+// A kanban card is re-read by content hash rather than order, so the hash must also wait for the
+// card's last event: a card whose link failed to write is retried, not marked seen.
+func TestCollectOnceRetriesAKanbanCardWhoseLinkFailedToWrite(t *testing.T) {
+ testenv.SetHome(t, t.TempDir())
+ f := newSweepFixture(t)
+ f.writeKanbanCard(t, "Continue the work.\n\n"+asymptoteobserve.HandoffMarker("claude_code", "src-1"), "", "2026-01-01T00:01:00Z")
+
+ prev := emitEvent
+ t.Cleanup(func() { emitEvent = prev })
+ emitEvent = func(event schema.Event, opts CollectOptions) error {
+ if event.Event.Action == "session.handoff" {
+ return errors.New("disk full")
+ }
+ return prev(event, opts)
+ }
+ if _, err := CollectOnce(f.options()); err == nil {
+ t.Fatal("the failed link write must surface")
+ }
+ emitEvent = prev
+ if _, err := CollectOnce(f.options()); err != nil {
+ t.Fatalf("retry: %v", err)
+ }
+ links := 0
+ for _, e := range f.logLines(t) {
+ if e.Event.Action == "session.handoff" {
+ links++
+ }
+ }
+ if links != 1 {
+ t.Fatalf("session.handoff events after the retry = %d, want 1", links)
+ }
+}