Commit Graph
4 Commits
Author SHA1 Message Date
ggbdpq 6e1e3af9e3 gateway: an Antigravity schema's array always says its items, tuple or not (#2826)
What changed
- plainSchema (internal/gateway/codeassist.go) now leaves every array
  schema with an items object, at any depth:
  - a tuple's items (an array, draft 07) collapses to its first member
    that says anything;
  - an array whose members were said in prefixItems — dropped by the
    subset — takes that tuple's first meaningful member as its items;
  - an array that still has none gets items {"type":"string"}.

Why
- Google requires items on every schema of type array. Claude Code's
  tools (ArtifactData's query.where) say an array of arrays in JSON
  Schema 2020-12 tuples, and stripping prefixItems left the inner array
  with none, so Antigravity turned the whole request away with 400
  "tools[0].function_declarations[3].parameters.properties[query].
  properties[where].items.items: missing field". plainSchema is the
  Antigravity path only: Gemini CLI and Vertex take the schema as it
  came, and no other vendor path strips tuples.

Run
- go test -tags nogui -count=1 -run 'TestPlainSchema|TestCodeAssist|TestAntigravity' ./internal/gateway/: ok (TestPlainSchemaArrayAlwaysHasItems red on 1a3b9268 before the fix, green after)
- go test -tags nogui -count=1 ./internal/gateway/: ok 327.237s
- go test -race -tags nogui -count=1 -run 'TestPlainSchema' ./internal/gateway/: ok 2.143s
- gofmt -l internal/gateway/: empty; go vet -tags nogui on darwin/linux/windows: clean
- go build -tags nogui ./..., GOOS=linux, GOOS=windows: ok

Generated-by: GLM-5.3-Flash (ZCode)

Run (rebased onto 9ae79122, upstream/main 10-27): upstream's b28e5ffd
(plugins#375) fixes the same missing-items hole its own way — every array
left with no items gets items {}, which its A/B against Google answered
200 with — and adds the Google schema-400 fall-through to the next member
(fallback.go shapeWords). The fallback here takes upstream's empty object
in place of a string-typed one, and the two default-expecting test rows
with it; the tuple collapse and the prefixItems recovery above the
fallback stay, as upstream's check only fires when items is nil and takes
none of them. TestPlainSchemaArrayAlwaysHasItems and upstream's
TestPlainSchemaArraysAllHaveItems / TestAntigravityArrayGetsItems all
green on the merged tree.

Run (rebased onto e156fdd03, upstream/main 11-02): upstream's abaf2c4e8
(#4561) makes plainSchema resolve local $refs and gives walk a path
argument, and f2ae7bdec judges a self-reference by whole segments;
neither touches the array fallback. firstSays rides before the new walk,
and the prefixItems recovery walks its member at path+"/items" as the
new signature asks. On this tree: TestPlainSchemaArrayAlwaysHasItems red
on clean main (2 of its 4 rows), green with the fix, red again with the
fix ablated; gofmt and go vet -tags nogui clean.

Generated-by: GLM-5.3-Flash (ZCode)

Generated-by: GLM-5.3-Flash (ZCode)

Landed from ggbdpq's branch (patch posted on the issue; sha256/patch-id
checked against the issue) by yetone, rebased on origin/main 2026-11-03.
Run at the pushed tree, on mote (macOS): go test -tags nogui -count=1 of
internal/gateway with -run over this batch's tests and their families
(PlainSchema, Antigravity, AutoMode, WebP, ClaudeTUI, NativeRelay,
Namespace, Grok, Zed, Codex, ClinePass, rewrite) ok; -race -count=3 of
the new tests ok; GOOS=linux and GOOS=windows go vet of internal/gateway
and gofmt -l clean. The full gateway-and-importers run, started at an
earlier base, was still running at the push; its reds get issues.
Changed in review: main already gives an array with no items {}
(b28e5ffd, plugins#375), so the reported prefixItems case already
answered 200. Taking the tuple's first member as items told the model
every item of ArtifactData's [field, op, value] is a string. A tuple
(prefixItems, or draft 07's items array) is now said once only when
every member that says something is alike; members that differ are
any item ({}). What this adds over main is the draft 07 items array,
which went to Google as an array, and alike members kept typed.
Broken by hand: codeassist.go reverted, TestPlainSchemaArrayAlwaysHasItems
red; restored, green. The draft 07 tuple fixture is made up, not a
reporter's tool; not tried against Antigravity itself.
2026-11-03 02:27:57 +08:00
yetone f2ae7bdecc gateway: plainSchema judges a self-reference by whole segments (#4561 review)
The previous commit's selfRef took a $ref as a self-reference when the
walk's path began with the ref's pointer as a string. So
"#/properties/a" inside /properties/ab, a sibling, was cut down to
{"type":"object"} instead of being resolved. A self-reference is now
the pointer itself or one of its containers: path == ref, or path
begins with ref + "/".

A "#/…" pointer that names nothing where it points also falls back to
its last segment as a $defs or definitions name again, as every ref did
before pointers were walked ("#/components/schemas/Mode" with Mode in
$defs).

TestPlainSchemaSelfRefBySegment covers both.

Broken by hand: selfRef and localRef back to the previous commit, test
kept. Red: "inner" and "mode" both go out as {"type":"object"}.

Not tried: a real Antigravity request with dsh's tool schema. The
fix is in the flattening, and the gateway tests send the result
through a fake upstream.

Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
  on c30d3b7b6: 82 packages ok. internal/gui was red only on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, SearchAll from
  b09349d17) and TestColdTurnsTaken (#4510). Both are filed, and neither
  touches this stack.
- Rebased onto 29d0ab39f, which changed internal/gateway since then:
  gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows) and
  go test -count=1 ./internal/gateway ./internal/usage ./internal/provider
  ./internal/sessions all ok at the pushed head. go build ./... ok for
  darwin, linux (nogui) and windows.
- go test -race of the gateway tests this stack adds or touches, on
  the stack at fb29cd30f: ok.
2026-10-31 23:35:27 +08:00
ggbdpq abaf2c4e8f gateway: plainSchema resolves a $ref into properties (#4561)
A $ref that points inside the schema ("#/properties/func/properties/
triggers/items", as dsh's tool parameters carry one) is a local JSON
pointer like a "#/$defs/x" one, but plainSchema read a ref only by its
$defs or definitions name: the pointer's last segment named nothing
there, and the field it stood for went out as a bare {type: object} on
the Antigravity path, the tool losing that field's shape.

Any local pointer is resolved now, where it names; a self-reference —
a ref to the site or one of its containers — stops at the target's
type alone, as the plugin's googleSchema has it.

A test with the error's path fails on the old code.

Reviewed and applied from #4561 (ggbdpq, branch head ab39ddcbc; the
patch's SHA-256 matches the issue). A review fix follows in the next
commit: selfRef matched a pointer as a string prefix.

Broken by hand: plainSchema back at main with the test kept, and
TestPlainSchemaResolvesPointerIntoProperties fails ("again" goes out as a
bare {"type":"object"}).

Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
  on c30d3b7b6: 82 packages ok. internal/gui was red only on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, SearchAll from
  b09349d17) and TestColdTurnsTaken (#4510). Both are filed, and neither
  touches this stack.
- Rebased onto 29d0ab39f, which changed internal/gateway since then:
  gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows) and
  go test -count=1 ./internal/gateway ./internal/usage ./internal/provider
  ./internal/sessions all ok at the pushed head. go build ./... ok for
  darwin, linux (nogui) and windows.
- go test -race of the gateway tests this stack adds or touches, on
  the stack at fb29cd30f: ok.
2026-10-31 23:35:27 +08:00
yetone e4375ce967 gateway: a tool's schema reaches Antigravity with only the keywords it takes (#187: Unknown name "exclusiveMinimum") — Antigravity refuses a request whose function declarations carry a JSON Schema keyword outside its subset, and magpie cut out only the ones it knew of, so zcode's and dsh's tools, whose numbers have exclusiveMinimum, were refused with 400 on every turn. Now each schema keeps only type, description, nullable, enum, properties, required, items, the bounds and pattern, and propertyOrdering, anything else left out; an exclusive bound given as a number becomes the inclusive one when there is none. Tested on a schema with exclusive bounds, format, title, uniqueItems, contains, dependentRequired and not 2026-09-29 12:12:45 +08:00