From 2f095e764da85a2d8dba83b6da7fb08804e5df94 Mon Sep 17 00:00:00 2001 From: Zeng Chuang Date: Tue, 24 Nov 2026 23:50:38 +0800 Subject: [PATCH 1/4] Place host inspection and file helpers in their owning Apps packages Agent-assisted-by: Codex / GPT-6 [effort=unknown] (author) Signed-off-by: zengchuang --- docs/apps-module-migrations.json | 81 +++++++++++++ docs/contracts/current-design.md | 4 +- docs/local-skill-evaluation.md | 2 +- docs/module-layout.md | 4 +- src/inferrsi/apps/artifacts.py | 114 ++++-------------- src/inferrsi/apps/cli/__init__.py | 2 +- src/inferrsi/apps/delivery/__init__.py | 2 +- src/inferrsi/apps/delivery/projection.py | 2 +- src/inferrsi/apps/delivery/snapshot.py | 2 +- .../apps/host/prepared_environment.py | 33 +++++ src/inferrsi/apps/inspection.py | 39 ++---- src/inferrsi/apps/storage/artifacts.py | 93 ++++++++++++++ src/inferrsi/harness/artifact_primitives.py | 2 +- src/inferrsi/harness/atomic_json.py | 2 +- src/inferrsi/harness/input_binding.py | 4 +- tests/_gate_policy_support.py | 2 +- tests/check_installed.py | 8 +- tests/fixtures/harness_improvement_demo.py | 2 +- tests/fixtures/skill_eval_compare_support.py | 2 +- tests/fixtures/skill_eval_pr_support.py | 2 +- tests/session_lock_probe.py | 2 +- tests/test_anthropic_agent.py | 2 +- tests/test_architecture_closed_loop.py | 4 +- tests/test_artifact_helper_copies.py | 10 +- tests/test_first_wave_isolation_policy.py | 3 +- tests/test_goal_checkpoint.py | 2 +- tests/test_image_modules.py | 2 +- tests/test_inspection.py | 18 +-- tests/test_legacy_run_split.py | 2 +- tests/test_project_service_reuse.py | 2 +- tests/test_result_delivery.py | 2 +- tests/test_session_lock_across_processes.py | 4 +- tests/test_skill_eval_compare.py | 4 +- tests/test_skill_eval_diagnostic.py | 2 +- tests/test_skill_eval_feedback.py | 2 +- tests/test_skill_eval_generation.py | 2 +- tests/test_skill_eval_historical_job.py | 2 +- tests/test_skill_eval_local.py | 2 +- tests/test_skill_eval_local_cli.py | 2 +- tests/test_skill_eval_pipeline.py | 2 +- tests/test_skill_eval_planned_guidance.py | 2 +- tests/test_skill_eval_planning_boundaries.py | 2 +- tests/test_skill_eval_pr.py | 2 +- tests/test_skill_eval_pr_diagnostic.py | 2 +- tests/test_skill_eval_retention.py | 2 +- tests/test_skill_eval_review_guidance.py | 2 +- tests/test_skill_evaluation.py | 4 +- tests/test_target_module_import_gate.py | 6 +- tests/test_yibuapi_runtime.py | 2 +- tools/goal_checkpoint.py | 2 +- tools/skill_eval_auto.py | 2 +- tools/skill_eval_cloud_export.py | 2 +- tools/skill_eval_compare.py | 4 +- tools/skill_eval_historical_job.py | 2 +- tools/skill_eval_improve.py | 2 +- tools/skill_eval_local.py | 2 +- tools/skill_eval_pilot.py | 2 +- tools/skill_eval_pr.py | 2 +- 58 files changed, 314 insertions(+), 203 deletions(-) create mode 100644 src/inferrsi/apps/host/prepared_environment.py create mode 100644 src/inferrsi/apps/storage/artifacts.py diff --git a/docs/apps-module-migrations.json b/docs/apps-module-migrations.json index 92320a0b7..d84a3a5d8 100644 --- a/docs/apps-module-migrations.json +++ b/docs/apps-module-migrations.json @@ -492,5 +492,86 @@ "tests/check_installed.py", "tests/test_apps_module_migrations.py" ] + }, + { + "old": "inferrsi.apps.artifacts", + "canonical": "inferrsi.apps.storage.artifacts", + "exports": [ + "REPLACE_ATTEMPTS", + "REPLACE_DELAY_SECONDS", + "atomic_write_json", + "digest", + "file_lock", + "sha256", + "write_json" + ], + "consumers": [ + "docs/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", + "src/inferrsi/harness/artifact_primitives.py", + "src/inferrsi/harness/atomic_json.py", + "src/inferrsi/harness/input_binding.py", + "tests/_gate_policy_support.py", + "tests/check_installed.py", + "tests/fixtures/harness_improvement_demo.py", + "tests/fixtures/skill_eval_compare_support.py", + "tests/fixtures/skill_eval_pr_support.py", + "tests/session_lock_probe.py", + "tests/test_anthropic_agent.py", + "tests/test_artifact_helper_copies.py", + "tests/test_goal_checkpoint.py", + "tests/test_image_modules.py", + "tests/test_inspection.py", + "tests/test_legacy_run_split.py", + "tests/test_project_service_reuse.py", + "tests/test_result_delivery.py", + "tests/test_session_lock_across_processes.py", + "tests/test_skill_eval_compare.py", + "tests/test_skill_eval_diagnostic.py", + "tests/test_skill_eval_feedback.py", + "tests/test_skill_eval_generation.py", + "tests/test_skill_eval_historical_job.py", + "tests/test_skill_eval_local.py", + "tests/test_skill_eval_local_cli.py", + "tests/test_skill_eval_pipeline.py", + "tests/test_skill_eval_planned_guidance.py", + "tests/test_skill_eval_planning_boundaries.py", + "tests/test_skill_eval_pr.py", + "tests/test_skill_eval_pr_diagnostic.py", + "tests/test_skill_eval_retention.py", + "tests/test_skill_eval_review_guidance.py", + "tests/test_skill_evaluation.py", + "tests/test_target_module_import_gate.py", + "tests/test_yibuapi_runtime.py", + "tools/goal_checkpoint.py", + "tools/skill_eval_auto.py", + "tools/skill_eval_cloud_export.py", + "tools/skill_eval_compare.py", + "tools/skill_eval_historical_job.py", + "tools/skill_eval_improve.py", + "tools/skill_eval_local.py", + "tools/skill_eval_pilot.py", + "tools/skill_eval_pr.py" + ] + }, + { + "old": "inferrsi.apps.inspection", + "canonical": "inferrsi.apps.host.prepared_environment", + "exports": [ + "inspect_environment" + ], + "consumers": [ + "docs/contracts/current-design.md", + "docs/module-layout.md", + "src/inferrsi/apps/cli/__init__.py", + "src/inferrsi/apps/inspection.py", + "tests/check_installed.py", + "tests/test_architecture_closed_loop.py", + "tests/test_first_wave_isolation_policy.py", + "tests/test_inspection.py" + ] } ] diff --git a/docs/contracts/current-design.md b/docs/contracts/current-design.md index b99dd9b38..33f75a917 100644 --- a/docs/contracts/current-design.md +++ b/docs/contracts/current-design.md @@ -25,7 +25,7 @@ Historical candidate text, review dispositions, and the earlier Proposed drafts ## D001 — One distribution, three cores plus Apps, document contracts rather than shared business DTOs -Decision: keep Knowledge, Harness, and Benchmark as sibling independent cores; Apps is the only assembler. Each core owns its types. Cross-boundary traffic uses versioned JSON envelopes with explicit conversion; there is no shared business `contracts` package. The technical-only `inferrsi.contracts` package re-exports only `RunSpec`, defined once in `contracts/runspec.py`; `contracts/claim.py` owns the same Verdict enum re-exported by Harness. These are not shared business DTOs. The old root `contracts.py`, `runspec.py`, `claim.py`, and `_json_v1.py` files are retired without forwarding shells, and so are the old root `_repo_pack_data.py` and `evidence_paths.py`. R1 (#412) retired eleven more root modules the same way: the seven Knowledge compatibility shells, the three old-run forwarders `evaluation.py`, `execution.py` and `reporting.py`, and root `inspection.py`, whose host binding is now `inferrsi.apps.inspection` over the facts API in `inferrsi.apps.host.inspection`. [`CHANGELOG.md`](../../CHANGELOG.md) maps every retired path to its replacement and states the import and pickle impact. +Decision: keep Knowledge, Harness, and Benchmark as sibling independent cores; Apps is the only assembler. Each core owns its types. Cross-boundary traffic uses versioned JSON envelopes with explicit conversion; there is no shared business `contracts` package. The technical-only `inferrsi.contracts` package re-exports only `RunSpec`, defined once in `contracts/runspec.py`; `contracts/claim.py` owns the same Verdict enum re-exported by Harness. These are not shared business DTOs. The old root `contracts.py`, `runspec.py`, `claim.py`, and `_json_v1.py` files are retired without forwarding shells, and so are the old root `_repo_pack_data.py` and `evidence_paths.py`. R1 (#412) retired eleven more root modules the same way: the seven Knowledge compatibility shells, the three old-run forwarders `evaluation.py`, `execution.py` and `reporting.py`, and root `inspection.py`, whose host binding is now `inferrsi.apps.host.prepared_environment` over the facts API in `inferrsi.apps.host.inspection`. [`CHANGELOG.md`](../../CHANGELOG.md) maps every retired path to its replacement and states the import and pickle impact. Permitted shared technical leaves are only: @@ -143,7 +143,7 @@ Decision: see [`gate-policy-runstore-and-first-prs.md`](gate-policy-runstore-and Decision: old entry points, arguments, `Path`, stdout, stderr, and old run 0/1/2 stay byte-for-byte compatible. New Apps naming/envelope/exit mapping is fixed by D022, but K01/H01 do not implement a CLI. -Current reading: this covers the CLI commands and the `inferrsi` and `python -m inferrsi` entry points. It no longer covers old root Python module paths. The revised delivery decision in #412, #451 and #408 retires those paths without aliases, in the change that moves their last consumers. R1 (#412) removed the old-run root modules `evaluation`, `execution` and `reporting` together with root `inspection`; the old run is `inferrsi.apps.legacy` and the host inspection binding is `inferrsi.apps.inspection`. A1 (#408) then moved root `cli.py` and `arguments.py` to `inferrsi.apps.cli` and `inferrsi.apps.cli.arguments` and deleted both root files; the console script and `python -m inferrsi` call `inferrsi.apps.cli:main`. +Current reading: this covers the CLI commands and the `inferrsi` and `python -m inferrsi` entry points. It no longer covers old root Python module paths. The revised delivery decision in #412, #451 and #408 retires those paths without aliases, in the change that moves their last consumers. R1 (#412) removed the old-run root modules `evaluation`, `execution` and `reporting` together with root `inspection`; the old run is `inferrsi.apps.legacy` and the host inspection binding is `inferrsi.apps.host.prepared_environment`. A1 (#408) then moved root `cli.py` and `arguments.py` to `inferrsi.apps.cli` and `inferrsi.apps.cli.arguments` and deleted both root files; the console script and `python -m inferrsi` call `inferrsi.apps.cli:main`. ## D014 — events remain local, not a new shared event schema diff --git a/docs/local-skill-evaluation.md b/docs/local-skill-evaluation.md index d592660ae..b07936cca 100644 --- a/docs/local-skill-evaluation.md +++ b/docs/local-skill-evaluation.md @@ -59,7 +59,7 @@ without silently changing its contract: ```python from inferrsi.benchmark.skill_eval_engineering import REQUEST -from inferrsi.apps.artifacts import write_json +from inferrsi.apps.storage.artifacts import write_json write_json("cases.json", [{ "id": "serving-response-v1", "split": "development", diff --git a/docs/module-layout.md b/docs/module-layout.md index aa41692a9..c3ae73cc8 100644 --- a/docs/module-layout.md +++ b/docs/module-layout.md @@ -499,10 +499,10 @@ R1 (#412) deleted these eleven root modules with no forwarding shell, | `inferrsi.evaluation` | `inferrsi.apps.legacy.evaluation` | | `inferrsi.execution` | `inferrsi.apps.legacy.run` | | `inferrsi.reporting` | `inferrsi.apps.legacy.reporting` | -| `inferrsi.inspection` | `inferrsi.apps.inspection` | +| `inferrsi.inspection` | `inferrsi.apps.host.prepared_environment` | Root `inspection.py` was not an alias. It bound the Infra facts API to the -host, and `apps/inspection.py` now holds that binding: `_command` is +host, and `apps/host/prepared_environment.py` now holds that binding: `_command` is `apps.host.commands.probe_command` and `repository_identity` is `apps.host.targets.repository_identity`, both read from the module on each call, so a test replaces either name there. `apps/host/inspection.py`, moved from diff --git a/src/inferrsi/apps/artifacts.py b/src/inferrsi/apps/artifacts.py index 45abfd8aa..469880418 100644 --- a/src/inferrsi/apps/artifacts.py +++ b/src/inferrsi/apps/artifacts.py @@ -1,93 +1,21 @@ -# Apps-owned file digests, file locks and JSON evidence writes. The function bodies equal -# those in the other cores' copies; tests/test_artifact_helper_copies.py keeps them equal. -# Apps imports no other inferrsi module here. - -import errno -import hashlib -import json -import os -import time -import uuid -from contextlib import contextmanager -from pathlib import Path - -# Windows refuses os.replace while another handle holds the destination open. -# A bounded retry covers the observed contention without hiding a real failure. -REPLACE_ATTEMPTS = 8 -REPLACE_DELAY_SECONDS = 0.05 - - -@contextmanager -def file_lock(path: Path): - """Hold a nonblocking OS file lock, released even if the process crashes.""" - with path.open("a+b") as stream: - if os.fstat(stream.fileno()).st_size == 0: - stream.write(b"0") - stream.flush() - stream.seek(0) - if os.name == "nt": - import msvcrt - - try: - msvcrt.locking(stream.fileno(), msvcrt.LK_NBLCK, 1) - except PermissionError as error: - if error.errno != errno.EACCES: - raise - # LK_NBLCK reports a lock violation as EACCES. - raise BlockingIOError(errno.EAGAIN, "File lock is held", path) from error - else: - import fcntl - - fcntl.flock(stream.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB) - try: - yield - finally: - stream.seek(0) - if os.name == "nt": - msvcrt.locking(stream.fileno(), msvcrt.LK_UNLCK, 1) - else: - fcntl.flock(stream.fileno(), fcntl.LOCK_UN) - - -def digest(value): - return hashlib.sha256( - json.dumps( - value, sort_keys=True, separators=(",", ":"), ensure_ascii=False, allow_nan=False - ).encode() - ).hexdigest() - - -def sha256(path): - hasher = hashlib.sha256() - with Path(path).open("rb") as stream: - for block in iter(lambda: stream.read(1024 * 1024), b""): - hasher.update(block) - return hasher.hexdigest() - - -def write_json(path, value): - Path(path).parent.mkdir(parents=True, exist_ok=True) - Path(path).write_text( - json.dumps(value, ensure_ascii=False, indent=2, allow_nan=False) + "\n", encoding="utf-8" - ) - - -def atomic_write_json(path: Path, value: object) -> None: - path = Path(path) - # A per-writer temporary name keeps two writers from sharing one file. - temporary = path.with_name(f"{path.name}.{os.getpid()}.{uuid.uuid4().hex[:8]}.tmp") - temporary.write_text( - json.dumps(value, ensure_ascii=False, indent=2, allow_nan=False) + "\n", encoding="utf-8" - ) - try: - for attempt in range(REPLACE_ATTEMPTS): - try: - temporary.replace(path) - return - except PermissionError: - if attempt + 1 == REPLACE_ATTEMPTS: - raise - time.sleep(REPLACE_DELAY_SECONDS) - finally: - if temporary.exists(): - temporary.unlink() +"""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/cli/__init__.py b/src/inferrsi/apps/cli/__init__.py index a514ad016..6a4224ef0 100644 --- a/src/inferrsi/apps/cli/__init__.py +++ b/src/inferrsi/apps/cli/__init__.py @@ -14,7 +14,7 @@ from ...knowledge.catalog import get_knowledge, search_knowledge from ...knowledge.knowledge_operations import KnowledgeReader from ...knowledge.research import research_knowledge -from ..inspection import inspect_environment +from ..host.prepared_environment import inspect_environment from ..knowledge import knowledge_reader from ..knowledge import read as read_knowledge from ..legacy.reporting import write_report diff --git a/src/inferrsi/apps/delivery/__init__.py b/src/inferrsi/apps/delivery/__init__.py index 47d9b6cf9..74454efbe 100644 --- a/src/inferrsi/apps/delivery/__init__.py +++ b/src/inferrsi/apps/delivery/__init__.py @@ -9,8 +9,8 @@ from tempfile import TemporaryDirectory from ... import __version__ -from ..artifacts import file_lock from ..storage import archive +from ..storage.artifacts import file_lock from . import adapters from .projection import iterative from .render import reports diff --git a/src/inferrsi/apps/delivery/projection.py b/src/inferrsi/apps/delivery/projection.py index 21bfd68ac..a8db9337b 100644 --- a/src/inferrsi/apps/delivery/projection.py +++ b/src/inferrsi/apps/delivery/projection.py @@ -3,7 +3,7 @@ import re from ...harness.usage import normalize_usage -from ..artifacts import digest +from ..storage.artifacts import digest from .schema import gap, number, timestamp diff --git a/src/inferrsi/apps/delivery/snapshot.py b/src/inferrsi/apps/delivery/snapshot.py index 02f728bda..22a2733c0 100644 --- a/src/inferrsi/apps/delivery/snapshot.py +++ b/src/inferrsi/apps/delivery/snapshot.py @@ -6,7 +6,7 @@ from pathlib import Path, PurePosixPath from ...harness import candidates -from ..artifacts import sha256 +from ..storage.artifacts import sha256 from .schema import decode MAX_DOCUMENT_BYTES = 8 * 1024 * 1024 diff --git a/src/inferrsi/apps/host/prepared_environment.py b/src/inferrsi/apps/host/prepared_environment.py new file mode 100644 index 000000000..d3525b4b9 --- /dev/null +++ b/src/inferrsi/apps/host/prepared_environment.py @@ -0,0 +1,33 @@ +"""Prepared-environment inspection bound to this host. + +``apps.host.inspection.inspect_environment`` is the facts API: it takes the +command probe and the repository snapshot as ports. This composition supplies the +real host probe and the Git repository identity. The facts module keeps both probes injectable. +""" + +from .commands import probe_command as _command +from .inspection import inspect_environment as _inspect_environment +from .targets import repository_identity + + +def inspect_environment( + repo: str, + repo_type: str, + backend: str, + *, + device_ids: tuple[str, ...] = (), + device_model: str | None = None, + python: str | None = None, +) -> dict: + # Both ports are read from this module on every call, so replacing + # ``_command`` or ``repository_identity`` here changes the next inspection. + return _inspect_environment( + repo, + repo_type, + backend, + device_ids=device_ids, + device_model=device_model, + python=python, + command=_command, + snapshot=repository_identity, + ) diff --git a/src/inferrsi/apps/inspection.py b/src/inferrsi/apps/inspection.py index 47a643342..d64dac46b 100644 --- a/src/inferrsi/apps/inspection.py +++ b/src/inferrsi/apps/inspection.py @@ -1,34 +1,9 @@ -"""Prepared-environment inspection bound to this host. +"""Compatibility exports for :mod:`inferrsi.apps.host.prepared_environment`.""" -``apps.host.inspection.inspect_environment`` is the facts API: it takes the -command probe and the repository snapshot as ports. This composition supplies the -real host probe and the Git repository identity. The host package imports nothing -from here. -""" +from .host.prepared_environment import ( + inspect_environment, +) -from .host.commands import probe_command as _command -from .host.inspection import inspect_environment as _inspect_environment -from .host.targets import repository_identity - - -def inspect_environment( - repo: str, - repo_type: str, - backend: str, - *, - device_ids: tuple[str, ...] = (), - device_model: str | None = None, - python: str | None = None, -) -> dict: - # Both ports are read from this module on every call, so replacing - # ``_command`` or ``repository_identity`` here changes the next inspection. - return _inspect_environment( - repo, - repo_type, - backend, - device_ids=device_ids, - device_model=device_model, - python=python, - command=_command, - snapshot=repository_identity, - ) +__all__ = [ + "inspect_environment", +] diff --git a/src/inferrsi/apps/storage/artifacts.py b/src/inferrsi/apps/storage/artifacts.py new file mode 100644 index 000000000..45abfd8aa --- /dev/null +++ b/src/inferrsi/apps/storage/artifacts.py @@ -0,0 +1,93 @@ +# Apps-owned file digests, file locks and JSON evidence writes. The function bodies equal +# those in the other cores' copies; tests/test_artifact_helper_copies.py keeps them equal. +# Apps imports no other inferrsi module here. + +import errno +import hashlib +import json +import os +import time +import uuid +from contextlib import contextmanager +from pathlib import Path + +# Windows refuses os.replace while another handle holds the destination open. +# A bounded retry covers the observed contention without hiding a real failure. +REPLACE_ATTEMPTS = 8 +REPLACE_DELAY_SECONDS = 0.05 + + +@contextmanager +def file_lock(path: Path): + """Hold a nonblocking OS file lock, released even if the process crashes.""" + with path.open("a+b") as stream: + if os.fstat(stream.fileno()).st_size == 0: + stream.write(b"0") + stream.flush() + stream.seek(0) + if os.name == "nt": + import msvcrt + + try: + msvcrt.locking(stream.fileno(), msvcrt.LK_NBLCK, 1) + except PermissionError as error: + if error.errno != errno.EACCES: + raise + # LK_NBLCK reports a lock violation as EACCES. + raise BlockingIOError(errno.EAGAIN, "File lock is held", path) from error + else: + import fcntl + + fcntl.flock(stream.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB) + try: + yield + finally: + stream.seek(0) + if os.name == "nt": + msvcrt.locking(stream.fileno(), msvcrt.LK_UNLCK, 1) + else: + fcntl.flock(stream.fileno(), fcntl.LOCK_UN) + + +def digest(value): + return hashlib.sha256( + json.dumps( + value, sort_keys=True, separators=(",", ":"), ensure_ascii=False, allow_nan=False + ).encode() + ).hexdigest() + + +def sha256(path): + hasher = hashlib.sha256() + with Path(path).open("rb") as stream: + for block in iter(lambda: stream.read(1024 * 1024), b""): + hasher.update(block) + return hasher.hexdigest() + + +def write_json(path, value): + Path(path).parent.mkdir(parents=True, exist_ok=True) + Path(path).write_text( + json.dumps(value, ensure_ascii=False, indent=2, allow_nan=False) + "\n", encoding="utf-8" + ) + + +def atomic_write_json(path: Path, value: object) -> None: + path = Path(path) + # A per-writer temporary name keeps two writers from sharing one file. + temporary = path.with_name(f"{path.name}.{os.getpid()}.{uuid.uuid4().hex[:8]}.tmp") + temporary.write_text( + json.dumps(value, ensure_ascii=False, indent=2, allow_nan=False) + "\n", encoding="utf-8" + ) + try: + for attempt in range(REPLACE_ATTEMPTS): + try: + temporary.replace(path) + return + except PermissionError: + if attempt + 1 == REPLACE_ATTEMPTS: + raise + time.sleep(REPLACE_DELAY_SECONDS) + finally: + if temporary.exists(): + temporary.unlink() diff --git a/src/inferrsi/harness/artifact_primitives.py b/src/inferrsi/harness/artifact_primitives.py index 49ba831c6..b15462a96 100644 --- a/src/inferrsi/harness/artifact_primitives.py +++ b/src/inferrsi/harness/artifact_primitives.py @@ -1,5 +1,5 @@ # Harness-owned digest, file hash and file lock. Each function body equals the one in -# inferrsi.apps.artifacts, so digests, hashes and lock files are byte-identical and the two +# inferrsi.apps.storage.artifacts, so digests, hashes and lock files are byte-identical and the two # locks exclude each other on the same path; Harness does not import that module here. # tests/test_artifact_helper_copies.py keeps the copies equal. diff --git a/src/inferrsi/harness/atomic_json.py b/src/inferrsi/harness/atomic_json.py index 788feeffd..42d3606ac 100644 --- a/src/inferrsi/harness/atomic_json.py +++ b/src/inferrsi/harness/atomic_json.py @@ -1,5 +1,5 @@ # Harness-owned atomic JSON evidence writes. The bytes equal those written by -# inferrsi.apps.artifacts.atomic_write_json; Harness does not import that module here. +# inferrsi.apps.storage.artifacts.atomic_write_json; Harness does not import that module here. import json import os diff --git a/src/inferrsi/harness/input_binding.py b/src/inferrsi/harness/input_binding.py index 7d63cea4c..9b2c0705d 100644 --- a/src/inferrsi/harness/input_binding.py +++ b/src/inferrsi/harness/input_binding.py @@ -8,8 +8,8 @@ from typing import BinaryIO # H input capture and byte-equivalent copies. H owns these digests and writes and never -# imports inferrsi.apps.artifacts. A source is read once into a snapshot; every later copy comes -# from that snapshot, never again from the mutable source. +# imports inferrsi.apps.storage.artifacts. A source is read once into a snapshot; +# every later copy comes from that snapshot, never again from the mutable source. _CHUNK = 1024 * 1024 # Schema ``Path``: relative and slash-separated; no '.'/'..' segment, backslash, colon, # or control character. diff --git a/tests/_gate_policy_support.py b/tests/_gate_policy_support.py index 045048ba6..1bf4cf6d2 100644 --- a/tests/_gate_policy_support.py +++ b/tests/_gate_policy_support.py @@ -97,7 +97,7 @@ # ``inferrsi.harness.serving`` and removed the emptied ``inferrsi.model.protocols``. # Each name covers everything below it. A file under one fails, and so does any import # that names one, even when its target is absent. -# Slices 3b, 4 and 5 moved the artifact helpers to ``inferrsi.apps.artifacts`` and the +# Slices 3b, 4 and 5 moved the artifact helpers to ``inferrsi.apps.storage.artifacts`` and the # provider modules to ``inferrsi.apps.integrations.anthropic``, and deleted both packages, # so the two package names are retired as a whole. # #558 moved ``inferrsi.harness.scenarios`` to ``inferrsi.harness.trials``, with no diff --git a/tests/check_installed.py b/tests/check_installed.py index 78eda6163..b85aa18a0 100644 --- a/tests/check_installed.py +++ b/tests/check_installed.py @@ -764,7 +764,7 @@ def _inventory(root, prefix): "evaluation": "inferrsi.apps.legacy.evaluation", "execution": "inferrsi.apps.legacy.run", "reporting": "inferrsi.apps.legacy.reporting", - "inspection": "inferrsi.apps.inspection", + "inspection": "inferrsi.apps.host.prepared_environment", } assert len(r1_retired) == 11 for retired, canonical in r1_retired.items(): @@ -811,7 +811,7 @@ def _inventory(root, prefix): assert import_module("inferrsi.apps.views.summary_chart").main.__module__ == ( "inferrsi.apps.views.summary_chart" ) -host_inspection = import_module("inferrsi.apps.inspection") +host_inspection = import_module("inferrsi.apps.host.prepared_environment") assert host_inspection._command is import_module("inferrsi.apps.host.commands").probe_command assert host_inspection.repository_identity is ( import_module("inferrsi.apps.host.targets").repository_identity @@ -981,7 +981,7 @@ def assert_not_importable(name): # #498 slice 2: the serving helpers ship only under inferrsi.harness.serving, with no # forwarder for the old Infra and Model paths. Slice 3c deleted the infra.campaign facade, # slice 3a moved the host bindings to inferrsi.apps.host, and slices 3b, 4 and 5 moved the -# artifact helpers to inferrsi.apps.artifacts and the provider modules to +# artifact helpers to inferrsi.apps.storage.artifacts and the provider modules to # inferrsi.apps.integrations.anthropic. Both packages are gone from the wheel. for retired in ("inferrsi.infra", "inferrsi.infra.artifacts", "inferrsi.infra.processes", "inferrsi.infra.http", "inferrsi.infra.campaign", "inferrsi.infra.commands", @@ -997,7 +997,7 @@ def assert_not_importable(name): "inferrsi.harness.serving.http", "inferrsi.harness.serving.image", "inferrsi.apps.host.commands", "inferrsi.apps.host.inspection", "inferrsi.apps.host.environment", "inferrsi.apps.host.platforms", - "inferrsi.apps.host.targets", "inferrsi.apps.artifacts", + "inferrsi.apps.host.targets", "inferrsi.apps.storage.artifacts", "inferrsi.apps.integrations.anthropic.anthropic_agent", "inferrsi.apps.integrations.anthropic.anthropic_edit_agent", "inferrsi.apps.integrations.anthropic.request_guard"): diff --git a/tests/fixtures/harness_improvement_demo.py b/tests/fixtures/harness_improvement_demo.py index 152e8115f..7633bd0d5 100644 --- a/tests/fixtures/harness_improvement_demo.py +++ b/tests/fixtures/harness_improvement_demo.py @@ -7,7 +7,7 @@ import tempfile from pathlib import Path -from inferrsi.apps.artifacts import write_json +from inferrsi.apps.storage.artifacts import write_json from tests.fixtures.skill_eval_compare_support import DATA, ROOT, source_repo from tools import skill_eval_compare as compare from tools import skill_eval_improve as improve diff --git a/tests/fixtures/skill_eval_compare_support.py b/tests/fixtures/skill_eval_compare_support.py index fb2add4d4..723a792d9 100644 --- a/tests/fixtures/skill_eval_compare_support.py +++ b/tests/fixtures/skill_eval_compare_support.py @@ -4,7 +4,7 @@ import sys from pathlib import Path -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json ROOT = Path(__file__).resolve().parents[2] DATA = json.loads((ROOT / "tests/fixtures/skill_eval_grading.json").read_text(encoding="utf-8")) diff --git a/tests/fixtures/skill_eval_pr_support.py b/tests/fixtures/skill_eval_pr_support.py index f6572ae70..8d344e7e2 100644 --- a/tests/fixtures/skill_eval_pr_support.py +++ b/tests/fixtures/skill_eval_pr_support.py @@ -3,7 +3,7 @@ import zipfile from urllib.parse import parse_qs, urlsplit -from inferrsi.apps.artifacts import write_json +from inferrsi.apps.storage.artifacts import write_json from tests.fixtures.skill_eval_compare_support import configuration, git from tools import skill_eval_compare as compare from tools import skill_eval_pr as integration diff --git a/tests/session_lock_probe.py b/tests/session_lock_probe.py index d8175213b..0e3f179cb 100644 --- a/tests/session_lock_probe.py +++ b/tests/session_lock_probe.py @@ -19,7 +19,7 @@ import inferrsi from inferrsi.apps import delivery -from inferrsi.apps.artifacts import atomic_write_json, sha256 +from inferrsi.apps.storage.artifacts import atomic_write_json, sha256 from inferrsi.harness import optimization # The child runs with -I and imports inferrsi from the same location as this process. diff --git a/tests/test_anthropic_agent.py b/tests/test_anthropic_agent.py index 35ae87df3..a8a1acc35 100644 --- a/tests/test_anthropic_agent.py +++ b/tests/test_anthropic_agent.py @@ -6,8 +6,8 @@ import pytest -from inferrsi.apps.artifacts import sha256, write_json from inferrsi.apps.integrations.anthropic import anthropic_agent as agent +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows import skill_evaluation as evaluation from inferrsi.harness import skill_evaluation as harness from tests.fixtures.skill_eval_compare_support import configuration diff --git a/tests/test_architecture_closed_loop.py b/tests/test_architecture_closed_loop.py index 682f9d464..3506b3766 100644 --- a/tests/test_architecture_closed_loop.py +++ b/tests/test_architecture_closed_loop.py @@ -429,8 +429,8 @@ def test_seam_guard_exempts_only_the_two_exact_seams(self) -> None: ("import inferrsi.knowledge.knowledge_operations_v2\n", "inferrsi.knowledge.knowledge_operations_v2"), # Another Apps or Knowledge module that is no seam of this assembler. - ("from inferrsi.apps.inspection import inspect_environment\n", - "inferrsi.apps.inspection"), + ("from inferrsi.apps.host.prepared_environment import inspect_environment\n", + "inferrsi.apps.host.prepared_environment"), ("from inferrsi.apps.api import read_attempt_view\n", "inferrsi.apps.api"), ("from inferrsi.knowledge.skill_catalog import get_skill\n", "inferrsi.knowledge.skill_catalog"), diff --git a/tests/test_artifact_helper_copies.py b/tests/test_artifact_helper_copies.py index c8841f06a..fc2580975 100644 --- a/tests/test_artifact_helper_copies.py +++ b/tests/test_artifact_helper_copies.py @@ -19,13 +19,13 @@ # Each helper name and the modules that hold a copy. #498 slice 3b added the Apps copy # and slice 5 deleted the Infra one, so Harness, Benchmark and Apps hold the three. COPIES = { - "sha256": ("inferrsi.apps.artifacts", "inferrsi.harness.artifact_primitives", + "sha256": ("inferrsi.apps.storage.artifacts", "inferrsi.harness.artifact_primitives", "inferrsi.benchmark.artifacts"), - "write_json": ("inferrsi.apps.artifacts", "inferrsi.benchmark.artifacts"), - "atomic_write_json": ("inferrsi.apps.artifacts", "inferrsi.harness.atomic_json", + "write_json": ("inferrsi.apps.storage.artifacts", "inferrsi.benchmark.artifacts"), + "atomic_write_json": ("inferrsi.apps.storage.artifacts", "inferrsi.harness.atomic_json", "inferrsi.benchmark.artifacts"), - "digest": ("inferrsi.apps.artifacts", "inferrsi.harness.artifact_primitives"), - "file_lock": ("inferrsi.apps.artifacts", "inferrsi.harness.artifact_primitives"), + "digest": ("inferrsi.apps.storage.artifacts", "inferrsi.harness.artifact_primitives"), + "file_lock": ("inferrsi.apps.storage.artifacts", "inferrsi.harness.artifact_primitives"), } CONSTANTS = ("REPLACE_ATTEMPTS", "REPLACE_DELAY_SECONDS") VALUE = {"b": [1.5, None, True, 1e-07, 1e16], "a": "非 ASCII", "nested": {"z": 0.1 + 0.2}} diff --git a/tests/test_first_wave_isolation_policy.py b/tests/test_first_wave_isolation_policy.py index f22a710f0..7444a99fb 100644 --- a/tests/test_first_wave_isolation_policy.py +++ b/tests/test_first_wave_isolation_policy.py @@ -421,7 +421,8 @@ def test_another_importer_fails(self) -> None: paths = ( "infra/other.py", "infra/inspection_helpers.py", "infra/__init__.py", "infra/platforms/__init__.py", "harness/api.py", "harness/runner.py", - "benchmark/probe.py", "apps/main.py", "apps/inspection.py", "model/probe.py", + "benchmark/probe.py", "apps/main.py", "apps/inspection.py", + "apps/host/prepared_environment.py", "model/probe.py", "cli.py", "arguments.py", "apps/cli/__init__.py", "apps/cli/arguments.py", "benchmark_operations.py", "apps/benchmark_operations.py", "summary_chart.py", "apps/views/summary_chart.py", "mindie_project.py", "apps/mindie/project.py", diff --git a/tests/test_goal_checkpoint.py b/tests/test_goal_checkpoint.py index ff844df8c..219614eac 100644 --- a/tests/test_goal_checkpoint.py +++ b/tests/test_goal_checkpoint.py @@ -5,7 +5,7 @@ import pytest -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from tests.fixtures.skill_eval_compare_support import FixedOutputClient, configuration from tools import goal_checkpoint as checkpoint from tools import skill_eval_compare as compare diff --git a/tests/test_image_modules.py b/tests/test_image_modules.py index a378bf129..81a5b3557 100644 --- a/tests/test_image_modules.py +++ b/tests/test_image_modules.py @@ -7,7 +7,7 @@ import pytest -from inferrsi.apps.artifacts import sha256 +from inferrsi.apps.storage.artifacts import sha256 from inferrsi.benchmark.sampling import collect_samples from inferrsi.benchmark.validators.image import ImageQualityGate, compare_images from inferrsi.harness.serving.image import ImageProtocol diff --git a/tests/test_inspection.py b/tests/test_inspection.py index 76004ee74..2bff24fd0 100644 --- a/tests/test_inspection.py +++ b/tests/test_inspection.py @@ -15,12 +15,12 @@ import pytest -from inferrsi.apps import inspection as host_inspection -from inferrsi.apps.artifacts import atomic_write_json from inferrsi.apps.host import commands, targets from inferrsi.apps.host import inspection as facts -from inferrsi.apps.inspection import inspect_environment +from inferrsi.apps.host import prepared_environment as host_inspection +from inferrsi.apps.host.prepared_environment import inspect_environment from inferrsi.apps.legacy.reporting import write_report +from inferrsi.apps.storage.artifacts import atomic_write_json ROCM_INFO = ( "=====================\n" @@ -68,10 +68,10 @@ def command(argv): with ( patch( - "inferrsi.apps.inspection.repository_identity", + "inferrsi.apps.host.prepared_environment.repository_identity", return_value={"available": True, "head": "test"}, ), - patch("inferrsi.apps.inspection._command", side_effect=command), + patch("inferrsi.apps.host.prepared_environment._command", side_effect=command), ): return inspect_environment(".", "vllm_omni", "cuda", device_ids=ids, device_model=model) @@ -103,10 +103,10 @@ def command(argv): with ( patch( - "inferrsi.apps.inspection.repository_identity", + "inferrsi.apps.host.prepared_environment.repository_identity", return_value={"available": True, "head": "test"}, ), - patch("inferrsi.apps.inspection._command", side_effect=command), + patch("inferrsi.apps.host.prepared_environment._command", side_effect=command), ): return inspect_environment( ".", "vllm_omni", backend, device_ids=ids, device_model=model @@ -242,7 +242,7 @@ def test_canonical_binding_is_the_real_host_probe_and_git_identity(): assert host_inspection._command is commands.probe_command assert host_inspection.repository_identity is targets.repository_identity assert host_inspection._inspect_environment is facts.inspect_environment - assert inspect_environment.__module__ == "inferrsi.apps.inspection" + assert inspect_environment.__module__ == "inferrsi.apps.host.prepared_environment" assert str(inspect.signature(inspect_environment)) == ( "(repo: str, repo_type: str, backend: str, *, device_ids: tuple[str, ...] = (), " "device_model: str | None = None, python: str | None = None) -> dict" @@ -342,7 +342,7 @@ def test_retired_root_inspection_is_gone_and_host_facts_load_no_core(): "assert not apps, apps\n" # The retired root binding reached the snapshot through the old run. The # canonical one loads no Benchmark module and no old-run composition. - "import inferrsi.apps.inspection\n" + "import inferrsi.apps.host.prepared_environment\n" "old_run = ('inferrsi.benchmark', 'inferrsi.apps.legacy', 'inferrsi.execution')\n" "loaded = [name for name in sys.modules if name.startswith(old_run)]\n" "assert not loaded, loaded\n" diff --git a/tests/test_legacy_run_split.py b/tests/test_legacy_run_split.py index d3dbd7466..0fe8ac2e7 100644 --- a/tests/test_legacy_run_split.py +++ b/tests/test_legacy_run_split.py @@ -13,11 +13,11 @@ import pytest -from inferrsi.apps import artifacts from inferrsi.apps.host import targets from inferrsi.apps.legacy import evaluation as legacy_evaluation from inferrsi.apps.legacy import reporting as legacy_reporting from inferrsi.apps.legacy import run as legacy_run +from inferrsi.apps.storage import artifacts from inferrsi.benchmark import legacy_run_v0, metrics, sampling from inferrsi.contracts import RunSpec, claim from inferrsi.harness import atomic_json diff --git a/tests/test_project_service_reuse.py b/tests/test_project_service_reuse.py index 6f40dc38d..67e7cfa08 100644 --- a/tests/test_project_service_reuse.py +++ b/tests/test_project_service_reuse.py @@ -10,9 +10,9 @@ import pytest -from inferrsi.apps import artifacts from inferrsi.apps.cli import main from inferrsi.apps.cli.arguments import parser +from inferrsi.apps.storage import artifacts from inferrsi.harness import artifact_primitives, optimization, project_service from inferrsi.harness.records import evidence, knowledge_capture from inferrsi.knowledge import knowledge_operations diff --git a/tests/test_result_delivery.py b/tests/test_result_delivery.py index 1b92fbbeb..07777b835 100644 --- a/tests/test_result_delivery.py +++ b/tests/test_result_delivery.py @@ -6,12 +6,12 @@ import pytest from inferrsi.apps import delivery -from inferrsi.apps.artifacts import atomic_write_json, sha256 from inferrsi.apps.cli import main from inferrsi.apps.delivery.projection import metric from inferrsi.apps.delivery.schema import decode, validate_result from inferrsi.apps.delivery.snapshot import MAX_DOCUMENT_BYTES, Snapshot from inferrsi.apps.storage import archive +from inferrsi.apps.storage.artifacts import atomic_write_json, sha256 from inferrsi.apps.storage.result import preparation_result from inferrsi.harness import optimization from tests.diagnosis_support import diagnosis_evidence diff --git a/tests/test_session_lock_across_processes.py b/tests/test_session_lock_across_processes.py index 28e2554f1..32084315c 100644 --- a/tests/test_session_lock_across_processes.py +++ b/tests/test_session_lock_across_processes.py @@ -35,7 +35,7 @@ if side == "harness": from inferrsi.harness.artifact_primitives import file_lock else: - from inferrsi.apps.artifacts import file_lock + from inferrsi.apps.storage.artifacts import file_lock with file_lock(lock): ready.write_text("held", encoding="utf-8") deadline = time.monotonic() + 60 @@ -54,7 +54,7 @@ if side == "harness": from inferrsi.harness.artifact_primitives import file_lock else: - from inferrsi.apps.artifacts import file_lock + from inferrsi.apps.storage.artifacts import file_lock try: with file_lock(lock): outcome = {"acquired": True} diff --git a/tests/test_skill_eval_compare.py b/tests/test_skill_eval_compare.py index d6f73df64..ca15e3090 100644 --- a/tests/test_skill_eval_compare.py +++ b/tests/test_skill_eval_compare.py @@ -9,7 +9,7 @@ import pytest -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.knowledge.knowledge_operations import KnowledgeReader, RevisionConflict from tests.fixtures.skill_eval_compare_support import ( DATA, @@ -1010,7 +1010,7 @@ def test_changed_runtime_controllers_reject_execution_and_report_without_calls(t module.report(output) saved = (output / "report.json").read_bytes(), (output / "report.md").read_bytes() assert "src/inferrsi/harness/local_process.py" in module.CONTROLLERS - assert "src/inferrsi/apps/artifacts.py" in module.CONTROLLERS + assert "src/inferrsi/apps/storage/artifacts.py" in module.CONTROLLERS assert "src/inferrsi/apps/integrations/anthropic/request_guard.py" in module.CONTROLLERS assert "tools/skill_eval_artifact_guidance.py" in module.CONTROLLERS # Each owner of the split trial path is frozen: composed entry, rules and host. diff --git a/tests/test_skill_eval_diagnostic.py b/tests/test_skill_eval_diagnostic.py index 44734ebfc..bffd5ee3b 100644 --- a/tests/test_skill_eval_diagnostic.py +++ b/tests/test_skill_eval_diagnostic.py @@ -7,7 +7,7 @@ import unittest from pathlib import Path -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.benchmark import skill_eval_diagnostic as diagnostic from tests.fixtures.skill_eval_compare_support import FixedOutputClient, configuration, git from tools import skill_eval_compare as compare diff --git a/tests/test_skill_eval_feedback.py b/tests/test_skill_eval_feedback.py index fa5a07d07..2d1cb551b 100644 --- a/tests/test_skill_eval_feedback.py +++ b/tests/test_skill_eval_feedback.py @@ -6,7 +6,7 @@ from pathlib import Path from unittest.mock import Mock, patch -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.benchmark import skill_eval_diagnostic as diagnostic from tests.fixtures.skill_eval_compare_support import FixedOutputClient from tests.fixtures.skill_eval_pr_support import approval, setup diff --git a/tests/test_skill_eval_generation.py b/tests/test_skill_eval_generation.py index 3e5200631..e68606b57 100644 --- a/tests/test_skill_eval_generation.py +++ b/tests/test_skill_eval_generation.py @@ -6,8 +6,8 @@ import pytest -from inferrsi.apps.artifacts import sha256, write_json from inferrsi.apps.integrations.anthropic import anthropic_agent as agent +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.apps.workflows import skill_evaluation as evaluation from inferrsi.benchmark import skill_eval_engineering as engineering diff --git a/tests/test_skill_eval_historical_job.py b/tests/test_skill_eval_historical_job.py index 1a06c5a15..1658f3e22 100644 --- a/tests/test_skill_eval_historical_job.py +++ b/tests/test_skill_eval_historical_job.py @@ -8,7 +8,7 @@ import pytest import yaml -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from tools import skill_eval_historical_job as job diff --git a/tests/test_skill_eval_local.py b/tests/test_skill_eval_local.py index 7f64fd873..a68049bb8 100644 --- a/tests/test_skill_eval_local.py +++ b/tests/test_skill_eval_local.py @@ -3,7 +3,7 @@ import pytest -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.benchmark import skill_eval_engineering as engineering from inferrsi.harness import artifact_sandbox as sandbox diff --git a/tests/test_skill_eval_local_cli.py b/tests/test_skill_eval_local_cli.py index a0366c8c5..3b339a234 100644 --- a/tests/test_skill_eval_local_cli.py +++ b/tests/test_skill_eval_local_cli.py @@ -11,7 +11,7 @@ import pytest -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.benchmark import skill_eval_engineering as engineering from inferrsi.harness import artifact_sandbox as sandbox diff --git a/tests/test_skill_eval_pipeline.py b/tests/test_skill_eval_pipeline.py index 995c627c1..69ca04c37 100644 --- a/tests/test_skill_eval_pipeline.py +++ b/tests/test_skill_eval_pipeline.py @@ -8,7 +8,7 @@ import pytest -from inferrsi.apps.artifacts import atomic_write_json, sha256 +from inferrsi.apps.storage.artifacts import atomic_write_json, sha256 from inferrsi.apps.workflows.skill_evaluation import run_trial, summarize from tools import skill_eval_pilot diff --git a/tests/test_skill_eval_planned_guidance.py b/tests/test_skill_eval_planned_guidance.py index c0973307f..3e999960a 100644 --- a/tests/test_skill_eval_planned_guidance.py +++ b/tests/test_skill_eval_planned_guidance.py @@ -8,7 +8,7 @@ import pytest -from inferrsi.apps.artifacts import write_json +from inferrsi.apps.storage.artifacts import write_json from tests.fixtures.skill_eval_compare_support import git from tests.fixtures.skill_eval_pr_support import setup from tests.test_skill_eval_pr_summary import visible diff --git a/tests/test_skill_eval_planning_boundaries.py b/tests/test_skill_eval_planning_boundaries.py index 50f8905a0..22e7a172a 100644 --- a/tests/test_skill_eval_planning_boundaries.py +++ b/tests/test_skill_eval_planning_boundaries.py @@ -7,7 +7,7 @@ import pytest -from inferrsi.apps.artifacts import write_json +from inferrsi.apps.storage.artifacts import write_json from tests.fixtures.skill_eval_compare_support import git from tests.fixtures.skill_eval_pr_support import SimulatedGitHub, setup from tests.test_skill_eval_pr import dispatch_event diff --git a/tests/test_skill_eval_pr.py b/tests/test_skill_eval_pr.py index a9a6b8c98..5e505bf0b 100644 --- a/tests/test_skill_eval_pr.py +++ b/tests/test_skill_eval_pr.py @@ -11,7 +11,7 @@ import pytest import yaml -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from tests.fixtures.skill_eval_compare_support import ROOT, FixedOutputClient, git from tests.fixtures.skill_eval_pr_support import ( SimulatedGitHub, diff --git a/tests/test_skill_eval_pr_diagnostic.py b/tests/test_skill_eval_pr_diagnostic.py index ed72ba2d9..bfdacecb5 100644 --- a/tests/test_skill_eval_pr_diagnostic.py +++ b/tests/test_skill_eval_pr_diagnostic.py @@ -3,7 +3,7 @@ import unittest from pathlib import Path -from inferrsi.apps.artifacts import write_json +from inferrsi.apps.storage.artifacts import write_json from inferrsi.benchmark import skill_eval_diagnostic as diagnostic from tests.fixtures.skill_eval_compare_support import FixedOutputClient from tests.fixtures.skill_eval_pr_support import setup diff --git a/tests/test_skill_eval_retention.py b/tests/test_skill_eval_retention.py index 2dd4840ab..fa0d57aeb 100644 --- a/tests/test_skill_eval_retention.py +++ b/tests/test_skill_eval_retention.py @@ -5,7 +5,7 @@ import pytest -from inferrsi.apps.artifacts import write_json +from inferrsi.apps.storage.artifacts import write_json from tests import test_skill_eval_auto as auto_tests from tests.fixtures.skill_eval_compare_support import FixedOutputClient from tests.fixtures.skill_eval_pr_support import SimulatedGitHub, approval, setup diff --git a/tests/test_skill_eval_review_guidance.py b/tests/test_skill_eval_review_guidance.py index c1e16b530..5fc655d8d 100644 --- a/tests/test_skill_eval_review_guidance.py +++ b/tests/test_skill_eval_review_guidance.py @@ -5,7 +5,7 @@ import pytest -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from tests.fixtures.skill_eval_compare_support import FixedOutputClient from tests.fixtures.skill_eval_pr_support import SimulatedGitHub, approval, setup from tools import skill_eval_pr as integration diff --git a/tests/test_skill_evaluation.py b/tests/test_skill_evaluation.py index 501a8d287..b9922fdd9 100644 --- a/tests/test_skill_evaluation.py +++ b/tests/test_skill_evaluation.py @@ -299,7 +299,7 @@ def verdict(execution, trace, output, checks): def test_harness_owned_writes_and_digests_match_apps_bytes(tmp_path): - from inferrsi.apps import artifacts + from inferrsi.apps.storage import artifacts from inferrsi.harness import atomic_json, input_binding value = {"b": [1.5, None, True, 1e-07, 1e16], "a": "非 ASCII", "nested": {"z": 0.1 + 0.2}} @@ -321,7 +321,7 @@ def test_harness_artifact_primitives_match_apps_bytes_and_semantics(tmp_path): import ast import inspect - from inferrsi.apps import artifacts as infra + from inferrsi.apps.storage import artifacts as infra from inferrsi.harness import artifact_primitives as harness for name in ("digest", "sha256", "file_lock"): diff --git a/tests/test_target_module_import_gate.py b/tests/test_target_module_import_gate.py index 6b7d4ae55..acfa3efff 100644 --- a/tests/test_target_module_import_gate.py +++ b/tests/test_target_module_import_gate.py @@ -246,12 +246,12 @@ def test_the_modules_that_replaced_the_retired_packages_are_not_retired(tmp_path # #498 retired the whole Infra and Model packages. Every module that took over from # them must stay importable by name under the new owner. report = _report(tmp_path, { - "apps/artifacts.py": "VALUE = 1\n", + "apps/storage/artifacts.py": "VALUE = 1\n", "apps/integrations/__init__.py": "", "apps/integrations/anthropic/__init__.py": "", "apps/integrations/anthropic/request_guard.py": "VALUE = 1\n", "apps/runner.py": ( - "from inferrsi.apps.artifacts import sha256\n" + "from inferrsi.apps.storage.artifacts import sha256\n" "from inferrsi.apps.integrations.anthropic import request_guard\n" ), "harness/runner.py": ( @@ -329,7 +329,7 @@ def test_clean_scan_is_not_isolation(self) -> None: name = module.removeprefix("inferrsi.") self.assertFalse((ROOT / f"{name}.py").exists(), name) self.assertFalse((ROOT / name).exists(), name) - self.assertTrue((ROOT / "apps" / "inspection.py").is_file()) + self.assertTrue((ROOT / "apps" / "host" / "prepared_environment.py").is_file()) self.assertEqual( support.CONTRACTS_MODULES, { diff --git a/tests/test_yibuapi_runtime.py b/tests/test_yibuapi_runtime.py index c23f10234..2c555632b 100644 --- a/tests/test_yibuapi_runtime.py +++ b/tests/test_yibuapi_runtime.py @@ -7,8 +7,8 @@ import pytest import yaml -from inferrsi.apps.artifacts import write_json from inferrsi.apps.integrations.anthropic import anthropic_agent as agent +from inferrsi.apps.storage.artifacts import write_json from inferrsi.harness import skill_evaluation as harness from tests.fixtures.skill_eval_compare_support import DATA from tests.fixtures.skill_eval_pr_support import SimulatedGitHub, approval, setup diff --git a/tools/goal_checkpoint.py b/tools/goal_checkpoint.py index ca673dbbe..8c3a0ffc9 100644 --- a/tools/goal_checkpoint.py +++ b/tools/goal_checkpoint.py @@ -8,7 +8,7 @@ from pathlib import Path from typing import Literal -from inferrsi.apps.artifacts import digest, sha256 +from inferrsi.apps.storage.artifacts import digest, sha256 from tools.skill_eval_compare import CONTROLLERS, ROLES, ROOT, read_report Action = Literal[ diff --git a/tools/skill_eval_auto.py b/tools/skill_eval_auto.py index 3b6508046..ca6581b5f 100644 --- a/tools/skill_eval_auto.py +++ b/tools/skill_eval_auto.py @@ -11,7 +11,7 @@ from pathlib import Path from urllib.parse import quote -from inferrsi.apps.artifacts import write_json +from inferrsi.apps.storage.artifacts import write_json from tools import skill_eval_pr as pr from tools.skill_eval_budget import ( Binding, diff --git a/tools/skill_eval_cloud_export.py b/tools/skill_eval_cloud_export.py index 176551d85..c4a605a78 100644 --- a/tools/skill_eval_cloud_export.py +++ b/tools/skill_eval_cloud_export.py @@ -4,7 +4,7 @@ import json from pathlib import Path -from inferrsi.apps.artifacts import sha256 +from inferrsi.apps.storage.artifacts import sha256 from inferrsi.benchmark import skill_eval_engineering as engineering from inferrsi.harness import artifact_sandbox from tools import skill_eval_compare as compare diff --git a/tools/skill_eval_compare.py b/tools/skill_eval_compare.py index d622ce0a4..8530dfc7b 100644 --- a/tools/skill_eval_compare.py +++ b/tools/skill_eval_compare.py @@ -12,7 +12,6 @@ from dataclasses import replace from pathlib import Path -from inferrsi.apps.artifacts import atomic_write_json, sha256, write_json from inferrsi.apps.integrations.anthropic.anthropic_agent import ( FULL_CONTEXT_KIND, AnthropicAgentClient, @@ -21,6 +20,7 @@ ) from inferrsi.apps.integrations.anthropic.anthropic_agent import SOURCE as AGENT_SOURCE from inferrsi.apps.integrations.anthropic.request_guard import SOURCE as GUARD_SOURCE +from inferrsi.apps.storage.artifacts import atomic_write_json, sha256, write_json from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.apps.workflows.skill_evaluation import export_bundle, run_trial, summarize from inferrsi.benchmark import skill_eval_diagnostic as diagnostic @@ -47,7 +47,7 @@ "src/inferrsi/harness/skill_evaluation.py", "src/inferrsi/harness/artifact_sandbox.py", "tools/skill_eval_snapshot.py", "src/inferrsi/harness/local_process.py", "src/inferrsi/harness/atomic_json.py", - "src/inferrsi/harness/input_binding.py", "src/inferrsi/apps/artifacts.py") + "src/inferrsi/harness/input_binding.py", "src/inferrsi/apps/storage/artifacts.py") EVIDENCE = ("execution.json", "agent/stdout.log", "agent/stderr.log", "verification/result.json", "verification/stdout.log", "verification/stderr.log") NUMBER = (int, float) diff --git a/tools/skill_eval_historical_job.py b/tools/skill_eval_historical_job.py index 6ca33d0a8..57b73056b 100644 --- a/tools/skill_eval_historical_job.py +++ b/tools/skill_eval_historical_job.py @@ -11,7 +11,7 @@ import urllib.request from pathlib import Path -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.benchmark import skill_eval_engineering as engineering from inferrsi.harness import artifact_sandbox from tools import skill_eval_auto as auto diff --git a/tools/skill_eval_improve.py b/tools/skill_eval_improve.py index eddc999bf..d6a858459 100644 --- a/tools/skill_eval_improve.py +++ b/tools/skill_eval_improve.py @@ -12,7 +12,7 @@ import time from pathlib import Path -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows.improvement import ( assessment, choose, diff --git a/tools/skill_eval_local.py b/tools/skill_eval_local.py index 8a5a74a4a..dce023d33 100644 --- a/tools/skill_eval_local.py +++ b/tools/skill_eval_local.py @@ -12,7 +12,7 @@ import stat from pathlib import Path -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows import skill_eval_engineering as artifact_check from inferrsi.benchmark import skill_eval_engineering as engineering from inferrsi.harness import artifact_sandbox diff --git a/tools/skill_eval_pilot.py b/tools/skill_eval_pilot.py index 844b96cd4..a1aefa3fb 100644 --- a/tools/skill_eval_pilot.py +++ b/tools/skill_eval_pilot.py @@ -7,7 +7,7 @@ import time from pathlib import Path -from inferrsi.apps.artifacts import sha256, write_json +from inferrsi.apps.storage.artifacts import sha256, write_json from inferrsi.apps.workflows.skill_evaluation import export_bundle, run_trial, summarize from inferrsi.harness.skill_evaluation import CodexClient from inferrsi.harness.usage import normalize_usage diff --git a/tools/skill_eval_pr.py b/tools/skill_eval_pr.py index 31ce3be21..628321fcb 100644 --- a/tools/skill_eval_pr.py +++ b/tools/skill_eval_pr.py @@ -14,8 +14,8 @@ from pathlib import Path, PurePosixPath from urllib.error import HTTPError -from inferrsi.apps.artifacts import sha256, write_json from inferrsi.apps.integrations.anthropic.anthropic_agent import money, reservation +from inferrsi.apps.storage.artifacts import sha256, write_json from tools import skill_eval_compare as compare from tools.check_knowledge_model_policy import GitHubHTTPError from tools.skill_eval_feedback import ( From 75cc8a88a736db2c97b6e526bacab202d5c07e56 Mon Sep 17 00:00:00 2001 From: Zeng Chuang Date: Wed, 25 Nov 2026 00:47:11 +0800 Subject: [PATCH 2/4] Document frozen SkillEval controller recovery Agent-assisted-by: Codex / gpt-5.6-sol [effort=unknown] (author) Signed-off-by: zengchuang --- docs/local-skill-evaluation.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/local-skill-evaluation.md b/docs/local-skill-evaluation.md index b07936cca..4bb2bf3a0 100644 --- a/docs/local-skill-evaluation.md +++ b/docs/local-skill-evaluation.md @@ -75,6 +75,10 @@ python tools/skill_eval_compare.py prepare --repo /path/to/repo \ Keep the returned frozen-plan SHA externally with the acceptance record. This freezes task, schema, starter, verifier/controllers and both selected bundles. +Every later operation on that plan, including `report`, must use its original +checkout and controller revision. When an upgrade moves or changes a controller, +reopen retained results with the original wheel or checkout recorded by the plan; +do not substitute the current controller or bypass `plan/freeze.json` verification. Before any real agent call separately establish trustworthy **whole-run cost bounds**, model identity, tool access, isolated environment, run order/repeats, timeout and treatment of failed/retried attempts. A plan hash is not permission From f4f2c8b70791c37c38f2635d2185bd0de1114870 Mon Sep 17 00:00:00 2001 From: Zeng Chuang Date: Wed, 25 Nov 2026 11:49:21 +0800 Subject: [PATCH 3/4] Use the canonical file helpers in the Qwen contract rejection test Register the campaign test that imports the storage helpers so a test requiring Torch keeps working after the Apps transition. Agent-assisted-by: Codex (implementation and verification) Signed-off-by: zengchuang --- docs/apps-module-migrations.json | 1 + tests/campaigns/test_qwen21_task.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/apps-module-migrations.json b/docs/apps-module-migrations.json index 119fe4679..0b419c817 100644 --- a/docs/apps-module-migrations.json +++ b/docs/apps-module-migrations.json @@ -558,6 +558,7 @@ "tests/apps/test_result_delivery.py", "tests/apps/test_yibuapi_runtime.py", "tests/benchmark/test_image_modules.py", + "tests/campaigns/test_qwen21_task.py", "tests/check_installed.py", "tests/fixtures/harness_improvement_demo.py", "tests/fixtures/service_reuse.py", diff --git a/tests/campaigns/test_qwen21_task.py b/tests/campaigns/test_qwen21_task.py index 0863c44f0..31ccc35bb 100644 --- a/tests/campaigns/test_qwen21_task.py +++ b/tests/campaigns/test_qwen21_task.py @@ -982,7 +982,7 @@ def test_candidate_cannot_change_the_recorded_case_configuration(tmp_path): def test_harness_continues_only_after_attributed_contract_rejection(tmp_path, failure): """Round 1 is the real CPU worker and Qwen assessor; later rows are synthetic stand-ins.""" pytest.importorskip("torch") - from inferrsi.apps.artifacts import atomic_write_json, sha256 + from inferrsi.apps.storage.artifacts import atomic_write_json, sha256 from inferrsi.harness import optimization from tests.diagnosis_support import diagnosis_evidence From e8a76ef4e56735b555bd8b64a2a901ca90b83206 Mon Sep 17 00:00:00 2001 From: Zeng Chuang Date: Wed, 25 Nov 2026 12:12:29 +0800 Subject: [PATCH 4/4] Keep the protocol identity test isolated from task evolution Freeze the current packaged task hashes in the test fixture before corrupting optimization.py, so the validator still proves it rejects that deliberate identity change before loading the protocol. Agent-assisted-by: Codex (implementation and verification) Signed-off-by: zengchuang --- tests/campaigns/test_qwen_gvo_diagnostic.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/campaigns/test_qwen_gvo_diagnostic.py b/tests/campaigns/test_qwen_gvo_diagnostic.py index d7765305d..30c968b35 100644 --- a/tests/campaigns/test_qwen_gvo_diagnostic.py +++ b/tests/campaigns/test_qwen_gvo_diagnostic.py @@ -58,7 +58,15 @@ def test_protocol_identity_checked_before_loading(tmp_path, monkeypatch): checker = module("validator/check.py") task = tmp_path / "task" shutil.copytree(task_resources("qwen21-denoise-npu"), task) + plan = tmp_path / "plan" + shutil.copytree(checker.PLAN, plan) + spec = json.loads((plan / "runspec.json").read_text()) + spec["packaged_task_sha256"] = { + name: checker.sha(task / name) for name in spec["packaged_task_sha256"] + } + (plan / "runspec.json").write_text(json.dumps(spec)) (task / "optimization.py").write_text("this is deliberately invalid Python source.") + monkeypatch.setattr(checker, "PLAN", plan) monkeypatch.setattr(checker, "task_resources", lambda _: task) with pytest.raises(ValueError, match="optimization.py"): checker.main(tmp_path / "trial", tmp_path / "failed")