Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/reference/timings.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ when a completed load receipt and live readback satisfy `ensure-image`.
of attempted HTTP sends in that runtime command, including registry
authentication, retries and redirects. A fresh loaded selection reports zero.
`image.tag.record` covers the local receipt read without network transfer.
A batch ensure also includes `attrs.image_index`, the zero-based position in
the batch request, so overlapping spans can be attributed to each image.

## Growing the vocabulary

Expand Down
1 change: 1 addition & 0 deletions docs/reference/v5-model-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ must be attached to the eventual exact integration revision.
| Dependency rebind, automatic refresh, incomplete initializer, terminal reuse | dependency-rebind, dependency-auto-refresh, stopped-pool-startup, restore-history | Dependency claim/readiness, saved execution, restore history and source convergence tests | Actual installer failure, cache corruption, retained application state and resource plateau. |
| Private environment allocation lifetime: staged values and private file members, crash between record and stage, retirement with the container | **Coverage gap:** no maintained model covers environment or credential delivery; file members share the existing allocation, intent record and retirement, so the state machine is unchanged | `packages/runtime-core/src/provider/environment.rs` (preparation bounds, staging layout, verification), `managed_environment.rs` (envelope v2 refusals, forwarding), `graph/launcher.rs` (read-only binds, overlap refusals) and `environment_recovery.rs` retirement tests | Live VM evidence that only the owning UID reads a member, writes fail read-only and the member is absent after cleanup; refresh or rotation of delivered files is not implemented. |
| One pool, many project roots: share-set changes, boot mounts, per-project share selection, removal of a referenced share | multi-root-share | `provider::share_update` (journaled stopped-pool add/remove, record before owner), `project_share::{check_request, check_boot, validate_set}`, `OwnedGuest::project_share_for`; `share_update` and `project_share` unit tests | Real provider boot with an updated mount record, virtio-fs device limits and live multi-project graphs on a host VM. Cross-project cleanup is abstracted to one run's own resources. |
| Concurrent image acquisition and import | [native-image-batch](../../tests/models/tla/native-image-batch/COVERAGE.md) | Three workers may prepare independent archives. The importer is exclusive and a failed worker prevents graph start. | Four jobs with cancellation. Byte budgets, registry requests and real guest behavior need separate evidence. |
| Cached image presence before archive reads | [native-image-presence](../../tests/models/tla/native-image-presence/COVERAGE.md) | `image_load::load_waiting` requires live exact image and platform readback for receipt reuse and verifies the archive on any upload path. Explicit archive loads retain their early hash. | One request, one archive, one lease, one boot. Expiry and registry availability may change before tag selection. Guest eviction may precede readback or create. Guest ownership, filesystem behavior, interrupted imports and performance require separate runtime evidence. |
| Native image builds: unleased build versus engine stop, crash mid-build, storage recreation, foreign or forged images, reclamation versus retained graph references | native-build-retention | `provider::image_build` (shared build fence, per-key lock, incarnation/boot/engine recheck and label check at adoption, dead-attempt recording) and `image_build::reclaim` (owned labels, current receipts, retained graph state scan, engine non-force removal); `image_build` regressions | One key and namespace. Since key version 2 (HACK-2533) every edited build context makes a new key with its own receipt; reclamation keeps, per build declaration, the current and one previous key's image, plus every image retained state or a container references and every receipt without a declaration, and an `up` that built runs it best-effort after readiness (`image_build::tests::ten_edits_of_one_build_leave_its_current_and_previous_images`); the model's retained-reference safety is unchanged, and which receipt is current is regression-tested, not modeled. Snapshots of a dead owner are removed at the next build in the namespace, only after the owner is proven gone and under that key's lock (`snapshots_of_dead_owners_are_removed_at_the_next_build_of_any_key`). Which inputs a key covers (context walk, ignore rules, hard-link groups, stat cache) and restore's per-up build decision are regression-tested in `image_build::context` and `image_build` and in `tests/native-project-builds.test.ts`, not modeled. A build client orphaned by a killed `hack-native` is not modeled (the client inherits the build fence and per-key lock, so both stay held until it exits: `image_build::tests::a_killed_coordinator_leaves_its_client_fenced`); real BuildKit, engine removal semantics and guest storage are host evidence. |
| Runtime service per native home (HACK-2460, design): start race, crash at any step, version skew and drain, lost replies, resends on new connections, one-shot fallback, inspection of started but unfinished work | runtime-service | Process half implemented as a library; nothing starts or calls it yet. `TakeLock`, `LoseRace` and `Bind` map to `service::start` (a lock on the private `run/service/` directory, then `service.lock`, each checked against its path and held for the process's whole life, drain included; an existing socket is probed and kept if anything answers). `IdleExit`, `Retire`, `RefuseDraining` and `ExitDrained` map to `run`, `refuse_queued` and `shut_down`, with `settle` releasing ownership only after a complete drain. The tests in `packages/runtime-core/src/service/tests.rs` walk each action (concurrent starts, lock replacement while serving and while draining, stale and live sockets, idle exit with a held session, retire, connections queued at shutdown, drain timeout). `Crash` gets its real-process SIGKILL test in the next slice. Intent records, admission of mutations, skew, fallback and inspection are not implemented; each later slice adds the regression that walks its actions, behind `HACK_RUNTIME_SERVICE` (default `off`) | Not modelled, covered by regression tests instead: a lock held for a moment after its owner let go, because a forked child shares the open file description until it runs `exec` (the starter's bounded retry window, `service/tests.rs`); the time bound on that window; a drain that runs out of time ending the process at once with exit code 3; a signal (TERM, INT, HUP) draining like retire; and a starter that never reads the notify line (`tests/runtime_service_contract.rs`, `tests/runtime_service_hooks.rs`). The model treats a release as immediate and every drain as finishing. Implemented slice assumes the `run/service/` directory itself is not replaced (replacing `service.lock` is covered) and that the process exits after a drain that ran out of its 10 s bound; it refuses, never serves, connections queued at stop. Assumption each mutation slice must meet: its inspector distinguishes proven absence from missing evidence (for example work a provider accepted but has not yet made visible), and missing evidence yields "unknown", never "not done"; the model makes dispatched work visible at once. Liveness, several leases, cancellation of joined attempts, event cursors, dashboard authentication, the idle-exit queue race and intent-write durability are not modelled. |
Expand Down
26 changes: 26 additions & 0 deletions packages/runtime-core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,32 @@ fn run() -> Result<(), CandidateError> {
Path::new(archive),
)?)?;
}
["runtime", "ensure-images", "--json", flags @ ..] => {
use std::io::Read;
let mut input = Vec::new();
std::io::stdin()
.take(65_537)
.read_to_end(&mut input)
.map_err(|_| {
CandidateError::new("invalid_arguments", "Cannot read the image batch.")
})?;
let jobs: Vec<(
String,
hack_runtime_core::provider::image_platform::PlatformPolicy,
)> = serde_json::from_slice(&input)
.map_err(|_| CandidateError::new("invalid_arguments", "Invalid image batch."))?;
if input.len() > 65_536 || jobs.len() > 64 {
return Err(CandidateError::new(
"invalid_arguments",
"Image batch exceeds its input bound.",
));
}
print_json(&hack_runtime_core::provider::image_ensure::ensure_batch(
&discover_candidate(&requested)?,
&jobs,
&image_policy(flags)?,
))?;
}
[
"runtime",
command @ ("ensure-image" | "cache-image"),
Expand Down
Loading
Loading