Skip to content

fix(build): ignore thirdparties scratch trees in native provenance checks (#30235) - #30592

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
daviszhen:fix-30235-native-provenance
Oct 19, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
daviszhen:fix-30235-native-provenance

Conversation

@daviszhen

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #30235

What this PR does / why we need it:

A clean checkout could not complete its first native build: native libraries compiled successfully, then the provenance record step failed with native inputs changed while the build was running (Makefile:367).

Root cause: cgo/mo-native-provenance classifies native inputs with git status --porcelain --untracked-files=all -- Makefile cgo thirdparties at prepare/begin/record/verify time. The thirdparties Makefile extracts and compiles inside scratch trees (_croaring_build, _fp16, _jemalloc_build, _simsimd, _stringzilla, _usearch_build, _xxhash_build) that are recreated from the tracked tarballs on demand — their contents are build outputs, never inputs. The historical versioned extraction trees (SimSIMD-*, StringZilla-*, fp16, usearch-*, install) were added to .gitignore in #21476 for exactly this reason, but the Makefile later switched to underscore scratch names and .gitignore was never updated. Any scratch tree left behind — by an in-flight build at record time, an interrupted make, or an exited recipe — therefore misjudged the build as having user-edited inputs, failing a genuinely clean first build.

Fix, mirroring the established pattern: ignore the seven scratch trees. Genuine input changes must still be detected, and they are: a modified tracked file or any non-scratch untracked file under Makefile/cgo/thirdparties still makes the same git status non-empty (verified locally), demoting the build to local-only (reusable=no).

Tests:

  • New regression test TestNativeBuildScratchDirsStayIgnored (optools, runs under go test ./optools/): runs git check-ignore over each of the seven scratch directories so a future Makefile scratch-tree rename cannot silently reintroduce the failure. Verified it fails when a rule is removed and passes with the fix.
  • Full go test ./optools/ suite passes.
  • End-to-end protocol check on this branch: with all seven scratch trees populated (simulating leftovers), git status --porcelain --untracked-files=all -- Makefile cgo thirdparties is empty and ./cgo/mo-native-provenance prepare classifies the build as rebuild-all + reusable=yes; with a genuine untracked thirdparties/scratch-note.txt added, the status lists it and prepare returns reusable=no — real input changes are still detected.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

…ecks (matrixorigin#30235)

A clean checkout could not complete its first native build: native
libraries compiled successfully, then the provenance record step failed
with "native inputs changed while the build was running".

cgo/mo-native-provenance classifies native *inputs* with
`git status --porcelain --untracked-files=all -- Makefile cgo
thirdparties` at prepare/begin/record/verify time. The thirdparties
Makefile extracts and compiles inside scratch trees
(_croaring_build, _fp16, _jemalloc_build, _simsimd, _stringzilla,
_usearch_build, _xxhash_build) that are recreated from the tracked
tarballs on demand, so their contents are never inputs. Unlike the
historical versioned extraction trees (SimSIMD-*, StringZilla-*, ...),
these underscore names were never added to .gitignore, so a scratch tree
left behind by an in-flight, interrupted, or otherwise incomplete
cleanup misjudged the build as having user-edited inputs.

Ignore the seven scratch trees, mirroring the existing install/* and
versioned-tree rules, and pin the contract with a regression test that
runs git check-ignore over each scratch directory so a future Makefile
scratch-tree rename cannot silently reintroduce matrixorigin#30235.

Verified: with all seven scratch trees populated,
`git status --porcelain --untracked-files=all -- Makefile cgo
thirdparties` is empty and `mo-native-provenance prepare` classifies
the build as reusable=yes; a genuine untracked file or a tracked edit
under thirdparties/ still makes the same status non-empty and the build
local-only (reusable=no).
@daviszhen
daviszhen force-pushed the fix-30235-native-provenance branch from 8447e33 to 547dcb7 Compare October 19, 2026 10:49
@daviszhen

Copy link
Copy Markdown
Contributor Author

Previous head 8447e33e9d failed UT Test on Ubuntu/x86 on FAIL_UT_CASES=TestDiskCacheReadWaitsForFullFileUpdateWithinShortWait — a -race finding in pkg/fileservice, which this PR does not touch (git diff upstream/main = .gitignore + optools/native_provenance_gitignore_test.go only; pkg/fileservice diff is empty).

Read of the race report (run 39229510831, job 117983861528): it triggers only on that test's timeout path — after <-time.After(time.Second) fires and t.Fatal runs, the deferred readVector.Release() (disk_cache_test.go:618) races the still in-flight background cache.Read's IOEntry.prepareData write (io_entry.go:127). I.e. a latent upstream test-harness race that surfaces under heavy -race load, not a regression from this change.

Local evidence at this head: go test -race ./pkg/fileservice/ -run '^TestDiskCacheReadWaitsForFullFileUpdateWithinShortWait$' -count=30 → 30/30 PASS; go test ./optools/ -run TestNativeBuildScratchDirsStayIgnored → PASS.

Rebased onto d0e7f9a552 (no content change to the fix) and pushed as 547dcb7735 to re-run CI.

@XuPeng-SH

XuPeng-SH commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 547dcb77351810ae53b23aa95a067eac99a4d615

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · superseded

Commit: 547dcb77351810ae53b23aa95a067eac99a4d615

"interrupted"

@XuPeng-SH XuPeng-SH 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.

mo-bot review · mo-bot-local · review

Commit: 547dcb77351810ae53b23aa95a067eac99a4d615

Assessment: approve

Reviewed the complete two-file delta and its build/provenance callers. The seven ignore rules correctly classify generated scratch trees through the existing Git policy, preserving genuine-input and artifact-integrity checks without duplicating logic. No actionable defects or SQL runtime costs were identified.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Isolation preflight passed. TestNativeBuildScratchDirsStayIgnored executed through test-exec and passed; focused.jsonl matches receipt checks/1792411185698855350-3.json.

  • The actual provenance script reproduced the failure with base ignore rules, then passed prepare/begin/record/verify and reuse with the new rules. Tracked edits, unrelated files, lookalike directories and artifact corruption remained rejected. protocol.log and protocol-details.json match receipt checks/1792411236663607823-4.json.

  • Both check receipts identify the assigned HEAD with an empty source delta. Diagnostic native inputs were matched against 191 source files; source remained unchanged.

  • Supplied exact-head CI reports successful shared build, Ubuntu unit tests, arm64 checks and multi-CN BVTs. The previous-head fileservice race concern affects unchanged code.

  • Evidence associations, input fingerprints and artifact hashes are retained in /home/xupeng/.local/state/mo-bot/jobs/eb618b69d9ceb4ff30b5165f/attempt-1/review-audit.json.

Limitations:

  • The local provenance check used stub artifact bytes; it validates classification and lifecycle behavior, not native compilation.

  • Raw CI logs and the standalone linked issue body were not supplied. CI conclusions and the issue contract were assessed from the frozen evidence.

@mergify mergify Bot added the queued label Oct 19, 2026
@mergify

mergify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-19 12:03 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-10-19 17:41 UTC · at c33b29529c20694811427bbcee10d40ba8e96081 · squash

This pull request spent 5 hours 37 minutes 44 seconds in the queue, including 53 minutes 33 seconds running CI.

Required conditions to merge

This branch was previously deployed

1 inactive deployment
ci — e781a287 Deployed Oct 19, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants