From afb7fd9530a6decbaedfdbf468f6b8b516f6d6b4 Mon Sep 17 00:00:00 2001 From: Zeng Chuang Date: Wed, 25 Nov 2026 13:12:51 +0800 Subject: [PATCH 1/2] Retire superseded Apps paths and verify the installed layout Record the 25 module migrations for 0.3.4. Keep historical records readable, move the Apps guide, and verify the installed wheel and repository layout. Preserve the protocol identity regression from main. Agent-assisted-by: Codex / GPT-6 [effort=unknown] (author) Agent-assisted-by: Codex (implementation and verification) Signed-off-by: zengchuang --- CHANGELOG.md | 5 + docs/README.md | 2 +- docs/apps-module-migrations.json | 117 +++++++++---- docs/architecture.md | 4 +- docs/benchmarks/engineering-benchmarks.md | 2 +- docs/guides/apps-output.md | 9 +- docs/guides/apps.md | 38 ++++ docs/module-layout.md | 80 ++++----- docs/operations.md | 2 +- src/inferrsi/apps/README.md | 38 ---- src/inferrsi/apps/archive.py | 29 ---- src/inferrsi/apps/artifact_reader.py | 11 -- src/inferrsi/apps/artifacts.py | 21 --- src/inferrsi/apps/benchmark_compare.py | 27 --- src/inferrsi/apps/benchmark_operations.py | 5 - src/inferrsi/apps/bridge.py | 17 -- src/inferrsi/apps/campaign.py | 5 - src/inferrsi/apps/candidate_provider.py | 9 - src/inferrsi/apps/cannbot/__init__.py | 6 - src/inferrsi/apps/cannbot/project.py | 27 --- src/inferrsi/apps/cannbot/read_worker.py | 5 - src/inferrsi/apps/context_provider.py | 11 -- src/inferrsi/apps/evidence_layout.py | 9 - src/inferrsi/apps/improvement.py | 5 - src/inferrsi/apps/inspection.py | 9 - src/inferrsi/apps/knowledge.py | 5 - src/inferrsi/apps/legacy/records.py | 58 +++++++ src/inferrsi/apps/mindie/__init__.py | 3 - src/inferrsi/apps/mindie/context.py | 5 - src/inferrsi/apps/mindie/mcp.py | 5 - src/inferrsi/apps/mindie/project.py | 13 -- src/inferrsi/apps/mindie/read_worker.py | 5 - src/inferrsi/apps/parallel_round.py | 5 - src/inferrsi/apps/result.py | 21 --- src/inferrsi/apps/skill_eval_engineering.py | 9 - src/inferrsi/apps/skill_evaluation.py | 5 - src/inferrsi/benchmark/README.md | 2 +- tests/apps/test_apps_module_migrations.py | 164 ++++++------------ tests/check_installed.py | 68 +++----- .../repository/test_package_root_inventory.py | 5 +- .../test_target_module_import_gate.py | 8 +- .../skill_eval/test_skill_eval_engineering.py | 6 +- 42 files changed, 300 insertions(+), 580 deletions(-) create mode 100644 docs/guides/apps.md delete mode 100644 src/inferrsi/apps/README.md delete mode 100644 src/inferrsi/apps/archive.py delete mode 100644 src/inferrsi/apps/artifact_reader.py delete mode 100644 src/inferrsi/apps/artifacts.py delete mode 100644 src/inferrsi/apps/benchmark_compare.py delete mode 100644 src/inferrsi/apps/benchmark_operations.py delete mode 100644 src/inferrsi/apps/bridge.py delete mode 100644 src/inferrsi/apps/campaign.py delete mode 100644 src/inferrsi/apps/candidate_provider.py delete mode 100644 src/inferrsi/apps/cannbot/__init__.py delete mode 100644 src/inferrsi/apps/cannbot/project.py delete mode 100644 src/inferrsi/apps/cannbot/read_worker.py delete mode 100644 src/inferrsi/apps/context_provider.py delete mode 100644 src/inferrsi/apps/evidence_layout.py delete mode 100644 src/inferrsi/apps/improvement.py delete mode 100644 src/inferrsi/apps/inspection.py delete mode 100644 src/inferrsi/apps/knowledge.py create mode 100644 src/inferrsi/apps/legacy/records.py delete mode 100644 src/inferrsi/apps/mindie/__init__.py delete mode 100644 src/inferrsi/apps/mindie/context.py delete mode 100644 src/inferrsi/apps/mindie/mcp.py delete mode 100644 src/inferrsi/apps/mindie/project.py delete mode 100644 src/inferrsi/apps/mindie/read_worker.py delete mode 100644 src/inferrsi/apps/parallel_round.py delete mode 100644 src/inferrsi/apps/result.py delete mode 100644 src/inferrsi/apps/skill_eval_engineering.py delete mode 100644 src/inferrsi/apps/skill_evaluation.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 319b8d1a4..36fe1382b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,11 @@ ### Changed +- Apps module retirement (0.3.4). Use the [documented replacements](docs/apps-module-migrations.json). + The public evaluation API remains at `inferrsi.apps.api`. See the + [migration instructions](docs/module-layout.md#apps-modules-and-retired-imports) for + script entries, retained pickles and frozen runs. + - `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/README.md b/docs/README.md index a96ca876a..b3153fb40 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,5 +6,5 @@ Open the entry for the task at hand and follow its links when you need a procedu - **Run an optimization.** The [operation guide](operations.md) maps commands to Python entry points. Use the [task input guide](guides/task-input.md) to define a workload, the [workflow](guides/optimization-workflow-unification.md) to run it and the [dashboard](dashboard.md) to inspect results. [Task guides](guides/) - **Choose a benchmark or check a claim.** Start with [engineering benchmarks](benchmarks/engineering-benchmarks.md) or [recorded results](benchmarks/optimization-results.md). For skill changes, use [skill evaluation](skill-evaluation/) or the [PR evidence handoff](skill-eval-pr.md). - **Find or contribute knowledge.** Start with [Find and Collect](knowledge-operations.md) or the [contribution guide](guides/knowledge/knowledge-contribution-workflow.md). The [Knowledge module](../src/inferrsi/knowledge/README.md) links to the library and its contracts. -- **Change the repository.** Read the [contributor guide](contributing.md) and [collaboration rules](agent-collaboration.md). [Architecture](architecture.md) records shared boundaries. [Module layout](module-layout.md#module-documentation) links to the four module READMEs. [Versioned contracts](contracts/) and the [engine template](template/) support implementation. +- **Change the repository.** Read the [contributor guide](contributing.md) and [collaboration rules](agent-collaboration.md). [Architecture](architecture.md) records shared boundaries. [Module layout](module-layout.md#module-documentation) links to the four module guides. [Versioned contracts](contracts/) and the [engine template](template/) support implementation. - **Trace a result.** [Field notes](field-notes/) describe specific workloads. [Source audits](reviews/) and [campaign evidence](../evidence/) retain their scope and provenance. Check the [privacy and security guide](privacy-security.md) before sharing artifacts. diff --git a/docs/apps-module-migrations.json b/docs/apps-module-migrations.json index 0b419c817..6a815b20b 100644 --- a/docs/apps-module-migrations.json +++ b/docs/apps-module-migrations.json @@ -21,7 +21,6 @@ "docs/module-layout.md", "docs/operations.md", "src/inferrsi/apps/api.py", - "src/inferrsi/apps/archive.py", "src/inferrsi/apps/cli/evaluate.py", "src/inferrsi/apps/delivery/__init__.py", "src/inferrsi/apps/handoff/bridge.py", @@ -47,8 +46,11 @@ "tests/benchmark/test_benchmark_preparation.py", "tests/harness/test_harness_entry_verification.py", "tests/harness/test_harness_generation_lineage.py", - "tests/apps/test_result_delivery.py" - ] + "tests/apps/test_result_delivery.py", + "src/inferrsi/apps/legacy/records.py" + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.artifact_reader", @@ -63,7 +65,6 @@ "docs/module-layout.md", "docs/operations.md", "src/inferrsi/apps/api.py", - "src/inferrsi/apps/artifact_reader.py", "src/inferrsi/apps/cli/evaluate.py", "src/inferrsi/apps/handoff/candidate_provider.py", "src/inferrsi/apps/handoff/production_capture.py", @@ -79,7 +80,9 @@ "tests/benchmark/test_benchmark_cpu_smoke.py", "tests/harness/test_harness_entry_verification.py", "tests/harness/test_harness_generation_lineage.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.result", @@ -102,7 +105,6 @@ "src/inferrsi/apps/handoff/bridge.py", "src/inferrsi/apps/handoff/candidate_provider.py", "src/inferrsi/apps/handoff/evidence_capture.py", - "src/inferrsi/apps/result.py", "src/inferrsi/apps/storage/archive.py", "src/inferrsi/apps/storage/artifact_reader.py", "src/inferrsi/apps/views/attempt.py", @@ -110,7 +112,9 @@ "tests/check_installed.py", "tests/apps/test_apps_module_migrations.py", "tests/apps/test_result_delivery.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.evidence_layout", @@ -124,7 +128,6 @@ "docs/contracts/current-design.md", "docs/module-layout.md", "docs/operations.md", - "src/inferrsi/apps/evidence_layout.py", "src/inferrsi/contracts/evidence.py", "tests/_gate_policy_support.py", "tests/check_installed.py", @@ -132,7 +135,9 @@ "tests/contracts/test_evidence_paths.py", "tests/repository/test_first_wave_isolation_policy.py", "tests/knowledge/test_repository_packs_facade.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.bridge", @@ -149,7 +154,6 @@ "docs/architecture.md", "docs/module-layout.md", "docs/operations.md", - "src/inferrsi/apps/bridge.py", "src/inferrsi/apps/handoff/candidate_provider.py", "src/inferrsi/apps/views/attempt.py", "src/inferrsi/apps/workflows/evaluation.py", @@ -163,7 +167,9 @@ "tests/benchmark/test_benchmark_preparation.py", "tests/harness/test_harness_entry_verification.py", "tests/harness/test_harness_prepared_binding.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.context_provider", @@ -177,12 +183,14 @@ "docs/architecture.md", "docs/module-layout.md", "docs/operations.md", - "src/inferrsi/apps/context_provider.py", "tests/check_installed.py", "tests/apps/test_apps_context_provider.py", "tests/apps/test_apps_module_migrations.py", - "tests/harness/test_harness_generation_seal.py" - ] + "tests/harness/test_harness_generation_seal.py", + "src/inferrsi/apps/legacy/records.py" + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.candidate_provider", @@ -196,10 +204,11 @@ "docs/module-layout.md", "docs/operations.md", "src/inferrsi/apps/api.py", - "src/inferrsi/apps/candidate_provider.py", "tests/check_installed.py", "tests/apps/test_apps_module_migrations.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.campaign", @@ -233,7 +242,9 @@ "tests/apps/test_search_archive.py", "tests/apps/test_search_attribution.py", "tests/apps/test_search_capture_delivery.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.benchmark_operations", @@ -253,7 +264,9 @@ "tests/repository/test_package_root_inventory.py", "tests/apps/test_project_optimization.py", "tests/repository/test_target_module_import_gate.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.improvement", @@ -273,7 +286,9 @@ "tests/apps/test_apps_module_migrations.py", "tests/harness/test_harness_improvement.py", "tools/skill_eval_improve.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.skill_evaluation", @@ -296,7 +311,9 @@ "tests/skill_eval/test_skill_evaluation.py", "tools/skill_eval_compare.py", "tools/skill_eval_pilot.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.skill_eval_engineering", @@ -321,7 +338,9 @@ "tools/skill_eval_local.py", "tools/skill_eval_qualify.py" ], - "script_entry": "main" + "script_entry": "main", + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.benchmark_compare", @@ -345,7 +364,9 @@ "tests/check_installed.py", "tests/apps/test_apps_module_migrations.py", "tests/benchmark/test_benchmark_compare.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.cannbot", @@ -368,7 +389,9 @@ "old": "inferrsi.apps.cannbot.project", "canonical": "inferrsi.apps.integrations.cannbot.project" } - } + }, + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.cannbot.project", @@ -396,7 +419,9 @@ "tests/apps/test_mindie_runtime.py", "tests/apps/test_optimization_session.py", "tests/apps/test_project_optimization.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.cannbot.read_worker", @@ -415,7 +440,9 @@ "tests/apps/test_apps_module_migrations.py", "tests/apps/test_cannbot_boundaries.py", "tests/apps/test_project_optimization.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.mindie", @@ -428,7 +455,9 @@ "tests/check_installed.py", "tests/apps/test_apps_module_migrations.py" ], - "package": true + "package": true, + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.mindie.context", @@ -447,7 +476,9 @@ "tests/apps/test_apps_module_migrations.py", "tests/apps/test_mindie_context.py", "tests/apps/test_mindie_runtime.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.mindie.project", @@ -470,7 +501,9 @@ "tests/apps/test_apps_module_migrations.py", "tests/apps/test_mindie_project.py", "tests/apps/test_mindie_runtime.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.mindie.mcp", @@ -484,7 +517,9 @@ "tests/check_installed.py", "tests/apps/test_apps_module_migrations.py", "tests/apps/test_mindie_project.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.mindie.read_worker", @@ -496,7 +531,9 @@ "docs/module-layout.md", "tests/check_installed.py", "tests/apps/test_apps_module_migrations.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.knowledge", @@ -509,11 +546,12 @@ "consumers": [ "docs/operations.md", "src/inferrsi/apps/cli/__init__.py", - "src/inferrsi/apps/knowledge.py", "tests/apps/test_apps_context_provider.py", "tests/apps/test_apps_knowledge.py", "tests/harness/test_harness_generation_seal.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.parallel_round", @@ -524,10 +562,11 @@ "close_round" ], "consumers": [ - "src/inferrsi/apps/parallel_round.py", "tests/harness/test_parallel_round.py", "tools/parallel_round.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.artifacts", @@ -543,7 +582,6 @@ ], "consumers": [ "docs/skill-evaluation/local-skill-evaluation.md", - "src/inferrsi/apps/artifacts.py", "src/inferrsi/apps/delivery/__init__.py", "src/inferrsi/apps/delivery/projection.py", "src/inferrsi/apps/delivery/snapshot.py", @@ -591,7 +629,9 @@ "tools/skill_eval_local.py", "tools/skill_eval_pilot.py", "tools/skill_eval_pr.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" }, { "old": "inferrsi.apps.inspection", @@ -603,11 +643,12 @@ "docs/contracts/current-design.md", "docs/module-layout.md", "src/inferrsi/apps/cli/__init__.py", - "src/inferrsi/apps/inspection.py", "tests/apps/test_inspection.py", "tests/check_installed.py", "tests/repository/test_architecture_closed_loop.py", "tests/repository/test_first_wave_isolation_policy.py" - ] + ], + "status": "retired", + "first_removal_version": "0.3.4" } ] diff --git a/docs/architecture.md b/docs/architecture.md index d28afa54d..a86700694 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -209,7 +209,7 @@ of these shared packages imports a campaign from `examples/`. Environment inspection follows that direction. `apps/host/inspection.py` is the facts API: it takes the command probe and the repository snapshot as ports. -`apps/inspection.py` binds those ports to this host with +`apps/host/prepared_environment.py` binds those ports to this host with `apps.host.commands.probe_command` and `apps.host.targets.repository_identity`, and the CLI calls that composition. The `apps/host/` package moved from Infra in #498 slice 3a and keeps its limit: it reaches no Knowledge, Harness or Benchmark @@ -267,7 +267,7 @@ The four core READMEs cover current entry points and extension rules. - [Knowledge](../src/inferrsi/knowledge/README.md) owns retrieval and the packaged knowledge corpus. - [Harness](../src/inferrsi/harness/README.md) owns execution, run records and recovery. - [Benchmark](../src/inferrsi/benchmark/README.md) owns task definitions and independent assessment. -- [Apps](../src/inferrsi/apps/README.md) owns the CLI and Python composition, host adapters and result delivery. +- [Apps](guides/apps.md) owns the CLI and Python composition, host adapters and result delivery. The [contracts](contracts/) define versioned interfaces. The neutral [resources package](../src/inferrsi/resources/) reads repository-pack diff --git a/docs/benchmarks/engineering-benchmarks.md b/docs/benchmarks/engineering-benchmarks.md index 5419043c0..24b3e6e14 100644 --- a/docs/benchmarks/engineering-benchmarks.md +++ b/docs/benchmarks/engineering-benchmarks.md @@ -62,7 +62,7 @@ and TTS entries also run directly by file path. ## Directory ownership [Benchmark](../../src/inferrsi/benchmark/README.md) owns task registration, -workloads and quality checks. [Apps](../../src/inferrsi/apps/README.md) resolves +workloads and quality checks. [Apps](../guides/apps.md) resolves and launches the selected entry with its original arguments and exit status. [Harness](../../src/inferrsi/harness/README.md) freezes iterative task protocol inputs and supplies the executor to entries that use it. diff --git a/docs/guides/apps-output.md b/docs/guides/apps-output.md index f146739c6..9c7eafa4e 100644 --- a/docs/guides/apps-output.md +++ b/docs/guides/apps-output.md @@ -114,8 +114,8 @@ functions are under `inferrsi.apps.storage.archive`. Storage construction and validation live in `inferrsi.apps.storage.result`. The former `inferrsi.apps.archive`, `artifact_reader`, `result` and -`evidence_layout` modules retain explicit public exports during the #490 -migration. New consumers and private-helper test patches use `apps.storage`. +`evidence_layout` module paths were retired in 0.3.4. Import their implementations from +`inferrsi.apps.storage` and point private-helper patches at the defining module. The [migration inventory](../apps-module-migrations.json) lists the exact exports. Persisted namespace values, artifact references and schema versions retain their existing spelling. @@ -139,8 +139,9 @@ The bound spec is handed to the host-supplied Harness execution port. projection. `handoff.context_provider` delivers Knowledge bytes for Harness to seal, and `handoff.candidate_provider` owns generation planning and candidate collection. `inferrsi.apps.api.CandidateProvider` exports the same canonical -class. The three former Apps modules retain their registered public exports; -the original attempt, public port signatures and fixed references are unchanged. +class. Use the registered handoff paths to bind the original attempt and read +its fixed references. Historical context pickles have an explicit +[migration reader](../module-layout.md#apps-modules-and-retired-imports). ## Fixed artifact reader diff --git a/docs/guides/apps.md b/docs/guides/apps.md new file mode 100644 index 000000000..96e029619 --- /dev/null +++ b/docs/guides/apps.md @@ -0,0 +1,38 @@ +# Apps + +Apps connects the CLI and host integrations to Benchmark preparation and +assessment, Harness execution, and Knowledge access. It binds the configured +ports, verifies requests and references, and publishes results. Benchmark +owns grading rules and Harness owns execution and retained run facts. + +## Entry points + +- [`cli/`](../../src/inferrsi/apps/cli/) dispatches the `inferrsi` CLI. +- [`api.py`](../../src/inferrsi/apps/api.py) exposes `prepare`, `execute`, `assess`, and + `EvaluationPort` for Python callers. The saved-request CLI uses this API. The implementation in + [`workflows/evaluation.py`](../../src/inferrsi/apps/workflows/evaluation.py) binds the injected core + ports and publishes their results. +- [`workflows/`](../../src/inferrsi/apps/workflows/) composes application workflows. [`handoff/`](../../src/inferrsi/apps/handoff/) + contains host-facing adapters, and [`storage/`](../../src/inferrsi/apps/storage/) handles application + publication and reads. +- [`workflows/speculative_search.py`](../../src/inferrsi/apps/workflows/speculative_search.py) connects + the Engine search CLI to Harness. [`search_benchmarks.py`](../../src/inferrsi/apps/workflows/search_benchmarks.py) + supplies Engine and Skill evaluators, and [`search_roles.py`](../../src/inferrsi/apps/workflows/search_roles.py) + implements the trainable CPU roles. + +## Benchmark launcher + +[`workflows/benchmark_operations.py`](../../src/inferrsi/apps/workflows/benchmark_operations.py) +resolves a registered task's `benchmark.py`, launches it through the Harness +child adapter, forwards arguments unchanged, and returns the child's status. +The child executes the task with `runpy` and supplies Harness's `execute_trial` +callback as an initial global. The task supplies workload setup, measurement, +and correctness rules. See the [Benchmark README](../../src/inferrsi/benchmark/README.md) +for registration. + +See the [saved-request CLI](apps-evaluate-cli.md), the +[publication contract](apps-output.md), and the +[module migration inventory](../apps-module-migrations.json). +The [evaluation](../../tests/apps/test_apps_evaluate_cli.py) and +[launcher](../../tests/benchmark/test_benchmark_operations.py) tests exercise these +entry points. diff --git a/docs/module-layout.md b/docs/module-layout.md index 7f1e7594c..179f5fd7e 100644 --- a/docs/module-layout.md +++ b/docs/module-layout.md @@ -6,7 +6,7 @@ through CLI and Python entry points. [Architecture](architecture.md) describes the dependencies. This page defines placement, import rules and compatibility. The [retired path inventory](#retired-root-modules) records the old package root and the [Apps migration inventory](apps-module-migrations.json) records -compatibility paths that still exist. +retired Apps paths and their replacements. @@ -17,7 +17,7 @@ from a short README next to the code. Describe what it owns, where callers enter, the invariants an extension must preserve and where to find the tests. Small internal packages can share their parent README. -- [Apps](../src/inferrsi/apps/README.md) covers assembly, host adapters and result delivery. +- [Apps](guides/apps.md) covers assembly, host adapters and result delivery. - [Benchmark](../src/inferrsi/benchmark/README.md) covers task discovery and independent assessment. - [Harness](../src/inferrsi/harness/README.md) covers execution, retention and recovery. - [Knowledge](../src/inferrsi/knowledge/README.md) covers package data, lookup and reads. @@ -33,55 +33,37 @@ or contract from the module README. When ownership changes, follow the ## Target modules -### Apps storage migration - -[Apps storage](../src/inferrsi/apps/README.md) owns the canonical storage -definitions. The four former paths in the -[migration inventory](apps-module-migrations.json) export the same public -objects. Old pickles resolve through the exports. New pickles and patches to -private helpers use the canonical modules. Storage has no dependency on handoff. -The retired root `inferrsi.evidence_paths` stays unavailable. Shim removal requires -a separate review with consumer migration, wheel and plugin validation, and a -first removal version. - -### Apps handoff migration - -The three former paths in the [migration inventory](apps-module-migrations.json) -export the canonical objects. `apps.api.CandidateProvider` is the class defined -in `apps/handoff/candidate_provider.py`. `EvaluationPort` is defined in `apps/api.py`. -The handoff initializer and compatibility imports perform no Knowledge reads, -device probes, process launches or service registration. `EvidenceCapture` is -defined in `apps/handoff/evidence_capture.py` and exposed through `apps.api`. - -### Apps workflows migration - -The former Apps paths in the [migration inventory](apps-module-migrations.json) -export the canonical workflow objects. The engineering verifier retains its -file and python -m entry points through a static import and a main guard. -New pickles and patches to private helpers use the canonical paths. Workflow -imports perform no data reads, probes, process launches or service registration. - -New optimization plans and evaluation controller snapshots fingerprint the -canonical source files. To inspect or resume a frozen pre-move run, including -`status` and `recover`, use its original runtime under the +### Apps modules and retired imports + +The [Apps overview](guides/apps.md) describes the CLI and public Python entry points. +The package root contains `__init__.py` and `api.py`. Workflows compose core ports; +handoff binds and projects records; storage owns fixed reads, writes and result envelopes. +Host inspection binds platform probes, integrations own external adapters, and delivery, +views and legacy own report delivery, read-only presentation and previous run formats. + +The [migration inventory](apps-module-migrations.json) gives each retired import, its +replacement, exported names and first removal version. From 0.3.4 use those +canonical imports. For the engineering verifier use +`python -m inferrsi.apps.workflows.skill_eval_engineering`, or invoke that installed +module's file. Cannbot and MindIE launch their canonical sibling workers with +the approved interpreter and the existing `-I -B` flags. To serve MindIE read +tools over stdio MCP, run `inferrsi mindie serve`. + +New plans and evaluation controllers fingerprint the canonical source files. +For a trusted local pickle of a historical `RunOutput` or `DeliveredContextDraft`, +open the input in binary mode and call `inferrsi.apps.legacy.records.load_record(stream)` +on the original platform. To migrate it, dump the returned value to a **new** file; +its classes then name their canonical modules and ordinary `pickle.load` reads it. +Keep original files and digests. For other old Python pickles, controller snapshots, +or frozen optimization runs, use the original wheel and its pinned worker to inspect +or resume them, including `status` and `recover`. Follow the [release-boundary recovery rules](guides/optimization-workflow-unification.md#release-boundary-recovery). -### Apps integrations migration - -The [migration inventory](apps-module-migrations.json) describes package shims -and their exports. The old Cannbot package exposes its own project shim, whose -public objects resolve to the canonical definitions. Imports in either order -preserve these module identities. Private helper patches target the canonical -modules. Importing the adapters performs no grant reads or worker launches. - -Launchers select the canonical sibling worker with the approved interpreter and -the existing `-I -B` flags. Each worker uses standard-library-only imports and -loads without InferRSI installed. The legacy worker shims remain importable. -Run the canonical worker file directly. To serve the project's approved MindIE -read tools over stdio MCP, run `inferrsi mindie serve`. - -Keep Anthropic's `request_guard.py` beside `anthropic_agent.py`. The agent -loads the guard by file path, and the edit adapter copies it into the run. +`apps.api.CandidateProvider` and `EvidenceCapture` refer to the canonical handoff +classes. `EvaluationPort` remains defined in `apps.api`. Storage has no dependency +on handoff. Adapters import without probing devices or launching services. The +Anthropic request guard stays beside its agent because the edit adapter copies it +into runs by file path. ### Core and technical packages diff --git a/docs/operations.md b/docs/operations.md index 254690d61..4070be10f 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -402,7 +402,7 @@ The public preparation, execution and assessment API remains creation helper is `inferrsi.apps.storage.evidence_layout.ensure_evidence_layout`. The CLI entry remains `inferrsi.apps.cli:main`. See the [output contract](guides/apps-output.md) and [migration inventory](apps-module-migrations.json) -for the retained old Apps imports and canonical storage paths. +for the retired Apps imports and their canonical storage paths. `inferrsi.apps.handoff.bridge`, `handoff.context_provider` and `handoff.candidate_provider` implement execution/evidence binding, context delivery and generation handoff. The API still exports the one canonical diff --git a/src/inferrsi/apps/README.md b/src/inferrsi/apps/README.md deleted file mode 100644 index 8b58b88e1..000000000 --- a/src/inferrsi/apps/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Apps - -Apps connects the CLI and host integrations to Benchmark preparation and -assessment, Harness execution, and Knowledge access. It binds the configured -ports, verifies requests and references, and publishes results. Benchmark -owns grading rules and Harness owns execution and retained run facts. - -## Entry points - -- [`cli/`](cli/) dispatches the `inferrsi` CLI. -- [`api.py`](api.py) exposes `prepare`, `execute`, `assess`, and - `EvaluationPort` for Python callers. The saved-request CLI uses this API. The implementation in - [`workflows/evaluation.py`](workflows/evaluation.py) binds the injected core - ports and publishes their results. -- [`workflows/`](workflows/) composes application workflows. [`handoff/`](handoff/) - contains host-facing adapters, and [`storage/`](storage/) handles application - publication and reads. -- [`workflows/speculative_search.py`](workflows/speculative_search.py) connects - the Engine search CLI to Harness. [`search_benchmarks.py`](workflows/search_benchmarks.py) - supplies Engine and Skill evaluators, and [`search_roles.py`](workflows/search_roles.py) - implements the trainable CPU roles. - -## Benchmark launcher - -[`workflows/benchmark_operations.py`](workflows/benchmark_operations.py) -resolves a registered task's `benchmark.py`, launches it through the Harness -child adapter, forwards arguments unchanged, and returns the child's status. -The child executes the task with `runpy` and supplies Harness's `execute_trial` -callback as an initial global. The task supplies workload setup, measurement, -and correctness rules. See the [Benchmark README](../benchmark/README.md) -for registration. - -See the [saved-request CLI](../../../docs/guides/apps-evaluate-cli.md), the -[publication contract](../../../docs/guides/apps-output.md), and the -[module migration inventory](../../../docs/apps-module-migrations.json). -The [evaluation](../../../tests/apps/test_apps_evaluate_cli.py) and -[launcher](../../../tests/benchmark/test_benchmark_operations.py) tests exercise these -entry points. diff --git a/src/inferrsi/apps/archive.py b/src/inferrsi/apps/archive.py deleted file mode 100644 index 8d8f14038..000000000 --- a/src/inferrsi/apps/archive.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.storage.archive`.""" - -from .storage.archive import ( - ResourceReader, - RunOutput, - archive_assessment, - archive_mount, - archive_prepared, - publish_result, - read_archive_artifact, - read_assessment, - read_prepared, - read_result, - validate_output_id, -) - -__all__ = [ - "ResourceReader", - "RunOutput", - "archive_mount", - "archive_prepared", - "read_archive_artifact", - "read_prepared", - "archive_assessment", - "read_assessment", - "validate_output_id", - "read_result", - "publish_result", -] diff --git a/src/inferrsi/apps/artifact_reader.py b/src/inferrsi/apps/artifact_reader.py deleted file mode 100644 index 15e33a8fe..000000000 --- a/src/inferrsi/apps/artifact_reader.py +++ /dev/null @@ -1,11 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.storage.artifact_reader`.""" - -from .storage.artifact_reader import ( - ArtifactReader, - AssessmentArtifacts, -) - -__all__ = [ - "ArtifactReader", - "AssessmentArtifacts", -] diff --git a/src/inferrsi/apps/artifacts.py b/src/inferrsi/apps/artifacts.py deleted file mode 100644 index 469880418..000000000 --- a/src/inferrsi/apps/artifacts.py +++ /dev/null @@ -1,21 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.storage.artifacts`.""" - -from .storage.artifacts import ( - REPLACE_ATTEMPTS, - REPLACE_DELAY_SECONDS, - atomic_write_json, - digest, - file_lock, - sha256, - write_json, -) - -__all__ = [ - "REPLACE_ATTEMPTS", - "REPLACE_DELAY_SECONDS", - "atomic_write_json", - "digest", - "file_lock", - "sha256", - "write_json", -] diff --git a/src/inferrsi/apps/benchmark_compare.py b/src/inferrsi/apps/benchmark_compare.py deleted file mode 100644 index c10791522..000000000 --- a/src/inferrsi/apps/benchmark_compare.py +++ /dev/null @@ -1,27 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.workflows.benchmark_compare`.""" - -from .workflows.benchmark_compare import ( - CONFIG_NAME, - DEFAULT_CONFIG, - OBSERVED_FIELDS, - collect, - compare_command, - dispatch, - prepare, - report, - resolve_config, - status, -) - -__all__ = [ - "DEFAULT_CONFIG", - "CONFIG_NAME", - "OBSERVED_FIELDS", - "resolve_config", - "prepare", - "status", - "dispatch", - "collect", - "report", - "compare_command", -] diff --git a/src/inferrsi/apps/benchmark_operations.py b/src/inferrsi/apps/benchmark_operations.py deleted file mode 100644 index c425b6182..000000000 --- a/src/inferrsi/apps/benchmark_operations.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Compatibility exports; use :mod:`inferrsi.apps.workflows.benchmark_operations`.""" - -from .workflows.benchmark_operations import run_task - -__all__ = ['run_task'] diff --git a/src/inferrsi/apps/bridge.py b/src/inferrsi/apps/bridge.py deleted file mode 100644 index 14e7372df..000000000 --- a/src/inferrsi/apps/bridge.py +++ /dev/null @@ -1,17 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.handoff.bridge`.""" - -from .handoff.bridge import ( - bind_execution, - check_assessment_identity, - execution_fields, - to_evidence, - verify_protocol, -) - -__all__ = [ - "execution_fields", - "verify_protocol", - "check_assessment_identity", - "bind_execution", - "to_evidence", -] diff --git a/src/inferrsi/apps/campaign.py b/src/inferrsi/apps/campaign.py deleted file mode 100644 index 4ac664831..000000000 --- a/src/inferrsi/apps/campaign.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Compatibility exports; use :mod:`inferrsi.apps.workflows.campaign`.""" - -from .workflows.campaign import capture_context, create_campaign, save_retrieval, verify_capture - -__all__ = ['create_campaign', 'capture_context', 'save_retrieval', 'verify_capture'] diff --git a/src/inferrsi/apps/candidate_provider.py b/src/inferrsi/apps/candidate_provider.py deleted file mode 100644 index 10203121e..000000000 --- a/src/inferrsi/apps/candidate_provider.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.handoff.candidate_provider`.""" - -from .handoff.candidate_provider import ( - CandidateProvider, -) - -__all__ = [ - "CandidateProvider", -] diff --git a/src/inferrsi/apps/cannbot/__init__.py b/src/inferrsi/apps/cannbot/__init__.py deleted file mode 100644 index 720b3084f..000000000 --- a/src/inferrsi/apps/cannbot/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.integrations.cannbot`.""" - -from ..integrations.cannbot import CannbotChannel -from . import project - -__all__ = ["CannbotChannel", "project"] diff --git a/src/inferrsi/apps/cannbot/project.py b/src/inferrsi/apps/cannbot/project.py deleted file mode 100644 index 5afec478f..000000000 --- a/src/inferrsi/apps/cannbot/project.py +++ /dev/null @@ -1,27 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.integrations.cannbot.project`.""" - -from ..integrations.cannbot.project import ( - MAX_BYTES, - PLATFORMS, - ChannelFailure, - describe, - disable, - enable, - load_grant, - project_root, - read, - search, -) - -__all__ = [ - "MAX_BYTES", - "PLATFORMS", - "ChannelFailure", - "project_root", - "load_grant", - "describe", - "search", - "read", - "enable", - "disable", -] diff --git a/src/inferrsi/apps/cannbot/read_worker.py b/src/inferrsi/apps/cannbot/read_worker.py deleted file mode 100644 index a2a8bfa0d..000000000 --- a/src/inferrsi/apps/cannbot/read_worker.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.integrations.cannbot.read_worker`.""" - -from ..integrations.cannbot.read_worker import OutputLimitError, capture, discover, read, search - -__all__ = ["OutputLimitError", "capture", "discover", "search", "read"] diff --git a/src/inferrsi/apps/context_provider.py b/src/inferrsi/apps/context_provider.py deleted file mode 100644 index d906a8af8..000000000 --- a/src/inferrsi/apps/context_provider.py +++ /dev/null @@ -1,11 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.handoff.context_provider`.""" - -from .handoff.context_provider import ( - ContextProvider, - DeliveredContextDraft, -) - -__all__ = [ - "DeliveredContextDraft", - "ContextProvider", -] diff --git a/src/inferrsi/apps/evidence_layout.py b/src/inferrsi/apps/evidence_layout.py deleted file mode 100644 index 6b87961f3..000000000 --- a/src/inferrsi/apps/evidence_layout.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.storage.evidence_layout`.""" - -from .storage.evidence_layout import ( - ensure_evidence_layout, -) - -__all__ = [ - "ensure_evidence_layout", -] diff --git a/src/inferrsi/apps/improvement.py b/src/inferrsi/apps/improvement.py deleted file mode 100644 index d3a4d6ef3..000000000 --- a/src/inferrsi/apps/improvement.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Compatibility exports; use :mod:`inferrsi.apps.workflows.improvement`.""" - -from .workflows.improvement import assessment, choose, holdout_accepts, rerun_assessment - -__all__ = ['assessment', 'choose', 'holdout_accepts', 'rerun_assessment'] diff --git a/src/inferrsi/apps/inspection.py b/src/inferrsi/apps/inspection.py deleted file mode 100644 index d64dac46b..000000000 --- a/src/inferrsi/apps/inspection.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.host.prepared_environment`.""" - -from .host.prepared_environment import ( - inspect_environment, -) - -__all__ = [ - "inspect_environment", -] diff --git a/src/inferrsi/apps/knowledge.py b/src/inferrsi/apps/knowledge.py deleted file mode 100644 index 4609af6b8..000000000 --- a/src/inferrsi/apps/knowledge.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Compatibility exports for inferrsi.apps.workflows.knowledge.""" - -from .workflows.knowledge import knowledge_reader, open_knowledge_store, read - -__all__ = ["knowledge_reader", "open_knowledge_store", "read"] diff --git a/src/inferrsi/apps/legacy/records.py b/src/inferrsi/apps/legacy/records.py new file mode 100644 index 000000000..186dbcc9e --- /dev/null +++ b/src/inferrsi/apps/legacy/records.py @@ -0,0 +1,58 @@ +"""Read the two retained Apps record types written under their former Python names.""" + +import pickle +from pathlib import PosixPath, WindowsPath +from typing import BinaryIO + +from ..handoff.context_provider import DeliveredContextDraft +from ..storage.archive import RunOutput + +_RECORDS = { + ("inferrsi.apps.archive", "RunOutput"): RunOutput, + ("inferrsi.apps.context_provider", "DeliveredContextDraft"): DeliveredContextDraft, + (RunOutput.__module__, RunOutput.__name__): RunOutput, + (DeliveredContextDraft.__module__, DeliveredContextDraft.__name__): DeliveredContextDraft, +} + + +def _new_record(cls, base, state): + if cls not in (RunOutput, DeliveredContextDraft) or base is not object or state is not None: + raise pickle.UnpicklingError("unexpected retained record constructor") + return object.__new__(cls) + + +def _legacy_bytes(text, encoding): + if type(text) is not str or encoding != "latin1": + raise pickle.UnpicklingError("unexpected retained bytes representation") + return text.encode("latin1") + + +# Protocols 0/1 use Python 2 names for record reconstruction and bytes. +_GLOBALS = { + **_RECORDS, + ("copy_reg", "_reconstructor"): _new_record, + ("copyreg", "_reconstructor"): _new_record, + ("__builtin__", "object"): object, + ("builtins", "object"): object, + ("_codecs", "encode"): _legacy_bytes, + ("pathlib", "PosixPath"): PosixPath, + ("pathlib", "WindowsPath"): WindowsPath, + ("pathlib._local", "PosixPath"): PosixPath, + ("pathlib._local", "WindowsPath"): WindowsPath, +} + + +class _RecordReader(pickle.Unpickler): + def find_class(self, module: str, name: str): + try: + return _GLOBALS[module, name] + except KeyError: + raise pickle.UnpicklingError("unsupported global in retained Apps record") from None + + +def load_record(stream: BinaryIO) -> RunOutput | DeliveredContextDraft: + """Read a trusted local record for offline migration on its original platform.""" + record = _RecordReader(stream).load() + if type(record) not in (RunOutput, DeliveredContextDraft): + raise pickle.UnpicklingError("expected a retained Apps record") + return record diff --git a/src/inferrsi/apps/mindie/__init__.py b/src/inferrsi/apps/mindie/__init__.py deleted file mode 100644 index b7a5d082b..000000000 --- a/src/inferrsi/apps/mindie/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -"""Compatibility package marker for legacy MindIE submodule imports.""" - -__all__ = [] diff --git a/src/inferrsi/apps/mindie/context.py b/src/inferrsi/apps/mindie/context.py deleted file mode 100644 index 10c8b7d1d..000000000 --- a/src/inferrsi/apps/mindie/context.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.integrations.mindie.context`.""" - -from ..integrations.mindie.context import MAX_BYTES, export_context - -__all__ = ["MAX_BYTES", "export_context"] diff --git a/src/inferrsi/apps/mindie/mcp.py b/src/inferrsi/apps/mindie/mcp.py deleted file mode 100644 index 9dbb389ba..000000000 --- a/src/inferrsi/apps/mindie/mcp.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.integrations.mindie.mcp`.""" - -from ..integrations.mindie.mcp import serve - -__all__ = ["serve"] diff --git a/src/inferrsi/apps/mindie/project.py b/src/inferrsi/apps/mindie/project.py deleted file mode 100644 index 71b3e6dd4..000000000 --- a/src/inferrsi/apps/mindie/project.py +++ /dev/null @@ -1,13 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.integrations.mindie.project`.""" - -from ..integrations.mindie.project import ( - ReadFailure, - call, - describe, - disable, - dispatch, - enable, - project_root, -) - -__all__ = ["ReadFailure", "project_root", "enable", "disable", "describe", "call", "dispatch"] diff --git a/src/inferrsi/apps/mindie/read_worker.py b/src/inferrsi/apps/mindie/read_worker.py deleted file mode 100644 index a121883ab..000000000 --- a/src/inferrsi/apps/mindie/read_worker.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.integrations.mindie.read_worker`.""" - -from ..integrations.mindie.read_worker import read - -__all__ = ["read"] diff --git a/src/inferrsi/apps/parallel_round.py b/src/inferrsi/apps/parallel_round.py deleted file mode 100644 index 115be188f..000000000 --- a/src/inferrsi/apps/parallel_round.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Compatibility exports for inferrsi.apps.workflows.parallel_round.""" - -from .workflows.parallel_round import close_round, make_assess, serve_ticket - -__all__ = ["make_assess", "serve_ticket", "close_round"] diff --git a/src/inferrsi/apps/result.py b/src/inferrsi/apps/result.py deleted file mode 100644 index 1a01315ba..000000000 --- a/src/inferrsi/apps/result.py +++ /dev/null @@ -1,21 +0,0 @@ -"""Compatibility exports for :mod:`inferrsi.apps.storage.result`.""" - -from .storage.result import ( - assessment_result, - execution_result, - is_public_error, - preparation_result, - publication_error, - validate_artifact_ref, - validate_result, -) - -__all__ = [ - "is_public_error", - "execution_result", - "preparation_result", - "assessment_result", - "publication_error", - "validate_artifact_ref", - "validate_result", -] diff --git a/src/inferrsi/apps/skill_eval_engineering.py b/src/inferrsi/apps/skill_eval_engineering.py deleted file mode 100644 index bbe7de38c..000000000 --- a/src/inferrsi/apps/skill_eval_engineering.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Compatibility exports; use :mod:`inferrsi.apps.workflows.skill_eval_engineering`.""" - -from inferrsi.apps.workflows.skill_eval_engineering import main, verify - -__all__ = ['verify', 'main'] - - -if __name__ == "__main__": - main() diff --git a/src/inferrsi/apps/skill_evaluation.py b/src/inferrsi/apps/skill_evaluation.py deleted file mode 100644 index 0fd84045b..000000000 --- a/src/inferrsi/apps/skill_evaluation.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Compatibility exports; use :mod:`inferrsi.apps.workflows.skill_evaluation`.""" - -from .workflows.skill_evaluation import export_bundle, run_trial, summarize - -__all__ = ['export_bundle', 'summarize', 'run_trial'] diff --git a/src/inferrsi/benchmark/README.md b/src/inferrsi/benchmark/README.md index bf1aee150..f84e6e1df 100644 --- a/src/inferrsi/benchmark/README.md +++ b/src/inferrsi/benchmark/README.md @@ -27,7 +27,7 @@ delivers Knowledge context where the workflow calls for it. `list --iterative` checks file presence without importing task code or probing devices. -The [Apps launcher](../apps/README.md#benchmark-launcher) forwards the task's +The [Apps launcher](../../../docs/guides/apps.md#benchmark-launcher) forwards the task's arguments and returns its exit status. Tasks own device setup, timing, and correctness. The MoE entry passes the injected `execute_trial` callback to its evaluation code, then supplies its metric reader and metric key to the diff --git a/tests/apps/test_apps_module_migrations.py b/tests/apps/test_apps_module_migrations.py index 9b2bd56ba..58ef31df5 100644 --- a/tests/apps/test_apps_module_migrations.py +++ b/tests/apps/test_apps_module_migrations.py @@ -1,17 +1,16 @@ -"""Compatibility and dependency checks for the implemented #490 slices.""" +"""Check retired Apps paths, their consumers and package dependencies.""" import ast -import inspect +import io import json import pickle from importlib import import_module -from importlib.util import resolve_name from pathlib import Path from types import ModuleType -from typing import get_origin import pytest +from inferrsi.apps.legacy.records import load_record from tests import _gate_policy_support as support from tests.contracts.test_contracts_package import IO_CONTROL, IO_PROBE, _fresh @@ -20,105 +19,37 @@ MIGRATIONS = json.loads((REPO / "docs/apps-module-migrations.json").read_text(encoding="utf-8")) -@pytest.mark.parametrize("entry", MIGRATIONS, ids=lambda entry: entry["old"]) -def test_shim_is_an_explicit_export_of_the_same_objects(entry): - relative = entry["old"].replace(".", "/") - path = REPO / "src" / (relative + ("/__init__.py" if entry.get("package") else ".py")) - tree = ast.parse(path.read_text(encoding="utf-8")) - statements = list(tree.body) - if entry.get("script_entry"): - guard = statements.pop() - assert ast.dump(guard) == ast.dump(ast.parse( - f'if __name__ == "__main__":\n {entry["script_entry"]}()\n' - ).body[0]) - docstring, *imports, declared = statements - assert isinstance(docstring, ast.Expr) and isinstance(docstring.value, ast.Constant) - package = entry["old"] if entry.get("package") else entry["old"].rpartition(".")[0] - imported_names = [] - for imported in imports: - assert isinstance(imported, ast.ImportFrom) - target = resolve_name("." * imported.level + (imported.module or ""), package) - for name in imported.names: - assert name.asname is None and name.name != "*" - module_export = entry.get("module_exports", {}).get(name.name) - if module_export: - assert target + "." + name.name == module_export["old"] - else: - assert target == entry["canonical"] - imported_names.append(name.name) - assert sorted(imported_names) == sorted(entry["exports"]) - if entry.get("script_entry"): - assert len(imports) == 1 and imports[0].level == 0 - assert isinstance(declared, ast.Assign) - assert [target.id for target in declared.targets] == ["__all__"] - assert ast.literal_eval(declared.value) == entry["exports"] - old, canonical = import_module(entry["old"]), import_module(entry["canonical"]) - assert old.__all__ == entry["exports"] - old_modules = {item["old"] for item in MIGRATIONS} - public = [name for name, value in vars(old).items() if not name.startswith("_") - and not (entry.get("package") and name not in old.__all__ - and isinstance(value, ModuleType) and value.__name__ in old_modules)] - assert sorted(public) == sorted(old.__all__) - for name in entry["exports"]: - value = getattr(canonical, name) - if name in entry.get("module_exports", {}): - binding = entry["module_exports"][name] - assert any(item["old"] == binding["old"] and item["canonical"] == binding["canonical"] - for item in MIGRATIONS) - assert getattr(old, name) is import_module(binding["old"]) - assert value is import_module(binding["canonical"]) - continue - assert getattr(old, name) is value - # Generic aliases retain stdlib metadata; only definitions move modules. - if get_origin(value) is None and (inspect.isfunction(value) or inspect.isclass(value)): - assert value.__module__ == entry["canonical"] - # Protocol 0 GLOBAL references mirror pre-migration function/class pickles. - assert pickle.loads(f"c{entry['old']}\n{name}\n.".encode("ascii")) is value - new_pickle = pickle.dumps(value, protocol=0) - assert entry["canonical"].encode("ascii") in new_pickle - assert pickle.loads(new_pickle) is value - - -def test_generic_alias_identity_does_not_depend_on_inspect_isclass(monkeypatch): - from inferrsi.apps.storage.archive import ResourceReader - - original = inspect.isclass - monkeypatch.setattr( - inspect, "isclass", lambda value: value is ResourceReader or original(value) - ) - entry = next(entry for entry in MIGRATIONS if entry["old"] == "inferrsi.apps.archive") - test_shim_is_an_explicit_export_of_the_same_objects(entry) +def test_apps_root_contains_only_the_public_entries_and_owned_packages(): + root = ROOT / "apps" + entries = {p.name for p in root.iterdir() if p.name != "__pycache__"} + packages = { + "cli", "delivery", "handoff", "host", "integrations", "legacy", "storage", + "views", "workflows", + } + assert entries == packages | {"__init__.py", "api.py"} + assert all((root / name / "__init__.py").is_file() for name in packages) + assert (root / "__init__.py").is_file() and (root / "api.py").is_file() -@pytest.mark.parametrize("child_first", [False, True]) -def test_legacy_cannbot_package_keeps_its_project_module_in_either_import_order(child_first): - script = """ -import importlib, json, sys -parent = 'inferrsi.apps.cannbot' -if sys.argv[1] == 'True': - importlib.import_module(parent + '.project') -old = importlib.import_module(parent) -child = importlib.import_module(parent + '.project') -canonical = importlib.import_module('inferrsi.apps.integrations.cannbot') -importlib.import_module(parent + '.read_worker') -assert old.project is child -assert child is not canonical.project -assert old.CannbotChannel is canonical.CannbotChannel -assert all(getattr(child, name) is getattr(canonical.project, name) for name in child.__all__) -print(json.dumps({'compatible': True})) -""" - assert _fresh(script, str(child_first)) == {"compatible": True} +@pytest.mark.parametrize("entry", MIGRATIONS, ids=lambda entry: entry["old"]) +def test_retired_path_is_absent_and_its_public_exports_have_replacements(entry): + assert entry["status"] == "retired" and entry["first_removal_version"] == "0.3.4" + with pytest.raises(ModuleNotFoundError) as absent: + import_module(entry["old"]) + assert absent.value.name == entry["old"] or entry["old"].startswith(absent.value.name + ".") + module = import_module(entry["canonical"]) + for name in entry["exports"]: + assert hasattr(module, name), (entry["canonical"], name) @pytest.mark.parametrize("system", ["cannbot", "mindie"]) def test_project_launchers_reference_the_canonical_standalone_worker(system): project = import_module(f"inferrsi.apps.integrations.{system}.project") - legacy = import_module(f"inferrsi.apps.{system}.project") worker = ROOT / "apps/integrations" / system / "read_worker.py" assert project._WORKER == worker assert Path(project.__file__).with_name("read_worker.py") == worker operation = "read" if system == "cannbot" else "call" - assert getattr(legacy, operation) is getattr(project, operation) + assert callable(getattr(project, operation)) script = """ import ast, json, runpy, sys from pathlib import Path @@ -148,7 +79,6 @@ class RunOutput: result: dict """ import sys - from types import ModuleType from unittest.mock import patch old = ModuleType("inferrsi.apps.archive") @@ -157,7 +87,8 @@ class RunOutput: data = pickle.dumps(old.RunOutput("output-test", Path("outputs/test"), {"retained": True})) from inferrsi.apps.storage.archive import RunOutput - restored = pickle.loads(data) + restored = load_record(io.BytesIO(data)) + assert pickle.loads(pickle.dumps(restored)) == restored assert type(restored) is RunOutput assert restored == RunOutput("output-test", Path("outputs/test"), {"retained": True}) @@ -166,9 +97,9 @@ def test_active_consumers_use_canonical_paths_and_are_registered(): modules = support._module_index(ROOT) old_names = {entry["old"] for entry in MIGRATIONS} entries = {entry["canonical"]: entry for entry in MIGRATIONS} - shims = {entry["old"].replace(".", "/") + ( - "/__init__.py" if entry.get("package") else ".py" - ) for entry in MIGRATIONS} + # Include absent names when resolving "from package import retired_module". + for name in old_names: + modules[name] = ROOT / (name.replace(".", "/") + ".py") for entry in MIGRATIONS: assert entry["consumers"] and len(entry["consumers"]) == len(set(entry["consumers"])) assert all((REPO / path).is_file() for path in entry["consumers"]) @@ -177,8 +108,6 @@ def test_active_consumers_use_canonical_paths_and_are_registered(): if path.is_relative_to(REPO / "tests/fixtures/legacy"): continue relative = path.relative_to(REPO).as_posix() - if relative.removeprefix("src/") in shims: - continue package = ".".join(path.relative_to(base).parts[:-1]) targets = support._direct_targets( ast.parse(path.read_text(encoding="utf-8")), package, modules @@ -189,11 +118,9 @@ def test_active_consumers_use_canonical_paths_and_are_registered(): def _is_handoff(name): - # Include retained shims as well as the canonical handoff implementations. - return name in { - "inferrsi.apps.api", "inferrsi.apps.bridge", "inferrsi.apps.context_provider", - "inferrsi.apps.candidate_provider", - } or name == "inferrsi.apps.handoff" or name.startswith("inferrsi.apps.handoff.") + return name in {"inferrsi.apps.api", "inferrsi.apps.handoff"} or name.startswith( + "inferrsi.apps.handoff." + ) def test_storage_has_no_direct_or_transitive_handoff_dependency(): @@ -234,9 +161,7 @@ def test_migrated_initializers_import_nothing_and_module_bodies_do_no_io(): path = REPO / "src" / package.replace(".", "/") / "__init__.py" tree = ast.parse(path.read_text(encoding="utf-8")) assert len(tree.body) == 1 and ast.get_docstring(tree) - modules = packages + [ - entry[key] for entry in MIGRATIONS for key in ("old", "canonical") - ] + modules = packages + [entry["canonical"] for entry in MIGRATIONS] result = _fresh(IO_PROBE, json.dumps(modules), IO_CONTROL) seen = result["seen"] assert {"os.listdir", "open"} <= set(seen.pop("control")) @@ -264,8 +189,7 @@ def find_spec(self, name, path=None, target=None): importlib.import_module(name) print(json.dumps({'parent_only': parent_only, 'warnings': [str(w.message) for w in caught]})) """ - modules = [entry[key] for entry in MIGRATIONS if ".storage." in entry["canonical"] - for key in ("old", "canonical")] + modules = [entry["canonical"] for entry in MIGRATIONS if ".storage." in entry["canonical"]] result = _fresh(script, json.dumps(modules)) assert result == {"parent_only": ["inferrsi.apps", "inferrsi.apps.storage"], "warnings": []} @@ -274,8 +198,7 @@ def test_public_candidate_provider_is_the_one_canonical_class(): from inferrsi.apps import api from inferrsi.apps.handoff.candidate_provider import CandidateProvider - old = import_module("inferrsi.apps.candidate_provider") - assert api.CandidateProvider is old.CandidateProvider is CandidateProvider + assert api.CandidateProvider is CandidateProvider assert CandidateProvider.__module__ == "inferrsi.apps.handoff.candidate_provider" assert api.EvaluationPort.__module__ == "inferrsi.apps.api" @@ -289,10 +212,24 @@ def test_delivered_context_draft_loads_a_legacy_instance_pickle(): canonical = b"cinferrsi.apps.handoff.context_provider\nDeliveredContextDraft\n" assert data.count(canonical) == 1 legacy = data.replace(canonical, b"cinferrsi.apps.context_provider\nDeliveredContextDraft\n") - restored = pickle.loads(legacy) + restored = load_record(io.BytesIO(legacy)) + assert pickle.loads(pickle.dumps(restored)) == restored assert type(restored) is DeliveredContextDraft and restored == value +@pytest.mark.parametrize("protocol", range(pickle.HIGHEST_PROTOCOL + 1)) +def test_record_reader_accepts_retained_data_across_pickle_protocols(protocol): + from inferrsi.apps.storage.archive import RunOutput + + value = RunOutput("answer", Path("outputs/test"), {"utf8": b"\xc3\xa9"}) + assert load_record(io.BytesIO(pickle.dumps(value, protocol))) == value + + +def test_record_reader_rejects_other_pickled_objects(): + with pytest.raises(pickle.UnpicklingError, match="unexpected|unsupported"): + load_record(io.BytesIO(pickle.dumps(complex(1, 2)))) + + @pytest.mark.parametrize("group", ["handoff", "workflows", "integrations"]) def test_cold_handoff_and_workflow_imports_do_not_read_data_probe_or_launch_services(group): script = """ @@ -325,8 +262,7 @@ def deny(*args, **kwargs): print(json.dumps({'parent_only': parent_only, 'warnings': [str(w.message) for w in caught], 'control': control})) """ - modules = [entry[key] for entry in MIGRATIONS if f".{group}." in entry["canonical"] - for key in ("old", "canonical")] + modules = [entry["canonical"] for entry in MIGRATIONS if f".{group}." in entry["canonical"]] result = _fresh(script, json.dumps(modules), group) assert result == {"parent_only": ["inferrsi.apps", f"inferrsi.apps.{group}"], "warnings": [], "control": True} diff --git a/tests/check_installed.py b/tests/check_installed.py index b85aa18a0..d69ed5b8c 100644 --- a/tests/check_installed.py +++ b/tests/check_installed.py @@ -3,7 +3,6 @@ import io import json import os -import pickle import shutil import subprocess import sys @@ -13,7 +12,6 @@ from importlib.resources import as_file, files from importlib.util import find_spec from pathlib import Path -from types import ModuleType import inferrsi import inferrsi.harness @@ -686,40 +684,17 @@ def _inventory(root, prefix): else: raise AssertionError("an unknown repository type must be refused") assert evidence.EVIDENCE_SEGMENTS == ("plan", "results", "patch", "validator") -# #490: installed compatibility exports resolve to their canonical definitions. -for name, group in ( - ("archive", "storage"), ("artifact_reader", "storage"), - ("result", "storage"), ("evidence_layout", "storage"), - ("bridge", "handoff"), ("context_provider", "handoff"), - ("candidate_provider", "handoff"), - ("campaign", "workflows"), ("benchmark_operations", "workflows"), - ("improvement", "workflows"), ("skill_evaluation", "workflows"), - ("skill_eval_engineering", "workflows"), ("benchmark_compare", "workflows"), - ("cannbot", "integrations"), ("cannbot.project", "integrations"), - ("cannbot.read_worker", "integrations"), ("mindie", "integrations"), - ("mindie.project", "integrations"), ("mindie.context", "integrations"), - ("mindie.mcp", "integrations"), ("mindie.read_worker", "integrations"), -): - old_name = f"inferrsi.apps.{name}" - canonical_name = f"inferrsi.apps.{group}.{name}" - old, canonical = import_module(old_name), import_module(canonical_name) - assert find_spec(old_name) is not None and find_spec(canonical_name) is not None - for exported in old.__all__: - value = getattr(canonical, exported) - if isinstance(value, ModuleType): - assert getattr(old, exported) is import_module(old_name + "." + exported) - assert value is import_module(canonical_name + "." + exported) - continue - assert getattr(old, exported) is value, (old_name, exported) - if getattr(value, "__module__", None) == canonical_name: - assert pickle.loads(f"c{old_name}\n{exported}\n.".encode("ascii")) is value - assert canonical_name.encode("ascii") in pickle.dumps(value, protocol=0) +# The installed package contains only its public Python entry and owned subpackages. +installed_apps = files("inferrsi.apps") +assert {item.name for item in installed_apps.iterdir() if item.name != "__pycache__"} == { + "__init__.py", "api.py", "cli", "delivery", "handoff", "host", "integrations", + "legacy", "storage", "views", "workflows", +} assert CandidateProvider is ( import_module("inferrsi.apps.handoff.candidate_provider").CandidateProvider ) -assert CandidateProvider is import_module("inferrsi.apps.candidate_provider").CandidateProvider assert EvaluationPort.__module__ == "inferrsi.apps.api" -# Both the former engineering verifier script and its canonical entry survive installation. +# The engineering verifier supports both installed module and file execution. with tempfile.TemporaryDirectory() as script_directory: script_root = Path(script_directory) script_task, script_output, script_result = ( @@ -730,21 +705,20 @@ def _inventory(root, prefix): "provenance": "Synthetic installed-entry control", }), encoding="utf-8") script_output.write_text("{}", encoding="utf-8") - for script_module in ("inferrsi.apps.skill_eval_engineering", - "inferrsi.apps.workflows.skill_eval_engineering"): - for script_entry in (["-I", "-m", script_module], - ["-I", import_module(script_module).__file__]): - script_result.unlink(missing_ok=True) - script_run = subprocess.run( - [sys.executable, *script_entry, str(script_task), str(script_output)], - env={**os.environ, "INFERRSI_RESULT_PATH": str(script_result)}, - cwd=script_root, capture_output=True, text=True, timeout=30, - ) - assert script_run.returncode == 1, script_run.stderr - assert script_run.stdout == script_run.stderr == "" - assert script_result.read_bytes() == ( - b'{"passed": false, "assertions": {"artifact_schema": false}}' - ) + script_module = "inferrsi.apps.workflows.skill_eval_engineering" + for script_entry in (["-I", "-m", script_module], + ["-I", import_module(script_module).__file__]): + script_result.unlink(missing_ok=True) + script_run = subprocess.run( + [sys.executable, *script_entry, str(script_task), str(script_output)], + env={**os.environ, "INFERRSI_RESULT_PATH": str(script_result)}, + cwd=script_root, capture_output=True, text=True, timeout=30, + ) + assert script_run.returncode == 1, script_run.stderr + assert script_run.stdout == script_run.stderr == "" + assert script_result.read_bytes() == ( + b'{"passed": false, "assertions": {"artifact_schema": false}}' + ) for retired in ("_repo_pack_data", "evidence_paths"): assert find_spec(f"inferrsi.{retired}") is None, retired assert not installed_root & {"_repo_pack_data.py", "evidence_paths.py"} diff --git a/tests/repository/test_package_root_inventory.py b/tests/repository/test_package_root_inventory.py index 6f0177791..324b45c09 100644 --- a/tests/repository/test_package_root_inventory.py +++ b/tests/repository/test_package_root_inventory.py @@ -119,7 +119,6 @@ def test_inventory_is_the_exact_final_two_file_root() -> None: assert not [node for node in ast.walk(initializer) if isinstance(node, (ast.Import, ast.ImportFrom))] # A2 moved its two files into Apps. - assert (REPO / PACKAGE / "apps" / "benchmark_operations.py").is_file() assert (REPO / PACKAGE / "apps" / "workflows" / "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. @@ -128,13 +127,13 @@ def test_inventory_is_the_exact_final_two_file_root() -> None: # C2 moved its two files; it left nothing behind under either old name. assert (REPO / PACKAGE / "resources" / "repository_packs.py").is_file() assert (REPO / PACKAGE / "contracts" / "evidence.py").is_file() - assert (REPO / PACKAGE / "apps" / "evidence_layout.py").is_file() + assert (REPO / PACKAGE / "apps" / "storage" / "evidence_layout.py").is_file() # R1 deleted its eleven files. Each implementation is at its canonical path. for name in RETIRED_BY_R1 - {"evaluation.py", "execution.py", "reporting.py", "inspection.py"}: assert (REPO / PACKAGE / "knowledge" / name).is_file(), name for name in ("legacy/evaluation.py", "legacy/run.py", "legacy/reporting.py", - "inspection.py"): + "host/prepared_environment.py"): assert (REPO / PACKAGE / "apps" / name).is_file(), name for name in RETIRED: assert not (REPO / PACKAGE / name).exists(), name diff --git a/tests/repository/test_target_module_import_gate.py b/tests/repository/test_target_module_import_gate.py index f5ebe2d91..405a42d7e 100644 --- a/tests/repository/test_target_module_import_gate.py +++ b/tests/repository/test_target_module_import_gate.py @@ -292,10 +292,8 @@ def test_no_new_cross_core_imports(self) -> None: "mindie_project.py", "mindie_context.py", "mindie_mcp.py", "_mindie_read_worker.py"): self.assertFalse((ROOT / retired).exists(), retired) - for moved in ("cli/__init__.py", "cli/arguments.py", "benchmark_operations.py", - "workflows/benchmark_operations.py", - "views/summary_chart.py", "mindie/project.py", "mindie/context.py", - "mindie/mcp.py", "mindie/read_worker.py", + for moved in ("cli/__init__.py", "cli/arguments.py", "workflows/benchmark_operations.py", + "views/summary_chart.py", "integrations/mindie/project.py", "integrations/mindie/context.py", "integrations/mindie/mcp.py", "integrations/mindie/read_worker.py"): self.assertTrue((ROOT / "apps" / moved).is_file(), moved) @@ -346,7 +344,7 @@ def test_clean_scan_is_not_isolation(self) -> None: sorted(path.name for path in (ROOT / "resources").iterdir() if path.is_file()), ["__init__.py", "repository_packs.py"], ) - self.assertTrue((ROOT / "apps" / "evidence_layout.py").is_file()) + self.assertTrue((ROOT / "apps" / "storage" / "evidence_layout.py").is_file()) # #412 R3: every staged trigger is gone, so the final tree is fully isolated in # the static import-closure sense. report = first_wave_report() diff --git a/tests/skill_eval/test_skill_eval_engineering.py b/tests/skill_eval/test_skill_eval_engineering.py index bbf5ba260..e13bc109f 100644 --- a/tests/skill_eval/test_skill_eval_engineering.py +++ b/tests/skill_eval/test_skill_eval_engineering.py @@ -18,11 +18,9 @@ ANSWER = {"artifact": "parser.py", "summary": "Repair", "artifact_source": engineering.STARTER} -@pytest.mark.parametrize("module", [ - "inferrsi.apps.skill_eval_engineering", "inferrsi.apps.workflows.skill_eval_engineering", -]) @pytest.mark.parametrize("by_file", [False, True]) -def test_old_and_canonical_script_entries_write_the_same_result(tmp_path, module, by_file): +def test_canonical_script_entries_write_the_same_result(tmp_path, by_file): + module = "inferrsi.apps.workflows.skill_eval_engineering" task, output, result = (tmp_path / name for name in ("task.json", "output.json", "result.json")) task.write_text(json.dumps(TASK), encoding="utf-8") output.write_text("{}", encoding="utf-8") From ec4a6464c3a03a893923272b86d8a5e2e5d927b3 Mon Sep 17 00:00:00 2001 From: Zeng Chuang Date: Wed, 25 Nov 2026 14:23:42 +0800 Subject: [PATCH 2/2] Migrate Qwen example imports to Apps storage Register both example consumers and scan the examples directory in the Apps migration guard so retired package imports fail before use. Agent-assisted-by: Codex / GPT-6 [effort=unknown] (author) Signed-off-by: zengchuang --- docs/apps-module-migrations.json | 2 ++ examples/qwen21_turbo_b300.py | 2 +- examples/qwen21_turbo_quality.py | 2 +- tests/apps/test_apps_module_migrations.py | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/apps-module-migrations.json b/docs/apps-module-migrations.json index 6a815b20b..5b8635b95 100644 --- a/docs/apps-module-migrations.json +++ b/docs/apps-module-migrations.json @@ -582,6 +582,8 @@ ], "consumers": [ "docs/skill-evaluation/local-skill-evaluation.md", + "examples/qwen21_turbo_b300.py", + "examples/qwen21_turbo_quality.py", "src/inferrsi/apps/delivery/__init__.py", "src/inferrsi/apps/delivery/projection.py", "src/inferrsi/apps/delivery/snapshot.py", diff --git a/examples/qwen21_turbo_b300.py b/examples/qwen21_turbo_b300.py index ab9cb2904..8ab4fa391 100644 --- a/examples/qwen21_turbo_b300.py +++ b/examples/qwen21_turbo_b300.py @@ -22,7 +22,7 @@ from inferrsi.harness.serving.server import launch_server, stop_server from inferrsi.apps.host import environment, targets from inferrsi.apps.host.platforms.cuda import qualify_devices -from inferrsi.apps import artifacts +from inferrsi.apps.storage import artifacts MODEL = "Qwen/Qwen-Image-2.1-Turbo" REVISION = "d65dbc9a7e8f6b5479e33dee6030eaab2a906509" diff --git a/examples/qwen21_turbo_quality.py b/examples/qwen21_turbo_quality.py index a258bc972..2f7d0d03a 100644 --- a/examples/qwen21_turbo_quality.py +++ b/examples/qwen21_turbo_quality.py @@ -6,7 +6,7 @@ from pathlib import Path import sys -from inferrsi.apps import artifacts as lifecycle +from inferrsi.apps.storage import artifacts as lifecycle def load(path): diff --git a/tests/apps/test_apps_module_migrations.py b/tests/apps/test_apps_module_migrations.py index 58ef31df5..64aab36e2 100644 --- a/tests/apps/test_apps_module_migrations.py +++ b/tests/apps/test_apps_module_migrations.py @@ -103,7 +103,8 @@ def test_active_consumers_use_canonical_paths_and_are_registered(): for entry in MIGRATIONS: assert entry["consumers"] and len(entry["consumers"]) == len(set(entry["consumers"])) assert all((REPO / path).is_file() for path in entry["consumers"]) - for base in (REPO / "src", REPO / "tests", REPO / "tools", REPO / "plugins"): + for directory in ("src", "tests", "tools", "plugins", "examples"): + base = REPO / directory for path in base.rglob("*.py"): if path.is_relative_to(REPO / "tests/fixtures/legacy"): continue