Repository navigation
feat(sources): materialize Hermes subagent-delegation topology (fs1.14/fs1.2.1) - #3231
Conversation
Problem: hermes_spans.py already parsed ATIF subagent_trajectories entries and ATOF hermes.subagent.* marks into hermes_subagent_span summary events, but explicitly declared topology_edges "absent" -- the delegation evidence was surfaced read-side (hermes_topology_projection.subagent_evidence) but never materialized as a real session_links parent edge, per fs1.14's last remaining scope item. What changed: 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 uses. ATOF: when the child's own trace records are not 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). ATIF: subagent_trajectories entries carry their own steps, so the child session 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 updated accordingly. 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's new HermesSubagentEvidenceRef. delegation_edge_materialized field) 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 carries an empty/absent list), so it stays inferred. Verification: devtools test tests/unit/sources/parsers/test_hermes_spans.py (32 passed), tests/unit/insights/test_hermes_topology_projection.py (13 passed); mypy --strict on the three touched modules (no issues). Ref polylogue-fs1.14
…ures (fs1.2.1) Problem: fs1.2.1 AC2 requires the ATIF/ATOF structural detectors to admit both real producer fixtures at the correct tightness AND reject a payload containing only the repository-invented marker; only the ATIF side had an explicit negative marker test. Separately, materializing subagent-delegation sessions from the real ATOF fixture (this branch's fs1.14 work) changed the real fixture's produced-session count from 1 to 2, which two pre-existing tests asserted exactly. What changed: added test_looks_like_atof_payload_rejects_a_repository_ invented_marker_only_shape (ATOF never had an invented marker historically, so this proves a marker-only payload was never, and is still not, sufficient) and a detect_provider-level assertion on the existing ATIF marker-rejection test, closing AC2 through both the structural predicate and the real dispatch entrypoint. Updated test_real_nemo_relay_atof_fixture_reaches_the_stream_parser_without_copying_content, test_import_explain_uses_atof_stream_fidelity_for_a_real_fixture, and test_source_parser_groups_real_shaped_hermes_atof_jsonl_as_one_retained_stream to the new 2-session count and added topology_edges="exact" assertions. Verification: devtools test tests/unit/sources/parsers/test_hermes_spans.py (33 passed), tests/unit/sources/test_dispatch_payloads.py (10 passed). Ref polylogue-fs1.2.1
devtools verify --quick's mypy step flagged the untyped dict literal added in the previous commit's detect_provider-level marker-rejection assertion (dict[str, Sequence[str]] inferred instead of JSONDocument). Annotate it explicitly; no behavior change. Verification: mypy --strict tests/unit/sources/parsers/test_hermes_spans.py tests/unit/sources/test_dispatch_payloads.py (no issues); devtools verify --quick (exit 0). Ref polylogue-fs1.2.1
…14/fs1.2.1) Problem: docs/hermes-operators.md's "What Polylogue cannot claim" section and the ATIF/ATOF fidelity examples asserted subagent_delegation "never reaches topology_edges/session_links" and showed topology_edges as permanently absent -- both now false for the case where the evidence is unambiguous and profile-qualified (this branch's fs1.14 work). What changed: updated the ATIF/ATOF capability example blocks with current observed values (topology_edges: exact/1/1 for the real ATOF fixture, parent_session_link added to both), narrowed cannot-claim item 5 to describe exactly when an edge is and isn't materialized, and added a "Subagent delegation is the one exception" paragraph to the Session identity section explaining this is the only case where the archive stores a real graph edge rather than a read-time lookup. Verification: devtools verify --quick (exit 0, render all/docs-coverage/ doc-commands all pass). Ref polylogue-fs1.14 Ref polylogue-fs1.2.1
|
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: 48 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 (2)
📝 WalkthroughWalkthroughHermes ATIF and ATOF parsing now materializes qualified subagent sessions and delegation edges, reports edge provenance, updates fidelity calculations, and validates fail-closed behavior for ambiguous or self-referential delegation. ChangesHermes topology and delegation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant HermesPayload
participant HermesParser
participant ParsedSession
participant TopologyProjection
HermesPayload->>HermesParser: provide ATIF or ATOF delegation evidence
HermesParser->>ParsedSession: create parent and qualified child sessions
HermesParser->>ParsedSession: assert delegation_edge_asserted when valid
ParsedSession->>TopologyProjection: expose delegation event payload
TopologyProjection-->>HermesPayload: report delegation_edge_materialized
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
…1.14) Problem: parse_atof_stream's delegation_targets computation excludes any child_session_id claimed by more than one distinct parent in a batch (len(parents) == 1 guard), but this fail-closed conflict path had no dedicated unit test -- only the simpler unknown-profile and self-reference fail-closed cases were covered. What changed: added test_atof_subagent_mark_fails_closed_when_two_parents_claim_the_same_child, two hermes.subagent.start marks from different parent sessions both naming "contested-child" as their child. Asserts no third (stub or overridden) session is materialized, both parents' hermes_subagent_span events keep delegation_edge_asserted=False, and topology_edges stays absent/0 on both sides while subagent_delegation (the underlying mark-shape mapping) stays exact -- the evidence is retained, only the graph edge is withheld. Verified the mutation this test targets (relaxing the len(parents) == 1 guard to admit every claimed child) makes it fail with a 3-session, spuriously-materialized-edge result, then reverted that mutation. Verification: devtools test tests/unit/sources/parsers/test_hermes_spans.py (34 passed); devtools verify --quick (exit 0). Ref polylogue-fs1.14
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@polylogue/sources/parsers/hermes_spans.py`:
- Around line 422-441: Update _mark_delegation_edges_on_subagent_events to
retain each grouped session’s parent/session ID while iterating, and mark
delegation_edge_asserted true only when delegation_targets[child_session_id]
matches that actual parent identity. Keep invalid, missing, and self-referential
child IDs false so materialized delegation fidelity remains fail-closed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8b310d9f-e226-4af7-8f9d-678c3e23ab19
📒 Files selected for processing (6)
docs/hermes-operators.mdpolylogue/insights/hermes_topology_projection.pypolylogue/sources/dispatch.pypolylogue/sources/parsers/hermes_spans.pytests/unit/sources/parsers/test_hermes_spans.pytests/unit/sources/test_dispatch_payloads.py
Problem: CodeRabbit inline review on PR #3231 (hermes_spans.py:441) found _mark_delegation_edges_on_subagent_events iterated grouped.values() without the owning session id, so it set delegation_edge_asserted=True whenever a mark's child_session_id was ANY key in delegation_targets -- not only when THIS session was the recorded parent for that specific child. Concrete failure: session S emits a self-referential mark (child==S, correctly excluded from delegation_claims by the child_session_id != session_id check), while an unrelated session P legitimately claims S as its own child (delegation_targets["S"] == "P"). Membership alone made S's own self-referential span read delegation_edge_asserted=True merely because "S" is a key in the map, contradicting the fail-closed self-reference guarantee test_atof_subagent_mark_fails_closed_on_self_reference already asserts. What changed: iterate grouped.items() to carry the owning session id, and require delegation_targets.get(child_session_id) == owning_session_id before setting the flag -- not just truthy membership. P's own claim on S is unaffected (P *is* the owning session for that resolved target) and still materializes S's real session_links edge to P. Added test_atof_self_referential_mark_stays_unasserted_when_another_session_ legitimately_claims_the_same_id reproducing the exact S/P scenario: asserts S's own span stays delegation_edge_asserted=False while P's edge to S still materializes (parent_session_provider_id, branch_type=subagent). Verified the mutation this test targets (reverting to membership-only: bool(delegation_targets.get(child_session_id))) makes it fail (True is False), then reverted that mutation. Verification: devtools test tests/unit/sources/parsers/test_hermes_spans.py (35 passed); mypy --strict polylogue/sources/parsers/hermes_spans.py tests/unit/sources/parsers/test_hermes_spans.py (no issues); devtools verify --quick (exit 0). Ref polylogue-fs1.14
|
Coordinator merge note: CodeRabbit's single Major finding (delegation_edge_asserted marked by global membership instead of parent identity — self-referential mark misattribution) fixed in 46047f2 with a mutation-proven regression test; reply posted on the inline thread. Conflict-guard (two parents claiming one child → no edge, visible debt) also gained its dedicated test earlier at coordinator request. Delegation edges materialize fail-closed from the real ATOF fixture (stub child sessions carry the edge under the same computed id, so later real ingest full-replaces in place); fs1.2.1 AC2 negative-marker tests + AC5 fidelity audit complete. 35+56 focused tests, mypy --strict, quick verify green ×3. Merging. |
/#3224/#3225/#3227/#3231 receipts Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ
Summary
Closes fs1.14's last remaining scope item (subagent-delegation topology
materialization from Hermes ATIF
subagent_trajectoriesand ATOFhermes.subagent.*marks) and fs1.2.1's residual detector-tightness andfidelity-honesty ACs, all against the two real redacted producer fixtures
already checked into the repo.
Problem
hermes_spans.pyalready parsed ATIFsubagent_trajectoriesentries andATOF
hermes.subagent.*marks intohermes_subagent_spansummary events,and
hermes_topology_projection.pyalready surfaced them read-side assubagent_evidence-- but both explicitly declaredtopology_edgesaspermanently
absent: the delegation evidence never became a realsession_linksgraph edge. Separately, fs1.2.1 had residual ACs (detectortightness proof, fidelity-band honesty) that were unaddressed after the
merged
unpaired-scope-debtand shared-file/single-session fixes (#3103,#3113).
Solution
Materialization (
polylogue/sources/parsers/hermes_spans.py):parse_atof_streamandparse_atif_documentnow materialize a realsession_linksparent edge (branch_type=subagent) for a subagentreference 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_trajectoriesentries carry their own
steps, so the child gets real parsed content, nota stub.
parse_atif_document's return type changed fromParsedSessiontolist[ParsedSession](parent + any materialized children);dispatch.py'slowering was updated accordingly (one call site).
Each observing session's own
hermes_subagent_spanevent now carries adelegation_edge_assertedflag recording whether materialization actuallyhappened, so
import_fidelity_declaration'stopology_edgescapability(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.startmark (topology_edges: exact); ATIF'ssubagent_trajectoriesmapping has no real-fixture evidence yet (every realATIF export sampled so far carries an empty/absent list), so it stays
inferred, neverexact.Detector tightness (fs1.2.1 AC2): added a negative test proving the
ATOF structural detector (
looks_like_atof_payload) rejects arepository-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 AC2for both artifact families. Also added a
detect_provider-level assertionon 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_fixturesite inhermes_spans.py. The pre-existingllm_request_spans/tool_execution_spans(ATIF) andllm_request_spans/tool_execution_spans/decision_points/error_taxonomy/subagent_delegation/context_events(ATOF) capabilitieswere 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_edgescapability is gated the same way:exactonly when thereal ATOF fixture proves both the field mapping and the edge materialization
end-to-end;
inferredon the ATIF route since no real fixture proves thatmapping yet.
Docs:
docs/hermes-operators.mdhad several claims thatsubagent_delegation"never reachestopology_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):
session_linksparentreferences 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); seetest_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.hermes_topology_projection.pyto surface the edges: satisfied--
HermesSubagentEvidenceRef.delegation_edge_materialized, read straightfrom the underlying event's
delegation_edge_assertedpayload flag; keptshape-agnostic (no new coupling to
hermes_spansinternals).above.
declared absent/inferred: satisfied -- ATIF
topology_edgesstaysinferredeven when materialized (neverexact, no real fixture proof).polylogue-fs1.2.1 (residual ACs 2 and 5):
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).
already satisfied except the new
topology_edgescapability, which isnow gated to the same standard (exact only for the real-fixture-proven
ATOF route). No existing capability required downgrading.
producer match, ATOF replay/append semantics, mutation-sensitive tests):
already satisfied by prior merged work (PRs fix(hermes): unpaired-scope debt + two confirmed live-ingest bugs #3103, fix(hermes): resolve confirmed live-ingest bugs polylogue-1zex and polylogue-flxh #3113, fix(sources): profile-qualify Hermes ATIF/ATOF observer session identity #3224,
fix(sources): Hermes ATIF/ATOF topology projection (fs1.14) #3225 per the bead's own notes) -- not re-implemented here, out of this
PR's stated residual scope.
Verification
Not run: full
devtools verify/--all(testmon unseeded in this worktree;out of the requested synchronous-foreground scope) and integration tests.
Residual risk
topology_edgesmaterialization only handles the case observed in thereal 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.
_events_for_step, so any future step-shapeaddition 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 withinpolylogue.sources.parsers.hermes_spans; the only production call site(
dispatch.py) was updated, and a repo-wide grep confirmed no othercaller exists.
Ref polylogue-fs1.14
Ref polylogue-fs1.2.1
Summary by CodeRabbit
New Features
Bug Fixes
Documentation