fix(device-plane): activate manager from reconciled baseline

This commit is contained in:
Codex
2026-08-11 01:12:44 +03:00
parent 04ba3a9f99
commit 8defd55715
5 changed files with 322 additions and 14 deletions
@@ -235,6 +235,68 @@ class DeviceManagerControlPlaneArtifactsTest(unittest.TestCase):
)
runtime_acceptance.assert_called_once_with()
def test_v2_activation_requires_exact_applied_reconciliation(self):
with tempfile.TemporaryDirectory(
prefix="nodedc-device-manager-v2-predecessor-",
) as directory:
root = Path(directory)
artifact = root / RUNNER.DEVICE_PLANE_MANAGER_RECONCILIATION_ARTIFACT
artifact_bytes = b"reviewed-reconciliation-artifact"
artifact.write_bytes(artifact_bytes)
state_file = root / "applied.jsonl"
state_file.write_text(
json.dumps({
"id": RUNNER.DEVICE_PLANE_MANAGER_RECONCILIATION_PATCH_ID,
"artifact": RUNNER.DEVICE_PLANE_MANAGER_RECONCILIATION_ARTIFACT,
"backup_id": (
RUNNER.DEVICE_PLANE_MANAGER_RECONCILIATION_APPLY_BACKUP_ID
),
"component": "device-plane",
"sha256": hashlib.sha256(artifact_bytes).hexdigest(),
"status": "ok",
}) + "\n",
encoding="utf-8",
)
backup = root / "failed-backup"
with (
mock.patch.object(RUNNER, "APPLIED_DIR", root),
mock.patch.object(RUNNER, "STATE_FILE", state_file),
mock.patch.object(
RUNNER,
"DEVICE_PLANE_MANAGER_RECONCILIATION_ARTIFACT_SHA256",
hashlib.sha256(artifact_bytes).hexdigest(),
),
mock.patch.object(
RUNNER,
"validate_device_plane_manager_control_plane_payload",
return_value=(
RUNNER.expected_device_plane_manager_control_plane_descriptor()
),
) as payload,
mock.patch.object(
RUNNER,
"validate_device_plane_manager_reconciliation_backup",
return_value=backup,
),
mock.patch.object(
RUNNER,
"validate_device_plane_manager_reconciled_baseline",
return_value={"accepted": True},
) as baseline,
):
result = (
RUNNER.validate_device_plane_manager_activation_predecessor(
root / "payload"
)
)
self.assertEqual(
result["mode"],
"reconciled-manager-forward-activation",
)
payload.assert_called_once_with(root / "payload")
baseline.assert_called_once_with(backup, marker_installed=True)
def test_initial_install_rollback_removes_manager_and_restores_core_only(self):
entries = RUNNER.DEVICE_PLANE_MANAGER_CONTROL_PLANE_ENTRIES
missing = {