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
4 changes: 3 additions & 1 deletion docs/apps-module-migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"tests/test_benchmark_cpu_smoke.py",
"tests/test_benchmark_preparation.py",
"tests/test_harness_entry_verification.py",
"tests/test_harness_generation_lineage.py",
"tests/test_result_delivery.py"
]
},
Expand Down Expand Up @@ -71,7 +72,8 @@
"tests/test_apps_module_migrations.py",
"tests/test_benchmark_assessment.py",
"tests/test_benchmark_cpu_smoke.py",
"tests/test_harness_entry_verification.py"
"tests/test_harness_entry_verification.py",
"tests/test_harness_generation_lineage.py"
]
},
{
Expand Down
10 changes: 5 additions & 5 deletions docs/contracts/generation-bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ It introduces no deadline or budget policy for existing ordinary commands.

## Remaining capability

This retention slice does not enable generation-lineage evaluation. The current
generation-chaining refusal remains in place. Future admission must separately
verify the fixed successful generation, retained candidate association, original
deadline and budget policy. Missing historical bounds cannot establish those
facts and must fail closed for that future operation.
Retention alone does not authorize generation-lineage evaluation. The separate
[same-Store CPU profile](generation-lineage.md) checks the fixed successful
generation, retained candidate association, original deadline and budget policy
before registration. Missing historical bounds cannot establish those facts and
remain a refusal for that operation. Ordinary execution and replay stay separate.
90 changes: 90 additions & 0 deletions docs/contracts/generation-lineage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Same-Store generation lineage for CPU evaluation

The restricted profile in [#584](https://github.com/InferMatrixLab/InferRSI/issues/584)
admits an evaluation of an already generated candidate through the existing
`Harness.execute` port. The host still saves the complete request and allocates
a distinct evaluation attempt. Apps forwards the original `generation_record_ref`;
H owns authorization, input capture, execution and replay. No public DTO or
record field is added.

This profile requires the same authorized RunStore and the existing trusted
local CPU evaluation target with its module root. It does not add scheduling,
automatic retries, another backend or budget-policy support.

## Admission before registration

After static request checks, H consults any existing registration first. Only
a fresh request reaches fixed preparation, target and lineage validation.
Public `execution_service.validate` has no Store authority and continues to
refuse non-null lineage. Use `Harness.execute` for Store-backed admission.

H reads the generation's specified record version through its own Store and
compares the complete RecordRef. It requires the same run and owner, a successful
finished ordinary generation, known side effects and a sealed
[original-bounds snapshot](generation-bounds.md). Historical generations without
that snapshot remain usable by their original ordinary/replay paths, but cannot
authorize a new lineage evaluation. There is no backfill or `current` fallback.

| Fixed source | Association checked by H |
| --- | --- |
| Original bounds and generation record | Original attempt/run/owner and request digest agree. The immutable generation-plan descriptor already binds registration to that original digest. |
| Original plan Ref | Read the pre-sealed H generation-plan bytes from the fixed internal slot and verify their size, SHA and v1 shape. This is not the worker's output manifest. |
| Generation record's `generation_plan` BoundInput | Exactly one verified file capture for the generation attempt, with the original expected/actual plan SHA and equal retained bytes. Its captured object locator may differ from the original plan locator. |
| Plan `output_contract.candidate_role` | Exactly one available retained artifact with that role, the generation attempt, an observed step and the declared format schema. |
| Evaluation candidate input | Its artifact namespace, complete `source_ref`, source locator and expected SHA match that original artifact; the supported snapshot is `file-v1`. |

H independently verifies retained plan/candidate bytes before registering the
evaluation. It does not parse the worker's manifest, grade the candidate, or
authenticate worker-reported CandidateDescriptor metadata. Apps' existing
candidate collection owns that parsing contract. The H guarantee here is the
original retained artifact/byte association and the fixed execution facts.

## Original limits and capture

The original deadline must not already be expired. The evaluation deadline may
be earlier or equal, never later. Comparison preserves the Timestamp contract's
nanosecond precision and does not rewrite either timestamp or request identity.
The budget scope and policy must be identical to the original snapshot; normal
local target budget admission still applies. The full original budget remains
retained separately from admission, reservations and actual usage.

At actual input capture, the authorized candidate is opened again through H's
own Store. Unrelated inputs retain their configured reader. Capture independently
checks the actual bytes against the frozen input identity. A source changed
after validation produces the existing committed `started=false` binding refusal
before any worker runs; it is not relabeled as a pre-registration failure.

Manual-candidate evaluation (`generation_record_ref=null`) keeps its existing
path. Generation and evaluation records remain distinct, and the evaluation
record keeps the original generation Ref. Execution exit status remains a fact,
not a Benchmark claim verdict.

## Errors and replay

Fresh lineage refusals occur at `validate`, before a claim or worker start:

| Condition | Existing code |
| --- | --- |
| Malformed requested RecordRef | `InvalidExecutionSpec` |
| Foreign Store authority, unsealed/unsuccessful generation, missing historical bounds or expired original deadline | `UnsupportedOperation` |
| Unknown fixed record/version | `RecordNotFound` |
| Full Ref, run/owner, plan/candidate association, deadline or budget identity mismatch | `IdentityMismatch` |
| Damaged committed record | `RecordIntegrityError` |
| Missing/inaccessible retained source | `ArtifactUnavailable` |
| Damaged bytes or malformed retained metadata | `ArtifactIntegrityError` |
| Unsupported generation-plan major version or candidate snapshot rule | `UnsupportedSchema` / `UnsupportedRuleVersion` |

The existing registered-request table takes precedence. Reusing a registered
generation attempt ID with the evaluation's different digest therefore returns
`RequestConflict` at `claim`, as explicitly accepted in
[7087203358](https://github.com/InferMatrixLab/InferRSI/issues/584#issuecomment-7087203358).
It does not become a fresh lineage refusal. An identical-digest completed replay
returns its original RecordRef before reading sources or binding a target, even
after sources disappear, the target retires or time expires. Live/unknown
registrations retain `AttemptInProgress` / `RecoveryRequired`; no new attempt
or implicit rerun is introduced.

Apps output publication remains separate from H commit: publication failure
preserves the already committed evaluation Ref and its generation association.
Replaying the saved request can publish that original result later. No execution
or evaluation verdict is manufactured to fill an unavailable artifact.
1 change: 1 addition & 0 deletions docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Effect classes used below:
| Seal a generation request before execution | Python `inferrsi.harness.generation.prepare_generation`; [original bounds](contracts/generation-bounds.md) | Local record-writing | Seals approved context, plan and original deadline/budget metadata; allocates no attempt, starts no process and does not enable generation-lineage evaluation |
| Verify a frozen preparation binding before registration | Python `inferrsi.harness.prepared_binding.verify` / `read` / `project` | Read-only / pure projection | Fixed ArtifactRef and read-only stream capability; no registration, entry resolution or execution; [binding contract](contracts/harness-prepared-binding.md) |
| Verify and execute one frozen source evaluation entry | Python `inferrsi.harness.api.Harness.execute` with trusted `LocalCpuTarget(module_root=...)` | Experiment-executing / record-writing | Fixed preparation and expected code digest; actual source captured after registration; T37 refusals start no worker; [source-entry contract](contracts/harness-entry-verification.md) |
| Evaluate one retained generated candidate | Python `inferrsi.harness.api.Harness.execute` with `generation_record_ref`; [same-Store lineage](contracts/generation-lineage.md) | Experiment-executing / record-writing | Same authorized Store, sealed successful generation and exact retained candidate; distinct attempt, original deadline/budget scope and policy; registered replay precedes fresh source reads; no worker-manifest parsing or automatic rerun |
| Capture and seal evaluation proofs | Python `Harness(..., evidence_capture=...)`; [capture contract](contracts/harness-evidence-capture.md) | Read-only capture callback / record-writing | H authorizes attempt bytes, seals actual provenance and retains drafts before one commit; ordinary mode and replay never call the observer |
| Assemble evidence capture by role | Python `apps.api.EvidenceCapture`; [host adapter](contracts/apps-evidence-capture.md) | Read-only byte assembly / injected pure projection | Reads only H-authorized candidate/report refs; no grading, producer sealing or record/archive writes; reentry is short-circuited by H |
| Replay the same saved execution request | Python `inferrsi.harness.api.Harness.execute` | Existing-state query / fixed record-reading | Same attempt and canonical digest; existing state short-circuits fresh binding/execution; [replay and original limits](contracts/harness-evaluation-replay.md) |
Expand Down
15 changes: 10 additions & 5 deletions src/inferrsi/harness/execution_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from inferrsi.contracts import json_v1
from inferrsi.harness import (
entry_code,
generation_lineage,
input_binding,
local_process,
prepared_binding,
Expand All @@ -27,7 +28,8 @@

# The ordinary CPU path preserves V05 null mode. Evaluation requires an explicit trusted
# module root, a fixed preparation binding and an actual source-entry snapshot before start.
# Registered requests replay the original facts and limits. Generation chaining is a later slice.
# Registered requests replay their original facts and limits.
# Fresh lineage admission additionally requires the same authorized RunStore.
ATTEMPT_FIELDS = (
"request_id", "run_id", "attempt_id", "owner", "target_request", "deadline_utc",
"resources", "budget", "retry_of", "retry_reason",
Expand Down Expand Up @@ -447,7 +449,7 @@ def _ordinary_path_errors(spec: Mapping) -> list[str]:
return errors


def _validate_fresh(spec, target, artifact_reader, evaluation):
def _validate_fresh(spec, target, artifact_reader, evaluation, *, store=None):
"""Validate workspace, command, fixed bytes and target support for a fresh request."""
errors = [
f"steps[{step_index}].args[{arg_index}]: contains a NUL character"
Expand All @@ -469,8 +471,8 @@ def _validate_fresh(spec, target, artifact_reader, evaluation):
unsupported = []
if evaluation and target.module_root is None:
unsupported.append("this target has no configured evaluation module root")
if spec["generation_record_ref"] is not None:
unsupported.append("generation chaining is not implemented in this slice")
if spec["generation_record_ref"] is not None and (store is None or not evaluation):
unsupported.append("generation lineage requires evaluation and its authorized Store")
request = spec["target_request"]
if (request["target_id"], request["config_revision"]) != (
target.target_id, target.config_revision
Expand All @@ -480,6 +482,9 @@ def _validate_fresh(spec, target, artifact_reader, evaluation):
raise PublicError(
"UnsupportedOperation", stage="validate", message="; ".join(unsupported)
)
if spec["generation_record_ref"] is not None:
return generation_lineage.authorize(store, spec, artifact_reader)
return artifact_reader


def validate(spec: object, target: LocalCpuTarget, *, artifact_reader=None) -> None:
Expand Down Expand Up @@ -1180,7 +1185,7 @@ def execute(
existing = store._reenter_if_registered(spec["attempt_id"], digest)
if existing is not None:
return run_store.flatten(existing, run_store.utc_now())
_validate_fresh(spec, target, artifact_reader, evaluation)
artifact_reader = _validate_fresh(spec, target, artifact_reader, evaluation, store=store)
# Another caller may have registered while the fixed preparation was read.
claimed = store.claim(attempt, digest)
if isinstance(claimed, run_store.CommittedRecord):
Expand Down
Loading
Loading