Route repo work through native Modeling runtime
This commit is contained in:
parent
88f5dce697
commit
04d44d7923
11 changed files with 537 additions and 432 deletions
|
|
@ -1,409 +0,0 @@
|
|||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use chrono::Utc;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse()?;
|
||||
let result = run_smoke(args)?;
|
||||
println!("{}", serde_json::to_string_pretty(&result)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct Args {
|
||||
root: PathBuf,
|
||||
smoke_root: PathBuf,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
fn parse() -> Result<Self> {
|
||||
let mut root = env::current_dir().context("failed to resolve current directory")?;
|
||||
let mut smoke_root = root.join(".epiphany-smoke");
|
||||
let mut args = env::args().skip(1).peekable();
|
||||
while let Some(arg) = args.next() {
|
||||
match arg.as_str() {
|
||||
"--root" => root = take_path(&mut args, "--root")?,
|
||||
"--smoke-root" => smoke_root = take_path(&mut args, "--smoke-root")?,
|
||||
other => return Err(anyhow!("unexpected argument {other:?}")),
|
||||
}
|
||||
}
|
||||
Ok(Self { root, smoke_root })
|
||||
}
|
||||
}
|
||||
|
||||
fn run_smoke(args: Args) -> Result<Value> {
|
||||
let root = args
|
||||
.root
|
||||
.canonicalize()
|
||||
.with_context(|| format!("failed to resolve {}", args.root.display()))?;
|
||||
let manifest = root.join("epiphany-core").join("Cargo.toml");
|
||||
if !manifest.exists() {
|
||||
return Err(anyhow!(
|
||||
"could not find epiphany-core manifest at {}",
|
||||
manifest.display()
|
||||
));
|
||||
}
|
||||
fs::create_dir_all(&args.smoke_root)
|
||||
.with_context(|| format!("failed to create {}", args.smoke_root.display()))?;
|
||||
let stamp = Utc::now().format("%Y%m%d-%H%M%S").to_string();
|
||||
let smoke_dir = args.smoke_root.join(format!("closure-model-gate-{stamp}"));
|
||||
if smoke_dir.exists() {
|
||||
fs::remove_dir_all(&smoke_dir)
|
||||
.with_context(|| format!("failed to clear {}", smoke_dir.display()))?;
|
||||
}
|
||||
fs::create_dir_all(&smoke_dir)
|
||||
.with_context(|| format!("failed to create {}", smoke_dir.display()))?;
|
||||
|
||||
let repo = smoke_dir.join("repo-body");
|
||||
fs::create_dir_all(&repo).with_context(|| format!("failed to create {}", repo.display()))?;
|
||||
git(["init"], &repo)?;
|
||||
git(
|
||||
["config", "user.email", "epiphany-smoke@example.invalid"],
|
||||
&repo,
|
||||
)?;
|
||||
git(["config", "user.name", "Epiphany Smoke"], &repo)?;
|
||||
fs::write(
|
||||
repo.join("README.md"),
|
||||
"# Closure Model Gate Smoke\n\nThis repository proves model-authored closure verdicts.\n",
|
||||
)
|
||||
.with_context(|| format!("failed to seed {}", repo.join("README.md").display()))?;
|
||||
git(["add", "README.md"], &repo)?;
|
||||
git(["commit", "-m", "Seed closure model smoke repo"], &repo)?;
|
||||
git(["switch", "-c", "epiphany/closure-model-gate"], &repo)?;
|
||||
|
||||
let local_verse = repo.join(".epiphany").join("local-verse.ccmp");
|
||||
cargo_json(
|
||||
&manifest,
|
||||
"epiphany-repo",
|
||||
&[
|
||||
"init",
|
||||
"--workspace",
|
||||
path_str(&repo)?,
|
||||
"--epiphany-root",
|
||||
path_str(&root)?,
|
||||
"--swarm-id",
|
||||
"closure-model-gate-smoke",
|
||||
"--topic",
|
||||
"closure-model-gate",
|
||||
],
|
||||
&root,
|
||||
)?;
|
||||
cargo_json(
|
||||
&manifest,
|
||||
"epiphany-swarm",
|
||||
&[
|
||||
"online",
|
||||
"--workspace",
|
||||
path_str(&repo)?,
|
||||
"--epiphany-root",
|
||||
path_str(&root)?,
|
||||
"--runtime-id",
|
||||
"closure-model-gate-smoke",
|
||||
"--local-verse-store",
|
||||
path_str(&local_verse)?,
|
||||
],
|
||||
&root,
|
||||
)?;
|
||||
|
||||
let good = drive_item(
|
||||
&manifest,
|
||||
&root,
|
||||
&repo,
|
||||
"closure-model-pass",
|
||||
"Prove a model-authored closure verdict can explicitly pass after deterministic family checks.",
|
||||
"passed",
|
||||
"Modeling reviewed the verified status section, path scope, family assertions, and authority seal.",
|
||||
)?;
|
||||
let bad = drive_item(
|
||||
&manifest,
|
||||
&root,
|
||||
&repo,
|
||||
"closure-model-block",
|
||||
"Prove a model-authored closure verdict can block publication even when deterministic family checks pass.",
|
||||
"needs-work",
|
||||
"Modeling found the status text too thin and requires another branch-local pass before publication.",
|
||||
)?;
|
||||
|
||||
require_eq(&good.close, &["status"], "closed")?;
|
||||
require_eq(
|
||||
&good.close,
|
||||
&["closureReview", "modelingReview", "closureReview", "status"],
|
||||
"passed",
|
||||
)?;
|
||||
require_bool(
|
||||
&good.close,
|
||||
&[
|
||||
"closureReview",
|
||||
"modelingReview",
|
||||
"closureReview",
|
||||
"gateEnforced",
|
||||
],
|
||||
true,
|
||||
)?;
|
||||
require_eq(&bad.close, &["status"], "awaiting-modeling")?;
|
||||
require_eq(&bad.close, &["soul", "verdict"], "passed")?;
|
||||
require_eq(
|
||||
&bad.close,
|
||||
&["closureReview", "modelingReview", "closureReview", "status"],
|
||||
"failed",
|
||||
)?;
|
||||
require_bool(
|
||||
&bad.close,
|
||||
&["closureReview", "modelingReview", "closureReview", "passed"],
|
||||
false,
|
||||
)?;
|
||||
require_eq(
|
||||
&bad.close,
|
||||
&["closureReview", "familyAssertions", "status"],
|
||||
"passed",
|
||||
)?;
|
||||
require_bool(
|
||||
&bad.close,
|
||||
&["closureReview", "sourceGrounding", "pathScopeMatched"],
|
||||
true,
|
||||
)?;
|
||||
require_bool(&good.close, &["privateStateExposed"], false)?;
|
||||
require_bool(&bad.close, &["privateStateExposed"], false)?;
|
||||
|
||||
let summary = json!({
|
||||
"schemaVersion": "epiphany.repo_work_closure_model_gate_smoke.v0",
|
||||
"status": "ok",
|
||||
"smokeDir": smoke_dir,
|
||||
"repo": repo,
|
||||
"branch": git_output(["branch", "--show-current"], &repo)?,
|
||||
"passItem": good.item,
|
||||
"passCloseStatus": good.close["status"],
|
||||
"passModelStatus": good.close["closureReview"]["modelingReview"]["closureReview"]["status"],
|
||||
"passModelGateEnforced": good.close["closureReview"]["modelingReview"]["closureReview"]["gateEnforced"],
|
||||
"blockItem": bad.item,
|
||||
"blockCloseStatus": bad.close["status"],
|
||||
"blockSoulVerdict": bad.close["soul"]["verdict"],
|
||||
"blockModelingRequestId": bad.close["modeling"]["requestId"],
|
||||
"blockModelStatus": bad.close["closureReview"]["modelingReview"]["closureReview"]["status"],
|
||||
"blockFamilyAssertionsStatus": bad.close["closureReview"]["familyAssertions"]["status"],
|
||||
"blockPathScopeMatched": bad.close["closureReview"]["sourceGrounding"]["pathScopeMatched"],
|
||||
"privateStateExposed": false,
|
||||
});
|
||||
write_json(&smoke_dir.join("summary.json"), &summary)?;
|
||||
Ok(summary)
|
||||
}
|
||||
|
||||
struct ItemProof {
|
||||
item: String,
|
||||
close: Value,
|
||||
}
|
||||
|
||||
fn drive_item(
|
||||
manifest: &Path,
|
||||
root: &Path,
|
||||
repo: &Path,
|
||||
item: &str,
|
||||
summary: &str,
|
||||
model_verdict: &str,
|
||||
model_finding: &str,
|
||||
) -> Result<ItemProof> {
|
||||
cargo_json(
|
||||
manifest,
|
||||
"epiphany-work",
|
||||
&[
|
||||
"accept",
|
||||
"--workspace",
|
||||
path_str(repo)?,
|
||||
"--from",
|
||||
"persona",
|
||||
"--item",
|
||||
item,
|
||||
"--summary",
|
||||
summary,
|
||||
],
|
||||
root,
|
||||
)?;
|
||||
cargo_json(
|
||||
manifest,
|
||||
"epiphany-work",
|
||||
&[
|
||||
"derive-plan",
|
||||
"--workspace",
|
||||
path_str(repo)?,
|
||||
"--item",
|
||||
item,
|
||||
"--action-family",
|
||||
"repo-status-section",
|
||||
"--model-ref",
|
||||
"closure-model-gate-smoke-imagination-v1",
|
||||
"--model-authored",
|
||||
],
|
||||
root,
|
||||
)?;
|
||||
for _ in 0..3 {
|
||||
cargo_json(
|
||||
manifest,
|
||||
"epiphany-work",
|
||||
&[
|
||||
"tick",
|
||||
"--workspace",
|
||||
path_str(repo)?,
|
||||
"--epiphany-root",
|
||||
path_str(root)?,
|
||||
"--item",
|
||||
item,
|
||||
"--cooldown-seconds",
|
||||
"0",
|
||||
],
|
||||
root,
|
||||
)?;
|
||||
}
|
||||
let close = cargo_json(
|
||||
manifest,
|
||||
"epiphany-work",
|
||||
&[
|
||||
"close",
|
||||
"--workspace",
|
||||
path_str(repo)?,
|
||||
"--item",
|
||||
item,
|
||||
"--closure-model-ref",
|
||||
"closure-model-gate-smoke-soul-v1",
|
||||
"--model-authored",
|
||||
"--closure-model-verdict",
|
||||
model_verdict,
|
||||
"--closure-model-finding",
|
||||
model_finding,
|
||||
],
|
||||
root,
|
||||
)?;
|
||||
Ok(ItemProof {
|
||||
item: item.to_string(),
|
||||
close,
|
||||
})
|
||||
}
|
||||
|
||||
fn cargo_json(manifest: &Path, bin: &str, args: &[&str], cwd: &Path) -> Result<Value> {
|
||||
let output = Command::new("cargo")
|
||||
.arg("run")
|
||||
.arg("--quiet")
|
||||
.arg("--manifest-path")
|
||||
.arg(manifest)
|
||||
.arg("--bin")
|
||||
.arg(bin)
|
||||
.arg("--")
|
||||
.args(args)
|
||||
.current_dir(cwd)
|
||||
.output()
|
||||
.with_context(|| format!("failed to run cargo bin {bin}"))?;
|
||||
if !output.status.success() {
|
||||
return Err(anyhow!(
|
||||
"{bin} failed with status {:?}\nstdout:\n{}\nstderr:\n{}",
|
||||
output.status.code(),
|
||||
String::from_utf8_lossy(&output.stdout),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
));
|
||||
}
|
||||
serde_json::from_slice(&output.stdout).with_context(|| {
|
||||
format!(
|
||||
"{bin} did not emit JSON on stdout:\n{}",
|
||||
String::from_utf8_lossy(&output.stdout)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn git<const N: usize>(args: [&str; N], cwd: &Path) -> Result<()> {
|
||||
let output = Command::new("git")
|
||||
.args(args)
|
||||
.current_dir(cwd)
|
||||
.output()
|
||||
.with_context(|| format!("failed to run git in {}", cwd.display()))?;
|
||||
if output.status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!(
|
||||
"git failed in {} with status {:?}\nstdout:\n{}\nstderr:\n{}",
|
||||
cwd.display(),
|
||||
output.status.code(),
|
||||
String::from_utf8_lossy(&output.stdout),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn git_output<const N: usize>(args: [&str; N], cwd: &Path) -> Result<String> {
|
||||
let output = Command::new("git")
|
||||
.args(args)
|
||||
.current_dir(cwd)
|
||||
.output()
|
||||
.with_context(|| format!("failed to run git in {}", cwd.display()))?;
|
||||
if output.status.success() {
|
||||
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
|
||||
} else {
|
||||
Err(anyhow!(
|
||||
"git failed in {} with status {:?}\nstdout:\n{}\nstderr:\n{}",
|
||||
cwd.display(),
|
||||
output.status.code(),
|
||||
String::from_utf8_lossy(&output.stdout),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn write_json(path: &Path, value: &Value) -> Result<()> {
|
||||
if let Some(parent) = path.parent() {
|
||||
fs::create_dir_all(parent)
|
||||
.with_context(|| format!("failed to create {}", parent.display()))?;
|
||||
}
|
||||
fs::write(path, serde_json::to_vec_pretty(value)?)
|
||||
.with_context(|| format!("failed to write {}", path.display()))
|
||||
}
|
||||
|
||||
fn require_eq(value: &Value, path: &[&str], expected: &str) -> Result<()> {
|
||||
let actual = path
|
||||
.iter()
|
||||
.try_fold(value, |current, key| current.get(*key))
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or("<missing>");
|
||||
if actual == expected {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!(
|
||||
"expected {} to be {expected:?}, got {actual:?}",
|
||||
path.join(".")
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn require_bool(value: &Value, path: &[&str], expected: bool) -> Result<()> {
|
||||
let actual = path
|
||||
.iter()
|
||||
.try_fold(value, |current, key| current.get(*key))
|
||||
.and_then(Value::as_bool);
|
||||
if actual == Some(expected) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!(
|
||||
"expected {} to be {expected}, got {:?}",
|
||||
path.join("."),
|
||||
actual
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn take_path(
|
||||
args: &mut std::iter::Peekable<impl Iterator<Item = String>>,
|
||||
flag: &str,
|
||||
) -> Result<PathBuf> {
|
||||
args.next()
|
||||
.map(PathBuf::from)
|
||||
.with_context(|| format!("missing value for {flag}"))
|
||||
}
|
||||
|
||||
fn path_str(path: &Path) -> Result<&str> {
|
||||
path.to_str()
|
||||
.ok_or_else(|| anyhow!("path is not valid UTF-8: {}", path.display()))
|
||||
}
|
||||
|
|
@ -17,6 +17,8 @@ use epiphany_core::EpiphanyCultMeshRepoWorkPublicProofEntry;
|
|||
use epiphany_core::EpiphanyCultMeshRepoWorkReadinessEntry;
|
||||
use epiphany_core::EpiphanyCultMeshRepoWorkReadinessReviewEntry;
|
||||
use epiphany_core::EpiphanyCultMeshWeksaLoweringReceiptEntry;
|
||||
use epiphany_core::EpiphanyRepoWorkModelingLaunchDocument;
|
||||
use epiphany_core::EpiphanyWorkerLaunchDocument;
|
||||
use epiphany_core::HANDS_ACTION_INTENT_SCHEMA_VERSION;
|
||||
use epiphany_core::HANDS_COMMAND_RECEIPT_TYPE;
|
||||
use epiphany_core::HANDS_COMMIT_RECEIPT_TYPE;
|
||||
|
|
@ -29,10 +31,12 @@ use epiphany_core::MindGatewayReview;
|
|||
use epiphany_core::PersonaMemoryCacheConfig;
|
||||
use epiphany_core::REPO_WORK_MAP_ENTRY_SCHEMA_VERSION;
|
||||
use epiphany_core::REPO_WORK_MODELING_FINDING_SCHEMA_VERSION;
|
||||
use epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID;
|
||||
use epiphany_core::REPO_WORK_MODELING_REQUEST_SCHEMA_VERSION;
|
||||
use epiphany_core::RepoWorkMapEntry;
|
||||
use epiphany_core::RepoWorkModelingFinding;
|
||||
use epiphany_core::RepoWorkModelingRequest;
|
||||
use epiphany_core::RuntimeSpineHeartbeatJobOptions;
|
||||
use epiphany_core::RuntimeSpineInitOptions;
|
||||
use epiphany_core::SOUL_VERDICT_RECEIPT_SCHEMA_VERSION;
|
||||
use epiphany_core::SUBSTRATE_GATE_REPO_ACCESS_GRANT_RECEIPT_SCHEMA_VERSION;
|
||||
|
|
@ -43,6 +47,7 @@ use epiphany_core::WeksaSpeakerContext;
|
|||
use epiphany_core::build_weksa_interlingua_packet;
|
||||
use epiphany_core::build_weksa_target_lowering_request;
|
||||
use epiphany_core::commit_repo_work_map_admission;
|
||||
use epiphany_core::default_launch_organ_contract;
|
||||
use epiphany_core::hands_action_review_for_intent;
|
||||
use epiphany_core::hands_command_receipt_for_review;
|
||||
use epiphany_core::hands_commit_receipt_for_review;
|
||||
|
|
@ -61,6 +66,7 @@ use epiphany_core::load_latest_epiphany_cultmesh_idunn_deployment_receipt;
|
|||
use epiphany_core::load_latest_epiphany_cultmesh_repo_work_overview;
|
||||
use epiphany_core::memory_graph_from_agent_memories;
|
||||
use epiphany_core::mind_state_commit_receipt;
|
||||
use epiphany_core::open_runtime_spine_heartbeat_job;
|
||||
use epiphany_core::plan_memory_graph_context_cut;
|
||||
use epiphany_core::put_hands_action_intent;
|
||||
use epiphany_core::put_hands_action_review;
|
||||
|
|
@ -68,7 +74,6 @@ use epiphany_core::put_hands_command_receipt;
|
|||
use epiphany_core::put_hands_commit_receipt;
|
||||
use epiphany_core::put_hands_patch_receipt;
|
||||
use epiphany_core::put_hands_pr_receipt;
|
||||
use epiphany_core::put_repo_work_modeling_finding;
|
||||
use epiphany_core::put_repo_work_modeling_request;
|
||||
use epiphany_core::put_soul_verdict_receipt;
|
||||
use epiphany_core::put_substrate_gate_repo_access_grant_receipt;
|
||||
|
|
@ -77,6 +82,7 @@ use epiphany_core::render_persona_memory_recall_with_cache;
|
|||
use epiphany_core::runtime_hands_action_intent;
|
||||
use epiphany_core::runtime_hands_action_review;
|
||||
use epiphany_core::runtime_hands_commit_receipt;
|
||||
use epiphany_core::runtime_job_snapshot;
|
||||
use epiphany_core::runtime_latest_hands_receipt_chain_after;
|
||||
use epiphany_core::runtime_repo_work_map_entry;
|
||||
use epiphany_core::runtime_repo_work_modeling_finding;
|
||||
|
|
@ -98,6 +104,7 @@ use std::fs;
|
|||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::process::Stdio;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let mut args = env::args().skip(1);
|
||||
|
|
@ -11547,7 +11554,7 @@ fn run_closure_pipeline(args: CloseArgs, phase: ClosurePhase) -> Result<Value> {
|
|||
write_json(&closure_receipt_path, &awaiting_receipt)?;
|
||||
return Ok(awaiting_receipt);
|
||||
}
|
||||
let modeling_finding_receipt_id = format!("repo-work-close-{item_slug}-modeling-finding");
|
||||
let modeling_finding_receipt_id = format!("{}-finding", modeling_request.request_id);
|
||||
let mut modeling_finding = RepoWorkModelingFinding {
|
||||
schema_version: REPO_WORK_MODELING_FINDING_SCHEMA_VERSION.to_string(),
|
||||
receipt_id: modeling_finding_receipt_id.clone(),
|
||||
|
|
@ -11576,18 +11583,25 @@ fn run_closure_pipeline(args: CloseArgs, phase: ClosurePhase) -> Result<Value> {
|
|||
if let Some(existing) =
|
||||
runtime_repo_work_modeling_finding(&runtime_store, &modeling_finding_receipt_id)?
|
||||
{
|
||||
modeling_finding.emitted_at = existing.emitted_at.clone();
|
||||
if modeling_finding != existing {
|
||||
if existing.item != modeling_finding.item
|
||||
|| existing.model_ref != modeling_finding.model_ref
|
||||
|| existing.soul_verdict_receipt_id != modeling_finding.soul_verdict_receipt_id
|
||||
|| existing.verdict != modeling_finding.verdict
|
||||
|| existing.finding != modeling_finding.finding
|
||||
|| existing.summary != modeling_finding.summary
|
||||
|| existing.changed_paths != modeling_finding.changed_paths
|
||||
|| existing.commit_sha != modeling_finding.commit_sha
|
||||
|| existing.request_id != modeling_finding.request_id
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"closure retry conflicts with immutable Modeling finding"
|
||||
));
|
||||
}
|
||||
modeling_finding = existing;
|
||||
} else {
|
||||
put_repo_work_modeling_finding(&runtime_store, &modeling_finding)?;
|
||||
modeling_finding =
|
||||
runtime_repo_work_modeling_finding(&runtime_store, &modeling_finding_receipt_id)?
|
||||
.ok_or_else(|| anyhow!("persisted Modeling finding could not be reread"))?;
|
||||
return Err(anyhow!(
|
||||
"closure cannot author a Modeling finding; route the typed request through the Modeling runtime first"
|
||||
));
|
||||
}
|
||||
if modeling_finding.soul_verdict_receipt_id != soul_verdict.receipt_id
|
||||
|| modeling_finding.commit_sha != commit_sha
|
||||
|
|
@ -14157,6 +14171,136 @@ fn run_queue(args: QueueArgs) -> Result<Value> {
|
|||
}))
|
||||
}
|
||||
|
||||
fn repo_work_modeling_job_id(item_slug: &str) -> String {
|
||||
format!("repo-work-modeling-{item_slug}")
|
||||
}
|
||||
|
||||
fn resolve_repo_work_model_runtime(epiphany_root: &Path) -> Result<PathBuf> {
|
||||
if let Some(configured) = env::var_os("EPIPHANY_MODEL_RUNTIME_BIN") {
|
||||
let configured = PathBuf::from(configured);
|
||||
return configured.canonicalize().with_context(|| {
|
||||
format!(
|
||||
"failed to resolve EPIPHANY_MODEL_RUNTIME_BIN {}",
|
||||
configured.display()
|
||||
)
|
||||
});
|
||||
}
|
||||
let exe_name = if cfg!(windows) {
|
||||
"epiphany-openai-runtime.exe"
|
||||
} else {
|
||||
"epiphany-openai-runtime"
|
||||
};
|
||||
let mut candidates = Vec::new();
|
||||
if let Some(target) = env::var_os("CARGO_TARGET_DIR") {
|
||||
candidates.push(PathBuf::from(target).join("debug").join(exe_name));
|
||||
}
|
||||
candidates.push(
|
||||
epiphany_root
|
||||
.join("epiphany-openai-runtime")
|
||||
.join("target")
|
||||
.join("debug")
|
||||
.join(exe_name),
|
||||
);
|
||||
candidates.push(epiphany_root.join("target").join("debug").join(exe_name));
|
||||
candidates
|
||||
.into_iter()
|
||||
.find(|candidate| candidate.is_file())
|
||||
.ok_or_else(|| anyhow!("epiphany-openai-runtime binary is not built"))
|
||||
}
|
||||
|
||||
fn launch_repo_work_modeling_worker(
|
||||
epiphany_root: &Path,
|
||||
workspace: &Path,
|
||||
artifact_dir: &Path,
|
||||
runtime_store: &Path,
|
||||
request: &RepoWorkModelingRequest,
|
||||
item_slug: &str,
|
||||
) -> Result<Value> {
|
||||
let job_id = repo_work_modeling_job_id(item_slug);
|
||||
let verified_diff = git_output(
|
||||
workspace,
|
||||
&[
|
||||
"show",
|
||||
"--format=fuller",
|
||||
"--stat",
|
||||
"--patch",
|
||||
&request.commit_sha,
|
||||
],
|
||||
)?;
|
||||
let verified_diff = verified_diff.chars().take(24_000).collect::<String>();
|
||||
let document = EpiphanyWorkerLaunchDocument::RepoWorkModeling(
|
||||
EpiphanyRepoWorkModelingLaunchDocument {
|
||||
thread_id: format!("repo-work-{}", request.item),
|
||||
request_id: request.request_id.clone(),
|
||||
item: request.item.clone(),
|
||||
soul_verdict_receipt_id: request.soul_verdict_receipt_id.clone(),
|
||||
commit_sha: request.commit_sha.clone(),
|
||||
changed_paths: request.changed_paths.clone(),
|
||||
instruction: request.instruction.clone(),
|
||||
dynamic_prompt_context: Some(format!(
|
||||
"The request is immutable and already Soul-verified. Interpret commit {} across [{}]. Return a bounded finding only; Mind owns admission and Bifrost owns publication.\n\n<soul_verified_commit_diff>\n{}\n</soul_verified_commit_diff>",
|
||||
request.commit_sha,
|
||||
request.changed_paths.join(", "),
|
||||
verified_diff
|
||||
)),
|
||||
},
|
||||
);
|
||||
let created_at = Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
|
||||
open_runtime_spine_heartbeat_job(
|
||||
runtime_store,
|
||||
RuntimeSpineHeartbeatJobOptions {
|
||||
runtime_id: "repo-work-local".to_string(),
|
||||
display_name: "Epiphany Repo Work".to_string(),
|
||||
session_id: format!("repo-work-session-{item_slug}"),
|
||||
objective: format!("Model Soul-verified repo work item {}.", request.item),
|
||||
coordinator_note: "Self routes the typed request; Modeling owns the result."
|
||||
.to_string(),
|
||||
job_id: job_id.clone(),
|
||||
role: "modeling".to_string(),
|
||||
binding_id: "repo-work-modeling-worker".to_string(),
|
||||
authority_scope: "epiphany.role.modeling.repo-work".to_string(),
|
||||
instruction: "Act as Modeling. Interpret only the typed repo-work request and return the required bounded result. Do not claim Mind, Hands, publication, merge, or service authority."
|
||||
.to_string(),
|
||||
launch_document: document,
|
||||
output_contract_id: REPO_WORK_MODELING_OUTPUT_CONTRACT_ID.to_string(),
|
||||
organ_launch_contract: default_launch_organ_contract(
|
||||
"epiphany.role.modeling.repo-work",
|
||||
"repo-work-modeling",
|
||||
REPO_WORK_MODELING_OUTPUT_CONTRACT_ID,
|
||||
),
|
||||
created_at,
|
||||
},
|
||||
)?;
|
||||
let runtime_bin = resolve_repo_work_model_runtime(epiphany_root)?;
|
||||
let stdout_path = artifact_dir.join(format!("{job_id}.stdout.log"));
|
||||
let stderr_path = artifact_dir.join(format!("{job_id}.stderr.log"));
|
||||
let stdout = fs::File::create(&stdout_path)?;
|
||||
let stderr = fs::File::create(&stderr_path)?;
|
||||
let child = Command::new(&runtime_bin)
|
||||
.arg("run-worker")
|
||||
.arg("--store")
|
||||
.arg(runtime_store)
|
||||
.arg("--job-id")
|
||||
.arg(&job_id)
|
||||
.arg("--cwd")
|
||||
.arg(workspace)
|
||||
.arg("--max-runtime-seconds")
|
||||
.arg("300")
|
||||
.stdout(Stdio::from(stdout))
|
||||
.stderr(Stdio::from(stderr))
|
||||
.spawn()
|
||||
.with_context(|| format!("failed to launch {}", runtime_bin.display()))?;
|
||||
Ok(json!({
|
||||
"jobId": job_id,
|
||||
"processId": child.id(),
|
||||
"runtimeBin": runtime_bin,
|
||||
"stdoutArtifact": stdout_path,
|
||||
"stderrArtifact": stderr_path,
|
||||
"requestId": request.request_id,
|
||||
"privateStateExposed": false
|
||||
}))
|
||||
}
|
||||
|
||||
fn run_tick(args: TickArgs) -> Result<Value> {
|
||||
let workspace = args
|
||||
.workspace
|
||||
|
|
@ -14511,12 +14655,117 @@ fn run_tick(args: TickArgs) -> Result<Value> {
|
|||
"Route Bifrost/GitHub publication through epiphany-work publish --closure-receipt."
|
||||
.to_string();
|
||||
} else if close_receipt_path.exists() {
|
||||
action = "await-modeling".to_string();
|
||||
status = "blocked".to_string();
|
||||
reason = "Soul passed and Self routed a typed Modeling request; no matching Modeling finding is admitted"
|
||||
.to_string();
|
||||
next_safe_move = "Route the persisted Modeling request to the Modeling daemon, then resume epiphany-work close with its typed result."
|
||||
.to_string();
|
||||
let partial_close = read_json(&close_receipt_path)?;
|
||||
let runtime_store = args
|
||||
.runtime_store
|
||||
.clone()
|
||||
.or_else(|| path_from_json(&partial_close, &["runtimeStore"]))
|
||||
.ok_or_else(|| anyhow!("awaiting-modeling closure has no runtime store"))?;
|
||||
let request_id = string_from_json(&partial_close, &["modeling", "requestId"])
|
||||
.ok_or_else(|| anyhow!("awaiting-modeling closure has no typed request id"))?;
|
||||
let request = runtime_repo_work_modeling_request(&runtime_store, &request_id)?
|
||||
.ok_or_else(|| anyhow!("typed Modeling request {request_id:?} is missing"))?;
|
||||
let finding_id = format!("{}-finding", request.request_id);
|
||||
if let Some(finding) = runtime_repo_work_modeling_finding(&runtime_store, &finding_id)? {
|
||||
if finding.verdict.trim().eq_ignore_ascii_case("passed") {
|
||||
action = "admit-modeling".to_string();
|
||||
if args.dry_run {
|
||||
status = "would-advance".to_string();
|
||||
reason = "a passing typed Modeling finding is ready for immutable Mind/map admission"
|
||||
.to_string();
|
||||
next_safe_move =
|
||||
"Rerun without --dry-run to resume closure through Mind admission."
|
||||
.to_string();
|
||||
} else {
|
||||
advanced_result = run_close(CloseArgs {
|
||||
workspace: workspace.clone(),
|
||||
item: Some(item.clone()),
|
||||
execute_receipt: Some(execute_receipt_path.clone()),
|
||||
runtime_store: Some(runtime_store.clone()),
|
||||
artifact_dir: Some(artifact_dir.clone()),
|
||||
verification_command: None,
|
||||
verification_summary: None,
|
||||
modeling_summary: Some(finding.summary.clone()),
|
||||
closure_model_ref: Some(finding.model_ref.clone()),
|
||||
closure_model_verdict: Some(finding.verdict.clone()),
|
||||
closure_model_finding: Some(finding.finding.clone()),
|
||||
require_source_grounding: false,
|
||||
model_authored: true,
|
||||
state_revision: 0,
|
||||
})?;
|
||||
status = advanced_result["status"]
|
||||
.as_str()
|
||||
.unwrap_or("closed")
|
||||
.to_string();
|
||||
reason = "Mind admitted the matching model-authored finding and repo-work map"
|
||||
.to_string();
|
||||
next_safe_move = "Stop before Bifrost publication authority.".to_string();
|
||||
}
|
||||
} else {
|
||||
action = "await-modeling-revision".to_string();
|
||||
status = "blocked".to_string();
|
||||
reason = format!(
|
||||
"Modeling returned verdict {}; immutable request requires reviewed revision before another attempt",
|
||||
finding.verdict
|
||||
);
|
||||
next_safe_move = "Review the Modeling finding and create a new bounded work request; do not overwrite immutable evidence."
|
||||
.to_string();
|
||||
}
|
||||
} else {
|
||||
let job_id = repo_work_modeling_job_id(&item_slug);
|
||||
match runtime_job_snapshot(&runtime_store, &job_id)? {
|
||||
Some(snapshot)
|
||||
if matches!(
|
||||
snapshot.job.status,
|
||||
epiphany_core::EpiphanyRuntimeJobStatus::Queued
|
||||
| epiphany_core::EpiphanyRuntimeJobStatus::Running
|
||||
) =>
|
||||
{
|
||||
action = "await-modeling".to_string();
|
||||
status = "waiting".to_string();
|
||||
reason = format!("Modeling worker job {job_id} is still active");
|
||||
next_safe_move =
|
||||
"Wait for the Modeling runtime result; do not launch a duplicate job."
|
||||
.to_string();
|
||||
}
|
||||
Some(snapshot) => {
|
||||
action = "await-modeling".to_string();
|
||||
status = "blocked".to_string();
|
||||
reason = format!(
|
||||
"Modeling worker job {job_id} ended as {:?} without a typed finding",
|
||||
snapshot.job.status
|
||||
);
|
||||
next_safe_move = "Inspect the sealed worker stdout/stderr and runtime result before a reviewed retry."
|
||||
.to_string();
|
||||
}
|
||||
None if args.dry_run => {
|
||||
action = "launch-modeling".to_string();
|
||||
status = "would-advance".to_string();
|
||||
reason = "typed Modeling request is ready for the existing worker runtime"
|
||||
.to_string();
|
||||
next_safe_move =
|
||||
"Rerun without --dry-run to launch the repo-work Modeling worker."
|
||||
.to_string();
|
||||
}
|
||||
None => {
|
||||
action = "launch-modeling".to_string();
|
||||
advanced_result = launch_repo_work_modeling_worker(
|
||||
&epiphany_root,
|
||||
&workspace,
|
||||
&artifact_dir,
|
||||
&runtime_store,
|
||||
&request,
|
||||
&item_slug,
|
||||
)?;
|
||||
status = "modeling-launched".to_string();
|
||||
reason =
|
||||
"Self routed the typed request to the existing model runtime".to_string();
|
||||
next_safe_move =
|
||||
"Let a later scheduler pulse consume the typed Modeling finding."
|
||||
.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if execute_receipt_path.exists() {
|
||||
action = "soul-verify".to_string();
|
||||
if args.dry_run {
|
||||
|
|
@ -16309,6 +16558,7 @@ fn default_if_empty(values: Vec<String>, defaults: Vec<String>) -> Vec<String> {
|
|||
#[cfg(test)]
|
||||
mod authority_tests {
|
||||
use super::*;
|
||||
use epiphany_core::put_repo_work_modeling_finding;
|
||||
|
||||
#[test]
|
||||
fn modeling_finding_is_mandatory_for_closure_admission() -> Result<()> {
|
||||
|
|
@ -16337,16 +16587,23 @@ mod authority_tests {
|
|||
let source = include_str!("epiphany-work.rs");
|
||||
let tick_start = source.find("fn run_tick").expect("run_tick");
|
||||
let tick_end = source[tick_start..]
|
||||
.find("fn run_queue")
|
||||
.find("#[cfg(test)]")
|
||||
.map(|offset| tick_start + offset)
|
||||
.unwrap_or(source.len());
|
||||
let tick = &source[tick_start..tick_end];
|
||||
assert!(!tick.contains("run_close(CloseArgs"));
|
||||
assert!(tick.contains("run_verify(CloseArgs"));
|
||||
assert!(tick.contains("run_close(CloseArgs"));
|
||||
assert!(tick.contains("await-modeling"));
|
||||
assert!(tick.contains("typed Modeling request"));
|
||||
assert!(!tick.contains("put_repo_work_modeling_finding"));
|
||||
assert!(!tick.contains("RepoWorkModelingFinding {"));
|
||||
assert!(!tick.contains("commit_repo_work_map_admission"));
|
||||
assert!(tick.find("runtime_repo_work_modeling_finding") < tick.find("run_close(CloseArgs"));
|
||||
let production = source
|
||||
.split("#[cfg(test)]")
|
||||
.next()
|
||||
.expect("production source before authority tests");
|
||||
assert!(!production.contains("put_repo_work_modeling_finding("));
|
||||
assert!(!source.contains(&["RepoWork", "MapStore"].concat()));
|
||||
assert!(!source.contains(&["repo-work-map", ".msgpack"].concat()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -921,6 +921,7 @@ pub use surfaces::EpiphanyReorientPressureLevel;
|
|||
pub use surfaces::EpiphanyReorientReason;
|
||||
pub use surfaces::EpiphanyReorientStateStatus;
|
||||
pub use surfaces::EpiphanyReorientWorkerLaunchDocument;
|
||||
pub use surfaces::EpiphanyRepoWorkModelingLaunchDocument;
|
||||
pub use surfaces::EpiphanyRetrievalFreshness;
|
||||
pub use surfaces::EpiphanyRetrievalFreshnessStatus;
|
||||
pub use surfaces::EpiphanyRoleAcceptanceFinding;
|
||||
|
|
@ -953,6 +954,7 @@ pub use surfaces::EpiphanyTokenUsageSnapshot;
|
|||
pub use surfaces::EpiphanyViewLens;
|
||||
pub use surfaces::EpiphanyWorkerLaunchDocument;
|
||||
pub use surfaces::REORIENT_WORKER_OUTPUT_CONTRACT_ID;
|
||||
pub use surfaces::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID;
|
||||
pub use surfaces::ROLE_WORKER_OUTPUT_CONTRACT_ID;
|
||||
pub use surfaces::build_reorient_acceptance_bundle;
|
||||
pub use surfaces::build_reorient_job_launch_request;
|
||||
|
|
|
|||
|
|
@ -141,8 +141,10 @@ pub use view::epiphany_view_needs_reorientation_inputs;
|
|||
pub use view::epiphany_view_needs_runtime_store;
|
||||
pub use worker_launch::EpiphanyReorientLaunchRequestInput;
|
||||
pub use worker_launch::EpiphanyReorientWorkerLaunchDocument;
|
||||
pub use worker_launch::EpiphanyRepoWorkModelingLaunchDocument;
|
||||
pub use worker_launch::EpiphanyRoleWorkerLaunchDocument;
|
||||
pub use worker_launch::EpiphanyWorkerLaunchDocument;
|
||||
pub use worker_launch::REORIENT_WORKER_OUTPUT_CONTRACT_ID;
|
||||
pub use worker_launch::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID;
|
||||
pub use worker_launch::ROLE_WORKER_OUTPUT_CONTRACT_ID;
|
||||
pub use worker_launch::build_reorient_job_launch_request;
|
||||
|
|
|
|||
|
|
@ -26,12 +26,15 @@ use crate::EpiphanyReorientReason;
|
|||
|
||||
pub const ROLE_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.role_result.v0";
|
||||
pub const REORIENT_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.reorient_result.v0";
|
||||
pub const REPO_WORK_MODELING_OUTPUT_CONTRACT_ID: &str =
|
||||
"epiphany.worker.repo_work_modeling_result.v0";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", tag = "documentKind")]
|
||||
pub enum EpiphanyWorkerLaunchDocument {
|
||||
Role(EpiphanyRoleWorkerLaunchDocument),
|
||||
Reorient(EpiphanyReorientWorkerLaunchDocument),
|
||||
RepoWorkModeling(EpiphanyRepoWorkModelingLaunchDocument),
|
||||
}
|
||||
|
||||
impl EpiphanyWorkerLaunchDocument {
|
||||
|
|
@ -39,6 +42,7 @@ impl EpiphanyWorkerLaunchDocument {
|
|||
match self {
|
||||
Self::Role(_) => ROLE_WORKER_OUTPUT_CONTRACT_ID,
|
||||
Self::Reorient(_) => REORIENT_WORKER_OUTPUT_CONTRACT_ID,
|
||||
Self::RepoWorkModeling(_) => REPO_WORK_MODELING_OUTPUT_CONTRACT_ID,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +50,7 @@ impl EpiphanyWorkerLaunchDocument {
|
|||
match self {
|
||||
Self::Role(_) => "role",
|
||||
Self::Reorient(_) => "reorient",
|
||||
Self::RepoWorkModeling(_) => "repo-work-modeling",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +58,7 @@ impl EpiphanyWorkerLaunchDocument {
|
|||
match self {
|
||||
Self::Role(document) => &document.thread_id,
|
||||
Self::Reorient(document) => &document.thread_id,
|
||||
Self::RepoWorkModeling(document) => &document.thread_id,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60,12 +66,28 @@ impl EpiphanyWorkerLaunchDocument {
|
|||
match self {
|
||||
Self::Role(document) => document.dynamic_prompt_context.as_deref(),
|
||||
Self::Reorient(document) => document.dynamic_prompt_context.as_deref(),
|
||||
Self::RepoWorkModeling(document) => document.dynamic_prompt_context.as_deref(),
|
||||
}
|
||||
.map(str::trim)
|
||||
.filter(|context| !context.is_empty())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EpiphanyRepoWorkModelingLaunchDocument {
|
||||
pub thread_id: String,
|
||||
pub request_id: String,
|
||||
pub item: String,
|
||||
pub soul_verdict_receipt_id: String,
|
||||
pub commit_sha: String,
|
||||
#[serde(default)]
|
||||
pub changed_paths: Vec<String>,
|
||||
pub instruction: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub dynamic_prompt_context: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EpiphanyRoleWorkerLaunchDocument {
|
||||
|
|
|
|||
|
|
@ -659,6 +659,34 @@ pub fn complete_worker_job_from_assistant_text(
|
|||
);
|
||||
put_runtime_reorient_worker_result(store_path.as_ref(), &typed_result)?;
|
||||
}
|
||||
(
|
||||
EpiphanyWorkerLaunchDocument::RepoWorkModeling(document),
|
||||
WorkerResultIngress::RepoWorkModeling(parsed),
|
||||
) => {
|
||||
let typed_result = epiphany_core::RepoWorkModelingFinding {
|
||||
schema_version: epiphany_core::REPO_WORK_MODELING_FINDING_SCHEMA_VERSION
|
||||
.to_string(),
|
||||
receipt_id: format!("{}-finding", document.request_id),
|
||||
item: document.item.clone(),
|
||||
model_ref: openai_request_id.to_string(),
|
||||
soul_verdict_receipt_id: document.soul_verdict_receipt_id.clone(),
|
||||
verdict: clean_optional_string(parsed.verdict.as_deref())
|
||||
.unwrap_or_else(|| "failed".to_string()),
|
||||
finding: clean_optional_string(parsed.finding.as_deref()).unwrap_or_else(|| {
|
||||
"Modeling returned no bounded repo-work finding.".to_string()
|
||||
}),
|
||||
summary: clean_optional_string(parsed.summary.as_deref()).unwrap_or_else(|| {
|
||||
"Modeling returned no repo-work summary.".to_string()
|
||||
}),
|
||||
changed_paths: document.changed_paths.clone(),
|
||||
commit_sha: document.commit_sha.clone(),
|
||||
emitted_at: now(),
|
||||
private_state_exposed: false,
|
||||
contract: "Model-authored interpretation of one typed Self request over a Soul-verified repo consequence.".to_string(),
|
||||
request_id: document.request_id.clone(),
|
||||
};
|
||||
epiphany_core::put_repo_work_modeling_finding(store_path.as_ref(), &typed_result)?;
|
||||
}
|
||||
_ => {
|
||||
return Err(anyhow!(
|
||||
"worker launch document and parsed result kind diverged"
|
||||
|
|
@ -1303,6 +1331,19 @@ fn worker_output_schema_json(document: &EpiphanyWorkerLaunchDocument) -> Result<
|
|||
EpiphanyWorkerLaunchDocument::Reorient(_) => {
|
||||
epiphany_core::epiphany_reorient_launch_output_schema()
|
||||
}
|
||||
EpiphanyWorkerLaunchDocument::RepoWorkModeling(_) => serde_json::json!({
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["verdict", "finding", "summary", "nextSafeMove", "evidenceIds"],
|
||||
"properties": {
|
||||
"verdict": { "type": "string", "enum": ["passed", "failed", "needs-work", "blocked"] },
|
||||
"finding": { "type": "string", "minLength": 1 },
|
||||
"summary": { "type": "string", "minLength": 1 },
|
||||
"nextSafeMove": { "type": "string", "minLength": 1 },
|
||||
"evidenceIds": { "type": "array", "items": { "type": "string" } },
|
||||
"artifactRefs": { "type": "array", "items": { "type": "string" } }
|
||||
}
|
||||
}),
|
||||
};
|
||||
serde_json::to_string_pretty(&schema).context("failed to render worker output schema")
|
||||
}
|
||||
|
|
@ -1329,6 +1370,9 @@ fn worker_output_contract_text(document: &EpiphanyWorkerLaunchDocument) -> &'sta
|
|||
EpiphanyWorkerLaunchDocument::Reorient(_) => {
|
||||
"Required reorient-result fields: mode, summary, nextSafeMove. Include checkpointStillValid, filesInspected, frontierNodeIds, evidenceIds, openQuestions, and continuityRisks when present."
|
||||
}
|
||||
EpiphanyWorkerLaunchDocument::RepoWorkModeling(_) => {
|
||||
"Required repo-work Modeling fields: verdict, finding, summary, nextSafeMove, evidenceIds. Interpret only the Soul-verified consequence named by the request. Do not claim Mind admission, publication, merge, or further Hands authority."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1367,10 +1411,22 @@ struct ReorientWorkerResultIngress {
|
|||
continuity_risks: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, serde::Deserialize)]
|
||||
#[serde(rename_all = "camelCase", default)]
|
||||
struct RepoWorkModelingResultIngress {
|
||||
verdict: Option<String>,
|
||||
finding: Option<String>,
|
||||
summary: Option<String>,
|
||||
next_safe_move: Option<String>,
|
||||
evidence_ids: Vec<String>,
|
||||
artifact_refs: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum WorkerResultIngress {
|
||||
Role(RoleWorkerResultIngress),
|
||||
Reorient(ReorientWorkerResultIngress),
|
||||
RepoWorkModeling(RepoWorkModelingResultIngress),
|
||||
}
|
||||
|
||||
impl WorkerResultIngress {
|
||||
|
|
@ -1378,6 +1434,9 @@ impl WorkerResultIngress {
|
|||
match self {
|
||||
WorkerResultIngress::Role(result) => clean_optional_string(result.verdict.as_deref()),
|
||||
WorkerResultIngress::Reorient(result) => clean_optional_string(result.mode.as_deref()),
|
||||
WorkerResultIngress::RepoWorkModeling(result) => {
|
||||
clean_optional_string(result.verdict.as_deref())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1387,6 +1446,9 @@ impl WorkerResultIngress {
|
|||
WorkerResultIngress::Reorient(result) => {
|
||||
clean_optional_string(result.summary.as_deref())
|
||||
}
|
||||
WorkerResultIngress::RepoWorkModeling(result) => {
|
||||
clean_optional_string(result.summary.as_deref())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1398,6 +1460,9 @@ impl WorkerResultIngress {
|
|||
WorkerResultIngress::Reorient(result) => {
|
||||
clean_optional_string(result.next_safe_move.as_deref())
|
||||
}
|
||||
WorkerResultIngress::RepoWorkModeling(result) => {
|
||||
clean_optional_string(result.next_safe_move.as_deref())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1405,6 +1470,7 @@ impl WorkerResultIngress {
|
|||
match self {
|
||||
WorkerResultIngress::Role(result) => clean_string_vec(&result.evidence_ids),
|
||||
WorkerResultIngress::Reorient(result) => clean_string_vec(&result.evidence_ids),
|
||||
WorkerResultIngress::RepoWorkModeling(result) => clean_string_vec(&result.evidence_ids),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1412,6 +1478,9 @@ impl WorkerResultIngress {
|
|||
match self {
|
||||
WorkerResultIngress::Role(result) => clean_string_vec(&result.artifact_refs),
|
||||
WorkerResultIngress::Reorient(result) => clean_string_vec(&result.artifact_refs),
|
||||
WorkerResultIngress::RepoWorkModeling(result) => {
|
||||
clean_string_vec(&result.artifact_refs)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1429,6 +1498,10 @@ fn parse_worker_result_ingress(
|
|||
parse_assistant_json::<ReorientWorkerResultIngress>(assistant_text)
|
||||
.map(WorkerResultIngress::Reorient)
|
||||
}
|
||||
EpiphanyWorkerLaunchDocument::RepoWorkModeling(_) => {
|
||||
parse_assistant_json::<RepoWorkModelingResultIngress>(assistant_text)
|
||||
.map(WorkerResultIngress::RepoWorkModeling)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1923,6 +1996,123 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repo_work_modeling_worker_emits_the_typed_finding() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
let store = temp.path().join("runtime.msgpack");
|
||||
initialize_runtime_spine(
|
||||
&store,
|
||||
RuntimeSpineInitOptions {
|
||||
runtime_id: "repo-work-test".to_string(),
|
||||
display_name: "Repo Work Test".to_string(),
|
||||
created_at: now(),
|
||||
},
|
||||
)?;
|
||||
epiphany_core::put_soul_verdict_receipt(
|
||||
&store,
|
||||
&epiphany_core::SoulVerdictReceipt {
|
||||
schema_version: epiphany_core::SOUL_VERDICT_RECEIPT_SCHEMA_VERSION.to_string(),
|
||||
receipt_id: "soul-repo-1".to_string(),
|
||||
source_result_id: "hands-result-1".to_string(),
|
||||
source_job_id: "hands-job-1".to_string(),
|
||||
verdict: "passed".to_string(),
|
||||
summary: "Soul passed.".to_string(),
|
||||
evidence_ids: vec!["commit-abc".to_string()],
|
||||
risks: Vec::new(),
|
||||
emitted_at: now(),
|
||||
contract: "test".to_string(),
|
||||
},
|
||||
)?;
|
||||
let request = epiphany_core::RepoWorkModelingRequest {
|
||||
schema_version: epiphany_core::REPO_WORK_MODELING_REQUEST_SCHEMA_VERSION.to_string(),
|
||||
request_id: "repo-request-1".to_string(),
|
||||
item: "map-repo".to_string(),
|
||||
requester: "self".to_string(),
|
||||
soul_verdict_receipt_id: "soul-repo-1".to_string(),
|
||||
commit_sha: "abc123".to_string(),
|
||||
changed_paths: vec!["README.md".to_string()],
|
||||
instruction: "Model the verified consequence.".to_string(),
|
||||
requested_at: now(),
|
||||
private_state_exposed: false,
|
||||
contract: "test".to_string(),
|
||||
};
|
||||
epiphany_core::put_repo_work_modeling_request(&store, &request)?;
|
||||
open_runtime_spine_heartbeat_job(
|
||||
&store,
|
||||
RuntimeSpineHeartbeatJobOptions {
|
||||
runtime_id: "repo-work-test".to_string(),
|
||||
display_name: "Repo Work Test".to_string(),
|
||||
session_id: "repo-session-1".to_string(),
|
||||
objective: "Map repo work.".to_string(),
|
||||
coordinator_note: "Self routes; Modeling authors.".to_string(),
|
||||
job_id: "repo-modeling-job-1".to_string(),
|
||||
role: "modeling".to_string(),
|
||||
binding_id: "repo-work-modeling-worker".to_string(),
|
||||
authority_scope: "epiphany.role.modeling.repo-work".to_string(),
|
||||
instruction: "Return the required repo-work Modeling result.".to_string(),
|
||||
launch_document: EpiphanyWorkerLaunchDocument::RepoWorkModeling(
|
||||
epiphany_core::EpiphanyRepoWorkModelingLaunchDocument {
|
||||
thread_id: "repo-thread-1".to_string(),
|
||||
request_id: request.request_id.clone(),
|
||||
item: request.item.clone(),
|
||||
soul_verdict_receipt_id: request.soul_verdict_receipt_id.clone(),
|
||||
commit_sha: request.commit_sha.clone(),
|
||||
changed_paths: request.changed_paths.clone(),
|
||||
instruction: request.instruction.clone(),
|
||||
dynamic_prompt_context: None,
|
||||
},
|
||||
),
|
||||
output_contract_id: epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID
|
||||
.to_string(),
|
||||
organ_launch_contract: epiphany_core::default_launch_organ_contract(
|
||||
"epiphany.role.modeling.repo-work",
|
||||
"repo-work-modeling",
|
||||
epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID,
|
||||
),
|
||||
created_at: now(),
|
||||
},
|
||||
)?;
|
||||
let launch = load_worker_launch_request(&store, "repo-modeling-job-1")?;
|
||||
let model_request = build_worker_model_request(&launch, DEFAULT_MODEL_PROVIDER, "gpt-5.4")?;
|
||||
assert_eq!(
|
||||
model_request.output_contract_id.as_deref(),
|
||||
Some(epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID)
|
||||
);
|
||||
assert!(
|
||||
model_request
|
||||
.output_schema_json
|
||||
.as_deref()
|
||||
.is_some_and(|schema| schema.contains("\"finding\""))
|
||||
);
|
||||
let openai_summary = EpiphanyOpenAiRuntimeRunSummary {
|
||||
store: store.display().to_string(),
|
||||
session_id: "openai-repo-session".to_string(),
|
||||
job_id: "openai-repo-job".to_string(),
|
||||
request_id: model_request.request_id.clone(),
|
||||
event_count: 1,
|
||||
verdict: "pass".to_string(),
|
||||
summary: "completed".to_string(),
|
||||
result_id: "openai-repo-result".to_string(),
|
||||
receipt_id: Some(model_request.request_id.clone()),
|
||||
tool_intent_ids: Vec::new(),
|
||||
};
|
||||
complete_worker_job_from_assistant_text(
|
||||
&store,
|
||||
&launch,
|
||||
&model_request.request_id,
|
||||
&openai_summary,
|
||||
r#"{"verdict":"passed","finding":"The verified README change updates the repo map.","summary":"README consequence mapped.","nextSafeMove":"Let Mind review the finding.","evidenceIds":["soul-repo-1"],"artifactRefs":[]}"#,
|
||||
)?;
|
||||
let finding =
|
||||
epiphany_core::runtime_repo_work_modeling_finding(&store, "repo-request-1-finding")?
|
||||
.expect("typed repo-work Modeling finding");
|
||||
assert_eq!(finding.request_id, request.request_id);
|
||||
assert_eq!(finding.verdict, "passed");
|
||||
assert_eq!(finding.commit_sha, "abc123");
|
||||
assert!(!finding.private_state_exposed);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcp_model_tool_call_becomes_typed_invocation_intent() -> Result<()> {
|
||||
let event = EpiphanyModelStreamEvent {
|
||||
|
|
|
|||
|
|
@ -126,6 +126,23 @@ no longer make Soul report failure. The partial closure artifact is
|
|||
gate rather than mistaking file existence for Mind admission. The scheduler
|
||||
source contains neither the Modeling finding writer nor map admission.
|
||||
|
||||
Repo work now has a native third worker launch kind beside generic role and
|
||||
reorientation work: `repo-work-modeling`. It runs through the existing
|
||||
`epiphany-openai-runtime`, carries the immutable request plus the bounded
|
||||
Soul-verified commit diff, and requires
|
||||
`epiphany.worker.repo_work_modeling_result.v0`. The runtime—not Self—converts
|
||||
model output directly into the canonical `RepoWorkModelingFinding`. Scheduler
|
||||
pulses launch one detached runtime job, wait without duplication, consume only
|
||||
the typed finding, and then resume the existing immutable Mind/map admission.
|
||||
A non-passing finding is immutable and stops for reviewed revision rather than
|
||||
being overwritten or silently retried.
|
||||
|
||||
The former direct CLI writer is cut. `epiphany-work close --model-authored ...`
|
||||
may no longer create a Modeling finding; closure can only reread the canonical
|
||||
runtime document. The obsolete direct-CLI closure smoke was deleted. A live
|
||||
negative probe returned exit 1 for forged passing CLI cargo while leaving the
|
||||
typed request awaiting its real Modeling worker.
|
||||
|
||||
The
|
||||
accepted interpretation is persisted as
|
||||
`epiphany.modeling.repo_work_finding.v0`; it references the passing Soul verdict,
|
||||
|
|
|
|||
|
|
@ -204,9 +204,9 @@ Delete or demote:
|
|||
|
||||
## Immediate Next Action
|
||||
|
||||
Route the persisted `epiphany.modeling.repo_work_request.v0` through the real
|
||||
Modeling worker/daemon and consume its matching typed finding before existing
|
||||
Mind/map admission. Soul verification is already a separate scheduler phase;
|
||||
do not rejoin it to Modeling or introduce CLI cargo as scheduler truth. Prove a
|
||||
fresh-repository scheduler timeline reaches Bifrost while Self cannot author
|
||||
Modeling evidence.
|
||||
Move repo-work Modeling process stewardship under Idunn and add a reviewed
|
||||
request generation for non-passing immutable findings. The scheduler now routes
|
||||
passing requests through the existing model runtime and reaches Bifrost without
|
||||
Self-authored Modeling evidence; preserve that authority path. Do not overwrite
|
||||
a blocked finding, launch duplicate jobs, or grow a scheduler-owned process
|
||||
manager.
|
||||
|
|
|
|||
|
|
@ -2061,6 +2061,30 @@ family/path checks passed and no private-state exposure. Authority tests pass
|
|||
3/3 and all 248 library tests pass. Next route the persisted request through a
|
||||
real Modeling worker/daemon and consume its typed result without CLI-supplied
|
||||
finding cargo.
|
||||
That artery is now live. `EpiphanyWorkerLaunchDocument` has a dedicated
|
||||
`RepoWorkModeling` kind and output contract rather than fabricating a whole
|
||||
`EpiphanyThreadState` for the generic coordinator Modeling lane. The scheduler
|
||||
opens one runtime-spine Modeling job, launches the existing
|
||||
`epiphany-openai-runtime` detached with sealed stdout/stderr artifacts, waits on
|
||||
later pulses, and resumes closure only after the runtime has persisted the
|
||||
matching typed finding. The first authenticated live attempt correctly returned
|
||||
`blocked`: the request named a commit but did not carry its diff. The coherent
|
||||
repair feeds the bounded Soul-verified `git show --stat --patch` consequence to
|
||||
Modeling. Live item `live-modeling-with-diff` in disposable repo
|
||||
`.epiphany-smoke/closure-model-gate-20260712-094208/repo-body` then returned a
|
||||
model-authored `passed` finding, a later pulse performed Mind/map admission, and
|
||||
overview reported `awaiting-publication` / `bifrost-publication-missing` with
|
||||
Soul passed and private state sealed. Runtime tests pass 8/8, authority tests
|
||||
3/3, and core library tests 248/248. The old direct-CLI closure-model smoke was
|
||||
deleted because its successful path required `close` to author Modeling cargo;
|
||||
closure now refuses when the runtime-authored typed finding is absent. Next make reviewed
|
||||
non-passing Modeling revisions a first-class new request/job generation and
|
||||
move detached worker process stewardship under Idunn rather than leaving launch
|
||||
physiology embedded in the scheduler.
|
||||
Live negative item `cli-modeling-authority-refusal` returned exit 1 when
|
||||
`close --model-authored` supplied a forged passing finding; the error names the
|
||||
required Modeling runtime route. The old CLI path is structurally unable to
|
||||
publish the canonical finding.
|
||||
|
||||
## Immediate Re-entry Instruction
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -659,4 +659,4 @@ current_status:
|
|||
- Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass.
|
||||
- `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure.
|
||||
last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. Gjallar readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync.
|
||||
next_action: Route the persisted immutable `epiphany.modeling.repo_work_request.v0` through the real Modeling worker/daemon, consume its matching typed finding, and invoke existing immutable Mind/map admission. Soul verification is now a separate scheduler phase. Prove a fresh repo advances from `awaiting-modeling` to the Bifrost gate while Self remains structurally unable to author the finding.
|
||||
next_action: Move detached repo-work Modeling worker stewardship under Idunn and add a reviewed request generation for non-passing immutable findings. Preserve the now-live typed scheduler path from Soul request through the existing model runtime, canonical Modeling finding, immutable Mind/map admission, and Bifrost gate; Self must remain unable to author or overwrite Modeling evidence.
|
||||
|
|
|
|||
Reference in a new issue