Pin a read's refusal as crossing the dispatch unchanged
The dispatch was honest and nothing forbade it flattening a refusal the mind raised: mutants that rewrapped a view refusal as unavailable, swallowed one into an empty answer, and rewrapped a query refusal all survived both suites. Flattening is the failure this cut exists to prevent, so it is now a test. The new daemon test drives each read method into a refusal the method itself raises, through `Daemon::handle`, with the shapes Soul reached over the wire: a reference whose kind and id disagree for `view` and for a subject `history`, and a semantic query for `query`, which is unavailable until Cut 11 wires an index. Each must arrive as the mind spelled it. The same reads answer when asked something answerable, so the arms are refusing on the mind's word rather than on their own shape. `D17`-`D19` rewrap each refusal and `D17L`-`D19L` swallow each into the empty answer of its own kind. `open_items` is not pinned and says so rather than carrying a weak entry: it raises no refusal of its own, and its only failing paths are store integrity inside the reader, which nothing on the daemon's surface can drive without a corrupt store. A mutant against that arm could not fail. The operation comparison is pinned in the same pass, because it shares this entries file. Its mismatch case compared two words that differ under any comparison, so a case-insensitive comparison survived; `Admit` now stands beside `query` as a malformed envelope, and `D5L2` folds case. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
4fba6cc6d4
commit
25a841dc6d
3 changed files with 181 additions and 2 deletions
|
|
@ -110,6 +110,7 @@ pub(crate) mod tests {
|
|||
use huginn_mind::wire::MindStatus;
|
||||
use huginn_mind::{
|
||||
Faculty, HistoryScope, PipelineAdmissionBatch, PipelineProvenance, PipelineQuery, PipelineStatus,
|
||||
SemanticQuery,
|
||||
};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tempfile::TempDir;
|
||||
|
|
@ -348,6 +349,60 @@ pub(crate) mod tests {
|
|||
assert_eq!(status(&mut daemon).documents, 1, "nothing landed");
|
||||
}
|
||||
|
||||
/// A refusal a read method raised is the answer the dispatch returns, whole.
|
||||
/// The instance check refuses before the method runs and is pinned above;
|
||||
/// these are the refusals the methods themselves raise, so nothing here is
|
||||
/// the daemon's own. Each must arrive as the mind spelled it: not rewrapped
|
||||
/// as `Unavailable`, not rewrapped as another read's refusal, and not
|
||||
/// swallowed into an empty answer, which would read as "no such document"
|
||||
/// rather than "that is not a reference".
|
||||
///
|
||||
/// `open_items` has no refusal of its own: its only failing paths are store
|
||||
/// integrity inside the reader, which the daemon's surface cannot drive
|
||||
/// without a corrupt store. So the daemon's `OpenItems` rewrap is not
|
||||
/// pinned here and carries no mutation entry.
|
||||
#[test]
|
||||
fn a_refusal_a_read_raised_is_the_answer_the_dispatch_returns_whole() {
|
||||
let (_root, mut daemon) = seeded();
|
||||
|
||||
// A reference whose kind and id disagree names no document any writer
|
||||
// could have composed; the leaf's own refusal says so.
|
||||
let invalid = PipelineRef { kind: PipelineKind::Question, id: "not a reference".into() };
|
||||
let malformed = MindRefusal::Document(huginn_mind::epiphany_pipeline::PipelineRefusal::InvalidFormat {
|
||||
field: "ref.id".into(),
|
||||
value: "not a reference".into(),
|
||||
});
|
||||
let view = HuginnMindRequest::View { instance: slug(INSTANCE), id: invalid.clone() };
|
||||
assert_eq!(daemon.handle(view, now()), HuginnMindResponse::Refused(malformed.clone()));
|
||||
|
||||
let history = HuginnMindRequest::History { instance: slug(INSTANCE), scope: HistoryScope::Subject(invalid) };
|
||||
assert_eq!(daemon.handle(history, now()), HuginnMindResponse::Refused(malformed));
|
||||
|
||||
// A semantic query is unavailable until Cut 11 wires an index, and the
|
||||
// detail is the mind's own sentence.
|
||||
let query = PipelineQuery {
|
||||
semantic: Some(SemanticQuery { text: "who owns the state".into(), top_k: 4 }),
|
||||
..PipelineQuery::default()
|
||||
};
|
||||
let unwired =
|
||||
MindRefusal::Unavailable { detail: "semantic query: the index is not wired (Cut 11)".into() };
|
||||
assert_eq!(
|
||||
daemon.handle(HuginnMindRequest::Query { instance: slug(INSTANCE), query }, now()),
|
||||
HuginnMindResponse::Refused(unwired)
|
||||
);
|
||||
|
||||
// And the same reads answer rather than refuse when they are asked
|
||||
// something answerable, so the arms above are refusing on the mind's
|
||||
// word and not on their own shape.
|
||||
let absent =
|
||||
PipelineRef { kind: PipelineKind::Question, id: Short(format!("{CAMPAIGN}:question:Q1")) };
|
||||
let present = HuginnMindRequest::View { instance: slug(INSTANCE), id: absent };
|
||||
assert_eq!(daemon.handle(present, now()), HuginnMindResponse::View(None));
|
||||
let plain = HuginnMindRequest::Query { instance: slug(INSTANCE), query: PipelineQuery::default() };
|
||||
let HuginnMindResponse::Query(page) = daemon.handle(plain, now()) else { panic!("expected a page") };
|
||||
assert_eq!(page.matched, 1);
|
||||
}
|
||||
|
||||
/// Cut 11's seam: the index is handed every landed write, derived ones
|
||||
/// included, and can read each; an index that fails changes nothing.
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -288,7 +288,11 @@ mod tests {
|
|||
request("m-4", MIND_SERVICE_ID, "admit", MIND_REQUEST_SCHEMA, STANDARD.encode([0xc1_u8, 0xc1])),
|
||||
"payload-not-a-request",
|
||||
),
|
||||
("m-5", request("m-5", MIND_SERVICE_ID, "query", MIND_REQUEST_SCHEMA, admit), "operation-mismatch"),
|
||||
("m-5", request("m-5", MIND_SERVICE_ID, "query", MIND_REQUEST_SCHEMA, admit.clone()), "operation-mismatch"),
|
||||
// The same operation under another casing is another name, not this
|
||||
// one: the comparison is of bytes, so `Admit` is no more `admit`
|
||||
// than `query` is.
|
||||
("m-5b", request("m-5b", MIND_SERVICE_ID, "Admit", MIND_REQUEST_SCHEMA, admit), "operation-mismatch"),
|
||||
];
|
||||
for (id, message, code) in cases {
|
||||
let reply = answer(&mut daemon, ®istry, message, now());
|
||||
|
|
|
|||
Loading…
Reference in a new issue