Skip to content

ci: publish - #13

Merged
Brooooooklyn merged 8 commits into
mainfrom
02-02-ci_publish
Feb 2, 2026
Merged

Brooooooklyn merged 8 commits into
mainfrom
02-02-ci_publish

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Feb 2, 2026 •

Copy link
Copy Markdown
Contributor

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 publish across workspaces (latest vs next tag) 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/core release scripts (prepublishOnly/preversion/version) to support NAPI artifact packaging/versioning.

Simplifies test running by adding a top-level yarn test script wired to vite test, consolidates vite.config.ts test 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

    • Added native Apple Silicon (darwin‑arm64) binary package and a version-aware CI publish workflow that publishes or tags releases based on the latest commit message.
  • Chores

    • Added release/versioning scripts and a top-level test script to run tests via Vite.
    • Consolidated and simplified test configuration into a single inline setup.
  • Documentation

    • Added README for the darwin‑arm64 package and updated development test commands.
  • Tests

    • Increased setup timeout in a parallel-generation test and made a functional integration test use deterministic weight initialization.

Copilot AI review requested due to automatic review settings February 2, 2026 12:30
@coderabbitai

coderabbitai Bot commented Feb 2, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Added 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 vite test script; simplified Vite test config; and made small deterministic/test timeout tweaks.

Changes

Cohort / File(s) Summary
CI Publish Pipeline
​.github/workflows/ci.yml
Set CARGO_INCREMENTAL: '1', replaced matrix test command with yarn test, and added a Publish job (runs-on: ubuntu-latest, needs: test, lint) that checks out with submodules, sets up Node+Yarn, installs deps, downloads mlx-node and mlx-metallib artifacts into packages/core, moves/list files, and conditionally runs npm publish (x.y.z → latest, x.y → --tag next, else skip).
Darwin-arm64 Package
packages/core/npm/darwin-arm64/package.json, packages/core/npm/darwin-arm64/README.md
Added @mlx-node/core-darwin-arm64 manifest and README including mlx-core.darwin-arm64.node and mlx.metallib, targeting darwin/arm64.
Core Package Scripts
packages/core/package.json
Added lifecycle scripts: prepublishOnly (napi prepublish --npm --no-github-release), preversion (build with oxnode and stage), and version (napi version).
Root package & docs
package.json, README.md
Added root test script (vite test) and updated README test commands to the simplified yarn test / yarn vite test run <path>.
Vite config
vite.config.ts
Removed ViteUserConfig type import and separate test configs; inlined a single test object in exported config (globals, environment, maxConcurrency, watch, testTimeout, maxWorkers, include).
Tests (minor & deterministic)
__test__/models/qwen3-generate-batch-parallel.test.ts, __test__/core/functional-integration.test.ts
Adjusted a beforeAll to include a 30000ms timeout; added deterministic weight initialization in functional integration test to stabilize the small-parameter-update expectation.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through CI at dawn's light,
Packed artifacts snug for an arm64 flight,
A tagged commit twinkled in my paw,
I nudged the registry with a gentle thaw,
And danced where tests and publish unite. 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'ci: publish' is vague and generic, using non-descriptive terms that don't convey the full scope of changes. Consider a more descriptive title such as 'ci: add automated npm publish pipeline with darwin-arm64 packaging' to better reflect the main changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 02-02-ci_publish

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 a license field.

The package manifest is missing a license field, 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 like 1.2.3
  • Second pattern (^[0-9]\+\.[0-9]\+\.[0-9]\+) matches semver prefix, so 1.2.3-beta would publish with next tag

However, a commit message like 1.2.3 would match the first grep and publish as stable, which is correct. But the logic flow means 1.2.3-beta.1 publishes with next, which seems intentional.

Consider adding comments to document this behavior, or use more explicit patterns with -E for 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

Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.json using @napi-rs/cli.
  • Introduce a platform-specific npm package and README for the darwin-arm64 native binary.
  • Extend the CI workflow with a publish job that downloads build artifacts and conditionally runs npm publish based 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.

Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread .github/workflows/ci.yml Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread .github/workflows/ci.yml Resolved
@Brooooooklyn
Brooooooklyn merged commit 00990e4 into main Feb 2, 2026
6 checks passed
@Brooooooklyn
Brooooooklyn deleted the 02-02-ci_publish branch February 2, 2026 17:17
@coderabbitai coderabbitai Bot mentioned this pull request Feb 22, 2026
Brooooooklyn added a commit that referenced this pull request Apr 11, 2026
Brooooooklyn added a commit that referenced this pull request Jul 28, 2026
…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.
Brooooooklyn added a commit that referenced this pull request Jul 28, 2026
…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.
Brooooooklyn added a commit that referenced this pull request Jul 28, 2026
…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.
Brooooooklyn added a commit that referenced this pull request Nov 9, 2026
#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants