WeKnora/migrations/versioned/000104_skill_served_version...

4 lines
147 B
MySQL
Raw Normal View History

fix(skills): upgrade outdated sandbox skills without rolling back the catalog or taking them offline (#3406) * fix(skills): keep retries and catalog installs from rewriting the skill definition Every install path wrote its archive back to the workspace catalog. After a skill was re-registered as v2, sandboxes still on v1 are pinned to v1's archive, so retrying one of them (a failed retry, or a ready skill retried with guidance) reinstalled v1 and also moved the catalog definition back to v1 and deleted v2's archive. Installs now carry where their archive came from. Only an upload or a source pull is a new definition; a retry or a catalog install uses bytes the workspace already stores and never rewrites the definition. A retry of a pinned install keeps its pin and replays its own version, and bytes that neither the definition nor the row holds are refused with a conflict. The catalog listing also reports each installation's version so the UI can show what an upgrade moves from and to. * feat(frontend): upgrade outdated skill installs from the catalog, sandbox drawer and agent editor An install whose archive differs from the catalog was flagged as outdated, but nothing could move it to the catalog version: the install drawer hid ready installs, and the manage drawer only offered a retry, which replays the sandbox's own archive. - Skill settings: cards with outdated installs show an upgrade button that opens the install drawer with every outdated sandbox preselected. The add wizard and install drawer also let outdated ready installs be picked, labelled with the version they move from and to. - Sandbox skill drawer: an outdated skill shows a "new version" row whose upgrade button installs the catalog onto that one sandbox. - Agent editor: skills on the chosen sandbox that are outdated show the version change and an upgrade button, both for admins only, matching the admin-only catalog install. The install progress entry, which opens a drawer backed by admin-only endpoints, is now admin-only too. - A skill that is being upgraded is no longer pruned from the agent's selected skills while it is briefly not ready. The outdated check is shared in utils/skillUpgrade.ts. * feat(skills): keep the previous version serving while an upgrade runs or after it fails An install rewrote the row to the new version and marked it installing as soon as it started, and the agent is only offered ready rows. So an upgrade took the skill away from every sandbox for its whole run, and a failed upgrade kept it away, even though the image pointer only moves on success and the previous version was in the image the whole time. The row now records what it described when it was last ready (served: version, description, instructions, digest, the archive its files come from, and the snapshot that installed it). The agent's usable set, member env acceptance and the @-mention list read TenantSkillEntity.ServedView, which is that version marked ready while the row is installing or failed. A successful install clears it and releases its archive; a failure or a stop keeps it. Keeping that consistent: - The served archive counts as a reader when a bundle is released or replaced by a re-registered catalog, so v1's files stay readable while v2 installs. - The reaper and a failed removal put the served version back when the image never moved past it, instead of labelling v1's files with the upgrade's metadata. A stuck upgrade whose chain cannot be read is left alone, since v1 keeps serving meanwhile. - The env declaration is stored after the pointer moves rather than before the snapshot, so an upgrade that fails late cannot drop the admin value of a variable the previous version still reads. Migration 000104 adds tenant_skills.served. The console says "upgrading, still running 1.1.0" or "upgrade failed, still running 1.1.0", the agent editor keeps such skills selectable, and the upgrade texts no longer warn that the skill goes offline. * fix(skills): offer only the upgrade to installs the catalog has moved past Review follow-up on the upgrade flow. - An install that differs from the catalog, ready or failed, is now offered the upgrade and not the retries. The retry icon and the retry-with-guidance box both replay the archive the install is pinned to, so next to an Upgrade button they reinstalled the version the operator came to leave behind. A failed first install of v1 whose catalog has since moved to v2 used to retry v1 from the drawer while the agent editor's Install went to v2; every entry now goes to v2, and the agent editor labels it "Upgrade". The drawer explains that the failed install is replaced by the catalog version. - A catalog install or a retry reuses the definition that already holds its bytes instead of re-running the catalog upsert, which rewrote the row and bumped its updated_at every time the skill was installed somewhere. The upsert still runs for a definition that does not exist yet or whose object was lost.
2026-09-18 12:27:43 +00:00
DO $$ BEGIN RAISE NOTICE '[Migration 000104 down] Dropping tenant_skills.served'; END $$;
ALTER TABLE tenant_skills DROP COLUMN IF EXISTS served;