Skip to content

Commit 0c3b7c9

Browse files
kurodo3[bot]claude
andcommitted
fix: assert key_reorder fixture invariant; add pull-requests: read to dependency-review
test_key_reorder_hashes_are_identical now explicitly asserts the fixture invariant (ipc_b64 and expected_hash are identical between the two vectors, because arrow-ipc normalises key order alphabetically before encoding) then hashes once as a live sanity check. Re-hashing both vectors would just hash the same bytes twice with no added signal beyond test_golden_vector. Also adds `pull-requests: read` to the dependency-review job's permissions block; actions/dependency-review-action requires it to fetch PR diff metadata and would fail at runtime with only `contents: read`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f4e9f22 commit 0c3b7c9

2 files changed

Lines changed: 24 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
dependency-review:
5151
runs-on: ubuntu-latest
5252
if: github.event_name == 'pull_request'
53+
permissions:
54+
contents: read
55+
pull-requests: read # required by actions/dependency-review-action to fetch PR diff
5356
steps:
5457
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5558

tests/test_golden_parity_metadata.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,30 @@ def test_empty_metadata_invariant_both_flags() -> None:
9898

9999

100100
def test_key_reorder_hashes_are_identical() -> None:
101-
"""key_reorder_canonical and key_reorder_shuffled must share the same expected_hash."""
101+
"""key_reorder_canonical and key_reorder_shuffled encode to identical IPC bytes.
102+
103+
arrow-ipc normalises metadata key order (alphabetical sort) before FlatBuffers
104+
encoding, so both vectors produce byte-identical blobs regardless of insertion
105+
order. This test asserts those fixture invariants explicitly, then hashes once
106+
as a live sanity check — re-hashing both would just hash the same bytes twice.
107+
"""
102108
canonical = _get_vector("key_reorder_canonical")
103109
shuffled = _get_vector("key_reorder_shuffled")
104110

105-
schema_c, _ = _deserialize_ipc(canonical["ipc_b64"])
106-
schema_s, _ = _deserialize_ipc(shuffled["ipc_b64"])
107-
108-
hash_c = ArrowDigester.hash_schema(schema_c, include_metadata=True).hex()
109-
hash_s = ArrowDigester.hash_schema(schema_s, include_metadata=True).hex()
110-
111-
assert hash_c == canonical["expected_hash"], (
112-
f"key_reorder_canonical live hash drifted from fixture"
111+
# Fixture invariants: arrow-ipc sorts keys before encoding, so both entries
112+
# must carry the same IPC blob and the same expected hash.
113+
assert canonical["ipc_b64"] == shuffled["ipc_b64"], (
114+
"key_reorder_canonical and key_reorder_shuffled must have identical ipc_b64 "
115+
"(arrow-ipc normalises metadata key order before FlatBuffers encoding)"
113116
)
114-
assert hash_s == shuffled["expected_hash"], (
115-
f"key_reorder_shuffled live hash drifted from fixture"
117+
assert canonical["expected_hash"] == shuffled["expected_hash"], (
118+
"key_reorder_canonical and key_reorder_shuffled must have identical expected_hash"
116119
)
117-
assert hash_c == hash_s, (
118-
"key_reorder_canonical and key_reorder_shuffled must have identical hashes\n"
119-
f" canonical: {hash_c}\n"
120-
f" shuffled: {hash_s}"
120+
121+
# Sanity check: live hash must match the (single) fixture value.
122+
schema, _ = _deserialize_ipc(canonical["ipc_b64"])
123+
live_hash = ArrowDigester.hash_schema(schema, include_metadata=True).hex()
124+
assert live_hash == canonical["expected_hash"], (
125+
f"key_reorder live hash drifted from fixture: "
126+
f"got {live_hash}, expected {canonical['expected_hash']}"
121127
)

0 commit comments

Comments
 (0)