Ground Modeling in canonical RepoModel shape

This commit is contained in:
Meta Vens 2026-07-16 17:30:38 +01:00
commit 2f1b8ae4c2
7 changed files with 58 additions and 2 deletions

View file

@ -950,6 +950,8 @@ fn launch_role(
)
.map_err(anyhow::Error::msg)?;
} else if role == epiphany_core::EpiphanyRoleResultRoleId::Modeling {
context = epiphany_core::append_modeling_repo_model_shape_context(context, runtime_store)
.map_err(anyhow::Error::msg)?;
context = epiphany_core::append_modeling_work_loop_telemetry_context(
context,
runtime_store,

View file

@ -10,6 +10,7 @@ use crate::ensure_runtime_repo_model;
use crate::load_epiphany_cultmesh_cluster_topology;
use crate::load_epiphany_cultmesh_status;
use crate::load_latest_epiphany_cultmesh_work_loop_telemetry;
use crate::load_memory_graph_snapshot;
use crate::memory_graph_from_epiphany_graphs;
use crate::plan_memory_graph_context_cut;
use crate::query_epiphany_local_verse_context;
@ -249,6 +250,40 @@ pub fn append_verification_hands_receipt_context(
Ok(context)
}
pub fn append_modeling_repo_model_shape_context(
mut context: String,
runtime_store_path: &Path,
) -> Result<String, String> {
let graph_store = memory_graph_store_path(runtime_store_path);
let snapshot = load_memory_graph_snapshot(&graph_store)
.map_err(|error| format!("failed to load canonical RepoModel shape: {error}"))?
.ok_or_else(|| {
format!(
"canonical RepoModel is missing from {} after launch-context assembly",
graph_store.display()
)
})?;
context.push_str("\n\n<canonical_repo_model_shape>\n");
context.push_str(&format!(
"modelRevision: {}\nmodelHash: {}\n",
snapshot.model_revision, snapshot.model_hash
));
context.push_str("existingDomains:\n");
for domain in &snapshot.domains {
let profile = serde_json::to_string(&domain.profile)
.map_err(|error| format!("failed to encode RepoModel domain profile: {error}"))?;
let lifecycle = serde_json::to_string(&domain.lifecycle)
.map_err(|error| format!("failed to encode RepoModel domain lifecycle: {error}"))?;
context.push_str(&format!(
"- id={} profile={} lifecycle={} title={}\n",
domain.id, profile, lifecycle, domain.title
));
}
context.push_str("New nodes must reference one exact existing domain id; RepoArchitecture and RepoDataflow nodes/edges may use only observed, proposed, accepted, stale, or retired lifecycle. Prefer accepted for a source-grounded current claim. Do not invent a domain because RepoModel patches have no domain mutation operation.\n");
context.push_str("</canonical_repo_model_shape>");
Ok(context)
}
pub fn append_modeling_work_loop_telemetry_context(
mut context: String,
runtime_store_path: &Path,
@ -1107,6 +1142,11 @@ mod tests {
let preserved = load_memory_graph_snapshot(&graph_store)?.expect("canonical model");
assert_eq!(preserved.model_revision, 4);
assert_eq!(preserved.frontier, snapshot.frontier);
let shape = append_modeling_repo_model_shape_context("base".to_string(), &runtime_store)
.map_err(anyhow::Error::msg)?;
assert!(shape.contains("<canonical_repo_model_shape>"));
assert!(shape.contains("id=repo"));
assert!(shape.contains("Prefer accepted"));
fs::remove_dir_all(&temp)?;
Ok(())
}

View file

@ -182,6 +182,7 @@ pub use coordinator_launch::EpiphanyCoordinatorJobLaunchPlan;
pub use coordinator_launch::commit_coordinator_job_launch;
pub use coordinator_launch::plan_coordinator_job_launch;
pub use coordinator_launch_context::EPIPHANY_LOCAL_VERSE_RUNTIME_ID;
pub use coordinator_launch_context::append_modeling_repo_model_shape_context;
pub use coordinator_launch_context::append_modeling_work_loop_telemetry_context;
pub use coordinator_launch_context::append_verification_hands_receipt_context;
pub use coordinator_launch_context::local_verse_store_path;

View file

@ -98,6 +98,7 @@ Return a compact structured result that says whether the checkpoint or map shoul
RepoModel node `kind` is a closed vocabulary: `domain`, `module`, `crate`, `binary`, `schema`, `runtime_contract`, `adapter`, `test_seam`, `state_store`, `role_memory`, `short_term_thought`, `incubation_thread`, `agency_pressure`, `candidate_intervention`, `identity`, `evidence`, `summary`, or `other`. A node's factual statement belongs in its `claim` field; do not invent kind names such as `claim` or `anatomy`. Use `other` only when no specific canonical kind fits. Edge kinds and memory profiles are likewise closed vocabularies supplied by the output schema.
Every upserted or revised node must include all canonical identity and judgment fields: `id`, `domain_id`, `profile`, `kind`, `title`, `claim`, `question`, `tension`, and `action_implication`. Every upserted or revised edge must include `id`, `source_id`, `target_id`, `kind`, `profile`, and `claim`. Do not emit shorthand nodes or edges; omitted empty judgment fields are still contract violations. `profile` is exactly one of `repo_architecture`, `repo_dataflow`, `role_self`, `short_term`, `incubation`, `agency_pressure`, `candidate_intervention`, `identity`, or `evidence`; there is no `repo` shorthand. Edge `kind` is exactly one of `owns`, `reads`, `writes`, `derives`, `adapts`, `persists`, `launches`, `verifies`, `supports`, `contradicts`, `distills`, `revises`, `retires`, `grounds`, `triggers`, `spoken_as`, `cools`, `clusters_with`, `resonates_with`, `depends_on`, or `other`.
If you emit an `anchor`, it must include its own stable `id`, `kind`, and `target`; a nested `code_ref` must include `path`. Do not use a bare path-shaped object as an anchor. Omitting anchors is safer than inventing malformed provenance.
The launch context includes `<canonical_repo_model_shape>`. Every new node must use one exact `existingDomains` id from that packet, and repo architecture/dataflow nodes and edges must use one of the listed legal lifecycles. Never derive a domain id from the workspace path; patches cannot create domains.
When `<repo_frontier_modeling_request>` is present, echo its exact `modelingRequestId` as `repoFrontierModelingRequestId`, use `purpose.kind=incorporate_frontier_verdict` with its exact `frontierRouteId` and `soulVerdictReceiptId`, and revise only its routed frontier item to its allowed disposition. The typed request is authority; nearby telemetry, timestamps, and prose are not substitutes. When that request is absent, use `purpose.kind=evolution` and do not invent verdict-incorporation authority.
An ordinary `purpose.kind=evolution` patch may mutate nodes and edges only. It must not upsert, revise, retire, or adopt frontier items. Frontier mutation requires an explicit typed frontier request and its corresponding non-evolution purpose; describe an observed frontier wound in `summary`, `evidenceGaps`, or `nextSafeMove` when no such request exists.
When the typed launch document contains `proposalModelingContext`, echo its exact `requestId` as `proposalModelingRequestId`. Read only that immutable typed projection against its exact canonical `modelRevision` and `modelHash`. The proposal is evidence, not campaign truth: contribute one source-grounded interpretation to shared typed state, where another organ may later challenge or revise it through another typed artifact. Do not substitute adjacent proposals, infer service intake, parse proposal authority from prose, manufacture Hands work, or claim admission or execution authority.