Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8757134
perf(native): overlap distinct image archive preparation
roodboi Nov 22, 2026
4f5b08f
merge: integrate next into native image batching
roodboi Nov 22, 2026
cc4d231
fix(native): budget image waits and recover only owned staging
roodboi Nov 22, 2026
1992cbd
fix(native): recover interrupted manifest proof publication (HACK-2555)
roodboi Nov 22, 2026
4b05b76
fix(native): admit image disk use and retain batch failures
roodboi Nov 22, 2026
79634ca
fix(native): preserve stray image staging entries
roodboi Nov 22, 2026
dbe3281
Merge remote-tracking branch 'origin/next' into codex-hd/native-image…
roodboi Nov 22, 2026
011e97e
fix(models): require the final counterexample state
roodboi Nov 22, 2026
70a36dc
perf(native): overlap first-start project image builds
roodboi Nov 22, 2026
51f0af6
fix(native): preserve first build error through cleanup
roodboi Nov 22, 2026
a416fda
fix(native): integrate build base registry blockers
roodboi Nov 22, 2026
5828716
test(native): require registry sibling cancellation
roodboi Nov 22, 2026
9ed94b5
fix(native): deduplicate equivalent Dockerfile paths
roodboi Nov 22, 2026
15b888d
docs: add rendered native build batch chart
roodboi Nov 22, 2026
3c452ae
fix(native): build from verified local base images
roodboi Nov 22, 2026
631ff46
Merge commit '011e97e8109f51dd147ce782d66be86c2fc90034' into lead/1112
roodboi Nov 22, 2026
daec5a3
fix(native): pass base-image notices through a callback
roodboi Nov 22, 2026
fe1e5be
fix: share native image policy with build bases
roodboi Nov 22, 2026
0833576
fix: apply up tag mode to native build bases
roodboi Nov 22, 2026
af5e612
fix: interrupt native build base downloads promptly
roodboi Nov 22, 2026
79ddf26
fix: recover stranded native build base aliases
roodboi Nov 22, 2026
33baa07
fix: reuse verified legacy builds during registry failures
roodboi Nov 22, 2026
7d91dbe
fix: reclaim superseded native build base keepers
roodboi Nov 22, 2026
d804ea3
fix: use the remaining build budget for base acquisition
roodboi Nov 22, 2026
2729139
test: exercise native build base acquisition and recovery
roodboi Nov 22, 2026
e1d450d
fix: release the image cache before waiting on another tag
roodboi Nov 22, 2026
f66545a
fix: finish build alias recovery after canceled solves
roodboi Nov 22, 2026
2c756ce
fix: keep managed build arguments out of native pull
roodboi Nov 22, 2026
10986ac
fix: protect service images during native base reclamation
roodboi Nov 22, 2026
7046ea1
fix: scope the native lease helper to macOS
roodboi Nov 22, 2026
c602cc8
fix: wait for image reclamation before pinning services
roodboi Nov 22, 2026
02e1e6c
fix: keep the image fence guard independent of policy
roodboi Nov 22, 2026
0f8c077
Merge overlapped project builds into offline build bases
roodboi Nov 22, 2026
f472316
fix: canonicalize native runtime request directories
roodboi Nov 23, 2026
aa27e42
fix: keep native build base retention off startup
roodboi Nov 23, 2026
53e5546
fix: publish refreshed build tags after their bases are retained
roodboi Nov 23, 2026
6d09a7f
fix: prioritize foreground work over build base retention
roodboi Nov 23, 2026
aaf4699
feat: allow opting out of native build base retention
roodboi Nov 23, 2026
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
32 changes: 22 additions & 10 deletions docs/guides/native-candidate.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,14 @@ With it:
an unchanged context is not read again. The cache misses only a change that keeps the
size, inode, modification time and change time identical, which needs a deliberate
clock or timestamp manipulation; set `HACK_NATIVE_REBUILD=1` after one.
- Only those inputs count. A changed network response (a download in a `RUN` step),
the contents of a cache mount (`RUN --mount=type=cache`), anything outside the build
context and a base-image tag that moved do not trigger a rebuild: a reused image keeps
the base-image digests it was built from. Set `HACK_NATIVE_REBUILD=1` on `up` or
`hack restart` to build every image again; base-image tags then resolve again too.
- A changed network response in a `RUN` step or changed cache mount contents do
not trigger a rebuild. Native checks base-image tags according to the image tag
policy and rebuilds when the selected base digest changes. `hack up --offline`
uses locally recorded selections even after they expire. `hack up --refresh-images`
checks the registry for current tags. Ordinary expiry is checked after readiness.
`HACK_NATIVE_REBUILD=1` forces BuildKit to run with the recorded selection.
Cold solves let BuildKit fetch missing bases by digest. Background retention
tags a verified local base or downloads and loads it after readiness.
- When an image is actually built, BuildKit reads a private copy of the included
context, made and checked against the build key right before it runs, so edits during
a build never reach the image. The copy keeps hard links as links and gives every
Expand Down Expand Up @@ -1447,6 +1450,12 @@ If the prepared tree changes, `runtime probe` and every build
refuse with `artifact_digest_mismatch`. `runtime probe` reports `builder_prepared`:
`true` when the client is present and unchanged, `false` for a home without it.

A native start can build distinct images together, including a retained start after edits. The
four-CPU development pool runs at most three builds at once. Identical build
requests still share one build. A failure or Ctrl-C requests cancellation of
the other builds, and the CLI waits for all started builds to settle before
returning. The foreground labels output by build and reports its elapsed time.

A home without the image builder refuses a build with `builder_not_prepared`:
"The image builder is not installed in this native home", with the setup command
that adds it, instead of a missing-file error. `hack up` prints that refusal with
Expand Down Expand Up @@ -1495,11 +1504,14 @@ JSON file (a singly linked, mode-`0600` file owned by you):
the resolved base references that the receipt and the result report. Never pass a
secret as a build argument. BuildKit build secrets are the right mechanism for
secrets; native builds do not support them yet.
- Every build runs under a BuildKit source policy: only the pinned base images
resolve as images, and network sources (`ADD` of an `http`, `https` or git URL, and
image blob sources) are denied. The engine would otherwise fetch those from outside
the isolated build network. The policy also covers sources that a base image's
stored `ONBUILD` triggers add; such bases refuse before the build anyway.
- A fresh recorded base resolution whose verified image is in the guest makes
no registry request. An expired resolution checks the registry and can use the
proven loaded base if the registry is unavailable. `hack pull` refreshes build
bases as well as service images. The build key includes each base digest.
- BuildKit receives only attempt-owned local references to the verified bases.
The source policy denies other image sources and remote `ADD`, git and image
blob sources. A private cache tag keeps the base while attempt aliases are
removed, including on recovery after an interrupted build.
- Argument values reach the client only through a private definition file (mode
`0600`, removed after the build), never its command line or its environment; the
client's environment is a fixed list of its own settings. Names must be plain
Expand Down
15 changes: 15 additions & 0 deletions docs/reference/disk-footprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,23 @@ objects as attribution within those disks when measuring host space.
| Native images and BuildKit cache | [Image import](../../packages/runtime-core/src/provider/image_load.rs), [build](../../packages/runtime-core/src/provider/image_build.rs) and [reclaim](../../packages/runtime-core/src/provider/image_build/reclaim.rs) in the guest engine. | Best-effort post-build cache target of 8 GiB. No aggregate image bound found. | Image reclamation uses retained references. Failed or interrupted pruning can leave extra engine data. |
| Native graph containers, persistent volumes, networks and graph receipts | [Graph runtime](../../packages/runtime-core/src/provider/graph/mod.rs), with host journals and guest resources. | No aggregate graph or retained-volume bound. | Down and recovery retain data by default. A crash can leave resources attached to prior receipts. |

### Native build base retention

After a native `hack up` reaches readiness, Hack can retain exact build bases
as guest engine images and stage missing images in the host image archive cache.
The guest cost is the retained layers that the engine cannot share with other
images. In one 11-service project, retaining two bases added 1.06 GiB of engine
image data. Reclaim checks the current and previous verified build generations
and protects images still referenced by services or tag records.

Set `HACK_NATIVE_BUILD_RETENTION=0` in the environment that launches `hack up`
to disable automatic retention. This also disables background build-base tag
refresh for that invocation. Existing images and archives remain on disk until
their normal cleanup runs.

## Temporary paths


| Location | Owner | Growth bound | Cleanup and interrupted operations |
| --- | --- | --- | --- |
| `hkgf-*` | Foreground graph [transport](../../packages/runtime-core/src/provider/graph/foreground/transport.rs), one root per run. | No aggregate bound. | Retirement preserves evidence used by recovery. A dead publisher can leave its directories and lock records. |
Expand Down
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
7 changes: 7 additions & 0 deletions docs/reference/v5-model-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ 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 up build batch: authored dispatch, bounded concurrency, stop and drain | [native-build-batch](../../tests/models/tla/native-build-batch/COVERAGE.md) | `runPendingBuilds` captures the first failure and drains every started invocation. Controlled runtime and source CLI SIGINT regressions cover cancellation and caller exit. | Four distinct keys and a cap of three. Per-key leases and receipts are covered by native-build-retention; actual VM settlement remains host 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 (except its diagnostic restore history, HACK-2554) 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. |
| Native build-base scheduling | native-build-base-scheduling | `reuse_receipt` uses local proof and read-only engine observation. `run_with_bases` sends cold pins to BuildKit. `retain::run` checks the image fence and provider lease before retaining pinned inputs. | One base, one build receipt, and one background worker. The model covers admitted import and tagging. Download staging yields when it observes foreground work and runs without the provider lease. The model omits provider wait budgets, transport and guest-side cancellation. |
| Native build-base alias lifetime | native-build-alias | `image_build::aliases` journals before publishing, keeps a cache reference, and sweeps only while holding the attempt key lock; tests exercise the live lock and stranded journal. | One base and one attempt. The verified pin and per-attempt name are enforced in Rust. The model abstracts registry transport and Docker's image deletion behavior. |
| 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. |
| MCP cold start, cancellation and duplicate launches | mcp-startup, mcp-startup-cancellation | Shared MCP bundle identity, startup deduplication and cancellation regressions | Fresh supported client sessions, full workflow coverage and measured overhead (WU16/WU20/WU28). |
| Software install/upgrade/rollback, active launcher versus selection, compatibility | **Coverage gap:** no maintained model here is an installer/selection refinement | `scripts/installer/channel.ts`, `src/lib/release-install.ts`, `tests/v4-upgrade.test.ts`, `tests/upgrade-installer.test.ts`, Python-free installer/download tests, candidate-install contract | Historical-byte compiled-CLI cases cover key-present/lost v4 homes, real Git/worktrees, consent, migration, resolution, retirement and sentinel-free output. Four injected publication faults cover stable caught-error rollback; transfer fixtures cover retry, deadlines and uncertain cancellation. No power-loss atomicity, hostile external writer, published artifact or real native runtime proof. Add a bounded selection/lock/crash/compatibility model before primary-driver promotion. |
Expand Down Expand Up @@ -150,6 +154,9 @@ liveness/reachability controls have their own documented assumptions.
| [native-pool-stop](../../tests/models/tla/native-pool-stop/PoolStop.tla) | 210 | 10 |
| [start-graph](../../tests/models/tla/start-graph/COVERAGE.md) | 1,656,372 + 81,534 two-boot | 10 |
| [probe-readiness](../../tests/models/tla/probe-readiness/ProbeReadiness.tla) | 175,757 | 7 |
| [native-build-base-scheduling](../../tests/models/tla/native-build-base-scheduling/BaseScheduling.tla) | 12 | 2 |
| [native-build-alias](../../tests/models/tla/native-build-alias/BuildAlias.tla) | 23 | 5 |
| [native-build-batch](../../tests/models/tla/native-build-batch/BuildBatch.tla) | 296 | 2 |
| [native-build-retention](../../tests/models/tla/native-build-retention/BuildRetention.tla) | 6,181 | 4 |
| [runtime-service](../../tests/models/tla/runtime-service/RuntimeService.tla) | 1,006,849 | 11 |
| [shared-helper-instance](../../tests/models/tla/shared-helper-instance/Instance.tla) | 7,649 | 11 |
Expand Down
23 changes: 18 additions & 5 deletions docs/versions/v5/native/existing-compose-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,24 @@ the build read. Change any of them and the next `up` builds again, also after
`hack down`; the run's containers are then recreated from the new image and named
volumes are kept. `hack restart` checks the same inputs before it stops anything: a
build that fails leaves the current project running, and a rebuilt image is what the
restarted project runs. A download in a `RUN` step, a cache mount and a moved base
image tag do not count; `HACK_NATIVE_REBUILD=1` on `up` or `hack restart` builds every
image again and looks the tags up now. After an `up` that built, native removes the
older images of each build, keeping the current one, the one before it and any image
a run still uses.
restarted project runs. A changed download in a `RUN` step or changed cache mount
contents do not trigger a rebuild. A changed base digest does. An unchanged build
verifies its receipt from local state before acquiring any base. Ordinary tag expiry
is checked in the background after readiness. Use `hack up --refresh-images` to
check base tags during startup. `HACK_NATIVE_REBUILD=1` forces a build with the
recorded selection.

For a cold build, BuildKit fetches any missing base by digest during the solve. After
readiness, native tries to retain the exact bases from current and previous builds,
one at a time. It tags a matching local engine image when available and otherwise
downloads and imports the base. It defers when startup, stop, build, or reclamation
already holds the required locks. Downloads stage outside the provider lease and
stop when they observe a foreground operation. An admitted import keeps the provider
lease until verification settles. Retention has a 30-minute budget and logs failures
without changing the startup result. `hack up --offline` can reuse an unchanged
build. An edited build also needs its verified base loaded in the guest. After an
`up` that built, native removes superseded build images while keeping the current
and previous image and any image a run still uses.

**Host aliases** (`extra_hosts` with `host-gateway`, or `internal.extra_hosts`).
Native's VM has no route to your machine except through a binding to one host
Expand Down
7 changes: 7 additions & 0 deletions docs/versions/v5/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ flowchart LR
Follow [Upgrade from v4](upgrade.md). It is a backup-first procedure, and it
says how to go back.

### Native build receipts and downgrades

New native build receipts record verified base image IDs for reclamation. After
a downgrade to a runtime that rejects the new receipt field, build-image
reclamation skips cleanup when it encounters those receipts. Upgrade to the
newer runtime to reclaim the images.

## 2. What you will notice every day

**`hack env list` hides every value.** It shows names, scopes and source files.
Expand Down
Loading
Loading