Update external worker audit for FEMLite 0.6.4

This commit is contained in:
Codex
2026-07-05 19:33:05 +08:00
parent 0d3f0fb7cc
commit 11071456a7
6 changed files with 118 additions and 62 deletions
+80 -37
View File
@@ -6,8 +6,29 @@ import subprocess
from pathlib import Path
def run_worker_probe(exe: Path, solver_id: str, case_file: Path) -> dict:
command = [
def run_command(command: list[str]) -> dict:
try:
completed = subprocess.run(command, text=True, capture_output=True, timeout=10.0)
except subprocess.TimeoutExpired as exc:
return {
"command": command,
"exit_code": None,
"stdout": exc.stdout or "",
"stderr": exc.stderr or "",
"status": "TIMEOUT",
}
return {
"command": command,
"exit_code": completed.returncode,
"stdout": completed.stdout,
"stderr": completed.stderr,
"status": "RAW",
}
def run_standard_worker_probe(exe: Path, solver_id: str, case_file: Path) -> dict:
result = run_command([
str(exe),
"--cclite-worker",
"--solver-id",
@@ -18,41 +39,52 @@ def run_worker_probe(exe: Path, solver_id: str, case_file: Path) -> dict:
"CCLITE_REAL_WORKER_AUDIT",
"--timeout-ms",
"100",
]
try:
completed = subprocess.run(command, text=True, capture_output=True, timeout=5.0)
except subprocess.TimeoutExpired as exc:
return {
"command": command,
"exit_code": None,
"stdout": exc.stdout or "",
"stderr": exc.stderr or "",
"status": "TIMEOUT",
"recognized_worker_cli": False,
"ipc_implemented": False,
}
output = (completed.stdout or "") + "\n" + (completed.stderr or "")
])
output = (result.get("stdout") or "") + "\n" + (result.get("stderr") or "")
recognized = "--solver-id" not in output and "unknown argument" not in output
unsupported = "not implemented" in output.lower() or "unsupported" in output.lower()
return {
"command": command,
"exit_code": completed.returncode,
"stdout": completed.stdout,
"stderr": completed.stderr,
"status": classify_probe(recognized, unsupported, completed.returncode),
"recognized_worker_cli": recognized,
"ipc_implemented": recognized and completed.returncode == 0 and not unsupported,
}
result["status"] = classify_standard_probe(recognized, unsupported, result["exit_code"])
result["recognized_worker_cli"] = recognized
result["ipc_implemented"] = recognized and result["exit_code"] == 0 and not unsupported
return result
def classify_probe(recognized: bool, unsupported: bool, exit_code: int) -> str:
def run_femlite_mock_probe(exe: Path, case_file: Path, report_path: Path) -> dict:
output_dir = report_path.parent / "femlite_worker_mock"
log_file = report_path.parent / "femlite_worker_mock.log"
result = run_command([
str(exe),
"--cclite-worker",
"--case",
str(case_file),
"--ipc-name",
"CCLITE_FEMLITE_WORKER_MOCK_AUDIT",
"--log",
str(log_file),
"--output-dir",
str(output_dir),
"--mock-steps",
"1",
])
output = (result.get("stdout") or "") + "\n" + (result.get("stderr") or "")
if result["exit_code"] == 0 and "worker mock completed" in output.lower():
result["status"] = "WORKER_MOCK_AVAILABLE"
elif "unknown worker argument" in output.lower() or "unknown argument" in output.lower():
result["status"] = "MISSING_WORKER_MOCK_CLI"
else:
result["status"] = "WORKER_MOCK_FAILED"
result["log_file"] = str(log_file)
result["output_dir"] = str(output_dir)
return result
def classify_standard_probe(recognized: bool, unsupported: bool, exit_code: int | None) -> str:
if recognized and unsupported:
return "CONTROLLED_UNSUPPORTED"
if recognized and exit_code == 0:
return "READY_FOR_HANDSHAKE"
return "READY_FOR_REAL_IPC"
if not recognized:
return "MISSING_WORKER_CLI"
return "MISSING_STANDARD_WORKER_ARGS"
return "FAILED"
@@ -61,14 +93,24 @@ def main() -> int:
parser.add_argument("--sph-exe", required=True)
parser.add_argument("--fem-exe", required=True)
parser.add_argument("--case-dir", required=True)
parser.add_argument("--fem-case", required=True)
parser.add_argument("--report", required=True)
args = parser.parse_args()
case_dir = Path(args.case_dir)
sph = run_worker_probe(Path(args.sph_exe), "SPH", case_dir / "mock_sph.inp")
fem = run_worker_probe(Path(args.fem_exe), "FEM", case_dir / "mock_fem.inp")
report_path = Path(args.report)
sph_standard = run_standard_worker_probe(Path(args.sph_exe), "SPH", case_dir / "mock_sph.inp")
fem_standard = run_standard_worker_probe(Path(args.fem_exe), "FEM", Path(args.fem_case))
fem_mock = run_femlite_mock_probe(Path(args.fem_exe), Path(args.fem_case), report_path)
status = "PARTIAL_EXTERNAL_WORKER_SUPPORT"
if sph_standard["ipc_implemented"] and fem_standard["ipc_implemented"]:
status = "READY_FOR_REAL_IPC"
elif fem_mock["status"] != "WORKER_MOCK_AVAILABLE":
status = "CONTROLLED_GAP"
report = {
"status": "CONTROLLED_GAP",
"status": status,
"required_worker_args": [
"--cclite-worker",
"--solver-id <SPH|FEM>",
@@ -76,16 +118,17 @@ def main() -> int:
"--ipc-name <prefix>",
"--timeout-ms <milliseconds>",
],
"sphlite": sph,
"femlite": fem,
"sphlite_standard_ipc": sph_standard,
"femlite_standard_ipc": fem_standard,
"femlite_worker_mock": fem_mock,
"conclusion": [
"SPHLite 0.8.2 recognizes worker mode but reports real IPC as not implemented.",
"FEMLite 0.6.3 does not yet recognize the worker CLI argument set.",
"CCLite 0.1.7 keeps mock-worker integration as the executable acceptance path.",
"FEMLite 0.6.4 provides a self-running CCLite worker mock.",
"FEMLite 0.6.4 does not yet accept the full CCLite standard IPC worker argument set.",
"CCLite 0.1.9 keeps mock-worker IPC integration as the executable acceptance path.",
],
}
report_path = Path(args.report)
report_path.parent.mkdir(parents=True, exist_ok=True)
report_path.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(f"real worker audit -> {report_path}")