Add CCLite 0.2.9 real worker gate
This commit is contained in:
@@ -59,6 +59,30 @@ def run_capabilities_probe(exe: Path) -> dict:
|
||||
return result
|
||||
|
||||
|
||||
def run_version_probe(exe: Path) -> dict:
|
||||
result = run_command([str(exe), "--version"], timeout=5.0)
|
||||
output = ((result.get("stdout") or "") + "\n" + (result.get("stderr") or "")).strip()
|
||||
result["version"] = extract_version_label(output)
|
||||
if result["exit_code"] == 0 and output:
|
||||
result["status"] = "VERSION_AVAILABLE"
|
||||
elif result["exit_code"] == 0:
|
||||
result["status"] = "VERSION_EMPTY"
|
||||
elif output and result["version"] != "unknown":
|
||||
result["status"] = "VERSION_OUTPUT_WITH_NONZERO_EXIT"
|
||||
else:
|
||||
result["status"] = "VERSION_UNAVAILABLE"
|
||||
return result
|
||||
|
||||
|
||||
def extract_version_label(output: str) -> str:
|
||||
for raw_line in output.splitlines():
|
||||
line = raw_line.strip()
|
||||
if not line or line.startswith("["):
|
||||
continue
|
||||
return line[:160]
|
||||
return "unknown"
|
||||
|
||||
|
||||
def run_standard_worker_probe(
|
||||
exe: Path,
|
||||
solver_id: str,
|
||||
@@ -147,6 +171,82 @@ def classify_standard_probe(
|
||||
return "FAILED"
|
||||
|
||||
|
||||
def build_adapter_strategy() -> dict:
|
||||
return {
|
||||
"status": "HYBRID_TRANSITION_SELECTED",
|
||||
"selected_strategy": "HYBRID_GENERIC_BLOCK_PLUS_SOLVER_ADAPTER",
|
||||
"summary": (
|
||||
"CCLite keeps the 05 ICD generic command/data blocks as the internal contract, "
|
||||
"and uses solver-specific adapters at the external real-worker boundary until "
|
||||
"SPHLite and FEMLite expose identical CCLite binary layouts."
|
||||
),
|
||||
"cclite_internal_contract": [
|
||||
"CCLite generic command block v1",
|
||||
"CCLite generic data block header with AoR v1 payloads",
|
||||
"CCLite-owned shared memory and named-event lifecycle",
|
||||
],
|
||||
"external_worker_boundary": [
|
||||
"SPHLite command/name adapter",
|
||||
"FEMLite native-header/name adapter",
|
||||
],
|
||||
"why_not_generic_only_now": (
|
||||
"The current worker packages report real IPC support, but their published "
|
||||
"control object names and at least the FEMLite binary header differ from "
|
||||
"CCLite generic blocks."
|
||||
),
|
||||
"why_not_solver_specific_only": (
|
||||
"The controller, mock-worker acceptance path, diagnostics, and contact "
|
||||
"algorithm already use a unified CCLite data model; replacing it with two "
|
||||
"solver-native contracts would duplicate validation logic."
|
||||
),
|
||||
"required_adapter_fields": [
|
||||
"command block name and event name mapping",
|
||||
"command seq/ack and command-id mapping",
|
||||
"data header magic/version/layout/role mapping",
|
||||
"record stride and capacity mapping",
|
||||
"empty and controlled load import mapping",
|
||||
"worker error-code and timeout mapping",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def build_block_capabilities(capabilities: dict[str, str]) -> dict:
|
||||
keys = [
|
||||
"command_block_version",
|
||||
"data_layout",
|
||||
"supports_sph_to_ccl_particle",
|
||||
"supports_ccl_to_sph_force",
|
||||
"supports_fem_to_ccl_facet",
|
||||
"supports_ccl_to_fem_load",
|
||||
"max_particle_records",
|
||||
"max_facet_records",
|
||||
"max_load_records",
|
||||
]
|
||||
return {key: capabilities.get(key, "unknown") for key in keys if key in capabilities}
|
||||
|
||||
|
||||
def build_worker_capability_summary(
|
||||
exe: Path,
|
||||
capability_probe: dict,
|
||||
version_probe: dict,
|
||||
gap_status: str,
|
||||
) -> dict:
|
||||
capabilities = capability_probe.get("capabilities", {})
|
||||
return {
|
||||
"worker_name": capabilities.get("solver", exe.stem),
|
||||
"executable": str(exe),
|
||||
"version": version_probe.get("version", "unknown"),
|
||||
"version_probe_status": version_probe.get("status", "VERSION_UNAVAILABLE"),
|
||||
"capability_probe_status": capability_probe.get("status", "CAPABILITIES_FAILED"),
|
||||
"ipc": {
|
||||
"backend": capabilities.get("ipc_backend", "unknown"),
|
||||
"supports_real_ipc": bool(capability_probe.get("supports_real_ipc", False)),
|
||||
},
|
||||
"block_capabilities": build_block_capabilities(capabilities),
|
||||
"gap_status": gap_status,
|
||||
}
|
||||
|
||||
|
||||
def build_protocol_alignment(fem_exe: Path) -> dict:
|
||||
fem_include = fem_exe.parent.parent / "include" / "femlite_cclite_ipc.h"
|
||||
fem_native_header = False
|
||||
@@ -201,10 +301,56 @@ def build_protocol_alignment(fem_exe: Path) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def build_v020_adapter_gate() -> dict:
|
||||
def build_controlled_gap_path(
|
||||
description: str,
|
||||
probe: dict | None,
|
||||
blocking_fields: list[str],
|
||||
) -> dict:
|
||||
result = {
|
||||
"status": "CONTROLLED_PROTOCOL_GAP",
|
||||
"description": description,
|
||||
"blocking_fields": blocking_fields,
|
||||
}
|
||||
if probe is not None:
|
||||
result.update({
|
||||
"probe_status": probe.get("status", "UNKNOWN"),
|
||||
"recognized_worker_cli": bool(probe.get("recognized_worker_cli", False)),
|
||||
"real_ipc_attach_attempted": bool(probe.get("real_ipc_attach_attempted", False)),
|
||||
"exit_code": probe.get("exit_code"),
|
||||
})
|
||||
return result
|
||||
|
||||
|
||||
def build_v020_adapter_gate(
|
||||
adapter_strategy: dict,
|
||||
worker_summary: dict,
|
||||
sph_standard: dict,
|
||||
fem_standard: dict,
|
||||
fem_explicit_ipc: dict,
|
||||
) -> dict:
|
||||
sph_blockers = [
|
||||
"SPHLite default control names use <ipc_name>.command/.command_event/.done_event.",
|
||||
"CCLite currently creates <prefix>_CCL_COMMAND_SPH and <prefix>_EVENT_COMMAND_SPH/<prefix>_EVENT_ACK_SPH.",
|
||||
"The audit has not yet executed a CCLite-side command/data adapter with pre-created resources.",
|
||||
]
|
||||
fem_blockers = [
|
||||
"FEMLite publishes a native compact femlite_cclite_command_block.",
|
||||
"FEMLite default control names use <prefix>_COMMAND_BLOCK/<prefix>_COMMAND_EVENT/<prefix>_DONE_EVENT.",
|
||||
"CCLite currently creates generic CCL_COMMAND_FEM and EVENT_COMMAND_FEM/EVENT_ACK_FEM resources.",
|
||||
]
|
||||
payload_blockers = [
|
||||
"Real worker export headers are not yet mapped into CCLite generic data headers.",
|
||||
"record_type, record_stride, capacity, role, and step_id cannot be validated through the current reader.",
|
||||
]
|
||||
load_blockers = [
|
||||
"Real worker load headers are not yet mapped from CCLite generic load blocks.",
|
||||
"IMPORT_LOADS acknowledgement cannot be validated until the command/data adapter is executable.",
|
||||
]
|
||||
|
||||
return {
|
||||
"gate_id": "V020_SINGLE_REAL_WORKER_SMOKE",
|
||||
"status": "CONTROLLED_PROTOCOL_GAP_UNTIL_ADAPTER_TESTS_PASS",
|
||||
"status": "CONTROLLED_PROTOCOL_GAP",
|
||||
"adapter_strategy": adapter_strategy["selected_strategy"],
|
||||
"mock_algorithm_acceptance_independent": True,
|
||||
"required_paths": [
|
||||
"real SPHLite + mock FEMLite, 1 step empty coupling",
|
||||
@@ -226,6 +372,37 @@ def build_v020_adapter_gate() -> dict:
|
||||
"resource naming cannot be mapped without an adapter",
|
||||
"record stride or block role cannot be validated by the current CCLite reader",
|
||||
],
|
||||
"path_results": {
|
||||
"real_sphlite_mock_fem_1step": build_controlled_gap_path(
|
||||
"Real SPHLite plus mock FEMLite, 1 step empty coupling.",
|
||||
sph_standard,
|
||||
sph_blockers,
|
||||
),
|
||||
"mock_sphlite_real_femlite_1step": build_controlled_gap_path(
|
||||
"Mock SPHLite plus real FEMLite, 1 step empty coupling.",
|
||||
fem_explicit_ipc if fem_explicit_ipc.get("real_ipc_attach_attempted") else fem_standard,
|
||||
fem_blockers,
|
||||
),
|
||||
"single_real_worker_100step": build_controlled_gap_path(
|
||||
"At least one single-real-worker path, 100 step empty coupling.",
|
||||
None,
|
||||
[
|
||||
"The 100 step gate depends on one executable 1 step real-worker adapter path.",
|
||||
"No seq/ack, timeout, or resource-release claim is made before that adapter path exists.",
|
||||
],
|
||||
),
|
||||
"payload_read_smoke": build_controlled_gap_path(
|
||||
"Real worker exported interface block header and payload validation.",
|
||||
None,
|
||||
payload_blockers,
|
||||
),
|
||||
"load_import_smoke": build_controlled_gap_path(
|
||||
"Real worker empty or controlled load block import validation.",
|
||||
None,
|
||||
load_blockers,
|
||||
),
|
||||
},
|
||||
"worker_capability_summary": worker_summary,
|
||||
}
|
||||
|
||||
|
||||
@@ -244,6 +421,8 @@ def main() -> int:
|
||||
fem_exe = Path(args.fem_exe)
|
||||
sph_capabilities = run_capabilities_probe(sph_exe)
|
||||
fem_capabilities = run_capabilities_probe(fem_exe)
|
||||
sph_version = run_version_probe(sph_exe)
|
||||
fem_version = run_version_probe(fem_exe)
|
||||
sph_standard = run_standard_worker_probe(sph_exe, "SPH", case_dir / "mock_sph.inp")
|
||||
fem_standard = run_standard_worker_probe(fem_exe, "FEM", Path(args.fem_case))
|
||||
fem_explicit_ipc = run_standard_worker_probe(
|
||||
@@ -254,6 +433,28 @@ def main() -> int:
|
||||
)
|
||||
fem_mock = run_femlite_mock_probe(fem_exe, Path(args.fem_case), report_path)
|
||||
protocol_alignment = build_protocol_alignment(fem_exe)
|
||||
adapter_strategy = build_adapter_strategy()
|
||||
worker_summary = {
|
||||
"sphlite": build_worker_capability_summary(
|
||||
sph_exe,
|
||||
sph_capabilities,
|
||||
sph_version,
|
||||
"CONTROLLED_PROTOCOL_GAP",
|
||||
),
|
||||
"femlite": build_worker_capability_summary(
|
||||
fem_exe,
|
||||
fem_capabilities,
|
||||
fem_version,
|
||||
"CONTROLLED_PROTOCOL_GAP",
|
||||
),
|
||||
}
|
||||
v020_adapter_gate = build_v020_adapter_gate(
|
||||
adapter_strategy,
|
||||
worker_summary,
|
||||
sph_standard,
|
||||
fem_standard,
|
||||
fem_explicit_ipc,
|
||||
)
|
||||
|
||||
both_report_real_ipc = sph_capabilities["supports_real_ipc"] and fem_capabilities["supports_real_ipc"]
|
||||
both_attach_attempted = (
|
||||
@@ -272,6 +473,7 @@ def main() -> int:
|
||||
|
||||
report = {
|
||||
"status": status,
|
||||
"gate_status": v020_adapter_gate["status"],
|
||||
"required_worker_args": [
|
||||
"--cclite-worker",
|
||||
"--solver-id <SPH|FEM>",
|
||||
@@ -281,17 +483,21 @@ def main() -> int:
|
||||
],
|
||||
"sphlite_capabilities": sph_capabilities,
|
||||
"femlite_capabilities": fem_capabilities,
|
||||
"sphlite_version": sph_version,
|
||||
"femlite_version": fem_version,
|
||||
"adapter_strategy": adapter_strategy,
|
||||
"worker_capability_summary": worker_summary,
|
||||
"sphlite_standard_ipc": sph_standard,
|
||||
"femlite_standard_ipc": fem_standard,
|
||||
"femlite_explicit_ipc_backend": fem_explicit_ipc,
|
||||
"femlite_worker_mock": fem_mock,
|
||||
"protocol_alignment": protocol_alignment,
|
||||
"v020_adapter_gate": build_v020_adapter_gate(),
|
||||
"v020_adapter_gate": v020_adapter_gate,
|
||||
"conclusion": [
|
||||
"The current SPHLite package reports CCLite worker and Windows shared memory/named event support.",
|
||||
"The current FEMLite package reports CCLite worker, worker mock, and Windows shared memory/named event support.",
|
||||
"Both workers now attempt real IPC attach when launched without pre-created CCLite resources.",
|
||||
"CCLite 0.1.10 still treats true external process interop as requiring a CCLite-side protocol/name adapter, because the published FEMLite IPC structures and names differ from CCLite 0.1.x generic blocks.",
|
||||
"CCLite 0.2.9 records V020_SINGLE_REAL_WORKER_SMOKE as CONTROLLED_PROTOCOL_GAP until the CCLite-side protocol/name adapter passes process-level tests.",
|
||||
"Mock-worker IPC integration remains the executable acceptance path until the adapter-level process tests pass.",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from common_csv import add_failure, write_verification_report
|
||||
|
||||
|
||||
REQUIRED_PATH_RESULTS = [
|
||||
"real_sphlite_mock_fem_1step",
|
||||
"mock_sphlite_real_femlite_1step",
|
||||
"single_real_worker_100step",
|
||||
"payload_read_smoke",
|
||||
"load_import_smoke",
|
||||
]
|
||||
|
||||
ACCEPTED_GATE_STATUSES = {
|
||||
"PASS",
|
||||
"CONTROLLED_PROTOCOL_GAP",
|
||||
}
|
||||
|
||||
|
||||
def build_report(args: argparse.Namespace) -> dict:
|
||||
audit_report_path = Path(args.audit_report)
|
||||
failed: list[str] = []
|
||||
metrics: dict[str, int | str] = {}
|
||||
|
||||
if not audit_report_path.exists():
|
||||
failed.append(f"missing audit report: {audit_report_path}")
|
||||
audit = {}
|
||||
else:
|
||||
audit = json.loads(audit_report_path.read_text(encoding="utf-8"))
|
||||
|
||||
gate = audit.get("v020_adapter_gate", {})
|
||||
gate_status = gate.get("status", "")
|
||||
metrics["gate_status"] = gate_status
|
||||
|
||||
if gate.get("gate_id") != args.case_id:
|
||||
add_failure(failed, "v020_adapter_gate", "gate_id", args.case_id, gate.get("gate_id"))
|
||||
if gate_status not in ACCEPTED_GATE_STATUSES:
|
||||
add_failure(failed, "v020_adapter_gate", "status", sorted(ACCEPTED_GATE_STATUSES), gate_status)
|
||||
|
||||
validate_adapter_strategy(audit, failed)
|
||||
validate_worker_summary(audit, failed, metrics)
|
||||
validate_path_results(gate, failed, metrics)
|
||||
|
||||
status = "PASS" if not failed else "FAIL"
|
||||
return {
|
||||
"case_id": args.case_id,
|
||||
"status": status,
|
||||
"metrics": metrics,
|
||||
"failed_checks": failed,
|
||||
"input": str(audit_report_path),
|
||||
"output_files": {
|
||||
"audit_report": str(audit_report_path),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def validate_adapter_strategy(audit: dict, failed: list[str]) -> None:
|
||||
strategy = audit.get("adapter_strategy", {})
|
||||
selected = strategy.get("selected_strategy", "")
|
||||
if selected != "HYBRID_GENERIC_BLOCK_PLUS_SOLVER_ADAPTER":
|
||||
add_failure(
|
||||
failed,
|
||||
"adapter_strategy",
|
||||
"selected_strategy",
|
||||
"HYBRID_GENERIC_BLOCK_PLUS_SOLVER_ADAPTER",
|
||||
selected,
|
||||
)
|
||||
required_fields = strategy.get("required_adapter_fields", [])
|
||||
if len(required_fields) < 5:
|
||||
add_failure(failed, "adapter_strategy", "required_adapter_fields", "at least 5", len(required_fields))
|
||||
|
||||
|
||||
def validate_worker_summary(audit: dict, failed: list[str], metrics: dict[str, int | str]) -> None:
|
||||
summary = audit.get("worker_capability_summary", {})
|
||||
for worker_key in ("sphlite", "femlite"):
|
||||
worker = summary.get(worker_key, {})
|
||||
location = f"worker_capability_summary.{worker_key}"
|
||||
for field in ("worker_name", "version", "capability_probe_status", "gap_status"):
|
||||
if not worker.get(field):
|
||||
add_failure(failed, location, field, "non-empty", worker.get(field))
|
||||
ipc = worker.get("ipc", {})
|
||||
if not ipc.get("backend"):
|
||||
add_failure(failed, location, "ipc.backend", "non-empty", ipc.get("backend"))
|
||||
if "supports_real_ipc" not in ipc:
|
||||
add_failure(failed, location, "ipc.supports_real_ipc", "present", "missing")
|
||||
block_capabilities = worker.get("block_capabilities", {})
|
||||
if not block_capabilities:
|
||||
add_failure(failed, location, "block_capabilities", "non-empty", block_capabilities)
|
||||
if worker.get("gap_status") not in ACCEPTED_GATE_STATUSES:
|
||||
add_failure(
|
||||
failed,
|
||||
location,
|
||||
"gap_status",
|
||||
sorted(ACCEPTED_GATE_STATUSES),
|
||||
worker.get("gap_status"),
|
||||
)
|
||||
metrics[f"{worker_key}_capability_fields"] = len(block_capabilities)
|
||||
|
||||
|
||||
def validate_path_results(gate: dict, failed: list[str], metrics: dict[str, int | str]) -> None:
|
||||
path_results = gate.get("path_results", {})
|
||||
controlled_gap_count = 0
|
||||
pass_count = 0
|
||||
for path_id in REQUIRED_PATH_RESULTS:
|
||||
path_result = path_results.get(path_id, {})
|
||||
status = path_result.get("status", "")
|
||||
location = f"v020_adapter_gate.path_results.{path_id}"
|
||||
if status not in ACCEPTED_GATE_STATUSES:
|
||||
add_failure(failed, location, "status", sorted(ACCEPTED_GATE_STATUSES), status)
|
||||
if status == "CONTROLLED_PROTOCOL_GAP":
|
||||
controlled_gap_count += 1
|
||||
blockers = path_result.get("blocking_fields", [])
|
||||
if not blockers:
|
||||
add_failure(failed, location, "blocking_fields", "non-empty", blockers)
|
||||
elif status == "PASS":
|
||||
pass_count += 1
|
||||
|
||||
metrics["path_result_count"] = len(path_results)
|
||||
metrics["pass_count"] = pass_count
|
||||
metrics["controlled_protocol_gap_count"] = controlled_gap_count
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--case-id", required=True)
|
||||
parser.add_argument("--audit-report", required=True)
|
||||
parser.add_argument("--report", required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
report = build_report(args)
|
||||
report_path = Path(args.report)
|
||||
write_verification_report(report_path, report)
|
||||
print(f"{report['case_id']} {report['status']} -> {report_path}")
|
||||
return 0 if report["status"] == "PASS" else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user