Wire repo birth startup valve
This commit is contained in:
parent
62ddc39df4
commit
d5b30166a7
6 changed files with 554 additions and 32 deletions
|
|
@ -165,6 +165,107 @@ fn run_smoke() -> Result<Value> {
|
|||
"memory packet should write summary markdown",
|
||||
)?;
|
||||
|
||||
let init_store = artifacts.join("repo-initialization.msgpack");
|
||||
let startup = run_personality(
|
||||
&root,
|
||||
&[
|
||||
"startup",
|
||||
"--repo",
|
||||
cult_repo.to_str().unwrap_or_default(),
|
||||
"--baseline",
|
||||
baseline.to_str().unwrap_or_default(),
|
||||
"--artifact-dir",
|
||||
artifacts.join("startup-first").to_str().unwrap_or_default(),
|
||||
"--init-store",
|
||||
init_store.to_str().unwrap_or_default(),
|
||||
],
|
||||
)?;
|
||||
require(
|
||||
startup["action"] == "reviewInitializationPackets",
|
||||
"startup should request birth packet review before accepted records exist",
|
||||
)?;
|
||||
require(
|
||||
startup["generatedPackets"].as_array().map_or(0, Vec::len) == 2,
|
||||
"startup should generate personality and memory packets",
|
||||
)?;
|
||||
let startup_personality_packet = packet_for_kind(&startup, "repo-personality")?;
|
||||
let startup_memory_packet = packet_for_kind(&startup, "repo-memory")?;
|
||||
require(
|
||||
startup_personality_packet.exists(),
|
||||
"startup should write personality packet",
|
||||
)?;
|
||||
require(
|
||||
startup_memory_packet.exists(),
|
||||
"startup should write memory packet",
|
||||
)?;
|
||||
let accepted_personality = run_personality(
|
||||
&root,
|
||||
&[
|
||||
"accept-init",
|
||||
"--init-store",
|
||||
init_store.to_str().unwrap_or_default(),
|
||||
"--packet",
|
||||
startup_personality_packet.to_str().unwrap_or_default(),
|
||||
"--kind",
|
||||
"repo-personality",
|
||||
"--accepted-by",
|
||||
"smoke-self",
|
||||
"--summary",
|
||||
"Smoke accepted repo personality birth packet after review.",
|
||||
],
|
||||
)?;
|
||||
require(
|
||||
accepted_personality["record"]["kind"] == "repo-personality",
|
||||
"accept-init should record personality birth",
|
||||
)?;
|
||||
let accepted_memory = run_personality(
|
||||
&root,
|
||||
&[
|
||||
"accept-init",
|
||||
"--init-store",
|
||||
init_store.to_str().unwrap_or_default(),
|
||||
"--packet",
|
||||
startup_memory_packet.to_str().unwrap_or_default(),
|
||||
"--kind",
|
||||
"repo-memory",
|
||||
"--accepted-by",
|
||||
"smoke-self",
|
||||
"--summary",
|
||||
"Smoke accepted repo memory birth packet after review.",
|
||||
],
|
||||
)?;
|
||||
require(
|
||||
accepted_memory["record"]["kind"] == "repo-memory",
|
||||
"accept-init should record memory birth",
|
||||
)?;
|
||||
let startup_after_accept = run_personality(
|
||||
&root,
|
||||
&[
|
||||
"startup",
|
||||
"--repo",
|
||||
cult_repo.to_str().unwrap_or_default(),
|
||||
"--baseline",
|
||||
baseline.to_str().unwrap_or_default(),
|
||||
"--artifact-dir",
|
||||
artifacts
|
||||
.join("startup-after-accept")
|
||||
.to_str()
|
||||
.unwrap_or_default(),
|
||||
"--init-store",
|
||||
init_store.to_str().unwrap_or_default(),
|
||||
],
|
||||
)?;
|
||||
require(
|
||||
startup_after_accept["action"] == "continueStartup",
|
||||
"startup should not rerun birth packets after accepted records exist",
|
||||
)?;
|
||||
require(
|
||||
startup_after_accept["generatedPackets"]
|
||||
.as_array()
|
||||
.is_some_and(Vec::is_empty),
|
||||
"startup should generate no packets after accepted records exist",
|
||||
)?;
|
||||
|
||||
let status = run_personality(
|
||||
&root,
|
||||
&["status", "--store", store.to_str().unwrap_or_default()],
|
||||
|
|
@ -195,6 +296,10 @@ fn run_smoke() -> Result<Value> {
|
|||
"memoryPacketPath": memory_packet_path,
|
||||
"memoryPromptPath": memory_prompt_path,
|
||||
"memorySummaryPath": memory_summary_path,
|
||||
"initStore": init_store,
|
||||
"startupPersonalityPacket": startup_personality_packet,
|
||||
"startupMemoryPacket": startup_memory_packet,
|
||||
"startupAfterAcceptAction": startup_after_accept["action"],
|
||||
"repoCount": scout["repoCount"],
|
||||
"roleProjections": status["roleProjections"],
|
||||
}))
|
||||
|
|
@ -299,6 +404,19 @@ fn path_value(value: &Value, key: &str) -> Result<PathBuf> {
|
|||
.ok_or_else(|| anyhow!("missing path value {key}"))
|
||||
}
|
||||
|
||||
fn packet_for_kind(value: &Value, kind: &str) -> Result<PathBuf> {
|
||||
value["generatedPackets"]
|
||||
.as_array()
|
||||
.and_then(|packets| {
|
||||
packets
|
||||
.iter()
|
||||
.find(|packet| packet["kind"] == kind)
|
||||
.and_then(|packet| packet["packetPath"].as_str())
|
||||
})
|
||||
.map(PathBuf::from)
|
||||
.ok_or_else(|| anyhow!("missing generated packet for {kind}"))
|
||||
}
|
||||
|
||||
fn require(condition: bool, message: &str) -> Result<()> {
|
||||
if condition {
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ const ROLE_PROJECTION_SCHEMA_VERSION: &str = "epiphany.role_personality_projecti
|
|||
const ARTIFACT_SCHEMA_VERSION: &str = "epiphany.repo_personality_artifacts.v0";
|
||||
const DISTILLER_PACKET_SCHEMA_VERSION: &str = "epiphany.repo_personality_distiller_packet.v0";
|
||||
const MEMORY_DISTILLER_PACKET_SCHEMA_VERSION: &str = "epiphany.repo_memory_distiller_packet.v0";
|
||||
const INITIALIZATION_RECORD_SCHEMA_VERSION: &str = "epiphany.repo_initialization_record.v0";
|
||||
const REPO_PERSONALITY_DISTILLER_PROMPT: &str =
|
||||
include_str!("../prompts/repo_personality_distiller.md");
|
||||
const REPO_MEMORY_DISTILLER_PROMPT: &str = include_str!("../prompts/repo_memory_distiller.md");
|
||||
|
|
@ -197,6 +198,34 @@ pub struct RolePersonalityProjection {
|
|||
pub evidence_refs: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.repo_initialization_record",
|
||||
schema = "EpiphanyRepoInitializationRecord"
|
||||
)]
|
||||
pub struct RepoInitializationRecord {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub record_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub repo_id: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub repo_path: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub kind: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub source_packet_schema_version: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub source_packet_path: String,
|
||||
#[cultcache(key = 7)]
|
||||
pub accepted_at: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub accepted_by: String,
|
||||
#[cultcache(key = 9)]
|
||||
pub summary: String,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let mut args = env::args().skip(1);
|
||||
let Some(command) = args.next() else {
|
||||
|
|
@ -208,6 +237,8 @@ fn main() -> Result<()> {
|
|||
"project" => run_project(parse_project_args(args)?),
|
||||
"agent-packet" => run_agent_packet(parse_packet_args(args, "agent-packet")?),
|
||||
"memory-packet" => run_memory_packet(parse_packet_args(args, "memory-packet")?),
|
||||
"startup" => run_startup(parse_startup_args(args)?),
|
||||
"accept-init" => run_accept_init(parse_accept_init_args(args)?),
|
||||
"status" => run_status(parse_status_args(args)?),
|
||||
other => Err(anyhow!("unknown command {other:?}")),
|
||||
}?;
|
||||
|
|
@ -229,6 +260,23 @@ struct ProjectArgs {
|
|||
artifact_dir: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct StartupArgs {
|
||||
repo: PathBuf,
|
||||
baseline: PathBuf,
|
||||
artifact_dir: PathBuf,
|
||||
init_store: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct AcceptInitArgs {
|
||||
init_store: PathBuf,
|
||||
packet: PathBuf,
|
||||
kind: String,
|
||||
accepted_by: String,
|
||||
summary: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct StatusArgs {
|
||||
store: PathBuf,
|
||||
|
|
@ -303,6 +351,76 @@ fn parse_project_args(args: impl Iterator<Item = String>) -> Result<ProjectArgs>
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_startup_args(args: impl Iterator<Item = String>) -> Result<StartupArgs> {
|
||||
let mut repo = None;
|
||||
let mut baseline = None;
|
||||
let mut artifact_dir = None;
|
||||
let mut init_store = None;
|
||||
parse_named_args(args, |name, value| match name {
|
||||
"--repo" => {
|
||||
repo = Some(PathBuf::from(value));
|
||||
Ok(())
|
||||
}
|
||||
"--baseline" => {
|
||||
baseline = Some(PathBuf::from(value));
|
||||
Ok(())
|
||||
}
|
||||
"--artifact-dir" => {
|
||||
artifact_dir = Some(PathBuf::from(value));
|
||||
Ok(())
|
||||
}
|
||||
"--init-store" => {
|
||||
init_store = Some(PathBuf::from(value));
|
||||
Ok(())
|
||||
}
|
||||
other => Err(anyhow!("unexpected startup argument {other}")),
|
||||
})?;
|
||||
Ok(StartupArgs {
|
||||
repo: repo.context("missing --repo")?,
|
||||
baseline: baseline.context("missing --baseline")?,
|
||||
artifact_dir: artifact_dir.context("missing --artifact-dir")?,
|
||||
init_store: init_store.context("missing --init-store")?,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_accept_init_args(args: impl Iterator<Item = String>) -> Result<AcceptInitArgs> {
|
||||
let mut init_store = None;
|
||||
let mut packet = None;
|
||||
let mut kind = None;
|
||||
let mut accepted_by = Some("Self".to_string());
|
||||
let mut summary = None;
|
||||
parse_named_args(args, |name, value| match name {
|
||||
"--init-store" => {
|
||||
init_store = Some(PathBuf::from(value));
|
||||
Ok(())
|
||||
}
|
||||
"--packet" => {
|
||||
packet = Some(PathBuf::from(value));
|
||||
Ok(())
|
||||
}
|
||||
"--kind" => {
|
||||
kind = Some(value);
|
||||
Ok(())
|
||||
}
|
||||
"--accepted-by" => {
|
||||
accepted_by = Some(value);
|
||||
Ok(())
|
||||
}
|
||||
"--summary" => {
|
||||
summary = Some(value);
|
||||
Ok(())
|
||||
}
|
||||
other => Err(anyhow!("unexpected accept-init argument {other}")),
|
||||
})?;
|
||||
Ok(AcceptInitArgs {
|
||||
init_store: init_store.context("missing --init-store")?,
|
||||
packet: packet.context("missing --packet")?,
|
||||
kind: kind.context("missing --kind")?,
|
||||
accepted_by: accepted_by.unwrap_or_else(|| "Self".to_string()),
|
||||
summary,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_status_args(args: impl Iterator<Item = String>) -> Result<StatusArgs> {
|
||||
let mut store = None;
|
||||
parse_named_args(args, |name, value| match name {
|
||||
|
|
@ -416,26 +534,11 @@ fn run_scout(args: ScoutArgs) -> Result<Value> {
|
|||
fn run_project(args: ProjectArgs) -> Result<Value> {
|
||||
fs::create_dir_all(&args.artifact_dir)
|
||||
.with_context(|| format!("failed to create {}", args.artifact_dir.display()))?;
|
||||
let mut baseline = repo_personality_cache(&args.baseline)?;
|
||||
baseline.pull_all_backing_stores()?;
|
||||
let reports = baseline.get_all::<RepoTerrainReport>()?;
|
||||
let target_id = repo_id(&args.repo);
|
||||
let report = reports
|
||||
.iter()
|
||||
.find(|report| report.repo_id == target_id || same_path(&report.path, &args.repo))
|
||||
.cloned()
|
||||
.unwrap_or_else(|| scout_repo(&args.repo).expect("target repo should be scoutable"));
|
||||
let profile = reduce_report(&report);
|
||||
|
||||
let store_path = args.artifact_dir.join("projection.msgpack");
|
||||
let mut cache = repo_personality_cache(&store_path)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
cache.put::<RepoTerrainReport>(report.repo_id.clone(), &report)?;
|
||||
cache.put::<RepoPersonalityProfile>(profile.repo_id.clone(), &profile)?;
|
||||
for projection in &profile.role_modulations {
|
||||
cache.put::<RolePersonalityProjection>(projection.projection_id.clone(), projection)?;
|
||||
}
|
||||
|
||||
let ProjectedRepo {
|
||||
store_path,
|
||||
report,
|
||||
profile,
|
||||
} = project_repo_to_store(&args.repo, &args.baseline, &args.artifact_dir)?;
|
||||
let summary = json!({
|
||||
"schemaVersion": ARTIFACT_SCHEMA_VERSION,
|
||||
"mode": "project",
|
||||
|
|
@ -461,6 +564,45 @@ fn run_project(args: ProjectArgs) -> Result<Value> {
|
|||
Ok(summary)
|
||||
}
|
||||
|
||||
struct ProjectedRepo {
|
||||
store_path: PathBuf,
|
||||
report: RepoTerrainReport,
|
||||
profile: RepoPersonalityProfile,
|
||||
}
|
||||
|
||||
fn project_repo_to_store(
|
||||
repo: &Path,
|
||||
baseline_path: &Path,
|
||||
artifact_dir: &Path,
|
||||
) -> Result<ProjectedRepo> {
|
||||
fs::create_dir_all(artifact_dir)
|
||||
.with_context(|| format!("failed to create {}", artifact_dir.display()))?;
|
||||
let mut baseline = repo_personality_cache(baseline_path)?;
|
||||
baseline.pull_all_backing_stores()?;
|
||||
let reports = baseline.get_all::<RepoTerrainReport>()?;
|
||||
let target_id = repo_id(repo);
|
||||
let report = reports
|
||||
.iter()
|
||||
.find(|report| report.repo_id == target_id || same_path(&report.path, repo))
|
||||
.cloned()
|
||||
.unwrap_or_else(|| scout_repo(repo).expect("target repo should be scoutable"));
|
||||
let profile = reduce_report(&report);
|
||||
|
||||
let store_path = artifact_dir.join("projection.msgpack");
|
||||
let mut cache = repo_personality_cache(&store_path)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
cache.put::<RepoTerrainReport>(report.repo_id.clone(), &report)?;
|
||||
cache.put::<RepoPersonalityProfile>(profile.repo_id.clone(), &profile)?;
|
||||
for projection in &profile.role_modulations {
|
||||
cache.put::<RolePersonalityProjection>(projection.projection_id.clone(), projection)?;
|
||||
}
|
||||
Ok(ProjectedRepo {
|
||||
store_path,
|
||||
report,
|
||||
profile,
|
||||
})
|
||||
}
|
||||
|
||||
fn run_status(args: StatusArgs) -> Result<Value> {
|
||||
let mut cache = repo_personality_cache(&args.store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
|
|
@ -478,6 +620,142 @@ fn run_status(args: StatusArgs) -> Result<Value> {
|
|||
}))
|
||||
}
|
||||
|
||||
fn run_startup(args: StartupArgs) -> Result<Value> {
|
||||
fs::create_dir_all(&args.artifact_dir)
|
||||
.with_context(|| format!("failed to create {}", args.artifact_dir.display()))?;
|
||||
let target_repo_id = repo_id(&args.repo);
|
||||
let accepted = accepted_initialization_kinds(&args.init_store, &target_repo_id)?;
|
||||
let personality_ready = accepted.contains("repo-personality");
|
||||
let memory_ready = accepted.contains("repo-memory");
|
||||
let mut generated_packets = Vec::new();
|
||||
let mut required_actions = Vec::new();
|
||||
let mut projection_store = None;
|
||||
|
||||
if !personality_ready || !memory_ready {
|
||||
let projection_dir = args.artifact_dir.join("projection");
|
||||
let projected = project_repo_to_store(&args.repo, &args.baseline, &projection_dir)?;
|
||||
projection_store = Some(projected.store_path.clone());
|
||||
if !personality_ready {
|
||||
let result = run_agent_packet(AgentPacketArgs {
|
||||
store: projected.store_path.clone(),
|
||||
artifact_dir: args.artifact_dir.join("repo-personality"),
|
||||
repo_id: Some(projected.profile.repo_id.clone()),
|
||||
})?;
|
||||
required_actions.push("reviewRepoPersonalityInitialization");
|
||||
generated_packets.push(json!({
|
||||
"kind": "repo-personality",
|
||||
"packetPath": result["packetPath"],
|
||||
"promptPath": result["promptPath"],
|
||||
"summaryPath": result["summaryPath"],
|
||||
}));
|
||||
}
|
||||
if !memory_ready {
|
||||
let result = run_memory_packet(AgentPacketArgs {
|
||||
store: projected.store_path.clone(),
|
||||
artifact_dir: args.artifact_dir.join("repo-memory"),
|
||||
repo_id: Some(projected.profile.repo_id.clone()),
|
||||
})?;
|
||||
required_actions.push("reviewRepoMemoryInitialization");
|
||||
generated_packets.push(json!({
|
||||
"kind": "repo-memory",
|
||||
"packetPath": result["packetPath"],
|
||||
"promptPath": result["promptPath"],
|
||||
"summaryPath": result["summaryPath"],
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
let action = if generated_packets.is_empty() {
|
||||
"continueStartup"
|
||||
} else {
|
||||
"reviewInitializationPackets"
|
||||
};
|
||||
let result = json!({
|
||||
"schemaVersion": ARTIFACT_SCHEMA_VERSION,
|
||||
"mode": "startup",
|
||||
"action": action,
|
||||
"repoId": target_repo_id,
|
||||
"repo": args.repo,
|
||||
"baseline": args.baseline,
|
||||
"artifactDir": args.artifact_dir,
|
||||
"initStore": args.init_store,
|
||||
"acceptedKinds": accepted,
|
||||
"missingKinds": initialization_kinds()
|
||||
.iter()
|
||||
.filter(|kind| !accepted.iter().any(|accepted| accepted == *kind))
|
||||
.copied()
|
||||
.collect::<Vec<_>>(),
|
||||
"projectionStore": projection_store,
|
||||
"generatedPackets": generated_packets,
|
||||
"requiredActions": required_actions,
|
||||
"requiresReview": action == "reviewInitializationPackets",
|
||||
"nextSafeMove": if action == "continueStartup" {
|
||||
"Startup birth records are accepted; leave later personality and memory movement to heartbeat, mood, evidence, sleep, and reviewed selfPatch."
|
||||
} else {
|
||||
"Self reviews generated birth packets, runs the relevant distiller lanes, applies accepted selfPatch candidates through agent memory review, then records accept-init for each completed birth rite."
|
||||
}
|
||||
});
|
||||
write_json(
|
||||
&args
|
||||
.artifact_dir
|
||||
.join("repo-initialization-startup-summary.json"),
|
||||
&result,
|
||||
)?;
|
||||
write_text(
|
||||
&args
|
||||
.artifact_dir
|
||||
.join("repo-initialization-startup-summary.md"),
|
||||
&render_startup_markdown(&result),
|
||||
)?;
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn run_accept_init(args: AcceptInitArgs) -> Result<Value> {
|
||||
let raw = fs::read_to_string(&args.packet)
|
||||
.with_context(|| format!("failed to read {}", args.packet.display()))?;
|
||||
let packet: Value = serde_json::from_str(&raw)
|
||||
.with_context(|| format!("failed to decode {}", args.packet.display()))?;
|
||||
let repo_id = packet
|
||||
.get("repoId")
|
||||
.and_then(Value::as_str)
|
||||
.ok_or_else(|| anyhow!("packet has no repoId"))?;
|
||||
let repo_path = packet
|
||||
.pointer("/input/repoTerrainReport/path")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or("");
|
||||
let packet_schema = packet
|
||||
.get("schemaVersion")
|
||||
.and_then(Value::as_str)
|
||||
.ok_or_else(|| anyhow!("packet has no schemaVersion"))?;
|
||||
validate_initialization_kind(&args.kind, packet_schema)?;
|
||||
let record = RepoInitializationRecord {
|
||||
schema_version: INITIALIZATION_RECORD_SCHEMA_VERSION.to_string(),
|
||||
record_id: initialization_record_id(repo_id, &args.kind),
|
||||
repo_id: repo_id.to_string(),
|
||||
repo_path: repo_path.to_string(),
|
||||
kind: args.kind.clone(),
|
||||
source_packet_schema_version: packet_schema.to_string(),
|
||||
source_packet_path: args.packet.display().to_string(),
|
||||
accepted_at: Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
|
||||
accepted_by: args.accepted_by,
|
||||
summary: args.summary.unwrap_or_else(|| {
|
||||
format!(
|
||||
"{} birth packet accepted for {}; detailed selfPatch application remains separately review-gated.",
|
||||
args.kind, repo_id
|
||||
)
|
||||
}),
|
||||
};
|
||||
let mut cache = repo_initialization_cache(&args.init_store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
cache.put(record.record_id.clone(), &record)?;
|
||||
Ok(json!({
|
||||
"schemaVersion": INITIALIZATION_RECORD_SCHEMA_VERSION,
|
||||
"mode": "accept-init",
|
||||
"initStore": args.init_store,
|
||||
"record": initialization_record_summary(&record),
|
||||
}))
|
||||
}
|
||||
|
||||
fn run_agent_packet(args: AgentPacketArgs) -> Result<Value> {
|
||||
fs::create_dir_all(&args.artifact_dir)
|
||||
.with_context(|| format!("failed to create {}", args.artifact_dir.display()))?;
|
||||
|
|
@ -708,6 +986,72 @@ fn repo_personality_cache(path: &Path) -> Result<CultCache> {
|
|||
Ok(cache)
|
||||
}
|
||||
|
||||
fn repo_initialization_cache(path: &Path) -> Result<CultCache> {
|
||||
let mut cache = CultCache::new();
|
||||
cache.register_entry_type::<RepoInitializationRecord>()?;
|
||||
cache.add_generic_backing_store(SingleFileMessagePackBackingStore::new(path));
|
||||
Ok(cache)
|
||||
}
|
||||
|
||||
fn initialization_kinds() -> &'static [&'static str] {
|
||||
&["repo-personality", "repo-memory"]
|
||||
}
|
||||
|
||||
fn accepted_initialization_kinds(store: &Path, repo_id: &str) -> Result<BTreeSet<String>> {
|
||||
if !store.exists() {
|
||||
return Ok(BTreeSet::new());
|
||||
}
|
||||
let mut cache = repo_initialization_cache(store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
let mut accepted = BTreeSet::new();
|
||||
for kind in initialization_kinds() {
|
||||
if cache
|
||||
.get::<RepoInitializationRecord>(&initialization_record_id(repo_id, kind))?
|
||||
.is_some()
|
||||
{
|
||||
accepted.insert((*kind).to_string());
|
||||
}
|
||||
}
|
||||
Ok(accepted)
|
||||
}
|
||||
|
||||
fn initialization_record_id(repo_id: &str, kind: &str) -> String {
|
||||
format!("{repo_id}::{kind}")
|
||||
}
|
||||
|
||||
fn validate_initialization_kind(kind: &str, packet_schema: &str) -> Result<()> {
|
||||
match (kind, packet_schema) {
|
||||
("repo-personality", DISTILLER_PACKET_SCHEMA_VERSION) => Ok(()),
|
||||
("repo-memory", MEMORY_DISTILLER_PACKET_SCHEMA_VERSION) => Ok(()),
|
||||
("repo-personality", other) => Err(anyhow!(
|
||||
"repo-personality init requires packet schema {:?}, got {:?}",
|
||||
DISTILLER_PACKET_SCHEMA_VERSION,
|
||||
other
|
||||
)),
|
||||
("repo-memory", other) => Err(anyhow!(
|
||||
"repo-memory init requires packet schema {:?}, got {:?}",
|
||||
MEMORY_DISTILLER_PACKET_SCHEMA_VERSION,
|
||||
other
|
||||
)),
|
||||
(other, _) => Err(anyhow!(
|
||||
"unknown initialization kind {other:?}; expected repo-personality or repo-memory"
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
fn initialization_record_summary(record: &RepoInitializationRecord) -> Value {
|
||||
json!({
|
||||
"recordId": record.record_id,
|
||||
"repoId": record.repo_id,
|
||||
"kind": record.kind,
|
||||
"sourcePacketSchemaVersion": record.source_packet_schema_version,
|
||||
"sourcePacketPath": record.source_packet_path,
|
||||
"acceptedAt": record.accepted_at,
|
||||
"acceptedBy": record.accepted_by,
|
||||
"summary": record.summary,
|
||||
})
|
||||
}
|
||||
|
||||
fn collect_memory_sources(
|
||||
repo: &Path,
|
||||
report: &RepoTerrainReport,
|
||||
|
|
@ -2146,6 +2490,51 @@ fn render_memory_packet_markdown(
|
|||
out
|
||||
}
|
||||
|
||||
fn render_startup_markdown(result: &Value) -> String {
|
||||
let mut out = String::new();
|
||||
out.push_str("# Repo Initialization Startup\n\n");
|
||||
out.push_str(&format!(
|
||||
"- Repo id: `{}`\n",
|
||||
result["repoId"].as_str().unwrap_or("unknown")
|
||||
));
|
||||
out.push_str(&format!(
|
||||
"- Action: `{}`\n",
|
||||
result["action"].as_str().unwrap_or("unknown")
|
||||
));
|
||||
out.push_str(&format!(
|
||||
"- Requires review: `{}`\n\n",
|
||||
result["requiresReview"].as_bool().unwrap_or(false)
|
||||
));
|
||||
out.push_str("## Accepted Birth Records\n\n");
|
||||
if let Some(kinds) = result["acceptedKinds"].as_array() {
|
||||
if kinds.is_empty() {
|
||||
out.push_str("- none\n");
|
||||
} else {
|
||||
for kind in kinds {
|
||||
out.push_str(&format!("- `{}`\n", kind.as_str().unwrap_or("unknown")));
|
||||
}
|
||||
}
|
||||
}
|
||||
out.push_str("\n## Generated Packets\n\n");
|
||||
if let Some(packets) = result["generatedPackets"].as_array() {
|
||||
if packets.is_empty() {
|
||||
out.push_str("- none\n");
|
||||
} else {
|
||||
for packet in packets {
|
||||
out.push_str(&format!(
|
||||
"- `{}`: `{}`\n",
|
||||
packet["kind"].as_str().unwrap_or("unknown"),
|
||||
packet["packetPath"].as_str().unwrap_or("missing")
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
out.push_str("\n## Next Safe Move\n\n");
|
||||
out.push_str(result["nextSafeMove"].as_str().unwrap_or(""));
|
||||
out.push('\n');
|
||||
out
|
||||
}
|
||||
|
||||
fn write_json(path: &Path, value: &Value) -> Result<()> {
|
||||
if let Some(parent) = path.parent() {
|
||||
fs::create_dir_all(parent)?;
|
||||
|
|
@ -2196,11 +2585,13 @@ fn round3(value: f64) -> f64 {
|
|||
|
||||
fn print_usage() {
|
||||
eprintln!(
|
||||
"usage: epiphany-repo-personality <scout|project|agent-packet|memory-packet|status> ...\n\
|
||||
"usage: epiphany-repo-personality <scout|project|agent-packet|memory-packet|startup|accept-init|status> ...\n\
|
||||
scout --root <path> --artifact-dir <path> [--max-repos <n>]\n\
|
||||
project --repo <path> --baseline <baseline.msgpack> --artifact-dir <path>\n\
|
||||
agent-packet --store <projection.msgpack> --artifact-dir <path> [--repo-id <id>]\n\
|
||||
memory-packet --store <projection.msgpack> --artifact-dir <path> [--repo-id <id>]\n\
|
||||
startup --repo <path> --baseline <baseline.msgpack> --artifact-dir <path> --init-store <init.msgpack>\n\
|
||||
accept-init --init-store <init.msgpack> --packet <packet.json> --kind <repo-personality|repo-memory> [--accepted-by <name>] [--summary <text>]\n\
|
||||
status --store <baseline-or-projection.msgpack>"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ remembers doctrine; the branch remembers the blade.
|
|||
- CultNet APIs are advertised as compatible schemas plus mutation contracts. Hello frames now expose readable document types, allowed operations, mutation authority, typed intent document types, and typed receipt document types; Aquarium should use those contracts to submit state changes and watch receipts rather than growing a little bespoke verb zoo.
|
||||
- Repo personality initialization now has a terrain-reduced plan and first native organ surface. `epiphany-repo-personality scout/project/agent-packet/status` scouts local git repos, scores body taxonomy/history temperament/memory doctrine, writes typed CultCache terrain/profile/role-projection MessagePack stores, emits JSON/Markdown inspection exports, and renders a birth-only Repo Personality Distiller specialist prompt packet. `epiphany-repo-personality-smoke` creates tiny repos and proves one terrain report, one personality profile, all eight role projections, and the rendered distiller packet can round-trip through typed stores/artifacts. The next seam is startup routing that checks for an accepted personality initialization record, launches the distiller only if absent, and lets Self review bounded `selfPatch` candidates into initial role memory and heartbeat seeds. After that, personality drift belongs to heartbeat, mood, rumination, sleep consolidation, lived evidence, and reviewed `selfPatch`, not repeated startup distillation.
|
||||
- Repo memory initialization is now split from personality initialization. `epiphany-repo-personality memory-packet` renders a birth-only Repo Memory Distiller packet from the same typed terrain/profile/projection store plus bounded source excerpts. It gives each organ its own mission filter: Self for routing/authority, Face for public surface, Imagination for plans/backlog, Eyes for prior art, Body for architecture, Hands for implementation habits, Soul for evidence, and Life for continuity. The output is still a Self-reviewed petition, not direct memory mutation.
|
||||
- The first birth startup valve is now native. `epiphany-repo-personality startup` checks a typed init store for accepted `repo-personality` and `repo-memory` records, generates missing packets under a startup artifact dir, and returns `reviewInitializationPackets`. `accept-init` seals a reviewed packet as `epiphany.repo_initialization_record.v0`; after both records exist, startup returns `continueStartup` and does not regenerate birth packets. This is the switchboard, not the full ritual: actual specialist execution, accepted `selfPatch` application, heartbeat seed mutation, and Aquarium review UI are still next.
|
||||
- Native CRRC automation is now landed only at turn-complete safe boundaries. It may submit `Op::Compact` for coordinator-approved `compactRehydrateReorient` or for a successful pre-compaction checkpoint intervention's pending compact handoff, and it may launch the fixed `reorient-worker` for coordinator-approved `launchReorientWorker`. It does not auto-launch Imagination/modeling/verification, accept findings, promote evidence, edit implementation code, or keep going after reviewable semantic output.
|
||||
- Pre-compaction checkpoint intervention is now landed. On token-count events for loaded Epiphany threads, when current context usage reaches 80% of the active auto-compact/context limit, the harness steers the active turn once with a CRRC checkpoint directive so the agent banks working context before compaction/reorientation. Pressure ignores cumulative token spend; cumulative-only telemetry reports unknown instead of yelling. A successful steer now latches a turn-scoped compact handoff that is consumed at clean turn completion, preventing the brake from decaying into another implementation turn. This is still bounded steering plus compaction handoff, not automatic semantic acceptance, a broad scheduler, or implementation continuation.
|
||||
- The old Python dogfood/live-specialist runners were cut because they encoded the obsolete completion path. The replacement must be native Rust/CultCache/CultNet and complete heartbeat-owned runtime-spine job results with auditable artifacts.
|
||||
|
|
@ -69,7 +70,7 @@ remembers doctrine; the branch remembers the blade.
|
|||
- The planning loop is now runtime-backed and operator-visible. Typed captures, backlog items, roadmap streams, Objective Drafts, and GitHub issue source refs live in `EpiphanyThreadState`, validate through revision-gated `thread/epiphany/update`, render into prompts when present, project read-only through `thread/epiphany/planning`, render in the GUI Planning panel, can be synthesized by the fixed Imagination/planning lane, and can be explicitly adopted through the artifacted `adoptObjectiveDraft` GUI action. Chat is deliberation, not an objective pipe; ideas and GitHub Issues remain planning state until explicit human adoption.
|
||||
- The bridge/dashboard slice is now landed far enough to test locally. Native `epiphany-rider-bridge` inspects Rider installation, solution, VCS, changed files, and captures file/selection/symbol context into `.epiphany-gui/rider` artifacts; Aquarium has Inspect Rider and renders Rider audit artifacts in Environment; Aquarium also embeds the adjacent EpiphanyGraph viewer over typed `graphs.architecture`, `graphs.dataflow`, and `graphs.links`.
|
||||
- A first Rider plugin scaffold lives under `integrations/rider`: tool window, Refresh status, and Send Context to Epiphany action. It shells through native `epiphany-rider-bridge` and does not own state. `gradle` is not installed on this machine, so the scaffold is not build-verified yet.
|
||||
- Next real product move: wire `epiphany-repo-personality` into startup protocol as a birth-only route with review-gated first application into role dossiers/heartbeat seeds. Continue Aquarium UI work in `E:\Projects\EpiphanyAquarium` after that; surface native heartbeat `sleepCycle`, `memoryResonance`, `incubation`, `thoughtLanes`, `bridge`, `candidateInterventions`, `appraisals`, and `reactions`; keep EpiphanyAgent focused on backend contracts, typed state, coordinator policy, bridge tools, heartbeat scheduling, Face guardrails, and the ongoing purification from Python/JSON scaffolding into Rust/CultCache/CultNet organs. Then build-verify/package the Rider plugin scaffold when Gradle/wrapper support is available, install the Aetheria-pinned Unity `6000.1.10f1` editor, and run the next Aetheria dogfood pass through Aquarium/Rider/Unity bridge artifacts. GitHub Issues import is deferred until the backlog source is fresh enough to deserve Imagination's attention.
|
||||
- Next real product move: complete the birth route by running generated startup packets through specialist execution, applying accepted `selfPatch` candidates into role dossiers, mutating heartbeat seeds from accepted personality pressure, and surfacing the review flow in Aquarium. Continue Aquarium UI work in `E:\Projects\EpiphanyAquarium` after that; surface native heartbeat `sleepCycle`, `memoryResonance`, `incubation`, `thoughtLanes`, `bridge`, `candidateInterventions`, `appraisals`, and `reactions`; keep EpiphanyAgent focused on backend contracts, typed state, coordinator policy, bridge tools, heartbeat scheduling, Face guardrails, and the ongoing purification from Python/JSON scaffolding into Rust/CultCache/CultNet organs. Then build-verify/package the Rider plugin scaffold when Gradle/wrapper support is available, install the Aetheria-pinned Unity `6000.1.10f1` editor, and run the next Aetheria dogfood pass through Aquarium/Rider/Unity bridge artifacts. GitHub Issues import is deferred until the backlog source is fresh enough to deserve Imagination's attention.
|
||||
- The repo is an Epiphany fork of Codex, not a Codex preset.
|
||||
- `vendor/codex` is tracked directly, not a submodule.
|
||||
- `epiphany-core` owns the heavy Epiphany organs where practical.
|
||||
|
|
|
|||
|
|
@ -496,6 +496,8 @@ It provides:
|
|||
- `project --repo <path> --baseline <baseline.msgpack> --artifact-dir <path>`
|
||||
- `agent-packet --store <projection.msgpack> --artifact-dir <path> [--repo-id <id>]`
|
||||
- `memory-packet --store <projection.msgpack> --artifact-dir <path> [--repo-id <id>]`
|
||||
- `startup --repo <path> --baseline <baseline.msgpack> --artifact-dir <path> --init-store <init.msgpack>`
|
||||
- `accept-init --init-store <init.msgpack> --packet <packet.json> --kind <repo-personality|repo-memory> [--accepted-by <name>] [--summary <text>]`
|
||||
- `status --store <baseline-or-projection.msgpack>`
|
||||
|
||||
The first implementation is intentionally deterministic. It inventories git
|
||||
|
|
@ -564,21 +566,29 @@ and a rendered role-specific memory distiller packet plus prompt.
|
|||
|
||||
## Next Implementation Step
|
||||
|
||||
Wire `epiphany-repo-personality` into startup protocol:
|
||||
|
||||
1. check for an accepted repo-personality initialization record
|
||||
2. if absent, launch the repo-personality distiller packet once through
|
||||
startup/heartbeat routing
|
||||
3. Self-reviewed first application into role memory through existing `selfPatch`
|
||||
policy
|
||||
4. heartbeat seed generation for personality/mood timing
|
||||
5. Aquarium surface for “repo personality changed” bubbles and profile
|
||||
inspection
|
||||
The first startup valve is now wired:
|
||||
|
||||
1. `startup` checks a typed CultCache init store for accepted
|
||||
`repo-personality` and `repo-memory` records.
|
||||
2. missing birth records generate the matching personality and/or memory packet
|
||||
under the startup artifact directory and return `reviewInitializationPackets`.
|
||||
3. `accept-init` records Self-reviewed packet acceptance in
|
||||
`epiphany.repo_initialization_record.v0`.
|
||||
4. a later `startup` for the same repo sees both accepted records and returns
|
||||
`continueStartup` without regenerating packets.
|
||||
That gets Epiphany from “I feel like this repo is anxious and glittery” to a
|
||||
repeatable profile that can initialize a swarm without needing the operator to
|
||||
personally diagnose every little machine soul by hand. A relief, frankly.
|
||||
|
||||
Remaining startup-routing gaps after the first valve:
|
||||
|
||||
1. actual LLM specialist execution for the generated packets
|
||||
2. first application of accepted `selfPatch` candidates into
|
||||
`state/agents.msgpack`
|
||||
3. heartbeat seed mutation from accepted personality pressure
|
||||
4. Aquarium review/action surfaces for generated birth packets and accepted
|
||||
initialization records
|
||||
|
||||
Clarification: "drift detection" here does not mean rerunning the distiller to
|
||||
keep personality synchronized with repo terrain. It means detecting whether the
|
||||
birth rite has already been accepted. If it has, startup should leave the
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -118,6 +118,7 @@ accepted_design:
|
|||
- Repo personality initialization is now specified as a map-reduce projection, not a hand-written vibe pass: read-only scouts score body taxonomy, history temperament, and memory doctrine across nearby repos, reduce them into normalized variance criteria, and emit reviewable `repoTerrainReport`, `repoPersonalityProfile`, and `rolePersonalityProjection` candidates before touching agent memory.
|
||||
- Native `epiphany-repo-personality` is the first startup-personality scout and birth-only distiller packet renderer: it deterministically inventories local git repos, scores repo terrain/history/state surfaces, writes typed CultCache terrain/profile/role-projection MessagePack stores, emits JSON/Markdown inspection glass, and renders a Repo Personality Distiller specialist prompt packet for Self-reviewed first role-memory petitions. The distiller must run only when a repo/swarm has no accepted personality initialization; after that, personality drift belongs to heartbeat, mood, rumination, sleep consolidation, lived evidence, and reviewed `selfPatch`. The next seam is startup routing that checks the accepted initialization record, launches the distiller only if absent, and then leaves later drift alone.
|
||||
- Repo memory initialization is a separate birth-only organ from repo personality initialization. `epiphany-repo-personality memory-packet` uses the typed terrain/profile/projection store plus bounded source excerpts from doctrine, docs, state, research, contracts, verification, runtime, and code surfaces to render a Repo Memory Distiller packet with one mission-specific brief for Self, Face, Imagination, Eyes, Body, Hands, Soul, and Life. It petitions Self with role-specific Ghostlight-shaped memory candidates; it does not mutate memory, set objectives, copy raw dumps, or reset living memory after startup.
|
||||
- The first repo birth startup valve is native: `epiphany-repo-personality startup` checks a typed CultCache init store for accepted `repo-personality` and `repo-memory` records, generates missing birth packets for Self review, and stops with `reviewInitializationPackets`; `accept-init` records reviewed packet acceptance as `epiphany.repo_initialization_record.v0`, after which startup returns `continueStartup` without rerunning the birth rites. Actual specialist execution, selfPatch application, heartbeat seed mutation, and Aquarium review UI are still the next routing gaps.
|
||||
- Limited native CRRC automation is now wired only at turn-complete safe boundaries: it can submit a compact operation when the read-only coordinator recommends `compactRehydrateReorient` or when a successful pre-compaction checkpoint intervention left a pending compact handoff for the completed turn, and it can launch the fixed `reorient-worker` when the coordinator recommends `launchReorientWorker`. It does not auto-launch modeling or verification, auto-accept findings, promote evidence, edit implementation code, or continue after reviewable semantic results; the rite may carry the stretcher, not declare the patient healed.
|
||||
- Pre-compaction checkpoint intervention is now wired at token-count boundaries: when a loaded Epiphany thread crosses the existing `shouldPrepareCompaction` pressure threshold during an active turn, the harness steers the active agent once for that turn with a bounded CRRC directive to bank scratch/checkpoint/map/evidence before compaction/reorientation. A successful steer marks a turn-scoped pending compact handoff consumed at clean turn completion; this is banking the fire before the dark, not semantic acceptance, broad scheduling, or automatic implementation continuation.
|
||||
- Native `epiphany-mvp-status` is the first dogfood operator view: it starts or reads a thread through app-server and renders scene, planning, pressure, reorient, jobs, role result read-backs, reorient result, CRRC recommendation, heartbeat, Face bubbles, and MVP role lanes as text or machine output without becoming a state store. The old Python status module has been cut; native Rust/CultCache/CultNet surfaces are the product path.
|
||||
|
|
@ -208,6 +209,7 @@ landed_baseline:
|
|||
- Native runtime spine slice: `epiphany-core::EpiphanyRuntimeIdentity`, `EpiphanyRuntimeSession`, `EpiphanyRuntimeJob`, `EpiphanyRuntimeJobResult`, and `EpiphanyRuntimeEvent` plus the native `epiphany-runtime-spine` binary establish a CultCache-backed spine, native job/result lifecycle, status projection, and framed CultNet hello output so the old Codex app-server runtime can be starved down to a temporary evacuation bridge instead of remaining the throne.
|
||||
- Native repo personality scout/birth-distiller packet slice: `epiphany-repo-personality` emits typed terrain reports, repo personality profiles, and all eight role personality projections from deterministic repo inventory and git-history scoring, then renders a birth-only Repo Personality Distiller specialist packet and prompt for review-gated initial personality quirk petitions; `epiphany-repo-personality-smoke` proves scout/project/agent-packet/status over tiny local repos.
|
||||
- Native repo memory scout/birth-distiller packet slice: `epiphany-repo-personality memory-packet` renders a separate Repo Memory Distiller prompt/packet with bounded source excerpts and role-specific distiller briefs, so a newborn swarm can be prefilled with mission-relevant doctrine, maps, research, implementation habits, verification practice, and continuity rules without confusing memory with personality.
|
||||
- Native repo birth startup valve slice: `epiphany-repo-personality startup` and `accept-init` make personality/memory birth packet generation one-shot and review-gated through typed initialization records; smoke proves first startup emits packets and post-accept startup continues without regeneration.
|
||||
guardrails:
|
||||
- Use focused Rust app-server mapper/handler tests plus matching native `epiphany-core` smoke binaries before modifying update, distill, propose, promote, read-projection, or notification behavior. The old Python smoke shims have been cut.
|
||||
- Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-phase6-scene-smoke` before modifying scene projection behavior.
|
||||
|
|
|
|||
Reference in a new issue