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

@ -402,6 +402,20 @@ describe("resolveRootUnion", () => {
expect(branches).toEqual([]);
});
it("declines a const paired with an assertion it cannot evaluate", () => {
// `minimum: 10` beside `const: 1` is as unsatisfiable as a type mismatch,
// and proving the conjunction safe is the requirement here.
const { branches } = resolveRootUnion({
type: "object",
properties: { x: { type: "number", minimum: 10 } },
anyOf: [
{ type: "object", properties: { x: { const: 1 } } },
{ type: "object", properties: { other: { type: "string" } } },
] as unknown[],
});
expect(branches).toEqual([]);
});
it("accepts a const its root type and enum admit", () => {
const { branches } = resolveRootUnion({
type: "object",