Repository navigation
fix(hermes): resolve confirmed live-ingest bugs polylogue-1zex and polylogue-flxh - #3113
Conversation
Problem: revision_backfill.py's _parse_one (shared by historical repair and the live full/append routes per its own docstring) had zero SQLite awareness -- unlike the two other Hermes call sites in live/batch.py that correctly check hermes_state.looks_like_state_db_path / hermes_verification.looks_like_verification_evidence_db_path before falling back to JSON parsing. A state.db or verification_evidence.db with exactly one session at ingest time (a brand new Hermes install, or any minimal fixture) crashed the live watcher's full-ingest path with UnicodeDecodeError trying to json-parse raw SQLite bytes. Two or more sessions dodged the bug via a different, working branch -- which is presumably why Phase 0 review (PR #3084) never caught it, since real installs almost always have many sessions. Fable-adjudicated hybrid fix (operator-delegated design decision, recorded in the bead): detect via SQLite magic-byte sniffing (sqlite_snapshot.looks_like_sqlite_bytes, reusing the one shared sniffer rather than inventing a third), then execute by threading the real on-disk blob path through (ArchiveStore.blob_path_for_hash) to the existing hermes_state/hermes_verification SQLite parsers -- sqlite3.connect needs a real path, not in-memory bytes. Falls back to a bounded temp-file spill only when no real path is materialized yet, preserving _parse_one's deliberate no-eager-read discipline for stream providers. Both affected entry points get direct regression coverage: _parse_one called directly (proving the temp-spill fallback) and backfill_historical_revision_evidence end-to-end (proving the real-path branch through the actual historical-repair entry point) -- plus the live watcher regression from the prior investigation now passes without xfail, and a verification_evidence.db sibling closes the AC's other affected source. Ref polylogue-1zex Co-Authored-By: Claude <[email protected]>
…n data Problem: 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), unlike Claude Code/Codex where one JSONL file is always exactly one session. A growth batch can therefore span a Hermes session boundary, and the pre-existing session's new events were silently and permanently lost while a brand-new session in the same batch was still created correctly. Root cause (found empirically -- corrects the original polylogue-flxh diagnosis, which assumed the bug lived in the incremental-append path): it doesn't. ATOF's multi-session shape already routes through full/bundle ingest (len(sessions) != 1), which handles session grouping fine. The actual break is in the archive's membership classifier (session_revision_membership.classify_membership_revisions), which requires message content to be an unchanging prefix across revisions to safely recognize append-only growth. The ATOF/ATIF summary message text embedded live event/step counts that changed on every reparse, so a genuinely-monotonic growth batch looked like a non-monotonic edit and the classifier conservatively kept the stale revision rather than risk accepting a bad one. What changed: 1. The summary message text is now permanently stable (session-id only, never embeds counts -- those remain fully queryable from session_events and import_fidelity_declaration, already the source of truth for them). This is the actual fix. 2. Fable-adjudicated Direction 3 (operator-delegated design decision, recorded in the bead): the live watcher also never attempts incremental append for the Hermes ATOF source class, always routing it through full/bundle ingest instead -- zero change to the one-session-per-revision invariant Claude Code/Codex/Beads correctness depends on, measured cost acceptable (live install: 24MB/1231 events after ~4 days, seconds-scale reparse). Filed polylogue-5rp1 as the recorded successor (per-session raw-revision splitting) for when that cost stops being acceptable (~128MB or >5s sustained poll cost). The regression test now passes without xfail and additionally proves idempotent replay of a growth batch (re-ingesting the same bytes twice does not duplicate or change stored state). Ref polylogue-flxh Ref polylogue-5rp1 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: 47 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 (9)
✨ 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 |
…us worker Problem: rebasing polylogue-9p8x's parallel census parse (8a1f827) onto master's #3113 (Hermes SQLite-detection fix to _parse_one) left _census_parse_worker calling _parse_one without payload_path/ archive_root, unlike the sequential parse_retained_raw_sessions. Functionally harmless (the bounded temp-file spill fallback in _sqlite_payload_path still parses correctly) but loses the "prefer the already-materialized blob path, no copy" optimization #3113 added, and the parallel path had no regression coverage proving it matches the sequential path's parameter threading for Hermes state.db/ verification_evidence.db raws specifically. Solution: thread payload_path (only computed for Provider.HERMES, verified to exist on disk first) and archive_root through the worker's _parse_one call, matching parse_retained_raw_sessions exactly. Added test_parallel_census_threads_hermes_sqlite_payload_path (two independent single-session state.db raws, forcing ingest_workers>1 to actually dispatch through the pool) and updated this report with the fourth self-abort receipt plus a diagnostic finding: attempts 3 and 4 both aborted at the identical code location right after generation began, despite attempt 4 requiring 5 minutes of sustained external quiet beforehand -- suggesting the generation phase's own I/O may be self-inducing the pressure gate, not purely external contention. Filed polylogue-cmw2 to investigate. Verification: - devtools test tests/unit/sources/test_revision_backfill.py: 18 passed - devtools test -k "raw_materialization or raw_authority": 148 passed - devtools verify --quick: exit 0 (16/16 steps) Ref polylogue-9p8x Ref polylogue-hjpx.2 Co-Authored-By: Claude <[email protected]>
…dence (#3122) ## Summary - Parallelizes raw-authority census parse across a process pool and decouples the spill-cache bound from the resource-envelope block, fixing the CLI `rebuild-index` path's dead `ingest_workers` parameter and silent double-parse (`polylogue-9p8x`). - Delivers a read-only yla8 live-archive authorization packet recommending the operator hold the live catch-up gate. - Delivers an honest hjpx.2 proof-status report: mutation-proof laws verified via existing regression coverage, but the July-15-scale execution itself did not complete this session (4 self-aborts under genuine host I/O contention — receipts included). ## Problem `maintenance/replay.py::rebuild_index_from_source` accepted `ingest_workers` but immediately `del`eted it, funneling the CLI `rebuild-index` command's parser census into one sequential call. Its spill cache also never activated on that path because it received `max_payload_bytes=None`, so every accepted revision was reparsed during replay after census had already parsed it once (measured live: ~204 sessions/35min single-core). Separately, hjpx.2 needed a July-15-archive-shape proof of raw-authority replay convergence, and yla8 needed a current live-archive preflight before any operator authorization decision. ## Solution - `polylogue/sources/revision_backfill.py`: new `_parse_retained_raws`/`_census_parse_worker` spread read-only blob→`ParsedSession` decode across a `ProcessPoolExecutor`; archive writes still apply in fixed `pending_rows` order regardless of worker completion order, proven byte-identical to sequential (`test_parallel_census_matches_sequential_archive_state`). New `max_cached_payload_bytes` parameter decouples the spill-cache bound from the resource-envelope block (the two were previously the same parameter — passing a finite cache bound on the CLI's unbounded `selected_raw_ids=None` full-archive census would otherwise immediately raise `RawRevisionReplayResourceBlockedError`, since `raw_membership_census_rows(None)` returns every raw in the archive in one selection). - `polylogue/storage/repair.py`, `polylogue/maintenance/replay.py`: both gained `ingest_workers`, defaulting to a new shared `resolve_parse_worker_count()` (`polylogue/pipeline/services/process_pool.py`), so the daemon convergence path and the hjpx.2 scale-proof harness get parallel census automatically with no harness changes needed. - Rebased onto master's `#3113` (Hermes SQLite-detection fix to `_parse_one`); added parity so the parallel worker threads the real on-disk blob path through for Hermes raws the same way the sequential path does. - `.agent/reports/yla8-authorization-packet-2026-07-18.md`: read-only live-archive audit (no mutation). Recommends holding authorization: no current verified backup (6 days stale), archive mid-restore (99.8% unmaterialized), and at observed throughput a full drain would take days-to-weeks without `polylogue-5jak` landing. - `.agent/reports/hjpx2-july15-scale-proof-2026-07-18.md`: verdict per law. Envelope/fairness/conservation/interruption-resume mechanisms are proven (via existing + this session's regression tests); daemon-health responsiveness is a confirmed harness gap (`polylogue-agvo` filed); the July-15-scale execution itself self-aborted 4 times under genuine, sustained host I/O contention (receipts included, plus a diagnostic finding that the generation phase may be self-inducing pressure — `polylogue-cmw2` filed). ## Alternatives rejected - The bead's own suggested one-line fix (`max_payload_bytes=64MiB` on the CLI path) was not applied as literally stated: it would have broken the unbounded full-archive rebuild by activating the resource-envelope block archive-wide. Introduced the separate `max_cached_payload_bytes` parameter instead. - Did not implement commit-batching (the bead's own "Fix 3 (optional)") to chase the originally-hypothesized 4x speedup — measured evidence (cProfile) shows SQLite commit overhead is comparable to parse time, so parse-parallelism alone cannot reach 4x; filed `polylogue-amg1` as separately-scoped follow-up rather than force a larger, transaction-boundary-touching change into this PR. - Did not build a real-daemon-process harness for daemon-health responsiveness within this PR; that's a genuinely separate harness component (`polylogue-agvo`). ## Verification - `devtools test tests/unit/sources/test_revision_backfill.py`: 18 passed - `devtools test -k "raw_materialization or raw_authority"`: 148 passed - `devtools test tests/unit/devtools/test_raw_authority_scale_proof.py`: 21 passed - `devtools test tests/unit/devtools/test_raw_authority_restart_proof.py`: 4 passed - `devtools test tests/unit/storage/test_incremental_rebuild_equivalence.py tests/unit/cli/test_archive_maintenance_cli.py`: 58 passed - `devtools verify --quick`: exit 0 (16/16 steps), green after every commit ## AC matrix - **polylogue-9p8x**: Fix 1 (honor `ingest_workers`) and Fix 2 (decouple spill cache) — satisfied, tested. AC4 (≥4x measured speedup) — **not satisfied**, corrected by evidence to ~1.2-1.7x (Amdahl-limited); deferred to `polylogue-amg1`. - **polylogue-yla8**: read-only packet delivered per spec; no live mutation. Not closed (that decision is the operator's, per the packet's own yes/no question). - **polylogue-hjpx.2**: mutation-proof laws (envelope, fairness, conservation, interruption/resume) — proven via regression. Daemon-health responsiveness — not provable with current harness, `polylogue-agvo` filed. July-15-scale execution (AC1/AC6/AC7) — **not achieved this session**; 4 honest self-abort receipts recorded, `polylogue-cmw2` filed for the generation-phase self-induced-pressure finding. Bead remains open, not force-closed. Ref polylogue-9p8x Ref polylogue-yla8 Ref polylogue-hjpx.2 Co-Authored-By: Claude <[email protected]> --------- 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
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:
state.db/verification_evidence.dbwith exactly one session at ingest time crashed the live watcher's full-ingest path (UnicodeDecodeErrortrying 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.events.jsonlis 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 existinghermes_state/hermes_verificationparsers, 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. Filedpolylogue-5rp1as 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 --quickgreen after every commit.Both beads (
polylogue-flxh,polylogue-1zex) updated with implementation notes;polylogue-5rp1filed as the flxh Direction-1 successor.