Repository navigation
feat: add a keyed decisions API with image assets - #31
TheGreatAxios wants to merge 3 commits into
Conversation
Callers can ask named choice, noul, score, and box questions and attach PNG or JPEG images. The existing question list and adapter stay in place.
Asset names no longer match inside JSON keys, box edges are checked on the adapter path, and the keyed API is documented.
|
Triage: Pass No changes needed from you. A maintainer will review this pull request. |
TheGreatAxios
left a comment
There was a problem hiding this comment.
Review · Request changes
Adds a keyed decisions API and PNG/JPEG image assets. Range checks, JSON-key matches, identifier substrings, JPEG-versus-PNG sniffing, and cross-kind answer mismatches behave as required. Three contract checks do not.
Findings
-
src/assets.ts:238—valueHasTokenwalks the questiontypestring and the generated<image:…>reference.serializeRequestwith an asset namedchoice,noul,score, orboxdoes not throw when that word appears only as the question type. An asset namedimageis accepted when the only occurrence is<image:hex>, because<and:are token boundaries. The caller never wrote those names in state, instructions, or criteria, but the pre-send check treats them as referenced. Keys and identifier substrings still thrownot referenced. -
src/schemas.ts:325—boxEdgesOutOfRangeonly checks that each edge is inside[0, 1]. A 200 body{ top: 0.8, bottom: 0.2, left: 0.1, right: 0.4 }returnsfallback: falsefromsystemOne, andparseJSONResponseof{ top: 0.9, bottom: 0.1, left: 0.8, right: 0.2 }does not throw. The box contract needstop < bottomandleft < right. Both paths share this helper, so inverted boxes are returned as success and crops get a negative width or height. Out-of-range edges still fail. -
src/client.ts:155—TypeSafe-Danger-Zone-Imagesis set only whenimageParts.length > 0. A box question with no image part sends the header as absent. The docs require that header on every box question, not only on requests that upload images.
A deleted probe (bun test tmp/critique-tests/pr31-review.test.ts) was 7 pass, 5 fail on these cases.
Review · Follow-upCommit Asset names count only as whole tokens in state, instructions, and criteria. Question types and a generated image reference do not. Inverted boxes (
|
|
Superseded by the 0.4.0 release, which is merged: #34 |
Summary
systemOne()withchoice,noul,score, andbox. Answers are named. Failures stay a fallback.image(),Image.fromBase64(), andwithAssets. PNG and JPEG go out as multipart with the images header. Other formats fail before the request.evaluate()andcreateSystemOneAdapter. The adapter accepts keyed questions.Verification
bun run checkexited 0.6b00c31found no defects.Fixes CL-11530