From c9a5ce3d29484f737e9f3ac4c8bf5cbb0abbae33 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 2 Dec 2026 22:46:20 +0100 Subject: [PATCH] Elaboration: a missing-structure prompt names the promise, its holder, its counterparty and what answers it Co-Authored-By: Claude Sonnet 5.5 --- crates/ghostlight/src/elaboration.rs | 41 ++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/crates/ghostlight/src/elaboration.rs b/crates/ghostlight/src/elaboration.rs index 7a5deff..c45a711 100644 --- a/crates/ghostlight/src/elaboration.rs +++ b/crates/ghostlight/src/elaboration.rs @@ -1198,6 +1198,7 @@ fn build_prompt( "Answer: {}\n", render_answer(snapshot, &session.answer) )); + prompt.push_str(&render_promise(snapshot, &session.answer)); prompt.push_str(&render_clock(snapshot)); prompt.push_str( "\nEverything below already stands. Reference it by its bracketed id and declare only what is missing. An affordance kind that already stands, the kernel's own speak among them, cannot be declared again: grant it by id.\n\n", @@ -1287,14 +1288,48 @@ pub(super) fn render_jurisdiction(snapshot: &WorldSnapshot, jurisdiction: Jurisd } } +/// What answers a promise whose counterparty can neither command nor litigate it. +const MISSING_STRUCTURE_NEEDS: &str = "the promise's counterparty must be able to command the promisor (grant_authority to the counterparty, over the promisor or a ground that covers it) or a forum must stand over the counterparty (open_forum with standing over the counterparty); declaring more subjects or facts does not answer it"; + +/// The promise a missing-structure boundary is about, with who holds it and who +/// it is owed to, by id, and what answers it. Empty for every other answer. +fn render_promise(snapshot: &WorldSnapshot, answer: &PatchAnswer) -> String { + let PatchAnswer::Boundary(CausalBoundary::MissingStructure { subject, key, .. }) = answer + else { + return String::new(); + }; + let named = |id: SubjectId| { + snapshot.subjects.iter().find(|entry| entry.id == id).map_or_else( + || format!("[{}]", super::table::id_text(id)), + |entry| format!("{} [{}]", entry.label, super::table::id_text(entry.id)), + ) + }; + let Some(commitment) = snapshot + .subjects + .iter() + .find(|entry| entry.id == *subject) + .and_then(|entry| entry.commitments.iter().find(|held| held.key == *key)) + else { + return String::new(); + }; + let owed = commitment + .counterparty + .map_or_else(|| "no one".to_owned(), named); + format!( + "Promise: {} promised \"{}\" to {}. It is answered when {MISSING_STRUCTURE_NEEDS}. +", + named(*subject), + commitment.statement.as_str(), + owed + ) +} + /// What the world still lacks when a clean patch did not answer. The wording /// follows each boundary's own predicate: the repair is a patch that makes the /// predicate stop holding. fn unsatisfied_answer(snapshot: &WorldSnapshot, answer: &PatchAnswer) -> Mismatch { let needs = match answer { - PatchAnswer::Boundary(CausalBoundary::MissingStructure { .. }) => { - "the promise's counterparty must be able to command the promisor (grant_authority over it) or the promisor must fall under a standing forum (open_forum with standing over the counterparty); declaring more subjects or facts does not answer it" - } + PatchAnswer::Boundary(CausalBoundary::MissingStructure { .. }) => MISSING_STRUCTURE_NEEDS, PatchAnswer::Boundary(CausalBoundary::UnelaboratedDestination { .. }) => { "the place must stop being a dead end: put something in it, or give it a second route" }