Skip to content

symfonic.platform.deployment_observation_groups

deployment_observation_groups

Format distinct observation populations without treating any as turn identity.

observation_groups

observation_groups(fallback, native, dispatch, refusals)

Build the existing report's closed metadata groups and absolute counts.

Source code in src/symfonic/platform/deployment_observation_groups.py
def observation_groups(fallback, native, dispatch, refusals):
    """Build the existing report's closed metadata groups and absolute counts."""
    return {
        "fallback_event_count": sum(fallback.values()),
        "fallback_groups": [
            {"entrypoint": entry, "capability": capability, "reason_code": reason, "count": count}
            for (entry, capability, reason), count in sorted(fallback.items())
        ],
        "native_entry_count": sum(native.values()),
        "native_entry_groups": [
            {"entrypoint": entry, "count": count} for entry, count in sorted(native.items())
        ],
        "dispatch_outcome_count": sum(dispatch.values()),
        "dispatch_outcome_counts": {
            outcome: sum(count for key, count in dispatch.items() if key[0] == outcome)
            for outcome in ("native", "direct_legacy", "fallback", "approved_rejection",
                            "pre_body_failure")
        },
        "dispatch_outcome_groups": [
            {"outcome": outcome, "entrypoint": entry, "capability": capability,
             "reason_code": reason, "selected_route": route, "count": count}
            for (outcome, entry, capability, reason, route), count in sorted(dispatch.items())
        ],
        "approved_migration_refusal": "observed" if refusals else "unobserved",
        "approved_migration_refusal_count": sum(refusals.values()),
        "approved_migration_refusal_groups": [
            {"boundary": boundary, "surface": surface, "reason_code": reason,
             "approval_reference": approval, "count": count}
            for (boundary, surface, reason, approval), count in sorted(refusals.items())
        ],
    }