Skip to content

fix(manager): stamp event ids with the run identity readers validate - #72

Open
Huang-404-Q wants to merge 1 commit into
AMAP-ML:mainfrom
Huang-404-Q:fix-runid-event-id-inference
Open

Huang-404-Q wants to merge 1 commit into
AMAP-ML:mainfrom
Huang-404-Q:fix-runid-event-id-inference

Conversation

@Huang-404-Q

Copy link
Copy Markdown

What this fixes

With a custom --log-dir (anything outside <runs-root>/<run-id>/lh_harness), the dashboard's event feed stays empty for a healthy run: every record is silently dropped with event_id does not belong to the requested run.

Why: the worker stamps event ids from the event log's grandparent path component (manager.py _append_event):

run_id = path.parents[2].name if len(path.parents) > 2 else "local"

but the dashboard/API validates each id against the run id it derives — the reserved id under --runs-root, or log_dir.parent.name for a pinned --log-dir. Those only coincide for the default layout. Concretely, lh-harness run --log-dir /x/myrun --dashboard stamps ids myrun:000001… while the embedded dashboard reads with the reserved id 20260828T000000Z_abcd1234 — the strict identity guard (webapi/events.py) then rejects every record, so REST replay, WebSocket deltas, and the snapshot's last-200 events all come back empty. The standalone web --log-dir path hits the same wall through its "local" fallback.

The change

  • HarnessConfig gains an optional run_id — the reader-facing run identity.
  • _append_event accepts run_event_id and prefers it over the path-derived stamp; every manager call site passes config.run_id.
  • The CLI threads the reserved run id into the config. Without a configured id (direct/test callers), the legacy path-derived stamp is kept, so default-layout behavior is unchanged.
  • The cross-run identity guard itself is untouched: foreign prefixes are still rejected.

Tests

tests/test_event_run_id.py (3 tests):

  • a configured run_id overrides the path-derived stamp;
  • without one, the stamp still falls back to the log directory's parent (default layout unchanged);
  • the reader accepts the configured stamp and keeps rejecting foreign ones.

Red/green verified: the first and third fail on main (empty feed for a pinned --log-dir), all pass with the fix. Full suite: 408 passed, 1 skipped; ruff clean on the touched files.

The dashboard/API validates every event id against the run id it derived
for the run: the reserved id under --runs-root, or log_dir.parent.name for
a pinned --log-dir. The worker instead stamped ids from the event log's
grandparent path component, which only matches for the default
<runs-root>/<run-id>/lh_harness layout.

With a custom --log-dir (e.g. /x/myrun), the worker stamped ids with an
unrelated path component ("myrun"), so the embedded dashboard rejected
every record with "event_id does not belong to the requested run" and the
event feed stayed empty for a perfectly healthy run. The standalone
snapshot fallback hit the same wall via its "local" default.

Thread the reader-facing id through HarnessConfig.run_id (set from the
CLI's reserved run id) and stamp ids with it; without a configured id the
legacy path-derived stamp remains. The cross-run identity guard keeps
rejecting foreign prefixes unchanged.
prax211 added a commit to cogniziocompany/LongHorizon-Harness that referenced this pull request Sep 6, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
prax211 added a commit to cogniziocompany/LongHorizon-Harness that referenced this pull request Sep 6, 2026
…deployed, doctor clean

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
prax211 added a commit to cogniziocompany/LongHorizon-Harness that referenced this pull request Sep 6, 2026
…ion and open question

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant