diff --git a/CHANGELOG.md b/CHANGELOG.md index a18e9671..ec44465e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,38 @@ ### Changed +- The campaign chart renderer and the single-task launcher move into the Apps + package and the two root modules are removed (Refs #408, A2), with no + forwarding shell, `sys.modules` alias or import fallback. Both files move + with their bytes unchanged: + - `inferrsi.summary_chart` → `inferrsi.apps.views.summary_chart` + (`src/inferrsi/summary_chart.py` → + `src/inferrsi/apps/views/summary_chart.py`), which keeps `build_svg`, + `build_markdown`, `spec_from_evaluation`, `check_trial_chart_eligibility`, + `SpecError` and `main` + - `inferrsi.benchmark_operations` → `inferrsi.apps.benchmark_operations` + (`src/inferrsi/benchmark_operations.py` → + `src/inferrsi/apps/benchmark_operations.py`), which keeps `run_task` + - `tools/campaign_summary_chart.py` keeps its command line and arguments. + Its exit codes, stdout, stderr and the SVG and Markdown bytes it writes are + unchanged. The dashboard, the HTML report and `benchmarks run` import the + canonical modules. + - Importing `inferrsi.summary_chart` or `inferrsi.benchmark_operations` now + raises `ModuleNotFoundError`, in external Python code as well as in this + repository, and a pickle that names an object by either path no longer + loads. Callers import from `inferrsi.apps.views.summary_chart` and + `inferrsi.apps.benchmark_operations`. Frozen evidence is not rewritten. + - The tracked package root shrinks from eight files to six. Besides + `__init__.py` and `__main__.py`, the four left (`mindie_context.py`, + `mindie_mcp.py`, `mindie_project.py` and `_mindie_read_worker.py`) wait for + M1 (#452). The gate's exact-file `APPLICATION_ENTRIES` listing is removed + with its last entry, so no root file is application assembly, and + `inferrsi.summary_chart` and `inferrsi.benchmark_operations` join + `RETIRED_ROOT_MODULES`, so a root file that returns under either name + fails. + - Isolation is still incomplete: the 12 Harness hits into Infra (R2, #412) + and the five runtime resource loaders (R3, #412) remain. + - The CLI moves into the Apps package and the two root CLI modules are removed (Refs #408, A1), with no forwarding shell, `sys.modules` alias or import fallback: diff --git a/docs/architecture.md b/docs/architecture.md index 0b050631..5c42ee2e 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -7,7 +7,7 @@ packages. `inferrsi benchmarks run ...` launches the package's `benchmark.py`. Task-specific orchestration, sampling and assessment live inside each package. The task library owns its `index.json` registration. The existing `benchmark/registry.py` discovers the resources. The CLI package `apps/cli/` -and the existing `benchmark_operations.py` provide application assembly and launch. +and `apps/benchmark_operations.py` provide application assembly and launch. Each task retains its own protocol and task-specific code. The [current-Agent optimization session](optimization-benchmarks.md) assembles @@ -159,7 +159,6 @@ the comparator; the engine AB/BA path retains its independent acceptance contrac ```text src/inferrsi/ apps/cli/ CLI entry `main` and its argument parser - benchmark_operations.py Resolve a task entry and launch it through Harness benchmark/ registry.py Generic task resource discovery tasks/ Task-specific definitions, workloads and assessment @@ -171,6 +170,7 @@ src/inferrsi/ improvement.py Improvement-step thresholds and acceptance rules apps/ api.py Python entry points for assembling and publishing Apps operations + benchmark_operations.py Resolve a task entry and launch it through Harness archive.py Publish and read the standardized Apps output in a workspace result.py Assemble and check the AppsResultV1 output envelope skill_evaluation.py Composed bundle export, trial run and summary @@ -189,11 +189,11 @@ src/inferrsi/ resources/ __init__.py Import-free initializer repository_packs.py Neutral REPO_TYPES and pack.json reader; imports no inferrsi module - summary_chart.py Stdlib SVG gain chart (chain/branch) and report figure spec apps/ evidence_layout.py Create the plan/results/patch/validator evidence directories campaign.py Knowledge values connected to Harness campaign records views/ + summary_chart.py Stdlib SVG gain chart (chain/branch) and report figure spec optimization_chart.py Managed optimization objective/token curves and final result dashboard.py Offline snapshot and HTML rendering dashboard_data.py Recorded run/campaign evidence into a view model @@ -271,17 +271,19 @@ examples/ Current Qwen runner, image validator and v4 adapter tests/fixtures/legacy/ Frozen historical validation dependencies for regressions ``` -The package root holds exactly eight tracked files at this stage: `__init__.py`, -`__main__.py`, `benchmark_operations.py`, `summary_chart.py`, -`mindie_context.py`, `mindie_mcp.py`, `mindie_project.py` and -`_mindie_read_worker.py`. #408 A1 moved the CLI and its parser to `apps/cli/` -and deleted root `cli.py` and `arguments.py` with no forwarding shell or alias; +The package root holds exactly six tracked files at this stage: `__init__.py`, +`__main__.py`, `mindie_context.py`, `mindie_mcp.py`, `mindie_project.py` and +`_mindie_read_worker.py`. #408 A2 moved the chart renderer to +`apps/views/summary_chart.py` and the task launcher to `apps/benchmark_operations.py` +and deleted root `summary_chart.py` and `benchmark_operations.py` with no forwarding +shell or alias. #408 A1 moved the CLI and its parser to `apps/cli/` +and deleted root `cli.py` and `arguments.py` the same way; `__main__.py` and the console script call `inferrsi.apps.cli:main`. #412 R1 deleted eleven root modules with no forwarding shell or alias: the seven Knowledge shells, whose code is in `knowledge/`; the three old-run forwarders `evaluation.py`, `execution.py` and `reporting.py`, whose code is in `apps/legacy/`; and `inspection.py`, whose host binding is `apps/inspection.py`. The final two-file root (`__init__.py` -and `__main__.py`) waits for the A2 (#408) and M1 (#452) moves. +and `__main__.py`) waits for the M1 (#452) move. [module-layout.md](module-layout.md#retired-root-modules) maps each retired path to its replacement and lists what still keeps the isolation gate false. diff --git a/docs/campaign-summary-chart.md b/docs/campaign-summary-chart.md index 4d5f533d..e91e79eb 100644 --- a/docs/campaign-summary-chart.md +++ b/docs/campaign-summary-chart.md @@ -4,7 +4,7 @@ One figure per campaign that answers "what did this campaign move, and by how much". It is drawn automatically when an experiment finishes, and the same renderer produces a standalone figure for a multi-step campaign. -The renderer is [inferrsi/summary_chart.py](../src/inferrsi/summary_chart.py), +The renderer is [inferrsi/apps/views/summary_chart.py](../src/inferrsi/apps/views/summary_chart.py), also exposed as [tools/campaign_summary_chart.py](../tools/campaign_summary_chart.py) and listed in the [operation guide](operations.md#summarize-a-campaign-figure--campaign_summary_chartpy). It uses only the standard library and writes SVG, so a committed figure diff --git a/docs/engineering-benchmarks.md b/docs/engineering-benchmarks.md index b10dc527..cc58bf4e 100644 --- a/docs/engineering-benchmarks.md +++ b/docs/engineering-benchmarks.md @@ -57,9 +57,9 @@ and TTS entries also run directly by file path. ```text src/inferrsi/ - arguments.py Existing CLI argument assembly - cli.py Existing command dispatch - benchmark_operations.py Application child launcher and executor injection + apps/ + cli/ CLI command dispatch and argument assembly + benchmark_operations.py Application child launcher and executor injection harness/ optimization.py Current-Agent session budget, records and recovery usage.py Shared usage normalization and totals diff --git a/docs/module-layout.md b/docs/module-layout.md index e932bf17..28ddfcbf 100644 --- a/docs/module-layout.md +++ b/docs/module-layout.md @@ -5,8 +5,8 @@ Knowledge move (K01) is implemented: `src/inferrsi/knowledge/` holds the seven moved Knowledge bodies. R1 (#412) deleted the seven static root compatibility shells that K01 left, so those names import only from `inferrsi.knowledge`. The engineering task contribution now implements `benchmark/registry.py` -and `benchmark/tasks/`. The CLI package `apps/cli/` and the flat -`benchmark_operations.py` assemble this slice. The former `observability/` +and `benchmark/tasks/`. The CLI package `apps/cli/` and +`apps/benchmark_operations.py` assemble this slice. The former `observability/` package is dissolved. Its campaign records, traces, logs and profile captures are in `harness/records/`, its dashboard views and templates are in `apps/views/`, and the @@ -43,18 +43,20 @@ no forwarding shell or alias. The flat package root is retired in stages. `tests/test_package_root_inventory.py` pins the root to an exact file set: 23 -tracked files after C1, 21 after C2, 10 after R1 (#412) and 8 after A1 (#408). -The eight are `__init__.py`, `__main__.py`, `_mindie_read_worker.py`, -`benchmark_operations.py`, `mindie_context.py`, `mindie_mcp.py`, -`mindie_project.py` and `summary_chart.py`. A1 moved root `cli.py` and +tracked files after C1, 21 after C2, 10 after R1 (#412), 8 after A1 (#408) and 6 +after A2 (#408). The six are `__init__.py`, `__main__.py`, +`_mindie_read_worker.py`, `mindie_context.py`, `mindie_mcp.py` and +`mindie_project.py`. A2 moved root `summary_chart.py` to +`apps/views/summary_chart.py` and root `benchmark_operations.py` to +`apps/benchmark_operations.py` and deleted both root files with no forwarding +shell or alias. A1 moved root `cli.py` and `arguments.py` to `apps/cli/__init__.py` and `apps/cli/arguments.py` and -deleted both root files with no forwarding shell or alias. Each later removal -PR shrinks the set in the same change: A2 (#408) moves the chart and the -benchmark launcher, and M1 (#452) moves the four MindIE files. The guard does +deleted both root files the same way. The last removal PR shrinks the set in +the same change: M1 (#452) moves the four MindIE files. The guard does not assert the final two-file root (`__init__.py` and `__main__.py`) early, and the build-generated `_version.py` is ignored wheel metadata, not a tracked root file. [Retired root modules](#retired-root-modules) lists the eleven -paths that R1 removed and the two that A1 removed. +paths that R1 removed, the two that A1 removed and the two that A2 removed. The current `src/inferrsi/harness/` tree is a mixed implementation. Its presence is not the target Harness boundary and is not evidence that the four @@ -107,7 +109,7 @@ Several flat modules remain shared seams until their slice starts. | Current path | Tentative reading | This slice | | --- | --- | --- | | `apps/cli/` (`__init__.py`, `arguments.py`), root `__main__.py` | Apps CLI entry and its parser | A1 (#408) moved root `cli.py` and `arguments.py` here; the entry is `inferrsi.apps.cli:main`, and `__main__.py` only delegates to it | -| `benchmark_operations.py` | Single-task application launcher | Resolves a task entry and invokes the Harness runner; ordinary projects do not use it | +| `apps/benchmark_operations.py` | Single-task application launcher | A2 (#408) moved root `benchmark_operations.py` here; resolves a task entry and invokes the Harness runner, and ordinary projects do not use it | | `benchmark/registry.py`, `benchmark/tasks/` | Task discovery, definitions and specialized rules | Task-specific quality and measurement code stays with each task | | `harness/optimization_session.py`, `harness/project.py`, `harness/task_protocol.py` | Shared preparation, execution and retained-result assessment | CLI supplies task resources and knowledge access; ordinary project lifecycle does not import Benchmark | | `harness/optimization.py`, `harness/candidates.py`, `harness/usage.py` | Shared project and packaged-task lifecycle | Injected execution/assessment; declared file/directory candidates, selection direction and exact/up-to rounds | @@ -125,7 +127,7 @@ Several flat modules remain shared seams until their slice starts. | `apps/inspection.py` | Prepared-environment inspection bound to this host | Binds the `infra/inspection.py` facts API to `infra.commands.probe_command` and `infra.targets.repository_identity`; replaces root `inspection.py`, which R1 deleted with the three old-run root forwarders | | `model/validators/` | Benchmark-leaning checks | Not moved | | `infra/` | Seams used by the current tree, including the `infra/inspection.py` facts API | Not a fourth core; reaches no Knowledge, Harness, Benchmark or Apps module | -| `summary_chart.py` | Current report helper | Not moved | +| `apps/views/summary_chart.py` | Stdlib SVG gain chart and report figure spec | A2 (#408) moved root `summary_chart.py` here; the renderer, its specification checks and its `main` are unchanged, and `tools/campaign_summary_chart.py` calls it | | `contracts/` (`runspec.py`, `json_v1.py`, `claim.py`, `evidence.py`) | Technical-only contracts: RunSpec, canonical JSON, verdict vocabulary, evidence segment and path rules | Exact module set; the initializer re-exports only `RunSpec`; not a fourth core | | `apps/evidence_layout.py` | Evidence directory creation over the `contracts/evidence.py` path rules | The `mkdir` half of former root `evidence_paths.py`; host I/O stays in Apps | | `resources/repository_packs.py` | Neutral `REPO_TYPES` and `repository_pack` facade | Former root `_repo_pack_data.py`, bytes unchanged; import-free initializer; not a fourth core | @@ -136,13 +138,12 @@ Several flat modules remain shared seams until their slice starts. `tests/test_target_module_import_gate.py` fails on a new import of `inferrsi.knowledge`, `inferrsi.benchmark`, or `inferrsi.apps` from anywhere except application assembly, and on Knowledge or Benchmark importing Harness. -Application assembly includes `inferrsi.apps` and the one remaining flat -entry `benchmark_operations.py`, listed by exact file name as -`APPLICATION_ENTRIES` in `tests/_gate_policy_support.py`. A1 (#408) moved -`cli.py` and `arguments.py` into `apps/cli/`, which is Apps by its first path -segment, and removed their two entries, so a root file that returns under -either name is not admitted. The listing is temporary: A2 removes the last -entry. Other flat modules retain +Application assembly is the `inferrsi.apps` package, identified by its first path +segment. No root file is application assembly: A1 (#408) moved `cli.py` and +`arguments.py` into `apps/cli/`, A2 (#408) moved `benchmark_operations.py` into +`apps/`, and with that last move the exact-file `APPLICATION_ENTRIES` listing in +`tests/_gate_policy_support.py` is removed. A root file that returns under any of +those names is not admitted. Other flat modules retain the same restrictions. The gate checks Benchmark task scripts as well as module code. `from inferrsi import knowledge` counts as an import of that core. @@ -491,9 +492,21 @@ The `inferrsi` console script and `python -m inferrsi` call unchanged. A test replaces a CLI name such as `_knowledge_reader` or `files` on `inferrsi.apps.cli`. -The root now holds the eight files listed under +The root now holds the six files listed under [Target modules](#target-modules). The final two-file root waits for the -A2 (#408) and M1 (#452) moves. +M1 (#452) move. + +A2 (#408) deleted two more root modules the same way: + +| Retired root module | Canonical module | +| --- | --- | +| `inferrsi.summary_chart` | `inferrsi.apps.views.summary_chart` | +| `inferrsi.benchmark_operations` | `inferrsi.apps.benchmark_operations` | + +`tools/campaign_summary_chart.py` keeps its command line and calls +`inferrsi.apps.views.summary_chart:main`, so its arguments, exit codes, output and +the SVG and Markdown bytes it writes are unchanged. The dashboard, the HTML report +and the CLI `benchmarks run` command import the canonical modules. ## Old `run` exit codes diff --git a/docs/operations.md b/docs/operations.md index 547900e6..1ffc3d68 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -31,7 +31,7 @@ Effect classes used below: | Optimize an ordinary project in the current Agent | CLI `campaign start/knowledge/round/status/final/recover` | Experiment-executing / local records | Harness freezes explicit caller-provided checks, manages multi-file candidates, executes and assesses retained results. This path does not depend on Benchmark or infer acceptance from the goal. See [shared workflow](optimization-workflow-unification.md) | | Prepare and record a fresh native Agent | CLI `agents prepare/dispatch/bind/record/status` | Local records / explicit host handoff | The initiating Agent calls native host tools. Records prevent repeated dispatch; exported host observations do not establish task acceptance. See [native sessions](native-agent-sessions.md) | | Discover packaged tasks | CLI `benchmarks list` / `benchmarks show`; Python `benchmark.registry.builtin_tasks` / `describe_task` | Read-only | Reads the task library's registry and opaque manifests from installed resources | -| Execute one packaged task | CLI `benchmarks run`; Python `benchmark_operations.run_task` | Experiment-executing | Application launches the task entry, supplies the execution callback and preserves arguments and exit status. The task owns its device, measurement and assessment protocol | +| Execute one packaged task | CLI `benchmarks run`; Python `apps.benchmark_operations.run_task` | Experiment-executing | Application launches the task entry, supplies the execution callback and preserves arguments and exit status. The task owns its device, measurement and assessment protocol | | Search packaged records | CLI `knowledge search` / `knowledge show`; catalog API | Read-only | Installed package catalog with the existing tier/repo/backend/scenario filters and IDs; these package-only filters exclude skills and cases from every other authority | | Prepare model-aware engine research | CLI `knowledge research`; Python `research_knowledge` | Read-only | Independent model/framework/task/modality/mechanism queries over the same package catalog; source-grounded known profiles, deduplicated matches and explicit target annotations; no engine/hardware qualification | | Discover/read packaged or custom skills | CLI `skills list` / `show` / `resource` / `reference` | Read-only | Metadata-first listing; `show` loads one named instruction body; `resource`/`reference` resolve paths for your file reader without loading or executing them | diff --git a/src/inferrsi/benchmark_operations.py b/src/inferrsi/apps/benchmark_operations.py similarity index 100% rename from src/inferrsi/benchmark_operations.py rename to src/inferrsi/apps/benchmark_operations.py diff --git a/src/inferrsi/apps/cli/__init__.py b/src/inferrsi/apps/cli/__init__.py index eb9b3d49..f909faf9 100644 --- a/src/inferrsi/apps/cli/__init__.py +++ b/src/inferrsi/apps/cli/__init__.py @@ -203,7 +203,7 @@ def main(argv: list[str] | None = None) -> int: _print(result) return 2 if result.get("state") == "blocked" else 0 if args.benchmark_action == "run": - from ...benchmark_operations import run_task + from ..benchmark_operations import run_task return run_task(args.task, args.arguments) from ...benchmark.registry import builtin_tasks, describe_task diff --git a/src/inferrsi/apps/legacy/reporting.py b/src/inferrsi/apps/legacy/reporting.py index c0633d13..df3cc9c0 100644 --- a/src/inferrsi/apps/legacy/reporting.py +++ b/src/inferrsi/apps/legacy/reporting.py @@ -5,7 +5,7 @@ from pathlib import Path from urllib.parse import quote -from inferrsi.summary_chart import ( +from inferrsi.apps.views.summary_chart import ( SpecError, build_svg, check_trial_chart_eligibility, diff --git a/src/inferrsi/apps/views/dashboard.py b/src/inferrsi/apps/views/dashboard.py index d8744b0a..ee935928 100644 --- a/src/inferrsi/apps/views/dashboard.py +++ b/src/inferrsi/apps/views/dashboard.py @@ -11,11 +11,11 @@ from pathlib import Path from inferrsi.harness.records.evidence import inside, sanitized_text -from inferrsi.summary_chart import SpecError, build_svg from .attempt_html import render_attempt from .dashboard_data import _number, load_dashboard from .dashboard_timeline import temporal_chart +from .summary_chart import SpecError, build_svg def _sanitize_spec(value: object, depth: int = 0) -> object: diff --git a/src/inferrsi/summary_chart.py b/src/inferrsi/apps/views/summary_chart.py similarity index 100% rename from src/inferrsi/summary_chart.py rename to src/inferrsi/apps/views/summary_chart.py diff --git a/tests/_gate_policy_support.py b/tests/_gate_policy_support.py index 79472526..884547e2 100644 --- a/tests/_gate_policy_support.py +++ b/tests/_gate_policy_support.py @@ -1,4 +1,4 @@ -"""First-wave isolation gate helpers (P0b, revised through #408 A1). +"""First-wave isolation gate helpers (P0b, revised through #408 A2). Imported by the import-gate and isolation-policy tests. This is a test support module, not a runtime package. @@ -17,17 +17,17 @@ MANIFEST = REPO / "docs" / "legacy-knowledge-manifest.json" NEW_CORES = ("knowledge", "benchmark", "apps") CORE_NAMES = ("knowledge", "harness", "benchmark", "apps") -# Current application seams, until the Apps package migration. These are not -# Knowledge compatibility shells and do not grant access to other flat modules. -# A1 (#408) moved the CLI and its parser into ``apps/cli/`` and removed their two -# entries. That package is Apps by its first path segment, so a root ``cli.py`` or -# ``arguments.py`` that returns is an unlisted flat module. A2 removes the last entry. -APPLICATION_ENTRIES = ("benchmark_operations.py",) +# No root file is application assembly. A1 (#408) moved the CLI and its parser into +# ``apps/cli/``, and A2 (#408) moved the task launcher to ``apps/benchmark_operations.py``. +# With that last move the ``APPLICATION_ENTRIES`` listing is gone: Apps is the +# ``inferrsi.apps`` package by its first path segment and nothing else, so a root +# ``cli.py``, ``arguments.py`` or ``benchmark_operations.py`` that returns is an unlisted +# flat module. # #408 A1, permanent: ``python -m inferrsi`` runs root ``__main__.py``, which stays in # the package root and hands over to the canonical Apps CLI. The gate admits that one # statement and nothing wider: this exact root file, this exact target module and this # exact name, bound by a plain module-level ``from import `` line. It is -# not an ``APPLICATION_ENTRIES`` listing, so the file is never treated as Apps. Every +# not an application entry, so the file is never treated as Apps. Every # other import in it of Apps, Knowledge or Benchmark fails as in any flat module. So do # an alias, a second name, a star import, the target imported as a module object, a # module beside or below the target, and the same line below module level. No other @@ -66,7 +66,11 @@ # #408 A1 deleted the root CLI and its parser the same way, with no forwarder or alias. # The implementation is ``inferrsi.apps.cli`` and ``inferrsi.apps.cli.arguments``. RETIRED_BY_A1 = frozenset({"inferrsi.cli", "inferrsi.arguments"}) -RETIRED_ROOT_MODULES = RETIRED_BY_R1 | RETIRED_BY_A1 +# #408 A2 deleted the root chart renderer and task launcher the same way. The +# implementations are ``inferrsi.apps.views.summary_chart`` and +# ``inferrsi.apps.benchmark_operations``. +RETIRED_BY_A2 = frozenset({"inferrsi.summary_chart", "inferrsi.benchmark_operations"}) +RETIRED_ROOT_MODULES = RETIRED_BY_R1 | RETIRED_BY_A1 | RETIRED_BY_A2 # #412 R1, permanent: the one importer of the neutral data leaf outside # ``inferrsi.knowledge``, with the only name it may bind (D020: Infra reads one pack # description and reaches no Knowledge or Harness). This is not a manifest @@ -231,8 +235,6 @@ def cross_core_violations( for path in sorted(root.rglob("*.py")): relative = path.relative_to(root) importer = relative.parts[0] if len(relative.parts) > 1 else "" - if relative.as_posix() in APPLICATION_ENTRIES: - importer = "apps" importer_module = _module_name(relative) for module in _imported_modules(path, root): target = _core_of(module) diff --git a/tests/check_installed.py b/tests/check_installed.py index 9ac409b0..2329898f 100644 --- a/tests/check_installed.py +++ b/tests/check_installed.py @@ -648,11 +648,14 @@ def _inventory(root, prefix): raise AssertionError(f"retired module inferrsi.{retired} must not import") assert not installed_root & {f"{name}.py" for name in r1_retired} assert installed_root - {"_version.py"} == { - "__init__.py", "__main__.py", "_mindie_read_worker.py", "benchmark_operations.py", - "mindie_context.py", "mindie_mcp.py", "mindie_project.py", "summary_chart.py", + "__init__.py", "__main__.py", "_mindie_read_worker.py", + "mindie_context.py", "mindie_mcp.py", "mindie_project.py", }, sorted(installed_root) # #408 A1: the CLI and its parser ship only as inferrsi.apps.cli; neither root name imports. -for a1_retired in ("cli", "arguments"): +# #408 A2: the chart renderer and the task launcher ship only under inferrsi.apps. +for a1_retired in ("cli", "arguments", "summary_chart", "benchmark_operations"): + assert find_spec(f"inferrsi.{a1_retired}") is None, a1_retired + assert f"inferrsi.{a1_retired}" not in sys.modules, a1_retired try: import_module(f"inferrsi.{a1_retired}") except ModuleNotFoundError: @@ -660,6 +663,11 @@ def _inventory(root, prefix): else: raise AssertionError(f"retired module inferrsi.{a1_retired} must not import") assert main.__module__ == "inferrsi.apps.cli" +for canonical in ("inferrsi.apps.views.summary_chart", "inferrsi.apps.benchmark_operations"): + assert find_spec(canonical) is not None, canonical +assert import_module("inferrsi.apps.views.summary_chart").main.__module__ == ( + "inferrsi.apps.views.summary_chart" +) host_inspection = import_module("inferrsi.apps.inspection") assert host_inspection._command is import_module("inferrsi.infra.commands").probe_command assert host_inspection.repository_identity is ( diff --git a/tests/test_benchmark_operations.py b/tests/test_benchmark_operations.py index e38e0d43..091dd462 100644 --- a/tests/test_benchmark_operations.py +++ b/tests/test_benchmark_operations.py @@ -4,7 +4,7 @@ import pytest -from inferrsi import benchmark_operations +from inferrsi.apps import benchmark_operations from inferrsi.apps.cli import main from inferrsi.benchmark import registry diff --git a/tests/test_campaign_record_injection.py b/tests/test_campaign_record_injection.py index b0957b4e..d6de8032 100644 --- a/tests/test_campaign_record_injection.py +++ b/tests/test_campaign_record_injection.py @@ -17,6 +17,7 @@ NEW_H_ENTRIES, REPO, RETIRED_BY_A1, + RETIRED_BY_A2, RETIRED_BY_R1, RETIRED_ROOT_MODULES, ROOT, @@ -365,15 +366,19 @@ def _record_modules(): def test_harness_records_load_no_knowledge_or_apps_module(): - # #412 R1 retired eleven root modules and #408 A1 retired the root CLI and its parser. - # None of those thirteen names may be loaded either. + # #412 R1 retired eleven root modules, #408 A1 retired the root CLI and its parser, + # and #408 A2 retired the root chart renderer and task launcher. None of those fifteen + # names may be loaded either. assert len(RETIRED_BY_R1) == 11 assert RETIRED_BY_A1 == {"inferrsi.cli", "inferrsi.arguments"} + assert RETIRED_BY_A2 == {"inferrsi.summary_chart", "inferrsi.benchmark_operations"} assert not RETIRED_BY_R1 & RETIRED_BY_A1 - assert RETIRED_ROOT_MODULES == RETIRED_BY_R1 | RETIRED_BY_A1 + assert not (RETIRED_BY_R1 | RETIRED_BY_A1) & RETIRED_BY_A2 + assert RETIRED_ROOT_MODULES == RETIRED_BY_R1 | RETIRED_BY_A1 | RETIRED_BY_A2 leaves = sorted(RETIRED_ROOT_MODULES) - assert len(leaves) == 13 + assert len(leaves) == 15 assert {"inferrsi.cli", "inferrsi.arguments"} <= set(leaves) + assert RETIRED_BY_A2 <= set(leaves) script = ( "import importlib, sys\n" f"for name in {_record_modules()!r}:\n" diff --git a/tests/test_first_wave_isolation_policy.py b/tests/test_first_wave_isolation_policy.py index fdab48c0..6d3854e3 100644 --- a/tests/test_first_wave_isolation_policy.py +++ b/tests/test_first_wave_isolation_policy.py @@ -420,7 +420,8 @@ def test_another_importer_fails(self) -> None: "infra/platforms/__init__.py", "harness/api.py", "harness/runner.py", "benchmark/probe.py", "apps/main.py", "apps/inspection.py", "model/probe.py", "cli.py", "arguments.py", "apps/cli/__init__.py", "apps/cli/arguments.py", - "benchmark_operations.py", "helper.py", "catalog.py", + "benchmark_operations.py", "apps/benchmark_operations.py", "summary_chart.py", + "apps/views/summary_chart.py", "helper.py", "catalog.py", "_repo_pack_data.py", ) for path in paths: @@ -484,13 +485,18 @@ def test_hidden_routes_around_the_rule_fail(self) -> None: class RetiredRootModuleTest(unittest.TestCase): - """#412 R1: the eleven deleted root modules cannot return, as any kind of file.""" + """#412 R1 and #408 A1, A2: the fifteen deleted root modules cannot return, as any file.""" def test_the_retired_set_is_the_exact_eleven_and_absent_from_the_tree(self) -> None: self.assertEqual(support.RETIRED_BY_A1, {"inferrsi.cli", "inferrsi.arguments"}) self.assertEqual( - support.RETIRED_ROOT_MODULES, support.RETIRED_BY_R1 | support.RETIRED_BY_A1 + support.RETIRED_BY_A2, {"inferrsi.summary_chart", "inferrsi.benchmark_operations"} ) + self.assertEqual( + support.RETIRED_ROOT_MODULES, + support.RETIRED_BY_R1 | support.RETIRED_BY_A1 | support.RETIRED_BY_A2, + ) + self.assertEqual(len(support.RETIRED_ROOT_MODULES), 15) self.assertEqual( support.RETIRED_BY_R1, { diff --git a/tests/test_optimization_session.py b/tests/test_optimization_session.py index 52bd3bbf..6fa9ea8b 100644 --- a/tests/test_optimization_session.py +++ b/tests/test_optimization_session.py @@ -266,7 +266,7 @@ def broken_assessor(*args): def test_task_runner_does_not_expose_harness_as_top_level_modules(task, tmp_path): - from inferrsi.benchmark_operations import run_task + from inferrsi.apps.benchmark_operations import run_task output = tmp_path / "imports.json" (task / "benchmark.py").write_text( diff --git a/tests/test_package_root_inventory.py b/tests/test_package_root_inventory.py index 064d1207..810451d3 100644 --- a/tests/test_package_root_inventory.py +++ b/tests/test_package_root_inventory.py @@ -1,7 +1,8 @@ -"""Exact inventory of the files directly under ``src/inferrsi/`` (#451 C1, C2; #412 R1; #408 A1). +"""Exact inventory of the files directly under ``src/inferrsi/``. -The flat package root is being retired. This guard pins the root to the exact file -set left after A1 and rejects any other root file. Each later removal PR (A2, M1) +Set by #451 C1, C2, #412 R1 and #408 A1, A2. The flat package root is being retired. +This guard pins the root to the exact file +set left after A2 and rejects any other root file. The last removal PR (M1) shrinks ``ROOT_FILES`` in the same change, until only ``__init__.py`` and ``__main__.py`` remain. It does not assert that final state early. """ @@ -38,17 +39,18 @@ ) # A1 (#408) moved the CLI and its parser to apps/cli/ and deleted both root files. RETIRED_BY_A1 = frozenset({"arguments.py", "cli.py"}) -RETIRED = RETIRED_BY_C1 | RETIRED_BY_C2 | RETIRED_BY_R1 | RETIRED_BY_A1 +# A2 (#408) moved the chart renderer to apps/views/ and the task launcher to apps/, and +# deleted both root files. +RETIRED_BY_A2 = frozenset({"benchmark_operations.py", "summary_chart.py"}) +RETIRED = RETIRED_BY_C1 | RETIRED_BY_C2 | RETIRED_BY_R1 | RETIRED_BY_A1 | RETIRED_BY_A2 ROOT_FILES = frozenset( { "__init__.py", "__main__.py", "_mindie_read_worker.py", - "benchmark_operations.py", "mindie_context.py", "mindie_mcp.py", "mindie_project.py", - "summary_chart.py", } ) # setuptools-scm writes this file at build time. It is gitignored wheel metadata and is @@ -88,25 +90,29 @@ def root_files(repo: Path) -> set[str]: return present - _listed(repo, "--deleted") -def test_inventory_is_the_exact_post_a1_set() -> None: - assert len(ROOT_FILES) == 8 +def test_inventory_is_the_exact_post_a2_set() -> None: + assert len(ROOT_FILES) == 6 assert len(RETIRED_BY_C1) == 4 and len(RETIRED_BY_C2) == 2 and len(RETIRED_BY_R1) == 11 assert RETIRED_BY_A1 == {"arguments.py", "cli.py"} + assert RETIRED_BY_A2 == {"benchmark_operations.py", "summary_chart.py"} assert not ROOT_FILES & RETIRED - assert len(RETIRED) == 19 - # 27 before C1, 23 after C1, 21 after C2, 10 after R1, 8 after A1. + assert len(RETIRED) == 21 + # 27 before C1, 23 after C1, 21 after C2, 10 after R1, 8 after A1, 6 after A2. assert len(ROOT_FILES | RETIRED) == 27 - assert len(ROOT_FILES | RETIRED_BY_C2 | RETIRED_BY_R1 | RETIRED_BY_A1) == 23 - assert len(ROOT_FILES | RETIRED_BY_R1 | RETIRED_BY_A1) == 21 - assert len(ROOT_FILES | RETIRED_BY_A1) == 10 + assert len(ROOT_FILES | RETIRED_BY_C2 | RETIRED_BY_R1 | RETIRED_BY_A1 | RETIRED_BY_A2) == 23 + assert len(ROOT_FILES | RETIRED_BY_R1 | RETIRED_BY_A1 | RETIRED_BY_A2) == 21 + assert len(ROOT_FILES | RETIRED_BY_A1 | RETIRED_BY_A2) == 10 + assert len(ROOT_FILES | RETIRED_BY_A2) == 8 assert GENERATED not in ROOT_FILES assert {"__init__.py", "__main__.py"} <= ROOT_FILES - # The final two-file root waits for the A2 and M1 moves; it is not asserted here. - # These six are their move targets and stay until then. + # The final two-file root waits for the M1 move; it is not asserted here. + # These four are its move targets and stay until then. assert ROOT_FILES - {"__init__.py", "__main__.py"} == { - "_mindie_read_worker.py", "benchmark_operations.py", "mindie_context.py", - "mindie_mcp.py", "mindie_project.py", "summary_chart.py", + "_mindie_read_worker.py", "mindie_context.py", "mindie_mcp.py", "mindie_project.py", } + # A2 moved its two files into Apps. + assert (REPO / PACKAGE / "apps" / "benchmark_operations.py").is_file() + assert (REPO / PACKAGE / "apps" / "views" / "summary_chart.py").is_file() # A1 moved its two files; the implementation is the apps/cli package. for name in ("__init__.py", "arguments.py"): assert (REPO / PACKAGE / "apps" / "cli" / name).is_file(), name @@ -153,21 +159,32 @@ def test_an_added_root_file_is_rejected(name: str) -> None: def test_a_removed_root_file_must_shrink_the_inventory() -> None: - chart = "summary_chart.py" - assert inventory_errors(set(ROOT_FILES) - {chart}) == [ - f"missing root file {PACKAGE}/{chart}: shrink ROOT_FILES in the PR that removes it" + worker = "_mindie_read_worker.py" + assert inventory_errors(set(ROOT_FILES) - {worker}) == [ + f"missing root file {PACKAGE}/{worker}: shrink ROOT_FILES in the PR that removes it" ] # A later removal PR passes once it shrinks the expected set with the files. - smaller = ROOT_FILES - {chart, "benchmark_operations.py"} + smaller = ROOT_FILES - {worker, "mindie_context.py", "mindie_mcp.py", "mindie_project.py"} assert inventory_errors(set(smaller), smaller) == [] - # A1 itself: the 10-file set it started from no longer matches the 8-file root, and - # keeping either old file beside the moved package is rejected. - after_r1 = ROOT_FILES | RETIRED_BY_A1 - assert inventory_errors(set(ROOT_FILES), after_r1) == [ + # A2 itself: the 8-file set it started from no longer matches the 6-file root, and + # keeping either old file beside its moved module is rejected. + after_a1 = ROOT_FILES | RETIRED_BY_A2 + assert inventory_errors(set(ROOT_FILES), after_a1) == [ + f"missing root file {PACKAGE}/{name}: shrink ROOT_FILES in the PR that removes it" + for name in sorted(RETIRED_BY_A2) + ] + assert inventory_errors(set(after_a1)) == [ + f"unexpected root file {PACKAGE}/{name}: a new module belongs in a subpackage" + for name in sorted(RETIRED_BY_A2) + ] + # A1 itself: the 10-file set it started from no longer matched its 8-file root, and + # keeping either old file beside the moved package was rejected. + after_r1 = after_a1 | RETIRED_BY_A1 + assert inventory_errors(set(after_a1), after_r1) == [ f"missing root file {PACKAGE}/{name}: shrink ROOT_FILES in the PR that removes it" for name in sorted(RETIRED_BY_A1) ] - assert inventory_errors(set(after_r1)) == [ + assert inventory_errors(set(after_r1), after_a1) == [ f"unexpected root file {PACKAGE}/{name}: a new module belongs in a subpackage" for name in sorted(RETIRED_BY_A1) ] @@ -238,7 +255,7 @@ def unexpected(name: str) -> str: (root / "runspec.py").write_text("", encoding="utf-8") assert inventory_errors(root_files(tmp_path)) == [unexpected("runspec.py")] (root / "runspec.py").unlink() - (root / "summary_chart.py").unlink() + (root / "mindie_mcp.py").unlink() assert inventory_errors(root_files(tmp_path)) == [ - f"missing root file {PACKAGE}/summary_chart.py: shrink ROOT_FILES in the PR that removes it" + f"missing root file {PACKAGE}/mindie_mcp.py: shrink ROOT_FILES in the PR that removes it" ] diff --git a/tests/test_project_optimization.py b/tests/test_project_optimization.py index eb9f312f..4a7aa855 100644 --- a/tests/test_project_optimization.py +++ b/tests/test_project_optimization.py @@ -77,7 +77,7 @@ def test_project_lifecycle_never_imports_benchmark(project): from pathlib import Path class NoBenchmark(importlib.abc.MetaPathFinder): def find_spec(self, fullname, path=None, target=None): - if fullname in ('inferrsi.benchmark', 'inferrsi.benchmark_operations') or ( + if fullname in ('inferrsi.benchmark', 'inferrsi.apps.benchmark_operations') or ( fullname.startswith('inferrsi.benchmark.') ): raise AssertionError('Ordinary optimization imported ' + fullname) diff --git a/tests/test_summary_chart.py b/tests/test_summary_chart.py index 6cc4a720..8248badd 100644 --- a/tests/test_summary_chart.py +++ b/tests/test_summary_chart.py @@ -6,8 +6,8 @@ import pytest -from inferrsi import summary_chart from inferrsi.apps.legacy.reporting import write_report +from inferrsi.apps.views import summary_chart PROJECT = Path(__file__).resolve().parents[1] EXAMPLES = PROJECT / "evidence" / "_template" / "results" diff --git a/tests/test_target_module_import_gate.py b/tests/test_target_module_import_gate.py index 41c9d175..bafcdff9 100644 --- a/tests/test_target_module_import_gate.py +++ b/tests/test_target_module_import_gate.py @@ -74,21 +74,15 @@ def test_no_new_cross_core_imports(self) -> None: self.assertEqual(allowed, frozenset()) self.assertEqual(cross_core_violations(allowed=allowed), []) self.assertFalse(hasattr(support, "LEGACY_RUN_FORWARDERS")) - # #408 A1: the CLI and its parser are apps/cli/, Apps by first path segment, so - # their two exact entries are gone and neither root file exists. Each listed - # file exists in the root, so an entry cannot outlive the file that A2 removes. - self.assertEqual(support.APPLICATION_ENTRIES, ("benchmark_operations.py",)) - for entry in support.APPLICATION_ENTRIES: - self.assertTrue((ROOT / entry).is_file(), entry) - for retired in ("cli.py", "arguments.py"): + # #408 A1 and A2: the CLI, its parser and the task launcher are under apps/, Apps by + # first path segment. With the last move the exact flat-entry listing is gone, so no + # root file is read as Apps and none of the old root files exists. + self.assertFalse(hasattr(support, "APPLICATION_ENTRIES")) + for retired in ("cli.py", "arguments.py", "benchmark_operations.py", "summary_chart.py"): self.assertFalse((ROOT / retired).exists(), retired) - for moved in ("__init__.py", "arguments.py"): - self.assertTrue((ROOT / "apps" / "cli" / moved).is_file(), moved) - # The listing is what admits the last flat entry: without it that file fails. - with mock.patch.object(support, "APPLICATION_ENTRIES", ()): - self.assertEqual( - cross_core_violations(), ["benchmark_operations.py imports inferrsi.benchmark"] - ) + for moved in ("cli/__init__.py", "cli/arguments.py", "benchmark_operations.py", + "views/summary_chart.py"): + self.assertTrue((ROOT / "apps" / moved).is_file(), moved) def test_first_wave_policy_holds_on_current_tree(self) -> None: self.assertEqual(first_wave_report().violations, ()) @@ -107,9 +101,13 @@ def test_clean_scan_is_not_isolation(self) -> None: "_repo_pack_data.py", "evidence_paths.py"): self.assertFalse((ROOT / retired).exists(), retired) # #412 R1: the eleven retired root modules are gone, with no package in their place. + # #408 A1 and A2 each retired two more. self.assertEqual(len(support.RETIRED_BY_R1), 11) self.assertEqual(support.RETIRED_BY_A1, {"inferrsi.cli", "inferrsi.arguments"}) - self.assertEqual(len(support.RETIRED_ROOT_MODULES), 13) + self.assertEqual( + support.RETIRED_BY_A2, {"inferrsi.summary_chart", "inferrsi.benchmark_operations"} + ) + self.assertEqual(len(support.RETIRED_ROOT_MODULES), 15) for module in support.RETIRED_ROOT_MODULES: name = module.removeprefix("inferrsi.") self.assertFalse((ROOT / f"{name}.py").exists(), name) @@ -203,8 +201,11 @@ def test_real_tree_allows_apps_and_same_core_only(self) -> None: "apps/cli/arguments.py": "from inferrsi.knowledge import catalog\n", "cli.py": "from inferrsi.apps.cli import main\n", "arguments.py": "from inferrsi.knowledge import catalog\n", - # The listing is the exact file name: a module beside it gains nothing. + # No root file is listed, so a module beside an old name gains nothing. "arguments_extra.py": "from inferrsi.knowledge import catalog\n", + # #408 A2: the task launcher is Apps by path too. The root file that held + # it is no longer an application entry and fails like the others. + "apps/benchmark_operations.py": "import inferrsi.benchmark\n", "benchmark_operations.py": "import inferrsi.benchmark\n", "unowned.py": "import inferrsi.benchmark\n", } @@ -219,6 +220,7 @@ def test_real_tree_allows_apps_and_same_core_only(self) -> None: "arguments.py imports inferrsi.knowledge", "arguments_extra.py imports inferrsi.knowledge", "benchmark/forbidden.py imports inferrsi.harness", + "benchmark_operations.py imports inferrsi.benchmark", "cli.py imports inferrsi.apps", "harness/probe.py imports inferrsi.knowledge", "knowledge/out.py imports inferrsi.harness", @@ -236,8 +238,8 @@ def test_module_entry_admits_only_the_canonical_cli_delegation(self) -> None: ) self.assertEqual(support.MODULE_ENTRY, "__main__.py") self.assertEqual(support.MODULE_ENTRY_DELEGATION, ("inferrsi.apps.cli", "main")) - # It passes by its own exact rule and is never listed as an application entry. - self.assertNotIn(support.MODULE_ENTRY, support.APPLICATION_ENTRIES) + # It passes by its own exact rule; since A2 no root file is an application entry. + self.assertFalse(hasattr(support, "APPLICATION_ENTRIES")) self.assertEqual(_scan_tree({"__main__.py": entry}), []) self.assertEqual(_scan_tree({"__main__.py": "from inferrsi.apps.cli import main\n"}), []) # Positive control: without the rule the same file is refused, so the statement diff --git a/tests/test_trial_check_reports.py b/tests/test_trial_check_reports.py index 34d8b213..856e4c3d 100644 --- a/tests/test_trial_check_reports.py +++ b/tests/test_trial_check_reports.py @@ -6,8 +6,8 @@ from inferrsi.apps.legacy.evaluation import evaluate from inferrsi.apps.legacy.reporting import write_report +from inferrsi.apps.views.summary_chart import SpecError, spec_from_evaluation from inferrsi.contracts import RunSpec -from inferrsi.summary_chart import SpecError, spec_from_evaluation def evaluated_pair(checks, side="candidate"): diff --git a/tools/campaign_summary_chart.py b/tools/campaign_summary_chart.py index 9168b0c8..09e0a137 100644 --- a/tools/campaign_summary_chart.py +++ b/tools/campaign_summary_chart.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Render a campaign gain summary figure from a JSON specification. -The renderer lives in the package (``inferrsi.summary_chart``) so the report +The renderer lives in the package (``inferrsi.apps.views.summary_chart``) so the report generator can draw the same figure when an experiment ends. This wrapper is the command-line entry point: @@ -19,7 +19,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src")) -from inferrsi.summary_chart import main # noqa: E402 +from inferrsi.apps.views.summary_chart import main # noqa: E402 if __name__ == "__main__": raise SystemExit(main())