Skip to content

feat: add safe WebUI model library operations - #1872

Merged
inureyes merged 13 commits into
mainfrom
feature/issue-1841-safe-model-library
Sep 14, 2026
Merged

inureyes merged 13 commits into
mainfrom
feature/issue-1841-safe-model-library

Conversation

@inureyes

@inureyes inureyes commented Sep 12, 2026

Copy link
Copy Markdown
Member

Summary

Adds authenticated WebUI downloads and managed-cache removal using the existing pool/coordinator: anonymous immutable-revision downloads, bounded admission/progress/cancellation, descriptor-anchored publication/deletion and shared bootstrap/admission policy. Single-model mode remains read-only; external/user-root/preset aliases and subtree overlaps are rejected. Includes the unload owned-drain revision fix and Linux device-identity portability repair.

Verified acceptance

Runtime source 84f1aeb2b4f5706bb0d63866b20ca48d74bf340a is based on main e9ee5f04; the final report commit changes no source or bundle.

  • Full workspace: 11,313 unique top-level tests passed, zero failed, 361 ignored; two nested restart-child passes counted separately. Workspace all-target clippy passed default and feature-disabled configurations with warnings denied.
  • All 46 contracts, structural/format checks, both binaries' production relocated empty/offline/TTY checks, 76 frontend tests/type/lint and deterministic bundle verification passed.
  • Unchanged strict fresh-cache driver passed pinned public SmolLM download/hash, production restart/new identity/old-operation 404/stable catalog ID, real load and nonempty 32-token generation, observed worker-exit unload, API deletion of only the new checkpoint and empty catalog. Repetitive output is not a quality claim. Both owned servers exited 0 without force.
  • Actual hosted CI run 34844128193 passed, including Linux clippy and feature-off checks; no GB10 exception was needed. Workflow-skipped CUDA/OpenXLA link jobs are not execution claims.

Evidence boundaries

The original 3cb4817d unload failure and 857937ca firmware timeout remain preserved. Later success after user-confirmed GPU availability establishes neither their external cause nor a reboot. ENOSPC coverage is injected, not physical disk exhaustion. Safari/VoiceOver/native 200% checks remain user-deferred until the whole implementation is ready, not passed.

Bilingual technical reports record architecture, reviews, failures and final evidence. PR remains in review pending central merge.

Refs #1834; Closes #1841

@inureyes inureyes added status:review Under review type:enhancement New features, capabilities, or significant additions priority:high High priority area:models Model architectures, weights, loading, metadata labels Sep 12, 2026
inureyes added a commit that referenced this pull request Sep 12, 2026
inureyes added a commit that referenced this pull request Sep 13, 2026
Refresh the PR #1872 bilingual technical reports with the issue #1841 repair checkpoint, the current focused CPU and fake-network validation record, and an explicit fake acceptance matrix that distinguishes covered cases from host-recovery and root-owned gaps.
inureyes added a commit that referenced this pull request Sep 13, 2026
Update the PR #1872 technical reports with the latest repair-cycle checkpoint, including the bounded timeout, simulated ENOSPC, retry-after-failure, and descendant-overlap ownership tests that now pass locally.

Validation: report-only change; source gates are recorded in the report.

Refs #1841.
inureyes added a commit that referenced this pull request Sep 14, 2026
inureyes added a commit that referenced this pull request Sep 14, 2026
Refresh the PR #1872 bilingual technical reports with the issue #1841 repair checkpoint, the current focused CPU and fake-network validation record, and an explicit fake acceptance matrix that distinguishes covered cases from host-recovery and root-owned gaps.
@inureyes
inureyes force-pushed the feature/issue-1841-safe-model-library branch from 034dfac to 3cb4817 Compare September 14, 2026 03:20
inureyes added a commit that referenced this pull request Sep 14, 2026
Update the PR #1872 technical reports with the latest repair-cycle checkpoint, including the bounded timeout, simulated ENOSPC, retry-after-failure, and descendant-overlap ownership tests that now pass locally.

Validation: report-only change; source gates are recorded in the report.

Refs #1841.
inureyes added a commit that referenced this pull request Sep 14, 2026
@inureyes
inureyes force-pushed the feature/issue-1841-safe-model-library branch from 857937c to 71552f8 Compare September 14, 2026 04:27
inureyes added a commit that referenced this pull request Sep 14, 2026
Refresh the PR #1872 bilingual technical reports with the issue #1841 repair checkpoint, the current focused CPU and fake-network validation record, and an explicit fake acceptance matrix that distinguishes covered cases from host-recovery and root-owned gaps.
inureyes added a commit that referenced this pull request Sep 14, 2026
Update the PR #1872 technical reports with the latest repair-cycle checkpoint, including the bounded timeout, simulated ENOSPC, retry-after-failure, and descendant-overlap ownership tests that now pass locally.

Validation: report-only change; source gates are recorded in the report.

Refs #1841.
inureyes added a commit that referenced this pull request Sep 14, 2026
…clean (#1889)

## Summary

Restores the `OpenXLA feature compile` CI job, which has failed on `main` since 2026-09-12 16:12 and therefore fails on every open PR. No behavior changes on any feature set.

## Cause

The job's second step is `cargo check --no-default-features --features xla-diagnostics --all-targets` under `RUSTFLAGS="-D warnings"`. Because `default = ["surgery", "webui"]`, that step builds with the WebUI off.

The last success on `main` was `9ead2b7d` (2026-09-12 04:43) and the first failure `70386ac6` (2026-09-12 16:12). The only commits between them are the WebUI series: #1857, #1860, #1865, #1868, #1864. They registered their routes behind `#[cfg(feature = "webui")]` but left the handlers, validators, constants, request types and imports those routes use outside the gate. With `webui` off all of it is dead code, and `-D warnings` makes each an error.

I checked before writing this that it was not already fixed elsewhere: current `origin/main` still carries the imports and its latest CI run still fails the job, `lablup/mlxcel-internal` was last pushed on 2026-09-10 and predates the breakage, and no merged or open PR fixes it.

## Change

Every orphaned item is gated on `webui`, matching the gate its only callers already carry.

- `src/server/router_server.rs`: 35 handlers, validators, constants and types, plus the `router_lifecycle`, `HeaderMap`, `Uri`, `AxumPath` and `RouterModelAction` imports only they use.
- `src/server/app.rs`: six axum imports.
- `src/models/mod.rs`: six detection re-exports used only by `server::webui`. `is_sequence_classification_architecture` stays ungated because `src/rerank/mod.rs` uses it.
- `src/server/auth.rs`: `with_extra_key`, called only from the WebUI security setup in `startup.rs`.
- `src/server/router_server_tests.rs`: `restore_env_var`, used only by a webui-gated test.

Gating the first layer exposed a second layer of imports that only the gated items used, so this was iterated until the compiler reported nothing. The only deleted lines are import lists being split; no logic is touched.

## Verification

Reproduced first on `main`: `cargo check --no-default-features --features cuda --lib --tests` reports 42 warnings in the `mlxcel` crate.

After the change, every `cargo check` below reports zero warnings and zero errors in workspace crates:

| features | targets |
|---|---|
| `--no-default-features --features cuda` | `--lib --tests` |
| `--features cuda` (defaults on) | `--lib --tests` |
| `--no-default-features --features cuda,webui` | `--lib --tests` |
| `--no-default-features --features cuda,surgery` | `--lib --tests` |
| `--no-default-features --features cuda` | `--all-targets` |
| `--features cuda` (defaults on) | `--all-targets` |

The `--all-targets` rows cover bins, benches and examples, where a gated item used by another target would have been a hard compile error rather than a warning. `cargo fmt --all -- --check` is clean.

Not built locally: the `xla-iree` feature itself. The `OpenXLA feature compile` job on this PR is the check for it, and it is the job this PR exists to turn green.

## Follow-up for open PRs

PR #1872 edits `src/server/router_server.rs` and carries the same imports, so it will need a rebase once this lands. A rebase request will be posted there.
@inureyes

Copy link
Copy Markdown
Member Author

Rebase needed onto main after #1889

#1889 has merged as b395a9e5 and restores the OpenXLA feature compile job, which had failed on main since 2026-09-12 16:12 and is the failing check on this PR too.

The job's second step runs cargo check --no-default-features --features xla-diagnostics --all-targets under RUSTFLAGS="-D warnings". Because default = ["surgery", "webui"], it builds with the WebUI off, and the WebUI series left the handlers, validators, constants, request types and imports behind its routes outside #[cfg(feature = "webui")], so each became a dead-code error. #1889 gates all of them on webui.

This PR touches src/server/router_server.rs, which #1889 edited in its import block and in front of 35 items, so expect conflicts there. Two things to carry through the rebase so the check stays green:

  • Keep the new gates on the items fix(server): gate webui-only helpers so --no-default-features builds clean #1889 gated, including the split imports (HeaderMap, Uri, AxumPath, RouterModelAction, and the whole router_lifecycle import).
  • Gate anything this PR adds that only webui routes use. The quickest way to find leftovers is cargo check --no-default-features --features cuda --lib --tests, which reports the same set of dead-code warnings that -D warnings turns into errors in CI, without needing the IREE build. A clean result there plus cargo check --features cuda --lib --tests with defaults on covers both sides of the gate.

WebUI model downloads and managed-cache deletion now share the router lifecycle coordinator so browser and compatibility routes observe the same bounded operations, cancellation boundary, and terminal results.

The implementation keeps WebUI Hub access anonymous, resolves downloads to immutable revisions before fd-relative staging, and confines deletion to managed cache snapshots through a private descriptor-anchored quarantine that preserves user model roots.

Validation: cargo fmt --check; cargo clippy --lib --tests --features metal,accelerate -- -D warnings; focused cargo test filters for anonymous download transport, fd staging, queue/idempotency/cancel, WebUI routes, cache deletion races and rescan guards; make verify-webui-contract; make verify-llama-compat; make verify-versions; make verify-kernel-dtype-keys.

Refs #1834; Closes #1841
Tighten WebUI-managed downloads so anonymous metadata asks HuggingFace for blob metadata, requires LFS SHA-256 for safetensors, preserves resolved-revision aliases, rejects idempotency payload drift before replay, keeps plan totals stable under throttled progress, and verifies same-size checksum/completeness failures before fd-relative publication.

Harden managed-cache removal admission by rechecking idle/current state under the operation guard, failing closed on configured physical aliases from models-dir or presets, preserving busy entries during rescan, and keeping compatibility in-flight download cancellation from requiring a published snapshot path.

Add whole-producer contract coverage for download operations and route accepted responses, plus hermetic fake HTTP and router tests for anonymous credentials, metadata status errors, offline rejection, disconnect truncation, checksum/completeness failures, duplicate/revision replay, queue saturation, cancellation linearization, and physical alias removal blocks.
Refresh the PR #1872 bilingual technical reports with the issue #1841 repair checkpoint, the current focused CPU and fake-network validation record, and an explicit fake acceptance matrix that distinguishes covered cases from host-recovery and root-owned gaps.
Reject cache removals when configured models-dir or preset entries are descendants of the managed snapshot, and add bounded fake coverage for loopback read timeouts, simulated ENOSPC writer failures, and retry-after-failure downloads.

Validation: cargo test --lib --profile test-fast --features metal,accelerate downloader::tests:: -- --nocapture; cargo test --lib --profile test-fast --features metal,accelerate server::router_models::router_models_tests:: -- --nocapture; cargo fmt --check; git diff --check; cargo clippy --lib --tests --features metal,accelerate -- -D warnings; make verify-webui-contract.

Refs #1841.
Update the PR #1872 technical reports with the latest repair-cycle checkpoint, including the bounded timeout, simulated ENOSPC, retry-after-failure, and descendant-overlap ownership tests that now pass locally.

Validation: report-only change; source gates are recorded in the report.

Refs #1841.
Exercise interrupted running and queued downloads across owned CPU-only test processes using the shared router coordinator and descriptor-anchored staging. Verify session-local operation history, authenticated old-operation 404 responses, explicit retry, retained private partials and stable published catalog identity without loading a model.

Document the non-destructive restart policy and distinguish this fake-writer regression from pending production CLI and real-checkpoint acceptance. Scoped restart tests, repeated process execution, clippy and 43 contract fixtures pass.

Refs #1841; Refs #1834
Integrate the library routes with the merged secured startup path and derive bootstrap actions and feature flags from the same cache, offline and platform policy used by mutation admission. Preserve single-model read-only behavior and avoid filesystem or network probes during capability projection.

Retain the upstream startup, Unicode and error fixtures alongside the library producer fixtures, and rebuild the deterministic bundle. Add whole-bootstrap, prefixed browser-security, no-cache admission and no-directory-creation regressions while retaining owned-process restart coverage.

Refs #1841; Refs #1834
A revision-checked unload validated its caller token, advanced the revision in its own drain transition, then rejected the old token before worker shutdown. Capture the owned drain revision under the lifecycle mutex and use it for post-wait validation, preserving current-entry and external-change checks. Keep legacy callers without a revision precondition on identity-only cleanup semantics.

The real acceptance failure is preserved. A loaded recording-worker regression reproduced expected3/current4 before repair; tests now cover request draining, observed worker exit, external revision and replacement rejection, shared revision allocation, and legacy failed-worker cleanup. The real harness remains unchanged for root acceptance.

Refs #1841; Refs #1834
Record the ui-common rebase without changing the reviewed library and unload repair semantics. Preserve the latest Metal firmware-timeout full-gate failure separately from historical passing and CPU-only evidence, and keep actual library acceptance pending an owner-coordinated quiet window.

Refs #1841; Refs #1834
Centralize the existing signed-device-to-u64 conversion in one narrowly documented helper, preserving Darwin representation without narrowing Linux metadata identity. Both anchored deletion checks use it; temporary-directory regressions reject changed device/inode and child replacement and cover Darwin signed values.

Rebase onto latest main e9ee5f0, retaining upstream feature-disabled helper gates and the unchanged library/security contracts. Record the executed hosted failures separately from the historical runner outage; Linux hosted validation and root-owned full/real acceptance remain required.

Refs #1841
@inureyes
inureyes force-pushed the feature/issue-1841-safe-model-library branch from 71552f8 to 84f1aeb Compare September 14, 2026 12:34
Record root's full workspace, strict fresh-cache model lifecycle and actual hosted CI passes at source84f1aeb2. Preserve the earlier unload and Metal firmware failures without causal or reboot claims, and keep whole-implementation manual accessibility checks deferred.

This report-only update changes no source or bundled assets. PR1872 remains in review for central merge.

Refs #1841
@inureyes
inureyes merged commit c30b89a into main Sep 14, 2026
16 checks passed
@inureyes inureyes added status:done Completed and removed status:review Under review labels Sep 14, 2026
@inureyes
inureyes deleted the feature/issue-1841-safe-model-library branch September 14, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:models Model architectures, weights, loading, metadata priority:high High priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(webui): track safe model downloads and cache deletion

1 participant