Repository navigation
fix(store): close the retained update policy edge cases - #1293
Conversation
…stored An inventory pass or snapshot that lists a replacement flags the removal of its predecessor as replacementExpected, even when a real-time dd:container-added already stored the replacement and it inherited the update policy on insert. The unguarded stash then sat under the identity key and handed the policy to the next recreate, after the user had cleared it. deleteContainer now skips that stash for an agent-owned record when a same-identity, same-name record is still stored. The removal event keeps replacementExpected, so HA/MQTT discovery for the live replacement is untouched, and controller-local records keep the unconditional stash. Refs: #1280
Replicas of one compose service share the compose:project/service identity key, so after a compose down/up the policy one replica stashed could be taken by whichever replica was re-added first. A stash now records the canonical container name, and an agent-owned insert only takes an identity-key entry recorded under its own name, leaving another replica's entry for that replica. The name is persisted in a new nullable update_policy_retention_cache.container_name column (schema migration 5) and carried by the legacy store importer when present. An entry written before this change has no name. Under a compose key it is consumed and dropped, since applying it could misapply another replica's policy and dropping it only loses a policy in flight across the upgrade. Under a plain identity key the key already names the container, so it is still applied. Controller-local inserts keep the name-agnostic match that carries a policy across a compose rename. Refs: #1280
An insert that found entries under both its identity key and its Docker id took the identity entry whenever one existed. After an agent to controller to agent move, that entry is the one the first move left behind, so it shadowed the policy the controller held when the container moved back. An expired identity entry also dropped a valid id entry. The insert still takes both entries, now discards expired ones and restores the entry stashed last, by expiresAt since every stash uses the same TTL. A tie, one delete stashing both keys, keeps the identity entry. Refs: #1280
deleteContainer ran the identity-sibling lookup on every agent removal, even for a record with no update-policy overrides, where the stash it guards is a no-op. The lookup now runs only when there is something to retain. The lookup filters on watcher and COALESCE(agent, ''), and the only index that served it was containers_watcher_status, which narrows to the watcher name (shared by every agent's local watcher) and then sorts by rowid. Schema migration 6 adds containers_watcher_agent on (watcher, COALESCE(agent, '')), which matches both terms and keeps rowid order, so the lookup on agent-owned inserts reads one watcher on one agent with no sort. Refs: #1280
…check The September runtime floor check split entry.version on every lockfile entry whose path matched a floored package, so a link entry (link: true, no version) failed the suite with a bare TypeError instead of a finding. Entries without a version are now skipped, and versioned entries keep the vetted-major and floor checks. The check moved into a helper so a node:test case can cover both paths against a fixture lockfile. Refs: #1280
…skip A watcher snapshot that lists a replacement already stored by an earlier dd:container-added flags its predecessor's prune as replacementExpected, the same shape as the inventory pass. The test fails without the deleteContainer guard and pins that the snapshot path leaves no stash behind either. Refs: #1280
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
⛔ Files ignored due to path filters (1)
📒 Files selected for processing (10)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe store now records container names with retained update policies and uses them when matching agent-owned compose replacements. Deletion and restoration logic handles empty overrides, identity siblings, expired entries, and entries keyed by both identity and container ID. Tests cover cache migration, imports, agent reconciliation, and replacement scenarios. The security-floor test helper skips lockfile entries without string versions. Possibly related PRs
Priority: ⬇️ Low Change: Bug fix Merge Risk: ⚪ Minimal · up to The change tightens how retained update policies are matched and persisted, and adds migrations and tests for it. No concrete merge-blocking problem was identified in the supplied material. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The changes strengthen policy matching and prevent cleared overrides from returning after replacement. No introduced authorization bypass was established. Remaining risk concerns upgrade compatibility and incomplete assurance around interrupted policy transfers. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Follow-up to #1290 for the update-policy retention edge cases its review turned up. All on 1.8; refs issue 1280.
replacementExpected: trueon that removal.container_namecolumn), and an agent-owned insert only takes an identity-key entry with its own name.expiresAt, so a changed retention TTL can't flip the order.(watcher, COALESCE(agent, ''))so it no longer scans every agent'slocalwatcher. A test pins the query plan.scripts/security-dependency-versions.test.mjsskips lockfile entries with no version instead of throwing.Deliberate trade-offs, written down on the roadmap: an agent compose container recreated under a different container name no longer inherits through the shared key (controller-local still does), and nameless stash entries written by 1.7 under an agent compose key are dropped on first read.
Checked locally: full pre-push gate with coverage thresholds met. One independent review pass; its coverage gap and TTL-ordering findings are fixed in the last two commits.
✨ Added
containerName, including import, persistence, migration, and legacy-record handling.🔧 Changed
containers(watcher, COALESCE(agent, '')).🐛 Fixed
UpdatePolicyRetentionCacheRecordadds the optionalcontainerNameproperty.Concerns