Repository navigation
uphold schema prints the JSON Schema of principles.toml, committed and drift-tested - #417
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 33 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (99.00%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #417 +/- ##
==========================================
+ Coverage 94.85% 94.87% +0.01%
==========================================
Files 52 53 +1
Lines 27259 27359 +100
==========================================
+ Hits 25857 25957 +100
Misses 1402 1402 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…rrent passes again (#419) Upstream tagged v0.17.2 while #417 and #418 were in CI, and the manual-stage pin check failed both on a line neither touched. ruff check and ruff format under v0.17.2 report nothing new over the whole tree. Claude-Session: https://claude.ai/code/session_01YTpdnDJrf2hT6hFyjS7evA
…itted copy is tested against the binary, the metaschema and the repository's own policies The schema is derived with schemars from the structs that deserialize the policy file, so deny_unknown_fields, rename and default mean to the schema what they mean to the reader. TOML has no null, so the generator's null alternatives are removed. The [override.<id>] table is read by hand and is described by a stand-in type; a unit test feeds every key of it to the reader. docs/schema/principles.schema.json is what the binary prints, and tests/schema_cli.rs fails while it differs (UPHOLD_SCHEMA_GOLDEN=bless writes it). The same test validates the file against the 2020-12 metaschema with jsonschema, runs policy/principles.toml and every bundled set through it, and checks that documents the deserializer refuses are refused. The release carries the schema and a .sha256 beside it as dist extra artifacts. dist writes no checksum for an extra artifact, so the build command writes it; release.yml is unchanged by this. Claude-Session: https://claude.ai/code/session_01YTpdnDJrf2hT6hFyjS7evA
69646ef to
b8ee4c9
Compare
uphold schemaprints a JSON Schema (draft 2020-12) forprinciples.toml, modelled onterm-server openapi: the binary prints its own spec, the output is committed, and a golden test fails while the two differ.What changed
schemarsderives the schema from the serde structs that read the policy file, sodeny_unknown_fieldsbecomesadditionalProperties: false,renamebecomes the key a person types, and doc comments become descriptions.src/schema.rsis the generator;uphold schematakes no arguments.docs/schema/principles.schema.jsonis the committed output.tests/schema_cli.rsfails while it differs fromuphold schema;UPHOLD_SCHEMA_GOLDEN=bless cargo test --test schema_clirewrites it.jsonschema(dev-dependency) to check the file against the 2020-12 metaschema, validatepolicy/principles.tomland every bundled set against it, and confirm that documents the deserializer refuses (unknown rule key, wrong types, bad enum values, a forbidden override key) are refused by the schema too.dist-workspace.tomlgains anextra-artifactsentry shippingprinciples.schema.jsonandprinciples.schema.json.sha256.release.ymlis untouched:dist generatewith theallow-dirtyline removed differs only in the existing Dependabotactions/checkoutpin.docs/REFERENCE.mdhas a new section (and table of contents entry) andREADME.mda line, covering regeneration and the taplo#:schemaline pointing at the release asset.Decisions to look at
Deserializeimpls,deserialize_withor untagged enums on the read path. Two things needed handling instead.[override.<id>]is held as a rawtoml::Tableand read by hand inOverride::of_table, soOverrideShapestands in for the schema, and a unit test writes every key it declares into a table and reads it back throughof_table. TOML has no null, soschemars'nullalternatives forOptionfields are stripped insrc/schema.rs(it has no setting for that)..sha256for archives and the source tarball only, and itssha256.sumdoes not list extra artifacts (checked withdist build --artifacts=global). The extra artifact's build command therefore writes the checksum itself withsha256sum. I verified it locally; the first real run is the next tag.[set]header outside a bundled set,ownerbesideowner_from, and non-compiling regexes are refused after the read; REFERENCE.md says so.[Type]markup.tests/structural_documentation.rs: documentingPolicyFileretired itsKNOWNexemption, so that entry is removed.deny.toml; the new crates (schemars,jsonschemaand their trees) are all under admitted licences.Not in this PR
No version bump or tag. The
#:schemaURL in the docs resolves once a release carries the asset.https://claude.ai/code/session_01YTpdnDJrf2hT6hFyjS7evA
Summary by CodeRabbit
uphold schemato print a JSON Schema for policy files, with editor support guidance.