feat: qualify bound configure-only recovery runtime on cloud VM
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-13 18:07:46 +01:00
parent b24314da9e
commit 2230235dfb
21 changed files with 1749 additions and 80 deletions
+40
View File
@@ -1,5 +1,45 @@
# Typed RootHelper bridge contract (implementation, not native acceptance)
## Configure-only partial recovery (schema 4, local implementation)
This is a **new, separately WebUI-approved** dev-test native action. Schema 4
requires `native_recovery = {schema_version:1, previous_grant_id,
previous_attempt_id, partial_proof_sha256}` and forbids `native_retry`.
Resolved transaction schema 2 adds `operation:"configure_only"`; only the
existing `rmm-apt-fixture-install-1.0` recipe/version 1, pinned fixture archive,
and old/new version `1.0` are eligible. Schema 1 retains its exact encoding.
The helper first requires the original saved signed request, immutable SQLite
partial proof, definitive `APT_PARTIAL_UNCONFIGURED_VERIFIED` outcome, and closed
consumed row. `recovery-planning` receives exactly `{native_recovery, proof}`;
Python rechecks the original still-active witnesses and complete current partial
snapshot. It seals only the content-addressed baseline and returns the normal
planning projection plus `native_recovery`. Ordinary planning continues to reject
unconfigured packages. This passive projection creates no job or authorization.
For execution the helper archives the definitive old active directory, stages
the exact proof as `active/partial-proof.json`, and binds its hash in the new
signed manifest. Python independently checks history, original target, full
partial baseline and installed fixture bytes. APT receives only
`install -- rmm-mvp-test=1.0`; the actual v3 hook must contain exactly one
equal-version `**CONFIGURE**` action. Unpack, removal, foreign packages and pending
configuration remain forbidden. The same native sandbox, grant deadlines,
locked-store handoff and complete postcondition/audit checks apply.
Create-once markers are `recovery-attempt-<previous_grant>.json`,
`pending-recovery-<previous_grant>.json`, and `recovery-<previous_grant>.json`.
Original/retry markers, signed histories and the original unknown proof remain
intact. Recovery produces `native_recovery:true`, `recovery_record_sha256` and
`partial_proof_sha256`; it creates no fresh-install acceptance record or
`native_record_sha256`. A later separately approved native 1.1 upgrade must
provide the ordinary acceptance evidence for the changed provider/runtime.
Local actual APT 2.6.2, with a vetoing collector and independently guarded fake
dpkg, emitted only the exact configure action/target; real and copied package
status stayed unchanged. This is **local regression evidence**, not Cloud-VM
recovery acceptance. Native deployment, UI approval and execution remain the
parent's next acceptance step.
## Explicit one-attempt recovery (schema 3, 2026-11-13)
Schema 2 keeps its exact old encoding (the optional field is omitted). Schema 3
+16 -6
View File
@@ -1,11 +1,21 @@
# Root-helper APT transaction provider / explicit first native acceptance
**Current 2026-11-13:** Cloud fixture retry reached armed hook and APT exit 0,
but independent verification found an unpacked/unconfigured package; outcome
remains **unknown**, with all original/retry tombstones and ledger preserved.
No native acceptance record, package repair or further retry. Root test policy
**Current 2026-11-13:** The Cloud fixture retry reached armed hook and APT exit 0,
leaving fixture 1.0 unpacked/unconfigured. An original-bound readonly proof and
normal signed RootSync now classified that original attempt as **failed**
(`APT_PARTIAL_UNCONFIGURED_VERIFIED`), preserving all histories/tombstones.
No native acceptance record or package repair exists. Root test policy remains
closed. Detailed real evidence: `../../docs/implementation-status.md`.
The configure-only recovery path, requiring its own new fixed WebUI approval, is implemented in source
(schema 4 manifest, transaction schema 2), with a dedicated passive recovery
projection and separate immutable recovery records. Its qualified runtime is now installed and its actual Cloud copied-database
sandbox readiness probe passed, preserving original state. **No configure-only
package effect or native package acceptance has yet run.** All **75 Python tests passed** in the offline readonly
unprivileged container, including actual APT 2.6.2 configure-only protocol and
guarded fake-dpkg arguments with unchanged real/copied status. See
[`HELPER-CONTRACT.md`](HELPER-CONTRACT.md) for the precise recovery boundary.
Source configuration now disables APT's `dpkg::selection::remove::approved`
rewrite, retaining the exact package's Configure operation while both pending
modes remain disabled and hook-pinned. Upstream explanation:
@@ -13,8 +23,8 @@ modes remain disabled and hook-pinned. Upstream explanation:
Local actual APT 2.6.2 regression in an offline readonly unprivileged container
proved unpack + exact `--configure rmm-mvp-test:all`, no `--pending` or foreign
target; independent dpkg guard simulated effects, real/copied status unchanged.
67 Python tests passed with this opt-in regression. **This source correction
is not deployed or natively accepted on the Cloud VM.** No automatic repair,
67 Python tests passed with this opt-in regression. **This correction is now installed and sandbox-probed on the Cloud VM;
its native package effect remains unaccepted.** No automatic repair,
marker reset or implicit unknown-resolution is introduced. Older sections below
describe historical increments; current operational status is the linked log.
+203 -17
View File
@@ -196,16 +196,19 @@ class PackageArchive:
archive_path: str
@classmethod
def parse(cls, obj):
def parse(cls, obj, configure_only=False):
exact(obj, 'name architecture old_version new_version origin sha256 size archive_path')
token(obj['name'], NAME, 'PACKAGE_NAME')
require(not FORBIDDEN.match(obj['name']), 'PROTECTED_PACKAGE')
require(obj['architecture'] in ('amd64', 'all'), 'ARCHITECTURE')
token(obj['new_version'], VERSION, 'VERSION')
if configure_only:
require(obj['old_version'] == obj['new_version'] == '1.0', 'RECOVERY_VERSION')
if obj['old_version'] is not None:
token(obj['old_version'], VERSION, 'VERSION')
# Debian ordering, not lexical/semver ordering. Read-only argv.
require(subprocess.run(['/usr/bin/dpkg', '--compare-versions', obj['old_version'],
require((obj['old_version'] == obj['new_version'] == '1.0') if configure_only else
subprocess.run(['/usr/bin/dpkg', '--compare-versions', obj['old_version'],
'lt', obj['new_version']], env=ENV,
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL).returncode == 0,
@@ -229,12 +232,16 @@ class ResolvedAptTransaction:
status_fingerprint: str
baseline_sha256: str
packages: Tuple[PackageArchive, ...]
operation: Optional[str] = None
@classmethod
def parse(cls, obj):
version = obj.get('schema_version') if type(obj) is dict else None
exact(obj, 'schema_version recipe_id recipe_version platform resolver_config_version '
'no_reboot status_fingerprint baseline_sha256 packages')
require(type(obj['schema_version']) is int and obj['schema_version'] == 1, 'SCHEMA_VERSION')
'no_reboot status_fingerprint baseline_sha256 packages' + (' operation' if version == 2 else ''))
require(type(version) is int and version in (1, 2), 'SCHEMA_VERSION')
configure_only = version == 2
require(not configure_only or obj['operation'] == 'configure_only', 'TRANSACTION_OPERATION')
token(obj['recipe_id'], IDENT, 'RECIPE_ID')
token(obj['recipe_version'], IDENT, 'RECIPE_VERSION')
require(obj['platform'] == 'ubuntu-24.04-amd64', 'UNSUPPORTED_PLATFORM')
@@ -244,9 +251,12 @@ class ResolvedAptTransaction:
token(obj['baseline_sha256'], HASH, 'FINGERPRINT')
require(type(obj['packages']) is list and 0 < len(obj['packages']) <= MAX_PACKAGES,
'PACKAGE_COUNT')
packages = tuple(PackageArchive.parse(p) for p in obj['packages'])
packages = tuple(PackageArchive.parse(p, configure_only=configure_only) for p in obj['packages'])
require(len({(p.name, p.architecture) for p in packages}) == len(packages), 'DUPLICATE_PACKAGE')
return cls(**{**obj, 'packages': packages})
transaction = cls(**{**obj, 'packages': packages})
if configure_only:
fixture_scope(transaction)
return transaction
@dataclass(frozen=True)
@@ -336,6 +346,10 @@ def fixture_scope(transaction):
'FIXTURE_RECIPE')
require(len(transaction.packages) == 1, 'FIXTURE_CLOSURE')
old, new = FIXTURE_RECIPES[transaction.recipe_id]
if transaction.operation == 'configure_only':
require(transaction.schema_version == 2 and transaction.recipe_id == 'rmm-apt-fixture-install-1.0',
'RECOVERY_FIXED_RECIPE')
old = new = '1.0'
package = transaction.packages[0]
require(package.name == 'rmm-mvp-test' and package.architecture == 'all' and
package.origin == 'rmm-test' and package.old_version == old and package.new_version == new,
@@ -370,14 +384,20 @@ def load_signed_action(transaction, context):
manifest_keys += ('resolved_apt_transaction provider_sha256 hook_sha256 apt_config_sha256 '
'runtime_sha256 test_result_id transaction_bytes')
version = action.get('schema_version') if type(action) is dict else None
exact(action, manifest_keys + (' native_retry' if version == 3 else ''))
exact(action, manifest_keys + (' native_retry' if version == 3 else ' native_recovery' if version == 4 else ''))
require(action['type'] == 'rmm.apt.helper-action' and
type(version) is int and version in (2, 3),
type(version) is int and version in (2, 3, 4),
'SIGNED_ACTION_SCHEMA')
if version == 3:
validate_retry_reference(action['native_retry'])
require(context.action == 'apt-native-acceptance' and context.execution_profile == 'dev-test',
'RETRY_NATIVE_TEST_ONLY')
if version == 4:
validate_recovery_reference(action['native_recovery'])
require(context.action == 'apt-native-acceptance' and context.execution_profile == 'dev-test' and
transaction.operation == 'configure_only', 'RECOVERY_NATIVE_CONFIGURE_ONLY')
else:
require(transaction.operation is None, 'RECOVERY_MANIFEST_REQUIRED')
expected_bytes = sealed_read(ACTIVE / 'expectation.json')
require(type(action['transaction_bytes']) is list and len(action['transaction_bytes']) <= 65536 and
all(type(value) is int and 0 <= value <= 255 for value in action['transaction_bytes']) and
@@ -418,6 +438,11 @@ def check_native_gate(transaction, context, action, runtime, native_acceptance):
'DEDICATED_HELPER_ACTION_REQUIRED')
path = record_path(transaction)
if native_acceptance:
if action.get('native_recovery') is not None:
verify_recovery_reference(transaction, context, action)
require(not os.path.lexists(BASE / ('recovery-' + action['native_recovery']['previous_grant_id'] + '.json')),
'RECOVERY_ALREADY_RECORDED')
return
require(not path.exists(), 'ACCEPTANCE_ALREADY_RECORDED')
return
proof = json_bytes(sealed_read(path))
@@ -486,6 +511,92 @@ def validate_retry_reference(ref):
token(ref['bootstrap_marker_sha256'], HASH, 'RETRY_MARKER_HASH')
def validate_recovery_reference(ref):
exact(ref, 'schema_version previous_grant_id previous_attempt_id partial_proof_sha256')
require(type(ref['schema_version']) is int and ref['schema_version'] == 1, 'RECOVERY_SCHEMA')
for key in ('previous_grant_id', 'previous_attempt_id'):
value = ref[key]
require(type(value) is str and str(uuid.UUID(value)) == value and uuid.UUID(value).int != 0,
'RECOVERY_ID')
token(ref['partial_proof_sha256'], HASH, 'RECOVERY_PROOF_HASH')
def validate_partial_proof(proof):
exact(proof, 'schema_version type transaction_sha256 job_payload_sha256 effect_armed_ledger_id '
'grant_id job_id attempt_id authorization_id plan_sha256 original_evidence_sha256 '
'original_baseline_sha256 observed_snapshot_sha256 status_fingerprint fixture_payload_sha256 '
'snapshot checked_at_ms partial_effect postconditions_passed reboot_required')
require(type(proof['schema_version']) is int and proof['schema_version'] == 1 and
proof['type'] == 'rmm.apt.partial-reconciliation' and proof['partial_effect'] is True and
proof['postconditions_passed'] is False and proof['reboot_required'] is False and
type(proof['checked_at_ms']) is int and proof['checked_at_ms'] > 0, 'RECOVERY_PROOF_TYPE')
for key in ('transaction_sha256', 'job_payload_sha256', 'plan_sha256', 'original_evidence_sha256',
'original_baseline_sha256', 'observed_snapshot_sha256', 'status_fingerprint', 'fixture_payload_sha256'):
token(proof[key], HASH, 'RECOVERY_PROOF_HASH')
for key in ('grant_id','job_id','attempt_id','authorization_id'):
value = proof[key]
require(type(value) is str and str(uuid.UUID(value)) == value and uuid.UUID(value).int != 0,
'RECOVERY_PROOF_ID')
token(proof['effect_armed_ledger_id'], IDENT, 'RECOVERY_PROOF_LEDGER')
require(type(proof['snapshot']) is dict and
digest(canonical(proof['snapshot'])) == proof['observed_snapshot_sha256'] and
proof['snapshot'].get('rmm-mvp-test:all') == {'version':'1.0','status':'install ok unpacked'} and
proof['fixture_payload_sha256'] == digest(b'1.0\n'), 'RECOVERY_PROOF_SNAPSHOT')
def verify_recovery_reference(transaction, context, action):
"""Only immutable linkage here; current state is checked before the hook.
RootHelper additionally requires this proof in its original shared SQLite
ledger with terminal classified failure and the original verified Request.
Caller-provided JSON or a root-owned file alone never grants authority.
"""
ref = action['native_recovery']; validate_recovery_reference(ref)
require(context.action == 'apt-native-acceptance' and context.execution_profile == 'dev-test' and
action['schema_version'] == 4 and transaction.schema_version == 2 and
transaction.operation == 'configure_only', 'RECOVERY_DEDICATED_ACTION')
fixture_scope(transaction)
raw_proof = sealed_read(ACTIVE / 'partial-proof.json')
proof = json_bytes(raw_proof); validate_partial_proof(proof)
require(raw_proof == canonical(proof) and digest(raw_proof) == ref['partial_proof_sha256'] and
proof['grant_id'] == ref['previous_grant_id'] and proof['attempt_id'] == ref['previous_attempt_id'],
'RECOVERY_IMMUTABLE_PROOF_BINDING')
require(context.grant_id != proof['grant_id'] and context.attempt_id != proof['attempt_id'] and
context.job_id != proof['job_id'] and context.authorization_id != proof['authorization_id'] and
context.plan_sha256 != proof['plan_sha256'], 'RECOVERY_NEW_APPROVAL_REQUIRED')
require(transaction.baseline_sha256 == proof['observed_snapshot_sha256'] and
transaction.status_fingerprint == proof['status_fingerprint'] and
sealed_read(ACTIVE / 'baseline.json') == canonical(proof['snapshot']), 'RECOVERY_BASELINE_BINDING')
previous = BASE / 'history' / ref['previous_grant_id']
secure_path(previous, directory=True, private=True)
names = ('context.json','signed-action.json','expectation.json','baseline.json','launch.json',
'native-prechecks.json','sandbox-ready.json','sandbox-result.json','hook-armed.json')
historical = {name: sealed_read(previous / name) for name in names}
for prefix in ('bootstrap-attempt-', 'bootstrap-retry-'):
name = prefix + 'rmm-apt-fixture-install-1.0.json'
historical[name] = sealed_read(BASE / name)
require(digest(canonical({name:digest(raw) for name,raw in historical.items()})) ==
proof['original_evidence_sha256'], 'RECOVERY_HISTORY_CHANGED')
old = VerifiedHelperContext.parse(json_bytes(historical['context.json']))
require(all(getattr(old, key) == proof[key] for key in
('transaction_sha256','job_payload_sha256','effect_armed_ledger_id','grant_id',
'job_id','attempt_id','authorization_id','plan_sha256')) and
digest(historical['signed-action.json']) == proof['job_payload_sha256'] and
digest(historical['expectation.json']) == proof['transaction_sha256'] and
digest(historical['baseline.json']) == proof['original_baseline_sha256'],
'RECOVERY_ORIGINAL_CONTEXT_BINDING')
old_job = json_bytes(historical['signed-action.json'])
new_job = json_bytes(sealed_read(ACTIVE / 'signed-action.json'))
require(all(old_job[key] == new_job[key] for key in
('tenant_id','asset_id','agent_id','enrollment_generation','assignment_version')) and
digest(sealed_read(previous / 'apt.conf')) == old_job['action']['apt_manifest']['apt_config_sha256'],
'RECOVERY_ORIGINAL_TARGET_OR_CONFIG')
require(not os.path.lexists(BASE / 'acceptance-rmm-apt-fixture-install-1.0.json') and
not os.path.lexists(BASE / 'pending-acceptance-rmm-apt-fixture-install-1.0.json'),
'RECOVERY_NOT_INSTALL_ACCEPTANCE')
return proof
def historical_retry_evidence(transaction, context, action):
"""Recheck immutable no-handoff evidence, never turn unknown into failed.
@@ -549,6 +660,10 @@ def historical_retry_evidence(transaction, context, action):
def bootstrap_binding(transaction, context, action):
binding = attempt_binding(context)
if action.get('native_recovery') is not None:
verify_recovery_reference(transaction, context, action)
binding.update(native_recovery=action['native_recovery'])
return BASE / ('recovery-attempt-' + action['native_recovery']['previous_grant_id'] + '.json'), binding
if action.get('native_retry') is not None:
binding.update(native_retry=action['native_retry'], previous_evidence_sha256=
historical_retry_evidence(transaction, context, action))
@@ -664,8 +779,16 @@ def complete_acceptance(transaction, context, action, runtime, evidence):
'completed_at_ms': time.time_ns() // 1000000}
# Stage+fsync complete bytes before publishing. Failed writes never leave a
# parseable final partial record. An existing final record is never replaced.
path = record_path(transaction)
staged = BASE / ('pending-acceptance-' + transaction.recipe_id + '.json')
recovery = action.get('native_recovery')
if recovery is not None:
verify_recovery_reference(transaction, context, action)
proof.update(schema_version=1, type='rmm.apt.native-recovery', operation='configure_only',
native_recovery=recovery)
path = BASE / ('recovery-' + recovery['previous_grant_id'] + '.json')
staged = BASE / ('pending-recovery-' + recovery['previous_grant_id'] + '.json')
else:
path = record_path(transaction)
staged = BASE / ('pending-acceptance-' + transaction.recipe_id + '.json')
durable_once(staged, proof)
linked = False
try:
@@ -681,6 +804,11 @@ def complete_acceptance(transaction, context, action, runtime, evidence):
path.unlink()
raise
# Retain staged bytes as an immutable record witness; never reset attempts.
if recovery is not None:
return {'test_acceptance': True, 'noProductionEvidence': True, 'native_recovery': True,
'recovery_record_sha256': digest(canonical(proof)),
'partial_proof_sha256': recovery['partial_proof_sha256'],
'test_result_id': action['test_result_id']}
return {'test_acceptance': True, 'noProductionEvidence': True,
'native_record_sha256': digest(canonical(proof)), 'test_result_id': action['test_result_id']}
@@ -747,6 +875,12 @@ def parse_protocol3(data):
def validate_actions(transaction, actions):
if transaction.operation == 'configure_only':
fixture_scope(transaction)
require(len(actions) == 1 and actions[0] == Action(
'rmm-mvp-test', '1.0', 'all', 'none', '=', '1.0', 'all', 'none', '**CONFIGURE**'),
'RECOVERY_CONFIGURE_ACTION_ONLY')
return
expected = {(p.name, p.architecture): p for p in transaction.packages}
seen = set()
for action in actions:
@@ -876,7 +1010,13 @@ def installed_snapshot():
def check_current_baseline(transaction, baseline):
require(digest(canonical(baseline)) == transaction.baseline_sha256, 'BASELINE_HASH')
require(status_fingerprint() == transaction.status_fingerprint, 'STATUS_FINGERPRINT')
require(installed_snapshot() == baseline, 'STATUS_BASELINE_CHANGED')
snapshot = partial_installed_snapshot() if transaction.operation == 'configure_only' else installed_snapshot()
require(snapshot == baseline, 'STATUS_BASELINE_CHANGED')
if transaction.operation == 'configure_only':
fixture_scope(transaction)
require(baseline.get('rmm-mvp-test:all') == {'version': '1.0', 'status': 'install ok unpacked'} and
sealed_read(Path('/usr/share/rmm-mvp-test/version'), limit=32) == b'1.0\n',
'RECOVERY_PARTIAL_PRECONDITION')
def check_preconditions(transaction, baseline):
@@ -884,7 +1024,8 @@ def check_preconditions(transaction, baseline):
for p in transaction.packages:
current = baseline.get(p.name + ':' + p.architecture)
require((current is None if p.old_version is None else
current == {'version': p.old_version, 'status': 'install ok installed'}),
current == {'version': p.old_version, 'status':
'install ok unpacked' if transaction.operation == 'configure_only' else 'install ok installed'}),
'PACKAGE_PRECONDITION')
@@ -933,6 +1074,10 @@ DPkg::Tools::Options::/usr/lib/rmm-apt-transaction/hook::InfoFD "0";
def apt_argv(transaction):
if transaction.operation == 'configure_only':
fixture_scope(transaction)
return ['/usr/bin/apt-get', '--yes', '--no-remove', '--no-install-recommends',
'install', '--', 'rmm-mvp-test=1.0']
# APT's --no-download also prevents the local file method from resolving
# its Install filename (v3 emits **ERROR**). Permit local acquisition of
# the already sealed/hash-checked archive. Empty sources, fixed paths and
@@ -1445,7 +1590,10 @@ def execute(request, native_acceptance=False):
check_current_baseline(transaction, baseline)
for package in transaction.packages:
verify_archive(package)
require(run_read(['/usr/bin/dpkg', '--audit']) == b'', 'DPKG_AUDIT')
# The exact bound unpacked fixture is the declared recovery input;
# ordinary jobs continue to require a clean audit before mutation.
if transaction.operation != 'configure_only':
require(run_read(['/usr/bin/dpkg', '--audit']) == b'', 'DPKG_AUDIT')
context.check_deadline()
if not native_acceptance:
evidence = verified_no_change(transaction, baseline, context)
@@ -1475,7 +1623,8 @@ def execute(request, native_acceptance=False):
if not armed:
# Trusted fixed config makes a missing hook a veto, not an
# after-the-fact substitute for pre-dpkg validation.
require(installed_snapshot() == baseline, 'MISSING_HOOK_WITH_CHANGE')
current = partial_installed_snapshot() if transaction.operation == 'configure_only' else installed_snapshot()
require(current == baseline, 'MISSING_HOOK_WITH_CHANGE')
return {'effect_state': 'known_failed', 'code': 'HOOK_NOT_HANDED_OFF',
'evidence': {'test_acceptance': True, 'noProductionEvidence': True}
if native_acceptance else {}}
@@ -1561,7 +1710,38 @@ def prepare_baseline_store():
'native_acceptance_created': False}
def recovery_planning(request):
"""Fresh passive projection of one ledger-verified, closed partial failure.
Rust verifies the signed original request, terminal failure and immutable
SQLite proof before invoking this fixed mode. No job or execution is made.
"""
exact(request, 'native_recovery proof')
ref, proof = request['native_recovery'], request['proof']
validate_recovery_reference(ref)
validate_partial_proof(proof)
require(digest(canonical(proof)) == ref['partial_proof_sha256'] and
proof['grant_id'] == ref['previous_grant_id'] and
proof['attempt_id'] == ref['previous_attempt_id'], 'RECOVERY_PLANNING_PROOF_BINDING')
fields = ('transaction_sha256 job_payload_sha256 effect_armed_ledger_id grant_id '
'job_id attempt_id authorization_id plan_sha256')
current = verify_partial({key: proof[key] for key in fields.split()})['proof']
require({key: value for key, value in current.items() if key != 'checked_at_ms'} ==
{key: value for key, value in proof.items() if key != 'checked_at_ms'},
'RECOVERY_PLANNING_STATE_CHANGED')
require(not os.path.lexists(BASE / ('recovery-attempt-' + ref['previous_grant_id'] + '.json')) and
not os.path.lexists(BASE / ('recovery-' + ref['previous_grant_id'] + '.json')),
'RECOVERY_ALREADY_ATTEMPTED')
result = _planning_status(proof)
result['native_recovery'] = ref
return result
def planning_status():
return _planning_status()
def _planning_status(recovery_proof=None):
"""Fixed passive fixture projection; complete dpkg state remains root-private.
Only content-addressed, fsynced helper metadata may be created here. No
@@ -1574,7 +1754,11 @@ def planning_status():
require(not observe_host_frontend_lock() and
not observe_host_frontend_lock(Path('/var/lib/dpkg/lock')), 'FOREIGN_PACKAGE_LOCK')
fingerprint = status_fingerprint() # Vetoes dirty updates/pending triggers.
snapshot = installed_snapshot()
snapshot_reader = partial_installed_snapshot if recovery_proof is not None else installed_snapshot
snapshot = snapshot_reader()
if recovery_proof is not None:
require(snapshot == recovery_proof['snapshot'] and fingerprint == recovery_proof['status_fingerprint'],
'RECOVERY_PLANNING_STATE_CHANGED')
runtime = runtime_identity()
prefetch = {}
for version in ('1.0', '1.1'):
@@ -1590,7 +1774,7 @@ def planning_status():
type(receipt['sealed_at_ms']) is int and 0 < receipt['sealed_at_ms'] <= time.time_ns() // 1000000,
'PREFETCH_RECEIPT')
prefetch[sha] = receipt
require(status_fingerprint() == fingerprint and installed_snapshot() == snapshot,
require(status_fingerprint() == fingerprint and snapshot_reader() == snapshot,
'PLANNING_STATE_CHANGED')
require(not observe_host_frontend_lock() and
not observe_host_frontend_lock(Path('/var/lib/dpkg/lock')), 'FOREIGN_PACKAGE_LOCK')
@@ -1615,7 +1799,7 @@ def planning_status():
else:
durable_once(path, snapshot)
# Do not publish a stale baseline if state changed during fsync.
require(status_fingerprint() == fingerprint and installed_snapshot() == snapshot,
require(status_fingerprint() == fingerprint and snapshot_reader() == snapshot,
'PLANNING_STATE_CHANGED')
return {'observed_at': time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),
'fixture_package': snapshot.get('rmm-mvp-test:all'),
@@ -1839,6 +2023,8 @@ def main():
sys.stdout.buffer.write(canonical(prepare_baseline_store()) + b'\n')
elif mode == 'planning-status':
sys.stdout.buffer.write(canonical(planning_status()) + b'\n')
elif mode == 'recovery-planning':
sys.stdout.buffer.write(canonical(recovery_planning(json_bytes(sys.stdin.buffer.read(MAX_INPUT + 1)))) + b'\n')
elif mode == 'probe-native':
sys.stdout.buffer.write(canonical(probe_native()) + b'\n')
elif mode == 'probe-worker':