Skip to main content

Crate smix_ai_tier

Crate smix_ai_tier 

Source
Expand description

§smix-ai-tier

The AI-assertion tier: hand a screenshot and a plain-language condition to a local claude CLI, get a structured verdict back. It backs the assertCondition and extractWithAI yaml verbs.

ⓘ
let verdict = smix_ai_tier::judge(&png, "a red error toast is visible", &cfg).await?;
if !verdict.pass {
    // verdict.reason explains what the judge saw
}

§This tier is fenced, and the fence is the point

smix senses the screen through the accessibility tree and Vision OCR. Those are deterministic, and they are what every selector resolves through. This tier is not part of that. It is an authoring and CI aid that sits beside the resolver, never inside it:

  • Nothing that senses may depend on this crate. Delete smix-ai-tier and the sense path still compiles and its tests still pass. That deletability is the fence, and it is enforced by a test (tests/fence.rs) rather than asserted in a comment.
  • Opt-in. The verbs are inert unless a flow turns them on.
  • Marked non-deterministic. A verdict is a judgement, not a measurement, and the output says so.
  • One provider. The local claude CLI, invoked as a subprocess. There is no provider abstraction here and there will not be one.

§Failure is loud

A missing CLI, a timeout, or output that isn’t the verdict we asked for are all errors. None of them degrade into pass: false — that would report “your app is broken” when the truth is “the judge never ran”.

Structs§

AiTierConfig
How to reach the judge.
StructuredVerdict
What the judge decided.

Enums§

Attachment
Something the question is about, alongside the words.

Functions§

ask
Ask once, and return what came back.
ask_with_attachments
Ask about something, with the something stated rather than described.
extract
Read fields off the screen.
judge
Ask the judge whether condition holds on the screen in screenshot_png.
parse_json_object
Take the first JSON object out of the reply, tolerating prose around it — models like to introduce themselves, and that is not a reason to fail a flow. The generic type is the caller’s target shape; a reply that carries no object, or one that does not deserialize into T, yields None.