Fix Formatter output contracts - #6872
Conversation
🦋 Changeset detectedLatest commit: a4b33fb The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
FormatterOutputContracts.test.ts— new test file with two reproduction tests forFormatteroutput contract violations:formatJson(undefined)returningundefined(not astring) andformat()misclassifying shared DAG references as[Circular].
These are precise, well-scoped reproduction tests that follow canonical @effect/vitest import patterns.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
0b8eaba to
a4b33fb
Compare
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Renamed
seen→ancestorsand addeddeletecleanup informat()— theWeakSetnow tracks only the current recursion path, so DAG-shared references render correctly at each location while true cycles still produce[Circular]. - Restructured object branch from early-return to single-return to support the
ancestors.delete(v)sentinel at every exit point. - Added
?? "null"toformatJson—JSON.stringify(undefined)no longer violates the: stringreturn type. JSDoc updated with a**Gotchas**section documenting the override. - Added tests for preserved non-circular references in
format()andformatJson(undefined).
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

Reproduction only
This PR adds reproduction tests only. No implementation fix is included. CI is expected to fail until the underlying issue is fixed.
Covered audit issues
1.
core-a-f-formatter-shared-reference-circular: Shared acyclic references are labeled circularModule:
FormatterExpected contract: format marks circular references as [Circular]; an acyclic graph that merely reuses one child should render that child at each location.
Observed result: Both focused assertions failed: a shared child rendered as [Circular], and formatJson returned runtime undefined.
Reproduction command:
2.
core-a-f-formatter-json-undefined-result: formatJson can violate its string return typeModule:
FormatterExpected contract: The exported formatJson function is declared to return string for input: unknown.
Observed result: Both focused assertions failed: a shared child rendered as [Circular], and formatJson returned runtime undefined.
Reproduction command: