Repository navigation
build: harden native downloads and development safeguards - #26577
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed on exact head dff270bc1872ba606496e6548ddf433c1d51bed5. The native-stage split, build-flag unification, HTTPS/checksum/timeout bounds, failure atomicity, and concurrent same-digest publication look sound.
Blocking finding: thirdparties/download silently succeeds when DESTINATION is an existing directory. mv -f "$tmp" "$destination" moves the verified temp file inside that directory under its random name, and the script prints success. Real HTTPS/curl reproduction: status=0 published_file=no destination_is_directory=yes moved_path=.../result/result.download.4xSZY9. The workflow oracle at .github/workflows/native-dependency-check.yml:90 uses test -r, which also passes for a readable directory. Thus producer and verifier can both be green while the declared ONNX file is absent and the final image misses the expected runtime library.
Please reject a directory destination before I/O (including symlinks to directories), add the counterexample to download_test, and require readable regular files (test -f && test -r) in the image check.
GitHub does not allow a formal REQUEST_CHANGES review on one’s own PR, so this COMMENT review should be treated as blocking.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed on exact head 4bd6eb79d94ec5ed9bc74edbdb672debf20b405d.
Two blocking findings remain:
-
thirdparties/download:48requires curl before the verified-cache fast path at line 117. A valid cached dependency therefore fails even though no transfer is needed. Reproduction with an exact valid cache andMO_DOWNLOAD_CURL_BIN=<missing path>:status=2,curl command not found, cache unchanged. This is a compatibility/resilience regression from the previous Make file target, which reused an existing artifact without invoking curl; it also defeats the intended cache fast path on offline/minimal builders. Please move only the curl capability check after successful cache verification and add a cache-hit-without-curl regression. -
.agents/skills/mo-dev/references/cgo-build-test.md:242installstrap cleanup_baseline EXIT INT HUP TERM, butcleanup_baselinedoes not exit or re-raise the signal. In Bash, all three signal counterexamples printhandler:<sig>followed bycontinued:<sig>; a cancelled baseline run therefore continues, records an exit/log, and can feed invalid attribution evidence. Keep cleanup onEXIT, and make INT/HUP/TERM handlers exit with their signal-derived status so the EXIT trap performs cleanup exactly once. Add or document the minimal signal oracle.
Other reviewed closure is sound: directory and symlink-directory destinations are now rejected; temp ownership, atomic same-digest publication, finite retries/timeouts, streaming byte bound, checksum/permissions, supported-platform mapping, native-stage split, and prebuilt Go build-flag parity all close correctly.
Fresh validation on this head:
sh -n thirdparties/download thirdparties/download_test- complete
make -C thirdparties test-download - supported linux/darwin amd64/arm64 Make mappings plus unsupported fail-closed
docker buildx build --check --platform linux/amd64,linux/arm64- prebuilt dry-run preserves
GO,GOAMD64,GOEXPERIMENT, typecheck tags, race, linker, and custom build options git diff --check
GitHub does not permit REQUEST_CHANGES on an author own PR, so this COMMENT review is intentionally blocking.
|
Adopted both blocking findings in
Fresh validation after the final edit:
The change stays at the existing ownership boundaries: no new cache/retry abstraction and no transfer-path cost; cache hits now avoid an unnecessary command lookup. |
ck89119
left a comment
There was a problem hiding this comment.
Deep review completed on exact head acbbace39f7c68ccf8ada06c04180cf32d3d46d4 against base 6b3ad84c9d01d453c2bcdd0f440637350e3aa8c6.
No blocking code findings remain. I independently rechecked the previously reported directory-destination, cache-hit-without-curl, and signal-termination defects; the latest head closes all three with matching regressions and correct ownership/exit semantics.
The broader audit covered downloader validation and failure atomicity, native/legacy curl retry bounds, byte/checksum/mode enforcement, concurrent publication, supported and rejected platform mappings, Docker native-stage artifact flow, non-root output verification, prebuilt mo-service build-flag parity, workflow permissions/cache partitioning, and the executable safety contracts in all changed development skills. No additional independent issues were found.
Fresh local evidence on this head:
sh -n thirdparties/download thirdparties/download_testpassed.- Complete
make -C thirdparties test-downloadpassed. - Linux amd64/arm64 and Darwin arm64 mappings expand correctly; unsupported tuples fail closed.
- Prebuilt build dry-run preserves the shared compiler/tag/linker/custom-option contract.
- Relative skill links and
git diff --checkpassed.
The local Docker driver cannot perform a multi-platform --check, so I did not treat that local command as evidence. The exact-head GitHub workflow independently passed Dockerfile validation plus real native builds on both amd64 and arm64, and all current CI checks are green.
Readiness note: the PR is currently behind main; refresh the exact head and rerun affected checks after any update before merging.
…in#26577) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [x] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#25267 ## What this PR does / why we need it: The image build fetched a pinned 21.9 MiB ONNX Runtime artifact directly from GitHub after `COPY . .`. A transient TLS EOF therefore failed the entire build, while source-only changes repeatedly invalidated the expensive native layer. This PR closes the failure and cache invalidation paths without adding another image lifecycle. ### Native dependency download and build - Adds one HTTPS-only downloader with finite attempts, connect/transfer timeouts, a hard streaming byte bound, exact post-download byte-count enforcement and SHA-256 verification, same-directory temporary files, atomic publication, and deterministic `0644` permissions for non-root consumers. - Rejects directory destinations, including symlinks to directories, before invoking curl. Verifies an existing file before reuse and leaves it intact on every failed transfer or verification path. - Uses curl native retry behavior, including `Retry-After`, when `--retry-all-errors` is supported. Capability detection keeps Ubuntu 20.04 curl 7.68 working through a bounded POSIX fallback; checksum mismatches remain fail-closed and are not retried as transport failures. - Fails closed for unsupported OS/architecture tuples and maps Linux amd64/arm64 plus macOS arm64 explicitly. - Builds third-party/CGo outputs in a source-independent Docker `native` stage. `GOPROXY` is scoped to the Go builder so proxy changes do not invalidate the native cache. - Keeps normal and prebuilt-native `mo-service` targets on one compiler/feature contract, preserving `GO`, `GOAMD64`, `GOEXPERIMENT`, tags, race, linker, and custom build options. ### CI coverage - Runs portable downloader tests on Linux and macOS. - Lints the Dockerfile for linux/amd64 and linux/arm64. - Actually builds the native stage on native amd64 and arm64 GitHub runners, with per-architecture GHA BuildKit caches. - Verifies ONNX Runtime, `libmo.so`, and `libmo.a` are readable from a non-root container. - Pins third-party GitHub Actions to full commit SHAs. ### Development skills included in this PR - Adds counterexample-driven public/internal witness guidance for planner, EXPLAIN, and rewrite regressions without sleep, retry, snapshot-only, or coverage-weakening shortcuts. - Makes `mo-dev` first-principles, proportional, performance-aware, and artifact-specific: small defects do not justify new frameworks, hot-path cost needs evidence, and non-Go changes no longer require unrelated Go tests. - Corrects typed terminal cleanup and current distributed receiver-registration/wait ownership; release branches must be inspected rather than assumed to match `main`. - Makes CGo baseline attribution preserve causal evidence in an isolated worktree, and makes index review cover committed, staged, unstaged, and untracked changes from a verified base/head range. - Hardens self-review, unhappy-path ownership analysis, and bug-triage metadata updates, including drift-safe per-label WAL operations and comment-before-deferral ordering. ### Design decisions - No separate ONNX base image: the cacheable native stage gives warm-build reuse without a second release, multi-platform tag, security refresh, and version-skew lifecycle. - No ad-hoc cross-compilation: CI uses native architecture runners for C/C++ outputs. - Existing base-image tag policy is unchanged; the ONNX artifact itself is pinned to an immutable commit and SHA-256. Digest pinning without automated refresh would freeze base-image security updates rather than improve this change. Validation performed on the committed head: - `sh -n thirdparties/download thirdparties/download_test` - `make -C thirdparties test-download` on macOS and in `matrixorigin/golang:1.26.4-ubuntu22.04` with curl 7.81 - Real HTTPS/SHA/permission download with `curlimages/curl:7.68.0` - Real 21.9 MiB ONNX Runtime download with curl 7.81, exact SHA-256, size, mode `0644`, and non-root readability - Supported/unsupported Make platform mapping dry-runs - `docker buildx build --check --platform linux/amd64,linux/arm64` - `actionlint v1.7.12` on the new workflow - Skill validation for `mo-bug-triage`, `mo-dev`, `mo-self-review`, and `unhappy-path-audit`; relative-link and `git diff --check` validation - Read-only triage candidate freeze command produced unique issue IDs and excluded pull requests No whole-repository test suite was run because this PR changes build/shell/workflow and skill artifacts, not Go production packages; validation is scoped to their actual contracts.
…in#26577) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [x] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#25267 ## What this PR does / why we need it: The image build fetched a pinned 21.9 MiB ONNX Runtime artifact directly from GitHub after `COPY . .`. A transient TLS EOF therefore failed the entire build, while source-only changes repeatedly invalidated the expensive native layer. This PR closes the failure and cache invalidation paths without adding another image lifecycle. ### Native dependency download and build - Adds one HTTPS-only downloader with finite attempts, connect/transfer timeouts, a hard streaming byte bound, exact post-download byte-count enforcement and SHA-256 verification, same-directory temporary files, atomic publication, and deterministic `0644` permissions for non-root consumers. - Rejects directory destinations, including symlinks to directories, before invoking curl. Verifies an existing file before reuse and leaves it intact on every failed transfer or verification path. - Uses curl native retry behavior, including `Retry-After`, when `--retry-all-errors` is supported. Capability detection keeps Ubuntu 20.04 curl 7.68 working through a bounded POSIX fallback; checksum mismatches remain fail-closed and are not retried as transport failures. - Fails closed for unsupported OS/architecture tuples and maps Linux amd64/arm64 plus macOS arm64 explicitly. - Builds third-party/CGo outputs in a source-independent Docker `native` stage. `GOPROXY` is scoped to the Go builder so proxy changes do not invalidate the native cache. - Keeps normal and prebuilt-native `mo-service` targets on one compiler/feature contract, preserving `GO`, `GOAMD64`, `GOEXPERIMENT`, tags, race, linker, and custom build options. ### CI coverage - Runs portable downloader tests on Linux and macOS. - Lints the Dockerfile for linux/amd64 and linux/arm64. - Actually builds the native stage on native amd64 and arm64 GitHub runners, with per-architecture GHA BuildKit caches. - Verifies ONNX Runtime, `libmo.so`, and `libmo.a` are readable from a non-root container. - Pins third-party GitHub Actions to full commit SHAs. ### Development skills included in this PR - Adds counterexample-driven public/internal witness guidance for planner, EXPLAIN, and rewrite regressions without sleep, retry, snapshot-only, or coverage-weakening shortcuts. - Makes `mo-dev` first-principles, proportional, performance-aware, and artifact-specific: small defects do not justify new frameworks, hot-path cost needs evidence, and non-Go changes no longer require unrelated Go tests. - Corrects typed terminal cleanup and current distributed receiver-registration/wait ownership; release branches must be inspected rather than assumed to match `main`. - Makes CGo baseline attribution preserve causal evidence in an isolated worktree, and makes index review cover committed, staged, unstaged, and untracked changes from a verified base/head range. - Hardens self-review, unhappy-path ownership analysis, and bug-triage metadata updates, including drift-safe per-label WAL operations and comment-before-deferral ordering. ### Design decisions - No separate ONNX base image: the cacheable native stage gives warm-build reuse without a second release, multi-platform tag, security refresh, and version-skew lifecycle. - No ad-hoc cross-compilation: CI uses native architecture runners for C/C++ outputs. - Existing base-image tag policy is unchanged; the ONNX artifact itself is pinned to an immutable commit and SHA-256. Digest pinning without automated refresh would freeze base-image security updates rather than improve this change. Validation performed on the committed head: - `sh -n thirdparties/download thirdparties/download_test` - `make -C thirdparties test-download` on macOS and in `matrixorigin/golang:1.26.4-ubuntu22.04` with curl 7.81 - Real HTTPS/SHA/permission download with `curlimages/curl:7.68.0` - Real 21.9 MiB ONNX Runtime download with curl 7.81, exact SHA-256, size, mode `0644`, and non-root readability - Supported/unsupported Make platform mapping dry-runs - `docker buildx build --check --platform linux/amd64,linux/arm64` - `actionlint v1.7.12` on the new workflow - Skill validation for `mo-bug-triage`, `mo-dev`, `mo-self-review`, and `unhappy-path-audit`; relative-link and `git diff --check` validation - Read-only triage candidate freeze command produced unique issue IDs and excluded pull requests No whole-repository test suite was run because this PR changes build/shell/workflow and skill artifacts, not Go production packages; validation is scoped to their actual contracts.
…in#26577) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [x] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#25267 ## What this PR does / why we need it: The image build fetched a pinned 21.9 MiB ONNX Runtime artifact directly from GitHub after `COPY . .`. A transient TLS EOF therefore failed the entire build, while source-only changes repeatedly invalidated the expensive native layer. This PR closes the failure and cache invalidation paths without adding another image lifecycle. ### Native dependency download and build - Adds one HTTPS-only downloader with finite attempts, connect/transfer timeouts, a hard streaming byte bound, exact post-download byte-count enforcement and SHA-256 verification, same-directory temporary files, atomic publication, and deterministic `0644` permissions for non-root consumers. - Rejects directory destinations, including symlinks to directories, before invoking curl. Verifies an existing file before reuse and leaves it intact on every failed transfer or verification path. - Uses curl native retry behavior, including `Retry-After`, when `--retry-all-errors` is supported. Capability detection keeps Ubuntu 20.04 curl 7.68 working through a bounded POSIX fallback; checksum mismatches remain fail-closed and are not retried as transport failures. - Fails closed for unsupported OS/architecture tuples and maps Linux amd64/arm64 plus macOS arm64 explicitly. - Builds third-party/CGo outputs in a source-independent Docker `native` stage. `GOPROXY` is scoped to the Go builder so proxy changes do not invalidate the native cache. - Keeps normal and prebuilt-native `mo-service` targets on one compiler/feature contract, preserving `GO`, `GOAMD64`, `GOEXPERIMENT`, tags, race, linker, and custom build options. ### CI coverage - Runs portable downloader tests on Linux and macOS. - Lints the Dockerfile for linux/amd64 and linux/arm64. - Actually builds the native stage on native amd64 and arm64 GitHub runners, with per-architecture GHA BuildKit caches. - Verifies ONNX Runtime, `libmo.so`, and `libmo.a` are readable from a non-root container. - Pins third-party GitHub Actions to full commit SHAs. ### Development skills included in this PR - Adds counterexample-driven public/internal witness guidance for planner, EXPLAIN, and rewrite regressions without sleep, retry, snapshot-only, or coverage-weakening shortcuts. - Makes `mo-dev` first-principles, proportional, performance-aware, and artifact-specific: small defects do not justify new frameworks, hot-path cost needs evidence, and non-Go changes no longer require unrelated Go tests. - Corrects typed terminal cleanup and current distributed receiver-registration/wait ownership; release branches must be inspected rather than assumed to match `main`. - Makes CGo baseline attribution preserve causal evidence in an isolated worktree, and makes index review cover committed, staged, unstaged, and untracked changes from a verified base/head range. - Hardens self-review, unhappy-path ownership analysis, and bug-triage metadata updates, including drift-safe per-label WAL operations and comment-before-deferral ordering. ### Design decisions - No separate ONNX base image: the cacheable native stage gives warm-build reuse without a second release, multi-platform tag, security refresh, and version-skew lifecycle. - No ad-hoc cross-compilation: CI uses native architecture runners for C/C++ outputs. - Existing base-image tag policy is unchanged; the ONNX artifact itself is pinned to an immutable commit and SHA-256. Digest pinning without automated refresh would freeze base-image security updates rather than improve this change. Validation performed on the committed head: - `sh -n thirdparties/download thirdparties/download_test` - `make -C thirdparties test-download` on macOS and in `matrixorigin/golang:1.26.4-ubuntu22.04` with curl 7.81 - Real HTTPS/SHA/permission download with `curlimages/curl:7.68.0` - Real 21.9 MiB ONNX Runtime download with curl 7.81, exact SHA-256, size, mode `0644`, and non-root readability - Supported/unsupported Make platform mapping dry-runs - `docker buildx build --check --platform linux/amd64,linux/arm64` - `actionlint v1.7.12` on the new workflow - Skill validation for `mo-bug-triage`, `mo-dev`, `mo-self-review`, and `unhappy-path-audit`; relative-link and `git diff --check` validation - Read-only triage candidate freeze command produced unique issue IDs and excluded pull requests No whole-repository test suite was run because this PR changes build/shell/workflow and skill artifacts, not Go production packages; validation is scoped to their actual contracts.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #25267
What this PR does / why we need it:
The image build fetched a pinned 21.9 MiB ONNX Runtime artifact directly from GitHub after
COPY . .. A transient TLS EOF therefore failed the entire build, while source-only changes repeatedly invalidated the expensive native layer.This PR closes the failure and cache invalidation paths without adding another image lifecycle.
Native dependency download and build
0644permissions for non-root consumers.Retry-After, when--retry-all-errorsis supported. Capability detection keeps Ubuntu 20.04 curl 7.68 working through a bounded POSIX fallback; checksum mismatches remain fail-closed and are not retried as transport failures.nativestage.GOPROXYis scoped to the Go builder so proxy changes do not invalidate the native cache.mo-servicetargets on one compiler/feature contract, preservingGO,GOAMD64,GOEXPERIMENT, tags, race, linker, and custom build options.CI coverage
libmo.so, andlibmo.aare readable from a non-root container.Development skills included in this PR
mo-devfirst-principles, proportional, performance-aware, and artifact-specific: small defects do not justify new frameworks, hot-path cost needs evidence, and non-Go changes no longer require unrelated Go tests.main.Design decisions
Validation performed on the committed head:
sh -n thirdparties/download thirdparties/download_testmake -C thirdparties test-downloadon macOS and inmatrixorigin/golang:1.26.4-ubuntu22.04with curl 7.81curlimages/curl:7.68.00644, and non-root readabilitydocker buildx build --check --platform linux/amd64,linux/arm64actionlint v1.7.12on the new workflowmo-bug-triage,mo-dev,mo-self-review, andunhappy-path-audit; relative-link andgit diff --checkvalidationNo whole-repository test suite was run because this PR changes build/shell/workflow and skill artifacts, not Go production packages; validation is scoped to their actual contracts.