Implement credentialed live hardening workplan

This commit is contained in:
2026-05-19 03:51:51 +02:00
parent b85f4c02f4
commit 1ccbab5c04
14 changed files with 906 additions and 37 deletions

View File

@@ -4,7 +4,15 @@ from pathlib import Path
from phase_memory.adapters import InMemorySemanticIndex
from phase_memory.contracts import graph_from_markitect
from phase_memory.evaluation import EVALUATION_REPORT_SCHEMA, EVALUATION_TREND_SCHEMA, evaluation_threshold_report, evaluation_trend_artifact
from phase_memory.evaluation import (
EVALUATION_REPORT_SCHEMA,
EVALUATION_TREND_HISTORY_SCHEMA,
EVALUATION_TREND_SCHEMA,
evaluation_threshold_report,
evaluation_trend_artifact,
load_evaluation_trend_history,
write_evaluation_trend_history,
)
from phase_memory.models import ActivationPlan, MemoryPath
from phase_memory.retrieval import activation_quality_report, select_event_path
from phase_memory.runtime import PhaseMemoryRuntime
@@ -126,6 +134,31 @@ def test_evaluation_trend_artifact_tracks_threshold_and_metric_deltas() -> None:
assert trend["diagnostics"][0]["code"] == "evaluation_metric_regressed"
def test_evaluation_trend_history_persists_without_duplicate_runs(tmp_path) -> None:
data = json.loads((FIXTURES / "evaluation-scenarios.json").read_text(encoding="utf-8"))
report = evaluation_threshold_report(data)
first = evaluation_trend_artifact(
report,
run_metadata={"run_id": "first", "created_at": "2026-05-19T00:00:00+00:00"},
)
second = evaluation_trend_artifact(
report,
previous_report=report,
run_metadata={"run_id": "second", "created_at": "2026-05-20T00:00:00+00:00"},
)
path = tmp_path / "evaluation-trend-history.json"
history = write_evaluation_trend_history(path, first)
history = write_evaluation_trend_history(path, first)
history = write_evaluation_trend_history(path, second)
loaded = load_evaluation_trend_history(path)
assert history["schema_version"] == EVALUATION_TREND_HISTORY_SCHEMA
assert loaded["count"] == 2
assert loaded["latest_artifact_id"] == second["id"]
assert "policy_denial_count" in loaded["metric_keys"]
def _activation_plan(response):
data = response["data"]["activation_plan"]
return ActivationPlan(