Skip to content

fix(ci): hash crates/engine/data and build.rs in engine-source-hash.sh#5461

Merged
matthewevans merged 2 commits into
phase-rs:mainfrom
davion-knight:fix/engine-source-hash-data-buildrs
Jul 9, 2026
Merged

fix(ci): hash crates/engine/data and build.rs in engine-source-hash.sh#5461
matthewevans merged 2 commits into
phase-rs:mainfrom
davion-knight:fix/engine-source-hash-data-buildrs

Conversation

@davion-knight

Copy link
Copy Markdown
Contributor

Fixes #5457.

Problem

scripts/engine-source-hash.sh is the single authority for the parse-diff baseline key (computed on both the publish and fetch sides of the coverage-parse-diff flow). It hashed only crates/engine/src, crates/engine/Cargo.toml, and Cargo.lock — omitting crates/engine/data/** and crates/engine/build.rs, both of which are compiled into the engine and change oracle-gen's parse output:

  • crates/engine/data/oracle-subtypes.json is include_str!d into the parser (parser/oracle_util.rs).
  • crates/engine/data/known-tokens.toml is embedded via build.rsOUT_DIR.

Consequence: a PR touching only known-tokens.toml (or build.rs) yields an unchanged engine-source hash, so the "Parse-detail diff vs base baseline" CI step fetches parse-baselines/coverage-data-<hash>.json built from a different parser state that happens to share the hash, and under-reports the PR's parse changes. Same failure family as the ci.yml cache-key gap already fixed — different file.

Fix

Add crates/engine/data and crates/engine/build.rs to the git ls-tree path set, and update the header comment. This mirrors ci.yml's cardgen- cache key, which was already widened to hash crates/engine/data/** and crates/engine/build.rs (ci.yml lines 215/243).

Per the issue, changing the hash function orphans existing coverage-data-<hash>.json objects for one main-push cycle (PRs see "Baseline pending" until main republishes) — benign and self-healing, same as any parser-state change.

Verification (local)

  • The script still emits a 16-hex digest.
  • git ls-tree -r HEAD -- crates/engine/data crates/engine/build.rs now contributes the three engine-compiled blobs (build.rs, known-tokens.toml, oracle-subtypes.json).
  • The new digest differs from the old src + Cargo.toml + Cargo.lock-only formula, confirming those inputs now actually participate — so a known-tokens.toml/build.rs-only PR will now invalidate the baseline key.
  • Only callers are ci.yml (which invoke the script and consume its output); no test hardcodes the old path set or digest.

`scripts/engine-source-hash.sh` — the single authority for the parse-diff
baseline key — hashed only crates/engine/src, Cargo.toml, and Cargo.lock,
omitting crates/engine/data/** and crates/engine/build.rs. Both are compiled
into the engine and change oracle-gen's parse output: oracle-subtypes.json is
`include_str!`d at parser/oracle_util.rs, and known-tokens.toml is embedded via
build.rs → OUT_DIR. So a PR touching only known-tokens.toml (or build.rs)
produced an unchanged hash, and the "Parse-detail diff vs base baseline" step
fetched a baseline built from a different parser state that happened to share
the hash — under-reporting the PR's parse changes.

Add both paths to the `git ls-tree` set so the fingerprint covers every input
that determines parse output, matching ci.yml's cardgen-cache key (widened to
include the same paths). Header comment updated to match.

Verified: the script still emits a 16-hex digest, the two paths now contribute
blobs (build.rs, known-tokens.toml, oracle-subtypes.json), and the digest
differs from the old src+manifest+lock-only formula.

Fixes phase-rs#5457.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the engine source hash script (scripts/engine-source-hash.sh) to include the engine data directory and build script in the fingerprint calculation. The review feedback points out a medium-severity issue where running the script from a subdirectory would fail to resolve paths correctly, and suggests adding the --full-tree flag to git ls-tree to resolve this.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread scripts/engine-source-hash.sh Outdated
@@ -37,6 +40,8 @@ sha="$1"
# Truncated to 16 hex chars to match the card_data_hash convention (ci.yml).
git ls-tree -r "$sha" -- \

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.

medium

[MEDIUM] Use --full-tree to ensure pathspecs are resolved relative to the repository root.

Why it matters: Without --full-tree, running this script from any subdirectory (e.g., scripts/) causes git ls-tree to resolve the paths relative to that subdirectory, resulting in no matches and silently producing the hash of an empty input.

Suggested fix: Add --full-tree to the git ls-tree command.

Suggested change
git ls-tree -r "$sha" -- \
git ls-tree --full-tree -r "$sha" -- \

@matthewevans matthewevans self-assigned this Jul 9, 2026
@matthewevans

Copy link
Copy Markdown
Member

Reviewed the current head and addressed the reviewer finding: git ls-tree now uses --full-tree, so the hash is stable when this helper is invoked from a subdirectory as well as the repository root. Local verification produced the same digest and 652 matching entries from both working directories. The change is scoped to the CI hash helper and is ready for the merge queue.

@matthewevans matthewevans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the current head and addressed the reviewer finding: git ls-tree now uses --full-tree, so the hash is stable when this helper is invoked from a subdirectory as well as the repository root. Local verification produced the same digest and 652 matching entries from both working directories. The change is scoped to the CI hash helper and is ready for the merge queue.

@matthewevans matthewevans added the bug Bug fix label Jul 9, 2026
@matthewevans
matthewevans enabled auto-merge July 9, 2026 21:43
@matthewevans matthewevans removed their assignment Jul 9, 2026
@matthewevans
matthewevans added this pull request to the merge queue Jul 9, 2026
Merged via the queue into phase-rs:main with commit 1cc1817 Jul 9, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

engine-source-hash.sh omits crates/engine/data/** and build.rs: parse-diff baselines can mismatch parser state

2 participants