From 4f7513bcba88a4639b1ed0d2b8256488c791fed3 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 10 Sep 2026 23:57:17 +0200 Subject: [PATCH] Cite Persona prose by quoting it, and make a bad quote a gap rather than a quarantine The Interpreter's speak and record_gap tools took byte offsets the model counted itself; on the Claude lane three of eight utterances came through cut mid-word and one empty span reached invocation as a non-canonical utterance and quarantined its cell. Both tools now take `source_quote`; the harness locates the quote in the preserved prose and derives the span. A quote not in the prose, empty, or padded is a translation gap at capture. The invariant is unchanged: only words in the prose become speech. Co-Authored-By: Claude Fable 5.1 --- crates/ghostlight-dungeon/src/runtime.rs | 14 +- .../src/world/controllers.rs | 205 +++++++++--------- .../ghostlight-persona-projection/src/lib.rs | 73 +++---- notes/ghostlight-implementation-plan.md | 9 + 4 files changed, 145 insertions(+), 156 deletions(-) diff --git a/crates/ghostlight-dungeon/src/runtime.rs b/crates/ghostlight-dungeon/src/runtime.rs index f485aa3..933d140 100644 --- a/crates/ghostlight-dungeon/src/runtime.rs +++ b/crates/ghostlight-dungeon/src/runtime.rs @@ -3334,8 +3334,7 @@ mod tests { struct InterruptingCoverPort { mailbox: WorldMailbox, source: String, - speech_start: usize, - speech_end: usize, + speech: String, speaker: SubjectId, interpreter_calls: AtomicUsize, } @@ -3371,11 +3370,8 @@ mod tests { InferenceEvent::ToolCall { call_id: format!("call_speak_{round}"), name: "speak".into(), - arguments: json!({ - "source_start_byte": self.speech_start, - "source_end_byte": self.speech_end, - }) - .to_string(), + arguments: json!({ "source_quote": self.speech }) + .to_string(), }, InferenceEvent::ToolCall { call_id: format!("call_finish_{round}"), @@ -3428,13 +3424,11 @@ mod tests { let source = "I say, \"Hold the line at the gate.\""; let speech = "Hold the line at the gate."; - let start = source.find(speech).unwrap(); let port = Arc::new(InterruptingCoverPort { mailbox: fixture.state.world.clone(), source: source.into(), - speech_start: start, - speech_end: start + speech.len(), + speech: speech.into(), speaker: operational_agent, interpreter_calls: AtomicUsize::new(0), }); diff --git a/crates/ghostlight-dungeon/src/world/controllers.rs b/crates/ghostlight-dungeon/src/world/controllers.rs index 0ee51c9..35f1af4 100644 --- a/crates/ghostlight-dungeon/src/world/controllers.rs +++ b/crates/ghostlight-dungeon/src/world/controllers.rs @@ -4594,23 +4594,29 @@ impl InterpreterFold { /// One interpreter tool call folded into `fold`, returning exactly the string /// the model is owed for it. pub(super) fn interpreter_tool_result( - source: &PersonaTurn, fold: &mut InterpreterFold, name: &str, arguments: &str, ) -> String { match name { INTERPRETER_SPEAK_TOOL => match serde_json::from_str::(arguments) { + // The quoted words must be canonical utterance text before they + // are captured: a quote the kernel would refuse as speech is a + // translation gap here, not an infrastructure fault at invocation. + Ok(call) if !fold.captured_speech && !super::patch::is_canonical_text(&call.source_quote) => { + let feedback = fold.accumulator.record_gap(RecordGapToolCall { + kind: TranslationGapKind::Unresolved, + source_quote: call.source_quote, + detail: "The quoted speech is not canonical utterance text (it is empty, padded, or spans lines), so it was not captured.".into(), + }); + format!("{feedback:?}") + } Ok(call) if !fold.captured_speech => { - let derived_text = source - .source_prose() - .get(call.source_start_byte..call.source_end_byte) - .unwrap_or_default() - .to_owned(); let feedback = fold.accumulator.capture_proposal( - SpeakProposal { text: derived_text }, - call.source_start_byte, - call.source_end_byte, + SpeakProposal { + text: call.source_quote.clone(), + }, + &call.source_quote, ); fold.captured_speech = feedback == CaptureToolFeedback::Accepted; format!("{feedback:?}") @@ -4618,8 +4624,7 @@ pub(super) fn interpreter_tool_result( Ok(call) => { let feedback = fold.accumulator.record_gap(RecordGapToolCall { kind: TranslationGapKind::Ambiguity, - source_start_byte: call.source_start_byte, - source_end_byte: call.source_end_byte, + source_quote: call.source_quote, detail: "More than one speech proposal was offered; this runner permits one decision invocation per opportunity.".into(), }); format!("{feedback:?}") @@ -4678,7 +4683,7 @@ impl InterpreterOracle { name, arguments, .. } = event { - let _ = interpreter_tool_result(source, &mut fold, name, arguments); + let _ = interpreter_tool_result(&mut fold, name, arguments); } } } @@ -4696,12 +4701,7 @@ impl ToolResultOracle for InterpreterOracle { } fn answer(&mut self, name: &str, arguments: &str) -> Result { - Ok(interpreter_tool_result( - &self.source, - &mut self.fold, - name, - arguments, - )) + Ok(interpreter_tool_result(&mut self.fold, name, arguments)) } } @@ -4744,7 +4744,7 @@ fn evaluate_interpreter_loop( name: name.clone(), arguments: arguments.clone(), }); - let result = interpreter_tool_result(source, &mut fold, name, arguments); + let result = interpreter_tool_result(&mut fold, name, arguments); conversation.push(CodexInputItem::ToolResult { call_id: call_id.clone(), output: result, @@ -5368,8 +5368,8 @@ fn evaluate_operational_loop( #[derive(Deserialize)] #[serde(deny_unknown_fields)] struct InterpreterSpeakCall { - source_start_byte: usize, - source_end_byte: usize, + /// The spoken words, quoted verbatim from the Persona prose. + source_quote: String, } #[derive(Deserialize)] @@ -5546,17 +5546,13 @@ fn interpreter_tools() -> Vec { vec![ tool_schema::tool( INTERPRETER_SPEAK_TOOL, - "Capture one exact spoken utterance by byte span in the preserved Persona prose; the harness derives the utterance verbatim.", - tool_schema::object(vec![ - ( - "source_start_byte".into(), - tool_schema::bounded_integer(0, u64::from(u32::MAX)), + "Capture one exact spoken utterance from the preserved Persona prose. Quote the spoken words verbatim, without the surrounding quotation marks; the harness locates the quote in the prose and records a gap instead if it is not there word for word.", + tool_schema::object(vec![( + "source_quote".into(), + tool_schema::canonical_string( + "the spoken words exactly as they appear in the Persona prose", ), - ( - "source_end_byte".into(), - tool_schema::bounded_integer(1, u64::from(u32::MAX)), - ), - ]), + )]), ), tool_schema::tool( INTERPRETER_RECORD_GAP_TOOL, @@ -5573,12 +5569,10 @@ fn interpreter_tools() -> Vec { ]), ), ( - "source_start_byte".into(), - tool_schema::bounded_integer(0, u64::from(u32::MAX)), - ), - ( - "source_end_byte".into(), - tool_schema::bounded_integer(1, u64::from(u32::MAX)), + "source_quote".into(), + tool_schema::canonical_string( + "the passage exactly as it appears in the Persona prose", + ), ), ( "detail".into(), @@ -6021,8 +6015,7 @@ mod tests { name: INTERPRETER_RECORD_GAP_TOOL.into(), arguments: json!({ "kind":"unresolved", - "source_start_byte":0, - "source_end_byte":1, + "source_quote":"I", "detail":"The intended action is unclear." }) .to_string(), @@ -6555,18 +6548,15 @@ mod tests { .find(|tool| tool.name == INTERPRETER_SPEAK_TOOL) .unwrap(); let schema: Value = serde_json::from_str(&interpreter_speak.parameters_json).unwrap(); - assert!( - !schema["properties"] - .as_object() - .unwrap() - .contains_key("text") - ); + let properties = schema["properties"].as_object().unwrap(); + assert!(properties.contains_key("source_quote")); + assert!(!properties.contains_key("text")); assert!( serde_json::from_str::( - r#"{"source_start_byte":0,"source_end_byte":4,"text":"invented"}"# + r#"{"source_quote":"the","text":"invented"}"# ) .is_err(), - "Interpreter speech cannot carry text independent of its source span" + "Interpreter speech cannot carry text independent of its source quote" ); } @@ -6898,6 +6888,49 @@ mod tests { .collect() } + /// A quote the kernel would refuse as speech is a translation gap at + /// capture, never an infrastructure fault at invocation: on the second SDK + /// road run a mis-spanned utterance failed the canonical-text rule inside + /// `speak_invocation` and quarantined the whole cell. + #[test] + fn a_non_canonical_or_absent_quote_is_a_gap_not_a_quarantine() { + let opportunity = fixture_opportunity(ControllerMode::NarrativePersona); + let source = "I say, \"The rain has teeth tonight.\" Then I wait."; + let turn = fixture_persona_turn(&opportunity, source); + for quote in ["", " teeth tonight.", "The rain has no teeth."] { + let mut fold = InterpreterFold::new(turn.clone()); + let answer = interpreter_tool_result( + &mut fold, + INTERPRETER_SPEAK_TOOL, + &json!({ "source_quote": quote }).to_string(), + ); + // A padded quote sits in the prose, so its gap binds to that exact + // span and the feedback is `Accepted`; an absent or empty one + // binds to the whole source. Neither is a captured proposal. + assert!(!fold.captured_speech, "{quote:?} was captured: {answer}"); + let report = fold + .accumulator + .finalize(InterpretationFinalization::InterpreterFinished); + assert!(report.proposals().is_empty()); + assert_eq!(report.gaps().len(), 1, "{quote:?}"); + assert!(report.spans_are_exact()); + } + // And the words as spoken are captured whole, bound to where they sit. + let mut fold = InterpreterFold::new(turn.clone()); + let answer = interpreter_tool_result( + &mut fold, + INTERPRETER_SPEAK_TOOL, + &json!({ "source_quote": "The rain has teeth tonight." }).to_string(), + ); + assert_eq!(answer, "Accepted"); + let report = fold + .accumulator + .finalize(InterpretationFinalization::InterpreterFinished); + let captured = &report.proposals()[0]; + assert_eq!(captured.source().verbatim(), "The rain has teeth tonight."); + assert_eq!(captured.source().start_byte(), source.find("The rain").unwrap()); + } + /// Spec test 1, interpreter lane. The string the oracle hands the model is /// the string the evaluator recomputes for the same call, in order. #[test] @@ -6906,12 +6939,7 @@ mod tests { let source = "I say, \"The rain has teeth tonight.\""; let turn = fixture_persona_turn(&opportunity, source); let speech = "The rain has teeth tonight."; - let start = source.find(speech).unwrap(); - let span = json!({ - "source_start_byte": start, - "source_end_byte": start + speech.len(), - }) - .to_string(); + let span = json!({ "source_quote": speech }).to_string(); let calls: Vec<(&str, &str, &str)> = vec![ ("call-0", INTERPRETER_SPEAK_TOOL, span.as_str()), // A second speak, so `captured_speech` is exercised. @@ -7214,20 +7242,10 @@ mod tests { let source = "I say, \"The rain has teeth tonight.\""; let turn = fixture_persona_turn(&opportunity, source); let speech = "The rain has teeth tonight."; - let start = source.find(speech).unwrap(); - let span = json!({ - "source_start_byte": start, - "source_end_byte": start + speech.len(), - }) - .to_string(); - // A span past the end of the prose: `get(..)` yields nothing and the - // capture is of the empty string, which is a real answer and not a - // decode failure. - let past_end = json!({ - "source_start_byte": source.len() + 1, - "source_end_byte": source.len() + 9, - }) - .to_string(); + let span = json!({ "source_quote": speech }).to_string(); + // A quote the prose does not contain: the capture is refused as a gap, + // which is a real answer and not a decode failure. + let past_end = json!({ "source_quote": "The rain has no teeth." }).to_string(); let oversized = oversized_arguments(); let calls: Vec<(&str, &str, &str)> = vec![ ("call-0", INTERPRETER_SPEAK_TOOL, span.as_str()), @@ -7238,11 +7256,7 @@ mod tests { ("call-3", INTERPRETER_RECORD_GAP_TOOL, "not json at all"), ("call-4", INTERPRETER_RECORD_GAP_TOOL, oversized.as_str()), ("call-5", "speek", "{}"), - ( - "call-6", - INTERPRETER_SPEAK_TOOL, - "{\"source_start_byte\":0}", - ), + ("call-6", INTERPRETER_SPEAK_TOOL, "{\"source_quote\":7}"), ]; let mut oracle = InterpreterOracle::new(&turn, &[]); assert_eq!(oracle.remaining_rounds() as usize, TOOL_STEP_BUDGET); @@ -7678,20 +7692,13 @@ mod tests { InferenceEvent::ToolCall { call_id: "call_bad_span".into(), name: INTERPRETER_SPEAK_TOOL.into(), - arguments: json!({ - "source_start_byte":source.len() + 10, - "source_end_byte":source.len() + 20 - }) - .to_string(), + arguments: json!({ "source_quote": "words the prose never says" }) + .to_string(), }, InferenceEvent::ToolCall { call_id: "call_speak".into(), name: INTERPRETER_SPEAK_TOOL.into(), - arguments: json!({ - "source_start_byte":start, - "source_end_byte":start + speech.len() - }) - .to_string(), + arguments: json!({ "source_quote": speech }).to_string(), }, InferenceEvent::ToolCall { call_id: "call_finish".into(), @@ -7846,8 +7853,7 @@ mod tests { name: INTERPRETER_RECORD_GAP_TOOL.into(), arguments: json!({ "kind":"unresolved", - "source_start_byte":0, - "source_end_byte":source.len(), + "source_quote":source, "detail":"The prose expresses no supported world action." }) .to_string(), @@ -8075,20 +8081,13 @@ mod tests { InferenceEvent::ToolCall { call_id: "bad-span".into(), name: INTERPRETER_SPEAK_TOOL.into(), - arguments: json!({ - "source_start_byte": source.len() + 1, - "source_end_byte": source.len() + 2 - }) - .to_string(), + arguments: json!({ "source_quote": "words the prose never says" }) + .to_string(), }, InferenceEvent::ToolCall { call_id: "exact-span".into(), name: INTERPRETER_SPEAK_TOOL.into(), - arguments: json!({ - "source_start_byte": start, - "source_end_byte": start + speech.len() - }) - .to_string(), + arguments: json!({ "source_quote": speech }).to_string(), }, InferenceEvent::ToolCall { call_id: "finish".into(), @@ -8433,13 +8432,9 @@ mod tests { } InferenceEvent::Text(_) | InferenceEvent::ToolCall { .. } => None, }) - .find(|call| { - call.source_start_byte == narrative_span.start_byte - && call.source_end_byte == narrative_span.end_byte - }) + .find(|call| call.source_quote == narrative_speech) .unwrap(); - assert!(interpreter_speak.source_start_byte == narrative_span.start_byte); - assert!(interpreter_speak.source_end_byte == narrative_span.end_byte); + assert!(interpreter_speak.source_quote == narrative_speech); snapshot = mailbox.snapshot().await.unwrap(); let log = mailbox.operator_log().await.unwrap(); @@ -11829,19 +11824,13 @@ mod tests { speech: &str, receipt: &str, ) -> Result { - let start = source - .find(speech) - .expect("the fixture prose quotes itself"); + assert!(source.contains(speech), "the fixture prose quotes itself"); output( vec![ InferenceEvent::ToolCall { call_id: format!("call_speak_{receipt}"), name: INTERPRETER_SPEAK_TOOL.into(), - arguments: json!({ - "source_start_byte": start, - "source_end_byte": start + speech.len(), - }) - .to_string(), + arguments: json!({ "source_quote": speech }).to_string(), }, InferenceEvent::ToolCall { call_id: format!("call_finish_{receipt}"), diff --git a/crates/ghostlight-persona-projection/src/lib.rs b/crates/ghostlight-persona-projection/src/lib.rs index 0766a7a..ce60985 100644 --- a/crates/ghostlight-persona-projection/src/lib.rs +++ b/crates/ghostlight-persona-projection/src/lib.rs @@ -5,7 +5,7 @@ pub const MEMBRANE_SCHEMA: &str = "ghostlight.persona_projection_membrane.v1"; pub const COGNITION_CONTROLLER_SCHEMA: &str = "ghostlight.decision_controller.v1"; pub const PERSONA_TURN_RECEIPT_SCHEMA: &str = "ghostlight.persona_turn_receipt.v3"; pub const RECORD_GAP_TOOL_NAME: &str = "record_gap"; -pub const RECORD_GAP_TOOL_CONTRACT: &str = "record_gap(kind: ambiguity | missing_reference | missing_affordance | missing_primitive | unresolved, source_start_byte: integer, source_end_byte: integer, detail: string)"; +pub const RECORD_GAP_TOOL_CONTRACT: &str = "record_gap(kind: ambiguity | missing_reference | missing_affordance | missing_primitive | unresolved, source_quote: string, detail: string)"; /// Selects how a decision owner thinks without making any claim about what /// kind of subject it is or which scope it controls. @@ -110,7 +110,7 @@ pub fn build_interpreter_prompt(input: &InterpreterPrompt<'_>) -> String { None => "The harness supplies the current legal typed proposal tools immediately before each step. Use only those current contracts; never reuse a contract remembered from an earlier step.".into(), }; format!( - "\nYou are a private Interpreter. Translate a natural Persona turn into zero or more typed candidate proposals supported by the prose and permissioned context. The owning runtime validates and commits proposals; you never claim that a proposed consequence already happened. Do not invent knowledge, capability, custody, perception, identifiers, or state references.\n\nInterpretation is total: this turn cannot fail because some prose has no available translation. The harness has already preserved the Persona turn verbatim as noncanonical source prose. Capture every translation you can justify, citing its exact UTF-8 byte span in that source. Spoken words become a typed speech proposal; wondering, deciding, attempting, and narration are not automatically speech. If a meaningful passage cannot be represented safely, call `{gap_tool}` instead of guessing. A report containing only source prose, or source prose plus gaps, is valid. If the step budget ends, the harness completes the report and records the unresolved source instead of failing.\n\nThe always-available gap tool is:\n{gap_contract}\nUse `ambiguity` when several translations remain live, `missing_reference` when the prose lacks an exact world reference, `missing_affordance` when the subject lacks a permitted way to attempt it, `missing_primitive` when the ontology has no suitable proposal vocabulary, and `unresolved` only when no narrower account fits.\n\nIf a section headed `Interrupted:` follows the Persona turn, the world moved after that prose was written and before it could take effect. The prose is not re-written and not re-authored; translate it again against what that section reports. You may capture a shorter or different span of the same prose, a different permitted action the prose supports, or call `{gap_tool}` with `unresolved` when the intent the prose carried has been overtaken. The reported change is not something this person said, did, or caused.\n\n{proposal_contract}\n\nDomain guidance and exact permissions:\n{guidance}\n\nIdentity:\n{identity}\n\nPermissioned typed context:\n{context}\n\nLived stream:\n{stream}\n\nPersona turn (already preserved verbatim as source evidence):\n{output}", + "\nYou are a private Interpreter. Translate a natural Persona turn into zero or more typed candidate proposals supported by the prose and permissioned context. The owning runtime validates and commits proposals; you never claim that a proposed consequence already happened. Do not invent knowledge, capability, custody, perception, identifiers, or state references.\n\nInterpretation is total: this turn cannot fail because some prose has no available translation. The harness has already preserved the Persona turn verbatim as noncanonical source prose. Capture every translation you can justify, quoting the exact words of that source verbatim in `source_quote`; the harness locates the quote in the preserved prose and binds the capture to it, so a quote that is not in the prose word for word is recorded as a gap. Spoken words become a typed speech proposal; wondering, deciding, attempting, and narration are not automatically speech. If a meaningful passage cannot be represented safely, call `{gap_tool}` instead of guessing. A report containing only source prose, or source prose plus gaps, is valid. If the step budget ends, the harness completes the report and records the unresolved source instead of failing.\n\nThe always-available gap tool is:\n{gap_contract}\nUse `ambiguity` when several translations remain live, `missing_reference` when the prose lacks an exact world reference, `missing_affordance` when the subject lacks a permitted way to attempt it, `missing_primitive` when the ontology has no suitable proposal vocabulary, and `unresolved` only when no narrower account fits.\n\nIf a section headed `Interrupted:` follows the Persona turn, the world moved after that prose was written and before it could take effect. The prose is not re-written and not re-authored; translate it again against what that section reports. You may capture a shorter or different span of the same prose, a different permitted action the prose supports, or call `{gap_tool}` with `unresolved` when the intent the prose carried has been overtaken. The reported change is not something this person said, did, or caused.\n\n{proposal_contract}\n\nDomain guidance and exact permissions:\n{guidance}\n\nIdentity:\n{identity}\n\nPermissioned typed context:\n{context}\n\nLived stream:\n{stream}\n\nPersona turn (already preserved verbatim as source evidence):\n{output}", identity = input.identity, guidance = input.domain_guidance, context = input.typed_context, @@ -360,6 +360,20 @@ impl SourceSpan { }) } + /// The first exact occurrence of `quote` in `source`. The model quotes + /// words; the harness counts bytes. A model that counts bytes itself cut + /// three of eight utterances mid-word on the first Claude road run. + pub fn locate(source: &str, quote: &str) -> Option { + if quote.is_empty() { + return None; + } + source.find(quote).map(|start_byte| Self { + start_byte, + end_byte: start_byte + quote.len(), + verbatim: quote.to_owned(), + }) + } + pub fn whole(source: &str) -> Self { Self { start_byte: 0, @@ -417,8 +431,8 @@ pub enum TranslationGapKind { #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct RecordGapToolCall { pub kind: TranslationGapKind, - pub source_start_byte: usize, - pub source_end_byte: usize, + /// The passage, quoted verbatim from the source prose. + pub source_quote: String, pub detail: String, } @@ -516,19 +530,14 @@ impl InterpretationAccumulator { } } - pub fn capture_proposal( - &mut self, - proposal: T, - source_start_byte: usize, - source_end_byte: usize, - ) -> CaptureToolFeedback { - let Some(source) = SourceSpan::exact( - self.source.source_prose(), - source_start_byte, - source_end_byte, - ) else { + /// Binds a typed proposal to the source words it translates. The quote must + /// occur verbatim in the preserved prose; otherwise the proposal is not + /// captured and the whole source stays unresolved. + pub fn capture_proposal(&mut self, proposal: T, source_quote: &str) -> CaptureToolFeedback { + let Some(source) = SourceSpan::locate(self.source.source_prose(), source_quote) else { let detail = format!( - "typed proposal could not be bound to source range {source_start_byte}..{source_end_byte}; its meaning remains untranslated" + "typed proposal quoted words that are not in the source prose (quote_digest={}); its meaning remains untranslated", + sha256(source_quote) ); self.record_whole_source_gap(TranslationGapKind::Unresolved, detail.clone()); return CaptureToolFeedback::RecordedAsGap { detail }; @@ -539,14 +548,11 @@ impl InterpretationAccumulator { } pub fn record_gap(&mut self, call: RecordGapToolCall) -> CaptureToolFeedback { - let Some(source) = SourceSpan::exact( - self.source.source_prose(), - call.source_start_byte, - call.source_end_byte, - ) else { + let Some(source) = SourceSpan::locate(self.source.source_prose(), &call.source_quote) + else { let detail = format!( - "{} [requested source range {}..{} was not exact, so the harness bound this gap to the complete source prose]", - call.detail, call.source_start_byte, call.source_end_byte + "{} [the quoted passage is not in the source prose, so the harness bound this gap to the complete source prose]", + call.detail ); self.record_whole_source_gap(call.kind, detail.clone()); return CaptureToolFeedback::RecordedAsGap { detail }; @@ -846,24 +852,20 @@ mod tests { let source = "I say, \"Mara, the bridge is unsafe.\" Then I try the rusted western gate."; let mut interpretation = InterpretationAccumulator::new(turn(source)); let warning = "Mara, the bridge is unsafe."; - let warning_start = source.find(warning).unwrap(); assert_eq!( interpretation.capture_proposal( TestProposal::Speak { recipient_id: "actor:mara", utterance: "Mara, the bridge is unsafe.", }, - warning_start, - warning_start + warning.len(), + warning, ), CaptureToolFeedback::Accepted ); - let gate_start = source.find("try the rusted western gate").unwrap(); assert_eq!( interpretation.record_gap(RecordGapToolCall { kind: TranslationGapKind::MissingReference, - source_start_byte: gate_start, - source_end_byte: gate_start + "try the rusted western gate".len(), + source_quote: "try the rusted western gate".into(), detail: "No exact gate id is visible in the permissioned context.".into(), }), CaptureToolFeedback::Accepted @@ -886,13 +888,12 @@ mod tests { } #[test] - fn invalid_gap_offsets_become_exact_gaps_instead_of_losing_meaning() { + fn a_gap_quote_outside_the_prose_becomes_an_exact_gap_instead_of_losing_meaning() { let speech = "I appeal to whoever can hear me."; let mut interpretation = InterpretationAccumulator::::new(turn(speech)); let feedback = interpretation.record_gap(RecordGapToolCall { kind: TranslationGapKind::MissingAffordance, - source_start_byte: 900, - source_end_byte: 940, + source_quote: "I appeal to the magistrate.".into(), detail: "No appeal channel is available.".into(), }); @@ -919,8 +920,7 @@ mod tests { recipient_id: "actor:mara", utterance: "warning", }, - 700, - 740, + "warning", ), CaptureToolFeedback::RecordedAsGap { .. } )); @@ -979,16 +979,13 @@ mod tests { fn infrastructure_interruption_leaves_the_turn_pending() { let source = "I say, \"Wait here.\""; let mut interpretation = InterpretationAccumulator::new(turn(source)); - let utterance = "Wait here."; - let start = source.find(utterance).unwrap(); assert_eq!( interpretation.capture_proposal( TestProposal::Speak { recipient_id: "actor:mara", utterance: "Wait here.", }, - start, - start + utterance.len(), + "Wait here.", ), CaptureToolFeedback::Accepted ); diff --git a/notes/ghostlight-implementation-plan.md b/notes/ghostlight-implementation-plan.md index b6dfe31..88417e0 100644 --- a/notes/ghostlight-implementation-plan.md +++ b/notes/ghostlight-implementation-plan.md @@ -627,6 +627,15 @@ shared by the evaluator and the oracle from the calls after it. The harness takes the connector binding only when `GHOSTLIGHT_CONTROLLER_CONNECTOR` is set, so an all-`claude` run needs no connector. +From run 2: the Interpreter's `speak` and `record_gap` cite the source by +quoting it (`source_quote`), and the harness locates the quote and derives +the span; the model no longer counts bytes, which cut three of eight +utterances mid-word. The same invariant holds (only words in the preserved +prose become speech; a quote not in the prose is a gap), and a quote that is +not canonical utterance text is a gap at capture rather than a quarantine at +invocation. `RecordGapToolCall` in `ghostlight-persona-projection` changed +shape; Epiphany pins that crate by revision and is unaffected until it moves. + ## Subtraction budget Prefer deletion, collapse, or reuse before adding surfaces. The replacement