From e99ca4bf5965fa097de108f77fcd88b6ccd632d1 Mon Sep 17 00:00:00 2001 From: GUOGUO Date: Tue, 17 Nov 2026 12:28:29 +0800 Subject: [PATCH 1/4] refactor(harness): close the artifact-primitive edges from six Harness modules into Infra (R2) agent_sessions, candidates, optimization, optimization_session, project and task_protocol take digest, sha256 and file_lock from the new harness/artifact_primitives.py and atomic_write_json from the existing harness/atomic_json.py. The function bodies equal those in infra/artifacts.py, so digests, hashes, JSON bytes, atomic replace and lock semantics are unchanged; infra/artifacts.py stays for its other users. first_wave_report() no longer reports the 12 harness -> model/infra hits. The only remaining blocker is the five runtime resource loaders (R3). Refs #412 Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author) Signed-off-by: GUOGUO --- CHANGELOG.md | 17 +++++++ docs/module-layout.md | 16 ++++-- src/inferrsi/harness/agent_sessions.py | 3 +- src/inferrsi/harness/artifact_primitives.py | 51 ++++++++++++++++++++ src/inferrsi/harness/candidates.py | 2 +- src/inferrsi/harness/optimization.py | 3 +- src/inferrsi/harness/optimization_session.py | 8 +-- src/inferrsi/harness/project.py | 2 +- src/inferrsi/harness/task_protocol.py | 2 +- tests/test_first_wave_isolation_policy.py | 38 +++++++++++++++ tests/test_skill_evaluation.py | 38 +++++++++++++++ tests/test_target_module_import_gate.py | 16 ++---- 12 files changed, 171 insertions(+), 25 deletions(-) create mode 100644 src/inferrsi/harness/artifact_primitives.py diff --git a/CHANGELOG.md b/CHANGELOG.md index ec44465ed..b14fedd4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ ### Changed +- Six Harness modules stop importing Infra (Refs #412, R2). `agent_sessions`, + `candidates`, `optimization`, `optimization_session`, `project` and + `task_protocol` take `digest`, `sha256` and `file_lock` from the new + `harness/artifact_primitives.py` and `atomic_write_json` from the existing + `harness/atomic_json.py`. The function bodies equal those in + `infra/artifacts.py`, so digests, file hashes, JSON bytes, atomic replace and + lock files are unchanged, and a Harness lock and an Infra lock on the same + path still exclude each other. `infra/artifacts.py` stays for its other users. + - `first_wave_report()` no longer reports `harness reaches model/infra`; it had + 12 hits, the package-level `inferrsi.infra` and `inferrsi.infra.artifacts` + edge from each of the six modules. Harness has no `inferrsi.model` edge. + - The optimization session's runtime identity adds + `harness/artifact_primitives.py`. The six edited modules are already in it, + so a session started before this change does not resume after it. + - Isolation is still incomplete: the five runtime resource loaders (R3, #412) + remain. + - The campaign chart renderer and the single-task launcher move into the Apps package and the two root modules are removed (Refs #408, A2), with no forwarding shell, `sys.modules` alias or import fallback. Both files move diff --git a/docs/module-layout.md b/docs/module-layout.md index 28ddfcbf2..7452d49f1 100644 --- a/docs/module-layout.md +++ b/docs/module-layout.md @@ -225,17 +225,23 @@ present; or the scan reports a violation. The three packages may appear in stage A clean graph for the new cores is reported separately as "new core business closure isolated" and never sets overall `isolation_complete` to true. -On the tree after A1 (#408), `first_wave_report()` has no violation and two -blockers, so `isolation_complete` is false and A1 does not claim otherwise: +On the tree after R2 (#412), `first_wave_report()` has no violation and one +blocker, so `isolation_complete` is false and R2 does not claim otherwise: | Blocker | Cause | Closed by | | --- | --- | --- | -| `harness reaches model/infra` (12 hits) | `agent_sessions`, `candidates`, `optimization`, `optimization_session`, `project` and `task_protocol` each reach `inferrsi.infra` and `inferrsi.infra.artifacts` | R2 (#412) | | `runtime resource loaders: 5` | The five declared loaders in the table above | R3 (#412) | R1 cleared the `allowlist` and `legacy run forwarders` blockers, and A1 cleared -the `temporary leaf importers` blocker that R1 left for root `arguments.py`. The loaders -also keep `new_core_closure_isolated` false. +the `temporary leaf importers` blocker that R1 left for root `arguments.py`. R2 +cleared `harness reaches model/infra` (12 hits): `agent_sessions`, `candidates`, +`optimization`, `optimization_session`, `project` and `task_protocol` each reached +`inferrsi.infra` and `inferrsi.infra.artifacts`. They now take `digest`, `sha256` +and `file_lock` from `harness/artifact_primitives.py` and `atomic_write_json` from +`harness/atomic_json.py`, whose function bodies equal those in `infra/artifacts.py`. +`infra/artifacts.py` stays for its other users. No Harness module reaches +`inferrsi.infra` or `inferrsi.model`. The loaders also keep +`new_core_closure_isolated` false. `knowledge-model-policy` stays the only required status. Until a separate process decision makes this import gate required, every migration PR attaches diff --git a/src/inferrsi/harness/agent_sessions.py b/src/inferrsi/harness/agent_sessions.py index 1ac821b9f..ef2b72d57 100644 --- a/src/inferrsi/harness/agent_sessions.py +++ b/src/inferrsi/harness/agent_sessions.py @@ -10,7 +10,8 @@ import uuid from pathlib import Path -from ..infra.artifacts import atomic_write_json, digest, file_lock, sha256 +from .artifact_primitives import digest, file_lock, sha256 +from .atomic_json import atomic_write_json from .usage import normalize_usage TERMINAL = {"completed", "failed", "cancelled"} diff --git a/src/inferrsi/harness/artifact_primitives.py b/src/inferrsi/harness/artifact_primitives.py new file mode 100644 index 000000000..9a91652f7 --- /dev/null +++ b/src/inferrsi/harness/artifact_primitives.py @@ -0,0 +1,51 @@ +# Harness-owned digest, file hash and file lock. Each function body equals the one in +# infra.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. + +import hashlib +import json +import os +from contextlib import contextmanager +from pathlib import Path + + +@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 + + msvcrt.locking(stream.fileno(), msvcrt.LK_NBLCK, 1) + 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() diff --git a/src/inferrsi/harness/candidates.py b/src/inferrsi/harness/candidates.py index 9f13f4361..11d647ccc 100644 --- a/src/inferrsi/harness/candidates.py +++ b/src/inferrsi/harness/candidates.py @@ -4,7 +4,7 @@ import stat from pathlib import Path -from ..infra.artifacts import digest, sha256 +from .artifact_primitives import digest, sha256 def members(source: Path, includes: list[str] | None = None) -> dict[str, Path]: diff --git a/src/inferrsi/harness/optimization.py b/src/inferrsi/harness/optimization.py index 8fd2a3fbc..09d738dfc 100644 --- a/src/inferrsi/harness/optimization.py +++ b/src/inferrsi/harness/optimization.py @@ -7,8 +7,9 @@ import uuid from pathlib import Path -from ..infra.artifacts import atomic_write_json, digest, file_lock, sha256 from . import candidates +from .artifact_primitives import digest, file_lock, sha256 +from .atomic_json import atomic_write_json from .usage import normalize_usage, usage_totals diff --git a/src/inferrsi/harness/optimization_session.py b/src/inferrsi/harness/optimization_session.py index 9e7975c2c..b123dc794 100644 --- a/src/inferrsi/harness/optimization_session.py +++ b/src/inferrsi/harness/optimization_session.py @@ -55,10 +55,10 @@ def _session_assess(root, directory, plan, execution): def _project_execute(root, directory, plan, deadline): + from inferrsi.harness.atomic_json import atomic_write_json from inferrsi.harness.candidates import identity, members, retain from inferrsi.harness.project import inspect_step, steps from inferrsi.harness.scenarios.external import execute_trial - from inferrsi.infra.artifacts import atomic_write_json output = directory / "execution" output.mkdir() @@ -107,13 +107,13 @@ def _project_execute(root, directory, plan, deadline): def _runtime_identity(): - from inferrsi.infra.artifacts import sha256 + from inferrsi.harness.artifact_primitives import sha256 root = Path(str(files("inferrsi"))) names = ("harness/optimization_session.py", "harness/optimization.py", "harness/local_process.py", "infra/processes.py", "infra/artifacts.py", "harness/scenarios/external.py", - "harness/atomic_json.py", + "harness/atomic_json.py", "harness/artifact_primitives.py", "harness/usage.py", "harness/agent_sessions.py", "harness/task_protocol.py", "harness/candidates.py", "harness/project.py", "harness/records/knowledge_capture.py", "apps/campaign.py", @@ -130,9 +130,9 @@ def session_command(args, *, task_source: Path | None = None, knowledge_reader=N if args.session_action == "start": import math + from inferrsi.harness.artifact_primitives import sha256 from inferrsi.harness.candidates import identity, retain from inferrsi.harness.task_protocol import prepare - from inferrsi.infra.artifacts import sha256 if args.rounds < 1 or any(not math.isfinite(value) or value <= 0 for value in ( args.max_minutes, args.evaluation_timeout_seconds diff --git a/src/inferrsi/harness/project.py b/src/inferrsi/harness/project.py index fa0da190d..c01fdf5d2 100644 --- a/src/inferrsi/harness/project.py +++ b/src/inferrsi/harness/project.py @@ -10,7 +10,7 @@ from pathlib import Path from statistics import median -from ..infra.artifacts import sha256 +from .artifact_primitives import sha256 def validate(settings: dict) -> None: diff --git a/src/inferrsi/harness/task_protocol.py b/src/inferrsi/harness/task_protocol.py index e2a00fc10..b62feaf1b 100644 --- a/src/inferrsi/harness/task_protocol.py +++ b/src/inferrsi/harness/task_protocol.py @@ -8,7 +8,7 @@ import shutil from pathlib import Path -from ..infra.artifacts import sha256 +from .artifact_primitives import sha256 def protocol(root: Path): diff --git a/tests/test_first_wave_isolation_policy.py b/tests/test_first_wave_isolation_policy.py index 6d3854e3f..0bd2fc1c7 100644 --- a/tests/test_first_wave_isolation_policy.py +++ b/tests/test_first_wave_isolation_policy.py @@ -1213,6 +1213,44 @@ def test_returning_skill_evaluation_infra_edge_fails(self) -> None: ) self.assertFalse(report.isolation_complete) + def test_returning_r2_harness_infra_edges_fail(self) -> None: + # #412 R2 removed infra.artifacts from six Harness modules. Putting one edge back, + # relative or absolute, top-level or inside a function, reports both the package + # and the module edge; reaching another infra module or model also counts. + infra = {"infra/__init__.py": "", "infra/artifacts.py": "VALUE = 1\n", + "infra/processes.py": "VALUE = 1\n", "model/__init__.py": "", + "model/metrics.py": "VALUE = 1\n"} + primitives = {"harness/artifact_primitives.py": "VALUE = 1\n", + "harness/atomic_json.py": "VALUE = 1\n"} + modules = ("agent_sessions", "candidates", "optimization", "optimization_session", + "project", "task_protocol") + clean = {f"harness/{name}.py": "from .artifact_primitives import VALUE\n" + for name in modules} + cleared = _report({**infra, **primitives, **clean}, manifest=EMPTY_ALLOWLIST, + base=CLEARED_TREE) + self.assertEqual(cleared.harness_model_infra, ()) + self.assertTrue(cleared.isolation_complete) + sources = ( + ("from ..infra.artifacts import VALUE\n", "inferrsi.infra.artifacts"), + ("def late():\n from inferrsi.infra.artifacts import VALUE\n", + "inferrsi.infra.artifacts"), + ("from ..infra import processes\n", "inferrsi.infra.processes"), + ("from inferrsi.model import metrics\n", "inferrsi.model.metrics"), + ) + for name in modules: + for source, target in sources: + with self.subTest(module=name, source=source): + report = _report({**infra, **primitives, **clean, + f"harness/{name}.py": source}, + manifest=EMPTY_ALLOWLIST, base=CLEARED_TREE) + package = target.rsplit(".", 1)[0] + self.assertEqual( + report.harness_model_infra, + (f"inferrsi.harness.{name} -> {package}", + f"inferrsi.harness.{name} -> {target}"), + ) + self.assertFalse(report.isolation_complete) + def test_mixed_harness_tree_is_not_an_isolated_core(self) -> None: tree = {"__init__.py": "", "harness/__init__.py": "", "harness/runner.py": "VALUE = 1\n"} report = _report({}, base=tree) diff --git a/tests/test_skill_evaluation.py b/tests/test_skill_evaluation.py index 791f4f5f6..9b8c6f1c3 100644 --- a/tests/test_skill_evaluation.py +++ b/tests/test_skill_evaluation.py @@ -315,6 +315,44 @@ def test_harness_owned_writes_and_digests_match_infra_bytes(tmp_path): assert not (tmp_path / "nan.json").exists() +def test_harness_artifact_primitives_match_infra_bytes_and_semantics(tmp_path): + # #412 R2: the six Harness modules now use these copies. Same source, same bytes, + # same failures, and the two file locks exclude each other on one path. + import ast + import inspect + + from inferrsi.harness import artifact_primitives as harness + from inferrsi.infra import artifacts as infra + + for name in ("digest", "sha256", "file_lock"): + assert inspect.getsource(getattr(harness, name)) == inspect.getsource( + getattr(infra, name)), name + tree = ast.parse(inspect.getsource(harness)) + assert not [node for node in ast.walk(tree) if isinstance(node, ast.ImportFrom) + and (node.level or (node.module or "").split(".")[0] == "inferrsi")] + value = {"b": [1.5, None, True, 1e-07, 1e16], "a": "非 ASCII", "nested": {"z": 0.1 + 0.2}} + assert harness.digest(value) == infra.digest(value) + with pytest.raises(ValueError): + harness.digest({"value": float("nan")}) + blob = tmp_path / "blob.bin" + blob.write_bytes(bytes(range(256)) * 9000) # crosses the 1 MiB read block + assert harness.sha256(blob) == infra.sha256(str(blob)) + with pytest.raises(FileNotFoundError): + harness.sha256(tmp_path / "missing.bin") + lock = tmp_path / "state.lock" + with harness.file_lock(lock): + assert lock.read_bytes() == b"0" + with pytest.raises(OSError): + with infra.file_lock(lock): + pass + with infra.file_lock(lock): + with pytest.raises(OSError): + with harness.file_lock(lock): + pass + with harness.file_lock(lock): + pass + assert lock.read_bytes() == b"0" + def test_summary_normalizes_usage_before_the_pure_statistics(): from inferrsi.benchmark import skill_evaluation as rules diff --git a/tests/test_target_module_import_gate.py b/tests/test_target_module_import_gate.py index bafcdff94..09ddd89f5 100644 --- a/tests/test_target_module_import_gate.py +++ b/tests/test_target_module_import_gate.py @@ -148,17 +148,11 @@ def test_clean_scan_is_not_isolation(self) -> None: self.assertFalse(hasattr(report, "residuals")) self.assertNotIn("residual", kinds) self.assertEqual(report.violations, ()) - # What keeps isolation false after R1: the parser entry due in A1, the six - # Harness modules that R2 closes and the five loaders that R3 closes. - self.assertEqual( - report.blockers, - ( - "harness reaches model/infra: inferrsi.harness.agent_sessions -> " - "inferrsi.infra (12 hits)", - "runtime resource loaders: 5", - ), - ) - self.assertEqual(len(report.harness_model_infra), 12) + # #412 R2 closed the six Harness modules: no Harness module reaches the + # package-level ``inferrsi.infra``, ``inferrsi.infra.artifacts`` or + # ``inferrsi.model``. What keeps isolation false is the five loaders that R3 closes. + self.assertEqual(report.blockers, ("runtime resource loaders: 5",)) + self.assertEqual(report.harness_model_infra, ()) self.assertFalse(report.new_core_closure_isolated) def test_split_skill_eval_modules_reach_no_model_or_infra(self) -> None: From a7d4b08c8b8b52147527968dde190aa85942f51a Mon Sep 17 00:00:00 2001 From: GUOGUO Date: Tue, 17 Nov 2026 14:02:13 +0800 Subject: [PATCH 2/4] test(gate): expect only the R3 loader blocker in two more real-tree checks (R2) test_knowledge_closure_is_clean_while_overall_stays_false and test_real_tree_holds_no_forwarder_and_stays_incomplete still pinned the twelve harness -> infra hits that R2 removed. The H200 full suite caught both. They now expect only "runtime resource loaders: 5" and zero harness -> model/infra paths; isolation stays false. Refs #412 Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author) Signed-off-by: GUOGUO --- tests/test_knowledge_compatibility_shells.py | 18 +++++------------- tests/test_legacy_run_forwarder_gate.py | 6 ++---- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/tests/test_knowledge_compatibility_shells.py b/tests/test_knowledge_compatibility_shells.py index dbd6c4825..f3bd04d3d 100644 --- a/tests/test_knowledge_compatibility_shells.py +++ b/tests/test_knowledge_compatibility_shells.py @@ -282,20 +282,12 @@ def test_package_init_and_infra_inspection_load_no_knowledge_body(): def test_knowledge_closure_is_clean_while_overall_stays_false(): # K01-5: the Knowledge package exists and its closure is clean. R1 cleared the - # allowlist and the old-run forwarders. The parser entry due in A1, the twelve - # harness -> infra hits (R2) and the five runtime resource loaders (R3) remain, - # and the loaders keep new_core_closure_isolated false. + # allowlist and the old-run forwarders, A1 the parser entry and R2 the twelve + # harness -> infra hits from six modules. The five runtime resource loaders (R3) + # remain, and they keep new_core_closure_isolated false. report = first_wave_report() assert report.violations == () - assert report.blockers == ( - "harness reaches model/infra: inferrsi.harness.agent_sessions -> inferrsi.infra (12 hits)", - "runtime resource loaders: 5", - ) - assert len(report.harness_model_infra) == 12 - assert {path.split(" -> ")[0] for path in report.harness_model_infra} == { - f"inferrsi.harness.{name}" - for name in ("agent_sessions", "candidates", "optimization", "optimization_session", - "project", "task_protocol") - } + assert report.blockers == ("runtime resource loaders: 5",) + assert report.harness_model_infra == () assert not report.new_core_closure_isolated assert not report.isolation_complete diff --git a/tests/test_legacy_run_forwarder_gate.py b/tests/test_legacy_run_forwarder_gate.py index 965ecedbb..d9f6cd121 100644 --- a/tests/test_legacy_run_forwarder_gate.py +++ b/tests/test_legacy_run_forwarder_gate.py @@ -94,8 +94,6 @@ def test_real_tree_holds_no_forwarder_and_stays_incomplete(): assert report.violations == () for name in RETIRED_FORWARDERS: assert not (support.ROOT / f"{name}.py").exists(), name - # What is left belongs to R2 and R3, plus the parser entry due in A1. - assert support.blocker_kinds(report) == { - "harness reaches model/infra", "runtime resource loaders", - } + # What is left belongs to R3: R2 closed the harness -> infra hits. + assert support.blocker_kinds(report) == {"runtime resource loaders"} assert not report.isolation_complete From 1d0190e01ea59954a679054e697a22450edce011 Mon Sep 17 00:00:00 2001 From: GUOGUO Date: Tue, 17 Nov 2026 15:38:45 +0800 Subject: [PATCH 3/4] test(harness): drop the in-lock read that Windows denies; pin the R2 runtime identity A Windows byte-range lock denies a read of the locked byte even from the same process, so reading the lock file inside file_lock() failed on Windows before the contention checks ran. Both contention checks stay, and the sentinel is still checked after release. Also assert that the optimization session's runtime identity covers artifact_primitives.py. Refs #412 Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author) Signed-off-by: GUOGUO --- tests/test_optimization_session.py | 2 ++ tests/test_skill_evaluation.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_optimization_session.py b/tests/test_optimization_session.py index beded41f8..9e9c37f2c 100644 --- a/tests/test_optimization_session.py +++ b/tests/test_optimization_session.py @@ -352,6 +352,8 @@ def test_runtime_identity_covers_migrated_process_domain_and_not_removed_executo identity = optimization_session._runtime_identity() root = Path(str(files("inferrsi"))) assert "harness/local_process.py" in identity + # #412 R2: the Harness-owned primitives replace infra.artifacts in six modules. + assert "harness/artifact_primitives.py" in identity assert "infra/executors/local.py" not in identity for name in identity: assert (root / name).is_file(), name diff --git a/tests/test_skill_evaluation.py b/tests/test_skill_evaluation.py index 9b8c6f1c3..ae398a384 100644 --- a/tests/test_skill_evaluation.py +++ b/tests/test_skill_evaluation.py @@ -340,8 +340,8 @@ def test_harness_artifact_primitives_match_infra_bytes_and_semantics(tmp_path): with pytest.raises(FileNotFoundError): harness.sha256(tmp_path / "missing.bin") lock = tmp_path / "state.lock" + # No read inside a held lock: a Windows byte-range lock denies it even in-process. with harness.file_lock(lock): - assert lock.read_bytes() == b"0" with pytest.raises(OSError): with infra.file_lock(lock): pass From 6bc3750ea2bc47c22b8a15baf4037fc2e90f8c09 Mon Sep 17 00:00:00 2001 From: GUOGUO Date: Tue, 17 Nov 2026 21:23:42 +0800 Subject: [PATCH 4/4] ci(host): run the R2 Harness primitive and writer nodes on hosted Windows The host-compatibility job ran only the eight plugin/DSH nodes and the installed-wheel check, so no independently verifiable job executed the R2 lock, hash, digest and atomic-writer regressions on Windows, where the file lock is an msvcrt byte range. Add a Windows-only step that runs those nodes and test_agent_sessions.py, fails on any skip, and retains its JUnit result with the other host results. macOS uses the same fcntl lock as the Linux full-check jobs and does not run the step. Refs #412 Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author) Signed-off-by: GUOGUO --- .github/workflows/ci-ready.yml | 52 ++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-ready.yml b/.github/workflows/ci-ready.yml index 863608e63..31bf30097 100644 --- a/.github/workflows/ci-ready.yml +++ b/.github/workflows/ci-ready.yml @@ -101,11 +101,12 @@ jobs: host-compatibility: # GitHub-hosted Windows and macOS CPU evidence, separate from the Ubuntu jobs above: - # a pass on Linux is not a pass on these hosts. It runs only the eight plugin and DSH - # nodes that an earlier Windows run recorded as failing (63 passed, 8 failed), then an - # installed-wheel check. A pass here does not rewrite that record. No GPU, remote - # service or credential is used; the DSH node talks to the fake SSH server that its - # own check starts. One host at a time, one pytest process, no full suite. + # a pass on Linux is not a pass on these hosts. It runs the eight plugin and DSH nodes + # that an earlier Windows run recorded as failing (63 passed, 8 failed), on Windows the + # Harness artifact-primitive and writer nodes, then an installed-wheel check. A pass + # here does not rewrite that record. No GPU, remote service or credential is used; the + # DSH node talks to the fake SSH server that its own check starts. One host at a time, + # one pytest process per step, no full suite. strategy: fail-fast: false max-parallel: 1 @@ -171,6 +172,46 @@ jobs: print(counts, flush=True) if counts != {"tests": len(nodes), "errors": 0, "failures": 0, "skipped": 0}: raise SystemExit("every selected host node must run and pass") + - name: Test the Harness artifact-primitive and writer nodes on Windows + # #412 R2: Harness owns copies of the Infra digest, hash, file lock and atomic + # writer. On Windows the lock is an msvcrt byte range that even denies a read of + # the locked byte, which no Linux job can show. macOS uses the same fcntl lock as + # the Linux jobs, so only Windows runs these nodes. Runs even if the step above + # failed, so both results are recorded. + if: ${{ !cancelled() && runner.os == 'Windows' }} + shell: python + env: + RESULTS: ${{ runner.temp }}/host-primitives-results.xml + run: | + import os + import subprocess + import sys + import xml.etree.ElementTree as ET + + nodes = [ + "tests/test_skill_evaluation.py::test_harness_artifact_primitives_match_infra_bytes_and_semantics", + "tests/test_skill_evaluation.py::test_harness_owned_writes_and_digests_match_infra_bytes", + "tests/test_legacy_run_split.py::test_harness_writer_bytes_equal_the_infra_writer", + "tests/test_legacy_run_split.py::test_harness_writer_rejects_nan_and_leaves_no_file", + "tests/test_legacy_run_split.py::test_sampling_sha256_matches_the_infra_hasher", + "tests/test_optimization_session.py::test_runtime_identity_covers_migrated_process_domain_and_not_removed_executor", + "tests/test_agent_sessions.py", + ] + results = os.environ["RESULTS"] + command = [sys.executable, "-m", "pytest", "-vv", "-rs", "-o", "addopts=", + "--junitxml=" + results, *nodes] + status = subprocess.run( + command, cwd=os.environ["GITHUB_WORKSPACE"], check=False + ).returncode + if status: + raise SystemExit(status) + # pytest exits 0 with skips, and a skipped node is not a pass. + suite = next(ET.parse(results).getroot().iter("testsuite")) + counts = {name: int(suite.get(name)) + for name in ("tests", "errors", "failures", "skipped")} + print(counts, flush=True) + if counts["skipped"]: + raise SystemExit("every selected primitive node must run and pass") - name: Check a wheel built from the sdist in a fresh environment outside the checkout # Runs even if a node above failed, so both results are recorded; either failure # still fails the job. @@ -244,5 +285,6 @@ jobs: name: host-compatibility-${{ matrix.os }} path: | ${{ runner.temp }}/host-compatibility-results.xml + ${{ runner.temp }}/host-primitives-results.xml ${{ runner.temp }}/host-wheel.log retention-days: 30