Change-detectors, tautologies, source-reading tests, redundant duplicates, mock-echo tests and dead/unrunnable tests. Per-test rationale in the lane ledger (category + reason for every removal).
57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
"""Every AIAgent construction path must attribute its execution surface.
|
|
|
|
The shared-metrics contract normalises a missing or unrecognised ``platform``
|
|
to ``unknown`` / ``other``. That is the correct behaviour for a *bounded*
|
|
schema, but it means a construction site that forgets to declare its surface
|
|
is silently mis-attributed rather than loudly broken: fleet telemetry then
|
|
reports "unknown" for real, attributable traffic.
|
|
|
|
These are contract tests between two pieces of data -- the surfaces the
|
|
contract accepts, and the surface each construction path actually declares --
|
|
not snapshots of any current value.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from hermes_cli.observability import shared_metrics_contract as contract
|
|
|
|
|
|
|
|
|
|
def test_acp_sessions_are_interactive():
|
|
"""An editor session is a human at a keyboard, like cli/tui/desktop."""
|
|
fields = contract.task_start_fields({"platform": "acp"})
|
|
assert fields["entrypoint"] == "interactive"
|
|
assert fields["execution_surface"] == "acp"
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"platform",
|
|
["cli", "tui", "desktop", "batch", "acp", "api_server", "cron", "telegram"],
|
|
)
|
|
def test_declared_platforms_resolve_to_a_named_surface(platform):
|
|
"""No production construction path should resolve to unknown/other.
|
|
|
|
'unknown' must mean "this run genuinely could not be attributed", not
|
|
"a construction site forgot to say who it was".
|
|
"""
|
|
surface = contract.execution_surface({"platform": platform})
|
|
assert surface not in {"unknown", "other"}, (
|
|
f"platform={platform!r} resolves to {surface!r}; a real surface is being "
|
|
"folded into the catch-all bucket"
|
|
)
|
|
|
|
|
|
def test_unattributed_runs_still_report_unknown():
|
|
"""The catch-all must survive: a genuinely undeclared run is 'unknown'.
|
|
|
|
This is the counterpart to the tests above -- fixing attribution must not
|
|
be achieved by inventing a default that hides real gaps.
|
|
"""
|
|
assert contract.execution_surface({}) == "unknown"
|
|
assert contract.task_start_fields({})["entrypoint"] == "unknown"
|