Skip to content

fix(conformance): render server values and multi-line details safely (#277 follow-up) - #284

Merged
thomasfosterau merged 2 commits into
trunkfrom
issue-271-fixture-render-followup
Oct 8, 2026
Merged

thomasfosterau merged 2 commits into
trunkfrom
issue-271-fixture-render-followup

Conversation

@thomasfosterau

@thomasfosterau thomasfosterau commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

Follow-up to #277. Refs #271.

The review follow-ups to #277, each checked against trunk before the change, plus a second commit for this PR's own review (items 5–7):

  1. Fixture-throw rows. The fixtureValues it.each in src/Conformance.test.ts gains four values. Each runs across all four member modes (create throws, update throws, cleanup throws, cleanup fails with):

    These pin fix(Conformance): render a throwing write fixture's value totally (#271) #277's fix. They pass on trunk and fail under the mutations below.

  2. Multi-line values in format. report.ts gains a hang helper (first line after one prefix, later lines after another):

    • WRITES entries: a cleanup-failed detail that spans lines keeps its later lines at the entry's sub-line indent (6 spaces) instead of the margin.
    • A finding's detail: it went through indent(…, " · "), so each later line got its own bullet and read as a second finding. Details can quote server data, such as a member name. Only the first line now carries ·; later lines hang at 8 spaces.
    • A finding's expected: / observed: (item 6 below): later lines hang 2 deeper than the label, not at the label's column, where a server type of "a\nb" would read as another field.
    • Left on indent: DIED messages, skip reasons, Passed notes and the rule reference. Each is the last thing in its outcome block, so a later line cannot be mistaken for a sibling field.
    • Single-line by construction: rule text and gap reasons are re-wrapped on whitespace. A probe's URL and headers cannot carry a newline, and the probe body is JSON.stringify'd.
    • Left as is: the header's target is the caller's own label, not server data.
  3. Doc over-claims. These texts said every value that throws when inspected becomes [unrenderable defect]: the renderThrown doc (core.ts), the Conformance.Outcome JSDoc (both places), the pending changeset .changeset/conformance-rule-defect-outcome.md (both sentences) and docs/conformance.md § cleanup. All of them now say only a value the kit cannot read at all gets the marker; item 5 makes the list exact.

  4. String on server values (pre-existing bug). Two rules in spec.ts rendered included members with String, which throws on valid JSON such as {"toString":1}, so the rule came out Errored instead of Failed:

    • spec/document/full-linkage: String(resource["type"]) and String(resource["id"] ?? resource["lid"]) on orphaned members. "included":[{"type":{"toString":1},"id":"2"}] made it Errored.
    • spec/document/no-duplicate-resources (spec.ts ~670): String(resource["id"]). identity requires a string type, but not a string id: it keys a member on its lid whenever its id is not a string. So two copies of {"type":"people","id":{"toString":1},"lid":"9"} in included made the rule Errored on trunk. It also printed people:undefined for a member identified only by lid.

    A new resourceLabel helper renders a string as itself and any other value through Formatter.format. Normal reports keep people:404 instead of switching to quoted JSON. Both rules use it. It names the member identity compares on (item 6).

    • I grepped the kit (spec.ts, profile.ts, write.ts, core.ts) for String(, template interpolation and .join over server-supplied values. Those two rules are the only sites. The other String( calls take kit-side values: schema property names in core.ts:208, the caller client's typed HttpClientError in core.ts:492 and a numeric status in spec.ts:987.

Second commit: this PR's review

  1. The [unrenderable defect] cases, stated exactly. I checked each claim by calling renderThrown directly:

    Value Renders as
    revoked Proxy [unrenderable defect]
    Proxy whose getPrototypeOf trap throws [unrenderable defect]
    Proxy whose only throwing trap is get [inspection threw]
    Error whose message / name getter throws [unrenderable defect]
    Error whose message / name is a Symbol [unrenderable defect]
    Error whose message / name is an object whose toString throws [unrenderable defect]
    Error whose name is a number 42: z
    object whose toString throws [toString threw]
    object with a throwing enumerable getter {"a":"[property access threw]"}

    The Outcome JSDoc (src/Conformance.ts), the changeset and the renderThrown doc now read "a revoked Proxy, or one whose getPrototypeOf trap throws, or an Error whose name or message throws when read or cannot become a string (a Symbol, or an object whose toString throws)". The UNRENDERABLE doc no longer says "throws when it is inspected". The errorMessage doc now covers message as well as name. The renderThrown doc also names [inspection threw] for a Proxy whose get trap throws.

  2. resourceLabel names the member identity compares on. It used id ?? lid, so two copies of {"type":"people","id":7,"lid":"8"} read people:7, though they were found equal on lid. It now picks isString(id) ? id : isString(lid) ? lid : (id ?? lid), so the label reads people:8, in full-linkage as well. When neither member is a string there is no key, and the id ?? lid fallback keeps naming whichever is present: people:5 for {"lid":5}, not people:undefined. That fallback is the one deviation from the review's suggested … : id.

  3. Multi-line expected: / observed: now use hang as well (item 2). It is two lines, the same helper and the same "later lines sit 2 deeper than what they belong to" rule as the WRITES and finding-detail cases.

Tests (test-first) and mutation checks

  • Item 1: the bug: a write fixture that throws an unstringifiable value is reported as Errored, not Skipped #271 rows pass on trunk (fix(Conformance): render a throwing write fixture's value totally (#271) #277 already fixed the behaviour).
    • Mutation A: renderThrown's catch: () => UNRENDERABLE changed to rethrow. All 8 bug: a write fixture that throws an unstringifiable value is reported as Errored, not Skipped #271 [unrenderable defect] rows fail (Proxy whose traps throw, and Error whose name getter throws, × 4 modes). In the second commit, the same mutation also fails all 4 rows of the new an error named by an object whose toString throws row (24 of 36 fixtureValues cases fail in all). The new rows pass when the mutation is reverted.
    • Mutation B: Formatter.format(thrown) changed to String(thrown). All 4 toString throws rows fail, along with the existing null-prototype rows.
    • Both mutations were reverted. I confirmed core.ts was byte-identical afterwards.
  • Item 2 / 7:
    • keeps a cleanup failure that spans lines inside its write's entry (cleanup Effect.fails with a tagged FixtureBroke({ message: "a\nb" })) failed before the report.ts change and passes after it. So does marks only the first line of a finding that spans lines as a finding. I used the tagged error in place of new Error("a\nb") so the test adds no new effect(avoid-untagged-errors) warning. The rendered detail has the same shape: FixtureBroke: a\nb.
    • hangs an expected or observed value that spans lines under its label failed while expected: / observed: used indent, and passes with hang.
  • Item 4 / 6:
    • names an orphaned included resource whose type or id is not a string failed before the fix (expected 'Errored' to be 'Failed'). names a duplicated included resource by its lid when it has no id also failed before it (people:undefined at /included/0 and /included/1).
    • New: names a duplicated included resource whose id is not a string by its lid and names an included resource by the member its identity is keyed on. Before the second commit they read people:{"toString":1} at … and people:7 at …; they pass after it.
    • Mutation C (S1): only the no-duplicate-resources site reverted to `${String(resource["type"])}:${String(resource["id"] ?? resource["lid"])}`. The {toString:1} case fails with expected 'Errored' to be 'Failed'.
    • Mutation D (S2): resourceLabel's member reverted to id ?? lid. Both new tests fail.
    • Both mutations were reverted from a byte-identical backup.

Verification

Run in order on the second commit's tree, in a fresh clone:

  • pnpm install --frozen-lockfile: pass
  • vp run build: pass
  • vp check: pass (0 errors). Total warnings 4340, the same as before this commit, so none were added.
  • vp run check (sources, type-level tests, examples, emitted declarations): pass ("every type gate green")
  • vp run -r test:unit: pass (root 2374 tests, examples 45 + 41 + 54)
  • vp run docgen (every JSDoc @example compiled and executed): pass ("Docs generation succeeded!")
  • fallow audit --base origin/trunk: pass ("No issues in 8 changed files"; 23 inherited findings excluded by the new-only gate)
  • ./node_modules/.bin/fallow audit --format json --quiet --explain --gate-marker agent: verdict pass

Changeset

  • .changeset/conformance-render-server-values.md (patch):
    • full-linkage and no-duplicate-resources no longer die on a non-string type/id. That includes no-duplicate-resources' Errored on a duplicated {"id":{"toString":1},"lid":"9"}.
    • Both name a resource by the member the kit compares it on: people:9 for a lid, and people:8 for {"id":7,"lid":"8"}.
    • format hangs multi-line WRITES details, finding details, and expected: / observed: values.
  • The pending .changeset/conformance-rule-defect-outcome.md is reworded only (items 3 and 5). Its bump is unchanged.

Notes

🤖 Generated with Claude Code


Generated by Claude Code

claude added 2 commits October 8, 2026 13:32
Review follow-ups to #277 (Refs #271):

- spec/document/full-linkage named an orphaned `included` member with
  `String(type)`/`String(id ?? lid)`, which throws on valid JSON such as
  `{"type":{"toString":1}}`, so the rule came out Errored, not Failed. Both
  it and spec/document/no-duplicate-resources now render through one
  `resourceLabel`: a string as itself, anything else via Formatter.format;
  the duplicate rule also names a lid-only resource by its lid.
- Conformance.format hangs the continuation lines of a multi-line WRITES
  entry (a cleanup-failed detail) and of a multi-line finding detail,
  instead of starting them at the margin or repeating the bullet.
- The fixture-throw it.each gains a Proxy whose traps throw, an object
  whose toString throws and an Error whose name getter throws.
- renderThrown's doc, the Outcome JSDoc, docs/conformance.md and the
  pending changeset no longer claim every value that throws when inspected
  becomes `[unrenderable defect]`.

Claude-Session: https://claude.ai/code/session_0187g2QpzaHqEzX8GJxiJBVc
Co-Authored-By: Claude <noreply@anthropic.com>
no-duplicate-resources rendered a duplicate with String(id ?? lid), so
a duplicated {type, id: {toString: 1}, lid} made the rule Errored, not
Failed; the label also named an id the comparison ignored. Both rules
now pick the member identity keys on (a string id, else a string lid)
and pin it with tests.

Hang a multi-line expected/observed under its label, add a fixture row
for an Error named by an object whose toString throws, and state the
[unrenderable defect] cases exactly (a revoked Proxy or one whose
getPrototypeOf trap throws; an Error whose name or message throws when
read or cannot become a string).

Refs #271.

Claude-Session: https://claude.ai/code/session_0187g2QpzaHqEzX8GJxiJBVc
Co-Authored-By: Claude <noreply@anthropic.com>
@thomasfosterau
thomasfosterau merged commit d8d9f18 into trunk Oct 8, 2026
1 check passed
@thomasfosterau
thomasfosterau deleted the issue-271-fixture-render-followup branch October 8, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: a write fixture that throws an unstringifiable value is reported as Errored, not Skipped

2 participants