Files
museion/MuseionTests/PersonaLoadOrderTests.swift
AlexKucera 22bca36857
CI / ci (push) Canceled after 0s
feat(mentor): pin prompt-end constraint ordering (#1)
Both personas gain the verbatim-shared "Draft first, rules last"
section (pass 1.5, session 1.2): the writer's material enters
context before the rule skills, so the deslop constraint tables sit
after the draft, nearest the writing they govern — the PRD's
prompt-end rule. A real ACP audit (the app's exact wire — never
-z: one-shot mode swaps the skills directive and loads nothing)
showed the baseline already read the piece before deslop, but by
model choice; the pin converts observed-once into instructed-
always, and PersonaLoadOrderTests guards presence + verbatim
parity over the bundled payload.

Verified layout, probe traps, and the additive-only propagation
cost are documented in docs/research/prompt-layout-factsheet.md
with the probe script in-repo; real-run verify: piece → persona →
deslop → verdict, 6 fix cards + 2 research candidates landed on
the real rails. Suite 479 + 1 load-flake cleared in isolation.

Closes #1
2026-10-30 11:20:01 +01:00

52 lines
2.2 KiB
Swift

//
// PersonaLoadOrderTests.swift
// MuseionTests
//
// #1 (PRD cross-cutting rule — prompt-end constraints): the persona pair
// pins the load-order doctrine — the writer's material lands in context
// BEFORE the rule skills, so the constraint tables (deslop) sit at/near
// the end of the working context, closest to the writing they govern.
// The section is shared verbatim between the personas (ref/writing
// skills/AGENTS.md: shared sections edit together or not at all).
//
import Foundation
@testable import Museion
import Testing
@Suite("PersonaLoadOrderTests")
struct PersonaLoadOrderTests {
/// The doctrine section heading both personas carry, verbatim.
private static let sectionHeading = "## Draft first, rules last"
private static func personaBody(_ name: String) throws -> String {
let dir = ((ProfileProvisioner.defaultPayloadRoot() as NSString)
.appendingPathComponent(name) as NSString)
return try String(contentsOfFile: dir.appendingPathComponent("SKILL.md"), encoding: .utf8)
}
/// The section text between its heading and the next `## ` heading,
/// trimmed — "" when absent.
private static func section(after heading: String, in body: String) -> String {
guard let range = body.range(of: heading) else { return "" }
let tail = body[range.upperBound...]
let end = tail.range(of: "\n## ")?.lowerBound ?? tail.endIndex
return String(tail[..<end]).trimmingCharacters(in: .whitespacesAndNewlines)
}
@Test func `both personas pin the load-order doctrine`() throws {
for name in ["pass-persona", "session-persona"] {
let body = try Self.personaBody(name)
#expect(body.contains(Self.sectionHeading), "\(name) lost the load-order pin")
let section = Self.section(after: Self.sectionHeading, in: body)
#expect(!section.isEmpty, "\(name) carries an empty load-order section")
}
}
@Test func `the load-order section is verbatim-shared between personas`() throws {
let pass = try Self.section(after: Self.sectionHeading, in: Self.personaBody("pass-persona"))
let session = try Self.section(after: Self.sectionHeading, in: Self.personaBody("session-persona"))
#expect(!pass.isEmpty && pass == session, "the personas' load-order sections diverged")
}
}