fix: address Copilot review round 15 — unevaluable const siblings, $ref fields, per-branch draft keys

- rootUnion: a merged declaration pairing a `const` with an assertion this
  module cannot evaluate (`minimum`, `pattern`, …) is declined. Proving the
  conjunction safe is the requirement, not disproving it — `minimum: 10`
  beside `const: 1` is as unsatisfiable as a type mismatch.
- declaresAnyFields counts a `$ref`: its shape is unknown rather than empty,
  so `anyOf: [{ $ref }, { $ref }]` no longer reports an App tool as
  input-free and auto-invokes it with `{}`.
- SchemaForm keys its draft-holding fields by the active branch as well, so a
  half-typed `-` or an unparsed JSON draft cannot survive a switch into a
  same-named field of the incoming branch — with both parent values
  `undefined`, nothing else tells the field the entity changed.

Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-08-26 05:49:43 -04:00
commit 09914772ea

View file

@ -134,6 +134,17 @@ describe("hasInputFields with root composition (#2123)", () => {
).toBe(true);
});
it("counts a $ref member, whose shape is unknown rather than empty", () => {
expect(
hasInputFields(
tool({
type: "object",
anyOf: [{ $ref: "#/$defs/Email" }, { $ref: "#/$defs/Sms" }],
}),
),
).toBe(true);
});
it("still reports no fields for a bare object schema", () => {
expect(hasInputFields(tool({ type: "object" }))).toBe(false);
});