Repository navigation
fix(nix): embed full git revision in packaged build identity - #2743
Conversation
|
Warning Review limit reached
Next review available in: 19 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0328a88281
ℹ️ 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".
| from polylogue import __version__ as polylogue_version | ||
| from polylogue.version import VERSION_INFO | ||
|
|
||
| build_version = VERSION_INFO.version |
There was a problem hiding this comment.
Keep the metrics version label aligned with --version
For any build with commit metadata, this emits only the base package version (e.g. 0.1.0) while the new docs and commit message describe the metrics version label as the same concise human identity exposed by polylogue --version/POLYLOGUE_VERSION (e.g. 0.1.0+<8-char>[-dirty]). Operators comparing the build-info metric to CLI/log output will see different version strings for the same runtime, and dirty builds also lose the dirty marker in this label. Use VERSION_INFO.full/POLYLOGUE_VERSION here and leave the new revision label as the full machine-readable hash.
Useful? React with 👍 / 👎.
Problem: flake.nix wrote BUILD_COMMIT from self.shortRev (7 hex
chars), so every packaged runtime (polylogue --version, polylogued
--version, ArchiveIdentity.build_commit, the daemon build-info
metric) could only ever report a truncated, collision-prone prefix.
The Nix build itself already retains the full revision (self.rev),
but nothing embedded it, so a running artifact could not
independently attest its exact source identity against a consuming
flake's flake.lock rev/narHash during schema-sensitive rollouts.
Separately, polylogue_daemon_build_info always reported
version="unknown" because it imported the nonexistent
polylogue.__version__ (the package has no such attribute) and
silently fell back in a bare except.
What changed:
- flake.nix: derive buildRevision from self.rev (falling back to
self.dirtyRev with its "-dirty" suffix stripped, then "unknown"),
and buildDirty from `self ? dirtyRev`; embed both into
polylogue/_build_info.py instead of the short forms. Added a
checks.build-info derivation that builds the package and asserts
the installed _build_info.py's BUILD_COMMIT/BUILD_DIRTY literally
match self.rev/self.dirtyRev, and that `polylogue --version`
surfaces the matching short prefix — a package-level proof the
reported revision matches the flake input.
- polylogue/daemon/metrics.py: fixed polylogue_daemon_build_info to
source version/revision/dirty from polylogue.version.VERSION_INFO
(the real API) instead of the broken __version__ import, and added
`revision` (full commit) and `dirty` labels alongside the existing
concise `version` label.
- docs/daemon.md: new "Build Identity & Deployment Attestation"
section documenting the concise-version vs full-revision fields
and how to join a running daemon's revision against a consuming
flake's flake.lock rev/narHash.
- tests/unit/daemon/test_metrics_endpoint.py: replaced the
substring-order-dependent version-label assertion (labels are
emitted sorted, so `{version=` no longer prefixes the label set)
with an order-independent check, and added a test pinning the new
revision/dirty labels and full 40-char length.
polylogue/version.py and the storage/archive_identity.py /
insights/export_bundles.py read paths already exposed
VERSION_INFO.commit as a full, untruncated field for source
checkouts and PyPI/hatch builds (git rev-parse HEAD is already full
there) — only the Nix packaging path and the metrics label were
truncated/broken.
Verification:
- nix flake check --no-build: all checks pass.
- nix build .#checks.x86_64-linux.build-info: passes; inspected the
built store path directly — _build_info.py now contains
BUILD_COMMIT = "d819423459dc1fdf3c2a249a5182d8d3970df3dd" (full 40
hex, this worktree's base commit) and BUILD_DIRTY = True (dirty
worktree), vs. the prior BUILD_COMMIT = "d819423" (shortRev) on
the same build.
- devtools test tests/unit/daemon/test_metrics_endpoint.py
tests/unit/core/test_version.py: 59 passed.
- mypy --strict polylogue/daemon/metrics.py: no issues.
Ref polylogue-6rvt
Co-Authored-By: Claude <[email protected]>
0328a88 to
88af2e3
Compare
## Summary Completes the release-artifact recovery path for v0.2.0, makes every documented install channel exercise its production packaging route, and attaches verifiable browser-store submission metadata. ## Problem v0.2.0 has a real GitHub tag/release but no release assets, no release/Homebrew tag workflow run, and no PyPI project. Rebuilding from current master could have published newer source under an older release version. The documented pipx and Homebrew install paths had not been exercised by their release workflows, and store archives were not bound to a full source revision. ## Solution - Release, container, and extension workflows accept release_tag, resolve refs/tags/vX.Y.Z, and reject a checkout whose commit differs from the tag target. Manual PyPI publication requires it. - PyPI release CI builds and installs the wheel through pipx, smokes CLI/daemon/MCP entrypoints, and requires installed VERSION_INFO to contain the full 40-character checked-out revision. - GHCR builds embed the full checkout revision, publish it as an OCI label, then pull slim and distroless images and assert the concise CLI prefix plus the exact machine-readable VERSION_INFO.commit. Recovery never rewrites latest. - Homebrew now audits, installs, and runs brew test on the generated resource-expanded formula before opening its tap PR. - Extension releases attach a source-revision-and-SHA-256 store-submission manifest alongside exactly one version-matched Chrome archive, Firefox archive, and screenshot bundle. The installation matrix documents every route and the no-recut recovery sequence. ## Acceptance matrix | Bead | Status | Evidence | | --- | --- | --- | | polylogue-y8s5 | implementation support satisfied; external publication deferred | Release, pipx, GHCR, Homebrew, and extension lanes now have recovery/publish/smoke wiring. The documented v0.2.0 dispatches still require operator-owned PyPI Trusted Publishing and Homebrew credentials. | | polylogue-6rvt | satisfied/extended | PR #2743 supplied full revision for Nix. This PR proves it from the installed wheel and embeds/smokes the same full revision in GHCR runtimes. | ## Verification - nix develop --command devtools release verify-distribution --work-dir /realm/tmp/polylogue-distribution-pipx — built wheel + sdist, installed each in isolated venvs, and exercised CLI, daemon, MCP, parser, and diagnostics entrypoints. - pipx install --suffix=-smoke /realm/tmp/polylogue-distribution-pipx/dist/polylogue-0.2.0-py3-none-any.whl — installed the built wheel through real pipx; polylogue-smoke, polylogued-smoke, and polylogue-mcp-smoke all passed. - node browser-extension/scripts/build.mjs --out /realm/tmp/polylogue-adversarial-store --no-source-sync — emitted one Chrome and one Firefox v0.2.0 archive; manifest checks verified version-matched names, a 40-character source revision, SHA-256, and sizes. - nix develop --command devtools verify ci-workflows — verify ci-workflows: 17 workflow files checked, no errors. - nix shell nixpkgs#actionlint -c actionlint on the changed workflows — exit 0. - Pre-push devtools verify --quick — exit 0 after each commit. The focused extension build suite has one reproducible unrelated failure: its pre-existing packaged-service-worker fixture expects two page requests and receives one. It does not cover any changed workflow/docs/package-metadata path; its archive-emission tests pass. No tests were added. The release verifier exercises the production Hatch build configuration and installed console entrypoints; removing a runtime dependency or entrypoint would fail the isolated-wheel smoke. The pipx smoke exercises the documented installer rather than a test wrapper. The Homebrew smoke executes the formula test shipped to users. The extension build uses the production archive builder, and the submission-manifest validation would fail if a required archive or its integrity metadata were removed.
Summary
Nix-packaged Polylogue runtimes (
polylogue/polylogued/polylogue-mcp) now embed the full 40-character git commit instead of a 7-character short revision, and the daemon'spolylogue_daemon_build_infoPrometheus metric now correctly exposes that full revision (it previously always reportedversion="unknown"due to a broken import).Problem
flake.nixwroteBUILD_COMMITfromself.shortRev(7 hex chars), so every packaged runtime —polylogue --version,polylogued --version,ArchiveIdentity.build_commit(daemon status JSON), and the daemon build-info metric — could only ever report a truncated, collision-prone prefix. The Nix build/flake.lock retain the full revision, but nothing embedded it into the artifact, so a running artifact couldn't independently attest its exact source identity against a consuming flake'sflake.lockrev/narHashduring schema-sensitive rollouts.Separately,
polylogue_daemon_build_infoalways reportedversion="unknown"because it imported the nonexistentpolylogue.__version__(no such attribute on the package) inside a baretry/except.Verified before fixing: building the package at HEAD (
d81942345…) embeddedBUILD_COMMIT = "d819423"(shortRev) into_build_info.py.Solution
flake.nix: derivebuildRevisionfromself.rev(falling back toself.dirtyRevwith the literal"-dirty"suffix stripped, then"unknown"), andbuildDirtyfromself ? dirtyRev; embed both intopolylogue/_build_info.py. Added achecks.build-infoderivation that builds the package and asserts the installed_build_info.py'sBUILD_COMMIT/BUILD_DIRTYliterally matchself.rev/self.dirtyRev, and thatpolylogue --versionsurfaces the matching short prefix — a package-level proof the reported revision matches the flake input.polylogue/daemon/metrics.py: fixedpolylogue_daemon_build_infoto sourceversion/revision/dirtyfrompolylogue.version.VERSION_INFO(the real API) instead of the broken__version__import, and addedrevision(full commit) anddirtylabels alongside the existing conciseversionlabel.docs/daemon.md: new "Build Identity & Deployment Attestation" section documenting the concise-version vs. full-revision fields and how to join a running daemon's revision against a consuming flake'sflake.lockrev/narHash.tests/unit/daemon/test_metrics_endpoint.py: replaced the substring-order-dependent version-label assertion (labels are emitted alphabetically sorted, so{version=no longer prefixes the label set oncedirty/revisionare added) with an order-independent check, plus a new test pinning therevision/dirtylabels and the full 40-char length.polylogue/version.pyand thestorage/archive_identity.py/insights/export_bundles.pyread paths already exposedVERSION_INFO.commitas a full, untruncated field for source checkouts and PyPI/hatch builds (git rev-parse HEADis already full there) — only the Nix packaging path and the metrics label were truncated/broken. No schema change.Acceptance criteria
buildRevision/buildDirtyinflake.nix).VERSION_INFO.commit/archive_storage.identity.build_commit(daemon status JSON) /polylogue_daemon_build_info{revision=...}(Prometheus) are full;polylogue --version/POLYLOGUE_VERSIONremain the concise 8-char-prefix human form.BUILD_DIRTY/VERSION_INFO.dirty/dirty="true|false"label, derived fromself ? dirtyRevin Nix.checks.x86_64-linux.build-infoinflake.nix.docs/daemon.mdsection.Verification
nix flake check --no-build: all checks pass.nix build .#checks.x86_64-linux.build-info --no-link --print-out-paths: passes; inspected the built store path directly —_build_info.pynow containsBUILD_COMMIT = "d819423459dc1fdf3c2a249a5182d8d3970df3dd"(full 40 hex) andBUILD_DIRTY = True(dirty worktree at build time), vs. the priorBUILD_COMMIT = "d819423"on the same build.devtools test tests/unit/daemon/test_metrics_endpoint.py tests/unit/core/test_version.py: 59 passed.mypy --strict polylogue/daemon/metrics.py: no issues.devtools verify --quick(format + lint + mypy +render all --check): exit 0.devtools test/devtools verify --allsuite (per operator lean-verification directive for this session — the coordinator runs consolidated verification before merging).Note: per the task instructions, GitHub CI is currently blocked by an account billing lock unrelated to this diff.
Ref polylogue-6rvt
🤖 Generated with Claude Code