Document the accepted MVP and retire superseded development plans
Rust development slice / linux (push) Failing after 14s

This commit is contained in:
2026-11-18 17:21:12 +01:00
parent f37b6dc4f7
commit 6963ad332c
188 changed files with 370 additions and 34933 deletions
-384
View File
@@ -1,384 +0,0 @@
# Typed RootHelper bridge contract (implementation, not native acceptance)
## Host reboot evidence and historical configured effect (Spec 1.13)
An ambient `reboot_required=true` is honest pending evidence, not an implicit
reboot request or a failed package postcondition. Future fixture effects must
prove equal HOST flags before/after, unchanged boot and no private-worker flag.
The parent captures `active/host-reboot-before.json` **before unshare/private
`/run`**. Schema 1 fields are `transaction_sha256`, `job_payload_sha256`,
`effect_armed_ledger_id`, `grant_id`, `boot_id`, `host_reboot_required` (bool),
and `observed_at_ms`, plus `schema_version`. Creation is exclusive and fsynced;
its observation must belong to the original grant window. New native prechecks
use schema 2, retaining the old exact checks and adding
`host_reboot_before_sha256` and `host_reboot_required_before`. The child binds the
saved host observation; its private `/run` never measures the host flag.
After real APT success the parent verifies the current host flag equals the
saved value, boot is unchanged and `sandbox-result.reboot_required` is false.
False/false and true/true are valid; either change or a private-worker flag
vetoes acceptance. Outcome evidence includes `host_reboot_required_before`,
`host_reboot_required_after`, `host_reboot_before_sha256`,
`reboot_required_introduced:false`; `reboot_required` truthfully retains ambient
true. Ordinary acceptance record **schema 3** explicitly binds those fields and
`native_prechecks_schema_version:2`. The reader rejects old record schemas or
inconsistent values. Separate future recovery records use schema 2 and retain
their distinct `rmm.apt.native-recovery` type. Noop observations remain effect-free
and report their actual current reboot flag. Fresh planning adds the required
public bool `host_reboot_required`; known ambient true is shown in the fixed
WebUI plan reason.
Historical grant `33775478-15b0-46ec-b059-44f500dbb0b6` had **no host-before
sample**. It must never acquire retroactive success or an acceptance record.
Fixed mode `verify-configured-recovery` receives the same eight original binding
fields as `verify-partial`. Only its signed schema-4 configure-only job, old
provider `5ff260…`, old schema-1 prechecks, original partial grant `31ef5e5e…` /
proof `dc3bf387…`, preserved recovery once marker, exact Configure hook, APT exit
0 and private-worker false are eligible. It checks complete stable installed
1.0 state, clean audit, actual payload, unchanged boot, idle locks and current
host marker contents twice, rechecking all thirteen immutable witnesses.
Output is `known_failed` /
`APT_RECOVERY_CONFIGURED_ACCEPTANCE_REBOOT_FLAG_VERIFIED`. Its 24-field proof
contains the original eight bindings, type/schema, original evidence digest,
partial proof hash, original baseline and current snapshot hashes/fingerprint,
payload hash, full snapshot, check time, `effect_complete:true`,
`partial_effect:false`, `postconditions_passed:false`, `reboot_required:true`,
`host_reboot_required:true` and `host_reboot_marker_sha256`. No ctime-based
inference becomes a before measurement. It writes nothing and runs no package
mutation. Rust independently verifies the saved signature/old unknown code,
appends a separate immutable proof, and leaves consumption locked until normal
signed RootSync. Native classification and future 1.1 acceptance remain pending
until actually executed; **81 local Python tests passed**, including both actual
APT argument regressions under the readonly unprivileged offline container.
## 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
requires `native_retry` and is valid only for dev-test `apt-native-acceptance`:
```
native_retry: {
schema_version: 1,
previous_grant_id: UUID,
previous_attempt_id: UUID,
bootstrap_marker_sha256: SHA256(original exact marker bytes)
}
```
This reference belongs to a **new separately UI-approved signed job**, never
an unsigned IPC override. Under the existing device lock, before consuming the
new grant and again before staging, the helper verifies the original saved
Ed25519 request historically, identical target/generation/assignment/transaction,
distinct job/attempt/authorization/plan, same-ledger terminal `failed` result
`HOOK_NOT_HANDED_OFF`, matching recorded outcome, original context/launch/
sandbox-100 evidence and absent hook/acceptance/retry markers. Historical
signature verification never grants a current start. Unknown or partial history
fails closed. Original active state may only move through the existing terminal
history rule; original tombstone never changes.
Provider independently checks original marker hash and immutable history,
identical full baseline and current normal baseline gates. It exclusively writes
`bootstrap-retry-<recipe>.json` binding the new attempt, signed reference and
hashes of historical evidence. Worker, hook and completion recheck it. This is
one recovery attempt per fixed fixture recipe, not general automatic retries.
Test/native outcomes are recorded in `docs/implementation-status.md`.
**Dedicated-runner update:** the current deployment and readiness protocol is
defined in [`../../deploy/linux/apt-helper-README.md`](../../deploy/linux/apt-helper-README.md).
The actual additive domain schema-2 types and AptNativeAcceptance variant have
since landed and are exercised by a local exact-signature/helper roundtrip test.
Agent routing and nonce/root-peer/identity/profile/stack-bound readiness are
implemented. Older descriptions below of absent domain fields or missing runner
describe the earlier increment, not a remaining implementation gate. Real VM
profile/probe/installation acceptance remains unmeasured, not passed.
## Current integration status / exact outstanding domain change
The helper now contains a real provider bridge in
`crates/privileged-helper/src/apt.rs`, called by its existing peer-credential
authenticated IPC handler, **not** by a script wrapper. The domain job source
was leased to the backend worker during this dispatch; it was not edited.
Legacy package jobs cannot supply the required manifest and remain gated.
No package capability was added to the agent. No native package/service/reboot
operation, VM action, helper installation or acceptance record occurred here.
Required additive domain/backend contract, before capability advertisement:
1. Define typed `AptExecutionManifest` **schema 2**, `ResolvedAptTransaction`
schema 1 and `PackageArchive` in domain (same exact fields/serde shape as the
helper types below; do not make domain depend on the helper crate). All deny
unknown/duplicate fields. No `serde_json::Value` opaque action authorization.
2. Existing `Action::EnsurePackage` and `Action::ApplyUpdates` gain a field
`apt_manifest: Option<AptExecutionManifest>`, default None for legacy reads.
Execution/validation requires Some for APT. Serialization MUST preserve the
complete object; ignoring unknown fields is explicitly detected and denied by
`APT_DOMAIN_MANIFEST_NOT_CONFIGURED`. No unsigned IPC manifest field exists.
3. Add a dedicated Action variant with this exact JSON shape:
```json
{
"action": "apt_native_acceptance",
"recipe_id": "rmm-apt-fixture-install-1.0",
"recipe_version": "1",
"apt_manifest": {"<all schema-2 fields below>": "<replace this placeholder>"}
}
```
`Action::name()` and permit.action are `apt_native_acceptance`. Root-only,
explicit dev-test, specific target, fixed UI-authorized job/attempt. The
upgrade recipe is `rmm-apt-fixture-update-1.1` and needs another job. This is
NOT an alias of run_script/diagnostic arbitrary execution. Backend plan/UI
allowlisting must show full transaction, exact hashes, origin, no-reboot,
execution identity and test-acceptance nature before approval.
4. For fixture ensure_package the outer recipe_id/version must match the nested
transaction exactly as strings. For apply_updates, outer provider=`apt`,
packages=`["rmm-mvp-test"]`, reboot_policy=`never`, nested upgrade recipe
only. Other original action parameters are retained and compared against the
domain's typed serialization, never accepted through parameter aliases.
5. Backend validation/planning/signing must validate both manifest transaction
representations, generate JobPayload once and sign its exact payload hash in
the existing Ed25519 permit. Keep all existing target/tenant/generation,
authorization/plan/job/attempt/identity/time bindings. Planning needs the
inspected root runtime/config hashes and immutable baseline/fingerprint.
6. Agent forwarding/capability negotiation must be separately integrated after
the domain contract and native prerequisites are complete. This dispatch did
not change agent/protocol/server files. No optimistic capability claim.
Current clear gates include `APT_PROVIDER_NOT_CONFIGURED`,
`APT_MANIFEST_NOT_CONFIGURED`, `APT_DOMAIN_MANIFEST_NOT_CONFIGURED`; an older
domain may reject the action even earlier as INVALID_JOB/unknown field. That
earlier rejection is not a fallback or authorization shortcut.
## Public Rust API
Current additive passive/no-change contract is documented in
`deploy/linux/runtime-README.md` ("Passive APT planning and declarative
no-change"). `readiness::PlanningResult` is returned only by authenticated
`apt_planning_v1`; it creates no capability. `planning-status` can create only
content-addressed root metadata seals. A normal exact already-desired fixture
returns driver `verified_no_change` / `POSTCONDITION_ALREADY_MET`, never a fake
`POSTCONDITIONS_VERIFIED` transaction/hook. Parent consumption and all signature,
manifest/runtime/native-record/artifact/current-state gates remain required.
```
apt::ProviderConfig // serde deny_unknown_fields
apt::AptExecutionManifest // schema 2
apt::ResolvedAptTransaction // schema 1
apt::PackageArchive
apt::is_apt_action(&JobPayload) -> bool
apt::policy_header(&JobPayload, &ProviderConfig) -> anyhow::Result<()>
apt::prepare(&Binding, &Request, &ProviderConfig, DateTime<Utc>)
-> anyhow::Result<PreparedApt>
PreparedApt::execute(self, &rusqlite::Connection) -> anyhow::Result<Outcome>
apt::install_known_payloads() -> anyhow::Result<()>
```
PreparedApt has no public fields/unchecked constructor. `prepare` independently
calls Binding::verify (exact Ed25519 request/grant and all existing bindings),
checks policy, exact signed manifest/domain preservation/code/runtime bindings,
installed trusted bytes and pre-grant prefetched artifacts. Parent consumes and
save_start-persists the request before execute. Execute independently requires
the corresponding consumed row (same agent/generation/job/attempt, result NULL)
and the exact originally saved request/signature/permit/plan/authorization.
Its stable effect_armed_ledger_id is `apt-<grant UUID>-<SQLite rowid>`.
## Exact manifest schema 2 inside Action.apt_manifest
```
type: "rmm.apt.helper-action"
schema_version: 2
action: "apt-native-acceptance" | "apt-execute"
execution_profile: "dev-test"
transaction_sha256: SHA256(transaction_bytes)
resolved_apt_transaction: complete typed ResolvedAptTransaction object
transaction_bytes: Vec<u8> / JSON array of integer bytes
provider_sha256: SHA256(exact installed Python provider bytes)
hook_sha256: SHA256(exact installed fixed hook bytes)
apt_config_sha256: SHA256(print-config output bytes)
runtime_sha256: SHA256(canonical inspect-runtime output object)
test_result_id: ASCII identifier [A-Za-z0-9_.-], 1..128 bytes
```
The full object AND exact transaction bytes are required. Deserialize the bytes
with the strict typed schema and require equality to the nested object. The
provider writes those **same bytes**, not reformatted JSON, to expectation.json.
It copies **the full original Request.job_bytes unchanged** to signed-action.json;
job_payload_sha256 in context is SHA256 of those complete domain job bytes.
The Python loader now requires that full JobPayload envelope and checks the
nested action, job/attempt/root identity, inner bytes/hash/object and code pins.
A detached old standalone schema-1 helper-action manifest is no longer accepted.
ResolvedAptTransaction fields (all mandatory): schema_version=1, recipe_id,
recipe_version="1", platform="ubuntu-24.04-amd64",
resolver_config_version="rmm-apt-local-v1", no_reboot=true, status_fingerprint,
baseline_sha256, packages. PackageArchive fields: name, architecture,
old_version (null/string), new_version, origin, sha256, size, archive_path.
Only the code-pinned single-package fixture install/upgrade is configured.
Production and arbitrary catalogs remain denied; a test acceptance does not
authorize another recipe/closure/profile. Exact fixture hashes are in README.
## Root configuration / trusted installation / prefetch
Existing root-owned 0600 helper config gains optional `apt_provider` (absent =
disabled). No new secret/environment variable or caller-supplied path:
```json
{
"schema_version": 1,
"execution_profile": "dev-test",
"allow_fixture_bootstrap": true,
"allowed_recipes": ["rmm-apt-fixture-install-1.0", "rmm-apt-fixture-update-1.1"],
"runtime_sha256": "<operator-reviewed canonical runtime hash>",
"apt_config_sha256": "<operator-reviewed exact config output hash>"
}
```
These are local policy limits, not approvals. Keep the existing binding,
signing-key pin, agent UID/socket GID and parent ledger provisioning unchanged.
No artifact URL/network fetch exists in the root provider.
Planned administrator tool installation, **not executed**:
```
/usr/local/libexec/rmm-privileged-helper --install-apt-provider
```
Root-only, fixed paths, create-only: embeds Python/hook bytes at Rust compile
time, writes root-owned `/usr/lib/rmm-apt-transaction/{apt_transaction.py,hook}`
(0644/0755), `/var/lib/rmm-apt-transaction` and archives/baselines/history (0700),
and `install-metadata.json` (0600, provider/hook hashes). Refuses existing files/
directories instead of replacing/chmodding them. Partial installation requires
explicit operator reconciliation; no automatic deletion/repair. On each use,
installed bytes and metadata must match the helper's compiled known payloads.
The interpreter is fixed `/usr/bin/python3 -I`, root-owned resolved interpreter;
all provider/store path components are root-owned, nonsymlink and not writable
by group/others. This installation creates no acceptance or grant.
Planned explicit pre-grant fixture preparation, **not executed**:
```
/usr/bin/python3 -I /usr/lib/rmm-apt-transaction/apt_transaction.py provision-fixture-store
```
Only the two pinned deterministic fixture archives can be created, never an
arbitrary archive/URL. Archives and `prefetch-<sha>.json` receipts are fsynced,
root-owned 0600, exclusive creation. Receipt fields: schema_version=1, sha256,
size, sealed_at_ms. Helper requires receipt time <= permit.not_before, matching
actual SHA256/size/single-link archive. Missing/writable/symlinked/unprefetched
artifacts fail before consumption. All downloads/imports must finish before the
final short grant, never during execution. Artifact mTLS fetch elsewhere must
ultimately yield the same root-verified sealed-store contract, not an agent path.
The same preparation stores complete canonical dpkg baseline at
`baselines/<baseline_sha256>.json` and emits baseline hash/status fingerprint
for the approved immutable plan. It creates neither jobs nor authorization.
For subsequent changed baselines, the root-only `prepare-baseline` mode samples
current dpkg state and creates a new content-addressed canonical baseline before
the new plan/final grant. An identical existing baseline is only read/verified,
never rewritten; changed state creates another hash file, never resets archives,
receipts or acceptance/attempt markers. It creates no job authority. Do not
modify a sealed file or fake a fingerprint. Archive preparation is create-only.
Root `inspect-runtime` / `print-config` provide the planning measurements; hash
inspect-runtime's canonical JSON object **without its trailing newline**. Review
the measured binary/OS/dpkg configuration rather than blindly trusting a hash.
## Handoff, outcomes, recovery and unit prerequisites
Parent handler retains its existing device lock, consumes once, save_start
persists exact signed request, and rechecks clock/grant before effects. Bridge
creates active/0700 and expectation/signed-action/baseline/config/context files
0600 using exclusive nofollow writes and file/directory fsync. Context schema 2
contains the same grant/job/attempt/authorization/plan IDs and original UTC
deadline translated to CLOCK_MONOTONIC, not a fresh 60-second grant.
An old active directory can only move to history/<old grant UUID> when the same
parent ledger contains a definitive succeeded/failed result. Unknown/null,
unrecognized/partial handoffs or existing history destination block execution.
No tombstone/native bootstrap-attempt record is removed. Parent grant/attempt
consumption survives any active-directory move.
Python receives only fixed mode/path argv and two hash/ledger fields via stdin,
with cleared environment; no shell, secret argv or script conversion. Structured
stdout is bounded to 64 KiB (excess drained without unbounded allocation), raw
stderr discarded. Never timeout-kill APT. Client timeout is unknown while the
helper keeps running and eventually journals the real result.
Exit 0 alone is never success. Strict JSON effect_state/code/evidence validation
requires bound ledger, exact package versions, full snapshot hash, installed
fixture payload hash, and bootstrap test flags/native-record/test-result binding.
Malformed/nonzero/missing/wrong evidence -> unknown. known_failed with an armed
marker -> unknown, not failed. Existing finish() leaves consumed.result NULL for
unknown/awaiting_reboot and persists execution_evidence, retaining the device lock.
**Existing helper systemd unit is not an APT-capability deployment.** Its
ProtectSystem=strict/other hardening can prevent the required store/package
writes and namespace setup. A separately reviewed native runner/unit profile
must permit the narrowly agreed fixture writes and setup capabilities while
preserving the provider's final sandbox. No unit sandbox was weakened here.
Do not announce capability based solely on a successful helper build.
Local verification commands/results are reported in the dispatch return.
Native helper installation, IPC package execution, lock probe, fixture install/
update and VM approval/acceptance remain unrun. Tests using private temporary
ledgers/mock children are not native acceptance evidence.
Actually executed for this bridge increment:
```
/home/Kevin/.cargo/bin/cargo fmt -p rmm-privileged-helper -- --check
/home/Kevin/.cargo/bin/cargo clippy -p rmm-privileged-helper --lib --bin rmm-privileged-helper --tests -- -D warnings
/home/Kevin/.cargo/bin/cargo test -p rmm-privileged-helper --lib --bin rmm-privileged-helper
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s tests/apt_transaction -p 'test_*.py' -v
```
Final results: formatting and warning-denying Clippy passed; **16 library + 2
binary Rust tests passed**, **41 Python tests passed**, AST syntax checks passed
for **6 Python files**. No full workspace suite was run. An initial Rust test
fixture used legacy ApplyUpdates, which the current domain rejected as
`INVALID_JOB`; cryptographic/parent-ledger tests were corrected to use an
existing valid signed action without executing it or allowing it as an APT
action. This is not evidence that the missing domain package contract landed.
+3 -430
View File
@@ -1,432 +1,5 @@
# Root-helper APT transaction provider / explicit first native acceptance
# APT-Transaktionsprüfungen
**Latest 2026-11-13:** The separately WebUI-approved configure-only attempt
`33775478…` reached APT 0 and completely installed fixture 1.0, but old provider
`5ff260…` rejected acceptance on the actual host reboot flag. Its private worker
reported false; the historical job had no HOST-before sample. It remains
**unknown** (`FIXTURE_UNEXPECTED_REBOOT_REQUIRED`), with no acceptance record,
Root scope closed and APT endpoint stopped. No before measurement or successful
acceptance is inferred retrospectively.
Dieses Verzeichnis enthält den lokalen APT-Prüfprovider und den Generator seiner Testpakete. Seine eigenen Tests liegen unter `tests/apt_transaction` und prüfen beispielsweise, welche Paketaktionen zur freigegebenen Transaktion gehören. [Provider](apt_transaction.py) · [Paketgenerator](build_fixture.py) · [Tests](../../tests/apt_transaction/test_guard.py)
New source implements an original-bound readonly failed-effect classification
and a parent-namespace host-before/after contract for future jobs, matching
Spec 1.13. Ambient true/true is reported honestly; changed host flags, private
worker flags or changed boot reject acceptance. All **81 Python tests passed**
in the readonly unprivileged offline container, including actual APT argument
regressions with guarded fake effects and unchanged real/copied status. Native
classification/new-runtime 1.1 acceptance remain pending. See
[`HELPER-CONTRACT.md`](HELPER-CONTRACT.md) for the exact versioned contract.
**Earlier 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:
[APT 2.7.14 dpkgpm.cc](https://github.com/Debian/apt/blob/2.7.14/apt-pkg/deb/dpkgpm.cc#L1626-L1657).
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 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.
Reproduce that **local** configure regression using the existing development
image with APT 2.6.2 (no host APT command):
```sh
docker run --rm --read-only --network none --user 1000:1000 \
--tmpfs /tmp:rw,exec,nosuid,nodev,mode=1777 \
--tmpfs /tmp/opencode:rw,exec,nosuid,nodev,mode=1777 \
-v "$PWD/tools/apt-transaction:/src/tools/apt-transaction:ro" \
-v "$PWD/tests/apt_transaction:/src/tests/apt_transaction:ro" \
-v "$PWD/deploy/linux:/src/deploy/linux:ro" -w /src \
-e PYTHONDONTWRITEBYTECODE=1 -e RMM_APT_ARGUMENT_REGRESSION=1 \
rust-discovery-dev-build:local \
python3 -m unittest discover -s tests/apt_transaction -p 'test_*.py' -q
```
Current dedicated runner/probe/profile/agent integration and executed local
checks: [`../../deploy/linux/apt-helper-README.md`](../../deploy/linux/apt-helper-README.md).
The general helper unit remains unchanged; actual native VM measurements are
still required. Readiness alone advertises no accepted package capability.
**Helper integration contract update:**
[`HELPER-CONTRACT.md`](HELPER-CONTRACT.md) defines the implemented Rust helper
bridge, root installation/store layout, schema-2 embedded manifest and exact
remaining additive domain fields. It supersedes the older standalone signed
helper-action example below: signed-action.json must now contain the **full
original JobPayload bytes**, with `action.apt_manifest`, including exact
`transaction_bytes`. No detached/unsigned manifest is accepted. No agent
capability or native acceptance follows from this bridge build.
**Implemented, locally tested; NOT integrated or VM-tested.** No host package
installation, VM access, real native acceptance, production evidence, grant
issuance or WebUI approval has been performed here. The native process path is
real code (unshare/mount/capabilities/seccomp/APT/dpkg), not merely a parser;
its root/native execution is still unverified. Local root/installer execution
in tests is explicitly mocked. No real acceptance record was created.
Python >=3.9, standard library; OS dependencies: APT/dpkg, util-linux
unshare/mount, libseccomp.so.2, Linux x86-64 namespaces/seccomp/capabilities.
Only Ubuntu 24.04 amd64 is eligible; this is not a support/acceptance claim.
No Rust API, Cargo workspace changes, network endpoint, signature verifier,
grant service or automatic retry is included.
## The circular gate is replaced, not bypassed
There are now two distinct helper-only CLI operations:
```
/usr/bin/python3 -I /usr/lib/rmm-apt-transaction/apt_transaction.py native-acceptance
/usr/bin/python3 -I /usr/lib/rmm-apt-transaction/apt_transaction.py execute
```
* `native-acceptance`: dedicated **dev-test** action, exactly one code-pinned
fixture install OR upgrade, its own fixed job/attempt and actual WebUI approval.
It permits only absence of a *previous* native record for that fixture recipe.
It uses the same signed binding, archives, native sandbox, hooks, locks,
deadlines and independent verification as normal execution. No force/insecure/
skip-validation flag exists.
* `execute`: requires an existing matching record **and** a freshly verified,
separately UI-approved normal job/startgrant. An acceptance record never
substitutes for any signature or authorization.
**Scope matrix:** records produced here authorize only their exact fixture
recipe, package closure, runtime identity and **dev-test** profile. Production
is rejected (`PRODUCTION_ACCEPTANCE_REQUIRED`), even for a test record. General
catalog packages are rejected (`FIXTURE_RECIPE`); the bootstrap does not certify
arbitrary packages or widen provider support. Supporting those needs a separate
reviewed native-acceptance policy/provider revision, not relabelling this record.
The legacy unsigned administrator-created `native-acceptance.json` schema 1
is no longer used. Old helper contexts (schema 1) are rejected as well.
Each of these is a separate, one-time bootstrap recipe (recipe_version `1`):
| recipe_id | exact transition | architecture | origin |
|---|---|---|---|
| `rmm-apt-fixture-install-1.0` | absent -> 1.0 | all | rmm-test |
| `rmm-apt-fixture-update-1.1` | 1.0 -> 1.1 | all | rmm-test |
Exactly one package, `rmm-mvp-test`, no dependencies/scripts/triggers. One job
never installs both versions. Upgrade requires another fixed UI-approved job.
Pinned deterministic Debian ar/USTAR archives, **20,672 bytes each**:
```
1.0 74036ae81223deab3aae994fd2a2a695af408741777e1ce17dcb4e32f1235867
1.1 ef67c9fe0ba1443fcfe465768e1204763063c369a2a1da04af6027d8a9c00491
```
`build_fixture.py EXISTING_PRIVATE_OUTPUT_DIR` creates those exact bytes with
fixed metadata. It refuses overwrites and never installs/imports/publishes.
Real local dpkg-deb control/payload inspection confirms the only installed file
is `/usr/share/rmm-mvp-test/version`, with the selected version plus newline.
The builder now uses deterministic stdlib ar/USTAR construction, not the previous
timestamp-dependent `dpkg-deb --build` output. Older built archives do **not**
qualify for bootstrap; import these pinned bytes manually into the approved
catalog, verify and seal them before requesting the final 60-second grant.
## Mandatory signed-action and verified-helper contract
This module does **not** verify signatures. The root helper is the trust boundary.
Before writing any handoff files or invoking either mode, it MUST independently:
1. Verify the signed grant type/schema/algorithm/key, online validity and actual
human WebUI authorization (or explicitly labelled allowed dev-test UI
simulation), tenant/asset/agent identity and generation/assignment bindings.
2. Verify plan hash, job payload hash **of exact bytes**, fixed job/attempt,
action, execution profile, recipe/version, code/hook/config/runtime hashes,
exact complete resolved transaction and deadlines against that signed grant.
3. Enforce an explicit helper operation allowlist: `apt-native-acceptance` only
from the dedicated dev-test fixture-bootstrap action, never a generic
diagnostic/shell/API request. `apt-execute` must not invoke bootstrap mode.
4. Recheck trusted clocks/current rights and durably consume the grant and
attempt in its parent journal BEFORE spawning. Reject previous/uncertain
attempts. Unprivileged network/MCP callers cannot write these files or invoke
an unrestricted privileged subprocess API. Preserve peer-credential checks.
### Signed job payload: exact schema 1
The following object itself is the **signed/grant-hash-bound job payload**,
stored unchanged as `active/signed-action.json`; it is NOT an extra unsigned
root manifest or a caller's `verified: true` assertion. Fields are mandatory:
```json
{
"type": "rmm.apt.helper-action",
"schema_version": 1,
"action": "apt-native-acceptance",
"execution_profile": "dev-test",
"transaction_sha256": "<SHA256 of exact expectation.json bytes>",
"resolved_apt_transaction": "<complete OBJECT defined below, not a string/reference>",
"provider_sha256": "<installed apt_transaction.py SHA256>",
"hook_sha256": "<fixed installed hook SHA256>",
"apt_config_sha256": "<apt_config() bytes SHA256>",
"runtime_sha256": "<canonical runtime_identity() SHA256>",
"test_result_id": "<fixed acceptance evidence ID>"
}
```
The string placeholder for `resolved_apt_transaction` above MUST be replaced
with the complete nested object in actual payloads. Normal mode uses action
`apt-execute`. Production is a recognized profile but cannot use these test
records. The helper must verify the signed action, not merely trust ownership
of a separately supplied hash. The provider rechecks exact signed-payload hash,
type/schema/action/profile, nested transaction equality and code/config/runtime
bindings; it relies on the helper for cryptography and grant consumption.
### ResolvedAptTransaction schema 1
All fields mandatory; unknown fields/types and duplicate JSON keys are rejected:
```
schema_version: integer = 1
recipe_id: one exact fixture recipe above
recipe_version: "1"
platform: "ubuntu-24.04-amd64"
resolver_config_version: "rmm-apt-local-v1"
no_reboot: true
status_fingerprint: 64 lowercase hex characters
baseline_sha256: 64 lowercase hex characters
packages: [PackageArchive] # exactly one for this accepted scope
```
`PackageArchive` exact fields:
```
name: "rmm-mvp-test"
architecture: "all"
old_version: null for install, "1.0" for update
new_version: "1.0" for install, "1.1" for update
origin: "rmm-test"
sha256: corresponding code-pinned hash above
size: 20672
archive_path: "/var/lib/rmm-apt-transaction/archives/<same sha256>.deb"
```
The general parser still understands up to 128 package changes / 1 MiB, but that
does not authorize a broader execution scope. Frozen dataclasses/tuple closure;
strict Debian version ordering via read-only typed `dpkg --compare-versions`.
Status fingerprint hashes raw status/architecture/extended_states and trigger
database state. Dirty dpkg updates, pending triggers, repair, reinstall,
downgrade, removal, crossgrade and core/kernel/boot packages are unsupported.
`active/baseline.json` is the complete canonical all-package snapshot from
`installed_snapshot()` (`dpkg-query`), not just the changed package:
```json
{"package:architecture":{"version":"<version>","status":"install ok installed"}}
```
Its canonical byte SHA256 binds `baseline_sha256`. A new install requires actual
absence, not leftover config-files. Existing consistent noninstalled entries may
be present for other packages. Fingerprint/baseline are rechecked in the native
hook, not accepted from simulation as authorization.
### VerifiedHelperContext schema 2
Root helper writes `active/context.json` only after the checks/consumption above:
```json
{
"schema_version": 2,
"transaction_sha256": "<exact expectation.json bytes SHA256>",
"job_payload_sha256": "<exact signed-action.json bytes SHA256>",
"action": "apt-native-acceptance",
"execution_profile": "dev-test",
"effect_armed_ledger_id": "<stable parent journal row>",
"grant_id": "<verified grant ID>",
"job_id": "<fixed job ID>",
"attempt_id": "<fixed attempt ID>",
"authorization_id": "<UI authorization ID>",
"plan_sha256": "<verified plan hash>",
"not_before_ms": 1794484800000,
"start_before_ms": 1794484860000,
"boot_id": "<current boot UUID>",
"monotonic_start_before_ns": 123456789000
}
```
UTC integer milliseconds; start window <=60,000ms, exclusive upper deadline.
Helper translates that same verified deadline to same-boot CLOCK_MONOTONIC ns;
never grants another fresh window. Both clocks/boot are checked after expensive
verification, before native launch and at the final hook gate. An installation
validly started is not aborted merely because its start deadline later expires.
## Deployment / exact invocation
Planned, **not deployed here**. Root helper/operator installs reviewed files:
* `apt_transaction.py` -> `/usr/lib/rmm-apt-transaction/apt_transaction.py`, 0644
* fixed `hook` -> `/usr/lib/rmm-apt-transaction/hook`, 0755
* `/var/lib/rmm-apt-transaction` and `active`, 0700, root-owned
* sealed archives in `archives/`, root-owned; no nonroot writer
* active expectation/context/baseline/signed-action/apt.conf files, 0600
* empty root-owned active `empty`, `lists`, `cache` directories, 0700
All path components must be real root-owned nonsymlink/non-group/world-writable
paths. `apt.conf` must equal `apt_config()` bytes. Read-only `print-config` emits
them; root-only `inspect-runtime` emits canonical measured runtime identity for
the helper/planner's reviewed signed payload, not an acceptance claim.
For **either** operation, stdin is exactly:
```json
{"transaction_sha256":"<same approved hash>","effect_armed_ledger_id":"<same parent row>"}
```
Use sanitized environment and close inherited private fds. No secrets in argv.
An acceptance request must invoke `native-acceptance`; a normal signed action
must invoke `execute`. Mixing the two is rejected. Internal `hook` and
`sandbox-worker` modes are not exposed as privileged IPC operations.
## Native pipeline and evidence publication
Both modes run the same pipeline:
1. Root/signed action/recipe/runtime/preconditions/actual archive validation;
constant hook/config/code binding before APT. Native provider flock only
serializes this provider, never replaces APT's locks.
2. Bootstrap additionally writes/fsyncs O_EXCL
`bootstrap-attempt-<fixed recipe_id>.json` in BASE, independently of active/
and grant IDs. One-time per recipe; no automatic deletion/reset/retry, even
after a failed native precheck. An operator must reconcile failures and use
a separately reviewed lifecycle/revision, not remove tombstones to retry.
3. Separate native child via fixed `unshare --mount --pid --fork --mount-proc
--net`, private propagation, tmpfs `/run`/`tmp`/`var/tmp`/`dev`, protected
readonly/masked kernel/boot/control-plane/tool/archive paths.
4. Drop bounding/effective/permitted capability sets to exactly filesystem/UID
subset `{0,1,3,4,6,7,8,31}`; inherited/ambient empty. No SYS_BOOT/SYS_ADMIN/
SYS_PTRACE/KILL/RAWIO/NET_ADMIN/MKNOD. Set NoNewPrivileges, load inherited
seccomp denying reboot/kexec, module loading, mount/namespace changes,
ptrace/process writes and other kernel-control operations.
5. **Actual native prechecks inside that child:** different PID/mount/net ns,
expected namespace PID1, exact caps/NNP/Seccomp, readonly mount flags, tmpfs
identity, masked sysrq, no conventional systemd/dbus/helper sockets; invalid
reboot magic and invalid kexec flags/fds must return EPERM. These calls never
contain valid reboot magic/commands or valid kexec input. No PID1 signals.
6. Hold real existing `/var/lib/dpkg/lock-frontend` with fcntl; a separate native
`apt-get -o DPkg::Lock::Timeout=0 check` must report that frontend-lock conflict
(100 + expected lock diagnostic). `check` is read-only, not an installation
probe. Never delete locks, kill owners or use simulation to prove locking.
A busy foreign lock vetoes the bootstrap. Release only this process's fd.
7. Fsync native-prechecks record, then sandbox-ready marker. Native APT uses
exact local archives, `--no-remove --no-install-recommends` and
constant isolated config. No global APT hooks/sources/preferences; reviewed
dpkg global config is runtime-hash-bound in the signed action. Native foreign
lock wait remains bounded to 10 seconds.
**2026-11-13 native diagnosis:** `--no-download` prevented APT's local file
acquisition and emitted `**ERROR**` instead of the absolute archive filename
in protocol v3. The provider permits local acquisition of the presealed
archive; the AF_UNIX-only private worker still rejects actual IPv4/IPv6
socket creation. Both denials are now checked inside worker/hook/probe.
A permitted IP socket or unrelated resource error vetoes; this is not a
network-download allowance or acceptance/manifest/hash/path bypass.
8. Mandatory v3 pre-dpkg hook repeats signed/runtime/scope/sandbox checks,
validates the whole actual action set, actual hashes/control/payload,
status/baseline and final deadline; O_EXCL + file/directory fsync effect-armed
marker **before returning 0**. Second hook is vetoed. No fallback.
Immediately after successful file/directory fsync, UTC/monotonic deadline and
boot identity are checked again. Expiry vetoes the hook while retaining its
armed marker: conservative unknown/reconciliation, never marker reuse.
9. After native child exit 0 and valid bound markers/result, independently query
**all** installed versions/statuses, detect unexpected changes, require empty
`dpkg --audit` and exact installed fixture version-file bytes. Private /run
reboot flag is combined with host flag. Bootstrap requires no reboot flag.
10. Only then publish root-owned 0600 schema-2
`acceptance-<fixed recipe_id>.json`, staging/fsync complete bytes before
exclusive publication and directory fsync. No failed/stale-start/partial/
unknown execution is promoted. Parent must treat publication/IO uncertainty
as unknown and reconcile; a record is never an excuse to retry that job.
Record binds exact approved recipe/packages, full measured runtime (tool, hook,
APT config, resolved binaries including APT/dpkg/dpkg-deb/dpkg-query/Python/
unshare/mount/shell/libseccomp hashes and version strings, OS/kernel identity,
dpkg config fingerprint), transaction/job-payload/plan hashes, grant/job/attempt/
authorization/test-result IDs, precheck/hook/postcondition hashes and completion
time. It explicitly contains `test_acceptance: true`, `noProductionEvidence: true`.
Install and upgrade have separate records; one does not certify the other.
## Result / safety bounds
One JSON result on stdout: `effect_state` = `known_failed`, `verified`, or
`unknown`; stable `code`; structured `evidence`. Every structured bootstrap
result, including veto/unknown, carries `evidence.test_acceptance=true` and
`evidence.noProductionEvidence=true`. Verified bootstrap additionally reports
record hash/test-result ID. Exit 0 means structured result, not job success.
Malformed CLI/hook input exits 100 with generic diagnostics. Parent must journal
missing output/death/partial markers after possible launch as unknown.
No `awaitreboot` output in this version: no post-boot completion condition exists.
No reboot is invoked. Any reboot/follow-up/retry needs another fixed approved job.
No auto-configure-all, autoremove, dist-upgrade, repair, index refresh, installer
timeout killing, or automatic record/attempt clearing is provided.
APT retains its frontend lock and normally hands off the inner dpkg lock.
**No claim that both locks are held during the hook.** Direct foreign dpkg and
malicious root are outside the frontend-lock guarantee; native inner locking
still applies. Root scripts are intrinsically trusted host-filesystem code;
this is not general malicious-root containment or arbitrary deferred-side-effect
verification. Bootstrap avoids that expansion by accepting only pinned
script/trigger/dependency-free fixtures. Existing dpkg triggers/global config,
kernel, root administrators, trusted binaries/helper remain in the TCB.
## Primary sources and actual local verification
APT 2.7.14 sources read before parser implementation:
* <https://github.com/Debian/apt/blob/2.7.14/doc/apt.conf.5.xml>
* <https://github.com/Debian/apt/blob/2.7.14/apt-pkg/deb/dpkgpm.cc>
* <https://github.com/Debian/apt/blob/2.7.14/apt-pkg/deb/debsystem.cc>
Native read-only lock probe checked against `DoCheck` (`Cache.Open/CheckDeps`,
not dpkg/install) in:
<https://github.com/Debian/apt/blob/2.7.14/cmdline/apt-get.cc>.
Hook protocol **VERSION 3**, nine fields:
`name old-version old-arch old-multiarch direction new-version new-arch
new-multiarch action`. New install old triple `- - none`; `<` install/upgrade,
`>` downgrade/removal; action absolute archive path or `**CONFIGURE**`/
`**REMOVE**`. Config lines precede a blank separator and support percent escaping
and repeated unnamed lists. SHA/size/origin are NOT transmitted in v3: actual
sealed files are independently checked. Whole closure must match, including one
configure per unpack; extra/missing/repeated actions are vetoed.
`tests/apt_transaction/fixtures/install-v3.txt` is source-derived, **not a native
installation capture**.
Actually executed unprivileged, with **no host package mutation**:
```
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s tests/apt_transaction -p 'test_*.py' -v
```
**39 tests passed** at the documentation update. Original 22 guard/archive/
parser/preconditions tests plus pinned fixture/control inspection, context/
signed manifest/recipe/profile/runtime binding, native-record matrix, fsync/
partial/negative evidence rejection, mocked full driver success/unknown/failure/
stale/redelivery, mocked native mount/capability/namespace/socket introspection,
and local unprivileged seccomp invalid-input EPERM probes.
The post-fsync deadline regression advances mocked UTC/monotonic clocks (both
and each independently), observes nonzero hook outcome/no modeled dpkg start,
and verifies that the durable marker survives and prevents a second handoff.
Native root/installer/VM parts are explicitly mocked under private temporary
BASE paths; mock-generated records are deleted with those dirs and are NOT
native evidence. Safe invalid-input probes and seccomp loading really ran in
short-lived unprivileged children. No valid reboot/kexec operation or host PID1
signal was attempted. Deterministic .deb bytes were really built/read/inspected,
never installed. Full root sandbox, real APT lock conflict, native fixture
install/update, helper signature integration and VM acceptance remain **unrun**.
Im MVP planen WebUI und MCP Linux-Wartung als Skriptauftrag. Ein zur Wartung berechtigter Benutzer reicht ein Shellskript für das Zielgerät ein. Die WebUI zeigt Skript und Rechte vor der persönlichen Entscheidung. Für den Ablauf im Produkt gilt der [Geräte- und Skriptvertrag](../../proto/BACKEND_CONTRACT.md).