Skip to content

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

fix(cli): report an unreadable runs directory beside the rollouts in harness2 status

Claude79d2998d2338
diff --git a/cli/beacon/cmd/endpoint_harness2.go b/cli/beacon/cmd/endpoint_harness2.go
index 5a74d6db..5b8f322e 100644
--- a/cli/beacon/cmd/endpoint_harness2.go
+++ b/cli/beacon/cmd/endpoint_harness2.go
@@ -206,6 +206,8 @@ type harness2StatusReport struct {
Present bool `json:"present"`
StatePath string `json:"state_path,omitempty"`
Rollouts []harness2RolloutStatus `json:"rollouts"`
+ // Errors names each runs directory that could not be read.
+ Errors []string `json:"errors,omitempty"`
}
func runEndpointHarness2Status(cmd *cobra.Command, args []string) error {
@@ -219,10 +221,9 @@ func runEndpointHarness2Status(cmd *cobra.Command, args []string) error {
return err
}
store := &harness2session.Store{Roots: roots}
- refs, err := store.List()
- if err != nil {
- return err
- }
+ // A root that cannot be read is reported beside the rollouts the others hold, as a sync reports
+ // it, rather than hiding them.
+ refs, listErr := store.List()
report := harness2StatusReport{
Roots: roots,
Present: store.Exists(),
@@ -252,10 +253,16 @@ func runEndpointHarness2Status(cmd *cobra.Command, args []string) error {
report.Rollouts = append(report.Rollouts, status)
}
+ if listErr != nil {
+ report.Errors = strings.Split(listErr.Error(), "\n")
+ }
if endpointOpts.jsonOutput {
return json.NewEncoder(cmd.OutOrStdout()).Encode(report)
}
out := cmd.OutOrStdout()
+ for _, msg := range report.Errors {
+ fmt.Fprintf(cmd.ErrOrStderr(), "warning: %s\n", msg)
+ }
if !report.Present {
fmt.Fprintf(out, "Harness² rollouts: none (no runs directory at %s); name one with --runs-dir\n", strings.Join(report.Roots, ", "))
return nil
diff --git a/cli/beacon/cmd/endpoint_harness2_test.go b/cli/beacon/cmd/endpoint_harness2_test.go
index 7b18c800..3a0dcdfe 100644
--- a/cli/beacon/cmd/endpoint_harness2_test.go
+++ b/cli/beacon/cmd/endpoint_harness2_test.go
@@ -44,9 +44,9 @@ func newHarness2CommandFixture(t *testing.T) harness2CommandFixture {
logPath: filepath.Join(root, "logs", "runtime.jsonl"),
}
for rel, body := range map[string]string{
- "lab/results/cx/run-1/codex_session.jsonl": harness2CodexStream,
+ "lab/results/cx/run-1/codex_session.jsonl": harness2CodexStream,
"jb/dataset/p/task1/model_traj/base/p_task1_base_attempt1_x.jsonl": harness2OpenCodeStream,
- "jb/judged/scores.jsonl": `{"task":"p/task1","score":1}` + "\n",
+ "jb/judged/scores.jsonl": `{"task":"p/task1","score":1}` + "\n",
} {
path := filepath.Join(f.runsDir, filepath.FromSlash(rel))
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
@@ -210,3 +210,22 @@ func TestHarness2StatePathAlwaysResolvesSomewhereDurable(t *testing.T) {
t.Fatalf("system default = %q", got)
}
}
+
+// A broken runs directory is reported beside the rollouts the others hold, not instead of them.
+func TestEndpointHarness2StatusReportsABrokenRootBesideTheRest(t *testing.T) {
+ f := newHarness2CommandFixture(t)
+ bad := filepath.Join(t.TempDir(), "gone")
+ if err := os.WriteFile(bad, []byte("x"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ endpointHarness2Opts.runsDirs = []string{bad, f.runsDir}
+ endpointOpts.jsonOutput = true
+ out := runHarness2(t, endpointHarness2StatusCmd, runEndpointHarness2Status)
+ var report harness2StatusReport
+ if err := json.Unmarshal([]byte(out), &report); err != nil {
+ t.Fatalf("status JSON %q: %v", out, err)
+ }
+ if len(report.Rollouts) != 2 || len(report.Errors) != 1 || !strings.Contains(report.Errors[0], "not a directory") {
+ t.Fatalf("report = %+v", report)
+ }
+}