Skip to content

refactor(profiles): three-scope template contract + drop is_builtin emission - #1399

Merged
jundot merged 3 commits into
jundot:mainfrom
popfido:refactor/profiles-templates-prep
May 27, 2026
Merged

jundot merged 3 commits into
jundot:mainfrom
popfido:refactor/profiles-templates-prep

Conversation

@popfido

@popfido popfido commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Prep PR carved out of #1371 per maintainer review. Tightens the server-side
template/profile API into a shape both HTML and the upcoming Swift app can
bind to cleanly, with one user-visible contract shift (drops is_builtin
from /api/profile-templates payloads).

Reviewable as a standalone server change — no Swift code, no client
required to demonstrate correctness.

What this changes on main

omlx/model_settings.py (+13/-2)

  • Adds UNIVERSAL_PROFILE_FIELDS — the keys a global (cross-model) template
    is allowed to carry. Per-model profiles continue to accept the full
    sampling surface; globals are now constrained to the universal subset so
    the three scopes (preset / global / model) compose without leaking
    model-specific fields up the chain.
  • get_template(name) returns {} for missing/empty templates instead of
    None. Callers that previously had to special-case None can now use
    the result directly.
  • /api/profile-templates payloads no longer stamp is_builtin: false on
    every entry. The flag carried no information once the catalog became
    user-templates-only; HTML doesn't read it, and consumers can treat
    templates as not-builtin by construction.

tests/test_model_settings_profiles.py (+35/-2)

Covers the new universal-field gating, the {} return contract, and the
shape of /api/profile-templates without is_builtin.

Behavior shifts to flag

  • get_template(name) returns {} not None for unknown templates.
    HTML admin and any external /api/profile-templates/{name} consumers
    should be checked against this — internal callers were audited.
  • /api/profile-templates payloads drop is_builtin. HTML doesn't
    reference the flag; older external clients that hard-required the key
    would break, though I'm not aware of any.

How this preps #1371

The Swift app's profiles UI binds a three-scope model (preset chips
shipped via omlx/admin/static/omlx_preset.json + per-server global
template + per-model profile). The server side of that contract — what
the global template is allowed to carry, what the API surface returns —
lives here so it can be reviewed and merged independently of the ~4k-line
Swift rewrite. Once this lands, #1371 only carries the Swift client
bindings on top.

Test plan

  • `pytest tests/test_model_settings_profiles.py` — 28/28
  • `pytest tests/test_model_settings.py tests/test_admin_profiles_api.py tests/test_admin_api_key.py` — 123/123
  • Manual: HTML admin → Settings → Profile Templates renders + CRUD still works
  • Manual: existing user templates persist + load on server restart

popfido added 3 commits May 25, 2026 12:33
Adds the universal/per-model field split and built-in preset templates
shipped on first run. UNIVERSAL_PROFILE_FIELDS gates which keys a global
template may carry; per-model profiles continue to accept the full
sampling surface. New default_global_profile.json seeds the preset
catalog when the user has no templates of their own.

Server-side foundation for the design's three-scope profile model
(preset / global / model) the Swift app now binds to.
Server-side slice. Drops the 4 hard-coded preset templates the
ModelSettingsManager shipped on first run and lets clients source their
catalog from `omlx/admin/static/omlx_preset.json` (the bundle that's
already refreshable from omlx.ai). The 4 builtin entries were never on
omlx.ai's side, so both HTML and the upcoming Swift app converge on the
bundle's 10-entry catalog with no drift.

- Delete `omlx/template/default_global_profile.json` and the
  `_get_builtin_templates()` machinery in `ModelSettingsManager`.
- Drop the rename/save/delete rejection branches that special-cased
  builtin names — `/api/profile-templates` now serves user templates
  only. `is_builtin` stays on the response schema (always false) so
  back-compat with older HTML/Swift clients is intact; a follow-up
  removes it once both clients no longer key on the field.
- Sync `model_profiles.py` to drop `load_default_global_templates()` —
  it's dead code once the builtin source is gone.
- Tests: drop the qwen3.6 builtin assertions; keep CRUD + persistence
  coverage.

Carved out of the Swift app PR (jundot#1371) for focused review per
maintainer ask — the Swift-side preset bundle client lives there.
`ModelSettingsManager` previously stamped `is_builtin: false` on every
template payload — belt-and-suspenders left over from when server-side
builtins existed. With those retired (prior commit), the flag is dead
weight: HTML doesn't read it, and the Swift app gates on
`templateScope` (defaults to `.global` when the field is absent) so
older clients keep working unchanged.

Schema-compat note: the field stays decodable on the client side as
`Optional<Bool>` — we're just dropping the emission. Older clients
that still expect the key continue to work because their decoders
treat it as optional.

Carved out of the Swift app PR (jundot#1371). The Swift-side stale-reference
patches and packaging/build.py cleanup that were also in the original
commit stay in jundot#1371 since they touch Swift sources.
@jundot

jundot commented May 27, 2026

Copy link
Copy Markdown
Owner

Thanks for slicing the server-side prep out. The universal vs per-model field split lines up cleanly with the three-scope model, and dropping the informationless is_builtin key is the right call. Internal callers all read fine against the new {} default.

Merging now.

@jundot
jundot merged commit 0c881f5 into jundot:main May 27, 2026
panwudi added a commit to panwudi/flyto-mlx that referenced this pull request May 27, 2026
Catch-up sync. Highlights:
- boundary-store cleanup race fix (jundot#1423) — eliminates the
  test_cleanup_all_drains_queue flake we have been carrying.
- per-engine MLX threads / streams (jundot#1304) — multiple models stepping
  scheduler.step() concurrently no longer cross-contaminate streams.
- VLM lazy state materialized on loader thread; skip MTPModule attach
  when checkpoint lacks mtp.* weights.
- Dead TieredCacheManager removed; profiles three-scope template
  refactor (jundot#1399).

4567 pass / 3 known env-override fails / 36 skip. Zero regression.
User delegated review.

---

Catch-up 同步. 主要内容:
- boundary-store 清理 race 修复 (jundot#1423) - 消掉一直拖着的
  test_cleanup_all_drains_queue flake.
- 每引擎 MLX 线程 / 流 (jundot#1304) - 多模型并发 scheduler.step()
  不再 cross-contaminate.
- VLM 在 loader 线程实例化 lazy 状态; checkpoint 无 mtp.* 权重时
  跳过 MTPModule attach.
- 删 dead TieredCacheManager; profiles three-scope template 重构
  (jundot#1399).

4567 pass / 3 known env-override fails / 36 skip. 零回归.
用户委托 review.
@popfido
popfido deleted the refactor/profiles-templates-prep branch May 29, 2026 10:36
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