PlotDirector/Docs/Codex/NameVerification.md

7.2 KiB

Explicit contextual name verification

Sources and ordinary usage

Ordinary Names availability continues to come exclusively from recorded active character names/aliases in the current series (migration 325). Character Type, species and story importance come from canonical character records. Textual matches never create or change characters, aliases, appearances or manuscript text.

Migration 329 adds one explicit, authorised manuscript lookup over the current series' active books and saved sources. Paragraph snapshots use their actual manuscript/paragraph identities, revision, ordinal and canonical book/chapter/scene mapping. Books without snapshots use existing SceneManuscriptSources, split into source-relative paragraphs. Legacy sources have no stable paragraph GUID, so their links open the canonical scene. Snapshot links resolve the paragraph's current page by identity in the existing paragraph workspace, rather than assuming its saved ordinal is still current.

Fingerprint reads return compact revision metadata/digests only. Snapshot revisions and source text hashes, plus conservative structural metadata, establish freshness across the saved series. Structural/metadata edits can therefore conservatively mark results outdated. Missing saved manuscript sources are reported as incomplete coverage. No automatic AI reverification occurs.

The local lookup narrows to authorised books before expanding stored JSON or source paragraphs. It returns at most 1,000 candidate paragraphs with bounded excerpts/adjacent context. C# applies escaped whole-word/phrase matching with Unicode letter/mark/number boundaries, normal whitespace and common punctuation variants. Substrings such as Will in William do not establish a textual match. Truncated searches/excerpts produce explicitly qualified lower-bound counts. At most 2,000 source references are retained in one lookup.

Budget, confirmation and provider execution

NameVerificationPlanner deduplicates identical focused contexts while retaining their original references. Each distinct occurrence focus is classified independently, including multiple occurrences within one paragraph. Batches have at most 20 contexts and obey the central operation's scope, HTTP-request, conservative token, output and duration budgets. The estimate uses the same request-body budget calculation and maximum retry count as the existing provider client. A result also has a bounded storage budget. The preview states the number of textual matches, planned contexts/matches, completeness and flat operation credit cost before confirmation.

The Data Protection confirmation binds the author, series, normalised name, content fingerprint, processing scope, model, policy limits, cost and ten-minute expiry. The server recomputes the plan before reservation. No match/no fitting AI context uses zero credits and no provider request, while still requiring entitlement to initiate verification. Reading existing results remains available after downgrade.

The existing IStoryIntelligenceClient sends bounded focused context only. Structured responses permit likely-name, ordinary-language or ambiguous assessments for the exact supplied IDs. Missing, duplicate, invented or out-of-scope IDs/classifications are rejected. Actual provider usage is recorded by the central ledger; routine tests use an in-memory HTTP handler and incur no external expenditure.

Persistence, concurrency and interruption

Migration 330 stores verification results against series, normalised name, fingerprint, algorithm version and scope key. A project-scoped preparation lock coalesces concurrent requests before credit reservation. Reservation binding, lease validation and result/credit settlement use stored procedures. Cached valid results incur no new processing or credits.

Useful partial findings are explicitly incomplete and may consume the confirmed flat operation cost. If processing stops without usable findings, the reservation is released. Interrupted runs have an explicit retry action with a fresh cost confirmation and the same configured bounds. Previous findings remain readable while a retry runs or fails. A retry never presents the unexamined remainder as a comprehensive search. Budget-limited results are not automatically retried or given a larger scope.

Migration 331 includes new account-scoped allowance/reservation/provider records in the established permanent account-deletion transaction, using the same account reservation lock. Project verification results follow the project's existing deletion lifecycle. No manuscript content is stored in billing/usage logs.

Shared workspace and Context

The main workspace and existing Context Names tab use the same Razor fragments, services and names-workspace.js. Textual lookup and verification require explicit selected-name actions; normal search never loads occurrence lists or initiates AI. Saved summaries distinguish confirmed recorded associations from possible textual name use. Findings are paged, ordinary-language results are collapsed, and qualified summaries retain scope/date/completeness.

Context uses its existing connection and names data invalidation. Pane searches/selections survive focus movement and relevant refreshes. Character navigation is marked as an author reference, without inheriting a Held scene as shared manuscript focus. Narrow panes have Back to Results; wide and vertically split panes size their details scroll area to the available pane height.

Verification evidence

Build and the executable regression harness passed at the phase gate. Focused matching tests cover Rose, May, Will, Mark, Hope, phrase/word boundaries, punctuation, deduplication, bounded scope, structured response validation, no-match/no-credit execution, entitlement denial, protected cost confirmation, cached reads, downgrade access, revision invalidation, failures and preserved source navigation.

Disposable SQL/service/provider qualification uses 500 synthetic characters, two books and 5,009 saved paragraphs. It verifies animal/alias associations, no textual availability inference, actual paragraph references, concurrent-job coalescing, atomic settlement, real provider-client ledger hooks with mocked HTTP, cache reuse, interrupted retry retention, downgrade denial and canonical fixture cleanup. Character/alias records remain byte-for-byte unchanged by verification.

Latest median warm timings on that isolated fixture (milliseconds): initial results 462.30 (previous procedure 2,303.50); prefix catalogue search 38.63 (previous 180.49); selected metadata 1.20; character associations 0.67; local candidate search 809.57; verification cache retrieval 5.78. These are synthetic qualification measurements, not production latency guarantees.

Compiled rendered acceptance passed in normal Chromium and actual installed Chromium PWA mode, including explicit text lookup, entitlement/allowance restrictions, confirmation/cancellation, qualified findings, unchanged availability, cache reuse, stale markers, zero-credit no-match results, all seven themes and Held Context reuse without focus changes or extra connections. Representative captures are in /tmp/pd-name-verification; final delivery evidence is collected separately. Actual-model semantic quality is not claimed from mocked-provider qualification.