6.3 KiB

Guided Investigation foundation — Phase3D.1

Implemented in authenticated Writer → Explore. The public Writing Problem Solver remains independent: no changes to its controllers, graph, pages, solution content, case data, SEO or URLs. Inspection covered SolverGraph, WritingSolverEngine/Traversal, WritingSolverRepository/Validator/Admin, authenticated workspace adapters and existing CuratedV2 case witnesses. Reused concepts are stable IDs, immutable structured publication, strict import validation, scoped workspace navigation and deterministic replay. The new engine does not reuse next-node traversal, cumulative uncapped affinity or public solution URLs.

Boundaries

  • Models/Investigations/Contracts.cs: catalogue, hypotheses, evidence, conditions, capabilities, author state and evaluation.
  • InvestigationEngine: pure function over an immutable catalogue, concern, current answers, available capability IDs and optional continuation bound. No I/O, random, clock, manuscript, COM, AI or external inference dependencies.
  • CatalogueValidator: version/schema/reference/weight/prerequisite/reachability validation before publication and on load.
  • DestinationRegistry: trusted authenticated route adapters. Questions and answers contain no URLs. Application access is rechecked before opening a scoped destination.
  • InvestigationService: book authority, private read, revision/invalidation, deterministic state evaluation, explicit persistence.
  • IInvestigationRepository/Dapper implementation: only stored-procedure application access; isolated browser tests implement the same boundary in memory.
  • WriterInvestigationsController: Development gate, author forms, no-store/noindex, CSRF, optimistic version, internal admin policy and diagnostic views.

The author UI uses existing layout/ribbon/theme and Markdown Help. Recommendations are authored strings plus actual supporting question/answer evidence. They never claim manuscript analysis. Opening a recommended tool uses a separate tab; the original investigation remains available. No objective, session, scene status, Word target or manuscript is changed by this engine.

Persistence

Migration273 adds immutable WriterInvestigationCatalogues, author/book-scoped WriterInvestigations and append-only WriterInvestigationEvents. Every explicit action atomically stores the new aggregate and reproducible evaluation/history snapshot. Answers are current by question ID; earlier versions survive only in events. Revision prunes currently ineligible dependent answers from live evidence, retaining events. Questions presented are recorded on the transition, alongside next-question diagnostics. Multiple investigations have different UUIDs; no automatic overwrite or read-time creation.

SQL verifies active project/book membership plus author ownership for every investigation read/update/event replay. Catalogue version and scope cannot change on update; integer expected-version fencing prevents lost updates. Published catalogues cannot be replaced. Account/book cascades delete private investigations and their event history; catalogues remain as shared content. New rows are not added to shared project JSON exports. Normal database backup covers all three stores. List UI shows100 most recently updated investigations per book; direct private URLs can resume older records. Per-investigation persistence is bounded to1000 transitions and40 configured substantive answers.

Synthetic imports and author/admin endpoints are available only when the host is Development and WriterInvestigations:Enabled is not false. Production cannot enable this preview by setting that flag true. Catalogue validation currently requires Synthetic=true. Release/configuration work to enable real catalogues must be a separately qualified phase. No new native binary is needed.

Later Feature Dependency Graph and Progressive Readiness

The user's additional requirements were recorded during implementation without restarting or refactoring this phase. Diagnostic evidence is independent of destination readiness: changing available capability IDs does not change support, opposition, conflicts, corroboration, scores or diagnostic coverage. Availability affects eligible actions and completion messaging only. This separation is explicitly tested.

Already useful: stable capability IDs, a separate resolver boundary, declared context/authority, availability, explicit prerequisites, hypothesis mappings, immutable catalogue versions and reproducible state. Capability prerequisites currently use answered-question conditions; this is intentionally small and is not a complete application dependency graph or book-readiness model. Five adapters are a synthetic test registry, not an inventory of implemented features. Optional chapter/scene/character contexts are not resolved in this phase; only authorised project/book adapters are implemented.

Future constraints to address: capability definitions currently live inside each immutable catalogue, the trusted resolver set is compiled, and prerequisite rules are flat all-answer/exclusion conditions. Do not grow those into an ad hoc feature graph. Introduce a separately versioned shared capability/dependency registry with typed context, requirement and readiness contracts; catalogues should refer to its stable IDs. Preserve old resolver aliases and pinned catalogue references. Readiness must produce missing-preparation facts and journeys, never evidence weights or diagnosis changes. Multi-step preparation should have a separate lifecycle from investigation answer revisions and recommendation history.

Safe sequence: (1) inventory existing implemented features and their actual permission/context/data requirements; (2) define and validate typed dependency edges, cycle policy and resolver aliases; (3) implement pure book-specific readiness with provenance and read-only queries; (4) introduce resumable preparation journeys and missing-prerequisite questions; (5) integrate readiness reasons with investigations without rescoring; (6) build the Feature Family Tree from the same model. Additive migrations can introduce the shared registry and journey state; retain existing catalogue JSON/events unchanged and use an adapter for schema1 imports/replay. Do not rewrite migration273 or repoint historical investigation versions. This later scope, production questions and Phase4 are not implemented here.