PlotDirector/Docs/Writer/Word-Companion-SignalR-Windows-Handover.md

26 KiB
Raw Blame History

Word Companion .44 — SignalR Windows execution handover

Baseline and scope

Implementation: 964ec5e9f7, approved Option C from assessment 10a542c, existing shared branch codex/word-companion-native-phase1-20261104. Fetch its current documentation descendant and record exact HEAD; confirm the implementation is an ancestor. Development already runs application 1.0.0+964ec5e9f798b60a283ad2c7415ef6a3c0e030f1 at https://dev.plotdirector.com/. No new server deployment, migration or configuration is required. Production remains untouched. Development attestation records DLL/JS hashes and rollback release.

Native source 1.0.0.44, MSI 1.0.44, ProductCode {8245E12F-39A8-4FC3-B1A0-9FB6AEB62F1A}; UpgradeCode unchanged {641A087B-9779-458C-B290-BCBBAD49319A}. Sources: PlotDirector.NativeCompanion/DeveloperVersion.props, Vsto/Properties/AssemblyInfo.cs, WindowsValidation/Setup/Release.json. No protocol/capability version bump. Agent adds pinned Microsoft.AspNetCore.SignalR.Client 10.0.15 and its transitive dependencies; VSTO retains its existing COM/IPC path and must not acquire SignalR packages.

Installed .43 is the control and must remain installed until a separately approved installation window. Atlas did not create a Windows package, sign, install, touch the Windows machine or measure physical Word performance. This document supersedes the old .41 build/version instructions in Phase3B4 handover; retain its fixture/evidence/recovery procedures and the 91-case physical matrix. In those historical cases substitute matched .44 add-in/agent, 1.0.44 MSI and this source/server baseline for literal .41 versions. Preserve all safety, identity, provenance and physical-evidence conditions.

Prerequisites and read-only inventory

Use the existing Windows development checkout and x64 PowerShell 7. Inspect actual Windows version, Word desktop version/build/architecture, Visual Studio Office/VSTO workload and x64 MSBuild, .NET 10 SDK and Microsoft.WindowsDesktop.App 10.x x64 runtime, .NET Framework 4.8/targeting pack, VSTO runtime, existing SDK NETFX 4.8 mage.exe, and existing approved code-signing certificate/private-key accessibility. The supported pipeline discovers/checks these; do not install prerequisites or change certificate trust automatically. Supported Word execution remains the established Windows desktop/VSTO setup; browser Word/Office.js is not equivalent. Record actual versions, not assumed support from an Atlas build.

Inspect installed add-in registration/manifest path, actual installed/running agent path/version and Troubleshooting version read-only. Compare installed .43 payload against its preserved inventory. Existing logs are produced by PlotDirector.NativeCompanion/Agent/Program.cs (AgentLog) under %LOCALAPPDATA%\PlotDirector\Companion; inspect the current logger's filenames, retain only sanitized UUID/stage/timing excerpts. Never copy protected state.json, refresh secrets, bearer headers, PKCE codes, cookies or raw account/manuscript dumps into evidence.

Before build, locate and verify the preserved .43 EXE and MSI, and copy them to a new clearly labelled private rollback directory without overwriting anything. Last reported candidate directory: C:\Users\Nick\Downloads\PlotDirectorCompanion-1.0.0.43-d46ed116; this is historical evidence, not proof it still exists. Recorded EXE SHA-256 6094E9857A6D0A43852576DB98F6FBE2EA179A08C9D14C6149FC08895B96ED7F, MSI 20E45867E5B68304EFB885B8D734BA29CDE9ED8930E02C45F9F357810DCA9C92; .43 ProductCode {D7159670-480D-42D6-A93B-9F9145D8201E}. Verify current hashes/signatures and inventory before treating these as rollback artefacts. Existing signer was 4F3EE0D52D2C60214FB1F81DF6E479820A16487F; verify its current validity/approved ownership, never create a replacement silently. No verified .43 rollback package means stop before installation and request the preserved package. Older .42 recovery remains historical; do not substitute an unverified package or force a downgrade.

Use an approved disposable Development account/project and synthetic Word manuscripts per the existing fixture strategy. Do not use real author manuscripts for edits, sync interruption or fault injection. Normal Development account verification/pairing must bind the correct Development account/server; never reset existing user binding to make tests pass. Refresh the browser and installed PWA to load the deployed JS, confirm actual origin/version and capture browser/PWA versions. Atlas Chromium fixtures were simulated PWA, not installed-PWA acceptance.

Build, managed gates and signed packaging

Build only; no Office Clean, F5 registration, legacy direct install or automatic process termination. Keep all generated evidence/staging outside Git until clean-tree build/package gates finish. Check every external exit code. The existing update script can reuse an exact existing package without rerunning gates; record reuse and run the explicit checks below regardless.

$ErrorActionPreference = 'Stop'
function Check-Exit { if ($LASTEXITCODE -ne 0) { throw "Native command failed: $LASTEXITCODE" } }
$branch = 'codex/word-companion-native-phase1-20261104'
git status --short --branch; Check-Exit
if ((git branch --show-current).Trim() -ne $branch) { throw 'Wrong shared branch; preserve state' }
if (git status --porcelain=v1) { throw 'Preserve local changes; do not reset/stash automatically' }
git fetch origin; Check-Exit
git pull --ff-only; Check-Exit
git merge-base --is-ancestor 964ec5e9f798b60a283ad2c7415ef6a3c0e030f1 HEAD; Check-Exit
$source = (git rev-parse HEAD).Trim(); Check-Exit
$native = 'PlotDirector.NativeCompanion'
$wv = "$native/WindowsValidation"
$release = Get-Content "$wv/Setup/Release.json" -Raw | ConvertFrom-Json
$version = ([xml](Get-Content "$native/DeveloperVersion.props" -Raw)).Project.PropertyGroup.ApplicationVersion
if ($version -ne '1.0.0.44' -or $release.version -ne $version -or $release.msiVersion -ne '1.0.44') { throw 'Wrong native release' }
if ($release.productCode -ne '{8245E12F-39A8-4FC3-B1A0-9FB6AEB62F1A}') { throw 'Unexpected product identity' }
Get-Content "$native/Vsto/Properties/AssemblyInfo.cs" | Select-String 'AssemblyVersion|AssemblyFileVersion'
$PSVersionTable
dotnet --info; Check-Exit
dotnet --list-runtimes; Check-Exit
. "$wv/DeveloperPackage.ps1"
$runId = [DateTime]::UtcNow.ToString('yyyyMMddTHHmmssZ') + '-signalr-windows-' + $source.Substring(0,8)
$stage = Join-Path (Get-DownloadsFolder) ("PlotDirectorQualification/" + $runId)
if (Test-Path -LiteralPath $stage) { throw 'Use a new run directory' }
New-Item -ItemType Directory -Path $stage | Out-Null

Set $thumbprint to the locally verified approved existing certificate thumbprint (public identifier only), then:

& "$wv/Update-WordCompanion.ps1" -CertificateThumbprint $thumbprint -NoSync

Actual supported sequence in that script: dotnet build PlotLine.slnx -c Release --disable-build-servers -m:1 /p:UseSharedCompilation=false (restores dependencies); foundation plus six focused native application suites; Office-equipped Visual Studio MSBuild PlotDirector.NativeCompanion\Vsto\PlotDirector.WordAddIn.csproj /restore /t:Build;VisualStudioForApplicationsBuild with Release, PrepareForRunDependsOn=CopyFilesToOutputDirectory, signing and ApplicationVersion from props; SDK mage.exe update/sign; agent dotnet publish PlotDirector.NativeCompanion/Agent/PlotDirector.Companion.Agent.csproj -f net10.0-windows10.0.19041.0 -c Release -r win-x64 --self-contained false; source/signer/hash inventory and atomic developer-package promotion. Use the script to preserve the exact quoting/signing policy. No new script or installer argument is needed for SignalR. Verify agent .deps.json/publish inventory includes SignalR Client/Core, Http.Connections.Client, SignalR Common/JSON protocol and transitive runtime files; package/CAB test must hash every payload file. SignalR package restore failure blocks packaging, never remove the dependency/security checks.

Run managed gates serially, capture transcripts privately and check exit codes:

dotnet run --no-build -c Release --project "$native/Tests/PlotDirector.Companion.Tests.csproj"; Check-Exit
dotnet run --no-build -c Release --project "$native/Tests/PlotDirector.Companion.Tests.csproj" -- --word-observation; Check-Exit
dotnet run --no-build -c Release --project "$native/Tests/PlotDirector.Companion.Tests.csproj" -- --chapter-sync; Check-Exit
dotnet run --no-build -c Release --project PlotLine.Tests/PlotLine.Tests.csproj -- --native-signalr; Check-Exit
dotnet run --no-build -c Release --project PlotLine.Tests/PlotLine.Tests.csproj; Check-Exit

If update reused a package, also run its focused --native-companion, --native-companion-http, --native-workflow, --native-tray, --native-import, --intent-assessment using the same application command syntax. New SignalR tests run inside the HTTP fixture and full harness. Atlas references are 309 native foundation, 453 chapter, 47 focused SignalR checks / 49 focused total PASS lines, 683 full harness PASS lines including nested integrations; investigate failures rather than treating counts as performance promises. The observation suite is a portable managed/IPC fixture already included in the Atlas foundation run; its Windows run still does not establish physical Word behavior. Existing browser fixture entry points are in PlotLine.Tests/Browser/; new writer-word-notifications.cjs runs against the existing disposable Razor fixture host, not a real user's tab/account. Do not run fixture mutation scripts against the public Development manuscript.

$package = Join-Path (Get-DownloadsFolder) "PlotDirectorWordCompanion/$version-$($source.Substring(0,8))"
$inventory = Test-DeveloperPackage $package
if ($inventory.commit -ne $source -or $inventory.version -ne '1.0.0.44') { throw 'Wrong payload' }
$setup = Join-Path $stage 'setup'
& "$wv/Setup/Test-DeveloperPayload.ps1" -PackagePath $package -ReportPath (Join-Path $stage 'payload.json')
& "$wv/Setup/Build-Setup.ps1" -PackagePath $package -ExpectedSourceCommit $source -OutputDirectory $setup -CertificateThumbprint $thumbprint
# $baselineMsi: actual preserved, hash/signature-verified .43 MSI (no guessed path).
& "$wv/Setup/Test-SetupPackage.ps1" -PackagePath $package -SetupDirectory $setup -BaselineMsi $baselineMsi -ReportPath (Join-Path $stage 'package.json')
# $failedSetup: set only to actual historical failed version12 fixture directory if verified available.
$failedSetup = $null
if ($failedSetup) {
    & "$wv/Setup/Test-UpgradeRegression.ps1" -FailedSetupDirectory $failedSetup -CorrectedSetupDirectory $setup -ReportPath (Join-Path $stage 'upgrade-regression.json')
}
Get-FileHash (Join-Path $setup 'PlotDirectorCompanionSetup.exe') -Algorithm SHA256
Get-FileHash (Join-Path $setup 'PlotDirectorCompanion.msi') -Algorithm SHA256
Get-AuthenticodeSignature (Join-Path $setup 'PlotDirectorCompanionSetup.exe') | Select-Object Status,StatusMessage,SignerCertificate
Get-AuthenticodeSignature (Join-Path $setup 'PlotDirectorCompanion.msi') | Select-Object Status,StatusMessage,SignerCertificate

Record unavailable historical negative control as BLOCKED; never fabricate inputs. Required .43 baseline/rollback and full payload/CAB/signature checks cannot be waived. Build-Setup checks exact source/version, source ancestry, manifests with mage -Verify, signs EXE/MSI and writes setup evidence. Test-SetupPackage independently verifies every CAB hash, per-user/asInvoker install, stable components and upgrade identity/ranges. Current developer signing policy allows only the specifically diagnosed untrusted developer-chain status, not invalid digest/expiry/wrong signer/other unknown failure. Do not weaken signing, install certificates, bypass execution policy or change trust stores. Present any normal trust prompt to the human.

Installation gate and recovery

Stop after presenting concrete .44 source/package hashes, signature results, test results and verified .43 rollback to the human. Ask for installation and a normal Word save/close window. Existing authorization is to prepare .44, not to replace installed .43 unattended. Do not remotely install, use silent MSI switches or invoke bootstrapper internal command modes. Following approval, the human launches the unified EXE from Explorer in the established normal-user session. Save/close only approved documents normally; do not kill Word.

Verify per-user Complete feature is Local (3), expected manifest/registration, installed .44 agent EXE/DLL and VSTO/client hashes match the package, actual running process path, loaded add-in Troubleshooting version .44, correct Development origin/account, one agent process and connected native/HTTP health. Existing binding/state must be retained. Native log native-signalr connected confirms subscription; inspect network/diagnostics for actual transport instead of inferring WebSockets from library selection. Standard SignalR transport fallback is allowed; ordinary HTTP fallback remains available when disconnected. An old .43 agent should continue using HTTP on the new server, without a new native hub connection.

Build/sign failure: preserve logs and .43; diagnose prerequisites/signer without installation/security bypass. Installation/add-in/agent load failure: preserve setup/registration/file inventory and normal Troubleshooting logs, stop qualification and ask before repair/uninstall. Pairing failure: verify origin/account/server and expiry/revocation; never erase protected state/reset binding to force a pass. Word unresponsive: stop issuing commands, allow recovery and human save/close; no destructive crash/hang experiment. Sync failure: preserve synthetic saved/accepted/physical distinctions, do not replay content or reset a book automatically. Server incompatibility: stop and report expected/actual version; no redeploy from Windows.

Rollback is the supported separately approved normal uninstall followed by verified .43 unified EXE reinstall, with Word saved/closed normally. Major upgrade does not authorize forced downgrade, registry edits, registration bypass or data deletion. Keep current protected binding and author content; no account reset. Development server backup is /srv/apps/plotdirector-dev/current-before-964ec5e9-20261121T164301Z; Linux operator must recheck active-work safety and compatibility before any separately authorized server rollback. Windows must not operate it.

Ordered physical SignalR supplement

After installation verification, run the existing 91-case matrix A→G with the version override above, plus these ordered cases. All use only owned synthetic fixtures. Each result needs UTC start/end, exact source/package/server/installed versions, instance/session/navigation aliases, expected/actual result, PASS/FAIL/BLOCKED and cleanup. A notification/queued request is never proof of actual Word execution. For timed cases capture click, matching authoritative receipt, actual Word landing and separate viewport observation. Any wrong document, stale completion or unauthorized content change fails immediately; stop dependent tests and preserve evidence.

ID / purpose Preconditions and exact actions Pass/fail condition Evidence and cleanup
SR01 Startup/one connection Matched installed .44, Small saved, paired Dev. Start agent then Word/browser; repeat Word-before-agent and browser-before-Word normally. Inspect process/subscription logs and actual network transport. One agent process/subscription; native/HTTP connected; no automatic navigation. Missing tooling to count connections is BLOCKED for that measurement. Sanitized start/connect/reconnect logs, process paths, transport; return to one normal running agent.
SR02 Warm navigation Small and Medium verified. Use the original .43 ten-target sequence (scene forward/back/repeat, chapter start, cross-chapter scenes, chapter back/forward, current scene) with normal verification enabled; include foreground and side-by-side as labelled branches. Every completed receipt matches exact ID/instance/session/manuscript/revision and actual range. Record all results; physical <2s warm confirmation target must be met on the agreed trials, report median/p90/worst, ~1s is a goal. Do not call a faster receipt alone success. UUIDs, new server enqueue→take/browser notification→receipt and existing native spans, range screenshots, actual visible landing timing; restore fixture focus with excluded cleanup trial.
SR03 Duplicate / receipt race Verified Small; browser and agent logs available. Repeat same-target navigations with distinct requests; use only existing controlled fixture hooks for same-ID duplication/pre-202 race. No duplicate physical execution for same ID or false completion; distinct explicit requests supported. No safe physical same-ID hook → that part BLOCKED, retain managed proof separately. Receipt/adapter UUID trace and counts, retain logs; no request forgery/injection into author session.
SR04 Inactive selected document Two fixture sessions A/B, explicitly A in Writer, B active in Word. Navigate to A, then switch active windows repeatedly without chooser action. Hint wakes exact A, actual A range selected; no automatic B substitution or Global Focus rewrite. Both identities, selected key, range and timelines; restore normal A choice.
SR05 Selected close/reopen (R2) A explicitly selected, B open. Close saved A normally; attempt navigation without choosing; reopen A, then explicitly reselect. No silent B/new-session fallback; old session unavailable until deliberate selection; then exact fresh target works. Selection/status/native execution counters; restore A explicitly.
SR06 Freshness (R1) Small saved and freshly observed. Execute existing C-group safe observation-stall hook only if available/authorized, while agent/hub remain alive; wait beyond45s, attempt navigation, recover hook. Transport/hint cannot renew producer UI proof; stale navigation refused; fresh observation restores eligibility. No safe hook → BLOCKED, never hang/crash Word. Producer vs agent timestamps, hint/receipt refusal/recovery; remove only run hook.
SR07 Network loss / missed hint Synthetic saved fixtures, no content upload. Use approved reversible network control for this process/Dev only; obtain human approval before firewall/network changes. Disconnect notification path, queue one navigation, restore connectivity, inspect reconciliation. If control isolates nothing safely, BLOCKED. HTTP fallback/reconnect recovers eligible unexpired command at most once; expired command cannot execute; no false completion from reconnect. Actual transport loss/restoration, retry/HTTP/ack times, command expiry; restore exact prior network settings immediately.
SR08 Renewal and idle Owned disposable account; keep Word idle/normal observations beyond access lifetime (10min) and record token renewal/reconnect without tokens; then navigate inactive A. Existing protected lifecycle renews/reconnects, one current process subscription, exact command completes; no spurious pairing/account change. Sanitized expiry/renewal/connect state and result, CPU/memory/requests while idle; retain binding.
SR09 Revocation / authority Dedicated disposable installation only; approval to revoke it. Owner revokes through normal Development installation UI while connected. Attempt a fixture command, then re-pair normally if authorized. Subscription closes, current HTTP denied, no command or success; fresh approved pairing required. Revoke/connect/HTTP denial, zero execution; restore only test binding with explicit approval, never revoke user's normal installation.
SR10 Revision/cancel/expiry Synthetic Small copy, saved baseline. Use existing D-group controls for revision change/cancel before take/execution and >25s expiry. Do not fabricate grants/ranges. Existing adapter/server checks refuse stale/cancelled/expired ID, late ack cannot complete; new explicit fresh request may succeed. Native result/receipt state and saved/accepted/position versions; restore synthetic content normally. Missing safe timing hook BLOCKS that branch.
SR11 Agent restart / server loss Saved A/B, no import/sync in flight; normal tray quit/start (approved). Inspect pending requests and reconnection. Server-restart branch only on separately authorized disposable harness, not remote Dev stop. No same-ID duplicate or stale queued execution; reconcile eligible state, old identity never becomes another document. Server restart loses in-memory queue and cannot invent completed receipt. Before/after session/process/command IDs; normal restart recovery, fresh explicit choice if required.
SR12 PWA/Review provenance Existing F-group fixtures including chapter-only/unmapped scene and stale historical AI review. Run browser refresh, installed PWA return, dirty-editor deferral and explicit passage reselection. F1/F2 retained, notes/decisions readable, stale precision/Word target cleared/refused; notification only wakes exact pending receipt. Actual installed PWA screenshots/versions, selected targets/notes (synthetic only); clean only approved synthetic drafts.
SR13 Large/contention/resource Owned 190k and250k synthetic fixtures; baseline open/start/full verification, saved single/same-length/multiple edits, periodic verification, switching/cancel/recovery. Run original G-group measurements during notification use. No typing/scroll/ribbon regression, starvation, stale/wrong target or duplicate ack; record resource/timing distribution. Enforce software bounds: hint256, registry16/user4096total, per-agent max4 requests/max2 regular and one per session. Physical resource thresholds without agreement are proposed, not historical guarantees. CPU/private bytes, Word UI/COM latency, queue depths, HTTP requests/bytes, reconciliation/checkpoint counts and durations; restore synthetic baselines. No synthetic hashing substitute for Word.

Missing physical fault hooks/tool access are explicit BLOCKED items, not permission to improvise a Word hang or mutate real data. Managed queue/server-restart/duplicate notification tests provide supplemental evidence, never fill physical rows automatically. The .43 control may be remeasured read-only before installation with approval; afterwards do not repeatedly uninstall/reinstall merely for a sample without human agreement. Preserve differences in document/session count/background verification in comparisons.

Evidence, completion and ready-to-paste Windows prompt

Create a NEW Docs/Writer/Evidence/Phase3B4/<UTC>-signalr-windows-<source8>/ only after clean build/package gates, copying sanitized results from $stage. Record OS/Word/VS/.NET/browser/PWA versions, native installed/loaded paths+versions+hashes, source, EXE/MSI hash/signature/cert validity, Development version, timestamps, every matrix ID and SR ID, measured scope/units and failures/reproduction/cleanup. JSONL results plus CSV trial/performance data and concise Markdown report; no whole HAR, tokens, private state or author manuscript content. Preserve cold/warm and actual-visible/ack distinction and all samples. Keep artifacts/private logs outside Git, commit sanitized evidence and updated reports only; normal fetch/push shared-branch workflow, no force-push or unrelated edits.

Physical completion requires all required installation/security/provenance/freshness/navigation/sync/workflow checks passed, accepted performance criteria and complete cleanup. Any BLOCKED/NOT_RUN means qualification remains incomplete. Atlas source/server readiness is established; Windows prerequisites/cert availability, verified preserved .43 artifacts, installation approval, real loaded .44 and physical latency/resources remain Windows gates.

Paste into a fresh Windows Codex session:

Read Docs/Writer/Word-Companion-SignalR-Windows-Handover.md, the latest implemented checkpoint in Docs/Writer/Word-Companion-SignalR-Architecture-Assessment.md, and Docs/Writer/Writer-Phase3B4-Navigation-Latency-Report.md. Implemented source 964ec5e9f7 is already qualified/deployed to Development. Follow this handover's exact clean shared-branch fetch/version/build/test/sign/package order for native1.0.0.44 (standard SignalR client10.0.15). Do not redo architecture or substitute a custom transport. Preserve installed .43 and verified rollback artifacts. Build/sign/inspect first, then stop and present exact package/signature/test evidence for human installation/Word-save-close approval; never install/kill Word/change certificates or bindings unattended. After approval verify actual installed/loaded .44 and run existing Phase3B4 matrix A→G with this handover's version override plus SR01–SR13 in order. Use only owned disposable synthetic fixtures and safe existing hooks; stop on unsafe behavior, genuine source/server mismatch, missing rollback/cert/tooling or any need for disruptive action beyond approval. Mark unsupported physical faults BLOCKED. Record all UUID-correlated monotonic spans and actual physical range landing; repeat controlled .43 warm sequence, median/p90/worst, foreground/side-by-side and large-manuscript resources. Never infer physical Word/installed PWA performance from Atlas fixtures. Do not deploy servers, touch Production, reset account/author data or weaken security. Sanitize run-specific evidence and update reports; fetch/commit/push only intended changes normally. Report exact source/package/loaded/server versions, physical results, cleanup and remaining blockers.