fix(config): harden model validation and config type-checking (#128)#169
Merged
Conversation
Prevents the config-corruption cascade a first-time user hit by answering `yes` to the free-text model prompt in `openkos init`. - validate_model now rejects YAML 1.1 reserved boolean/null words (yes/no/true/false/on/off/null, case-insensitive) via an exact-token check applied before the character allowlist; tags that merely contain a reserved substring (yesmodel, on-prem) are still accepted. - read_config now enforces that a present `model`/`embedding_model` value is a str, raising ValueError with actionable messaging on a non-str (e.g. a bool from a YAML round-trip); null/absent still falls back to defaults and unrelated bool fields are untouched. - doctor no longer crashes with a TypeError on a non-str model: the read_config guard is fully subsumed at the config layer, so its config-valid check reports [FAIL] with remediation instead of a traceback. Regression tests cover both fields. Advances #128 (Slice A: config hardening); the interactive model picker remains as a follow-up slice.
jasonssdev
added a commit
that referenced
this pull request
Jul 25, 2026
Merge the workspace-init and doctor-command delta specs into the main specs tree and move the change folder to the archive. Closes the SDD cycle for the config-hardening slice (implemented, verified PASS, reviewed 0 findings, merged via #169). Advances #128; the interactive model picker (Slice B, init-model-picker) remains active.
This was referenced Jul 25, 2026
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.
Summary
Slice A of #128. Fixes the config-corruption cascade a real first-time user hit on published 0.1.1 by answering
yesto the free-text model prompt inopenkos init—model: yesround-tripped through PyYAML as the booleanTrue, silently corruptingopenkos.yaml, crashingopenkos doctor, and making every LLM call fail with an opaque 400.Three independent hardening defects, all closed at the config layer:
validate_modelrejects YAML 1.1 reserved words —yes/no/true/false/on/off/null(case-insensitive), via an exact-token frozenset check applied before the character allowlist. Tags containing a reserved substring (yesmodel,on-prem) are still accepted.read_configtype-checksmodelandembedding_model— a present non-strvalue raisesValueErrorwith actionable messaging;null/absent still falls back to defaults, and unrelated bool fields (e.g.review: false) are untouched.doctorno longer crashes on a non-str model. Theread_configguard fully subsumes theTypeErroratmodel_tag_matches(verified by control-flow trace: a raisingread_configleavescfg = None, so the checks fall back to valid default tags). No production change tomain.py/ollama.py— only a regression test.Scope
Production change is a single file:
src/openkos/config.py(+24). Tests:test_config.py(+98),test_doctor.py(+52).Verification
uv run pytest: 2089 passed, exit 0uv run ruff check . && uv run ruff format --check .: cleanuv run mypy .: cleanStrict TDD throughout (RED confirmed for the right reason before each GREEN, including a
git stashto prove the doctorTypeErrorpre-fix).Issue
Advances #128 (Slice A: config hardening). Does not close it — the interactive model picker (Slice B) remains as a follow-up.