Promote a scheme to user-authored on approve or edit (#99) #112
No reviewers
Labels
No labels
area/ai
area/backend
area/frontend
area/infra
area/scheduler
area/wled
good-first-issue
priority/high
priority/low
priority/medium
type/bug
type/chore
type/ci-cd
type/docs
type/feature
type/qa
v1.0.0
v1.1.0
v1.2.0
v2.0.0
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rbrooks/Iris-WLED!112
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/scheme-source-promotion"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #99.
What was wrong
Only
communitywas promoted, which had two consequences:An approved AI suggestion kept
source: "ai"forever. Spec §3.3 layer 4 says it is "promoted to source 1" — it never was. The calendar's "AI-sourced" filter matchessource === "ai", so a scheme the user had reviewed and adopted stayed in the review queue permanently and the filter never drained. That is the only thing the filter exists to do.PUT /schemes/{id}never touchedsourceat all, so a scheme whose colours, effect, speed and label had all been replaced still reported the template that contributed nothing to the result.A third thing found while fixing it
The rule was duplicated —
approve_schemeandbulk_approveeach spelled out the sameif source == "community"check, so the bug existed in two places and any fix had to be made twice. It now lives in one_mark_user_authoredhelper used by approve, bulk approve and update.The open question, decided
#99 left open whether approving an untouched
builtinshould promote. It does, for two reasons beyond the spec wording:scheme_generator.py:123already marks a scheme carried forward from an approved prior occurrence asuser. So leaving this year's approved copy asbuiltinwhile next year's regenerated copy saidusercontradicted the generator's own convention.Recorded in spec §3.3 rather than left implicit in the code, since that was the actual failure here — the spec and the implementation disagreed and nothing said so.
Also
The edit audit entry now carries
sourceinbefore/after, so the promotion shows up in the trail instead of being a silent side effect of an unrelated edit.Verification
ruff,ruff format,mypyclean; all seven pre-commit hooks pass.builtin/fallback/community/ai.aischeme is in the AI-filtered set before approval and out of it after.No frontend change needed:
SidePanel'ssource.includes("user")badge and theaifilter both start behaving correctly once the backend stops lying about provenance.🤖 Generated with Claude Code
Only `community` was promoted. Two consequences: - Spec §3.3 layer 4 says an approved AI suggestion is "promoted to source 1". It never was, so it kept `source: "ai"` permanently. The calendar's "AI-sourced" filter matches on that, so a scheme the user had reviewed and adopted stayed in the review queue forever and the filter never drained -- the only thing it exists to do. - `PUT /schemes/{id}` never touched `source` at all, so a scheme whose colours, effect, speed and label had all been replaced still reported the template that contributed nothing to the result. The promotion rule was also duplicated: `approve_scheme` and `bulk_approve` each spelled out the same `if source == "community"` check, so any fix had to be made twice. It now lives in one `_mark_user_authored` helper used by approve, bulk approve, and update. Approving promotes regardless of origin. Spec §3.3 source 1 is "schemes the user has explicitly saved *or approved*", and `scheme_generator` already marks a scheme carried forward from an approved prior occurrence as `user` -- so leaving this year's approved copy as `builtin` while next year's said `user` contradicted the generator's own convention. Recorded in the spec rather than left implicit in the code. The edit audit entry now includes `source` in before/after, so the promotion is visible in the trail rather than being a silent side effect. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>