test(plugins): cover skill mirror lifecycle
This commit is contained in:
@ -271,6 +271,8 @@ class PluginManager:
|
||||
current = self.skill_store.read_published_skill(declaration.name)
|
||||
if current is None:
|
||||
continue
|
||||
if self._reconcile_published_update(binding, current.version, snapshot.skill_tree_hash):
|
||||
continue
|
||||
classification = classify_plugin_skill_update(
|
||||
binding.accepted_upstream_tree_hash,
|
||||
current.version.tree_hash,
|
||||
@ -317,6 +319,33 @@ class PluginManager:
|
||||
finally:
|
||||
transaction.cleanup()
|
||||
|
||||
def _reconcile_published_update(
|
||||
self,
|
||||
binding: PluginSkillBinding,
|
||||
current_version: SkillVersion,
|
||||
observed_upstream_tree_hash: str,
|
||||
) -> bool:
|
||||
if not binding.pending_candidate_id:
|
||||
return False
|
||||
candidates = self.learning_store.list_learning_candidates()
|
||||
candidate = next(
|
||||
(item for item in candidates if item.candidate_id == binding.pending_candidate_id),
|
||||
None,
|
||||
)
|
||||
if candidate is None or candidate.status != "published":
|
||||
return False
|
||||
candidate_hash = str(candidate.evidence.get("new_upstream_tree_hash") or "")
|
||||
version_hash = str(current_version.provenance.get("new_upstream_tree_hash") or "")
|
||||
if not candidate_hash or candidate_hash != observed_upstream_tree_hash or version_hash != candidate_hash:
|
||||
return False
|
||||
binding.accepted_upstream_tree_hash = candidate_hash
|
||||
binding.observed_upstream_tree_hash = candidate_hash
|
||||
binding.accepted_beaver_version = current_version.version
|
||||
binding.current_beaver_version = current_version.version
|
||||
binding.pending_candidate_id = None
|
||||
binding.status = "synced"
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def _create_update_candidate(
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user