Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions docs/apps-module-migrations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
[
{
"old": "inferrsi.apps.archive",
"canonical": "inferrsi.apps.storage.archive",
"exports": [
"ResourceReader",
"RunOutput",
"archive_mount",
"archive_prepared",
"read_archive_artifact",
"read_prepared",
"archive_assessment",
"read_assessment",
"validate_output_id",
"read_result",
"publish_result"
],
"consumers": [
"docs/apps-output.md",
"docs/architecture.md",
"docs/module-layout.md",
"docs/operations.md",
"src/inferrsi/apps/api.py",
"src/inferrsi/apps/bridge.py",
"src/inferrsi/apps/candidate_provider.py",
"src/inferrsi/apps/delivery/__init__.py",
"src/inferrsi/apps/storage/artifact_reader.py",
"src/inferrsi/apps/views/attempt.py",
"tests/check_installed.py",
"tests/test_apps_assess.py",
"tests/test_apps_module_migrations.py",
"tests/test_apps_output.py",
"tests/test_apps_port_validation.py",
"tests/test_apps_prepare.py",
"tests/test_apps_publication.py",
"tests/test_apps_replay.py",
"tests/test_result_delivery.py"
]
},
{
"old": "inferrsi.apps.artifact_reader",
"canonical": "inferrsi.apps.storage.artifact_reader",
"exports": [
"ArtifactReader",
"AssessmentArtifacts"
],
"consumers": [
"docs/apps-output.md",
"docs/architecture.md",
"docs/module-layout.md",
"docs/operations.md",
"src/inferrsi/apps/api.py",
"src/inferrsi/apps/candidate_provider.py",
"src/inferrsi/apps/views/attempt.py",
"tests/check_installed.py",
"tests/test_apps_artifact_reader.py",
"tests/test_apps_assess.py",
"tests/test_apps_generation_plan.py",
"tests/test_apps_module_migrations.py"
]
},
{
"old": "inferrsi.apps.result",
"canonical": "inferrsi.apps.storage.result",
"exports": [
"is_public_error",
"execution_result",
"preparation_result",
"assessment_result",
"publication_error",
"validate_artifact_ref",
"validate_result"
],
"consumers": [
"docs/apps-output.md",
"docs/architecture.md",
"docs/module-layout.md",
"docs/operations.md",
"src/inferrsi/apps/api.py",
"src/inferrsi/apps/bridge.py",
"src/inferrsi/apps/candidate_provider.py",
"src/inferrsi/apps/delivery/adapters.py",
"src/inferrsi/apps/storage/archive.py",
"src/inferrsi/apps/storage/artifact_reader.py",
"src/inferrsi/apps/views/attempt.py",
"tests/check_installed.py",
"tests/test_apps_module_migrations.py",
"tests/test_result_delivery.py"
]
},
{
"old": "inferrsi.apps.evidence_layout",
"canonical": "inferrsi.apps.storage.evidence_layout",
"exports": [
"ensure_evidence_layout"
],
"consumers": [
"docs/apps-output.md",
"docs/architecture.md",
"docs/contracts/current-design.md",
"docs/module-layout.md",
"docs/operations.md",
"src/inferrsi/contracts/evidence.py",
"tests/_gate_policy_support.py",
"tests/check_installed.py",
"tests/test_apps_module_migrations.py",
"tests/test_evidence_paths.py",
"tests/test_first_wave_isolation_policy.py",
"tests/test_repository_packs_facade.py"
]
}
]
14 changes: 11 additions & 3 deletions docs/apps-output.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ error retains the committed PreparedRef.
`read_prepared` verifies the fixed prepared bytes and identity using the same
storage configuration. `read_archive_artifact` reads protocol or resource bytes
from the archive mount and verifies the reference's size and digest. Both
functions are under `inferrsi.apps.archive`.
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`.
The [migration inventory](apps-module-migrations.json) lists the exact exports.
Persisted namespace values, artifact references and schema versions retain
their existing spelling.

## Execute binding

Expand All @@ -128,7 +136,7 @@ The bound spec is handed to the host-supplied Harness execution port.

## Fixed artifact reader

`inferrsi.apps.artifact_reader.ArtifactReader(storage_config)` implements
`inferrsi.apps.storage.artifact_reader.ArtifactReader(storage_config)` implements
`open(ArtifactRef)` for hosts composing execution or offline assessment.
Locations select one configured mount by its full prefix and slash boundary.
Directory mounts verify the declared bytes and reject links or traversal.
Expand All @@ -151,5 +159,5 @@ code after a confirmed archive commit. Archive failure returns exit code 6 and
keeps the assessment in the result with a null `assessment_ref`. If the archive
commit succeeds and output publication fails, the result retains the committed
`assessment_ref`.
`inferrsi.apps.archive.read_assessment` resolves that fixed reference and checks
`inferrsi.apps.storage.archive.read_assessment` resolves that fixed reference and checks
the archived bytes, version and identity for reports and other read-only consumers.
6 changes: 5 additions & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ src/inferrsi/
__init__.py Import-free initializer
repository_packs.py Neutral REPO_TYPES and pack.json reader; imports no inferrsi module
apps/
evidence_layout.py Create the plan/results/patch/validator evidence directories
storage/
archive.py Immutable preparations/assessments and manifest.json/result.json
artifact_reader.py Read verified artifacts through authorized mounts
result.py AppsResultV1 construction and validation
evidence_layout.py Create plan/results/patch/validator evidence directories
campaign.py Knowledge values connected to Harness campaign records
mindie/
project.py Opt-in per-checkout grant, the worker launch and the recorded read
Expand Down
2 changes: 1 addition & 1 deletion docs/contracts/current-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Permitted shared technical leaves are only:
- `inferrsi.contracts.evidence` — the existing evidence segment names and pure path rules; it reads and writes no filesystem state and is not re-exported by the package initializer;
- `inferrsi.resources.repository_packs` — the neutral raw pack-data reader and the existing static data enumeration (D020), formerly root `inferrsi._repo_pack_data`. Its parent initializer `resources/__init__.py` imports nothing. Outside Knowledge it has one permanent importer, `inferrsi.infra.inspection`, which binds only `repository_pack`; that exact rule is not a compatibility pair. A1 (#408) removed the separate temporary entry for root `arguments.py`: the moved parser `inferrsi.apps.cli.arguments` reads the same `REPO_TYPES` object through `inferrsi.knowledge.catalog` and does not import the leaf.

The neutral leaf carries no target selection, task, scoring, scheduling, or public business DTO, and imports none of K/H/B/Apps. It still finds the Harness-owned `pack.json` through `files("inferrsi").joinpath("harness", "data", "repo_packs", ...)`, so reading it never imports Harness. Creating the evidence directories is host I/O and stays in Apps, in `inferrsi.apps.evidence_layout`; that module is not a shared leaf. The list is exact: a `contracts.` or `resources.` prefix admits no other module.
The neutral leaf carries no target selection, task, scoring, scheduling, or public business DTO, and imports none of K/H/B/Apps. It still finds the Harness-owned `pack.json` through `files("inferrsi").joinpath("harness", "data", "repo_packs", ...)`, so reading it never imports Harness. Creating the evidence directories is host I/O and stays in Apps, in `inferrsi.apps.storage.evidence_layout`; that module is not a shared leaf. The list is exact: a `contracts.` or `resources.` prefix admits no other module.

Why: this matches the accepted A–D direction and removes the reverse dependency that a shared DTO package creates. Rejected: a shared business DTO package; Apps owning scoring/sampling/budget algorithms; creating empty packages to declare migration done.

Expand Down
39 changes: 31 additions & 8 deletions docs/module-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,41 @@ 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
collected-context projection is in `knowledge/context_projection.py`.
#371 remains the proposal for the Apps package path and is not accepted here.
#371 owns the Apps composition. Its accepted directory follow-up
[#490](https://github.com/InferMatrixLab/InferRSI/issues/490) starts with the
`apps/storage/` slice described below.

The old `run` chain is split by owner. Its gates are in
`benchmark/legacy_run_v0.py`, its execution facts stay in `harness/`, and
`apps/legacy/` composes them with the report. `apps/legacy/` is the path named
by the confirmed split for this slice; that use does not accept #371.
`apps/legacy/` composes them with the report. That path was established by
the earlier confirmed split.
`apps/cli/` imports the old run only inside its `run` command, so the other
commands, including ordinary optimization, still load no Benchmark module.
R1 deleted the three root forwarders of that chain (`evaluation.py`,
`execution.py` and `reporting.py`), and the CLI imports `apps/legacy/` itself.

## Target modules

### Apps storage migration

`apps/storage/` owns `archive.py`, `artifact_reader.py`, `result.py` and
`evidence_layout.py`. API, handoff, view and delivery consumers import these
canonical implementations. Storage has no direct or transitive import back to
handoff. The package initializer imports nothing.

The four old Apps paths remain explicit static exports of the same public
objects. [apps-module-migrations.json](apps-module-migrations.json) records the
implemented paths, exports and consumers. Private-helper imports and test
patches must target the canonical module. Old Apps pickle references load
through these exports; new pickles use the canonical definition. The retired
root `inferrsi.evidence_paths` has no alias and remains unavailable.

Shim removal requires a separate reviewed PR recording consumer migration,
wheel and plugin validation, and the first removal version. Handoff, workflows
and integrations remain subsequent #490 slices.

### Core and technical packages

The four target modules are peers: `knowledge`, `harness`, `benchmark`, and
`apps`. Knowledge, Harness, and Benchmark do not import one another. Apps is
the only assembler. `src/inferrsi/contracts/__init__.py` re-exports only
Expand All @@ -33,7 +55,7 @@ business DTOs and performs no core or host initialization.

`contracts/evidence.py` holds the evidence segment names and the per-campaign
path rules. It only builds paths and does no filesystem I/O. Creating the
directories is `apps/evidence_layout.py`, which reuses those rules, so `mkdir`
directories is `apps/storage/evidence_layout.py`, which reuses those rules, so `mkdir`
stays out of the contracts package. `resources/repository_packs.py` is the
neutral repository-pack facade: the one `REPO_TYPES` tuple and the `pack.json`
reader. It imports no `inferrsi` module, and `resources/__init__.py` imports
Expand Down Expand Up @@ -89,7 +111,7 @@ contract slice. Do not treat PR #338 as a reason to add a top-level
`tests/architecture_closed_loop.py` is the handoff exercised by
`tests/test_architecture_closed_loop.py`. The coordinator does not import
Knowledge, Harness, or Benchmark. Refusal cases still inject outcomes. That
file is not the Apps package, and #371 remains the proposal for that path.
file is not the Apps implementation owned by #371.
It does not change Bundle revision.

`tests/architecture_real_ports.py` is the CPU/offline connection injected for
Expand Down Expand Up @@ -119,18 +141,19 @@ Several flat modules remain shared seams until their slice starts.
| `apps/skill_evaluation.py`, `apps/skill_eval_engineering.py`, `apps/improvement.py` | Composed skill-evaluation entries | Join Knowledge reads, Harness execution and Benchmark rules behind the signatures that `harness/` held before the split |
| `knowledge/knowledge_operations.py`, `knowledge/knowledge_store.py`, `knowledge/catalog.py`, `knowledge/research.py`, `knowledge/skill_catalog.py`, `knowledge/_skill_selection.py`, `knowledge/_source_snapshot.py` | The seven Knowledge implementations, moved by K01 | Interfaces unchanged; the same-named root shells were deleted by R1 |
| `harness/records/` | Campaign manifests, traces, logs, profile captures and delivered-context captures | Imports no Knowledge or Apps module; `apps/campaign.py` supplies the backend names, the selection default and the context projection |
| `apps/views/`, `apps/campaign.py` | Dashboard views, templates and the Knowledge-to-records connection | Apps path still follows the #371 proposal |
| `apps/views/`, `apps/campaign.py` | Dashboard views, templates and the Knowledge-to-records connection | Apps composition under #371; campaign organization follows in #490 |
| `apps/mindie/` (`project.py`, `context.py`, `mcp.py`, `read_worker.py`) | The local MindIE adapter: project grant, stdio MCP, context export and the read worker | M1 (#452) moved the four root MindIE files here; no Harness, Knowledge or Infra module names MindIE, and the initializer imports nothing |
| `harness/` | Mixed legacy tree, not target isolation | Not redefined |
| `harness/runner.py`, `harness/scenarios/external.py`, `harness/atomic_json.py` | Old run execution facts and Harness-owned JSON writes | Ports injected; no Model edge, and no Infra edge except the local process executor |
| `benchmark/legacy_run_v0.py`, `benchmark/sampling.py` | Old run gates and metric validation; image/video sample collection | Imports only `model/protocols/metrics`; owns its rule inputs and verdict labels |
| `apps/legacy/` | Old run composition, old `evaluate` entry and HTML report | Supplies the Git source snapshot from `infra/targets`; path follows the confirmed split, #371 still proposed |
| `apps/legacy/` | Old run composition, old `evaluate` entry and HTML report | Supplies the Git source snapshot from `infra/targets`; remains in Apps |
| `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 |
| `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 |
| `apps/storage/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 |
| `apps/storage/` (`archive.py`, `artifact_reader.py`, `result.py`) | Fixed artifact publication and reads; normalized AppsResultV1 | #490 storage slice; the old Apps modules retain explicit public exports |
| `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 |
| `knowledge/data/`, `harness/data/` | Packaged resources, placed by owner since K02 | Corpus under Knowledge; pack descriptions under Harness |

Expand Down
8 changes: 8 additions & 0 deletions docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,14 @@ normal scoped PR path.

## Experiments

The public preparation, execution and assessment API remains
`inferrsi.apps.api`. Its fixed artifact access and output publication use
`inferrsi.apps.storage.archive`, `artifact_reader` and `result`; the directory
creation helper is `inferrsi.apps.storage.evidence_layout.ensure_evidence_layout`.
The CLI entry remains `inferrsi.apps.cli:main`. See the
[output contract](apps-output.md) and [migration inventory](apps-module-migrations.json)
for the retained old Apps imports and canonical storage paths.

### Inspect/prepare — `doctor`, `plan`, `--dry-run`

- **Inputs:** repository/backend/device flags; `plan` takes the full experiment specification.
Expand Down
12 changes: 6 additions & 6 deletions src/inferrsi/apps/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from inferrsi.harness.errors import PublicError
from inferrsi.harness.execution_spec import request_digest

from .archive import (
from .bridge import bind_execution as _bind_prepared_execution
from .bridge import check_assessment_identity, execution_fields, to_evidence, verify_protocol
from .candidate_provider import CandidateProvider as CandidateProvider
from .storage.archive import (
ResourceReader,
RunOutput,
archive_assessment,
Expand All @@ -20,11 +23,8 @@
read_prepared,
validate_output_id,
)
from .artifact_reader import ArtifactReader, AssessmentArtifacts
from .bridge import bind_execution as _bind_prepared_execution
from .bridge import check_assessment_identity, execution_fields, to_evidence, verify_protocol
from .candidate_provider import CandidateProvider as CandidateProvider
from .result import (
from .storage.artifact_reader import ArtifactReader, AssessmentArtifacts
from .storage.result import (
assessment_result,
execution_result,
is_public_error,
Expand Down
Loading
Loading