fix(config): support flat slot TOML shape in profile in-use scanning#1129
Merged
Conversation
_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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,runtimeas scalars), every top-level scalar was dumped intoextra, so the requiredportnever reached the top level andSlotConfigvalidation failed. Result: repeatedprofiles.in_use_scan_errorwarnings, emptyused_by, and a broken in-use delete guard.Fix
_flatten_slot_toml()now branches on shape:[slot]table present): unchanged — hoist[slot], all other top-level siblings (incl. stray scalars) →extra, so existing round-trips are byte-identical.[slot]table): hoist top-level scalars as slot fields; sibling tables ([server],[npu],[image],[defaults], …) still land inextraand are promoted by the existing_hoist_*_from_extravalidators.[model]stays nested andnamefalls back to the filename in both shapes.extracollection is consume-based so nothing is dropped or duplicated.Acceptance criteria
load_slot_config()accepts flat top-levelname/port/profile/device/runtime(+ sibling tables).load_slot_config()still accepts legacy[slot]TOMLs.profiles.in_use_scan_errorfor valid flat slot TOMLs.used_by/ in-use detection reports slots for flat TOMLs.profiles.in_use).Tests
tests/config/test_loader.py: flat TOML loads all fields; flat sibling tables land typed (server) / inextra(defaults); flat TOML infersnamefrom filename.tests/api/test_profiles_crud.py:_seed_flat_slot_tomlhelper +test_delete_in_use_409_flat_slot_toml(409 guard + populatedused_by).Targeted 82 passed; broader
tests/config tests/slots tests/capabilities834 passed / 5 skipped;ruffclean.🤖 Generated with Claude Code