feat(mentor): blind read A/B judgment (#122)
CI / ci (push) Canceled after 0s

A purposeful writer action on the open post — the "Blind Read" button
beside Run Pass — triggers a whole-document advisory judgment: the
current document against the Pass-start snapshot (the newest
passes/pass-N.md on disk), decided by a FRESH session of the same
museion profile over the existing one-shot ACP rail. Both versions
travel inline in one prompt under neutral A/B position labels with
randomized order — the judge never learns which is the rewrite — and
the A/B-to-origin reveal appends only after the verdict, so the mapping
cannot leak; cancelled, refused, and spawn-failed turns reveal nothing.

Advisory-only per decision #120: no Pass State advance, no cards, no
Learnings, the roster never grows — the verdict is display-only and
dies with the transient transcript. The writer stays judge of record;
demonstrator picks and Fix Card status are untouched. Honest refusals
for the degenerate states: no snapshot yet, an unchanged document, or
a busy rail (passes and reads refuse each other; the pass bar's one
Cancel ends either).

The pass engine's spawn/session/teardown block became one shared
runOneShot rail (failure rows speak the run's own name), the pass-bar
button gates on a derived openPieceHasSnapshot flag, the fake ACP
gained a prompt-log observable, and the GLOSSARY "Blind Read" term
landed with the issue.

Finish-audit (three reviewers): a refusal still ends .ended, so the
reveal now gates on the stopReason (flip-verified pin), plus the
Cancel-rail and pass/blind-read exclusivity pins. Suite 500; swiftformat
clean; swiftlint adds no violations over the HEAD baseline.

Closes #122
This commit is contained in:
AlexKucera committed 2026-10-30 17:31:00 +01:00
1 parent 4724e00b73
commit 97e86cf62d
15 files changed
+627 -32

No files matched your search

+26
View File
@@ -607,6 +607,32 @@ nonisolated extension PostStore {
try body.write(to: passes.appendingPathComponent(kind.snapshotFileName), atomically: true, encoding: .utf8)
}
/// #122: the Blind Read's comparison base — the newest pre-pass
/// snapshot on disk, either pass kind (a re-run overwrites in place,
/// so the newest file IS the latest Pass-start). Nil when no pass ever
/// ran over the piece. Read-only; the Blind Read records nothing.
static func latestPassSnapshot(id: String, home: URL) -> (kind: PassKind, body: String)? {
guard let dir = folder(of: id, home: home) else { return nil }
let passesDir = dir.appendingPathComponent("passes")
var newest: (kind: PassKind, date: Date)?
for kind in PassKind.allCases {
let url = passesDir.appendingPathComponent(kind.snapshotFileName)
guard let date = try? FileManager.default.attributesOfItem(atPath: url.path)[.modificationDate]
as? Date else { continue }
if newest == nil || date > newest!.date {
newest = (kind, date)
}
}
guard let newest else { return nil }
// ponytail: read-after-stat race is a stale base at worst — the
// snapshot only changes at a pass invocation, never mid-read.
guard let body = try? String(
contentsOf: passesDir.appendingPathComponent(newest.kind.snapshotFileName),
encoding: .utf8,
) else { return nil }
return (kind: newest.kind, body: body)
}
/// #24 (S3.1): advance `pass_state` when a pass completes. Monotonic:
/// the new state is the higher of the file's current state and the
/// pass's doneState — passes run in ANY order, so a Pass 1 completing