Repository navigation
ci: publish - #13
ci: publish#13
Conversation
📝 WalkthroughWalkthroughAdded a CI Publish job that downloads build artifacts and conditionally publishes npm packages; introduced a darwin‑arm64 npm package and README; added lifecycle scripts and a root Changes
Sequence Diagram(s)sequenceDiagram
participant CI as CI (GitHub Actions)
participant Git as Git
participant Artifacts as Artifact Storage
participant Workspace as packages/core
participant NPM as npm Registry
CI->>Git: checkout (with submodules)
CI->>Artifacts: download artifact mlx-node
CI->>Artifacts: download artifact mlx-metallib
Artifacts->>Workspace: move artifacts into workspace paths
CI->>Workspace: ls -R packages/core
CI->>Git: git log -1 --pretty=%B
alt commit matches x.y.z
CI->>NPM: npm publish --access public
else commit matches x.y
CI->>NPM: npm publish --tag next --access public
else
CI-->>CI: echo "skipping publish"
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @.github/workflows/ci.yml:
- Around line 177-179: The workflow step using actions/setup-node@v6 is missing
required inputs for npm auth and consistent runtime; update the Setup Node.js
step to include node-version (e.g., "18" or your project's version) and the
registry-url input pointing to the npm registry (e.g.,
"https://registry.npmjs.org/") so that NODE_AUTH_TOKEN-based authentication
works; ensure the step also preserves auth-token usage by keeping the
NODE_AUTH_TOKEN secret in the job environment.
- Around line 192-203: The publish step lacks authentication and runs from the
repo root; update the "Publish package" job so npm publish uses the repository
secret NODE_AUTH_TOKEN (exported as NODE_AUTH_TOKEN or NODE_AUTH_TOKEN in the
step environment) and run npm publish from the package directory (e.g., cd
packages/core or use npm --prefix packages/core) so the package in packages/core
is published; ensure both branches (stable and next tag) set the auth env and
change working directory before invoking npm publish.
🧹 Nitpick comments (2)
packages/core/npm/darwin-arm64/package.json (1)
1-16: Consider adding alicensefield.The package manifest is missing a
licensefield, which is recommended for npm packages. This helps with license compliance tooling and npm registry display.📝 Suggested addition
{ "name": "@mlx-node/core-darwin-arm64", "version": "0.0.0", + "license": "MIT", "description": "Internal native bindings - import from `@mlx-node/lm` or `@mlx-node/trl` instead",.github/workflows/ci.yml (1)
195-200: Clarify the version pattern matching logic.The current regex patterns may cause unintended behavior:
- First pattern (
^[0-9]\+\.[0-9]\+\.[0-9]\+$) matches exact semver like1.2.3- Second pattern (
^[0-9]\+\.[0-9]\+\.[0-9]\+) matches semver prefix, so1.2.3-betawould publish withnexttagHowever, a commit message like
1.2.3would match the firstgrepand publish as stable, which is correct. But the logic flow means1.2.3-beta.1publishes withnext, which seems intentional.Consider adding comments to document this behavior, or use more explicit patterns with
-Efor extended regex:📝 Suggested improvement for clarity
- name: Publish package run: | - npm install -g npm - if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; + COMMIT_MSG=$(git log -1 --pretty=%B) + # Exact semver (e.g., "1.2.3") -> publish as latest + if echo "$COMMIT_MSG" | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$"; then npm publish --access public - elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; + # Semver with prerelease suffix (e.g., "1.2.3-beta.1") -> publish as next + elif echo "$COMMIT_MSG" | grep -E "^[0-9]+\.[0-9]+\.[0-9]+-"; then npm publish --tag next --access public else echo "Not a release, skipping publish" fi
There was a problem hiding this comment.
Pull request overview
This PR wires up CI-driven publishing for the @mlx-node/core native module and introduces an npm package for the darwin-arm64 binary.
Changes:
- Add build/publish/version scripts to
packages/core/package.jsonusing@napi-rs/cli. - Introduce a platform-specific npm package and README for the
darwin-arm64native binary. - Extend the CI workflow with a
publishjob that downloads build artifacts and conditionally runsnpm publishbased on the latest commit message.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/core/package.json | Adds prepublishOnly, preversion, and version scripts to support NAPI-based packaging and versioning for @mlx-node/core. |
| packages/core/npm/darwin-arm64/package.json | Defines the @mlx-node/core-darwin-arm64 npm package, including binary and mlx.metallib as distributable files and darwin/arm64 targeting. |
| packages/core/npm/darwin-arm64/README.md | Documents that this package ships the aarch64-apple-darwin binary for @mlx-node/core. |
| .github/workflows/ci.yml | Adds a publish job that retrieves build artifacts, moves them into place via a workspace script, and conditionally runs npm publish to release packages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/ci.yml:
- Around line 167-173: The publish job ("publish") should be gated to only run
on direct pushes to main to avoid PR-triggered npm publish attempts; add a
job-level condition (if) on the publish job such as checking github.event_name
== 'push' and github.ref == 'refs/heads/main' so the job only executes for push
events to the main branch and not for pull_request events.
431f566 to
a722fc9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/ci.yml:
- Around line 67-69: Replace the incorrect direct npm script invocation "yarn
build:ts && yarn test" with Vite+ CLI form by using "vite run build:ts && vite
test" so custom script build:ts is executed via `vite run` and the built-in Vite
test command is used; keep the existing "cargo test" step as-is. Ensure you
update the CI job step that currently contains the string "yarn build:ts && yarn
test" to the new "vite run build:ts && vite test" invocation.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
…nload identity, session safety Six confirmed defects from the final whole-branch review (each control-flow verified + probed before fixing); one finding refuted, one documented residual. - #6 metrics (regression from R11): the trace-only token UNION projected GROSS traces.prompt_tokens into the `input` column while turns store NET (prompt-cacheRead), double-counting cached tokens. Clamp the trace side to MAX(prompt-cached,0) in tokensByDay + turnTotals; fixture totals corrected. - #4 downloads: gate the install-skip on the completion marker's repo+revision (new readCompletion helper), not mere presence — a different revision of the same slug no longer reports a false `done`; mismatch falls through to the owned-swap. - #7 trace ingest: move the vanished-file row reconciliation BEFORE the ingest loop so a renamed trace file's globally-unique rows are freed before the new name is ingested (were permanently dropped); watermark reconcile stays after. - #8 session ingest: reject a non-object top-level entry (a `header\nnull\n` file) in isValidSessionTopology before dereferencing .type, routing it to the existing quarantine path instead of a warn-only catch that retained stale rows. - #3 session rename: refuse (409) renaming a session whose file was modified within a liveness window — pi has no cross-process lock, so appending to a file a live agent is extending would race that turn. Documented best-effort. - #5 cold cache: publish the index entry before the directory fsync so a post-rename dir-fsync failure keeps in-process accounting consistent with the on-disk file (rebuild_index already self-heals on restart). - #2 cold-tier fingerprint→materialize window: documented as an accepted v1 residual (off-by-default, adversary-owns-files; fd-coupled hashing out of scope). - #1 (train KV poisoning): refuted — training never uses the paged/cold path. Gate: typecheck exit0 · cold_cache 33/0 · dashboard 8 suites/175 · lint 0-err.
…nload identity, session safety Six confirmed defects from the final whole-branch review (each control-flow verified + probed before fixing); one finding refuted, one documented residual. - #6 metrics (regression from R11): the trace-only token UNION projected GROSS traces.prompt_tokens into the `input` column while turns store NET (prompt-cacheRead), double-counting cached tokens. Clamp the trace side to MAX(prompt-cached,0) in tokensByDay + turnTotals; fixture totals corrected. - #4 downloads: gate the install-skip on the completion marker's repo+revision (new readCompletion helper), not mere presence — a different revision of the same slug no longer reports a false `done`; mismatch falls through to the owned-swap. - #7 trace ingest: move the vanished-file row reconciliation BEFORE the ingest loop so a renamed trace file's globally-unique rows are freed before the new name is ingested (were permanently dropped); watermark reconcile stays after. - #8 session ingest: reject a non-object top-level entry (a `header\nnull\n` file) in isValidSessionTopology before dereferencing .type, routing it to the existing quarantine path instead of a warn-only catch that retained stale rows. - #3 session rename: refuse (409) renaming a session whose file was modified within a liveness window — pi has no cross-process lock, so appending to a file a live agent is extending would race that turn. Documented best-effort. - #5 cold cache: publish the index entry before the directory fsync so a post-rename dir-fsync failure keeps in-process accounting consistent with the on-disk file (rebuild_index already self-heals on restart). - #2 cold-tier fingerprint→materialize window: documented as an accepted v1 residual (off-by-default, adversary-owns-files; fd-coupled hashing out of scope). - #1 (train KV poisoning): refuted — training never uses the paged/cold path. Gate: typecheck exit0 · cold_cache 33/0 · dashboard 8 suites/175 · lint 0-err.
…nload identity, session safety Six confirmed defects from the final whole-branch review (each control-flow verified + probed before fixing); one finding refuted, one documented residual. - #6 metrics (regression from R11): the trace-only token UNION projected GROSS traces.prompt_tokens into the `input` column while turns store NET (prompt-cacheRead), double-counting cached tokens. Clamp the trace side to MAX(prompt-cached,0) in tokensByDay + turnTotals; fixture totals corrected. - #4 downloads: gate the install-skip on the completion marker's repo+revision (new readCompletion helper), not mere presence — a different revision of the same slug no longer reports a false `done`; mismatch falls through to the owned-swap. - #7 trace ingest: move the vanished-file row reconciliation BEFORE the ingest loop so a renamed trace file's globally-unique rows are freed before the new name is ingested (were permanently dropped); watermark reconcile stays after. - #8 session ingest: reject a non-object top-level entry (a `header\nnull\n` file) in isValidSessionTopology before dereferencing .type, routing it to the existing quarantine path instead of a warn-only catch that retained stale rows. - #3 session rename: refuse (409) renaming a session whose file was modified within a liveness window — pi has no cross-process lock, so appending to a file a live agent is extending would race that turn. Documented best-effort. - #5 cold cache: publish the index entry before the directory fsync so a post-rename dir-fsync failure keeps in-process accounting consistent with the on-disk file (rebuild_index already self-heals on restart). - #2 cold-tier fingerprint→materialize window: documented as an accepted v1 residual (off-by-default, adversary-owns-files; fd-coupled hashing out of scope). - #1 (train KV poisoning): refuted — training never uses the paged/cold path. Gate: typecheck exit0 · cold_cache 33/0 · dashboard 8 suites/175 · lint 0-err.
#339) ## Problem After `mlx download model -m unsloth/Qwen3.8-Flash-Next-GGUF -g "*UD-Q4_K_XL*"` the CLI printed: ``` To convert GGUF to MLX SafeTensors format: mlx convert -i .../UD-Q4_K_XL/...-00001-of-00004.gguf -o <dir>-mlx mlx convert -i .../UD-Q4_K_XL/...-00002-of-00004.gguf -o <dir>-mlx ... one line per shard ``` Each line is wrong: | Fact | Where | |---|---| | `mlx convert` reads only the file it is given, so shard 1 alone gives a model with only its own tensors | `crates/mlx-core/src/utils/gguf.rs` `convert_gguf_to_safetensors_inner`; `docs/convert-quantize.md` trap #13 | | Shards 2..N have no `general.architecture` (llama.cpp split puts metadata in split 0 only) | checked on the real Flash Next shard headers | | All lines share one `-o`, so each run replaces the last one | `packages/cli/src/commands/convert.ts` `commitStagedOutput` | | qwen4exp / deepseek41 need no conversion: the native loader opens shard 00001 and reads the other shards | `qwen4_exp/weights.rs` `index_gguf`; `docs/qwen38-flash-next.md` | ## Fix `ggufNextSteps()` replaces the per-file loop: ``` weightFiles → ggufLoadEntries() one entry per split set (shard 00001) or single file → readGgufArchitecture(entry) → family in ggufArchitectures (split sets: only when ggufDiscovery.split)? yes → "Load directly: <path>" (+ --assets-repo note when config.json/tokenizer.json are missing for requiresAssets families) no, split → llama-gguf-split --merge, then mlx convert no, single → mlx convert, own -o per model when there are several → split set with missing shards → "Incomplete split GGUF" line ``` Output for the Flash Next download now: ``` Load directly (no conversion needed): ~/.mlx-node/models/qwen3.8-flash-next-gguf/UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf (reads the other 3 shard(s) beside it) ``` Only the printed hint changes. Download, sync, and marker logic are not touched. ## Split-name parser (no regex) `parseGgufFileName()` in `packages/lm/src/model-discovery.ts` reads `<stem>-NNNNN-of-NNNNN.gguf` right to left (5-digit count, `-of-`, 5-digit ordinal, `-`). Anything else is a single file. | Call site | Before | After | |---|---|---| | CLI hint (`ggufLoadEntries`) | new regex | parser | | Discovery (`supportedGgufName`) | `/-(\d{5})-of-(\d{5})\.gguf$/i` | parser, same rules (shard 00001, 1..1024, `ggufDiscovery.split`) | New discovery test: only shard 00001 of a qwen4exp split set is listed; a clef split set and an `-00002-of-00001` name are refused. Other GGUF-name regexes stay (`QWEN35_XL_GGUF`, `BONSAI_PQ2_GGUF`, `GGUF_COMPANION_NAME`): they match quant tags or tokens, not split names. ## Tests - New `__test__/cli/download-gguf-next-steps.test.ts`: split collapse, direct split load (qwen4exp), merge path (qwen35 split), gemma4 assets note, unique `-o` per variant, unreadable header fallback, incomplete split. - `vp test` on the 4 download test files: 75 passed. `yarn typecheck` and `vp lint --type-aware --type-check` are clean. ## Not in this PR (found during research) `mlx serve` model discovery scans `<modelsDir>/<entry>/*.gguf` only one level deep, so the nested layout `<modelsDir>/qwen3.8-flash-next-gguf/UD-Q4_K_XL/*.gguf` that `mlx download` creates is not found (`packages/lm/src/model-discovery.ts` `modelFileInventory`). This needs a separate decision. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Note
Medium Risk
Medium risk because it introduces automated npm publishing based on commit-message parsing and new prepublish/version scripts, which can affect release integrity and artifact correctness.
Overview
Adds a new CI publish job that downloads build artifacts and conditionally runs
npm publishacross workspaces (latest vsnexttag) based on the latest commit message; also enables Cargo incremental builds and updates the test command used in CI.Introduces an Apple Silicon binary subpackage (
@mlx-node/core-darwin-arm64) and adds@mlx-node/corerelease scripts (prepublishOnly/preversion/version) to support NAPI artifact packaging/versioning.Simplifies test running by adding a top-level
yarn testscript wired tovite test, consolidatesvite.config.tstest settings to a single config, and reduces test flakiness by making one integration test deterministic and extending a model-load setup timeout.Written by Cursor Bugbot for commit 18d818a. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
New Features
Chores
Documentation
Tests