Files
zosstorage/docs/VIBE_HOWTO.md
Jan De Landtsheer 507bc172c2 feat: first-draft preview-capable zosstorage
- CLI: add topology selection (-t/--topology), preview flags (--show/--report), and removable policy override (--allow-removable) (src/cli/args.rs)
- Config: built-in sensible defaults; deterministic overlays for logging, fstab, removable, topology (src/config/loader.rs)
- Device: discovery via /proc + /sys with include/exclude regex and removable policy (src/device/discovery.rs)
- Idempotency: detection via blkid; safe emptiness checks (src/idempotency/mod.rs)
- Partition: topology-driven planning (Single, DualIndependent, BtrfsRaid1, SsdHddBcachefs) (src/partition/plan.rs)
- FS: planning + creation (mkfs.vfat, mkfs.btrfs, bcachefs format) and UUID capture via blkid (src/fs/plan.rs)
- Orchestrator: pre-flight with preview JSON (disks, partition_plan, filesystems_planned, mount scheme). Skips emptiness in preview; supports stdout+file (src/orchestrator/run.rs)
- Util/Logging/Types/Errors: process execution, tracing, shared types (src/util/mod.rs, src/logging/mod.rs, src/types.rs, src/errors.rs)
- Docs: add README with exhaustive usage and preview JSON shape (README.md)

Builds and unit tests pass: discovery, util, idempotency helpers, and fs parser tests.
2025-09-29 11:37:07 +02:00

6.0 KiB
Raw Blame History

VIBE HOWTO — Work Fast Without Re-reading the Tree

Purpose

  • Ship features incrementally, with minimal context reload.
  • Use grep-friendly region markers, a single API index, and clear responsibilities per module.
  • Keep safety and error conventions explicit and consistent.

Key Ideas

Quickstart

  • Build:
    • cargo build
  • Inspect CLI:
    • cargo run -- --help
  • Run with config and debug logs:
    • cargo run -- --config ./config/zosstorage.example.yaml --log-level debug
  • Default config file location (initramfs/user space):

What the REGION markers mean

  • REGION: API — one-liners for public items; grep target
  • REGION: RESPONSIBILITIES — scope and non-goals
  • REGION: EXTENSION_POINTS — how to extend without rewriting modules
  • REGION: SAFETY — invariants; when to abort; idempotency rules
  • REGION: ERROR_MAPPING — exact mapping to Error variants
  • REGION: TODO — the next concrete steps to implement

Where to start (by responsibility)

Daily workflow (feature implementation)

  1. Find the module

    • Open the file and read the REGION header block for a 10-second overview.
    • If you dont know where to look, grep by region:
      • grep -R "REGION: TODO" src/
      • grep -R "REGION: API" src/
  2. Implement only the declared APIs first

    • Keep signatures stable (as in docs/API-SKELETONS.md).
    • Replace todo!() bodies one by one.
    • Add safety and error notes under REGION: SAFETY and REGION: ERROR_MAPPING.
  3. Keep docs in sync

  4. Validate and build

Error policy (quick rules)

  • Map external tool failures to Error::Tool with status and stderr (see src/errors.rs).
  • Validation failures should be Error::Validation with clear messages.
  • Config IO/parse issues are Error::Config; reporting IO errors are Error::Report.
  • Use Error::Other(anyhow) sparingly (last-resort wrapping).

Safety and idempotency rules

  • Never change a disk that isnt empty when require_empty_disks=true.
  • Partitioning must guarantee GPT, 1 MiB alignment, reserved GPT names, and no preexisting signatures.
  • Filesystems must use reserved labels: ZOSBOOT (ESP) and ZOSDATA (all data filesystems).
  • Orchestrator must do nothing on already-provisioned systems and exit success.

Suggested first implementation tasks

  • Utilities (unblocks everything else)
    • Implement which_tool, run_cmd, run_cmd_capture, udev_settle in src/util/mod.rs
  • Kernel cmdline data: URL support
  • Logging init

VM test matrix (virtio /dev/vd?)

  • 1 disk (/dev/vda):
    • single → btrfs on data, label ZOSDATA
  • 2 disks (/dev/vda, /dev/vdb):
    • dual_independent → btrfs per disk (two ZOSDATA)
    • bcachefs cache/backing → /dev/vda cache (SSD-like), /dev/vdb backing (HDD-like), label ZOSDATA
    • btrfs_raid1 → mirrored btrfs across both, label ZOSDATA
  • 3 disks (/dev/vda, /dev/vdb, /dev/vdc):
    • bcachefs → cache on /dev/vda; backing on /dev/vdb and /dev/vdc with two replicas; label ZOSDATA

Continuity checklist (resume after a break)

Commit discipline

  • Small commits per module/functionality.
  • Keep REGION markers accurate (especially API and TODO).
  • When changing behavior, update docs and/or ADRs in the same PR.

Reference index