Repository navigation
fix: keep a running model download's status when a custom model is set - #35634
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. This is a one-condition fix at the write that caused the overwrite. The linked issue and a new test pin the defect, and the spec line is the mandated same-commit update. What this change shipsInventory (3 items) — 3 justifiedIntent: keep a running bundled embedding-model download reporting its own step and attempt when someone configures a custom model mid-download. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 53bfe8f Description read[DESCRIPTION-READ] cf7b7404571fc9fe1071b0a276b792760f8ab71c91df73c56513597f1c29c104 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the guard sits in [DESIGN-REVIEWED] 53bfe8f Description read[DESCRIPTION-READ] 7fe47107c1673580abc87fa0576a92b47584a8c8a95af98103067a9e0f6c851c That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
buluoray
left a comment
There was a problem hiding this comment.
Approve on 256684e. When a custom embedding model is configured while the bundled model is still downloading, a second setup call no longer overwrites the running download's step and attempt. The check and the write run on the event loop with no await between them, so the download thread cannot slip in between. The return value and the custom-model step written when no download runs are unchanged. The new test holds a real download mid-transfer, turns red when the guard is removed, and waits on events rather than sleeping. No security surface is touched. Decisive lines: src/kiro_crew/embeddings_download.py:183-184, test/test_custom_embedding_model.py:479-507
ModelDownloadManager.ensure_model wrote step custom_model before it took the download lock, so a call that found a custom embedding model configured while the bundled model was still downloading replaced that download's status with custom_model until the download wrote it again, and the attempt number the download carries forward was lost. The custom-model branch still returns False, but it writes its status only when no download holds the lock; a running download keeps the status it owns until it ends. Closes #34429
256684e to
53bfe8f
Compare
|
Rebased: main moved in docs/system-specs/modules/memory-skills-hooks.md (plus 288 files in the directories this PR touches) since this head's CI ran (f9788c5 -> e47278c); CI re-running. The four red backend shards on 256684e failed two tests that were red on main itself, [operator: bolichen97] |
Problem / Motivation
Goal: A bundled embedding-model download that is already running keeps reporting its own progress when a custom embedding model is configured while it runs.
ModelDownloadManager.ensure_modellets concurrent callers share one in-flight download, and that download owns the manager'sstatuswhile it holds the lock. The custom-model check breaks this: whenmemory.embed_model_pathis set while the bundled model is still downloading, a secondensure_modelcall writescustom_modelwithattempt: 0over the running download's status. The embedding status then readsdownload_step: custom_model; the next progress update restores the step but keepsattempt: 0for the rest of that attempt, and during a retry backoff nothing restores it until the next attempt starts.Why it matters
The embedding-status endpoint reports this status as
download_stepanddownload_attempt, and the Enable handler reads it to decide whether a download is already in flight. The Memory card does not show the wrong step, because with a custom model configured it takes its step from the custom file instead. Today the one caller that can reach the overwrite is the dashboard's Enable/Retry, and only when the configured custom file is missing or unreadable (otherwise it never callsensure_model) and the click lands between a download taking the lock and writing its first step (otherwise it adopts the running download); the download then reportsattempt: 0for the rest of its first attempt.ensure_modelis what promises concurrent callers one shared download, so the status guarantee belongs there rather than in each caller's own check. Low severity: the download itself is not affected.Not a goal
False), or thecustom_modelstep it reports when no download is running.stt/models.py), which is Voice settings show the wrong model: a custom-model check overwrites a running download's status #34431.What changed (motivation → approach → change)
A running bundled download now keeps reporting its own step and attempt when a custom embedding model is configured while it runs.
The overwrite came from the custom-model check in
ModelDownloadManager.ensure_model(embeddings_download.py): it wrotestatusbefore taking the download lock, while the running download writes that samestatusunder the lock. The check now writescustom_modelonly when no download holds the lock. It still returnsFalseand never starts the bundled download. The memory-skills-hooks spec states the rule.Backwards compatibility
Compatible: the return value is unchanged, and so is every status written when no download is running; only an overwrite of a running download's status is dropped.
Removes nothing: no key, record, path or function goes away, and the
custom_modelstep is still written whenever no download holds the lock.Tests
test_refusal_leaves_a_running_download_status_alone(test/test_custom_embedding_model.py): a bundled download blocked mid-transfer holds the lock withstep: downloading; a secondensure_modelafter a custom model is configured returnsFalse, the step staysdownloading, and the download then finishesready.test_interactive_download_refusesstill pinscustom_modelwhen no download is running.Proof: PROVEN test/test_custom_embedding_model.py::TestDownloadSuppression::test_refusal_leaves_a_running_download_status_alone (head 53bfe8f)
Determinism, on Linux at this head:
-n0test/test_custom_embedding_model.pyandtest/test_embeddings_download.py, 10 repeats,-n 4 --dist loadgroup --max-worker-restart=2-n0Manual verification
N/A — unit coverage sufficient: the overwrite is one in-process status write, and the test reproduces it with a real download thread held mid-transfer.
Screenshots / video
N/A — backend-only change; no dashboard file is touched.
Related Issues
Closes #34429
Sibling sweep
Swept: git grep -nE "status = {" -- src/kiro_crew/embeddings_download.py
Sibling: src/kiro_crew/embeddings_download.py:184 -- changed here
Sibling: src/kiro_crew/stt/models.py:964 -- not affected -- #34835 (closing #34431) fixed it on main, which this branch carries
Sibling: src/kiro_crew/stt/decoder.py:412 -- not affected -- its pre-lock write fires only when KIROCREW_SKIP_MODEL_DOWNLOAD=1, and then no fetch ever starts
The other two pre-lock writes in
embeddings_download.py,readyat lines 173 and 387, are not in the class: each fires only when the bundled file is already installed, the step a finished download reports.Pattern harvest
Rule candidate: review-prompt
Pattern: "a caller writes a status field that a lock-holding task owns, before taking that lock"
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)