Files
museion/MuseionTests/ProfileLayoutTests.swift
AlexKucera a8b158ca26
CI / ci (push) Canceled after 0s
refactor(profiles): one layout + config-set rail
#182: ProfileLayout owns the profile root default and every per-profile
path (dir, .env, configured marker, gateway pid, skills dir) — the five
scattered profile-root literals are gone; the provisioner, the settings
writer, and backup/restore derive paths only through it, pinned once in
ProfileLayoutTests. RESTORE.md prose and the ps-scan grep keep their
literal text deliberately (doc text and argv matching, not paths).

HermesConfigRail owns the config set/unset contract once: argv shape
(+--force), provider-first hoisting (switching providers clears a stale
inherited base_url — a caller can no longer order it wrong), ✓-line
verification, unset-idempotence. The provisioner seeds provider/default/
max_tokens; the writer edits provider/default/effort/base_url — each
keeps its own key list, only the mechanism and ordering rule unify. The
rail's Failure carries key/profile/excerpt for both error surfaces.

Audit hardenings folded in: a leading-dash value refuses before any
spawn (free-text model/endpoint fields cannot reach the child CLI as
options), whitespace-only endpoints read as empty at both writer gates,
the deliberate 500-char excerpt cap is pinned not just commented, and
the failed-unset branch is pinned (the fake hermes grew a
config-unset-fails knob).

Full suite 684 passed / 0 failed; dash + whitespace pins flip-verified.

Closes #182
2026-11-10 11:32:47 +01:00

36 lines
1.5 KiB
Swift

//
// ProfileLayoutTests.swift
// MuseionTests
//
// #182 — the profile layout's one pinning suite.
//
// Scenario: A layout change is one module + one suite — From user story #182
// Given the Hermes profile layout (root, per-profile dir, .env, marker,
// gateway pid, skills dir) is owned by ProfileLayout alone
// When any layout fact moves (root renamed, a file renamed)
// Then ProfileLayout.swift plus exactly this suite change — the provisioner,
// the settings writer, and backup/restore derive every path through it and
// no literal profile-root string exists outside the layout module.
//
import Foundation
@testable import Museion
import Testing
@Suite("ProfileLayoutTests")
struct ProfileLayoutTests {
/// Pinned against LITERALS (not the layout's own inputs) so a fact change
/// fails here — this suite is the layout contract of record.
@Test func `root default is the hermes profiles dir`() {
#expect(ProfileLayout.defaultRoot == NSHomeDirectory() + "/.hermes/profiles")
}
@Test func `per-profile path builders pin every layout fact`() {
#expect(ProfileLayout.profileDir("museion-pass1", root: "/r") == "/r/museion-pass1")
#expect(ProfileLayout.envFile(in: "/r/museion") == "/r/museion/.env")
#expect(ProfileLayout.configuredMarker(in: "/r/museion") == "/r/museion/.museion-provisioned")
#expect(ProfileLayout.gatewayPID(in: "/r/museion") == "/r/museion/gateway.pid")
#expect(ProfileLayout.skillsDir(in: "/r/museion") == "/r/museion/skills")
}
}