diff --git a/crates/ghostlight/src/lib.rs b/crates/ghostlight/src/lib.rs index aa15adc..53d29bd 100644 --- a/crates/ghostlight/src/lib.rs +++ b/crates/ghostlight/src/lib.rs @@ -124,7 +124,7 @@ pub use sdk_inference::{DEFAULT_SDK_MODEL_PREFIX, SdkBinding}; pub use table::{ DecodedBatch, PatchSite, TableError, actor_tools, authoring_tools, decode_actor_call, decode_authoring_call, decode_authoring_calls, describe_refusal, describe_refusal_to_actor, - table_view, + id_text, id_text_matches, table_view, }; pub use vault::{VaultError, VaultEvidenceSource}; use patch::{EdgeRecord, EntityRecord, LedgerDelta, ResolvedOp, ResolvedPatch}; diff --git a/crates/ghostlight/src/table.rs b/crates/ghostlight/src/table.rs index 359af45..054285c 100644 --- a/crates/ghostlight/src/table.rs +++ b/crates/ghostlight/src/table.rs @@ -1075,7 +1075,13 @@ impl InferenceOutput { /// The canonical id as the patch vocabulary spells it: the bare UUID text, /// without the typed wrapper's name. Moved here from the seed lane, which /// still calls it here; nothing about its behaviour changed with the move. -pub(super) fn id_text(id: impl std::fmt::Debug) -> String { +/// `pub`, not `pub(super)` (PA.f113): this is the one place that decides how +/// an id is spelled — `table_view` prints through it, and Dungeon's +/// `dispatch` reads an id an agent typed back through `id_text_matches` +/// below, rather than each consumer keeping its own debug-paren-strip copy. +/// A copy drifts silently when this printer changes; a shared call site +/// cannot. +pub fn id_text(id: impl std::fmt::Debug) -> String { let text = format!("{id:?}"); match (text.find('('), text.rfind(')')) { (Some(open), Some(close)) if open < close => text[open + 1..close].to_owned(), @@ -1083,6 +1089,16 @@ pub(super) fn id_text(id: impl std::fmt::Debug) -> String { } } +/// The parser matching `id_text` above (PA.f113): `text` names `id` only +/// when it is exactly the bytes `id_text(id)` would print — no brackets, no +/// padding, no case folding, because this is plain string equality against +/// the printer's own output rather than a second, independently-tolerant +/// parse. Kept beside the printer so the two cannot drift apart the way +/// `table_view`'s print and Dungeon's three hand-copied strips once did. +pub fn id_text_matches(id: impl std::fmt::Debug, text: &str) -> bool { + id_text(id) == text +} + /// The world the seed session is authoring into, rendered from snapshot /// fields that already exist. Moved from the elaboration lane, byte-for-byte: /// the seed prompt calls it here now, and its text does not change with the