Files
Jeremy 90feee5c6b fix: bound what a provider reply costs once parsed, not only its bytes (#190)
* test(ai-native): read access lists in-process in the Windows tests

The owner-only tests read each file's access list back with PowerShell's
Get-Acl. That call failed for every test on the windows-latest CI runner
after #184 merged, while the library code itself was not involved. The
tests now read the owner and list with GetNamedSecurityInfoW, through a
test-only helper in the named unsafe module, and the owner parser no
longer assumes a group section.

* test(ai-native): accept the LA alias for the built-in Administrator

CI runners use the machine's built-in Administrator account (RID 500),
which SDDL writes as LA instead of its full SID. The owner-only tests
compared against the full SID and failed on windows-latest; the files
themselves were correct.

* fix: bound what a provider reply costs once parsed, not only its bytes

A byte cap did not bound memory: a reply of many tiny objects costs about a
hundred times its size as a serde_json Value. craft_ai_http::json::parse
builds the same Value but charges an estimate of each allocation against a
budget and refuses the reply once it runs out.

The OpenAI, Gemini, Vertex, declarative and ComfyUI readers now parse
through it. OpenAI also gets a byte cap per kind of reply (model list
8 MiB, chat 32 MiB, images 128 MiB), a budget per stream line, and the
structured-output re-read keeps the chat budget. Deliberate-bug cases are
in tools/mutation/mutation_reply_parse.py (group rp).
2026-11-12 12:12:16 +01:00
..

craft-ai-http

The one TLS setting every hosted call in Craft AI uses: certificates are checked by the platform's own verifier, so a machine whose antivirus or company proxy re-signs HTTPS with an installed root still works. The trade-off (those installed roots are trusted too) is written at the top of src/lib.rs.

let config = ureq::Agent::config_builder()
    .tls_config(craft_ai_http::tls_config())
    .build();

A test fails if any crate in the workspace builds a ureq agent without it.

Reading a JSON reply

A byte cap on a reply does not bound what parsing it costs: a reply of many tiny objects takes about a hundred times its size as a serde_json::Value. craft_ai_http::json::parse(bytes, budget) builds the same Value, but refuses the reply once an estimate of its parsed memory passes budget. A reply that is mostly one long string (a base64 picture) costs about its length, so give a budget a little above the reply's byte cap. The OpenAI, Gemini, Vertex, declarative and ComfyUI adapters read their JSON replies through it.