PlotDirector/Docs/Investigations/Writer2Audit/06-Phased-Implementation-Plan.md

17 KiB

Phased Implementation Plan

This is a proposal, not authorisation to implement or deploy. Gate numbers follow specification §15. Use independent feature flags/capability negotiation so useful increments ship without replacing all Writer functions in one release. No production changes are authorised.

Common gate requirements

  • Build dotnet build PlotLine.slnx, then run dotnet run --project PlotLine.Tests/PlotLine.Tests.csproj serially. The executable harness is the gate; dotnet test is not a substitute.
  • Add behaviour-level tests for new durable contracts and risks; do not rely solely on string assertions or add tests that merely mirror a UI implementation. Revise existing source-contract assertions when deliberately superseding old layout, keeping functional coverage.
  • Run focused browser/PWA checks for changed journeys; include four themes, keyboard/touch, small/laptop/desktop, slow/failed requests and no-data/partial-data states. Simulated PWA is not Windows installed-PWA acceptance.
  • For native changes: portable protocol/agent tests plus actual Windows VSTO compile/package/upgrade and real Word responsiveness/capture/focus qualification. Old capability profiles remain supported. Linux tests cannot certify COM or OS window restrictions.
  • SQL integration uses a disposable verified test database with synthetic fixtures. Read relevant scripts before running them; tests that roll back still write and are outside this audit. Never run them on Production. Recheck repository Docs/Codex/Testing.md and Database.md during implementation.
  • Proposed schema changes become new forward-only migrations only after implementation approval. Verify effective Development target, back up before applying, apply narrowly in order and verify object/permission compatibility. Document old-application compatibility; application rollback does not undo SQL.
  • Before a Development rollout follow Docs/Codex/Deployment.md: no active imports/analysis, deliberate commit/build identity, release backup and authenticated smoke. Preserve existing manuscripts and user work. Log acceptance results per gate. Production requires separate explicit authorisation.
  • Feature rollback must preserve accepted data, events/receipts and pending outbox entries. If old code cannot capture activity, mark the resulting coverage gap; never present rollback time as fully observed history.

G0 — audit and decisions

Objective/deliverables: the seven documents, full requirements mapping, schema/retention recommendation, evidence limits and current regression record in this directory.

Acceptance: product owner can distinguish working reusable capabilities, new development and unverified Windows requirements; no fabricated historical provenance; no code/data changes, migration or deployment. Resolve blocking retention/privacy/scope decisions before production capture. No schedule or report claims based on old state that cannot support them.

Current result: audit delivered; see Verification.md for actual commands and results. This gate ends here.

G1 — reliable capture foundation

G1a: server acceptance, baseline and read-only evidence view

Dependencies: retention policy and scope/actor semantics; inventory of latest accepted procedures and all full/selective acceptance paths; existing entitlement/access decisions.

Deliverables: versioned event envelope; durable scoped receipt uniqueness; atomic canonical-save/event append; baseline event for current accepted state; separate unchanged-validation/mapping/declaration events; versioned word diff; coverage metadata; minimal bounded evidence query; projection checkpoints/replay. Optional retained snapshot/diff store only within approved policy. Extend backup/restore/delete format and permissions deliberately. Supply an administrative reconciliation/read tool with no manuscript-specific logic.

Acceptance criteria:

  • Existing accepted manuscript and scene/evidence GUIDs survive; first baseline contributes zero new writing output. No automatic reimport/reanalysis.
  • Exact retry before/after restart and after newer events returns the original receipt; same key/different payload rejected. Parallel accepted transitions cannot double-count.
  • Canonical save + event are atomic under injected failure. Downstream notification/projection failure is recoverable without lost accepted events or duplicate totals.
  • Gross additions/deletions/net reconcile with declared token fixtures; formatting-only unchanged text yields no word growth; zero net revision may have positive additions/deletions; moves and split/merge do not invent book growth. Ambiguity yields honest coverage.
  • UTC receipt, observed precision/skew and author-local day are distinct. Old clients produce acceptance-time coverage without invented observation times.
  • Rebuild produces the same aggregates/checksum; read queries are book-scoped, bounded and authorised. No dashboard GET writes or schedules AI work.
  • Restore/import/copy/archive/delete/erasure scenarios preserve lineage and privacy without replaying historical content as new writing. Expired/inactive subscription and revoked native grant cases are explicit.

Tests: synthetic full/chapter/no-op/mapping change; deleted/duplicate/moved/copied paragraphs, cross-chapter structure review, stale base and concurrent devices; replay/payload collision; tokenisation/control characters/Unicode/large chapter; transactional failure injection; report coverage classes; projection replay; tenant/book isolation; restore and deletion safety. Reuse ParagraphManuscriptTests, ParagraphWorkflowTests, ParagraphChapterTests, ParagraphBackupTests, ChapterSynchronisationTests, ManuscriptReaderTests and relevant SQL fixtures.

Risk/rollback: new accepted-state hooks can damage the most important path. Additive schema and flag capture readers separately; preserve old endpoint responses. Keep old server compatible with added columns/tables. If capture is disabled, record a coverage boundary rather than silently resuming a complete-history claim.

G1b: native durable observations and offline delivery

Dependencies: G1a event/receipt protocol; protected storage and negotiated native capabilities; decided offline retention/capacity handling.

Deliverables: production protected outbox, acknowledgements/retry/backpressure, account/document-scoped producer identity, offline uncertain intervals and durable diagnostics. Do not claim the existing standalone coalescing queue already satisfies this.

Acceptance: disconnect/edit/reconnect and restart/crash never inflate events, words or sessions; captured observations survive as designed; uncaptured intervals are labelled. Sign out/revoke/change account cannot deliver prose to a different scope. Clock skew does not reorder accepted state or manufacture duration. Old add-ins remain usable at lower coverage. Word typing/save remains responsive.

Tests: native portable restart/outbox capacity/corrupt file/account switch; HTTP retries/timeouts/ack loss; real Windows offline, Word close, cancelled close, document rename/Save As, copied IDs, multiple documents/instances, same-length edits and large manuscripts. Existing native qualification fixtures must continue to pass.

Risk/rollback: protected data loss or false completeness. Stop new capture if storage unsafe, retain pending entries, expose gap and manual resolution/export. Roll back agent with compatible outbox format; never discard outstanding events in an installer upgrade.

G1a provides useful honest capture to legacy clients before G1b; acceptance-time history must remain visibly different from native observation history.

G2 — navigation, dashboard, workspaces and display setup

Dependencies: G1a for observed indicators; existing S/D/V components. Navigation/display work can be implemented independently, but cannot display unbacked historical figures.

Deliverables: contextual Writer ribbon and canonical route map; common shell book selection; progressive Overview; five queue tabs; compact Companion state/actions; bounded drillable cards/charts; Display Setup with arbitrary screen-role profiles and fallback. Keep current plan forms and Context/Intent links accessible.

Acceptance:

  • Selected book consistently scopes queues/charts/status. Legacy Writer URLs resolve without losing context; no removal of legitimate /Writing/Context and /Writing/Intent deep links.
  • First viewport prioritises current work, next opportunity and compact state at desktop/laptop/small sizes. No permanent setup wall; skip/no-plan remains useful.
  • No linked document shows no misleading linked-Word layout/session actions. Absence of heartbeat is not labelled definitively not installed.
  • Every available chart/issue/chapter/scene target navigates correctly, supports keyboard access and has non-colour/table equivalents. Partial history is explicit.
  • Display discovery handles 1/2/3/4+ screens, negative coordinates, denied/unavailable permission, popup blocking, docking/topology changes and manual fallback. Word placement is not falsely claimed before native support.

Tests: Browser/writer-workspace.cjs, writer-navigation-themes.cjs, writer-goal-navigation.cjs, workspace-maximise.cjs, writing-context-navigation.cjs, writing-context-components.cjs, writing-desks.cjs, native-companion-workspace.cjs; actual installed PWA and monitor matrix. Existing browser tests are reusable starting points, not coverage of all proposed features.

Risk/rollback: UI/scope regressions and inaccessible charts. Feature-flag new routes/dashboard and restore old landing links independently; no data conversion required merely for tab/ribbon delivery. Preserve any new local profile format for safe downgrade.

G3 — Writing Rhythm and plan engine

Dependencies: G2 navigation/selection; approved flexible-mode and calendar semantics; G1 baseline for reliable prefill; plan-version/availability/exception schema.

Deliverables: skippable/resumable wizard, four schedule-fit choices, accessible weekly availability painting/manual entry, flexible mode, protected time, holidays/exceptions, milestone proposals, preview-before-save/apply and dismissal; capacity-aware scheduling and explicit timezone.

Acceptance: create a plan with no daily word target and no fixed weekdays; protect personal time; save/resume/skip setup; detect existing manuscript without inventing historical work; approve a proposal before activation. Only available opportunities appear by default; holidays/unavailable days are neutral. Suggestions never mutate plan automatically. Multiple small scenes can share capacity deliberately; over-capacity/dependency conflicts are explained. Reforecast preserves historical Done/Skipped declarations and original plan versions.

Tests: fixed/flexible/zero availability, crossing midnight, DST/travel, holidays and protected slots; no word target; custom session capacity; plan proposal stale-version rejection; insufficient capacity; task split accounting; completed-item preservation during regeneration; permissions and account isolation. Existing schedule service/repository tests/source contracts need behaviour-level extensions; don't assume persisted Automatic setting is a running engine.

Risk/rollback: reforecast overwriting history, incompatible JSON availability and wrong local days. Keep legacy format read-compatible via adapter; version new structures, preserve original plans/items; disable new planner while old plan views remain available. No destructive conversion.

G4 — Focus Sessions, passes and Writing Journey

Dependencies: G1 captured history/receipt semantics; G3 opportunities; independent pass/milestone/session schema; capability-gated Word commands.

Deliverables: 20/30/45/60/custom sessions with objectives, pause/resume/extend/finish, optional break/note, non-modal focus mode; explicit lifecycle and qualified durations; chapter-pass matrix; zoomable calendar Journey with observed past, Today and future proposals; links from dashboard/Journey/Word and future Editor contract.

Acceptance: 30-minute sprint pauses/extends/completes without interrupting typing; browser sleep/reload/crash yields honest time, not fictitious continuous concentration. Separate elapsed/pause/declared interruption/document-activity evidence. Finish is idempotent. Concurrent devices do not create duplicate sessions. Draft Chapter 35 and revise Chapter 8 concurrently with separate pass states; document edits never mark a pass reviewed/complete. Day/week/month/book views and chapter/scene drill-down work. Word navigate/open/focus is best effort and author-authorised; unsupported clients retain working fallback.

Tests: fake monotonic clock/state machine, duplicate/stale transitions, background throttling/sleep/timezone changes, multiple tabs/native/browser recovery, no document/non-document sessions, optional break/reflection note privacy, dismiss/deny notifications; overlap and pass-state provenance; large timeline paging and keyboard/list access; Windows Word mid-sentence/focus/save scenarios and older client compatibility.

Risk/rollback: attention overclaims, session double-counting, distracting timers, pass status colliding with scene status. Keep elapsed and evidence partitions immutable, disable session UI without erasing transitions, keep explicit pass states readable; old Writer can continue through original scene workflow.

G5 — insights, editorial collaboration and evidence reports

Dependencies: sufficient qualifying G1/G4 data; approved retention/privacy/export rules; granular assignment permissions before collaborator login; projections and plan history.

Deliverables: factual statistics and optional explainable/dismissible insights; independent behavioural dimensions; author-owned external milestones/feedback imports first; scoped integrated contributor views later; report scope/preview/redaction/export, concise overview and detailed evidence coverage.

Acceptance: show sample size/window/limitations; suppress insufficient-data insights; observed availability never becomes natural preference by itself. Dismissal/cooldown persists and no insight changes a schedule. External editor updates remain declared/imported; directly captured collaborator changes are separately attributed. Assigned contributors cannot see unrelated books/private notes/research through routes, APIs, SignalR, exports or charts. Reports reconcile counts with ledger/projection version; missing/expired evidence is disclosed. No AI-free/human-only certification wording.

Tests: insufficient sample/partial coverage/bias examples, deterministic statistic versions, dismissal/reappearance, actor attribution/import retry/redaction, assignment revocation, cross-book/chapter negative authorisation and export tests; selected-date/pass/contributor totals without join multiplication; expired subscription read/export access; retention expiry/deletion and restore privacy regression.

Risk/rollback: privacy leakage, misleading inference and over-broad collaboration. External-report-first delivery avoids granting project-wide access prematurely. Disable integrated contributor routes until scope tests pass. Insights/read projections can be disabled/rebuilt; retain author declarations/dismissals and report audit basis.

G6 — signed provenance PDF and optional verification

Dependencies: G5 accurate reports; approved report purpose/disclosure, signing/verification security design and explicit separate sign-off.

Deliverables: report identity/timestamp/scope/evidence manifest, cryptographic PDF signature and verification; protected keys, rotation/revocation/compromise procedure, optional privacy-preserving QR endpoint, verification help text and retention policy.

Acceptance: modifying issued bytes fails verification; correct issued reports validate with intended tools and appropriate certificate lifecycle rules. Public verification reveals only approved metadata, no manuscript/contributor identities by default. Redacted export and signature agree. Verification claims issuance/integrity only and explicitly excludes AI-free certification. Reports clearly state evidence gaps/imports/declarations and expired backing evidence.

Tests: independent signature verification, tampering, wrong key, expired/revoked/rotated key, timestamp validation, disclosure/redaction, enumeration/rate limits, deleted/private reports, backup/key recovery and incident drill. Security review is mandatory; a logo or digest is insufficient acceptance.

Risk/rollback: compromised keys or overstated assurance. Disable issuance independently of access to existing reports; publish accurate revocation/status where applicable, retain issued artifacts and key identifiers per policy. Never silently re-sign an old report as if it were originally issued under a new key.

Milestones and sequencing

G1a → G1b establishes reliable evidence before dependent analysis. G2 can ship navigation, queues and display setup in small increments while showing only supported metrics. G3 produces opportunities and plan proposals. G4 adds sessions/passes/Journey. G5 needs both sufficient data and access controls; split external editorial reporting from integrated collaboration. G6 is independently optional and security-gated.

Do not commit a calendar delivery estimate before sizing native offline work, retention/storage and scoped collaboration. These are the largest uncertainty drivers. Each milestone is independently reviewable and testable; no single deployment must replace the entire Writer interface.