Skip to content

feat(up): one journaled apply of a versioned runtime blueprint - #126

Merged
jamessburnss1313-dev merged 4 commits into
mainfrom
claude/wonderful-tesla-9m1q1w
Nov 29, 2026
Merged

jamessburnss1313-dev merged 4 commits into
mainfrom
claude/wonderful-tesla-9m1q1w

Conversation

@jamessburnss1313-dev

@jamessburnss1313-dev jamessburnss1313-dev commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Part of #109 · epic hanzo-inc/app#562 · contract hanzoai/hips#33

Why "Part of" and not "Fixes": #109's acceptance list includes 8 GB reference-hardware performance evidence and an airplane-mode restart run. Both need a reference machine. The epic says to close only with verified evidence, so this PR does not auto-close the issue.

What changes

hanzo up (every mode except --local) is one journaled apply of a blueprint:

  • Blueprint (lifecycle/provision.rs, schema hanzo.ai/runtime-blueprint/v1).
    • It holds the CLI release, the pinned hanzo-vm and k3s checkpoint, the mode, the shape, the Cloud image, issuer, staged set and project app.
    • hanzo.config.json is folded in by up::with_app_manifest, which is now one implementation with two readers.
    • Its key is the sha256 of its canonical JSON.
  • Journal (~/.hanzo/lifecycle/apply.json, fsync then atomic rename after each transition).
    • Resume: a failed step, or one a killed process left running, is where the next run starts.
    • Readiness: an act that returns while its step is still not ready within its patience counts as failed.
    • Reconcile: cloud and app:* run on every apply, because their acts are the reconcilers (re-pin, hanzod upstream, --link).
    • Skip: engine is left alone while it still answers.
    • Repair: a done step that stopped holding is acted on again.
    • Robust: a corrupt or foreign journal is replaced with a note.
  • hanzo up rollback applies the most recent other blueprint that ever completed, through the same apply. It deletes nothing; hanzo reset stays the only destructive verb.
  • One apply per machine. The lock is taken before the state file or hanzod are touched, and released before the dashboard opens.
  • hanzo up plan [--json] changes nothing. It prints:
    • the machine
    • the digest
    • each step with its journal status
    • every download
    • every service-manager act (or "none")
    • any blocker

The machine is read, never assumed (lifecycle/platform.rs).

  • It reads the OS, arch, $SHELL, WSL, euid, /dev/kvm and cloud-hypervisor.
  • A blocked runtime is refused before anything is written or downloaded, using vm.rs's existing preflight text.
  • Nothing runs sudo or prompts. Native k3s is adopted, never installed. Docker is not used.

Bugs fixed (each with a test that fails before the fix)

  1. hanzo up --ai-only printed "✓ AI-only environment ready" with the router inactive. It now names what did not answer.
  2. export KUBECONFIG=… was printed to every shell, which is wrong for PowerShell, cmd, nu and fish. It is now spelled for the shell that is there, or said in words if the shell is unknown.
  3. A Windows-style $SHELL path was not recognised.
  4. main's clippy -D warnings lane was red on a dead test-only import.

Evidence

Proved (run here, Linux x86_64):

  • The forge's exact test: lane is green: make test with an empty read-only HOME, then an empty writable HOME, which stayed empty.
  • cargo clippy --locked --all-targets -- -D warnings is clean.
  • 21 new provisioner and platform tests.
  • Real binary with no KVM: hanzo up was refused with the fix printed, and nothing was downloaded.
  • Real binary, --ai-only:
    • It failed, journaled the failure and named the endpoints.
    • With a stand-in on the engine port, it resumed and reached ready.
    • A repeat run printed "already in place".
    • A corrupt journal was replaced with a note.
  • Independent red review: 3 rounds, final round clean (see the comment).

Built but not proved:

  • macOS arm64 (including tests) and Windows x86_64 type-check with no new warnings. They are not run: there is no macOS or Windows runner in this estate. Windows PowerShell is untested. hanzo up plan prints that warning on those machines.
  • The full VM boot through the journal was not run: this box has no /dev/kvm. The acts are the unchanged up::up / up::start.
  • LocalOs and the env_up ordering have no test of their own.

Not done:

  • 8 GB performance evidence and an airplane-mode restart.
  • The workspace layer of the hips#33 blueprint. Its draft PR was not findable.
  • Pre-existing and out of scope: sh -c app spawn on Windows, and engine::up relying on systemd (so --ai-only on macOS fails honestly).

Rollout / rollback

  • Rollout: ships with the next tag. The first hanzo up after upgrade starts a fresh journal.
  • Undo: revert this PR. Older builds ignore apply.json, and deleting that file is harmless.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P5YBdxxi7GdeYNnGHaf4Lw

#109)

`hanzo up` resolves a blueprint (schema hanzo.ai/runtime-blueprint/v1),
keys it by the sha256 of its canonical JSON, and applies its steps
through one journal in ~/.hanzo/lifecycle/apply.json:

- a step done under the same key that still observes ready is left
  alone, so a repeated `hanzo up` acts on nothing;
- a failed step, or one a killed process left running, is where the
  next `hanzo up` resumes; a done step that stopped holding is repaired;
- an act whose observation stays false is failed, not done
  (`hanzo up --ai-only` printed "ready" with the router inactive);
- `hanzo up rollback` applies the last blueprint that completed and
  deletes nothing; one apply per machine (try_lock).

`hanzo up plan [--json]` shows the machine, digest, steps with journal
status, every download, the privileges needed and any blocker.

The machine is read, never assumed (lifecycle/platform.rs): OS, arch,
$SHELL, WSL, euid, /dev/kvm and cloud-hypervisor. A blocked runtime is
refused before any download, reusing vm.rs's preflight text. The
KUBECONFIG line is spelled for the shell that is there instead of
`export` for everyone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P5YBdxxi7GdeYNnGHaf4Lw
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-29T02:35:01.901955Z
We couldn’t complete this review. Comment @codex review to try again.
b10ef10 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

…nest privileges

From the independent review on #126:
- `cloud` and `app:*` run on every apply: up::up is the warm-cluster
  reconciler (re-pin, hanzod upstream, --link). Skipping a "ready"
  cloud dropped all of it, --link included. Only `engine` is skipped
  when it still answers.
- A step gets patience to become ready (engine 20s) instead of one
  300ms probe straight after a systemctl restart.
- The refusal and the apply lock come before the state file or hanzod
  are touched.
- The rollback target is the last OTHER blueprint that ever completed,
  journaled with this release's vm/checkpoint, refused where the cwd
  manifest would change it.
- A corrupt or foreign journal is replaced with a note, not a hard
  error; a journal whose steps differ starts over instead of panicking;
  saves fsync before the rename.
- `hanzo up plan` names every service-manager act (k3s.service via
  --no-ask-password, the router user unit) instead of claiming none.
- nu gets a literal string, so a Windows path is not read as escapes.
- the --ai-only --native runtime step accepts a running hanzo-vm
  supervisor, as up::start does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P5YBdxxi7GdeYNnGHaf4Lw
… to itself

Second review on #126: the lock lived for the whole TUI session, so a
second terminal's `hanzo up` was refused while the dashboard was open.
The state file is now read under the lock too. A rollback no longer
leaves the applied blueprint as its own rollback target. LLM.md states
that a failed --native runtime step no longer starts the engine anyway.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P5YBdxxi7GdeYNnGHaf4Lw

Copy link
Copy Markdown
Contributor Author

Independent red review (separate agent, read the diff cold)

Round 1, on b10ef10: 2 blockers, 8 should-fix, several nits. All addressed in 911f31c.

Blockers

  1. --link was silently dropped on a warm hanzo up. The cloud step was skipped as "already in place", so up::up → finish_link never ran.
  2. A repeated hanzo up stopped reconciling the warm cluster (re-pin, pull secret, workload re-apply, hanzod upstream re-registration). cloud_ready only checked the Deployment's readiness.
    • Fix for 1 and 2: cloud and app:* now run on every apply; their acts are the reconcilers. Only engine is skipped while it still answers.

Should-fix
3. --ai-only --native failed when a hanzo-vm supervisor was running.

  • Fix: the runtime observation accepts it.
  • Separately, a failed runtime step now stops the apply before the engine starts. That behaviour is now documented in LLM.md.
  1. The engine was probed once, 300 ms after systemctl restart. It now gets 20 s of patience.
  2. A corrupt or foreign journal bricked hanzo up. It is now replaced with a note.
  3. A blueprint that had completed could be lost as the rollback target. It is now tracked by completed.
  4. The apply lock was taken after state was written and hanzod was told. It is now taken before.
  5. Rollback recorded a stale vm/checkpoint, and the cwd manifest could change it.
    • Fix: it is rebuilt with this release's vm/checkpoint, and it is refused when the cwd manifest would change it.
  6. A journal whose steps differed under the same key panicked. It now starts over.
  7. The plan claimed "no step asks for root". It now names k3s.service via --no-ask-password and the router user unit.

Nits fixed: nu quoting (Windows paths) and fsync before rename.
Nit documented, not fixed: cmd's %VAR% expansion.

Round 2, on 911f31c: 1 new should-fix, plus nits. Addressed in ccb899e.

  • The apply lock was held for the whole dashboard session. It is now dropped after the apply, and the state file is read under the lock.
  • Rollback could leave the applied blueprint as its own target. That is now filtered out.
  • The repeat test was renamed to describe what it now checks.

Round 3, on ccb899e: clean.

Gaps stated, not fixed

  • LocalOs and the env_up ordering have no test of their own (they need a runtime). The state machine they drive has 21 tests against a fake world.

Gates run locally

  • The forge's exact test: lane (make test with an empty read-only HOME, then an empty writable HOME that must stay empty): green.
  • cargo clippy --locked --all-targets -- -D warnings: clean. It was red on main from a dead test-only import, fixed in 5b33700.
  • The forge itself (git.hanzo.ai) is unreachable from this session, so its own run is not shown here.

Generated by Claude Code

@jamessburnss1313-dev
jamessburnss1313-dev merged commit 37f7df4 into main Nov 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants