Skip to content

common: stamp build time + commit, log build info in every build#556

Open
myleshorton wants to merge 1 commit into
mainfrom
fisk/build-stamp
Open

common: stamp build time + commit, log build info in every build#556
myleshorton wants to merge 1 commit into
mainfrom
fisk/build-stamp

Conversation

@myleshorton

@myleshorton myleshorton commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What

  • Add common.BuildTime + common.Commit vars (ldflags-injected, alongside Version).
  • Remove the if Dev() gate on build/dependency logging (added incidentally in Linux daemon and systemd service #301) so it runs in every build.
  • On startup, log a concise build banner (version, buildTime, commit, goVersion, mainModule) at Info, plus the linked versions of the load-bearing deps (keepcurrent, amp, domainfront, kindling, lantern-box, sing-box) at Info; the full dependency list stays at Debug (so no per-dep spam in prod).

Why

A 9.1.14 iOS TestFlight build shipped a pre-fix keepcurrent (54a4d9a, the send-on-closed-channel crash) even though go.mod declared the fixed f204338. Because logModuleInfo() was gated behind Dev(), beta/prod builds logged nothing about their actual linked deps — the stale build was invisible until a crash stack happened to reveal the version. debug.ReadBuildInfo() reflects what is really linked into the binary, so surfacing it makes stale-build regressions visible directly.

Pairs with getlantern/lantern's Makefile change that injects the new ldflags.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WGpKfgkbfdJwwsTaouMDoR

Summary by CodeRabbit

  • New Features
    • App startup now includes more detailed build metadata in logs, such as version, build time, commit, Go version, and main module info.
    • Important linked dependencies are highlighted more prominently in startup logs, while full dependency details remain available at a lower log level.

Add BuildTime and Commit vars (ldflags-injected alongside Version) and un-gate
build/dependency logging that was Dev()-only. A shipped binary now logs its
version, build time, commit, and the linked versions of the load-bearing deps
(keepcurrent, amp, domainfront, kindling, lantern-box, sing-box) at Info on
startup, with the full dependency list at Debug.

Motivation: a 9.1.14 iOS TestFlight build shipped a pre-fix keepcurrent
(send-on-closed-channel crash) even though go.mod declared the fixed version.
logModuleInfo() being gated behind Dev() meant beta/prod builds logged nothing
about their actual linked deps, so the stale build was invisible until a crash
stack happened to reveal the version. ReadBuildInfo reflects what is really in
the binary, making such stale-build regressions visible directly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGpKfgkbfdJwwsTaouMDoR
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 05e392e9-effc-4cd5-8aa4-68c734c1d8f5

📥 Commits

Reviewing files that changed from the base of the PR and between ce70c50 and 47efbcd.

📒 Files selected for processing (2)
  • common/constants.go
  • common/init.go

📝 Walkthrough

Walkthrough

Adds BuildTime and Commit package-level variables to common/constants.go for ldflags injection, and replaces the prior Dev-only logModuleInfo() in common/init.go with an always-on logBuildInfo() that logs build identity and filters dependency logging via a new loadBearingDeps allowlist.

Changes

Build Metadata Logging

Layer / File(s) Summary
Build metadata variables
common/constants.go
Adds exported BuildTime and Commit variables defaulting to "unknown", documented for ldflags injection at build time.
Init wiring and build info logging
common/init.go
Init now unconditionally calls new logBuildInfo(), which reads build info via debug.ReadBuildInfo(), logs version/build/commit/module details, and logs dependencies at Info level if listed in a new loadBearingDeps allowlist or Debug level otherwise; replaces the previous Dev-only logModuleInfo().

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Init
  participant logBuildInfo
  participant ReadBuildInfo as debug.ReadBuildInfo
  participant Logger

  Init->>logBuildInfo: call on startup
  logBuildInfo->>ReadBuildInfo: request build info
  ReadBuildInfo-->>logBuildInfo: return info or failure
  alt info available
    logBuildInfo->>Logger: log Version, BuildTime, Commit, GoVersion, Main
    loop each dependency
      logBuildInfo->>Logger: log at Info (load-bearing) or Debug (other)
    end
  else info unavailable
    logBuildInfo->>Logger: log "no build info" message
  end
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: added build metadata stamping and always-on build info logging.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fisk/build-stamp

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR makes Radiance binaries self-describing by adding ldflags-injected build identity fields and emitting build + dependency linkage information on startup in all builds (not just Dev), so mismatched/stale linked dependencies are visible directly in logs.

Changes:

  • Add common.BuildTime and common.Commit build-time variables (ldflags-injected alongside Version).
  • Replace the Dev-only debug.ReadBuildInfo() logging with logBuildInfo() that runs in every build.
  • Log a concise build banner at Info and log dependency versions (Info for selected “load-bearing” deps; Debug for full list).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
common/init.go Always logs build identity + linked module versions at startup (Info for selected deps, Debug for full list).
common/constants.go Adds ldflags-injected BuildTime and Commit variables to capture build identity.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread common/init.go
Comment on lines +136 to 140
if _, ok := loadBearingDeps[dep.Path]; ok {
slog.Info("build dep", "path", dep.Path, "version", dep.Version)
}
} else {
slog.Info("No build information available.")
slog.Debug("build dep", "path", dep.Path, "version", dep.Version)
}
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.

2 participants