Skip to content

refactor(harness,apps): move serving helpers and host bindings, remove the campaign facade - #510

Merged
Dong1017 merged 10 commits into
mainfrom
impl/498-s2-serving
Nov 19, 2026
Merged

Dong1017 merged 10 commits into
mainfrom
impl/498-s2-serving

Conversation

@Dong1017

@Dong1017 Dong1017 commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Governing Issue and delivery slice

Refs #498

  • Accepted scope: slices 2, 3c and 3a of task: retire the infra/ and model/ packages into their owning modules #498, as one PR by the owner's decision (issuecomment-7002457678). Slice 2's placement is in issuecomment-6996972802; 3c and 3a ship together because infra/campaign.py re-exports environment and targets, and Infra may not import Apps.
  • What this PR delivers: three moves, each with no forwarder or alias, with the matching guards, tests and docs.
    • Slice 2, serving helpers to harness/serving/: infra.processes, infra.http and model.protocols.image become server.py, http.py and image.py; the emptied model/protocols package is removed; the initializer imports nothing; _runtime_identity() hashes harness/serving/server.py in place of infra/processes.py, and a plan from before the change is refused before dispatch and left unchanged.
    • Slice 3c, the campaign facade: infra/campaign.py is deleted and helper_hashes moves into examples/qwen21_turbo_b300.py unchanged, its only caller; the example imports infra.artifacts, infra.environment and infra.targets directly.
    • Slice 3a, host bindings to apps/host/: infra/{commands,inspection,environment}.py, infra/platforms/ and infra/targets/ move; the permanent neutral-leaf importer moves from inferrsi.infra.inspection to inferrsi.apps.host.inspection in the source, LEAF_IMPORTERS and technical_leaf.permanent_importers, with the earlier state kept in revision_history; the gate fails any path from apps/host/ to a Knowledge, Harness or Benchmark module, or to any Apps module outside the package; every leaf lock is unchanged.
    • Retirement guards: the gate and tests/check_installed.py reject every retired path, including with no file behind it.
  • What it does not deliver: slice 3b, slice 4 and slice 5. inferrsi.infra now holds only artifacts.py, and the model/ provider modules stay. The harness/scenarios/ rename is out of scope (task: retire the infra/ and model/ packages into their owning modules #498 body, "Out of scope").

Knowledge authorship declaration

No path protected by docs/knowledge-model-policy.md changes. The declaration below is disclosure only.

{"schema_version":1,"head_sha":"2e7c8630d89d3c14957f5eef6d868b22d2f51146","human_only":false,"material_ai_authors":[{"tool":"Claude Code","model_id":"claude-opus-5-5","effort":"xhigh","role":"author"}]}

Changed artifacts and evidence

Requirement (#498 slice 2) Actual change Check / evidence Remaining gap
Serving helpers move to harness/serving/ git mv of the three files. Only image.py changes, in one import line (from .http import post_json). test_server_processes.py (including the real Linux cleanup test, which is skipped off Linux), test_image_modules.py (local HTTP image request), test_qwen21_turbo_campaign.py (example campaign): pass on H200 none
Linux-only server contract kept server.py bytes are unchanged test_server_processes.py: non-Linux rejection, inaccessible procfs, real cleanup after the leader exits while an unrelated process survives. The embedded subprocess source imports the new path. none
Empty initializer; the image client does not load the server helpers harness/serving/__init__.py holds only a docstring tests/check_installed.py: a fresh -I interpreter imports inferrsi.harness.serving.image and finds only serving, serving.image and serving.http, and no inferrsi.infra or inferrsi.model module installed-package on this PR
Runtime identity binds the canonical file _runtime_identity() key swap test_runtime_identity_covers_migrated_process_domain_and_not_removed_executor: the new key is present, its hash equals the installed file's SHA-256, and infra/processes.py is absent none
A pre-move plan is refused before dispatch and left unchanged Fixture tests/fixtures/optimization-session/pre-serving-runtime-identity.json: the runtime identity that main at 25df477 records, computed from that commit's own file bytes test_a_plan_from_before_the_serving_move_is_refused_and_left_unchanged: status and recover both exit 2 with "Optimization runtime changed" before dispatch, and the plan bytes are unchanged. test_changed_installed_server_bytes_refuse_an_untouched_plan: after a real start, changing server.py in a disposable copy of the identity files makes status refuse the untouched plan. none: the two-runtime check below covers recovery
Old paths fail, even with no file behind them RETIRED_MODULES gains inferrsi.model.protocols (which now covers slice 1's metrics path), inferrsi.infra.processes and inferrsi.infra.http. New gate controls cover imports and returning files. The "not retired" control now uses live paths. test_target_module_import_gate.py: pass on H200 none
No forwarder in the wheel tests/check_installed.py: find_spec is None for the two Infra paths and for inferrsi.model.protocols, the four new modules ship, and inferrsi.infra.campaign has no launch_server installed-package on this PR pending CI
Docs and CHANGELOG docs/architecture.md (layer table, dependency sentence, directory map, extension table, server note), docs/contributing.md, docs/module-layout.md, src/inferrsi/model/README.md, the inferrsi.model docstring, CHANGELOG review docs/assets/modular-directory-map-en.svg was already stale before this PR (it still shows root cli.py, runspec.py and infra/executors/). It is left for the directory-name follow-up recorded in #498.

Checks and dependencies

  • Checks actually run:
    • H200 Linux, Python 3.12.13, the tree committed as bf65c76. I ran a git archive of the commit. All 2711 files matched a SHA-256 manifest. A shim outside the tree routed around the H200 cufile-python tests package, and PYTHONPATH was absolute. The run covered 17 files:

      • test_server_processes.py, test_image_modules.py and test_optimization_session.py;
      • test_target_module_import_gate.py, test_legacy_run_split.py, test_module_boundaries.py and test_first_wave_isolation_policy.py;
      • test_qwen21_turbo_campaign.py and test_ltx25_campaign.py;
      • test_knowledge_compatibility_shells.py, test_legacy_run_forwarder_gate.py, test_campaign_record_injection.py and test_package_root_inventory.py;
      • test_project_optimization.py, test_architecture_closed_loop.py, test_artifact_helper_copies.py and test_flare_adapter.py.

      Result: 388 passed, 1 skipped, 402 subtests passed. The skip is test_package_root_inventory.py:153, which needs Git metadata; full-check runs it.

    • The first H200 run at 0f73c69 had 3 failures, all in tests. bf65c76 fixes them:

      • The two new refusal tests expected a return code, but the CLI raises an argparse SystemExit(2) with the same message.
      • The R2 gate test built its synthetic tree with infra/processes.py, which is now correctly reported as retired. It now uses the live infra/commands.py.
    • Lint: Ruff 0.17.5 on src tests tools and git diff --check pass.

    • Two-runtime check on H200 (scripts and results in the PR conversation). The old runtime is a 25df477 wheel, the new runtime an f50e27e wheel, each in its own venv, and both drive one untouched session:

      • The old runtime starts the session and is interrupted after a round's child completes.
      • The new wheel refuses status and recover with exit 2, and all 15 session files stay byte-identical.
      • The old runtime then recovers from the retained receipt, with completed_rounds 1 and no second candidate run.
      • In a disposable venv, the new wheel's installed server.py is changed, and it then refuses its own untouched plan.
  • Not run:
    • The installed-wheel check, which installed-package on this PR runs.
    • No NPU or GPU serving run. The server helper bytes are unchanged.
    • The two-runtime check runs outside CI, because it needs two wheels. Its scripts and results are in the PR conversation.
  • Compatibility:
    • Imports of the three old paths fail with ModuleNotFoundError.
    • Pickles that name them no longer load.
    • Sessions planned before this change are refused under the new runtime, by design.
  • Dependencies: main gained Add service-reuse evaluation for project campaigns #480, ci: make Windows and macOS host checks advisory and non-blocking #508 and Anchor contract schema patterns at the end of input #514 after this branch was cut. 6f151a7 merges main 9b81c9b in. The only conflict was in CHANGELOG, resolved by keeping both entries. None of the merged changes uses a moved module, and the gate reports no violation or blocker on the merged tree.

Remaining work and Issue closure

Provenance

The code, tests and docs were written in a Claude Code session reported as claude-opus-5-5, effort xhigh, confirmed by the owner. This is client and session attribution, not a backend attestation. Each commit has DCO sign-off and an Agent-assisted-by line.

🤖 Generated with Claude Code

Starting a supervised serving process, the timed JSON transport and the
image request client are execution helpers, so they move to a new
harness/serving package with no forwarder or alias:

- infra/processes.py -> harness/serving/server.py
- infra/http.py -> harness/serving/http.py
- model/protocols/image.py -> harness/serving/image.py

The emptied model/protocols package is removed. The serving initializer
imports nothing, so importing the HTTP or image client loads no server
helper; the installed-wheel check proves this in a fresh interpreter. The
server helpers keep their Linux-only process-group contract.

infra/campaign.py no longer re-exports launch_server and stop_server,
because Infra imports no Harness module; the example campaign imports
them from harness/serving/server.py. The optimization session's runtime
identity hashes harness/serving/server.py in place of infra/processes.py.
A plan made before this change is refused before status or recover runs
and is left unchanged; a fixture pins the earlier runtime identity from
that commit's own file bytes. CHANGELOG says how to resume such a session
with the runtime that planned it.

The gate fails any import of the retired paths, and the installed-wheel
check asserts that they are absent and the new modules ship.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: GUOGUO <xwdong1998@163.com>
…ixture

The session CLI reports a refused runtime as an argparse usage error, so
the new refusal tests expect SystemExit with status 2 and the message.
The R2 gate test built its synthetic Infra tree with infra/processes.py,
which is now a retired path and correctly reported; it uses the live
infra/commands.py for its "another Infra module" case instead.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: GUOGUO <xwdong1998@163.com>

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO PASS

Initial review of Slice 2 at bf65c76f2a7caa6592b4db84e471767254dd5f63. The remaining blocker is the explicit two-runtime acceptance requirement in #498, not the serving module placement.

The refusal test creates a session under the new runtime and substitutes the old runtime-identity map into its plan.json. It does verify the new source CLI rejects that map for status and recover without changing the plan. It does not use a plan, receipts and retained inputs produced together by the pinned pre-move runtime. The added check_installed.py probe checks import retirement and isolation, not old-session refusal by the installed wheel. Neither test shows the same original session recovering from its receipts on the pinned old runtime. Please supply a reproducible two-runtime fixture or linked results using the same untouched session: old runtime produces it, new installed wheel rejects it without rewriting, and old runtime recovers it from its retained inputs and receipts.

I checked the moves, runtime identity path and embedded Linux cleanup-test import. Server/HTTP file bytes are unchanged; image changes its HTTP import. No additional implementation blocker identified. I inspected the diff and check metadata; current-head Ready was queued at inspection. The H200 numbers are author-reported. I did not execute the repository, build a wheel or run old-runtime recovery.

@Dong1017 Dong1017 added kind:task Bounded delivery task with a delegated slice area:harness Harness module: profile, A/B loop, quality gates, evidence reports labels Nov 19, 2026
The map still listed infra/http.py after it moved to harness/serving/http.py.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: GUOGUO <xwdong1998@163.com>

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review of the installed-runtime identity coverage at bf65c76f.

Comment thread tests/test_optimization_session.py Outdated
path = session / "plan.json"
plan = json.loads(path.read_text(encoding="utf-8"))
assert plan["runtime_identity"] == optimization_session._runtime_identity()
plan["runtime_identity"]["harness/serving/server.py"] = "0" * 64

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the frozen plan, not the installed server. Could the regression create a plan with the new wheel, change harness/serving/server.py in a disposable install, then verify status rejects the untouched plan? That covers #498’s canonical-byte drift requirement separately from the old-wheel recovery case.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in c74434b. test_changed_installed_server_bytes_refuse_an_untouched_plan starts a real session. It then points the runtime identity at a disposable copy of the identity files and checks that the unchanged copy is accepted. After that it changes harness/serving/server.py in the copy and expects status to refuse the untouched plan, with the plan bytes unchanged.

On H200 the same check ran against a real installed new wheel in a disposable venv (issuecomment-6999697086).

Review of bf65c76: the drift test edited the frozen plan instead of the
server. It now starts a real session, points the runtime identity at a
disposable copy of the identity files, accepts the unchanged copy, then
changes harness/serving/server.py in the copy and expects status to be
refused with the plan bytes unchanged.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: GUOGUO <xwdong1998@163.com>

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO PASS

Independent incremental review: bf65c76f2a7caa6592b4db84e471767254dd5f63 → c74434b0e081fa096ae7b2b5784f2e6940a81f44, following my prior review. I inspected the complete two-file increment and rechecked #498's explicit Slice 2 requirements.

The new negative control is better targeted: it first accepts an untouched current-runtime plan, changes the canonical server bytes in a disposable identity-file installation, then verifies refusal and unchanged plan bytes. Removing the obsolete Infra HTTP entry from the architecture tree is also correct. Neither change introduces a new identified blocker.

The original two-runtime requirement remains unfulfilled. tests/test_optimization_session.py:487–503 still creates a current-runtime session and substitutes its runtime_identity map. The new test below it changes copied current-runtime files; it is not a session produced by the pinned pre-move runtime and does not exercise recovery from old receipts. This increment adds neither a genuine retained pre-move session nor its rejection under the new installed wheel and recovery under the pinned old runtime.

Please retain a reproducible fixture or linked evidence for the same untouched old plan, receipts and inputs across both runtimes: new installed wheel rejects status/recover without rewriting the plan; pinned pre-move runtime recovers from the retained receipts. This is the explicit #498 acceptance item, not a request for unrelated device experiments. The changed-byte negative control can remain as a separate regression.

Static code/test-definition review only. No CI status or logs inspected, no repository code/tests/builds executed, and no merge.

@Dong1017

Copy link
Copy Markdown
Collaborator Author

New head: c74434b0e081fa096ae7b2b5784f2e6940a81f44. No approval existed at bf65c76, so this push voids none.

The head adds two commits:

  • f50e27e: drops the infra/http.py line that the architecture directory map still listed.
  • c74434b: rewrites the drift test (inline comment 4624039139).

No source file changed after bf65c76.

Two-runtime check with one untouched session (reviews 5968724825 and 5969264012)

Setup:

  • Host: H200 Linux, Python 3.12.13.
  • Old runtime: 25df477, the main this PR branches from.
  • New runtime: f50e27e. c74434b changes only tests/test_optimization_session.py.
  • Build: each side is a git archive checked against a per-file SHA-256 manifest and built as a wheel. Each wheel is installed with --no-deps --no-index into its own venv.
  • Driver: the same driver script runs under python -I from outside both trees. It uses the synthetic CPU task from tests/test_optimization_session.py::task.
Step Runtime Result
1 session start old exit 0
2 session round; the coordinator is interrupted after the child completes, as in test_recovery_collects_completed_execution_without_running_candidate_twice old exit 130 (KeyboardInterrupt); the receipt is retained
3 session status new wheel exit 2: Optimization runtime changed, use its frozen runtime to resume
4 session recover new wheel exit 2, same message
— session files before step 3 and after step 4 — all 15 files have identical SHA-256; plan.json still names infra/processes.py
5 session recover old exit 0: completed_rounds 1, best candidate score 2
6 session status old exit 0, completed_rounds 1
— calls.log — 2 once: the candidate was not run again
steps.log
verify-old=0
build-old=0
venv-old=0
install-old=0
wheel-old acbdfa9d40ed6fd1a103be15d4b85fee62fc8c42141fa016e40668476d12d8ea  inferrsi-0.1.0.dev0-py3-none-any.whl
verify-new=0
build-new=0
venv-new=0
install-new=0
wheel-new f6056d723240fef22a6bfc83c2dcad8c32e9a14d6519e56bea7149acdc7f1c88  inferrsi-0.1.0.dev0-py3-none-any.whl
step1 old start exit=0
step2 old interrupted-round 2 exit=130
step3 new status exit=2
step4 new recover exit=2
session-unchanged-by-new=0 files=15
plan-names-infra-processes=1
step5 old recover exit=0
step6 old status exit=0
calls.log=2,
done

Changed installed server bytes with an untouched plan (inline 4624039139)

On H200:

  • The new wheel, in a disposable copy of its venv, starts a session, and status exits 0.
  • The installed harness/serving/server.py is then changed. Before the change its SHA-256 is 2ca19843…, the same as the file at f50e27e.
  • status then exits 2 with the same message, and the 8 session files are unchanged.

In CI: test_changed_installed_server_bytes_refuse_an_untouched_plan does the same against a disposable copy of the identity files. It accepts the unchanged copy first. It replaces the earlier test that edited the plan.

drift.log
server=$WORK/drift-venv/lib/python3.12/site-packages/inferrsi/harness/serving/server.py
drift-step1 start exit=0
drift-step2 status exit=0
server-before 2ca1984373423b190b13523fa76ce760e74cc851bbd29b0e532d8d7e92e62c8d  $WORK/drift-venv/lib/python3.12/site-packages/inferrsi/harness/serving/server.py
server-after 52d0d05ca97ca66b87c983436ce49f89c6f1646ca191b9bf31e170d29faa6a99  $WORK/drift-venv/lib/python3.12/site-packages/inferrsi/harness/serving/server.py
drift-step3 status exit=2
session-unchanged-by-drift=0 files=8
done

Reproduction

Put old.tar and new.tar (git archive of the two commits), their manifests and verify.py (the per-file SHA-256 check) in $WORK, then run two_runtime.sh followed by installed_drift.sh.

two_runtime_driver.py
import json
import sys
from pathlib import Path

# Drive one optimization session through the installed inferrsi of this interpreter.
# The same driver runs under the pre-move and the new runtime, so only the runtime
# differs. Usage: two_runtime_driver.py <workdir> <command> [factor]
from inferrsi.apps.cli import main
from inferrsi.benchmark import registry
from inferrsi.harness import optimization_session

work, command = Path(sys.argv[1]), sys.argv[2]
library = work / "library"
session = work / "session"
registry._library_root = lambda: library


def write_task():
    # The synthetic CPU task from tests/test_optimization_session.py::task.
    task = library / "test-work"
    task.mkdir(parents=True)
    (library / "index.json").write_text(
        json.dumps({"schema_version": 1, "packages": [task.name]}), encoding="utf-8")
    (task / "TASK.md").write_text("Synthetic protocol control\n", encoding="utf-8")
    (task / "baseline.py").write_text("FACTOR = 1\n", encoding="utf-8")
    (task / "optimization.py").write_text(
        "import json\n"
        "def validate_arguments(args):\n    assert not args\n    return {}\n"
        "def arguments(candidate, output, settings):\n"
        "    return [str(candidate), str(output)]\n"
        "def assess(directory, settings, execution):\n"
        "    return json.loads((directory / 'measurement/result.json').read_text())\n",
        encoding="utf-8")
    (task / "benchmark.py").write_text(
        "import json, runpy, sys\nfrom pathlib import Path\n"
        "value = runpy.run_path(sys.argv[1])['FACTOR']\n"
        "output = Path(sys.argv[2])\noutput.mkdir()\n"
        "with Path('calls.log').open('a') as stream:\n    stream.write(str(value) + '\\n')\n"
        "status = 'completed' if value > 0 else 'candidate_failure'\n"
        "result = {'status': status, 'verdict': 'PASS' if value > 0 else 'FAIL',\n"
        "          'score': value if value > 0 else None}\n"
        "(output / 'result.json').write_text(json.dumps(result))\n",
        encoding="utf-8")


def run(argv):
    try:
        return main(argv)
    except SystemExit as stopped:
        return stopped.code


if command == "start":
    write_task()
    code = run(["benchmarks", "session", "start", "test-work", "--session", str(session),
                "--rounds", "3", "--max-minutes", "5", "--evaluation-timeout-seconds", "15",
                "--condition", "synthetic-current-agent", "--evaluation-args", ""])
elif command == "interrupted-round":
    # As in test_recovery_collects_completed_execution_without_running_candidate_twice:
    # the child finishes and leaves its receipt, then the coordinator is interrupted.
    original = optimization_session._session_execute

    def crash_after_execution(*args):
        original(*args)
        raise KeyboardInterrupt("coordinator interrupted after child completion")

    optimization_session._session_execute = crash_after_execution
    candidate = session / "work/candidate.py"
    candidate.write_text(f"FACTOR = {sys.argv[3]}\n", encoding="utf-8")
    try:
        code = run(["benchmarks", "session", "round", "--session", str(session),
                    "--candidate", str(candidate), "--hypothesis", "two-runtime check"])
    except KeyboardInterrupt as interrupted:
        print(json.dumps({"interrupted": str(interrupted)}))
        code = 130
elif command in ("status", "recover"):
    code = run(["benchmarks", "session", command, "--session", str(session)])
else:
    raise SystemExit(f"unknown command {command}")
sys.stdout.flush()
sys.exit(code)
two_runtime.sh
#!/usr/bin/env bash
# Two-runtime release-boundary check for #498 slice 2. One untouched session:
# the pre-move runtime starts it and leaves an interrupted round with its receipt, the
# new installed wheel must refuse it without changing any session file, and the
# pre-move runtime must then recover it from its receipts.
set -u
work=${WORK:?set WORK to a directory holding the inputs}
cd "$work"
rm -f steps.log
log() { echo "$*" >> steps.log; }
for side in old new; do
  rm -rf "tree-$side" "venv-$side" "dist-$side" && mkdir "tree-$side" "dist-$side"
  tar -xf "$side.tar" -C "tree-$side"
  python3 -I verify.py "tree-$side" "MANIFEST-$side.json" > "verify-$side.json"; log "verify-$side=$?"
  SETUPTOOLS_SCM_PRETEND_VERSION=0.1.0.dev0 python3 -m pip wheel --no-deps --no-build-isolation \
    -w "dist-$side" "./tree-$side" > "build-$side.log" 2>&1; log "build-$side=$?"
  python3 -m venv --without-pip "venv-$side"; log "venv-$side=$?"
  python3 -m pip --python "venv-$side/bin/python" install --no-deps --no-index \
    "dist-$side"/inferrsi-*.whl > "install-$side.log" 2>&1; log "install-$side=$?"
  (cd dist-$side && sha256sum inferrsi-*.whl | sed "s/^/wheel-$side /") >> steps.log
  "venv-$side/bin/python" -I -c "import inferrsi, pathlib; print('location-$side', pathlib.Path(inferrsi.__file__).parent)" >> steps.log
done
rm -rf run && mkdir run
step=0
run() {
  local side=$1; shift; step=$((step + 1))
  (cd "$work/run" && "$work/venv-$side/bin/python" -I "$work/two_runtime_driver.py" "$work/run" "$@" \
    > "$work/out-$step-$side-$1.txt" 2> "$work/err-$step-$side-$1.txt")
  log "step$step $side $* exit=$?"
}
manifest() { (cd "$work/run/session" && find . -type f -print0 | sort -z | xargs -0 sha256sum) > "$work/$1"; }
run old start
run old interrupted-round 2
manifest manifest-before-new.txt
run new status
run new recover
manifest manifest-after-new.txt
cmp -s manifest-before-new.txt manifest-after-new.txt; log "session-unchanged-by-new=$? files=$(wc -l < manifest-before-new.txt)"
grep -c '"infra/processes.py"' run/session/plan.json | sed 's/^/plan-names-infra-processes=/' >> steps.log
run old recover
run old status
log "calls.log=$(tr '\n' ',' < run/session/calls.log 2>/dev/null)"
log done
tar -czf results.tgz steps.log manifest-before-new.txt manifest-after-new.txt out-*.txt err-*.txt
installed_drift.sh
#!/usr/bin/env bash
# Installed-wheel drift check for #498 slice 2: the new wheel starts a session, then the
# installed harness/serving/server.py changes in a disposable venv. The untouched plan
# must be refused, and no session file may change.
set -u
work=${WORK:?set WORK to a directory holding the inputs}
cd "$work"
rm -f drift.log
log() { echo "$*" >> drift.log; }
rm -rf drift-venv && cp -a venv-new drift-venv
server=$(drift-venv/bin/python -I -c "import inferrsi.harness.serving.server as s; print(s.__file__)")
log "server=$server"
rm -rf drift && mkdir drift
step=0
run() {
  step=$((step + 1))
  (cd "$work/drift" && "$work/drift-venv/bin/python" -I "$work/two_runtime_driver.py" "$work/drift" "$@" \
    > "$work/drift-out-$step-$1.txt" 2> "$work/drift-err-$step-$1.txt")
  log "drift-step$step $* exit=$?"
}
manifest() { (cd "$work/drift/session" && find . -type f -print0 | sort -z | xargs -0 sha256sum) > "$work/$1"; }
run start
run status
manifest drift-manifest-before.txt
sha256sum "$server" | sed 's/^/server-before /' >> drift.log
printf '\n# changed canonical bytes\n' >> "$server"
sha256sum "$server" | sed 's/^/server-after /' >> drift.log
run status
manifest drift-manifest-after.txt
cmp -s drift-manifest-before.txt drift-manifest-after.txt; log "session-unchanged-by-drift=$? files=$(wc -l < drift-manifest-before.txt)"
log done
tar -czf drift-results.tgz drift.log drift-manifest-*.txt drift-out-*.txt drift-err-*.txt

Not claimed:

  • This check runs outside CI, because it needs two wheels.
  • No real serving process or GPU was used: the server bytes are unchanged, and the synthetic task runs on CPU.

The PR body's head_sha and evidence are updated.

zengchuang-hw
zengchuang-hw previously approved these changes Nov 19, 2026

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PASS

Evidence-only follow-up at unchanged head c74434b0e081fa096ae7b2b5784f2e6940a81f44, superseding the missing two-runtime evidence hold in my prior review.

The author has now supplied the two-runtime procedure, driver and execution record: an old installed runtime creates the session and leaves a completed child receipt before coordinator interruption; the new installed wheel refuses status/recover while the 15 session-file hashes remain unchanged; the old runtime then recovers one completed round with score 2, with one candidate invocation in calls.log. A separate installed-wheel drift record changes canonical server bytes while preserving the new plan and session files.

I independently read the driver and orchestration scripts against the pinned old controller. The interruption occurs after execution and before settlement, while recover reads the existing receipt without relaunching the candidate. The driver does not rewrite runtime_identity or bypass its guard; it changes only task discovery and the intentional interruption hook. The tested new runtime f50e27e2605cfa19d12d50988c4b88a4a8a22f1c has the same production source as this head: the complete subsequent delta changes only tests/test_optimization_session.py. Thus this supplies the previously missing, specifically scoped two-runtime evidence, rather than merely the substituted-map unit test.

Evidence boundary: these are author-executed results and an inspectable reproduction procedure, not my independently reproduced run. I have not downloaded or independently hashed the wheel binaries or raw session archive. The supplied results, static lifecycle check and unchanged production bytes address the prior hold; no remaining in-scope blocking implementation issue was found. The earlier module-move/import-retirement assessment remains applicable.

No CI results inspected, no repository code/tests/builds executed, and no merge. Approval is for this bounded Slice 2, not acceptance or closure of all of #498.

infra/campaign.py only re-exported Infra helpers, and its one caller is
the Qwen21 example campaign. The example now imports infra.artifacts,
infra.environment and infra.targets directly, and helper_hashes moves into
it unchanged. The facade had to go before the Infra helpers move to Apps,
because Infra may not import Apps.

helper_hashes hashes every Python file of the installed package, so a new
record no longer lists inferrsi/infra/campaign.py; every other bound path
is unchanged and existing records are not rewritten. The gate fails any
import of inferrsi.infra.campaign, and the installed-wheel check asserts
that it is absent. The example test patches the owning modules.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: GUOGUO <xwdong1998@163.com>
cursor[bot]
cursor Bot previously approved these changes Nov 19, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

PR review verdict — PASS
Reviewed base 092d4f67e8a627afd1fe55abf5a5c825297b9181 and head c74434b0e081fa096ae7b2b5784f2e6940a81f44 (#498 slice 2).

Independent technical/third-party verify as cursor[bot] (collaborator permission none — not a write+ eligible Approver under docs/agent-collaboration.md; this is not a dual-tip / merge-ready claim). Author Dong1017 is ineligible; tip pair is zengchuang-hw Approve on the same head. Merge stays with Dong always-on / write+ humans once required checks and a write+ independent Approve are satisfied.

Verified:

  • Pure git mv of infra/processes.py → harness/serving/server.py and infra/http.py → harness/serving/http.py; image.py only changes the relative post_json import; emptied model/protocols removed with no forwarders.
  • harness/serving/__init__.py imports nothing; infra/campaign.py drops launch_server/stop_server; example imports the new server path.
  • Runtime identity binds harness/serving/server.py (not infra/processes.py); pre-move plan fixture refuses status/recover with exit 2 and unchanged plan bytes; changed installed server bytes also refuse an untouched plan.
  • RETIRED_MODULES covers inferrsi.model.protocols, inferrsi.infra.processes, inferrsi.infra.http; gate + check_installed.py cover old paths and isolated image-client import.
  • Local targeted: 175 passed, 4 skipped, 330 subtests.
  • Ready 44457533401: full-check 3.10/3.11 5313 passed, 37 skipped, 672 subtests; installed-package / browser / references / declarations / advisory hosts success.

The command probes, the environment facts API, dependency and storage
facts, device discovery and source identity serve the Apps host binding,
so they move from infra/ to a new apps/host package with no forwarder or
alias: commands.py, inspection.py, environment.py, platforms/ and
targets/. Only inspection.py changes, in the one import line that reads
the neutral data leaf one package level deeper.

The permanent neutral-leaf importer rule moves with its file in the same
change. LEAF_IMPORTERS and technical_leaf.permanent_importers name
inferrsi.apps.host.inspection, the old module is retired, and no state
admits two importers. The manifest keeps the A1 state unchanged in
revision_history and every leaf lock unchanged. The negative controls
move with the importer. The apps/host package keeps Infra's limit: the
gate fails any path from it to a Knowledge, Harness or Benchmark module.

Callers, the example campaign, tests, the installed-wheel check, docs and
CHANGELOG use the new paths. infra/ now holds only artifacts.py.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: GUOGUO <xwdong1998@163.com>
Resolve the CHANGELOG conflict with the contract-v1 pattern entry by
keeping both entries. No retired path is used by the merged changes.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: GUOGUO <xwdong1998@163.com>
@Dong1017
Dong1017 dismissed stale reviews from cursor[bot] and zengchuang-hw via 6f151a7 November 19, 2026 06:49
@Dong1017

Dong1017 commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

New head: 6f151a7aab81ed6d6dd8faba4c1d7e2dc490b762.

This push voided the approvals given at c74434b (cursor[bot] and zengchuang-hw).

The PR had become conflicting with main, so 6f151a7 merges main 9b81c9b (#480, #508 and #514) with an ordinary signed-off merge commit. No rebase and no force push.

  • Conflict: the only one was in CHANGELOG.md, where the Anchor contract schema patterns at the end of input #514 contract-pattern entry sat at the same place as this slice's entry. Both entries are kept unchanged.
  • Code: no source or test line of this PR changed in the merge.
  • Retired paths: none of the merged changes uses them. A search for infra.processes, infra.http, model.protocols and launch_server outside the moved modules and their tests finds only the pinned pre-move fixture.

Evidence:

  • On the merged tree, first_wave_report() gives violations == () and blockers == ().
  • Ruff 0.17.5 passes.
  • Locally, the three runtime-identity tests and test_target_module_import_gate.py pass.
  • The ready lane on 6f151a7 is the full-suite proof.

The two-runtime and installed-drift evidence in issuecomment-6999697086 was taken at 25df477 → f50e27e.

#480 changed several files that the runtime identity hashes: harness/local_process.py, harness/optimization.py, harness/candidates.py and harness/optimization_session.py. So that evidence does not bind this head. I am rerunning the same check with the current main 9b81c9b as the old runtime and 6f151a7 as the new one, and will post the results here.

Edited: the first version said the covered runtime files did not change in the merge. That was wrong.

@Dong1017
Dong1017 enabled auto-merge (squash) November 19, 2026 06:55
@Dong1017

Copy link
Copy Markdown
Collaborator Author

@zengchuang-hw can you review and approve again?

The test imported artifacts and targets from inferrsi.infra on one line;
targets moved to inferrsi.apps.host in this slice.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: GUOGUO <xwdong1998@163.com>
cursor[bot]
cursor Bot previously approved these changes Nov 19, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

PR review verdict — PASS
Reviewed base 9b81c9ba1d4d1f7d45bd039a7c02ac2f01859426 and head 6f151a7aab81ed6d6dd8faba4c1d7e2dc490b762.

Re-verify after merge of main voided tip Approves at c74434b0…. Head is an ordinary merge of main 9b81c9b (#480/#508/#514) onto the serving slice; serving move content unchanged vs prior PASS tip.

Verified:

  • harness/serving/{server,http,image}.py present; __init__.py imports nothing
  • Retired live paths infra.processes / infra.http / model.protocols absent; gate + installed-wheel checks cover them
  • _runtime_identity() hashes harness/serving/server.py (not infra/processes.py)
  • Local targeted: 175 passed, 4 skipped, 330 subtests
  • Ready 44474977344: full-check 3.10/3.11, installed-package, dashboard-browser, hosts, pr-references success; declarations 44475212054 success

Technical/third-party verify only (cursor[bot] permission none). Not a write+ eligible Approver claim; not dual-tip / merge-ready under agent-collaboration. Merge still needs write+ independent Approve — left to Dong always-on / write+ humans. Dong1017 is author so this is first formal cursor vote on tip.

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO PASS

应本轮请求增量复核:c74434b0e081fa096ae7b2b5784f2e6940a81f44 → 6f151a7aab81ed6d6dd8faba4c1d7e2dc490b762(上轮检视)。

迁移逻辑与退役路径检查仍在,CHANGELOG 两项都保留;未发现新增确定性实现缺陷。但合入 main 带入了 runtime identity 覆盖的四个文件更新,尤其 session_command 会在身份检查前读取 campaign manifest 并可能分流 service-reuse。此前的两运行时证据 25df477 → f50e27e 不能证明新组合仍满足 #498 的旧 session 兼容要求。

批准前只需补当前 9b81c9ba1d4d1f7d45bd039a7c02ac2f01859426 → 6f151a7aab81ed6d6dd8faba4c1d7e2dc490b762 的两运行时记录:同一旧计划在新运行时的 status/recover 拒绝、原运行时仍可恢复、旧计划 canonical bytes 未改写,并能核查没有重执行。不是要求因 SHA 变化重跑无关硬件测试。静态核对了提交变化、运行时入口与 #498 要求;没有执行仓库代码、测试或查 CI。

The R2 gate fixture now proves the host limit that replaced Infra's: a
host module may not reach another Apps module, and the leaf importer's
core check follows the modernized rule. The qwen21 artifact-ownership
test patches the owning module instead of the deleted facade. The
contracts violation string is the resolved package, as `_direct_targets`
records it.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: GUOGUO <xwdong1998@163.com>
Slices 3c and 3a of #498 join this branch, so one PR carries the serving
move and the host move. The manifest base commit is the merged main.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: GUOGUO <xwdong1998@163.com>
@Dong1017 Dong1017 changed the title refactor(harness): move the serving helpers into harness/serving refactor(harness,apps): move serving helpers and host bindings, remove the campaign facade Nov 19, 2026
@Dong1017

Copy link
Copy Markdown
Collaborator Author

New head: 2e7c8630d89d3c14957f5eef6d868b22d2f51146.

This push voided the approvals given at c74434b. The head remains unapproved.

This PR now carries three slices of #498, as the owner decided in #498 (comment):

  • slice 2, the serving helpers to harness/serving/ (unchanged since c74434b);
  • slice 3c, deleting the infra/campaign.py facade and moving helper_hashes into the example campaign;
  • slice 3a, moving the host bindings to apps/host/ and moving the permanent neutral-leaf importer with them.

Slices 3c and 3a ship together because infra/campaign.py re-exports environment and targets, and Infra may not import Apps.

Slice 3a keeps the permanent-rule change explicit. The owner accepted it in the same decision:

  • LEAF_IMPORTERS and technical_leaf.permanent_importers now name inferrsi.apps.host.inspection with the same one name.
  • inferrsi.infra.inspection is retired, so no state admits two importers.
  • The manifest keeps the earlier A1 state unchanged in revision_history, and every leaf lock is unchanged.
  • The gate now fails any path from apps/host/ to a Knowledge, Harness or Benchmark module, or to any Apps module outside the package.

Evidence:

  • Two-runtime check, rerun after the merge with main. The old runtime is current main 9b81c9b and the new one is the merge at 6f151a7:
    • The old runtime starts the session and is interrupted after a round's child completes.
    • The new wheel refuses status and recover with exit 2, and all 15 session files stay byte-identical.
    • The old runtime recovers from the retained receipt with completed_rounds 1 and a single candidate run.
    • In a disposable venv, changing the installed server.py makes status refuse its own untouched plan.
  • A/B on H200 over 79 related test files. Baseline is main 9b81c9b; candidate is this head:
    • Both sides: 127 failed, 46 skipped, 457 subtests.
    • Candidate passed 1868 against the baseline's 1847: the candidate runs seven more tests because three previously failing files collect again.
    • Candidate-only failures: 0. The 127 shared failures are H200 environment failures; most of them are git 2.34 rejecting --no-lazy-fetch in the git-fixture tests.
  • Gate and lint on this head: first_wave_report() gives violations == () and blockers == (); Ruff 0.17.5 passes.

The ready lane on 2e7c863 is the full-suite proof.

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PASS

增量检视 6f151a7aab81ed6d6dd8faba4c1d7e2dc490b762 → 2e7c8630d89d3c14957f5eef6d868b22d2f51146,上轮意见。

上轮证据缺口解除:补充记录覆盖了现有旧/新运行时组合的 status/recover 拒绝、旧计划字节不变、旧运行时从 receipt 恢复且候选仅执行一次,以及 canonical server 字节变化被拒绝。此增量没有再改 runtime identity 的输入文件。

实际新增 3a/3c 与 #498 的范围决定一致:host 实现迁移、facade 删除,无反向依赖或转发壳;neutral-leaf 规则仅保留新 importer,gate、manifest、旧路径负例同步。非阻塞:PR 正文和 CHANGELOG 中的 3c 旧路径可更新为实际的 apps.host.*。

已静态检查增量、规则和现有试验记录,未自行执行仓库或测试,未查询 CI。批准限本次切片,不代表 #498 整体验收。

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

PR review verdict — PASS
Reviewed base 9b81c9ba1d4d1f7d45bd039a7c02ac2f01859426 and head 2e7c8630d89d3c14957f5eef6d868b22d2f51146.

Tip re-verify after prior cursor Approve on 6f151a7a… was dismissed. Delta since that PASS moves host bindings infra/{commands,environment,inspection,platforms,targets} → apps/host/, deletes the infra.campaign import facade, and updates callers/docs/tests. Local targeted suites: 295 passed, 5 skipped. Ready green on tip (44487819041).

Author is Dong1017 → first formal cursor tip vote (Dong ineligible). Technical/third-party verify only (cursor[bot] permission none) — not a write+ eligible Approver / dual tip / merge-ready claim. Merge stays with Dong always-on / write+ humans (zeng tip Approve already present).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:harness Harness module: profile, A/B loop, quality gates, evidence reports kind:task Bounded delivery task with a delegated slice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants