docs: record native companion Phase 1 evidence and Windows acceptance limits
This commit is contained in:
parent
7d1810c7bc
commit
d100481387
98
Docs/WordCompanion/2026-11-04-phase1-implementation.md
Normal file
98
Docs/WordCompanion/2026-11-04-phase1-implementation.md
Normal file
@ -0,0 +1,98 @@
|
||||
# Word Companion Phase 1 implementation report
|
||||
|
||||
Date: 4 November 2026. Branch: `codex/word-companion-native-phase1-20261104`.
|
||||
|
||||
## Outcome and acceptance boundary
|
||||
|
||||
Implemented a minimal VSTO source foundation, separate .NET 10 agent, versioned bounded named-pipe protocol, document/session manager, positional structural pipeline, native ribbon, diagnostics and automated managed tests. The separate agent is the confirmed product architecture; the investigation's earlier comparison of in-process alternatives is superseded by that decision.
|
||||
|
||||
The managed implementation builds and passes its Linux tests. **The VSTO project has not compiled or loaded in Microsoft Word, and actual Word responsiveness has not been measured.** Phase 1 is ready for code review and Windows qualification, not desktop acceptance, public installation or full migration. No Production or Development deployment, service restart or live database migration was performed.
|
||||
|
||||
The existing Office.js Companion remains in place. Native authentication and session-aware server routing are deliberately deferred: native Context/Intent synchronization has not been demonstrated. Existing browser functionality received focused compatibility-preserving repairs.
|
||||
|
||||
## Architecture and responsibilities
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
W[Word application and documents] -->|STA events / bounded COM reads| V[VSTO ribbon + UI scheduler]
|
||||
V <-->|async framed pipe v1 / values only| A[Per-user .NET 10 agent]
|
||||
A --> S[Instance leases and per-document sessions]
|
||||
A --> P[Structural parsing / positional scene resolution]
|
||||
A --> D[Bounded diagnostics and metadata scheduling substrate]
|
||||
A -.->|future authenticated session-aware contracts| API[Existing HTTP and SignalR domain services]
|
||||
O[Existing Office.js Companion] <-->|existing compatible contracts| API
|
||||
API <-->|existing multi-screen coordination| B[Browser Context / Intent / Writer]
|
||||
```
|
||||
|
||||
Solid native paths are implemented and exercised in portable tests; the Word/COM portion requires Windows validation. The dashed server path is a dependency, not an implemented integration. No native component writes manuscript prose or performs AI analysis.
|
||||
|
||||
| Component | Implementation and evidence |
|
||||
| --- | --- |
|
||||
| [Protocol](../../PlotDirector.NativeCompanion/Protocol/README.md) | .NET Standard 2.0 value-only contracts; protocol/capability negotiation, correlation IDs, 256 KiB framed limit, instance/session/revision/snapshot IDs. |
|
||||
| [Client](../../PlotDirector.NativeCompanion/Client/AgentLink.cs) | Background asynchronous pipe I/O, deadlines, idle keepalive, bounded recovery/backoff, safe launch throttling, authoritative open-document reconciliation. No COM access. |
|
||||
| [UI scheduler](../../PlotDirector.NativeCompanion/Client/WordAccessScheduler.cs) | Thread ownership assertion, 64-action capacity, latest-event coalescing, selection priority, fair lower-priority work and quiet periods. |
|
||||
| [Agent](../../PlotDirector.NativeCompanion/Agent/Program.cs) | Interactive Windows executable, exclusive per-user/logon lock, fixed endpoint identity, idle shutdown and rotating structured diagnostics. No privileged service. |
|
||||
| [Pipe host](../../PlotDirector.NativeCompanion/Agent/PipeHost.cs) | CurrentUserOnly pipes, maximum eight peers, handshake deadline, connection leases and isolated disconnect. Native client independently checks server process SID. Windows security remains unverified. |
|
||||
| [Session manager](../../PlotDirector.NativeCompanion/Agent/SessionManager.cs) | Exact instance/session routing, multiple books, active document per instance, snapshot validation, stale/cancelled work rejection and bounded storage. |
|
||||
| [VSTO host](../../PlotDirector.NativeCompanion/Vsto/PlotDirector.WordAddIn.csproj) | Classic .NET Framework 4.8 Word VSTO project, Office host-item metadata and native ribbon. Excluded from Linux solution build; Windows solution and developer script supplied. |
|
||||
| [Word adapter](../../PlotDirector.NativeCompanion/Vsto/WordAdapter.cs) | STA-only lifecycle/selection handling, bounded batched extraction, marker metadata and timing instrumentation. Source syntax checked; interop binding/load unverified. |
|
||||
| [Deferred queue](../../PlotDirector.NativeCompanion/Agent/DeferredWorkQueue.cs) | Durable bounded metadata-only intents for future Automatic/OnSave/Manual modes; not connected to a sender or authenticated account. |
|
||||
|
||||
See the [component README](../../PlotDirector.NativeCompanion/README.md) for exact limits and protocol ownership. Publisher identity is Nick Beckley.
|
||||
|
||||
## Functional proof and identity
|
||||
|
||||
Each add-in load has a WordInstanceId; each open document has a distinct live SessionId, separate from persistent ManuscriptId. Sessions carry local project/book association, revision, structural snapshot, position and pending work. An instance cannot address another instance's document. Disconnect only retires sessions belonging to the disconnected lease. No native server command is sent to an arbitrary latest-connected Word instance.
|
||||
|
||||
The portable harness drives actual local framed pipe exchanges through handshake, three synthetic manuscripts, snapshots, positional chapter/scene resolution, active-session switching, close, idle disconnect and agent-host restart/reconciliation. Linux named pipes use Unix-domain sockets; this demonstrates managed transport behavior, not Windows ACLs, process crash recovery inside Word or VSTO loading.
|
||||
|
||||
Native custom properties use the separate `PlotDirector.Native.*` namespace. Missing document GUIDs produce explicitly provisional identities; Settings offers explicit persistence without forcing a save. Until persisted they are not stable across reopen. Local project/book IDs have `AssociationVerified=false` and grant no server authority. Reading/migrating the Office.js settings bag requires real linked DOCX evidence and is deferred; this prototype is not a binding switchover.
|
||||
|
||||
Agent structure resolution uses paragraph positions, outline levels and PlotDirector marker identifiers. Repeated text is not used as document identity. Stale revisions, incomplete/out-of-order fragments, cancelled snapshots and closed sessions cannot commit a snapshot. Dense/unsupported marker structures fail safely rather than retry indefinitely.
|
||||
|
||||
## Responsiveness design and limitations
|
||||
|
||||
COM objects remain on the original Word STA. Worker messages contain values only. A 25 ms UI timer pumps bounded work; extraction reads at most 2,048 characters per fragment and up to four fragments or a cooperative approximately 20 ms batch before yielding. Selection has priority and repeated events coalesce. Pending backpressured DTOs are retained without re-reading Word or waiting for agent space. COM calls, batches, queue depth and UI tick delay are instrumented.
|
||||
|
||||
Individual COM calls cannot be preempted. The 20–30 ms target is unmeasured and must not be represented as a platform guarantee. Save and close callbacks never cancel Word's operation, wait for IPC, force saving or upload prose. Cancelled closes retain sessions; actual closes are reconciled in bounded UI steps. Native disconnection/restart does not synchronously wait on Word's UI thread.
|
||||
|
||||
Completed structural snapshots are reused for cursor movements. Length changes and the first saved-to-dirty transition invalidate them. Same-length structural edits while already dirty require explicit Synchronise Now in Phase 1. This is not a complete edit journal. Synchronise Now currently means local structural refresh; native Sign In/server prose synchronization are explicitly unavailable. Marker helpers preserve text and have no remotely callable mutation command in protocol v1.
|
||||
|
||||
Limits include 32 documents per instance, bounded FIFO plus coalesced position slots, per-document/global snapshot storage budgets and bounded structural boundary counts. More than 32 open documents defers partial close reconciliation rather than falsely retiring unseen documents. Windows trials must establish suitability for real manuscripts and Word event behavior.
|
||||
|
||||
## Security and browser repairs
|
||||
|
||||
Commit `1506281` preserves existing hub signatures/events while replacing client marker acknowledgements with an atomic owner-validated stored procedure. Authenticated build ownership, current project access, active manuscript and book/project association are mandatory; provided preview/document identifiers must match. Legacy omitted optional fields remain compatible. Unsent/non-built work cannot be acknowledged; repeated settled acknowledgements are idempotent and late failures cannot regress completion. Rejected acknowledgements broadcast no successful state.
|
||||
|
||||
[Migration 230](../../PlotLine/Sql/230_WordMarkerAcknowledgementOwnership.sql) must be applied before any future deployment of the server fix. It was applied only to the pre-existing explicitly guarded synthetic database for testing, not live Development. Security fixture mutations were transactionally rolled back.
|
||||
|
||||
Context and Intent fragment loading now uses generation checks and cancellation; obsolete response bodies, failures and completion handlers cannot replace newer content or loading state. Returning to displayed content invalidates a pending request. Chapter-only Intent state clears stale scene identity. Writer launcher now uses registered writing role rather than undeclared `currentRole`. No Context/Intent UI rewrite or breaking SignalR change was introduced.
|
||||
|
||||
## Verification evidence
|
||||
|
||||
Source commits: investigation baseline `f0fe32b`; server/browser fixes `1506281`; native foundation `7d1810c`. Evidence is retained in [Evidence/2026-11-04-phase1](Evidence/2026-11-04-phase1/managed-build.log).
|
||||
|
||||
| Check | Result / evidence |
|
||||
| --- | --- |
|
||||
| Managed solution build | [Passed, 0 warnings/errors](Evidence/2026-11-04-phase1/managed-build.log), `dotnet build PlotLine.slnx --disable-build-servers -m:1 /p:UseSharedCompilation=false`. VSTO intentionally excluded. |
|
||||
| Native harness | [118 assertions passed](Evidence/2026-11-04-phase1/native-tests.log), including capacity-slot assertions; not 118 independent scenarios. Actual pipe handshake/recovery, multiple sessions, coalescing, cancellation, stale requests, bounded queues, ownership callback rejection and durable queue behavior. |
|
||||
| Application harness | [406 checks passed](Evidence/2026-11-04-phase1/application-regressions.log), executable PlotLine.Tests, exit 0. |
|
||||
| Actual ownership SQL | [Passed](Evidence/2026-11-04-phase1/ownership-regressions.log): foreign owner/access, preview/document mismatch, active association, unsent/non-built work, legacy compatibility, idempotence and late failures. Guarded synthetic database only. |
|
||||
| Chromium focused regressions | [Passed](Evidence/2026-11-04-phase1/browser-regressions.log): production Context/Intent scripts with delayed responses including ignored abort, stale failures and fresh launcher. |
|
||||
| Existing Writer/PWA and goals | [Writer passed](Evidence/2026-11-04-phase1/writer-regressions.log); [goal workflow passed](Evidence/2026-11-04-phase1/goal-regressions.log), DB-free compiled Razor fixture host, subsequently stopped. |
|
||||
| VSTO Windows build | [Blocked on Linux](Evidence/2026-11-04-phase1/windows-build-unavailable.log): MSB4019, missing Microsoft.VisualStudio.Tools.Office.targets. No semantic interop compile or real Word run. |
|
||||
| VSTO syntax/XML | [Syntax passed](Evidence/2026-11-04-phase1/vsto-syntax-only.log); XML also parsed. These checks are not an Office build or compatibility proof. |
|
||||
|
||||
Two intermediate default managed builds terminated with internal CLR error `0x80131506`; cause was not established. The serial build with build servers disabled passed. This development-host event establishes no conclusion about Word stability.
|
||||
|
||||
## Windows qualification and remaining work
|
||||
|
||||
Follow [Windows validation](../../PlotDirector.NativeCompanion/WindowsValidation/README.md). Developer build tooling accepts a local signing certificate; no installer, automatic updater or distribution channel was implemented. The classic VSTO host-item plumbing must be validated, and regenerated against the installed Visual Studio Word template if necessary.
|
||||
|
||||
The procedure covers 190,000-word and 250,000-word OOXML fixtures, many short/repeated paragraphs, a very long paragraph, rapid cursor movement, continuous typing, scrolling during extraction, saving during pending work, three simultaneously open books, multiple Word processes, cancelled close, agent termination/restart, wrong-user access and pipe spoofing. Fixture-generation scripts have not been validated by opening their output in Word. Record baseline/enabled UI latency, COM/batch timings, CPU/memory, queue depth and recovery; managed test timings are not substitute measurements.
|
||||
|
||||
Before accepting Phase 1, build/load on supported Windows/Office bitness, run the full functional/security/performance matrix and resolve any measured problems. Before full migration, review native authentication, server-authorized document binding, session-aware compatible SignalR routing, Context/Intent following policy across multiple instances/screens and the Office.js settings migration bridge. Do not wire native documents into the old user-only presence route.
|
||||
|
||||
Future prose work should use Word-authoritative scene changes, quiet/save/manual triggers, expected revisions and idempotency, bounded retries, authenticated account/environment isolation, retention policy and optional encrypted cache. The present metadata queue does not implement scene prose uploads, account isolation or server acknowledgements. No automatic AI reanalysis or server-to-Word prose writing was added.
|
||||
|
||||
Phase 1 implementation stops here pending review and Windows evidence. Full migration, deployment and public installation are not authorized by this report.
|
||||
Loading…
x
Reference in New Issue
Block a user