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
Ship a never-uploaded sandbox log to managed ingest on session start
shukieshahe063152dd53a
diff --git a/cli/beacon-hooks/internal/cloudshuttle/asymptote_test.go b/cli/beacon-hooks/internal/cloudshuttle/asymptote_test.goindex 5aff0dfa..8d1e334f 100644--- a/cli/beacon-hooks/internal/cloudshuttle/asymptote_test.go+++ b/cli/beacon-hooks/internal/cloudshuttle/asymptote_test.go@@ -224,3 +224,24 @@ func TestSessionStartFlushesThePreviousRunsTailToManagedIngest(t *testing.T) {t.Fatal("the flushed log should be removed before the new run starts")}}++func TestSessionStartShipsALogWhoseRunNeverUploaded(t *testing.T) {+ server, calls := startFakeIngest(t, 200)+ cfg := asymptoteConfig(t, server)+ appendLines(t, cfg.LogPath, `{"event":1}`, `{"event":2}`) // the previous run's Stop hook never fired++ next := cfg+ next.RunID = "run-2"+ if err := preserveExistingLog(next); err != nil {+ t.Fatal(err)+ }+ if len(*calls) != 1 || strings.Join((*calls)[0].lines, "|") != `{"event":1}|{"event":2}` {+ t.Fatalf("expected the whole never-sent log to be posted: %+v", *calls)+ }+ if _, err := os.Stat(cfg.LogPath); !os.IsNotExist(err) {+ t.Fatal("the shipped log should be removed, not renamed aside")+ }+ if matches, _ := filepath.Glob(cfg.LogPath + ".previous-*"); len(matches) != 0 {+ t.Fatalf("no .previous-* copy should be left behind: %v", matches)+ }+}diff --git a/cli/beacon-hooks/internal/cloudshuttle/shuttle.go b/cli/beacon-hooks/internal/cloudshuttle/shuttle.goindex 47118397..5f9a07e2 100644--- a/cli/beacon-hooks/internal/cloudshuttle/shuttle.go+++ b/cli/beacon-hooks/internal/cloudshuttle/shuttle.go@@ -565,7 +565,13 @@ func preserveExistingLog(cfg Config) error {if info.Size() == 0 {return os.Remove(cfg.LogPath)}- if st, err := readState(cfg.StatePath); err == nil && st.LastObject != "" && uploadConfigured(cfg) {+ st, stateErr := readState(cfg.StatePath)+ hasState := stateErr == nil && st.LastObject != ""+ // Bucket targets can only re-upload under the object name a previous run already used, so+ // they need state. Managed ingest is addressed by the lines' own session ids, so a log from+ // a run that never got a successful batch out (no state) is shipped whole rather than+ // renamed aside, where an ephemeral sandbox would lose it.+ if uploadConfigured(cfg) && (hasState || cfg.Upload == uploadAsymptote) {snapshot, cleanup, err := snapshotLog(cfg.LogPath)if err == nil {defer cleanup()@@ -576,7 +582,9 @@ func preserveExistingLog(cfg Config) error {// Ship whatever the previous run's last hook did not get to, under that run's// identity so the stored offset applies and nothing is sent twice.previous := cfg- previous.Provider, previous.RunID = st.Provider, st.RunID+ if hasState {+ previous.Provider, previous.RunID = st.Provider, st.RunID+ }uploadErr = uploadAsymptoteIncremental(ctx, previous, snapshot, info.Size())} else {uploadErr = uploadSnapshot(ctx, cfg, st.LastObject, snapshot)