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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

### Changed

- Import the four-port AB/BA loop with `from inferrsi.harness.manager import run_experiment`.
The former `inferrsi.harness.runner` module was removed. The `inferrsi run` CLI and
`inferrsi.apps.legacy.run.run_experiment` continue to supply the four port bindings.

- Apps module retirement (0.3.4). Use the [documented replacements](docs/apps-module-migrations.json).
The public evaluation API remains at `inferrsi.apps.api`. See the
[migration instructions](docs/guides/module-layout.md#apps-modules-and-retired-imports) for
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ synthetic contract fixtures, not accelerator measurements.

`apps.legacy.run.run_experiment(spec, environment, *, execute, snapshot)` composes
the old run and accepts small callable adapters. It passes them, the Benchmark v0
gates and the report to `harness.runner.run_experiment`, whose four ports
gates and the report to `harness.manager.run_experiment`, whose four ports
(`execute`, `snapshot`, `assess`, `report`) have no defaults. An omitted
`execute` or `snapshot` is read from `apps.legacy.run` when the run starts
(`execute_trial` and `repository_identity`), which is the two-argument call
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/modular-directory-map-en.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/contracts/function-owners.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Status: **Proposed baseline**; individually **adopted** entries are identified b
| `skill_eval_diagnostic` task definition/`validate_task`/`expected`/`verify` | B task/pure criteria; `main` as a B-defined worker entry | worker started by H; prepare/assess do not execute `main` |
| `skill_eval_engineering` task/vectors/`validate_task` | B task-owned definition and pure vector judgment | `verify` must be split from process start; offline assess does not re-measure through an execution port |
| same file `materialize_generated_artifact`/`read_regular`/`input_hashes`/`SandboxUnavailable`/`RUNNER`/`sandbox_command`/`_invoke` | H input capture/sandbox execution capability | real capability/control domain tested in the later H02 PR; B consumes fixed output only |
| `harness/runner` execution/termination/directory/state events | H execution and facts; AB/BA/repetitions → B protocol/worker; `write_report` → Apps | old run unchanged; migrating old `evaluate` decouples the runner first; new H scoring cannot be retained by attaching a `legacy` label |
| `harness.manager.run_experiment` execution/termination/directory/state events | H execution and facts; AB/BA/repetitions → B protocol/worker; `write_report` → Apps | old run unchanged; migrating old `evaluate` decouples the runner first; new H scoring cannot be retained by attaching a `legacy` label |
| `harness/improvement` `usage_totals`/`assessment`/`holdout_accepts`/`rerun_assessment` | B experiment validity/comparison/acceptance rules; budget admission/reservation/charging reconciliation remains H | read normalized facts only; provider parsing does not move because of import convenience |
| same file `choose` | H search progression; `SelectionPolicy` split into B threshold rules and H progression/stop policy | no shared business `Policy` class; Apps does not create a retry loop |
| `harness/knowledge_capture` `assemble_context_text`/`_item` | K pure knowledge text projection | Apps connects K/H; Apps gives H the fixed expected text/hash; H stores the actually delivered text/hash; `verify_capture` byte integrity belongs to H and does not call K assembly in reverse; it is not a task-benefit verdict |
Expand All @@ -23,7 +23,7 @@ Status: **Proposed baseline**; individually **adopted** entries are identified b
| `harness/records/profile_timeline` `attach_profile`, `_compile` (builds the bounded dashboard overview stored with the record), fixed-byte verification, and digest reads (`read_profiles`/`profile_event_table`) (added with the OBS dissolve; **adopted owner: H records; RSI-master architecture decision 2026-11-14 Asia/Shanghai, recorded in the [D008 wave-2 ownership decision](d008-wave2-ownership-decision.md#profile-records-and-overview); independent PR review remains separate**) | H records: attach a reviewed profile, compile the stored overview from those bytes, and verify stored bytes | Record, overview-compile and byte-integrity paths stay in H because the overview is record content: it is computed once at attach from a bounded trace and published content-addressed, so the stored bytes cannot depend on who renders them. Its top-lane, longest-event and top-kernel selection reduces one trace for a bounded record; it ranks no candidate, run or claim and produces no verdict. UI route decoration, including `events_url`, belongs to Apps views, not H. Issue #413's broad timeline-to-Apps placement is refined here: persisted factual records and bounded overview encoding stay in H; UI projections and route decoration belong to Apps. The route decoration is removed from H in this PR, preserving stored bytes, digest verification and the external view response. |
| `apps/views/profile_searches` `pre_profile_searches` (added with the OBS dissolve; **adopted owner: Apps views; RSI-master architecture decision 2026-11-14 Asia/Shanghai, recorded in the [D008 wave-2 ownership decision](d008-wave2-ownership-decision.md#pre-profile-searches); independent PR review remains separate**) | Apps views: Dashboard-consumed presentation list relating a profile capture to named searches completed before it | It joins an H record with ledger read models, which only Apps may assemble. Its `verified`/`not_before`/`unknown_time` values are display annotations over an existing search state; they are not evidence for a claim, and using them that way needs a new owner decision. |
| `benchmark/sampling` `collect_samples` (moved out of `harness/scenarios/media` by the old-run split; **ownership disposition: B sampling; RSI-master [adopted decision, 2026-11-14 Asia/Shanghai](d008-wave2-ownership-decision.md#benchmark-sampling); independent PR review remains separate**) | B sampling: seed ordering, timing records and artifact hashes | Request transport stays with the caller's injected `request(item, path)` callback; Benchmark hashes artifacts with its own `_sha256`, pinned to `apps.artifacts.sha256` by `tests/apps/test_legacy_run_split.py::test_sampling_sha256_matches_the_apps_hasher` (the Infra hasher and its test name were retired by #498), and imports no H or Apps module. The per-group progress line on stdout is the old `run` protocol output kept for D022 and is a protocol constraint, not a presentation owner. |
| `harness/runner` `snapshot` port `(repo, exclude) -> dict` (separated from the runner by the old-run split; **ownership disposition: H port contract, Apps legacy binding, `apps/host/targets` implementation (moved from `infra/targets` by #498); RSI-master [adopted decision, 2026-11-14 Asia/Shanghai](d008-wave2-ownership-decision.md#snapshot-port); independent PR review remains separate**) | H owns the port and its contract; the Apps legacy composition owns the binding; `apps/host/targets` owns the Git identity implementation | H keeps the port required and keyword-only with no default and holds no copy of the implementation. `apps/legacy/run.py` binds `snapshot=repository_identity` for the old run; the root `execution.py` forwarder was deleted by #412 R1, and the CLI imports `apps/legacy/` itself. A change of the binding owner needs its own review. Out-of-tree callers that used the removed H defaults are not covered by this row. |
| `harness.manager.run_experiment` `snapshot` port `(repo, exclude) -> dict` (separated from the runner by the old-run split; **ownership disposition: H port contract, Apps legacy binding, `apps/host/targets` implementation (moved from `infra/targets` by #498); RSI-master [adopted decision, 2026-11-14 Asia/Shanghai](d008-wave2-ownership-decision.md#snapshot-port); independent PR review remains separate**) | H owns the port and its contract; the Apps legacy composition owns the binding; `apps/host/targets` owns the Git identity implementation | H keeps the port required and keyword-only with no default and holds no copy of the implementation. `apps/legacy/run.py` binds `snapshot=repository_identity` for the old run; the root `execution.py` forwarder was deleted by #412 R1, and the CLI imports `apps/legacy/` itself. A change of the binding owner needs its own review. Out-of-tree callers that used the removed H defaults are not covered by this row. |

D008 rows are architecture decisions under the delegation recorded at the top of this file. An independent reviewer verifies the cited code, tests and dependency direction and may block on a missing adoption record; a reviewer does not choose the owner, and a PR approval is not the D008 adoption record. The architecture owner records adoption in the governed contract or decision record; the rows cite that decision record, independently of PR approval.

Expand Down
5 changes: 3 additions & 2 deletions docs/guides/module-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ The leaf's own import rule and `REPO_TYPES` object identity govern it.
`inferrsi.harness.run_store`, and `inferrsi.harness.errors`. Each registered
entry must appear in the import graph and satisfy its dependency rules.
The closure rule above applies to every Harness module. The gate rejects
imports of the ten former root-level search modules and any file that
restores one of those paths.
imports of the former root-level runner and ten search modules, and any
file that restores one of those paths. Import the four-port AB/BA loop with
`from inferrsi.harness.manager import run_experiment`.
- **No residual.** The skill-evaluation split (#410) moved `export_bundle` to
Apps and removed the registered `harness.skill_evaluation` → root
`knowledge_operations` edge together with its exemption. Every harness
Expand Down
2 changes: 1 addition & 1 deletion src/inferrsi/apps/legacy/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from inferrsi.benchmark.legacy_run_v0 import evaluate as _evaluate
from inferrsi.benchmark.legacy_run_v0 import read_metric, trial_metric
from inferrsi.contracts import RunSpec
from inferrsi.harness.runner import run_experiment as _run_experiment
from inferrsi.harness.manager import run_experiment as _run_experiment
from inferrsi.harness.trials.external import execute_trial as _execute_trial

from .evaluation import run_rules
Expand Down
13 changes: 7 additions & 6 deletions src/inferrsi/harness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ measurement and assessment rules.
- [`run_store.py`](run_store.py) provides `RunStore` and `RunStoreReader` for
namespaced records and content-addressed artifacts. Pass `record_version`
to read a fixed record and use `open(ref)` to read retained artifact bytes.
- [`runner.py`](runner.py) owns the common AB/BA loop. It calls injected
`execute`, `snapshot`, `assess`, and `report` ports and records the returned
assessment. [`trials/external.py`](trials/external.py) runs and retains a
single command trial with the supplied metric reader.
- [`optimization_session.py`](optimization_session.py) connects session
commands to the budget and recovery logic in [`optimization.py`](optimization.py).
[`task_protocol.py`](task_protocol.py) prepares task protocol packages and runs
their operations in a subprocess with source hash and response checks.
- [`skill_evaluation.py`](skill_evaluation.py) executes and retains
skill-evaluation trials. [`artifact_sandbox.py`](artifact_sandbox.py) captures
and replays submitted artifacts.
- [Manager](manager/__init__.py) exposes `EngineSearchPlan`, `run_engine_search`
and `read_engine_search`. It checks the budget before starting a search.
- [Manager](manager/__init__.py) exposes the common AB/BA loop as
`from inferrsi.harness.manager import run_experiment`. Apps supplies the
`execute`, `snapshot`, `assess` and `report` ports. Manager records the
returned assessment. [External trials](trials/external.py) run and retain
each command with the supplied metric reader.
- Manager also exposes `EngineSearchPlan`, `run_engine_search` and
`read_engine_search`. It checks the budget before starting a search.
Its [improvement loop](manager/search/improvement.py) uses injected assessments.
[VATS](manager/search/vats.py) selects edits and verification jobs. The
[search campaign](manager/search/search_campaign.py) coordinates GVO updates
Expand Down
5 changes: 3 additions & 2 deletions src/inferrsi/harness/manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Manage Harness session progression and search budgets."""
"""Manage Harness experiments, session progression and search budgets."""

from ._runner import run_experiment
from .search._engine import EngineSearchPlan, read_engine_search, run_engine_search

__all__ = ["EngineSearchPlan", "read_engine_search", "run_engine_search"]
__all__ = ["EngineSearchPlan", "read_engine_search", "run_engine_search", "run_experiment"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from datetime import datetime, timezone
from pathlib import Path

from ..contracts import RunSpec
from ..contracts.runspec import revision_matches
from .atomic_json import atomic_write_json as _write_json
from .trials.external import collect_trial_checks
from ...contracts import RunSpec
from ...contracts.runspec import revision_matches
from ..atomic_json import atomic_write_json as _write_json
from ..trials.external import collect_trial_checks


def run_experiment(
Expand Down
2 changes: 1 addition & 1 deletion src/inferrsi/harness/parallel_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
confined_execute,
)
from inferrsi.harness.device_lease import DeviceLease, LeaseError
from inferrsi.harness.manager import run_experiment as run_experiment_loop
from inferrsi.harness.round_budget import (
Binding,
BudgetError,
Expand All @@ -85,7 +86,6 @@
ensure_open,
seconds_remaining,
)
from inferrsi.harness.runner import run_experiment as run_experiment_loop

_TERMINAL = frozenset({"measured", "rejected", "unsettled", "failed"})

Expand Down
2 changes: 1 addition & 1 deletion src/inferrsi/harness/trials/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""External command trials and their retained checks, independent of model and device.

Experiment scheduling stays in harness.runner.
Harness Manager schedules experiments.
"""
9 changes: 5 additions & 4 deletions tests/apps/test_legacy_run_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from inferrsi.apps.storage import artifacts
from inferrsi.benchmark import legacy_run_v0, metrics, sampling
from inferrsi.contracts import RunSpec, claim
from inferrsi.harness.runner import run_experiment
from inferrsi.harness.manager import run_experiment
from inferrsi.harness.trials.external import execute_trial
from tests.repository._gate_policy_support import ROOT, _scan, _walk

Expand All @@ -38,17 +38,18 @@ def _reached(module: str) -> set[str]:


def test_moved_harness_modules_are_gone_without_shells():
for name in ("evaluation", "reporting", "scenarios.media"):
for name in ("evaluation", "reporting", "runner", "scenarios.media"):
assert f"inferrsi.harness.{name}" not in GRAPH.trees
assert importlib.util.find_spec("inferrsi.harness.runner") is None


def test_runner_and_external_lost_their_model_artifact_and_target_edges():
assert _outside("inferrsi.harness.runner", "inferrsi.model", "inferrsi.infra") == set()
assert _outside("inferrsi.harness.manager._runner", "inferrsi.model", "inferrsi.infra") == set()
assert _outside("inferrsi.harness.trials.external", "inferrsi.model") == set()
assert _outside("inferrsi.harness.trials.external", "inferrsi.infra") <= PROCESS_DOMAIN
assert _outside("inferrsi.harness.atomic_json", "inferrsi.") == {"inferrsi.harness"}
# Transitively the old chain keeps only the process domain, and no new core.
for module in ("inferrsi.harness.runner", "inferrsi.harness.trials.external"):
for module in ("inferrsi.harness.manager._runner", "inferrsi.harness.trials.external"):
reached = _reached(module)
assert {n for n in reached if n.startswith(("inferrsi.model", "inferrsi.infra"))} <= (
PROCESS_DOMAIN
Expand Down
6 changes: 4 additions & 2 deletions tests/contracts/test_contracts_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import dataclasses
import importlib
import importlib.util
import inspect
import json
import os
import pickle
Expand All @@ -25,7 +26,7 @@
from inferrsi.apps.legacy import evaluation as legacy_evaluation
from inferrsi.apps.legacy import run as legacy_run
from inferrsi.contracts import RunSpec, claim, json_v1, runspec
from inferrsi.harness import runner
from inferrsi.harness.manager import run_experiment

SRC = Path(__file__).resolve().parents[2] / "src"
ROOT = SRC / "inferrsi"
Expand Down Expand Up @@ -125,8 +126,9 @@ def test_initializer_reexports_only_runspec_and_there_is_one_class() -> None:
assert contracts.RunSpec is runspec.RunSpec is RunSpec
assert (RunSpec.__module__, RunSpec.__qualname__) == ("inferrsi.contracts.runspec", "RunSpec")
# Every consumer in the tree holds that same class object.
for consumer in (arguments, legacy_evaluation, legacy_run, runner):
for consumer in (arguments, legacy_evaluation, legacy_run):
assert consumer.RunSpec is RunSpec, consumer.__name__
assert inspect.signature(run_experiment).parameters["spec"].annotation is RunSpec


def test_harness_reexports_the_same_verdict_objects() -> None:
Expand Down
3 changes: 2 additions & 1 deletion tests/repository/_gate_policy_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@
# so the two package names are retired as a whole.
# #558 moved ``inferrsi.harness.scenarios`` to ``inferrsi.harness.trials``, with no
# forwarder, so the old package name is retired as a whole too.
# #702 moved the ten root-level search modules under the Manager.
# #702 moved the root-level runner and ten search modules under the Manager.
RETIRED_MODULES = frozenset({
"inferrsi.infra",
"inferrsi.model",
"inferrsi.harness.scenarios",
"inferrsi.harness.runner",
"inferrsi.harness.gvo",
"inferrsi.harness.improvement",
"inferrsi.harness.search_adapter",
Expand Down
32 changes: 32 additions & 0 deletions tests/repository/check_installed.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,38 @@ def assert_not_importable(name):
raise AssertionError(f"retired module {name} must not import")


def check_installed_abba_runner():
from inferrsi.apps.legacy.run import execute_trial
from inferrsi.harness.manager import run_experiment

command = (
sys.executable, "-c",
"import sys; from pathlib import Path; Path(sys.argv[1]).write_text(sys.argv[2])",
"{result}", '{"metrics":{"latency_ms":1}}',
)
reported = []

def assess(baseline, candidate, validation, integrity, error):
assert [trial["metric"] for trial in baseline] == [1]
assert [trial["metric"] for trial in candidate] == [1]
assert validation is None and integrity["verified"] and error is None
return {"verdict": "INCONCLUSIVE"}

with tempfile.TemporaryDirectory(prefix="inferrsi-installed-abba-") as cwd:
spec = RunSpec(repo=cwd, baseline_command=command, candidate_command=command,
repetitions=1, output_dir=str(Path(cwd) / "runs"), max_minutes=1)
run_dir = run_experiment(
spec, {}, execute=execute_trial,
snapshot=lambda *_: {"available": True, "snapshot_hash": "fixed"},
assess=assess, report=reported.append,
)
assert reported == [run_dir]
assert json.loads((run_dir / "evaluation.json").read_bytes()) == {"verdict": "INCONCLUSIVE"}


assert_not_importable("inferrsi.harness.runner")
check_installed_abba_runner()

# #498 slice 1: the metric contract and the quality validators ship only under
# inferrsi.benchmark. The old inferrsi.model paths are not in the wheel and have no alias.
# Slice 2 removed the emptied inferrsi.model.protocols package, so it stands for
Expand Down
Loading
Loading