Skip to content

fix(Conformance): render a throwing write fixture's value totally (#271) - #277

Merged
thomasfosterau merged 1 commit into
trunkfrom
issue-271-fixture-throw-render
Oct 8, 2026
Merged

thomasfosterau merged 1 commit into
trunkfrom
issue-271-fixture-throw-render

Conversation

@thomasfosterau

Copy link
Copy Markdown
Owner

Summary

Closes #271 (body and the widening comment: create, update and cleanup).

A write fixture member that threw a value String cannot convert came out Errored instead of Skipped, and a cleanup that failed with or threw a value Cause.pretty cannot inspect turned the release step into a defect (ledger detail: undefined, and the rules whose targets it disposed of Errored).

  • src/internal/conformance/core.ts exports the total renderer runRule already used after fix(Conformance): render a rule defect totally, capped at 500 characters #272, as renderThrown (@internal). runRule now calls it. Behaviour is unchanged: Result.try, an Error as Name: message, a string as itself, anything else through Formatter.format, the 500-unit cap, and [unrenderable defect] when rendering throws. The no-unknown-parameters warn-tier rule is suppressed on its one line with a reason: a thrown value has no schema to parse it by.

  • src/internal/conformance/write.ts: the create and update skip reasons render through renderThrown instead of String(error). runCleanup sets detail to renderThrown(Cause.squash(cause)) instead of Cause.pretty(cause).split("\n")[0]. Cause.squash is total: it returns the first Fail's error, otherwise the first Die's defect, otherwise a fixed Error. The runCleanup and dispose doc comments now say they never fail or die, whatever the cleanup fails with.

  • Docs: I removed the "until bug: a write fixture that throws an unstringifiable value is reported as Errored, not Skipped #271" qualification fix(Conformance): render a rule defect totally, capped at 500 characters #272 added in four places. The sentence now reads "A write fixture member that throws is not a defect, whatever it throws":

    • .changeset/conformance-rule-defect-outcome.md. It is still pending (package at 0.16.3, changeset not yet consumed), so I amended it rather than adding one.
    • the Conformance.Outcome JSDoc;
    • the one README sentence;
    • docs/conformance.md § cleanup ("recorded, not propagated"), which now also says how detail renders.

    I wrote "member" on purpose. A writes record whose property getter itself throws (the existing "thrown before the rule's Effect" case) is still a rule defect and still Errored. That is unchanged and still pinned.

Tests (written first)

The fixture-throw it.each in src/Conformance.test.ts now crosses five values with four ways a member can misbehave: create throws, update throws, cleanup throws, and cleanup returns Effect.fail. That makes 20 cases.

  • Values: the existing tagged error, { __proto__: null } (a null-prototype object), the revoked Proxy, an error whose message getter throws, and an error whose name is a Symbol.
  • Expected results:
    • create: every write rule Skipped, naming writes["articles"].create threw: <rendered>, and nothing recorded;
    • update: only spec/status/update-response Skipped, the others Passed;
    • cleanup: every write rule Passed, and the 5 entries not removed by the kit's own DELETE are cleanup-failed with detail exactly the rendered value;
    • every case: no Errored outcome and no Failed one.

Mutation checks:

  • On unfixed code (only the test change applied): 16 of the 20 cases fail.
    • All 4 new values × create/update fail with Errored outcomes.
    • The three unrenderable values × both cleanup modes fail with 5 Errored outcomes.
    • The null-prototype value × both cleanup modes fails on detail ("Error: {}" vs "{}").
    • The 4 tagged-error rows pass, as before.
  • Reverting one site at a time fails exactly that site's rows: create only gives the 4 create rows, update only the 4 update rows, and the cleanup line only the 8 cleanup rows.
  • Making renderThrown's catch rethrow fails 16 cases: the 12 unrenderable fixture rows plus the 4 existing runRule "unrenderable" tests.

Verification

Run in the AGENTS.md order on the pushed head:

  • pnpm install --frozen-lockfile: pass
  • vp run build: pass
  • vp check: pass (0 errors). No new warn-tier site in the changed lines, apart from the one justified oxlint-disable-next-line above.
  • vp run check (sources, type-level tests, examples, emitted declarations): pass ("every type gate green")
  • vp run -r test:unit: pass (root 2329 tests in 40 files; examples 41 + 45 + 54)
  • vp run docgen (every JSDoc @example compiled and executed): pass
  • fallow audit --format json --quiet --explain --gate-marker agent: verdict pass (0 introduced; 7 dead-code and 4 complexity findings inherited)
  • fallow audit --base origin/trunk: "No issues in 7 changed files" (11 inherited findings excluded)

Changeset

  • I amended the pending .changeset/conformance-rule-defect-outcome.md (minor, unreleased) in place, because the behaviour it describes has not shipped. No new changeset.

Notes

  • cleanup-failed detail format: a cleanup that fails with a string now records the string itself (store offline), not Cause.pretty's first line (Error: store offline). An Error reads Name: message either way. The Report.writes ledger has not been released yet (0.17.0), so no shipped output changes.
  • The detail is no longer cut at the first newline. It is capped at 500 UTF-16 code units, like an Errored message. Say if you would rather keep a first-line cut for the ledger.
  • Out of scope, left as is: runner's transportError: String(result.failure) in core.ts. It stringifies a typed HttpClientError, not a fixture value.
  • I did not touch src/Assemble.ts, src/Middleware.ts, src/Query.ts or src/Endpoint.ts.

🤖 Generated with Claude Code


Generated by Claude Code

A write fixture's `create` or `update` that threw a value `String` cannot
convert (a null-prototype object, a revoked Proxy, an Error whose `message`
getter throws or whose `name` is a Symbol) threw again inside the skip
reason's `catch`, and the rules it drove came out `Errored` instead of
`Skipped`. A `cleanup` that failed with or threw such a value made
`Cause.pretty` throw inside the release step, so its ledger entry kept
`detail: undefined` and the rules whose targets it disposed of died.

core.ts now exports the total renderer `runRule` already used, as
`renderThrown`, and write.ts renders the create / update skip reasons and
the `cleanup-failed` detail (of `Cause.squash(cause)`) through it: the same
`Name: message` / `Formatter.format` rendering, the same 500-unit cap and
the same `[unrenderable defect]` marker.

The fixture-throw `it.each` crosses five values with create, update,
cleanup throwing and cleanup failing. The pending
conformance-rule-defect-outcome changeset, the `Outcome` JSDoc, README and
docs/conformance.md drop the "until #271" qualification.

Claude-Session: https://claude.ai/code/session_0187g2QpzaHqEzX8GJxiJBVc
Co-Authored-By: Claude <noreply@anthropic.com>
@thomasfosterau
thomasfosterau merged commit f696104 into trunk Oct 8, 2026
1 check passed
@thomasfosterau
thomasfosterau deleted the issue-271-fixture-throw-render branch October 8, 2026 11:27
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