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
83 changes: 83 additions & 0 deletions docs/contracts/production-proofs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# P1 worker-report codecs and capture drafts

`inferrsi.benchmark.proofs` owns pure `encode_report`, `decode_report`,
`validate_report`, `project`, and `ProofProjector` ports. This is the Benchmark
codec/projector slice of the accepted capture boundary in
[#565](https://github.com/InferMatrixLab/InferRSI/issues/565#issuecomment-7063820381).
It does not implement a worker, grader predicate, baseline workload, sampler,
Harness capture lifecycle or Apps adapter. Their actual behavior and resource
pins remain prerequisites for shared production acceptance.

## Closed raw report

The frozen `fixture-grader@1` output contains exactly `schema_version: 1`,
`grader` and `samples`. The latter two are required and may be null for an
incomplete family. A non-null grader contains exactly `status` (`passed` or
`failed`) and `reasons` (portable identifiers). Samples contain the four frozen
identities A1/B1/B2/A2, baseline/candidate/candidate/baseline and rounds 1/1/2/2.
Each value is a positive canonical Decimal string with unit `ms`.

No identity, Ref, producer, control domain or cleanup assertion is accepted from
the worker. JSON whitespace is allowed; duplicate keys, floating/nonfinite
numeric tokens, invalid Unicode and unsupported versions are rejected. Encoders
use the existing canonical v1 codec. Neither encoding nor validation opens files.

## Frozen configuration and runtime inputs

Construct `ProofProjector(prepared, protocol_bytes)` before attempting execution.
It snapshots the preparation and checks the existing task/grader/recipe/rule
support and complete protocol identity using the production preparation port.
Unsupported configuration raises `ProofError` with the existing portable code.

Call `project(phase, facts, *, candidate_bytes, report_bytes)` on that object, or
use the one-shot function with `prepared` and `protocol_bytes` first. The two
phases are `preparing` and `finalizing`. Bytes are supplied by a host adapter;
this module receives no filesystem, network, process, archive or store handle.
`None` means the corresponding byte input is unavailable. An unexpected host
content type raises `TypeError` rather than becoming an evidence gap.

`CONTEXT_FIELDS` specifies a closed version-1 wire projection of existing H
facts: request/run/attempt/digest, preparation/protocol/operation/scope/candidate,
actual bound inputs and target/runtime binding, steps, started/outcome/exit code,
cleanup and leases. Unavailable terminal fields are null. The host supplies a
defensive snapshot; no shared Python business DTO is introduced.

The candidate bytes must match the actual retained input's digest, size, attempt
and capture fact. Any frozen candidate expectation also applies. Worker report
families require an actually started input-bound step with the observed entry,
revision and code digest matching the frozen recipe. Allowed control domains
must match the actual target; changing a locator does not change identity.
These checks do not authenticate a caller-provided context: H owns the context,
read capability and final producer sealing.

## Draft output and refusal

The return is `(draft_wire, proof_blobs)`. Draft wire has exactly
`schema_version`, `checks` and `errors`. Each check has the frozen check identity,
revision, subject, phase and artifact schema, plus status, reasons, `proof_key`
and source. Sources are `candidate_capture`, `worker_report`, `cleanup_capture`.
`proof_key` is null when no proof was produced. The separate map associates keys
with immutable canonical proof bytes. Errors contain a portable `code`, affected
`check_ids`, and an identifier `reason`.

The preparing phase checks actual UTF-8 bytes and drafts format-proof@1. Invalid
UTF-8 gives a failed format proof, not a host error or an invented correctness
failure. This projector does not decide whether to start a worker.

The finalizing phase projects completed grader/sample families into the existing
grader-proof@1 and samples-proof@1. Attempt/candidate/hash fields come from H
facts, never report declarations. A missing or invalid family is not_performed
without a proof. An explicit null family remains valid report syntax but emits
an `InvalidRequest` draft error with `report_family_incomplete` and its check ID;
H persists that diagnostic as a finalizing execution error after the worker ran.
Each incomplete family gets its own diagnostic. A valid grader result survives
invalid sample semantics, and
vice versa; invalid raw JSON or a foreign report envelope invalidates the report
itself. The cleanup proof comes only from observed cleanup and acquired-lease
release facts. Unknown or failed cleanup never becomes confirmed.

H must validate drafts, retain raw and derived bytes before its record commit,
compute Refs itself and seal actual producer/domain/route/attempt fields. A draft
is neither a trustworthy CheckObservation nor a committed Ref. Existing offline
assessment and V21/V22 rules remain unchanged. This slice alone cannot make a
real execution record contain matching proofs or establish complete F/C/M.
1 change: 1 addition & 0 deletions docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Effect classes used below:
| Freeze a configured P1 preparation | Python `benchmark.preparation.PreparationService.prepare`; [production prepare](contracts/production-prepare.md) | Read-only resource access / pure encoding | Verifies supplied frozen worker/resource bytes and returns a preparation, protocol and role-keyed closure; Apps separately archives them before publishing a Ref |
| Evaluate saved requests | CLI `evaluate prepare/execute/assess`; [saved-request CLI](apps-evaluate-cli.md) | Local archive/output writing; execute additionally runs the configured H target | Explicit saved request, output ID, storage and trusted runtime configuration; reuses Apps ports and results without allocating attempts, selecting feedback or retrying |
| Assess one fixed P1 record offline | Python `benchmark.assessment.assess`; [production assess](contracts/production-assess.md) | Read-only retained evidence / pure encoding | Verifies the frozen protocol, actual capture and proof bytes; returns independent claims without launching a worker or writing an archive; Apps selects the primary key and archives the result |
| Project P1 worker reports into capture drafts | Python `benchmark.proofs` codecs / `ProofProjector.project`; [proof drafts](contracts/production-proofs.md) | Pure computation | Produces proof bytes from supplied capture facts and reports; H must authenticate, retain and seal them before commit; no worker or grader execution |
| Seal a generation with frozen feedback authorization | Python `harness.generation.prepare_generation`; [opt-in feedback profile](contracts/generation-feedback-policy.md) | Local context / policy / generation-plan retention | Optional fixed policy and source record Refs authorize original scope/check proofs before provider calls. Absent-policy calls remain a trusted-host path; no automatic execution or policy-approval authentication |
| Seal host-approved generation context without a policy Ref | Python `harness.generation.prepare_generation`; [feedback boundary](contracts/generation-feedback.md) | Local context / generation-plan retention | The trusted host authorizes feedback and excludes final-only results before handoff. Without the opt-in policy Ref, H seals supplied material and does not prove feedback-policy enforcement or execute a worker |
| Visualize a recorded run or campaign | CLI `dashboard`; [dashboard](dashboard.md) | Report-generating / local read-only serving | Writes an offline HTML snapshot or serves an optional live view on loopback; does not run an agent or validate a claim |
Expand Down
Loading
Loading