Repository navigation
feat: make the repository state the truth about the drivers it publishes - #18
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 778e412f6b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| version = manifest_version(manifest_raw) | ||
| if version is None or version in seen: | ||
| continue |
There was a problem hiding this comment.
Reject later source bytes under an existing version
When a Lua source changes in a later commit without a manifest version bump, this branch skips that commit because the version is already in seen, so generate_history.py --check still succeeds and the new bytes can be packaged under the old version. This already occurs for esphome-dsmr 1.0.1, whose commits be9c9ee and aadd923 have different hashes, and a committed same-version mutation reproduces the false success. Compare every subsequent occurrence against the recorded hash and report a mutation rather than silently continuing.
Useful? React with 👍 / 👎.
| if additions: | ||
| # Not a failure. A version becomes recordable only once its commit | ||
| # exists, so a branch that bumps a driver always runs one version | ||
| # ahead of the file until `make history` runs at release. |
There was a problem hiding this comment.
Record new versions before allowing their release
On the main commit that introduces a version, additions is nonempty but --check deliberately returns success. I checked .github/workflows/ftw-drivers-release.yml: it publishes signed artifacts on pushes to main and never invokes make history, so every future bumped version can be released while absent from driver-history.json, defeating the promised lookup and rollback record until someone happens to make a later manual history commit. The release path needs to require or create the history record before publication.
AGENTS.md reference: AGENTS.md:L13-L14
Useful? React with 👍 / 👎.
Manifest sha256 and size_bytes were maintained by hand and had drifted: 60 of 62 manifests described bytes their driver no longer had, and 22 claimed nothing at all. validate_manifest.py only checked that the size was a non-negative number, so nothing caught it. index.yaml was the only file telling the truth, because it derives both from the source. Derive them everywhere instead. tools/sync_manifests.py rewrites both fields from the Lua file, make check runs it and fails on any diff. Two gaps followed from the same place. There was no quick way to raise a version without forgetting one of the two files that state it, and no way to recover an older driver: index.yaml names only the current version, while spec/driver-package-v1.md already promises rollback to a previously verified package. - make bump-driver ID=<id> LEVEL=patch moves the manifest and the DRIVER table together, then refreshes the generated catalog. - driver-history.json records every published version with its source hash, size, first commit and date. The record is append-only: a published version describes bytes already running on hardware, so make check fails if an entry is rewritten or dropped. Signed-off-by: Fredrik Ahlgren <[email protected]>
#17 changed drivers/lua/sungrow.lua, so the manifest hash this branch wrote no longer described the file. This is the guard working: make check caught it rather than letting main carry a manifest that lied. Signed-off-by: Fredrik Ahlgren <[email protected]>
778e412 to
035891a
Compare
Summary
This repository is the source of truth for Sourceful drivers. On three counts
it was not stating the truth, and the Sungrow work in #17 ran into all three.
Manifests described bytes their driver no longer had.
sha256andsize_byteswere typed by hand. 60 of 62 manifests had a stalesize_bytes,5 had a stale
sha256, and 22 claimed nothing at all (sha256: "",size_bytes: 0).validate_manifest.pyonly checked that the size was anon-negative number, so nothing caught it.
index.yamlwas the only filetelling the truth, because it derives both from the source file.
There was no quick way to raise a version. A driver states its version in
up to two places that must agree: the manifest, and the
versionfield of theDRIVERtable where a driver has one. Moving one and forgetting the otherships a driver that misreports itself to the host.
There was no way back to an older driver.
index.yamlnames one versionper driver: the current one.
spec/driver-package-v1.mdalready promises"rollback to a previously verified package without mutating the old release",
and nothing in the catalog made that possible.
What changed
tools/sync_manifests.pyderivessha256andsize_bytesfrom the Lua file.make checkruns it and fails on any diff, so a stale manifest cannot reachmain.make bump-driver ID=<id> LEVEL=patchmoves the manifest and theDRIVERtable together, then refreshes
index.yaml,devices.yamland the supportstatus. Only 4 of 62 drivers declare a version in Lua; the tool handles both
shapes and says which it did.
driver-history.jsonrecords every version this repository has published —73 versions across 62 drivers — with the source SHA-256, the size, the commit
that first carried it and the date. An operator can now look up a version and
read the exact source out of that commit.
The history is append-only. A published version describes bytes already
running on hardware somewhere, so rewriting an entry would make the record lie
about what a site installed.
make checkfails if an entry is rewritten ordropped. It does not fail on a version that is merely not recorded yet: a
version becomes recordable only once its commit exists, so a branch that bumps
a driver runs one ahead until
make historyruns at release.Driver evidence
Not applicable. No driver behaviour changes. The 118 manifest field updates
are corrections to metadata that already described these files;
index.yaml,which is generated, is unchanged by them.
Safety
driver-history.jsonholds public commit hashes and source hashes only.Package or promotion evidence
not applicable— no package version, target, control contract or releasecandidate changes.
Checks
Signed-off-by.make check— 2675 passed, 549 skipped (up from 2606; 69 new)New in
tests/test_driver_truth.py:sha256andsize_bytesdescribe the file it names;DRIVERtable agree on the version;Verified by hand that the guards bite: appending a line to a driver without
syncing fails both the test and
sync_manifests --check(exit 1), and editingor deleting a recorded history entry fails
generate_history --check.🤖 Generated with Claude Code