diff --git a/CHANGELOG.md b/CHANGELOG.md index c92f7bda8..7f3a87d4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,26 @@ `harness.execution_spec` and `harness.errors` paths have been removed. Existing store roots retain their namespace, object references and exact record versions. +- Import `LocalCpuTarget` from `inferrsi.harness.executor`. Its former + `inferrsi.harness.api` entry was removed. Hosts continue to import `Harness` + from `inferrsi.harness.api`. +- Import `prepare_generation`, `read_prepared_binding`, `project_prepared_binding` + and `verify_prepared_binding` from `inferrsi.harness.executor`. These replace + `harness.generation.prepare_generation` and `harness.prepared_binding`'s + `read`, `project` and `verify`. They accept the same specs and artifact readers. +- Hosts execute a prepared spec through `Harness.execute` from `inferrsi.harness.api`. + The former `harness.execution_service`, `harness.entry_code`, `harness.input_binding` + and `harness.evidence_capture` implementations now live inside Executor. + The source modules `candidates`, `confinement`, `skill_evaluation` and `artifact_sandbox` + moved from `inferrsi.harness` to `inferrsi.harness.executor` with their in-tree callers. +- Service recovery uses `process_group_empty` from `inferrsi.harness.executor`. + Local process supervision, launch records and device leases live under + `harness.executor`; the three former root modules were removed. +- The external trial runner moved from `harness.trials.external` to + `harness.executor.trials.external` for apps that inject single-command trials. +- Import `Verdict` and `parse_verdict` from `inferrsi.contracts.claim`. + The former `inferrsi.harness` exports have been removed. + - `inferrsi benchmarks compare` keeps every attempt of an arm (Refs #509, P1.1). The new `--action retry --trial ` opens a fresh attempt with its own job and workspace after a collected, terminal attempt. The collected attempt stays as evidence, and no campaign is renamed. diff --git a/docs/apps-module-migrations.json b/docs/apps-module-migrations.json index b6f4dbd9f..773b5a209 100644 --- a/docs/apps-module-migrations.json +++ b/docs/apps-module-migrations.json @@ -590,7 +590,7 @@ "src/inferrsi/apps/delivery/snapshot.py", "src/inferrsi/harness/records/artifact_primitives.py", "src/inferrsi/harness/records/atomic_json.py", - "src/inferrsi/harness/input_binding.py", + "src/inferrsi/harness/executor/_input_binding.py", "tests/apps/test_anthropic_agent.py", "tests/apps/test_goal_checkpoint.py", "tests/apps/test_inspection.py", diff --git a/docs/architecture.md b/docs/architecture.md index 874d77254..e384b3d4e 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -44,7 +44,7 @@ tool and retain the native identity and returned artifacts. The child owns the complete start/knowledge/round/final lifecycle; the parent observes and collects. This path records the handoff; it does not implement a background Agent CLI driver or a native-host deadline. -The application injects `harness.trials.external.execute_trial` into the +The application injects `harness.executor.trials.external.execute_trial` into the [two-rank MoE entry](benchmarks/moe-forward-benchmark.md). The standalone image benchmark and [TTS service protocol](benchmarks/tts-benchmark.md) expose their documented execution boundaries. Apps and Harness callers assemble these operations into optimization @@ -284,7 +284,7 @@ the [import gate](guides/module-layout.md#import-gate) for migration and depende | Add | Main extension locations | Required qualification | | --- | --- | --- | -| Model or scenario | `harness/serving`, `benchmark/metrics.py`, `benchmark/validators`; trials run through the model-independent `harness/trials/external.py` | Frozen request and metric contract; model-specific quality coverage | +| Model or scenario | `harness/serving`, `benchmark/metrics.py`, `benchmark/validators`; trials run through the model-independent `harness/executor/trials/external.py` | Frozen request and metric contract; model-specific quality coverage | | Repository | `apps/host/targets`, a composed scenario, `resources/repo_packs` | Stable source identity; command/result contract; environment isolation | | Hardware | `apps/host/platforms` | Device selection, process exclusivity and independent backend/model evidence; a backend is registered in `apps/host/platforms/__init__.py` and its probe command is defined in the implementing module under `apps/host/platforms/`, not in package data | @@ -332,7 +332,7 @@ float; `benchmark.legacy_run_v0.trial_metric` then applies the one finite, posit metric contract (`benchmark.metrics.validate_metric`) to whatever the reader returns, so a reader that yields `0.0`, a `bool` or a non-finite value records a metric error rather than entering the evaluation. The Harness executor -`harness.trials.external.execute_trial` holds no metric rule: a caller that +`harness.executor.trials.external.execute_trial` holds no metric rule: a caller that passes a metric key also passes `metric=`, its validation function. Run state is written by the termination path, never assumed. `status.json` @@ -385,7 +385,7 @@ require Linux with a readable `/proc` process table. They reject other platforms before launch; missing or inaccessible process enumeration raises an error rather than reporting successful cleanup. Workers must remain in their owned process group. Windows Job Object support in the general command executor -(`harness.local_process`) does not extend to these server helpers. These constraints do not restrict read-only knowledge +(`harness.executor.local_process`) does not extend to these server helpers. These constraints do not restrict read-only knowledge operations or the control CLI to Linux. - Existing CLI flags, external JSON metrics, run artifacts, cancellation diff --git a/docs/assets/modular-directory-map-en.svg b/docs/assets/modular-directory-map-en.svg index c406246a7..100a0b224 100644 --- a/docs/assets/modular-directory-map-en.svg +++ b/docs/assets/modular-directory-map-en.svg @@ -28,7 +28,7 @@ harness/ manager/ AB/BA trials - local_process.py + executor/ Deadlines and cleanup records/ Campaign records and traces diff --git a/docs/benchmarks/moe-forward-benchmark.md b/docs/benchmarks/moe-forward-benchmark.md index 6e2e8a574..d4fc4cffc 100644 --- a/docs/benchmarks/moe-forward-benchmark.md +++ b/docs/benchmarks/moe-forward-benchmark.md @@ -47,7 +47,7 @@ inferrsi benchmarks run moe-forward-npu \ `--timeout-seconds` 都必须显式指定;两组配对为每实现每性能 case 16 个计时样本, 四组为 32 个。超时包括入口准备和执行,之后最多有额外的有界进程清理等待。 入口先冻结题目、候选和 grader 的副本及 SHA256,再通过现有 -由应用入口注入的 `harness.trials.external.execute_trial` 执行。 +由应用入口注入的 `harness.executor.trials.external.execute_trial` 执行。 该执行器不含 metric 规则,入口在传 metric key 的同时传入自己的校验函数 (`metric=read_metric`)。 Python 调用 `evaluate` 时须显式传入 `execute_trial`。它额外清理本次唯一环境标记的 diff --git a/docs/contracts/function-owners.md b/docs/contracts/function-owners.md index 62aba264c..1d0452a62 100644 --- a/docs/contracts/function-owners.md +++ b/docs/contracts/function-owners.md @@ -16,7 +16,7 @@ Status: **Proposed baseline**; individually **adopted** entries are identified b | `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 | -| `harness/trials/external` `execute_trial`/`collect_trial_checks` | H: run one command through `execute_command`, retain its record, and collect the trial checks; semantic metric validation (`read_metric`/`validate_metric`) is B and lives in `benchmark/metrics.py` | `execute_trial` applies only the metric callable the caller injects and holds no metric rule; offline assess executes nothing | +| `harness/executor/trials/external` `execute_trial`/`collect_trial_checks` | H: run one command through `execute_command`, retain its record, and collect the trial checks; semantic metric validation (`read_metric`/`validate_metric`) is B and lives in `benchmark/metrics.py` | `execute_trial` applies only the metric callable the caller injects and holds no metric rule; offline assess executes nothing | | `campaign_records` `STAGES`/claim capture/reconciliation | H records; dashboard/report presentation → Apps | first remove the `campaign_records → dashboard_data` reverse dependency; #333 is Proposed and no claim is made that a unified event envelope is accepted | | `catalog.repository_pack`/`REPO_TYPES` | D020 neutral raw-data technical leaf; target interpretation stays H | K does not expose the pack reader publicly; `apps/host/inspection` (the former `infra/inspection`, moved by #498) changes only its same-leaf import; seven K bodies/root entries/tests move together | | `apps/views/dashboard_workflow` `command_state`/`run_workflow`/`validation_progress` (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#dashboard-workflow); independent PR review remains separate**) | Apps views: read-only presentation projection of workflow and command state | The module imports only the standard library and reads records the caller already loaded; it has no H, K or Benchmark edge. A group `state` such as `completed` is a display state for the run workflow, not a verdict, and must not be read as the legacy `Verdict`. `validation_progress` only validates counters from a snapshot `dashboard_data` has already read; it opens no file. | @@ -31,7 +31,7 @@ Any later split of a mixed function is accepted by real pytest/host/wheel/record ## Implemented rows -The skill-evaluation split (#410) implements the `skill_evaluation`, `skill_eval_diagnostic`, `skill_eval_engineering` and `improvement` rows. H keeps `harness/skill_evaluation.py`, `harness/artifact_sandbox.py` and `harness/manager/search/improvement.py`; B holds `benchmark/skill_evaluation.py`, `benchmark/skill_eval_diagnostic.py`, `benchmark/skill_eval_engineering.py` and `benchmark/improvement.py`; Apps composes them in `apps/workflows/skill_evaluation.py`, `apps/workflows/skill_eval_engineering.py` and `apps/workflows/improvement.py`. Two points follow the tree as it stands after #338, not the row text: +The skill-evaluation split (#410) implements the `skill_evaluation`, `skill_eval_diagnostic`, `skill_eval_engineering` and `improvement` rows. H keeps `harness/executor/skill_evaluation.py`, `harness/executor/artifact_sandbox.py` and `harness/manager/search/improvement.py`; B holds `benchmark/skill_evaluation.py`, `benchmark/skill_eval_diagnostic.py`, `benchmark/skill_eval_engineering.py` and `benchmark/improvement.py`; Apps composes them in `apps/workflows/skill_evaluation.py`, `apps/workflows/skill_eval_engineering.py` and `apps/workflows/improvement.py`. Two points follow the tree as it stands after #338, not the row text: - `usage_totals` stays in `harness/records/usage.py`, because `harness/optimization.py` consumes it for budget accounting. B `assessment` receives the baseline and candidate totals from Apps and does not import H. - `SelectionPolicy` holds only the two thresholds, so it lives whole in B. H `choose` receives the assessments, the validity block and the composition flag; it holds no threshold and no policy class. diff --git a/docs/contracts/gate-policy-runstore-and-first-prs.md b/docs/contracts/gate-policy-runstore-and-first-prs.md index 50d82f368..9a6fce592 100644 --- a/docs/contracts/gate-policy-runstore-and-first-prs.md +++ b/docs/contracts/gate-policy-runstore-and-first-prs.md @@ -38,7 +38,7 @@ The symbol inventory is AST-derived and does not claim to have found every third 1. The default cross-core prohibition stays. Only the seven leaf→exact-K-module edges above may serve as migration-compatibility exceptions; a module prefix does not authorize adjacent new modules. 2. Shape checks allow only a module docstring, a `future` import, the listed `ImportFrom` lines (alias only as `name as name`), and an `__all__` constant string list. No business definitions, other imports, assignment side effects, or dynamic module hooks. -3. The static graph resolves absolute/relative imports, `from package import name`, and known export edges, and builds the transitive closure. Any target K/B/H core API entry that reaches another core, Apps, or a legacy facade fails. The D020 neutral technical leaf is not a legacy facade and must be independently verified to contain only raw data reading/data constants and no core imports; "only indirectly, so it passes" is not allowed. Target H entry points are the new `harness.api`/`execution_service`/`run_store`; the current mixed `harness` does not automatically count as an isolated core. +3. The static graph resolves absolute/relative imports, `from package import name`, and known export edges, and builds the transitive closure. Any target K/B/H core API entry that reaches another core, Apps, or a legacy facade fails. The D020 neutral technical leaf is not a legacy facade and must be independently verified to contain only raw data reading/data constants and no core imports; "only indirectly, so it passes" is not allowed. Target H entry points are `harness.api`, `harness.executor` and `harness.records`; the current mixed `harness` does not automatically count as an isolated core. 4. The existing `harness/skill_evaluation.py → knowledge_operations → knowledge.*` edge is a registered **exact residual legacy dependency**: retained, and it keeps `overall isolation_complete=false`. It is not erased from the report and no new/expanded H bypass is permitted. It is not an exception available to a target H new entry. The skill-evaluation split (#410) later removed this edge and its exemption; [Module layout](../guides/module-layout.md#first-wave-compatibility-exceptions-proposed) records the current rule. 5. `test_clean_scan_is_not_isolation` becomes a staged-model test. It does not permanently assert that all three package directories are absent. It verifies that `overall` is still false when any target package, any compat exception, or an old H→model/infra transitive residual is missing. Green is not manufactured by deleting assertions. 6. A non-empty allowlist forces `overall isolation_complete=false`; "new core business closure isolated" is reported as a separate verifiable result and cannot impersonate isolation of the whole historical namespace. diff --git a/docs/contracts/generation-bounds.md b/docs/contracts/generation-bounds.md index b513e3284..bc8e91906 100644 --- a/docs/contracts/generation-bounds.md +++ b/docs/contracts/generation-bounds.md @@ -1,6 +1,6 @@ # Internal original generation bounds -`inferrsi.harness.generation.prepare_generation` seals an approved context and +`inferrsi.harness.executor.prepare_generation` seals an approved context and generation plan before execution registration. Its caller supplies the original attempt, context request, candidate context and provider ports. It writes the authorized RunStore and returns the ordinary execution specification; it does diff --git a/docs/contracts/generation-feedback-policy.md b/docs/contracts/generation-feedback-policy.md index aea3471ef..79ca9ab1c 100644 --- a/docs/contracts/generation-feedback-policy.md +++ b/docs/contracts/generation-feedback-policy.md @@ -7,7 +7,7 @@ It is separate from a search/loop controller and does not grade evidence. ## Host entry -`inferrsi.harness.generation.prepare_generation` keeps its existing required +`inferrsi.harness.executor.prepare_generation` keeps its existing required arguments and accepts three keyword-only options: | Option | Value | diff --git a/docs/contracts/generation-feedback.md b/docs/contracts/generation-feedback.md index ec97df548..3548b684e 100644 --- a/docs/contracts/generation-feedback.md +++ b/docs/contracts/generation-feedback.md @@ -3,7 +3,7 @@ This documents the first-phase boundary accepted in [#371, decision 7084973960](https://github.com/InferMatrixLab/InferRSI/issues/371#issuecomment-7084973960). V25 assigns frozen feedback policy to Harness. The current -`inferrsi.harness.generation.prepare_generation`, when called without an explicit +`inferrsi.harness.executor.prepare_generation`, when called without an explicit `feedback_policy_ref`, does not enforce that policy: it receives a host-built `candidate_context`, retains the delivered context and seals the generation plan. There is no automatic next round on this path. diff --git a/docs/contracts/harness-entry-verification.md b/docs/contracts/harness-entry-verification.md index e345a1fb0..e8818c82e 100644 --- a/docs/contracts/harness-entry-verification.md +++ b/docs/contracts/harness-entry-verification.md @@ -1,7 +1,8 @@ # Harness source-entry verification The local CPU target can opt into the first frozen evaluation task with -`LocalCpuTarget(..., module_root=)`. The host owns +`LocalCpuTarget(..., module_root=)` from +`inferrsi.harness.executor`. The host owns this configuration. Requests cannot supply the root. Existing targets with no module root retain their ordinary-command behavior and refuse evaluation mode before registration. diff --git a/docs/contracts/harness-evaluation-replay.md b/docs/contracts/harness-evaluation-replay.md index d6ac213d2..770688a60 100644 --- a/docs/contracts/harness-evaluation-replay.md +++ b/docs/contracts/harness-evaluation-replay.md @@ -55,7 +55,7 @@ caller cancellation with a descendant, fixed cleanup facts, commit failure after a real start, cross-process replay and registration races. Execution facts do not provide a complete Benchmark F/C/M proof or a service-gain claim. -The [local process supervisor](../../src/inferrsi/harness/local_process.py) +The [local process supervisor](../../src/inferrsi/harness/executor/local_process.py) rechecks cancellation and the attempt deadline or step timeout after opening logs and before starting the worker. The [launch-boundary test](../../tests/harness/test_harness_execute.py) covers this diff --git a/docs/contracts/harness-prepared-binding.md b/docs/contracts/harness-prepared-binding.md index 16b39589f..7a32430f0 100644 --- a/docs/contracts/harness-prepared-binding.md +++ b/docs/contracts/harness-prepared-binding.md @@ -1,17 +1,17 @@ # Harness preparation binding before registration The Harness evaluation path checks declarations before registering an attempt. -`inferrsi.harness.prepared_binding.verify(spec, artifact_reader)` returns a +`inferrsi.harness.executor.verify_prepared_binding(spec, artifact_reader)` returns a `FixedPreparation` projection or raises a Harness `PublicError`. The spec must first pass `execution_service.validate`'s static shape checks; `Harness.execute` performs both checks in that order. Ordinary command mode reads no preparation. -The projection's `read(ref, reader)` port obtains a binary stream through +The projection's `read_prepared_binding(ref, reader)` port obtains a binary stream through `reader.open(ArtifactRef)`, closes it, bounds reads by the declared size plus one byte, and independently checks size and SHA-256. Missing bytes or a missing reader produce `ArtifactUnavailable`; changed bytes or noncanonical JSON produce `ArtifactIntegrityError`. Unknown host programming errors propagate. -`project(bytes)` is pure: it parses the canonical v1 envelope and validates the +`project_prepared_binding(bytes)` is pure: it parses the canonical v1 envelope and validates the fields used by Harness. It does not read a protocol, resolve an entry or start a process. A schema version other than v1 is explicitly unsupported. diff --git a/docs/contributing.md b/docs/contributing.md index 2864f2afd..7e69fbfb4 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -37,7 +37,7 @@ Nightly checks cover Linux and Windows checkouts with `core.autocrlf` set to Use `harness/serving` for a new model's server and request protocol and `benchmark/metrics.py` with `benchmark/validators` for its metric and quality checks. -`harness/trials/external.py` runs any external command as one trial and is the +`harness/executor/trials/external.py` runs any external command as one trial and is the same for every model. Use `apps/host/targets` with `resources/repo_packs` for repositories, and `apps/host/platforms` for hardware. A backend is registered in diff --git a/docs/guides/module-layout.md b/docs/guides/module-layout.md index 38d43afd3..5ad5a7b7e 100644 --- a/docs/guides/module-layout.md +++ b/docs/guides/module-layout.md @@ -341,8 +341,8 @@ The leaf's own import rule and `REPO_TYPES` object identity govern it. that, `inferrsi.infra` reached no Knowledge, Harness, Benchmark, or Apps module. - **Harness entries.** The registered component packages are `inferrsi.harness.manager` and `inferrsi.harness.executor`. The gate also - tracks `inferrsi.harness.api`, `inferrsi.harness.execution_service`, - `inferrsi.harness.input_binding`, `inferrsi.harness.local_process`, + tracks `inferrsi.harness.api`, `inferrsi.harness.executor._execution`, + `inferrsi.harness.executor._input_binding`, `inferrsi.harness.executor.local_process`, `inferrsi.harness.records`, its `_run_store` backend and `inferrsi.contracts._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 @@ -355,8 +355,8 @@ The leaf's own import rule and `REPO_TYPES` object identity govern it. module is walked on the full graph. A harness module that reaches an old root leaf fails, and so does each harness module that reaches the leaf through it. The report lists every remaining `harness` → Model or Infra - path in `harness_model_infra`; the split modules `harness.skill_evaluation`, - `harness.manager.search.improvement`, `harness.artifact_sandbox` and `harness.records.atomic_json` + path in `harness_model_infra`; the split modules `harness.executor.skill_evaluation`, + `harness.manager.search.improvement`, `harness.executor.artifact_sandbox` and `harness.records.atomic_json` have none. The manifest records the base commit, each old leaf's file hash at that diff --git a/docs/guides/operations.md b/docs/guides/operations.md index 5f55d199a..babb4499c 100644 --- a/docs/guides/operations.md +++ b/docs/guides/operations.md @@ -40,8 +40,8 @@ Effect classes used below: | Rebuild scoped legacy evidence views | `python tools/rebuild_model_evidence.py --archive --output ` | CPU-only; creates a new output directory | Authenticates original bytes and pinned projection/code; no extraction, network, archived-code execution or campaign qualification | | Inspect evidence inventory / generate budget input | `python tools/validate_evidence.py [--budget-assets]` | Read-only | Offline layout/hash/schema checks; optional disposable #328 metadata view derived from campaign authority; no downloads | | Execute one ordinary local CPU command with a fixed record | Python `inferrsi.harness.api.Harness.allocate` / `execute` / `read` | Experiment-executing / record-writing | One explicit RunStore root and one trusted local CPU target; ordinary command mode only; a record holds execution facts, so exit 0 is not a verdict; no device, model or network fallback | -| 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) | +| Seal a generation request before execution | Python `inferrsi.harness.executor.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 `verify_prepared_binding`, `read_prepared_binding` and `project_prepared_binding` from `inferrsi.harness.executor` | 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 | @@ -52,8 +52,8 @@ Effect classes used below: | 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 | | Configure the CPU evidence-smoke task | Python `benchmark.cpu_smoke.prepare_service`; [task contract](../contracts/p1-cpu-smoke.md) | Read-only owned resource configuration | Freezes the standalone worker and same-source baseline for the existing prepare port; actual execution/retention stays in H; no performance-gain claim | -| 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 | +| Seal a generation with frozen feedback authorization | Python `harness.executor.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.executor.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 | | Capture a knowledge context | CLI `campaign capture-context`; [offline dashboard](../dashboard.md#record-the-optimization-story-campaign-trace) | Local evidence-writing | Saves assembled context and resource hashes in a new `knowledge/.json`. Supports ordinary questions and explicit IDs. The only accepted explicit `--relevance-method` value is `find-lexical-v1` | | Retain an executed retrieval | Python `apps.workflows.campaign.save_retrieval`; [capture contract](knowledge/knowledge-retrieval-trace.md#retain-a-standalone-result) | Local evidence-writing | Saves an existing catalog/collect result under a fresh campaign capture ID; no new search or automatic publication | diff --git a/docs/guides/skill-evaluation/README.md b/docs/guides/skill-evaluation/README.md index acfea003c..ddf108107 100644 --- a/docs/guides/skill-evaluation/README.md +++ b/docs/guides/skill-evaluation/README.md @@ -14,12 +14,12 @@ are observations with order/cache/provider-drift confounding, not causal skill effects; a time-effect study needs a separately authorized frozen plan and budget. The small report-audit driver reuses `KnowledgeReader` bundles, the real Codex -CLI and `harness.local_process.execute_command`. It adapts the sibling pilot's +CLI and `harness.executor.local_process.execute_command`. It adapts the sibling pilot's fresh-session, event and independent-verifier methods; its old fixed no-skill/human/distilled controller is not imported. No external evaluation platform source is copied. Existing knowledge retains its source/license limits. -Ownership follows the module split. `inferrsi.harness.skill_evaluation` adapts the +Ownership follows the module split. `inferrsi.harness.executor.skill_evaluation` adapts the client, executes each trial and retains its facts. `inferrsi.benchmark.skill_evaluation` holds check validity, the task verdict and condition statistics. `inferrsi.apps.workflows.skill_evaluation` composes both with the bundle export behind the diff --git a/docs/guides/skill-evaluation/local-skill-evaluation.md b/docs/guides/skill-evaluation/local-skill-evaluation.md index 630697436..bf68d53b6 100644 --- a/docs/guides/skill-evaluation/local-skill-evaluation.md +++ b/docs/guides/skill-evaluation/local-skill-evaluation.md @@ -21,7 +21,7 @@ flowchart LR `tools/skill_eval_compare.py` still owns prepare/execute/report and paired snapshots. `tools/skill_eval_local.py` adds manual stage/capture, without launching an agent. `src/inferrsi/benchmark/skill_eval_engineering.py` owns the one task, its -19 public behavior probes and their judgment. `src/inferrsi/harness/artifact_sandbox.py` +19 public behavior probes and their judgment. `src/inferrsi/harness/executor/artifact_sandbox.py` replays the retained artifact under bubblewrap and separates the single writable artifact from frozen inputs; `src/inferrsi/apps/workflows/skill_eval_engineering.py` composes the two. The existing cloud read/submit route is unchanged; diff --git a/docs/guides/skill-evaluation/skill-eval-cloud-replay.md b/docs/guides/skill-evaluation/skill-eval-cloud-replay.md index ed9c482c7..8242613c6 100644 --- a/docs/guides/skill-evaluation/skill-eval-cloud-replay.md +++ b/docs/guides/skill-evaluation/skill-eval-cloud-replay.md @@ -26,7 +26,7 @@ The UTF-8 JSON object has exactly these keys (duplicate keys are rejected): - `grader_sha256`: SHA256 of the trusted `src/inferrsi/benchmark/skill_eval_engineering.py` file bytes: the task, its vectors and their judgment. The replay sandbox - (`src/inferrsi/harness/artifact_sandbox.py`) is not part of this digest; the + (`src/inferrsi/harness/executor/artifact_sandbox.py`) is not part of this digest; the receipt's qualification records the exact revision that ran it. - `inputs_sha256`, `protocol_sha256`: lowercase 64-character provenance digests. These are retained, **not independently authenticated by this receipt**. diff --git a/docs/guides/speculative-search.md b/docs/guides/speculative-search.md index 1efa07e44..98bfe6561 100644 --- a/docs/guides/speculative-search.md +++ b/docs/guides/speculative-search.md @@ -31,7 +31,7 @@ and `work_control`. For subprocess environment setup, replace imports of | Policy | `apps.workflows.search_roles` | Independent eight-feature linear softmax, recorded behavior probabilities, deterministic deployment actions | | Scorer | `apps.workflows.search_roles` | Separate linear model; actual suffix MSE and optional paid continuation differences | | Work/state authority | `harness.manager.search.work_control` | Transactions in the shared `RunStore` SQLite database | -| Execution | Existing `trials.external` and `local_process` | Absolute deadline and process-domain cleanup; no new subprocess runner | +| Execution | Existing `executor.trials.external` and `executor.local_process` | Absolute deadline and process-domain cleanup; no new subprocess runner | | Engine | `apps.workflows.search_benchmarks.EngineEvaluator` | Existing packaged `optimization.py` as one whole check; currently the Qwen denoiser NPU task | | Skill | `apps.workflows.search_benchmarks.SkillEvaluator`, checkout `tools.speculative_skill.Comparator` | Explicit provider configuration, original baseline, independent grader, separate development/holdout descriptors | | Final | `harness.manager.search.search_campaign.finalize` | One-time scope claim before access; receipt-only recovery/export; task promotion only | diff --git a/evidence/qwen-vats-gvo-910b1-20261124/plan/retained-sha256.json b/evidence/qwen-vats-gvo-910b1-20261124/plan/retained-sha256.json index 166e89790..82ba672ce 100644 --- a/evidence/qwen-vats-gvo-910b1-20261124/plan/retained-sha256.json +++ b/evidence/qwen-vats-gvo-910b1-20261124/plan/retained-sha256.json @@ -9,5 +9,5 @@ "results/summary.json": "df3029cfcaacb91018b6c931017b059b99a80633116586f9446fe82e31986132", "results/trials.jsonl": "6bd39719a5c0d794b1c5e04403b03789ae5ca42e0c9c74694200bdb6355a0756", "validator/README.md": "c224e3d864829d5c1a2f8bc4e4c89e36834409d4ce78fc1fa7dc59f6f739fdd3", - "validator/check.py": "61c274e036ec8167ddb18f9d102f4116a74e308a526f2ff4642bcd891a2d309c" + "validator/check.py": "83b89ce30d89c8dd68e7092403ec5b62d965a9a9587caa65fcd0b541def5d3fd" } diff --git a/evidence/qwen-vats-gvo-910b1-20261124/validator/check.py b/evidence/qwen-vats-gvo-910b1-20261124/validator/check.py index fe7eee0e8..a9ade12be 100644 --- a/evidence/qwen-vats-gvo-910b1-20261124/validator/check.py +++ b/evidence/qwen-vats-gvo-910b1-20261124/validator/check.py @@ -9,7 +9,8 @@ from statistics import geometric_mean from inferrsi.benchmark.registry import task_resources -from inferrsi.harness import candidates, task_protocol +from inferrsi.harness import task_protocol +from inferrsi.harness.executor import candidates from inferrsi.harness.manager.search.work_control import WorkControl from inferrsi.harness.records import RunStoreReader diff --git a/src/inferrsi/apps/cli/evaluate.py b/src/inferrsi/apps/cli/evaluate.py index d47d58985..8a5eccfac 100644 --- a/src/inferrsi/apps/cli/evaluate.py +++ b/src/inferrsi/apps/cli/evaluate.py @@ -93,7 +93,8 @@ def _prepare_ports(config: dict) -> dict: def _execute_ports(config: dict, storage: dict, *, capture_evidence: bool = False) -> dict: - from ...harness.api import Harness, LocalCpuTarget + from ...harness.api import Harness + from ...harness.executor import LocalCpuTarget from ...harness.records import RunStore from ..storage.artifact_reader import ArtifactReader diff --git a/src/inferrsi/apps/delivery/snapshot.py b/src/inferrsi/apps/delivery/snapshot.py index 22a2733c0..811553e90 100644 --- a/src/inferrsi/apps/delivery/snapshot.py +++ b/src/inferrsi/apps/delivery/snapshot.py @@ -5,7 +5,7 @@ import stat from pathlib import Path, PurePosixPath -from ...harness import candidates +from ...harness.executor import candidates from ..storage.artifacts import sha256 from .schema import decode diff --git a/src/inferrsi/apps/legacy/run.py b/src/inferrsi/apps/legacy/run.py index 1134b5778..28055f0cb 100644 --- a/src/inferrsi/apps/legacy/run.py +++ b/src/inferrsi/apps/legacy/run.py @@ -9,8 +9,8 @@ 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.executor.trials.external import execute_trial as _execute_trial 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 from .reporting import write_report diff --git a/src/inferrsi/apps/workflows/search_benchmarks.py b/src/inferrsi/apps/workflows/search_benchmarks.py index 7054cafc9..f5e0faf57 100644 --- a/src/inferrsi/apps/workflows/search_benchmarks.py +++ b/src/inferrsi/apps/workflows/search_benchmarks.py @@ -13,11 +13,11 @@ from inferrsi.apps.workflows.improvement import assessment from inferrsi.benchmark.improvement import SelectionPolicy, holdout_accepts from inferrsi.benchmark.registry import task_resources -from inferrsi.harness import candidates, task_protocol -from inferrsi.harness.executor import runtime_environment +from inferrsi.harness import task_protocol +from inferrsi.harness.executor import candidates, runtime_environment +from inferrsi.harness.executor.trials.external import execute_trial from inferrsi.harness.records.artifact_primitives import digest, sha256 from inferrsi.harness.records.atomic_json import atomic_write_json -from inferrsi.harness.trials.external import execute_trial class EngineEvaluator: diff --git a/src/inferrsi/apps/workflows/skill_eval_engineering.py b/src/inferrsi/apps/workflows/skill_eval_engineering.py index b907e9a53..9cf90f6bc 100644 --- a/src/inferrsi/apps/workflows/skill_eval_engineering.py +++ b/src/inferrsi/apps/workflows/skill_eval_engineering.py @@ -7,7 +7,7 @@ from pathlib import Path from inferrsi.benchmark import skill_eval_engineering as task_rules -from inferrsi.harness import artifact_sandbox +from inferrsi.harness.executor import artifact_sandbox def verify(task, output): diff --git a/src/inferrsi/apps/workflows/skill_evaluation.py b/src/inferrsi/apps/workflows/skill_evaluation.py index 16bc7acc8..b93d4cca4 100644 --- a/src/inferrsi/apps/workflows/skill_evaluation.py +++ b/src/inferrsi/apps/workflows/skill_evaluation.py @@ -6,7 +6,7 @@ from inferrsi.benchmark import skill_eval_engineering as engineering_task from inferrsi.benchmark import skill_evaluation as rules -from inferrsi.harness import skill_evaluation as host +from inferrsi.harness.executor import skill_evaluation as host from inferrsi.harness.records.usage import normalize_usage from inferrsi.knowledge.knowledge_operations import KnowledgeReader diff --git a/src/inferrsi/harness/README.md b/src/inferrsi/harness/README.md index 5f8e8b505..b07574899 100644 --- a/src/inferrsi/harness/README.md +++ b/src/inferrsi/harness/README.md @@ -7,7 +7,7 @@ measurement and assessment rules. ## Entry points - [the public API](api/__init__.py) exposes `Harness.allocate`, `execute`, and `read` for local - CPU commands. [`local_process.py`](local_process.py) owns the process domain. + CPU commands. The [Executor supervisor](executor/local_process.py) owns the process domain. - [Records](records/__init__.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. @@ -18,13 +18,13 @@ measurement and assessment rules. 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 +- [Skill trials](executor/skill_evaluation.py) execute commands and retain their results. + The [artifact sandbox](executor/artifact_sandbox.py) captures and replays submitted artifacts. - [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 + returned assessment. [External trials](executor/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. @@ -34,8 +34,18 @@ measurement and assessment rules. and final evaluation, and [work control](manager/search/work_control.py) records claims, receipts and budget use in the RunStore. See the [speculative search design](../../../docs/guides/speculative-search.md) for recovery rules. -- [Executor](executor/__init__.py) supplies `runtime_environment` so that child - processes use the same InferRSI installation as their parent. +- [Executor](executor/__init__.py) supplies the host's `LocalCpuTarget`, the + canonical `request_digest` and `runtime_environment`. Child processes use the + same InferRSI installation as their parent. Manager calls `process_group_empty` + on Executor when verifying a recorded service's process group. + Hosts import `prepare_generation` here to seal the context and plan before + registration. `read_prepared_binding` verifies the fixed artifact bytes, + `project_prepared_binding` reads the execution fields from those bytes, and + `verify_prepared_binding` compares them with the requested execution spec. + [Local execution](executor/_execution.py) snapshots inputs and the trusted entry before + starting a child. It seals captured evidence before the RunStore commits the attempt. + [Candidate retention](executor/candidates.py) fixes the input bytes for execution. + The [command supervisor](executor/confinement.py) runs commands within the selected backend. ## Managed optimization loop diff --git a/src/inferrsi/harness/__init__.py b/src/inferrsi/harness/__init__.py index ccfcd35ed..9e0149b66 100644 --- a/src/inferrsi/harness/__init__.py +++ b/src/inferrsi/harness/__init__.py @@ -1,6 +1 @@ -"""Harness: command execution and RunStore records, the AB/BA runner, optimization -sessions and their records. Verdict labels come from contracts; reports are injected.""" - -from inferrsi.contracts.claim import Verdict, parse_verdict - -__all__ = ["Verdict", "parse_verdict"] +"""Harness execution, evidence records and managed optimization sessions.""" diff --git a/src/inferrsi/harness/api/__init__.py b/src/inferrsi/harness/api/__init__.py index 6bc17909c..5b3d419c2 100644 --- a/src/inferrsi/harness/api/__init__.py +++ b/src/inferrsi/harness/api/__init__.py @@ -7,7 +7,7 @@ ) __all__ = [ - "PUBLIC_ERROR_CODES", "Harness", "LocalCpuTarget", "PartialExecutionFacts", "PublicError", + "PUBLIC_ERROR_CODES", "Harness", "PartialExecutionFacts", "PublicError", ] @@ -16,8 +16,4 @@ def __getattr__(name): from ._harness import Harness return Harness - if name == "LocalCpuTarget": - from inferrsi.harness.execution_service import LocalCpuTarget - - return LocalCpuTarget raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/src/inferrsi/harness/api/_harness.py b/src/inferrsi/harness/api/_harness.py index f6283397a..eb450db79 100644 --- a/src/inferrsi/harness/api/_harness.py +++ b/src/inferrsi/harness/api/_harness.py @@ -2,8 +2,8 @@ from collections.abc import Mapping -from inferrsi.harness import execution_service -from inferrsi.harness.execution_service import LocalCpuTarget +from inferrsi.harness.executor import LocalCpuTarget +from inferrsi.harness.executor import _execution as execution_service from inferrsi.harness.records import RunStore from inferrsi.harness.records import _run_store as run_store diff --git a/src/inferrsi/harness/attempt_recovery.py b/src/inferrsi/harness/attempt_recovery.py index 260940b6b..36cad4287 100644 --- a/src/inferrsi/harness/attempt_recovery.py +++ b/src/inferrsi/harness/attempt_recovery.py @@ -6,7 +6,7 @@ import uuid from pathlib import Path -from .launch_records import observe +from .executor.launch_records import observe from .records.atomic_json import durable_write_json from .records.evidence import bounded_record_bytes diff --git a/src/inferrsi/harness/executor/__init__.py b/src/inferrsi/harness/executor/__init__.py index 6a7cd6b55..9517f7cc4 100644 --- a/src/inferrsi/harness/executor/__init__.py +++ b/src/inferrsi/harness/executor/__init__.py @@ -1,4 +1,4 @@ -"""Execution request identity and child process environment.""" +"""Local execution targets, generation preparation and verified input bindings.""" import hashlib import os @@ -9,6 +9,34 @@ from inferrsi.contracts import json_v1 +__all__ = [ + "LocalCpuTarget", "prepare_generation", "process_group_empty", "project_prepared_binding", + "read_prepared_binding", "request_digest", "runtime_environment", "verify_prepared_binding", +] + + +def __getattr__(name): + if name == "LocalCpuTarget": + from ._target import LocalCpuTarget + + return LocalCpuTarget + if name == "prepare_generation": + from ._generation import prepare_generation + + return prepare_generation + if name in ("project_prepared_binding", "read_prepared_binding", "verify_prepared_binding"): + from . import _prepared_binding + + return getattr(_prepared_binding, name) + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + + +def process_group_empty(group: int) -> bool | None: + """Return whether the recorded group is empty, or None if it cannot be inspected.""" + from .local_process import _group_empty + + return _group_empty(group) + def runtime_environment() -> dict[str, str]: """Return a child environment bound to this InferRSI installation.""" diff --git a/src/inferrsi/harness/entry_code.py b/src/inferrsi/harness/executor/_entry_code.py similarity index 97% rename from src/inferrsi/harness/entry_code.py rename to src/inferrsi/harness/executor/_entry_code.py index ef8ed3e6a..ca466553a 100644 --- a/src/inferrsi/harness/entry_code.py +++ b/src/inferrsi/harness/executor/_entry_code.py @@ -6,7 +6,7 @@ from dataclasses import dataclass from pathlib import Path -from . import input_binding +from . import _input_binding as input_binding _MODULE = re.compile(r"[A-Za-z_][A-Za-z0-9_]*", re.ASCII) diff --git a/src/inferrsi/harness/evidence_capture.py b/src/inferrsi/harness/executor/_evidence_capture.py similarity index 99% rename from src/inferrsi/harness/evidence_capture.py rename to src/inferrsi/harness/executor/_evidence_capture.py index 72ce70827..a9e2e7618 100644 --- a/src/inferrsi/harness/evidence_capture.py +++ b/src/inferrsi/harness/executor/_evidence_capture.py @@ -9,7 +9,7 @@ from inferrsi.contracts import json_v1 from inferrsi.contracts._harness_errors import PublicError -from inferrsi.harness import input_binding +from inferrsi.harness.executor import _input_binding as input_binding from inferrsi.harness.records import _run_store as run_store CONTEXT_FIELDS = frozenset( diff --git a/src/inferrsi/harness/execution_service.py b/src/inferrsi/harness/executor/_execution.py similarity index 96% rename from src/inferrsi/harness/execution_service.py rename to src/inferrsi/harness/executor/_execution.py index d36ea8456..2f40f6947 100644 --- a/src/inferrsi/harness/execution_service.py +++ b/src/inferrsi/harness/executor/_execution.py @@ -14,17 +14,17 @@ from inferrsi.contracts import json_v1 from inferrsi.contracts._harness_errors import PublicError -from inferrsi.harness import ( - entry_code, - generation_lineage, - input_binding, +from inferrsi.harness.executor import ( + LocalCpuTarget, local_process, - prepared_binding, + request_digest, + verify_prepared_binding, ) -from inferrsi.harness import ( - evidence_capture as capture_service, -) -from inferrsi.harness.executor import request_digest +from inferrsi.harness.executor import _entry_code as entry_code +from inferrsi.harness.executor import _evidence_capture as capture_service +from inferrsi.harness.executor import _generation_lineage as generation_lineage +from inferrsi.harness.executor import _input_binding as input_binding +from inferrsi.harness.executor import _prepared_binding as prepared_binding from inferrsi.harness.records import RunStore from inferrsi.harness.records import _run_store as run_store @@ -82,45 +82,6 @@ _USAGE_SOURCE = "harness-local-process" -@dataclass(frozen=True) -class LocalCpuTarget: - """Trusted host configuration of the local CPU target; never read from a request. - - ``work_root`` holds per-attempt workspaces (``workspaces/``) and private - capture snapshots. ``controller_root`` / ``target_root`` authorize input sources of - those namespaces; ``None`` leaves that namespace unauthorized. ``module_root`` - explicitly enables evaluation through standalone source entries under that trusted - root. The retained source is executed directly in an isolated Python interpreter; - package imports and ambient cwd/PYTHONPATH entry resolution are not used. - """ - - target_id: str - config_revision: str - work_root: Path - controller_root: Path | None = None - target_root: Path | None = None - module_root: Path | None = None - - def __post_init__(self) -> None: - errors = [ - f"{name}: not an Id" - for name in ("target_id", "config_revision") - if not run_store._is_id(getattr(self, name)) - ] - for name in ("work_root", "controller_root", "target_root", "module_root"): - value = getattr(self, name) - if value is None: - continue - object.__setattr__(self, name, Path(value)) - if not Path(value).is_absolute(): - errors.append(f"{name}: must be an explicit absolute local path") - if errors: - raise PublicError( - "InvalidRequest", stage="configure", message="illegal local CPU target", - field_errors=errors, - ) - - def _decimal(seconds: float) -> str: """A canonical non-negative Decimal string with microsecond resolution.""" text = f"{max(seconds, 0.0):.6f}".rstrip("0").rstrip(".") @@ -469,7 +430,7 @@ def _validate_fresh(spec, target, artifact_reader, evaluation, *, store=None): if evaluation: # Malformed or inconsistent bindings are refused here, before the RunStore sees the # request. The reader is the read-only port; H does not write or register anything. - prepared_binding.verify(spec, artifact_reader) + verify_prepared_binding(spec, artifact_reader) unsupported = [] if evaluation and target.module_root is None: unsupported.append("this target has no configured evaluation module root") diff --git a/src/inferrsi/harness/generation.py b/src/inferrsi/harness/executor/_generation.py similarity index 97% rename from src/inferrsi/harness/generation.py rename to src/inferrsi/harness/executor/_generation.py index bb51bf2d1..715b9f2a2 100644 --- a/src/inferrsi/harness/generation.py +++ b/src/inferrsi/harness/executor/_generation.py @@ -6,9 +6,9 @@ from inferrsi.contracts._harness_errors import PublicError from inferrsi.contracts.json_v1 import encode -from inferrsi.harness import generation_feedback -from inferrsi.harness.execution_service import LocalCpuTarget, validate -from inferrsi.harness.executor import request_digest +from inferrsi.harness.executor import LocalCpuTarget, request_digest +from inferrsi.harness.executor import _generation_feedback as generation_feedback +from inferrsi.harness.executor._execution import validate from inferrsi.harness.records import RunStore from inferrsi.harness.records import _run_store as run_store diff --git a/src/inferrsi/harness/generation_feedback.py b/src/inferrsi/harness/executor/_generation_feedback.py similarity index 98% rename from src/inferrsi/harness/generation_feedback.py rename to src/inferrsi/harness/executor/_generation_feedback.py index 5bbcadffd..c8f92e49d 100644 --- a/src/inferrsi/harness/generation_feedback.py +++ b/src/inferrsi/harness/executor/_generation_feedback.py @@ -9,7 +9,7 @@ from inferrsi.contracts import json_v1 from inferrsi.contracts._harness_errors import PublicError -from inferrsi.harness import prepared_binding +from inferrsi.harness.executor import _prepared_binding as prepared_binding from inferrsi.harness.records import _run_store as run_store ROLE = "generation_feedback_policy" @@ -163,7 +163,7 @@ def _plan(value, context): "policy belongs to another campaign", "IdentityMismatch") _shape(value["starting_point"], {"candidate", "inputs", "generation_record_ref"}) _candidate(value["starting_point"]["candidate"]) - from inferrsi.harness.execution_service import _input_errors + from inferrsi.harness.executor._execution import _input_errors _require(not _input_errors(value["starting_point"]["inputs"]), "invalid starting inputs") _require(sum(item["role"] == value["starting_point"]["candidate"]["input_role"] @@ -193,7 +193,7 @@ def _requirements(reader, scoped): ref = scoped["prepared_ref"] data = _read(reader, ref["artifact"]) try: - fixed = prepared_binding.project(data) + fixed = prepared_binding.project_prepared_binding(data) except PublicError as exc: code = "InvalidRequest" if exc.code == "InvalidExecutionSpec" else exc.code raise _fail(code, exc.message) from exc diff --git a/src/inferrsi/harness/generation_lineage.py b/src/inferrsi/harness/executor/_generation_lineage.py similarity index 98% rename from src/inferrsi/harness/generation_lineage.py rename to src/inferrsi/harness/executor/_generation_lineage.py index b42fd8765..89fafbb04 100644 --- a/src/inferrsi/harness/generation_lineage.py +++ b/src/inferrsi/harness/executor/_generation_lineage.py @@ -6,7 +6,7 @@ from inferrsi.contracts import json_v1 from inferrsi.contracts._harness_errors import PublicError -from inferrsi.harness import prepared_binding +from inferrsi.harness.executor import _prepared_binding as prepared_binding from inferrsi.harness.records import _run_store as run_store _PLAN_FIELDS = {"schema_version", "provider", "output_contract", "context_refs", "attempt_id"} @@ -76,7 +76,7 @@ def _source(store, spec): _require(bounds["request_digest"] == record["request_digest"] and all(bounds[key] == record[key] for key in ("attempt_id", "run_id", "owner")), "generation differs from its original sealed binding") - from inferrsi.harness.execution_service import _request_errors + from inferrsi.harness.executor._execution import _request_errors _require(not _request_errors({**spec, "budget": bounds["budget"]}), "invalid original budget snapshot", "ArtifactIntegrityError") diff --git a/src/inferrsi/harness/input_binding.py b/src/inferrsi/harness/executor/_input_binding.py similarity index 100% rename from src/inferrsi/harness/input_binding.py rename to src/inferrsi/harness/executor/_input_binding.py diff --git a/src/inferrsi/harness/prepared_binding.py b/src/inferrsi/harness/executor/_prepared_binding.py similarity index 97% rename from src/inferrsi/harness/prepared_binding.py rename to src/inferrsi/harness/executor/_prepared_binding.py index 1440c3750..f1098ba0e 100644 --- a/src/inferrsi/harness/prepared_binding.py +++ b/src/inferrsi/harness/executor/_prepared_binding.py @@ -21,7 +21,7 @@ from inferrsi.contracts import json_v1 from inferrsi.contracts._harness_errors import PublicError -from inferrsi.harness import input_binding +from inferrsi.harness.executor import _input_binding as input_binding from inferrsi.harness.records import _run_store as run_store STAGE = "prepared_binding" @@ -151,7 +151,7 @@ def _recipe_errors(recipe: object) -> list[str]: return errors -def read(ref: Mapping, reader) -> bytes: +def read_prepared_binding(ref: Mapping, reader) -> bytes: """The fixed bytes of ``ref`` from the read-only port, verified against the Ref. The port's own verification is not trusted: size and hash are checked here again @@ -197,7 +197,7 @@ def read(ref: Mapping, reader) -> bytes: return b"".join(parts) -def project(data: bytes) -> FixedPreparation: +def project_prepared_binding(data: bytes) -> FixedPreparation: """Parse the identity fields of canonical PreparedEvaluation bytes.""" try: prepared = json_v1.decode(data) @@ -348,13 +348,14 @@ def _worker_errors(spec: Mapping, recipe: dict) -> list[str]: return errors -def verify(spec: Mapping, reader) -> FixedPreparation: +def verify_prepared_binding(spec: Mapping, reader) -> FixedPreparation: """Check an evaluation-mode spec against its fixed preparation before registration. ``spec`` has passed the static ExecutionSpec checks, so its evaluation fields are all set and well formed. Raises a PublicError for any malformed or inconsistent binding. """ - fixed = project(read(spec["prepared_ref"]["artifact"], reader)) + data = read_prepared_binding(spec["prepared_ref"]["artifact"], reader) + fixed = project_prepared_binding(data) if fixed.identity_rule not in (CAPTURED_SHA256, EXPECTED_SHA256): raise _refuse( "UnsupportedRuleVersion", "the frozen candidate identity rule is unsupported" diff --git a/src/inferrsi/harness/executor/_target.py b/src/inferrsi/harness/executor/_target.py new file mode 100644 index 000000000..10683d7e7 --- /dev/null +++ b/src/inferrsi/harness/executor/_target.py @@ -0,0 +1,48 @@ +"""Trusted local CPU target configuration supplied by the host.""" + +from __future__ import annotations + +from dataclasses import dataclass +from pathlib import Path + +from inferrsi.contracts._harness_errors import PublicError +from inferrsi.harness.records import _run_store as run_store + + +@dataclass(frozen=True) +class LocalCpuTarget: + """Trusted host configuration of the local CPU target; never read from a request. + + ``work_root`` holds per-attempt workspaces (``workspaces/``) and private + capture snapshots. ``controller_root`` / ``target_root`` authorize input sources of + those namespaces; ``None`` leaves that namespace unauthorized. ``module_root`` + explicitly enables evaluation through standalone source entries under that trusted + root. The retained source is executed directly in an isolated Python interpreter; + package imports and ambient cwd/PYTHONPATH entry resolution are not used. + """ + + target_id: str + config_revision: str + work_root: Path + controller_root: Path | None = None + target_root: Path | None = None + module_root: Path | None = None + + def __post_init__(self) -> None: + errors = [ + f"{name}: not an Id" + for name in ("target_id", "config_revision") + if not run_store._is_id(getattr(self, name)) + ] + for name in ("work_root", "controller_root", "target_root", "module_root"): + value = getattr(self, name) + if value is None: + continue + object.__setattr__(self, name, Path(value)) + if not Path(value).is_absolute(): + errors.append(f"{name}: must be an explicit absolute local path") + if errors: + raise PublicError( + "InvalidRequest", stage="configure", message="illegal local CPU target", + field_errors=errors, + ) diff --git a/src/inferrsi/harness/artifact_sandbox.py b/src/inferrsi/harness/executor/artifact_sandbox.py similarity index 100% rename from src/inferrsi/harness/artifact_sandbox.py rename to src/inferrsi/harness/executor/artifact_sandbox.py diff --git a/src/inferrsi/harness/candidates.py b/src/inferrsi/harness/executor/candidates.py similarity index 98% rename from src/inferrsi/harness/candidates.py rename to src/inferrsi/harness/executor/candidates.py index cc4b4b9d5..094e6ad78 100644 --- a/src/inferrsi/harness/candidates.py +++ b/src/inferrsi/harness/executor/candidates.py @@ -4,7 +4,7 @@ import stat from pathlib import Path -from .records.artifact_primitives import digest, sha256 +from ..records.artifact_primitives import digest, sha256 def members(source: Path, includes: list[str] | None = None) -> dict[str, Path]: diff --git a/src/inferrsi/harness/confinement.py b/src/inferrsi/harness/executor/confinement.py similarity index 99% rename from src/inferrsi/harness/confinement.py rename to src/inferrsi/harness/executor/confinement.py index 7b82da5e1..90a8035a8 100644 --- a/src/inferrsi/harness/confinement.py +++ b/src/inferrsi/harness/executor/confinement.py @@ -26,10 +26,11 @@ from pathlib import Path _ENV_ALLOW = frozenset({"PATH", "LANG", "LC_ALL", "LC_CTYPE", "TZ", "PYTHONIOENCODING"}) -_PACKAGE_ROOT = str(Path(__file__).resolve().parents[2]) +_PACKAGE_ROOT = str(Path(__file__).resolve().parents[3]) _SUPERVISOR = ( "import sys; sys.path.insert(0, sys.argv[1]); " - "from inferrsi.harness.confinement import enter_namespace; enter_namespace(sys.argv[2])" + "from inferrsi.harness.executor.confinement import enter_namespace; " + "enter_namespace(sys.argv[2])" ) _REAP_SECONDS = 10.0 _GUARD = """ diff --git a/src/inferrsi/harness/device_lease.py b/src/inferrsi/harness/executor/device_lease.py similarity index 97% rename from src/inferrsi/harness/device_lease.py rename to src/inferrsi/harness/executor/device_lease.py index e9e6e3666..1ecafd6df 100644 --- a/src/inferrsi/harness/device_lease.py +++ b/src/inferrsi/harness/executor/device_lease.py @@ -4,7 +4,7 @@ from contextlib import AbstractContextManager from pathlib import Path, PureWindowsPath -from .records.artifact_primitives import file_lock +from ..records.artifact_primitives import file_lock class LeaseError(RuntimeError): diff --git a/src/inferrsi/harness/launch_records.py b/src/inferrsi/harness/executor/launch_records.py similarity index 97% rename from src/inferrsi/harness/launch_records.py rename to src/inferrsi/harness/executor/launch_records.py index 8dc6f3cf1..a94b6a390 100644 --- a/src/inferrsi/harness/launch_records.py +++ b/src/inferrsi/harness/executor/launch_records.py @@ -6,8 +6,8 @@ from itertools import count from pathlib import Path -from .records.artifact_primitives import digest -from .records.atomic_json import durable_write_json +from ..records.artifact_primitives import digest +from ..records.atomic_json import durable_write_json def linux_process_domain() -> tuple[str | None, str | None]: diff --git a/src/inferrsi/harness/local_process.py b/src/inferrsi/harness/executor/local_process.py similarity index 99% rename from src/inferrsi/harness/local_process.py rename to src/inferrsi/harness/executor/local_process.py index e7201105e..dbd1fe29c 100644 --- a/src/inferrsi/harness/local_process.py +++ b/src/inferrsi/harness/executor/local_process.py @@ -6,7 +6,7 @@ from datetime import datetime, timezone from pathlib import Path -from .records.atomic_json import atomic_write_json +from ..records.atomic_json import atomic_write_json # H local process control domain (moved from infra in H02): one command inside its # Windows Job or POSIX process group, deadline and cancellation, and tree cleanup. @@ -181,10 +181,13 @@ def _stop_tree(process: subprocess.Popen, windows_job: _WindowsJob | None = None def _group_empty(group: int) -> bool | None: """Confirm a POSIX process group has no member left; None when unobservable.""" + killpg = getattr(os, "killpg", None) + if killpg is None: + return None deadline = time.monotonic() + _DRAIN_SECONDS while True: try: - os.killpg(group, 0) + killpg(group, 0) except ProcessLookupError: return True except PermissionError: diff --git a/src/inferrsi/harness/skill_evaluation.py b/src/inferrsi/harness/executor/skill_evaluation.py similarity index 98% rename from src/inferrsi/harness/skill_evaluation.py rename to src/inferrsi/harness/executor/skill_evaluation.py index 0bf229a7f..4002ffec7 100644 --- a/src/inferrsi/harness/skill_evaluation.py +++ b/src/inferrsi/harness/executor/skill_evaluation.py @@ -5,11 +5,11 @@ from dataclasses import dataclass from pathlib import Path +from ..records.atomic_json import atomic_write_json +from ..records.usage import normalize_usage as normalize_usage from . import artifact_sandbox -from .input_binding import file_sha256 +from ._input_binding import file_sha256 from .local_process import execute_command -from .records.atomic_json import atomic_write_json -from .records.usage import normalize_usage as normalize_usage def global_skills() -> list[str]: diff --git a/src/inferrsi/harness/trials/__init__.py b/src/inferrsi/harness/executor/trials/__init__.py similarity index 100% rename from src/inferrsi/harness/trials/__init__.py rename to src/inferrsi/harness/executor/trials/__init__.py diff --git a/src/inferrsi/harness/trials/external.py b/src/inferrsi/harness/executor/trials/external.py similarity index 97% rename from src/inferrsi/harness/trials/external.py rename to src/inferrsi/harness/executor/trials/external.py index d7cb3147c..1b6a97728 100644 --- a/src/inferrsi/harness/trials/external.py +++ b/src/inferrsi/harness/executor/trials/external.py @@ -5,8 +5,8 @@ from functools import partial from pathlib import Path +from ...records.atomic_json import atomic_write_json as _write_json from ..local_process import execute_command -from ..records.atomic_json import atomic_write_json as _write_json def execute_trial( diff --git a/src/inferrsi/harness/manager/_runner.py b/src/inferrsi/harness/manager/_runner.py index 5ed34134b..46d34b8ce 100644 --- a/src/inferrsi/harness/manager/_runner.py +++ b/src/inferrsi/harness/manager/_runner.py @@ -10,8 +10,8 @@ from ...contracts import RunSpec from ...contracts.runspec import revision_matches +from ..executor.trials.external import collect_trial_checks from ..records.atomic_json import atomic_write_json as _write_json -from ..trials.external import collect_trial_checks def run_experiment( diff --git a/src/inferrsi/harness/manager/search/_engine.py b/src/inferrsi/harness/manager/search/_engine.py index 080c70eba..2cea73648 100644 --- a/src/inferrsi/harness/manager/search/_engine.py +++ b/src/inferrsi/harness/manager/search/_engine.py @@ -65,7 +65,7 @@ def run_engine_search( Apps supplies a snapshot loader and an evaluator factory. The factory receives the frozen-input directory and retains the baseline there after budget admission. """ - from inferrsi.harness import candidates + from inferrsi.harness.executor import candidates from inferrsi.harness.records import RunStore from inferrsi.harness.records.artifact_primitives import digest from inferrsi.harness.records.atomic_json import atomic_write_json diff --git a/src/inferrsi/harness/manager/search/search_adapter.py b/src/inferrsi/harness/manager/search/search_adapter.py index 29accbde0..80308b29d 100644 --- a/src/inferrsi/harness/manager/search/search_adapter.py +++ b/src/inferrsi/harness/manager/search/search_adapter.py @@ -13,11 +13,10 @@ from pathlib import Path, PureWindowsPath from inferrsi.contracts.claim import Verdict -from inferrsi.harness import candidates -from inferrsi.harness.executor import runtime_environment +from inferrsi.harness.executor import candidates, runtime_environment +from inferrsi.harness.executor.trials.external import execute_trial from inferrsi.harness.records.artifact_primitives import digest, sha256 from inferrsi.harness.records.atomic_json import atomic_write_json -from inferrsi.harness.trials.external import execute_trial from . import search_tree as tree from .search_records import encode diff --git a/src/inferrsi/harness/optimization.py b/src/inferrsi/harness/optimization.py index 67158ef32..c43387642 100644 --- a/src/inferrsi/harness/optimization.py +++ b/src/inferrsi/harness/optimization.py @@ -9,7 +9,8 @@ from functools import cache from pathlib import Path -from . import analyzer, attempt_recovery, candidates, indexer +from . import analyzer, attempt_recovery, indexer +from .executor import candidates from .records import knowledge_capture, service_io from .records.artifact_primitives import digest, file_lock, sha256 from .records.atomic_json import atomic_write_json, durable_write_json @@ -1547,7 +1548,7 @@ def _service_cleanup_confirmed(state, attempt): def _service_cleanup_receipt(root, state, path): from . import project_service as service - from .local_process import _group_empty + from .executor import process_group_empty latest = state["pending"] or (state["attempts"][-1] if state["attempts"] else None) proof = service_io.read(path) @@ -1589,7 +1590,7 @@ def _service_cleanup_receipt(root, state, path): raise ValueError("Cleanup inspection service owner mismatch") if ( owner.get("process_group_id") is not None - and _group_empty(owner["process_group_id"]) is not True + and process_group_empty(owner["process_group_id"]) is not True ): raise ValueError("Recorded process domain is still live or unobservable") relative = "recoveries/cleanup-" + uuid.uuid4().hex + ".json" diff --git a/src/inferrsi/harness/optimization_session.py b/src/inferrsi/harness/optimization_session.py index 568cb2e23..a1376c675 100644 --- a/src/inferrsi/harness/optimization_session.py +++ b/src/inferrsi/harness/optimization_session.py @@ -17,8 +17,8 @@ def _session_execute(root, directory, plan, deadline): + from inferrsi.harness.executor.trials.external import execute_trial from inferrsi.harness.task_protocol import run as run_protocol - from inferrsi.harness.trials.external import execute_trial if plan["task_source"] == "project": return _project_execute(root, directory, plan, deadline) @@ -53,10 +53,10 @@ def _session_assess(root, directory, plan, execution, mechanism=None): def _project_execute(root, directory, plan, deadline): - from inferrsi.harness.candidates import identity, members, retain + from inferrsi.harness.executor.candidates import identity, members, retain + from inferrsi.harness.executor.trials.external import execute_trial from inferrsi.harness.project import inspect_step, steps from inferrsi.harness.records.atomic_json import atomic_write_json - from inferrsi.harness.trials.external import execute_trial output = directory / "execution" output.mkdir() @@ -128,7 +128,7 @@ def session_command(args, *, ranking_policy_for, task_source: Path | None = None if args.session_action == "start": import math - from inferrsi.harness.candidates import identity, retain + from inferrsi.harness.executor.candidates import identity, retain from inferrsi.harness.records.artifact_primitives import sha256 from inferrsi.harness.task_protocol import prepare @@ -409,7 +409,7 @@ def _run_entry(entry: str, arguments: list[str], *, launch_directory: Path | Non runtime_root = str(runner.parent.parent) sys.path.insert(0, runtime_root) try: - from inferrsi.harness.trials.external import execute_trial + from inferrsi.harness.executor.trials.external import execute_trial finally: sys.path.remove(runtime_root) diff --git a/src/inferrsi/harness/parallel_round.py b/src/inferrsi/harness/parallel_round.py index c79762b38..396a5ff1c 100644 --- a/src/inferrsi/harness/parallel_round.py +++ b/src/inferrsi/harness/parallel_round.py @@ -65,12 +65,12 @@ from pathlib import Path from inferrsi.contracts import RunSpec -from inferrsi.harness.confinement import ( +from inferrsi.harness.executor.confinement import ( ConfinementUnavailable, UnreapedCommand, confined_execute, ) -from inferrsi.harness.device_lease import DeviceLease, LeaseError +from inferrsi.harness.executor.device_lease import DeviceLease, LeaseError from inferrsi.harness.manager import run_experiment as run_experiment_loop from inferrsi.harness.records.artifact_primitives import digest from inferrsi.harness.round_budget import ( diff --git a/src/inferrsi/harness/project_service.py b/src/inferrsi/harness/project_service.py index 1133ffe5f..74d1ffdde 100644 --- a/src/inferrsi/harness/project_service.py +++ b/src/inferrsi/harness/project_service.py @@ -14,7 +14,7 @@ from pathlib import Path from statistics import mean, median -from .candidates import members, retain +from .executor.candidates import members, retain from .records import service_io from .records.atomic_json import atomic_write_json @@ -615,8 +615,8 @@ def proven_capture_elapsed(root, pending, execution): def execute(root, directory, plan, pending, deadline): """One retained attempt, one owned service, ordered client stages, no silent retry.""" from .executor import runtime_environment - from .local_process import supervised_service - from .trials.external import execute_trial + from .executor.local_process import supervised_service + from .executor.trials.external import execute_trial settings = plan["evaluation_settings"] conditions = pending["conditions"] diff --git a/src/inferrsi/harness/task_protocol.py b/src/inferrsi/harness/task_protocol.py index 8249f79c9..e523f5ae5 100644 --- a/src/inferrsi/harness/task_protocol.py +++ b/src/inferrsi/harness/task_protocol.py @@ -15,8 +15,9 @@ import time from pathlib import Path -from . import local_process, protocol_child -from .launch_records import LaunchRecord +from . import protocol_child +from .executor import local_process +from .executor.launch_records import LaunchRecord from .records.artifact_primitives import sha256 # One protocol operation must finish within this time; the child and every process in diff --git a/tests/apps/test_anthropic_agent.py b/tests/apps/test_anthropic_agent.py index d90059bac..180dd125d 100644 --- a/tests/apps/test_anthropic_agent.py +++ b/tests/apps/test_anthropic_agent.py @@ -9,7 +9,7 @@ from inferrsi.apps.integrations.anthropic import anthropic_agent as agent from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows import skill_evaluation as evaluation -from inferrsi.harness import skill_evaluation as harness +from inferrsi.harness.executor import skill_evaluation as harness from tests.fixtures.skill_eval_compare_support import configuration from tools import skill_eval_compare as compare from tools.skill_eval_pilot import SCHEMA diff --git a/tests/apps/test_apps_evaluate_cli.py b/tests/apps/test_apps_evaluate_cli.py index b6302d6b1..6a5b56981 100644 --- a/tests/apps/test_apps_evaluate_cli.py +++ b/tests/apps/test_apps_evaluate_cli.py @@ -18,7 +18,7 @@ from inferrsi.benchmark import cpu_smoke from inferrsi.benchmark.workers import fixture_worker as worker from inferrsi.contracts.json_v1 import decode, encode -from inferrsi.harness import execution_service +from inferrsi.harness.executor import _execution as execution_service from inferrsi.harness.records import RunStore from inferrsi.harness.records import _run_store as run_store from tests.apps.test_apps_generation_plan import generation as generation diff --git a/tests/apps/test_apps_evidence_capture.py b/tests/apps/test_apps_evidence_capture.py index ade4181a6..b0bd5aabc 100644 --- a/tests/apps/test_apps_evidence_capture.py +++ b/tests/apps/test_apps_evidence_capture.py @@ -19,8 +19,9 @@ from inferrsi.benchmark import assessment, proofs from inferrsi.benchmark import preparation as benchmark from inferrsi.contracts.json_v1 import decode, encode -from inferrsi.harness import execution_service -from inferrsi.harness.api import Harness, LocalCpuTarget +from inferrsi.harness.api import Harness +from inferrsi.harness.executor import LocalCpuTarget +from inferrsi.harness.executor import _execution as execution_service from inferrsi.harness.records import RunStore from inferrsi.harness.records import _run_store as run_store from tests.benchmark.test_benchmark_preparation import preparation as preparation diff --git a/tests/apps/test_apps_fixed_cpu_views.py b/tests/apps/test_apps_fixed_cpu_views.py index dd702fb31..a6ef3fabe 100644 --- a/tests/apps/test_apps_fixed_cpu_views.py +++ b/tests/apps/test_apps_fixed_cpu_views.py @@ -16,7 +16,7 @@ from inferrsi.apps.views.dashboard_live import DashboardServer from inferrsi.contracts.json_v1 import encode from inferrsi.harness.api import Harness -from inferrsi.harness.generation import prepare_generation +from inferrsi.harness.executor import prepare_generation from inferrsi.harness.records import RunStore, RunStoreReader from inferrsi.harness.records._run_store import Claim from tests.apps.test_apps_generation_plan import generation as generation diff --git a/tests/apps/test_apps_generation_plan.py b/tests/apps/test_apps_generation_plan.py index 96c3f41a4..2c5bc120c 100644 --- a/tests/apps/test_apps_generation_plan.py +++ b/tests/apps/test_apps_generation_plan.py @@ -12,7 +12,8 @@ from inferrsi.apps.storage.artifact_reader import ArtifactReader from inferrsi.contracts.json_v1 import decode, encode from inferrsi.harness.api import Harness, PublicError -from inferrsi.harness.execution_service import LocalCpuTarget, validate +from inferrsi.harness.executor import LocalCpuTarget +from inferrsi.harness.executor._execution import validate from inferrsi.harness.records import RunStore _FIXTURES = Path(__file__).resolve().parents[2] / "docs/contracts/fixtures/t108-v4" diff --git a/tests/apps/test_apps_generation_views.py b/tests/apps/test_apps_generation_views.py index 5e0c44fc4..eacf5f1a8 100644 --- a/tests/apps/test_apps_generation_views.py +++ b/tests/apps/test_apps_generation_views.py @@ -10,7 +10,7 @@ from inferrsi.apps.views.attempt_html import render_attempt from inferrsi.contracts.json_v1 import encode from inferrsi.harness.api import PublicError -from inferrsi.harness.generation import prepare_generation +from inferrsi.harness.executor import prepare_generation from tests.apps.test_apps_generation_plan import generation as generation from tests.harness.test_harness_generation_seal import cpu_generation as cpu_generation diff --git a/tests/apps/test_apps_module_migrations.py b/tests/apps/test_apps_module_migrations.py index a24774d49..3bb6180b8 100644 --- a/tests/apps/test_apps_module_migrations.py +++ b/tests/apps/test_apps_module_migrations.py @@ -176,7 +176,7 @@ def test_cold_storage_imports_do_not_load_handoff_or_probe_modules(): blocked = ('inferrsi.apps.handoff', 'inferrsi.apps.api', 'inferrsi.apps.bridge', 'inferrsi.apps.context_provider', 'inferrsi.apps.candidate_provider', 'inferrsi.apps.host', 'inferrsi.knowledge', 'inferrsi.benchmark', - 'inferrsi.harness.execution_service', 'inferrsi.harness.records._run_store', + 'inferrsi.harness.executor._execution', 'inferrsi.harness.records._run_store', 'sqlite3', '_sqlite3') class Block(importlib.abc.MetaPathFinder): def find_spec(self, name, path=None, target=None): @@ -240,8 +240,8 @@ def test_cold_handoff_and_workflow_imports_do_not_read_data_probe_or_launch_serv script = """ import builtins, importlib, importlib.abc, io, json, socket, sqlite3, subprocess, sys, warnings from unittest.mock import patch -blocked = ('inferrsi.apps.api', 'inferrsi.harness.execution_service', - 'inferrsi.harness.records._run_store', 'inferrsi.harness.generation', +blocked = ('inferrsi.apps.api', 'inferrsi.harness.executor._execution', + 'inferrsi.harness.records._run_store', 'inferrsi.harness.executor._generation', 'torch', 'numpy', 'PIL', 'vllm') if sys.argv[2] == 'handoff': blocked += ('inferrsi.apps.host', 'inferrsi.benchmark', 'inferrsi.apps.integrations') diff --git a/tests/apps/test_apps_port_validation.py b/tests/apps/test_apps_port_validation.py index bd43aa1b1..dd79f3c75 100644 --- a/tests/apps/test_apps_port_validation.py +++ b/tests/apps/test_apps_port_validation.py @@ -79,7 +79,7 @@ def test_importing_the_digest_leaves_storage_and_execution_unloaded(): assert find_spec("inferrsi.harness.execution_spec") is None assert find_spec("inferrsi.harness.run_store") is None assert not {"sqlite3", "_sqlite3", - "inferrsi.harness.records._run_store", "inferrsi.harness.execution_service", + "inferrsi.harness.records._run_store", "inferrsi.harness.executor._execution", "inferrsi.harness.executor._execution_service"} & sys.modules.keys() """ subprocess.run([sys.executable, "-c", probe], env=child_env(), check=True) diff --git a/tests/apps/test_apps_production_cli.py b/tests/apps/test_apps_production_cli.py index 01c511930..1c985b32a 100644 --- a/tests/apps/test_apps_production_cli.py +++ b/tests/apps/test_apps_production_cli.py @@ -17,7 +17,7 @@ from inferrsi.benchmark import cpu_smoke, proofs from inferrsi.benchmark.workers import fixture_worker as worker from inferrsi.contracts.json_v1 import decode, encode -from inferrsi.harness import execution_service +from inferrsi.harness.executor import _execution as execution_service from inferrsi.harness.executor import request_digest from inferrsi.harness.records import RunStore from inferrsi.harness.records import _run_store as run_store diff --git a/tests/apps/test_legacy_run_split.py b/tests/apps/test_legacy_run_split.py index dbf37302d..e7ba0641e 100644 --- a/tests/apps/test_legacy_run_split.py +++ b/tests/apps/test_legacy_run_split.py @@ -20,8 +20,8 @@ from inferrsi.apps.storage import artifacts from inferrsi.benchmark import legacy_run_v0, metrics, sampling from inferrsi.contracts import RunSpec, claim +from inferrsi.harness.executor.trials.external import execute_trial 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 GRAPH = _scan(ROOT, frozenset()) @@ -45,13 +45,13 @@ def test_moved_harness_modules_are_gone_without_shells(): def test_runner_and_external_lost_their_model_artifact_and_target_edges(): 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.executor.trials.external", "inferrsi.model") == set() + assert _outside("inferrsi.harness.executor.trials.external", "inferrsi.infra") <= PROCESS_DOMAIN assert _outside("inferrsi.harness.records.atomic_json", "inferrsi.") == { "inferrsi.harness", "inferrsi.harness.records", } # Transitively the old chain keeps only the process domain, and no new core. - for module in ("inferrsi.harness.manager._runner", "inferrsi.harness.trials.external"): + for module in ("inferrsi.harness.manager._runner", "inferrsi.harness.executor.trials.external"): reached = _reached(module) assert {n for n in reached if n.startswith(("inferrsi.model", "inferrsi.infra"))} <= ( PROCESS_DOMAIN diff --git a/tests/apps/test_optimization_session.py b/tests/apps/test_optimization_session.py index 9382a5024..c9f9b4def 100644 --- a/tests/apps/test_optimization_session.py +++ b/tests/apps/test_optimization_session.py @@ -133,7 +133,7 @@ def test_packaged_round_uses_target_dependencies(task, tmp_path, capsys, monkeyp def test_group_observation_requires_the_recorded_boot_and_namespace( monkeypatch, recorded, current, probe, result, ): - from inferrsi.harness import launch_records + from inferrsi.harness.executor import launch_records calls = [] @@ -423,7 +423,7 @@ def start(log): def test_launch_intent_appears_only_after_flush_and_cannot_replace_prior_intent( tmp_path, monkeypatch, ): - from inferrsi.harness.launch_records import LaunchRecord + from inferrsi.harness.executor.launch_records import LaunchRecord path = tmp_path / "launch-step.json" @@ -445,8 +445,8 @@ def fail_before_publication(_descriptor): def test_missing_executable_is_recorded_as_never_spawned(tmp_path): - from inferrsi.harness.launch_records import observe - from inferrsi.harness.trials.external import execute_trial + from inferrsi.harness.executor.launch_records import observe + from inferrsi.harness.executor.trials.external import execute_trial execution = tmp_path / "execution" launch_path = execution / "launch-01.json" @@ -467,7 +467,7 @@ def test_recovery_counts_an_interrupted_round_once_and_keeps_every_step( ): from inferrsi.apps.delivery import read_bundle from inferrsi.apps.views.dashboard import dashboard_snapshot - from inferrsi.harness import launch_records + from inferrsi.harness.executor import launch_records best = submit(session, 2, capsys)["best"] calls = session / "step-calls.log" @@ -550,7 +550,7 @@ def stop_during_second_step(root, attempt, plan, deadline): def test_recover_never_spawns_a_second_assessor_with_a_receipt( session, capsys, monkeypatch, held_child, ): - from inferrsi.harness import launch_records + from inferrsi.harness.executor import launch_records execute = optimization_session._session_execute calls = session / "assessor-calls.log" @@ -671,7 +671,7 @@ def should_not_assess(*args): def test_frozen_drift_retains_unconfirmed_launch( session, monkeypatch, capsys, operation, recorded_gate, ): - from inferrsi.harness.launch_records import LaunchRecord + from inferrsi.harness.executor.launch_records import LaunchRecord def stop_during_assessment(root, attempt, plan, execution): LaunchRecord.numbered(attempt, "protocol-assess", ["assess"]) @@ -1429,7 +1429,7 @@ def test_runtime_identity_covers_migrated_process_domain_and_not_removed_executo identity = optimization_session._runtime_identity() root = Path(str(files("inferrsi"))) - assert "harness/local_process.py" in identity + assert "harness/executor/local_process.py" in identity # #412 R2: the Harness-owned primitives replace infra.artifacts in six modules. assert "harness/records/artifact_primitives.py" in identity # #412 R3: the protocol child entry runs every task protocol operation. @@ -1443,6 +1443,9 @@ def test_runtime_identity_covers_migrated_process_domain_and_not_removed_executo assert (root / name).is_file(), name assert "infra/processes.py" not in identity assert "harness/serving/server.py" not in identity + # The explicit prepare_generation import reaches execution validation even before use. + assert "harness/executor/_generation.py" in identity + assert "harness/executor/_execution.py" in identity assert "harness/execution_service.py" not in identity assert "benchmark/assessment.py" not in identity evidence = (root / "harness/records/evidence.py").read_bytes() @@ -1514,7 +1517,7 @@ def _session_bytes(root): @pytest.mark.parametrize("fixture, removed_file", [ # #498 slice 5 removed infra/artifacts.py from the runtime identity. ("pre-infra-removal-session", "infra/artifacts.py"), - # #558 renamed harness/scenarios to harness/trials. + # The pre-#558 session records the original scenarios path. ("pre-trials-rename-session", "harness/scenarios/external.py"), ("pre-recovery-closure-session", "harness/serving/server.py"), ]) diff --git a/tests/apps/test_project_optimization.py b/tests/apps/test_project_optimization.py index f4f2887d9..d6fe65c3c 100644 --- a/tests/apps/test_project_optimization.py +++ b/tests/apps/test_project_optimization.py @@ -441,7 +441,7 @@ def test_changed_retained_assessment_is_rejected(project, capsys): def test_candidate_directory_identity_includes_new_files(tmp_path): - from inferrsi.harness.candidates import identity, retain + from inferrsi.harness.executor.candidates import identity, retain source = tmp_path / "source" source.mkdir() @@ -454,7 +454,7 @@ def test_candidate_directory_identity_includes_new_files(tmp_path): @pytest.mark.skipif(os.name == "nt", reason="POSIX executable mode") def test_snapshot_preserves_executable_helper_and_binds_its_mode(tmp_path): - from inferrsi.harness.candidates import identity, retain + from inferrsi.harness.executor.candidates import identity, retain source = tmp_path / "source" source.mkdir() @@ -471,7 +471,7 @@ def test_snapshot_preserves_executable_helper_and_binds_its_mode(tmp_path): def test_record_read_verifies_each_distinct_candidate_again_on_next_read(project, capsys): from unittest.mock import patch - from inferrsi.harness import candidates + from inferrsi.harness.executor import candidates start(project, capsys) root = project[3] @@ -494,7 +494,7 @@ def test_record_read_verifies_each_distinct_candidate_again_on_next_read(project def test_shared_candidate_path_still_checks_each_recorded_digest(project, capsys): from unittest.mock import patch - from inferrsi.harness import candidates + from inferrsi.harness.executor import candidates start(project, capsys) root = project[3] diff --git a/tests/apps/test_project_service_reuse.py b/tests/apps/test_project_service_reuse.py index f54130b79..09b541b8f 100644 --- a/tests/apps/test_project_service_reuse.py +++ b/tests/apps/test_project_service_reuse.py @@ -537,7 +537,7 @@ def test_profile_timeout_retains_quality_and_stops_without_silent_retry(campaign def test_profile_interruption_retains_verdict_with_verified_cleanup(campaign, monkeypatch): - from inferrsi.harness.trials import external + from inferrsi.harness.executor.trials import external begin(campaign) original = external.execute_trial @@ -1329,7 +1329,7 @@ def test_refresh_without_round_capacity_preserves_finalizable_state(campaign, ro def test_backfill_after_final_preserves_original_evidence_and_selection(campaign, monkeypatch): from inferrsi.apps.views.dashboard import dashboard_snapshot, render_dashboard - from inferrsi.harness.trials import external + from inferrsi.harness.executor.trials import external baseline = begin(campaign)["best"] attempt = submit(campaign, version="selected", a=90)["latest_observation"] @@ -1628,7 +1628,7 @@ def stop_after_durable_boundary(path, document): def advance_clock_during_profile(monkeypatch, seconds): - from inferrsi.harness.trials import external + from inferrsi.harness.executor.trials import external wall_offset = 0 clock = SimpleNamespace( diff --git a/tests/apps/test_search_benchmarks.py b/tests/apps/test_search_benchmarks.py index 8e7745cf4..e8a811582 100644 --- a/tests/apps/test_search_benchmarks.py +++ b/tests/apps/test_search_benchmarks.py @@ -13,7 +13,8 @@ from inferrsi.apps.workflows.search_roles import Snapshot from inferrsi.apps.workflows.speculative_search import command from inferrsi.benchmark.improvement import SelectionPolicy -from inferrsi.harness import candidates +from inferrsi.harness.executor import candidates +from inferrsi.harness.executor.trials.external import execute_trial from inferrsi.harness.manager import EngineSearchPlan, read_engine_search, run_engine_search from inferrsi.harness.manager.search.search_adapter import ArtifactAdapter, Edit from inferrsi.harness.manager.search.search_campaign import ( @@ -28,7 +29,6 @@ from inferrsi.harness.records import RunStore from inferrsi.harness.records.artifact_primitives import digest from inferrsi.harness.task_protocol import TaskProtocolError -from inferrsi.harness.trials.external import execute_trial from tests.fixtures.speculative_search import contract diff --git a/tests/apps/test_trial_checks.py b/tests/apps/test_trial_checks.py index 643858461..ecd4b8a45 100644 --- a/tests/apps/test_trial_checks.py +++ b/tests/apps/test_trial_checks.py @@ -13,7 +13,7 @@ from inferrsi.apps.legacy.run import run_experiment from inferrsi.apps.views.summary_chart import SpecError, spec_from_evaluation from inferrsi.contracts import RunSpec -from inferrsi.harness.trials.external import collect_trial_checks +from inferrsi.harness.executor.trials.external import collect_trial_checks def evaluated_pair(checks, side="candidate"): diff --git a/tests/apps/test_yibuapi_runtime.py b/tests/apps/test_yibuapi_runtime.py index 54264d29a..31df4d2e9 100644 --- a/tests/apps/test_yibuapi_runtime.py +++ b/tests/apps/test_yibuapi_runtime.py @@ -9,7 +9,7 @@ from inferrsi.apps.integrations.anthropic import anthropic_agent as agent from inferrsi.apps.storage.artifacts import write_json -from inferrsi.harness import skill_evaluation as harness +from inferrsi.harness.executor import skill_evaluation as harness from tests.apps.test_anthropic_agent import ANSWER, MODEL, SCHEMA_SMALL, read, submit from tests.fixtures.skill_eval_compare_support import DATA from tests.fixtures.skill_eval_pr_support import SimulatedGitHub, approval, setup diff --git a/tests/benchmark/test_benchmark_cpu_smoke.py b/tests/benchmark/test_benchmark_cpu_smoke.py index a678b1d94..f3f215812 100644 --- a/tests/benchmark/test_benchmark_cpu_smoke.py +++ b/tests/benchmark/test_benchmark_cpu_smoke.py @@ -18,8 +18,9 @@ from inferrsi.benchmark import preparation as prepare_port from inferrsi.benchmark.workers import fixture_worker as worker from inferrsi.contracts.json_v1 import decode -from inferrsi.harness import execution_service -from inferrsi.harness.api import Harness, LocalCpuTarget +from inferrsi.harness.api import Harness +from inferrsi.harness.executor import LocalCpuTarget +from inferrsi.harness.executor import _execution as execution_service from inferrsi.harness.records import RunStore from inferrsi.harness.records import _run_store as run_store from tests.benchmark.test_benchmark_preparation import preparation as preparation diff --git a/tests/benchmark/test_benchmark_operations.py b/tests/benchmark/test_benchmark_operations.py index 4b37cbcfc..e7bc287d0 100644 --- a/tests/benchmark/test_benchmark_operations.py +++ b/tests/benchmark/test_benchmark_operations.py @@ -113,7 +113,7 @@ def test_application_injects_executor_and_preserves_script_imports(library): (package / "benchmark.py").write_text( "from helper import VALUE\n" "assert VALUE == 42\n" - "assert execute_trial.__module__ == 'inferrsi.harness.trials.external'\n", + "assert execute_trial.__module__ == 'inferrsi.harness.executor.trials.external'\n", encoding="utf-8", ) assert main(["benchmarks", "run", package.name]) == 0 @@ -151,7 +151,7 @@ def test_direct_task_child_uses_the_selected_runtime_before_host_imports(tmp_pat result = subprocess.run( [sys.executable, "-I", "-S", "-c", bootstrap, str(runner), str(entry), "" if startup_shadow == "cwd" else str(shadow), - str(runner.parent / "trials/external.py")], + str(runner.parent / "executor/trials/external.py")], cwd=tmp_path, capture_output=True, text=True, encoding="utf-8", timeout=30, ) assert result.returncode == 0, result.stderr diff --git a/tests/benchmark/test_moe_benchmark.py b/tests/benchmark/test_moe_benchmark.py index 82495e285..6f45a8f8e 100644 --- a/tests/benchmark/test_moe_benchmark.py +++ b/tests/benchmark/test_moe_benchmark.py @@ -13,7 +13,7 @@ import pytest from inferrsi.benchmark.metrics import read_metric -from inferrsi.harness.trials.external import execute_trial +from inferrsi.harness.executor.trials.external import execute_trial from tests.benchmark.engineering_task_support import load_task_module moe = load_task_module("moe-forward-npu", "benchmark") diff --git a/tests/campaigns/test_qwen_gvo_diagnostic.py b/tests/campaigns/test_qwen_gvo_diagnostic.py index 319199e0e..e726abf87 100644 --- a/tests/campaigns/test_qwen_gvo_diagnostic.py +++ b/tests/campaigns/test_qwen_gvo_diagnostic.py @@ -93,7 +93,7 @@ def unexpected_load(*args, **kwargs): "fault", ["verdict", "promotion", "selection", "receipt", "source", "rule", "operation-rule"] ) def test_offline_checker_requires_bound_durable_promotion(tmp_path, fault): - from inferrsi.harness import candidates + from inferrsi.harness.executor import candidates checker = module("validator/check.py") candidate_dir = tmp_path / "winner" diff --git a/tests/contracts/test_contracts_package.py b/tests/contracts/test_contracts_package.py index fd7e4c720..5b2669eb1 100644 --- a/tests/contracts/test_contracts_package.py +++ b/tests/contracts/test_contracts_package.py @@ -131,10 +131,10 @@ def test_initializer_reexports_only_runspec_and_there_is_one_class() -> None: assert inspect.signature(run_experiment).parameters["spec"].annotation is RunSpec -def test_harness_reexports_the_same_verdict_objects() -> None: - assert harness.__all__ == ["Verdict", "parse_verdict"] - assert harness.Verdict is claim.Verdict - assert harness.parse_verdict is claim.parse_verdict +def test_verdict_types_are_available_from_the_claim_contract() -> None: + assert claim.parse_verdict("pass") is claim.Verdict.PASS + assert not hasattr(harness, "Verdict") + assert not hasattr(harness, "parse_verdict") assert claim.Verdict.__module__ == "inferrsi.contracts.claim" diff --git a/tests/harness/test_confinement.py b/tests/harness/test_confinement.py index b600eab05..c610d1277 100644 --- a/tests/harness/test_confinement.py +++ b/tests/harness/test_confinement.py @@ -10,8 +10,8 @@ import pytest -from inferrsi.harness import confinement -from inferrsi.harness.confinement import ( +from inferrsi.harness.executor import confinement +from inferrsi.harness.executor.confinement import ( ConfinementUnavailable, FixtureBackend, UnavailableBackend, @@ -68,7 +68,7 @@ def test_missing_backend_refuses_without_running(tmp_path): def test_select_backend_fails_closed_when_namespaces_are_disabled(monkeypatch): - monkeypatch.setattr("inferrsi.harness.confinement.namespaces_available", lambda: False) + monkeypatch.setattr("inferrsi.harness.executor.confinement.namespaces_available", lambda: False) assert isinstance(select_backend(), UnavailableBackend) @@ -93,7 +93,7 @@ def fake_popen(argv, **kwargs): return FailedUnshare(argv) return real_popen(argv, **kwargs) - monkeypatch.setattr("inferrsi.harness.confinement.subprocess.Popen", fake_popen) + monkeypatch.setattr("inferrsi.harness.executor.confinement.subprocess.Popen", fake_popen) with pytest.raises(ConfinementUnavailable, match="unshare failed"): UnshareBackend().run( (sys.executable, "-c", "print('should-not-run')"), @@ -131,7 +131,7 @@ def fake_popen(argv, **kwargs): argv = [sys.executable, "-c", payload] return real_popen(argv, **kwargs) - monkeypatch.setattr("inferrsi.harness.confinement.subprocess.Popen", fake_popen) + monkeypatch.setattr("inferrsi.harness.executor.confinement.subprocess.Popen", fake_popen) with pytest.raises(ConfinementUnavailable, match="timed out"): UnshareBackend().run( (sys.executable, "-c", "print('unused')"), @@ -174,13 +174,15 @@ def killpg(pgid, sig): def test_supervisor_ignores_a_shadow_package_in_the_candidate(tmp_path): shadow = tmp_path / "candidate" - (shadow / "inferrsi" / "infra").mkdir(parents=True) + executor = shadow / "inferrsi" / "harness" / "executor" + executor.mkdir(parents=True) canary = tmp_path / "shadow-imported" (shadow / "inferrsi" / "__init__.py").write_text( f"open({str(canary)!r}, 'w').write('1')\n", encoding="utf-8" ) - (shadow / "inferrsi" / "infra" / "__init__.py").write_text("", encoding="utf-8") - (shadow / "inferrsi" / "infra" / "confinement.py").write_text( + (executor.parent / "__init__.py").touch() + (executor / "__init__.py").touch() + (executor / "confinement.py").write_text( "def enter_namespace(path):\n raise SystemExit('shadow')\n", encoding="utf-8" ) completed = subprocess.run( @@ -273,7 +275,7 @@ def test_runtime_roots_under_system_python_exclude_usr(): script = ( "import json, sys, sysconfig\n" "sys.path[:0] = %r\n" - "from inferrsi.harness.confinement import runtime_roots\n" + "from inferrsi.harness.executor.confinement import runtime_roots\n" "print(json.dumps({\n" " 'roots': [str(p) for p in runtime_roots()],\n" " 'prefix': sys.prefix,\n" @@ -429,7 +431,7 @@ def blocked(argv, **kwargs): return subprocess.CompletedProcess(argv, 1, stderr=b"Operation not permitted") monkeypatch.setattr(Path, "read_text", fake_read) - monkeypatch.setattr("inferrsi.harness.confinement.subprocess.run", blocked) + monkeypatch.setattr("inferrsi.harness.executor.confinement.subprocess.run", blocked) assert namespaces_available() is False diff --git a/tests/harness/test_harness_entry_verification.py b/tests/harness/test_harness_entry_verification.py index a5e311a6e..7a5dbffeb 100644 --- a/tests/harness/test_harness_entry_verification.py +++ b/tests/harness/test_harness_entry_verification.py @@ -18,8 +18,10 @@ from inferrsi.apps.storage.artifact_reader import ArtifactReader from inferrsi.benchmark import preparation as benchmark from inferrsi.contracts.json_v1 import decode -from inferrsi.harness import entry_code, execution_service -from inferrsi.harness.api import Harness, LocalCpuTarget, PublicError +from inferrsi.harness.api import Harness, PublicError +from inferrsi.harness.executor import LocalCpuTarget +from inferrsi.harness.executor import _entry_code as entry_code +from inferrsi.harness.executor import _execution as execution_service from inferrsi.harness.records import RunStore from inferrsi.harness.records import _run_store as run_store from tests.benchmark.test_benchmark_preparation import preparation as preparation diff --git a/tests/harness/test_harness_evaluation_replay.py b/tests/harness/test_harness_evaluation_replay.py index 16cc71b91..fdbf91685 100644 --- a/tests/harness/test_harness_evaluation_replay.py +++ b/tests/harness/test_harness_evaluation_replay.py @@ -12,9 +12,9 @@ import pytest from inferrsi.contracts.json_v1 import encode -from inferrsi.harness import execution_service -from inferrsi.harness.api import Harness, LocalCpuTarget, PublicError -from inferrsi.harness.executor import request_digest +from inferrsi.harness.api import Harness, PublicError +from inferrsi.harness.executor import LocalCpuTarget, request_digest +from inferrsi.harness.executor import _execution as execution_service from inferrsi.harness.records import _run_store as run_store from tests.benchmark.test_benchmark_preparation import preparation as preparation from tests.harness.test_harness_entry_verification import evaluation as evaluation @@ -276,12 +276,13 @@ def test_completed_request_replays_in_a_new_controller_without_archive_or_target script = ( "import json,sys; from pathlib import Path; " "from inferrsi.contracts.json_v1 import decode; " - "from inferrsi.harness import execution_service; " - "from inferrsi.harness.api import Harness,LocalCpuTarget; " + "from inferrsi.harness.executor import _execution as execution_service; " + "from inferrsi.harness.api import Harness; " + "from inferrsi.harness.executor import LocalCpuTarget; " "from inferrsi.harness.records import RunStore; " "s=RunStore(sys.argv[1],'test'); spec=decode(sys.stdin.buffer.read()); " "target=LocalCpuTarget('retired','2',work_root=Path(sys.argv[1]).parent/'retired'); " - "execution_service.prepared_binding.verify=lambda *a,**k: " + "execution_service.verify_prepared_binding=lambda *a,**k: " "(_ for _ in ()).throw(RuntimeError('replay read preparation')); " "execution_service.local_process._supervise=lambda *a,**k: " "(_ for _ in ()).throw(RuntimeError('replay started a worker')); " diff --git a/tests/harness/test_harness_evidence_capture.py b/tests/harness/test_harness_evidence_capture.py index c6ca64236..627f43c79 100644 --- a/tests/harness/test_harness_evidence_capture.py +++ b/tests/harness/test_harness_evidence_capture.py @@ -12,8 +12,10 @@ import pytest from inferrsi.contracts.json_v1 import decode, encode -from inferrsi.harness import evidence_capture, execution_service -from inferrsi.harness.api import Harness, LocalCpuTarget, PublicError +from inferrsi.harness.api import Harness, PublicError +from inferrsi.harness.executor import LocalCpuTarget +from inferrsi.harness.executor import _evidence_capture as evidence_capture +from inferrsi.harness.executor import _execution as execution_service from inferrsi.harness.records import _run_store as run_store from tests.benchmark.test_benchmark_preparation import preparation as preparation from tests.harness.test_harness_entry_verification import evaluation as evaluation diff --git a/tests/harness/test_harness_execute.py b/tests/harness/test_harness_execute.py index e10a9e5be..e9a5fa667 100644 --- a/tests/harness/test_harness_execute.py +++ b/tests/harness/test_harness_execute.py @@ -15,9 +15,10 @@ import pytest from inferrsi.contracts import json_v1 -from inferrsi.harness import execution_service, input_binding, local_process -from inferrsi.harness.api import Harness, LocalCpuTarget, PublicError -from inferrsi.harness.executor import request_digest +from inferrsi.harness.api import Harness, PublicError +from inferrsi.harness.executor import LocalCpuTarget, local_process, request_digest +from inferrsi.harness.executor import _execution as execution_service +from inferrsi.harness.executor import _input_binding as input_binding from inferrsi.harness.records import RunStore, RunStoreReader from inferrsi.harness.records import _run_store as run_store from tests.harness.run_store_child import REPO, child_env @@ -34,22 +35,22 @@ # residue (the mixed ``inferrsi.harness`` __init__ loads ``inferrsi.contracts.claim``). # The Executor package computes the execution request digest. Service ownership uses the # atomic JSON writer, whose dependencies are all in the standard library. -# #451 C1: the encoder and the claim types live in the contracts package, so importing -# either runs the ``inferrsi.contracts`` initializer, whose single import is the RunSpec -# module. The last two names are that exact residue; a ``contracts`` prefix is never allowed. +# Importing the encoder runs the contracts initializer and loads RunSpec. The +# LocalCpuTarget leaf is reached through Executor's explicit lazy import. NEW_H_CLOSURE = { - "inferrsi.harness.api", "inferrsi.harness.execution_service", - "inferrsi.harness.input_binding", "inferrsi.harness.local_process", - "inferrsi.harness.prepared_binding", - "inferrsi.harness.entry_code", - "inferrsi.harness.evidence_capture", - "inferrsi.harness.generation_lineage", + "inferrsi.harness.api", "inferrsi.harness.executor._execution", + "inferrsi.harness.executor._input_binding", "inferrsi.harness.executor.local_process", + "inferrsi.harness.executor._prepared_binding", + "inferrsi.harness.executor._entry_code", + "inferrsi.harness.executor._evidence_capture", + "inferrsi.harness.executor._generation_lineage", + "inferrsi.harness.executor._generation", "inferrsi.harness.executor._generation_feedback", "inferrsi.harness.records.atomic_json", "inferrsi.harness.records", "inferrsi.harness.api._harness", "inferrsi.harness.records._run_store", "inferrsi.contracts._harness_errors", - "inferrsi.harness.executor", + "inferrsi.harness.executor", "inferrsi.harness.executor._target", "inferrsi.contracts.json_v1", - "inferrsi.harness", "inferrsi.contracts.claim", + "inferrsi.harness", "inferrsi.contracts", "inferrsi.contracts.runspec", } # Prints a grandchild's pid, then outlives any test deadline with it. diff --git a/tests/harness/test_harness_feedback_policy.py b/tests/harness/test_harness_feedback_policy.py index 30a9d9446..a4ea054d4 100644 --- a/tests/harness/test_harness_feedback_policy.py +++ b/tests/harness/test_harness_feedback_policy.py @@ -13,8 +13,7 @@ from inferrsi.contracts.json_v1 import decode, encode from inferrsi.harness.api import PublicError -from inferrsi.harness.executor import request_digest -from inferrsi.harness.generation import prepare_generation +from inferrsi.harness.executor import prepare_generation, request_digest from inferrsi.harness.records import _run_store as run_store from tests.apps.test_apps_generation_plan import _fixed_input, _provider from tests.apps.test_apps_generation_plan import generation as generation @@ -167,8 +166,10 @@ def test_opt_in_retains_policy_and_allowed_proof_for_real_generation(authorized) def test_registered_policy_generation_replays_before_fresh_authorization( authorized, monkeypatch, tmp_path, fault, ): - from inferrsi.harness import execution_service, generation_feedback - from inferrsi.harness.api import Harness, LocalCpuTarget + from inferrsi.harness.api import Harness + from inferrsi.harness.executor import LocalCpuTarget + from inferrsi.harness.executor import _execution as execution_service + from inferrsi.harness.executor import _generation_feedback as generation_feedback store, _, harness, _, _, _, _, _, _ = authorized spec = prepare(authorized) @@ -376,7 +377,7 @@ def test_authorization_imports_no_other_business_module_in_a_child(authorized, t child = """ import io, json, sys sys.path.insert(0, sys.argv[1]) -from inferrsi.harness.generation_feedback import verify +from inferrsi.harness.executor._generation_feedback import verify from inferrsi.harness.records import RunStoreReader data = json.load(open(sys.argv[2], encoding='utf-8')) class Reader: diff --git a/tests/harness/test_harness_generation_bounds.py b/tests/harness/test_harness_generation_bounds.py index c4b86aa09..f60c7682a 100644 --- a/tests/harness/test_harness_generation_bounds.py +++ b/tests/harness/test_harness_generation_bounds.py @@ -13,8 +13,7 @@ from inferrsi.contracts.json_v1 import decode, encode from inferrsi.harness.api import PublicError -from inferrsi.harness.executor import request_digest -from inferrsi.harness.generation import prepare_generation +from inferrsi.harness.executor import prepare_generation, request_digest from inferrsi.harness.records import RunStoreReader from inferrsi.harness.records import _run_store as run_store from tests.apps.test_apps_generation_plan import generation as generation diff --git a/tests/harness/test_harness_generation_lineage.py b/tests/harness/test_harness_generation_lineage.py index 737af0bd9..47d0ede7f 100644 --- a/tests/harness/test_harness_generation_lineage.py +++ b/tests/harness/test_harness_generation_lineage.py @@ -18,10 +18,10 @@ from inferrsi.benchmark import assessment, cpu_smoke, preparation, proofs from inferrsi.benchmark.workers import fixture_worker as worker from inferrsi.contracts.json_v1 import decode, encode -from inferrsi.harness import execution_service, generation_lineage from inferrsi.harness.api import Harness, PublicError -from inferrsi.harness.executor import request_digest -from inferrsi.harness.generation import prepare_generation +from inferrsi.harness.executor import _execution as execution_service +from inferrsi.harness.executor import _generation_lineage as generation_lineage +from inferrsi.harness.executor import prepare_generation, request_digest from inferrsi.harness.records import _run_store as run_store from tests.apps.test_apps_generation_plan import _fixed_input from tests.apps.test_apps_generation_plan import generation as generation @@ -603,8 +603,9 @@ def unavailable(*args, **kwargs): sys.path.insert(0, sys.argv[1]) from inferrsi.apps import api from inferrsi.contracts.json_v1 import decode, encode -from inferrsi.harness import generation_lineage -from inferrsi.harness.api import Harness, LocalCpuTarget +from inferrsi.harness.executor import _generation_lineage as generation_lineage +from inferrsi.harness.api import Harness +from inferrsi.harness.executor import LocalCpuTarget from inferrsi.harness.records import RunStore from inferrsi.harness.records._run_store import Claim root = Path(sys.argv[2]) diff --git a/tests/harness/test_harness_generation_seal.py b/tests/harness/test_harness_generation_seal.py index db7d88c1e..ace262755 100644 --- a/tests/harness/test_harness_generation_seal.py +++ b/tests/harness/test_harness_generation_seal.py @@ -15,9 +15,8 @@ from inferrsi.apps.handoff.context_provider import ContextProvider from inferrsi.apps.workflows.knowledge import knowledge_reader from inferrsi.contracts.json_v1 import decode, encode -from inferrsi.harness.api import Harness, LocalCpuTarget, PublicError -from inferrsi.harness.executor import request_digest -from inferrsi.harness.generation import prepare_generation +from inferrsi.harness.api import Harness, PublicError +from inferrsi.harness.executor import LocalCpuTarget, prepare_generation, request_digest from inferrsi.harness.records import RunStore, RunStoreReader from inferrsi.harness.records import _run_store as run_store from tests.apps.test_apps_generation_plan import _fixed_input, _provider diff --git a/tests/harness/test_harness_improvement.py b/tests/harness/test_harness_improvement.py index d863455c3..40d5dac8a 100644 --- a/tests/harness/test_harness_improvement.py +++ b/tests/harness/test_harness_improvement.py @@ -7,8 +7,8 @@ from inferrsi.apps.workflows.improvement import assessment, choose, holdout_accepts from inferrsi.benchmark.improvement import SelectionPolicy +from inferrsi.harness.executor.skill_evaluation import CodexClient from inferrsi.harness.records.usage import usage_totals -from inferrsi.harness.skill_evaluation import CodexClient from tests.fixtures.harness_improvement_demo import ScriptedClient, configuration from tests.fixtures.skill_eval_compare_support import git from tools import skill_eval_compare as compare diff --git a/tests/harness/test_harness_prepared_binding.py b/tests/harness/test_harness_prepared_binding.py index cc7993654..5af2b5edd 100644 --- a/tests/harness/test_harness_prepared_binding.py +++ b/tests/harness/test_harness_prepared_binding.py @@ -10,9 +10,15 @@ from inferrsi.apps.handoff.bridge import bind_execution, verify_protocol from inferrsi.contracts.json_v1 import decode, encode -from inferrsi.harness import execution_service, prepared_binding -from inferrsi.harness.api import Harness, LocalCpuTarget, PublicError -from inferrsi.harness.executor import request_digest +from inferrsi.harness.api import Harness, PublicError +from inferrsi.harness.executor import ( + LocalCpuTarget, + project_prepared_binding, + read_prepared_binding, + request_digest, + verify_prepared_binding, +) +from inferrsi.harness.executor import _execution as execution_service from inferrsi.harness.records import RunStore from inferrsi.harness.records import _run_store as run_store @@ -77,10 +83,14 @@ def assert_empty(store): def test_projection_reads_the_fixed_preparation_without_resolving_an_entry(binding): spec, reader, store, harness = binding - fixed = prepared_binding.verify(spec, reader) + fixed = verify_prepared_binding(spec, reader) assert fixed.prepared_id == spec["prepared_ref"]["prepared_id"] assert fixed.code_sha256 == spec["steps"][0]["expected_code_sha256"] assert len(reader.opens) == 1 + data = read_prepared_binding(spec["prepared_ref"]["artifact"], reader) + assert data == reader.data + assert project_prepared_binding(data) == fixed + assert reader.opens == [spec["prepared_ref"]["artifact"]] * 2 # T37 is a later delivery: valid evaluation bindings still cannot start. with pytest.raises(PublicError) as caught: harness.execute(spec) @@ -321,7 +331,7 @@ def open(self, ref): elif mode == "wrong-hash": original["sha256"] = "0" * 64 with pytest.raises(PublicError) as caught: - prepared_binding.verify(spec, None if mode == "missing" else Tracked()) + verify_prepared_binding(spec, None if mode == "missing" else Tracked()) assert caught.value.code == ("ArtifactUnavailable" if mode in {"missing", "os-error"} else "ArtifactIntegrityError") if mode not in {"missing", "os-error"}: @@ -340,7 +350,7 @@ def open(self, ref): return BytesIO(b"{}") with pytest.raises(PublicError) as caught: - prepared_binding.verify(spec, Mutating()) + verify_prepared_binding(spec, Mutating()) assert caught.value.code == "ArtifactIntegrityError" assert spec["prepared_ref"]["artifact"] == original assert_empty(store) @@ -354,5 +364,5 @@ def open(self, ref): raise TypeError("broken host reader") with pytest.raises(TypeError, match="broken host reader"): - prepared_binding.verify(spec, Broken()) + verify_prepared_binding(spec, Broken()) assert_empty(store) diff --git a/tests/harness/test_harness_run_store.py b/tests/harness/test_harness_run_store.py index a942caab5..10c5333c3 100644 --- a/tests/harness/test_harness_run_store.py +++ b/tests/harness/test_harness_run_store.py @@ -49,10 +49,7 @@ # ``inferrsi.contracts`` initializer, whose single import is the RunSpec module. These are # the two exact names that initializer adds; a ``contracts`` prefix is never allowed. CONTRACTS_INIT = {"inferrsi.contracts", "inferrsi.contracts.runspec"} -# Package initializers run on import: the existing mixed harness __init__ loads -# inferrsi.contracts.claim (the Verdict enum). This is a known residue, not an edge added -# by the new H modules. -PACKAGE_INIT_RESIDUE = {"inferrsi", "inferrsi.harness", "inferrsi.contracts.claim"} +PARENT_PACKAGES = {"inferrsi", "inferrsi.harness"} FORBIDDEN_PREFIXES = ( "inferrsi.knowledge", "inferrsi.benchmark", "inferrsi.apps", "inferrsi.evaluation", "inferrsi.catalog", "inferrsi.research", "inferrsi.knowledge_store", "inferrsi.inspection", @@ -338,9 +335,7 @@ def test_h01_6_new_h_closure_reaches_no_legacy_k_b_or_apps_module() -> None: pending.extend(_inferrsi_imports(module)) assert closure == NEW_H_CLOSURE | CONTRACTS_INIT - # Runtime: importing a submodule also runs each parent package's __init__. The mixed - # ``inferrsi.harness`` __init__ loads ``inferrsi.contracts.claim`` (the Verdict enum). - # That is a known residue of the existing package, not a legacy, K, B, or Apps module. + # The fresh interpreter also loads the parent packages of Records. code = ( "import json, sys; from inferrsi.harness.records import RunStore; " "print(json.dumps(sorted(m for m in sys.modules if m.split('.')[0] == 'inferrsi')))" @@ -354,9 +349,8 @@ def test_h01_6_new_h_closure_reaches_no_legacy_k_b_or_apps_module() -> None: assert not [m for m in loaded if m.startswith(FORBIDDEN_PREFIXES)] # Keep the static graph exact. The runtime set may also include inferrsi._version # when setuptools_scm has written the gitignored file after `pip install -e`. - allowed = NEW_H_CLOSURE | CONTRACTS_INIT | PACKAGE_INIT_RESIDUE | {"inferrsi._version"} - assert loaded <= allowed - assert NEW_H_CLOSURE | CONTRACTS_INIT | PACKAGE_INIT_RESIDUE <= loaded + expected = NEW_H_CLOSURE | CONTRACTS_INIT | PARENT_PACKAGES + assert loaded - {"inferrsi._version"} == expected def test_commit_rejects_unbacked_or_foreign_artifact_refs(tmp_path: Path) -> None: diff --git a/tests/harness/test_local_executor.py b/tests/harness/test_local_executor.py index 311f5e238..3405e34ed 100644 --- a/tests/harness/test_local_executor.py +++ b/tests/harness/test_local_executor.py @@ -3,6 +3,29 @@ import subprocess import sys from pathlib import Path +from types import SimpleNamespace + +import pytest + +from inferrsi.harness.executor import local_process, process_group_empty + + +@pytest.mark.parametrize("error,expected", [(None, False), (ProcessLookupError, True), + (PermissionError, None)]) +def test_process_group_cleanup_receipt(monkeypatch, error, expected): + def killpg(group, signal): + assert (group, signal) == (81, 0) + if error is not None: + raise error() + + monkeypatch.setattr(local_process, "os", SimpleNamespace(killpg=killpg)) + monkeypatch.setattr(local_process, "_DRAIN_SECONDS", 0) + assert process_group_empty(81) is expected + + +def test_process_group_cleanup_without_a_native_probe(monkeypatch): + monkeypatch.setattr(local_process, "os", SimpleNamespace()) + assert process_group_empty(81) is None def test_local_executor_does_not_inherit_parent_stdin(tmp_path): @@ -19,7 +42,7 @@ def test_local_executor_does_not_inherit_parent_stdin(tmp_path): "import sys\n" "import time\n" "from pathlib import Path\n" - "from inferrsi.harness.local_process import execute_command\n" + "from inferrsi.harness.executor.local_process import execute_command\n" "command = (sys.executable, str(Path(__file__).with_name('child.py')))\n" "result = execute_command(command, Path.cwd(), Path('trial'), time.monotonic() + 30)\n" "print(json.dumps({'status': result['status']}))\n", diff --git a/tests/harness/test_parallel_round.py b/tests/harness/test_parallel_round.py index 4b33ddf08..3d661e0af 100644 --- a/tests/harness/test_parallel_round.py +++ b/tests/harness/test_parallel_round.py @@ -13,14 +13,14 @@ from inferrsi.apps.workflows.parallel_round import close_round, serve_ticket from inferrsi.harness import parallel_round -from inferrsi.harness.confinement import ( +from inferrsi.harness.executor.confinement import ( ConfinementUnavailable, FixtureBackend, UnreapedCommand, UnshareBackend, namespaces_available, ) -from inferrsi.harness.device_lease import DeviceLease, LeaseError +from inferrsi.harness.executor.device_lease import DeviceLease, LeaseError from inferrsi.harness.parallel_round import ( RoundPlanError, _read_nofollow, @@ -163,7 +163,7 @@ def test_two_acquires_do_not_share_one_device(self, tmp_path): worker = """ import sys from pathlib import Path -from inferrsi.harness.device_lease import DeviceLease, LeaseError +from inferrsi.harness.executor.device_lease import DeviceLease, LeaseError try: with DeviceLease(Path(sys.argv[1])).acquire("cpu-0"): diff --git a/tests/harness/test_speculative_search.py b/tests/harness/test_speculative_search.py index 9cebfb480..db3c4908a 100644 --- a/tests/harness/test_speculative_search.py +++ b/tests/harness/test_speculative_search.py @@ -3,7 +3,7 @@ import pytest from inferrsi.contracts.claim import Verdict -from inferrsi.harness import candidates +from inferrsi.harness.executor import candidates from inferrsi.harness.manager.search import search_tree as tree from tests.fixtures.speculative_search import ( add, diff --git a/tests/repository/_gate_policy_support.py b/tests/repository/_gate_policy_support.py index 80ee1a19e..fe5e519a4 100644 --- a/tests/repository/_gate_policy_support.py +++ b/tests/repository/_gate_policy_support.py @@ -108,6 +108,22 @@ "inferrsi.model", "inferrsi.harness.scenarios", "inferrsi.harness.runner", + "inferrsi.harness.trials", + "inferrsi.harness.local_process", + "inferrsi.harness.launch_records", + "inferrsi.harness.device_lease", + "inferrsi.harness.generation", + "inferrsi.harness.generation_feedback", + "inferrsi.harness.generation_lineage", + "inferrsi.harness.prepared_binding", + "inferrsi.harness.execution_service", + "inferrsi.harness.entry_code", + "inferrsi.harness.evidence_capture", + "inferrsi.harness.input_binding", + "inferrsi.harness.artifact_sandbox", + "inferrsi.harness.candidates", + "inferrsi.harness.confinement", + "inferrsi.harness.skill_evaluation", "inferrsi.harness.gvo", "inferrsi.harness.improvement", "inferrsi.harness.search_adapter", @@ -152,10 +168,10 @@ NEW_H_ENTRIES = ( "inferrsi.harness.api", "inferrsi.contracts._harness_errors", - "inferrsi.harness.execution_service", + "inferrsi.harness.executor._execution", "inferrsi.harness.executor", - "inferrsi.harness.input_binding", - "inferrsi.harness.local_process", + "inferrsi.harness.executor._input_binding", + "inferrsi.harness.executor.local_process", "inferrsi.harness.manager", "inferrsi.harness.records", "inferrsi.harness.records._run_store", diff --git a/tests/repository/architecture_real_ports.py b/tests/repository/architecture_real_ports.py index 4cb492d6f..e770560e9 100644 --- a/tests/repository/architecture_real_ports.py +++ b/tests/repository/architecture_real_ports.py @@ -18,7 +18,7 @@ from inferrsi.apps.legacy.evaluation import evaluate from inferrsi.contracts import RunSpec -from inferrsi.harness.trials.external import execute_trial +from inferrsi.harness.executor.trials.external import execute_trial from inferrsi.knowledge.knowledge_operations import KnowledgeReader from tests.repository.architecture_closed_loop import _canonical, _digest diff --git a/tests/repository/check_installed.py b/tests/repository/check_installed.py index e1fd58763..f5669a890 100644 --- a/tests/repository/check_installed.py +++ b/tests/repository/check_installed.py @@ -41,15 +41,28 @@ assert request_digest({}) == "sha256:" + hashlib.sha256(b"{}").hexdigest() assert "InvalidRequest" in PUBLIC_ERROR_CODES for name in ( - "sqlite3", "inferrsi.harness.records._run_store", "inferrsi.harness.execution_service", + "sqlite3", "inferrsi.harness.records._run_store", "inferrsi.harness.executor._execution", ): assert name not in sys.modules, name for old in ( "run_store", "execution_spec", "errors", "atomic_json", "artifact_primitives", - "service_observations", "usage", + "service_observations", "usage", "generation", "prepared_binding", + "generation_feedback", "generation_lineage", "execution_service", "entry_code", + "evidence_capture", "input_binding", "artifact_sandbox", "candidates", "confinement", + "skill_evaluation", ): assert find_spec("inferrsi.harness." + old) is None, old +from inferrsi.harness import api +from inferrsi.harness.executor import LocalCpuTarget from inferrsi.harness.records import RunStore, RunStoreReader + +assert not hasattr(api, "LocalCpuTarget") +try: + LocalCpuTarget("cpu", "1", Path("relative")) +except PublicError as error: + assert type(error) is PublicError and error.code == "InvalidRequest" +else: + raise AssertionError("LocalCpuTarget accepted a relative root") assert issubclass(RunStore, RunStoreReader) try: RunStore(Path("relative"), "p5") @@ -62,10 +75,13 @@ # The new Harness binding port ships independently of Apps and Benchmark. subprocess.run([ sys.executable, "-I", "-B", "-c", - "import sys; from inferrsi.harness import prepared_binding as p; " - "from inferrsi.harness import entry_code; assert callable(entry_code.capture_module); " - "from inferrsi.harness import evidence_capture; assert callable(evidence_capture.observe); " - "assert all(callable(getattr(p, n)) for n in ('read', 'project', 'verify')); " + "import sys; from inferrsi.harness import executor; " + "from inferrsi.harness.executor import _entry_code; " + "assert callable(_entry_code.capture_module); " + "from inferrsi.harness.executor import _evidence_capture; " + "assert callable(_evidence_capture.observe); " + "assert all(callable(getattr(executor, n)) for n in ('prepare_generation', " + "'read_prepared_binding', 'project_prepared_binding', 'verify_prepared_binding')); " "assert not any(n == root or n.startswith(root + '.') for n in sys.modules " "for root in ('inferrsi.apps', 'inferrsi.benchmark', 'inferrsi.knowledge'))", ], check=True, capture_output=True, text=True) @@ -680,7 +696,9 @@ def _inventory(root, prefix): # #451 C1: the shared data/byte contracts ship as one package. The four retired root # modules are not in the wheel and have no alias. assert RunSpec.__module__ == "inferrsi.contracts.runspec" -assert inferrsi.harness.Verdict is claim.Verdict +assert claim.parse_verdict("PASS") is claim.Verdict.PASS +assert not hasattr(inferrsi.harness, "Verdict") +assert not hasattr(inferrsi.harness, "parse_verdict") assert json_v1.decode(json_v1.encode({"b": [1, None], "a": "x"})) == {"a": "x", "b": [1, None]} for retired in ("_json_v1", "runspec", "claim"): assert find_spec(f"inferrsi.{retired}") is None, retired @@ -1026,10 +1044,15 @@ def assess(baseline, candidate, validation, integrity, error): "inferrsi.infra.platforms", "inferrsi.infra.targets", "inferrsi.model", "inferrsi.model.anthropic_agent", "inferrsi.model.anthropic_edit_agent", "inferrsi.model.request_guard", "inferrsi.harness.scenarios", - "inferrsi.harness.scenarios.external"): + "inferrsi.harness.scenarios.external", "inferrsi.harness.trials", + "inferrsi.harness.trials.external", "inferrsi.harness.local_process", + "inferrsi.harness.launch_records", "inferrsi.harness.device_lease"): assert_not_importable(retired) assert not {child.name for child in files("inferrsi").iterdir()} & {"infra", "model"} -for canonical in ("inferrsi.harness.trials", "inferrsi.harness.trials.external", +for canonical in ("inferrsi.harness.executor.local_process", + "inferrsi.harness.executor.launch_records", + "inferrsi.harness.executor.device_lease", + "inferrsi.harness.executor.trials", "inferrsi.harness.executor.trials.external", "inferrsi.harness.serving", "inferrsi.harness.serving.server", "inferrsi.harness.serving.http", "inferrsi.harness.serving.image", "inferrsi.apps.host.commands", "inferrsi.apps.host.inspection", diff --git a/tests/repository/test_architecture_closed_loop.py b/tests/repository/test_architecture_closed_loop.py index 17fdbc151..71628ba3c 100644 --- a/tests/repository/test_architecture_closed_loop.py +++ b/tests/repository/test_architecture_closed_loop.py @@ -377,7 +377,7 @@ def test_real_cpu_offline_ports_connect_three_refs(self) -> None: def test_real_ports_stay_on_three_existing_seams(self) -> None: imported = _import_modules(PORTS) self.assertIn("inferrsi.knowledge.knowledge_operations", imported) - self.assertIn("inferrsi.harness.trials.external", imported) + self.assertIn("inferrsi.harness.executor.trials.external", imported) self.assertIn("inferrsi.apps.legacy.evaluation", imported) # The six banned families are unchanged. Two of the three seams are canonical # Knowledge and Apps modules since #412 R1; the guard exempts those two exact @@ -396,7 +396,7 @@ def test_real_ports_stay_on_three_existing_seams(self) -> None: self.assertNotIn("collect", calls) # #412 R1 deleted the root shell; these are the implementation's own imports. knowledge = _import_modules(ROOT / "src/inferrsi/knowledge/knowledge_operations.py") - harness = _import_modules(ROOT / "src/inferrsi/harness/trials/external.py") + harness = _import_modules(ROOT / "src/inferrsi/harness/executor/trials/external.py") self.assertFalse(any("harness" in name or "evaluation" in name for name in knowledge)) self.assertFalse(any("knowledge" in name or "evaluation" in name for name in harness)) text = LAYOUT.read_text(encoding="utf-8") @@ -410,7 +410,7 @@ def test_seam_guard_exempts_only_the_two_exact_seams(self) -> None: "from inferrsi.apps.legacy.evaluation import evaluate\n", "import inferrsi.knowledge.knowledge_operations\n", "import inferrsi.apps.legacy.evaluation as old_evaluate\n", - "from inferrsi.harness.trials.external import execute_trial\n", + "from inferrsi.harness.executor.trials.external import execute_trial\n", "from inferrsi.contracts import RunSpec\n", "import json\nfrom pathlib import Path\n", ) diff --git a/tests/repository/test_first_wave_isolation_policy.py b/tests/repository/test_first_wave_isolation_policy.py index a0a725440..f74d600b0 100644 --- a/tests/repository/test_first_wave_isolation_policy.py +++ b/tests/repository/test_first_wave_isolation_policy.py @@ -42,7 +42,7 @@ # Module paths assumed for synthetic graphs only; the gate never infers them. SYNTHETIC_H_ENTRIES = ( "inferrsi.harness.api", - "inferrsi.harness.execution_service", + "inferrsi.harness.executor._execution", "inferrsi.harness.records", ) # #451 C2: the leaf lives in ``inferrsi.resources``, whose initializer imports nothing. @@ -59,6 +59,7 @@ "apps/__init__.py": "", "apps/main.py": "from inferrsi.knowledge import catalog\nfrom inferrsi.harness import api\n", "harness/__init__.py": "", + "harness/executor/__init__.py": "", "harness/api.py": "VALUE = 1\n", } # The bounded contracts package (#451 C1, C2): the initializer's one export and five @@ -980,9 +981,9 @@ def test_new_h_entry_through_old_shell_fails(self) -> None: "inferrsi.harness.records reaches inferrsi.catalog", ), ( - "harness/execution_service.py", + "harness/executor/_execution.py", "from inferrsi.research import research_knowledge\n", - "inferrsi.harness.execution_service reaches inferrsi.research", + "inferrsi.harness.executor._execution reaches inferrsi.research", ), ) for path, source, expected in cases: @@ -1023,28 +1024,30 @@ def test_former_residual_edge_fails_for_its_importer_and_dependents(self) -> Non # The edge that S01 removed has no exemption left: the importer fails, # and so does every harness module that reaches the leaf through it. tree = { - "harness/skill_evaluation.py": "from ..knowledge_operations import KnowledgeReader\n", - "harness/manager/search/improvement.py": "from ... import skill_evaluation\n", + "harness/executor/skill_evaluation.py": ( + "from ...knowledge_operations import KnowledgeReader\n" + ), + "harness/manager/search/improvement.py": "from ...executor import skill_evaluation\n", } report = _report(tree) self.assertIn( - "inferrsi.harness.skill_evaluation reaches inferrsi.knowledge_operations: " - "inferrsi.harness.skill_evaluation -> inferrsi.knowledge_operations", + "inferrsi.harness.executor.skill_evaluation reaches inferrsi.knowledge_operations: " + "inferrsi.harness.executor.skill_evaluation -> inferrsi.knowledge_operations", report.violations, ) self.assertIn( "inferrsi.harness.manager.search.improvement reaches inferrsi.knowledge_operations: " - "inferrsi.harness.manager.search.improvement -> inferrsi.harness.skill_evaluation" - " -> inferrsi.knowledge_operations", + "inferrsi.harness.manager.search.improvement" + " -> inferrsi.harness.executor.skill_evaluation -> inferrsi.knowledge_operations", report.violations, ) self.assertNotIn("residual", blocker_kinds(report)) self.assertFalse(report.isolation_complete) - entry = "from inferrsi.harness import skill_evaluation\n" + entry = "from inferrsi.harness.executor import skill_evaluation\n" granted = _report({**tree, "harness/api.py": entry}) self.assertIn( "inferrsi.harness.api reaches inferrsi.knowledge_operations: inferrsi.harness.api" - " -> inferrsi.harness.skill_evaluation -> inferrsi.knowledge_operations", + " -> inferrsi.harness.executor.skill_evaluation -> inferrsi.knowledge_operations", granted.violations, ) self.assertFalse(granted.new_core_closure_isolated) @@ -1090,8 +1093,8 @@ def test_transitive_path_through_root_helpers_fails(self) -> None: def test_old_leaf_detection_is_not_sort_dependent(self) -> None: # A second path to the same leaf is found whichever edge is walked first. direct = { - "harness/skill_evaluation.py": ( - "from ..knowledge_operations import KnowledgeReader\n" + "harness/executor/skill_evaluation.py": ( + "from ...knowledge_operations import KnowledgeReader\n" ) } for name in ("aa_bridge", "zz_bridge"): @@ -1102,11 +1105,11 @@ def test_old_leaf_detection_is_not_sort_dependent(self) -> None: "knowledge_operations.py": _shell("inferrsi.knowledge_operations"), f"{name}.py": "from . import knowledge_operations\n", "harness/parallel_round.py": ( - f"from . import skill_evaluation\nfrom .. import {name}\n" + f"from .executor import skill_evaluation\nfrom .. import {name}\n" ), } ) - for module in ("parallel_round", "skill_evaluation"): + for module in ("parallel_round", "executor.skill_evaluation"): self.assertTrue( _violated( report, @@ -1119,15 +1122,15 @@ def test_h_entry_own_parent_init_is_walked(self) -> None: # Importing a new H entry executes its package init even when the # entry body has no imports. leak = { - "harness/skill_evaluation.py": ( - "from ..knowledge_operations import KnowledgeReader\n" + "harness/executor/skill_evaluation.py": ( + "from ...knowledge_operations import KnowledgeReader\n" ), - "harness/__init__.py": "from . import skill_evaluation\n", + "harness/__init__.py": "from .executor import skill_evaluation\n", } expected = ( "inferrsi.harness.api reaches inferrsi.knowledge_operations: " "inferrsi.harness.api -> inferrsi.harness -> " - "inferrsi.harness.skill_evaluation -> inferrsi.knowledge_operations" + "inferrsi.harness.executor.skill_evaluation -> inferrsi.knowledge_operations" ) isolated = _report({**leak, "harness/api.py": "VALUE = 1\n"}) self.assertIn(expected, isolated.violations) @@ -1147,10 +1150,10 @@ def test_non_entry_own_parent_init_is_walked(self) -> None: # through the package init, and fails like an entry does. report = _report( { - "harness/skill_evaluation.py": ( - "from ..knowledge_operations import KnowledgeReader\n" + "harness/executor/skill_evaluation.py": ( + "from ...knowledge_operations import KnowledgeReader\n" ), - "harness/__init__.py": "from . import skill_evaluation\n", + "harness/__init__.py": "from .executor import skill_evaluation\n", "harness/parallel_round.py": "VALUE = 1\n", "harness/api.py": "VALUE = 1\n", } @@ -1159,7 +1162,7 @@ def test_non_entry_own_parent_init_is_walked(self) -> None: self.assertIn( f"inferrsi.harness.{module} reaches inferrsi.knowledge_operations: " f"inferrsi.harness.{module} -> inferrsi.harness -> " - "inferrsi.harness.skill_evaluation -> inferrsi.knowledge_operations", + "inferrsi.harness.executor.skill_evaluation -> inferrsi.knowledge_operations", report.violations, ) @@ -1210,8 +1213,8 @@ def test_returning_skill_evaluation_infra_edge_fails(self) -> None: tree = { "infra/__init__.py": "", "infra/artifacts.py": "VALUE = 1\n", - "harness/skill_evaluation.py": "from ..infra.artifacts import VALUE\n", - "harness/manager/search/improvement.py": "from ... import skill_evaluation\n", + "harness/executor/skill_evaluation.py": "from ...infra.artifacts import VALUE\n", + "harness/manager/search/improvement.py": "from ...executor import skill_evaluation\n", } cleared = _report({}, manifest=EMPTY_ALLOWLIST, base=CLEARED_TREE) self.assertEqual(cleared.harness_model_infra, ()) @@ -1220,19 +1223,19 @@ def test_returning_skill_evaluation_infra_edge_fails(self) -> None: self.assertEqual( report.harness_model_infra, ( - "inferrsi.harness.manager.search.improvement -> inferrsi.harness.skill_evaluation" - " -> inferrsi.infra", - "inferrsi.harness.manager.search.improvement -> inferrsi.harness.skill_evaluation" - " -> inferrsi.infra.artifacts", - "inferrsi.harness.skill_evaluation -> inferrsi.infra", - "inferrsi.harness.skill_evaluation -> inferrsi.infra.artifacts", + "inferrsi.harness.executor.skill_evaluation -> inferrsi.infra", + "inferrsi.harness.executor.skill_evaluation -> inferrsi.infra.artifacts", + "inferrsi.harness.manager.search.improvement" + " -> inferrsi.harness.executor.skill_evaluation -> inferrsi.infra", + "inferrsi.harness.manager.search.improvement" + " -> inferrsi.harness.executor.skill_evaluation -> inferrsi.infra.artifacts", ), ) self.assertEqual( report.blockers, ( - "harness reaches model/infra: inferrsi.harness.manager.search.improvement -> " - "inferrsi.harness.skill_evaluation -> inferrsi.infra (4 hits)", + "harness reaches model/infra: inferrsi.harness.executor.skill_evaluation" + " -> inferrsi.infra (4 hits)", ), ) self.assertFalse(report.isolation_complete) @@ -1250,27 +1253,29 @@ def test_returning_r2_harness_infra_edges_fail(self) -> None: "model/metrics.py": "VALUE = 1\n"} primitives = {"harness/records/artifact_primitives.py": "VALUE = 1\n", "harness/records/atomic_json.py": "VALUE = 1\n"} - modules = ("agent_sessions", "candidates", "optimization", "optimization_session", + modules = ("agent_sessions", "executor.candidates", "optimization", "optimization_session", "project", "task_protocol") - clean = {f"harness/{name}.py": "from .records.artifact_primitives import VALUE\n" - for name in modules} + paths = {name: "harness/" + name.replace(".", "/") + ".py" for name in modules} + clean = {path: "from inferrsi.harness.records.artifact_primitives import VALUE\n" + for path in paths.values()} cleared = _report({**infra, **primitives, **clean}, manifest=EMPTY_ALLOWLIST, base=CLEARED_TREE) self.assertEqual(cleared.harness_model_infra, ()) self.assertTrue(cleared.isolation_complete) sources = ( - ("from ..infra.artifacts import VALUE\n", "inferrsi.infra.artifacts"), + ("from {prefix}infra.artifacts import VALUE\n", "inferrsi.infra.artifacts"), ("def late():\n from inferrsi.infra.artifacts import VALUE\n", "inferrsi.infra.artifacts"), # #498 retired infra.processes and infra.commands; other is a synthetic Infra module. - ("from ..infra import other\n", "inferrsi.infra.other"), + ("from {prefix}infra import other\n", "inferrsi.infra.other"), ("from inferrsi.model import metrics\n", "inferrsi.model.metrics"), ) for name in modules: + prefix = "." * (2 + name.count(".")) for source, target in sources: with self.subTest(module=name, source=source): report = _report({**infra, **primitives, **clean, - f"harness/{name}.py": source}, + paths[name]: source.format(prefix=prefix)}, manifest=EMPTY_ALLOWLIST, base=CLEARED_TREE) package = target.rsplit(".", 1)[0] self.assertEqual( @@ -1312,12 +1317,14 @@ def test_each_trigger_alone_keeps_overall_false(self) -> None: ("absent: apps/", {"apps/__init__.py": None, "apps/main.py": None}, EMPTY_ALLOWLIST), ("allowlist: 9 compatibility pairs", {}, STAGED), ( - "harness reaches model/infra: inferrsi.harness.skill_evaluation" + "harness reaches model/infra: inferrsi.harness.executor.skill_evaluation" " -> inferrsi.infra", { "infra/__init__.py": "", "infra/artifacts.py": "VALUE = 1\n", - "harness/skill_evaluation.py": "from ..infra.artifacts import VALUE\n", + "harness/executor/skill_evaluation.py": ( + "from ...infra.artifacts import VALUE\n" + ), }, EMPTY_ALLOWLIST, ), diff --git a/tests/repository/test_target_module_import_gate.py b/tests/repository/test_target_module_import_gate.py index 0204ac932..09dbe619a 100644 --- a/tests/repository/test_target_module_import_gate.py +++ b/tests/repository/test_target_module_import_gate.py @@ -191,7 +191,9 @@ def test_by_path_loading_is_admitted_nowhere_else(tmp_path, relative): ("apps/runner.py", "from ..infra.environment import storage_locations\n", "inferrsi.infra.environment"), ("apps/runner.py", "from ..infra.commands import probe_command\n", "inferrsi.infra.commands"), - # #558: the trial runner moved to inferrsi.harness.trials. + # Retired trial package names from #558 and #702. + ("apps/runner.py", "from inferrsi.harness.trials.external import execute_trial\n", + "inferrsi.harness.trials.external"), ("apps/runner.py", "from inferrsi.harness.scenarios.external import execute_trial\n", "inferrsi.harness.scenarios.external"), ("harness/manager/_runner.py", "from ..scenarios.external import collect_trial_checks\n", @@ -262,10 +264,11 @@ def test_the_modules_that_replaced_the_retired_packages_are_not_retired(tmp_path ), "harness/manager/_runner.py": ( "from inferrsi.harness.serving.image import ImageProtocol\n" - "from ..trials.external import collect_trial_checks\n" + "from ..executor.trials.external import collect_trial_checks\n" ), - "harness/trials/__init__.py": "", - "harness/trials/external.py": "def collect_trial_checks():\n return []\n", + "harness/executor/__init__.py": "", + "harness/executor/trials/__init__.py": "", + "harness/executor/trials/external.py": "def collect_trial_checks():\n return []\n", "benchmark/runner.py": "from inferrsi.benchmark.metrics import read_metric\n", }) assert not [item for item in report.violations if "retired module" in item] @@ -401,9 +404,9 @@ def test_split_skill_eval_modules_reach_no_model_or_infra(self) -> None: # remaining harness -> model/infra hits belong to other modules. report = first_wave_report() for name in ( - "skill_evaluation", + "executor.skill_evaluation", "manager.search.improvement", - "artifact_sandbox", + "executor.artifact_sandbox", "records.atomic_json", ): with self.subTest(module=name): diff --git a/tests/skill_eval/test_skill_eval_compare.py b/tests/skill_eval/test_skill_eval_compare.py index 7120628ef..8ba7fe80c 100644 --- a/tests/skill_eval/test_skill_eval_compare.py +++ b/tests/skill_eval/test_skill_eval_compare.py @@ -1009,16 +1009,16 @@ def test_changed_runtime_controllers_reject_execution_and_report_without_calls(t authorization = module.prepare(config, repo, output) module.report(output) saved = (output / "report.json").read_bytes(), (output / "report.md").read_bytes() - assert "src/inferrsi/harness/local_process.py" in module.CONTROLLERS + assert "src/inferrsi/harness/executor/local_process.py" in module.CONTROLLERS assert "src/inferrsi/apps/storage/artifacts.py" in module.CONTROLLERS assert "src/inferrsi/apps/integrations/anthropic/request_guard.py" in module.CONTROLLERS assert "tools/skill_eval_artifact_guidance.py" in module.CONTROLLERS # Each owner of the split trial path is frozen: composed entry, rules and host. - for owner in ("apps/workflows", "benchmark", "harness"): + for owner in ("apps/workflows", "benchmark", "harness/executor"): assert f"src/inferrsi/{owner}/skill_evaluation.py" in module.CONTROLLERS for name in ("apps/workflows/skill_eval_engineering.py", "benchmark/skill_eval_engineering.py", - "benchmark/skill_eval_diagnostic.py", "harness/artifact_sandbox.py", - "harness/records/atomic_json.py", "harness/input_binding.py"): + "benchmark/skill_eval_diagnostic.py", "harness/executor/artifact_sandbox.py", + "harness/records/atomic_json.py", "harness/executor/_input_binding.py"): assert "src/inferrsi/" + name in module.CONTROLLERS assert not any("harness/skill_eval_" in name for name in module.CONTROLLERS) client = FixedOutputClient(tmp_path) diff --git a/tests/skill_eval/test_skill_eval_engineering.py b/tests/skill_eval/test_skill_eval_engineering.py index e13bc109f..218483aaf 100644 --- a/tests/skill_eval/test_skill_eval_engineering.py +++ b/tests/skill_eval/test_skill_eval_engineering.py @@ -11,7 +11,7 @@ from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.benchmark import skill_eval_engineering as engineering -from inferrsi.harness import artifact_sandbox as sandbox +from inferrsi.harness.executor import artifact_sandbox as sandbox TASK = {"id": "serving-parser", "split": "development", "request": engineering.REQUEST, "provenance": "Reconstructed public regression fixture"} diff --git a/tests/skill_eval/test_skill_eval_generation.py b/tests/skill_eval/test_skill_eval_generation.py index e68606b57..66044df78 100644 --- a/tests/skill_eval/test_skill_eval_generation.py +++ b/tests/skill_eval/test_skill_eval_generation.py @@ -11,8 +11,8 @@ from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.apps.workflows import skill_evaluation as evaluation from inferrsi.benchmark import skill_eval_engineering as engineering -from inferrsi.harness import artifact_sandbox as sandbox -from inferrsi.harness import skill_evaluation as harness +from inferrsi.harness.executor import artifact_sandbox as sandbox +from inferrsi.harness.executor import skill_evaluation as harness from tests.fixtures.skill_eval_compare_support import configuration from tools import skill_eval_compare as compare diff --git a/tests/skill_eval/test_skill_eval_local.py b/tests/skill_eval/test_skill_eval_local.py index 2d7ef804a..77610f256 100644 --- a/tests/skill_eval/test_skill_eval_local.py +++ b/tests/skill_eval/test_skill_eval_local.py @@ -9,7 +9,7 @@ from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.benchmark import skill_eval_engineering as engineering -from inferrsi.harness import artifact_sandbox as sandbox +from inferrsi.harness.executor import artifact_sandbox as sandbox from tests.fixtures.skill_eval_compare_support import configuration from tools import skill_eval_compare as compare from tools import skill_eval_local as local diff --git a/tests/skill_eval/test_skill_evaluation.py b/tests/skill_eval/test_skill_evaluation.py index 3ffc3ed25..7744a110a 100644 --- a/tests/skill_eval/test_skill_evaluation.py +++ b/tests/skill_eval/test_skill_evaluation.py @@ -8,7 +8,7 @@ from inferrsi.apps.workflows.skill_evaluation import export_bundle, run_trial, summarize from inferrsi.benchmark.skill_evaluation import task_verdict -from inferrsi.harness.skill_evaluation import CodexClient, toml_value, trace_metrics +from inferrsi.harness.executor.skill_evaluation import CodexClient, toml_value, trace_metrics from inferrsi.knowledge.knowledge_operations import KnowledgeReader ROOT = Path(__file__).resolve().parents[2] @@ -269,7 +269,7 @@ def test_expired_real_executor_deadline_records_missing_events(tmp_path): def test_host_trial_takes_verdict_rules_as_ports(tmp_path): - from inferrsi.harness import skill_evaluation as host + from inferrsi.harness.executor import skill_evaluation as host workspace = tmp_path / "workspace" workspace.mkdir() @@ -300,7 +300,7 @@ def verdict(execution, trace, output, checks): def test_harness_owned_writes_and_digests_match_apps_bytes(tmp_path): from inferrsi.apps.storage import artifacts - from inferrsi.harness import input_binding + from inferrsi.harness.executor import _input_binding as input_binding from inferrsi.harness.records import atomic_json value = {"b": [1.5, None, True, 1e-07, 1e16], "a": "非 ASCII", "nested": {"z": 0.1 + 0.2}} diff --git a/tools/parallel_round.py b/tools/parallel_round.py index 5ac10d2de..5d7677c78 100644 --- a/tools/parallel_round.py +++ b/tools/parallel_round.py @@ -7,7 +7,7 @@ from pathlib import Path from inferrsi.apps.workflows.parallel_round import close_round, serve_ticket -from inferrsi.harness.confinement import select_backend +from inferrsi.harness.executor.confinement import select_backend from inferrsi.harness.parallel_round import prepare, submit, ticket_status diff --git a/tools/skill_eval_cloud_export.py b/tools/skill_eval_cloud_export.py index c4a605a78..c96731479 100644 --- a/tools/skill_eval_cloud_export.py +++ b/tools/skill_eval_cloud_export.py @@ -6,7 +6,7 @@ from inferrsi.apps.storage.artifacts import sha256 from inferrsi.benchmark import skill_eval_engineering as engineering -from inferrsi.harness import artifact_sandbox +from inferrsi.harness.executor import artifact_sandbox from tools import skill_eval_compare as compare diff --git a/tools/skill_eval_cloud_replay.py b/tools/skill_eval_cloud_replay.py index 230a75533..de0039326 100644 --- a/tools/skill_eval_cloud_replay.py +++ b/tools/skill_eval_cloud_replay.py @@ -8,7 +8,7 @@ from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.benchmark import skill_eval_engineering as engineering -from inferrsi.harness import artifact_sandbox +from inferrsi.harness.executor import artifact_sandbox from tools import skill_eval_artifact_guidance as artifact_guidance from tools.skill_eval_qualify import qualify diff --git a/tools/skill_eval_compare.py b/tools/skill_eval_compare.py index 5371a91e3..a4be7f5ca 100644 --- a/tools/skill_eval_compare.py +++ b/tools/skill_eval_compare.py @@ -25,9 +25,9 @@ from inferrsi.apps.workflows.skill_evaluation import export_bundle, run_trial, summarize from inferrsi.benchmark import skill_eval_diagnostic as diagnostic from inferrsi.benchmark import skill_eval_engineering as engineering -from inferrsi.harness import artifact_sandbox +from inferrsi.harness.executor import artifact_sandbox +from inferrsi.harness.executor.skill_evaluation import CodexClient from inferrsi.harness.records.usage import normalize_usage -from inferrsi.harness.skill_evaluation import CodexClient from inferrsi.knowledge.knowledge_operations import KnowledgeReader, safe_path from tools import skill_eval_artifact_guidance as artifact_guidance from tools.skill_eval_pilot import PROMPT, SCHEMA, observed_tokens @@ -44,11 +44,12 @@ "src/inferrsi/benchmark/skill_evaluation.py", "src/inferrsi/benchmark/skill_eval_diagnostic.py", "src/inferrsi/benchmark/skill_eval_engineering.py", - "src/inferrsi/harness/skill_evaluation.py", - "src/inferrsi/harness/artifact_sandbox.py", "tools/skill_eval_snapshot.py", - "src/inferrsi/harness/local_process.py", + "src/inferrsi/harness/executor/skill_evaluation.py", + "src/inferrsi/harness/executor/artifact_sandbox.py", "tools/skill_eval_snapshot.py", + "src/inferrsi/harness/executor/local_process.py", "src/inferrsi/harness/records/atomic_json.py", - "src/inferrsi/harness/input_binding.py", "src/inferrsi/apps/storage/artifacts.py") + "src/inferrsi/harness/executor/_input_binding.py", + "src/inferrsi/apps/storage/artifacts.py") EVIDENCE = ("execution.json", "agent/stdout.log", "agent/stderr.log", "verification/result.json", "verification/stdout.log", "verification/stderr.log") NUMBER = (int, float) diff --git a/tools/skill_eval_historical_job.py b/tools/skill_eval_historical_job.py index 57b73056b..d55e403fa 100644 --- a/tools/skill_eval_historical_job.py +++ b/tools/skill_eval_historical_job.py @@ -13,7 +13,7 @@ from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.benchmark import skill_eval_engineering as engineering -from inferrsi.harness import artifact_sandbox +from inferrsi.harness.executor import artifact_sandbox from tools import skill_eval_auto as auto from tools import skill_eval_compare as compare from tools import skill_eval_historical_accounting as accounting diff --git a/tools/skill_eval_improve.py b/tools/skill_eval_improve.py index ae166ebb7..4b679e4e8 100644 --- a/tools/skill_eval_improve.py +++ b/tools/skill_eval_improve.py @@ -20,8 +20,8 @@ rerun_assessment, ) from inferrsi.benchmark.improvement import SelectionPolicy +from inferrsi.harness.executor.skill_evaluation import CodexClient from inferrsi.harness.records.usage import usage_totals -from inferrsi.harness.skill_evaluation import CodexClient from inferrsi.knowledge.knowledge_operations import KnowledgeReader, safe_path from tools import skill_eval_compare as compare diff --git a/tools/skill_eval_local.py b/tools/skill_eval_local.py index 68844a460..a9b137178 100644 --- a/tools/skill_eval_local.py +++ b/tools/skill_eval_local.py @@ -15,7 +15,7 @@ from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.benchmark import skill_eval_engineering as engineering -from inferrsi.harness import artifact_sandbox +from inferrsi.harness.executor import artifact_sandbox from inferrsi.harness.records.usage import normalize_usage diff --git a/tools/skill_eval_pilot.py b/tools/skill_eval_pilot.py index 90730938f..8172db748 100644 --- a/tools/skill_eval_pilot.py +++ b/tools/skill_eval_pilot.py @@ -9,8 +9,8 @@ from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows.skill_evaluation import export_bundle, run_trial, summarize +from inferrsi.harness.executor.skill_evaluation import CodexClient from inferrsi.harness.records.usage import normalize_usage -from inferrsi.harness.skill_evaluation import CodexClient from inferrsi.knowledge.knowledge_operations import KnowledgeReader ROOT = Path(__file__).resolve().parents[1] @@ -207,7 +207,7 @@ def prepare( source_files = [ ROOT / "src/inferrsi/apps/workflows/skill_evaluation.py", ROOT / "src/inferrsi/benchmark/skill_evaluation.py", - ROOT / "src/inferrsi/harness/skill_evaluation.py", + ROOT / "src/inferrsi/harness/executor/skill_evaluation.py", Path(__file__), ROOT / "tools/skill_eval_verifier.py", ] diff --git a/tools/skill_eval_qualify.py b/tools/skill_eval_qualify.py index fc775de1b..a0efd178f 100644 --- a/tools/skill_eval_qualify.py +++ b/tools/skill_eval_qualify.py @@ -14,7 +14,7 @@ from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.benchmark import skill_eval_engineering as engineering -from inferrsi.harness import artifact_sandbox +from inferrsi.harness.executor import artifact_sandbox ROOT = Path(__file__).resolve().parents[1] CONTROL = ROOT / "tests/fixtures/skill_eval_engineering/correct_parser.py" diff --git a/tools/speculative_skill.py b/tools/speculative_skill.py index 43c3dbfe5..42658a3cf 100644 --- a/tools/speculative_skill.py +++ b/tools/speculative_skill.py @@ -14,11 +14,10 @@ import time from pathlib import Path -from inferrsi.harness import candidates -from inferrsi.harness.executor import runtime_environment +from inferrsi.harness.executor import candidates, runtime_environment +from inferrsi.harness.executor.trials.external import execute_trial from inferrsi.harness.records.artifact_primitives import digest, sha256 from inferrsi.harness.records.atomic_json import atomic_write_json -from inferrsi.harness.trials.external import execute_trial from inferrsi.knowledge.knowledge_operations import KnowledgeReader from tools import skill_eval_compare as compare from tools.skill_eval_improve import materialize