Repository navigation
fix(update): copy memory before the unattended policy-provider apply - #23760
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change adds the same copy-or-skip step the other appliers already take to the one unattended applier that lacked it, and the placement test now enforces it. Notes
[DESIGN-REVIEWED] 7de4bc3 Description read[DESCRIPTION-READ] 0c6f59cbc41ed93744fbd90029dfddfc0c899823d06763657d47db157a41ab58 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The gap comes from issue #21898 and is pinned by the placement test. One note: the refusal block is now written out twice. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: a policy-managed host updating itself unattended always has a fresh memory copy to restore from. FIX.
[FIRST-PRINCIPLES-REVIEWED] 7de4bc3 Description read[DESCRIPTION-READ] 1e144f3236c3d3137fc25387fb8cc0a7f642f0a967a82f680fb70d4bc34b00ee That sha256 names the PR description this verdict read. 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: |
|
Review-ready at head 7de4bc3.
The First Principles note (the skip block repeats the one in update_apply.py) is a non-blocking note. I left it so this PR stays the same shape as #21873's git path. Waiting on a maintainer review. I will not merge, approve or arm auto-merge. 🤖 AI-assisted comment 🤖 |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the unattended policy-provider update path now takes the same pre-update memory copy as the other update paths, and skips the apply when the copy fails; one source file plus tests.
Problem / Motivation
Goal: The gateway's unattended policy-provider update takes a fresh copy of every memory store before it rewrites the install, and skips the update when that copy fails.
On a host whose security policy sets an
apply_command,_check_for_updates_via_providerrunsprovider.apply()for the mandatory min_version floor and for voluntary auto-update. Neither call takes the pre-update memory copy thatkirocrew update, the dashboard apply button and the git auto-update take. So the gateway can rewrite the install with no fresh copy of any memory store.Why it matters
Memory stores are the one thing nothing else can rebuild. A policy-managed host updates itself with nobody watching, so a bad update there could leave the user with no recent copy to restore from.
Not a goal
update_provider.apply_policy_update/ the provider'sapply()) and removing the caller-side copies in the dashboard and CLI. See "Decision" below.What changed (motivation → approach → change)
Symptom: the policy-provider applier was the one unattended applier with no pre-update memory copy. Cause: the copy lives at each caller, and this caller never got one.
Change: before each of the two
provider.apply()calls, the gateway runswheel_apply.snapshot_memory_before_update. If it fails, the update is skipped the same way the git auto-update skips it: a warning in the log, one dashboard notice, and afailedprogress line built bywheel_apply.snapshot_refusal. It never applies blind and never exits the gateway; the next check tries again. The apply slot is still released. The failure text is redacted and capped at 500 characters before it is shown, like the git path.The placement test (
test/test_update_memory_copy_placement.py) now scansslack/gateway_runtime/update_schedule.pyand countsprovider.apply()as a rewrite. A nested copy helper's own body does not count as a copy site, so eachprovider.apply()needs its own call to the helper.Decision. The issue lists two levels. This PR takes the caller-side one, matching how #21873 covered the dashboard and git appliers. It is the smaller change, it touches only the unattended path, and each caller keeps its own way of reporting a refusal (the CLI exits, the dashboard returns 500, the gateway posts a notice). The seam move changes the CLI and dashboard paths too, and the seam has no caller-neutral way to report a refusal, so it is left for a maintainer to rule on.
Backwards compatibility
Compatible: an update that copies memory successfully applies exactly as before; only an update whose copy fails is now skipped instead of applied.
Removes nothing: no key, path, record or public function is removed; the only new behaviour is a skip when the memory copy fails.
Tests
test/test_slack_gateway_update_provider_snapshot.py: for both sites (min_version floor and auto-update), the copy runs beforeprovider.apply(); a failed copy skips the apply, skips the restart, releases the apply slot, and posts the notice and thefailedprogress line.test/test_update_memory_copy_placement.py: pins_check_for_updates_via_provideras a known applier. Removing either helper call fails it.Proof: PROVEN test/test_slack_gateway_update_provider_snapshot.py::test_the_memory_copy_runs_before_the_provider_apply[min_version-floor], test/test_slack_gateway_update_provider_snapshot.py::test_the_memory_copy_runs_before_the_provider_apply[auto-update], test/test_slack_gateway_update_provider_snapshot.py::test_a_failed_copy_skips_the_apply_and_says_so[min_version-floor], test/test_slack_gateway_update_provider_snapshot.py::test_a_failed_copy_skips_the_apply_and_says_so[auto-update], test/test_update_memory_copy_placement.py::test_every_rewrite_is_preceded_by_the_memory_copy[slack/gateway_runtime/update_schedule.py::_check_for_updates_via_provider] (head 7de4bc3)
Mutant check: replacing either
if not await _snapshot_memory_or_skip(result):withif False:fails the behaviour test for that site and the placement test.Manual verification
N/A — unit coverage sufficient: both call sites and the refusal path are driven directly with a real
CommandProviderand a stubbed copy step.Related Issues
Closes #21898
Sibling sweep
Swept: git grep -nE "provider.apply(|apply_policy_update(" -- src/
Sibling: src/kiro_crew/cli_server_update.py:109 -- not affected --
_updateruns_snapshot_memory_or_exitbeforeapply_policy_updateSibling: src/kiro_crew/dashboard/handlers/updates_apply.py -- not affected --
api_update_applyruns_snapshot_memory_or_refusebefore the tracked policy applySibling: src/kiro_crew/platform/update_provider.py:561 -- not affected -- the seam itself; its two callers above copy first
Sibling: src/kiro_crew/slack/gateway_runtime/update_schedule.py -- changed here
Pattern harvest
Rule candidate: lint
Pattern: a call that rewrites the install with no memory copy since the previous rewrite; the placement test already enforces this, and this PR adds the provider path to its scan.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)