The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(dsh): report partial spool drains
Justin D'Souzacbf593c926ce
diff --git a/cli/beacon/internal/dshsession/collect.go b/cli/beacon/internal/dshsession/collect.goindex 7fc6b9e4..0e634a08 100644--- a/cli/beacon/internal/dshsession/collect.go+++ b/cli/beacon/internal/dshsession/collect.go@@ -133,11 +133,11 @@ func CollectOnce(opts CollectOptions) (summary Summary, err error) {// two capture paths describe one event identically (same key, same call id), the// surviving copy is the collection_method=hook line doctor's capture check counts,// not the poll backfill of the same moment.- if drained, drainErr := drainSessionSpool(ref, opts, seen); drainErr != nil {+ drained, drainErr := drainSessionSpool(ref, opts, seen)+ summary.SpoolEvents += drained+ if drainErr != nil {summary.Errors++errs = append(errs, fmt.Errorf("DeepSeek session %s spool: %w", ref.ID, drainErr))- } else if drained > 0 {- summary.SpoolEvents += drained}changed, collectErr := collectSession(store, ref, state, opts, &summary)if sessionsync.Stopped(collectErr) {diff --git a/cli/beacon/internal/dshsession/spool_test.go b/cli/beacon/internal/dshsession/spool_test.goindex b2370b0f..2f5d1acd 100644--- a/cli/beacon/internal/dshsession/spool_test.go+++ b/cli/beacon/internal/dshsession/spool_test.go@@ -355,6 +355,34 @@ func TestCollectOnceDrainsTheWorkspaceSpoolAlongsideTheStore(t *testing.T) {}}+func TestCollectOnceCountsSpoolEventsAppendedBeforeDrainFailure(t *testing.T) {+ root := t.TempDir()+ workspace := t.TempDir()+ writeSession(t, filepath.Join(root, "sessions", "s-partial-drain"), SessionFileJSON,+ record("session", map[string]interface{}{"id": "s-partial-drain", "cwd": workspace}),+ )+ base, _ := asymptoteobserve.DSHSpoolPath(workspace, "s-partial-drain")+ valid := spoolTestEvent(t, "s-partial-drain", "session.started", "id-valid")+ invalid := spoolTestEvent(t, "s-partial-drain", "prompt.submitted", "id-invalid")+ invalid.Vendor = ""+ writeSpoolFile(t, base, valid, invalid)++ opts := CollectOptions{+ DSHHome: root,+ StatePath: filepath.Join(t.TempDir(), "state.json"),+ Write: true,+ LogPath: filepath.Join(t.TempDir(), "runtime.jsonl"),+ UserMode: true,+ }+ summary, err := CollectOnce(opts)+ if err == nil {+ t.Fatal("CollectOnce succeeded despite the invalid second spool event")+ }+ if summary.SpoolEvents != 1 {+ t.Fatalf("SpoolEvents = %d, want 1 event appended before the drain failed", summary.SpoolEvents)+ }+}+// The --workspace / --session-id filters decide which sessions are considered at all; a// filtered-out session's spool is left untouched rather than half-drained behind the// operator's filter.