diff --git a/infra/deploy-runner/nodedc-deploy b/infra/deploy-runner/nodedc-deploy index 468a5ee..880899e 100755 --- a/infra/deploy-runner/nodedc-deploy +++ b/infra/deploy-runner/nodedc-deploy @@ -8,6 +8,7 @@ import grp import hashlib import http.client import io +import itertools import json import os import pwd @@ -2960,6 +2961,11 @@ GITEA_SALVAGE_UNSUPPORTED_SCHEMA_TABLES = tuple( ) COMPONENTS = { + "device-core-release-drift-audit": { + "payload_root": DEVICE_PLANE_ROOT, + "artifact_only": True, + "services": (), + }, "device-core-release-reconciliation": { "payload_root": DEVICE_PLANE_ROOT, "artifact_only": True, @@ -4968,6 +4974,10 @@ def denied_payload_path(component, rel): def allowed_payload_path(component, rel): validate_posix_path(rel) + if component == "device-core-release-drift-audit": + if rel in ("deployment", DEVICE_RELEASE_DRIFT_AUDIT_ENTRY): + return True + die("Device Core drift audit accepts only its exact descriptor") if component == "device-core-release-reconciliation": if rel in ("deployment", DEVICE_RELEASE_RECONCILIATION_ENTRY): return True @@ -11588,6 +11598,8 @@ def load_artifact(artifact, work_dir): die(f"files.txt entry missing in payload: {rel}") validate_payload_tree(manifest["component"], payload_dir, entries) + if manifest["component"] == "device-core-release-drift-audit": + validate_device_release_drift_audit_payload(payload_dir, entries, manifest["id"]) if manifest["component"] == "device-core-release-reconciliation": validate_device_release_reconciliation_payload(payload_dir, entries, manifest["id"]) if manifest["component"] == "device-core-release": @@ -22440,6 +22452,10 @@ def is_platform_provider_catalog_only(entries): def component_services(component, entries=None): + if component == "device-core-release-drift-audit": + if tuple(entries or ()) != (DEVICE_RELEASE_DRIFT_AUDIT_ENTRY,): + die("Device Core drift audit requires the exact descriptor entry") + return () if component == "device-core-release-reconciliation": if tuple(entries or ()) != (DEVICE_RELEASE_RECONCILIATION_ENTRY,): die("Device Core reconciliation requires the exact descriptor entry") @@ -32623,6 +32639,159 @@ def device_release_r5_reconciled(row): return True +# Diagnostic-only domain. Never used as a substitute acceptance fingerprint. +DEVICE_RELEASE_DRIFT_AUDIT_ID = "device-core-release-r5-drift-audit-v1-20260929-001" +DEVICE_RELEASE_DRIFT_AUDIT_ENTRY = "deployment/device-core-release-r5-drift-audit-v1.json" + + +def device_release_drift_audit_descriptor(): + return {"schemaVersion": "nodedc.device-core.release-drift-audit.v1", + "auditId": DEVICE_RELEASE_DRIFT_AUDIT_ID, + "failedReleaseId": DEVICE_RELEASE_R5_ID, + "failedSha256": DEVICE_RELEASE_R5_SHA, + "backupId": DEVICE_RELEASE_R5_BACKUP, "mode": "read-only-plan;apply-forbidden"} + + +def validate_device_release_drift_audit_payload(payload, entries, patch_id): + if tuple(entries) != (DEVICE_RELEASE_DRIFT_AUDIT_ENTRY,) or patch_id != DEVICE_RELEASE_DRIFT_AUDIT_ID: + die("Device Core drift audit identity/entry mismatch") + if read_strict_json(payload / DEVICE_RELEASE_DRIFT_AUDIT_ENTRY, "Device Core drift audit") != device_release_drift_audit_descriptor(): + die("Device Core drift audit descriptor mismatch") + + +def device_release_drift_fields(info): + # Exact preimage of the existing snapshot, deliberately not changing it. + host = json.loads(json.dumps(info.get("HostConfig") or {})) + if isinstance(host.get("Ulimits"), list): + host["Ulimits"].sort(key=lambda x: json.dumps(x, sort_keys=True)) + config = info.get("Config") or {} + fields = {"HostConfig": host, + "Config": {k: config.get(k) for k in ("Env", "User", "Cmd", "Entrypoint", "WorkingDir", "ExposedPorts")}, + "Mounts": sorted(info.get("Mounts") or [], key=lambda x: json.dumps(x, sort_keys=True)), + "networks": sorted((info.get("NetworkSettings") or {}).get("Networks") or {})} + if isinstance(fields["Config"]["Env"], list): + fields["Config"]["Env"] = sorted(fields["Config"]["Env"]) + return fields + + +def device_release_drift_digest(fields): + return hashlib.sha256(json.dumps(fields, sort_keys=True).encode()).hexdigest() + + +def device_release_drift_probe(fields, expected, budget=20000): + """Find an exact saved SHA preimage; report differences, never accept them.""" + current = device_release_drift_digest(fields) + result = {"expectedSha256": expected, "actualSha256": current, + "exactCurrentMatch": current == expected, "exactPreimageFound": current == expected, + "candidatesChecked": 1, "changedFields": [], "searchTruncated": False} + if current == expected: + return result + if not isinstance(expected, str) or not re.fullmatch(r"[a-f0-9]{64}", expected): + die("Device Core drift audit expected digest is invalid") + original = json.loads(json.dumps(fields)) + lists = [] + for name in ("Binds", "Mounts"): + value = original["HostConfig"].get(name) + if value is None: + lists.append((name, None)) + continue + if not isinstance(value, list) or len(value) > 8: + result["searchTruncated"] = True + result["reason"] = "mount-list-bound" + return result + encoded = [json.dumps(item, sort_keys=True) for item in value] + if len(set(encoded)) != len(encoded): + result["searchTruncated"] = True + result["reason"] = "ambiguous-duplicate-mounts" + return result + lists.append((name, value)) + actual_mode = original["HostConfig"].get("NetworkMode") + modes = [actual_mode] + [name for name in original["networks"] if name != actual_mode] + # Only permutations of observed values and attached-network names. This can + # identify a NetworkMode difference but cannot authorize changing/ignoring it. + work = json.loads(json.dumps(original)) + left, right = lists + for mode in modes: + if mode != actual_mode or "NetworkMode" in original["HostConfig"]: + work["HostConfig"]["NetworkMode"] = mode + for left_order in ([None] if left[1] is None else itertools.permutations(left[1])): + if left[1] is not None: + work["HostConfig"][left[0]] = list(left_order) + for right_order in ([None] if right[1] is None else itertools.permutations(right[1])): + if right[1] is not None: + work["HostConfig"][right[0]] = list(right_order) + if result["candidatesChecked"] >= budget: + result["searchTruncated"] = True + return result + result["candidatesChecked"] += 1 + if device_release_drift_digest(work) != expected: + continue + result["exactPreimageFound"] = True + result["changedFields"] = ["HostConfig." + key for key in ("Binds", "Mounts", "NetworkMode") + if work["HostConfig"].get(key) != original["HostConfig"].get(key)] + if mode != actual_mode: + result["currentNetworkMode"] = actual_mode + result["matchingSavedNetworkMode"] = mode + return result + return result + + +def device_release_drift_sample(): + inventory = device_plane_runtime_inventory(DEVICE_RELEASE_INVENTORY) + if set(device_plane_inventory_service_names(inventory)) != set(DEVICE_RELEASE_INVENTORY): + die("Device Core drift audit requires the exact five-service inventory") + samples = {} + for row in inventory["services"]: + fields = device_release_drift_fields(inspect_device_plane_container(row["containerId"])) + row["runtimeConfigSha256"] = device_release_drift_digest(fields) + samples[row["service"]] = {"runtime": row, "fields": fields} + return samples + + +def device_release_drift_audit(payload, entries, patch_id): + validate_device_release_drift_audit_payload(payload, entries, patch_id) + before = device_release_r5_evidence() + report = {"schemaVersion": "nodedc.device-core.runtime-drift-report.v1", + "mutation": False, "applyAllowed": False, "failedReleaseId": DEVICE_RELEASE_R5_ID, + "incidentEvidenceExact": True, "checks": {}, "services": {}} + + def check(name, operation): + try: + value = operation() + report["checks"][name] = {"ok": value is not False} + except Exception as exc: + # Never emit raw inspect, environment/secret values, or exception text. + report["checks"][name] = {"ok": False, "errorType": type(exc).__name__} + + check("source", lambda: collect_exact_files(DEVICE_PLANE_ROOT, DEVICE_RELEASE_ENTRIES[:-1], "Device Core drift source") == before["installedFiles"]) + check("noOrphanRelease", lambda: not (DEVICE_PLANE_ROOT / DEVICE_RELEASE_ENTRY).exists() and not (DEVICE_PLANE_ROOT / DEVICE_RELEASE_ENTRY).is_symlink()) + check("compose", lambda: {str(p): sha256_file(p) for p in component_compose_files("device-plane")} == before["compose"]) + check("health", lambda: run_healthchecks("device-core-release", DEVICE_RELEASE_ENTRIES, DEVICE_RELEASE_SERVICES)) + check("runtimeBoundaries", lambda: validate_device_manager_control_plane_runtime(require_edge_channel=True, core_network_mode="private-egress", require_persistent_data=True, read_only=True)) + check("otherComposeServices", lambda: device_release_other_compose_services() == before["otherComposeServices"]) + observations = [device_release_drift_sample() for _ in range(3)] + for service in DEVICE_RELEASE_INVENTORY: + saved = before["runtime"][service] + samples = [observation[service] for observation in observations] + row = samples[0]["runtime"] + fields = samples[0]["fields"] + proof = device_release_drift_probe(fields, saved["runtimeConfigSha256"]) + proof.update({"expectedImageId": saved["imageId"], "actualImageId": row["imageId"], + "imageMatches": row["imageId"] == saved["imageId"], + "samplesStable": all(sample == samples[0] for sample in samples), + "sampleCount": len(samples), + "sampleSha256": [sample["runtime"]["runtimeConfigSha256"] for sample in samples], + "healthReady": all(sample["runtime"]["running"] and sample["runtime"]["health"] in (None, "healthy") for sample in samples), + "preservedServiceExact": row == saved if service not in DEVICE_RELEASE_SERVICES else None, + "mountCounts": {key: len(fields["HostConfig"].get(key) or []) for key in ("Binds", "Mounts")}, + "fieldSha256": {section: {key: device_release_drift_digest(value) for key, value in fields[section].items()} + for section in ("HostConfig", "Config")}}) + report["services"][service] = proof + print("device_release_drift_audit=" + json.dumps(report, sort_keys=True, separators=(",", ":"))) + print("device_release_drift_audit_result=diagnostic-only;apply=forbidden;acceptance-barriers=unchanged") + return report + + def preflight_device_release(payload, entries, patch_id): d = validate_device_release_payload(payload, entries, patch_id) predecessor = device_release_predecessor(d) @@ -32742,6 +32911,9 @@ def plan_artifact(artifact): gitea_salvage_preflight = None with tempfile.TemporaryDirectory(prefix="plan-", dir=TMP_DIR) as tmp: manifest, entries, payload_dir = load_artifact(artifact, Path(tmp)) + if manifest["component"] == "device-core-release-drift-audit": + device_release_drift_audit(payload_dir, entries, manifest["id"]) + return if manifest["component"] == "device-core-release-reconciliation": preflight_device_release_reconciliation(payload_dir, entries, manifest["id"]) if manifest["component"] == "device-core-release": @@ -40040,6 +40212,8 @@ def apply_artifact(artifact): with tempfile.TemporaryDirectory(prefix=f"apply-{current_stamp}-", dir=TMP_DIR) as tmp: work = Path(tmp) manifest, entries, payload_dir = load_artifact(artifact, work) + if manifest["component"] == "device-core-release-drift-audit": + die("Device Core drift audit is plan-only; apply is forbidden") if is_gitea_fresh_install_slice( manifest["component"], entries, diff --git a/infra/deploy-runner/test_device_core_drift_audit.py b/infra/deploy-runner/test_device_core_drift_audit.py new file mode 100644 index 0000000..a10a7f0 --- /dev/null +++ b/infra/deploy-runner/test_device_core_drift_audit.py @@ -0,0 +1,158 @@ +"""The diagnostic domain must not weaken any release/reconciliation barrier.""" +from contextlib import ExitStack, redirect_stdout, redirect_stderr +import copy +import importlib.machinery +import importlib.util +import io +import json +from pathlib import Path +import tempfile +import unittest +from unittest import mock + +from test_device_core_release import R, runtime + +path = Path(__file__).resolve().parents[1] / 'device-core-deploy/build_drift_audit.py' +loader = importlib.machinery.SourceFileLoader('drift_builder', str(path)) +spec = importlib.util.spec_from_loader(loader.name, loader) +B = importlib.util.module_from_spec(spec) +loader.exec_module(B) + + +def inspect_fixture(): + return {'HostConfig': {'Binds': ['/host/a:/a:ro', '/host/b:/b:ro'], + 'Mounts': [{'Source': '/host/c', 'Target': '/c', 'ReadOnly': True}, + {'Source': '/host/d', 'Target': '/d', 'ReadOnly': True}], + 'NetworkMode': 'private', 'Ulimits': [{'Name': 'nproc', 'Soft': 100}, {'Name': 'nofile', 'Soft': 128}], + 'PortBindings': {}, 'ReadonlyRootfs': True, 'SecurityOpt': ['no-new-privileges:true']}, + 'Config': {'Env': ['SECRET=never-print-this-value', 'B=2', 'A=1'], 'User': '1000', 'Cmd': ['node', 'app.mjs']}, + 'Mounts': [{'Destination': '/b', 'Source': '/host/b', 'RW': False}, {'Destination': '/a', 'Source': '/host/a', 'RW': False}], + 'NetworkSettings': {'Networks': {'private': {}, 'egress': {}}}} + + +class DriftAuditTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory(); self.addCleanup(self.tmp.cleanup) + self.root = Path(self.tmp.name) + self.artifact = self.root/'audit.tgz'; self.artifact.write_bytes(B.bundle()[1]) + self.work = self.root/'work'; self.work.mkdir() + self.manifest, self.entries, self.payload = R.load_artifact(self.artifact, self.work) + + def test_deterministic_fixed_descriptor_and_no_runtime_authority(self): + self.assertEqual(self.artifact.read_bytes(), B.bundle()[1]) + self.assertEqual(tuple(self.entries), (R.DEVICE_RELEASE_DRIFT_AUDIT_ENTRY,)) + component = self.manifest['component'] + self.assertEqual(R.component_services(component, self.entries), ()) + self.assertEqual(R.component_builds(component, self.entries), ()) + self.assertEqual(R.component_compose_files(component), ()) + self.assertTrue(R.component_artifact_only(component)) + for rel in ['deployment/other.json', 'services/device-control-core/src/app.mjs', 'secrets/key']: + with self.subTest(rel=rel), self.assertRaises(R.DeployError): R.allowed_payload_path(component, rel) + descriptor = R.device_release_drift_audit_descriptor(); descriptor['mode'] = 'repair' + (self.payload/R.DEVICE_RELEASE_DRIFT_AUDIT_ENTRY).write_text(json.dumps(descriptor)) + with self.assertRaises(R.DeployError): R.validate_device_release_drift_audit_payload(self.payload, self.entries, self.manifest['id']) + + def test_diagnostic_fields_exactly_match_existing_production_hash(self): + info = inspect_fixture() + rows = [{k:v for k,v in row.items() if k != 'runtimeConfigSha256'} for row in runtime().values()] + inventory = {'schemaVersion': 'nodedc.device-plane.runtime-inventory.v1', + 'composeProject': 'nodedc-device-plane', 'services': rows} + with mock.patch.object(R, 'device_plane_runtime_inventory', return_value=inventory), mock.patch.object(R, 'inspect_device_plane_container', return_value=copy.deepcopy(info)): + actual = R.device_release_runtime_snapshot() + expected = R.device_release_drift_digest(R.device_release_drift_fields(info)) + self.assertTrue(all(row['runtimeConfigSha256'] == expected for row in actual.values())) + + def test_permutations_find_exact_saved_hash_without_mutating_input(self): + fields = R.device_release_drift_fields(inspect_fixture()); saved = copy.deepcopy(fields) + saved['HostConfig']['Binds'].reverse(); saved['HostConfig']['Mounts'].reverse() + original = copy.deepcopy(fields) + result = R.device_release_drift_probe(fields, R.device_release_drift_digest(saved)) + self.assertTrue(result['exactPreimageFound']); self.assertFalse(result['exactCurrentMatch']) + self.assertEqual(result['changedFields'], ['HostConfig.Binds', 'HostConfig.Mounts']) + self.assertEqual(fields, original) + + def test_seven_mounts_are_supported_without_guessing_any_values(self): + fields = R.device_release_drift_fields(inspect_fixture()); fields['HostConfig']['Binds'] = None + fields['HostConfig']['Mounts'] = [{'Source': '/h/'+str(i), 'Target': '/t/'+str(i)} for i in range(7)] + saved = copy.deepcopy(fields); saved['HostConfig']['Mounts'].reverse() + result = R.device_release_drift_probe(fields, R.device_release_drift_digest(saved)) + self.assertTrue(result['exactPreimageFound']); self.assertFalse(result['searchTruncated']) + self.assertEqual(result['changedFields'], ['HostConfig.Mounts']) + + def test_network_mode_difference_is_reported_not_silently_normalized(self): + fields = R.device_release_drift_fields(inspect_fixture()); saved = copy.deepcopy(fields) + saved['HostConfig']['NetworkMode'] = 'egress' + result = R.device_release_drift_probe(fields, R.device_release_drift_digest(saved)) + self.assertTrue(result['exactPreimageFound']); self.assertFalse(result['exactCurrentMatch']) + self.assertEqual(result['changedFields'], ['HostConfig.NetworkMode']) + self.assertEqual(result['matchingSavedNetworkMode'], 'egress') + + def test_real_configuration_changes_never_become_order_proofs(self): + fields = R.device_release_drift_fields(inspect_fixture()) + for section, key, value in [('HostConfig', 'ReadonlyRootfs', False), ('HostConfig', 'PortBindings', {'1/tcp': [{'HostPort': '1234'}]}), ('Config', 'Env', ['DIFFERENT=secret']), ('HostConfig', 'Binds', ['/h/changed:/a:ro'])]: + saved = copy.deepcopy(fields); saved[section][key] = value + with self.subTest(key=key): + self.assertFalse(R.device_release_drift_probe(fields, R.device_release_drift_digest(saved))['exactPreimageFound']) + + def test_search_limit_and_duplicates_are_explicit_unresolved_results(self): + fields = R.device_release_drift_fields(inspect_fixture()) + result = R.device_release_drift_probe(fields, 'a'*64, budget=2) + self.assertFalse(result['exactPreimageFound']); self.assertTrue(result['searchTruncated']) + self.assertEqual(result['candidatesChecked'], 2) + fields['HostConfig']['Binds'] *= 2 + self.assertEqual(R.device_release_drift_probe(fields, 'a'*64)['reason'], 'ambiguous-duplicate-mounts') + + def test_report_checks_all_services_and_never_emits_plaintext(self): + current = runtime(); fields = R.device_release_drift_fields(inspect_fixture()) + for row in current.values(): row['runtimeConfigSha256'] = R.device_release_drift_digest(fields) + samples = {name: {'runtime': row, 'fields': fields} for name, row in current.items()} + changed = copy.deepcopy(samples); changed['device-control-core']['fields']['HostConfig']['ReadonlyRootfs'] = False + before = {'runtime': current, 'compose': {}, 'installedFiles': {}, 'otherComposeServices': {}} + with ExitStack() as stack: + for name, value in [('device_release_r5_evidence', before), ('collect_exact_files', {}), ('component_compose_files', ()), ('device_release_other_compose_services', {})]: + stack.enter_context(mock.patch.object(R, name, return_value=value)) + stack.enter_context(mock.patch.object(R, 'DEVICE_PLANE_ROOT', self.root/'live')) + stack.enter_context(mock.patch.object(R, 'device_release_drift_sample', side_effect=[samples, changed, samples])) + stack.enter_context(mock.patch.object(R, 'run_healthchecks', side_effect=R.DeployError('secret-must-not-be-printed'))) + boundary = stack.enter_context(mock.patch.object(R, 'validate_device_manager_control_plane_runtime')) + mutation = stack.enter_context(mock.patch.object(R.subprocess, 'run')) + output = stack.enter_context(redirect_stdout(io.StringIO())) + report = R.device_release_drift_audit(self.payload, self.entries, self.manifest['id']) + rendered = output.getvalue() + self.assertFalse(report['applyAllowed']); self.assertFalse(report['mutation']) + self.assertEqual(set(report['services']), set(R.DEVICE_RELEASE_INVENTORY)) + self.assertFalse(report['services']['device-control-core']['samplesStable']) + self.assertFalse(report['checks']['health']['ok']); self.assertTrue(report['checks']['source']['ok']) + self.assertTrue(boundary.call_args.kwargs['read_only']); mutation.assert_not_called() + for text in ['never-print-this-value', 'SECRET=', 'secret-must-not-be-printed', '/host/a']: + self.assertNotIn(text, rendered) + + def test_apply_is_rejected_before_any_application_or_backup_action(self): + for directory in ['inbox', 'applied', 'failed', 'backups', 'state', 'tmp']:(self.root/directory).mkdir() + with ExitStack() as stack: + for name, value in [('INBOX', self.root/'inbox'), ('APPLIED_DIR', self.root/'applied'), ('FAILED_DIR', self.root/'failed'), ('BACKUPS_DIR', self.root/'backups'), ('STATE_DIR', self.root/'state'), ('TMP_DIR', self.root/'tmp'), ('STATE_FILE', self.root/'state/applied.jsonl'), ('FAILED_STATE_FILE', self.root/'state/failed.jsonl'), ('LOCK_DIR', self.root/'lock')]: + stack.enter_context(mock.patch.object(R, name, value)) + for name in ['require_root', 'ensure_layout', 'validate_artifact_location']: + stack.enter_context(mock.patch.object(R, name)) + command = stack.enter_context(mock.patch.object(R.subprocess, 'run')) + runtime_action = stack.enter_context(mock.patch.object(R, 'run_component_runtime')) + root = stack.enter_context(mock.patch.object(R, 'component_root')) + stack.enter_context(redirect_stdout(io.StringIO())); stack.enter_context(redirect_stderr(io.StringIO())) + with self.assertRaisesRegex(R.DeployError, 'plan-only; apply is forbidden'): R.apply_artifact(self.artifact) + command.assert_not_called(); runtime_action.assert_not_called(); root.assert_not_called() + self.assertEqual(list((self.root/'backups').iterdir()), []) + self.assertFalse(R.load_state(R.FAILED_STATE_FILE)[0]['started_apply']) + + def test_plan_dispatches_only_the_registered_audit(self): + with mock.patch.object(R, 'validate_artifact_location'), mock.patch.object(R, 'ensure_layout'), \ + mock.patch.object(R, 'TMP_DIR', self.root), \ + mock.patch.object(R, 'device_release_drift_audit') as audit, \ + mock.patch.object(R, 'preflight_device_release_reconciliation') as recovery, \ + mock.patch.object(R, 'run_component_runtime') as mutation: + R.plan_artifact(self.artifact) + audit.assert_called_once() + self.assertEqual(audit.call_args.args[2], R.DEVICE_RELEASE_DRIFT_AUDIT_ID) + recovery.assert_not_called(); mutation.assert_not_called() + + +if __name__ == '__main__': unittest.main() diff --git a/infra/device-core-deploy/README.md b/infra/device-core-deploy/README.md index cd4cccf..8485c2e 100644 --- a/infra/device-core-deploy/README.md +++ b/infra/device-core-deploy/README.md @@ -90,3 +90,26 @@ receipt + original incident evidence. Other rollback failures remain blocked. The r5 archive must never be replayed. Reconciliation does not install a release or activate automatic deployment. Only after its live acceptance may a NEW successful CI run become the next normal-release candidate. + +## Read-only diagnosis after rejected reconciliation + +Reconciliation001 stopped in plan on the saved Core runtime configuration hash. +No apply ran. This does not prove either harmless ordering or actual drift. The +original backup stores only an aggregate hash, and the legacy snapshot retains +HostConfig.Binds/Mounts order. Existing acceptance is deliberately unchanged. + +`build_drift_audit.py` creates a separate `device-core-release-drift-audit` bundle. +Its only entry is `deployment/device-core-release-r5-drift-audit-v1.json`. +Only canonical `plan` can execute this diagnostic; `apply` refuses before any +application/backup action. It proves original incident evidence and reports all +five service image/hash comparisons over three observations, source/Compose, +health, secret/mount/network boundaries and unrelated Compose preservation. +No raw inspect, environment values or secrets are printed. + +The diagnostic searches at most 20,000 exact legacy hash candidates, changing only +the order of observed HostConfig.Binds/Mounts (up to eight each) and NetworkMode +among attached network names. It preserves every other value. A matching old +NetworkMode is reported as a difference, never accepted as harmless. Exhaustion, +changing samples or no match remains unresolved. No diagnostic result creates a +reconciliation marker or bypasses the original acceptance barriers. A subsequent +recovery decision requires the actual NAS report. diff --git a/infra/device-core-deploy/build_drift_audit.py b/infra/device-core-deploy/build_drift_audit.py new file mode 100644 index 0000000..431660e --- /dev/null +++ b/infra/device-core-deploy/build_drift_audit.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +"""Build the exact plan-only r5 drift audit; apply is forbidden.""" +import argparse +import gzip +import hashlib +import io +import json +from pathlib import Path +import tarfile + +ROOT = Path(__file__).resolve().parent +ENTRY = 'deployment/device-core-release-r5-drift-audit-v1.json' + + +def bundle(): + descriptor = (ROOT / 'r5-drift-audit-v1.json').read_bytes() + identity = json.loads(descriptor)['auditId'] + members = { + 'manifest.env': ('id='+identity+'\ncomponent=device-core-release-drift-audit\ntype=app-overlay\n').encode(), + 'files.txt': (ENTRY+'\n').encode(), + 'payload/'+ENTRY: descriptor, + } + output=io.BytesIO() + with gzip.GzipFile(fileobj=output, mode='wb', mtime=0, filename='') as compressed: + with tarfile.open(fileobj=compressed, mode='w') as archive: + for name,data in sorted(members.items()): + info=tarfile.TarInfo(name);info.mode=0o644;info.size=len(data) + archive.addfile(info,io.BytesIO(data)) + return identity,output.getvalue() + + +if __name__=='__main__': + parser=argparse.ArgumentParser(description=__doc__) + parser.add_argument('--output-dir',required=True,type=Path) + args=parser.parse_args();args.output_dir.mkdir(parents=True,exist_ok=True) + identity,data=bundle();path=args.output_dir/('nodedc-'+identity+'.tgz') + with path.open('xb') as stream:stream.write(data) + print(json.dumps({'artifact':str(path),'sha256':hashlib.sha256(data).hexdigest(),'id':identity})) diff --git a/infra/device-core-deploy/r5-drift-audit-v1.json b/infra/device-core-deploy/r5-drift-audit-v1.json new file mode 100644 index 0000000..4a62b94 --- /dev/null +++ b/infra/device-core-deploy/r5-drift-audit-v1.json @@ -0,0 +1,8 @@ +{ + "schemaVersion": "nodedc.device-core.release-drift-audit.v1", + "failedReleaseId": "device-core-release-v1-r5-67b2ae586399eb1eb7d3a6c074a292e0dbb7b406", + "failedSha256": "b8dd1384f499d1173ce7d95dc1f2433a404290f443bd612816ad9136ccbf9347", + "backupId": "device-core-release-device-core-release-v1-r5-67b2ae586399eb1eb7d3a6c074a292e0dbb7b406-20260929-190019", + "mode": "read-only-plan;apply-forbidden", + "auditId": "device-core-release-r5-drift-audit-v1-20260929-001" +}