Move agent smokes into native tools
This commit is contained in:
parent
fc0e9a3594
commit
643c4f36d7
14 changed files with 666 additions and 113 deletions
|
|
@ -15,7 +15,11 @@ pub const AGENT_MEMORY_TYPE: &str = "epiphany.agent_memory";
|
|||
pub const AGENT_MEMORY_SCHEMA_VERSION: &str = "ghostlight.agent_state.v0";
|
||||
|
||||
const ROLE_TARGETS: &[(&str, &str, &str)] = &[
|
||||
("imagination", "epiphany.imagination", "imagination.agent-state.json"),
|
||||
(
|
||||
"imagination",
|
||||
"epiphany.imagination",
|
||||
"imagination.agent-state.json",
|
||||
),
|
||||
("modeling", "epiphany.body", "body.agent-state.json"),
|
||||
("verification", "epiphany.soul", "soul.agent-state.json"),
|
||||
("implementation", "epiphany.hands", "hands.agent-state.json"),
|
||||
|
|
@ -26,10 +30,7 @@ const ROLE_TARGETS: &[(&str, &str, &str)] = &[
|
|||
];
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.agent_memory",
|
||||
schema = "EpiphanyAgentMemoryEntry"
|
||||
)]
|
||||
#[cultcache(type = "epiphany.agent_memory", schema = "EpiphanyAgentMemoryEntry")]
|
||||
pub struct EpiphanyAgentMemoryEntry {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
|
|
@ -325,8 +326,9 @@ pub fn review_agent_self_patch(
|
|||
}
|
||||
match patch.reason.as_deref() {
|
||||
Some(reason) if reason.trim().len() >= 16 && reason.len() <= 800 => {}
|
||||
_ => reasons
|
||||
.push("selfPatch reason must be a bounded explanation of at least 16 characters".to_string()),
|
||||
_ => reasons.push(
|
||||
"selfPatch reason must be a bounded explanation of at least 16 characters".to_string(),
|
||||
),
|
||||
}
|
||||
|
||||
if let Some(object) = patch_value.as_object() {
|
||||
|
|
@ -344,13 +346,31 @@ pub fn review_agent_self_patch(
|
|||
}
|
||||
|
||||
let mut mutation_count = 0;
|
||||
mutation_count += review_memory_patch_array("semanticMemories", patch.semantic_memories.as_ref(), &mut reasons);
|
||||
mutation_count += review_memory_patch_array("episodicMemories", patch.episodic_memories.as_ref(), &mut reasons);
|
||||
mutation_count += review_memory_patch_array("relationshipMemories", patch.relationship_memories.as_ref(), &mut reasons);
|
||||
mutation_count += review_memory_patch_array(
|
||||
"semanticMemories",
|
||||
patch.semantic_memories.as_ref(),
|
||||
&mut reasons,
|
||||
);
|
||||
mutation_count += review_memory_patch_array(
|
||||
"episodicMemories",
|
||||
patch.episodic_memories.as_ref(),
|
||||
&mut reasons,
|
||||
);
|
||||
mutation_count += review_memory_patch_array(
|
||||
"relationshipMemories",
|
||||
patch.relationship_memories.as_ref(),
|
||||
&mut reasons,
|
||||
);
|
||||
mutation_count += review_goal_patch_array(patch.goals.as_ref(), &mut reasons);
|
||||
mutation_count += review_value_patch_array(patch.values.as_ref(), &mut reasons);
|
||||
mutation_count += review_private_notes(patch.private_notes.as_ref(), &mut reasons);
|
||||
review_string_array("evidenceIds", patch.evidence_ids.as_ref(), &mut reasons, 16, 160);
|
||||
review_string_array(
|
||||
"evidenceIds",
|
||||
patch.evidence_ids.as_ref(),
|
||||
&mut reasons,
|
||||
16,
|
||||
160,
|
||||
);
|
||||
if mutation_count == 0 {
|
||||
reasons.push(
|
||||
"selfPatch must contain at least one semantic memory, episodic memory, relationship memory, goal, value, or private note"
|
||||
|
|
@ -359,7 +379,12 @@ pub fn review_agent_self_patch(
|
|||
}
|
||||
|
||||
AgentMemoryReview {
|
||||
status: if reasons.is_empty() { "accepted" } else { "rejected" }.to_string(),
|
||||
status: if reasons.is_empty() {
|
||||
"accepted"
|
||||
} else {
|
||||
"rejected"
|
||||
}
|
||||
.to_string(),
|
||||
target_agent_id,
|
||||
target_role_id: role_id.to_string(),
|
||||
target_store: store_path.display().to_string(),
|
||||
|
|
@ -402,9 +427,14 @@ pub fn apply_agent_self_patch(
|
|||
upsert_values(&mut entry.agent.canonical_state.values, incoming);
|
||||
}
|
||||
if let Some(mut private_notes) = patch.private_notes {
|
||||
entry.agent.identity.private_notes.append(&mut private_notes);
|
||||
entry
|
||||
.agent
|
||||
.identity
|
||||
.private_notes
|
||||
.append(&mut private_notes);
|
||||
let keep_from = entry.agent.identity.private_notes.len().saturating_sub(32);
|
||||
entry.agent.identity.private_notes = entry.agent.identity.private_notes[keep_from..].to_vec();
|
||||
entry.agent.identity.private_notes =
|
||||
entry.agent.identity.private_notes[keep_from..].to_vec();
|
||||
}
|
||||
cache.put(role_id.to_string(), &entry)?;
|
||||
review.applied = Some(true);
|
||||
|
|
@ -515,7 +545,9 @@ fn entry_from_projection(
|
|||
));
|
||||
}
|
||||
if projection.agents.len() != 1 {
|
||||
return Err(anyhow!("role memory projection must contain exactly one agent"));
|
||||
return Err(anyhow!(
|
||||
"role memory projection must contain exactly one agent"
|
||||
));
|
||||
}
|
||||
let agent = projection.agents.into_iter().next().expect("checked len");
|
||||
if agent.agent_id != expected_agent_id {
|
||||
|
|
@ -547,7 +579,12 @@ fn validate_agent_entry(entry: &EpiphanyAgentMemoryEntry, expected_agent_id: &st
|
|||
}
|
||||
check_string(&entry.world.world_id, "world.world_id", &mut errors, 120);
|
||||
check_string(&entry.world.setting, "world.setting", &mut errors, 800);
|
||||
check_string(&entry.world.time.label, "world.time.label", &mut errors, 200);
|
||||
check_string(
|
||||
&entry.world.time.label,
|
||||
"world.time.label",
|
||||
&mut errors,
|
||||
200,
|
||||
);
|
||||
if entry.world.canon_context.is_empty() {
|
||||
errors.push("world.canon_context must not be empty".to_string());
|
||||
}
|
||||
|
|
@ -557,8 +594,18 @@ fn validate_agent_entry(entry: &EpiphanyAgentMemoryEntry, expected_agent_id: &st
|
|||
entry.role_id, entry.agent.agent_id, expected_agent_id
|
||||
));
|
||||
}
|
||||
check_string(&entry.agent.identity.name, "identity.name", &mut errors, 200);
|
||||
check_string(&entry.agent.identity.origin, "identity.origin", &mut errors, 800);
|
||||
check_string(
|
||||
&entry.agent.identity.name,
|
||||
"identity.name",
|
||||
&mut errors,
|
||||
200,
|
||||
);
|
||||
check_string(
|
||||
&entry.agent.identity.origin,
|
||||
"identity.origin",
|
||||
&mut errors,
|
||||
800,
|
||||
);
|
||||
check_string(
|
||||
&entry.agent.identity.public_description,
|
||||
"identity.public_description",
|
||||
|
|
@ -604,13 +651,20 @@ fn validate_agent_entry(entry: &EpiphanyAgentMemoryEntry, expected_agent_id: &st
|
|||
&entry.agent.canonical_state.presentation_strategy,
|
||||
),
|
||||
("voice_style", &entry.agent.canonical_state.voice_style),
|
||||
("situational_state", &entry.agent.canonical_state.situational_state),
|
||||
(
|
||||
"situational_state",
|
||||
&entry.agent.canonical_state.situational_state,
|
||||
),
|
||||
] {
|
||||
if group.is_empty() {
|
||||
errors.push(format!("canonical_state.{group_name} must not be empty"));
|
||||
}
|
||||
for (name, vector) in group {
|
||||
validate_trait_vector(vector, &format!("canonical_state.{group_name}.{name}"), &mut errors);
|
||||
validate_trait_vector(
|
||||
vector,
|
||||
&format!("canonical_state.{group_name}.{name}"),
|
||||
&mut errors,
|
||||
);
|
||||
}
|
||||
}
|
||||
errors
|
||||
|
|
@ -625,7 +679,12 @@ fn validate_memory(memory: &GhostlightMemory, path: &str, errors: &mut Vec<Strin
|
|||
|
||||
fn validate_goal(goal: &GhostlightGoal, path: &str, errors: &mut Vec<String>) {
|
||||
check_string(&goal.goal_id, &format!("{path}.goal_id"), errors, 120);
|
||||
check_string(&goal.description, &format!("{path}.description"), errors, 800);
|
||||
check_string(
|
||||
&goal.description,
|
||||
&format!("{path}.description"),
|
||||
errors,
|
||||
800,
|
||||
);
|
||||
if !matches!(
|
||||
goal.scope.as_str(),
|
||||
"immediate" | "scene" | "case" | "arc" | "life"
|
||||
|
|
@ -633,7 +692,12 @@ fn validate_goal(goal: &GhostlightGoal, path: &str, errors: &mut Vec<String>) {
|
|||
errors.push(format!("{path}.scope is not a Ghostlight scope"));
|
||||
}
|
||||
check_unit(goal.priority, &format!("{path}.priority"), errors);
|
||||
check_string(&goal.emotional_stake, &format!("{path}.emotional_stake"), errors, 400);
|
||||
check_string(
|
||||
&goal.emotional_stake,
|
||||
&format!("{path}.emotional_stake"),
|
||||
errors,
|
||||
400,
|
||||
);
|
||||
if !matches!(
|
||||
goal.status.as_str(),
|
||||
"active" | "blocked" | "dormant" | "resolved" | "abandoned"
|
||||
|
|
@ -660,7 +724,9 @@ fn validate_trait_vector(vector: &GhostlightTraitVector, path: &str, errors: &mu
|
|||
|
||||
fn check_string(value: &str, path: &str, errors: &mut Vec<String>, max_len: usize) {
|
||||
if value.trim().is_empty() || value.len() > max_len {
|
||||
errors.push(format!("{path} must be non-empty text under {max_len} characters"));
|
||||
errors.push(format!(
|
||||
"{path} must be non-empty text under {max_len} characters"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -734,9 +800,22 @@ fn review_memory_patch_array(
|
|||
"selfPatch {field}[{index}].memoryId must start with 'mem-' and avoid whitespace"
|
||||
));
|
||||
}
|
||||
check_patch_text(&item.summary, &format!("selfPatch {field}[{index}].summary"), reasons, 600);
|
||||
check_patch_unit(item.salience, &format!("selfPatch {field}[{index}].salience"), reasons);
|
||||
check_patch_unit(item.confidence, &format!("selfPatch {field}[{index}].confidence"), reasons);
|
||||
check_patch_text(
|
||||
&item.summary,
|
||||
&format!("selfPatch {field}[{index}].summary"),
|
||||
reasons,
|
||||
600,
|
||||
);
|
||||
check_patch_unit(
|
||||
item.salience,
|
||||
&format!("selfPatch {field}[{index}].salience"),
|
||||
reasons,
|
||||
);
|
||||
check_patch_unit(
|
||||
item.confidence,
|
||||
&format!("selfPatch {field}[{index}].confidence"),
|
||||
reasons,
|
||||
);
|
||||
}
|
||||
value.len()
|
||||
}
|
||||
|
|
@ -754,14 +833,25 @@ fn review_goal_patch_array(value: Option<&Vec<SelfPatchGoal>>, reasons: &mut Vec
|
|||
"selfPatch goals[{index}].goalId must start with 'goal-' and avoid whitespace"
|
||||
));
|
||||
}
|
||||
check_patch_text(&item.description, &format!("selfPatch goals[{index}].description"), reasons, 700);
|
||||
check_patch_text(
|
||||
&item.description,
|
||||
&format!("selfPatch goals[{index}].description"),
|
||||
reasons,
|
||||
700,
|
||||
);
|
||||
if !matches!(
|
||||
item.scope.as_str(),
|
||||
"immediate" | "scene" | "case" | "arc" | "life"
|
||||
) {
|
||||
reasons.push(format!("selfPatch goals[{index}].scope is not a Ghostlight scope"));
|
||||
reasons.push(format!(
|
||||
"selfPatch goals[{index}].scope is not a Ghostlight scope"
|
||||
));
|
||||
}
|
||||
check_patch_unit(item.priority, &format!("selfPatch goals[{index}].priority"), reasons);
|
||||
check_patch_unit(
|
||||
item.priority,
|
||||
&format!("selfPatch goals[{index}].priority"),
|
||||
reasons,
|
||||
);
|
||||
check_patch_text(
|
||||
&item.emotional_stake,
|
||||
&format!("selfPatch goals[{index}].emotionalStake"),
|
||||
|
|
@ -772,13 +862,18 @@ fn review_goal_patch_array(value: Option<&Vec<SelfPatchGoal>>, reasons: &mut Vec
|
|||
item.status.as_str(),
|
||||
"active" | "blocked" | "dormant" | "resolved" | "abandoned"
|
||||
) {
|
||||
reasons.push(format!("selfPatch goals[{index}].status is not a Ghostlight status"));
|
||||
reasons.push(format!(
|
||||
"selfPatch goals[{index}].status is not a Ghostlight status"
|
||||
));
|
||||
}
|
||||
}
|
||||
value.len()
|
||||
}
|
||||
|
||||
fn review_value_patch_array(value: Option<&Vec<SelfPatchValue>>, reasons: &mut Vec<String>) -> usize {
|
||||
fn review_value_patch_array(
|
||||
value: Option<&Vec<SelfPatchValue>>,
|
||||
reasons: &mut Vec<String>,
|
||||
) -> usize {
|
||||
let Some(value) = value else {
|
||||
return 0;
|
||||
};
|
||||
|
|
@ -791,8 +886,17 @@ fn review_value_patch_array(value: Option<&Vec<SelfPatchValue>>, reasons: &mut V
|
|||
"selfPatch values[{index}].valueId must start with 'value-' and avoid whitespace"
|
||||
));
|
||||
}
|
||||
check_patch_text(&item.label, &format!("selfPatch values[{index}].label"), reasons, 240);
|
||||
check_patch_unit(item.priority, &format!("selfPatch values[{index}].priority"), reasons);
|
||||
check_patch_text(
|
||||
&item.label,
|
||||
&format!("selfPatch values[{index}].label"),
|
||||
reasons,
|
||||
240,
|
||||
);
|
||||
check_patch_unit(
|
||||
item.priority,
|
||||
&format!("selfPatch values[{index}].priority"),
|
||||
reasons,
|
||||
);
|
||||
}
|
||||
value.len()
|
||||
}
|
||||
|
|
@ -805,7 +909,12 @@ fn review_private_notes(value: Option<&Vec<String>>, reasons: &mut Vec<String>)
|
|||
reasons.push("selfPatch privateNotes may contain at most 6 records".to_string());
|
||||
}
|
||||
for (index, item) in value.iter().enumerate() {
|
||||
check_patch_text(item, &format!("selfPatch privateNotes[{index}]"), reasons, 600);
|
||||
check_patch_text(
|
||||
item,
|
||||
&format!("selfPatch privateNotes[{index}]"),
|
||||
reasons,
|
||||
600,
|
||||
);
|
||||
}
|
||||
value.len()
|
||||
}
|
||||
|
|
@ -821,16 +930,25 @@ fn review_string_array(
|
|||
return;
|
||||
};
|
||||
if value.len() > max_items {
|
||||
reasons.push(format!("selfPatch {field} may contain at most {max_items} records"));
|
||||
reasons.push(format!(
|
||||
"selfPatch {field} may contain at most {max_items} records"
|
||||
));
|
||||
}
|
||||
for (index, item) in value.iter().enumerate() {
|
||||
check_patch_text(item, &format!("selfPatch {field}[{index}]"), reasons, max_len);
|
||||
check_patch_text(
|
||||
item,
|
||||
&format!("selfPatch {field}[{index}]"),
|
||||
reasons,
|
||||
max_len,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_patch_text(value: &str, path: &str, reasons: &mut Vec<String>, max_len: usize) {
|
||||
if value.trim().is_empty() || value.len() > max_len {
|
||||
reasons.push(format!("{path} must be non-empty text under {max_len} characters"));
|
||||
reasons.push(format!(
|
||||
"{path} must be non-empty text under {max_len} characters"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -843,9 +961,9 @@ fn check_patch_unit(value: f64, path: &str, reasons: &mut Vec<String>) {
|
|||
fn valid_identifier(value: &str, prefix: &str) -> bool {
|
||||
value.starts_with(prefix)
|
||||
&& value.len() <= 120
|
||||
&& value
|
||||
.chars()
|
||||
.all(|ch| ch.is_ascii() && (ch.is_ascii_alphanumeric() || matches!(ch, '-' | '_' | '.')))
|
||||
&& value.chars().all(|ch| {
|
||||
ch.is_ascii() && (ch.is_ascii_alphanumeric() || matches!(ch, '-' | '_' | '.'))
|
||||
})
|
||||
}
|
||||
|
||||
fn upsert_memories(records: &mut Vec<GhostlightMemory>, incoming: Vec<SelfPatchMemory>) {
|
||||
|
|
@ -962,12 +1080,13 @@ mod tests {
|
|||
let mut cache = agent_memory_cache(&store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
let body = cache.get_required::<EpiphanyAgentMemoryEntry>("modeling")?;
|
||||
assert!(body
|
||||
.agent
|
||||
.memories
|
||||
.semantic
|
||||
.iter()
|
||||
.any(|memory| memory.memory_id == "mem-body-native-source-grounding"));
|
||||
assert!(
|
||||
body.agent
|
||||
.memories
|
||||
.semantic
|
||||
.iter()
|
||||
.any(|memory| memory.memory_id == "mem-body-native-source-grounding")
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ use epiphany_core::review_agent_self_patch;
|
|||
use epiphany_core::validate_agent_memory_store;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use uuid::Uuid;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let mut args = env::args().skip(1);
|
||||
|
|
@ -20,7 +22,9 @@ fn main() -> Result<()> {
|
|||
"migrate-json-dir" => {
|
||||
let agent_dir = require_path_arg(&mut args, "--agent-dir")?;
|
||||
let store = require_path_arg(&mut args, "--store")?;
|
||||
print_json(&migrate_agent_memory_json_dir_to_cultcache(agent_dir, store)?)?;
|
||||
print_json(&migrate_agent_memory_json_dir_to_cultcache(
|
||||
agent_dir, store,
|
||||
)?)?;
|
||||
}
|
||||
"project-json-dir" => {
|
||||
let store = require_path_arg(&mut args, "--store")?;
|
||||
|
|
@ -60,6 +64,16 @@ fn main() -> Result<()> {
|
|||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
"smoke" => {
|
||||
let store = optional_path_arg(&mut args, "--store")?
|
||||
.unwrap_or_else(|| PathBuf::from("state/agents.msgpack"));
|
||||
let result = run_smoke(&store)?;
|
||||
let ok = result["ok"].as_bool().unwrap_or(false);
|
||||
print_json(&result)?;
|
||||
if !ok {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
print_usage();
|
||||
std::process::exit(2);
|
||||
|
|
@ -79,7 +93,22 @@ fn require_string_arg(args: &mut impl Iterator<Item = String>, name: &str) -> Re
|
|||
if flag != name {
|
||||
anyhow::bail!("expected {name}, got {flag}");
|
||||
}
|
||||
args.next().with_context(|| format!("missing value for {name}"))
|
||||
args.next()
|
||||
.with_context(|| format!("missing value for {name}"))
|
||||
}
|
||||
|
||||
fn optional_path_arg(
|
||||
args: &mut impl Iterator<Item = String>,
|
||||
name: &str,
|
||||
) -> Result<Option<PathBuf>> {
|
||||
let values: Vec<String> = args.collect();
|
||||
if values.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
if values.len() != 2 || values[0] != name {
|
||||
anyhow::bail!("expected optional {name} <path>, got {values:?}");
|
||||
}
|
||||
Ok(Some(PathBuf::from(&values[1])))
|
||||
}
|
||||
|
||||
fn read_patch_arg(value: &str) -> Result<serde_json::Value> {
|
||||
|
|
@ -100,6 +129,74 @@ fn print_json<T: serde::Serialize>(value: &T) -> Result<()> {
|
|||
|
||||
fn print_usage() {
|
||||
eprintln!(
|
||||
"usage: epiphany-agent-memory-store <migrate-json-dir|project-json-dir|status|validate|review-patch|apply-patch> ..."
|
||||
"usage: epiphany-agent-memory-store <migrate-json-dir|project-json-dir|status|validate|review-patch|apply-patch|smoke> ..."
|
||||
);
|
||||
}
|
||||
|
||||
fn run_smoke(store: &Path) -> Result<serde_json::Value> {
|
||||
let errors = validate_agent_memory_store(store)?;
|
||||
if !errors.is_empty() {
|
||||
return Ok(serde_json::json!({
|
||||
"ok": false,
|
||||
"phase": "validate",
|
||||
"errors": errors,
|
||||
}));
|
||||
}
|
||||
let accepted_patch = serde_json::json!({
|
||||
"agentId": "epiphany.body",
|
||||
"reason": "The Body should remember accepted graph growth must be source-grounded and bounded.",
|
||||
"semanticMemories": [{
|
||||
"memoryId": "mem-body-smoke-source-grounding",
|
||||
"summary": "A modeling self-memory request is acceptable when it improves future graph/checkpoint judgment without smuggling project truth.",
|
||||
"salience": 0.74,
|
||||
"confidence": 0.86,
|
||||
}],
|
||||
});
|
||||
let accepted = review_agent_self_patch("modeling", &accepted_patch, store);
|
||||
let wrong_role = review_agent_self_patch("verification", &accepted_patch, store);
|
||||
let forbidden_patch = serde_json::json!({
|
||||
"agentId": "epiphany.body",
|
||||
"reason": "This tries to put project state in lane memory, which should be refused.",
|
||||
"graphs": {},
|
||||
"semanticMemories": [{
|
||||
"memoryId": "mem-body-bad-project-truth",
|
||||
"summary": "Bad patch.",
|
||||
"salience": 0.5,
|
||||
"confidence": 0.5,
|
||||
}],
|
||||
});
|
||||
let forbidden = review_agent_self_patch("modeling", &forbidden_patch, store);
|
||||
|
||||
let temp_dir = scoped_temp_dir("epiphany-agent-memory-smoke")?;
|
||||
let temp_store = temp_dir.join("agents.msgpack");
|
||||
fs::copy(store, &temp_store).with_context(|| {
|
||||
format!(
|
||||
"failed to copy {} to {}",
|
||||
store.display(),
|
||||
temp_store.display()
|
||||
)
|
||||
})?;
|
||||
let applied = apply_agent_self_patch("modeling", &accepted_patch, &temp_store)?;
|
||||
let temp_validation_errors = validate_agent_memory_store(&temp_store)?;
|
||||
let _ = fs::remove_dir_all(&temp_dir);
|
||||
|
||||
let ok = accepted.status == "accepted"
|
||||
&& wrong_role.status == "rejected"
|
||||
&& forbidden.status == "rejected"
|
||||
&& applied.status == "accepted"
|
||||
&& temp_validation_errors.is_empty();
|
||||
Ok(serde_json::json!({
|
||||
"ok": ok,
|
||||
"accepted": accepted,
|
||||
"wrongRole": wrong_role,
|
||||
"forbidden": forbidden,
|
||||
"applied": applied,
|
||||
"tempValidationErrors": temp_validation_errors,
|
||||
}))
|
||||
}
|
||||
|
||||
fn scoped_temp_dir(prefix: &str) -> Result<PathBuf> {
|
||||
let path = env::temp_dir().join(format!("{prefix}-{}", Uuid::new_v4()));
|
||||
fs::create_dir_all(&path).with_context(|| format!("failed to create {}", path.display()))?;
|
||||
Ok(path)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,22 @@
|
|||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use epiphany_core::HeartbeatCompleteOptions;
|
||||
use epiphany_core::HeartbeatTickOptions;
|
||||
use epiphany_core::apply_agent_self_patch;
|
||||
use epiphany_core::complete_heartbeat_store;
|
||||
use epiphany_core::heartbeat_status_projection;
|
||||
use epiphany_core::initialize_heartbeat_store;
|
||||
use epiphany_core::load_heartbeat_state_entry;
|
||||
use epiphany_core::migrate_heartbeat_json_to_cultcache;
|
||||
use epiphany_core::tick_heartbeat_store;
|
||||
use epiphany_core::validate_agent_memory_store;
|
||||
use epiphany_core::write_heartbeat_json_projection;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use uuid::Uuid;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let mut args = env::args().skip(1);
|
||||
|
|
@ -31,6 +37,7 @@ fn main() -> Result<()> {
|
|||
let mut role: Option<String> = None;
|
||||
let mut action_id: Option<String> = None;
|
||||
let mut limit = 8_usize;
|
||||
let mut agent_store: Option<PathBuf> = None;
|
||||
|
||||
while let Some(arg) = args.next() {
|
||||
match arg.as_str() {
|
||||
|
|
@ -52,6 +59,7 @@ fn main() -> Result<()> {
|
|||
"--role" => role = Some(next_value(&mut args, "--role")?),
|
||||
"--action-id" => action_id = Some(next_value(&mut args, "--action-id")?),
|
||||
"--limit" => limit = next_value(&mut args, "--limit")?.parse()?,
|
||||
"--agent-store" => agent_store = Some(next_path(&mut args, "--agent-store")?),
|
||||
_ => return Err(anyhow!("unknown argument {arg:?}")),
|
||||
}
|
||||
}
|
||||
|
|
@ -169,6 +177,15 @@ fn main() -> Result<()> {
|
|||
);
|
||||
}
|
||||
}
|
||||
"smoke" => {
|
||||
let agent_store = agent_store.unwrap_or_else(|| PathBuf::from("state/agents.msgpack"));
|
||||
let result = run_smoke(&agent_store)?;
|
||||
let ok = result["ok"].as_bool().unwrap_or(false);
|
||||
println!("{}", serde_json::to_string_pretty(&result)?);
|
||||
if !ok {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
_ => return usage(),
|
||||
}
|
||||
|
||||
|
|
@ -186,6 +203,286 @@ fn next_value(args: &mut impl Iterator<Item = String>, name: &str) -> Result<Str
|
|||
|
||||
fn usage() -> Result<()> {
|
||||
Err(anyhow!(
|
||||
"usage: epiphany-heartbeat-store init --store <path>\n epiphany-heartbeat-store tick --store <path> --artifact-dir <path> [--coordinator-action <action>] [--defer-completion]\n epiphany-heartbeat-store complete --store <path> --artifact-dir <path> --role <role> [--action-id <id>]\n epiphany-heartbeat-store status --store <path> [--artifact-dir <path>]\n epiphany-heartbeat-store migrate-json --json <path> --store <path> [--projection <path>]\n epiphany-heartbeat-store project --store <path> --projection <path>"
|
||||
"usage: epiphany-heartbeat-store init --store <path>\n epiphany-heartbeat-store tick --store <path> --artifact-dir <path> [--coordinator-action <action>] [--defer-completion]\n epiphany-heartbeat-store complete --store <path> --artifact-dir <path> --role <role> [--action-id <id>]\n epiphany-heartbeat-store status --store <path> [--artifact-dir <path>]\n epiphany-heartbeat-store migrate-json --json <path> --store <path> [--projection <path>]\n epiphany-heartbeat-store project --store <path> --projection <path>\n epiphany-heartbeat-store smoke [--agent-store <path>]"
|
||||
))
|
||||
}
|
||||
|
||||
fn run_smoke(agent_store: &Path) -> Result<serde_json::Value> {
|
||||
let temp_dir = scoped_temp_dir("epiphany-heartbeat-smoke")?;
|
||||
let temp_agent_store = temp_dir.join("agents.msgpack");
|
||||
let store_path = temp_dir.join("heartbeats.msgpack");
|
||||
let artifact_dir = temp_dir.join("artifacts");
|
||||
fs::copy(agent_store, &temp_agent_store).with_context(|| {
|
||||
format!(
|
||||
"failed to copy {} to {}",
|
||||
agent_store.display(),
|
||||
temp_agent_store.display()
|
||||
)
|
||||
})?;
|
||||
|
||||
let initial_errors = validate_agent_memory_store(&temp_agent_store)?;
|
||||
if !initial_errors.is_empty() {
|
||||
let _ = fs::remove_dir_all(&temp_dir);
|
||||
return Ok(serde_json::json!({
|
||||
"ok": false,
|
||||
"phase": "agent-memory-validate",
|
||||
"validationErrors": initial_errors,
|
||||
}));
|
||||
}
|
||||
|
||||
initialize_heartbeat_store(&store_path, 1.0)?;
|
||||
let work = tick_heartbeat_store(
|
||||
&store_path,
|
||||
&artifact_dir,
|
||||
HeartbeatTickOptions {
|
||||
target_heartbeat_rate: 1.0,
|
||||
coordinator_action: Some("continueImplementation".to_string()),
|
||||
target_role: None,
|
||||
urgency: 0.95,
|
||||
schedule_id: "smoke-work".to_string(),
|
||||
source_scene_ref: "smoke/coordinator".to_string(),
|
||||
defer_completion: true,
|
||||
},
|
||||
)?;
|
||||
let blocked_repeat = tick_heartbeat_store(
|
||||
&store_path,
|
||||
&artifact_dir,
|
||||
HeartbeatTickOptions {
|
||||
target_heartbeat_rate: 1.0,
|
||||
coordinator_action: Some("continueImplementation".to_string()),
|
||||
target_role: None,
|
||||
urgency: 0.95,
|
||||
schedule_id: "smoke-work".to_string(),
|
||||
source_scene_ref: "smoke/coordinator".to_string(),
|
||||
defer_completion: true,
|
||||
},
|
||||
)
|
||||
.err()
|
||||
.map(|error| error.to_string());
|
||||
|
||||
let action_id = work["event"]["actionId"]
|
||||
.as_str()
|
||||
.ok_or_else(|| anyhow!("smoke work event has no actionId"))?
|
||||
.to_string();
|
||||
let completed = complete_heartbeat_store(
|
||||
&store_path,
|
||||
&artifact_dir,
|
||||
HeartbeatCompleteOptions {
|
||||
role: "implementation".to_string(),
|
||||
action_id: Some(action_id),
|
||||
},
|
||||
)?;
|
||||
let mut idle = tick_heartbeat_store(
|
||||
&store_path,
|
||||
&artifact_dir,
|
||||
HeartbeatTickOptions {
|
||||
target_heartbeat_rate: 1.0,
|
||||
coordinator_action: None,
|
||||
target_role: None,
|
||||
urgency: 0.0,
|
||||
schedule_id: "smoke-idle".to_string(),
|
||||
source_scene_ref: "smoke/idle".to_string(),
|
||||
defer_completion: false,
|
||||
},
|
||||
)?;
|
||||
|
||||
if let Some(patch) = idle["rumination"]["selfPatch"].as_object() {
|
||||
let role_id = idle["rumination"]["roleId"]
|
||||
.as_str()
|
||||
.ok_or_else(|| anyhow!("idle rumination has no roleId"))?
|
||||
.to_string();
|
||||
let patch = serde_json::Value::Object(patch.clone());
|
||||
let applied = apply_agent_self_patch(&role_id, &patch, &temp_agent_store)?;
|
||||
idle["rumination"]["result"] = serde_json::to_value(applied)?;
|
||||
idle["rumination"]["applied"] = serde_json::Value::Bool(true);
|
||||
write_rumination_artifact(&artifact_dir, "smoke-idle", &idle["rumination"])?;
|
||||
}
|
||||
|
||||
let validation_errors = validate_agent_memory_store(&temp_agent_store)?;
|
||||
let status = heartbeat_status_projection(&store_path, &artifact_dir, 1.0, 8)?;
|
||||
let initiative_errors = validate_schedule_shape(&work["schedule"])
|
||||
.into_iter()
|
||||
.chain(validate_schedule_shape(&idle["schedule"]))
|
||||
.collect::<Vec<_>>();
|
||||
let ok = work["event"]["selectedRole"] == "implementation"
|
||||
&& work["event"]["turnStatus"] == "running"
|
||||
&& blocked_repeat
|
||||
.as_deref()
|
||||
.is_some_and(|message| message.contains("already has running heartbeat turn"))
|
||||
&& completed["event"]["turnStatus"] == "completed"
|
||||
&& idle["event"]["actionType"] == "ruminate_memory"
|
||||
&& idle["event"]["turnStatus"] == "completed"
|
||||
&& idle["event"]["nextReadyAt"].as_f64().unwrap_or_default()
|
||||
> completed["event"]["nextReadyAt"]
|
||||
.as_f64()
|
||||
.unwrap_or_default()
|
||||
&& idle["rumination"]["result"]["status"] == "accepted"
|
||||
&& validation_errors.is_empty()
|
||||
&& initiative_errors.is_empty()
|
||||
&& artifact_dir.join("smoke-work.initiative.json").exists()
|
||||
&& artifact_dir.join("smoke-work.completion.json").exists()
|
||||
&& artifact_dir.join("smoke-idle.rumination.json").exists()
|
||||
&& status["participants"].as_array().map(Vec::len) == Some(8);
|
||||
|
||||
let result = serde_json::json!({
|
||||
"ok": ok,
|
||||
"workEvent": work["event"],
|
||||
"blockedRepeat": blocked_repeat,
|
||||
"completionEvent": completed["event"],
|
||||
"idleEvent": idle["event"],
|
||||
"idleRumination": idle["rumination"],
|
||||
"validationErrors": validation_errors,
|
||||
"initiativeErrors": initiative_errors,
|
||||
});
|
||||
let _ = fs::remove_dir_all(&temp_dir);
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn write_rumination_artifact(
|
||||
artifact_dir: &Path,
|
||||
schedule_id: &str,
|
||||
value: &serde_json::Value,
|
||||
) -> Result<()> {
|
||||
fs::create_dir_all(artifact_dir)
|
||||
.with_context(|| format!("failed to create {}", artifact_dir.display()))?;
|
||||
let path = artifact_dir.join(format!("{schedule_id}.rumination.json"));
|
||||
fs::write(&path, format!("{}\n", serde_json::to_string_pretty(value)?))
|
||||
.with_context(|| format!("failed to write {}", path.display()))
|
||||
}
|
||||
|
||||
fn validate_schedule_shape(schedule: &serde_json::Value) -> Vec<String> {
|
||||
let mut errors = Vec::new();
|
||||
let required = [
|
||||
"schema_version",
|
||||
"schedule_id",
|
||||
"source_scene_ref",
|
||||
"scene_clock",
|
||||
"participants",
|
||||
"action_catalog",
|
||||
"reaction_windows",
|
||||
"selection_policy",
|
||||
"next_actor_selection",
|
||||
"review_notes",
|
||||
];
|
||||
for key in required {
|
||||
if schedule.get(key).is_none() {
|
||||
errors.push(format!("initiative schedule missing {key}"));
|
||||
}
|
||||
}
|
||||
if schedule["schema_version"] != "ghostlight.initiative_schedule.v0" {
|
||||
errors.push("initiative schedule has wrong schema_version".to_string());
|
||||
}
|
||||
if !schedule["scene_clock"].is_number()
|
||||
|| schedule["scene_clock"]
|
||||
.as_f64()
|
||||
.is_some_and(|clock| clock < 0.0)
|
||||
{
|
||||
errors.push("initiative schedule scene_clock must be non-negative number".to_string());
|
||||
}
|
||||
for participant in schedule["participants"].as_array().into_iter().flatten() {
|
||||
if ![
|
||||
"active",
|
||||
"blocked",
|
||||
"withdrawn",
|
||||
"incapacitated",
|
||||
"offscreen",
|
||||
]
|
||||
.contains(&participant["status"].as_str().unwrap_or_default())
|
||||
{
|
||||
errors.push(format!(
|
||||
"participant {:?} has invalid status",
|
||||
participant["agent_id"]
|
||||
));
|
||||
}
|
||||
for key in [
|
||||
"initiative_speed",
|
||||
"next_ready_at",
|
||||
"reaction_bias",
|
||||
"interrupt_threshold",
|
||||
"current_load",
|
||||
] {
|
||||
if !participant[key].is_number() {
|
||||
errors.push(format!(
|
||||
"participant {:?} {key} must be numeric",
|
||||
participant["agent_id"]
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
for action in schedule["action_catalog"].as_array().into_iter().flatten() {
|
||||
if ![
|
||||
"speak",
|
||||
"silence",
|
||||
"move",
|
||||
"gesture",
|
||||
"touch_object",
|
||||
"block_object",
|
||||
"use_object",
|
||||
"show_object",
|
||||
"withhold_object",
|
||||
"transfer_object",
|
||||
"spend_resource",
|
||||
"attack",
|
||||
"wait",
|
||||
"mixed",
|
||||
]
|
||||
.contains(&action["action_type"].as_str().unwrap_or_default())
|
||||
{
|
||||
errors.push(format!(
|
||||
"action {:?} has invalid action_type",
|
||||
action["action_id"]
|
||||
));
|
||||
}
|
||||
if !["micro", "short", "standard", "major", "committed"]
|
||||
.contains(&action["action_scale"].as_str().unwrap_or_default())
|
||||
{
|
||||
errors.push(format!(
|
||||
"action {:?} has invalid action_scale",
|
||||
action["action_id"]
|
||||
));
|
||||
}
|
||||
}
|
||||
let selection = &schedule["next_actor_selection"];
|
||||
if ![
|
||||
"scheduled_turn",
|
||||
"reaction_interrupt",
|
||||
"coordinator_override",
|
||||
]
|
||||
.contains(&selection["selection_kind"].as_str().unwrap_or_default())
|
||||
{
|
||||
errors.push("next_actor_selection has invalid selection_kind".to_string());
|
||||
}
|
||||
for snapshot in selection["readiness_snapshot"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
{
|
||||
if let Some(object) = snapshot.as_object() {
|
||||
let extra_keys = object
|
||||
.keys()
|
||||
.filter(|key| {
|
||||
![
|
||||
"agent_id",
|
||||
"next_ready_at",
|
||||
"reaction_readiness",
|
||||
"eligible_for_reaction",
|
||||
]
|
||||
.contains(&key.as_str())
|
||||
})
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
if !extra_keys.is_empty() {
|
||||
errors.push(format!(
|
||||
"readiness snapshot has Ghostlight-incompatible keys: {extra_keys:?}"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
errors
|
||||
}
|
||||
|
||||
fn scoped_temp_dir(prefix: &str) -> Result<PathBuf> {
|
||||
let path = env::temp_dir().join(format!("{prefix}-{}", Uuid::new_v4()));
|
||||
fs::create_dir_all(&path).with_context(|| format!("failed to create {}", path.display()))?;
|
||||
Ok(path)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,18 +43,18 @@ fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
add_content_checks(
|
||||
&mut findings,
|
||||
&map_path,
|
||||
&scratch_path,
|
||||
&ledger_path,
|
||||
);
|
||||
add_content_checks(&mut findings, &map_path, &scratch_path, &ledger_path);
|
||||
add_handoff_checks(&mut findings, &handoff_path);
|
||||
add_agents_checks(&mut findings, &agents_path);
|
||||
let (status, log) = match (run_git(&root, ["status", "--short", "--branch"]), run_git(&root, ["log", "--oneline", "-5"])) {
|
||||
let (status, log) = match (
|
||||
run_git(&root, ["status", "--short", "--branch"]),
|
||||
run_git(&root, ["log", "--oneline", "-5"]),
|
||||
) {
|
||||
(Ok(status), Ok(log)) => {
|
||||
if status.lines().skip(1).any(|line| !line.trim().is_empty()) {
|
||||
findings.push(warn("git worktree has uncommitted changes; commit or explain before compaction"));
|
||||
findings.push(warn(
|
||||
"git worktree has uncommitted changes; commit or explain before compaction",
|
||||
));
|
||||
} else {
|
||||
findings.push(ok("git worktree is clean"));
|
||||
}
|
||||
|
|
@ -62,7 +62,10 @@ fn main() -> Result<()> {
|
|||
}
|
||||
_ => {
|
||||
findings.push(error("git check failed"));
|
||||
("(git status unavailable)".to_string(), "(git log unavailable)".to_string())
|
||||
(
|
||||
"(git status unavailable)".to_string(),
|
||||
"(git log unavailable)".to_string(),
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -102,12 +105,17 @@ fn add_content_checks(
|
|||
}
|
||||
match extract_map_field(map_path, "next_action") {
|
||||
Ok(Some(_)) => findings.push(ok("state/map.yaml has current_status.next_action")),
|
||||
Ok(None) => findings.push(error("state/map.yaml is missing current_status.next_action")),
|
||||
Ok(None) => findings.push(error(
|
||||
"state/map.yaml is missing current_status.next_action",
|
||||
)),
|
||||
Err(err) => findings.push(error(format!("map next_action check failed: {err}"))),
|
||||
}
|
||||
match extract_active_subgoals(map_path) {
|
||||
Ok(subgoals) if !subgoals.is_empty() => {
|
||||
findings.push(ok(format!("state/map.yaml has {} active subgoal(s)", subgoals.len())));
|
||||
findings.push(ok(format!(
|
||||
"state/map.yaml has {} active subgoal(s)",
|
||||
subgoals.len()
|
||||
)));
|
||||
}
|
||||
Ok(_) => findings.push(warn("state/map.yaml has no active_subgoals entries")),
|
||||
Err(err) => findings.push(error(format!("active_subgoals check failed: {err}"))),
|
||||
|
|
@ -116,7 +124,9 @@ fn add_content_checks(
|
|||
Ok(Some(value)) if value == "No active scratch subgoal." => {
|
||||
findings.push(ok("state/scratch.md has no stale active scratch subgoal"));
|
||||
}
|
||||
Ok(Some(value)) => findings.push(warn(format!("state/scratch.md has active scratch subgoal: {value}"))),
|
||||
Ok(Some(value)) => findings.push(warn(format!(
|
||||
"state/scratch.md has active scratch subgoal: {value}"
|
||||
))),
|
||||
Ok(None) => findings.push(warn("state/scratch.md has no Current Subgoal value")),
|
||||
Err(err) => findings.push(error(format!("scratch check failed: {err}"))),
|
||||
}
|
||||
|
|
@ -131,7 +141,9 @@ fn add_content_checks(
|
|||
"state/ledgers.msgpack parses ({} evidence record(s))",
|
||||
entry.evidence.len()
|
||||
)));
|
||||
findings.push(ok(format!("state/ledgers.msgpack has {active} active branch(es)")));
|
||||
findings.push(ok(format!(
|
||||
"state/ledgers.msgpack has {active} active branch(es)"
|
||||
)));
|
||||
}
|
||||
Err(err) => findings.push(error(format!("state ledger parse failed: {err}"))),
|
||||
}
|
||||
|
|
@ -143,7 +155,9 @@ fn add_handoff_checks(findings: &mut Vec<Finding>, handoff_path: &Path) {
|
|||
return;
|
||||
};
|
||||
if text.contains("Current branch before") || text.contains("Current HEAD before") {
|
||||
findings.push(error("handoff embeds an exact branch or HEAD snapshot; use git commands instead"));
|
||||
findings.push(error(
|
||||
"handoff embeds an exact branch or HEAD snapshot; use git commands instead",
|
||||
));
|
||||
} else {
|
||||
findings.push(ok("handoff avoids exact branch/HEAD snapshots"));
|
||||
}
|
||||
|
|
@ -168,12 +182,19 @@ fn add_agents_checks(findings: &mut Vec<Finding>, agents_path: &Path) {
|
|||
if text.contains("epiphany-prepare-compaction") {
|
||||
findings.push(ok("AGENTS.md tells agents to use the compaction helper"));
|
||||
} else {
|
||||
findings.push(error("AGENTS.md does not mention epiphany-prepare-compaction"));
|
||||
findings.push(error(
|
||||
"AGENTS.md does not mention epiphany-prepare-compaction",
|
||||
));
|
||||
}
|
||||
if text.to_lowercase().contains("prepare for imminent compaction") {
|
||||
if text
|
||||
.to_lowercase()
|
||||
.contains("prepare for imminent compaction")
|
||||
{
|
||||
findings.push(ok("AGENTS.md names the imminent-compaction trigger"));
|
||||
} else {
|
||||
findings.push(warn("AGENTS.md does not name the imminent-compaction trigger phrase"));
|
||||
findings.push(warn(
|
||||
"AGENTS.md does not name the imminent-compaction trigger phrase",
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -185,9 +206,18 @@ fn render_report(
|
|||
log: &str,
|
||||
latest: Option<&EpiphanyLedgerEvidenceRecord>,
|
||||
) -> Result<String> {
|
||||
let ok_count = findings.iter().filter(|finding| finding.level == "ok").count();
|
||||
let warn_count = findings.iter().filter(|finding| finding.level == "warn").count();
|
||||
let error_count = findings.iter().filter(|finding| finding.level == "error").count();
|
||||
let ok_count = findings
|
||||
.iter()
|
||||
.filter(|finding| finding.level == "ok")
|
||||
.count();
|
||||
let warn_count = findings
|
||||
.iter()
|
||||
.filter(|finding| finding.level == "warn")
|
||||
.count();
|
||||
let error_count = findings
|
||||
.iter()
|
||||
.filter(|finding| finding.level == "error")
|
||||
.count();
|
||||
let mut lines = vec![
|
||||
"Epiphany pre-compaction persistence check".to_string(),
|
||||
format!("Workspace: {}", root.display()),
|
||||
|
|
@ -226,7 +256,11 @@ fn render_report(
|
|||
lines.push(String::new());
|
||||
lines.push("Findings:".to_string());
|
||||
for finding in findings {
|
||||
lines.push(format!("[{}] {}", finding.level.to_uppercase(), finding.message));
|
||||
lines.push(format!(
|
||||
"[{}] {}",
|
||||
finding.level.to_uppercase(),
|
||||
finding.message
|
||||
));
|
||||
}
|
||||
lines.extend([
|
||||
String::new(),
|
||||
|
|
@ -245,7 +279,11 @@ fn extract_map_field(path: &Path, name: &str) -> Result<Option<String>> {
|
|||
let prefix = format!(" {name}:");
|
||||
for line in fs::read_to_string(path)?.lines() {
|
||||
if line.starts_with(&prefix) {
|
||||
return Ok(Some(line.split_once(':').map(|(_, value)| value.trim().to_string()).unwrap_or_default()));
|
||||
return Ok(Some(
|
||||
line.split_once(':')
|
||||
.map(|(_, value)| value.trim().to_string())
|
||||
.unwrap_or_default(),
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ fn main() -> Result<()> {
|
|||
let branches = require_path_arg(&mut args, "--branches")?;
|
||||
let evidence = require_path_arg(&mut args, "--evidence")?;
|
||||
let store = require_path_arg(&mut args, "--store")?;
|
||||
print_json(&migrate_state_ledgers_to_cultcache(branches, evidence, store)?)?;
|
||||
print_json(&migrate_state_ledgers_to_cultcache(
|
||||
branches, evidence, store,
|
||||
)?)?;
|
||||
}
|
||||
"project-json" => {
|
||||
let store = require_path_arg(&mut args, "--store")?;
|
||||
|
|
@ -88,10 +90,14 @@ fn require_string_arg(args: &mut impl Iterator<Item = String>, name: &str) -> Re
|
|||
if flag != name {
|
||||
anyhow::bail!("expected {name}, got {flag}");
|
||||
}
|
||||
args.next().with_context(|| format!("missing value for {name}"))
|
||||
args.next()
|
||||
.with_context(|| format!("missing value for {name}"))
|
||||
}
|
||||
|
||||
fn optional_string_arg(args: &mut impl Iterator<Item = String>, name: &str) -> Result<Option<String>> {
|
||||
fn optional_string_arg(
|
||||
args: &mut impl Iterator<Item = String>,
|
||||
name: &str,
|
||||
) -> Result<Option<String>> {
|
||||
let remaining = args.collect::<Vec<_>>();
|
||||
let mut found = None;
|
||||
let mut index = 0;
|
||||
|
|
@ -106,7 +112,9 @@ fn optional_string_arg(args: &mut impl Iterator<Item = String>, name: &str) -> R
|
|||
Ok(found)
|
||||
}
|
||||
|
||||
fn collect_branch_tail(args: &mut impl Iterator<Item = String>) -> Result<(Vec<String>, Option<String>)> {
|
||||
fn collect_branch_tail(
|
||||
args: &mut impl Iterator<Item = String>,
|
||||
) -> Result<(Vec<String>, Option<String>)> {
|
||||
let remaining = args.collect::<Vec<_>>();
|
||||
let mut artifacts = Vec::new();
|
||||
let mut note = None;
|
||||
|
|
|
|||
|
|
@ -193,7 +193,11 @@ fn extract_map_field(path: &Path, name: &str) -> Result<Option<String>> {
|
|||
let prefix = format!(" {name}:");
|
||||
for line in fs::read_to_string(path)?.lines() {
|
||||
if line.starts_with(&prefix) {
|
||||
return Ok(Some(line.split_once(':').map(|(_, value)| value.trim().to_string()).unwrap_or_default()));
|
||||
return Ok(Some(
|
||||
line.split_once(':')
|
||||
.map(|(_, value)| value.trim().to_string())
|
||||
.unwrap_or_default(),
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
|
|
@ -233,5 +237,7 @@ fn parse_named_args(
|
|||
}
|
||||
|
||||
fn print_usage() {
|
||||
eprintln!("usage: epiphany-state <status|migrate-json|add-evidence|add-branch|close-branch> ...");
|
||||
eprintln!(
|
||||
"usage: epiphany-state <status|migrate-json|add-evidence|add-branch|close-branch> ..."
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,6 @@ mod retrieval;
|
|||
mod rollout;
|
||||
mod state_ledger;
|
||||
|
||||
pub use cultcache_rs::CacheBackingStore;
|
||||
pub use cultcache_rs::CultCache;
|
||||
pub use cultcache_rs::CultCacheEnvelope;
|
||||
pub use cultcache_rs::DatabaseEntry;
|
||||
pub use cultcache_rs::PushAllOptions;
|
||||
pub use cultcache_rs::SingleFileMessagePackBackingStore;
|
||||
pub use agent_memory::AgentMemoryReview;
|
||||
pub use agent_memory::AgentSelfPatch;
|
||||
pub use agent_memory::EpiphanyAgentMemoryEntry;
|
||||
|
|
@ -23,6 +17,12 @@ pub use agent_memory::migrate_agent_memory_json_dir_to_cultcache;
|
|||
pub use agent_memory::project_agent_memory_to_json_dir;
|
||||
pub use agent_memory::review_agent_self_patch;
|
||||
pub use agent_memory::validate_agent_memory_store;
|
||||
pub use cultcache_rs::CacheBackingStore;
|
||||
pub use cultcache_rs::CultCache;
|
||||
pub use cultcache_rs::CultCacheEnvelope;
|
||||
pub use cultcache_rs::DatabaseEntry;
|
||||
pub use cultcache_rs::PushAllOptions;
|
||||
pub use cultcache_rs::SingleFileMessagePackBackingStore;
|
||||
pub use distillation::EpiphanyDistillInput;
|
||||
pub use distillation::EpiphanyDistillProposal;
|
||||
pub use distillation::distill_observation;
|
||||
|
|
|
|||
|
|
@ -155,7 +155,11 @@ pub fn add_state_branch(
|
|||
.get::<EpiphanyStateLedgerEntry>(STATE_LEDGER_KEY)?
|
||||
.unwrap_or_else(default_state_ledger);
|
||||
validate_branch(&branch)?;
|
||||
if entry.branches.iter().any(|candidate| candidate.id == branch.id) {
|
||||
if entry
|
||||
.branches
|
||||
.iter()
|
||||
.any(|candidate| candidate.id == branch.id)
|
||||
{
|
||||
return Err(anyhow!("Branch {:?} already exists.", branch.id));
|
||||
}
|
||||
entry.branches.push(branch.clone());
|
||||
|
|
@ -258,7 +262,8 @@ fn default_state_ledger() -> EpiphanyStateLedgerEntry {
|
|||
}
|
||||
|
||||
fn read_evidence_jsonl(path: &Path) -> Result<Vec<EpiphanyLedgerEvidenceRecord>> {
|
||||
let raw = fs::read_to_string(path).with_context(|| format!("failed to read {}", path.display()))?;
|
||||
let raw =
|
||||
fs::read_to_string(path).with_context(|| format!("failed to read {}", path.display()))?;
|
||||
let mut records = Vec::new();
|
||||
for (index, line) in raw.lines().enumerate() {
|
||||
if line.trim().is_empty() {
|
||||
|
|
@ -266,8 +271,9 @@ fn read_evidence_jsonl(path: &Path) -> Result<Vec<EpiphanyLedgerEvidenceRecord>>
|
|||
}
|
||||
let record: EpiphanyLedgerEvidenceRecord = serde_json::from_str(line)
|
||||
.with_context(|| format!("failed to decode {} line {}", path.display(), index + 1))?;
|
||||
validate_evidence(&record)
|
||||
.with_context(|| format!("invalid evidence at {} line {}", path.display(), index + 1))?;
|
||||
validate_evidence(&record).with_context(|| {
|
||||
format!("invalid evidence at {} line {}", path.display(), index + 1)
|
||||
})?;
|
||||
records.push(record);
|
||||
}
|
||||
Ok(records)
|
||||
|
|
|
|||
|
|
@ -1512,7 +1512,7 @@ Current tests cover the landed flows at useful seams:
|
|||
- live app-server smoke for the first bounded reorient-launch runtime consumer plus CRRC coordinator recommendations in `tools/epiphany_phase6_reorient_launch_smoke.py`.
|
||||
- live app-server smoke for the first MVP operator status view in `tools/epiphany_mvp_status_smoke.py`.
|
||||
- focused app-server mapper coverage for `thread/epiphany/roles`, plus MVP status smoke coverage that consumes the roles surface.
|
||||
- focused app-server/protocol coverage for `thread/epiphany/roleLaunch`, `thread/epiphany/roleResult`, and `thread/epiphany/roleAccept`, plus live role smoke coverage that launches Imagination, modeling, and verification workers, reads completed results, accepts a reviewed Imagination planning patch and a reviewed modeling graph patch, proves durable planning grows without objective adoption, proves the durable graph grows before verification sees the expanded frontier, and proves a modeling `selfPatch` review is carried through result/accept. `tools/epiphany_agent_memory_smoke.py` validates the Ghostlight-shaped dossiers and accepted/refused/apply behavior for self-memory patches.
|
||||
- focused app-server/protocol coverage for `thread/epiphany/roleLaunch`, `thread/epiphany/roleResult`, and `thread/epiphany/roleAccept`, plus live role smoke coverage that launches Imagination, modeling, and verification workers, reads completed results, accepts a reviewed Imagination planning patch and a reviewed modeling graph patch, proves durable planning grows without objective adoption, proves the durable graph grows before verification sees the expanded frontier, and proves a modeling `selfPatch` review is carried through result/accept. Native `epiphany-agent-memory-store smoke` validates the Ghostlight-shaped dossiers and accepted/refused/apply behavior for self-memory patches.
|
||||
- live app-server smoke for the first Phase 6 job-control boundary in `tools/epiphany_phase6_job_control_smoke.py`.
|
||||
- live app-server smoke for explicit Phase 6 role launch/read-back in `tools/epiphany_phase6_role_smoke.py`.
|
||||
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ instead of posting.
|
|||
Use:
|
||||
|
||||
```powershell
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_agent_memory.py' validate
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_agent_memory.py' smoke
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_agent_memory.py' status
|
||||
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-agent-memory-store -- validate --store .\state\agents.msgpack
|
||||
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-agent-memory-store -- smoke --store .\state\agents.msgpack
|
||||
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-agent-memory-store -- status --store .\state\agents.msgpack
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_agent_heartbeat.py' tick --coordinator-action continueImplementation --urgency 0.95 --apply-rumination
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_agent_heartbeat.py' smoke
|
||||
cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-heartbeat-store -- smoke --agent-store .\state\agents.msgpack
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_face_discord.py' draft --content 'Face notices the organs are arguing about evidence again.'
|
||||
& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_face_discord.py' smoke
|
||||
```
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -208,8 +208,8 @@ landed_baseline:
|
|||
- Use `tools/epiphany_mvp_status_smoke.py` before modifying the MVP operator status view.
|
||||
- Use `tools/epiphany_mvp_coordinator_smoke.py` before modifying the fixed-lane MVP coordinator endpoint or runner.
|
||||
- Use `tools/epiphany_phase6_role_smoke.py` before modifying explicit role launch/read-back/acceptance behavior.
|
||||
- Use `tools/epiphany_agent_memory_smoke.py` before modifying role self-memory dossiers or `selfPatch` persistence policy.
|
||||
- Use `tools/epiphany_agent_heartbeat_smoke.py` before modifying heartbeat initiative timing, idle rumination, or role slot selection.
|
||||
- Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-agent-memory-store -- smoke --store .\state\agents.msgpack` before modifying role self-memory dossiers or `selfPatch` persistence policy.
|
||||
- Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-heartbeat-store -- smoke --agent-store .\state\agents.msgpack` before modifying heartbeat initiative timing, idle rumination, or role slot selection.
|
||||
- Use `tools/epiphany_face_discord_smoke.py` before modifying Face's #aquarium posting/draft guardrails.
|
||||
- Use `tools/epiphany_unity_bridge_smoke.py` before modifying the Unity editor/runtime bridge.
|
||||
- Use `tools/epiphany_rider_bridge_smoke.py` before modifying the Rider source-context bridge.
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
import epiphany_agent_heartbeat
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(epiphany_agent_heartbeat.main(["smoke"]))
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
import epiphany_agent_memory
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(epiphany_agent_memory.main(["smoke"]))
|
||||
Reference in a new issue