Repository navigation
fix(Conformance): render a rule defect totally, capped at 500 characters - #272
Merged
Merged
Conversation
…cters (#246) Follow-up to #265. Rendering an `Errored` outcome's message could itself throw — `Predicate.isError` on a revoked `Proxy` throws — and the throw escaped `Effect.catchDefect`, killing the run the outcome exists to keep. The renderer now runs under `Result.try` and falls back to `[unrenderable defect]`, and caps the message at 500 characters, ending a longer one in `…` without splitting a surrogate pair. Pins the existing fixture-throw behaviour: a `create` that throws skips every write rule, an `update` that throws skips only `update-response`, and a `cleanup` that throws is recorded as `cleanup-failed`; none is Errored. Drops "and never was" from the pending changeset and adds the cap and the total rendering to it. Refs #246 Claude-Session: https://claude.ai/code/session_0187g2QpzaHqEzX8GJxiJBVc Co-Authored-By: Claude <noreply@anthropic.com>
…ssage template (#246) A write fixture that throws a value the kit can't render (a revoked Proxy, say) still makes its rule Errored until #271, cleanup included; the changeset, the Outcome JSDoc, the README and docs/conformance.md now say so instead of promising it never does. Pin errorMessage's template with an error whose name is a number (it renders as "42"; untemplated, it would fall back to the marker) and one whose name is a Symbol (the marker), and say exactly that in its doc. Note on Conformance.assert that RuleDied's message is always rendered while its cause holds the defect as thrown. Say "UTF-16 code units" for the cap. Claude-Session: https://claude.ai/code/session_0187g2QpzaHqEzX8GJxiJBVc Co-Authored-By: Claude <noreply@anthropic.com>
thomasfosterau
force-pushed
the
issue-246-rule-defect-followup-2
branch
from
October 8, 2026 07:04
6ea7e11 to
56a8c65
Compare
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #265. Refs #246.
The review follow-up to #265 (nothing in that review was blocking):
src/internal/conformance/core.ts,runRule). Rendering anErroredoutcome's message could itself throw:Predicate.isErroron a revokedProxythrowsTypeError: Cannot perform 'getPrototypeOf' on a proxy that has been revoked. That throw escapedEffect.catchDefectand killed the run theErroredoutcome exists to keep. Rendering now runs underResult.tryand falls back to the fixed string[unrenderable defect].errorMessagerendersnamethrough a template too, so a non-stringnamethat coerces to a string (a number, say) still renders; one that cannot coerce (a Symbol, or an object whosetoStringthrows) throws there, and the message falls back to[unrenderable defect].Errored.messageis capped at 500 UTF-16 code units, the…marker included. A longer message is cut to 499 code units plus…. The cut never splits a surrogate pair: a high surrogate that would end up last is dropped as well.defectitself is kept whole. The cap reachesassert'sRuleDiedmessage too, because that message is built fromErrored.message.it.eachafter "records a cleanup that fails". On trunk it matches the description for a thrown value the kit can render (the test throws a tagged error), so nothing changed: acreatethat throws skips every write rule with a reason namingwrites["articles"].create threw; anupdatethat throws skips onlyspec/status/update-responseand every other write rule passes; acleanupthat throws leaves every creation except the one the kit DELETEd ascleanup-failed. None of the three produces anErroredoutcome or a finding. A fixture member that throws a value the kit can't render (a revokedProxy,Object.create(null)) still makes its ruleErrored— that is bug: a write fixture that throws an unstringifiable value is reported as Errored, not Skipped #271..changeset/conformance-rule-defect-outcome.mdand added the cap and the total rendering to it.Second review round (commit 2, after rebasing onto trunk b1d774b)
cleanupis included:runCleanupinwrite.tscallsCause.pretty, which throws on a revokedProxy, a throwing getter or a Symbolname. The sentence now reads "A write fixture that throws a value the kit can render is not a defect … One that throws a value the kit can't render (a revokedProxy, say) is still reported asErroreduntil bug: a write fixture that throws an unstringifiable value is reported as Errored, not Skipped #271." It is changed in the changeset, theConformance.OutcomeJSDoc andREADME.md. Only that one README sentence changed, because other open work also edits README.docs/conformance.md's "A cleanup that fails is recorded, not propagated" is qualified the same way. Published files already link issues (README[#260](…), JSDoc{@link https://…/issues/122 #122}, changesets#237/#250), so the published text links bug: a write fixture that throws an unstringifiable value is reported as Errored, not Skipped #271 in the same style.write.tsis not touched here; bug: a write fixture that throws an unstringifiable value is reported as Errored, not Skipped #271 now covers cleanup too.errorMessagetemplate is pinned, and its doc no longer over-claims. New rows inrenders %s a rule dies with as itself: a tagged error whosenameis42, with an empty message (renders"42") and with a message (renders"42: refused"). A new test,marks an error whose name cannot become a string as unrenderable, uses a Symbolnameand expects[unrenderable defect]. The doc now says that a coercible non-stringnamerenders and a non-coercible one falls back to the marker. The test usesTransportRefused, notnew Error, so that it adds noavoid-untagged-errorswarning.Conformance.assertJSDoc now notes thatRuleDied'smessageis always rendered, while itscauseholds the defect as it was thrown. A reporter that pretty-prints the cause can therefore throw on a defect that cannot be inspected. Thecausecontract is unchanged.OutcomeJSDoc, the changeset and the internalErroreddoc.Tests (written first)
reports a defect no rendering can read, %s, as Erroreduses a revokedProxyin three ways: thrown by the transport, passed toEffect.dieby the transport, and thrown before the rule's Effect starts (awritesgetter). Each must produce oneErroredoutcome with the message[unrenderable defect], keep the samedefect, let the run complete and printthe rule died: [unrenderable defect], and leave the store empty. To support this,verifyOver/rungained an optional client wrapper.caps the message of a defect too long for a report line,does not split a surrogate pair when it caps a message,leaves a message at the cap as it is.renders an error named by a number …(two rows) andmarks an error whose name cannot become a string as unrenderable.Mutation checks:
core.tsrestored, 5 tests fail: all 3 revoked-proxy cases, where the run itself rejects with theTypeErrorfromPredicate.isErroratcore.ts:566, plus the cap test and the surrogate test.capped, only the surrogate test fails.errorMessage's empty-message branch untemplated (error.nameinstead of`${error.name}`),renders an error named by a number a rule dies with as itselffails: the number reachescapped, which throws, so the message becomes the marker instead of"42". The other 110 tests pass.it.eachpins trunk's behaviour, so it passes on trunk by design.Found, not done
#271:
write.tsbuilds a fixture's skip reason withString(error), andrunCleanuprecords a failed cleanup withCause.pretty. A fixture that throwsObject.create(null)or a revokedProxytherefore makes its ruleErroredinstead ofSkippedorcleanup-failed. The run still completes because of item 1 above. It sits outside this follow-up's scope, so it is filed rather than fixed here.Verification
Each gate was run in AGENTS.md order on the head commit's tree (rebased onto trunk b1d774b). Every one passed.
pnpm install --frozen-lockfile: passvp run build: passvp check: pass,Found 0 errors and 4353 warnings. None of the warnings is on an added line: I checked the lint output against the diff's added line ranges.vp run check(sources, type-level tests, examples, emitted declarations): passvp run -r test:unit: pass. Root: 39 files, 2266 tests. Examples: 42, 39 and 53 tests.vp run docgen(every JSDoc@examplecompiled and executed): pass, "Docs generation succeeded!"fallow audit --format json --quiet --explain --gate-marker agent: verdictpassfallow audit --base origin/trunk: pass. "No issues in 6 changed files"; 11 inherited findings were excluded by the gate.Changeset
.changeset/for every change to published behaviour. I amended the pending, unreleased.changeset/conformance-rule-defect-outcome.md(minor) rather than adding a new one: the cap, the total rendering and the qualified fixture-throw sentence all refine the same unreleasedErroredoutcome.Notes
[unrenderable defect]. Both are private constants incore.ts(MESSAGE_LIMIT,UNRENDERABLE), not exported options.Errored.messageis still astring; only its content is bounded.RuleDied.causestill holds the raw defect.README.mdand theConformance.OutcomeJSDoc, both of which ship on npm, now link bug: a write fixture that throws an unstringifiable value is reported as Errored, not Skipped #271. Once bug: a write fixture that throws an unstringifiable value is reported as Errored, not Skipped #271 lands, that sentence should be simplified back to the unqualified promise.🤖 Generated with Claude Code
Generated by Claude Code