Skip to content

FLT-362 Lean comparison arm

The producer is fleet-lean-specs/Kit/Verse4Verse: locked statements, kernel-checked proof terms and deterministic JSONL generation. Files under tests/Verse4Verse.Scripture.Tests/LeanVectors are byte-for-byte copies of its vectors/verse4verse artifacts. Regenerate in that kit and copy all four artifacts together; never edit expected outcomes in C#.

LeanVectorParityTests adapts the kit's LeanVectors.VectorRunner pattern: verify SHA-256 before parsing, validate the entire corpus before invoking policy code, then compare exact verdict and ordered reason arrays for every case. Failure output groups every mismatching case by observed signature; it does not stop at the first disagreement. Schema parity checks exact enum names and order.

Deliberate comparison boundary

The existing detailed AiDraftReasonCode remains intact. The public AiDraftCheckReason enum is the nine-code Lean comparison vocabulary. AiDraftVerdict.CheckReasons explicitly projects detailed diagnostics into that vocabulary and returns [OK] for an allowed decision. It loses detail; callers still have Reasons. Unsupported Unicode/key/translation/lexicon diagnostics throw instead of disappearing. InvalidInput means an empty slice only within this comparison subset and projects to CountMismatch.

Detailed C# code Comparison code
MissingVerse, UnexpectedVerse Dropped
DuplicateSourceKey, DuplicateTargetKey Duplicated
MergedVerse Merged
SplitVerse Split
ChapterVerseCountMismatch, empty-input InvalidInput CountMismatch
UnlistedKeyMapping, InvalidException, NumberMismatch NumberDrift
ProperNameMismatch NameDrift
EmptyVerse EmptyVerse

The adapter renders natural-number book IDs as opaque ASCII B{id} keys. Numeric observations become canonical ASCII decimal tokens; name IDs 0, 1, 2 become Abel, Moses, David with an explicit fixed lexicon. All verses on one side share one translation ID. Empty text must have no lexical observations. Mapping edges and target rows are positionally aligned, and both target keys must agree. Unsupported or misaligned inputs fail the loader; none are silently omitted.

This corpus does not establish equivalence over arbitrary text: C# also handles Unicode normalization and digit-script/leading-zero distinctions, malformed application inputs, translation identities and explicit verse-range bridges. Natural-number observations do not express those distinctions. Exact rename exceptions preserve source coverage and do not grant chapter-wide or lexical waivers. Passing these vectors establishes agreement only for the emitted cases.

Reproduce

Use the existing .local-flt362 isolated SDK/cache environment and launch hidden:

dotnet build ../Verse4Verse.slnx --no-restore -m:1 -p:UseSharedCompilation=false
dotnet test ../Verse4Verse.slnx --no-build --no-restore -m:1 --logger trx

Set Logging__EventLog__LogLevel__Default=None for the local Windows test host. The pre-existing PostgreSQL-dependent producer integration test requires its configured database; absence is a failing infrastructure check, never a skip.

Baseline disagreement receipt

Producer corpus SHA-256: 3181b182c1f336efe6f829107711e320a3f2dfe8968d7dbc96626e3590154d30. The unmodified Evaluate decision logic produced 1,264 mismatches in 2,900 cases, grouped into nine full diagnostic signatures. Every mismatching verdict was Reject on both sides; all differences were missing reason codes. Full signatures and every affected case ID are preserved verbatim from test TRX output in FLT-362-lean-baseline-mismatches.txt.

The first two signature pairs have the same coarse codes as the next two but also carry detailed InvalidInput because their source slice is empty.

Cases Expected Lean reasons Actual projected C# reasons Detailed distinction
4 Dropped, Duplicated, Merged, CountMismatch, NumberDrift Dropped, Duplicated, CountMismatch, NumberDrift InvalidInput
232 Dropped, Duplicated, Merged, Split, CountMismatch, NumberDrift Dropped, Duplicated, Split, CountMismatch, NumberDrift InvalidInput
8 Dropped, Duplicated, Merged, CountMismatch, NumberDrift Dropped, Duplicated, CountMismatch, NumberDrift no InvalidInput
464 Dropped, Duplicated, Merged, Split, CountMismatch, NumberDrift Dropped, Duplicated, Split, CountMismatch, NumberDrift no InvalidInput
132 Duplicated, Merged, NumberDrift Duplicated, NumberDrift target collision
232 Duplicated, Merged, Split, CountMismatch, NumberDrift Duplicated, Split, CountMismatch, NumberDrift target collision and split
64 Duplicated, CountMismatch, NumberDrift Duplicated, CountMismatch duplicate source numbers
64 Duplicated, CountMismatch, NameDrift Duplicated, CountMismatch duplicate source names
64 Duplicated, Merged, NumberDrift, NameDrift Duplicated, NumberDrift target collision and name conflict

Merged was missing in 1,136 cases, including 64 also missing NameDrift. Another 64 duplicate-source cases lacked NumberDrift, and another 64 lacked NameDrift: 1,264 distinct affected cases total. The coarser NumberDrift combines key and numeral drift, so an existing key-drift reason can mask an additional missing detailed NumberMismatch; no claim about detailed-code equivalence is made.

Cedric adjudicated the Lean keyed-relation semantics as the intended finite contract. The C# fix adds MergedVerse when distinct source identities collide at one target key, and checks lexical observations across all rows sharing each mapped identity. Each key group caches representative token arrays plus number/name conflict flags. A mapped pair agrees only when both groups are uniform and their representatives agree; equality transitivity avoids scanning a Cartesian product. Length checks reject unequal token arrays before multiset counting. Duplicate identities already rejected, so these changes add diagnostics without granting previously rejected inputs. The captured Lean artifacts and expected outcomes were not edited.

Baseline commands (headless, existing isolated cache):

dotnet build ../tests/Verse4Verse.Scripture.Tests/Verse4Verse.Scripture.Tests.csproj --no-restore -m:1 -p:UseSharedCompilation=false
Build succeeded. 0 Warning(s), 0 Error(s). Time Elapsed 00:00:12.62

dotnet test ../tests/Verse4Verse.Scripture.Tests/Verse4Verse.Scripture.Tests.csproj --no-build --no-restore --filter FullyQualifiedName~LeanVectorParityTests --logger "console;verbosity=detailed" --logger trx --results-directory ./lean-baseline-results
Lean parity: cases=2900; mismatches=1264; classes=9
Total tests: 5. Passed: 4. Failed: 1. Exit: 1

Raw command receipts: .local-flt362/lean-baseline-build.log, .local-flt362/lean-baseline-test.log, and .local-flt362/lean-baseline-results/.

Post-fix parity receipt

The same filtered command, with results directory ./lean-parity-results, reports:

Build succeeded. 0 Warning(s), 0 Error(s). Time Elapsed 00:00:32.79
Lean parity: cases=2900; mismatches=0; classes=0
Test Run Successful. Total tests: 5. Passed: 5. Exit: 0

The tests include exact reason-enum/schema parity, captured producer shape, corrupted corpus hash rejection and duplicate schema-label rejection. Raw receipts: .local-flt362/lean-parity-build.log, .local-flt362/lean-parity-test.log, and .local-flt362/lean-parity-results/.

Final solution receipt after summary optimization

Headless commands from .local-flt362, with the existing isolated cache and Logging__EventLog__LogLevel__Default=None:

dotnet build ../Verse4Verse.slnx --no-restore -m:1 -p:UseSharedCompilation=false
Build succeeded.
    0 Warning(s)
    0 Error(s)
Time Elapsed 00:01:15.75

dotnet test ../Verse4Verse.slnx --no-build --no-restore -m:1 --logger trx --results-directory ./lean-optimized-results
Architecture: Passed 1, Failed 0, Skipped 0
Catalog:      Passed 181, Failed 0, Skipped 0
Scripture:    Passed 223, Failed 0, Skipped 0
Site:         Passed 48, Failed 0, Skipped 0
Translate:    Passed 73, Failed 1, Skipped 0
Total:        Passed 526, Failed 1, Skipped 0, Total 527
Solution test exit: 1

The only failure is the pre-existing ProducerPipelineTests.PublicCommandsImportProducerHistoryAndRemainIdempotent: Npgsql.NpgsqlException: Failed to connect to 127.0.0.1:5432, during ProducerPipelineTests.InitializeAsync() at line 37. No service configuration, unrelated test, skip or expected result was changed to hide that infrastructure failure. The full solution suite is not green in this environment.

The final Scripture TRX records the parity test as Passed with exact stdout:

Lean parity: cases=2900; mismatches=0; classes=0

That stdout is also preserved in FLT-362-lean-final-parity.txt. The Scripture total includes all five new parity/contract tests and every pre-existing Scripture test. Raw final receipts: .local-flt362/lean-optimized-build.log, .local-flt362/lean-optimized-test.log, and .local-flt362/lean-optimized-results/. The earlier full run remains separately preserved under lean-final-*.

git -c safe.directory=<worktree> diff --check exited zero. SHA-256 comparisons of the copied JSONL, digest, schema and decision table against the kit producer files all returned True. Both worktrees remain uncommitted and unpushed.