Skip to content

feat: make the repository state the truth about the drivers it publishes - #18

Merged
frahlg merged 2 commits into
mainfrom
18-driver-truth-versioning-and-history
Jul 25, 2026
Merged

frahlg merged 2 commits into
mainfrom
18-driver-truth-versioning-and-history

Conversation

@frahlg

@frahlg frahlg commented Jul 25, 2026

Copy link
Copy Markdown
Member

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. sha256 and
size_bytes were typed by hand. 60 of 62 manifests had a stale size_bytes,
5 had a stale sha256, and 22 claimed nothing at all (sha256: "",
size_bytes: 0). 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 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 version field of the
DRIVER table where a driver has one. Moving one and forgetting the other
ships a driver that misreports itself to the host.

There was no way back to an older driver. index.yaml names one version
per driver: the current one. spec/driver-package-v1.md already 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.py derives sha256 and size_bytes from the Lua file.
make check runs it and fails on any diff, so a stale manifest cannot reach
main.

make bump-driver ID=<id> LEVEL=patch moves the manifest and the DRIVER
table together, then refreshes index.yaml, devices.yaml and the support
status. Only 4 of 62 drivers declare a version in Lua; the tool handles both
shapes and says which it did.

driver-history.json records 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 check fails if an entry is rewritten or
dropped. 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 history runs 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

  • The driver starts read-only, or this is a separately reviewed control change.
  • Vendor signs are converted at the driver boundary.
  • Cached telemetry becomes stale instead of being re-emitted as fresh.
  • No credentials, serial numbers, private addresses or site data are included.

driver-history.json holds public commit hashes and source hashes only.

Package or promotion evidence

not applicable — no package version, target, control contract or release
candidate changes.

Checks

  • Commits include Signed-off-by.
  • make check — 2675 passed, 549 skipped (up from 2606; 69 new)

New in tests/test_driver_truth.py:

  • every manifest's sha256 and size_bytes describe the file it names;
  • manifest and DRIVER table agree on the version;
  • the history is well formed and no published version is rewritten;
  • current versions can be traced back to a commit.

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 editing
or deleting a recorded history entry fails generate_history --check.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread tools/generate_history.py
Comment on lines +84 to +86
version = manifest_version(manifest_raw)
if version is None or version in seen:
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread tools/generate_history.py
Comment on lines +167 to +170
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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

frahlg added 2 commits July 25, 2026 09:11
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]>
@frahlg
frahlg force-pushed the 18-driver-truth-versioning-and-history branch from 778e412 to 035891a Compare July 25, 2026 07:12
@frahlg
frahlg merged commit 1e77310 into main Jul 25, 2026
5 checks passed
@frahlg
frahlg deleted the 18-driver-truth-versioning-and-history branch July 25, 2026 07:13
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