mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-11 04:00:38 +00:00
Merge frozen native containment master f6132bd into V3 repair
Preserve the root V3 current-writer, PTC dispatch identity, and reliability fixes while incorporating provider-owned native ranges and the private packaged runner bootstrap. Refresh only the current cordis-inspect-jsdoc V3 owner through the built headless profile so upstream subprocess API coverage is exercised. Preserve incoming master V2 bytes and all other fixtures and benchmark thresholds.
This commit is contained in:
@@ -769,7 +769,7 @@ def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument(
|
||||
"--scenario",
|
||||
choices=("all", "sdk-default", "sdk-custom", "sdk-minimal", "sdk-fs-search", "sdk-spawn-node", "sdk-mcp", "sdk-snapshot", "sdk-restart", "sdk-profile-plugin", "sdk-live", "direct"),
|
||||
choices=("all", "sdk-default", "sdk-custom", "sdk-minimal", "sdk-fs-search", "sdk-spawn-node", "sdk-mcp", "sdk-snapshot", "sdk-restart", "sdk-profile-plugin", "sdk-live", "runner", "direct"),
|
||||
default="all",
|
||||
)
|
||||
parser.add_argument("--exe", type=Path)
|
||||
@@ -788,13 +788,20 @@ def main() -> None:
|
||||
parser.error("--scenario sdk-profile-plugin requires --installed-wheel")
|
||||
if args.installed_wheel:
|
||||
args.exe = assert_installed_wheel_environment()
|
||||
if args.scenario in {"all", "sdk-custom", "sdk-minimal", "sdk-fs-search", "sdk-spawn-node", "sdk-snapshot", "sdk-restart", "direct"} and args.exe is None:
|
||||
parser.error("--exe is required for custom, minimal, snapshot, and direct scenarios")
|
||||
if args.scenario in {"all", "sdk-custom", "sdk-minimal", "sdk-fs-search", "sdk-spawn-node", "sdk-snapshot", "sdk-restart", "runner", "direct"} and args.exe is None:
|
||||
parser.error("--exe is required for custom, minimal, fs-search, spawn-node, snapshot, restart, runner, and direct scenarios")
|
||||
if args.update_snapshots and args.scenario not in {"all", "sdk-minimal", "sdk-snapshot", "sdk-restart"}:
|
||||
parser.error("--update-snapshots requires --scenario sdk-minimal, sdk-snapshot, sdk-restart, or all")
|
||||
if args.exe is not None and not args.exe.is_file():
|
||||
parser.error(f"runtime executable does not exist: {args.exe}")
|
||||
|
||||
if args.scenario in {"all", "runner"}:
|
||||
assert args.exe is not None
|
||||
smoke_packaged_runner(args.exe.resolve())
|
||||
if args.scenario == "runner":
|
||||
print("smoke-python-runtime: runner passed")
|
||||
return
|
||||
|
||||
if args.scenario == "sdk-live":
|
||||
smoke_sdk_live()
|
||||
print("smoke-python-runtime: sdk-live passed")
|
||||
@@ -1435,6 +1442,104 @@ def smoke_direct(base_url: str, executable: Path) -> None:
|
||||
assert_session_log(sessions, root, EXPECTED_TEXT)
|
||||
|
||||
|
||||
def smoke_packaged_runner(executable: Path) -> None:
|
||||
"""Exercise the private subprocess runner through the single-file entry."""
|
||||
with tempfile.TemporaryDirectory(prefix="dsh-packaged-runner-") as temporary:
|
||||
root = Path(temporary).resolve()
|
||||
target_script = (
|
||||
"import os,sys; "
|
||||
"ok = (os.getcwd() == os.environ['PACKAGED_RUNNER_EXPECTED_CWD'] "
|
||||
"and os.environ.get('DSH_SUBPROCESS_RUNNER') == 'target-collision-restored'); "
|
||||
"sys.exit(7 if ok else 9)"
|
||||
)
|
||||
if not IS_WINDOWS:
|
||||
request_path = root / "launch-request.json"
|
||||
target_env = dict(os.environ)
|
||||
target_env["DSH_SUBPROCESS_RUNNER"] = "target-collision-restored"
|
||||
target_env["PACKAGED_RUNNER_EXPECTED_CWD"] = str(root)
|
||||
request_path.write_text(
|
||||
json.dumps({"cwd": str(root), "env": target_env}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
request_path.chmod(0o600)
|
||||
environment = dict(os.environ)
|
||||
environment["DSH_SUBPROCESS_RUNNER"] = str(request_path)
|
||||
result = subprocess.run(
|
||||
[str(executable), "--", sys.executable, "-c", target_script],
|
||||
cwd=root,
|
||||
env=environment,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30,
|
||||
check=False,
|
||||
)
|
||||
if result.returncode != 7 or request_path.exists() or (root / "startup-error.json").exists():
|
||||
raise AssertionError(
|
||||
"packaged POSIX runner failed: "
|
||||
f"exit={result.returncode}; stdout={result.stdout!r}; stderr={result.stderr!r}"
|
||||
)
|
||||
return
|
||||
|
||||
node = shutil.which("node")
|
||||
if node is None:
|
||||
raise AssertionError("packaged Windows runner smoke requires node on PATH")
|
||||
helper = root / "windows-runner-smoke.mjs"
|
||||
helper.write_text(
|
||||
"""import { spawn } from 'node:child_process'
|
||||
const [runtime, target, cwd, targetScript] = process.argv.slice(2)
|
||||
const child = spawn(runtime, ['--', target, '-c', targetScript], {
|
||||
cwd,
|
||||
env: { ...process.env, DSH_SUBPROCESS_RUNNER: 'windows' },
|
||||
stdio: ['ignore', 'ignore', 'ignore', 'ipc', 'pipe', 'pipe', 'pipe'],
|
||||
})
|
||||
const messages = []
|
||||
let stdout = ''
|
||||
let stderr = ''
|
||||
child.stdio[4].destroy()
|
||||
child.stdio[5].on('data', chunk => { stdout += chunk.toString() })
|
||||
child.stdio[6].on('data', chunk => { stderr += chunk.toString() })
|
||||
child.on('message', message => { messages.push(message) })
|
||||
const result = await new Promise((resolve, reject) => {
|
||||
child.once('error', reject)
|
||||
child.once('spawn', () => {
|
||||
child.send({
|
||||
type: 'start',
|
||||
cwd,
|
||||
env: {
|
||||
...process.env,
|
||||
DSH_SUBPROCESS_RUNNER: 'target-collision-restored',
|
||||
PACKAGED_RUNNER_EXPECTED_CWD: cwd,
|
||||
},
|
||||
}, error => { if (error) reject(error) })
|
||||
})
|
||||
child.once('close', (exitCode, signal) => { resolve({ exitCode, signal }) })
|
||||
})
|
||||
process.stdout.write(JSON.stringify({ ...result, messages, stdout, stderr }))
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
helper_result = subprocess.run(
|
||||
[node, str(helper), str(executable), sys.executable, str(root), target_script],
|
||||
cwd=root,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30,
|
||||
check=False,
|
||||
)
|
||||
if helper_result.returncode != 0:
|
||||
raise AssertionError(f"packaged Windows runner helper failed: {helper_result.stderr}")
|
||||
observed = json.loads(helper_result.stdout)
|
||||
expected = {
|
||||
"exitCode": 0,
|
||||
"signal": None,
|
||||
"messages": [{"type": "target-exit", "exitCode": 7}],
|
||||
"stdout": "",
|
||||
"stderr": "",
|
||||
}
|
||||
if observed != expected:
|
||||
raise AssertionError(f"packaged Windows runner returned unexpected facts: {observed}")
|
||||
|
||||
|
||||
def is_idle_notification(message: dict[str, object]) -> bool:
|
||||
"""Return whether a JSON-RPC notification marks a session idle."""
|
||||
params = message.get("params")
|
||||
|
||||
Reference in New Issue
Block a user