Files
museion/MuseionTests/AGENTS.md
T
AlexKucera f49e4b6ca0
CI / ci (push) Canceled after 0s
refactor(settings): provider facts as data
#181: ModelProvider is the provider-descriptor table — label, effort
ladder, flagship, endpoint, env var joined by wire dialect (chat/models
paths + the SSE decoder selector), auth mode (Bearer vs Anthropic's
header pair), keyless (nous rides the Portal login), and the ONE
trailing-slash endpoint trim. The probe's URL builders, auth headers,
and stream-decoder picks select by data; the per-dialect bodies and
decoders stay separate functions, not switch clothing.

ProviderCredential.resolve is the ONE credential rail (provider key,
else the shared Portal session key for keyless providers — official
endpoint ONLY, never a user-set URL). Settings' Test Connection and the
new PassReadiness module both call it; the twice-implemented #175
fallback can no longer drift. One deliberate tightening, reviewer-
blessed: a nous pass profile on a custom base_url with no pasted key now
reads missingKey where the old session-model fallback said ready — the
old copy had no endpoint gate at all.

Pass readiness leaves the session model (PassReadiness.swift maps each
pass surface to ready/missingKey/unknown over the descriptor;
MentorSessionModel stores the verdicts and reads no keys or auth
files). runPass and blindRead run their guards through one shared rail
(guardOpenPieceRun) — identical refusal strings, blockers named
honestly. No app-side model-settings store (ADR-0014 red line).

Rider: the #179 mid-pass repoint pin polls the rig's hasHeldPrompt
before releasing the held turn — runningPass flips before the one-shot
engine parks its prompt, so firing into that window false-failed under
parallel-suite load.

Full suite 668/668 (xcresult executed count). Finish-audit: three
reviewers (ponytail/security/general), zero findings above LOW; two
ponytail trims and one pin tightening applied.

Closes #181
2026-11-10 10:58:29 +01:00

7.2 KiB

MuseionTests

Purpose

Unit tests for the Museion application target, hosted in the app process (TEST_HOST).

Ownership

Owned by the root AGENTS.md contract.

Local Contracts

  • Uses Swift Testing (@Test, #expect) — not XCTest.
  • Always give @Suite its string argument — bare @Suite is stripped by this repo's swiftformat.
  • Imports @testable import Museion; app code is default-MainActor, so cross-actor tests need @MainActor or nonisolated declarations in app code.
  • Deployment target and versions follow the app target; leave CURRENT_PROJECT_VERSION = 1 here.

Work Guidance

Conventions every suite follows. Per-suite pin inventories are NOT kept here — each test file opens with a scenario header naming its issue and pins; read the file.

  • One runnable check per non-trivial fact: the smallest test that fails if the logic breaks. No fixtures or per-function suites unless asked.
  • Never touch the real machine: throwaway Homes in temp dirs (makeHome, storeHome, makeModelHome, makeSessionHome, importHome); every ProfileProvisioner.perform call injects masterRoot (the default writes the REAL Application Support); keychain tests inject their OWN account slot (a live production token is never read, replaced, or deleted); roster/defaults under hosted tests redirect to temp or assert .standard byte-unchanged; psScan is stubbed (a dev machine may run the real engine).
  • Shared helpers are internal in the founding file. When a suite crosses a file-length or type-body ceiling, split the new pins into their own file and keep the helpers where they are (PostStorePassTests, MicropubModelTests, MCPToolsPromoteTests, SettingsModelWritePathTests precedents).
  • Engine tests run IN-PROCESS at the EngineTransport seam (#178): ScriptedEngine.swift holds the scripted adapter (mode strings mirroring the retired zsh fake: full/crashAfterHandshake/hangOnPrompt/cancelOnPrompt/refuseOnPrompt/noStopReason/strayResearchOnPrompt/loadReplay*/strictMcp), the shared payloads (ScriptedPayloads), and the rig roots — build rigs there, never duplicate. Spawn observables: the rig's spawned-profiles record (which engine ran), transport identity (mentor.host.chat/oneShot) where pid pins used to live, isClosed for reaped. Child processes appear in EXACTLY ONE suite — EngineSmokeTests, one real-process wire smoke per LLM Surface (chat/pass1/pass2, ADR-0014) over the zsh fake (makeFakeACP/acpTempDir, defined in ACPClientTests.swift, kept as the wire fixture). The fake-hermes CLI harness (ProfileProvisioner/Backup suites) still speaks real Process with base64 payloads, <name>-spawn-log, <name>-prompt-log, and defer teardown at rig creation.
  • Waiting: bounded poll loops, each arming its OWN deadline; poll for the watcher rescan after disk writes. Lock/goal machine tests pass spawnsTicker: false — the real 1 s ticker could complete a met goal before an injected tick (the #30/#147 flake family).
  • Suite-name filters (-only-testing:MuseionTests/<Suite>) do not run free functions — pin things as suite members.

Suite map

  • EngineGateTests, GatelessLaunchTests — engine probe; gateless launch seam, status-pill and header state mappings.
  • ACPClientTests — turn-outcome seam + view predicates over the scripted engine (#178: the client wire contract itself lives in EngineSmokeTests; makeFakeACP/acpTempDir remain here as the shared wire fixture).
  • ScriptedEngine.swift — #178: the scripted in-process EngineTransport adapter, shared payloads, and the scripted rig roots every engine suite builds on.
  • EngineSmokeTests — #178: the ONLY child-spawning suite — one real-process end-to-end wire smoke per LLM Surface (chat on museion: handshake/stream/verdict/crash/restart/teardown; pass1/pass2: own engine under its profile, teardown reap, chat engine untouched).
  • ProfileProvisionerTests, ProfileSurfaceTests, ProfileSkillMigrationTests, ProfileProvisionerFailureTests, ProfileBackupTests — provisioning, symlink migration, failure paths, backup (one fake-hermes harness).
  • PostLibraryTests, PostStoreTests, PostStorePassTests, PostFrontmatterTests — scan, write side, pass substrate, stats capture, research notes, the frontmatter codec (#180: posture round-trips, lenient decode, named eligibility predicates).
  • DraftStatsTests, TrendViewTests — text metrics and the trend view's pure facts.
  • WritingGoalTests, WritingLockTests — Cold Turkey goal engine + lock machine (kiosk calls no-op under hosted tests by construction — never pinned by driving them).
  • MicropubTests, MicropubModelTests, MicropubMediaTests — publish wire contract, model flow, media/illustration surface.
  • MCPToolsTests, MCPServerWireTests, MCPToolsPromoteTests, ToolPayloadsTests, LearningsPaneTests, LearningDecayTests — museion-tools store, wire, promote, tool-payload decoder shapes (strict + lenient, #177), learnings pane, decay.
  • FixCardApplyTests — fix-card apply/skip/done lifecycle.
  • PostsModelTests, PassRunTests, BlindReadTests, EngineLifecycleTests, SessionLifecycleTests, SessionScopeTests, TranscriptRailTests — model orchestration over the scripted in-process engine (#178): passes, blind read, per-surface engines, session lifecycle, scoped hosting, the typed transcript rail (#177 — speaker/notice type facts through the scripted engine, prefix-free invariant, append-seam classifiers), and the #179 write-rail pins in PostsModelTests (write → one library refresh + strip cleared; failed write owns the strip; nil-Home refuses cleanly; import batch keeps per-file strip messages; mid-pass Home repoint refuses the advance — endHeldPrompt is the rig hook that ends a held turn normally, polled to via hasHeldPrompt first: runningPass flips before the one-shot engine parks its prompt, so firing into that window false-fails under load).
  • DeslopLintTests (with the DeslopLintWiringTests member) — native lint findings, config story, emit loop.
  • EditorSessionTests, ReadingPresenterTests, ProsePresenterTests, FocusModeTests, ImportExternalTests, ImageIngestTests — editor session, reading pipeline, editing-surface parity, focus math, import + image ingest.
  • OutlineTreeTests, OutlinePresenterTests, OutlineDragTests, EscEventProbeTests — outliner model, projection, drag plumbing, Esc delivery probe.
  • ProseListTests, ProseRekeyTests — prose list model + fold rendering, fold rekey pipeline.
  • SettingsModelTests, SettingsModelWritePathTests, HermesSettingsWriterTests, ProviderProbeTests, ProviderProbeTransportTests, ProviderCredentialTests — settings model, real CLI write path, probe decode + request builders, the #181 ONE credential resolution (pasted key wins, keyless fallback on the official endpoint, custom-endpoint and no-login refusals).
  • WordBoundaryTruncationTests, PolishSeamTests, ResearchCandidateTests, PersonaLoadOrderTests — UI pure seams, research candidates, persona payload contract (the four-shared-sections + load-order pins).

Verification

  • xcodebuild -project Museion.xcodeproj -scheme Museion -destination 'platform=macOS' -only-testing:MuseionTests test — verify by the xcresult EXECUTED count, never the SUCCEEDED banner.

Child DOX Index

  • None — flat directory.