Fix batch 8a-fix4: library id printer/parser PA.f113

table.rs owns one id printer (id_text, now pub) and its matching parser
(id_text_matches), both against the same debug-paren strip. table_view
prints through id_text; id_text_matches is exact equality against it, so a
consumer reading an id an agent typed cannot drift from what the printer
prints without a shared edit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-22 20:07:48 +02:00
commit 340d5836e5
2 changed files with 18 additions and 2 deletions

View file

@ -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};

View file

@ -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