Skip to content

harness: add bounded P1 Indexer Evolver loop, delivery-boundary and recovery checks (P1-S2) - #888

Draft
fake0fan wants to merge 4 commits into
InferMatrixLab:mainfrom
fake0fan:p1-s2-indexer-evolver
Draft

fake0fan wants to merge 4 commits into
InferMatrixLab:mainfrom
fake0fan:p1-s2-indexer-evolver

Conversation

@fake0fan

@fake0fan fake0fan commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Governing Issue and delivery slice

Refs #867
Refs #460

  • Accepted scope / delegation: P1 slice S2 (Bounded Evolver loop, delivery-boundary checks, interrupted-call recovery & CPU negative suite) under #867, following the RFC rfc: Harness²-style rule improvement loop — abstract module rules first, start with the Indexer #460 owner decision (7275079865) and S2 claim (7282094135).
  • Anchors touched: none (keeps Knowledge, Benchmark and Harness strictly isolated with zero cross-core imports under A1/A4/A5; loop and recovery live in Harness per D005; Apps assembles).
  • Stacked prerequisite: currently stacked on P0 S3 (harness: freeze and resume unregistered candidate ranking rules #770), P0 S4 (knowledge: replay a retained Find ranking from its frozen rule #771) and P1 S1 (benchmark: add CPU Indexer ranking comparison evaluator (P1-S1) #869); kept as Draft until upstream slices merge into main, then will be rebased cleanly onto main before requesting independent review.
  • What this PR delivers:
    • src/inferrsi/benchmark/indexer_evolution.py: pure Benchmark rules for frozen evolution config validation, proposal envelope & delivery-boundary citation verification, development selection, mandatory rerun agreement, single-use held-out gate (accept_h1 / retain_h0), and deterministic single-coordinate search control (propose_deterministic_weights).
    • src/inferrsi/harness/manager/search/indexer_evolution.py: durable Harness controller (IndexerEvolutionController) and pack_evolver_context:
      • Verifies development captures via knowledge_capture.verify_capture, ingests retained development session traces (--dev-session: plan.json digest, knowledge/*.json captures, sanitized per-round optimization_trace steps, final and experiment-timing.json, refusing tampered or heldout sessions), refuses heldout evidence before serialization, packs strictly within context_bytes, and binds delivery_receipt (context_sha256, delivered_evidence, omitted_evidence) to the final serialized context.
      • Routes provider Evolver calls through Harness _agent_sessions.py (prepare -> dispatch -> bind -> record) with hard per-call budget reservation held across dropped responses and restarts, non-duplicating reconciliation by job_id, unknown usage recorded as null (never zero), and definite not_created failure release.
      • Enforces mandatory independent rerun before freezing H1, exclusive single-use held-out claim (durable_write_json(..., exclusive=True)), and proposer isolation after held-out claim.
    • src/inferrsi/apps/workflows/indexer_evolution.py + src/inferrsi/apps/cli/{arguments.py,__init__.py} + docs/guides/operations.md: Apps assembly (run_indexer_evolution, optional runtime-env-only make_openai_compatible_provider) and CLI subcommand inferrsi benchmarks indexer-evolve.
    • tests/benchmark/test_indexer_evolution_rules.py, tests/harness/test_indexer_evolution_controller.py, tests/apps/test_indexer_evolution_workflow.py: full rfc: Harness²-style rule improvement loop — abstract module rules first, start with the Indexer #460 §4.5 and §4.6 positive and negative CPU test suite (including david's delivery-boundary omission fixture, tampered/redacted/held-out leakage refusals, Amy's 10/6/5 interrupted-call budget reservation and restart recovery without resends, out-of-range edits, inconclusive/rerun failure retention of H0, single-use held-out claim, and real-corpus deterministic & provider CPU workflow tests).
  • What it does not deliver: paired real-task benchmarks compare ranking-policy arms (S3 of [P1] Indexer rule iteration: CPU comparison evaluator, bounded Evolver loop, and paired real-task comparison #867), any real-model or NPU/GPU pilot execution (separate acceptance issue), any change to repository default ranking weights, or any end-to-end task/service PASS claim.

Knowledge authorship declaration

{
  "schema_version": 1,
  "head_sha": "b66bf08c56cf9edaaf068ed08688a1f8dc7f4b74",
  "human_only": false,
  "material_ai_authors": [
    {
      "tool": "Antigravity",
      "model_id": "gemini-4-neon",
      "effort": "xhigh",
      "role": "author"
    },
    {
      "tool": "Antigravity",
      "model_id": "claude-opus-5-5",
      "effort": "high",
      "role": "author"
    }
  ]
}

(Note: claude-opus-5-5 appears only in the stacked P0 S3/S4 commits while this PR is Draft; P1-S1 4fc53ff2 and P1-S2 32b902b1 are authored with Antigravity / gemini-4-neon [effort=xhigh]. None of the changed files are in protected_paths.)

Changed artifacts and evidence

Requirement Actual change Check / evidence and result Remaining gap
Pure Benchmark evolution, proposal-boundary & deterministic control rules src/inferrsi/benchmark/indexer_evolution.py, tests/benchmark/test_indexer_evolution_rules.py 4/4 unit & negative tests passed; import gate & boundary checks passed Rebase onto main after #770/#771/#869 merge
Harness bounded controller, delivery boundary (#460 §4.6), interrupted-call recovery & budget reservation (#460 §4.5), single-use holdout src/inferrsi/harness/manager/search/indexer_evolution.py, tests/harness/test_indexer_evolution_controller.py 6/6 controller tests passed (david delivery-boundary fixture, tampered/redacted/held-out refusals, 10/6/5 reservation & restart recovery with zero resends, not_created release, budget exhaustion, out-of-range/rerun failure, single-use holdout & proposer isolation) Independent review after rebase
Apps workflow & CLI benchmarks indexer-evolve src/inferrsi/apps/workflows/indexer_evolution.py, src/inferrsi/apps/cli/{arguments.py,__init__.py}, docs/guides/operations.md, tests/apps/test_indexer_evolution_workflow.py 3/3 workflow & CLI tests passed on real installed corpus (development.json + synthetic tmp holdout; repo heldout.json untouched); ruff check src tests tools clean Independent review after rebase

Checks and dependencies

  • Checks actually run (result and tested scope):
    • ruff check src tests tools — passed (0 errors)
    • pytest tests/benchmark/test_indexer_evolution_rules.py tests/harness/test_indexer_evolution_controller.py tests/apps/test_indexer_evolution_workflow.py — 14 passed, 0 failed (7/7 controller tests including --dev-session trace ingestion & tamper/heldout refusals)
    • pytest tests/repository/test_target_module_import_gate.py tests/repository/test_module_boundaries.py tests/repository/test_first_wave_isolation_policy.py tests/repository/test_package_root_inventory.py tests/repository/test_architecture_anchors.py — all passed
  • Failed, skipped, timed-out or not-run checks (if applicable):
    • Full pytest suite not run locally (host Git 2.34 lacks Git >= 2.45 flags used by unrelated repo tests); CI will be authoritative once rebased onto main and marked ready.
  • Dependencies / shared interfaces / integration assumptions (if applicable):
    • Reuses Harness _agent_sessions.py, knowledge_capture.verify_capture, durable_write_json(..., exclusive=True), P0 S2 RankingPolicy/RankingSpace, P0 S4 ranking_replay, and P1 S1 compare_indexer_policies.

Remaining work and Issue closure

Managed sessions accept a candidate ranking configuration through --ranking-policy-file, mutually exclusive with --ranking-policy. Ordinary plans freeze the full receipt (with config_sha256) and ranking_policy_source: configuration; service-reuse plans pin the full configuration by value (no digest key, preserving service_io.no_fingerprints) and ranking_policy_source: configuration in both plan.json and campaign.json, cross-checked on load and delivery projection. Resume, Find and Read rebuild the rule from the frozen configuration through the injected resolver instead of the registry, so every search and read receipt carries the candidate. Candidate IDs cannot reuse registered names, named-policy plans keep their registry check, and tamper/mismatch cases fail with zero session writes.

Agent-assisted-by: Antigravity / claude-opus-5-5 [effort=high] (author)
Agent-assisted-by: Antigravity / gemini-4-neon [effort=xhigh] (author)
Signed-off-by: Chenguang Zheng <zhengcg0505@gmail.com>
Add ranking_replay: replay_binding records the query, limit, filters, byte budget, frozen rule, scoring version and corpus digest of one Find and delivery; verify_replay reproduces the returned, delivered and omitted order and reports reproduced only for the identical corpus and scoring version. Archival capture verification stays a separate check. Regression tests replay default and unregistered candidate captures over the frozen ranking corpus, report their delivery difference, show a changed corpus is not reported as reproduced while the old capture still verifies, and reject missing bindings and a changed rule.

Agent-assisted-by: Antigravity / claude-opus-5-5 [effort=high] (author)
Signed-off-by: Chenguang Zheng <zhengcg0505@gmail.com>
Add pure CPU comparison and descriptive scoring rules for two Indexer RankingPolicy arms in benchmark.indexer_comparison (no cross-core imports) and assemble the workflow and CLI subcommand benchmarks indexer-compare in Apps. The workflow reuses frozen RankingPolicy/RankingSpace validation and ranking_replay corpus digests, replay bindings and delivery differences, enforces heldout split isolation and zero-write refusal on invalid or out-of-space inputs, and reports offline CPU retrieval/delivery metrics only.

Agent-assisted-by: Antigravity / gemini-4-neon [effort=xhigh] (author)
Signed-off-by: Chenguang Zheng <zhengcg0505@gmail.com>
…ry-boundary and recovery checks

Add pure Benchmark proposal, selection, rerun, held-out gate and deterministic coordinate-control rules in benchmark.indexer_evolution; add the durable bounded Harness controller in harness.manager.search.indexer_evolution with development-session trace and knowledge-capture ingestion (verifying plan_digest, captures, optimization_trace steps, timing and held-out exclusion), verified delivery-boundary packing, Evolver calls routed through _agent_sessions.py with hard budget reservations on interrupted calls, non-duplicating reconciliation, mandatory rerun and an exclusive single-use held-out claim; and assemble the workflow and CLI subcommand benchmarks indexer-evolve (--dev-session, --mode deterministic|provider) in Apps. Cover delivery-boundary omission refusal, tampered/redacted/held-out leakage refusal, session trace ingestion, interrupted-call restart recovery and budget reservation, out-of-range edits, inconclusive/rerun failure retention of H0, and end-to-end CPU workflow runs.

Agent-assisted-by: Antigravity / gemini-4-neon [effort=xhigh] (author)
Signed-off-by: Chenguang Zheng <zhengcg0505@gmail.com>
@fake0fan
fake0fan force-pushed the p1-s2-indexer-evolver branch from 32b902b to b66bf08 Compare November 30, 2026 15:19
@Dong1017 Dong1017 added area:apps Apps line: CLI, Python entrypoints, host inspection, workflows, views, and adapters area:benchmark Benchmark line: preparation ports, metric contracts, validators, and isolated workers area:harness Harness module: profile, A/B loop, quality gates, evidence reports labels Nov 30, 2026

@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.

Dot, acting for @david6666666.

Draft feedback on b66bf08c, not a vote. The single-use held-out claim correctly prevents a second evaluation. One restart window still leaves the recorded decision and status disagreeing; details inline.

"holdout_report": holdout_report,
"selected_rule": state["selected_rule"],
}
durable_write_json(self._holdout_result_path, result_doc, exclusive=True)

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.

Dot, acting for @david6666666.

If the process stops after holdout-result.json is durable but before _save_state, a restart still reports holdout_claimed; rerunning the gate refuses the existing claim. Could recovery reconcile a valid durable result to its original claim and plan into terminal state, without calling the evaluator again? Please cover that exact write boundary with a restart test.

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

Labels

area:apps Apps line: CLI, Python entrypoints, host inspection, workflows, views, and adapters area:benchmark Benchmark line: preparation ports, metric contracts, validators, and isolated workers area:harness Harness module: profile, A/B loop, quality gates, evidence reports

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants