Skip to content

install_release.sh installs binaries that misreport their own commit, breaking the AGENTS.md verification step #799

Closed

Description

@MatrixMagician

Problem

scripts/install_release.sh computes the git hash after cargo build, and uses it only to name the install directory:

https://github.com/1jehuang/jcode/blob/master/scripts/install_release.sh#L38-L58

Nothing passes that hash into the build. crates/jcode-build-meta/build.rs deliberately does not declare .git/HEAD as a rerun-if-changed input, and that decision is correct and well-documented (watching it turns routine git activity into a full-tree recompile). The consequence is that an incremental build reuses whatever hash was baked in last time.

So the script installs a binary containing new code into versions/<new-hash>/ while that binary reports the old hash from --version.

Observed while upgrading v0.67.1 → v0.68.0:

$ readlink -f ~/.jcode/builds/current/jcode
/home/user/.jcode/builds/versions/8bda2ebc9/jcode     # named for the new commit

$ ~/.jcode/builds/current/jcode --version
jcode v0.68.0-dev (fcf53909f)                          # reports the PREVIOUS commit

The binary genuinely contained the new code (confirmed with strings), but nothing about its self-reported identity said so.

This matters more than a cosmetic version string, because it breaks the one verification step AGENTS.md prescribes:

cargo build alone proves nothing about behavior. ... Confirm which binary you are actually inspecting.

Checking jcode --version after a self-dev install is precisely the recommended check, and it silently reports the wrong thing. "Is my change actually in this binary?" becomes unanswerable without resorting to strings on the artifact. For an agent doing self-dev work this is an actively misleading feedback loop: it can conclude an install failed when it succeeded, and rebuild in circles.

The build.rs comment anticipates the cosmetic case:

For ordinary dev builds the embedded git hash/dirty flag may lag the very latest commit within a session; that is a cosmetic --version detail and an acceptable trade for keeping incremental builds incremental.

That trade is right for ordinary dev builds. It is not right for the install path, which is exactly where identity gets consumed. Note the in-app updater (update.rs::build_from_source) already sets JCODE_RELEASE_BUILD=1 for its build; only the manual install script omits the metadata vars.

Expected behavior

  • A binary installed at versions/<hash>/ reports <hash> from --version.
  • Verifying an upgrade via jcode --version measures the binary that was just built.

Fix

  1. Resolve the git identity before cargo build and pass it via JCODE_BUILD_GIT_HASH / JCODE_BUILD_GIT_DATE / JCODE_BUILD_GIT_DIRTY. These are already declared rerun-if-env-changed in build.rs, so this forces exactly the metadata refresh needed without reintroducing the full-tree rebuild that watching .git/HEAD caused.
  2. After building, assert the binary's --version contains the expected commit, and refuse to install if not. A binary that misreports its own identity should fail loudly rather than get installed.

Deliberately not setting JCODE_RELEASE_BUILD: that would relabel a local source install as a release build and drop the -dev suffix, which is a different claim than "installed from a local source tree".

Affected file:

  • scripts/install_release.sh

Verified locally: --version now tracks HEAD exactly across successive installs, including the -dirty case. Happy to open a PR.

Activity

  1. MatrixMagician commented on Aug 5, 2026

    @MatrixMagician
    Author

    The installer fix is on the same branch as #798, since both bugs surfaced from one upgrade:

    https://github.com/MatrixMagician/jcode/tree/fix/sidecar-haiku-model-id

    Compare view against upstream master:
    master...MatrixMagician:jcode:fix/sidecar-haiku-model-id

    scripts/install_release.sh (+49/-12), rebased onto current master. See the comment on #798 for why I could not open the PR directly.

    Verified by observing --version move from a stale hash to exactly HEAD across successive installs, including the -dirty case. Before the fix, the binary installed at versions/8bda2ebc9/ reported fcf53909f.

  2. added
    bug
    triage: reproducible
    autonomous: likely
    on Aug 6, 2026
  3. 1jehuang commented on Aug 9, 2026

    @1jehuang
    Owner

    Implemented an independent fix in PR #863. The installer now supplies current git metadata to the build and rejects a binary whose reported identity is stale. Bash syntax checks and a regression covering dirty builds and stale-metadata rejection pass.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  4. added a commit that references this issue on Aug 10, 2026
    3d663f0
  5. added a commit that references this issue on Aug 15, 2026
    a8e0afd
  6. added 5 commits that reference this issue on Aug 30, 2026
    35a415b
    bc33928
    254c266
    6309bcc
    8abbf1b
  7. added a commit that references this issue on Sep 18, 2026
    ab2b2f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: likelybugtriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions