Skip to content

Seal Harness generation inputs before execution registration - #475

Draft
zengchuang-hw wants to merge 1 commit into
InferMatrixLab:mainfrom
zengchuang-hw:codex/harness-447-delivery-seal
Draft

zengchuang-hw wants to merge 1 commit into
InferMatrixLab:mainfrom
zengchuang-hw:codex/harness-447-delivery-seal

Conversation

@zengchuang-hw

@zengchuang-hw zengchuang-hw commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Governing issue and proposal

Refs #447
Refs #371

This draft implements the proposed pre-registration retention transaction from the storage handoff for Harness owner review. The current Claim.commit requires the final request digest to register the attempt. V24 computes that digest after binding the retained generation manifest.

  • inferrsi.harness.generation.prepare_generation calls the injected Apps ContextProvider, verifies the actual bytes and commits them with the delivery metadata in RunStore. It hands the committed delivery to CandidateProvider, commits the resulting GenerationManifest and returns the final ExecutionSpec with its generation_plan input.
  • Pre-registration slots are keyed by attempt and role. A read opens only the committed stored bytes and verifies their identity. A retry with the same data reuses the slot. Conflicting data for the same attempt is refused. Normal execute registers the original attempt with the final spec digest.
  • The production evaluation leg remains dependent on task: Harness evaluation-mode CPU execute for Apps #429, task: Benchmark production prepare and frozen resource closure #430 and task: Benchmark production offline assess for Apps #434. The CPU test in this draft runs the generation leg from actual packaged Knowledge through Apps, the SQLite RunStore, the ordinary CPU executor and Apps candidate collection.

Verification

Five focused tests passed. They cover failure before staging and after staging but before commit, no visible delivery/manifest on those failures, cross-process reread of the delivered bytes and pins, successful CPU execution, replay of the original attempt, immutable delivery and retry after a manifest commit failure. The broader Windows regression on cc9b2206 passed with 127 tests and 43 subtests, with two POSIX-only skips. Repository Ruff and the staged diff check passed.

Signed-off-by: zengchuang <zengchuang3@huawei.com>
Agent-assisted-by: Codex (author)

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One recovery case where a sealed delivery is not reused on retry.

)
attempt_id = attempt["attempt_id"]
try:
draft = context_provider.collect(deepcopy(context_request))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could a retry after a failed manifest commit resume from the committed delivery instead of collecting Knowledge again? I reproduced the same unpinned request failing with RequestConflict after its Knowledge revision changed, even though the original sealed bytes and pins were still readable. Please bind the request identity to the committed slot, reuse that delivery on a matching retry, and keep rejecting a genuinely different request.

@Dong1017

Copy link
Copy Markdown
Collaborator

Posted by an agent on behalf of @Dong1017 (incremental review only; david6666666's retry/RequestConflict point on generation.py:33 is not repeated).

No verdict on the design; two concrete findings on the sealing guarantee at head cc9b2206.

Blocker

  1. generation_inputs is only immutable against UPDATE, not DELETE + INSERT. _GENERATION_SCHEMA (src/inferrsi/harness/run_store.py, the two statements after L107) creates generation_inputs with a PRIMARY KEY (attempt_hash, role) and one BEFORE UPDATE trigger. There is no BEFORE DELETE trigger, unlike records_no_delete and attempts_no_delete in _SCHEMA (L95, L97), which exist for exactly this reason. After a sealed delivery, a DELETE followed by an INSERT of a different sha256/data for the same (attempt_hash, role) succeeds. I checked the DDL directly (SQLite 3, same two statements, no application code): DELETE FROM generation_inputs WHERE role='delivered-context' leaves 0 rows, and re-inserting the same primary key with different bytes succeeds. _seal_generation_input guards the application path (it only INSERTs when the row is absent and compares tuple(row) != values otherwise), so this needs a direct SQLite writer or any future code path that deletes; the point of the trigger set on the other tables is that immutability must not depend on the writer behaving. The _GENERATION_SCHEMA statements also use IF NOT EXISTS, so an existing store that somehow lost the trigger is not repaired. Please add generation_inputs_no_delete and, if the intent is that a store's generation inputs are append-only like records, say so in the stage contract.

Optional

  1. A failed generation-plan commit leaves a committed delivery that a later final cannot use, and no test covers the operator path out. test_manifest_commit_failure_keeps_delivery_without_registering_execution asserts that the delivery survives and that read_delivered_context finds it, but the attempt then cannot be re-prepared with a different plan (the row comparison raises RequestConflict), and re-preparing with the same plan reuses the same delivery, which is what david's point covers. Worth stating in the docstring or a test that the supported recovery is retry with the identical inputs, so a future reader does not add a "reset" helper.

Checking scope: read the full diff of generation.py, run_store.py and tests/test_harness_generation_seal.py at cc9b2206, origin/main's _SCHEMA and the Apps _plan_generation contract, and reproduced the DELETE/INSERT behaviour against the DDL in a scratch SQLite database. Did not run the repository test suite and did not exercise prepare_generation against a real store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants