Move graph query smoke to Rust
This commit is contained in:
parent
86e4440b33
commit
0cf4b0814e
7 changed files with 548 additions and 332 deletions
540
epiphany-core/src/bin/epiphany-phase6-graph-query-smoke.rs
Normal file
540
epiphany-core/src/bin/epiphany-phase6-graph-query-smoke.rs
Normal file
|
|
@ -0,0 +1,540 @@
|
|||
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::time::Duration;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[path = "epiphany-mvp-status.rs"]
|
||||
mod status_cli;
|
||||
|
||||
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,
|
||||
}
|
||||
|
||||
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("phase6-graph-query-codex-home"),
|
||||
result: root
|
||||
.join(".epiphany-smoke")
|
||||
.join("phase6-graph-query-smoke-result.json"),
|
||||
transcript: root
|
||||
.join(".epiphany-smoke")
|
||||
.join("phase6-graph-query-smoke-transcript.jsonl"),
|
||||
stderr: root
|
||||
.join(".epiphany-smoke")
|
||||
.join("phase6-graph-query-smoke-server.stderr.log"),
|
||||
};
|
||||
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")?,
|
||||
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 = status_cli::absolute_path(&args.app_server)?;
|
||||
if !app_server.exists() {
|
||||
return Err(anyhow!(
|
||||
"codex app-server binary not found: {}",
|
||||
app_server.display()
|
||||
));
|
||||
}
|
||||
let codex_home = status_cli::absolute_path(&args.codex_home)?;
|
||||
let result_path = status_cli::absolute_path(&args.result)?;
|
||||
let transcript_path = status_cli::absolute_path(&args.transcript)?;
|
||||
let stderr_path = status_cli::absolute_path(&args.stderr)?;
|
||||
reset_smoke_paths(
|
||||
&root,
|
||||
&[
|
||||
codex_home.clone(),
|
||||
result_path.clone(),
|
||||
transcript_path.clone(),
|
||||
stderr_path.clone(),
|
||||
],
|
||||
)?;
|
||||
fs::create_dir_all(&codex_home)
|
||||
.with_context(|| format!("failed to create {}", codex_home.display()))?;
|
||||
|
||||
let mut client = status_cli::AppServerClient::start(
|
||||
&app_server,
|
||||
&codex_home,
|
||||
&transcript_path,
|
||||
&stderr_path,
|
||||
)?;
|
||||
client.send(
|
||||
"initialize",
|
||||
Some(json!({
|
||||
"clientInfo": {
|
||||
"name": "epiphany-phase6-graph-query-smoke",
|
||||
"title": "Epiphany Phase 6 Graph Query Smoke",
|
||||
"version": "0.1.0",
|
||||
},
|
||||
"capabilities": {"experimentalApi": true},
|
||||
})),
|
||||
true,
|
||||
)?;
|
||||
client.send("initialized", None, false)?;
|
||||
let started = client.send(
|
||||
"thread/start",
|
||||
Some(json!({"cwd": root.join("epiphany-core"), "ephemeral": true})),
|
||||
true,
|
||||
)?;
|
||||
let thread_id = started
|
||||
.pointer("/thread/id")
|
||||
.and_then(Value::as_str)
|
||||
.ok_or_else(|| anyhow!("thread/start response missing thread.id"))?
|
||||
.to_string();
|
||||
|
||||
let missing_notification_start = client.notification_len();
|
||||
let missing_response = client.send(
|
||||
"thread/epiphany/graphQuery",
|
||||
Some(json!({
|
||||
"threadId": thread_id,
|
||||
"query": {"kind": "node", "nodeIds": ["graph-query-surface"]},
|
||||
})),
|
||||
true,
|
||||
)?;
|
||||
assert_missing_graph_query(&missing_response, &thread_id)?;
|
||||
client.require_no_notification(
|
||||
"thread/epiphany/stateUpdated",
|
||||
missing_notification_start,
|
||||
Duration::from_secs(1),
|
||||
)?;
|
||||
|
||||
let update_notification_start = client.notification_len();
|
||||
let update = client.send(
|
||||
"thread/epiphany/update",
|
||||
Some(json!({
|
||||
"threadId": thread_id,
|
||||
"expectedRevision": 0,
|
||||
"patch": graph_query_patch(),
|
||||
})),
|
||||
true,
|
||||
)?;
|
||||
require(
|
||||
update.get("revision").and_then(Value::as_u64) == Some(1),
|
||||
"graph query smoke patch should advance revision to 1",
|
||||
)?;
|
||||
client.wait_for_notification(
|
||||
"thread/epiphany/stateUpdated",
|
||||
update_notification_start,
|
||||
Duration::from_secs(10),
|
||||
)?;
|
||||
|
||||
let frontier_notification_start = client.notification_len();
|
||||
let frontier_response = client.send(
|
||||
"thread/epiphany/graphQuery",
|
||||
Some(json!({
|
||||
"threadId": thread_id,
|
||||
"query": {
|
||||
"kind": "frontierNeighborhood",
|
||||
"direction": "outgoing",
|
||||
"depth": 1,
|
||||
},
|
||||
})),
|
||||
true,
|
||||
)?;
|
||||
assert_frontier_graph_query(&frontier_response)?;
|
||||
client.require_no_notification(
|
||||
"thread/epiphany/stateUpdated",
|
||||
frontier_notification_start,
|
||||
Duration::from_secs(1),
|
||||
)?;
|
||||
|
||||
let path_notification_start = client.notification_len();
|
||||
let path_response = client.send(
|
||||
"thread/epiphany/graphQuery",
|
||||
Some(json!({
|
||||
"threadId": thread_id,
|
||||
"query": {
|
||||
"kind": "path",
|
||||
"paths": ["app-server/src/codex_message_processor.rs"],
|
||||
"symbols": ["map_epiphany_graph_query"],
|
||||
},
|
||||
})),
|
||||
true,
|
||||
)?;
|
||||
assert_path_graph_query(&path_response)?;
|
||||
client.require_no_notification(
|
||||
"thread/epiphany/stateUpdated",
|
||||
path_notification_start,
|
||||
Duration::from_secs(1),
|
||||
)?;
|
||||
|
||||
let final_read = client.send(
|
||||
"thread/read",
|
||||
Some(json!({"threadId": thread_id, "includeTurns": false})),
|
||||
true,
|
||||
)?;
|
||||
require(
|
||||
final_read
|
||||
.pointer("/thread/epiphanyState/revision")
|
||||
.and_then(Value::as_u64)
|
||||
== Some(1),
|
||||
"graph query reflection should not mutate state revision",
|
||||
)?;
|
||||
|
||||
let result = json!({
|
||||
"threadId": thread_id,
|
||||
"codexHome": codex_home,
|
||||
"missingStateStatus": missing_response["stateStatus"],
|
||||
"frontierStateStatus": frontier_response["stateStatus"],
|
||||
"pathStateStatus": path_response["stateStatus"],
|
||||
"readyRevision": frontier_response["stateRevision"],
|
||||
"frontierArchitectureNodeIds": ids(&frontier_response["graph"]["architectureNodes"]),
|
||||
"frontierDataflowNodeIds": ids(&frontier_response["graph"]["dataflowNodes"]),
|
||||
"pathMatchedSymbols": path_response["matched"]["symbols"],
|
||||
"frontierNotificationCount": client.notification_count(
|
||||
"thread/epiphany/stateUpdated",
|
||||
frontier_notification_start,
|
||||
),
|
||||
"pathNotificationCount": client.notification_count(
|
||||
"thread/epiphany/stateUpdated",
|
||||
path_notification_start,
|
||||
),
|
||||
"finalReadRevision": final_read["thread"]["epiphanyState"]["revision"],
|
||||
});
|
||||
write_json(&result_path, &result)?;
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn graph_query_patch() -> Value {
|
||||
let code_ref = json!({
|
||||
"path": "app-server/src/codex_message_processor.rs",
|
||||
"start_line": 15201,
|
||||
"end_line": 15534,
|
||||
"symbol": "map_epiphany_graph_query"
|
||||
});
|
||||
json!({
|
||||
"objective": "Expose read-only graph traversal for implementation and verifier agents.",
|
||||
"activeSubgoalId": "phase6-graph-query-smoke",
|
||||
"subgoals": [{
|
||||
"id": "phase6-graph-query-smoke",
|
||||
"title": "Live-smoke graph query traversal",
|
||||
"status": "active",
|
||||
"summary": "The graph query surface should traverse typed graph state without mutating it."
|
||||
}],
|
||||
"graphs": {
|
||||
"architecture": {
|
||||
"nodes": [
|
||||
{
|
||||
"id": "graph-query-surface",
|
||||
"title": "Graph query surface",
|
||||
"purpose": "Return bounded graph neighborhoods and path matches for agents.",
|
||||
"code_refs": [code_ref.clone()]
|
||||
},
|
||||
{
|
||||
"id": "implementation-agent",
|
||||
"title": "Implementation agent",
|
||||
"purpose": "Uses graph neighborhoods to decide where to edit."
|
||||
},
|
||||
{
|
||||
"id": "verifier-agent",
|
||||
"title": "Verifier agent",
|
||||
"purpose": "Uses graph neighborhoods to inspect blast radius."
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"id": "edge-query-implementation",
|
||||
"source_id": "graph-query-surface",
|
||||
"target_id": "implementation-agent",
|
||||
"kind": "guides",
|
||||
"code_refs": [code_ref.clone()]
|
||||
},
|
||||
{
|
||||
"id": "edge-query-verifier",
|
||||
"source_id": "graph-query-surface",
|
||||
"target_id": "verifier-agent",
|
||||
"kind": "guides"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dataflow": {
|
||||
"nodes": [{
|
||||
"id": "typed-graph-state",
|
||||
"title": "Typed graph state",
|
||||
"purpose": "Remain the authoritative model behind graph traversal.",
|
||||
"code_refs": [code_ref.clone()]
|
||||
}]
|
||||
},
|
||||
"links": [{
|
||||
"dataflow_node_id": "typed-graph-state",
|
||||
"architecture_node_id": "graph-query-surface",
|
||||
"relationship": "authoritative-query-source",
|
||||
"code_refs": [code_ref]
|
||||
}]
|
||||
},
|
||||
"graphFrontier": {
|
||||
"active_node_ids": ["graph-query-surface"],
|
||||
"active_edge_ids": ["edge-query-implementation"]
|
||||
},
|
||||
"graphCheckpoint": {
|
||||
"checkpoint_id": "phase6-graph-query-smoke",
|
||||
"graph_revision": 1,
|
||||
"summary": "Graph query traversal is the active Phase 6 smoke target.",
|
||||
"frontier_node_ids": ["graph-query-surface"]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn assert_missing_graph_query(response: &Value, thread_id: &str) -> Result<()> {
|
||||
require(
|
||||
response.get("threadId").and_then(Value::as_str) == Some(thread_id),
|
||||
"graph query should echo thread id",
|
||||
)?;
|
||||
require(
|
||||
response.get("source").and_then(Value::as_str) == Some("live"),
|
||||
"missing graph query should report live source",
|
||||
)?;
|
||||
require(
|
||||
response.get("stateStatus").and_then(Value::as_str) == Some("missing"),
|
||||
"missing graph query should report missing state",
|
||||
)?;
|
||||
require(
|
||||
response.get("stateRevision").is_none(),
|
||||
"missing graph query should not invent a revision",
|
||||
)?;
|
||||
require(
|
||||
response.get("graph") == Some(&json!({})),
|
||||
"missing graph query should not invent graph records",
|
||||
)?;
|
||||
require(
|
||||
string_array_eq(
|
||||
response
|
||||
.pointer("/missing/nodeIds")
|
||||
.and_then(Value::as_array),
|
||||
&["graph-query-surface"],
|
||||
),
|
||||
"missing graph query should echo unresolved explicit node ids",
|
||||
)
|
||||
}
|
||||
|
||||
fn assert_frontier_graph_query(response: &Value) -> Result<()> {
|
||||
require(
|
||||
response.get("stateStatus").and_then(Value::as_str) == Some("ready"),
|
||||
"frontier graph query should report ready state",
|
||||
)?;
|
||||
require(
|
||||
response.get("stateRevision").and_then(Value::as_u64) == Some(1),
|
||||
"frontier graph query should preserve revision",
|
||||
)?;
|
||||
require(
|
||||
ids_eq(
|
||||
response
|
||||
.pointer("/graph/architectureNodes")
|
||||
.and_then(Value::as_array),
|
||||
&[
|
||||
"graph-query-surface",
|
||||
"implementation-agent",
|
||||
"verifier-agent",
|
||||
],
|
||||
),
|
||||
"frontier graph query should return one-hop architecture neighbors",
|
||||
)?;
|
||||
require(
|
||||
ids_eq(
|
||||
response
|
||||
.pointer("/graph/dataflowNodes")
|
||||
.and_then(Value::as_array),
|
||||
&["typed-graph-state"],
|
||||
),
|
||||
"frontier graph query should preserve linked dataflow node",
|
||||
)?;
|
||||
require(
|
||||
ids_eq(
|
||||
response
|
||||
.pointer("/graph/architectureEdges")
|
||||
.and_then(Value::as_array),
|
||||
&["edge-query-implementation", "edge-query-verifier"],
|
||||
),
|
||||
"frontier graph query should return active and incident architecture edges",
|
||||
)?;
|
||||
require(
|
||||
response
|
||||
.pointer("/graph/links/0/dataflow_node_id")
|
||||
.and_then(Value::as_str)
|
||||
== Some("typed-graph-state"),
|
||||
"frontier graph query should return architecture/dataflow link",
|
||||
)?;
|
||||
require(
|
||||
string_array_eq(
|
||||
response
|
||||
.pointer("/frontier/active_node_ids")
|
||||
.and_then(Value::as_array),
|
||||
&["graph-query-surface"],
|
||||
),
|
||||
"frontier graph query should include current frontier",
|
||||
)?;
|
||||
require(
|
||||
response
|
||||
.pointer("/checkpoint/checkpoint_id")
|
||||
.and_then(Value::as_str)
|
||||
== Some("phase6-graph-query-smoke"),
|
||||
"frontier graph query should include graph checkpoint",
|
||||
)?;
|
||||
require(
|
||||
response.get("missing") == Some(&json!({})),
|
||||
"frontier graph query should have no missing records",
|
||||
)
|
||||
}
|
||||
|
||||
fn assert_path_graph_query(response: &Value) -> Result<()> {
|
||||
require(
|
||||
response.get("stateStatus").and_then(Value::as_str) == Some("ready"),
|
||||
"path graph query should report ready state",
|
||||
)?;
|
||||
require(
|
||||
string_array_eq(
|
||||
response.pointer("/matched/paths").and_then(Value::as_array),
|
||||
&["app-server/src/codex_message_processor.rs"],
|
||||
),
|
||||
"path graph query should report matched code ref path",
|
||||
)?;
|
||||
require(
|
||||
string_array_eq(
|
||||
response
|
||||
.pointer("/matched/symbols")
|
||||
.and_then(Value::as_array),
|
||||
&["map_epiphany_graph_query"],
|
||||
),
|
||||
"path graph query should report matched symbol",
|
||||
)?;
|
||||
require(
|
||||
string_array_contains(
|
||||
response
|
||||
.pointer("/matched/nodeIds")
|
||||
.and_then(Value::as_array),
|
||||
"graph-query-surface",
|
||||
),
|
||||
"path graph query should include graph query node in matches",
|
||||
)?;
|
||||
require(
|
||||
string_array_contains(
|
||||
response
|
||||
.pointer("/matched/nodeIds")
|
||||
.and_then(Value::as_array),
|
||||
"typed-graph-state",
|
||||
),
|
||||
"path graph query should include linked dataflow node in matches",
|
||||
)
|
||||
}
|
||||
|
||||
fn ids(value: &Value) -> Value {
|
||||
json!(
|
||||
value
|
||||
.as_array()
|
||||
.map(|items| {
|
||||
items
|
||||
.iter()
|
||||
.filter_map(|item| item.get("id").and_then(Value::as_str))
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.unwrap_or_default()
|
||||
)
|
||||
}
|
||||
|
||||
fn ids_eq(values: Option<&Vec<Value>>, expected: &[&str]) -> bool {
|
||||
values.is_some_and(|values| {
|
||||
values.len() == expected.len()
|
||||
&& values
|
||||
.iter()
|
||||
.zip(expected)
|
||||
.all(|(value, expected)| value.get("id").and_then(Value::as_str) == Some(*expected))
|
||||
})
|
||||
}
|
||||
|
||||
fn string_array_eq(values: Option<&Vec<Value>>, expected: &[&str]) -> bool {
|
||||
values.is_some_and(|values| {
|
||||
values.len() == expected.len()
|
||||
&& values
|
||||
.iter()
|
||||
.zip(expected)
|
||||
.all(|(value, expected)| value.as_str() == Some(*expected))
|
||||
})
|
||||
}
|
||||
|
||||
fn string_array_contains(values: Option<&Vec<Value>>, expected: &str) -> bool {
|
||||
values.is_some_and(|values| values.iter().any(|value| value.as_str() == Some(expected)))
|
||||
}
|
||||
|
||||
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 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"))
|
||||
}
|
||||
|
|
@ -1505,7 +1505,7 @@ Current tests cover the landed flows at useful seams:
|
|||
- live app-server smoke for the first Phase 6 freshness boundary through native `epiphany-phase6-freshness-smoke`.
|
||||
- live app-server smoke for watcher-backed invalidation inputs inside the Phase 6 freshness boundary in `tools/epiphany_phase6_invalidation_smoke.py`.
|
||||
- live app-server smoke for the first Phase 6 context boundary through native `epiphany-phase6-context-smoke`.
|
||||
- live app-server smoke for the first Phase 6 graph traversal boundary in `tools/epiphany_phase6_graph_query_smoke.py`.
|
||||
- live app-server smoke for the first Phase 6 graph traversal boundary through native `epiphany-phase6-graph-query-smoke`.
|
||||
- live app-server smoke for the first Phase 6 planning boundary in `tools/epiphany_phase6_planning_smoke.py`.
|
||||
- live app-server smoke for the first Phase 6 pressure boundary through native `epiphany-phase6-pressure-smoke`.
|
||||
- live app-server smoke for the first Phase 6 reorientation policy boundary in `tools/epiphany_phase6_reorient_smoke.py`.
|
||||
|
|
@ -1529,7 +1529,7 @@ $env:CARGO_TARGET_DIR='C:\Users\Meta\.cargo-target-codex'; cargo test -p codex-a
|
|||
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-freshness-smoke
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_invalidation_smoke.py'
|
||||
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-context-smoke
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_graph_query_smoke.py'
|
||||
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-graph-query-smoke
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_planning_smoke.py'
|
||||
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-pressure-smoke
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_reorient_smoke.py'
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ The landed machine now has:
|
|||
- read-only Phase 6 targeted state-shard reflection through `thread/epiphany/context`
|
||||
- live Phase 6 context app-server smoke coverage through native `epiphany-phase6-context-smoke`
|
||||
- read-only Phase 6 graph traversal through `thread/epiphany/graphQuery`
|
||||
- live Phase 6 graph traversal smoke coverage in `tools/epiphany_phase6_graph_query_smoke.py`
|
||||
- live Phase 6 graph traversal smoke coverage through native `epiphany-phase6-graph-query-smoke`
|
||||
- read-only Phase 6 context-pressure reflection through `thread/epiphany/pressure`
|
||||
- live Phase 6 pressure app-server smoke coverage through native `epiphany-phase6-pressure-smoke`
|
||||
- durable Phase 6 investigation checkpointing in authoritative typed state, prompt rendering, and scene/context reflection
|
||||
|
|
@ -459,7 +459,7 @@ cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-conte
|
|||
Before modifying graph traversal behavior, run:
|
||||
|
||||
```powershell
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_graph_query_smoke.py'
|
||||
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-graph-query-smoke
|
||||
```
|
||||
|
||||
Before modifying planning state or projection behavior, run:
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ The current spine, blessed but not yet finished:
|
|||
- live freshness app-server smoke through native `epiphany-phase6-freshness-smoke`
|
||||
- live watcher-backed invalidation smoke through `tools/epiphany_phase6_invalidation_smoke.py`
|
||||
- live context app-server smoke through native `epiphany-phase6-context-smoke`
|
||||
- live graph traversal app-server smoke through `tools/epiphany_phase6_graph_query_smoke.py`
|
||||
- live graph traversal app-server smoke through native `epiphany-phase6-graph-query-smoke`
|
||||
- live planning app-server smoke through `tools/epiphany_phase6_planning_smoke.py`
|
||||
- live GUI planning adoption smoke through `tools/epiphany_gui_planning_smoke.py`
|
||||
- live pressure app-server smoke through native `epiphany-phase6-pressure-smoke`
|
||||
|
|
@ -234,7 +234,7 @@ cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-conte
|
|||
For graph traversal behavior changes, run:
|
||||
|
||||
```powershell
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_graph_query_smoke.py'
|
||||
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-graph-query-smoke
|
||||
```
|
||||
|
||||
For planning state/projection behavior changes, run:
|
||||
|
|
@ -470,7 +470,7 @@ Live `thread/epiphany/scene`, `thread/epiphany/jobs`, `thread/epiphany/roles`,
|
|||
`thread/epiphany/graphQuery`, `thread/epiphany/planning`, `thread/epiphany/pressure`,
|
||||
`thread/epiphany/reorient`, `thread/epiphany/crrc`, `thread/epiphany/coordinator`,
|
||||
native `epiphany-mvp-status`, native `epiphany-mvp-coordinator`, and
|
||||
`tools/epiphany_phase6_graph_query_smoke.py` / `tools/epiphany_phase6_planning_smoke.py`
|
||||
native `epiphany-phase6-graph-query-smoke` / `tools/epiphany_phase6_planning_smoke.py`
|
||||
/ `tools/epiphany_gui_planning_smoke.py`
|
||||
smokes are now guardrails, not the next organs.
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -204,7 +204,7 @@ landed_baseline:
|
|||
- Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-freshness-smoke` before modifying freshness reflection behavior.
|
||||
- Use `tools/epiphany_phase6_invalidation_smoke.py` before modifying watcher-backed invalidation behavior inside freshness reflection.
|
||||
- Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-context-smoke` before modifying targeted context-shard behavior.
|
||||
- Use `tools/epiphany_phase6_graph_query_smoke.py` before modifying graph traversal behavior.
|
||||
- Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-graph-query-smoke` before modifying graph traversal behavior.
|
||||
- Use `tools/epiphany_phase6_planning_smoke.py` before modifying planning state or the read-only planning projection.
|
||||
- Use `tools/epiphany_gui_planning_smoke.py` before modifying GUI Objective Draft adoption behavior.
|
||||
- Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-pressure-smoke` before modifying context-pressure reflection behavior.
|
||||
|
|
|
|||
|
|
@ -1,324 +0,0 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from epiphany_phase5_smoke import AppServerClient
|
||||
from epiphany_phase5_smoke import DEFAULT_APP_SERVER
|
||||
from epiphany_phase5_smoke import ROOT
|
||||
from epiphany_phase5_smoke import require
|
||||
from epiphany_phase5_smoke import reset_smoke_paths
|
||||
|
||||
|
||||
DEFAULT_CODEX_HOME = ROOT / ".epiphany-smoke" / "phase6-graph-query-codex-home"
|
||||
DEFAULT_RESULT = ROOT / ".epiphany-smoke" / "phase6-graph-query-smoke-result.json"
|
||||
DEFAULT_TRANSCRIPT = ROOT / ".epiphany-smoke" / "phase6-graph-query-smoke-transcript.jsonl"
|
||||
DEFAULT_STDERR = ROOT / ".epiphany-smoke" / "phase6-graph-query-smoke-server.stderr.log"
|
||||
|
||||
GRAPH_QUERY_CODE_REF = {
|
||||
"path": "app-server/src/codex_message_processor.rs",
|
||||
"start_line": 15201,
|
||||
"end_line": 15534,
|
||||
"symbol": "map_epiphany_graph_query",
|
||||
}
|
||||
|
||||
|
||||
def graph_query_patch() -> dict[str, Any]:
|
||||
return {
|
||||
"objective": "Expose read-only graph traversal for implementation and verifier agents.",
|
||||
"activeSubgoalId": "phase6-graph-query-smoke",
|
||||
"subgoals": [
|
||||
{
|
||||
"id": "phase6-graph-query-smoke",
|
||||
"title": "Live-smoke graph query traversal",
|
||||
"status": "active",
|
||||
"summary": "The graph query surface should traverse typed graph state without mutating it.",
|
||||
}
|
||||
],
|
||||
"graphs": {
|
||||
"architecture": {
|
||||
"nodes": [
|
||||
{
|
||||
"id": "graph-query-surface",
|
||||
"title": "Graph query surface",
|
||||
"purpose": "Return bounded graph neighborhoods and path matches for agents.",
|
||||
"code_refs": [GRAPH_QUERY_CODE_REF],
|
||||
},
|
||||
{
|
||||
"id": "implementation-agent",
|
||||
"title": "Implementation agent",
|
||||
"purpose": "Uses graph neighborhoods to decide where to edit.",
|
||||
},
|
||||
{
|
||||
"id": "verifier-agent",
|
||||
"title": "Verifier agent",
|
||||
"purpose": "Uses graph neighborhoods to inspect blast radius.",
|
||||
},
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"id": "edge-query-implementation",
|
||||
"source_id": "graph-query-surface",
|
||||
"target_id": "implementation-agent",
|
||||
"kind": "guides",
|
||||
"code_refs": [GRAPH_QUERY_CODE_REF],
|
||||
},
|
||||
{
|
||||
"id": "edge-query-verifier",
|
||||
"source_id": "graph-query-surface",
|
||||
"target_id": "verifier-agent",
|
||||
"kind": "guides",
|
||||
},
|
||||
],
|
||||
},
|
||||
"dataflow": {
|
||||
"nodes": [
|
||||
{
|
||||
"id": "typed-graph-state",
|
||||
"title": "Typed graph state",
|
||||
"purpose": "Remain the authoritative model behind graph traversal.",
|
||||
"code_refs": [GRAPH_QUERY_CODE_REF],
|
||||
}
|
||||
]
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"dataflow_node_id": "typed-graph-state",
|
||||
"architecture_node_id": "graph-query-surface",
|
||||
"relationship": "authoritative-query-source",
|
||||
"code_refs": [GRAPH_QUERY_CODE_REF],
|
||||
}
|
||||
],
|
||||
},
|
||||
"graphFrontier": {
|
||||
"active_node_ids": ["graph-query-surface"],
|
||||
"active_edge_ids": ["edge-query-implementation"],
|
||||
},
|
||||
"graphCheckpoint": {
|
||||
"checkpoint_id": "phase6-graph-query-smoke",
|
||||
"graph_revision": 1,
|
||||
"summary": "Graph query traversal is the active Phase 6 smoke target.",
|
||||
"frontier_node_ids": ["graph-query-surface"],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def assert_missing_graph_query(response: dict[str, Any], thread_id: str) -> None:
|
||||
require(response["threadId"] == thread_id, "graph query should echo thread id")
|
||||
require(response["source"] == "live", "missing graph query should report live source")
|
||||
require(response["stateStatus"] == "missing", "missing graph query should report missing state")
|
||||
require("stateRevision" not in response, "missing graph query should not invent a revision")
|
||||
require(response["graph"] == {}, "missing graph query should not invent graph records")
|
||||
require(
|
||||
response["missing"]["nodeIds"] == ["graph-query-surface"],
|
||||
"missing graph query should echo unresolved explicit node ids",
|
||||
)
|
||||
|
||||
|
||||
def assert_frontier_graph_query(response: dict[str, Any]) -> None:
|
||||
require(response["stateStatus"] == "ready", "frontier graph query should report ready state")
|
||||
require(response["stateRevision"] == 1, "frontier graph query should preserve revision")
|
||||
require(
|
||||
[node["id"] for node in response["graph"]["architectureNodes"]]
|
||||
== ["graph-query-surface", "implementation-agent", "verifier-agent"],
|
||||
"frontier graph query should return one-hop architecture neighbors",
|
||||
)
|
||||
require(
|
||||
[node["id"] for node in response["graph"]["dataflowNodes"]] == ["typed-graph-state"],
|
||||
"frontier graph query should preserve linked dataflow node",
|
||||
)
|
||||
require(
|
||||
[edge["id"] for edge in response["graph"]["architectureEdges"]]
|
||||
== ["edge-query-implementation", "edge-query-verifier"],
|
||||
"frontier graph query should return active and incident architecture edges",
|
||||
)
|
||||
require(
|
||||
response["graph"]["links"][0]["dataflow_node_id"] == "typed-graph-state",
|
||||
"frontier graph query should return architecture/dataflow link",
|
||||
)
|
||||
require(
|
||||
response["frontier"]["active_node_ids"] == ["graph-query-surface"],
|
||||
"frontier graph query should include current frontier",
|
||||
)
|
||||
require(
|
||||
response["checkpoint"]["checkpoint_id"] == "phase6-graph-query-smoke",
|
||||
"frontier graph query should include graph checkpoint",
|
||||
)
|
||||
require(response["missing"] == {}, "frontier graph query should have no missing records")
|
||||
|
||||
|
||||
def assert_path_graph_query(response: dict[str, Any]) -> None:
|
||||
require(response["stateStatus"] == "ready", "path graph query should report ready state")
|
||||
require(
|
||||
response["matched"]["paths"] == ["app-server/src/codex_message_processor.rs"],
|
||||
"path graph query should report matched code ref path",
|
||||
)
|
||||
require(
|
||||
response["matched"]["symbols"] == ["map_epiphany_graph_query"],
|
||||
"path graph query should report matched symbol",
|
||||
)
|
||||
require(
|
||||
"graph-query-surface" in response["matched"]["nodeIds"],
|
||||
"path graph query should include graph query node in matches",
|
||||
)
|
||||
require(
|
||||
"typed-graph-state" in response["matched"]["nodeIds"],
|
||||
"path graph query should include linked dataflow node in matches",
|
||||
)
|
||||
|
||||
|
||||
def run_smoke(args: argparse.Namespace) -> dict[str, Any]:
|
||||
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)
|
||||
|
||||
with AppServerClient(app_server, codex_home, transcript_path, stderr_path) as client:
|
||||
client.send(
|
||||
"initialize",
|
||||
{
|
||||
"clientInfo": {
|
||||
"name": "epiphany-phase6-graph-query-smoke",
|
||||
"title": "Epiphany Phase 6 Graph Query Smoke",
|
||||
"version": "0.1.0",
|
||||
},
|
||||
"capabilities": {"experimentalApi": True},
|
||||
},
|
||||
)
|
||||
client.send("initialized", expect_response=False)
|
||||
started = client.send(
|
||||
"thread/start",
|
||||
{"cwd": str(ROOT / "epiphany-core"), "ephemeral": True},
|
||||
)
|
||||
assert started is not None
|
||||
thread_id = started["thread"]["id"]
|
||||
|
||||
missing_notification_start = len(client.notifications)
|
||||
missing_response = client.send(
|
||||
"thread/epiphany/graphQuery",
|
||||
{
|
||||
"threadId": thread_id,
|
||||
"query": {"kind": "node", "nodeIds": ["graph-query-surface"]},
|
||||
},
|
||||
)
|
||||
assert missing_response is not None
|
||||
assert_missing_graph_query(missing_response, thread_id)
|
||||
client.require_no_notification(
|
||||
"thread/epiphany/stateUpdated",
|
||||
start_index=missing_notification_start,
|
||||
)
|
||||
|
||||
update_notification_start = len(client.notifications)
|
||||
update = client.send(
|
||||
"thread/epiphany/update",
|
||||
{"threadId": thread_id, "expectedRevision": 0, "patch": graph_query_patch()},
|
||||
)
|
||||
assert update is not None
|
||||
require(update["revision"] == 1, "graph query smoke patch should advance revision to 1")
|
||||
client.wait_for_notification(
|
||||
"thread/epiphany/stateUpdated",
|
||||
start_index=update_notification_start,
|
||||
)
|
||||
|
||||
frontier_notification_start = len(client.notifications)
|
||||
frontier_response = client.send(
|
||||
"thread/epiphany/graphQuery",
|
||||
{
|
||||
"threadId": thread_id,
|
||||
"query": {
|
||||
"kind": "frontierNeighborhood",
|
||||
"direction": "outgoing",
|
||||
"depth": 1,
|
||||
},
|
||||
},
|
||||
)
|
||||
assert frontier_response is not None
|
||||
assert_frontier_graph_query(frontier_response)
|
||||
client.require_no_notification(
|
||||
"thread/epiphany/stateUpdated",
|
||||
start_index=frontier_notification_start,
|
||||
)
|
||||
|
||||
path_notification_start = len(client.notifications)
|
||||
path_response = client.send(
|
||||
"thread/epiphany/graphQuery",
|
||||
{
|
||||
"threadId": thread_id,
|
||||
"query": {
|
||||
"kind": "path",
|
||||
"paths": ["app-server/src/codex_message_processor.rs"],
|
||||
"symbols": ["map_epiphany_graph_query"],
|
||||
},
|
||||
},
|
||||
)
|
||||
assert path_response is not None
|
||||
assert_path_graph_query(path_response)
|
||||
client.require_no_notification(
|
||||
"thread/epiphany/stateUpdated",
|
||||
start_index=path_notification_start,
|
||||
)
|
||||
|
||||
final_read = client.send("thread/read", {"threadId": thread_id, "includeTurns": False})
|
||||
assert final_read is not None
|
||||
require(
|
||||
final_read["thread"]["epiphanyState"]["revision"] == 1,
|
||||
"graph query reflection should not mutate state revision",
|
||||
)
|
||||
|
||||
result = {
|
||||
"threadId": thread_id,
|
||||
"codexHome": str(codex_home),
|
||||
"missingStateStatus": missing_response["stateStatus"],
|
||||
"frontierStateStatus": frontier_response["stateStatus"],
|
||||
"pathStateStatus": path_response["stateStatus"],
|
||||
"readyRevision": frontier_response["stateRevision"],
|
||||
"frontierArchitectureNodeIds": [
|
||||
node["id"] for node in frontier_response["graph"]["architectureNodes"]
|
||||
],
|
||||
"frontierDataflowNodeIds": [
|
||||
node["id"] for node in frontier_response["graph"]["dataflowNodes"]
|
||||
],
|
||||
"pathMatchedSymbols": path_response["matched"]["symbols"],
|
||||
"frontierNotificationCount": client.count_notifications(
|
||||
"thread/epiphany/stateUpdated",
|
||||
start_index=frontier_notification_start,
|
||||
),
|
||||
"pathNotificationCount": client.count_notifications(
|
||||
"thread/epiphany/stateUpdated",
|
||||
start_index=path_notification_start,
|
||||
),
|
||||
"finalReadRevision": final_read["thread"]["epiphanyState"]["revision"],
|
||||
}
|
||||
|
||||
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 Phase 6 Epiphany graph query traversal surface."
|
||||
)
|
||||
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)
|
||||
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())
|
||||
Reference in a new issue