FLT-362: C# baseline for the later Lean comparison¶
This phase adds pure decisions only. No UI/API routes, imports, publication paths, database models, or Lean tooling are wired or changed. FLT-360 must supply the Lean toolchain before a separate proof arm can be compared against this baseline.
Contracts and intended integration¶
AiDraftGatekeeper belongs to Scripture. A caller supplies the complete source
translation slice, AI targets with explicit source keys, and an explicit exception
list (empty is valid; null is not). Use the existing Verse model, including its
EndNumber so a bridged verse cannot silently become an ordinary single verse.
Source/target list order has no significance. Each side must contain one translation.
The alignment producer must assign AiDraftVerse.SourceKey independently of model
prose. Exceptions are trusted, exact source-to-target key relocations; identity,
unused, duplicated, conflicting, and many-to-one entries fail. Psalm headings may
use verse zero. This baseline supports one-to-one numbering changes, not historical
merge/split equivalences: those still deny, even with exceptions. Chapter counts
are compared after applying only the specified relocations, including chapters
present on just one side.
Step zero is Unicode NFC (NormalizationForm.FormC). .NET uses UTF-16 strings;
malformed Unicode is rejected before downstream UTF-8 serialization. Numbers are
maximal Unicode decimal-digit sequences: leading zeroes, digit scripts and repeated
occurrences matter. Names are ordinal, case-sensitive whole Unicode word tokens
from AiDraftNameLexicon (letters, digits, marks and connector punctuation form
words). Apostrophes and hyphens delimit tokens. The versioned table is a deliberately
limited baseline, not every biblical name or spelling. A trusted translation-specific
table may be supplied; it must be nonempty and contain unique normalized single-token
names. The model must never choose its own lexicon or exception list.
Passing checks structural and lexical invariants, not translation semantics. A text-only swap with no names/numbers drift, invented prose, or corruption outside the supplied slice is not detectable here. The source slice must be established by the trusted caller. This gate supplies no license or publication approval.
Future integration: invoke the gate on the full draft slice before draft persistence
or publication; route every display/download decision through ContentDisplayPolicy
at the server boundary. The latter lives in BuildingBlocks so Lyrics and Scripture
can share it without forbidden module references. Existing string statuses require
an explicit adapter; Catalog's moderation ReviewStatus.Approved is not proof of
rights review. Unknown or missing evidence maps to Unknown/false and denies.
ContentKind distinguishes lyrics from Scripture; source kind alone cannot express
the Scripture paywall rule. CopyrightOrigin distinguishes a live fetch from merely
displaying a stored notice. Live means fetched for this request; LiveOnly excludes
both cache and offline storage. AudioDownloadRoute.Download means exactly
/download, with any other download route mapped to Other. None means no audio
download is requested. These are trusted adapter facts, not I/O performed by policy.
AiLabelPresent means the displayed label exactly equals the returned RequiredLabel:
AI DRAFT — Unreviewed Dialect Rendering (Compare with Licensed Scripture)
Rights review is separate from translation review, so even a rights-reviewed AI draft keeps this label. Unlicensed content and rejected review states always deny.
Test baseline¶
ContentDisplayPolicyTestsenumerates all 98,304 combinations of the seven finite enum domains and three booleans, including declaredUnknownvalues. It separately checks undeclared enum values and null input. Each rule has a rejection assertion; positive witnesses cover all three sources and prevent deny-everything vacuity.AiDraftGatekeeperTestscovers merge/split/drop/duplicate, exact Psalm exceptions, unchanged chapter counts with swapped IDs, numbers/names multiplicity, Unicode boundaries, NFC/NFD equivalence, empty verses, malformed input, and invalid exceptions.- The CsCheck suite runs 2,000 generated valid mappings with a fixed replay seed and single thread. It varies verse count, chapter, numbers, names, book and relocations; reverses target order; then checks number/name drift, blank, drop and split variants. A completed-case assertion prevents silently reducing the requested sample size.
CsCheck's generation, shrinking and replay interface follows its upstream documentation.
Five seeded mutations for comparison¶
These are proposed mutations, not bugs left in production. Apply one at a time to an isolated comparison branch, run the named tests, record output, then revert it. No mutation execution or kill-rate claim is made by this list.
| ID | Planted bug | Expected failing test |
|---|---|---|
| M1 | Remove target-key injectivity rejection; keep chapter counts and exact exception checks | ExceptionListCannotGrantBlanketWaiversOrIntroduceCollisions (one explicit move collides with an unchanged key) |
| M2 | Return raw text from normalization instead of NFC | NfcAndNfdAreEquivalentBeforeNameExtractionAndInputsAreNotMutated and generated José cases |
| M3 | Compare digit sets instead of multisets | DigitSequencesPreserveIdentityAndMultiplicity (40 40 versus 40) |
| M4 | Exempt AI drafts from the Scripture paywall rejection | Exhaustive display-policy enumeration: otherwise-valid AI draft with Paywall=true |
| M5 | Accept stored copyright for Bible Brain when CopyrightShown=true |
Exhaustive display-policy enumeration: otherwise-valid Bible Brain with CopyrightOrigin.Stored |
For the later comparison, keep these outcomes and generators identical between arms. Record tree, runtime, seed, generated-case count, finite-space count, mutation results and any proof assumptions. Passing randomized tests is not an exhaustive proof over text or arbitrary verse collections.
Local verification environment¶
The validation run uses the already installed .NET SDK 10.0.301, headless with
MSBUILDDISABLENODEREUSE=1, MSBUILDENSURESTDOUTFORTASKPROCESSES=1,
DOTNET_NOLOGO=1, and shared compilation disabled. Scratch SDK selection, process
state, logs, TRX results and offline packages live under ignored .local-flt362/.
No global SDK, tool or application installation is required.
This sandbox cannot read the user NuGet configuration; Windows TLS also fails with
No credentials are available in the security package. Local APPDATA/CLI state and
an explicit offline NuGet configuration avoid accessing that user state. CsCheck
4.9.0 was fetched from NuGet's official flat-container endpoint using the already
installed OpenSSL executable with certificate-chain and hostname verification.
Its package SHA-256 is
81A5F0DD29BD751C8CC339D389CA02721C57213C410F0A5F51C506A3B1B49929.
Ordinary offline dotnet restore then succeeded using this package and the existing
package cache; repository NuGet sources and security settings remain unchanged.
The online vulnerability audit is unverified in this environment.
Cross-family plan review could not run: the council MCP required unavailable approval, and the Clahadore CLI usage governor denied execution because native usage state was unavailable. Neither control was bypassed. A separate Cedric read-only static review found no high-confidence defects; that does not substitute for a cross-family gate. No commit, push, deployment or publication is performed.
Observed build/test receipts¶
From .local-flt362/, with the local environment described above:
dotnet build ../Verse4Verse.slnx --no-restore -m:1 -p:UseSharedCompilation=false
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:01:06.17
dotnet test ../Verse4Verse.slnx --no-build --no-restore -m:1 --logger trx --results-directory ./results
Architecture: Passed 1, Failed 0
Catalog: Passed 181, Failed 0
Scripture: Passed 218, Failed 0
Site: Passed 47, Failed 1
Translate: Passed 73, Failed 1
TRX inspection reports NewTests=34, Passed=34, Failed=0, including the exhaustive
finite-input and 2,000-case CsCheck tests. The solution test command exits 1: Site's
existing last-good-content test cannot write to Windows Event Log, and Translate's
existing producer pipeline integration test cannot connect to PostgreSQL at
127.0.0.1:5432.
The Site environment issue was resolved for testing only, without editing code:
$env:Logging__EventLog__LogLevel__Default = 'None'
dotnet test ../tests/Verse4Verse.Site.Tests/Verse4Verse.Site.Tests.csproj --no-build --no-restore --logger trx --results-directory ./results-eventlog
Observed final line:
Passed! - Failed: 0, Passed: 48, Skipped: 0, Total: 48, Duration: 821 ms - Verse4Verse.Site.Tests.dll (net10.0)
PostgreSQL remains an explicit infrastructure blocker, not a skipped or passing
test. Docker access is also denied by this sandbox. CI provisions a disposable
PostgreSQL 17 service for this test; rerun ProducerPipelineTests with that service
and the normal test connection configuration when available. git diff --check
exits 0. Raw receipts remain in .local-flt362/.