Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# A session started by an older runtime keeps its exact bytes; its plan pins file hashes.
/tests/fixtures/optimization-session/pre-infra-removal-session/** -text
/tests/fixtures/optimization-session/pre-trials-rename-session/** -text
/tests/fixtures/optimization-session/pre-recovery-closure-session/** -text whitespace=cr-at-eol
# Reusable guidance is editable text, not a frozen evidence bundle.
/evidence/README.md text eol=lf
/evidence/_template/** text eol=lf
Expand Down
16 changes: 12 additions & 4 deletions docs/benchmarks/optimization-benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,18 @@ is retained separately from the per-round cumulative series. These are labelled
caller exports. Monetary cost remains unknown.

For an interrupted coordinator, run `session recover --session <directory>`.
It collects the existing execution record and task output and settles the same
attempt. Recovery performs no new candidate execution. If the execution record
is unavailable, inspect the original process and resource cleanup before further
action. Recovery also regenerates a summary from already settled state.
Recovery uses the existing execution receipt and task output to settle the same
attempt. An interrupted round without a complete result retains its candidate and
launch evidence, uses one planned round, and records `INCONCLUSIVE`. If final
evaluation is interrupted, inspect the retained attempt before explicitly running
`final` again within the original deadline.

When a launch has no cleanup receipt, Linux recovery can check its recorded process
group from the same boot and PID namespace. A live or unconfirmed launch blocks
further execution. After inspecting and cleaning up every unconfirmed process and
resource, use `recover --confirm-domain-empty` to record that confirmation. Recovery
refuses confirmation while it can observe a live group. A settled session can also
regenerate its summary with `recover`.

## Ownership and future automatic Agent launch

Expand Down
7 changes: 4 additions & 3 deletions docs/guides/result-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ remain null without accounting observations; elapsed wall time is insufficient.
| Input | Authoritative facts | Deliberate gaps |
| --- | --- | --- |
| Native project / Benchmark | Plan, campaign, state, digest-bound observations/execution/evidence and retained code; labelled cached history if observations are lost | Cached history cannot verify delivery; summaries cannot substitute for final |
| Native service-reuse campaign | Plan version 3, state version 2, frozen protocol and retained final observation with labelled cached history if the observation is lost or conflicts | Delivery acceptance requires a separate digest-bound run and configuration |
| Historical version 1 `summary.json` | Recorded final assessment and reported completion | No reconstructed rounds, independent final, binding or usage coverage |
| Legacy run directory | `run.lock.json`, `status.json`, `evaluation.json`; paired single-experiment median | No invented iterative rounds/final or generalized L4 claim |
| Apps `result.json` | Validated AppsResultV1, explicitly selected primary claim, fixed refs, all original claims | Operation success is not campaign completion; storage is not implicitly mounted/fetched |
Expand All @@ -173,9 +174,9 @@ Revision is a full 40- or 64-character lowercase hexadecimal identity. Both fixe
documents must verify and record that `candidate_revision`. The run also records
the identical `configuration_ref`, final `attempt_id` and frozen `protocol_digest`.
Matching names alone are insufficient. This alternative cannot override contradictory
file fingerprints. [Service-reuse campaigns](service-reuse-campaigns.md) can
supply revision bindings. The exporter's verification is limited to the
retained run and configuration documents in this path.
file fingerprints. The exporter's verification is limited to the retained run
and configuration documents in this path. [Service-reuse campaigns](service-reuse-campaigns.md)
record revisions in their native format, which has no such digest-bound pair.

## Artifact index and publication

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ extend-exclude = [
"tests/fixtures/legacy",
"tests/fixtures/optimization-session/pre-infra-removal-session",
"tests/fixtures/optimization-session/pre-trials-rename-session",
"tests/fixtures/optimization-session/pre-recovery-closure-session",
]

[tool.ruff.lint]
Expand Down
5 changes: 5 additions & 0 deletions src/inferrsi/apps/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ def _optimization_actions(stages, *, project=False):
help="JSON mechanism with expected region/counter directions")
if name == "final":
stage.add_argument("--reason", help="Why the caller stopped an up-to-budget search")
if name == "recover":
stage.add_argument(
"--confirm-domain-empty", action="store_true",
help="Attest that the interrupted optimization attempt has no live processes",
)
if name in ("round", "final"):
stage.add_argument("--usage-export", type=Path)
if project and name in ("round", "baseline", "refresh-references"):
Expand Down
150 changes: 131 additions & 19 deletions src/inferrsi/apps/delivery/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,102 @@ def _binding(snapshot, selected, final, *, attempt_id, protocol_digest):
)


def _service_reuse(snapshot, result, plan, state, campaign, *, plan_ref, state_ref):
"""Report the service controller's retained assessment without re-running it."""
settings = plan.get("evaluation_settings")
protocol_id = settings.get("protocol_id") if isinstance(settings, dict) else None
if (
type(plan.get("schema_version")) is not int or plan["schema_version"] != 3
or type(state.get("schema_version")) is not int or state["schema_version"] != 2
or plan.get("evaluation_mode") != "service_reuse"
or campaign.get("evaluation_mode") != "service_reuse"
or not isinstance(protocol_id, str) or not protocol_id
or state.get("protocol_id") != protocol_id or campaign.get("protocol_id") != protocol_id
or campaign.get("ranking_policy") != plan.get("ranking_policy")
or campaign.get("diagnosis_required", False) != plan.get("diagnosis_required", False)
):
raise ValueError("Incompatible service campaign records")
protocol, protocol_ref = snapshot.object("frozen/evaluation.json", "protocol", required=True)
if protocol != settings:
raise ValueError("Retained service protocol and plan disagree")
result["campaign"].update(
id=campaign.get("campaign_id"), task_kind=plan.get("task_source"), task=plan.get("task"),
plan_ref=plan_ref,
acceptance_basis={"protocol_id": protocol_id, "protocol_ref": protocol_ref},
)
result["execution"] = {
"namespace": "inferrsi.harness.optimization",
"evaluation_mode": "service_reuse",
"state": state.get("state"),
"completed_rounds": sum(row.get("terminal") is True for row in state["rounds"]),
"round_limit": plan.get("round_limit"),
"started_at": timestamp(state.get("started_at")),
}
for field, candidate in (("baseline", state.get("initial_reference")),
("selected_candidate", state.get("best"))):
if candidate:
result[field] = {
key: candidate.get(key) for key in ("candidate_id", "revision", "kind")
}
if state.get("state") in ("completed", "blocked"):
result["export"]["kind"] = "final"
final = state.get("final")
if final is None:
gap(result, "FINAL_NOT_RUN", "final_acceptance", "Independent final evaluation is absent")
return
if (not isinstance(final, dict) or final.get("kind") != "final"
or final not in state["attempts"]):
raise ValueError("Service final is missing from committed attempts")
observation, ref = snapshot.object(final["path"] + "/observation.json", "assessment")
retained = observation == final
if not retained:
gap(result, "CACHED_ASSESSMENT_UNVERIFIED", ref,
"The retained final is unavailable or differs from committed service state")
assessment_ref = ref if retained else state_ref
value = final.get("assessment")
assessment(result, value, assessment_ref, scope="independent_final")
provenance = {
"kind": "retained_observation" if retained else "cached_state",
"artifact_ref": assessment_ref,
"json_pointer": "/assessment" if retained else "/final/assessment",
"verification": "verified" if retained else "unverified",
} if result["acceptance"]["status"] == "assessed" else None
result["acceptance"]["assessment_provenance"] = provenance
result["final"] = {
"attempt_id": final.get("attempt_id"), "revision": final.get("revision"),
"protocol_ref": protocol_ref, "assessment_ref": assessment_ref,
"assessment_provenance": provenance,
"binding": {"verified": False, "kind": None},
}
gap(result, "CANDIDATE_BINDING_UNVERIFIED", "final_acceptance",
"Delivery acceptance requires a digest-bound run and configuration")
if (state.get("state") == "completed" and state.get("pending") is None
and result["acceptance"]["verdict"] in ("PASS", "FAIL")):
result["completion"] = {
"status": "completed",
"reason": "Service controller recorded a completed independent final" if retained else
"Service controller recorded a completed independent final in unverified cached state",
}


def iterative(snapshot, result):
plan, plan_ref = snapshot.object("plan.json", "plan", required=True)
state, state_ref = snapshot.object("state.json", "control", required=True)
campaign, campaign_ref = snapshot.object("campaign.json", "campaign", required=True)
result["sources"] = [
{"artifact_ref": ref, "type": kind, "revision": snapshot.entries[ref]["source_revision"]}
for ref, kind in (
(plan_ref, "plan"),
(state_ref, "optimization_state"),
(campaign_ref, "campaign"),
)
]
if (plan.get("schema_version") == 3 or plan.get("evaluation_mode") == "service_reuse"
or campaign.get("evaluation_mode") == "service_reuse"):
_service_reuse(
snapshot, result, plan, state, campaign, plan_ref=plan_ref, state_ref=state_ref,
)
return
if (
type(plan.get("schema_version")) is not int
or plan["schema_version"] not in (1, 2)
Expand All @@ -220,14 +312,6 @@ def iterative(snapshot, result):
task=plan.get("task"),
instructions_ref="source:frozen/TASK.md",
)
result["sources"] = [
{"artifact_ref": ref, "type": kind, "revision": snapshot.entries[ref]["source_revision"]}
for ref, kind in (
(plan_ref, "plan"),
(state_ref, "optimization_state"),
(campaign_ref, "campaign"),
)
]
frozen_refs = [
snapshot.file("frozen/" + name, "protocol", expected)
for name, expected in plan["frozen_files"].items()
Expand Down Expand Up @@ -296,7 +380,7 @@ def iterative(snapshot, result):
if (
not isinstance(value, dict)
or value.get("status")
not in ("completed", "candidate_failure", "infrastructure_failure")
not in ("completed", "candidate_failure", "infrastructure_failure", "interrupted")
or value.get("verdict") not in ("PASS", "FAIL", "INCONCLUSIVE")
):
value = None
Expand All @@ -322,11 +406,22 @@ def iterative(snapshot, result):
if record.get("candidate_sha256")
else None
)
evidence_refs = [
snapshot.file(
interrupted = (value or {}).get("status") == "interrupted"
execution = historical.get("execution") or {}
if interrupted:
recovery = historical.get("recovery")
evidence_refs = []
if (isinstance(recovery, dict) and isinstance(recovery.get("path"), str)
and isinstance(recovery.get("sha256"), str)):
evidence_refs.append(snapshot.file(
recovery["path"], "recovery", recovery["sha256"]
))
else:
gap(result, "RECOVERY_EVIDENCE_MISSING", ref, "Recovery evidence is unavailable")
else:
evidence_refs = [snapshot.file(
directory + "/execution/execution.json", "execution", record.get("execution_sha256")
)
]
)]
for name, expected in (value or {}).get("evidence_files", {}).items():
evidence_refs.append(snapshot.file(directory + "/" + name, "measurement", expected))
usage_source = (record.get("observations") or {}).get("usage_source")
Expand Down Expand Up @@ -394,21 +489,34 @@ def iterative(snapshot, result):
"knowledge_refs": record.get("knowledge_refs"),
"knowledge_attribution": "agent_declared",
"change_summary": record.get("change_summary"),
"execution_state": historical.get("execution", {}).get("status"),
"execution_returncode": historical.get("execution", {}).get("returncode"),
"execution_state": "interrupted" if interrupted else execution.get("status"),
"execution_returncode": execution.get("returncode"),
"assessment_ref": assessment_ref,
"assessment_provenance": provenance if value else None,
"verdict": (value or {}).get("verdict"),
"reason": (value or {}).get("reason"),
"score": (value or {}).get("score"),
"metric_refs": list(range(metric_start, len(result["metrics"]))),
"selection_decision": "retained"
if best_after.get("candidate_id") == (record.get("candidate_id"))
else "not_retained",
"selection_decision": (
"interrupted" if interrupted else "retained"
if best_after.get("candidate_id") == record.get("candidate_id")
else "not_retained"
),
"best_candidate": best_after,
"best_score": best_after.get("score"),
}
)
for record in state.get("final_attempts", []):
directory = record["path"]
recovery = record["recovery"]
result.setdefault("final_attempts", []).append({
"attempt_id": directory.rsplit("/", 1)[-1],
"status": "interrupted",
"assessment_ref": snapshot.file(
directory + "/observation.json", "assessment", record["observation_sha256"]
),
"recovery_ref": snapshot.file(recovery["path"], "recovery", recovery["sha256"]),
})
if pending := state.get("pending"):
result["rounds"].append(
{
Expand Down Expand Up @@ -441,6 +549,10 @@ def iterative(snapshot, result):
"started_at": timestamp(state.get("started_at")),
"ended_at": timestamp(state.get("settled_at")),
}
if gate := state.get("cleanup_unconfirmed"):
result["execution"]["cleanup_unconfirmed"] = snapshot.file(
gate["path"], "recovery", gate["recovery_sha256"]
)
rounds_complete = (
len(rounds) == plan["round_limit"]
if plan["round_mode"] == "exact"
Expand All @@ -450,7 +562,7 @@ def iterative(snapshot, result):
rounds_complete
and final_value is not None
and final_value.get("status") in ("completed", "candidate_failure")
and final_observation.get("execution", {}).get("status") in ("completed", "failed")
and (final_observation.get("execution") or {}).get("status") in ("completed", "failed")
and state.get("pending") is None
)
result["completion"] = {
Expand Down
19 changes: 15 additions & 4 deletions src/inferrsi/apps/views/dashboard_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,12 +749,16 @@ def _managed_dashboard(root: Path, campaign: dict) -> dict:
gain = assessment.get("improvement_pct")
if gain is None and speedup is not None:
gain = (speedup - 1) * 100
decision = ("adopted" if record["best_after"].get("candidate_id") == candidate_id
recovery = record.get("recovery")
decision = ("interrupted" if recovery else
"adopted" if record["best_after"].get("candidate_id") == candidate_id
and record["best_after"]["kind"] == "candidate" else "rejected")
facts = file_ref(root, root / record["path"] / "execution/execution.json", "execution")
facts = (file_ref(root, root / recovery["path"], "recovery") if recovery else
file_ref(root, root / record["path"] / "execution/execution.json", "execution"))
judged = file_ref(root, root / record["path"] / "observation.json", "assessment")
row.update(
run_id=Path(record["path"]).name, state=record["execution"]["status"],
run_id=Path(record["path"]).name,
state="interrupted" if recovery else record["execution"]["status"],
status_state="present", evaluation_state="present", verdict=assessment["verdict"],
quality="failed" if assessment.get("quality_passed") is False else
"passed" if assessment.get("quality_passed") is True else "not_recorded",
Expand All @@ -768,7 +772,8 @@ def _managed_dashboard(root: Path, campaign: dict) -> dict:
direction=(metrics["direction"] if metrics.get("direction") in (
"minimize", "maximize") else plan["selection"]["direction"]),
decision=decision,
outcome="quality_failed" if assessment.get("quality_passed") is False else
outcome="interrupted" if recovery else
"quality_failed" if assessment.get("quality_passed") is False else
"unverified", # No synthetic environment qualification or noise estimate.
artifacts={**row["artifacts"], "execution": facts, "assessment": judged,
"status": facts, "evaluation": judged},
Expand Down Expand Up @@ -797,6 +802,12 @@ def _managed_dashboard(root: Path, campaign: dict) -> dict:
displayed_summary["final_reference"] = (
file_ref(root, root / state["final"]["path"] / "observation.json", "final_assessment")
if state["final"] else None)
if attempts := state.get("final_attempts"):
displayed_summary["interrupted_finals"] = [
file_ref(root, root / record["recovery"]["path"], "recovery") for record in attempts
]
if gate := state.get("cleanup_unconfirmed"):
displayed_summary["cleanup_unconfirmed"] = file_ref(root, root / gate["path"], "recovery")
return {
"campaign_id": sanitized_text(campaign["campaign_id"]), "synthetic": False,
"rounds": rounds, "rounds_state": "present", "corrupt_round_lines": [],
Expand Down
4 changes: 3 additions & 1 deletion src/inferrsi/apps/workflows/benchmark_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,9 @@ def _trial_result(root, plan, trial, host, payload, *, workspace, host_error=Non
"knowledge_attribution": "agent_declared; delivery is not proof of use",
"speedup": assessment.get("speedup", assessment.get("score")),
"best_speedup": record["best_after"]["score"], "quality": assessment["verdict"],
"adopted": record["best_after"].get("candidate_id") == record["candidate_id"],
"assessment_status": assessment["status"],
"adopted": (assessment["status"] != "interrupted" and
record["best_after"].get("candidate_id") == record["candidate_id"]),
})
if (host["state"] != "completed" or not delivery["acceptance"]["delivery_accepted"]
or delivery["completion"]["status"] != "completed"):
Expand Down
Loading
Loading