Implement credentialed drill packaging workplan
This commit is contained in:
parent
022cd8d37e
commit
6e0372d21a
23 changed files with 924 additions and 43 deletions
|
|
@ -10,8 +10,10 @@ from .contracts import graph_from_markitect
|
|||
from .models import Diagnostic, MemoryPath
|
||||
from .retrieval import activation_quality_report, select_event_path
|
||||
from .runtime import PhaseMemoryRuntime
|
||||
from .utils import stable_digest, utc_now_iso
|
||||
|
||||
EVALUATION_REPORT_SCHEMA = "phase_memory.evaluation.threshold_report.v1"
|
||||
EVALUATION_TREND_SCHEMA = "phase_memory.evaluation.trend_artifact.v1"
|
||||
|
||||
DEFAULT_THRESHOLDS = {
|
||||
"policy_denial_count": 1,
|
||||
|
|
@ -65,6 +67,54 @@ def evaluation_threshold_report(data: dict[str, Any], *, thresholds: dict[str, f
|
|||
}
|
||||
|
||||
|
||||
def evaluation_trend_artifact(
|
||||
report: dict[str, Any],
|
||||
*,
|
||||
previous_report: dict[str, Any] | None = None,
|
||||
run_metadata: dict[str, Any] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
run_metadata = {
|
||||
"created_at": utc_now_iso(),
|
||||
**dict(run_metadata or {}),
|
||||
}
|
||||
metrics = dict(report.get("metrics") or {})
|
||||
thresholds = dict(report.get("thresholds") or {})
|
||||
previous_metrics = dict((previous_report or {}).get("metrics") or {})
|
||||
threshold_deltas = {
|
||||
key: round(float(metrics.get(key) or 0) - float(threshold), 4)
|
||||
for key, threshold in sorted(thresholds.items())
|
||||
}
|
||||
metric_deltas = {
|
||||
key: round(float(value or 0) - float(previous_metrics.get(key) or 0), 4)
|
||||
for key, value in sorted(metrics.items())
|
||||
if key in previous_metrics
|
||||
}
|
||||
diagnostics = [dict(item) for item in report.get("diagnostics", ())]
|
||||
for key, delta in metric_deltas.items():
|
||||
if delta < 0:
|
||||
diagnostics.append(
|
||||
Diagnostic(
|
||||
"warn",
|
||||
"evaluation_metric_regressed",
|
||||
"Evaluation metric declined from the previous report.",
|
||||
key,
|
||||
{"delta": delta, "current": metrics.get(key), "previous": previous_metrics.get(key)},
|
||||
).to_dict()
|
||||
)
|
||||
artifact_id = f"evaluation-trend:{stable_digest([run_metadata, metrics, thresholds, previous_metrics])}"
|
||||
return {
|
||||
"schema_version": EVALUATION_TREND_SCHEMA,
|
||||
"id": artifact_id,
|
||||
"valid": not any(item.get("severity") == "error" for item in diagnostics),
|
||||
"run": run_metadata,
|
||||
"metrics": metrics,
|
||||
"thresholds": thresholds,
|
||||
"threshold_deltas": threshold_deltas,
|
||||
"metric_deltas": metric_deltas,
|
||||
"report": report,
|
||||
"previous_report_id": (previous_report or {}).get("id", ""),
|
||||
"diagnostics": diagnostics,
|
||||
}
|
||||
def _policy_scenario(scenario: dict[str, Any]) -> dict[str, Any]:
|
||||
runtime = PhaseMemoryRuntime()
|
||||
response = runtime.plan_activation(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue