PlotDirector/Docs/Codex/ContextIntent-67.md
2026-12-01 13:38:48 +00:00

7.8 KiB

Context Intent task 67: preparation and schema release prerequisite

Status: partial implementation, not ready for acceptance. No migration, database change or deployment has been performed. The task remains incomplete.

Implemented preparation

PlotLine/Services/Context/ContextIntentText.cs is a pure shared server utility:

  • Paste preparation accepts ordinary lines, bullets, numbered lists and checked or unchecked Markdown checkboxes. It preserves order and repeated objectives, rejects oversized input without truncation, and returns editable-preview data. A pasted check is a requested manual state for preview, never persisted completion.
  • Palette preparation merges appearances by supplied identity key, unions names, aliases and provenance, and keeps different identities with the same label apart.
  • Matching examines only the supplied changed passage, uses exact case-insensitive names/aliases with Unicode word boundaries, prefers the longest overlapping phrase and returns all identities for shared spellings. It neither confirms a candidate nor creates facts, knowledge, relationships, events or completion.
  • Offsets describe the exact supplied passage in UTF-16; they are not Word positions. Callers must supply authorised identities and encode text when rendering.

The regression harness includes ContextIntentTextTests, also available with dotnet run --project PlotLine.Tests/PlotLine.Tests.csproj -- --context-intent-text. The existing NameTextMatcher is a different, normalised manuscript-wide name verification search: it does not preserve exact original passage offsets or select longest overlapping multi-entity matches. Intent preparation does not invoke that paid verification workflow or change its contracts.

There is no Context endpoint, palette data loader, UI or persistence wired to this utility yet. Passing these tests does not establish feature acceptance.

Concrete storage proposal for the remaining implementation

Keep ChapterGoals and existing scene purpose/outcome fields authoritative. Keep the existing SceneChecklistItems identities for scene objectives; do not copy them into an independent Intent document. Extend that checklist to support chapter items:

Concern Proposed contract
Scope Nullable SceneID plus nullable ChapterID, exactly one populated. Existing scene rows remain unchanged. Chapter rows reference the canonical chapter.
Text/order/completion Reuse ItemText (300 characters), SortOrder, IsCompleted and the existing item identity. Preserve author order across completion changes.
Change/notes Add an explicit changed flag and optional author notes. Changing an item never silently completes it.
Entity links Separate child rows keyed by item, entity kind and canonical/candidate identity, with explicit covered state. Link and covered are distinct from item completion. Validate each identity in the authorised project/book at save time.
Passage evidence Separate child rows containing source book/chapter/scene, accepted revision/paragraph identity when available and the quoted passage. Retain evidence as author evidence if a later manuscript revision changes it; do not reinterpret it as a fact.
Concurrency Atomic stored-procedure saves with a scope/row fingerprint that also detects changes by existing Writer and scene editors. Stale saves retain the local draft and require reconciliation.
Permissions Reuse book/project access and ContextEditPolicy; independently validate scope and edit permission in stored procedures. All mutations require antiforgery.
Lifecycle Item children delete with the item. Chapter/book/project deletion and restore explicitly include chapter items; no orphaned metadata. Entity archival/merge must retain meaningful author evidence and resolve current identity through canonical references.

This is a proposed schema contract, not an approved or qualified SQL migration. Recheck the next migration number when implementing (339 was the latest numeric prefix at discovery). Never edit existing numbered scripts.

Required source integration before qualification:

  • Update checklist read/write projections and preserve compatibility with existing SceneChecklist_ListByScene, SceneChecklist_Save and scene/Writer callers.
  • Extend ProjectBackupStoredFieldContract.Schema.cs and ProjectBackupGraphValidation.cs. Current backups require a scene link for every checklist row; merely making SceneID nullable would lose chapter items.
  • Add forward-only replacements for affected backup/export/restore and scoped deletion procedures. Current explicit checklist export projection is visible in migration 215; graph restore evolves through 229, 236 and 241. Trace the effective procedures rather than replaying those historical scripts. Include entity link and evidence remapping in portable backups and book recovery.
  • Qualify existing scene checklist compatibility, chapter-only scope, project isolation, stale concurrent saves, archival/deletion and backup/restore round trips with synthetic data in disposable databases. Existing author records must survive.

Remaining application and acceptance work

Implement one shared partial/component in the Context tool registry and docked Writer sidebar, using the same saved data. Default to chapter scope; optional scene scope must work without prose or Word. Reuse existing goal editors. Add paste preview, manual add/edit/check/change/notes, drag and keyboard reorder, explicit entity link/covered actions, and evidence drop contracts for future project 12 integration. Do not implement a native editor or a separate Intent window.

Build the palette from authorised canonical references and persisted candidates only; do not reconstruct raw Scene Intelligence JSON or trigger analysis. Use typed identity keys, canonical aliases and provenance; default to current chapter/scene associations with wider story search. Include characters, locations, assets, threads and relevant plotlines. Matching remains reference suggestions only.

Register the component with the existing Context lifecycle, dirty/busy refresh guards and saved-data invalidation. Extend the invalidation category map for all palette categories. Refresh newly captured entities while held without retargeting the held chapter/scene; preserve focus and drafts across panes/windows. Handle accepted Word manuscript updates through the existing accepted-source contract. Use theme controls, collapsible/resizable palette and PlotDirector.toast.

Run the solution build, regression harness, focused UI/concurrency tests and schema qualification. After a reviewed schema release to Development, verify the full deployed commit and use the registered ordinary browser fixture for real manual checklist/entity-link/evidence persistence after reload and fresh login, held-scope SignalR refresh, chapter-only/no-prose use and cleanup. Record receipts, feature URL, actual outcomes and limitations in CYJ. Production is excluded.

Deployment gate requiring operator assistance

Docs/Codex/Deployment.md, “SQL changes and recovery”, requires an explicit reviewed plan qualified against Development's schema. The installed unattended route invokes the routine code-only publisher. Tools/Deployment/development_release.py explicitly rejects any PlotLine/Sql changes relative to its approved baseline with: “Schema changes require a separately reviewed/qualified migration plan”.

The worker must not bypass that guard, invoke sudo, access signing material, manually apply SQL or change the baseline. An operator must identify/provision the authorised schema qualification and activation route for this task. This is a deployment prerequisite, not a request to reopen the agreed Intent product design. Resume from the committed preparation and this contract once that route is supplied; do not claim Development readiness or mark task 67 complete in the meantime.