PlotDirector/Docs/Writer/Writer-Phase3B1-Integration-Correctness-Completion.md

19 KiB
Raw Blame History

Writer Phase 3B.1 — integration correctness completion

20 November 2026 (Europe/London). Scope: F1/F2 from the integration audit, audit commit e7c35ae, existing shared branch codex/word-companion-native-phase1-20261104.

F1: Review fallback selection

The accepted Reader resolver correctly returned no precise paragraph for chapter-only or unmapped-scene Focus. Review's selectNarrativeParagraph previously changed its local selection only when supplied a paragraph, so the null branch reloaded the previous passage. Its notes panel, new-annotation reference and precise Word target could disagree with the chapter fallback.

The null branch now clears the local paragraph/range, precise Word paragraph and scene, panel's selected scene, scene-specific note context and hidden new-annotation reference fields before loading chapter context. Scene annotations from the previous selection are hidden immediately, including while the context request is pending or fails. Existing recorded annotation provenance is not changed. The unmapped-scene explanation now describes the chapter fallback and explicit passage selection.

The existing dirty/busy/text-selection/dialog gates still run before this reset. Unsaved annotation/note drafts keep their original references and text. After Save/Cancel and explicit Show current focus/Go, applying the deferred fallback performs the reset. Selecting an accepted passage explicitly afterwards still restores its verified scene context. Neither fallback nor selection writes an annotation or moves Word.

F2: historical native AI-review positions

Previously the AI-review page filtered live documents by manuscript GUID and numeric Word revision and queued the stored suggestion's offset. A new open session can reuse that revision number, so this was not sufficient position provenance.

NativeReviewNavigation now validates both the chooser and the POST action. Eligibility requires:

  • Correct author/book/manuscript and exactly one live lease for the source session, then the explicitly selected instance/session on POST.
  • Nonempty original source-session provenance inside the authenticated capture, with its revision matching the result and live session; available saved Word with acknowledged-navigation capability.
  • Existing authenticated encrypted capture, unprotected using the existing NativeImport.Source.v1 purpose, with matching source session/revision/book/manuscript/chapter bounds.
  • Valid complete capture geometry; its recomputed content/position hash must match the review's stored hash. Suggestion start/end must coincide with actual captured paragraph boundaries within that chapter.

The content proof is the retained authenticated capture/hash plus the unchanged original saved live session/revision. It is not a new live Word text read, a guess from similar prose, or a canonical GUID inferred from an offset. An unsaved, changed, reopened, copied, ambiguous or unverifiable source is refused. The stored procedure returns the review table, whose columns do not include the model’s optional SourceSession/SourceRevision. The guard therefore derives provenance from the authenticated capture; if optional model fields are supplied, it additionally cross-checks them. Missing valid captured provenance/source is a supported legacy read/decision state, not a reason to rewrite historical records or reimport a book.

Refused navigation returns HTTP 409 with a brief explanation. The review remains readable and approve/reject controls remain available; the unsafe chooser is omitted. Valid navigation uses the existing presence command queue with saved-state and acknowledgement requirements, existing ID/expiry/session/manuscript fences and native execution checks. The UI continues to say requested, never completed merely because a request was queued. Existing correlated completed/failed/timed-out receipt behaviour remains intact. No parallel transport or receipt system was added.

Changed files and permanent regression coverage

File Change
writer-review.js Clear obsolete local/annotation/Word targets on non-precise Focus application
narrative-focus-review.js Accurate existing fallback explanation
NativeReviewNavigation.cs Shared original-session/content proof and unambiguous candidate guard
NativeWorkspaceController.cs Apply guard to GET chooser and POST; queue through existing acknowledged navigation
native Review view Explain unavailable original position without removing decision controls
application composition Register scoped navigation guard
NativeReviewNavigationTests.cs Controller/service/queue contract tests; focused executable entry and full harness registration
test entry points Register F2 suite and --native-review-navigation command
ToolbarBrowserHost.cs Isolated accepted fixture with same-chapter scene association removal, preserving paragraph GUIDs
reader-word-freshness.cjs Assert metadata updates in the existing collapsed details rather than requiring its timestamp to be visibly expanded
writer-phase21-word.cjs Qualify navigation through authoritative Global Focus instead of superseded objective-save event; initialise independent fixture focus and assert objective remains unchanged
writer-phase3b1-review.cjs Permanent real Chromium/MVC regression based on audit reproduction, repeated in simulated PWA

F1 coverage includes mapped→chapter-only/unmapped/mapped within one chapter, cross-chapter navigation, accepted mapping removal with stable paragraph identities, dirty annotation/note deferral and explicit resumption, delayed obsolete panel responses, refresh/cached return, and explicit passage reselection. It asserts correct Global Focus/chapter, empty obsolete paragraph/scene/Word/new-annotation targets, and zero automatic annotation saves or Word navigation commands. Existing Focus synchronisation tests additionally cover delayed/out-of-order chapter responses and obsolete Reader scroll restorations.

F2 exercises valid original source, the actual persisted shape with absent optional model fields but complete authenticated capture, failed/timed-out acknowledgement, reopened sessions including equal numeric revisions and changed preceding text, copied properties, missing session/revision/capture, mismatched source session, changed capture/hash, changed live revision, unsaved Word, wrong author/book/manuscript/instance, expired/replaced leases, ambiguous duplicate source sessions and non-boundary offsets. Unsafe cases issue no native command (therefore no simulated Word selection); review reading/decisions remain available for the owning author. Navigation assertions compare the source/review record before and after, with repository proxies rejecting unrelated writes. Physical Word selection is not simulated as physical acceptance.

Architectural and data preservation

No SQL migration, schema change, inline application SQL, native/protocol/version change, manuscript identity change, annotation reference rewrite, new editor or ribbon control. Word document binding and accepted content remain authoritative through their existing contracts. Global Focus does not move Word automatically; Word observations do not change Global Focus. Objectives, sessions, intentions and local reading positions keep their independent targets. No R1/R2 reliability work, optional Context acknowledgement change, Phase 3B.2 or 3B.3 was undertaken.

The unrelated untracked Docs/Investigations/CanonicalManuscriptArchitectureAssessment.md remains untouched. Remote fetch/pull completed before changes; shared-branch updates use ordinary commits/push, without rewriting history.

Automated qualification

  • Solution build passed, zero warnings/errors. The initial normal build passed; one later build process failed with an internal CLR error before compilation. Retrying serially with -m:1 -nr:false -p:UseSharedCompilation=false passed cleanly. This was not reported as an application-test failure or a Windows build.

  • Full executable application harness passed 633 checks, exit 0, including new historical-review guards and existing Writer/Review/Focus/Reader/Word checks.

  • New F1 rendered-MVC Chromium suite passed in normal browser and simulated PWA with all nine requested transition/retention scenarios and zero automatic annotation/Word commands.

  • Current Phase21 Review browser/simulated-PWA suite passed chapter/scene/passage annotation create/edit, classification/resolution, responsive layouts, panels and Focus navigation.

  • The historical writer3-review.cjs suite stopped at a superseded “Reading & Audio Review” summary (now a hidden dialog heading). It is not claimed to pass. Current Phase21 Review covers the actual audio dialog/ribbon and annotation UI. No production UI was altered to satisfy the obsolete selector.

  • The Phase21 Word test initially dispatched the superseded objective-save event and assumed process-global fixture Focus would reset between browser contexts. The test now initialises its own Focus and uses PlotDirectorNarrativeFocus.set, preserving an explicit objective-target assertion. Current normal-browser/simulated-PWA repeated navigation, unique command IDs, updated focus and cross-book rejection pass.

  • Global Focus synchronisation and Manuscript Reader browser suites passed, including stale chapter responses/scroll restorations and three widths × four themes × browser/PWA. Reader accepted-metadata freshness passed in browser/simulated PWA, preserving selected text and prose DOM. Its assertion now waits for attached timestamps because current Review deliberately collapses metadata details; production metadata visibility was not changed.

Persistence qualification correction

Final persistence inspection established that dbo.NativeChapterReview_Access returns the review table, while NativeReviewSource_Save stores session/revision in the retained encrypted capture and result JSON, rather than dedicated SourceSession/SourceRevision columns. The first server guard safely refused unverifiable targets but also depended on those optional model fields being populated. Before completion, this was corrected to derive authority from the authenticated capture and cross-check optional fields only when present.

A permanent persisted source-only regression now keeps the optional fields null and requires valid exact-session navigation. A real Development SQL repository save/read round-trip additionally confirmed that actual persisted rows have that shape and that the production guard can queue the exact source position into an isolated presence store. The SQL test used a disposable account, synthetic capture and ephemeral test protector; it did not operate Word or claim successful native execution. Missing session/revision inside the capture, mismatched hashes or another live session still fail closed. The normal legacy UI explanation makes no promise that resubmitting cached analysis can refresh old positional provenance.

Final qualification and Development deployment

Final source: bcef86e1cc47764ae2165e4d9d1232fd666bbe13, incorporating initial F1/F2 implementation 0aeb9d1005b892858c7f5ed4f1689351f2b3c125 and the retained-provenance compatibility correction. Both commits were pushed normally to the existing shared branch. The subsequent completion-report/evidence commit does not change deployed binaries and is identified in the final handoff.

Final source build passed with zero warnings/errors, and the full executable application harness passed 633 checks again after the provenance correction. The focused source-navigation suite also passed again. Native source/protocol were unchanged; preservation qualification passed 292 foundation and 453 chapter synchronisation assertions. These are managed/Linux fixture results, not physical Windows acceptance.

Qualification manifest records exact release/hash/data results. Evidence directory contains successful build, full application, native, current browser, real SQL round-trip, deployed-browser and preservation/cleanup logs. The existing obsolete writer3-review.cjs selector failure is explicitly recorded above rather than counted as a pass.

Deployment evidence Result
Final release /srv/apps/plotdirector-dev/releases/bcef86e-20261120T214617Z
Previous application backup /srv/apps/plotdirector-dev/current-before-bcef86e-20261120T214617Z
Running application informational version 1.0.0+bcef86e1cc47764ae2165e4d9d1232fd666bbe13, read from the deployed DLL
Service plotdirector-dev active after restart and authenticated acceptance
Local/public smoke Real GET 200 at http://127.0.0.1:5050/ and TLS-validated https://dev.plotdirector.com/
Before stopping Zero active work across eight import/analysis/generation/commit/pipeline/synthesis/enrichment/build status sources. Pending editorial review candidates are not worker jobs
Final service journal Zero warning/error entries from final deployment through acceptance/cleanup
Configuration/data Deployed appsettings, environment files, data protection, uploads and log directories preserved; no migration or configuration change
Native deployment None; no Windows process, installation or document was operated

Published and deployed SHA-256 values match:

Artifact SHA-256
PlotLine.dll 27fbaac9f38ebedf1a6b744f1ed3149b8c6e80fabd3fcfd869ab5d979ca28cc8
wwwroot/js/writer-review.js 32831976d52bc0ce51b5c6c981c76b6c70a3922b87d06164984a0b209ce03b0b
wwwroot/js/narrative-focus-review.js 3fdcb1515a46374262588b892860343dcf05b91a001ae1b3ce0fe1986d21c56c

The initial Development release 0aeb9d1-20261120T213346Z was superseded after the persistence compatibility issue was found during final qualification. It failed closed rather than navigating unverifiable positions. The final release above contains the corrected source-only provenance handling and passed the full application harness and actual SQL round-trip. An earlier temporary-filesystem publish hit quota before deployment; the successful final publish used a fresh disk-backed staging directory. Failed publish output was never installed.

Authenticated deployed acceptance and preservation

Real Chromium and simulated standalone/PWA contexts logged in through normal authentication as a disposable Development account. They exercised the deployed MVC/Razor/JavaScript, without replacing manuscript/Focus/Review endpoints with fixture responses:

  • Mapped scene→chapter-only and mapped scene→unmapped scene in the same accepted chapter: Global Focus/chapter remain correct, Review panel has no old scene, exact Word paragraph/scene references clear, and a new annotation has no inherited passage or scene fields.
  • Chapter-only refresh and cached-return lifecycle preserve the cleared targets. The accepted unmapped scene remains unmapped; no paragraph association is manufactured.
  • A legacy native review remains readable with decision controls and an explanatory unavailable-position message. Its unsafe chooser is absent; an authenticated CSRF-valid direct navigation POST returns 409. No Word document was connected or selected.
  • The separate real SQL round-trip confirmed valid retained source-only provenance with the production guard and an isolated native command queue. This establishes actual repository compatibility, not a live Word/UI navigation result.

The synthetic accepted manuscript/paragraph/scene/checkpoint payload had the same SHA-256 before and after browser acceptance, and zero annotations were written. Existing annotation reference/provenance behaviour is additionally covered by the full harness and current annotation browser suite; no observation schema or save implementation was changed.

Before provisioning, the existing guarded identity helper verified PlotDirector_Development, made a copy-only/checksum backup and verified its file was nonempty. The final provisioning backup is /var/opt/mssql/backup/pwa-desktop-20261120T214223-bfd877dbbc894f828b3dd6a028dcb738.bak. Only owned disposable fixture data was written. The first fixture attempt correctly hit the existing scene-map completeness guard; only that synthetic fixture was corrected to represent the unassigned scene explicitly, without assigning any paragraph to it.

Normal account deletion removed both rounds of disposable projects and private identities. Final read-only checks found zero remaining synthetic account/project/snapshot/annotation/native-review rows; the private credential file was deleted. No author's manuscript collection or real accepted content was used. Production was untouched.

Native version implications and outstanding physical acceptance

There is no native package/version change or new installation requirement from these server/browser fixes. Native source remains 1.0.0.40, with the existing acknowledged-navigation capability, command identity, session/revision/manuscript fences, expiry and adapter acknowledgement protocol. This does not assert which version is currently installed on a Windows device.

Physical Windows/Word and an actually installed Windows PWA were unavailable. The portable native queue, real SQL, Chromium and simulated standalone contexts must not be described as physical acceptance. Phase 3B.4 should use an authorised disposable manuscript and matched existing capability-supporting add-in/agent to verify:

  1. Valid retained capture in its original saved live session selects the intended document/range and reports the actual adapter acknowledgement; queueing alone remains requested.
  2. Reopen with the same numeric revision, copied properties, changed preceding content, changed/unsaved revision, stale/expired session or late acknowledgement never selects a stale range. Reading and decisions remain usable.
  3. F1 chapter-only/unmapped fallback, dirty annotation/note deferral, explicit reselection, refresh and real PWA return preserve intended targets and drafts while Word remains independent.
  4. Existing large-manuscript typing/scrolling/cancellation and document-switching behaviour is preserved; no new Word responsiveness or performance result is claimed here.

No installation, Word closure, real manuscript mutation or production change is authorised merely by this report. Stage 3B.1's automated and Development acceptance is complete; stop for review. Phase 3B.2/3B.3 has not begun.