Repository navigation
fix(sources): Hermes ATIF/ATOF topology projection (fs1.14) - #3225
Conversation
|
Warning Review limit reached
Next review available in: 28 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 (18)
📝 WalkthroughWalkthroughHermes ATIF and ATOF artifacts now receive distinct profile-aware observer session identities. A new pure topology projection composes artifact evidence, preserves provenance, reports fidelity and unpaired artifacts, detects conflicts, and is covered by parser and projection tests. ChangesHermes topology archival and projection
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant HermesParser
participant Archive
participant TopologyProjection
participant OperatorCLI
HermesParser->>Archive: store conversational, ATIF, ATOF, and verification artifacts
OperatorCLI->>Archive: read artifact-qualified session ids
OperatorCLI->>TopologyProjection: provide archived event lists
TopologyProjection-->>OperatorCLI: return correlated evidence, caveats, and conflicts
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5bc2cdedaa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…iliation in flight Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ
5bc2cde to
028b2ae
Compare
Rebased onto master — composed with #3224 (merged)This branch was rebased onto current Composed identity scheme:
Conflicts resolved: New test proving the composition:
Verification:
Ref polylogue-fs1.14 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
polylogue/sources/parsers/hermes_verification.py (1)
105-115: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winVerification session ids still drop profile context
hermes_verification_session_id_for()strips@profile-...before derivingverification:<raw_id>, so two profiles reusing the same raw Hermes session id can still collide here. The docstring should also stop saying it mirrors ATIF/ATOF stripping, since those helpers now preserve the qualifier.🤖 Prompt for 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. In `@polylogue/sources/parsers/hermes_verification.py` around lines 105 - 115, Update hermes_verification_session_id_for to preserve the full conversational_session_id, including any `@profile-`<key> qualifier, when deriving the verification session id via observer_session_provider_id. Revise its docstring to describe qualifier preservation and remove the claim that it mirrors ATIF/ATOF stripping behavior.
🤖 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/insights/hermes_topology_projection.py`:
- Around line 1-303: Register HermesTopologyProjection in INSIGHT_REGISTRY using
the descriptor-driven integration required for insights modules. Add its field
accessors, Pydantic query model, operations methods, and CLI/MCP metadata,
wiring the existing project_hermes_topology aggregator into the registered
insight without changing its pure composition behavior.
---
Outside diff comments:
In `@polylogue/sources/parsers/hermes_verification.py`:
- Around line 105-115: Update hermes_verification_session_id_for to preserve the
full conversational_session_id, including any `@profile-`<key> qualifier, when
deriving the verification session id via observer_session_provider_id. Revise
its docstring to describe qualifier preservation and remove the claim that it
mirrors ATIF/ATOF stripping behavior.
🪄 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: 9669a2c2-4581-4188-9a59-f810ee9fac6f
📒 Files selected for processing (11)
docs/design/hermes-archival-export-contract.mddocs/hermes-operators.mddocs/plans/topology-target.yamldocs/topology-status.mdpolylogue/insights/hermes_topology_projection.pypolylogue/sources/parsers/hermes_spans.pypolylogue/sources/parsers/hermes_verification.pytests/unit/insights/test_hermes_topology_projection.pytests/unit/sources/parsers/test_hermes_spans.pytests/unit/sources/test_dispatch_payloads.pytests/unit/sources/test_live_watcher.py
| """Provenance-preserving Hermes topology projection (fs1.14). | ||
|
|
||
| ATIF and (future) ATOF materialization must enrich one logical Hermes session | ||
| revision without merging raw artifacts destructively or double-counting | ||
| evidence. Every Hermes artifact class -- the state-db conversational session | ||
| (``hermes_state.py``), the ATIF trajectory export and ATOF event stream | ||
| (``hermes_spans.py``), and the verification ledger (``hermes_verification.py``) | ||
| -- is retained as its own independent, non-colliding archive session (fs1.14 | ||
| fixed a prior identity collision where ATIF and ATOF shared one | ||
| ``observer:<id>`` provider_session_id and silently clobbered each other, see | ||
| ``hermes_spans.py``'s module docstring). This module owns the typed, | ||
| read-side composition across those independently-acquired artifacts for one | ||
| raw Hermes session id: it states, per artifact, whether evidence exists and | ||
| what fidelity it carries, without inferring parentage from proximity or | ||
| copying any message/event body across artifact boundaries. | ||
|
|
||
| Design discipline (mirrors ``hermes_verification_coverage.py`` / | ||
| ``context.hermes_delivery_correlation``): a pure aggregator over | ||
| already-fetched ``SessionEventRecord`` rows, no I/O, unit-testable in | ||
| isolation. Callers resolve each artifact's expected session id (via | ||
| ``hermes_state._qualified_session_id`` / ``hermes_spans.atif_session_provider_id`` | ||
| / ``hermes_spans.atof_session_provider_id`` / | ||
| ``hermes_verification.observer_session_provider_id``) and fetch its events | ||
| (``get_session_events``) before calling in; a resolved id with ``events=None`` | ||
| means that artifact's session does not exist in the archive -- the common | ||
| case for a Hermes session that only ever produced some of its possible | ||
| evidence classes, not an error. | ||
|
|
||
| Provenance rules this module enforces: | ||
|
|
||
| - **Never merge.** The projection only ever references session ids and | ||
| counts; it never returns message/event bodies from one artifact class | ||
| labelled as another's. | ||
| - **Unpaired traces are visible debt.** An ATIF session with no sibling ATOF | ||
| session (or vice versa) for the same raw Hermes session id is a partial | ||
| acquisition, not silently treated as "no observer evidence at all" -- | ||
| surfaced in ``unpaired_artifacts`` plus an explicit caveat. | ||
| - **Conflicting parent identifiers fail closed.** A subagent trajectory that | ||
| names its own parent session as its child (a structurally impossible | ||
| self-reference), or an ATIF-reported subagent-session-id set that shares no | ||
| member with the independently-acquired ATOF-reported set for the same | ||
| parent, is rendered as an explicit ``HermesTopologyConflict`` rather than | ||
| silently trusting one source over the other. | ||
| - **Deterministic composition.** Output ordering never depends on input | ||
| ordering (event lists are scanned but every collection in the result is | ||
| sorted before being returned), so rebuilding this projection from the same | ||
| retained raw evidence reproduces byte-identical output (AC: "replay and | ||
| rebuild are idempotent"). | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Sequence | ||
| from dataclasses import dataclass | ||
| from typing import TYPE_CHECKING, Literal | ||
|
|
||
| from polylogue.insights.archive_models import ArchiveInsightModel | ||
| from polylogue.sources.parsers.hermes_state import HermesFidelityStatus | ||
|
|
||
| if TYPE_CHECKING: | ||
| from polylogue.storage.runtime.archive.records import SessionEventRecord | ||
|
|
||
| HermesArtifactKind = Literal["conversational", "atif", "atof", "verification"] | ||
| _ARTIFACT_ORDER: tuple[HermesArtifactKind, ...] = ("conversational", "atif", "atof", "verification") | ||
|
|
||
|
|
||
| @dataclass(frozen=True, slots=True) | ||
| class HermesArtifactInput: | ||
| """One artifact's expected session id and its already-fetched events, if any. | ||
|
|
||
| ``session_id`` is always the caller-resolved, deterministic identity this | ||
| artifact class would carry for the raw Hermes session id being projected | ||
| (a producer-positive join key, never inferred from proximity/timing). | ||
| ``events is None`` means no session was found at that id -- the artifact | ||
| is simply absent from the archive, not an error. | ||
| """ | ||
|
|
||
| session_id: str | ||
| events: Sequence[SessionEventRecord] | None = None | ||
|
|
||
|
|
||
| class HermesArtifactObservation(ArchiveInsightModel): | ||
| """Whether one Hermes artifact class has retained evidence, and its fidelity.""" | ||
|
|
||
| artifact: HermesArtifactKind | ||
| session_id: str | ||
| available: bool | ||
| event_count: int = 0 | ||
| fidelity_status: HermesFidelityStatus | None = None | ||
| caveats: tuple[str, ...] = () | ||
|
|
||
|
|
||
| class HermesSubagentEvidenceRef(ArchiveInsightModel): | ||
| """One producer-reported subagent-session reference, never physically linked. | ||
|
|
||
| ``source_artifact`` states exactly which independently-acquired artifact | ||
| reported this reference (ATIF's ``subagent_trajectories`` or ATOF's | ||
| ``hermes.subagent.*`` marks) -- field-level provenance, per the design. | ||
| """ | ||
|
|
||
| source_artifact: Literal["atif", "atof"] | ||
| subagent_session_id: str | ||
| agent_name: str | None = None | ||
| status: str | None = None | ||
|
|
||
|
|
||
| class HermesTopologyConflict(ArchiveInsightModel): | ||
| """An explicit, fail-closed conflict -- never silently resolved by picking a side.""" | ||
|
|
||
| kind: Literal["self_referential_subagent", "atif_atof_subagent_identity_mismatch"] | ||
| detail: str | ||
| evidence_refs: tuple[str, ...] | ||
|
|
||
|
|
||
| class HermesTopologyProjection(ArchiveInsightModel): | ||
| """One logical Hermes session's topology, composed read-side from every retained artifact.""" | ||
|
|
||
| hermes_session_id: str | ||
| artifacts: tuple[HermesArtifactObservation, ...] | ||
| subagent_evidence: tuple[HermesSubagentEvidenceRef, ...] = () | ||
| unpaired_artifacts: tuple[HermesArtifactKind, ...] = () | ||
| conflicts: tuple[HermesTopologyConflict, ...] = () | ||
| caveats: tuple[str, ...] = () | ||
|
|
||
|
|
||
| def _observe_artifact(artifact: HermesArtifactKind, artifact_input: HermesArtifactInput) -> HermesArtifactObservation: | ||
| events = artifact_input.events | ||
| if events is None: | ||
| return HermesArtifactObservation(artifact=artifact, session_id=artifact_input.session_id, available=False) | ||
|
|
||
| caveats: list[str] = [] | ||
| fidelity_status: HermesFidelityStatus = "exact" if events else "absent" | ||
| if artifact == "atof": | ||
| unpaired_scopes = sum(1 for event in events if event.event_type == "hermes_atof_unpaired_scope") | ||
| if unpaired_scopes: | ||
| fidelity_status = "degraded" | ||
| caveats.append(f"{unpaired_scopes} ATOF scope(s) never observed both their start and end phase.") | ||
| if artifact == "atif": | ||
| unrecognized_steps = sum(1 for event in events if event.event_type == "hermes_observer_span") | ||
| if unrecognized_steps: | ||
| fidelity_status = "degraded" | ||
| caveats.append(f"{unrecognized_steps} ATIF step(s) matched none of the documented shapes.") | ||
|
|
||
| return HermesArtifactObservation( | ||
| artifact=artifact, | ||
| session_id=artifact_input.session_id, | ||
| available=True, | ||
| event_count=len(events), | ||
| fidelity_status=fidelity_status, | ||
| caveats=tuple(caveats), | ||
| ) | ||
|
|
||
|
|
||
| def _atif_subagent_refs(events: Sequence[SessionEventRecord]) -> list[HermesSubagentEvidenceRef]: | ||
| refs: list[HermesSubagentEvidenceRef] = [] | ||
| for event in events: | ||
| if event.event_type != "hermes_subagent_span": | ||
| continue | ||
| subagent_session_id = event.payload.get("subagent_session_id") | ||
| if not isinstance(subagent_session_id, str) or not subagent_session_id: | ||
| continue | ||
| agent_name = event.payload.get("subagent_agent_name") | ||
| refs.append( | ||
| HermesSubagentEvidenceRef( | ||
| source_artifact="atif", | ||
| subagent_session_id=subagent_session_id, | ||
| agent_name=agent_name if isinstance(agent_name, str) and agent_name else None, | ||
| ) | ||
| ) | ||
| return refs | ||
|
|
||
|
|
||
| def _atof_subagent_refs(events: Sequence[SessionEventRecord]) -> list[HermesSubagentEvidenceRef]: | ||
| refs: list[HermesSubagentEvidenceRef] = [] | ||
| for event in events: | ||
| if event.event_type != "hermes_subagent_span": | ||
| continue | ||
| child_session_id = event.payload.get("child_session_id") | ||
| if not isinstance(child_session_id, str) or not child_session_id: | ||
| continue | ||
| status = event.payload.get("status") | ||
| refs.append( | ||
| HermesSubagentEvidenceRef( | ||
| source_artifact="atof", | ||
| subagent_session_id=child_session_id, | ||
| status=status if isinstance(status, str) and status else None, | ||
| ) | ||
| ) | ||
| return refs | ||
|
|
||
|
|
||
| def _detect_conflicts( | ||
| hermes_session_id: str, | ||
| subagent_evidence: Sequence[HermesSubagentEvidenceRef], | ||
| ) -> list[HermesTopologyConflict]: | ||
| conflicts: list[HermesTopologyConflict] = [] | ||
|
|
||
| self_referential = sorted( | ||
| {ref.subagent_session_id for ref in subagent_evidence if ref.subagent_session_id == hermes_session_id} | ||
| ) | ||
| if self_referential: | ||
| conflicts.append( | ||
| HermesTopologyConflict( | ||
| kind="self_referential_subagent", | ||
| detail=( | ||
| f"Hermes session {hermes_session_id} was reported as its own subagent -- a " | ||
| "structurally impossible parent/child identity, rendered explicit rather than " | ||
| "silently linked." | ||
| ), | ||
| evidence_refs=tuple(self_referential), | ||
| ) | ||
| ) | ||
|
|
||
| atif_ids = {ref.subagent_session_id for ref in subagent_evidence if ref.source_artifact == "atif"} | ||
| atof_ids = {ref.subagent_session_id for ref in subagent_evidence if ref.source_artifact == "atof"} | ||
| if atif_ids and atof_ids and atif_ids.isdisjoint(atof_ids): | ||
| conflicts.append( | ||
| HermesTopologyConflict( | ||
| kind="atif_atof_subagent_identity_mismatch", | ||
| detail=( | ||
| f"ATIF and ATOF independently reported non-overlapping subagent-session identities " | ||
| f"for Hermes session {hermes_session_id} -- neither source is trusted over the other; " | ||
| "both evidence sets are retained as-is." | ||
| ), | ||
| evidence_refs=tuple(sorted(atif_ids | atof_ids)), | ||
| ) | ||
| ) | ||
|
|
||
| return conflicts | ||
|
|
||
|
|
||
| def project_hermes_topology( | ||
| hermes_session_id: str, | ||
| *, | ||
| conversational: HermesArtifactInput, | ||
| atif: HermesArtifactInput, | ||
| atof: HermesArtifactInput, | ||
| verification: HermesArtifactInput, | ||
| ) -> HermesTopologyProjection: | ||
| """Compose every retained Hermes artifact for one raw session id, without merging. | ||
|
|
||
| Every input's ``session_id`` is the caller-resolved, producer-positive | ||
| join key for that artifact class (see ``HermesArtifactInput``); this | ||
| function only reads structural event evidence already fetched by the | ||
| caller (never re-queries, never infers a parent from timing/proximity). | ||
| """ | ||
| observations = { | ||
| "conversational": _observe_artifact("conversational", conversational), | ||
| "atif": _observe_artifact("atif", atif), | ||
| "atof": _observe_artifact("atof", atof), | ||
| "verification": _observe_artifact("verification", verification), | ||
| } | ||
|
|
||
| subagent_evidence: list[HermesSubagentEvidenceRef] = [] | ||
| if atif.events is not None: | ||
| subagent_evidence.extend(_atif_subagent_refs(atif.events)) | ||
| if atof.events is not None: | ||
| subagent_evidence.extend(_atof_subagent_refs(atof.events)) | ||
| subagent_evidence.sort(key=lambda ref: (ref.source_artifact, ref.subagent_session_id)) | ||
|
|
||
| unpaired: list[HermesArtifactKind] = [] | ||
| caveats: list[str] = [] | ||
| atif_available = observations["atif"].available | ||
| atof_available = observations["atof"].available | ||
| if atif_available and not atof_available: | ||
| unpaired.append("atof") | ||
| caveats.append( | ||
| f"Hermes session {hermes_session_id}: ATIF trajectory evidence exists with no sibling ATOF " | ||
| "event stream -- partial artifact-family acquisition, surfaced as visible debt, not silently " | ||
| "treated as complete." | ||
| ) | ||
| if atof_available and not atif_available: | ||
| unpaired.append("atif") | ||
| caveats.append( | ||
| f"Hermes session {hermes_session_id}: ATOF event-stream evidence exists with no sibling ATIF " | ||
| "trajectory export -- partial artifact-family acquisition, surfaced as visible debt, not " | ||
| "silently treated as complete." | ||
| ) | ||
|
|
||
| conflicts = _detect_conflicts(hermes_session_id, subagent_evidence) | ||
| caveats.extend(conflict.detail for conflict in conflicts) | ||
| for observation in observations.values(): | ||
| caveats.extend(observation.caveats) | ||
|
|
||
| return HermesTopologyProjection( | ||
| hermes_session_id=hermes_session_id, | ||
| artifacts=tuple(observations[artifact] for artifact in _ARTIFACT_ORDER), | ||
| subagent_evidence=tuple(subagent_evidence), | ||
| unpaired_artifacts=tuple(sorted(unpaired)), | ||
| conflicts=tuple(conflicts), | ||
| caveats=tuple(caveats), | ||
| ) | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "HermesArtifactInput", | ||
| "HermesArtifactKind", | ||
| "HermesArtifactObservation", | ||
| "HermesSubagentEvidenceRef", | ||
| "HermesTopologyConflict", | ||
| "HermesTopologyProjection", | ||
| "project_hermes_topology", | ||
| ] |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
New insights module isn't registered through INSIGHT_REGISTRY.
Per repo guidelines for polylogue/insights/**/*.py, insights should be registered through the descriptor-driven INSIGHT_REGISTRY (field accessors, Pydantic query models, operations methods, CLI/MCP metadata). project_hermes_topology/HermesTopologyProjection are defined as a standalone pure aggregator with no registry wiring. The PR objectives note CLI/MCP integration is deliberately deferred, but the guideline is stated as a requirement for this path regardless of the deferral — worth confirming whether registration is planned as an immediate follow-up commit in this same stack or genuinely out of scope for now.
As per coding guidelines: "polylogue/insights/**/*.py: Register insights through the descriptor-driven INSIGHT_REGISTRY, including field accessors, Pydantic query models, operations methods, and CLI/MCP metadata."
🤖 Prompt for 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.
In `@polylogue/insights/hermes_topology_projection.py` around lines 1 - 303,
Register HermesTopologyProjection in INSIGHT_REGISTRY using the
descriptor-driven integration required for insights modules. Add its field
accessors, Pydantic query model, operations methods, and CLI/MCP metadata,
wiring the existing project_hermes_topology aggregator into the registered
insight without changing its pure composition behavior.
Source: Coding guidelines
There was a problem hiding this comment.
Confirmed this against the actual registry pattern (polylogue/insights/registry.py's INSIGHT_REGISTRY) before replying: there's direct precedent for a pure, unregistered composition helper in this same package — polylogue/insights/hermes_verification_coverage.py — which this module's own docstring explicitly points to ("like hermes_verification_coverage, it is not yet wired into any CLI/MCP surface").
hermes_topology_projection.project_hermes_topology is deliberately a typed read-side composition helper at this stage, not a registered insight surface yet. Registry/CLI/MCP surfacing (field accessors, a Pydantic query model, an operations method, CLI/MCP metadata) is owned by the Hermes integration-health rollup work (Ref polylogue-fs1.15), which is the natural consumer that will actually call this projection from a real surface. Registering it now, ahead of that consumer, would add an INSIGHT_REGISTRY entry with no operations-layer caller behind it — an unconsumed registry entry rather than a genuinely surfaced insight.
If this reasoning turns out wrong once fs1.15 lands, the fix is cheap (add the descriptor then) — but doing it here would be scope creep against a design (fs1.15) that already owns this exact surfacing decision.
Ref polylogue-fs1.14, polylogue-fs1.15
|
Follow-up to the P1 (semantic reparse): tracked as bead |
Problem (CodeRabbit review on #3225, both P2): 1. hermes_topology_projection.py:132 -- _observe_artifact() defaulted the verification artifact's fidelity_status to "exact" whenever any verification events were present, silently upgrading past what hermes_verification.import_fidelity_declaration() actually declares: its retention_completeness capability is unconditionally "degraded" whenever any hermes_verification_event exists (the producer prunes events older than 30 days and caps retained events), and its correlation capability degrades whenever a row carries Hermes's own session_id="default" ambiguous-correlation fallback. 2. hermes_topology_projection.py:142 -- the ATIF branch degraded fidelity on every hermes_observer_span event, but hermes_spans._events_for_step() deliberately reuses that same generic event type for two different meanings: a genuinely unrecognized step shape (payload["shape"] == "unrecognized", real fidelity debt) and a recognized observation-only step (payload["shape"] == "observation_only", not debt). The projection was conflating the two. What changed: _observe_artifact() in polylogue/insights/hermes_topology_projection.py now (1) only counts hermes_observer_span events with shape=="unrecognized" as ATIF fidelity debt, and (2) mirrors hermes_verification's own declared degradation triggers for the verification artifact -- degrading on any hermes_verification_event (retention) or any ambiguous_correlation=True event/state row (correlation) -- instead of defaulting to "exact". Tests added in tests/unit/insights/test_hermes_topology_projection.py: - test_atif_observation_only_steps_do_not_degrade_fidelity_but_unrecognized_ones_do: asserts fidelity_status=="exact" with no caveats for an observation-only step, and "degraded" with the expected caveat for a genuinely unrecognized step. Mutation: degrading on every hermes_observer_span regardless of shape fails the first assertion. - test_verification_fidelity_preserves_declared_degradation_not_defaulted_exact: asserts fidelity_status=="degraded" for ordinary verification events (retention) and separately for an ambiguous_correlation event. Mutation: defaulting to "exact" whenever events is non-empty fails both. Verification: - devtools test tests/unit/insights/test_hermes_topology_projection.py tests/unit/sources/parsers/test_hermes_spans.py tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_live_watcher.py -- 136 passed. - devtools verify --quick -- exit 0. Ref polylogue-fs1.14 Co-Authored-By: Claude <[email protected]>
|
Coordinator merge note: CodeRabbit's four findings all triaged — both P2s fixed in 32f4ee2 with regression tests (verification fidelity preserves declared degradation incl. ambiguous-correlation; only shape==unrecognized spans count as fidelity debt); P1 acknowledged and tracked as polylogue-yqeo (post-promote targeted reprocess); registry question answered with hermes_verification_coverage.py precedent, surfacing owned by fs1.15. Composed identity scheme proven by the 2-profiles×2-artifact-families→4-sessions test; 136 focused tests + quick-gate green post-fix. Merging. |
Problem: both parse_atif_document and parse_atof_stream minted the identical observer:<hermes_session_id> provider_session_id for a given raw Hermes session id. Since sessions.session_id is computed from origin + this native id, importing an ATIF trajectory export and an ATOF event stream for the same Hermes session physically collided on one archive row -- the second ingest's content-hash full-replace silently discarded the first artifact's session_events (verified via the two real-fixture tests, which asserted the identical provider_session_id for both artifact families). What changed: hermes_spans.py now mints artifact-qualified identities (atif_session_provider_id -> observer:atif:<id>, atof_session_provider_id -> observer:atof:<id>, replacing the shared observer_session_provider_id/hermes_observer_session_id_for helpers with hermes_atif_session_id_for/hermes_atof_session_id_for). Updated every test asserting the old shared id and added a regression test proving the two artifact families no longer collide for an identical raw Hermes session id through the real dispatch/parse route. Ref polylogue-fs1.14
Problem: the fs1.14 design asks for a typed read-side composition across every independently-acquired Hermes artifact class (state.db conversational session, ATIF trajectory, ATOF event stream, verification ledger) for one raw Hermes session id -- stating per-artifact availability/fidelity, rendering an unpaired ATIF/ATOF trace as visible debt, and failing closed on a conflicting producer-reported subagent identity, without ever physically merging message/event bodies across artifacts. What changed: polylogue/insights/hermes_topology_projection.py adds project_hermes_topology, a pure aggregator (no I/O, mirrors hermes_verification_coverage.py's design) over caller-fetched SessionEventRecord rows. It composes HermesArtifactObservation per artifact (availability, event count, fidelity_status derived from structural evidence already in the event stream), extracts producer- reported subagent evidence from both ATIF (subagent_trajectories) and ATOF (hermes.subagent.* marks) as HermesSubagentEvidenceRef entries tagged with their source artifact, flags an ATIF-only or ATOF-only session as unpaired_artifacts, and renders a self-referential subagent id or a disjoint ATIF/ATOF subagent-id disagreement as an explicit HermesTopologyConflict. Output ordering is fully deterministic (sorted collections) so replay/rebuild from the same retained raw evidence reproduces identical output. Not done here (explicitly deferred, not silently assumed): physical session_links/topology_edges materialization from subagent evidence, and wiring this projection into any CLI/MCP surface -- it follows the same standalone-first precedent as hermes_verification_coverage.py (fs1.4), which shipped unit-tested before any surface consumed it. Also regenerated the topology projection docs (new module under polylogue/) via `devtools render topology-projection && devtools render topology-status`. Verification: devtools test tests/unit/insights/test_hermes_topology_projection.py (10 passed); devtools verify --quick (exit 0). Ref polylogue-fs1.14
…tion
Updates docs/hermes-operators.md's "What Polylogue cannot claim"
item 1, which previously documented the ATIF/ATOF session-id collision
as unfixed live behavior ("ATIF and ATOF do not compose when they
share a session id... verified empirically"). Marks it [Fixed,
fs1.14], updates the session-identity table to the new
observer:atif:/observer:atof: prefixes, renames the correlation-helper
references, points to the new hermes_topology_projection module, and
fixes the two stale CLI query examples that still used the old shared
observer: prefix. Also updates hermes-archival-export-contract.md's
"what is explicitly NOT done" note and the stale docstring cross-
references in hermes_verification.py (carried in the prior commit)
that named the now-renamed hermes_spans helpers.
Ref polylogue-fs1.14
…test Problem: rebasing this branch (artifact-family-qualified Hermes observer ids, observer:atif:<id> / observer:atof:<id>) onto master (which had independently gained profile qualification for the same ids via #3224, observer:<id>@PROfile-<key>) left docs/hermes-operators.md describing only the pre-#3224 behavior (helpers "stripping any @PROfile-<key> qualifier"), and left no test proving the two fixes compose rather than one silently overriding the other. What changed: - docs/hermes-operators.md: "Session identity" section and "What Polylogue cannot claim" item 1 now describe the composed scheme -- ATIF/ATOF ids are both artifact-qualified and, when profile_root is known, profile-qualified (observer:atif:<id>@PROfile-<key> / observer:atof:<id>@PROfile-<key>), and hermes_atif_session_id_for/hermes_atof_session_id_for now PRESERVE the profile qualifier rather than stripping it. Notes that hermes_verification.py's helper still strips it (deliberately out of this fix's scope, per #3224's own scope notes). - tests/unit/sources/parsers/test_hermes_spans.py: adds test_two_profiles_times_two_artifact_families_compose_to_four_distinct_sessions, which ingests both an ATIF trajectory and an ATOF stream for the same raw Hermes session id under two different profile roots and asserts 4 distinct provider_session_ids, 2 distinct parent_session_provider_id values (one per profile, shared correctly across that profile's ATIF+ATOF pair), and that the read-side hermes_atif_session_id_for/hermes_atof_session_id_for helpers resolve each profile's conversational id back to that same profile's observer sessions only. - docs/plans/topology-target.yaml, docs/topology-status.md: regenerated (devtools render topology-projection && render topology-status) to reflect the composed module set after rebase. - ruff format on the two touched test files (pre-existing formatting drift surfaced by the rebase, not new content). Verification: - devtools test tests/unit/sources/parsers/test_hermes_spans.py tests/unit/insights/test_hermes_topology_projection.py tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_live_watcher.py -- 134 passed. - devtools verify --quick -- exit 0 (ruff format/check, mypy --strict, render all --check, topology/layering/closure-matrix/manifests/ ci-workflows/doc-commands/docs-coverage/test-infra-currency/ test-clock-hygiene/pytest-timeout-overrides/degrade-loudly all ok). Ref polylogue-fs1.14 Co-Authored-By: Claude <[email protected]>
Problem (CodeRabbit review on #3225, both P2): 1. hermes_topology_projection.py:132 -- _observe_artifact() defaulted the verification artifact's fidelity_status to "exact" whenever any verification events were present, silently upgrading past what hermes_verification.import_fidelity_declaration() actually declares: its retention_completeness capability is unconditionally "degraded" whenever any hermes_verification_event exists (the producer prunes events older than 30 days and caps retained events), and its correlation capability degrades whenever a row carries Hermes's own session_id="default" ambiguous-correlation fallback. 2. hermes_topology_projection.py:142 -- the ATIF branch degraded fidelity on every hermes_observer_span event, but hermes_spans._events_for_step() deliberately reuses that same generic event type for two different meanings: a genuinely unrecognized step shape (payload["shape"] == "unrecognized", real fidelity debt) and a recognized observation-only step (payload["shape"] == "observation_only", not debt). The projection was conflating the two. What changed: _observe_artifact() in polylogue/insights/hermes_topology_projection.py now (1) only counts hermes_observer_span events with shape=="unrecognized" as ATIF fidelity debt, and (2) mirrors hermes_verification's own declared degradation triggers for the verification artifact -- degrading on any hermes_verification_event (retention) or any ambiguous_correlation=True event/state row (correlation) -- instead of defaulting to "exact". Tests added in tests/unit/insights/test_hermes_topology_projection.py: - test_atif_observation_only_steps_do_not_degrade_fidelity_but_unrecognized_ones_do: asserts fidelity_status=="exact" with no caveats for an observation-only step, and "degraded" with the expected caveat for a genuinely unrecognized step. Mutation: degrading on every hermes_observer_span regardless of shape fails the first assertion. - test_verification_fidelity_preserves_declared_degradation_not_defaulted_exact: asserts fidelity_status=="degraded" for ordinary verification events (retention) and separately for an ambiguous_correlation event. Mutation: defaulting to "exact" whenever events is non-empty fails both. Verification: - devtools test tests/unit/insights/test_hermes_topology_projection.py tests/unit/sources/parsers/test_hermes_spans.py tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_live_watcher.py -- 136 passed. - devtools verify --quick -- exit 0. Ref polylogue-fs1.14 Co-Authored-By: Claude <[email protected]>
Problem: master gained #3226 (objective-posture insight, new module + topology regen) and #3227 (hermes_verification.py profile-qualified identity: verification:<id>[@PROfile-<key>], hermes_verification_session_id_for now PRESERVES the qualifier instead of stripping it) since this branch's last rebase. Rebasing surfaced one real conflict and one silent cross-file break the rebase's textual merge did not flag: - polylogue/sources/parsers/hermes_verification.py: conflicting docstring edits (both #3227 and this branch's earlier commit touched the same observer_session_provider_id/hermes_verification_session_id_for docstrings) -- resolved to describe the composed state: profile-qualified AND correctly referencing hermes_spans's renamed atif_session_provider_id/atof_session_provider_id (this branch) instead of the retired shared observer_session_provider_id. - tests/unit/sources/parsers/test_hermes_verification.py (added by #3227, never touched by this branch's commits, so the rebase reported no conflict): test_verification_family_prefix_stays_distinguishable_from_atif_atof_observer_family imported hermes_spans.observer_session_provider_id, a name this branch retired in favor of atif_session_provider_id/atof_session_provider_id -- an ImportError, not a merge conflict, so it only surfaced by actually running the suite. Fixed to import and assert against both renamed functions (verification: stays distinguishable from BOTH observer:atif: and observer:atof:, not just the old single observer: family). Semantic composition check (per coordinator request): hermes_topology_projection.py never hardcodes a session-id shape itself -- callers resolve each artifact's session_id (see HermesArtifactInput docstring) via hermes_spans.atif_session_provider_id/atof_session_provider_id or hermes_verification.hermes_verification_session_id_for -- so the module is scheme-agnostic by construction and needed no code change. Added test_composes_with_profile_qualified_verification_ids_like_atif_and_atof in tests/unit/insights/test_hermes_topology_projection.py, which drives the REAL hermes_verification_session_id_for/hermes_identity helpers (not a hand-typed "verification:<id>" string) from a profile-qualified conversational session id and proves: the resolved verification id preserves the qualifier (not stripped, matching #3227's fix), and two different profiles resolve to two distinct, non-colliding verification session ids for the same raw Hermes session id -- exactly the guarantee ATIF/ATOF already have. docs/hermes-operators.md: "Session identity" section and item 1 updated -- previously (written before #3227 merged) claimed hermes_verification's helper "still strips" the profile qualifier and was "explicitly left out of this fix's scope"; now correctly describes it as fixed separately (polylogue-y9zx, PR #3227) using the same shared hermes_identity.py scheme. docs/plans/topology-target.yaml, docs/topology-status.md: regenerated (devtools render topology-projection && render topology-status) to reflect #3226's new objective-posture insight module -- no textual conflict during rebase, but genuinely stale without regen. Verification: - devtools test tests/unit/insights/test_hermes_topology_projection.py tests/unit/sources/parsers/test_hermes_spans.py tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_live_watcher.py tests/unit/sources/parsers/test_hermes_verification.py -- 151 passed. - devtools verify --quick -- exit 0. Ref polylogue-fs1.14 Co-Authored-By: Claude <[email protected]>
32f4ee2 to
81eb28a
Compare
## Summary Adds the missing automated actor for the MCP `judge` dispatcher's candidate queue: a policy engine plus a daemon periodic-loop trigger surface that decides which `CANDIDATE`-status assertions are auto-judgeable and calls the same storage chokepoint the MCP `judge` dispatcher uses, escalating the residue to an explicit, queryable `handoff` assertion. ## Problem Per the polylogue-800m design note (PR #3202), the MCP `judge` dispatcher lets an operator judge assertion candidates in bulk, but nothing calls it automatically. Every agent-authored candidate (pathology findings, ontology/ transform candidates, findings, ...) defaults to waiting on an explicit human decision, which the operator has said does not scale — most agent-authored annotations will never be seen by a human. ## Solution - **`polylogue/daemon/judgment_automation.py`** (new): a policy engine (`evaluate_candidate`) applies per-kind confidence thresholds (`auto_accept_min_confidence`/`auto_reject_max_confidence`) decoded from a new `[judgment_automation.policies]` config table (`parse_judgment_automation_policy`). A candidate is judged (`run_judgment_automation_sweep_once`) via the real `judge_assertion_candidates` storage chokepoint — the same one the MCP `judge` dispatcher calls — when the policy is unambiguous; every other candidate (no policy for its kind, no `confidence` value, or a confidence inside the undecided band) is escalated: a deterministic `handoff`-kind assertion pointing at the candidate is upserted so the residue is a queryable review queue, not silent limbo. - **`polylogue/daemon/cli.py`**: wires `periodic_judgment_automation_sweep` into the existing `periodic_loops` list next to `_periodic_db_optimize`/ `periodic_embedding_backlog_check`, following the established periodic- maintenance-loop pattern rather than a `DaemonConverger` stage — judgment candidates are not file/session-scoped, and `docs/retro/2026-05-24-1498-cascade.md` flags `convergence_stages.py` as due for a refactor before a 4th stage, so this keeps the bead's footprint out of that hot file entirely. - **`polylogue/config.py`**: four new layered config keys — `judgment_automation_enabled` (fail-closed bool, off by default, following the `mcp_judge_enabled` pattern), `judgment_automation_interval_s`, `judgment_automation_batch_limit`, and the raw `judgment_automation_policy` table (decoded by the owning module, same shape as `health_convergence_debt`). - **Dual capability gate**: the sweep only judges when *both* `judgment_automation_enabled` AND `mcp_judge_enabled` (polylogue-800m's independent capability boundary) are true — it exercises the same judge write authority as the MCP dispatcher, so its own opt-in must not, by itself, grant that authority. Both flags are re-read every tick (`reload_behavior="daemon-loop"`), so flipping either off in `polylogue.toml` takes effect on the next tick without a daemon restart. - Docs: `docs/configuration.md` (config key table) and `docs/daemon.md` (new "Judgment Automation" section with a worked `polylogue.toml` example). ## Verification - `devtools test tests/unit/daemon/test_judgment_automation.py tests/unit/core/test_config_inventory.py tests/unit/daemon/test_daemon_cli.py` → `183 passed` - `mypy --strict` on `polylogue/config.py polylogue/daemon/cli.py polylogue/daemon/judgment_automation.py tests/unit/daemon/test_judgment_automation.py` → `Success: no issues found in 4 source files` - `devtools verify --quick` (ruff format/check, mypy, render-all --check, topology/layering/closure-matrix/manifests/ci-workflows/doc-commands/docs-coverage/test-infra-currency/test-clock-hygiene/pytest-timeout-overrides/degrade-loudly) → `exit_code: 0` - Not run: full `devtools verify` (testmon-affected) / `--seed-testmon` — per-repo policy this is the default pre-PR baseline, but it was explicitly deferred for this lane in favor of the focused set above plus `--quick`. ## Residual risk - No real-world confidence-producing detector is wired to a `[judgment_automation.policies]` entry yet in this PR — the policy table starts empty by default, so the sweep is a bounded no-op until an operator configures at least one kind. This is intentional (config-gated OFF, fail-closed on missing policy) but means the automation has no live exercise beyond the test fixtures until an operator opts a real detector kind in. - The escalation `handoff` assertion is discoverable only via an explicit `kind=handoff` filter today (not in `ASSERTION_CLAIM_KINDS`'s default set); wiring a dedicated MCP/CLI "review queue" surface for it is left as follow-up rather than expanding this PR's scope. Ref polylogue-6qjc --------- Co-authored-by: Claude <[email protected]>
…provenance-projection' into tmp/pr3225-merge # Conflicts: # docs/topology-status.md
…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
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Fixes the Hermes ATIF+ATOF session-identity collision named in polylogue-fs1.14
and adds a typed, provenance-preserving read-side topology projection that
composes every retained Hermes artifact class (conversational state.db
session, ATIF trajectory, ATOF event stream, verification ledger) for one
raw Hermes session id without ever physically merging message/event bodies.
Problem
hermes_spans.py'sparse_atif_documentandparse_atof_streamboth mintedthe identical
observer:<hermes_session_id>provider_session_idfor agiven raw Hermes session id. Since
sessions.session_idis computed fromorigin+ this native id, importing an ATIF trajectory export and an ATOFevent stream for the same Hermes session physically collided on one
archive row: the archive's content-hash full-replace rule made the second
ingest silently discard the first artifact's
session_events. This wasdirectly, empirically documented (and left unfixed) in
docs/hermes-operators.md's "What Polylogue cannot claim" section — item 1stated "ATIF and ATOF do not compose when they share a session id," verified
by ingesting the checked-in real ATIF and ATOF fixtures into one archive and
observing only one survived. The two real-fixture tests in
test_hermes_spans.pyeven asserted the identicalprovider_session_idforboth artifact families, which is the collision made visible in test form.
Beyond the identity collision, fs1.14's design asked for a typed composition
across every Hermes artifact class stating field-level provenance (source
artifact, fidelity) and rendering an unpaired trace or a conflicting
producer-reported subagent identity as explicit, visible evidence rather
than silently resolved.
Solution
Identity fix (
polylogue/sources/parsers/hermes_spans.py): ATIF andATOF now mint artifact-qualified, non-colliding identities —
atif_session_provider_id→observer:atif:<id>,atof_session_provider_id→
observer:atof:<id>— replacing the sharedobserver_session_provider_id/
hermes_observer_session_id_forhelpers withhermes_atif_session_id_for/hermes_atof_session_id_for. Every testasserting the old shared id was updated (
test_hermes_spans.py,test_dispatch_payloads.py,test_live_watcher.py), and a new regressiontest (
test_atif_and_atof_no_longer_collide_on_one_session_identity_fs1_14)proves the two artifact families no longer collide for an identical raw
Hermes session id through the real dispatch/parse route both artifacts
actually ingest through.
Topology projection (
polylogue/insights/hermes_topology_projection.py,new module):
project_hermes_topologyis a pure aggregator (no I/O, mirrorsthe existing
hermes_verification_coverage.py/hermes_delivery_correlation.pydesign precedent) over caller-fetched
SessionEventRecordrows. It composesone
HermesArtifactObservationper artifact class (availability, eventcount, a fidelity status derived from structural evidence already present in
the event stream — e.g.
hermes_atof_unpaired_scopeevents degrade ATOF,unrecognized-shape
hermes_observer_spanevents degrade ATIF), extractsproducer-reported subagent evidence from both ATIF's
subagent_trajectoriesand ATOF's
hermes.subagent.*marks asHermesSubagentEvidenceRefentriestagged by source artifact, flags an ATIF-only or ATOF-only session as
unpaired_artifacts(visible debt), and renders a self-referential subagentid or a disjoint ATIF/ATOF subagent-identity disagreement as an explicit
HermesTopologyConflict— never silently trusting one source over theother. All output collections are sorted, so composing from the same
retained raw evidence twice reproduces byte-identical output.
Not done here (explicitly deferred, not silently assumed): physical
session_links/topology_edgesmaterialization from subagent evidenceremains out of scope — the projection surfaces evidence refs read-side, the
same discipline
hermes_spans.pyalready documents for the ATIF/ATOF ↔state-db relationship itself. Wiring this projection into any CLI/MCP
surface is also deferred, following the same standalone-first precedent
hermes_verification_coverage.py(fs1.4) already set — it shippedunit-tested before any surface consumed it.
Docs:
docs/hermes-operators.md's "What Polylogue cannot claim" item 1is updated from "unfixed, verified empirically" to "[Fixed, fs1.14]", the
session-identity table and CLI examples now show the split
observer:atif:/observer:atof:prefixes, and item 5 now mentions the newprojection's conflict detection.
docs/design/hermes-archival-export-contract.mdand stale docstring cross-references in
hermes_verification.pywere alsoupdated.
AC matrix (polylogue-fs1.14)
project_hermes_topologycomposes all four artifact classes read-side with per-artifact isolated event counts (test_per_artifact_event_counts_never_cross_contaminateproves no cross-artifact leakage); the identity-collision fix independently guarantees no duplicate/clobbered messages when both ATIF and ATOF exist for one sessiontest_projection_is_idempotent_and_deterministic_across_repeated_calls; deterministic sorted output; existingtest_atif_parse_is_idempotent_and_deterministic/test_atof_stream_is_idempotent_across_append_replay_and_keeps_scope_edgescover the parser sideunpaired_artifacts+ explicit caveat when ATIF exists without ATOF or vice versa (test_atif_present_without_atof_sibling_becomes_visible_unpaired_debtand its ATOF-mirror)HermesTopologyConflict(test_self_referential_subagent_fails_closed_as_explicit_conflict,test_disjoint_atif_atof_subagent_identities_fail_closed_as_explicit_conflict)hermes_verification_coverage.py; it is not yet wired into a CLI/MCP surface (that wiring is separate follow-up work, matching how fs1.4's verification-coverage primitive shipped)session_links/topology_edgesrow materialization from that evidence remains out of scope for this pass, consistent withhermes_spans.py's existing documented deferral of the ATIF/ATOF ↔ state-db physical mergeVerification
devtools test tests/unit/insights/test_hermes_topology_projection.py tests/unit/sources/parsers/test_hermes_spans.py tests/unit/sources/parsers/test_hermes_verification.py tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_live_watcher.py tests/unit/insights/test_hermes_verification_coverage.py→140 passed/realm/project/polylogue/.venv/bin/python -m mypy --stricton every touched/added file →Success: no issues founddevtools render topology-projection && devtools render topology-status(required — new module underpolylogue/)devtools render all --check→ exit 0, noout of syncdevtools verify --quick(ruff format/check, mypy, render all, topology/layering/closure-matrix/manifests/ci-workflows/doc-commands/docs-coverage/test-infra-currency/test-clock-hygiene/pytest-timeout-overrides/degrade-loudly) → exit 0, run twice (pre-push hook + manual)devtools verify(testmon not seeded in this fresh worktree checkout; per repo policy this is a one-time harness-level seed, not a per-PR requirement) and the broaderdevtools test tests/unitsweep (anti-pattern per repo policy — testmon/focused selection is the intended inner loop)Residual risk
tested read model waiting for a surface, matching the existing
hermes_verification_coverage.pyprecedent. A follow-up bead should wireboth into a named surface together.
session_links/topology_edges— a real physical child-session write for ATIFsubagent_trajectorieswas considered and deliberately not attempted thispass: no real
subagent_trajectoriesevidence has been observed in a liveexport yet (per
hermes_spans.py's existing fidelity notes), so committingto a session-linking schema for an unverified real shape was judged
premature. This is the same honesty boundary
hermes_spans.pyalreadydrew for the ATIF/ATOF ↔ state-db merge itself.
feature/ingest/hermes-atif-atof-topology-projectionchecked out andlocked at the same base commit with zero divergence, suggesting a possible
parallel dispatch of this same bead. I used a different branch name
(
feature/ingest/hermes-atif-atof-provenance-projection) rather thantouch that branch/worktree. The coordinator should check for a duplicate
PR before merging this one.
Ref polylogue-fs1.14
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests