Repository navigation
fix(hermes): unpaired-scope debt + two confirmed live-ingest bugs - #3103
Conversation
Problem: fs1.2.1's remaining AC flagged "append resume" and "unpaired events" as open concerns. Investigating empirically (not just re-reading code) against a live watcher instance revealed a genuine, confirmed data-loss bug: real ~/.hermes/observability/nemo-relay/atof/events.jsonl is ONE file shared across every Hermes session on an install (live-verified: 3+ distinct session ids interleaved in one file). The live-ingest raw-revision-authority replay chain and append path both hard-require exactly one logical session per raw revision -- correct for every other origin's file layout (Claude Code, Codex, Beads: always one file, one session) but genuinely violated by ATOF's shared-file shape. What changed: added an empirical regression test (test_live_append_atof_shared_file_multi_session_boundary_loses_events) that drives the real LiveBatchProcessor through a growth batch spanning a Hermes-session boundary. Direct sqlite inspection proves session A's new event is silently and permanently lost (not retried into existence -- the same bytes fail identically forever) while session B's brand-new content is still committed. Marked xfail(strict=True) pending a real fix, so it turns green (and the strict marker catches it) the moment someone lands the fix, rather than being a silent, easy-to-miss known-broken state. Filed polylogue-flxh with three candidate fix directions (raw-revision splitting, session-identity redesign, always-full-reingest for this origin), none chosen -- this touches core shared ingest plumbing used by every live provider and deserves its own reviewed pass, not a rushed patch. Added a loud fidelity caveat to hermes_spans.py's module docstring so this isn't only visible in a test file. Ref polylogue-flxh Ref polylogue-fs1.2.1 Co-Authored-By: Claude <[email protected]>
Problem: fs1.2.1's remaining AC asked for "unpaired debt" to be surfaced. A kind=scope UUID that never sees both its start and end phase (a crashed request, or a truncated/rotated file cutting a pending scope in half) was indistinguishable from a normal completed pair -- the start-only or end-only span was recorded like any other, with no signal that its counterpart never arrived. What changed: parse_atof_stream now tracks scope-phase pairing per UUID across the whole replayed stream and emits a typed hermes_atof_unpaired_scope event for any UUID missing either phase. Verified against the real fixture: llm-error-1 (a genuine scope=end with no matching scope=start, already present in the committed fixture) is now surfaced instead of silently blending in. Added a new unpaired_scope_debt fidelity capability (degraded when nonzero, absent key when zero) plus focused tests for both the start-only and end-only directions and a paired-scope-is-not-flagged sanity check. Also fixed a real cosmetic gap found while touching this: the ATOF session summary text enumerated LLM/tool/decision/subagent/error/ unrecognized counts but never context-span count, silently omitting a whole event class from the human-readable summary. Ref polylogue-fs1.2.1 Co-Authored-By: Claude <[email protected]>
…on crash
Problem: fs1.15 asks for Hermes coverage/freshness to flow through the
existing named-source freshness surface (polylogue-1xc.13) rather than a
new reporting command. That surface (project_named_source_freshness) is
entirely origin-agnostic, so this should already work for free -- but it
had never actually been driven end-to-end with real Hermes sources through
the real live watcher, only verified via the marker-payload/CLI route.
What changed: added real end-to-end tests driving LiveBatchProcessor with
real Hermes state.db and ATOF sources, then querying
project_named_source_freshness on the exact source paths. Confirms the
surface already covers Hermes correctly (INDEXED_UNCONVERGED/SEARCHABLE
stage, accepted raw revision present) once ingestion succeeds -- closing
that part of fs1.15's ask with zero new code, per its own design note
("compose EXISTING... no new monitoring database").
Driving state.db through the real watcher (not the marker-payload route)
surfaced a second confirmed bug, distinct from polylogue-flxh:
revision_backfill.py's _parse_one (shared by historical repair and the
live full/append routes per its own docstring) has zero SQLite awareness,
unlike the two other Hermes call sites in live/batch.py that correctly
special-case it. A state.db or verification_evidence.db with exactly ONE
session at ingest time crashes with UnicodeDecodeError trying to
json-parse raw SQLite bytes; two or more sessions route through a
different, working branch -- which is presumably why Phase 0 review
(PR #3084, merged) never caught it, since real installs almost always
have many sessions. Pinned as xfail(strict=True); filed polylogue-1zex
with root cause and two candidate fix directions, neither chosen (touches
shared plumbing used by historical repair too).
Ref polylogue-1zex
Ref polylogue-fs1.15
Co-Authored-By: Claude <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 41 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…lylogue-flxh (#3113) ## Summary Fixes both confirmed, previously-open Hermes live-ingestion data-loss/crash bugs (polylogue-1zex, polylogue-flxh) per operator-delegated design decisions recorded in the beads. Continuation of the maximalist Hermes fidelity program (Ref polylogue-fs1.2.1, polylogue-wj25, polylogue-fs1.15). ## Problem Two confirmed bugs from the prior investigation pass (PR #3103) remained open, pending design decisions the coordinator adjudicated this session: 1. **polylogue-1zex**: a Hermes `state.db`/`verification_evidence.db` with exactly one session at ingest time crashed the live watcher's full-ingest path (`UnicodeDecodeError` trying to json-parse raw SQLite bytes) — `revision_backfill.py`'s `_parse_one` (shared with historical repair) had no SQLite awareness, unlike two sibling call sites. 2. **polylogue-flxh**: real ATOF `events.jsonl` is one file shared across every Hermes session on an install. A growth batch spanning a session boundary silently and permanently lost the pre-existing session's new events. ## Solution **1zex** (Fable-adjudicated hybrid): SQLite magic-byte detection in `_parse_one` (`sqlite_snapshot.looks_like_sqlite_bytes`, one shared sniffer) + threading the real on-disk blob path through (`ArchiveStore.blob_path_for_hash`) to the existing `hermes_state`/`hermes_verification` parsers, falling back to a bounded temp-file spill only when no real path is materialized. Both entry points (live full-ingest and historical repair) get direct regression coverage. **flxh** (Fable-adjudicated Direction 3, plus a root-cause correction found empirically): implementing Direction 3 alone (origin-scoped routing — ATOF never takes the incremental-append path, always full/bundle ingest) did **not** fix the regression test, because the append path was never actually involved in the repro. Deeper investigation (direct tracing of the archive's membership-reconciliation internals) found the real cause: the ATOF/ATIF summary message text embedded live event/step counts that changed on every reparse, breaking the membership classifier's requirement that message content be an unchanging prefix across revisions to safely recognize append-only growth — a genuinely-monotonic growth batch looked non-monotonic and got silently rejected. Fixed by making the summary text permanently stable (session-id only; counts remain fully queryable from `session_events`/`import_fidelity_declaration`). Direction 3's append-routing change is kept as real defense-in-depth (matches the adjudicated rationale, zero risk to other origins), documented as not the load-bearing fix. Filed `polylogue-5rp1` as the recorded Direction-1 successor (per-session raw-revision splitting) for when ATOF files exceed the ~128MB/5s threshold named in the design decision. ## Verification - `devtools test tests/unit/sources/test_revision_backfill.py` — 14/14. - `devtools test tests/unit/sources/test_hermes_source_freshness_integration.py` — 4/4 (no xfail). - `devtools test tests/unit/sources/parsers/test_hermes_spans.py` — 19/19. - `devtools test tests/unit/sources/test_live_watcher.py` — 86/86 (no xfail — both prior xfails now pass for real, including a new idempotent-replay assertion for the flxh fix). - `devtools test tests/unit/sources` (full sweep) — 1774/1776 (2 known pre-existing, unrelated ChatGPT failures verified against baseline). - `devtools verify --quick` green after every commit. Both beads (`polylogue-flxh`, `polylogue-1zex`) updated with implementation notes; `polylogue-5rp1` filed as the flxh Direction-1 successor. --------- Co-authored-by: Claude <[email protected]>
…4/fs1.2.1) (#3231) ## Summary Closes fs1.14's last remaining scope item (subagent-delegation topology materialization from Hermes ATIF `subagent_trajectories` and ATOF `hermes.subagent.*` marks) and fs1.2.1's residual detector-tightness and fidelity-honesty ACs, all against the two real redacted producer fixtures already checked into the repo. ## Problem `hermes_spans.py` already parsed ATIF `subagent_trajectories` entries and ATOF `hermes.subagent.*` marks into `hermes_subagent_span` summary events, and `hermes_topology_projection.py` already surfaced them read-side as `subagent_evidence` -- but both explicitly declared `topology_edges` as permanently `absent`: the delegation evidence never became a real `session_links` graph edge. Separately, fs1.2.1 had residual ACs (detector tightness proof, fidelity-band honesty) that were unaddressed after the merged `unpaired-scope-debt` and shared-file/single-session fixes (#3103, #3113). ## Solution **Materialization** (`polylogue/sources/parsers/hermes_spans.py`): `parse_atof_stream` and `parse_atif_document` now materialize a real `session_links` parent edge (`branch_type=subagent`) for a subagent reference when the child session id is producer-positive, non-self- referential, unambiguous (no two different parents claiming the same child), and a profile root is known -- the same fail-closed pattern fs1.14's profile-qualification fix already established. On the ATOF route, when the child's own trace records aren't present in the same batch, a minimal delegation-evidence-only session is materialized so the edge still lands in the archive (content-hash full-replace later reconciles it if the child's real trace is separately ingested). On the ATIF route, `subagent_trajectories` entries carry their own `steps`, so the child gets real parsed content, not a stub. `parse_atif_document`'s return type changed from `ParsedSession` to `list[ParsedSession]` (parent + any materialized children); `dispatch.py`'s lowering was updated accordingly (one call site). Each observing session's own `hermes_subagent_span` event now carries a `delegation_edge_asserted` flag recording whether materialization actually happened, so `import_fidelity_declaration`'s `topology_edges` capability (and `hermes_topology_projection.HermesSubagentEvidenceRef. delegation_edge_materialized`) can report it without cross-session lookups. ATOF's mapping is proven end-to-end against the real NeMo Relay ATOF fixture's `hermes.subagent.start` mark (`topology_edges: exact`); ATIF's `subagent_trajectories` mapping has no real-fixture evidence yet (every real ATIF export sampled so far carries an empty/absent list), so it stays `inferred`, never `exact`. **Detector tightness (fs1.2.1 AC2):** added a negative test proving the ATOF structural detector (`looks_like_atof_payload`) rejects a repository-invented marker-only payload -- ATOF never had an invented marker historically (unlike ATIF's pre-fix `polylogue_artifact: "hermes_atif_trace"`), so this closes the "reject the marker" half of AC2 for both artifact families. Also added a `detect_provider`-level assertion on the existing ATIF marker-rejection test, proving rejection through the real dispatch entrypoint, not just the low-level predicate. **Fidelity honesty (fs1.2.1 AC5):** audited every `status="exact"` / `verified_by_real_fixture` site in `hermes_spans.py`. The pre-existing `llm_request_spans`/`tool_execution_spans` (ATIF) and `llm_request_spans`/`tool_execution_spans`/`decision_points`/ `error_taxonomy`/`subagent_delegation`/`context_events` (ATOF) capabilities were already correctly gated (real-fixture-proven mapping, "exact" means the *mapping* is proven, matching the precedent already established and tested elsewhere in this file for exactly this reason) -- no downgrade needed. The new `topology_edges` capability is gated the same way: `exact` only when the real ATOF fixture proves both the field mapping and the edge materialization end-to-end; `inferred` on the ATIF route since no real fixture proves that mapping yet. **Docs:** `docs/hermes-operators.md` had several claims that `subagent_delegation` "never reaches `topology_edges`/`session_links`" -- narrowed to describe exactly when an edge is and isn't materialized, and updated the ATIF/ATOF capability example blocks to current observed values. ## Per-bead AC matrix **polylogue-fs1.14** (residual scope: subagent-delegation topology materialization): - Materialize parent/child delegation evidence as `session_links` parent references from producer-positive ids + profile qualification, fail closed otherwise: **satisfied** -- `hermes_spans.py` (`_mark_delegation_edges_on_subagent_events`, `_atif_subagent_child_session`, `_atof_subagent_delegation_stub_session`); see `test_real_atof_fixture_subagent_mark_materializes_delegation_edge`, `test_atof_subagent_mark_fails_closed_without_profile_root`, `test_atof_subagent_mark_fails_closed_on_self_reference`, `test_atif_subagent_trajectory_materializes_delegation_edge_with_known_profile`, `test_atif_subagent_trajectory_fails_closed_without_profile_root`, `test_atif_subagent_trajectory_fails_closed_on_self_reference`. - Extend `hermes_topology_projection.py` to surface the edges: **satisfied** -- `HermesSubagentEvidenceRef.delegation_edge_materialized`, read straight from the underlying event's `delegation_edge_asserted` payload flag; kept shape-agnostic (no new coupling to `hermes_spans` internals). - Anti-vacuity real-fixture test + fail-closed test: **satisfied** -- see above. - Where the real fixture lacks subagent evidence (ATIF), keep the capability declared absent/inferred: **satisfied** -- ATIF `topology_edges` stays `inferred` even when materialized (never `exact`, no real fixture proof). **polylogue-fs1.2.1** (residual ACs 2 and 5): - AC2 (detector tightness admits both real fixtures, rejects marker-only): **satisfied** -- ATIF marker-rejection was already tested; added the `detect_provider`-level proof plus the ATOF equivalent (`test_looks_like_atof_payload_rejects_a_repository_invented_marker_only_shape`). Both real fixtures already pass detection (pre-existing tests, unaffected). - AC5 (fidelity exact only where real bytes prove the mapping): **audited, already satisfied except the new `topology_edges` capability**, which is now gated to the same standard (exact only for the real-fixture-proven ATOF route). No existing capability required downgrading. - ACs 1, 3, 4, 6 (real-byte fixture acquisition, full per-event-class producer match, ATOF replay/append semantics, mutation-sensitive tests): **already satisfied by prior merged work** (PRs #3103, #3113, #3224, #3225 per the bead's own notes) -- not re-implemented here, out of this PR's stated residual scope. ## Verification ``` devtools test tests/unit/sources/parsers/test_hermes_spans.py tests/unit/sources/test_dispatch_payloads.py tests/unit/insights/test_hermes_topology_projection.py # 56 passed in 3.89s mypy --strict polylogue/sources/parsers/hermes_spans.py polylogue/insights/hermes_topology_projection.py polylogue/sources/dispatch.py tests/unit/sources/parsers/test_hermes_spans.py tests/unit/sources/test_dispatch_payloads.py # Success: no issues found in 5 source files devtools verify --quick # exit_code 0 (format, lint, mypy, render all --check, topology/layering/ # closure-matrix/schema-roundtrip/manifests/ci-workflows/doc-commands/ # docs-coverage/test-infra-currency/test-clock-hygiene/pytest-timeout- # overrides/degrade-loudly all pass) ``` Not run: full `devtools verify`/`--all` (testmon unseeded in this worktree; out of the requested synchronous-foreground scope) and integration tests. ## Residual risk - `topology_edges` materialization only handles the case observed in the real fixture (one mark, one child, single batch). Two different parents claiming the same child id in one batch is fail-closed (no edge) but not independently unit-tested beyond code review -- low risk, same pattern as the already-tested self-referential guard. - ATIF child sessions reuse `_events_for_step`, so any future step-shape addition to that function automatically applies to subagent children too (intentional, not drift). - `parse_atif_document`'s return-type change (`ParsedSession` -> `list[ParsedSession]`) is a public-ish API change within `polylogue.sources.parsers.hermes_spans`; the only production call site (`dispatch.py`) was updated, and a repo-wide grep confirmed no other caller exists. Ref polylogue-fs1.14 Ref polylogue-fs1.2.1 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Hermes imports now recognize real ATIF documents and can represent delegated subagent sessions. * Subagent evidence now indicates when a concrete parent-child session link was materialized. * Delegated sessions can be created from available trajectory or stream evidence, including minimal evidence-only sessions. * **Bug Fixes** * Improved session identity handling to prevent collisions between parent and delegated sessions. * Unsupported or ambiguous delegation references now fail closed without creating topology links. * **Documentation** * Updated Hermes fidelity, topology, and session-correlation guidance to reflect delegation behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
/#3224/#3225/#3227/#3231 receipts Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ
Summary
Continuation of the maximalist Hermes fidelity program (Ref polylogue-fs1.2.1, polylogue-wj25, polylogue-fs1.15) after PR #3092 merged. Closes out the remaining ATOF fs1.2.1 AC items that were tractable in-scope, and empirically investigates two
fs1.2.1/fs1.15open questions that turned up two previously-unknown, confirmed live-ingestion bugs — both pinned asxfail(strict=True)regression witnesses with dedicated beads, not silently left undiscovered.Problem
fs1.2.1's remaining AC explicitly flagged "append resume" and "unpaired events" as open concerns, and fs1.15 asked whether Hermes coverage/freshness already flows through the existing named-source freshness surface. Investigating these empirically (driving the real
LiveBatchProcessor, not just re-reading code) surfaced:kind=scopeUUID that never sees both itsstartandendphase (a crashed request, or a truncated/rotated file cutting a pending scope in half) was indistinguishable from a normal completed span.~/.hermes/observability/nemo-relay/atof/events.jsonlis ONE file shared across every Hermes session on an install. The live-ingest raw-revision-authority replay chain requires exactly one logical session per raw revision — correct for Claude Code/Codex/Beads (always one file, one session), but genuinely violated by ATOF's shared-file shape. A growth batch spanning a session boundary silently and permanently loses the pre-existing session's new event.state.dborverification_evidence.dbwith exactly ONE session at ingest time crashes the live watcher's full-ingest path withUnicodeDecodeError—revision_backfill.py's_parse_one(shared with historical repair) has zero SQLite awareness, unlike the two other Hermes call sites that correctly special-case it. Real installs almost always have 2+ sessions, which is presumably why this escaped the earlier Phase 0 review (PR feat(daemon): watch Hermes runtime evidence #3084, merged).Solution
Three commits:
feat(hermes): surface ATOF unpaired scope UUIDs as explicit debt—parse_atof_streamnow tracks scope-phase pairing per UUID and emits a typedhermes_atof_unpaired_scopeevent for any UUID missing either phase, plus a newunpaired_scope_debtfidelity capability. Verified against the real fixture (llm-error-1, a genuine unpaired scope already present in the committed fixture) and two new synthetic tests (start-only, end-only, and a paired-is-not-flagged sanity check).fix(hermes): document and pin confirmed ATOF shared-file data-loss bug— empirical regression test driving the real watcher through a session-boundary-spanning growth batch; direct sqlite inspection proves the loss. Filed polylogue-flxh with three candidate fix directions (none chosen — this is core shared ingest plumbing used by every live provider, deserves its own reviewed pass). Added a loud fidelity caveat tohermes_spans.py's module docstring.test(hermes): prove named-source freshness coverage, pin single-session crash— provesproject_named_source_freshness(origin-agnostic, no new code needed) correctly covers Hermes state.db/ATOF once ingestion succeeds; separately confirms and pins the single-session SQLite crash. Filed polylogue-1zex.Verification
devtools test tests/unit/sources/parsers/test_hermes_spans.py— 19/19.devtools test tests/unit/sources/test_live_watcher.py— 85 passed, 1 xfailed (expected).devtools test tests/unit/sources/test_hermes_source_freshness_integration.py— 2 passed, 1 xfailed (expected).devtools verify --quickgreen after every commit.Known residual gaps, tracked not silently dropped: polylogue-flxh and polylogue-1zex (both filed, neither fixed — both require careful design review of shared core ingest plumbing rather than a rushed patch in this pass). ATIF subagent topology materialization and verification-ledger session-id profile-qualification remain explicitly deferred design decisions (documented in prior session's bead notes), not attempted here since they'd change shipped public identity contracts without operator sign-off.