feat(validate): report the schema revision a validation actually used - #60
Merged
Merged
Conversation
`gds validate repository --json` named its target and its findings but not the schemas it judged them against, and nothing else in the CLI did either -- there was no schema digest anywhere in the tree. Callers filled the gap with the binary's version string, and that string identifies nothing. On this machine the binary reports 0.8.0, the source constant is 0.7.0, and the newest release tag is gds-v0.6.0; no tag for either 0.7.0 or 0.8.0 exists. A consumer printing `gds --version` beside a green result is printing a name with no contract behind it, which is the shape this estate keeps finding: a value without the thing that gives it meaning. `Set.Digest()` hashes every embedded schema file, path and content, in the sorted order `fs.ReadDir` returns, and `validate repository` carries it in `data.schema_digest`. It is derived from content, so unlike a build-time stamp it cannot name a revision that was never compiled. Verified in both directions. Adding a property to repository.schema.json and rebuilding moves the digest from 2526481e to c02d033f. The coverage test recomputes the digest over the embedded set independently; excluding file content from the implementation makes it fail with a different digest over 50 schema files, so the assertion can fail rather than merely pass.
`core/app` and `core/validation` are both in the source paths the bundle lock digests, so adding the schema digest changed the source tree identity and left every projection stale against it. Regenerated through `gds generate repository` plan/apply rather than by hand: the two files carry per-file digests in their own headers that cannot be derived by reading them. `gds generate repository --check` now reports no findings.
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.
gds validate repository --jsonnamed its target and its findings but never the schemas it judged them against. Nothing else in the CLI did either — there was no schema digest anywhere in the tree.A version string cannot fill that gap, and here is the proof
Consumers reached for the binary's version. Measured on this machine:
No tag exists for
0.7.0or0.8.0. But the sharper problem is not the numbering — it is that two live checkouts of this project carry different schemas, and no version string distinguishes them.schemas/v1/repository.schema.jsonhere and in the archivedNDDev-it-com/github-device-syncare not the same document. The archived one listsworkflow_refandrepository_idas required; this one marks both optional and carries an extragenerated-fromenum value. Same file name, same project, different contract — and the two produce different digests,sha256:e27e6877…here againstsha256:2526481e…there.I established which set the installed binary actually carries by asking the artifact rather than the source: it holds 51
$ids pointing atNDDev-OpenNetwork/github-device-sync/schemasand none at the archived path. So a consumer printinggds --versionbeside a green result is printing a name with no contract behind it, while the thing that decided the result is invisible.This came from
setup-systems, whosecheck_render.shprintsgds --versionbeside its validation result, with a comment explaining that a green result which does not name its validator is worth less than one that does. The reasoning is right; the value available to them was not. I answered their schema question from the archived tree before noticing the split, which is the same mistake from the other side.What this adds
Set.Digest()hashes every embedded schema file — path and content, NUL-separated, in the sorted orderfs.ReadDirreturns — andvalidate repositorycarries it asdata.schema_digest:{ "anchor": "/…/.gds/repository.yaml", "target": "/…", "schema_digest": "sha256:e27e6877aa05171e7849a5ed9d7f9ff5f16852be8adf769a4c18d6b1483fd90b" }Being derived from content, it cannot name a revision that was never compiled, and it separates the two schema sets above without anyone having to know they exist.
Verified in both directions
It moves when the schemas move. Adding a property to
repository.schema.jsonand rebuilding changed the digest.The test can fail.
TestSchemaDigestCoversEverySchemaFilerecomputes the digest independently over the embedded set. Mutating the implementation to hash paths but not file content makes it fail —Digest() = "sha256:9e4dbfe4…", want "sha256:2526481e…" over 50 schema files— and the real implementation passes. A digest that skipped a file would stay identical while that file changed, which is the failure it exists to prevent, so the assertion had to be shown capable of catching it.TestSchemaDigestIdentifiesTheEmbeddedSetcovers format and determinism: two sets compiled from the same embedded schemas must agree, or the digest identifies the run rather than the schemas and is worse than printing nothing.Scope
datainoperation-result.schema.jsonis an open object withmaxProperties: 128, so no schema change is needed.go build ./...,go vet, and thecore/validationandcore/appsuites are clean.