The round lowers through the ModelPort: Prompt::lower over a LoweringInput, two answer phases

run::score_round no longer calls lower::lower. Prompt::lower prints the
meaning of an admitted view, en-US entity forms and the inventory at the
view's revision, and no item text, key, group, speaker or packet key. The
answer is a LoweringDraft {text}, held in score_round's locals and scored,
never written to run.cc, a RoundRecord, a Decision or EditFeedback. A round
or cycle asks every encode prompt, then every lowering prompt, all or
nothing. An entry an edit adds can now be lowered.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Weksa 2026-11-10 09:18:38 +00:00
commit 74ebafbc65
11 changed files with 748 additions and 72 deletions

View file

@ -1,7 +1,8 @@
//! The encoder and editor steps: what a model's answer becomes. This is the one
//! place JSON is read (the xenos boundary): a model answers in JSON,
//! `PacketDraft::parse` or `EditDraft::parse` reads it (both through
//! `from_json`), and nothing is stored as JSON. The encoder writes meaning
//! The encoder, editor and lowerer steps: what a model's answer becomes. This is
//! the one place JSON is read (the xenos boundary): a model answers in JSON,
//! `PacketDraft::parse`, `EditDraft::parse` or `LoweringDraft::parse` reads it
//! (all through `from_json`), and nothing is stored as JSON. The lowerer writes
//! `text` only. The encoder writes meaning
//! only; `into_packet` sets the id, schema version, inventory revision, kind,
//! provenance, constraints and extensions, and an empty trace, so a model that
//! saw a Validation item cannot hand its words to whoever reads packets. The
@ -199,6 +200,19 @@ impl EditDraft {
}
}
/// A lowering as the lowerer writes it: the English text, nothing else.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct LoweringDraft {
pub text: String,
}
impl LoweringDraft {
pub fn parse(answer: &str) -> Result<Self, DraftError> {
from_json(answer)
}
}
/// `encoder:<hex16>`, a digest of the model id and the prompt digest.
pub fn encoder_id(model: &str, prompt_digest: &str) -> EncoderId {
let digest = fnv1a64(format!("weksa-encoder-v1:{model}:{prompt_digest}").as_bytes());
@ -273,6 +287,24 @@ mod tests {
assert_eq!(PacketDraft::of(&made), draft);
}
#[test]
fn lowering_draft_parse() {
let draft = LoweringDraft::parse("\n {\"text\":\"a\"} \n").unwrap();
assert_eq!(draft.text, "a");
for bad in [
r#"{"text":"a","trace":"b"}"#,
r#"{}"#,
r#"{"text":1}"#,
"the sage acts",
"",
] {
let err = LoweringDraft::parse(bad).unwrap_err();
// Position only: no answer bytes in either rendering.
let shown = format!("{err} {err:?}");
assert!(!shown.contains("sage") && !shown.contains("trace"), "{shown}");
}
}
#[test]
fn parse_reads_a_draft_and_trims() {
let draft = PacketDraft::of(&packets()[0]);