Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(config): support flat slot TOML shape in profile in-use scanning#1129

Merged
thinmintdev merged 3 commits into
mainfrom
fix/1087-flat-slot-toml-profile-scan
Jul 6, 2026
Merged

fix(config): support flat slot TOML shape in profile in-use scanning#1129
thinmintdev merged 3 commits into
mainfrom
fix/1087-flat-slot-toml-profile-scan

Conversation

@thinmintdev

Copy link
Copy Markdown
Contributor

Closes #1087.

Problem

ProfileStore._slot_profiles()load_slot_config()_flatten_slot_toml() only hoisted slot fields out of a legacy [slot] table. On systems where slot files use the current flat top-level shape (name, port, profile, device, runtime as scalars), every top-level scalar was dumped into extra, so the required port never reached the top level and SlotConfig validation failed. Result: repeated profiles.in_use_scan_error warnings, empty used_by, and a broken in-use delete guard.

Fix

_flatten_slot_toml() now branches on shape:

  • Legacy nested ([slot] table present): unchanged — hoist [slot], all other top-level siblings (incl. stray scalars) → extra, so existing round-trips are byte-identical.
  • Flat (no [slot] table): hoist top-level scalars as slot fields; sibling tables ([server], [npu], [image], [defaults], …) still land in extra and are promoted by the existing _hoist_*_from_extra validators.

[model] stays nested and name falls back to the filename in both shapes. extra collection is consume-based so nothing is dropped or duplicated.

Acceptance criteria

  • load_slot_config() accepts flat top-level name/port/profile/device/runtime (+ sibling tables).
  • load_slot_config() still accepts legacy [slot] TOMLs.
  • Profile listing no longer logs profiles.in_use_scan_error for valid flat slot TOMLs.
  • used_by / in-use detection reports slots for flat TOMLs.
  • Deleting a profile used by a flat-shape slot is blocked (409 profiles.in_use).
  • Regression tests cover both flat and nested shapes.

Tests

  • tests/config/test_loader.py: flat TOML loads all fields; flat sibling tables land typed (server) / in extra (defaults); flat TOML infers name from filename.
  • tests/api/test_profiles_crud.py: _seed_flat_slot_toml helper + test_delete_in_use_409_flat_slot_toml (409 guard + populated used_by).

Targeted 82 passed; broader tests/config tests/slots tests/capabilities 834 passed / 5 skipped; ruff clean.

🤖 Generated with Claude Code

thinmintdev and others added 3 commits July 6, 2026 01:16
_flatten_slot_toml only hoisted slot fields out of a legacy [slot]
table, so flat top-level slot files (name/port/profile/device/runtime
as scalars) had their required `port` dumped into `extra` and failed
SlotConfig validation. This produced repeated profiles.in_use_scan_error
warnings and broke profile used_by / in-use delete guards.

Branch on shape: legacy nested [slot] files keep their exact behavior
(top-level siblings → extra); flat files hoist top-level scalars as slot
fields while sibling tables ([server]/[npu]/[image]/[defaults]) still
round-trip via extra. [model] stays nested and `name` still falls back
to the filename in both shapes.

Closes #1087

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Unblocks CI for #1129 — `ruff format --check` reported 1 file would be
reformatted. No semantic change, formatting only.
@thinmintdev thinmintdev merged commit 2ad0f91 into main Jul 6, 2026
3 checks passed
@thinmintdev thinmintdev deleted the fix/1087-flat-slot-toml-profile-scan branch July 6, 2026 09:06
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.

Support flat slot TOML shape in profile in-use scanning

1 participant