PlotDirector/Docs/WordCompanion/2026-11-09-chapter-sync-contract.md

6.1 KiB
Raw Blame History

Chapter synchronisation contract and implementation ledger

Baseline: shared branch, Windows 1.0.0.22 commit 51316f0. No author manuscript is a test fixture.

Decisions before implementation

  • The accepted ParagraphManuscript remains the sole canonical manuscript, paragraph GUID, scene assignment and author-decision model. Chapter checkpoints are additive metadata in that existing JSON snapshot, carried by the existing backup path. No import or scene detection is rerun.
  • SHA-256 v1 fingerprints encode exact UTF-16 code units with a little-endian paragraph-count/length prefix. No Unicode, whitespace, line-ending or Word control-character normalisation. Paragraph boundaries, order, splitting and merging remain distinguishable. A separate identity digest includes ordered native IDs, lengths and outline levels; a mapping digest includes PlotDirector paragraph/scene/chapter assignments.
  • A hash match is a proposal. The server accepts only complete unique native identity evidence, exact content/boundary equality, current authenticated document/session/revision and coherent accepted-snapshot lineage. Unknown/duplicated IDs or complex XML must fail safely.
  • Per-session live position validations are distinct from durable source checkpoints. A new session does not erase source checkpoints, and validating one chapter never makes unchecked absolute positions in another chapter trustworthy.
  • Unchanged chapter validation must not update prose, scenes, evidence, decisions, statistics or AI. Changed-chapter reconciliation must reuse the existing engine and transactional snapshot procedure, preserve unrelated identities and invalidate incompatible live positions. Ambiguity requires review.
  • New native capabilities are negotiated explicitly. Installed 1.0.0.22 retains its existing endpoints and behaviour; no server silently sends an unsupported command or claims it has fast chapter validation.
  • Benchmarks of COM Range.Text, native identity enumeration and WordOpenXML cannot run on Atlas. Prepare a Windows harness and record only actual portable measurements here; adoption/performance claims remain subject to Windows qualification.

Safety

New migrations are forward-only and applied only after verified Development backup. No real-book backfill, automatic repair or mutation-based qualification. Native changes are source only on Atlas. Deploy only after the normal idle-work guard passes. Production untouched.

Delivery ledger

Implementation, tests, measured portable timings, migration/deployment identity and remaining Windows limitations will be recorded as work completes.

First portable milestone

Versioned fingerprint/XML reader, accepted-snapshot checkpoint model, read-only unchanged-chapter validation, explicit missing-native-ID adoption, conservative changed-chapter merging through the existing engine, authorised API/service, and forward migration 245 source are implemented. Migration is not yet applied and this milestone is not yet deployed. Solution build passes without warnings. Focused tests cover reordered/split paragraphs, Unicode/control characters, cross-session positions, stale lineage, duplicate IDs, preservation of unrelated GUIDs/scenes, hard boundaries and unsafe XML rejection. Portable SHA-256 measurement: 48 synthetic chapters / 8,640 paragraphs in 26.7 ms on Atlas; excludes Word/COM and is not a Windows performance claim.

Integrated candidate

The subsequent implementation extends the existing native/agent/presence/recovery paths end to end, with optional chapter capability, progressive validation, explicit repair, compact status and version 1.0.0.23 source. Migrations 245–247 have been applied to Development after verified backups; the original 245 ledger above records the earlier source-only milestone. See the current implementation/deployment evidence and Windows qualification instructions for the actual final status. Real Word COM timings and execution are not verified on Atlas.

Atlas acceptance repair and native picture evidence (1.0.0.27 source)

The server acceptance investigation reproduced SQL timeouts on an isolated 8,457-paragraph fixture. Forward migrations 248–250 materialise the accepted paragraph/prior-scene indices once, scope scene projections and statistics to the changed chapter, and shift later source paragraph bounds without replacing their prose. Acceptance replies are tied to the checkpoint transaction; a subsequent progress refresh cannot undo a committed acceptance. Diagnostics include stage, chapter, request/session identifiers and SQL error number, without prose or authentication material.

The optional chapter-native-text-v1 pipe capability adds chapter-chunk action ids-exact. Its payload retains the existing eight-hex-digit native ID plus eight-hex-digit UTF-16 span per paragraph. The new action certifies that the VSTO reader has also read each native paragraph's Range.Text, checked its length against the measured range span, and checked their concatenation against the chapter's aggregate Range.Text. This extra COM work is confined to chapters whose range XML contains drawing elements. Both pipe peers must advertise the capability; ordinary ids evidence remains unchanged. Older agents/add-ins cannot certify the picture fallback. The HTTP chapter observation and fingerprint version are unchanged.

For drawings, the parser uses that exact native text partition and still checks paragraph count, IDs, spans, outline and complete chapter coverage. Non-picture paragraphs must additionally match their XML text. It does not project inline/anchored object characters from XML. Tables, text boxes, fields, tracked changes and other previously unsafe structures remain refused. The server still independently requires exact accepted chapter content and ordered paragraph evidence; changed content requires the existing explicit reconciliation authority.

Version 1.0.0.27 is source and installer metadata only on Atlas. Actual VSTO compilation, package signing/install/upgrade, picture-span behaviour and Word responsiveness require Windows qualification. No Windows execution is claimed by portable fixture tests.