Skip to content
Merged
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
7 changes: 6 additions & 1 deletion docs/guides/result-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +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 |
| Native service-reuse campaign | Plan version 3, state version 2, frozen protocol and the retained final attempts | 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 @@ -159,6 +159,11 @@ Arbitrary files named `result.json` or `summary.json` are not guessed into these
contracts. Campaign-specific historical formats need explicit adapters; unsupported
schemas fail instead of manufacturing facts.

Service-reuse bundles list each final in `final_attempts`, with its attempt ID,
candidate, revision, verdict and indexed assessment reference. The history marks
the current final. When an observation is missing or conflicts with state, that
row identifies its cached assessment and labels it unverified.

The no-fingerprint extension uses identical `best.binding` and
`final.candidate_binding` objects in retained native records:

Expand Down
29 changes: 29 additions & 0 deletions docs/guides/service-reuse-campaigns.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,35 @@ required warmup and measurement receipts for the selection and its reference
runs under the applicable conditions, then collects performance and quality on
its own service.

### Continue after an independent FAIL

For an up-to-budget service-reuse campaign, add `--allow-final-continuation`
when starting the campaign to allow one explicit continuation. After a completed
independent FAIL with verified cleanup, `campaign status` reports
`can_continue: true` when the retained references are valid and a search round
and search time remain. If continuation is unavailable, read
`continuation_block_reason`. Use the failed final's `attempt_id` and submit a
committed candidate.

```text
inferrsi campaign round --session <campaign> --candidate <committed-project> \
--hypothesis <candidate-change> --continue-after-final <attempt-id> \
--continuation-reason <why-search-should-continue>
inferrsi campaign final --session <campaign> --reason <why-search-stopped>
```

The first continued round records the prior final and continuation reason in
the same locked admission that allocates the round. The original round cap,
deadline and final reserve apply. If admission is interrupted, use
`campaign recover` to settle the retained attempt under the usual cleanup
rules. An explicit retry of an inconclusive round uses its existing round slot.

Status and the summary list each final attempt with its candidate, verdict and
observation path. The dashboard and result bundle identify the current final
alongside the history. The latest conclusive final is current. A later
INCONCLUSIVE or interrupted attempt leaves the preceding conclusive result
available with its own observation and previously published bundle.

## Profiling a settled round

Run `inferrsi campaign profile --session <campaign> --round <round-number>` to
Expand Down
9 changes: 9 additions & 0 deletions src/inferrsi/apps/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ def _optimization_actions(stages, *, project=False):
help="Adopt a candidate only when its declared mechanism is "
"confirmed by measured breakdown/counters")
start.add_argument("--round-mode", choices=("exact", "up_to"), default="up_to")
start.add_argument(
"--allow-final-continuation", action="store_true",
help="Allow one explicit continuation after a failed up-to-budget service final",
)
else:
start.add_argument("task")
start.add_argument("--evaluation-args", required=True)
Expand Down Expand Up @@ -253,6 +257,11 @@ def _optimization_actions(stages, *, project=False):
help="Delivered path, path#item-ref, or CANNBot receipt; repeatable")
stage.add_argument("--mechanism-file", type=Path,
help="JSON mechanism with expected region/counter directions")
if project:
stage.add_argument("--continue-after-final", metavar="ATTEMPT_ID",
help="Reopen a service campaign after this failed final")
stage.add_argument("--continuation-reason",
help="Why search should continue after the failed final")
if name == "final":
stage.add_argument("--reason", help="Why the caller stopped an up-to-budget search")
if name == "recover":
Expand Down
60 changes: 42 additions & 18 deletions src/inferrsi/apps/delivery/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,36 @@ def _binding(snapshot, selected, final, *, attempt_id, protocol_digest):
)


def _service_final_attempts(snapshot, result, state, state_ref):
history = []
for index, attempt in enumerate(state["attempts"]):
if attempt.get("kind") != "final":
continue
observation, ref = snapshot.object(attempt["path"] + "/observation.json", "assessment")
retained = observation == attempt
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 = attempt.get("assessment")
verdict = value.get("verdict") if isinstance(value, dict) else None
history.append({
"attempt_id": attempt["attempt_id"],
"candidate_id": attempt.get("candidate_id"),
"revision": attempt.get("revision"),
"verdict": verdict,
"assessment_ref": assessment_ref,
"assessment_provenance": {
"kind": "retained_observation" if retained else "cached_state",
"artifact_ref": assessment_ref,
"json_pointer": "/assessment" if retained else f"/attempts/{index}/assessment",
"verification": "verified" if retained else "unverified",
},
"current": attempt == state.get("final"),
})
return history


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")
Expand All @@ -211,6 +241,7 @@ def _service_reuse(snapshot, result, plan, state, campaign, *, plan_ref, state_r
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)
or campaign.get("allow_final_continuation") != plan.get("allow_final_continuation")
):
raise ValueError("Incompatible service campaign records")
protocol, protocol_ref = snapshot.object("frozen/evaluation.json", "protocol", required=True)
Expand Down Expand Up @@ -238,37 +269,30 @@ def _service_reuse(snapshot, result, plan, state, campaign, *, plan_ref, state_r
if state.get("state") in ("completed", "blocked"):
result["export"]["kind"] = "final"
final = state.get("final")
result["final_attempts"] = _service_final_attempts(snapshot, result, state, state_ref)
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"]):
current = next((item for item in result["final_attempts"] if item["current"]), None)
if current is None:
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
assessment(result, final.get("assessment"), current["assessment_ref"],
scope="independent_final")
provenance = (current["assessment_provenance"]
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,
"attempt_id": current["attempt_id"], "revision": current["revision"],
"candidate_id": current["candidate_id"],
"protocol_ref": protocol_ref, "assessment_ref": current["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")):
retained = provenance["verification"] == "verified"
result["completion"] = {
"status": "completed",
"reason": "Service controller recorded a completed independent final" if retained else
Expand Down
11 changes: 11 additions & 0 deletions src/inferrsi/apps/delivery/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ def _sections(result):

sections.insert(0, ("Benchmark metrics", ["Metric", "Value", "Coverage / source"],
benchmark_metric_rows(result["benchmark_metrics"])))
final_attempts = result.get("final_attempts")
if final_attempts and result["execution"].get("evaluation_mode") == "service_reuse":
sections.insert(3, (
"Independent final attempts",
["Attempt", "Candidate", "Revision", "Verdict", "Assessment", "Current result"],
[
[row["attempt_id"], row["candidate_id"], row["revision"], row["verdict"],
row["assessment_provenance"], "Yes" if row["current"] else ""]
for row in final_attempts
],
))
return sections


Expand Down
7 changes: 4 additions & 3 deletions src/inferrsi/apps/delivery/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ def validate_result(value):
for key in ("baseline", "selected_candidate", "final"):
if value[key] is not None and not isinstance(value[key], dict):
raise ValueError("Invalid optional delivery object")
for key in ("sources", "gaps", "metrics", "checks", "rounds"):
if value[key] is None and key not in ("sources", "gaps"):
for key in ("sources", "gaps", "metrics", "checks", "rounds", "final_attempts"):
rows = value.get(key)
if rows is None and key not in ("sources", "gaps"):
continue
if not isinstance(value[key], list) or any(not isinstance(row, dict) for row in value[key]):
if not isinstance(rows, list) or any(not isinstance(row, dict) for row in rows):
raise ValueError("Invalid delivery collection")
if value["completion"].get("status") not in ("completed", "incomplete"):
raise ValueError("Invalid workflow completion")
Expand Down
11 changes: 10 additions & 1 deletion src/inferrsi/apps/views/optimization_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def render_service(summary):
+ str(len(summary["accepted_attempt_ids"]))
+ "</p>",
]
current_final = summary.get("current_final_attempt_id")
if current_final:
chunks.insert(2, "<p>Current final attempt: " + escape(current_final) + "</p>")
for attempt in summary["attempts"]:
execution = attempt["execution"]
profiling = attempt.get("profiling")
Expand Down Expand Up @@ -57,7 +60,13 @@ def render_service(summary):
)
+ "</tr>"
)
chunks.append("</table><ul>")
chunks.append("</table>")
if attempt["kind"] == "final":
chunks.append(
"<p>Candidate " + escape(attempt["candidate_id"])
+ " · Evidence " + escape(attempt["path"] + "/observation.json") + "</p>"
)
chunks.append("<ul>")
for stage in execution.get("steps", []):
chunks.append(
"<li>"
Expand Down
Loading
Loading