fix(node): clarify wireless enrollment and restore active K1 after upgrade

This commit is contained in:
DCCONSTRUCTIONS
2026-09-07 13:02:28 +03:00
parent ef1c1f50de
commit 5c4546a2a6
10 changed files with 229 additions and 18 deletions
@@ -130,3 +130,29 @@ test('a confirmed scan with zero candidates remains a valid empty result',async(
})};
assert.deepEqual((await api.enroll(transport,initial,'scan')).candidates,[]);
});
test('finishing enrollment requires a verified current device session and survives no stale fence',()=>{
const connected={...initial,connected:true,discovery_generation:3,mode_revision:2,
device_session:{device_session_id:'session-one'},command_result:{status:'succeeded'}};
assert.equal(api.enrollmentProof(initial,'synthetic-ble'),null);
const proof=api.enrollmentProof(connected,'synthetic-ble');
assert.ok(proof);
assert.equal(api.enrollmentProofCurrent(proof,connected,'synthetic-ble'),true);
for(const patch of [{fresh:false},{available:false},{connected:false},{runtime_id:'other-runtime'},
{discovery_generation:4},{mode_revision:3},{selected_device_id:'other-device'},
{device_session:{device_session_id:'other-session'}},{command_result:{status:'rejected'}}]){
assert.equal(api.enrollmentProofCurrent(proof,{...connected,...patch},'synthetic-ble'),false);
}
assert.equal(api.enrollmentProofCurrent(null,connected,'synthetic-ble'),false);
assert.equal(api.enrollmentProofCurrent(proof,connected,'other-device'),false);
});
test('lost BLE candidate tells the operator to rescan without blaming Ethernet or Wi-Fi credentials',()=>{
const notice=api.enrollmentNotice({...initial,connection_attempt:{
schema_version:'missioncore.xgrids-k1-connection-attempt/v1',attempt_id:'test',status:'failed',
public_error_code:'network-provision-candidate-not-fresh',
}});
assert.match(notice,/Найдите K1 ещё раз/);
assert.match(notice,/Настройки Wi-Fi не были отправлены/);
assert.doesNotMatch(notice,/пароль|Ethernet/);
});
+1 -1
View File
@@ -11,7 +11,7 @@ import sys
ROOT = Path(__file__).resolve().parents[1]
VERSION = "0.8.2"
VERSION = "0.8.3"
sys.path.insert(0, str(ROOT.parents[1] / "scripts/packaging"))
from debian import package
+8
View File
@@ -15,6 +15,14 @@ case "$1" in
systemctl enable mission-core-node.service
systemctl restart mission-core-node.service
systemctl try-restart mission-core-realsense.service
if [ -f /run/mission-core-node-k1-upgrade-active ]; then
# A jointly upgraded plugin starts itself after its own configuration.
# Restore it here only when that package is already configured.
if [ "$(dpkg-query -W -f='${Status}' mission-core-xgrids-k1 2>/dev/null || true)" = "install ok installed" ]; then
systemctl start mission-core-k1.service
fi
rm -f /run/mission-core-node-k1-upgrade-active
fi
fi
;;
esac
+4 -1
View File
@@ -28,7 +28,10 @@ if [ "$1" = install ] || [ "$1" = upgrade ]; then
esac
# End the admitted idle worker before dpkg replaces its Python modules.
# New UI commands now fail unavailable instead of racing the package copy.
if [ -f /usr/lib/systemd/system/mission-core-k1.service ]; then
if systemctl is-active --quiet mission-core-k1.service; then
# Preserve an optional worker's prior running state across a Node-only
# update. /run is root-owned; the plugin still owns initial activation.
(umask 077; : > /run/mission-core-node-k1-upgrade-active)
systemctl stop mission-core-k1.service
fi
fi