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
Justin D'Souzacfb1df277da1
diff --git a/cli/beacon/internal/ingest/endpoint/reader.go b/cli/beacon/internal/ingest/endpoint/reader.goindex e7a8f1e8..b3877966 100644--- a/cli/beacon/internal/ingest/endpoint/reader.go+++ b/cli/beacon/internal/ingest/endpoint/reader.go@@ -130,12 +130,18 @@ func logFiles(path string) ([]string, error) {base := filepath.Base(path)entries, err := os.ReadDir(dir)if err != nil {+ if os.IsNotExist(err) {+ return []string{path}, nil+ }return nil, err}var archives []stringfor _, entry := range entries {+ if entry.IsDir() {+ continue+ }name := entry.Name()- if strings.HasPrefix(name, base+".") {+ if _, ok := archiveIndex(base, name); ok {archives = append(archives, filepath.Join(dir, name))}}diff --git a/cli/beacon/internal/ingest/endpoint/reader_test.go b/cli/beacon/internal/ingest/endpoint/reader_test.goindex 839a49c1..ba11705d 100644--- a/cli/beacon/internal/ingest/endpoint/reader_test.go+++ b/cli/beacon/internal/ingest/endpoint/reader_test.go@@ -1,10 +1,12 @@package endpointimport (+ "context""os""path/filepath""testing"+ beaconauth "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/auth"endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/ingest")@@ -37,6 +39,34 @@ func TestEndpointSourceBatchesValidEventsAndMalformedRejects(t *testing.T) {}}+func TestUploadTreatsMissingLogDirectoryAsNoBatches(t *testing.T) {+ root := t.TempDir()+ logPath := filepath.Join(root, "missing", "runtime.jsonl")+ statePath := filepath.Join(root, "upload-state.json")+ store := ingest.Store{Path: statePath}+ if err := store.Save(ingest.State{LastError: "stale error"}); err != nil {+ t.Fatal(err)+ }++ source := NewSource(endpointconfig.Config{UserMode: true, LogPath: logPath}, logPath, true)+ res := ingest.Upload(context.Background(), ingest.Options{+ Settings: ingest.Settings{Enabled: true, Managed: true, SourceID: "source-1"},+ Store: store,+ Creds: &beaconauth.Credentials{Token: "token", UserID: "user"},+ Source: source,+ })++ if res.Uploaded {+ t.Fatalf("missing log directory should not upload: %#v", res.State)+ }+ if res.State.LastError != "" {+ t.Fatalf("LastError = %q", res.State.LastError)+ }+ if stored := store.Load(); stored.LastError != "" {+ t.Fatalf("persisted LastError = %q", stored.LastError)+ }+}+func TestEndpointSourceHonorsSavedOffset(t *testing.T) {dir := t.TempDir()logPath := filepath.Join(dir, "runtime.jsonl")@@ -193,6 +223,36 @@ func TestEndpointSourceReadsRotatedArchivesOldestFirst(t *testing.T) {}}+func TestEndpointSourceIgnoresWriterLockFile(t *testing.T) {+ dir := t.TempDir()+ logPath := filepath.Join(dir, "runtime.jsonl")+ if err := os.WriteFile(logPath+".lock", []byte("not-json\n"), 0600); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(logPath, []byte("{\"event\":\"active\"}\n"), 0600); err != nil {+ t.Fatal(err)+ }++ source := NewSource(endpointconfig.Config{UserMode: true, LogPath: logPath}, logPath, true)+ batches, err := source.Batches(ingest.State{FileOffsets: map[string]int64{}}, 500, 1024)+ if err != nil {+ t.Fatal(err)+ }++ if len(batches) != 1 {+ t.Fatalf("len(batches) = %d, want 1: %#v", len(batches), batches)+ }+ if batches[0].Cursor.LogPath != logPath || batches[0].Cursor.Archive != "" {+ t.Fatalf("unexpected active cursor: %#v", batches[0].Cursor)+ }+ if batches[0].Rejected != 0 {+ t.Fatalf("Rejected = %d, want 0", batches[0].Rejected)+ }+ if string(batches[0].Events[0]) != "{\"event\":\"active\"}" {+ t.Fatalf("event = %s", batches[0].Events[0])+ }+}+func TestEndpointSourceFollowsSavedOffsetAcrossArchiveRenumbering(t *testing.T) {dir := t.TempDir()logPath := filepath.Join(dir, "runtime.jsonl")