fix(827): execute pinned launcher in place
This commit is contained in:
@@ -320,7 +320,7 @@ def git_object_bytes(gated_root: Path, relative_path: str) -> bytes:
|
|||||||
def gated_launcher_precondition(
|
def gated_launcher_precondition(
|
||||||
root: Path, socket_path: Path, environment: dict[str, str]
|
root: Path, socket_path: Path, environment: dict[str, str]
|
||||||
) -> tuple[Path, Path]:
|
) -> tuple[Path, Path]:
|
||||||
"""Materialize verified WI-3 launcher bytes inside this fixture before exec."""
|
"""Verify the pinned WI-3 source before the adjacent in-place launch guard."""
|
||||||
|
|
||||||
if environment.get("MOSAIC_LEASE_BROKER_SOCKET") != str(socket_path):
|
if environment.get("MOSAIC_LEASE_BROKER_SOCKET") != str(socket_path):
|
||||||
raise RuntimeError("D4 precondition: lease broker socket is not this fixture")
|
raise RuntimeError("D4 precondition: lease broker socket is not this fixture")
|
||||||
@@ -375,18 +375,42 @@ def gated_launcher_precondition(
|
|||||||
):
|
):
|
||||||
raise RuntimeError("D4 precondition: pinned launcher lacks file-generation markers")
|
raise RuntimeError("D4 precondition: pinned launcher lacks file-generation markers")
|
||||||
|
|
||||||
fixture_launcher_dir = root / "pinned-lease-broker"
|
return gated_root / launcher_relative, gated_root / generation_relative
|
||||||
fixture_launcher_dir.mkdir(mode=0o700)
|
|
||||||
fixture_launcher = fixture_launcher_dir / "launch-runtime.py"
|
|
||||||
fixture_generation = fixture_launcher_dir / "lease_generation.py"
|
def launch_verified_pi(
|
||||||
fixture_launcher.write_bytes(launcher_bytes)
|
launcher: Path,
|
||||||
fixture_generation.write_bytes(generation_bytes)
|
workspace: Path,
|
||||||
os.chmod(fixture_launcher, 0o600)
|
sessions: Path,
|
||||||
os.chmod(fixture_generation, 0o600)
|
extension: Path,
|
||||||
if hashlib.sha256(fixture_launcher.read_bytes()).hexdigest() != GATED_LAUNCHER_SHA256:
|
environment: dict[str, str],
|
||||||
raise RuntimeError("D4 precondition: fixture launcher hash mismatch")
|
) -> PiRpc:
|
||||||
environment["PYTHONPATH"] = str(fixture_launcher_dir)
|
command = [
|
||||||
return fixture_launcher, fixture_generation
|
sys.executable,
|
||||||
|
str(launcher),
|
||||||
|
"--runtime",
|
||||||
|
"pi",
|
||||||
|
"--",
|
||||||
|
"pi",
|
||||||
|
"--mode",
|
||||||
|
"rpc",
|
||||||
|
"--session-dir",
|
||||||
|
str(sessions),
|
||||||
|
"--no-extensions",
|
||||||
|
"--no-context-files",
|
||||||
|
"--no-prompt-templates",
|
||||||
|
"--model",
|
||||||
|
"openai-codex/gpt-5.6-sol",
|
||||||
|
"--thinking",
|
||||||
|
"medium",
|
||||||
|
"--extension",
|
||||||
|
str(extension),
|
||||||
|
]
|
||||||
|
# This is deliberately the statement immediately before Popen (inside
|
||||||
|
# PiRpc): the pinned worktree bytes are re-hashed then executed in place.
|
||||||
|
if hashlib.sha256(launcher.read_bytes()).hexdigest() != GATED_LAUNCHER_SHA256:
|
||||||
|
raise RuntimeError("D4 precondition: adjacent launcher hash mismatch")
|
||||||
|
return PiRpc(command, workspace, environment)
|
||||||
|
|
||||||
|
|
||||||
def assert_d4(records: list[dict[str, Any]]) -> dict[str, object]:
|
def assert_d4(records: list[dict[str, Any]]) -> dict[str, object]:
|
||||||
@@ -575,7 +599,7 @@ def run_once(index: int) -> Path:
|
|||||||
environment = isolated_environment(root, index, workspace, socket_path, pi_log)
|
environment = isolated_environment(root, index, workspace, socket_path, pi_log)
|
||||||
# Must run before the fixture broker or Pi process is launched. It proves
|
# Must run before the fixture broker or Pi process is launched. It proves
|
||||||
# the launcher registers before exec and can only read this fixture socket.
|
# the launcher registers before exec and can only read this fixture socket.
|
||||||
fixture_launcher, fixture_generation = gated_launcher_precondition(
|
gated_launcher, generation_module = gated_launcher_precondition(
|
||||||
root, socket_path, environment
|
root, socket_path, environment
|
||||||
)
|
)
|
||||||
broker = subprocess.Popen(
|
broker = subprocess.Popen(
|
||||||
@@ -587,38 +611,14 @@ def run_once(index: int) -> Path:
|
|||||||
"--log",
|
"--log",
|
||||||
str(generation_log),
|
str(generation_log),
|
||||||
"--generation-module",
|
"--generation-module",
|
||||||
str(fixture_generation),
|
str(generation_module),
|
||||||
],
|
],
|
||||||
text=True,
|
text=True,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
)
|
)
|
||||||
wait_path(socket_path)
|
wait_path(socket_path)
|
||||||
pi = PiRpc(
|
pi = launch_verified_pi(gated_launcher, workspace, sessions, extension, environment)
|
||||||
[
|
|
||||||
sys.executable,
|
|
||||||
str(fixture_launcher),
|
|
||||||
"--runtime",
|
|
||||||
"pi",
|
|
||||||
"--",
|
|
||||||
"pi",
|
|
||||||
"--mode",
|
|
||||||
"rpc",
|
|
||||||
"--session-dir",
|
|
||||||
str(sessions),
|
|
||||||
"--no-extensions",
|
|
||||||
"--no-context-files",
|
|
||||||
"--no-prompt-templates",
|
|
||||||
"--model",
|
|
||||||
"openai-codex/gpt-5.6-sol",
|
|
||||||
"--thinking",
|
|
||||||
"medium",
|
|
||||||
"--extension",
|
|
||||||
str(extension),
|
|
||||||
],
|
|
||||||
workspace,
|
|
||||||
environment,
|
|
||||||
)
|
|
||||||
pi.send({"id": "state", "type": "get_state"})
|
pi.send({"id": "state", "type": "get_state"})
|
||||||
state = pi.response("state")
|
state = pi.response("state")
|
||||||
original_session = state["data"]["sessionFile"]
|
original_session = state["data"]["sessionFile"]
|
||||||
|
|||||||
Reference in New Issue
Block a user