Skip to content

Make Codex and Claude Code subscriptions go further: a local model router that gives routine agent work to economical models and keeps your strongest model for the hard parts.

fix(validation): clarify harness evidence and Desktop wrapper options (#209)

澄潭eb821b8cb24e
diff --git a/docs/code-map/testing.md b/docs/code-map/testing.md
index 8feac124..49443269 100644
--- a/docs/code-map/testing.md
+++ b/docs/code-map/testing.md
@@ -221,6 +221,15 @@ Hosted prerequisite installation belongs to
[`test-ci-setup.py`](../../scripts/test-ci-setup.py) covers Ubuntu source selection
and bounded failure handling; the real hosted matrix verifies package installation.
+Hosted shard inventory and harness policy belong to
+[ci-shards.py](../../scripts/ci-shards.py); [ci-run.py](../../scripts/ci-run.py)
+captures launch concurrency settings for the [shared report](../../scripts/validation-report.py).
+See [the hosted guide](../github-actions-validation.md#rust-test-concurrency) for
+the explicit process-target exception and unknown effective concurrency.
+The [host adapter](../../scripts/validation-host.py) derives admitted local/Desktop
+run help from the [local runner parser](../../scripts/local-rust.py), while retaining
+configured repository/jobs and Desktop origin-fetch admission.
+
1. Run `python3 scripts/test-plan.py --base <exact-base>`; use `--integration` for
branch integration. Review affected consumers and explain semantic adjustments.
2. Follow the selected commands and [CI definitions](../github-actions-validation.md).
diff --git a/docs/github-actions-validation.md b/docs/github-actions-validation.md
index 57e375e3..6a6b0079 100644
--- a/docs/github-actions-validation.md
+++ b/docs/github-actions-validation.md
@@ -201,6 +201,28 @@ Build concurrency defaults to the runner CPU count; incremental compilation is
disabled. Every job keeps its own checkout-local Cargo output. The hosted job is
disposable, so there is no persistent worktree cleanup service.
+### Rust test concurrency
+
+Compiler jobs and host CPU count do not describe effective test concurrency.
+Full hosted unit/binary, integration and doctest bundles use the `hosted-default` policy:
+they pass no `--test-threads` override, including for CPA bridge unit tests and
+process-backed CLI, daemon and Gateway targets. Libtest can select its default or
+consume `RUST_TEST_THREADS` from the launch environment. The report retains these
+settings separately and leaves effective runtime concurrency explicitly unknown.
+
+This is an explicit hosted exception to the focused/SSH process-target one-thread
+policy and the workspace DAG's per-target bounds. The hosted bundles retain their
+existing workspace/all-features graph and complete target inventory; the runner
+does not split those bundles or silently insert a focused target's bound. Affected
+plans and explicit gates retain their selected commands, including any explicit
+harness bound, under `selected-command`. Shard planning tests cover both policies.
+
+Use these recorded differences when comparing a focused pass with a hosted failure.
+A later pass does not establish that concurrency caused an earlier failure.
+Changing the hosted bounds requires separate execution evidence; neither a retry
+nor this diagnostic metadata changes production deadlines, assertions or the
+meaning of an earlier failure.
+
## Evidence and failures
Each invocation checks the full expected SHA against HEAD and rejects tracked
@@ -213,7 +235,16 @@ not establish product scenario acceptance.
`artifacts/ci/<name>/` contains the complete command log and JSON result, including
revision, CPU count, platform, timestamps, and Cargo/Rust versions for Cargo
-commands. Failure prints the log tail; Actions uploads available artifacts even
+commands. Rust test results and derived reports also retain `harness_concurrency`:
+the requested thread arguments (an empty list means omitted), the launch
+`RUST_TEST_THREADS` value and whether that environment was observed, the configured
+limit/source when unambiguous, the applicable policy, and an unknown effective
+thread count. A configured limit is not measured active concurrency: Cargo config,
+custom harnesses and test-created threads may change runtime behavior. Older or
+non-hosted records without an environment snapshot remain unknown rather than
+being reconstructed from today's environment or CPU count.
+
+Failure prints the log tail; Actions uploads available artifacts even
when a check fails. Each shard uses a distinct artifact name; the aggregate job does not
replace those per-command records. Timeout and cancellation stop the command process group
before removing its private short TMPDIR. A forcibly terminated VM cannot be
diff --git a/docs/validation-routing.md b/docs/validation-routing.md
index 83f1f750..7c9b878f 100644
--- a/docs/validation-routing.md
+++ b/docs/validation-routing.md
@@ -81,6 +81,16 @@ option; the SSH backend workbench keeps its own queue. Cleanup still fails fast
when another owner is active. Waiting never starts a second compiler or changes
the exact candidate, default target directory or evidence rules.
+`desktop run --help` derives its admitted options from the caller's runner parser,
+omitting `--source`, `--repo` and `--jobs`. Configure repository and compiler jobs
+in `validation.json`; full or abbreviated overrides are rejected, with a
+source-specific reason for source overrides.
+Desktop always fetches from origin, even on a local Mac, so push the exact candidate
+after public-content checks and omit `--source`. Local backend help follows the
+same wrapper-owned-option rule and retains local committed-source selection.
+The `--sha` help reflects the caller-HEAD default; `--wait-for-lock` remains available.
+Help does not contact the execution host or require its checkout to be updated.
+
Arguments after `backend`/`desktop` otherwise follow the selected runner's CLI.
SSH backend returns a queued run ID and supports `wait/status/logs/cleanup/gc`.
Use `backend wait RUN_ID --timeout 50` for one compact terminal or timeout
diff --git a/scripts/ci-run.py b/scripts/ci-run.py
index 77e99933..1cefaa2f 100644
--- a/scripts/ci-run.py
+++ b/scripts/ci-run.py
@@ -24,7 +24,8 @@ def test_counts(log):
(sum(int(row[i]) for row in rows) for i in range(3))))
-def execute(command, root, output, expected_sha, timeout, require_tests=False, feedback=None):
+def execute(command, root, output, expected_sha, timeout, require_tests=False, feedback=None,
+ harness_policy="selected-command"):
output.mkdir(parents=True, exist_ok=False)
result = {"id": output.name, "command": command, "expected_sha": expected_sha,
"process_exit": None, "status": "failed", "scenario_state": "not_assessed",
@@ -58,6 +59,7 @@ def execute(command, root, output, expected_sha, timeout, require_tests=False, f
env.setdefault("CARGO_BUILD_JOBS", str(max(1, os.cpu_count() or 1)))
env["CARGO_INCREMENTAL"] = "0"
result["build_jobs"] = env["CARGO_BUILD_JOBS"]
+ result["harness_concurrency"] = reporting.harness_concurrency(command, env, harness_policy)
if command[0] == "cargo":
metadata = json.loads(subprocess.check_output(
["cargo", "metadata", "--locked", "--no-deps", "--format-version", "1"],
@@ -116,6 +118,8 @@ def main():
parser.add_argument("--expected-sha", default=os.environ.get("GITHUB_SHA"), required=False)
parser.add_argument("--timeout", type=int, default=3600)
parser.add_argument("--require-tests", action="store_true")
+ parser.add_argument("--harness-policy", choices=("selected-command", "hosted-default"),
+ default="selected-command", help="Documented harness policy; does not change the command")
reporting.add_arguments(parser)
parser.add_argument("command", nargs=argparse.REMAINDER)
args = parser.parse_args()
@@ -124,7 +128,7 @@ def main():
parser.error("provide a safe name, exact SHA, positive timeout, and command")
root = Path(subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip()).resolve()
return execute(command, root, root / "artifacts/ci" / args.name,
- args.expected_sha, args.timeout, args.require_tests, reporting.options(args))
+ args.expected_sha, args.timeout, args.require_tests, reporting.options(args), args.harness_policy)
if __name__ == "__main__":
diff --git a/scripts/ci-shards.py b/scripts/ci-shards.py
index f5c97055..8684160c 100755
--- a/scripts/ci-shards.py
+++ b/scripts/ci-shards.py
@@ -234,6 +234,10 @@ def run_commands(shard, commands):
argv = [sys.executable, str(runner), "--name", f"{shard}-{index}", "--phase", "final"]
if command[:2] == ["cargo", "test"]:
argv.append("--require-tests")
+ # Full workspace bundles retain libtest defaults, including process
+ # targets. Affected/gate commands retain their planner-selected flags.
+ policy = "hosted-default" if command[:len(FULL_TEST)] == FULL_TEST else "selected-command"
+ argv.extend(["--harness-policy", policy])
completed = subprocess.run([*argv, "--", *command])
if completed.returncode:
return completed.returncode
diff --git a/scripts/local-rust.py b/scripts/local-rust.py
index f65c00f7..90c2dafe 100644
--- a/scripts/local-rust.py
+++ b/scripts/local-rust.py
@@ -392,7 +392,7 @@ def run(store, args, prepare=None, on_record=None):
return store.load(key)
-def main():
+def argument_parser():
parser = argparse.ArgumentParser(description=__doc__)
sub = parser.add_subparsers(dest="action", required=True)
p = sub.add_parser("run", help="Exact committed candidate in an isolated worktree")
@@ -426,6 +426,11 @@ def main():
p.add_argument("id")
p.add_argument("--verdict", choices=("green", "expected_red", "red"), required=True)
p.add_argument("--evidence-saved", action="store_true", required=True)
+ return parser
+
+
+def main():
+ parser = argument_parser()
args = parser.parse_args()
store = Store()
if args.action == "run":
diff --git a/scripts/test-ci-run.py b/scripts/test-ci-run.py
index f78aa0ea..a23e2fb9 100644
--- a/scripts/test-ci-run.py
+++ b/scripts/test-ci-run.py
@@ -92,6 +92,45 @@ class RunnerTests(unittest.TestCase):
self.assertEqual(status, 1)
self.assertIsNone(result["process_exit"])
+ def test_cargo_launch_records_environment_and_requested_limit_without_measuring_threads(self):
+ # A real child process observes the same environment that result/report record.
+ # This is runner evidence, not execution of HiRoute Rust tests.
+ binary = self.root / "bin"
+ binary.mkdir()
+ fixture = ("#!" + sys.executable + "\nimport json, os, sys\n"
+ "if 'metadata' in sys.argv:\n"
+ " print(json.dumps({'target_directory': os.path.join(os.getcwd(), 'target')}))\n"
+ "elif '--version' in sys.argv:\n print('fixture toolchain')\n"
+ "else:\n print('RUST_TEST_THREADS=' + str(os.environ.get('RUST_TEST_THREADS')))\n"
+ " print('test result: ok. 1 passed; 0 failed; 0 ignored')\n")
+ for name in ("cargo", "rustc"):
+ (binary / name).write_text(fixture)
+ (binary / name).chmod(0o755)
+ cases = [(None, [], "default", None), ("4", [], "environment", 4),
+ ("4", ["--", "--test-threads", "2"], "argument", 2)]
+ for index, (environment, arguments, source, limit) in enumerate(cases):
+ output = self.root / ("cargo-" + str(index))
+ with self.subTest(source=source), patch.dict(os.environ, {
+ "PATH": str(binary) + os.pathsep + os.environ["PATH"]}):
+ os.environ.pop("RUST_TEST_THREADS", None)
+ if environment is not None:
+ os.environ["RUST_TEST_THREADS"] = environment
+ with patch.object(ci.os, "cpu_count", return_value=16):
+ self.assertEqual(ci.execute(["cargo", "test", *arguments], self.root, output,
+ self.sha, 5, True), 0)
+ result = json.loads((output / "result.json").read_text())
+ report = json.loads((output / "validation-report.json").read_text())
+ harness = result["harness_concurrency"]
+ self.assertEqual(harness["environment_threads"], environment)
+ self.assertEqual(harness["configuration_source"], source)
+ self.assertEqual(harness["configured_thread_limit"], limit)
+ self.assertEqual(harness["policy"], "selected-command")
+ self.assertIsNone(harness["effective_threads"])
+ self.assertEqual(harness["effective_state"], "unknown")
+ self.assertEqual(report["context"]["harness_concurrency"], harness)
+ self.assertIn("RUST_TEST_THREADS=" + str(environment), (output / "command.log").read_text())
+ self.assertIn("runtime concurrency is unknown", (output / "validation-report.md").read_text())
+
if __name__ == "__main__":
unittest.main()
diff --git a/scripts/test-ci-shards.py b/scripts/test-ci-shards.py
index e50651e3..6e08f062 100755
--- a/scripts/test-ci-shards.py
+++ b/scripts/test-ci-shards.py
@@ -8,6 +8,7 @@ import json
import os
from pathlib import Path
import tempfile
+import subprocess
import unittest
from unittest.mock import patch
@@ -107,6 +108,32 @@ class ShardPlanningTests(unittest.TestCase):
with self.assertRaisesRegex(ValueError, "restricted to GitHub Actions"):
shards.run_commands("quality", [["true"]])
+ def test_full_hosted_bundles_preserve_default_process_policy_and_complete_selectors(self):
+ commands = shards.full_commands(full_plan(), self.metadata)
+ for shard in ["unit", *shards.INTEGRATION_SHARDS]:
+ command = commands[shard][0]
+ self.assertNotIn("--", command)
+ self.assertEqual(command[:len(shards.FULL_TEST)], shards.FULL_TEST)
+ if shard != "unit":
+ selected = set(command[len(shards.FULL_TEST) + 1::2])
+ self.assertEqual(selected, {target for _, target in shards.INTEGRATION_SHARDS[shard]})
+ with patch.dict(os.environ, {"GITHUB_ACTIONS": "true"}), \
+ patch.object(shards.subprocess, "run", return_value=subprocess.CompletedProcess([], 0)) as run:
+ self.assertEqual(shards.run_commands(shard, [command]), 0)
+ argv = run.call_args.args[0]
+ self.assertEqual(argv[argv.index("--harness-policy") + 1], "hosted-default")
+ self.assertEqual(argv[argv.index("--") + 1:], command)
+
+ def test_affected_command_keeps_its_explicit_thread_policy(self):
+ command = ["cargo", "test", "--locked", "-p", "hiroute-cli", "--test", "service_proxy",
+ "--", "--test-threads=1"]
+ with patch.dict(os.environ, {"GITHUB_ACTIONS": "true"}), \
+ patch.object(shards.subprocess, "run", return_value=subprocess.CompletedProcess([], 0)) as run:
+ self.assertEqual(shards.run_commands("affected", [command]), 0)
+ argv = run.call_args.args[0]
+ self.assertEqual(argv[argv.index("--harness-policy") + 1], "selected-command")
+ self.assertEqual(argv[argv.index("--") + 1:], command)
+
if __name__ == "__main__":
unittest.main()
diff --git a/scripts/test-validation-report.py b/scripts/test-validation-report.py
index bd053307..74ece80c 100644
--- a/scripts/test-validation-report.py
+++ b/scripts/test-validation-report.py
@@ -111,6 +111,42 @@ class Parsing(unittest.TestCase):
class Feedback(unittest.TestCase):
+ def test_harness_settings_distinguish_omitted_environment_argument_and_unknown(self):
+ command = ["cargo", "test", "--locked"]
+ omitted = report.harness_concurrency(command, {})
+ self.assertEqual(omitted["requested_threads"], [])
+ self.assertTrue(omitted["environment_recorded"])
+ self.assertEqual(omitted["configuration_source"], "default")
+ self.assertIsNone(omitted["configured_thread_limit"])
+ old = report.context(row(cpu_count=16))["harness_concurrency"]
+ self.assertFalse(old["environment_recorded"])
+ self.assertEqual(old["configuration_source"], "unknown")
+ self.assertIsNone(old["effective_threads"])
+ for arguments in (["--test-threads=2"], ["--test-threads", "2"]):
+ context = report.harness_concurrency([*command, "--", *arguments], {"RUST_TEST_THREADS": "8"})
+ self.assertEqual(context["requested_threads"], ["2"])
+ self.assertEqual(context["environment_threads"], "8")
+ self.assertEqual(context["configuration_source"], "argument")
+ self.assertEqual(context["configured_thread_limit"], 2)
+ self.assertIsNone(context["effective_threads"])
+
+ def test_ambiguous_or_invalid_thread_setting_does_not_invent_limit(self):
+ for arguments in (["--test-threads"], ["--test-threads=0"], ["--test-threads=oops"],
+ ["--test-threads=1", "--test-threads=2"]):
+ context = report.harness_concurrency(["cargo", "test", "--", *arguments], {"RUST_TEST_THREADS": "8"})
+ self.assertIsNone(context["configured_thread_limit"])
+ self.assertIsNone(context["effective_threads"])
+ self.assertIsNone(report.harness_concurrency(["cargo", "check"], {}))
+
+ def test_same_command_with_different_launch_environment_reports_context_gap(self):
+ command = row()["command"]
+ focused = report.build_report(row(harness_concurrency=report.harness_concurrency(
+ command, {"RUST_TEST_THREADS": "1"})), target())
+ final = report.build_report(row(phase="final", process_exit=101,
+ harness_concurrency=report.harness_concurrency(command, {})),
+ target(failed=True), [focused])
+ self.assertEqual(final["findings"][0]["context_differences"], ["harness_concurrency"])
+
def test_child_failures_are_not_attributed_to_parent_regressions(self):
focused = report.build_report(row(), target())
# A parent can intentionally spawn a failing test and still pass its own assertion.
diff --git a/scripts/test-validation.py b/scripts/test-validation.py
index 36e0693d..5f42ea67 100644
--- a/scripts/test-validation.py
+++ b/scripts/test-validation.py
@@ -4,6 +4,7 @@ import contextlib
import importlib.util
import io
import json
+import re
import os
from pathlib import Path
import subprocess
@@ -299,6 +300,87 @@ pilot.record('build:' + sys.argv[1])
self.assertNotIn('--jobs', argv)
self.assertNotIn('--cargo-only', argv)
+ def test_desktop_help_uses_real_runner_options_but_omits_wrapper_owned_values(self):
+ repo = Path(host.__file__).resolve().parent.parent
+ direct = subprocess.run([sys.executable, str(repo / 'scripts/local-rust.py'), 'run', '--help'],
+ text=True, capture_output=True, timeout=10, check=True).stdout
+ for transport in ('local', 'ssh'):
+ target = {'transport': transport, 'repo': str(self.root)}
+ with self.subTest(transport=transport), patch.object(m.subprocess, 'run') as run, \
+ patch.object(m.subprocess, 'check_output') as git, contextlib.redirect_stdout(io.StringIO()) as output:
+ self.assertEqual(m.dispatch({'desktop': target}, 'desktop', ['run', '--help']), 0)
+ run.assert_not_called()
+ git.assert_not_called()
+ help_text = output.getvalue()
+ self.assertIn('validation.py desktop run', help_text)
+ self.assertIn('exact pushed candidate from origin', help_text)
+ self.assertIn('local Mac', help_text)
+ self.assertIn("defaults to the caller's HEAD", help_text)
+ self.assertIn('[--sha SHA]', help_text)
+ for option in ('--source', '--repo', '--jobs'):
+ self.assertIn(option, direct)
+ self.assertNotIn(option, help_text)
+ flags = lambda value: set(re.findall(r'(?m)^ (?:-h, )?(--[\w-]+)', value))
+ self.assertEqual(flags(help_text), flags(direct) - {'--source', '--repo', '--jobs'})
+ self.assertIn('--wait-for-lock', help_text)
+
+ def test_real_validation_cli_desktop_help_works_before_contacting_execution_host(self):
+ self.write({'desktop': {'transport': 'ssh', 'host': 'unreachable-help-fixture', 'repo': '/missing/checkout'}})
+ result = subprocess.run([sys.executable, str(Path(m.__file__)), '--config', str(self.config),
+ 'desktop', 'run', '--help'], text=True, capture_output=True, timeout=5)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertIn('exact pushed candidate from origin', result.stdout)
+ self.assertNotIn('--source', result.stdout)
+
+ def test_source_overrides_explain_desktop_origin_and_local_backend_separately(self):
+ for action, expected in [('desktop', 'exact pushed candidate from origin'),
+ ('backend', 'Local backend selects committed source')]:
+ for override in (['--source', 'local'], ['--source=origin']):
+ p = self.payload(action, ['run', *override])
+ p['name'] = action
+ with self.subTest(action=action, override=override), \
+ patch.object(host.sys, 'platform', 'darwin'), patch.object(host.subprocess, 'run') as run:
+ with self.assertRaisesRegex(ValueError, expected):
+ host.execute(p)
+ run.assert_not_called()
+ for override in (['--repo', '/other'], ['--jobs=7']):
+ p = self.payload('desktop', ['run', *override])
+ p['name'] = 'desktop'
+ with patch.object(host.sys, 'platform', 'darwin'), self.assertRaisesRegex(ValueError, 'validation.json'):
+ host.execute(p)
+
+ def test_cargo_help_and_options_are_not_interpreted_as_wrapper_overrides(self):
+ p = self.payload('desktop', ['run', '--ref', 'refs/heads/test', '--', 'cargo', 'check', '--help', '--jobs=3'])
+ p['name'] = 'desktop'
+ with patch.object(host.sys, 'platform', 'darwin'), \
+ patch.object(host.subprocess, 'run', return_value=subprocess.CompletedProcess([], 0)) as run:
+ self.assertEqual(host.execute(p), 0)
+ argv = run.call_args.args[0]
+ self.assertEqual(argv[argv.index('--') + 1:], ['cargo', 'check', '--help', '--jobs=3'])
+
+ def test_real_parser_abbreviations_cannot_override_wrapper_source_or_configuration(self):
+ spec = importlib.util.spec_from_file_location('local_rust', Path(m.__file__).with_name('local-rust.py'))
+ runner = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(runner)
+ prefix = ['run', '--ref', 'refs/heads/test', '--sha', 'a' * 40]
+ for canonical, abbreviations, value, expected in (
+ ('source', ['--so', '--sou', '--sour'], 'local', 'exact pushed candidate from origin'),
+ ('jobs', ['--j', '--jo', '--job'], '7', 'validation.json'),
+ ('repo', ['--rep'], '/other/repository', 'validation.json')):
+ for abbreviation in abbreviations:
+ for override in ([abbreviation, value], [abbreviation + '=' + value]):
+ args = [*prefix, *override, '--', 'cargo', 'check']
+ # Positive control: these are accepted overrides in the real direct runner.
+ parsed = runner.argument_parser().parse_args(args)
+ self.assertEqual(str(getattr(parsed, canonical)), value)
+ p = self.payload('desktop', args)
+ p['name'] = 'desktop'
+ with self.subTest(override=override), patch.object(host.sys, 'platform', 'darwin'), \
+ patch.object(host.subprocess, 'run') as run:
+ with self.assertRaisesRegex(ValueError, expected):
+ host.execute(p)
+ run.assert_not_called()
+
def test_platform_and_gui_fail_before_starting_product(self):
p = self.payload('pilot', ['start', '--app', '/tmp/app'])
p['name'] = 'desktop'
diff --git a/scripts/validation-host.py b/scripts/validation-host.py
index 761a768e..7b6e499a 100644
--- a/scripts/validation-host.py
+++ b/scripts/validation-host.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Execution-host adapter. Receives a JSON request from validation.py over stdin."""
+import argparse
import hashlib
import importlib.util
import json
@@ -103,6 +104,36 @@ def doctor(payload, repo, env):
return 0 if ready else 2
+def run_help(repo, action):
+ """Derive wrapper help from the caller's actual runner argument parser."""
+ spec = importlib.util.spec_from_file_location("local_rust", repo / "scripts/local-rust.py")
+ runner = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(runner)
+ parser = runner.argument_parser()
+ subcommands = next(item for item in parser._actions if isinstance(item, argparse._SubParsersAction))
+ run = subcommands.choices["run"]
+ run.prog = "validation.py " + action + " run"
+ run.description = ("Desktop always fetches the exact pushed candidate from origin, including on a local Mac."
+ if action == "desktop" else
+ "Local backend selects committed source from the configured repository.")
+ run.epilog = "Configure repository and compiler jobs in validation.json. Pass Cargo arguments after --."
+ for option in run._actions:
+ if option.dest in ("repo", "source", "jobs"):
+ option.help = argparse.SUPPRESS
+ elif option.dest == "sha":
+ option.required = False
+ option.help = "Exact candidate commit (defaults to the caller's HEAD)"
+ run.print_help()
+ return 0
+
+
+def overrides_option(arguments, option):
+ # The runner accepts unambiguous argparse long-option abbreviations. Reject
+ # every prefix here, including ambiguous ones, so none can bypass ownership.
+ return any(value.startswith("--") and option.startswith(value.split("=", 1)[0])
+ for value in arguments)
+
+
def execute(payload):
target = payload["target"]
action = payload["action"]
@@ -133,8 +164,12 @@ def execute(payload):
if arguments[0] == "run":
boundary = arguments.index("--") if "--" in arguments else len(arguments)
options = arguments[:boundary]
- if any(a in ("--repo", "--source", "--jobs") or a.startswith(("--repo=", "--source=", "--jobs=")) for a in options):
- raise ValueError("Configure repo/jobs in validation.json; source follows the selected transport")
+ if overrides_option(options, "--source"):
+ if action == "desktop":
+ raise ValueError("Desktop always fetches the exact pushed candidate from origin, including on a local Mac; omit --source")
+ raise ValueError("Local backend selects committed source from the configured repository; omit --source")
+ if any(overrides_option(options, option) for option in ("--repo", "--jobs")):
+ raise ValueError("Configure repo/jobs in validation.json; omit these command-line overrides")
additions = ["--repo", str(repo)]
if action == "backend":
additions += ["--source", "local"]
diff --git a/scripts/validation-report.py b/scripts/validation-report.py
index 12578caa..1bb57c70 100644
--- a/scripts/validation-report.py
+++ b/scripts/validation-report.py
@@ -161,9 +161,38 @@ def context(record):
profile="release" if "--release" in command else "default",
build_options=build, build_jobs=record.get("build_jobs"),
harness_options=command[command.index("--") + 1:] if "--" in command else [],
+ harness_concurrency=record.get("harness_concurrency", harness_concurrency(command)),
command=command)
+def harness_concurrency(command, environment=None, policy=None):
+ """Record launch settings, never infer measured concurrency from host CPUs.
+
+ Cargo config, custom harnesses and test-created threads can change runtime
+ behavior. Even an explicit libtest limit is configuration, not a measurement.
+ """
+ if command[:2] != ["cargo", "test"]:
+ return None
+ arguments = command[command.index("--") + 1:] if "--" in command else []
+ requested = []
+ for index, argument in enumerate(arguments):
+ if argument == "--test-threads":
+ requested.append(arguments[index + 1] if index + 1 < len(arguments) else None)
+ elif argument.startswith("--test-threads="):
+ requested.append(argument.split("=", 1)[1])
+ inherited = environment.get("RUST_TEST_THREADS") if environment is not None else None
+ source = "argument" if requested else ("environment" if inherited is not None else
+ "default" if environment is not None else "unknown")
+ selected = requested[0] if len(requested) == 1 else inherited if not requested else None
+ limit = int(selected) if isinstance(selected, str) and re.fullmatch(r"[0-9]+", selected) else None
+ if limit is not None and limit < 1:
+ limit = None
+ return dict(requested_threads=requested, environment_threads=inherited,
+ environment_recorded=environment is not None, configured_thread_limit=limit,
+ configuration_source=source, effective_threads=None, effective_state="unknown",
+ policy=policy)
+
+
def compare(report, related):
findings = []
if report["phase"] != "final":
@@ -180,7 +209,7 @@ def compare(report, related):
findings.append(dict(common, kind="repeated_final", action="Explain why this exact final command needed another run."))
if report["process_exit"] in (None, 0) or previous.get("phase") != "focused" or not previous.get("observed_tests_passed"):
continue
- differences = [key for key in ("package_scope", "requested_features", "platform", "architecture", "rustc", "cargo", "profile", "build_options", "build_jobs", "harness_options")
+ differences = [key for key in ("package_scope", "requested_features", "platform", "architecture", "rustc", "cargo", "profile", "build_options", "build_jobs", "harness_options", "harness_concurrency")
if previous.get("context", {}).get(key) != report["context"].get(key)]
unknown = [key for key in ("platform", "architecture", "rustc", "cargo")
if not report["context"].get(key) or not previous.get("context", {}).get(key)]
@@ -279,8 +308,12 @@ def build_report(record, log, related=()):
def markdown(report):
lines = ["# Validation feedback", "", "Candidate: `" + str(report["sha"]) + "`; phase: " + report["phase"],
- "", "Process exit: " + str(report["process_exit"]) + "; observed target report complete: " + str(report["complete"]),
- "", "| Cargo target | Seconds | Passed / failed / ignored | Complete |", "| --- | ---: | --- | --- |"]
+ "", "Process exit: " + str(report["process_exit"]) + "; observed target report complete: " + str(report["complete"])]
+ harness = report["context"].get("harness_concurrency")
+ if harness:
+ lines += ["", "Harness concurrency (launch settings; runtime concurrency is unknown):",
+ "", "```json", json.dumps(harness, indent=2), "```"]
+ lines += ["", "| Cargo target | Seconds | Passed / failed / ignored | Complete |", "| --- | ---: | --- | --- |"]
for module in report["modules"]:
counts = module["counts"]
values = " / ".join(str(counts[k]) for k in ("passed", "failed", "ignored")) if counts else "unknown"
diff --git a/scripts/validation.py b/scripts/validation.py
index d16a0230..89847a65 100644
--- a/scripts/validation.py
+++ b/scripts/validation.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Route build/test tools using ~/.config/hiroute/validation.json."""
import argparse
+import importlib.util
import json
from pathlib import Path
import shlex
@@ -87,6 +88,15 @@ def dispatch(targets, action, arguments, frontend_dist=None, dry_run=False):
if frontend_dist and not (arguments[:1] == ["run"] and (
action == "desktop" or (action == "backend" and target["transport"] == "ssh"))):
raise ValueError("--frontend-dist is only for desktop run or SSH backend run")
+ if action == "desktop" or (action == "backend" and target["transport"] == "local"):
+ options = arguments[:arguments.index("--")] if "--" in arguments else arguments
+ if options[:1] == ["run"] and any(a in ("-h", "--help") for a in options):
+ # Help belongs to the caller's wrapper, just like admission. Do not
+ # require an SSH connection or an upgraded execution-host checkout.
+ spec = importlib.util.spec_from_file_location("validation_host", REPO / "scripts/validation-host.py")
+ host = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(host)
+ return host.run_help(REPO, action)
if action in ("backend", "desktop", "pilot-build"):
arguments = with_candidate(arguments, REPO)
if name == "backend" and target["transport"] == "ssh":