Add typed repository Body observations
This commit is contained in:
parent
cd1a16669b
commit
917d20e2cc
8 changed files with 1535 additions and 0 deletions
125
epiphany-core/src/bin/epiphany-repository-body.rs
Normal file
125
epiphany-core/src/bin/epiphany-repository-body.rs
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
use anyhow::{Result, bail};
|
||||
use epiphany_core::{
|
||||
ObserveOutcome, RuntimeSpineInitOptions, bind_repository_body,
|
||||
bind_runtime_to_agent_memory_swarm, ensure_agent_memory_swarm_identity,
|
||||
initialize_runtime_spine, load_repository_body_status, observe_repository_body,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = std::env::args().skip(1).collect::<Vec<_>>();
|
||||
let Some(command) = args.first().map(String::as_str) else {
|
||||
return usage();
|
||||
};
|
||||
match command {
|
||||
"bind" => {
|
||||
let binding = bind_repository_body(
|
||||
&PathBuf::from(required(&args, "--repo")?),
|
||||
&PathBuf::from(required(&args, "--store")?),
|
||||
&PathBuf::from(required(&args, "--runtime-store")?),
|
||||
required(&args, "--workspace-id")?,
|
||||
)?;
|
||||
println!(
|
||||
"bound workspace={} swarm={} runtime={} scope={} root={}",
|
||||
binding.workspace_id,
|
||||
binding.swarm_id,
|
||||
binding.runtime_id,
|
||||
binding.scope,
|
||||
binding.git_top_level
|
||||
);
|
||||
}
|
||||
"observe" => {
|
||||
let repo = required(&args, "--repo")?;
|
||||
let store = required(&args, "--store")?;
|
||||
let runtime_store = required(&args, "--runtime-store")?;
|
||||
match observe_repository_body(
|
||||
&PathBuf::from(repo),
|
||||
&PathBuf::from(store),
|
||||
&PathBuf::from(runtime_store),
|
||||
)? {
|
||||
ObserveOutcome::Created(value) => println!(
|
||||
"created generation={} tree={} continuity={}",
|
||||
value.generation, value.tree_oid, value.continuity_status
|
||||
),
|
||||
ObserveOutcome::Unchanged(value) => println!(
|
||||
"unchanged generation={} tree={} continuity={}",
|
||||
value.generation, value.tree_oid, value.continuity_status
|
||||
),
|
||||
}
|
||||
}
|
||||
"status" => {
|
||||
let store = PathBuf::from(required(&args, "--store")?);
|
||||
match load_repository_body_status(&store)? {
|
||||
None => println!("missing"),
|
||||
Some((binding, value)) => println!(
|
||||
"observed workspace={} swarm={} runtime={} scope={} generation={} tree={} head={} continuity={}",
|
||||
binding.workspace_id,
|
||||
binding.swarm_id,
|
||||
binding.runtime_id,
|
||||
binding.scope,
|
||||
value.generation,
|
||||
value.tree_oid,
|
||||
value.head_oid.as_deref().unwrap_or("unborn"),
|
||||
value.continuity_status
|
||||
),
|
||||
}
|
||||
}
|
||||
"smoke" => smoke()?,
|
||||
_ => return usage(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn required<'a>(args: &'a [String], name: &str) -> Result<&'a str> {
|
||||
let index = args
|
||||
.iter()
|
||||
.position(|arg| arg == name)
|
||||
.ok_or_else(|| anyhow::anyhow!("missing {name}"))?;
|
||||
args.get(index + 1)
|
||||
.map(String::as_str)
|
||||
.ok_or_else(|| anyhow::anyhow!("missing value for {name}"))
|
||||
}
|
||||
fn usage<T>() -> Result<T> {
|
||||
bail!(
|
||||
"usage: epiphany-repository-body bind --repo PATH --store PATH --runtime-store PATH --workspace-id ID | observe --repo PATH --store PATH --runtime-store PATH | status --store PATH | smoke"
|
||||
)
|
||||
}
|
||||
fn smoke() -> Result<()> {
|
||||
let root = std::env::current_dir()?;
|
||||
let store = std::env::temp_dir().join(format!(
|
||||
"epiphany-repository-body-smoke-{}.cc",
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
let runtime_store = store.with_extension("runtime.cc");
|
||||
let agent_store = store.with_extension("agents.cc");
|
||||
initialize_runtime_spine(
|
||||
&runtime_store,
|
||||
RuntimeSpineInitOptions {
|
||||
runtime_id: "epiphany-smoke-runtime".into(),
|
||||
display_name: "Repository Body smoke".into(),
|
||||
created_at: "2026-07-15T00:00:00Z".into(),
|
||||
},
|
||||
)?;
|
||||
ensure_agent_memory_swarm_identity(&agent_store, "epiphany-smoke-swarm")?;
|
||||
bind_runtime_to_agent_memory_swarm(&runtime_store, &agent_store, "2026-07-15T00:00:01Z")?;
|
||||
bind_repository_body(
|
||||
&root,
|
||||
&store,
|
||||
&runtime_store,
|
||||
"epiphany-repository-body-smoke",
|
||||
)?;
|
||||
let outcome = observe_repository_body(&root, &store, &runtime_store)?;
|
||||
let observed = load_repository_body_status(&store)?
|
||||
.ok_or_else(|| anyhow::anyhow!("smoke observation missing after commit"))?;
|
||||
std::fs::remove_file(&store)?;
|
||||
std::fs::remove_file(&runtime_store)?;
|
||||
std::fs::remove_file(&agent_store)?;
|
||||
let generation = match outcome {
|
||||
ObserveOutcome::Created(value) | ObserveOutcome::Unchanged(value) => value.generation,
|
||||
};
|
||||
println!(
|
||||
"repository-body-smoke=ok generation={} tree={} continuity={}",
|
||||
generation, observed.1.tree_oid, observed.1.continuity_status
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ mod promotion;
|
|||
mod prompt_context;
|
||||
mod proposal;
|
||||
mod repo_model_gateway;
|
||||
mod repository_body_observer;
|
||||
mod retrieval;
|
||||
mod runtime_spine;
|
||||
mod semantic_backend;
|
||||
|
|
@ -805,6 +806,7 @@ pub use proposal::EpiphanyMapProposal;
|
|||
pub use proposal::EpiphanyMapProposalInput;
|
||||
pub use proposal::propose_map_update;
|
||||
pub use repo_model_gateway::*;
|
||||
pub use repository_body_observer::*;
|
||||
pub use retrieval::EPIPHANY_RETRIEVAL_DEFAULT_LIMIT;
|
||||
pub use retrieval::EPIPHANY_RETRIEVAL_MAX_LIMIT;
|
||||
pub use retrieval::EpiphanyRetrieveQuery;
|
||||
|
|
|
|||
1337
epiphany-core/src/repository_body_observer.rs
Normal file
1337
epiphany-core/src/repository_body_observer.rs
Normal file
File diff suppressed because it is too large
Load diff
Reference in a new issue