Skip to content

refactor: every JSON encoding is its format's Effect Schema - #93

Open
systemfsoftware-bot wants to merge 9 commits into
mainfrom
refactor/codecs
Open

systemfsoftware-bot wants to merge 9 commits into
mainfrom
refactor/codecs

Conversation

@systemfsoftware-bot

@systemfsoftware-bot systemfsoftware-bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Deletes every hand-written JSON writer and reader. Each format's text is Schema.fromJsonString over its own schema. There is no shared canonical-JSON module, key sorter or Json namespace.

  • ApiModelFromJsonText, RuleCorpusFromJsonText, VerdictFromJsonText, PackageManifestFromJsonText and ExportTargetFromPackageExports are the readers and writers of their formats. ApiModel.decode/encode and Verdict.decodeRuleCorpus are removed.
  • Structural identity keys for types, signatures and items encode through their own schemas (typeExprKey, signatureKey, itemKey).
  • The verdict cell's writer encodes from Schema.toEncoded(Verdict), because the cell hands it the encoded verdict.
  • formatDocModel, formatTsdocMetadata and the verdict writer return typed failures instead of throwing.
  • vitest uses inlineSchemaTests() from @systemfsoftware/effect-schema-vite. src/schema-laws.test.ts is the committed stub, and the plugin generates the round-trip and recursion laws for every exported schema.
  • AGENTS.md's output rule now names schema encoding instead of the deleted module.

Output change: JSON keys follow schema declaration order and the text has no trailing newline. Decoding accepts any key order, and API_MODEL_SCHEMA_VERSION is unchanged. The scenario asserting the trailing newline is deleted (it covered removed behaviour).

Follow-ups: the doc model and tsdoc metadata still build untyped JSON, and sortModel runs before encode rather than inside it. Each moves to a declared schema in its own PR.

Checks: install, typecheck, lint and build exit 0. Each test file in packages/api-extractor passes when run on its own, and so do the e2e app's two integration files.

…gh its own schema

Every JSON text is Schema.fromJsonString over the format's schema. The shared wrapper, the key-sorting replacer, canonicalKey and the Json namespace are deleted. Structural keys for types, signatures and items encode through their own schemas. The verdict writer encodes from Schema.toEncoded(Verdict), because the cell hands it the encoded verdict. The scenario asserting the removed trailing newline is deleted.
@systemfsoftware-bot systemfsoftware-bot changed the title refactor: every JSON encoding is an Effect Schema refactor: every JSON encoding is its format's Effect Schema Nov 29, 2026

This branch has not been deployed

No deployments
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.

1 participant