Grow typed swarm state surfaces
This commit is contained in:
parent
8c2b08b463
commit
d7b921015e
40 changed files with 20484 additions and 1080 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,11 +1,16 @@
|
|||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use epiphany_core::AgentMemoryLifecycleOperation;
|
||||
use epiphany_core::AgentSelfPatch;
|
||||
use epiphany_core::agent_memory_status;
|
||||
use epiphany_core::apply_agent_memory_lifecycle_operation;
|
||||
use epiphany_core::apply_agent_self_patch_document;
|
||||
use epiphany_core::migrate_agent_memory_json_dir_to_cultcache;
|
||||
use epiphany_core::project_agent_memory_to_json_dir;
|
||||
use epiphany_core::project_persona_state_for_role;
|
||||
use epiphany_core::refresh_agent_state_soa;
|
||||
use epiphany_core::repair_agent_memory_store;
|
||||
use epiphany_core::review_agent_memory_lifecycle_operation;
|
||||
use epiphany_core::review_agent_self_patch_document;
|
||||
use epiphany_core::validate_agent_memory_store;
|
||||
use std::env;
|
||||
|
|
@ -42,6 +47,19 @@ fn main() -> Result<()> {
|
|||
let store = require_path_arg(&mut args, "--store")?;
|
||||
print_json(&agent_memory_status(store)?)?;
|
||||
}
|
||||
"refresh-soa" => {
|
||||
let store = require_path_arg(&mut args, "--store")?;
|
||||
print_json(&refresh_agent_state_soa(store)?)?;
|
||||
}
|
||||
"repair" => {
|
||||
let store = require_path_arg(&mut args, "--store")?;
|
||||
let result = repair_agent_memory_store(store)?;
|
||||
let ok = result["ok"].as_bool().unwrap_or(false);
|
||||
print_json(&result)?;
|
||||
if !ok {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
"validate" => {
|
||||
let store = require_path_arg(&mut args, "--store")?;
|
||||
let errors = validate_agent_memory_store(&store)?;
|
||||
|
|
@ -71,6 +89,25 @@ fn main() -> Result<()> {
|
|||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
"review-lifecycle" => {
|
||||
let store = require_path_arg(&mut args, "--store")?;
|
||||
let role_id = require_string_arg(&mut args, "--role-id")?;
|
||||
let operation = read_lifecycle_arg(&require_string_arg(&mut args, "--operation")?)?;
|
||||
print_json(&review_agent_memory_lifecycle_operation(
|
||||
&role_id, &operation, store,
|
||||
))?;
|
||||
}
|
||||
"apply-lifecycle" => {
|
||||
let store = require_path_arg(&mut args, "--store")?;
|
||||
let role_id = require_string_arg(&mut args, "--role-id")?;
|
||||
let operation = read_lifecycle_arg(&require_string_arg(&mut args, "--operation")?)?;
|
||||
let result = apply_agent_memory_lifecycle_operation(&role_id, operation, store)?;
|
||||
let accepted = result.status == "accepted";
|
||||
print_json(&result)?;
|
||||
if !accepted {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
"smoke" => {
|
||||
let store = optional_path_arg(&mut args, "--store")?
|
||||
.unwrap_or_else(|| PathBuf::from("state/agents.msgpack"));
|
||||
|
|
@ -121,14 +158,33 @@ fn optional_path_arg(
|
|||
fn read_patch_arg(value: &str) -> Result<AgentSelfPatch> {
|
||||
let path = PathBuf::from(value);
|
||||
if path.exists() {
|
||||
let raw = fs::read_to_string(&path)
|
||||
.with_context(|| format!("failed to read patch {}", path.display()))?;
|
||||
let raw = read_json_file_lossless(&path, "patch")?;
|
||||
return serde_json::from_str(&raw)
|
||||
.with_context(|| format!("failed to decode typed selfPatch {}", path.display()));
|
||||
}
|
||||
serde_json::from_str(value).context("failed to decode typed selfPatch JSON")
|
||||
}
|
||||
|
||||
fn read_lifecycle_arg(value: &str) -> Result<AgentMemoryLifecycleOperation> {
|
||||
let path = PathBuf::from(value);
|
||||
if path.exists() {
|
||||
let raw = read_json_file_lossless(&path, "lifecycle operation")?;
|
||||
return serde_json::from_str(&raw).with_context(|| {
|
||||
format!(
|
||||
"failed to decode typed memory lifecycle operation {}",
|
||||
path.display()
|
||||
)
|
||||
});
|
||||
}
|
||||
serde_json::from_str(value).context("failed to decode typed memory lifecycle operation JSON")
|
||||
}
|
||||
|
||||
fn read_json_file_lossless(path: &Path, label: &str) -> Result<String> {
|
||||
let raw = fs::read_to_string(path)
|
||||
.with_context(|| format!("failed to read {label} {}", path.display()))?;
|
||||
Ok(raw.trim_start_matches('\u{feff}').to_string())
|
||||
}
|
||||
|
||||
fn print_json<T: serde::Serialize>(value: &T) -> Result<()> {
|
||||
println!("{}", serde_json::to_string_pretty(value)?);
|
||||
Ok(())
|
||||
|
|
@ -136,7 +192,7 @@ fn print_json<T: serde::Serialize>(value: &T) -> Result<()> {
|
|||
|
||||
fn print_usage() {
|
||||
eprintln!(
|
||||
"usage: epiphany-agent-memory-store <migrate-json-dir|project-json-dir|project-persona|status|validate|review-patch|apply-patch|smoke> ..."
|
||||
"usage: epiphany-agent-memory-store <migrate-json-dir|project-json-dir|project-persona|status|refresh-soa|repair|validate|review-patch|apply-patch|review-lifecycle|apply-lifecycle|smoke> ..."
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -184,6 +240,8 @@ fn run_smoke(store: &Path) -> Result<serde_json::Value> {
|
|||
)
|
||||
})?;
|
||||
let applied = apply_agent_self_patch_document("modeling", accepted_patch, &temp_store)?;
|
||||
let soa_refresh = refresh_agent_state_soa(&temp_store)?;
|
||||
let soa_status = agent_memory_status(&temp_store)?;
|
||||
let temp_validation_errors = validate_agent_memory_store(&temp_store)?;
|
||||
let _ = fs::remove_dir_all(&temp_dir);
|
||||
|
||||
|
|
@ -191,6 +249,8 @@ fn run_smoke(store: &Path) -> Result<serde_json::Value> {
|
|||
&& wrong_role.status == "rejected"
|
||||
&& forbidden.status == "rejected"
|
||||
&& applied.status == "accepted"
|
||||
&& soa_refresh["rowCount"] == 7
|
||||
&& soa_status["persistedAgentStateSoa"]["rowCount"] == 7
|
||||
&& temp_validation_errors.is_empty()
|
||||
&& project_persona_state_for_role(store, "Persona")?["schemaVersion"]
|
||||
== epiphany_core::PERSONA_STATE_SCHEMA_VERSION;
|
||||
|
|
@ -200,6 +260,8 @@ fn run_smoke(store: &Path) -> Result<serde_json::Value> {
|
|||
"wrongRole": wrong_role,
|
||||
"forbidden": forbidden,
|
||||
"applied": applied,
|
||||
"soaRefresh": soa_refresh,
|
||||
"soaStatus": soa_status["persistedAgentStateSoa"].clone(),
|
||||
"tempValidationErrors": temp_validation_errors,
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -743,7 +743,9 @@ fn mood_label(arousal: f64, guardedness: f64, curiosity: f64) -> &'static str {
|
|||
|
||||
fn reaction_recommended_use(role_id: &str, mode: &str) -> &'static str {
|
||||
match (role_id, mode) {
|
||||
("Persona", "draft") => "Prepare a reviewed Aquarium-facing draft; do not post automatically.",
|
||||
("Persona", "draft") => {
|
||||
"Prepare a reviewed Aquarium-facing draft; do not post automatically."
|
||||
}
|
||||
(_, "hold_and_verify") => "Bias toward verifier/modeler review before expression.",
|
||||
(_, "inspect") => {
|
||||
"Bias the next heartbeat toward a bounded retrieval or modeling inspection."
|
||||
|
|
|
|||
175
epiphany-core/src/bin/epiphany-cluster-daemon.rs
Normal file
175
epiphany-core/src/bin/epiphany-cluster-daemon.rs
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use chrono::Utc;
|
||||
use epiphany_core::EpiphanyCultMeshDaemonStatusEntry;
|
||||
use epiphany_core::query_epiphany_local_verse_context;
|
||||
use epiphany_core::seed_epiphany_local_verse_context;
|
||||
use epiphany_core::write_epiphany_cultmesh_daemon_status;
|
||||
use serde_json::json;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse()?;
|
||||
match args.command.as_str() {
|
||||
"heartbeat" | "status" | "once" => {
|
||||
let written = write_heartbeat(&args, 0)?;
|
||||
print_output(&args, "heartbeat", vec![written])
|
||||
}
|
||||
"serve" | "loop" | "daemon" => serve(args),
|
||||
other => anyhow::bail!("unknown command {other:?}; use heartbeat or serve"),
|
||||
}
|
||||
}
|
||||
|
||||
fn serve(args: Args) -> Result<()> {
|
||||
let mut written = Vec::new();
|
||||
let mut iteration = 0_u64;
|
||||
loop {
|
||||
written.push(write_heartbeat(&args, iteration)?);
|
||||
iteration = iteration.saturating_add(1);
|
||||
if args.max_iterations > 0 && iteration >= args.max_iterations {
|
||||
break;
|
||||
}
|
||||
thread::sleep(Duration::from_secs(args.interval_seconds));
|
||||
}
|
||||
print_output(&args, "serveComplete", written)
|
||||
}
|
||||
|
||||
fn write_heartbeat(args: &Args, iteration: u64) -> Result<EpiphanyCultMeshDaemonStatusEntry> {
|
||||
seed_epiphany_local_verse_context(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
Utc::now().to_rfc3339(),
|
||||
)?;
|
||||
let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?;
|
||||
let current = context
|
||||
.daemon_statuses
|
||||
.iter()
|
||||
.find(|status| status.daemon_id == args.daemon_id)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"local Verse has no daemon status row for {}",
|
||||
args.daemon_id
|
||||
)
|
||||
})?;
|
||||
let mut next = current.clone();
|
||||
next.status = args.daemon_status.clone();
|
||||
next.last_heartbeat_utc = Utc::now().to_rfc3339();
|
||||
next.operator_action = if next.status == "ready" {
|
||||
"none".to_string()
|
||||
} else {
|
||||
"pokeDaemon".to_string()
|
||||
};
|
||||
next.private_state_exposed = false;
|
||||
next.notes = vec![
|
||||
"Heartbeat published by epiphany-cluster-daemon; local Verse status is liveness projection, not private daemon memory.".to_string(),
|
||||
format!("Daemon body domain: {}", current.body_domain),
|
||||
format!("Heartbeat iteration: {iteration}"),
|
||||
];
|
||||
if let Some(note) = args.note.as_ref() {
|
||||
next.notes.push(note.clone());
|
||||
}
|
||||
write_epiphany_cultmesh_daemon_status(&args.store, args.runtime_id.clone(), next)
|
||||
}
|
||||
|
||||
fn print_output(
|
||||
args: &Args,
|
||||
status: &str,
|
||||
written: Vec<EpiphanyCultMeshDaemonStatusEntry>,
|
||||
) -> Result<()> {
|
||||
let latest = written
|
||||
.last()
|
||||
.context("cluster daemon wrote no heartbeat status")?;
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&json!({
|
||||
"schemaVersion": "epiphany.cluster_daemon_run.v0",
|
||||
"status": status,
|
||||
"store": args.store,
|
||||
"runtimeId": args.runtime_id,
|
||||
"daemonId": latest.daemon_id,
|
||||
"clusterId": latest.cluster_id,
|
||||
"daemonStatus": latest.status,
|
||||
"lastHeartbeatUtc": latest.last_heartbeat_utc,
|
||||
"heartbeatCount": written.len(),
|
||||
"intervalSeconds": args.interval_seconds,
|
||||
"maxIterations": args.max_iterations,
|
||||
"privateStateExposed": false,
|
||||
}))?
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
struct Args {
|
||||
command: String,
|
||||
store: PathBuf,
|
||||
runtime_id: String,
|
||||
daemon_id: String,
|
||||
daemon_status: String,
|
||||
interval_seconds: u64,
|
||||
max_iterations: u64,
|
||||
note: Option<String>,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
fn parse() -> Result<Self> {
|
||||
let mut values = env::args().skip(1);
|
||||
let command = values.next().unwrap_or_else(|| "heartbeat".to_string());
|
||||
let mut store = PathBuf::from(".epiphany-run/cultmesh/local-verse.ccmp");
|
||||
let mut runtime_id = "epiphany-local".to_string();
|
||||
let mut daemon_id = None;
|
||||
let mut daemon_status = "ready".to_string();
|
||||
let mut interval_seconds = 60_u64;
|
||||
let mut max_iterations = 1_u64;
|
||||
let mut note = None;
|
||||
|
||||
while let Some(arg) = values.next() {
|
||||
match arg.as_str() {
|
||||
"--store" => store = PathBuf::from(values.next().context("missing --store value")?),
|
||||
"--runtime-id" => {
|
||||
runtime_id = values.next().context("missing --runtime-id value")?
|
||||
}
|
||||
"--daemon-id" => {
|
||||
daemon_id = Some(values.next().context("missing --daemon-id value")?)
|
||||
}
|
||||
"--daemon-status" => {
|
||||
daemon_status = values.next().context("missing --daemon-status value")?
|
||||
}
|
||||
"--interval-seconds" => {
|
||||
interval_seconds = values
|
||||
.next()
|
||||
.context("missing --interval-seconds value")?
|
||||
.parse()?;
|
||||
}
|
||||
"--max-iterations" => {
|
||||
max_iterations = values
|
||||
.next()
|
||||
.context("missing --max-iterations value")?
|
||||
.parse()?;
|
||||
}
|
||||
"--note" => note = Some(values.next().context("missing --note value")?),
|
||||
other => anyhow::bail!("unknown argument {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(parent) = store.parent() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
}
|
||||
let daemon_id = daemon_id.context("cluster daemon requires --daemon-id")?;
|
||||
if !matches!(daemon_status.as_str(), "ready" | "degraded" | "down") {
|
||||
anyhow::bail!("--daemon-status must be ready, degraded, or down");
|
||||
}
|
||||
Ok(Self {
|
||||
command,
|
||||
store,
|
||||
runtime_id,
|
||||
daemon_id,
|
||||
daemon_status,
|
||||
interval_seconds,
|
||||
max_iterations,
|
||||
note,
|
||||
})
|
||||
}
|
||||
}
|
||||
3316
epiphany-core/src/bin/epiphany-daemon-supervisor.rs
Normal file
3316
epiphany-core/src/bin/epiphany-daemon-supervisor.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -6,17 +6,20 @@ use epiphany_core::hands_action_review_for_intent;
|
|||
use epiphany_core::hands_command_receipt_for_review;
|
||||
use epiphany_core::hands_commit_receipt_for_review;
|
||||
use epiphany_core::hands_patch_receipt_for_review;
|
||||
use epiphany_core::hands_pr_receipt_for_review;
|
||||
use epiphany_core::initialize_runtime_spine;
|
||||
use epiphany_core::put_hands_action_intent;
|
||||
use epiphany_core::put_hands_action_review;
|
||||
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::runtime_hands_action_intent;
|
||||
use epiphany_core::runtime_hands_action_review;
|
||||
use epiphany_core::runtime_hands_command_receipt;
|
||||
use epiphany_core::runtime_hands_commit_receipt;
|
||||
use epiphany_core::runtime_hands_patch_receipt;
|
||||
use epiphany_core::runtime_hands_pr_receipt;
|
||||
use serde_json::json;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
|
@ -54,7 +57,12 @@ fn main() -> Result<()> {
|
|||
"hands-review-smoke".to_string(),
|
||||
&intent,
|
||||
"approved".to_string(),
|
||||
vec!["patch".to_string()],
|
||||
vec![
|
||||
"patch".to_string(),
|
||||
"command".to_string(),
|
||||
"commit".to_string(),
|
||||
"pr".to_string(),
|
||||
],
|
||||
vec![
|
||||
"Substrate Gate grant id is named; this smoke does not execute the patch.".to_string(),
|
||||
],
|
||||
|
|
@ -97,6 +105,20 @@ fn main() -> Result<()> {
|
|||
);
|
||||
put_hands_commit_receipt(&store, &commit)?;
|
||||
|
||||
let pr = hands_pr_receipt_for_review(
|
||||
"hands-pr-smoke".to_string(),
|
||||
&intent,
|
||||
&review,
|
||||
&commit,
|
||||
"https://github.com/GameCult/EpiphanyAgent/pull/smoke".to_string(),
|
||||
"smoke".to_string(),
|
||||
"Smoke Hands PR publication receipt".to_string(),
|
||||
"bifrost-publication-receipt-smoke".to_string(),
|
||||
"Recorded a typed PR receipt shape for Bifrost-blessed GitHub publication.".to_string(),
|
||||
"2026-06-02T00:01:00Z".to_string(),
|
||||
);
|
||||
put_hands_pr_receipt(&store, &pr)?;
|
||||
|
||||
let stored_intent =
|
||||
runtime_hands_action_intent(&store, "hands-intent-smoke")?.expect("stored Hands intent");
|
||||
let stored_review =
|
||||
|
|
@ -107,6 +129,7 @@ fn main() -> Result<()> {
|
|||
.expect("stored Hands command");
|
||||
let stored_commit =
|
||||
runtime_hands_commit_receipt(&store, "hands-commit-smoke")?.expect("stored Hands commit");
|
||||
let stored_pr = runtime_hands_pr_receipt(&store, "hands-pr-smoke")?.expect("stored Hands PR");
|
||||
|
||||
if stored_review.intent_id != stored_intent.intent_id {
|
||||
anyhow::bail!("Hands review lost its intent edge");
|
||||
|
|
@ -126,6 +149,12 @@ fn main() -> Result<()> {
|
|||
{
|
||||
anyhow::bail!("Hands commit receipt lost its intent/review edge");
|
||||
}
|
||||
if stored_pr.intent_id != stored_intent.intent_id
|
||||
|| stored_pr.review_id != stored_review.review_id
|
||||
|| stored_pr.commit_receipt_id != stored_commit.receipt_id
|
||||
{
|
||||
anyhow::bail!("Hands PR receipt lost its intent/review/commit edge");
|
||||
}
|
||||
|
||||
println!(
|
||||
"{}",
|
||||
|
|
@ -137,6 +166,8 @@ fn main() -> Result<()> {
|
|||
"patchReceiptId": stored_patch.receipt_id,
|
||||
"commandReceiptId": stored_command.receipt_id,
|
||||
"commitReceiptId": stored_commit.receipt_id,
|
||||
"prReceiptId": stored_pr.receipt_id,
|
||||
"bifrostPublicationReceiptId": stored_pr.bifrost_publication_receipt_id,
|
||||
"changedPaths": stored_patch.changed_paths,
|
||||
}))?
|
||||
);
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@ use epiphany_core::HandsActionReview;
|
|||
use epiphany_core::hands_command_receipt_for_review;
|
||||
use epiphany_core::hands_commit_receipt_for_review;
|
||||
use epiphany_core::hands_patch_receipt_for_review;
|
||||
use epiphany_core::hands_pr_receipt_for_review;
|
||||
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::runtime_hands_action_intent;
|
||||
use epiphany_core::runtime_hands_action_review;
|
||||
use epiphany_core::runtime_hands_commit_receipt;
|
||||
use serde_json::json;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
|
|
@ -25,6 +28,7 @@ fn main() -> Result<()> {
|
|||
Command::RecordPatch(command) => record_patch(&args.store, command)?,
|
||||
Command::RecordCommand(command) => record_command(&args.store, command)?,
|
||||
Command::RecordCommit(command) => record_commit(&args.store, command)?,
|
||||
Command::RecordPr(command) => record_pr(&args.store, command)?,
|
||||
Command::RecordPass(command) => record_pass(&args.store, command)?,
|
||||
};
|
||||
println!("{}", serde_json::to_string_pretty(&output)?);
|
||||
|
|
@ -42,6 +46,7 @@ enum Command {
|
|||
RecordPatch(RecordPatchArgs),
|
||||
RecordCommand(RecordCommandArgs),
|
||||
RecordCommit(RecordCommitArgs),
|
||||
RecordPr(RecordPrArgs),
|
||||
RecordPass(RecordPassArgs),
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +83,16 @@ struct RecordCommitArgs {
|
|||
validate_commit_sha: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct RecordPrArgs {
|
||||
gate: GateArgs,
|
||||
commit_receipt_id: String,
|
||||
pull_request_url: String,
|
||||
pull_request_number: String,
|
||||
pull_request_title: String,
|
||||
bifrost_publication_receipt_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct RecordPassArgs {
|
||||
gate: GateArgs,
|
||||
|
|
@ -104,6 +119,7 @@ impl Args {
|
|||
"record-patch" => Command::RecordPatch(parse_record_patch(tokens)?),
|
||||
"record-command" => Command::RecordCommand(parse_record_command(tokens)?),
|
||||
"record-commit" => Command::RecordCommit(parse_record_commit(tokens)?),
|
||||
"record-pr" => Command::RecordPr(parse_record_pr(tokens)?),
|
||||
"record-pass" => Command::RecordPass(parse_record_pass(tokens)?),
|
||||
_ => return Err(anyhow!("unknown command {command_name}\n{}", usage())),
|
||||
};
|
||||
|
|
@ -163,6 +179,26 @@ fn parse_record_commit(tokens: impl Iterator<Item = String>) -> Result<RecordCom
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_record_pr(tokens: impl Iterator<Item = String>) -> Result<RecordPrArgs> {
|
||||
let mut options = ParsedOptions::parse(tokens)?;
|
||||
let gate = options.take_gate()?;
|
||||
let commit_receipt_id = options.take_required("--commit-receipt-id")?;
|
||||
let pull_request_url = options.take_required("--pull-request-url")?;
|
||||
let pull_request_number = options.take_required("--pull-request-number")?;
|
||||
let pull_request_title = options.take_required("--pull-request-title")?;
|
||||
let bifrost_publication_receipt_id =
|
||||
options.take_required("--bifrost-publication-receipt-id")?;
|
||||
options.finish()?;
|
||||
Ok(RecordPrArgs {
|
||||
gate,
|
||||
commit_receipt_id,
|
||||
pull_request_url,
|
||||
pull_request_number,
|
||||
pull_request_title,
|
||||
bifrost_publication_receipt_id,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_record_pass(tokens: impl Iterator<Item = String>) -> Result<RecordPassArgs> {
|
||||
let mut options = ParsedOptions::parse(tokens)?;
|
||||
let gate = options.take_gate()?;
|
||||
|
|
@ -362,6 +398,60 @@ fn record_commit(store: &PathBuf, args: RecordCommitArgs) -> Result<serde_json::
|
|||
}))
|
||||
}
|
||||
|
||||
fn record_pr(store: &PathBuf, args: RecordPrArgs) -> Result<serde_json::Value> {
|
||||
let (intent, review) = load_gate(store, &args.gate, "pr")?;
|
||||
let commit_receipt =
|
||||
runtime_hands_commit_receipt(store, &args.commit_receipt_id)?.ok_or_else(|| {
|
||||
anyhow!(
|
||||
"Hands commit receipt {} was not found",
|
||||
args.commit_receipt_id
|
||||
)
|
||||
})?;
|
||||
if commit_receipt.intent_id != intent.intent_id || commit_receipt.review_id != review.review_id
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"Hands commit receipt {} belongs to intent {}/review {}, not {}/{}",
|
||||
commit_receipt.receipt_id,
|
||||
commit_receipt.intent_id,
|
||||
commit_receipt.review_id,
|
||||
intent.intent_id,
|
||||
review.review_id
|
||||
));
|
||||
}
|
||||
let receipt_id = args
|
||||
.gate
|
||||
.receipt_id
|
||||
.unwrap_or_else(|| generated_receipt_id("hands-pr"));
|
||||
let receipt = hands_pr_receipt_for_review(
|
||||
receipt_id,
|
||||
&intent,
|
||||
&review,
|
||||
&commit_receipt,
|
||||
args.pull_request_url,
|
||||
args.pull_request_number,
|
||||
args.pull_request_title,
|
||||
args.bifrost_publication_receipt_id,
|
||||
args.gate.summary,
|
||||
now(),
|
||||
);
|
||||
put_hands_pr_receipt(store, &receipt)?;
|
||||
Ok(json!({
|
||||
"status": "ok",
|
||||
"type": "epiphany.hands.pr_receipt",
|
||||
"receiptId": receipt.receipt_id,
|
||||
"intentId": receipt.intent_id,
|
||||
"reviewId": receipt.review_id,
|
||||
"commitReceiptId": receipt.commit_receipt_id,
|
||||
"commitSha": receipt.commit_sha,
|
||||
"branch": receipt.branch,
|
||||
"pullRequestUrl": receipt.pull_request_url,
|
||||
"pullRequestNumber": receipt.pull_request_number,
|
||||
"bifrostPublicationReceiptId": receipt.bifrost_publication_receipt_id,
|
||||
"changedPaths": receipt.changed_paths,
|
||||
"store": store,
|
||||
}))
|
||||
}
|
||||
|
||||
fn record_pass(store: &PathBuf, args: RecordPassArgs) -> Result<serde_json::Value> {
|
||||
let patch = record_patch(
|
||||
store,
|
||||
|
|
@ -570,7 +660,7 @@ fn take_value(tokens: &mut impl Iterator<Item = String>, name: &str) -> Result<S
|
|||
}
|
||||
|
||||
fn usage() -> &'static str {
|
||||
"usage: epiphany-hands-action [--store path] <record-patch|record-command|record-commit|record-pass> (--gate-summary path | --intent-id id --review-id id) --summary text ..."
|
||||
"usage: epiphany-hands-action [--store path] <record-patch|record-command|record-commit|record-pr|record-pass> (--gate-summary path | --intent-id id --review-id id) --summary text ..."
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
@ -585,6 +675,7 @@ mod tests {
|
|||
use epiphany_core::runtime_hands_command_receipt;
|
||||
use epiphany_core::runtime_hands_commit_receipt;
|
||||
use epiphany_core::runtime_hands_patch_receipt;
|
||||
use epiphany_core::runtime_hands_pr_receipt;
|
||||
use epiphany_core::runtime_latest_hands_receipt_chain_after;
|
||||
|
||||
#[test]
|
||||
|
|
@ -682,16 +773,18 @@ mod tests {
|
|||
assert!(runtime_hands_command_receipt(&store, command_id)?.is_some());
|
||||
assert!(runtime_hands_commit_receipt(&store, commit_id)?.is_some());
|
||||
|
||||
let chain =
|
||||
runtime_latest_hands_receipt_chain_after(&store, "2026-06-02T00:00:02Z")?
|
||||
.expect("record-pass should produce a complete Hands receipt chain");
|
||||
let chain = runtime_latest_hands_receipt_chain_after(&store, "2026-06-02T00:00:02Z")?
|
||||
.expect("record-pass should produce a complete Hands receipt chain");
|
||||
assert_eq!(chain.patch_receipt_id, patch_id);
|
||||
assert_eq!(chain.command_receipt_id, command_id);
|
||||
assert_eq!(chain.commit_receipt_id, commit_id);
|
||||
assert_eq!(chain.intent_id, "hands-intent-test");
|
||||
assert_eq!(chain.review_id, "hands-review-test");
|
||||
assert_eq!(chain.runtime_job_id, "hands-job-test");
|
||||
assert_eq!(chain.substrate_gate_grant_receipt_id, "substrate-grant-test");
|
||||
assert_eq!(
|
||||
chain.substrate_gate_grant_receipt_id,
|
||||
"substrate-grant-test"
|
||||
);
|
||||
assert_eq!(chain.command, "cargo test");
|
||||
assert_eq!(chain.exit_code, "0");
|
||||
assert_eq!(chain.commit_sha, "def456");
|
||||
|
|
@ -722,6 +815,96 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn records_pr_receipt_against_commit_and_bifrost_publication() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("runtime-spine.msgpack");
|
||||
seed_gate(&store, vec!["src".to_string()])?;
|
||||
record_commit(
|
||||
&store,
|
||||
RecordCommitArgs {
|
||||
gate: gate_args("hands-commit-test"),
|
||||
commit_sha: "abc123".to_string(),
|
||||
branch: "codex/test".to_string(),
|
||||
changed_paths: vec!["src/lib.rs".to_string()],
|
||||
validate_commit_sha: false,
|
||||
},
|
||||
)?;
|
||||
|
||||
let result = record_pr(
|
||||
&store,
|
||||
RecordPrArgs {
|
||||
gate: gate_args("hands-pr-test"),
|
||||
commit_receipt_id: "hands-commit-test".to_string(),
|
||||
pull_request_url: "https://github.com/GameCult/EpiphanyAgent/pull/1".to_string(),
|
||||
pull_request_number: "1".to_string(),
|
||||
pull_request_title: "Route Bifrost publication proof".to_string(),
|
||||
bifrost_publication_receipt_id: "bifrost-publication-receipt-test".to_string(),
|
||||
},
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
result
|
||||
.pointer("/bifrostPublicationReceiptId")
|
||||
.and_then(serde_json::Value::as_str),
|
||||
Some("bifrost-publication-receipt-test")
|
||||
);
|
||||
let receipt =
|
||||
runtime_hands_pr_receipt(&store, "hands-pr-test")?.expect("stored Hands PR receipt");
|
||||
assert_eq!(receipt.commit_receipt_id, "hands-commit-test");
|
||||
assert_eq!(receipt.commit_sha, "abc123");
|
||||
assert_eq!(
|
||||
receipt.pull_request_url,
|
||||
"https://github.com/GameCult/EpiphanyAgent/pull/1"
|
||||
);
|
||||
assert_eq!(
|
||||
receipt.bifrost_publication_receipt_id,
|
||||
"bifrost-publication-receipt-test"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn refuses_pr_receipt_when_review_does_not_allow_publication() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("runtime-spine.msgpack");
|
||||
seed_gate_with_operations(
|
||||
&store,
|
||||
vec!["src".to_string()],
|
||||
vec![
|
||||
"patch".to_string(),
|
||||
"command".to_string(),
|
||||
"commit".to_string(),
|
||||
],
|
||||
)?;
|
||||
record_commit(
|
||||
&store,
|
||||
RecordCommitArgs {
|
||||
gate: gate_args("hands-commit-test"),
|
||||
commit_sha: "abc123".to_string(),
|
||||
branch: "codex/test".to_string(),
|
||||
changed_paths: vec!["src/lib.rs".to_string()],
|
||||
validate_commit_sha: false,
|
||||
},
|
||||
)?;
|
||||
|
||||
let result = record_pr(
|
||||
&store,
|
||||
RecordPrArgs {
|
||||
gate: gate_args("hands-pr-test"),
|
||||
commit_receipt_id: "hands-commit-test".to_string(),
|
||||
pull_request_url: "https://github.com/GameCult/EpiphanyAgent/pull/1".to_string(),
|
||||
pull_request_number: "1".to_string(),
|
||||
pull_request_title: "Route Bifrost publication proof".to_string(),
|
||||
bifrost_publication_receipt_id: "bifrost-publication-receipt-test".to_string(),
|
||||
},
|
||||
);
|
||||
|
||||
assert!(result.is_err());
|
||||
assert!(runtime_hands_pr_receipt(&store, "hands-pr-test")?.is_none());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn refuses_patch_receipt_outside_requested_paths() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
|
|
@ -769,6 +952,7 @@ mod tests {
|
|||
"patch".to_string(),
|
||||
"command".to_string(),
|
||||
"commit".to_string(),
|
||||
"pr".to_string(),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use epiphany_core::HeartbeatCompleteOptions;
|
|||
use epiphany_core::HeartbeatHeatUpdateOptions;
|
||||
use epiphany_core::HeartbeatPumpOptions;
|
||||
use epiphany_core::HeartbeatQueueMentionOptions;
|
||||
use epiphany_core::HeartbeatStaleTurnRepairOptions;
|
||||
use epiphany_core::HeartbeatTickOptions;
|
||||
use epiphany_core::VoidRoutineOptions;
|
||||
use epiphany_core::apply_agent_self_patch_document;
|
||||
|
|
@ -13,9 +14,11 @@ use epiphany_core::complete_heartbeat_store;
|
|||
use epiphany_core::heartbeat_status_projection;
|
||||
use epiphany_core::initialize_ghostlight_scene_heartbeat_store;
|
||||
use epiphany_core::initialize_heartbeat_store;
|
||||
use epiphany_core::load_epiphany_cultmesh_swarm_brake;
|
||||
use epiphany_core::load_heartbeat_state_entry;
|
||||
use epiphany_core::pump_heartbeat_store;
|
||||
use epiphany_core::queue_heartbeat_pending_mention_store;
|
||||
use epiphany_core::recover_stale_heartbeat_store;
|
||||
use epiphany_core::run_void_routine_store;
|
||||
use epiphany_core::tick_heartbeat_store;
|
||||
use epiphany_core::update_heartbeat_heat_store;
|
||||
|
|
@ -33,6 +36,7 @@ fn main() -> Result<()> {
|
|||
};
|
||||
let mut store_path: Option<PathBuf> = None;
|
||||
let mut artifact_dir: Option<PathBuf> = None;
|
||||
let mut local_verse_store: Option<PathBuf> = None;
|
||||
let mut target_heartbeat_rate = 1.0_f64;
|
||||
let mut min_heartbeat_rate = 0.05_f64;
|
||||
let mut max_heartbeat_rate = 4.0_f64;
|
||||
|
|
@ -73,11 +77,16 @@ fn main() -> Result<()> {
|
|||
let mut reply_to_message_id: Option<String> = None;
|
||||
let mut source_surface = "operator".to_string();
|
||||
let mut mention_id: Option<String> = None;
|
||||
let mut max_age_seconds = 1800_i64;
|
||||
let mut now_utc: Option<String> = None;
|
||||
|
||||
while let Some(arg) = args.next() {
|
||||
match arg.as_str() {
|
||||
"--store" => store_path = Some(next_path(&mut args, "--store")?),
|
||||
"--artifact-dir" => artifact_dir = Some(next_path(&mut args, "--artifact-dir")?),
|
||||
"--local-verse-store" => {
|
||||
local_verse_store = Some(next_path(&mut args, "--local-verse-store")?)
|
||||
}
|
||||
"--target-heartbeat-rate" => {
|
||||
target_heartbeat_rate = next_value(&mut args, "--target-heartbeat-rate")?.parse()?
|
||||
}
|
||||
|
|
@ -138,6 +147,10 @@ fn main() -> Result<()> {
|
|||
}
|
||||
"--source-surface" => source_surface = next_value(&mut args, "--source-surface")?,
|
||||
"--mention-id" => mention_id = Some(next_value(&mut args, "--mention-id")?),
|
||||
"--max-age-seconds" => {
|
||||
max_age_seconds = next_value(&mut args, "--max-age-seconds")?.parse()?
|
||||
}
|
||||
"--now-utc" => now_utc = Some(next_value(&mut args, "--now-utc")?),
|
||||
_ => return Err(anyhow!("unknown argument {arg:?}")),
|
||||
}
|
||||
}
|
||||
|
|
@ -169,6 +182,7 @@ fn main() -> Result<()> {
|
|||
);
|
||||
}
|
||||
"tick" => {
|
||||
assert_swarm_brake_allows_heartbeat(&local_verse_store, "tick")?;
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("tick requires --store"))?;
|
||||
let artifact_dir =
|
||||
artifact_dir.ok_or_else(|| anyhow!("tick requires --artifact-dir"))?;
|
||||
|
|
@ -216,7 +230,25 @@ fn main() -> Result<()> {
|
|||
)?;
|
||||
println!("{}", result);
|
||||
}
|
||||
"repair-stale" => {
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("repair-stale requires --store"))?;
|
||||
let artifact_dir =
|
||||
artifact_dir.ok_or_else(|| anyhow!("repair-stale requires --artifact-dir"))?;
|
||||
let result = recover_stale_heartbeat_store(
|
||||
&store_path,
|
||||
&artifact_dir,
|
||||
HeartbeatStaleTurnRepairOptions {
|
||||
max_age_seconds,
|
||||
now_utc,
|
||||
reason: heat_reason.unwrap_or_else(|| {
|
||||
"Operator requested stale heartbeat turn recovery.".to_string()
|
||||
}),
|
||||
},
|
||||
)?;
|
||||
println!("{}", result);
|
||||
}
|
||||
"pump" => {
|
||||
assert_swarm_brake_allows_heartbeat(&local_verse_store, "pump")?;
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("pump requires --store"))?;
|
||||
let artifact_dir =
|
||||
artifact_dir.ok_or_else(|| anyhow!("pump requires --artifact-dir"))?;
|
||||
|
|
@ -250,6 +282,7 @@ fn main() -> Result<()> {
|
|||
println!("{}", result);
|
||||
}
|
||||
"heat" => {
|
||||
assert_swarm_brake_allows_heartbeat(&local_verse_store, "heat")?;
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("heat requires --store"))?;
|
||||
let result = update_heartbeat_heat_store(
|
||||
&store_path,
|
||||
|
|
@ -267,6 +300,7 @@ fn main() -> Result<()> {
|
|||
println!("{}", result);
|
||||
}
|
||||
"queue-mention" => {
|
||||
assert_swarm_brake_allows_heartbeat(&local_verse_store, "queue-mention")?;
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("queue-mention requires --store"))?;
|
||||
let target_role_id = role.unwrap_or_else(|| "Persona".to_string());
|
||||
let result = queue_heartbeat_pending_mention_store(
|
||||
|
|
@ -320,6 +354,7 @@ fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
"routine" => {
|
||||
assert_swarm_brake_allows_heartbeat(&local_verse_store, "routine")?;
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("routine requires --store"))?;
|
||||
let artifact_dir =
|
||||
artifact_dir.ok_or_else(|| anyhow!("routine requires --artifact-dir"))?;
|
||||
|
|
@ -369,10 +404,36 @@ 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> [--profile epiphany|ghostlight-scene] [--scene-id <id>] [--scene-participant <id|name|speed|reaction|threshold|constraint;constraint>]\n epiphany-heartbeat-store tick --store <path> --artifact-dir <path> [--coordinator-action <action>] [--agent-store <path> --apply-rumination] [--defer-completion]\n epiphany-heartbeat-store pump --store <path> --artifact-dir <path> [--agent-store <path>] [--urgency <0..1>] [--min-heartbeat-rate <n>] [--max-heartbeat-rate <n>] [--min-concurrency <n>] [--max-concurrency <n>] [--max-ticks <n>]\n epiphany-heartbeat-store heat --store <path> [--scope global|all|agent|role|arena|participant_kind|group] [--selector <id>] [--multiplier <n>] [--id <id>] [--label <text>] [--reason <text>] [--expires-after <scene-clock-delta>] [--clear]\n epiphany-heartbeat-store complete --store <path> --artifact-dir <path> --role <role> [--action-id <id>]\n epiphany-heartbeat-store queue-mention --store <path> [--role Persona] --channel-id <id> --message-id <id> --author-id <id> --content <text> --visible-prompt <text> [--author-name <name>] [--reply-to-message-id <id>] [--source-surface <name>]\n epiphany-heartbeat-store status --store <path> [--artifact-dir <path>]\n epiphany-heartbeat-store routine --store <path> --artifact-dir <path> [--agent-store <path>] [--source <source>] [--no-dream]\n epiphany-heartbeat-store smoke [--agent-store <path>]"
|
||||
"usage: epiphany-heartbeat-store init --store <path> [--profile epiphany|ghostlight-scene] [--scene-id <id>] [--scene-participant <id|name|speed|reaction|threshold|constraint;constraint>]\n epiphany-heartbeat-store tick --store <path> --artifact-dir <path> [--local-verse-store <path>] [--coordinator-action <action>] [--agent-store <path> --apply-rumination] [--defer-completion]\n epiphany-heartbeat-store pump --store <path> --artifact-dir <path> [--local-verse-store <path>] [--agent-store <path>] [--urgency <0..1>] [--min-heartbeat-rate <n>] [--max-heartbeat-rate <n>] [--min-concurrency <n>] [--max-concurrency <n>] [--max-ticks <n>]\n epiphany-heartbeat-store heat --store <path> [--local-verse-store <path>] [--scope global|all|agent|role|arena|participant_kind|group] [--selector <id>] [--multiplier <n>] [--id <id>] [--label <text>] [--reason <text>] [--expires-after <scene-clock-delta>] [--clear]\n epiphany-heartbeat-store complete --store <path> --artifact-dir <path> --role <role> [--action-id <id>]\n epiphany-heartbeat-store repair-stale --store <path> --artifact-dir <path> [--max-age-seconds <n>] [--reason <text>] [--now-utc <rfc3339>]\n epiphany-heartbeat-store queue-mention --store <path> [--local-verse-store <path>] [--role Persona] --channel-id <id> --message-id <id> --author-id <id> --content <text> --visible-prompt <text> [--author-name <name>] [--reply-to-message-id <id>] [--source-surface <name>]\n epiphany-heartbeat-store status --store <path> [--artifact-dir <path>]\n epiphany-heartbeat-store routine --store <path> --artifact-dir <path> [--local-verse-store <path>] [--agent-store <path>] [--source <source>] [--no-dream]\n epiphany-heartbeat-store smoke [--agent-store <path>]"
|
||||
))
|
||||
}
|
||||
|
||||
fn assert_swarm_brake_allows_heartbeat(
|
||||
local_verse_store: &Option<PathBuf>,
|
||||
command: &str,
|
||||
) -> Result<()> {
|
||||
let Some(local_verse_store) = local_verse_store else {
|
||||
return Ok(());
|
||||
};
|
||||
if !local_verse_store.exists() {
|
||||
return Ok(());
|
||||
}
|
||||
let Some(brake) = load_epiphany_cultmesh_swarm_brake(local_verse_store, "epiphany-local")?
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
if brake.status == "engaged" {
|
||||
anyhow::bail!(
|
||||
"epiphany-heartbeat-store {command} refusing to run: local Verse swarm brake engaged; scope={}; protected={}; affected={}; reason={}",
|
||||
brake.scope,
|
||||
brake.protected_surfaces.join(","),
|
||||
brake.affected_clusters.join(","),
|
||||
brake.reason
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_scene_participant(raw: &str) -> Result<GhostlightSceneParticipantSeed> {
|
||||
let parts = raw.split('|').collect::<Vec<_>>();
|
||||
if parts.len() != 6 {
|
||||
|
|
@ -557,6 +618,45 @@ fn run_smoke(agent_store: &Path) -> Result<serde_json::Value> {
|
|||
agent_store: Some(temp_agent_store.clone()),
|
||||
},
|
||||
)?;
|
||||
let stale_store_path = temp_dir.join("stale-heartbeats.msgpack");
|
||||
initialize_heartbeat_store(&stale_store_path, 1.0)?;
|
||||
let stale_work = tick_heartbeat_store(
|
||||
&stale_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-stale-work".to_string(),
|
||||
source_scene_ref: "smoke/stale".to_string(),
|
||||
defer_completion: true,
|
||||
agent_store: Some(temp_agent_store.clone()),
|
||||
},
|
||||
)?;
|
||||
let stale_repair = recover_stale_heartbeat_store(
|
||||
&stale_store_path,
|
||||
&artifact_dir,
|
||||
HeartbeatStaleTurnRepairOptions {
|
||||
max_age_seconds: 0,
|
||||
now_utc: None,
|
||||
reason: "Smoke-test stale heartbeat recovery receipt.".to_string(),
|
||||
},
|
||||
)?;
|
||||
let after_stale_repair = tick_heartbeat_store(
|
||||
&stale_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-after-stale-repair".to_string(),
|
||||
source_scene_ref: "smoke/stale".to_string(),
|
||||
defer_completion: true,
|
||||
agent_store: Some(temp_agent_store.clone()),
|
||||
},
|
||||
)?;
|
||||
let initiative_errors = validate_schedule_shape(&work["schedule"])
|
||||
.into_iter()
|
||||
.chain(validate_schedule_shape(&idle["schedule"]))
|
||||
|
|
@ -594,7 +694,7 @@ fn run_smoke(agent_store: &Path) -> Result<serde_json::Value> {
|
|||
&& 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)
|
||||
&& status["participants"].as_array().map(Vec::len) == Some(7)
|
||||
&& routine["routine"]["schema_version"] == "epiphany.void_routine.v0"
|
||||
&& routine["routine"]["memoryResonance"]["schema_version"]
|
||||
== "epiphany.memory_resonance.v0"
|
||||
|
|
@ -665,8 +765,16 @@ fn run_smoke(agent_store: &Path) -> Result<serde_json::Value> {
|
|||
let ok = ok
|
||||
&& relaxed_pump["pump"]["launched"].as_u64() == Some(0)
|
||||
&& relaxed_pump["pump"]["pacing"]["targetConcurrency"].as_u64() == Some(0)
|
||||
&& alarmed_pump["pump"]["launched"].as_u64().unwrap_or(0) >= 6
|
||||
&& alarmed_pump["pump"]["pacing"]["targetConcurrency"].as_u64() == Some(8);
|
||||
&& alarmed_pump["pump"]["launched"].as_u64() == Some(7)
|
||||
&& alarmed_pump["pump"]["pacing"]["targetConcurrency"].as_u64() == Some(7)
|
||||
&& stale_work["event"]["turnStatus"] == "running"
|
||||
&& stale_repair["repaired"].as_u64() == Some(1)
|
||||
&& stale_repair["receipts"]
|
||||
.as_array()
|
||||
.and_then(|receipts| receipts.first())
|
||||
.is_some_and(|receipt| receipt[10] == "repaired" && receipt[12] == false)
|
||||
&& after_stale_repair["event"]["selectedRole"] == stale_work["event"]["selectedRole"]
|
||||
&& after_stale_repair["event"]["turnStatus"] == "running";
|
||||
|
||||
let result = serde_json::json!({
|
||||
"ok": ok,
|
||||
|
|
@ -680,6 +788,8 @@ fn run_smoke(agent_store: &Path) -> Result<serde_json::Value> {
|
|||
"personalityTiming": routine_status["participants"],
|
||||
"relaxedPump": relaxed_pump["pump"],
|
||||
"alarmedPump": alarmed_pump["pump"],
|
||||
"staleRepair": stale_repair,
|
||||
"afterStaleRepairEvent": after_stale_repair["event"],
|
||||
"validationErrors": validation_errors,
|
||||
"initiativeErrors": initiative_errors,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use epiphany_core::append_runtime_event;
|
|||
use epiphany_core::create_runtime_session;
|
||||
use epiphany_core::hands_action_review_for_intent;
|
||||
use epiphany_core::initialize_runtime_spine;
|
||||
use epiphany_core::load_epiphany_cultmesh_swarm_brake;
|
||||
use epiphany_core::put_coordinator_run_receipt;
|
||||
use epiphany_core::put_hands_action_intent;
|
||||
use epiphany_core::put_hands_action_review;
|
||||
|
|
@ -76,6 +77,7 @@ struct Args {
|
|||
artifact_dir: PathBuf,
|
||||
agent_memory_dir: PathBuf,
|
||||
runtime_store: PathBuf,
|
||||
local_verse_store: PathBuf,
|
||||
mode: String,
|
||||
max_steps: usize,
|
||||
poll_seconds: f64,
|
||||
|
|
@ -111,6 +113,10 @@ impl Args {
|
|||
artifact_dir: root.join(".epiphany-dogfood").join("coordinator"),
|
||||
agent_memory_dir: root.join("state").join("agents.msgpack"),
|
||||
runtime_store: root.join("state").join("runtime-spine.msgpack"),
|
||||
local_verse_store: root
|
||||
.join(".epiphany-run")
|
||||
.join("cultmesh")
|
||||
.join("local-verse.ccmp"),
|
||||
mode: "plan".to_string(),
|
||||
max_steps: 4,
|
||||
poll_seconds: 5.0,
|
||||
|
|
@ -153,6 +159,9 @@ impl Args {
|
|||
"--runtime-store" => {
|
||||
parsed.runtime_store = take_path(&mut args, "--runtime-store")?
|
||||
}
|
||||
"--local-verse-store" => {
|
||||
parsed.local_verse_store = take_path(&mut args, "--local-verse-store")?
|
||||
}
|
||||
"--mode" => parsed.mode = take_string(&mut args, "--mode")?,
|
||||
"--max-steps" => {
|
||||
parsed.max_steps = take_string(&mut args, "--max-steps")?.parse()?
|
||||
|
|
@ -200,6 +209,8 @@ impl Args {
|
|||
|
||||
fn run_coordinator(args: &Args) -> Result<Value> {
|
||||
let root = env::current_dir().context("failed to resolve current dir")?;
|
||||
let local_verse_store = status_cli::absolute_path(&args.local_verse_store)?;
|
||||
assert_local_verse_brake_released(&local_verse_store, "epiphany-mvp-coordinator")?;
|
||||
let app_server = status_cli::absolute_path(&args.app_server)?;
|
||||
let mut cwd = status_cli::absolute_path(&args.cwd)?;
|
||||
let model_runtime_bin = resolve_model_runtime_bin(&root, &args.model_runtime_bin)?;
|
||||
|
|
@ -421,13 +432,8 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
}
|
||||
if args.supersede_failed_results && role_result_needs_supersession(role_id, &result)
|
||||
{
|
||||
let superseded = supersede_role_result(
|
||||
&mut client,
|
||||
&thread_id,
|
||||
role_id,
|
||||
revision,
|
||||
&result,
|
||||
)?;
|
||||
let superseded =
|
||||
supersede_role_result(&mut client, &thread_id, role_id, revision, &result)?;
|
||||
push_event(
|
||||
&mut step,
|
||||
json!({"type": "roleFailureReview", "roleId": role_id, "superseded": status_cli::sanitize_for_operator(superseded)}),
|
||||
|
|
@ -749,6 +755,26 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
Ok(summary)
|
||||
}
|
||||
|
||||
fn assert_local_verse_brake_released(local_verse_store: &Path, runner_name: &str) -> Result<()> {
|
||||
if !local_verse_store.exists() {
|
||||
return Ok(());
|
||||
}
|
||||
let Some(brake) = load_epiphany_cultmesh_swarm_brake(local_verse_store, "epiphany-local")?
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
if brake.status == "engaged" {
|
||||
anyhow::bail!(
|
||||
"{runner_name} refusing to run: local Verse swarm brake engaged; scope={}; protected={}; affected={}; reason={}",
|
||||
brake.scope,
|
||||
brake.protected_surfaces.join(","),
|
||||
brake.affected_clusters.join(","),
|
||||
brake.reason
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn collect_coordinator_status(
|
||||
client: &mut status_cli::AppServerClient,
|
||||
thread_id: &str,
|
||||
|
|
|
|||
|
|
@ -310,7 +310,9 @@ fn validate_status(status: &Value, rendered: &str) -> Result<()> {
|
|||
.and_then(Value::as_array);
|
||||
require(
|
||||
persona_actions.is_some_and(|items| {
|
||||
items.iter().any(|item| item.as_str() == Some("personaBubble"))
|
||||
items
|
||||
.iter()
|
||||
.any(|item| item.as_str() == Some("personaBubble"))
|
||||
&& items
|
||||
.iter()
|
||||
.any(|item| item.as_str() == Some("characterTurn"))
|
||||
|
|
|
|||
|
|
@ -1435,7 +1435,10 @@ pub fn render_status(status: &Value) -> String {
|
|||
),
|
||||
String::new(),
|
||||
"Persona".to_string(),
|
||||
format!("- latest artifact: {}", maybe(&latest_persona["name"], "none")),
|
||||
format!(
|
||||
"- latest artifact: {}",
|
||||
maybe(&latest_persona["name"], "none")
|
||||
),
|
||||
format!(
|
||||
"- latest content: {}",
|
||||
maybe(&latest_persona["content"], "none")
|
||||
|
|
|
|||
|
|
@ -6,10 +6,16 @@ use epiphany_core::EPIPHANY_CULTMESH_OPERATOR_RUN_INTENT_SCHEMA_VERSION;
|
|||
use epiphany_core::EPIPHANY_CULTMESH_OPERATOR_RUN_RECEIPT_SCHEMA_VERSION;
|
||||
use epiphany_core::EpiphanyCultMeshOperatorRunIntentEntry;
|
||||
use epiphany_core::EpiphanyCultMeshOperatorRunReceiptEntry;
|
||||
use epiphany_core::epiphany_cultmesh_coordinator_run_receipt_from_summary_json;
|
||||
use epiphany_core::epiphany_cultmesh_hands_action_gate_from_summary_json;
|
||||
use epiphany_core::epiphany_cultmesh_role_review_event_from_summary_json;
|
||||
use epiphany_core::load_latest_epiphany_cultmesh_operator_run_intent;
|
||||
use epiphany_core::load_latest_epiphany_cultmesh_operator_run_receipt;
|
||||
use epiphany_core::write_epiphany_cultmesh_coordinator_run_receipt;
|
||||
use epiphany_core::write_epiphany_cultmesh_hands_action_gate;
|
||||
use epiphany_core::write_epiphany_cultmesh_operator_run_intent;
|
||||
use epiphany_core::write_epiphany_cultmesh_operator_run_receipt;
|
||||
use epiphany_core::write_epiphany_cultmesh_role_review_event;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use std::env;
|
||||
|
|
@ -81,6 +87,55 @@ fn main() -> Result<()> {
|
|||
"receipt": receipt,
|
||||
}))?;
|
||||
}
|
||||
"coordinator-receipt" => {
|
||||
let summary_path = args
|
||||
.coordinator_summary
|
||||
.clone()
|
||||
.context("coordinator-receipt requires --coordinator-summary")?;
|
||||
let summary_source = fs::read_to_string(&summary_path)
|
||||
.with_context(|| format!("failed to read {}", summary_path.display()))?;
|
||||
let summary_json: Value =
|
||||
serde_json::from_str(summary_source.trim_start_matches('\u{feff}'))
|
||||
.with_context(|| format!("failed to parse {}", summary_path.display()))?;
|
||||
let receipt_id = if args.coordinator_receipt_id.trim().is_empty() {
|
||||
format!("coordinator-cultmesh-{}", args.run_id)
|
||||
} else {
|
||||
args.coordinator_receipt_id.clone()
|
||||
};
|
||||
let written = write_epiphany_cultmesh_coordinator_run_receipt(
|
||||
&args.store,
|
||||
epiphany_cultmesh_coordinator_run_receipt_from_summary_json(
|
||||
args.runtime_id.clone(),
|
||||
receipt_id,
|
||||
Utc::now().to_rfc3339(),
|
||||
args.artifact_root.clone(),
|
||||
&summary_json,
|
||||
)?,
|
||||
)?;
|
||||
let hands_action_gate = epiphany_cultmesh_hands_action_gate_from_summary_json(
|
||||
args.runtime_id.clone(),
|
||||
Utc::now().to_rfc3339(),
|
||||
summary_path.display().to_string(),
|
||||
&summary_json,
|
||||
)?
|
||||
.map(|gate| write_epiphany_cultmesh_hands_action_gate(&args.store, gate))
|
||||
.transpose()?;
|
||||
let role_review_event = epiphany_cultmesh_role_review_event_from_summary_json(
|
||||
args.runtime_id.clone(),
|
||||
Utc::now().to_rfc3339(),
|
||||
summary_path.display().to_string(),
|
||||
&summary_json,
|
||||
)?
|
||||
.map(|event| write_epiphany_cultmesh_role_review_event(&args.store, event))
|
||||
.transpose()?;
|
||||
print_json(json!({
|
||||
"status": "written",
|
||||
"store": args.store,
|
||||
"coordinatorReceipt": written,
|
||||
"handsActionGate": hands_action_gate,
|
||||
"roleReviewEvent": role_review_event,
|
||||
}))?;
|
||||
}
|
||||
"smoke" => {
|
||||
let intent = EpiphanyCultMeshOperatorRunIntentEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_OPERATOR_RUN_INTENT_SCHEMA_VERSION.to_string(),
|
||||
|
|
@ -160,6 +215,8 @@ struct Args {
|
|||
status: String,
|
||||
operator_snapshot_store: String,
|
||||
operator_snapshot_id: String,
|
||||
coordinator_summary: Option<PathBuf>,
|
||||
coordinator_receipt_id: String,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
|
|
@ -187,6 +244,8 @@ impl Args {
|
|||
status: "completed".to_string(),
|
||||
operator_snapshot_store: String::new(),
|
||||
operator_snapshot_id: String::new(),
|
||||
coordinator_summary: None,
|
||||
coordinator_receipt_id: String::new(),
|
||||
};
|
||||
|
||||
while let Some(arg) = values.next() {
|
||||
|
|
@ -216,6 +275,13 @@ impl Args {
|
|||
"--operator-snapshot-id" => {
|
||||
args.operator_snapshot_id = next(&mut values, "--operator-snapshot-id")?
|
||||
}
|
||||
"--coordinator-summary" => {
|
||||
args.coordinator_summary =
|
||||
Some(PathBuf::from(next(&mut values, "--coordinator-summary")?))
|
||||
}
|
||||
"--coordinator-receipt-id" => {
|
||||
args.coordinator_receipt_id = next(&mut values, "--coordinator-receipt-id")?
|
||||
}
|
||||
_ => anyhow::bail!("unknown argument {arg:?}"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use chrono::Utc;
|
||||
use epiphany_core::epiphany_cultmesh_daemon_tool_invocation_from_status_json;
|
||||
use epiphany_core::epiphany_cultmesh_operator_snapshot_from_status_json;
|
||||
use epiphany_core::load_latest_epiphany_cultmesh_operator_snapshot;
|
||||
use epiphany_core::write_epiphany_cultmesh_daemon_tool_invocation_intent;
|
||||
use epiphany_core::write_epiphany_cultmesh_daemon_tool_invocation_receipt;
|
||||
use epiphany_core::write_epiphany_cultmesh_operator_snapshot;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
|
|
@ -17,7 +20,7 @@ fn main() -> Result<()> {
|
|||
let input = args.input.context("from-status requires --input")?;
|
||||
let source = fs::read_to_string(&input)
|
||||
.with_context(|| format!("failed to read {}", input.display()))?;
|
||||
let status_json: Value = serde_json::from_str(&source)
|
||||
let status_json: Value = serde_json::from_str(source.trim_start_matches('\u{feff}'))
|
||||
.with_context(|| format!("failed to parse {}", input.display()))?;
|
||||
let snapshot = epiphany_cultmesh_operator_snapshot_from_status_json(
|
||||
args.runtime_id.clone(),
|
||||
|
|
@ -28,10 +31,34 @@ fn main() -> Result<()> {
|
|||
&status_json,
|
||||
)?;
|
||||
let written = write_epiphany_cultmesh_operator_snapshot(&args.store, snapshot)?;
|
||||
let latest_tool_invocation = epiphany_cultmesh_daemon_tool_invocation_from_status_json(
|
||||
args.runtime_id.clone(),
|
||||
input.to_string_lossy(),
|
||||
&status_json,
|
||||
)?;
|
||||
let mut written_tool_intent = None;
|
||||
let mut written_tool_receipt = None;
|
||||
if let Some((intent, receipt)) = latest_tool_invocation {
|
||||
written_tool_intent = Some(write_epiphany_cultmesh_daemon_tool_invocation_intent(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
intent,
|
||||
)?);
|
||||
if let Some(receipt) = receipt {
|
||||
written_tool_receipt =
|
||||
Some(write_epiphany_cultmesh_daemon_tool_invocation_receipt(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
receipt,
|
||||
)?);
|
||||
}
|
||||
}
|
||||
print_json(json!({
|
||||
"status": "written",
|
||||
"store": args.store,
|
||||
"snapshot": written,
|
||||
"toolInvocationIntent": written_tool_intent,
|
||||
"toolInvocationReceipt": written_tool_receipt,
|
||||
}))?;
|
||||
}
|
||||
"latest" => {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ use anyhow::Context;
|
|||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use chrono::SecondsFormat;
|
||||
use epiphany_core::EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID;
|
||||
use epiphany_core::EPIPHANY_CULTMESH_PERSONA_SPEECH_AUDIT_SCHEMA_VERSION;
|
||||
use epiphany_core::EpiphanyCultMeshPersonaSpeechAuditEntry;
|
||||
use epiphany_core::load_latest_epiphany_cultmesh_persona_speech_audit;
|
||||
use epiphany_core::write_epiphany_cultmesh_persona_speech_audit;
|
||||
use reqwest::blocking::Client;
|
||||
use serde_json::Value;
|
||||
use std::cmp::Reverse;
|
||||
|
|
@ -14,6 +19,7 @@ use uuid::Uuid;
|
|||
|
||||
const CHAT_SCHEMA_VERSION: &str = "epiphany.persona_chat.v0";
|
||||
const BUBBLE_SCHEMA_VERSION: &str = "epiphany.persona_bubble.v0";
|
||||
const SPEECH_AUDIT_SCHEMA_VERSION: &str = "epiphany.persona_speech_audit.v0";
|
||||
const DISCORD_API: &str = "https://discord.com/api/v10";
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
|
|
@ -34,6 +40,8 @@ fn main() -> Result<()> {
|
|||
};
|
||||
let mut config_path = PathBuf::from("state/persona-discord.toml");
|
||||
let mut artifact_dir = PathBuf::from(".epiphany-persona");
|
||||
let mut cultmesh_store = PathBuf::from(".epiphany-run/cultmesh/persona-speech.ccmp");
|
||||
let mut runtime_id = "epiphany-local".to_string();
|
||||
let mut content: Option<String> = None;
|
||||
let mut channel_id: Option<String> = None;
|
||||
let mut source = "epiphany/Persona".to_string();
|
||||
|
|
@ -48,6 +56,8 @@ fn main() -> Result<()> {
|
|||
match arg.as_str() {
|
||||
"--config" => config_path = next_path(&mut args, "--config")?,
|
||||
"--artifact-dir" => artifact_dir = next_path(&mut args, "--artifact-dir")?,
|
||||
"--cultmesh-store" => cultmesh_store = next_path(&mut args, "--cultmesh-store")?,
|
||||
"--runtime-id" => runtime_id = next_value(&mut args, "--runtime-id")?,
|
||||
"--content" => content = Some(next_value(&mut args, "--content")?),
|
||||
"--channel-id" => channel_id = Some(next_value(&mut args, "--channel-id")?),
|
||||
"--source" => source = next_value(&mut args, "--source")?,
|
||||
|
|
@ -73,13 +83,23 @@ fn main() -> Result<()> {
|
|||
&content,
|
||||
&config,
|
||||
&artifact_dir,
|
||||
&cultmesh_store,
|
||||
&runtime_id,
|
||||
"draft",
|
||||
"drafted without posting",
|
||||
)?
|
||||
}
|
||||
"bubble" => {
|
||||
let content = read_content(content)?;
|
||||
run_bubble(&content, &artifact_dir, &source, &status, &mood)?
|
||||
run_bubble(
|
||||
&content,
|
||||
&artifact_dir,
|
||||
&cultmesh_store,
|
||||
&runtime_id,
|
||||
&source,
|
||||
&status,
|
||||
&mood,
|
||||
)?
|
||||
}
|
||||
"post" => {
|
||||
let config = load_config(&config_path)?;
|
||||
|
|
@ -88,6 +108,8 @@ fn main() -> Result<()> {
|
|||
&content,
|
||||
&config,
|
||||
&artifact_dir,
|
||||
&cultmesh_store,
|
||||
&runtime_id,
|
||||
channel_id,
|
||||
persona_name,
|
||||
persona_avatar_url,
|
||||
|
|
@ -114,34 +136,62 @@ fn run_draft(
|
|||
content: &str,
|
||||
config: &PersonaConfig,
|
||||
artifact_dir: &Path,
|
||||
cultmesh_store: &Path,
|
||||
runtime_id: &str,
|
||||
status: &str,
|
||||
reason: &str,
|
||||
) -> Result<Value> {
|
||||
ensure_content(content, "Persona chat")?;
|
||||
let path = write_draft(content, config, artifact_dir, status, reason)?;
|
||||
let audit = audit_persona_speech(
|
||||
content,
|
||||
PersonaSpeechActionKind::Draft,
|
||||
artifact_dir,
|
||||
cultmesh_store,
|
||||
runtime_id,
|
||||
allowed_channel_id(config).as_deref(),
|
||||
false,
|
||||
)?;
|
||||
let path = write_draft(content, config, artifact_dir, status, reason, Some(&audit))?;
|
||||
Ok(serde_json::json!({
|
||||
"ok": status != "blocked",
|
||||
"posted": false,
|
||||
"draftPath": path,
|
||||
"speechAudit": audit,
|
||||
}))
|
||||
}
|
||||
|
||||
fn run_bubble(
|
||||
content: &str,
|
||||
artifact_dir: &Path,
|
||||
cultmesh_store: &Path,
|
||||
runtime_id: &str,
|
||||
source: &str,
|
||||
status: &str,
|
||||
mood: &str,
|
||||
) -> Result<Value> {
|
||||
ensure_content(content, "Persona bubble")?;
|
||||
let audit = audit_persona_speech(
|
||||
content,
|
||||
PersonaSpeechActionKind::Bubble,
|
||||
artifact_dir,
|
||||
cultmesh_store,
|
||||
runtime_id,
|
||||
None,
|
||||
false,
|
||||
)?;
|
||||
let payload = bubble_payload(content, source, status, mood);
|
||||
let path = artifact_dir.join(format!("Persona-bubble-{}-{}.json", now_stamp(), short_id()));
|
||||
let path = artifact_dir.join(format!(
|
||||
"Persona-bubble-{}-{}.json",
|
||||
now_stamp(),
|
||||
short_id()
|
||||
));
|
||||
write_json(&path, &payload)?;
|
||||
Ok(serde_json::json!({
|
||||
"ok": true,
|
||||
"posted": false,
|
||||
"bubblePath": path,
|
||||
"bubble": payload,
|
||||
"speechAudit": audit,
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
@ -149,6 +199,8 @@ fn run_post(
|
|||
content: &str,
|
||||
config: &PersonaConfig,
|
||||
artifact_dir: &Path,
|
||||
cultmesh_store: &Path,
|
||||
runtime_id: &str,
|
||||
channel_id: Option<String>,
|
||||
persona_name: Option<String>,
|
||||
persona_avatar_url: Option<String>,
|
||||
|
|
@ -157,6 +209,32 @@ fn run_post(
|
|||
ensure_content(content, "Persona chat")?;
|
||||
let configured_channel_id = allowed_channel_id(config);
|
||||
let requested_channel_id = channel_id.or_else(|| configured_channel_id.clone());
|
||||
let audit = audit_persona_speech(
|
||||
content,
|
||||
PersonaSpeechActionKind::Post,
|
||||
artifact_dir,
|
||||
cultmesh_store,
|
||||
runtime_id,
|
||||
requested_channel_id.as_deref(),
|
||||
true,
|
||||
)?;
|
||||
if audit.decision == "blocked" {
|
||||
let path = write_draft(
|
||||
content,
|
||||
config,
|
||||
artifact_dir,
|
||||
"blocked",
|
||||
&format!("speech audit blocked: {}", audit.reasons.join("; ")),
|
||||
Some(&audit),
|
||||
)?;
|
||||
return Ok(serde_json::json!({
|
||||
"ok": false,
|
||||
"posted": false,
|
||||
"blocked": "speech-audit",
|
||||
"draftPath": path,
|
||||
"speechAudit": audit,
|
||||
}));
|
||||
}
|
||||
let Some(configured_channel_id) = configured_channel_id else {
|
||||
let path = write_draft(
|
||||
content,
|
||||
|
|
@ -164,12 +242,14 @@ fn run_post(
|
|||
artifact_dir,
|
||||
"blocked",
|
||||
"missing #aquarium channel id",
|
||||
Some(&audit),
|
||||
)?;
|
||||
return Ok(serde_json::json!({
|
||||
"ok": false,
|
||||
"posted": false,
|
||||
"blocked": "missing-channel-id",
|
||||
"draftPath": path,
|
||||
"speechAudit": audit,
|
||||
}));
|
||||
};
|
||||
if requested_channel_id.as_deref() != Some(configured_channel_id.as_str()) {
|
||||
|
|
@ -179,12 +259,14 @@ fn run_post(
|
|||
artifact_dir,
|
||||
"blocked",
|
||||
"requested channel does not match configured #aquarium channel id",
|
||||
Some(&audit),
|
||||
)?;
|
||||
return Ok(serde_json::json!({
|
||||
"ok": false,
|
||||
"posted": false,
|
||||
"blocked": "wrong-channel",
|
||||
"draftPath": path,
|
||||
"speechAudit": audit,
|
||||
}));
|
||||
}
|
||||
let Some(token) = bot_token(config) else {
|
||||
|
|
@ -194,12 +276,14 @@ fn run_post(
|
|||
artifact_dir,
|
||||
"blocked",
|
||||
"missing Discord bot token",
|
||||
Some(&audit),
|
||||
)?;
|
||||
return Ok(serde_json::json!({
|
||||
"ok": false,
|
||||
"posted": false,
|
||||
"blocked": "missing-token",
|
||||
"draftPath": path,
|
||||
"speechAudit": audit,
|
||||
}));
|
||||
};
|
||||
let persona = resolve_persona(config, persona_name, persona_avatar_url)?;
|
||||
|
|
@ -221,6 +305,7 @@ fn run_post(
|
|||
"posted message {} via {}",
|
||||
posted.message_id, posted.transport
|
||||
),
|
||||
Some(&audit),
|
||||
)?;
|
||||
Ok(serde_json::json!({
|
||||
"ok": true,
|
||||
|
|
@ -232,6 +317,7 @@ fn run_post(
|
|||
"avatarUrl": persona.avatar_url,
|
||||
})),
|
||||
"draftPath": path,
|
||||
"speechAudit": audit,
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
@ -247,6 +333,163 @@ struct PostedDiscordMessage {
|
|||
transport: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
enum PersonaSpeechActionKind {
|
||||
Draft,
|
||||
Bubble,
|
||||
Post,
|
||||
}
|
||||
|
||||
impl PersonaSpeechActionKind {
|
||||
fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
PersonaSpeechActionKind::Draft => "draft",
|
||||
PersonaSpeechActionKind::Bubble => "bubble",
|
||||
PersonaSpeechActionKind::Post => "post",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct PersonaSpeechAudit {
|
||||
#[serde(rename = "schema_version")]
|
||||
schema_version: String,
|
||||
audit_id: String,
|
||||
created_at: String,
|
||||
action_kind: PersonaSpeechActionKind,
|
||||
decision: String,
|
||||
reasons: Vec<String>,
|
||||
content_fingerprint: String,
|
||||
opening_key: String,
|
||||
topic_key: String,
|
||||
requested_channel_id: Option<String>,
|
||||
recent_window_count: usize,
|
||||
repeated_opening_count: usize,
|
||||
repeated_topic_count: usize,
|
||||
same_channel_post_count: usize,
|
||||
audit_path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct RecentPersonaSpeech {
|
||||
opening_key: String,
|
||||
topic_key: String,
|
||||
channel_id: Option<String>,
|
||||
action_kind: PersonaSpeechActionKind,
|
||||
}
|
||||
|
||||
fn audit_persona_speech(
|
||||
content: &str,
|
||||
action_kind: PersonaSpeechActionKind,
|
||||
artifact_dir: &Path,
|
||||
cultmesh_store: &Path,
|
||||
runtime_id: &str,
|
||||
requested_channel_id: Option<&str>,
|
||||
public_post: bool,
|
||||
) -> Result<PersonaSpeechAudit> {
|
||||
let opening_key = opening_key(content);
|
||||
let topic_key = topic_key(content);
|
||||
let recent = recent_persona_speech(artifact_dir, 12);
|
||||
let repeated_opening_count = recent
|
||||
.iter()
|
||||
.filter(|speech| !opening_key.is_empty() && speech.opening_key == opening_key)
|
||||
.count();
|
||||
let repeated_topic_count = recent
|
||||
.iter()
|
||||
.filter(|speech| !topic_key.is_empty() && speech.topic_key == topic_key)
|
||||
.count();
|
||||
let same_channel_post_count = requested_channel_id
|
||||
.map(|channel_id| {
|
||||
recent
|
||||
.iter()
|
||||
.filter(|speech| {
|
||||
speech.action_kind == PersonaSpeechActionKind::Post
|
||||
&& speech.channel_id.as_deref() == Some(channel_id)
|
||||
})
|
||||
.count()
|
||||
})
|
||||
.unwrap_or(0);
|
||||
let mut reasons = Vec::new();
|
||||
if public_post && repeated_opening_count >= 2 {
|
||||
reasons.push("repeated-opening".to_string());
|
||||
}
|
||||
if public_post && repeated_topic_count >= 3 {
|
||||
reasons.push("repeated-topic".to_string());
|
||||
}
|
||||
if public_post && same_channel_post_count >= 4 {
|
||||
reasons.push("channel-saturation".to_string());
|
||||
}
|
||||
if content.trim().len() > 1800 {
|
||||
reasons.push("content-too-long-for-public-persona".to_string());
|
||||
}
|
||||
let decision = if reasons.is_empty() {
|
||||
"eligible"
|
||||
} else {
|
||||
"blocked"
|
||||
}
|
||||
.to_string();
|
||||
let audit_id = format!("persona-speech-audit-{}", short_id());
|
||||
let audit_path = artifact_dir.join(format!(
|
||||
"Persona-speech-audit-{}-{}.json",
|
||||
now_stamp(),
|
||||
audit_id
|
||||
));
|
||||
let audit = PersonaSpeechAudit {
|
||||
schema_version: SPEECH_AUDIT_SCHEMA_VERSION.to_string(),
|
||||
audit_id,
|
||||
created_at: now_iso(),
|
||||
action_kind,
|
||||
decision,
|
||||
reasons,
|
||||
content_fingerprint: content_fingerprint(content),
|
||||
opening_key,
|
||||
topic_key,
|
||||
requested_channel_id: requested_channel_id.map(str::to_string),
|
||||
recent_window_count: recent.len(),
|
||||
repeated_opening_count,
|
||||
repeated_topic_count,
|
||||
same_channel_post_count,
|
||||
audit_path,
|
||||
};
|
||||
write_json(&audit.audit_path, &serde_json::to_value(&audit)?)?;
|
||||
let cultmesh_entry = persona_speech_audit_cultmesh_entry(&audit, runtime_id);
|
||||
write_epiphany_cultmesh_persona_speech_audit(cultmesh_store, cultmesh_entry)?;
|
||||
Ok(audit)
|
||||
}
|
||||
|
||||
fn persona_speech_audit_cultmesh_entry(
|
||||
audit: &PersonaSpeechAudit,
|
||||
runtime_id: &str,
|
||||
) -> EpiphanyCultMeshPersonaSpeechAuditEntry {
|
||||
EpiphanyCultMeshPersonaSpeechAuditEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_PERSONA_SPEECH_AUDIT_SCHEMA_VERSION.to_string(),
|
||||
audit_id: audit.audit_id.clone(),
|
||||
runtime_id: runtime_id.to_string(),
|
||||
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
|
||||
persona_agent_id: "epiphany.Persona".to_string(),
|
||||
action_kind: audit.action_kind.as_str().to_string(),
|
||||
decision: audit.decision.clone(),
|
||||
content_fingerprint: audit.content_fingerprint.clone(),
|
||||
opening_key: audit.opening_key.clone(),
|
||||
topic_key: audit.topic_key.clone(),
|
||||
requested_channel_id: audit.requested_channel_id.clone().unwrap_or_default(),
|
||||
recent_window_count: audit.recent_window_count as u32,
|
||||
repeated_opening_count: audit.repeated_opening_count as u32,
|
||||
repeated_topic_count: audit.repeated_topic_count as u32,
|
||||
same_channel_post_count: audit.same_channel_post_count as u32,
|
||||
reasons: audit.reasons.clone(),
|
||||
artifact_ref: audit.audit_path.display().to_string(),
|
||||
created_at_utc: audit.created_at.clone(),
|
||||
private_state_exposed: false,
|
||||
notes: vec![
|
||||
"Persona speech audit is parent-side mouth policy; it stores fingerprints and counters, not raw Persona prose.".to_string(),
|
||||
"Public speech remains blocked when repetition or saturation trips before Discord transport work.".to_string(),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_persona(
|
||||
config: &PersonaConfig,
|
||||
persona_name: Option<String>,
|
||||
|
|
@ -445,6 +688,8 @@ fn execute_persona_webhook(
|
|||
|
||||
fn run_smoke() -> Result<Value> {
|
||||
let temp_dir = scoped_temp_dir("epiphany-persona-discord-smoke")?;
|
||||
let cultmesh_store = temp_dir.join("persona-speech.ccmp");
|
||||
let runtime_id = "epiphany-persona-smoke";
|
||||
let config = PersonaConfig {
|
||||
allowed_channel_name: "#aquarium".to_string(),
|
||||
allowed_channel_id: None,
|
||||
|
|
@ -461,12 +706,16 @@ fn run_smoke() -> Result<Value> {
|
|||
"Persona notices Modeling and Soul disagree about evidence shape.",
|
||||
&config,
|
||||
&temp_dir,
|
||||
&cultmesh_store,
|
||||
runtime_id,
|
||||
"draft",
|
||||
"drafted without posting",
|
||||
)?;
|
||||
let bubble = run_bubble(
|
||||
"Persona opens an Aquarium bubble even while Discord is unavailable.",
|
||||
&temp_dir,
|
||||
&cultmesh_store,
|
||||
runtime_id,
|
||||
"smoke/Persona",
|
||||
"ready",
|
||||
"attentive",
|
||||
|
|
@ -475,6 +724,8 @@ fn run_smoke() -> Result<Value> {
|
|||
"Persona should not post without a configured #aquarium channel id.",
|
||||
&config,
|
||||
&temp_dir,
|
||||
&cultmesh_store,
|
||||
runtime_id,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
|
|
@ -487,11 +738,52 @@ fn run_smoke() -> Result<Value> {
|
|||
"Persona should not post outside #aquarium.",
|
||||
&config,
|
||||
&temp_dir,
|
||||
&cultmesh_store,
|
||||
runtime_id,
|
||||
Some("456".to_string()),
|
||||
Some("Wrong Persona".to_string()),
|
||||
None,
|
||||
None,
|
||||
)?;
|
||||
let repeated_audit_seed = audit_persona_speech(
|
||||
"Rite noted: Modeling and Soul keep circling the same evidence seam.",
|
||||
PersonaSpeechActionKind::Post,
|
||||
&temp_dir,
|
||||
&cultmesh_store,
|
||||
runtime_id,
|
||||
Some("123"),
|
||||
false,
|
||||
)?;
|
||||
write_draft(
|
||||
"Rite noted: Modeling and Soul keep circling the same evidence seam.",
|
||||
&config,
|
||||
&temp_dir,
|
||||
"posted",
|
||||
"seed prior posted Persona output for speech-audit smoke",
|
||||
Some(&repeated_audit_seed),
|
||||
)?;
|
||||
write_draft(
|
||||
"Rite noted: Modeling and Soul keep circling the same evidence seam.",
|
||||
&config,
|
||||
&temp_dir,
|
||||
"posted",
|
||||
"seed second prior posted Persona output for speech-audit smoke",
|
||||
Some(&repeated_audit_seed),
|
||||
)?;
|
||||
let repeated = run_post(
|
||||
"Rite noted: Modeling and Soul keep circling the same evidence seam again.",
|
||||
&config,
|
||||
&temp_dir,
|
||||
&cultmesh_store,
|
||||
runtime_id,
|
||||
Some("123".to_string()),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)?;
|
||||
let latest_cultmesh_audit =
|
||||
load_latest_epiphany_cultmesh_persona_speech_audit(&cultmesh_store, runtime_id)?
|
||||
.context("Persona speech audit smoke expected latest CultMesh audit")?;
|
||||
let ok = draft["ok"] == true
|
||||
&& bubble["ok"] == true
|
||||
&& bubble["bubble"]["schema_version"] == BUBBLE_SCHEMA_VERSION
|
||||
|
|
@ -499,13 +791,27 @@ fn run_smoke() -> Result<Value> {
|
|||
&& blocked["ok"] == false
|
||||
&& blocked["blocked"] == "missing-channel-id"
|
||||
&& wrong["ok"] == false
|
||||
&& wrong["blocked"] == "wrong-channel";
|
||||
&& wrong["blocked"] == "wrong-channel"
|
||||
&& repeated["ok"] == false
|
||||
&& repeated["blocked"] == "speech-audit"
|
||||
&& repeated["speechAudit"]["decision"] == "blocked"
|
||||
&& repeated["speechAudit"]["reasons"]
|
||||
.as_array()
|
||||
.is_some_and(|reasons| reasons.iter().any(|reason| reason == "repeated-opening"))
|
||||
&& latest_cultmesh_audit.decision == "blocked"
|
||||
&& latest_cultmesh_audit
|
||||
.reasons
|
||||
.iter()
|
||||
.any(|reason| reason == "repeated-opening")
|
||||
&& !latest_cultmesh_audit.private_state_exposed;
|
||||
let result = serde_json::json!({
|
||||
"ok": ok,
|
||||
"draft": draft,
|
||||
"bubble": bubble,
|
||||
"blocked": blocked,
|
||||
"wrongChannel": wrong,
|
||||
"repeatedSpeech": repeated,
|
||||
"latestCultMeshSpeechAudit": latest_cultmesh_audit,
|
||||
});
|
||||
let _ = fs::remove_dir_all(&temp_dir);
|
||||
Ok(result)
|
||||
|
|
@ -517,6 +823,7 @@ fn write_draft(
|
|||
artifact_dir: &Path,
|
||||
status: &str,
|
||||
reason: &str,
|
||||
speech_audit: Option<&PersonaSpeechAudit>,
|
||||
) -> Result<PathBuf> {
|
||||
let payload = serde_json::json!({
|
||||
"schema_version": CHAT_SCHEMA_VERSION,
|
||||
|
|
@ -528,6 +835,7 @@ fn write_draft(
|
|||
"persona_name": config.persona_name,
|
||||
"persona_avatar_url": config.persona_avatar_url,
|
||||
"content": content.trim(),
|
||||
"speechAudit": speech_audit,
|
||||
});
|
||||
let path = artifact_dir.join(format!("Persona-chat-{}-{}.json", now_stamp(), short_id()));
|
||||
write_json(&path, &payload)?;
|
||||
|
|
@ -592,6 +900,112 @@ fn latest_persona_artifacts(artifact_dir: &Path, limit: usize) -> Vec<Value> {
|
|||
.collect()
|
||||
}
|
||||
|
||||
fn recent_persona_speech(artifact_dir: &Path, limit: usize) -> Vec<RecentPersonaSpeech> {
|
||||
let Ok(read_dir) = fs::read_dir(artifact_dir) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let mut paths = read_dir
|
||||
.filter_map(Result::ok)
|
||||
.map(|entry| entry.path())
|
||||
.filter(|path| {
|
||||
path.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.is_some_and(|name| {
|
||||
name.starts_with("Persona-chat-") || name.starts_with("Persona-bubble-")
|
||||
})
|
||||
})
|
||||
.filter_map(|path| Some((path.metadata().ok()?.modified().ok()?, path)))
|
||||
.collect::<Vec<_>>();
|
||||
paths.sort_by_key(|item| Reverse(item.0));
|
||||
paths
|
||||
.into_iter()
|
||||
.take(limit)
|
||||
.filter_map(|(_, path)| {
|
||||
let payload: Value = serde_json::from_str(&fs::read_to_string(&path).ok()?).ok()?;
|
||||
let content = payload["content"]
|
||||
.as_str()
|
||||
.or_else(|| payload["bubble"]["content"].as_str())?
|
||||
.to_string();
|
||||
let status = payload["status"].as_str().unwrap_or_default();
|
||||
let action_kind = if payload["schema_version"] == BUBBLE_SCHEMA_VERSION {
|
||||
PersonaSpeechActionKind::Bubble
|
||||
} else if status == "posted" {
|
||||
PersonaSpeechActionKind::Post
|
||||
} else {
|
||||
PersonaSpeechActionKind::Draft
|
||||
};
|
||||
Some(RecentPersonaSpeech {
|
||||
opening_key: opening_key(&content),
|
||||
topic_key: topic_key(&content),
|
||||
channel_id: payload["allowed_channel_id"].as_str().map(str::to_string),
|
||||
action_kind,
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn opening_key(content: &str) -> String {
|
||||
content
|
||||
.split_whitespace()
|
||||
.take(5)
|
||||
.map(normalize_token)
|
||||
.filter(|token| !token.is_empty())
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
}
|
||||
|
||||
fn topic_key(content: &str) -> String {
|
||||
let mut tokens = content
|
||||
.split_whitespace()
|
||||
.map(normalize_token)
|
||||
.filter(|token| token.len() >= 4 && !persona_stopword(token))
|
||||
.collect::<Vec<_>>();
|
||||
tokens.sort();
|
||||
tokens.dedup();
|
||||
tokens.into_iter().take(6).collect::<Vec<_>>().join("|")
|
||||
}
|
||||
|
||||
fn content_fingerprint(content: &str) -> String {
|
||||
topic_key(content)
|
||||
+ "::"
|
||||
+ &content
|
||||
.split_whitespace()
|
||||
.map(normalize_token)
|
||||
.filter(|token| !token.is_empty())
|
||||
.take(24)
|
||||
.collect::<Vec<_>>()
|
||||
.join("-")
|
||||
}
|
||||
|
||||
fn normalize_token(value: &str) -> String {
|
||||
value
|
||||
.trim_matches(|ch: char| !ch.is_ascii_alphanumeric())
|
||||
.chars()
|
||||
.filter(|ch| ch.is_ascii_alphanumeric() || *ch == '-' || *ch == '_')
|
||||
.collect::<String>()
|
||||
.to_ascii_lowercase()
|
||||
}
|
||||
|
||||
fn persona_stopword(value: &str) -> bool {
|
||||
matches!(
|
||||
value,
|
||||
"about"
|
||||
| "after"
|
||||
| "again"
|
||||
| "because"
|
||||
| "before"
|
||||
| "being"
|
||||
| "should"
|
||||
| "there"
|
||||
| "these"
|
||||
| "thing"
|
||||
| "through"
|
||||
| "under"
|
||||
| "without"
|
||||
| "would"
|
||||
)
|
||||
}
|
||||
|
||||
fn persona_webhook_cache_path(config: &PersonaConfig, artifact_dir: &Path) -> PathBuf {
|
||||
config
|
||||
.webhook_cache_path
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -156,6 +156,43 @@ pub struct HandsCommitReceipt {
|
|||
pub contract: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(type = "epiphany.hands.pr_receipt", schema = "HandsPrReceipt")]
|
||||
pub struct HandsPrReceipt {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub receipt_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub intent_id: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub review_id: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub runtime_job_id: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub commit_receipt_id: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub commit_sha: String,
|
||||
#[cultcache(key = 7)]
|
||||
pub branch: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub pull_request_url: String,
|
||||
#[cultcache(key = 9)]
|
||||
pub pull_request_number: String,
|
||||
#[cultcache(key = 10)]
|
||||
pub pull_request_title: String,
|
||||
#[cultcache(key = 11)]
|
||||
pub changed_paths: Vec<String>,
|
||||
#[cultcache(key = 12)]
|
||||
pub bifrost_publication_receipt_id: String,
|
||||
#[cultcache(key = 13)]
|
||||
pub summary: String,
|
||||
#[cultcache(key = 14)]
|
||||
pub emitted_at: String,
|
||||
#[cultcache(key = 15)]
|
||||
pub contract: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct HandsCultNetContract {
|
||||
|
|
@ -363,6 +400,39 @@ pub fn hands_commit_receipt_for_review(
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn hands_pr_receipt_for_review(
|
||||
receipt_id: String,
|
||||
intent: &HandsActionIntent,
|
||||
review: &HandsActionReview,
|
||||
commit_receipt: &HandsCommitReceipt,
|
||||
pull_request_url: String,
|
||||
pull_request_number: String,
|
||||
pull_request_title: String,
|
||||
bifrost_publication_receipt_id: String,
|
||||
summary: String,
|
||||
emitted_at: String,
|
||||
) -> HandsPrReceipt {
|
||||
HandsPrReceipt {
|
||||
schema_version: HANDS_PR_RECEIPT_SCHEMA_VERSION.to_string(),
|
||||
receipt_id,
|
||||
intent_id: intent.intent_id.clone(),
|
||||
review_id: review.review_id.clone(),
|
||||
runtime_job_id: intent.runtime_job_id.clone(),
|
||||
commit_receipt_id: commit_receipt.receipt_id.clone(),
|
||||
commit_sha: commit_receipt.commit_sha.clone(),
|
||||
branch: commit_receipt.branch.clone(),
|
||||
pull_request_url,
|
||||
pull_request_number,
|
||||
pull_request_title,
|
||||
changed_paths: commit_receipt.changed_paths.clone(),
|
||||
bifrost_publication_receipt_id,
|
||||
summary,
|
||||
emitted_at,
|
||||
contract: "Hands PR receipt proves GitHub pull-request publication as a consequence of a reviewed action, commit receipt, and Bifrost publication gate; GitHub remains a substrate, not governance authority.".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use chrono::DateTime;
|
||||
use chrono::Duration;
|
||||
use chrono::Utc;
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::BTreeSet;
|
||||
|
|
@ -37,9 +39,11 @@ pub use heartbeat_roles::initialize_heartbeat_store;
|
|||
pub use heartbeat_store::heartbeat_state_cache;
|
||||
pub use heartbeat_store::load_heartbeat_cognition_entry;
|
||||
pub use heartbeat_store::load_heartbeat_state_entry;
|
||||
pub use heartbeat_store::load_latest_heartbeat_stale_turn_repair_receipt;
|
||||
pub use heartbeat_store::validate_heartbeat_cognition;
|
||||
pub use heartbeat_store::validate_heartbeat_state;
|
||||
pub use heartbeat_store::write_heartbeat_cognition_entry;
|
||||
pub use heartbeat_store::write_heartbeat_stale_turn_repair_receipt;
|
||||
pub use heartbeat_store::write_heartbeat_state_entry;
|
||||
|
||||
pub(super) const HEARTBEAT_ARENA_MAINTENANCE: &str = "maintenance";
|
||||
|
|
@ -580,6 +584,133 @@ pub fn complete_heartbeat_store(
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn recover_stale_heartbeat_store(
|
||||
store_path: impl AsRef<Path>,
|
||||
artifact_dir: impl AsRef<Path>,
|
||||
options: HeartbeatStaleTurnRepairOptions,
|
||||
) -> Result<Value> {
|
||||
if options.max_age_seconds < 0 {
|
||||
return Err(anyhow!(
|
||||
"stale heartbeat repair max_age_seconds must be non-negative"
|
||||
));
|
||||
}
|
||||
if options.reason.trim().is_empty() {
|
||||
return Err(anyhow!("stale heartbeat repair requires a reason"));
|
||||
}
|
||||
let store_path = store_path.as_ref();
|
||||
let mut state = load_heartbeat_state_entry(store_path)?.ok_or_else(|| {
|
||||
anyhow!(
|
||||
"CultCache store {} has no heartbeat state entry",
|
||||
store_path.display()
|
||||
)
|
||||
})?;
|
||||
let repaired_at = options.now_utc.clone().unwrap_or_else(now_iso);
|
||||
let repaired_at_time = parse_heartbeat_time("repair time", &repaired_at)?;
|
||||
let mut receipts = Vec::new();
|
||||
|
||||
for participant in &mut state.participants {
|
||||
let pending = match participant.pending_turn.clone() {
|
||||
Some(pending) if pending.status == "running" => pending,
|
||||
_ => continue,
|
||||
};
|
||||
let started_at = parse_heartbeat_time("pending turn start time", &pending.started_at)?;
|
||||
let stale_age_seconds = repaired_at_time
|
||||
.signed_duration_since(started_at)
|
||||
.num_seconds();
|
||||
if stale_age_seconds < options.max_age_seconds {
|
||||
continue;
|
||||
}
|
||||
participant.pending_turn = None;
|
||||
participant.current_load = 0.0;
|
||||
participant.next_ready_at = round6(state.scene_clock.max(pending.started_scene_clock));
|
||||
let receipt = EpiphanyHeartbeatStaleTurnRepairReceipt {
|
||||
schema_version: HEARTBEAT_STALE_TURN_REPAIR_SCHEMA_VERSION.to_string(),
|
||||
receipt_id: format!(
|
||||
"heartbeat-stale-turn-repair-{}-{}",
|
||||
participant.role_id,
|
||||
now_stamp()
|
||||
),
|
||||
repaired_at_utc: repaired_at.clone(),
|
||||
role_id: participant.role_id.clone(),
|
||||
agent_id: participant.agent_id.clone(),
|
||||
action_id: pending.action_id.clone(),
|
||||
schedule_id: pending.schedule_id.clone(),
|
||||
started_at_utc: pending.started_at.clone(),
|
||||
stale_age_seconds,
|
||||
reason: options.reason.clone(),
|
||||
resulting_status: "repaired".to_string(),
|
||||
next_ready_at: participant.next_ready_at,
|
||||
private_state_exposed: false,
|
||||
notes: vec![
|
||||
"Stale heartbeat repair is a Continuity-facing operator-safe receipt, not silent scheduler cleanup.".to_string(),
|
||||
"The repaired lane becomes schedulable only through normal heartbeat selection after the receipt is written.".to_string(),
|
||||
],
|
||||
};
|
||||
let event = HeartbeatHistoryEvent {
|
||||
ts: repaired_at.clone(),
|
||||
schedule_id: pending.schedule_id.clone(),
|
||||
selected_role: participant.role_id.clone(),
|
||||
selected_agent_id: participant.agent_id.clone(),
|
||||
action_id: pending.action_id.clone(),
|
||||
action_type: pending.action_type.clone(),
|
||||
arena: participant_arena(participant).to_string(),
|
||||
participant_kind: participant_kind(participant).to_string(),
|
||||
action_scale: pending.action_scale.clone(),
|
||||
coordinator_action: None,
|
||||
target_role: None,
|
||||
work_role: None,
|
||||
scene_clock: Some(state.scene_clock),
|
||||
next_ready_at: Some(participant.next_ready_at),
|
||||
turn_status: Some("stale_repaired".to_string()),
|
||||
cooldown_started_after_completion: Some(false),
|
||||
};
|
||||
state.history.push(event);
|
||||
receipts.push(receipt);
|
||||
}
|
||||
|
||||
if receipts.is_empty() {
|
||||
return Ok(serde_json::json!({
|
||||
"ok": true,
|
||||
"storeFile": store_path,
|
||||
"repaired": 0,
|
||||
"receipts": [],
|
||||
"reviewNotes": [
|
||||
"No running heartbeat turns exceeded the stale repair threshold."
|
||||
],
|
||||
}));
|
||||
}
|
||||
|
||||
trim_history(&mut state);
|
||||
write_heartbeat_state_entry(store_path, &state)?;
|
||||
let mut written_receipts = Vec::new();
|
||||
for receipt in receipts {
|
||||
written_receipts.push(write_heartbeat_stale_turn_repair_receipt(
|
||||
store_path, &receipt,
|
||||
)?);
|
||||
}
|
||||
|
||||
let artifact_dir = artifact_dir.as_ref();
|
||||
fs::create_dir_all(artifact_dir)
|
||||
.with_context(|| format!("failed to create {}", artifact_dir.display()))?;
|
||||
write_json_artifact(
|
||||
artifact_dir.join(format!("heartbeat-stale-repair-{}.json", now_stamp())),
|
||||
&serde_json::json!({
|
||||
"schemaVersion": "epiphany.heartbeat.stale_repair_artifact.v0",
|
||||
"storeFile": store_path,
|
||||
"repairedAtUtc": repaired_at,
|
||||
"maxAgeSeconds": options.max_age_seconds,
|
||||
"receipts": written_receipts,
|
||||
}),
|
||||
)?;
|
||||
|
||||
Ok(serde_json::json!({
|
||||
"ok": true,
|
||||
"storeFile": store_path,
|
||||
"repaired": written_receipts.len(),
|
||||
"receipts": written_receipts,
|
||||
}))
|
||||
}
|
||||
|
||||
fn tick_once(
|
||||
state: &mut EpiphanyHeartbeatStateEntry,
|
||||
options: &HeartbeatTickOptions,
|
||||
|
|
@ -2491,7 +2622,9 @@ fn mood_label(arousal: f64, guardedness: f64, curiosity: f64) -> &'static str {
|
|||
|
||||
fn reaction_recommended_use(role_id: &str, mode: &str) -> &'static str {
|
||||
match (role_id, mode) {
|
||||
("Persona", "draft") => "Prepare a reviewed Aquarium-facing draft; do not post automatically.",
|
||||
("Persona", "draft") => {
|
||||
"Prepare a reviewed Aquarium-facing draft; do not post automatically."
|
||||
}
|
||||
(_, "hold_and_verify") => "Bias toward verifier/modeler review before expression.",
|
||||
(_, "inspect") => {
|
||||
"Bias the next heartbeat toward a bounded retrieval or modeling inspection."
|
||||
|
|
@ -3174,6 +3307,12 @@ pub(super) fn now_iso() -> String {
|
|||
.replace('Z', "+00:00")
|
||||
}
|
||||
|
||||
fn parse_heartbeat_time(label: &str, value: &str) -> Result<DateTime<Utc>> {
|
||||
DateTime::parse_from_rfc3339(value)
|
||||
.map(|time| time.with_timezone(&Utc))
|
||||
.with_context(|| format!("failed to parse {label} {value:?} as RFC3339"))
|
||||
}
|
||||
|
||||
fn now_stamp() -> String {
|
||||
chrono::Utc::now().format("%Y%m%dT%H%M%SZ").to_string()
|
||||
}
|
||||
|
|
@ -3360,6 +3499,85 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_heartbeat_repair_receipt_clears_running_turn() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store_path = temp.path().join("stale-heartbeats.msgpack");
|
||||
let artifact_dir = temp.path().join("artifacts");
|
||||
initialize_heartbeat_store(&store_path, 1.0)?;
|
||||
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: "stale-work".to_string(),
|
||||
source_scene_ref: "test/stale".to_string(),
|
||||
defer_completion: true,
|
||||
agent_store: None,
|
||||
},
|
||||
)?;
|
||||
let mut state = load_heartbeat_state_entry(&store_path)?.expect("heartbeat state");
|
||||
let implementation = state
|
||||
.participants
|
||||
.iter_mut()
|
||||
.find(|participant| participant.role_id == "implementation")
|
||||
.expect("implementation participant exists");
|
||||
implementation
|
||||
.pending_turn
|
||||
.as_mut()
|
||||
.expect("running implementation turn exists")
|
||||
.started_at = "2026-06-17T00:00:00+00:00".to_string();
|
||||
write_heartbeat_state_entry(&store_path, &state)?;
|
||||
|
||||
let repaired = recover_stale_heartbeat_store(
|
||||
&store_path,
|
||||
&artifact_dir,
|
||||
HeartbeatStaleTurnRepairOptions {
|
||||
max_age_seconds: 60,
|
||||
now_utc: Some("2026-06-17T00:05:00+00:00".to_string()),
|
||||
reason:
|
||||
"Unit test simulates a stale worker lane that needs operator-safe recovery."
|
||||
.to_string(),
|
||||
},
|
||||
)?;
|
||||
assert_eq!(repaired["repaired"], serde_json::json!(1));
|
||||
let receipt = load_latest_heartbeat_stale_turn_repair_receipt(&store_path)?
|
||||
.expect("stale-turn repair receipt exists");
|
||||
assert_eq!(receipt.role_id, "implementation");
|
||||
assert_eq!(receipt.action_id, "heartbeat.implementation.work");
|
||||
assert_eq!(receipt.stale_age_seconds, 300);
|
||||
assert!(!receipt.private_state_exposed);
|
||||
|
||||
let state = load_heartbeat_state_entry(&store_path)?.expect("heartbeat state");
|
||||
let implementation = state
|
||||
.participants
|
||||
.iter()
|
||||
.find(|participant| participant.role_id == "implementation")
|
||||
.expect("implementation participant exists");
|
||||
assert!(implementation.pending_turn.is_none());
|
||||
|
||||
let next = 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: "after-stale-repair".to_string(),
|
||||
source_scene_ref: "test/stale".to_string(),
|
||||
defer_completion: true,
|
||||
agent_store: None,
|
||||
},
|
||||
)?;
|
||||
assert_eq!(next["event"]["selectedRole"], "implementation");
|
||||
assert_eq!(next["event"]["turnStatus"], "running");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ghostlight_scene_heartbeat_selects_character_turns() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ pub const HEARTBEAT_COGNITION_SCHEMA_VERSION: &str = "epiphany.agent_heartbeat_c
|
|||
pub const HEARTBEAT_STATUS_SCHEMA_VERSION: &str = "epiphany.agent_heartbeat_status.v0";
|
||||
pub const INITIATIVE_SCHEMA_VERSION: &str = "ghostlight.initiative_schedule.v0";
|
||||
pub const VOID_ROUTINE_SCHEMA_VERSION: &str = "epiphany.void_routine.v0";
|
||||
pub const HEARTBEAT_STALE_TURN_REPAIR_TYPE: &str = "epiphany.heartbeat.stale_turn_repair";
|
||||
pub const HEARTBEAT_STALE_TURN_REPAIR_SCHEMA_VERSION: &str =
|
||||
"epiphany.heartbeat.stale_turn_repair.v0";
|
||||
pub const HEARTBEAT_STALE_TURN_REPAIR_LATEST_KEY: &str = "heartbeat/stale-turn-repair/latest";
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
|
|
@ -78,6 +82,42 @@ pub struct EpiphanyHeartbeatCognitionEntry {
|
|||
pub reactions: Option<HeartbeatAgentReactions>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.heartbeat.stale_turn_repair",
|
||||
schema = "EpiphanyHeartbeatStaleTurnRepairReceipt"
|
||||
)]
|
||||
pub struct EpiphanyHeartbeatStaleTurnRepairReceipt {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub receipt_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub repaired_at_utc: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub role_id: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub agent_id: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub action_id: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub schedule_id: String,
|
||||
#[cultcache(key = 7)]
|
||||
pub started_at_utc: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub stale_age_seconds: i64,
|
||||
#[cultcache(key = 9)]
|
||||
pub reason: String,
|
||||
#[cultcache(key = 10)]
|
||||
pub resulting_status: String,
|
||||
#[cultcache(key = 11)]
|
||||
pub next_ready_at: f64,
|
||||
#[cultcache(key = 12)]
|
||||
pub private_state_exposed: bool,
|
||||
#[cultcache(key = 13)]
|
||||
pub notes: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.agent_heartbeat",
|
||||
|
|
@ -873,6 +913,13 @@ pub struct HeartbeatCompleteOptions {
|
|||
pub action_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct HeartbeatStaleTurnRepairOptions {
|
||||
pub max_age_seconds: i64,
|
||||
pub now_utc: Option<String>,
|
||||
pub reason: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct VoidRoutineOptions {
|
||||
pub agent_store: Option<std::path::PathBuf>,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
use super::EpiphanyHeartbeatCognitionEntry;
|
||||
use super::EpiphanyHeartbeatStaleTurnRepairReceipt;
|
||||
use super::EpiphanyHeartbeatStateEntry;
|
||||
use super::HEARTBEAT_ARENA_MAINTENANCE;
|
||||
use super::HEARTBEAT_ARENA_SCENE;
|
||||
use super::HEARTBEAT_COGNITION_KEY;
|
||||
use super::HEARTBEAT_COGNITION_SCHEMA_VERSION;
|
||||
use super::HEARTBEAT_STALE_TURN_REPAIR_LATEST_KEY;
|
||||
use super::HEARTBEAT_STALE_TURN_REPAIR_SCHEMA_VERSION;
|
||||
use super::HEARTBEAT_STATE_KEY;
|
||||
use super::HEARTBEAT_STATE_SCHEMA_VERSION;
|
||||
use super::LegacyHeartbeatStateWithCognition;
|
||||
|
|
@ -23,6 +26,7 @@ pub fn heartbeat_state_cache(store_path: impl AsRef<Path>) -> Result<CultCache>
|
|||
let mut cache = CultCache::new();
|
||||
cache.register_entry_type::<EpiphanyHeartbeatStateEntry>()?;
|
||||
cache.register_entry_type::<EpiphanyHeartbeatCognitionEntry>()?;
|
||||
cache.register_entry_type::<EpiphanyHeartbeatStaleTurnRepairReceipt>()?;
|
||||
cache.add_generic_backing_store(SingleFileMessagePackBackingStore::new(store_path.as_ref()));
|
||||
cache.pull_all_backing_stores()?;
|
||||
Ok(cache)
|
||||
|
|
@ -32,6 +36,7 @@ fn legacy_heartbeat_state_cache(store_path: impl AsRef<Path>) -> Result<CultCach
|
|||
let mut cache = CultCache::new();
|
||||
cache.register_entry_type::<LegacyHeartbeatStateWithCognition>()?;
|
||||
cache.register_entry_type::<EpiphanyHeartbeatCognitionEntry>()?;
|
||||
cache.register_entry_type::<EpiphanyHeartbeatStaleTurnRepairReceipt>()?;
|
||||
cache.add_generic_backing_store(SingleFileMessagePackBackingStore::new(store_path.as_ref()));
|
||||
cache.pull_all_backing_stores()?;
|
||||
Ok(cache)
|
||||
|
|
@ -80,6 +85,66 @@ pub fn write_heartbeat_cognition_entry(
|
|||
cache.put(HEARTBEAT_COGNITION_KEY, cognition)
|
||||
}
|
||||
|
||||
pub fn write_heartbeat_stale_turn_repair_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
receipt: &EpiphanyHeartbeatStaleTurnRepairReceipt,
|
||||
) -> Result<EpiphanyHeartbeatStaleTurnRepairReceipt> {
|
||||
validate_heartbeat_stale_turn_repair_receipt(receipt)?;
|
||||
let mut cache = heartbeat_state_cache(store_path)?;
|
||||
let written = cache.put(receipt.receipt_id.clone(), receipt)?;
|
||||
cache.put(HEARTBEAT_STALE_TURN_REPAIR_LATEST_KEY, &written)?;
|
||||
Ok(written)
|
||||
}
|
||||
|
||||
pub fn load_latest_heartbeat_stale_turn_repair_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
) -> Result<Option<EpiphanyHeartbeatStaleTurnRepairReceipt>> {
|
||||
let cache = heartbeat_state_cache(store_path)?;
|
||||
cache.get::<EpiphanyHeartbeatStaleTurnRepairReceipt>(HEARTBEAT_STALE_TURN_REPAIR_LATEST_KEY)
|
||||
}
|
||||
|
||||
pub fn validate_heartbeat_stale_turn_repair_receipt(
|
||||
receipt: &EpiphanyHeartbeatStaleTurnRepairReceipt,
|
||||
) -> Result<()> {
|
||||
if receipt.schema_version != HEARTBEAT_STALE_TURN_REPAIR_SCHEMA_VERSION {
|
||||
return Err(anyhow!(
|
||||
"heartbeat stale-turn repair schema_version is {:?}, expected {:?}",
|
||||
receipt.schema_version,
|
||||
HEARTBEAT_STALE_TURN_REPAIR_SCHEMA_VERSION
|
||||
));
|
||||
}
|
||||
if receipt.private_state_exposed {
|
||||
return Err(anyhow!(
|
||||
"heartbeat stale-turn repair receipt must not expose private state"
|
||||
));
|
||||
}
|
||||
if receipt.receipt_id.trim().is_empty()
|
||||
|| receipt.role_id.trim().is_empty()
|
||||
|| receipt.agent_id.trim().is_empty()
|
||||
|| receipt.action_id.trim().is_empty()
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"heartbeat stale-turn repair receipt requires receipt, role, agent, and action ids"
|
||||
));
|
||||
}
|
||||
if receipt.stale_age_seconds < 0 {
|
||||
return Err(anyhow!(
|
||||
"heartbeat stale-turn repair receipt stale_age_seconds must be non-negative"
|
||||
));
|
||||
}
|
||||
if receipt.reason.trim().is_empty() {
|
||||
return Err(anyhow!(
|
||||
"heartbeat stale-turn repair receipt requires a reason"
|
||||
));
|
||||
}
|
||||
if receipt.resulting_status != "repaired" {
|
||||
return Err(anyhow!(
|
||||
"heartbeat stale-turn repair receipt resulting_status must be repaired"
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn validate_heartbeat_cognition(cognition: &EpiphanyHeartbeatCognitionEntry) -> Result<()> {
|
||||
if cognition.schema_version != HEARTBEAT_COGNITION_SCHEMA_VERSION {
|
||||
return Err(anyhow!(
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ mod continuity_gateway;
|
|||
mod cultmesh_integration;
|
||||
mod distillation;
|
||||
mod eyes_gateway;
|
||||
mod persona_turn;
|
||||
mod hands_gateway;
|
||||
mod heartbeat_state;
|
||||
mod memory_graph;
|
||||
mod mind_gateway;
|
||||
mod organ_dependencies;
|
||||
mod persona_turn;
|
||||
mod promotion;
|
||||
mod prompt_context;
|
||||
mod proposal;
|
||||
|
|
@ -58,9 +58,13 @@ pub use agent_launch::render_epiphany_coordinator_note;
|
|||
pub use agent_launch::render_epiphany_pre_compaction_checkpoint_intervention;
|
||||
pub use agent_launch::unique_strings;
|
||||
pub use agent_memory::AgentCanonicalTraitSeed;
|
||||
pub use agent_memory::AgentMemoryBundle;
|
||||
pub use agent_memory::AgentMemoryLifecycleAction;
|
||||
pub use agent_memory::AgentMemoryLifecycleOperation;
|
||||
pub use agent_memory::AgentMemoryReview;
|
||||
pub use agent_memory::AgentSelfPatch;
|
||||
pub use agent_memory::EpiphanyAgentMemoryEntry;
|
||||
pub use agent_memory::EpiphanyAgentStateSoaEntry;
|
||||
pub use agent_memory::EpiphanyOrganStateProfile;
|
||||
pub use agent_memory::EpiphanyOrganStateProfileKind;
|
||||
pub use agent_memory::GhostlightEvent;
|
||||
|
|
@ -73,14 +77,19 @@ pub use agent_memory::PERSONA_STATE_SCHEMA_VERSION;
|
|||
pub use agent_memory::agent_memory_role_ids;
|
||||
pub use agent_memory::agent_memory_status;
|
||||
pub use agent_memory::apply_agent_canonical_trait_seeds;
|
||||
pub use agent_memory::apply_agent_memory_lifecycle_operation;
|
||||
pub use agent_memory::apply_agent_self_patch;
|
||||
pub use agent_memory::apply_agent_self_patch_document;
|
||||
pub use agent_memory::load_agent_memory_entry_for_role;
|
||||
pub use agent_memory::load_agent_state_soa_entry;
|
||||
pub use agent_memory::migrate_agent_memory_json_dir_to_cultcache;
|
||||
pub use agent_memory::organ_state_profile_for_role;
|
||||
pub use agent_memory::project_agent_memory_to_json_dir;
|
||||
pub use agent_memory::project_persona_state_for_role;
|
||||
pub use agent_memory::project_persona_state_from_entry;
|
||||
pub use agent_memory::refresh_agent_state_soa;
|
||||
pub use agent_memory::repair_agent_memory_store;
|
||||
pub use agent_memory::review_agent_memory_lifecycle_operation;
|
||||
pub use agent_memory::review_agent_self_patch;
|
||||
pub use agent_memory::review_agent_self_patch_document;
|
||||
pub use agent_memory::validate_agent_memory_store;
|
||||
|
|
@ -105,16 +114,74 @@ pub use cultcache_rs::CultCacheEnvelope;
|
|||
pub use cultcache_rs::DatabaseEntry;
|
||||
pub use cultcache_rs::PushAllOptions;
|
||||
pub use cultcache_rs::SingleFileMessagePackBackingStore;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_INTENT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_BODY_CHANGE_PUBLICATION_RECEIPT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_COLLABORATION_FEEDBACK_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_COLLABORATION_FEEDBACK_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_COLLABORATION_FEEDBACK_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_CONTRACT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_CONTRACT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_GITHUB_PUBLICATION_RECEIPT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_CONTINUITY_CONTRACT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_CONTINUITY_CONTRACT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_COORDINATOR_RUN_RECEIPT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_COORDINATOR_RUN_RECEIPT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_POKE_INTENT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_POKE_RECEIPT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_RESTART_POLICY_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_RESTART_POLICY_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_SCHEDULER_RECEIPT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_SCHEDULER_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_SCHEDULER_RECEIPT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_STATUS_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_STATUS_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_TOOL_CAPABILITY_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_TOOL_CAPABILITY_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_TOOL_INVOCATION_INTENT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_TOOL_INVOCATION_INTENT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_TOOL_INVOCATION_INTENT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_TOOL_INVOCATION_RECEIPT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_TOOL_INVOCATION_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_DAEMON_TOOL_INVOCATION_RECEIPT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_EVE_CONNECTION_INTENT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_EVE_CONNECTION_INTENT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_EVE_CONNECTION_INTENT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_EVE_CONNECTION_RECEIPT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_EVE_CONNECTION_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_EVE_CONNECTION_RECEIPT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_EVE_SURFACE_STATE_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_EVE_SURFACE_STATE_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_EYES_CONTRACT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_EYES_CONTRACT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_GLOBAL_ROOM_POLICY_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_GLOBAL_ROOM_POLICY_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_GLOBAL_TIER;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_GLOBAL_VERSE_ID;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_HANDS_ACTION_GATE_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_HANDS_ACTION_GATE_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_HANDS_ACTION_GATE_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_HANDS_CONTRACT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_HANDS_CONTRACT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_IMAGINATION_CONSENSUS_RECEIPT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_IMAGINATION_CONSENSUS_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_IMAGINATION_CONSENSUS_RECEIPT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_INTERNAL_TIER;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_INTERNAL_VERSE_ID;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_LOCAL_AREA_TIER;
|
||||
|
|
@ -133,6 +200,12 @@ pub use cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_TYPE;
|
|||
pub use cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_STATUS_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_STATUS_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_STATUS_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_PERSONA_SPEECH_AUDIT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_PERSONA_SPEECH_AUDIT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_PERSONA_SPEECH_AUDIT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_ROLE_REVIEW_EVENT_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_ROLE_REVIEW_EVENT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_ROLE_REVIEW_EVENT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_SOUL_CONTRACT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_SOUL_CONTRACT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_STATUS_KEY;
|
||||
|
|
@ -140,60 +213,163 @@ pub use cultmesh_integration::EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION;
|
|||
pub use cultmesh_integration::EPIPHANY_CULTMESH_STATUS_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_SUBSTRATE_GATE_CONTRACT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_SUBSTRATE_GATE_CONTRACT_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_SWARM_BRAKE_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_SWARM_BRAKE_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_SWARM_BRAKE_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_VERSE_POLICY_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_VERSE_POLICY_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_TYPE;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshAgentStateSoaSummaryEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshBifrostCollaborationFeedbackEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshBifrostContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshBifrostGithubPublicationReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshClusterTopologyEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshContinuityContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshCoordinatorRunReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonPokeIntentEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonPokeReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonRestartPolicyEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonSchedulerReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonStatusEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonToolCapabilityEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonToolInvocationIntentEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDaemonToolInvocationReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshDocuments;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshEveConnectionIntentEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshEveConnectionReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshEveSurfaceStateEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshEyesContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshGlobalRoomPolicyEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshHandsActionGateEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshHandsContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshImaginationConsensusReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshMindContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshOdinAdvertisementEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshOperatorRunIntentEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshOperatorRunReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshOperatorSnapshotEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshOperatorStatusEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshPersonaSpeechAuditEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshRoleReviewEventEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshSoulContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshStatusEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshSubstrateGateContractEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshSwarmBrakeEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshVersePolicyEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshWorkLoopTelemetryEntry;
|
||||
pub use cultmesh_integration::EpiphanyLocalVerseContext;
|
||||
pub use cultmesh_integration::EpiphanyLocalVerseContractSummary;
|
||||
pub use cultmesh_integration::EpiphanyLocalVerseWorkLoopSummary;
|
||||
pub use cultmesh_integration::default_epiphany_cultmesh_operator_status;
|
||||
pub use cultmesh_integration::default_epiphany_cultmesh_swarm_brake;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_agent_state_soa_summary_from_entry;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_bifrost_body_change_publication_intent;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_bifrost_body_change_publication_receipt_for_intent;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_bifrost_collaboration_feedback;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_bifrost_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_bifrost_github_publication_receipt_for_publication;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_continuity_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_coordinator_run_receipt_from_summary_json;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_daemon_poke_intent_from_status;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_daemon_poke_receipt_for_intent;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_daemon_statuses;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_daemon_tool_capabilities;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_daemon_tool_invocation_from_status_json;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_daemon_tool_invocation_intent_from_capability;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_daemon_tool_invocation_receipt_for_intent;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_eve_connection_intent_from_advertisement;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_eve_connection_receipt_for_intent;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_eve_surface_states;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_eyes_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_global_room_policies;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_hands_action_gate_from_summary_json;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_hands_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_imagination_consensus_receipt_for_feedback;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_mind_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_operator_snapshot_from_status_json;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_role_review_event_from_summary_json;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_soul_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_substrate_gate_contracts;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_verse_policies;
|
||||
pub use cultmesh_integration::epiphany_local_verse_work_loop_summary;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_cluster_topology;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_liveness;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_restart_policy;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_restart_policy_directory;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_service_lifecycle_receipts;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_daemon_tool_directory;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_eve_surface_directory;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_operator_snapshot;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_operator_status;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_status;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_swarm_brake;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_agent_state_soa_summary;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_bifrost_body_change_publication_intent;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_bifrost_body_change_publication_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_bifrost_collaboration_feedback;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_bifrost_github_publication_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_coordinator_run_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_poke_intent;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_poke_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_scheduler_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_tool_invocation_intent;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_tool_invocation_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_eve_connection_intent;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_eve_connection_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_hands_action_gate;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_imagination_consensus_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_operator_run_intent;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_operator_run_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_operator_snapshot;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_persona_speech_audit;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_role_review_event;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_work_loop_telemetry;
|
||||
pub use cultmesh_integration::open_epiphany_cultmesh_node;
|
||||
pub use cultmesh_integration::query_epiphany_local_verse_context;
|
||||
pub use cultmesh_integration::seed_epiphany_local_verse_context;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_agent_state_soa_summary;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_body_change_publication_intent;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_body_change_publication_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_collaboration_feedback;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_github_publication_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_continuity_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_coordinator_run_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_poke_intent;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_poke_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_restart_policy;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_scheduler_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_service_lifecycle_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_status;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_statuses;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_tool_capabilities;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_tool_invocation_intent;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_daemon_tool_invocation_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_eve_connection_intent;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_eve_connection_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_eve_surface_states;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_eyes_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_global_room_policies;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_hands_action_gate;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_hands_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_imagination_consensus_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_mind_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_operator_run_intent;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_operator_run_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_operator_snapshot;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_operator_status;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_persona_speech_audit;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_role_review_event;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_soul_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_status;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_substrate_gate_contracts;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_swarm_brake;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_verse_policies;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_work_loop_telemetry;
|
||||
pub use distillation::EpiphanyDistillInput;
|
||||
|
|
@ -226,27 +402,17 @@ pub use eyes_gateway::EyesCultNetContract;
|
|||
pub use eyes_gateway::EyesEvidencePacket;
|
||||
pub use eyes_gateway::default_eyes_cultnet_contracts;
|
||||
pub use eyes_gateway::eyes_evidence_packet_from_research_finding;
|
||||
pub use persona_turn::PERSONA_INTERPRETER_PROMPT_SCHEMA_VERSION;
|
||||
pub use persona_turn::PERSONA_PROJECTOR_PROMPT_SCHEMA_VERSION;
|
||||
pub use persona_turn::PERSONA_TURN_PROMPT_SCHEMA_VERSION;
|
||||
pub use persona_turn::PersonaIdentity;
|
||||
pub use persona_turn::PersonaInterpreterInput;
|
||||
pub use persona_turn::PersonaProjectorInput;
|
||||
pub use persona_turn::PersonaRepoActivity;
|
||||
pub use persona_turn::PersonaSocialAffordance;
|
||||
pub use persona_turn::PersonaTranscriptMessage;
|
||||
pub use persona_turn::PersonaTurnInput;
|
||||
pub use persona_turn::build_persona_interpreter_prompt;
|
||||
pub use persona_turn::build_persona_projector_prompt;
|
||||
pub use persona_turn::build_persona_turn_prompt;
|
||||
pub use persona_turn::persona_projected_surface_is_clean;
|
||||
pub use hands_gateway::*;
|
||||
pub use heartbeat_state::EpiphanyHeartbeatCognitionEntry;
|
||||
pub use heartbeat_state::EpiphanyHeartbeatStaleTurnRepairReceipt;
|
||||
pub use heartbeat_state::EpiphanyHeartbeatStateEntry;
|
||||
pub use heartbeat_state::GhostlightSceneParticipantSeed;
|
||||
pub use heartbeat_state::HEARTBEAT_COGNITION_KEY;
|
||||
pub use heartbeat_state::HEARTBEAT_COGNITION_SCHEMA_VERSION;
|
||||
pub use heartbeat_state::HEARTBEAT_COGNITION_TYPE;
|
||||
pub use heartbeat_state::HEARTBEAT_STALE_TURN_REPAIR_LATEST_KEY;
|
||||
pub use heartbeat_state::HEARTBEAT_STALE_TURN_REPAIR_SCHEMA_VERSION;
|
||||
pub use heartbeat_state::HEARTBEAT_STALE_TURN_REPAIR_TYPE;
|
||||
pub use heartbeat_state::HEARTBEAT_STATE_KEY;
|
||||
pub use heartbeat_state::HEARTBEAT_STATE_SCHEMA_VERSION;
|
||||
pub use heartbeat_state::HEARTBEAT_STATE_TYPE;
|
||||
|
|
@ -272,6 +438,7 @@ pub use heartbeat_state::HeartbeatPersonalityProjection;
|
|||
pub use heartbeat_state::HeartbeatPumpOptions;
|
||||
pub use heartbeat_state::HeartbeatQueueMentionOptions;
|
||||
pub use heartbeat_state::HeartbeatSelectionPolicy;
|
||||
pub use heartbeat_state::HeartbeatStaleTurnRepairOptions;
|
||||
pub use heartbeat_state::HeartbeatTickOptions;
|
||||
pub use heartbeat_state::VoidRoutineOptions;
|
||||
pub use heartbeat_state::complete_heartbeat_store;
|
||||
|
|
@ -283,14 +450,17 @@ pub use heartbeat_state::initialize_ghostlight_scene_heartbeat_store;
|
|||
pub use heartbeat_state::initialize_heartbeat_store;
|
||||
pub use heartbeat_state::load_heartbeat_cognition_entry;
|
||||
pub use heartbeat_state::load_heartbeat_state_entry;
|
||||
pub use heartbeat_state::load_latest_heartbeat_stale_turn_repair_receipt;
|
||||
pub use heartbeat_state::pump_heartbeat_store;
|
||||
pub use heartbeat_state::queue_heartbeat_pending_mention_store;
|
||||
pub use heartbeat_state::recover_stale_heartbeat_store;
|
||||
pub use heartbeat_state::run_void_routine_store;
|
||||
pub use heartbeat_state::tick_heartbeat_store;
|
||||
pub use heartbeat_state::update_heartbeat_heat_store;
|
||||
pub use heartbeat_state::validate_heartbeat_cognition;
|
||||
pub use heartbeat_state::validate_heartbeat_state;
|
||||
pub use heartbeat_state::write_heartbeat_cognition_entry;
|
||||
pub use heartbeat_state::write_heartbeat_stale_turn_repair_receipt;
|
||||
pub use heartbeat_state::write_heartbeat_state_entry;
|
||||
pub use memory_graph::EpiphanyMemoryEdgeKind;
|
||||
pub use memory_graph::EpiphanyMemoryEmbeddingManifest;
|
||||
|
|
@ -361,6 +531,20 @@ pub use organ_dependencies::evaluate_receipt_proof_profiles;
|
|||
pub use organ_dependencies::receipt_proof_evaluation_errors;
|
||||
pub use organ_dependencies::render_organ_dependencies;
|
||||
pub use organ_dependencies::render_organ_dependency;
|
||||
pub use persona_turn::PERSONA_INTERPRETER_PROMPT_SCHEMA_VERSION;
|
||||
pub use persona_turn::PERSONA_PROJECTOR_PROMPT_SCHEMA_VERSION;
|
||||
pub use persona_turn::PERSONA_TURN_PROMPT_SCHEMA_VERSION;
|
||||
pub use persona_turn::PersonaIdentity;
|
||||
pub use persona_turn::PersonaInterpreterInput;
|
||||
pub use persona_turn::PersonaProjectorInput;
|
||||
pub use persona_turn::PersonaRepoActivity;
|
||||
pub use persona_turn::PersonaSocialAffordance;
|
||||
pub use persona_turn::PersonaTranscriptMessage;
|
||||
pub use persona_turn::PersonaTurnInput;
|
||||
pub use persona_turn::build_persona_interpreter_prompt;
|
||||
pub use persona_turn::build_persona_projector_prompt;
|
||||
pub use persona_turn::build_persona_turn_prompt;
|
||||
pub use persona_turn::persona_projected_surface_is_clean;
|
||||
pub use promotion::EpiphanyPromotionDecision;
|
||||
pub use promotion::EpiphanyPromotionInput;
|
||||
pub use promotion::EpiphanyStateReplacementValidationInput;
|
||||
|
|
@ -440,6 +624,7 @@ pub use runtime_spine::put_hands_action_review;
|
|||
pub use runtime_spine::put_hands_command_receipt;
|
||||
pub use runtime_spine::put_hands_commit_receipt;
|
||||
pub use runtime_spine::put_hands_patch_receipt;
|
||||
pub use runtime_spine::put_hands_pr_receipt;
|
||||
pub use runtime_spine::put_mind_gateway_review;
|
||||
pub use runtime_spine::put_mind_state_commit_receipt;
|
||||
pub use runtime_spine::put_runtime_reorient_worker_result;
|
||||
|
|
@ -454,6 +639,7 @@ pub use runtime_spine::runtime_hands_action_review;
|
|||
pub use runtime_spine::runtime_hands_command_receipt;
|
||||
pub use runtime_spine::runtime_hands_commit_receipt;
|
||||
pub use runtime_spine::runtime_hands_patch_receipt;
|
||||
pub use runtime_spine::runtime_hands_pr_receipt;
|
||||
pub use runtime_spine::runtime_hands_receipt_chain_after;
|
||||
pub use runtime_spine::runtime_hello_frame;
|
||||
pub use runtime_spine::runtime_job_snapshot;
|
||||
|
|
|
|||
|
|
@ -392,8 +392,7 @@ mod tests {
|
|||
themes: vec![
|
||||
HeartbeatIncubationTheme {
|
||||
theme_id: "theme-body-soul".to_string(),
|
||||
summary: "Modeling and Soul keep touching evidence boundaries."
|
||||
.to_string(),
|
||||
summary: "Modeling and Soul keep touching evidence boundaries.".to_string(),
|
||||
latent_question: "Should this become doctrine?".to_string(),
|
||||
holding_close_because: "It is live but not settled.".to_string(),
|
||||
why_it_pulls: "It affects future review gates.".to_string(),
|
||||
|
|
|
|||
|
|
@ -114,8 +114,7 @@ fn role_snapshot() -> EpiphanyMemoryGraphSnapshot {
|
|||
profile: EpiphanyMemoryProfile::RoleSelf,
|
||||
kind: EpiphanyMemoryNodeKind::RoleMemory,
|
||||
title: "Typed boundaries".to_string(),
|
||||
claim: "Modeling remembers that typed boundaries keep the machine legible."
|
||||
.to_string(),
|
||||
claim: "Modeling remembers that typed boundaries keep the machine legible.".to_string(),
|
||||
question: "Which boundary is currently lying?".to_string(),
|
||||
tension: String::new(),
|
||||
action_implication: "Prefer one owned graph store over profile-local stores."
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use serde::Serialize;
|
|||
pub const PERSONA_PROJECTOR_PROMPT_SCHEMA_VERSION: &str =
|
||||
"epiphany.imagination_persona_projector_prompt.v0";
|
||||
pub const PERSONA_TURN_PROMPT_SCHEMA_VERSION: &str = "epiphany.persona_turn_prompt.v0";
|
||||
pub const PERSONA_INTERPRETER_PROMPT_SCHEMA_VERSION: &str = "epiphany.persona_interpreter_prompt.v0";
|
||||
pub const PERSONA_INTERPRETER_PROMPT_SCHEMA_VERSION: &str =
|
||||
"epiphany.persona_interpreter_prompt.v0";
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
@ -398,7 +399,8 @@ mod tests {
|
|||
identity_id: "epiphany".to_string(),
|
||||
display_name: "Epiphany".to_string(),
|
||||
repo_name: "EpiphanyAgent".to_string(),
|
||||
public_description: "Pushy machine-saint Persona for typed agent substrate.".to_string(),
|
||||
public_description: "Pushy machine-saint Persona for typed agent substrate."
|
||||
.to_string(),
|
||||
jurisdiction: vec!["typed state and review-gated agency".to_string()],
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,209 @@ pub fn render_epiphany_prompt_context(input: &EpiphanyPromptContextInput) -> Str
|
|||
));
|
||||
}
|
||||
|
||||
if !input.local_verse.cluster_topology.is_empty() {
|
||||
lines.push("## Cluster Topology".to_string());
|
||||
for cluster in input.local_verse.cluster_topology.iter().take(7) {
|
||||
lines.push(format!(
|
||||
"- `{}` -> private Verse `{}`; body={}, daemon={}, Eve={}",
|
||||
cluster.display_name,
|
||||
cluster.private_verse_id,
|
||||
cluster.body_domain,
|
||||
cluster.daemon_id,
|
||||
cluster.eve_surface_id
|
||||
));
|
||||
}
|
||||
push_omitted_count(
|
||||
&mut lines,
|
||||
input.local_verse.cluster_topology.len(),
|
||||
7,
|
||||
"cluster topology rows",
|
||||
);
|
||||
}
|
||||
|
||||
if !input.local_verse.odin_advertisements.is_empty() {
|
||||
lines.push("## Odin Discovery".to_string());
|
||||
for advertisement in input.local_verse.odin_advertisements.iter().take(7) {
|
||||
lines.push(format!(
|
||||
"- `{}` advertises Verse `{}` via Eve `{}`; private_state_exposed={}",
|
||||
advertisement.cluster_id,
|
||||
advertisement.advertised_verse_id,
|
||||
advertisement.eve_surface_id,
|
||||
advertisement.private_state_exposed
|
||||
));
|
||||
}
|
||||
push_omitted_count(
|
||||
&mut lines,
|
||||
input.local_verse.odin_advertisements.len(),
|
||||
7,
|
||||
"Odin advertisements",
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(intent) = input.local_verse.latest_eve_connection_intent.as_ref() {
|
||||
lines.push("## Eve Collaboration".to_string());
|
||||
lines.push(format!(
|
||||
"- Intent `{}`: {} -> {} via {}; feedback_route={}; private_state_requested={}",
|
||||
intent.intent_id,
|
||||
intent.source_cluster_id,
|
||||
intent.target_cluster_id,
|
||||
intent.target_eve_surface_id,
|
||||
intent.feedback_route,
|
||||
intent.private_state_requested
|
||||
));
|
||||
if let Some(receipt) = input.local_verse.latest_eve_connection_receipt.as_ref() {
|
||||
lines.push(format!(
|
||||
"- Receipt `{}`: status={}, private_state_exposed={}",
|
||||
receipt.receipt_id, receipt.status, receipt.private_state_exposed
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if !input.local_verse.daemon_tool_capabilities.is_empty() {
|
||||
lines.push("## Daemon Tool Directory".to_string());
|
||||
for capability in input.local_verse.daemon_tool_capabilities.iter().take(10) {
|
||||
lines.push(format!(
|
||||
"- `{}` hosted by `{}` via `{}`: op={}, available_to_all_agents={}, gate={}",
|
||||
capability.capability_id,
|
||||
capability.host_daemon_id,
|
||||
capability.eve_surface_id,
|
||||
capability.operation,
|
||||
capability.available_to_all_agents,
|
||||
capability.authority_gate
|
||||
));
|
||||
}
|
||||
push_omitted_count(
|
||||
&mut lines,
|
||||
input.local_verse.daemon_tool_capabilities.len(),
|
||||
10,
|
||||
"daemon tool capabilities",
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(summary) = input.local_verse.latest_agent_state_soa_summary.as_ref() {
|
||||
lines.push("## Agent State SoA".to_string());
|
||||
lines.push(format!(
|
||||
"- Summary `{}`: rows={}, source={}, private_state_exposed={}",
|
||||
summary.summary_id,
|
||||
summary.row_count,
|
||||
summary.source_store,
|
||||
summary.private_state_exposed
|
||||
));
|
||||
for index in 0..summary.role_ids.len().min(7) {
|
||||
lines.push(format!(
|
||||
"- `{}` / `{}`: profile={}, contract={}, semantic={}, episodic={}, relationship={}, goals={}, values={}",
|
||||
summary.role_ids[index],
|
||||
summary.agent_ids.get(index).cloned().unwrap_or_default(),
|
||||
summary.profile_kinds.get(index).cloned().unwrap_or_default(),
|
||||
summary
|
||||
.portable_contracts
|
||||
.get(index)
|
||||
.cloned()
|
||||
.unwrap_or_default(),
|
||||
summary
|
||||
.semantic_memory_counts
|
||||
.get(index)
|
||||
.copied()
|
||||
.unwrap_or_default(),
|
||||
summary
|
||||
.episodic_memory_counts
|
||||
.get(index)
|
||||
.copied()
|
||||
.unwrap_or_default(),
|
||||
summary
|
||||
.relationship_memory_counts
|
||||
.get(index)
|
||||
.copied()
|
||||
.unwrap_or_default(),
|
||||
summary.goal_counts.get(index).copied().unwrap_or_default(),
|
||||
summary.value_counts.get(index).copied().unwrap_or_default()
|
||||
));
|
||||
}
|
||||
push_omitted_count(
|
||||
&mut lines,
|
||||
summary.role_ids.len(),
|
||||
7,
|
||||
"agent state SoA rows",
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(intent) = input
|
||||
.local_verse
|
||||
.latest_daemon_tool_invocation_intent
|
||||
.as_ref()
|
||||
{
|
||||
lines.push("## Daemon Tool Invocation".to_string());
|
||||
lines.push(format!(
|
||||
"- Intent `{}`: {} requested `{}` on `{}` via {}; gate={}; private_state_requested={}",
|
||||
intent.intent_id,
|
||||
intent.requesting_agent_id,
|
||||
intent.operation,
|
||||
intent.host_daemon_id,
|
||||
intent.eve_surface_id,
|
||||
intent.authority_gate,
|
||||
intent.private_state_requested
|
||||
));
|
||||
if let Some(receipt) = input
|
||||
.local_verse
|
||||
.latest_daemon_tool_invocation_receipt
|
||||
.as_ref()
|
||||
{
|
||||
lines.push(format!(
|
||||
"- Receipt `{}`: status={}, receipt_contract={}, private_state_exposed={}",
|
||||
receipt.receipt_id,
|
||||
receipt.status,
|
||||
receipt.receipt_contract_type,
|
||||
receipt.private_state_exposed
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(intent) = input
|
||||
.local_verse
|
||||
.latest_bifrost_body_change_publication_intent
|
||||
.as_ref()
|
||||
{
|
||||
lines.push("## Bifrost Publication Gate".to_string());
|
||||
lines.push(format!(
|
||||
"- Intent `{}`: {} -> {}; paths={}, verification_receipts={}, review_receipts={}, private_state_included={}",
|
||||
intent.intent_id,
|
||||
intent.source_agent_id,
|
||||
intent.target_repository,
|
||||
intent.changed_paths.len(),
|
||||
intent.verification_receipt_ids.len(),
|
||||
intent.review_receipt_ids.len(),
|
||||
intent.private_state_included
|
||||
));
|
||||
if let Some(receipt) = input
|
||||
.local_verse
|
||||
.latest_bifrost_body_change_publication_receipt
|
||||
.as_ref()
|
||||
{
|
||||
lines.push(format!(
|
||||
"- Receipt `{}`: status={}, ledger={}, github_receipt={}, private_state_exposed={}",
|
||||
receipt.receipt_id,
|
||||
receipt.status,
|
||||
receipt.bifrost_ledger_entry_id,
|
||||
receipt.github_publication_receipt_id,
|
||||
receipt.private_state_exposed
|
||||
));
|
||||
}
|
||||
if let Some(github) = input
|
||||
.local_verse
|
||||
.latest_bifrost_github_publication_receipt
|
||||
.as_ref()
|
||||
{
|
||||
lines.push(format!(
|
||||
"- GitHub `{}`: pr={}, hands_pr={}, ledger={}, private_state_exposed={}",
|
||||
github.receipt_id,
|
||||
github.pull_request_url,
|
||||
github.hands_pr_receipt_id,
|
||||
github.ledger_entry_id,
|
||||
github.private_state_exposed
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(status) = input.local_verse.operator_status.as_ref() {
|
||||
lines.push(format!(
|
||||
"- Operator status `{}`: {}",
|
||||
|
|
@ -51,6 +254,24 @@ pub fn render_epiphany_prompt_context(input: &EpiphanyPromptContextInput) -> Str
|
|||
));
|
||||
}
|
||||
|
||||
if let Some(summary) = input.local_verse.latest_work_loop_summary.as_ref() {
|
||||
lines.push("## Work Loop Receipt Digest".to_string());
|
||||
lines.push(format!(
|
||||
"- Telemetry `{}`: {} -> {}; hands=({}/{}/{}), changed_paths={}, source_refs={}, soul_receipts={}, verification_assertions={}",
|
||||
summary.telemetry_id,
|
||||
summary.source_stage,
|
||||
summary.target_stages.join(","),
|
||||
summary.hands_patch_receipt_id,
|
||||
summary.hands_command_receipt_id,
|
||||
summary.hands_commit_receipt_id,
|
||||
summary.changed_path_count,
|
||||
summary.source_ref_count,
|
||||
summary.soul_receipt_ids.len(),
|
||||
summary.verification_assertion_count
|
||||
));
|
||||
lines.push(format!("- {}", compact_line(&summary.sealed_preview_note)));
|
||||
}
|
||||
|
||||
if !input.local_verse.contract_summaries.is_empty() {
|
||||
lines.push("## Organ Contract Summary".to_string());
|
||||
for contract in input.local_verse.contract_summaries.iter().take(8) {
|
||||
|
|
@ -166,8 +387,25 @@ fn push_omitted_count(lines: &mut Vec<String>, total: usize, shown: usize, label
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::EPIPHANY_CULTMESH_INTERNAL_VERSE_ID;
|
||||
use crate::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION;
|
||||
use crate::EpiphanyAgentStateSoaEntry;
|
||||
use crate::EpiphanyCultMeshWorkLoopTelemetryEntry;
|
||||
use crate::epiphany_cultmesh_agent_state_soa_summary_from_entry;
|
||||
use crate::epiphany_cultmesh_bifrost_body_change_publication_intent;
|
||||
use crate::epiphany_cultmesh_bifrost_body_change_publication_receipt_for_intent;
|
||||
use crate::epiphany_cultmesh_bifrost_github_publication_receipt_for_publication;
|
||||
use crate::epiphany_cultmesh_daemon_tool_invocation_intent_from_capability;
|
||||
use crate::epiphany_cultmesh_daemon_tool_invocation_receipt_for_intent;
|
||||
use crate::query_epiphany_local_verse_context;
|
||||
use crate::seed_epiphany_local_verse_context;
|
||||
use crate::write_epiphany_cultmesh_agent_state_soa_summary;
|
||||
use crate::write_epiphany_cultmesh_bifrost_body_change_publication_intent;
|
||||
use crate::write_epiphany_cultmesh_bifrost_body_change_publication_receipt;
|
||||
use crate::write_epiphany_cultmesh_bifrost_github_publication_receipt;
|
||||
use crate::write_epiphany_cultmesh_daemon_tool_invocation_intent;
|
||||
use crate::write_epiphany_cultmesh_daemon_tool_invocation_receipt;
|
||||
use crate::write_epiphany_cultmesh_work_loop_telemetry;
|
||||
use epiphany_state_model::EpiphanyMemoryContextPacket;
|
||||
use epiphany_state_model::EpiphanyMemoryFreshnessStatus;
|
||||
use epiphany_state_model::EpiphanyMemorySummary;
|
||||
|
|
@ -177,6 +415,152 @@ mod tests {
|
|||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("epiphany-local-verse.ccmp");
|
||||
seed_epiphany_local_verse_context(&store, "epiphany-test", "2026-06-02T00:00:00Z")?;
|
||||
let seeded_verse = query_epiphany_local_verse_context(&store, "epiphany-test")?;
|
||||
let hands_action = seeded_verse
|
||||
.daemon_tool_capabilities
|
||||
.iter()
|
||||
.find(|capability| {
|
||||
capability.capability_id == "epiphany.cluster.hands.tool.repo-action"
|
||||
})
|
||||
.expect("Hands repo-action capability exists");
|
||||
let tool_intent = epiphany_cultmesh_daemon_tool_invocation_intent_from_capability(
|
||||
"daemon-tool-intent-prompt-test",
|
||||
"epiphany.Persona",
|
||||
"epiphany.cluster.persona",
|
||||
hands_action,
|
||||
"cultmesh://epiphany-local/hands-action-intent/prompt-test",
|
||||
"Persona requests Hands review through the daemon tool directory.",
|
||||
);
|
||||
write_epiphany_cultmesh_daemon_tool_invocation_intent(
|
||||
&store,
|
||||
"epiphany-test",
|
||||
tool_intent.clone(),
|
||||
)?;
|
||||
let tool_receipt = epiphany_cultmesh_daemon_tool_invocation_receipt_for_intent(
|
||||
"daemon-tool-receipt-prompt-test",
|
||||
&tool_intent,
|
||||
"accepted-for-hands-review",
|
||||
hands_action.receipt_contract_type.clone(),
|
||||
"cultmesh://epiphany-local/hands-action-review/prompt-test",
|
||||
"Hands accepted the invocation.",
|
||||
);
|
||||
write_epiphany_cultmesh_daemon_tool_invocation_receipt(
|
||||
&store,
|
||||
"epiphany-test",
|
||||
tool_receipt,
|
||||
)?;
|
||||
let bifrost_intent = epiphany_cultmesh_bifrost_body_change_publication_intent(
|
||||
"bifrost-publication-intent-prompt-test",
|
||||
"epiphany.cluster.hands",
|
||||
"epiphany.Hands",
|
||||
"repo:E:/Projects/EpiphanyAgent",
|
||||
"E:/Projects/EpiphanyAgent",
|
||||
"codex/perfect-machine-cultmesh",
|
||||
"Route body change through Bifrost before GitHub publication.",
|
||||
"Bifrost must ledger review, verification, credit, and GitHub routing.",
|
||||
vec!["epiphany-core/src/cultmesh_integration.rs".to_string()],
|
||||
vec!["soul-verdict-prompt-test".to_string()],
|
||||
vec!["maintainer-review-prompt-test".to_string()],
|
||||
vec!["epiphany.Hands".to_string()],
|
||||
vec!["GameCult/EpiphanyAgent".to_string()],
|
||||
);
|
||||
write_epiphany_cultmesh_bifrost_body_change_publication_intent(
|
||||
&store,
|
||||
"epiphany-test",
|
||||
bifrost_intent.clone(),
|
||||
)?;
|
||||
let bifrost_receipt = epiphany_cultmesh_bifrost_body_change_publication_receipt_for_intent(
|
||||
"bifrost-publication-receipt-prompt-test",
|
||||
&bifrost_intent,
|
||||
"accepted-for-github-publication",
|
||||
"bifrost-ledger-prompt-test",
|
||||
"github-publication-prompt-test",
|
||||
vec!["credit-receipt-prompt-test".to_string()],
|
||||
vec!["maintainer-review-prompt-test".to_string()],
|
||||
"https://github.com/GameCult/EpiphanyAgent/pull/prompt-test",
|
||||
);
|
||||
write_epiphany_cultmesh_bifrost_body_change_publication_receipt(
|
||||
&store,
|
||||
"epiphany-test",
|
||||
bifrost_receipt.clone(),
|
||||
)?;
|
||||
let github_receipt = epiphany_cultmesh_bifrost_github_publication_receipt_for_publication(
|
||||
"github-publication-receipt-prompt-test",
|
||||
&bifrost_receipt,
|
||||
"hands-pr-prompt-test",
|
||||
"E:/Projects/EpiphanyAgent",
|
||||
"codex/perfect-machine-cultmesh",
|
||||
"prompt-test",
|
||||
"dry-run-no-commit",
|
||||
"epiphany.Hands",
|
||||
);
|
||||
write_epiphany_cultmesh_bifrost_github_publication_receipt(
|
||||
&store,
|
||||
"epiphany-test",
|
||||
github_receipt,
|
||||
)?;
|
||||
write_epiphany_cultmesh_work_loop_telemetry(
|
||||
&store,
|
||||
EpiphanyCultMeshWorkLoopTelemetryEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION.to_string(),
|
||||
runtime_id: "epiphany-test".to_string(),
|
||||
verse_id: EPIPHANY_CULTMESH_INTERNAL_VERSE_ID.to_string(),
|
||||
telemetry_id: "work-loop-prompt-test".to_string(),
|
||||
thread_id: "thread-prompt-test".to_string(),
|
||||
produced_at_utc: "2026-06-18T00:00:00Z".to_string(),
|
||||
source_stage: "Hands".to_string(),
|
||||
target_stages: vec!["Soul".to_string(), "Modeling".to_string()],
|
||||
lower_bound_receipt_at: "2026-06-18T00:00:00Z".to_string(),
|
||||
hands_intent_id: "hands-intent-prompt-test".to_string(),
|
||||
hands_review_id: "hands-review-prompt-test".to_string(),
|
||||
hands_runtime_job_id: "hands-job-prompt-test".to_string(),
|
||||
substrate_gate_grant_receipt_id: "substrate-grant-prompt-test".to_string(),
|
||||
hands_patch_receipt_id: "hands-patch-prompt-test".to_string(),
|
||||
hands_command_receipt_id: "hands-command-prompt-test".to_string(),
|
||||
hands_commit_receipt_id: "hands-commit-prompt-test".to_string(),
|
||||
command: "cargo test".to_string(),
|
||||
exit_code: "0".to_string(),
|
||||
stdout_artifact: "stdout.log".to_string(),
|
||||
stderr_artifact: "stderr.log".to_string(),
|
||||
commit_sha: "abc123".to_string(),
|
||||
branch: "codex/perfect-machine-cultmesh".to_string(),
|
||||
changed_paths: vec!["epiphany-core/src/prompt_context.rs".to_string()],
|
||||
artifact_previews: vec!["sealed stdout preview should stay internal".to_string()],
|
||||
source_refs: vec!["epiphany-core/src/prompt_context.rs".to_string()],
|
||||
source_path_proof: vec!["source proof should stay internal".to_string()],
|
||||
soul_receipt_ids: vec!["soul-acceptance-prompt-test".to_string()],
|
||||
summary: "Hands consequence digest for prompt assembly.".to_string(),
|
||||
receipt_payload_previews: vec![
|
||||
"sealed patch payload should stay internal".to_string(),
|
||||
],
|
||||
commit_diff_preview: "diff --git sealed".to_string(),
|
||||
verification_assertions: vec!["prompt renders digest only".to_string()],
|
||||
},
|
||||
)?;
|
||||
let agent_state_soa = EpiphanyAgentStateSoaEntry {
|
||||
schema_version: "epiphany.agent_state_soa.v0".to_string(),
|
||||
generated_at: "2026-06-18T00:00:00Z".to_string(),
|
||||
source_store: "state/agents.msgpack".to_string(),
|
||||
role_ids: vec!["Persona".to_string(), "implementation".to_string()],
|
||||
agent_ids: vec!["epiphany.Persona".to_string(), "epiphany.hands".to_string()],
|
||||
display_names: vec!["Persona".to_string(), "Hands".to_string()],
|
||||
profile_kinds: vec!["Persona".to_string(), "WorkOrgan".to_string()],
|
||||
portable_contracts: vec![
|
||||
"gamecult.persona_state.v0".to_string(),
|
||||
"epiphany.work_organ_state.v0".to_string(),
|
||||
],
|
||||
semantic_memory_counts: vec![3, 2],
|
||||
episodic_memory_counts: vec![1, 0],
|
||||
relationship_memory_counts: vec![2, 0],
|
||||
goal_counts: vec![1, 1],
|
||||
value_counts: vec![4, 3],
|
||||
};
|
||||
let agent_state_summary = epiphany_cultmesh_agent_state_soa_summary_from_entry(
|
||||
"epiphany-test",
|
||||
"agent-state-soa-summary-prompt-test",
|
||||
&agent_state_soa,
|
||||
);
|
||||
write_epiphany_cultmesh_agent_state_soa_summary(&store, agent_state_summary)?;
|
||||
let local_verse = query_epiphany_local_verse_context(&store, "epiphany-test")?;
|
||||
let memory_context = EpiphanyMemoryContextPacket {
|
||||
id: "memctx-test".to_string(),
|
||||
|
|
@ -204,6 +588,33 @@ mod tests {
|
|||
assert!(rendered.contains("Odin"));
|
||||
assert!(rendered.contains("Yggdrasil"));
|
||||
assert!(rendered.contains("Bifrost"));
|
||||
assert!(rendered.contains("Cluster Topology"));
|
||||
assert!(rendered.contains("Odin Discovery"));
|
||||
assert!(rendered.contains("eve://epiphany/persona"));
|
||||
assert!(rendered.contains("private_state_exposed=false"));
|
||||
assert!(rendered.contains("Daemon Tool Directory"));
|
||||
assert!(rendered.contains("available_to_all_agents=true"));
|
||||
assert!(rendered.contains("Daemon Tool Invocation"));
|
||||
assert!(rendered.contains("daemon-tool-intent-prompt-test"));
|
||||
assert!(rendered.contains("receipt_contract=epiphany.hands.action_review"));
|
||||
assert!(rendered.contains("Agent State SoA"));
|
||||
assert!(rendered.contains("agent-state-soa-summary-prompt-test"));
|
||||
assert!(rendered.contains("gamecult.persona_state.v0"));
|
||||
assert!(rendered.contains("epiphany.work_organ_state.v0"));
|
||||
assert!(rendered.contains("Bifrost Publication Gate"));
|
||||
assert!(rendered.contains("bifrost-publication-intent-prompt-test"));
|
||||
assert!(rendered.contains("github_receipt=github-publication-prompt-test"));
|
||||
assert!(rendered.contains("github-publication-receipt-prompt-test"));
|
||||
assert!(rendered.contains("hands_pr=hands-pr-prompt-test"));
|
||||
assert!(rendered.contains("Work Loop Receipt Digest"));
|
||||
assert!(rendered.contains("work-loop-prompt-test"));
|
||||
assert!(rendered.contains("hands-patch-prompt-test"));
|
||||
assert!(rendered.contains("hands-command-prompt-test"));
|
||||
assert!(rendered.contains("hands-commit-prompt-test"));
|
||||
assert!(rendered.contains("exposes only this digest"));
|
||||
assert!(!rendered.contains("sealed patch payload should stay internal"));
|
||||
assert!(!rendered.contains("diff --git sealed"));
|
||||
assert!(!rendered.contains("sealed stdout preview should stay internal"));
|
||||
assert!(rendered.contains("gamecult-local"));
|
||||
assert!(rendered.contains("Shared graph law"));
|
||||
assert!(rendered.contains("Mind reviews durable state effects"));
|
||||
|
|
|
|||
|
|
@ -722,6 +722,7 @@ pub fn runtime_spine_cache(store_path: impl AsRef<Path>) -> Result<CultCache> {
|
|||
cache.register_entry_type::<HandsPatchReceipt>()?;
|
||||
cache.register_entry_type::<HandsCommandReceipt>()?;
|
||||
cache.register_entry_type::<HandsCommitReceipt>()?;
|
||||
cache.register_entry_type::<HandsPrReceipt>()?;
|
||||
cache.register_entry_type::<SoulVerdictReceipt>()?;
|
||||
cache.register_entry_type::<ContinuityRecoveryReceipt>()?;
|
||||
cache.register_entry_type::<EpiphanyOpenAiAdapterStatus>()?;
|
||||
|
|
@ -1419,6 +1420,43 @@ pub fn runtime_hands_commit_receipt(
|
|||
cache.get::<HandsCommitReceipt>(receipt_id)
|
||||
}
|
||||
|
||||
pub fn put_hands_pr_receipt(store_path: impl AsRef<Path>, receipt: &HandsPrReceipt) -> Result<()> {
|
||||
validate_non_empty(&receipt.receipt_id, "Hands PR receipt id")?;
|
||||
validate_non_empty(&receipt.intent_id, "Hands PR intent")?;
|
||||
validate_non_empty(&receipt.review_id, "Hands PR review")?;
|
||||
validate_non_empty(&receipt.runtime_job_id, "Hands PR runtime job")?;
|
||||
validate_non_empty(&receipt.commit_receipt_id, "Hands PR commit receipt")?;
|
||||
validate_non_empty(&receipt.commit_sha, "Hands PR commit sha")?;
|
||||
validate_non_empty(&receipt.branch, "Hands PR branch")?;
|
||||
validate_non_empty(&receipt.pull_request_url, "Hands PR url")?;
|
||||
validate_non_empty(&receipt.pull_request_number, "Hands PR number")?;
|
||||
validate_non_empty(&receipt.pull_request_title, "Hands PR title")?;
|
||||
validate_non_empty(
|
||||
&receipt.bifrost_publication_receipt_id,
|
||||
"Hands PR Bifrost publication receipt",
|
||||
)?;
|
||||
validate_non_empty(&receipt.summary, "Hands PR summary")?;
|
||||
validate_non_empty(&receipt.emitted_at, "Hands PR timestamp")?;
|
||||
if receipt.changed_paths.is_empty() {
|
||||
return Err(anyhow!("Hands PR receipt must name changed paths"));
|
||||
}
|
||||
let mut cache = runtime_spine_cache(store_path)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
require_identity(&cache)?;
|
||||
cache.put(&receipt.receipt_id, receipt)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn runtime_hands_pr_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
receipt_id: &str,
|
||||
) -> Result<Option<HandsPrReceipt>> {
|
||||
validate_non_empty(receipt_id, "Hands PR receipt id")?;
|
||||
let mut cache = runtime_spine_cache(store_path)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
cache.get::<HandsPrReceipt>(receipt_id)
|
||||
}
|
||||
|
||||
pub fn runtime_hands_receipt_chain_after(
|
||||
store_path: impl AsRef<Path>,
|
||||
after_timestamp: &str,
|
||||
|
|
@ -3656,6 +3694,19 @@ mod tests {
|
|||
"2026-05-06T00:07:10Z".to_string(),
|
||||
);
|
||||
put_hands_commit_receipt(&store, &hands_commit)?;
|
||||
let hands_pr = crate::hands_pr_receipt_for_review(
|
||||
"hands-pr-1".to_string(),
|
||||
&hands_intent,
|
||||
&hands_review,
|
||||
&hands_commit,
|
||||
"https://github.com/GameCult/EpiphanyAgent/pull/1".to_string(),
|
||||
"1".to_string(),
|
||||
"Publish focused patch".to_string(),
|
||||
"bifrost-publication-receipt-1".to_string(),
|
||||
"Published focused patch as pull request.".to_string(),
|
||||
"2026-05-06T00:07:20Z".to_string(),
|
||||
);
|
||||
put_hands_pr_receipt(&store, &hands_pr)?;
|
||||
let stored_intent = runtime_hands_action_intent(&store, "hands-intent-1")?
|
||||
.expect("Hands action intent should persist");
|
||||
assert_eq!(stored_intent, hands_intent);
|
||||
|
|
@ -3671,6 +3722,9 @@ mod tests {
|
|||
let stored_commit = runtime_hands_commit_receipt(&store, "hands-commit-1")?
|
||||
.expect("Hands commit receipt should persist");
|
||||
assert_eq!(stored_commit, hands_commit);
|
||||
let stored_pr = runtime_hands_pr_receipt(&store, "hands-pr-1")?
|
||||
.expect("Hands PR receipt should persist");
|
||||
assert_eq!(stored_pr, hands_pr);
|
||||
assert!(runtime_hands_receipt_chain_after(
|
||||
&store,
|
||||
"2026-05-06T00:06:45Z"
|
||||
|
|
|
|||
|
|
@ -1102,10 +1102,7 @@ mod tests {
|
|||
|
||||
let review = finding.self_persistence.as_ref().unwrap();
|
||||
assert_eq!(review.status, EpiphanyRoleSelfPersistenceStatus::Accepted);
|
||||
assert_eq!(
|
||||
review.target_agent_id.as_deref(),
|
||||
Some("epiphany.modeling")
|
||||
);
|
||||
assert_eq!(review.target_agent_id.as_deref(), Some("epiphany.modeling"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Reference in a new issue