feat(perception): stabilize pre-capture methodology
This commit is contained in:
@@ -10,6 +10,7 @@ from fastapi import APIRouter, HTTPException
|
||||
from fastapi.routing import APIRoute
|
||||
from pydantic import ValidationError
|
||||
|
||||
from k1link.web.compute_contour_api import default_compute_contour
|
||||
from k1link.web.system_telemetry_api import (
|
||||
EXPECTED_NODE_ID,
|
||||
WorkerConnectionProfile,
|
||||
@@ -17,6 +18,7 @@ from k1link.web.system_telemetry_api import (
|
||||
WorkerProfileStore,
|
||||
WorkerTelemetryService,
|
||||
_agent_raw_document,
|
||||
_profile_from_compute_contour,
|
||||
_ssh_arguments,
|
||||
build_system_telemetry_router,
|
||||
)
|
||||
@@ -272,6 +274,23 @@ def test_worker_telemetry_prefers_ndc_container_names_during_migration(
|
||||
assert triton["canonical_name"] == "ndc-mission-core-triton"
|
||||
|
||||
|
||||
def test_worker_telemetry_history_keeps_one_row_per_agent_observation(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
service = WorkerTelemetryService(
|
||||
WorkerProfileStore(tmp_path / "system"),
|
||||
lambda _: _probe(),
|
||||
cache_seconds=0,
|
||||
)
|
||||
|
||||
first = service.snapshot(10)
|
||||
second = service.snapshot(10)
|
||||
|
||||
assert len(first["history"]) == 1
|
||||
assert len(second["history"]) == 1
|
||||
assert second["history"][0]["observed_at_utc"] == "2026-07-27T12:00:00Z"
|
||||
|
||||
|
||||
def test_agent_metrics_are_mapped_to_the_existing_product_contract() -> None:
|
||||
document = _agent_raw_document(
|
||||
{
|
||||
@@ -340,6 +359,25 @@ def test_agent_metrics_are_mapped_to_the_existing_product_contract() -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_compute_contour_maps_to_worker_identity_without_singleton_defaults() -> None:
|
||||
contour = default_compute_contour().model_copy(
|
||||
update={
|
||||
"contour_id": "field-worker",
|
||||
"agent_id": "field-agent",
|
||||
"display_name": "Field Worker",
|
||||
"expected_node_id": "FIELD-01",
|
||||
"address": "192.0.2.25",
|
||||
}
|
||||
)
|
||||
|
||||
profile = _profile_from_compute_contour(contour)
|
||||
|
||||
assert profile.profile_id == "field-worker"
|
||||
assert profile.display_name == "Field Worker"
|
||||
assert profile.expected_node_id == "FIELD-01"
|
||||
assert profile.address == "192.0.2.25"
|
||||
|
||||
|
||||
def test_profile_apply_fails_closed_on_wrong_node_and_keeps_old_profile(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user