Repository navigation
feat(package): define package JSON via self-documenting codecs - #738
Draft
koterpillar wants to merge 3 commits into
Draft
koterpillar wants to merge 3 commits into
koterpillar wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (78.47%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #738 +/- ##
==========================================
- Coverage 92.03% 91.04% -1.00%
==========================================
Files 131 133 +2
Lines 5477 5681 +204
Branches 330 367 +37
==========================================
+ Hits 5041 5172 +131
- Misses 106 142 +36
- Partials 330 367 +37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
koterpillar
force-pushed
the
json-doc-codecs
branch
11 times, most recently
from
November 3, 2026 04:27
2f83f82 to
b00e8dd
Compare
koterpillar
force-pushed
the
json-doc-codecs
branch
7 times, most recently
from
November 8, 2026 04:14
41323c4 to
9d04b4e
Compare
Introduce `JSONCodec`, a typeclass bundling the JSON encoder, decoder and documentation of a type. Package records describe their fields with `jsonCodecObject`; each field spec is tagged with the Haskell field name and matched against the record's Generic representation, so adding, removing or renaming a field without updating the codec is a type error. `ArchiveFields` and `FilterFields` are flattened via `JSONObjectCodec`. `FromJSON`/`ToJSON` are derived via `ViaJSONCodec`. Field defaults come from `RecValue`, the same notion of "default" that package name splitting uses. Descriptions are placeholders for now. Encoding now omits optional fields that are absent and fields equal to their default, instead of writing `null` or the default value. Parsing is unchanged. This changes the stored hash of most packages (and the yum repo version), so they will be reinstalled once. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Render the JSONCodec documentation of SomePackage as a table of fields per package type: key, type and description, with required fields marked by a star. Fields of nested objects are indented under their parent. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Replace the placeholder descriptions in the package codecs with one-line explanations of each JSON key. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
koterpillar
force-pushed
the
json-doc-codecs
branch
from
November 24, 2026 10:07
07b4f95 to
8c34d71
Compare
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
Introduces
JSONCodec(Mybox.JSONCodec), a typeclass that bundles the JSON encoder, decoder and documentation of a type in one value, and uses it to define the JSON representation of every package.jsonCodecObject. Each field spec is tagged with the Haskell field name (field @"repo" "clone" "...") and the list is matched against the record'sGenericrepresentation, so adding, removing, reordering or renaming a record field without updating the codec is a type error.JSONObjectCodecis the companion class for types represented as a set of keys rather than a value:ArchiveFieldsandFilterFieldsare flattened into the enclosing object viafieldFlat.FilterFieldsalso has a standaloneJSONCodecinstance for the nested Forgereleaseobject.Packagenow requiresJSONCodecinstead ofFromJSON/ToJSON; package hashes are computed through the codec. Concrete packages still deriveFromJSON/ToJSONviaViaJSONCodecfor convenience, andSomePackagedocuments itself as one-of all package objects.field(required),fieldDefault(defaults to the type'sRecValuervEmptywhen absent, omitted whenrvNull),fieldOptional(Maybe, omitted when absent),fieldFlat(flattened). UsingRecValuemeans the encoder and package name splitting share one notion of "default".Text,Bool,Path, lists (accepting a single item),NonEmpty, and untaggedEither(archiveraw). Enums (LinksMethod,InstallerKind) useenumCodec, which documents every value.--package-help.mybox --package-helpRenders the
SomePackagedocumentation as a table per package type: key, type and description, with required keys marked by a star. Fields of nested objects (the Forgereleasefilter) are indented under their parent. Lists that accept a single item show astext | [text]; enums list their values.Encoding change
Encoding now writes a key only when it carries information: optional fields are omitted when absent (previously
nullfor clonebranch, systeminstaller/url, yumgpg_key) and fields equal to their default are omitted (previouslypost: [],root: false, the filter and archive lists, etc. were always written). Parsing is unchanged and round-trips exactly.Because the stored package hash is the encoding minus the name (and the yum repo version is the encoding), every package that stores a hash will be considered changed and reinstalled once after upgrading. Packages fully determined by their name store no hash and are unaffected. The reinstalls are idempotent (fetch and reset, upgrade, re-link, re-extract).
Test plan
Mybox.JSONCodecSpeccovers each field policy, defaults, null handling, unknown keys, flattening and generated docsMybox.Package.SomeSpecchecks all 12 package types are documented, render in--package-helpand have no duplicate JSON keys after flatteningMybox.Display.SimpleSpecchecks the exact rendering of a documentation tree,Mybox.Config.CommandLineSpecthe new flagPackageNamespecs pass for every package🤖 Generated with Claude Code