// // Pass.swift // Museion // // #24 (S3.1): the pass substrate's shared vocabulary — PassKind (the app's // own Pass 1 / Pass 2 names; the skill stack's vocabulary stays engine-side, // CONTEXT.md) and PassContext, the minimal engine-facing prompt shape. // import Foundation /// One structured critique pass over a Piece (#24). Pass 1 = paragraph /// level and up; Pass 2 = sentence level and below. App vocabulary only — /// strictly 'Pass 1'/'Pass 2' (CONTEXT.md). nonisolated enum PassKind: String, CaseIterable { case pass1 = "Pass 1" case pass2 = "Pass 2" /// What the pass critiques (CONTEXT.md). var level: String { switch self { case .pass1: "paragraph level and up" case .pass2: "sentence level and below" } } /// The fixed pre-pass snapshot filename in `/passes/` — latest /// per pass type kept (a re-run overwrites in place). var snapshotFileName: String { switch self { case .pass1: "pass-1.md" case .pass2: "pass-2.md" } } /// The Pass State a completed pass advances to. var doneState: Post.PassState { switch self { case .pass1: .pass1Done case .pass2: .pass2Done } } } /// The engine-facing pass context (#24, PRD G6): pass name, piece path, /// tool reminders — the methodology itself lives engine-side and never /// travels through the app. nonisolated enum PassContext { /// The minimal engine-facing prompt for one pass over one piece. /// Pinned shape — keep it a small constant, not a template system. /// Restored contract (#23, museion-tools rail): findings travel as /// fix-card tool calls (submit_fix_cards) — the reply carries the /// verdict, never the findings. #29: fact-checking research travels /// as candidate source-note tool calls (submit_research_notes) — /// engine-owned cargo in the session, never written by the engine. static func stub(kind: PassKind, pieceURL: URL, hasResearch: Bool) -> String { "Pass \(kind.rawValue) — \(kind.level).\nPiece: \(pieceURL.path)\n" + (hasResearch ? "Research notes: \(pieceURL.deletingLastPathComponent().appendingPathComponent("research").path)\n" : "") + "Critique the piece for this pass. Fact-check claims where needed — research findings " + "travel as candidate source-note tool calls (submit_research_notes), never written to disk. " + "Deliver the verdict in your reply — " + "findings travel as fix-card tool calls (submit_fix_cards). Do not write to the piece folder." } /// Honest app-side token estimate BEFORE a pass runs (PRD: predictable, /// shown before, never a deterrent). static func estimateTokens(kind: PassKind, body: String, pieceURL: URL, hasResearch: Bool) -> Int { // chars/4 — the standard ~4-characters-per-token approximation, rounded up. let total = (stub(kind: kind, pieceURL: pieceURL, hasResearch: hasResearch) + body).count return (total + 3) / 4 } }