Skip to content

Reliability audit fixes + release 0.3.1 - #3

Merged
ensevengg merged 5 commits into
support-artifact-bundlesfrom
reliability-fixes
Sep 15, 2026
Merged

ensevengg merged 5 commits into
support-artifact-bundlesfrom
reliability-fixes

Conversation

@ensevengg

Copy link
Copy Markdown
Owner

Summary

Third and final PR of the stack (contains #1 and #2). Applies the findings of the branch reliability audit (docs/research/branch-reliability-audit.md), which identified real bugs in the earlier stack with reproduced probes — each fix below corresponds to an audit finding:

  • Batch abort on projector-first manifests (P1) — supported artifacts are normalized model-first before import, and partial records are never serialized without the model artifact (primary_artifact raising StopIteration previously aborted the whole batch).
  • Split vision bundles on re-pull (P1) — per-artifact reuse now requires the prior target to live in the current import_user_repo directory, so a changed digest can't leave the model/projector pair split across two LM Studio directories.
  • Alias cleanup errors abort the batch (P1) — stale-alias unlink() and staging mkdir() failures are translated to per-model error results.
  • status crash when lms is broken (P2) — inventory failure degrades to "pending" for projector bundles instead of taking the command down.
  • BOM-tolerant state reads (P2) — utf-8-sig on load; a BOM previously discarded every sync record as corrupt.
  • Durable state writes — fsync before replace, per-process temp names, temp cleanup on failure.
  • same_file inode-0 guard (P2) — FAT/exFAT report inode 0, which made every same-size file compare "equal" and risked stale-alias reuse.
  • Real hard-link permission probe in sdl doctor — links an actual blob into both staging dirs, catching restrictions like Linux fs.protected_hardlinks that the st_dev check can't see; adds an lms ls inventory check to doctor.
  • Prune sweeps .studiolink-imports — copy-mode staging leftovers from crashes no longer pin blob space forever.
  • sdl upgrade fixes — pins studiolink=={latest} so the success message can't describe a different release than pip installed; version comparison uses leading digits so 1rc1 no longer parses as 11.
  • README rewritten to match actual behavior (staging dirs, digest-isolated repos, hard-link retention semantics).

Verification

  • Full suite: 173 passed (main: 117); ruff clean, pyright clean (0 errors).

Stack / merge order

  1. Harden sync lifecycle and platform discovery #1 stabilize-sync-lifecycle → main
  2. Sync Ollama model-projector (vision) bundles #2 support-artifact-bundles → stabilize-sync-lifecycle
  3. This PR → support-artifact-bundles

Merge in order; this PR supersedes the other two if merged last (it contains both).

Alias creation: mkdir() and the stale-alias unlink() ran outside the
OSError->RuntimeError conversion, so a PermissionError/FileExistsError
escaped _sync_one and aborted the whole sync batch. Wrap both calls so
each model reports an error result instead.

Artifact order: a manifest that lists the projector before the model made
per-artifact partial persistence serialize a projector-only record, whose
primary_artifact lookup raised StopIteration and aborted the batch. The
adapter now normalizes model layers first, partial persistence never
serializes without a model artifact, and primary_artifact raises a clear
ValueError if the invariant is ever violated.

Bundle co-location: re-pulling one artifact of a vision bundle changed
import_user_repo, but the unchanged artifact was still reused from the old
digest-keyed directory, splitting the pair across LM Studio directories.
Reuse now requires the prior target to live in the current destination
directory, so both artifacts are re-imported together and vision
confirmation checks the new location.

Already-synced policy: a complete import that Ollama can no longer back
now reports "skipped" for bundles too, matching text models, instead of a
spurious stale error.

same_file(): treat st_ino == 0 as unknowable identity. On filesystems
without file ids (FAT/exFAT) every file on the volume compared equal,
which could silently reuse a stale alias and import old weights.
Read state.json with utf-8-sig so an editor-added BOM no longer makes
every record disappear and trigger a mass re-import. Write through a
per-process temp file with fsync before the atomic replace, so concurrent
writers cannot interleave into one temp file and a crash cannot leave a
truncated state file behind.
status() no longer crashes when lms cannot be executed: with a broken
CLI, projector bundles read as pending instead of the whole command
failing for users with synced vision models.

doctor gains two checks: a reversible hard-link probe of a real blob into
each staging destination (catching restrictions such as Linux
fs.protected_hardlinks that same-volume st_dev checks cannot see), and an
lms ls --json inventory check that vision verification depends on.

prune now also sweeps .studiolink-imports, where copy-mode temporary
aliases live; anything found there survived a crash or cleanup failure
and pinned blob space.
_version_tuple concatenated every digit run in a component, so 0.1.0rc1
compared as (0, 1, 11) - newer than any 0.1.x release. Only the leading
numeric run counts now, so pre-releases never look newer than their
release.

The upgrade command pins the exact version it just reported, so the
success message cannot describe a different release than the one pip
installed.
The audit documents the verified failure modes behind this branch's
fixes, including two merge blockers in the bundles branch (projector-first
manifests and split vision bundles) found during review.
@ensevengg
ensevengg merged commit 3ddc769 into support-artifact-bundles Sep 15, 2026
7 checks passed
ensevengg added a commit that referenced this pull request Oct 22, 2026
Land #2 and #3 on main (vision bundles + reliability fixes, 0.3.1)
ensevengg added a commit that referenced this pull request Nov 16, 2026
PRs #2 and #3 landed on their stacked parent branches instead of main, so
this branch was written without them. Merge them in and apply this
branch's import guarantees to multi-artifact records:

- verify, transactionally replace, recover, copy-reuse and reclaim each
  artifact; record a file identity per artifact
- keep a previous import tracked when a re-pull fails partway; the retry
  adopts files the failed attempt already verified
- keep imports whose Ollama blob was deleted synced only while their
  recorded identity is unchanged (symlinks and edited files are stale)
- sweep every leftover in copy-mode staging, since copy mode removes its
  aliases after each locked import
- apply manifest size checks to projector blobs

Validation: 281 passed on Python 3.12 including 27 sandboxed real-lms
cases; 254 passed, 27 skipped on 3.13 and 3.14; Ruff, formatting,
Pyright and distribution builds pass.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant