Move MVP status smoke to Rust

This commit is contained in:
Meta Vens 2026-05-06 09:38:46 +01:00
commit 2c6358058c
7 changed files with 413 additions and 214 deletions

View file

@ -0,0 +1,407 @@
use anyhow::Context;
use anyhow::Result;
use anyhow::anyhow;
use serde_json::Value;
use serde_json::json;
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
const DEFAULT_APP_SERVER: &str = r"C:\Users\Meta\.cargo-target-codex\debug\codex-app-server.exe";
fn main() -> Result<()> {
let args = Args::parse()?;
let result = run_smoke(&args)?;
println!("{}", serde_json::to_string_pretty(&result)?);
Ok(())
}
#[derive(Debug)]
struct Args {
app_server: PathBuf,
codex_home: PathBuf,
result: PathBuf,
transcript: PathBuf,
stderr: PathBuf,
rendered: PathBuf,
status_exe: Option<PathBuf>,
}
impl Args {
fn parse() -> Result<Self> {
let root = env::current_dir().context("failed to resolve current dir")?;
let mut parsed = Self {
app_server: PathBuf::from(DEFAULT_APP_SERVER),
codex_home: root.join(".epiphany-smoke").join("mvp-status-codex-home"),
result: root
.join(".epiphany-smoke")
.join("mvp-status-smoke-result.json"),
transcript: root
.join(".epiphany-smoke")
.join("mvp-status-smoke-transcript.jsonl"),
stderr: root
.join(".epiphany-smoke")
.join("mvp-status-smoke-server.stderr.log"),
rendered: root
.join(".epiphany-smoke")
.join("mvp-status-smoke-rendered.txt"),
status_exe: None,
};
let mut args = env::args().skip(1);
while let Some(arg) = args.next() {
match arg.as_str() {
"--app-server" => parsed.app_server = take_path(&mut args, "--app-server")?,
"--codex-home" => parsed.codex_home = take_path(&mut args, "--codex-home")?,
"--result" => parsed.result = take_path(&mut args, "--result")?,
"--transcript" => parsed.transcript = take_path(&mut args, "--transcript")?,
"--stderr" => parsed.stderr = take_path(&mut args, "--stderr")?,
"--rendered" => parsed.rendered = take_path(&mut args, "--rendered")?,
"--status-exe" => parsed.status_exe = Some(take_path(&mut args, "--status-exe")?),
other => return Err(anyhow!("unknown argument: {other}")),
}
}
Ok(parsed)
}
}
fn run_smoke(args: &Args) -> Result<Value> {
let root = env::current_dir().context("failed to resolve current dir")?;
let app_server = absolute_path(&args.app_server)?;
if !app_server.exists() {
return Err(anyhow!(
"codex app-server binary not found: {}",
app_server.display()
));
}
let codex_home = absolute_path(&args.codex_home)?;
let result_path = absolute_path(&args.result)?;
let transcript_path = absolute_path(&args.transcript)?;
let stderr_path = absolute_path(&args.stderr)?;
let rendered_path = absolute_path(&args.rendered)?;
reset_smoke_paths(
&root,
&[
codex_home.clone(),
result_path.clone(),
transcript_path.clone(),
stderr_path.clone(),
rendered_path.clone(),
],
)?;
let status_exe = match &args.status_exe {
Some(path) => absolute_path(path)?,
None => sibling_exe("epiphany-mvp-status")?,
};
ensure_status_built(&root, &status_exe)?;
let status = run_status_json(
&root,
&status_exe,
&app_server,
&codex_home,
&result_path,
&transcript_path,
&stderr_path,
)?;
let rendered = run_status_rendered(
&root,
&status_exe,
&app_server,
&codex_home,
&transcript_path.with_file_name("mvp-status-smoke-render-transcript.jsonl"),
&stderr_path.with_file_name("mvp-status-smoke-render-server.stderr.log"),
)?;
if let Some(parent) = rendered_path.parent() {
fs::create_dir_all(parent)?;
}
fs::write(&rendered_path, &rendered)?;
validate_status(&status, &rendered)?;
let result = json!({
"threadId": status["threadId"],
"recommendation": status["crrc"]["recommendation"],
"roles": status["roles"],
"roleResults": status["roleResults"],
"planning": status["planning"],
"heartbeat": status["heartbeat"],
"face": status["face"],
"stateStatus": status["scene"]["scene"]["stateStatus"],
"availableActions": status["scene"]["scene"]["availableActions"],
"rendered": rendered,
});
write_json(&result_path, &result)?;
Ok(result)
}
fn run_status_json(
root: &Path,
status_exe: &Path,
app_server: &Path,
codex_home: &Path,
result_path: &Path,
transcript_path: &Path,
stderr_path: &Path,
) -> Result<Value> {
let output = Command::new(status_exe)
.current_dir(root)
.arg("--app-server")
.arg(app_server)
.arg("--codex-home")
.arg(codex_home)
.arg("--cwd")
.arg(root)
.arg("--transcript")
.arg(transcript_path)
.arg("--stderr")
.arg(stderr_path)
.arg("--result")
.arg(result_path)
.arg("--json")
.output()
.context("failed to run native status JSON command")?;
if !output.status.success() {
return Err(anyhow!(
"native status JSON command failed: {}{}",
String::from_utf8_lossy(&output.stderr),
String::from_utf8_lossy(&output.stdout)
));
}
serde_json::from_slice(&output.stdout).context("failed to decode native status JSON")
}
fn run_status_rendered(
root: &Path,
status_exe: &Path,
app_server: &Path,
codex_home: &Path,
transcript_path: &Path,
stderr_path: &Path,
) -> Result<String> {
let output = Command::new(status_exe)
.current_dir(root)
.arg("--app-server")
.arg(app_server)
.arg("--codex-home")
.arg(codex_home)
.arg("--cwd")
.arg(root)
.arg("--transcript")
.arg(transcript_path)
.arg("--stderr")
.arg(stderr_path)
.output()
.context("failed to run native status rendered command")?;
if !output.status.success() {
return Err(anyhow!(
"native status rendered command failed: {}{}",
String::from_utf8_lossy(&output.stderr),
String::from_utf8_lossy(&output.stdout)
));
}
String::from_utf8(output.stdout).context("rendered status was not UTF-8")
}
fn validate_status(status: &Value, rendered: &str) -> Result<()> {
require(
status
.pointer("/scene/scene/stateStatus")
.and_then(Value::as_str)
== Some("missing"),
"fresh status smoke should honestly report missing Epiphany state",
)?;
require(
status
.pointer("/crrc/recommendation/action")
.and_then(Value::as_str)
== Some("regatherManually"),
"fresh status smoke should recommend manual regather without state",
)?;
require(
array_contains(status.pointer("/scene/scene/availableActions"), "crrc"),
"status view should expose the CRRC action in the scene",
)?;
require(
array_contains(status.pointer("/scene/scene/availableActions"), "roles"),
"status view should expose the role ownership action in the scene",
)?;
require(
rendered.contains("Epiphany MVP Status") && rendered.contains("Recommendation"),
"rendered status should include the operator view headings",
)?;
require(
rendered.contains("regatherManually"),
"rendered status should expose the CRRC recommendation",
)?;
let lane_ids = status
.pointer("/roles/roles")
.and_then(Value::as_array)
.ok_or_else(|| anyhow!("roles surface missing roles"))?
.iter()
.filter_map(|lane| lane.get("id").and_then(Value::as_str))
.collect::<Vec<_>>();
require(
lane_ids
== [
"implementation",
"imagination",
"modeling",
"verification",
"reorientation",
],
"roles surface should expose the five MVP role lanes",
)?;
require(
status
.pointer("/roles/note")
.and_then(Value::as_str)
.is_some_and(|note| note.starts_with("Role ownership is derived read-only")),
"roles surface should declare read-only derived ownership",
)?;
require(
status
.pointer("/planning/stateStatus")
.and_then(Value::as_str)
== Some("missing")
&& status
.pointer("/planning/summary/captureCount")
.and_then(Value::as_u64)
== Some(0),
"fresh status smoke should expose empty planning state honestly",
)?;
require(
rendered.contains("Planning") && rendered.contains("captures: 0"),
"rendered status should expose the planning section",
)?;
require(
rendered.contains("Role Lanes") && rendered.contains("Verification / Review"),
"rendered status should expose the role lane section",
)?;
require(
rendered.contains("Role Findings")
&& status
.pointer("/roleResults/imagination/status")
.and_then(Value::as_str)
== Some("missingState")
&& status
.pointer("/roleResults/modeling/status")
.and_then(Value::as_str)
== Some("missingState")
&& status
.pointer("/roleResults/verification/status")
.and_then(Value::as_str)
== Some("missingState"),
"rendered status should expose fixed role result read-back status",
)?;
require(
status
.pointer("/heartbeat/schema_version")
.and_then(Value::as_str)
== Some("epiphany.agent_heartbeat_status.v0"),
"status view should expose heartbeat initiative status for Aquarium",
)?;
let face_actions = status
.pointer("/face/availableActions")
.and_then(Value::as_array);
require(
face_actions.is_some_and(|items| {
items.len() == 1 && items.first().and_then(Value::as_str) == Some("faceBubble")
}),
"status view should expose Face bubble action for Aquarium",
)?;
require(
rendered.contains("Heartbeat") && rendered.contains("Face"),
"rendered status should expose heartbeat and Face sections",
)?;
Ok(())
}
fn reset_smoke_paths(root: &Path, paths: &[PathBuf]) -> Result<()> {
let smoke_root = root.join(".epiphany-smoke").canonicalize().or_else(|_| {
let smoke_root = root.join(".epiphany-smoke");
fs::create_dir_all(&smoke_root)?;
smoke_root.canonicalize()
})?;
for path in paths {
if !path.exists() {
continue;
}
let resolved = path.canonicalize()?;
if resolved == smoke_root || !resolved.starts_with(&smoke_root) {
return Err(anyhow!(
"refusing to delete non-smoke path: {}",
path.display()
));
}
if path.is_dir() {
fs::remove_dir_all(path)?;
} else {
fs::remove_file(path)?;
}
}
Ok(())
}
fn ensure_status_built(root: &Path, status_exe: &Path) -> Result<()> {
if status_exe.exists() {
return Ok(());
}
let status = Command::new("cargo")
.current_dir(root)
.arg("build")
.arg("--manifest-path")
.arg(root.join("epiphany-core").join("Cargo.toml"))
.arg("--bin")
.arg("epiphany-mvp-status")
.status()
.context("failed to build epiphany-mvp-status")?;
require(
status.success() && status_exe.exists(),
&format!(
"native status binary was not built: {}",
status_exe.display()
),
)
}
fn sibling_exe(name: &str) -> Result<PathBuf> {
let mut exe = env::current_exe().context("failed to resolve current executable")?;
exe.set_file_name(format!("{name}{}", env::consts::EXE_SUFFIX));
Ok(exe)
}
fn array_contains(value: Option<&Value>, needle: &str) -> bool {
value
.and_then(Value::as_array)
.is_some_and(|items| items.iter().any(|item| item.as_str() == Some(needle)))
}
fn absolute_path(path: &Path) -> Result<PathBuf> {
if path.is_absolute() {
Ok(path.to_path_buf())
} else {
Ok(env::current_dir()?.join(path))
}
}
fn write_json(path: &Path, value: &Value) -> Result<()> {
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)?;
}
fs::write(path, format!("{}\n", serde_json::to_string_pretty(value)?))?;
Ok(())
}
fn require(condition: bool, message: &str) -> Result<()> {
if condition {
Ok(())
} else {
Err(anyhow!("{message}"))
}
}
fn take_path(args: &mut impl Iterator<Item = String>, name: &str) -> Result<PathBuf> {
args.next()
.map(PathBuf::from)
.ok_or_else(|| anyhow!("{name} requires a value"))
}

View file

@ -1510,7 +1510,7 @@ Current tests cover the landed flows at useful seams:
- live app-server smoke for the first Phase 6 pressure boundary in `tools/epiphany_phase6_pressure_smoke.py`.
- live app-server smoke for the first Phase 6 reorientation policy boundary in `tools/epiphany_phase6_reorient_smoke.py`.
- live app-server smoke for the first bounded reorient-launch runtime consumer plus CRRC coordinator recommendations in `tools/epiphany_phase6_reorient_launch_smoke.py`.
- live app-server smoke for the first MVP operator status view in `tools/epiphany_mvp_status_smoke.py`.
- live app-server smoke for the first MVP operator status view through native `epiphany-mvp-status-smoke`.
- focused app-server mapper coverage for `thread/epiphany/roles`, plus MVP status smoke coverage that consumes the roles surface.
- focused app-server/protocol coverage for `thread/epiphany/roleLaunch`, `thread/epiphany/roleResult`, and `thread/epiphany/roleAccept`, plus live role smoke coverage that launches Imagination, modeling, and verification workers, reads completed results, accepts a reviewed Imagination planning patch and a reviewed modeling graph patch, proves durable planning grows without objective adoption, proves the durable graph grows before verification sees the expanded frontier, and proves a modeling `selfPatch` review is carried through result/accept. Native `epiphany-agent-memory-store smoke` validates the Ghostlight-shaped dossiers and accepted/refused/apply behavior for self-memory patches.
- live app-server smoke for the first Phase 6 job-control boundary in `tools/epiphany_phase6_job_control_smoke.py`.
@ -1534,6 +1534,6 @@ $env:CARGO_TARGET_DIR='C:\Users\Meta\.cargo-target-codex'; cargo test -p codex-a
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_pressure_smoke.py'
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_reorient_smoke.py'
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_reorient_launch_smoke.py'
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_mvp_status_smoke.py'
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-mvp-status-smoke
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_job_control_smoke.py'
```

View file

@ -93,7 +93,7 @@ The landed machine now has:
- prompt-level anti-Greenspun guardrails: Epiphany keeps Codex's useful operator discipline and requires a bounded research/scout check before agents invent bespoke versions of known algorithms, parsers, schedulers, renderers, protocols, storage layers, security mechanisms, or workflow engines
- live Phase 6 reorientation app-server smoke coverage in `tools/epiphany_phase6_reorient_smoke.py`
- live Phase 6 reorient-launch app-server smoke coverage in `tools/epiphany_phase6_reorient_launch_smoke.py`
- live Phase 6 MVP status smoke coverage in `tools/epiphany_mvp_status_smoke.py`
- live Phase 6 MVP status smoke coverage through native `epiphany-mvp-status-smoke`
- live Phase 6 job-control app-server smoke coverage in `tools/epiphany_phase6_job_control_smoke.py`
The current phase is Phase 6: reflection boundary and observable harness state.

View file

@ -154,7 +154,7 @@ The current spine, blessed but not yet finished:
- live pressure app-server smoke through `tools/epiphany_phase6_pressure_smoke.py`
- live reorientation app-server smoke through `tools/epiphany_phase6_reorient_smoke.py`
- live reorient-guided worker launch smoke through `tools/epiphany_phase6_reorient_launch_smoke.py`
- live MVP operator status smoke through `tools/epiphany_mvp_status_smoke.py`
- live MVP operator status smoke through native `epiphany-mvp-status-smoke`
- live MVP coordinator smoke through native `epiphany-mvp-coordinator-smoke`
- live job-control app-server smoke through `tools/epiphany_phase6_job_control_smoke.py`
- live specialist MVP pass through `tools/epiphany_mvp_live_specialist.py`
@ -274,7 +274,7 @@ cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-mvp-coordina
For the first MVP operator status view, run:
```powershell
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_mvp_status_smoke.py'
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-mvp-status-smoke
```
For GUI Objective Draft adoption behavior, run:

Binary file not shown.

View file

@ -212,7 +212,7 @@ landed_baseline:
- Use `tools/epiphany_phase6_reorient_launch_smoke.py` before modifying the bounded reorient-guided worker launch surface.
- Use `tools/epiphany_phase6_reorient_launch_smoke.py` before modifying the bounded reorient-worker result read-back surface.
- Use `tools/epiphany_phase6_reorient_launch_smoke.py` before modifying the read-only CRRC coordinator recommendation surface.
- Use `tools/epiphany_mvp_status_smoke.py` before modifying the MVP operator status view.
- Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-mvp-status-smoke` before modifying the MVP operator status view.
- Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-mvp-coordinator-smoke` before modifying the fixed-lane MVP coordinator endpoint or runner.
- Use `cargo test --manifest-path .\epiphany-core\Cargo.toml --lib runtime_spine -- --nocapture` and `cargo build --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-runtime-spine` before modifying native runtime-spine state or CultNet hello emission.
- Use `tools/epiphany_phase6_role_smoke.py` before modifying explicit role launch/read-back/acceptance behavior.

View file

@ -1,208 +0,0 @@
from __future__ import annotations
import argparse
import json
import os
from pathlib import Path
import subprocess
from epiphany_mvp_status import DEFAULT_APP_SERVER
from epiphany_mvp_status import ROOT
from epiphany_phase5_smoke import require
from epiphany_phase5_smoke import reset_smoke_paths
DEFAULT_CODEX_HOME = ROOT / ".epiphany-smoke" / "mvp-status-codex-home"
DEFAULT_RESULT = ROOT / ".epiphany-smoke" / "mvp-status-smoke-result.json"
DEFAULT_TRANSCRIPT = ROOT / ".epiphany-smoke" / "mvp-status-smoke-transcript.jsonl"
DEFAULT_STDERR = ROOT / ".epiphany-smoke" / "mvp-status-smoke-server.stderr.log"
DEFAULT_RENDERED = ROOT / ".epiphany-smoke" / "mvp-status-smoke-rendered.txt"
def native_status_exe() -> Path:
exe = Path(os.environ.get("CARGO_TARGET_DIR", r"C:\Users\Meta\.cargo-target-codex")) / "debug" / "epiphany-mvp-status.exe"
if exe.exists():
return exe
subprocess.run(
[
"cargo",
"build",
"--manifest-path",
str(ROOT / "epiphany-core" / "Cargo.toml"),
"--bin",
"epiphany-mvp-status",
],
cwd=ROOT,
check=True,
)
require(exe.exists(), f"native status binary was not built: {exe}")
return exe
def run_smoke(args: argparse.Namespace) -> dict[str, object]:
app_server = args.app_server.resolve()
if not app_server.exists():
raise FileNotFoundError(f"codex app-server binary not found: {app_server}")
codex_home = args.codex_home.resolve()
result_path = args.result.resolve()
transcript_path = args.transcript.resolve()
stderr_path = args.stderr.resolve()
reset_smoke_paths(codex_home, result_path, transcript_path, stderr_path)
rendered_path = args.rendered.resolve()
if rendered_path.exists():
rendered_path.unlink()
exe = native_status_exe()
completed = subprocess.run(
[
str(exe),
"--app-server",
str(app_server),
"--codex-home",
str(codex_home),
"--cwd",
str(ROOT),
"--transcript",
str(transcript_path),
"--stderr",
str(stderr_path),
"--result",
str(result_path),
"--json",
],
cwd=ROOT,
text=True,
capture_output=True,
check=False,
)
require(completed.returncode == 0, completed.stderr or completed.stdout)
status = json.loads(completed.stdout)
rendered_completed = subprocess.run(
[
str(exe),
"--app-server",
str(app_server),
"--codex-home",
str(codex_home),
"--cwd",
str(ROOT),
"--transcript",
str(transcript_path.with_name("mvp-status-smoke-render-transcript.jsonl")),
"--stderr",
str(stderr_path.with_name("mvp-status-smoke-render-server.stderr.log")),
],
cwd=ROOT,
text=True,
capture_output=True,
check=False,
)
require(rendered_completed.returncode == 0, rendered_completed.stderr or rendered_completed.stdout)
rendered = rendered_completed.stdout
rendered_path.write_text(rendered, encoding="utf-8")
require(
status["scene"]["scene"]["stateStatus"] == "missing",
"fresh status smoke should honestly report missing Epiphany state",
)
require(
status["crrc"]["recommendation"]["action"] == "regatherManually",
"fresh status smoke should recommend manual regather without state",
)
require(
"crrc" in status["scene"]["scene"]["availableActions"],
"status view should expose the CRRC action in the scene",
)
require(
"roles" in status["scene"]["scene"]["availableActions"],
"status view should expose the role ownership action in the scene",
)
require(
"Epiphany MVP Status" in rendered and "Recommendation" in rendered,
"rendered status should include the operator view headings",
)
require(
"regatherManually" in rendered,
"rendered status should expose the CRRC recommendation",
)
lane_ids = [lane["id"] for lane in status["roles"]["roles"]]
require(
lane_ids
== ["implementation", "imagination", "modeling", "verification", "reorientation"],
"roles surface should expose the five MVP role lanes",
)
require(
status["roles"]["note"].startswith("Role ownership is derived read-only"),
"roles surface should declare read-only derived ownership",
)
require(
status["planning"]["stateStatus"] == "missing"
and status["planning"]["summary"]["captureCount"] == 0,
"fresh status smoke should expose empty planning state honestly",
)
require(
"Planning" in rendered and "captures: 0" in rendered,
"rendered status should expose the planning section",
)
require(
"Role Lanes" in rendered and "Verification / Review" in rendered,
"rendered status should expose the role lane section",
)
require(
"Role Findings" in rendered
and status["roleResults"]["imagination"]["status"] == "missingState"
and status["roleResults"]["modeling"]["status"] == "missingState"
and status["roleResults"]["verification"]["status"] == "missingState",
"rendered status should expose fixed role result read-back status",
)
require(
status["heartbeat"]["schema_version"] == "epiphany.agent_heartbeat_status.v0",
"status view should expose heartbeat initiative status for Aquarium",
)
require(
status["face"]["availableActions"] == ["faceBubble"],
"status view should expose Face bubble action for Aquarium",
)
require(
"Heartbeat" in rendered and "Face" in rendered,
"rendered status should expose heartbeat and Face sections",
)
result = {
"threadId": status["threadId"],
"recommendation": status["crrc"]["recommendation"],
"roles": status["roles"],
"roleResults": status["roleResults"],
"planning": status["planning"],
"heartbeat": status["heartbeat"],
"face": status["face"],
"stateStatus": status["scene"]["scene"]["stateStatus"],
"availableActions": status["scene"]["scene"]["availableActions"],
"rendered": rendered,
}
result_path.parent.mkdir(parents=True, exist_ok=True)
result_path.write_text(
json.dumps(result, indent=2, ensure_ascii=False) + "\n",
encoding="utf-8",
)
return result
def main() -> int:
parser = argparse.ArgumentParser(
description="Live-smoke the Epiphany MVP operator status view."
)
parser.add_argument("--app-server", type=Path, default=DEFAULT_APP_SERVER)
parser.add_argument("--codex-home", type=Path, default=DEFAULT_CODEX_HOME)
parser.add_argument("--result", type=Path, default=DEFAULT_RESULT)
parser.add_argument("--transcript", type=Path, default=DEFAULT_TRANSCRIPT)
parser.add_argument("--stderr", type=Path, default=DEFAULT_STDERR)
parser.add_argument("--rendered", type=Path, default=DEFAULT_RENDERED)
args = parser.parse_args()
result = run_smoke(args)
print(json.dumps(result, indent=2, ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())