CI / ci (push) Canceled after 0s
The pass rails landed in 683ddf8 left guards #1-3 and the pass bar's
Cancel rail without direct coverage. Three new tests over the fake ACP
path: a second runPass while one streams refuses "already running" and
cancelPass ends the held turn (state stays First Draft), a pass
mid-mentor-reply refuses before the snapshot lands, and a pass against
a never-opened engine refuses "isn't ready". Every guard in
PostsModel.runPass now has a flip-verified pin (299 tests green).
Finish-audit fanout over the delta: the three whole-tree enumerator
walks became fileExists one-liners at the deterministic path (same
discrimination, suite convention); two Info findings deferred with
landing spots in the session log.
Closes #24
17 KiB
17 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. - Imports
@testable import Museion; app code is default-MainActor, so cross-actor tests need@MainActoror nonisolated declarations in app code. - Deployment target and versions follow the app target; leave
CURRENT_PROJECT_VERSION = 1here.
Work Guidance
- Non-trivial logic leaves one runnable check behind: the smallest test that fails if the logic breaks. No fixtures or per-function suites unless asked.
EngineGateTests.swiftbuilds fakehermesshell scripts in temp dirs and runs them through the realProcesspath — copy that pattern for any future child-process testing.ACPClientTests.swiftextends it into a full fake ACP server: a zsh script speaking real NDJSON JSON-RPC over stdio (makeFakeACP), with a per-binary mode file (crashAfterHandshake,hangOnPrompt,cancelOnPrompt— one chunk then stopReason cancelled,refuseOnPrompt— refusal, no chunks; default full) and a base64-encoded fix-card payload — shell quoting can never break the wire JSON.makeFakeACP+acpTempDirare internal (shared-helper convention) for reuse by later test files (#24);makeStrictFakeACPstays private. The full mode streams aagent_thought_chunkbefore the message chunks — pinning the #24 dogfood thought lane (thinking lands in a collapsed.thoughtrow, never in the critique text). Crash assertions use Swift Testing'sconfirmation(hook the callback BEFORE triggering the crash).makeStrictFakeACP(same file) guardssession/newthe way adapter ≥0.21.5 does — rejecting a missingmcpServerswith-32602— pinning the wire contract the lenient fake can't catch. #24 turn-outcome seam tests live INSIDE the suite — suite-name filters (-only-testing:MuseionTests/ACPClientTests) do not run free functions: ended/cancelled/failed mapping, labeled prompt renders the label not the wire stub.ProfileProvisionerTests.swiftextends it: the fake creates the profile at<binaryDir>/profiles/<name>(self-locating, race-free under parallel tests); payload dirs are built at runtime; the bundled-payload test asserts manifest ↔ payload correspondence. #23: the fake also speaks-p museion mcp list/mcp add(marker file = already registered, invocation log for the exact add command line, one stdin line read,mcp-add-failsreject knob); registration tests pin fresh-add-exact-command, already-registered skip, probe-failure →.failed(.register). #48 failure-path tests live inProfileProvisionerFailureTests.swift(own file — Not-Now defer + re-fail,registration only via the mcp add cli rail never hand-written yaml(config.yaml byte-identity through failed + nil-skip + CLI-registering passes — the #44 invariant as amended by #23), state.json engine-gate-only, copy-phase catch branch, path-traversal rejection, orphaned-temp sweep). Shared helpers (makeFakeHermes,makePayload,defaultSkills,provTempDir) are internal inProfileProvisionerTests.swift.ProfileBackupTests.swift(own helpersbackupTempDir/makeProfileFixture) injects profile/backups roots, a fixed clock, and apsScanstub — a dev machine may run the real engine, so the ps scan is never trusted in tests.PostLibraryTests.swift(#17, #107) — throwaway Homes viamakeHome/writePiece/writePostin temp dirs: bare corpus posts (First Draft/writer defaults), lenient + quoted frontmatter (pass_state/origin/type), two-level scan acrossprojects/<name>/<id>/+archive/<name>/<id>/(project/isArchived stamped, noise at both levels), lazy folders / hidden dirs / symlinks not surfacing, localizedStandardCompare title sort,untitlededges (blank, marker-only, unterminated frontmatter), leading-blank-line frontmatter, default Home =~/Documents/Museion.PostStoreTests.swift(#18, #107) — write side viastoreHome/readPost(same temp-dir pattern): slug algorithm cases (diacritics, CJK, cap, punctuation-only → untitled), lazy first write intoprojects/<name>/<id>/+ #59 stamp (type first) round-trip throughPost.scan, untitled fallback, case-insensitive collision suffixes over the GLOBAL slug space (projects + archive; archived slugs never reused),writeNew(project:)routing, rename (retitle + move within the same project, archived stays archived, insert-title path, same-slug retitle-only, collision -2), trash removes from projects/ and archive/, overwrite preservation + bare-post normalization,readBodystripping, blocked-project failure path, writeNew outline stamping (#109:type: outlinefirst line,projects/<project>/<id>/post.mdplacement, scan round-trip; default.postpinned). #114: convert round-trip — verbatim keeps the body + flips type (scan reads post, stamp values kept), ladder shape, vanished-piece throw, archived piece converts in place (stays underarchive/). #108: project moves —readPiece(home:root:project:id:)path-aware helper; move (byte-identity, same-project no-op), archive/restore round-trip, archived-move refusal,unarchiveProjectfresh + merge cases (dot-entries skipped),createProjectvalidation matrix (duplicate case-insensitive + NFD twin, empty/slash/dot/:rejected), hidden user folders survive unarchive (source removed only when emptied),unarchiveProjectmodel test (dirty open piece flushes before the move). Fold pin: decomposed-jamo folder on disk vs a precomposed title →-2(Swift==/Set already fold canonical equivalence — the premise asserts byte inequality;foldedis the explicit, tested contract). #24 (S3.1) pass substrate:snapshotPass(body verbatim underpasses/pass-1.md, no frontmatter; re-run overwrites = latest per type; pass-1/pass-2 coexist; vanished id throws),advancePassState(First Draft + pass1 → Pass-1 Done with origin/type/body byte-preserved through the stamp round-trip; First Draft + pass2 → Pass-2 Done order-free; Pass-2 Done + pass1 stays put — monotonic, never regresses; re-run idempotent; vanished id throws),PassContextstub shape (pass name + level, piece path, research line only when hasResearch, fix-card reminder) +estimateTokens(stub+body chars/4 rounded up, expected derived independently in the test).MCPToolsTests.swift+MCPServerWireTests.swift(#23, S2.4) — the museion-tools store + wire: anchor matrix (exact substring, occurrence 2-of-2 valid / 3-of-2 stale / vanished quote / empty quote → stale), submit round-trip (snake_case card file in<piece>/cards/, stale lands flagged, vanished piece + malformed card throw), scan newest-first + junk skip, learnings per content type (learnings/posts|outlines) + missing dir → empty; the wire tests driveMCPServer.run(lines:write:)in-process — initialize protocolVersion echo, notifications silent, both tools with typed schemas, a full submit round-trip through real JSON-RPC lines, isError tool failures, -32601/-32700.PostsModelTests.swift(#108 audits, #109) — the model-layer lifecycle the store tests can't see, viamakeModelHome(direct@MainActormodel over a temp home): archive-open-piece clears selection+session, moveToProject reopens the session at the newfolderURL, restore reopens off the archive path, New Project's draft lands in the named project, abandoning a draft for an external file dropspendingProject, unarchive of a dirty open piece flushes before the folder move,moveTargetslists empty projects from disk (default included); #109:newOutline()stages a"- "/.outlinedraft (selected project targeting waits for the bind rescan, default-project fallback),saveDraftof it materializes withtype: outlineand opens the session. #111 (S7): the guard lifecycle — mixed outline fires + holds (no session, file untouched), prose answer opens with the routing override + an edit/flush cycle drops nothing, outline answer = consented drop on save, cancel re-guards on next open, clean outline/prose pieces open untouched, reselect of the open guarded piece is a no-op, a draft staged during the ask displaces it and survives the answer, guard fires from the scan-known type too (poll-loop rescan wait);writeMixedOutlineis onewriteNewcall. #114 (S4): convert lifecycle — the open outline piece converts and REOPENS routed prose (proseOverridePostIDset, disktype: post, ladder applied); an unopened piece converts without touching the open session or selection;verbatim convert flips the posts list after the rescan(the live-report regression pin). #114 audit pins: dirty-session flushes before the transform, staging warns fromsession.text(piece open) vs disk (closed), Headings aborts when the body went lossy behind an unwarned ask (and the warned-consent path proceeds), unanswered #67 conflict aborts (alert stays answerable), failed flush aborts (piece vanished), convert dismisses a held #111 guard ask as a cancel. #23: the card-lifecycle pins — cards pre-seeded via a directFixCardStore.submitsurface after select, a card landing on disk AFTER open grows the list through the watcher-driven rescan (poll pattern, no reselect), closing the piece (newPost) clears to [], archive-open path covered.PassRunTests.swift(#24, S3.1) — the pass orchestration over the REAL client + fake ACP path, viamakePassRig(temp home + boundPostsModel+MentorSessionModelovermakeFakeACP, reusing the now-internal ACPClientTests helpers): end-to-end run (pre-pass snapshot inpasses/pass-1.md, disk stampPass-1 Done, label row "Pass 1 ·