Kk-carrier docs

Test plan

Use this plan to validate the external runner design. The harness guide explains test structure and fault coverage.

Run the checks

Node 24 and the repository's pinned pnpm are required.

pnpm install --frozen-lockfile
pnpm check
pnpm test:runner
node harness/src/cli.ts --list
node harness/src/cli.ts sim
node harness/src/cli.ts sim --seed 42 --json

pnpm check includes typechecking, lint, ratchets and all Node tests. test:runner is a focused alternative when iterating on the external boundary, not an extra requirement after the full suite. --list lists registered harness checks; protocol and real-runner Node tests also contribute coverage.

Two gates: the framework suite and the transaction completion release gate, followed by product acceptance Framework suite Acceptance criteria below, every layer of the harness. pnpm check gates Linux and macOS in CI Transaction completion gate Real worker, live service, killed processes, stale locks, budgets. supervise.test.ts, lock.test.ts required for the initial release Product acceptance Your installer on your target platforms, with its own data. product repository not certified by a green suite
A green framework suite proves the mechanism. It does not certify a product's platform support.

Acceptance criteria

AreaRequired behaviorFailure that must be detected
Runner acquisitionVerify runner size/hash before execution; preserve exit result and clean scratch codeCorrupt runner executes or worker failure becomes success
Request boundaryValidate wire version, fields, id, target and consent before loading the adapterInvalid input reaches trusted product code
Ownership and policyNew upgrades respect installation owner, approved target and compatibilityAnother manager's install is changed or the selected version changes after consent
Product acquisitionVerify exact target bytes; bound stalled transfers and validate resumed contentCorrupt, truncated or mismatched bytes reach staging
TransactionJournal intent before effects; serialize operations; retain a recoverable stable slotConflicting writers, illegal transitions or loss of the fallback
Service transitionStop old instance, start candidate, check live identity/version and declared lifecycle surfacesCached evidence, stale instance or wrong target authorizes promotion
Failure recoveryRoll back before durable promote intent; replay commit after itA live candidate alone is treated as a committed transaction
Retry and receiptsSame id/target replays the recorded result; different target is rejectedRetry repeats lifecycle effects or rewrites an earlier result
Controller boundaryEnforce call budgets and validate response shapeHung/failed command or malformed probe reports success
Workloads and dataTest the product's promised quiesce/resume and migration behaviorRollback restores bytes but loses promised workload state
ObservationPreserve unreadable/absent/observed distinctions; report actual outcomeMissing data becomes success, or historical success is presented as current health

The real-runner suite builds a runner and controls a separate service with no K import. It covers successful upgrade, wrong-version rollback, concurrent-worker refusal, worker death between stop and start, offline recovery and receipt replay. Generated crash cases and seeded simulation cover mechanism-level interleavings. Neither establishes exhaustive OS failure or physical power-cut coverage.

Transaction completion release gate

The Linux process tests in core/src/launcher/supervise.test.ts exercise these cases with a built worker and live service. core/src/txn/lock.test.ts races eight real processes against a stale lock; engine tests cover every recovery call budget. Whole-invocation loss is simulated by killing supervisor and worker, not by a physical power cut. Product OS startup triggers remain separate acceptance.

ScenarioRequired result
Worker exits without a durable outcomeSupervisor invokes recovery and returns the settled result, not launch success
Upgrade or recovery call hangsBounded execution; fence outstanding effects before any replacement worker
Worker dies but a controller action survivesNo takeover until the remaining writer is stopped or safely fenced
Another installer starts during recoveryOne state writer; original operation stays bound across retries
A newer operation completes before the old supervisor resumesOld supervisor reads/replays its own result and never recovers or mutates the newer operation
Recovery repeatedly failsFinite attempts and elapsed time; explicit unresolved result, retained state and executable recovery path
Installer starts with unfinished workSettle it before accepting new work; do not silently retry the failed target
Crash during terminal reporting or cleanupRecorded result is replayable; cleanup cannot erase required recovery state
Whole machine or supervisor stopsNext installer invocation restores consistency; product OS startup trigger tested separately

Use real worker/controller processes for timeout and takeover cases, including late effects and competing invocations. Keep generated journal-fault tests for transaction ordering. Run both successful settlement and deliberately failed recovery so an implementation that always returns success cannot pass.

Maintaining test quality

For larger deterministic runs:

node harness/src/cli.ts sim --start-seed 1 --seeds 50000

The nightly workflow runs an expanded seed set and retains failures in .k-harness/sim-failures.json. Replay the reported seed before turning a discovered failure into a fixed regression case.

Product and platform acceptance

The CI workflow gates Linux and macOS checks; Windows is informational while the harness port remains incomplete.

Before shipping an installer, test its actual packaging, installation ownership, first-install baseline, running-service upgrade, bad-candidate rollback, recovery while offline, workload/data preservation, and survival outside the application's service unit. Verify cloud reconnection separately if the product promises it.

K does not supply a universal fresh-install procedure, a signed distribution service, reversible data migrations or automatic recovery after a machine reboot.