A test is not instant and the address field stays editable while it runs, so its answer can arrive after the address has changed. `set_models` then recorded the models against whatever the field held by the time it returned, filing one endpoint's models under another — the mislabelling `models_fit` exists to prevent, reached the asynchronous way rather than the synchronous ones already closed. `set_models` now takes the address the test was started against and returns whether the models were taken, so an answer that outlived its address is dropped and the caller can say the result is out of date. The parameter replaces the old signature rather than joining it: there was no second legitimate caller, and leaving an address-free version beside it would have left the racy call the shorter, easier one to reach — against this module's rule that the rules live once so two screens cannot disagree. Also fixes a pre-existing mismatch found while testing this: `from_connection` recorded the loaded address untrimmed while `prepare` compares it trimmed, so a stored endpoint with stray whitespace dropped its models on the first save.
Craft AI model
craft-ai-core is the data model and contract for AI in the Craft Apps: connections, models,
capabilities, roles (tools), requests, jobs, consent, request history, the shared store's file
format, and the declarative route spec. It has no I/O, no async runtime and compiles for
wasm32-unknown-unknown. It depends only on serde and serde_json.
One connection is set up once (in the launcher or any app) and every app that has the tool uses it. Each app keeps its own interface for each tool.
Boundaries
- Never crashes: the crate denies
unwrap,expect,panicand friends, and the workspace forbidsunsafe. - No secrets: a connection holds a reference to a secret (
SecretRef), never the value.SecretStringdoes not print. - No app code: an app is only an
AppIdstring. The contract is described in docs/ai-shared-layer.md and the declarative route spec in docs/ai-declarative-adapter.md.
Later pull requests add the desktop half (secret stores and the shared store file), the client, the provider adapters and egui widgets as separate crates.
Platforms
All platforms, including wasm32-unknown-unknown (checked in CI). No I/O.
Usage
Depend on it for the types. Worked examples: tests/custom_tools.rs, tests/mock_conformance.rs, tests/spec_calls.rs; the contract is in docs/ai-shared-layer.md.