Files
museion/MuseionTests/GatelessLaunchTests.swift
T
AlexKucera 55eff3a754
CI / ci (push) Canceled after 0s
feat(launch): flip to the gateless launch (#151)
Wayfinder map #148's terminal slice (decisions #150 architecture,
#149 UX variant A): every launch now opens straight into the
workspace. The engine check (hermes acp --check) runs async from
ContentView.task via AppGateState.startLaunchCheck — provisioning
(x3 profiles) and the daily backup auto-fire the moment it passes
(the gate era's exact onEnginePass chain, moved verbatim; once per
app-launch, first window only, no-op under hosted tests). Nothing
blocks: the blocking gate sheet, the placeholder logo screen,
gateRaised/gateDismissed, EngineGateView, and the
ProvisioningFailureCard sheet are deleted (net -350 lines with the
additions).

Engine state stays visible instead of interrupting: a 44x44 rail
pill above Archive (8pt pulsing accent dot while checking, warning
glyph on an accent-12% wash when failed, nothing at all once
healthy — the slot collapses and the rail spacing closes) and
mono-10 mentor-pane header states (checking... / engine missing /
setup failed / hermes <base> once ready — the BASE version, never
the gate's derived string; session chip renders only once ready).
Failure auto-expands an anchored floating card (340pt, accent
border — floats, never blocks): engine-missing carries #40's
install steps with the gateless correction plus Copy, guide link,
Re-check (disabled-while-checking), stderr + probed path;
provisioning failure rides the same card (failing profile named,
Retry inline). Focus mode recesses the card with the rail. Panes
spawn the engine the moment the check lands (.task(id: binaryPath)
on the nil->value arrival; a nil binary never calls openSession —
that path lands the crash card). state.json semantics unchanged
(About still reads it); #38's no-silent-degradation AC survives,
carried by the pill.

New GatelessLaunchTests pin the seam (hosted-test no-op, chain
armed, pill + mentor-header visibility mappings — flip-verified);
EngineGateTests byte-untouched and green; the dead deferFailure
(#48's Not-Now) deleted with its test. PRD G1 amended; gateless
DOX pass (Museion/AGENTS.md engine section rewritten); CHANGELOG;
devlog. The #149 prototype ships lint-clean.

Verified: full-scheme test 582 passed / 0 failed / 0 skipped
(xcresult executed count, unit + UI), swiftformat lint clean,
swiftlint 0 errors on touched files, finish-audit fanout clean
(ponytail/security/general; 5 fixes applied, header-mapping pins
flip-discriminated and restored).

Closes #151
Closes #139
2026-11-03 16:50:55 +01:00

112 lines
4.0 KiB
Swift

//
// GatelessLaunchTests.swift
// MuseionTests
//
// #151 — the gateless launch pins. Scenario:
//
// ## Scenario: Gateless launch — the workspace is the first frame
// From user story #151 (map #148; #150 architecture, #149 UX contract)
//
// Given a launch with no engine verdict yet
// When the app opens
// Then the workspace renders immediately, the engine check runs async
// (provisioning + backup auto-fire on pass), and the rail pill + mentor
// header name the checking/failed states without ever blocking.
//
import Foundation
@testable import Museion
import Testing
@Suite("GatelessLaunchTests")
struct GatelessLaunchTests {
// MARK: startLaunchCheck (#151 machinery)
/// Hosted tests run the app as their runner — the launch check must
/// neither probe nor arm the auto-fire chain there (the panes' guard
/// pattern; a fired chain would write the REAL profile roots).
@Test @MainActor func `startLaunchCheck no-ops under hosted tests`() async {
let gate = AppGateState()
await gate.startLaunchCheck()
#expect(gate.gateModel.phase == .idle)
#expect(gate.gateModel.onPass == nil)
}
/// The entry point arms onPass before the check runs — the moved
/// onEnginePass body (provisioning → backup). The model-level facts
/// stay pinned by EngineGateTests (onPass fires per passing check,
/// Re-check included; a repeat begin is a no-op).
@Test @MainActor func `wireAutoFire arms the launch chain`() {
let gate = AppGateState()
gate.wireAutoFire()
#expect(gate.gateModel.onPass != nil)
}
// MARK: Pill visibility mapping (#149 variant A contract)
/// The pill exists only while checking or failed — idle and a healthy
/// pass render NOTHING (the slot collapses, rail spacing closes).
@Test @MainActor func `pill visibility maps idle and healthy pass to hidden`() {
#expect(EngineStatusSurface.visibility(phase: .idle, provisioningFailed: false) == .hidden)
#expect(EngineStatusSurface.visibility(phase: .idle, provisioningFailed: true) == .hidden)
#expect(
EngineStatusSurface.visibility(
phase: .pass(engineVersion: "9.9.9", binaryPath: "/x"), provisioningFailed: false,
) == .hidden,
)
}
@Test @MainActor func `checking maps to the pulsing dot`() {
#expect(EngineStatusSurface.visibility(phase: .checking, provisioningFailed: false) == .pulsing)
}
@Test @MainActor func `engine failure maps to the orange failed state`() {
#expect(
EngineStatusSurface.visibility(
phase: .fail(firstProbePath: "/x", stderrExcerpt: ""), provisioningFailed: false,
) == .failed,
)
}
/// A provisioning failure rides the same orange surface under a passed
/// gate — the pill names why Passes/Sessions are dead (#38's
/// no-silent-degradation AC, carried by the pill).
@Test @MainActor func `provisioning failure keeps the pill failed under a passed gate`() {
#expect(
EngineStatusSurface.visibility(
phase: .pass(engineVersion: "9.9.9", binaryPath: "/x"), provisioningFailed: true,
) == .failed,
)
}
// MARK: Mentor header states (#149's contract — the pure mapping)
@Test @MainActor func `header state maps the gate verdicts`() {
#expect(MentorEngineStatus.state(phase: .idle, provisioningFailed: false) == .checking)
#expect(MentorEngineStatus.state(phase: .checking, provisioningFailed: false) == .checking)
#expect(
MentorEngineStatus.state(
phase: .pass(engineVersion: "9.9.9", binaryPath: "/x"), provisioningFailed: false,
) == .ready,
)
}
@Test @MainActor func `header names setup failed only under a passed gate`() {
#expect(
MentorEngineStatus.state(
phase: .pass(engineVersion: "9.9.9", binaryPath: "/x"), provisioningFailed: true,
) == .setupFailed,
)
}
/// The outrank rule: engine failure wins over a lingering provisioning
/// failure (no engine → Retry can't run anyway).
@Test @MainActor func `header engine failure outranks a lingering provisioning failure`() {
#expect(
MentorEngineStatus.state(
phase: .fail(firstProbePath: "/x", stderrExcerpt: ""), provisioningFailed: true,
) == .engineMissing,
)
}
}