PlotDirector/Docs/Locations/Refinements.md

16 KiB

Locations refinements: picker, taxonomy and shared Attributes

This refines the existing workspace, without changing its cards, ribbon, containment commands, merge reconciliation, protected Undo or live-update contracts. See the shared Attributes component standard.

Hierarchical selection

location-picker.js exposes PlotDirectorLocationPicker.mount(host, options) and enhance(select). It sorts roots and siblings alphabetically (independent of the workspace sort), renders containment branches and canonical icons, highlights selection and shows its full path. Name, alias and full-path search reveals matching ancestors. Temporary search expansion is separate from ordinary expansion; clearing search restores the ordinary state. Duplicate names display paths. Arrow keys, Home/End, Enter and Space navigate/select; Enter in search focuses a result and never submits a mutation.

Options: locations, types, selected, allowRoot, rootLabel, excludeIds, excludeBranches, label, searchLabel, onChange. IDs may be numeric or stable keys. excludeBranches prevents selecting the source and its descendants while leaving their context visible. Expansion remains available on unselectable headings. The return object exposes value, path(id) and focus(). No picker selection itself writes to the database. The operation owns confirmation and saving.

Workspace Change Parent, branch filter and reviewed merge use the inline picker in their existing modal. Traditional Create/Edit parent, Details relationship target and traditional Merge opt in using select[data-location-picker], project ID and operation exclusions. Without JavaScript, the native form controls remain. The modal uses shared theme variables and up to 900px width; paths wrap. LocationWorkspace/Picker checks project access and uses Location_PickerRead, loading only names, parent/type IDs and aliases, plus the canonical taxonomy. No manuscript prose is loaded. Map and floor-plan selection interfaces are unchanged.

Server project ownership, cycle/descendant guards, merge version checks, confirmation and original relationship validation remain authoritative. Client exclusions are conveniences, not security controls. The picker is also composed for type selection with grouping headings made unassignable.

Canonical taxonomy

Forward-only migration 338_LocationTypeTaxonomy.sql adds LocationTypeTaxonomy and two read procedures. The catalogue contains 105 entries: 97 canonical assignable type IDs, the assignable NULL Unclassified choice, and seven grouping headings. It adds 81 LocationTypes rows, leaving the existing 16 rows, IDs, names, order and active state unchanged. No Locations row is rewritten or specialised. City already existed (ID 16); it is now discoverable under Settlements. Existing Building, Town, Room and NULL Unclassified remain exactly those stored values.

TypeKey is the stable taxonomy identity. LocationTypeID maps assignable entries to the existing foreign key. Metadata supplies ParentKey, DisplayName, SortOrder, IconKey, SemanticTone and IsAssignable. Group headings never become rows in LocationTypes. Assignable categories such as Residential, Commercial, Public and institutional, Historic and defensive, Building and Room remain valid selections. NULL Unclassified has a stable metadata key and no invented canonical ID. Office in premises and Office in a room have distinct canonical IDs/names, with the same friendly label distinguished by its taxonomy path. Active legacy/custom types absent from metadata are read under Other with their existing IDs and names.

Extend via a reviewed forward-only migration: insert an assignable LocationTypes row only when needed, insert metadata with a unique stable key and existing parent key, choose an existing shared icon key (or add SVG geometry to ApplicationRibbon), and specify order/tone/assignability. Never renumber canonical IDs, change existing records or infer specialisations from manuscript text. The reader and UI consume metadata; no feature-specific taxonomy switch/list is required.

LocationWorkspace preserves types as the older flat canonical-ID/name list (non-null IDs only) and adds taxonomy for all nodes, including NULL Unclassified. The enhanced workspace derives its choices from taxonomy metadata; older open clients keep their original response contract. The presentation adapter resolves metadata icon keys through ApplicationRibbon. Details, type context menus and traditional forms consume the same taxonomy. Parent-type filtering/counts include the category's own value and all descendants using sets of assigned IDs; each location counts once. Grouping headings filter but cannot be assigned or used as record drop targets. The server accepts only active LocationTypes IDs (or NULL), rejecting heading keys independently of the client.

Classification taxonomy is not physical containment. A Flat may be under Residential in this catalogue and under any valid recorded parent in the author's world. No type-based containment restriction or temporary/temporal tracking is introduced. Real/Fictional provenance remains separate.

Consumer compatibility audit

  • LocationLookup_All, Location_Get, Location_ListByProject, Location_WorkspaceRead, Location_WorkspaceAssign and the existing model keep their assignable ID/name contracts.
  • Import lookup procedures and ImportServices still resolve canonical IDs/names. Existing StoryIntelligenceLocationImportService generic matching is not changed or re-run; old sort priority is retained and new types follow it. This task adds no AI request or geocoding work.
  • Project backup/export/restore and story-bible location summaries still use LocationTypeID and canonical TypeName. Global taxonomy metadata is deployment configuration, not duplicated project data.
  • Geography chain/hierarchy reads join the same IDs/names; explicit geography review remains intact.
  • Maps, Floor Plans, Context and Word Companion keep their location identities, references, existing detection/Quick Add flags and provider contracts. Their interfaces and focus/Hold/Follow are unchanged.

Verification and delivery evidence follows below. Production remained untouched.

Reproduce the focused rendered checks

Start the existing executable harness with --toolbar-browser-host. On a qualified disposable Locations clone, export the current catalogue (metadata/icons only):

dotnet run --project PlotLine.Tests -- --location-taxonomy-fixture /private/clone.json /tmp/pd-refinements-taxonomy.json
node PlotLine.Tests/Browser/workspace-refinements.cjs
xvfb-run -a node PlotLine.Tests/Browser/workspace-refinements.cjs --installed
node PlotLine.Tests/Browser/shared-attributes-comparison.cjs
xvfb-run -a node PlotLine.Tests/Browser/shared-attributes-comparison.cjs --installed

PD_TAXONOMY_FIXTURE can override the snapshot path. No second production taxonomy definition is maintained in JavaScript. The browser tests use actual compiled Razor/shared assets with synthetic HTTP mutations. PlotLine.Tests/Sql/LocationTaxonomy.sql is guarded to disposable clones and rolls its fixtures back. Existing Characters and Locations browser regressions remain separate checks.

Delivery and verification

Final deployed application: 3cbafd34f2. Development release development-location-refinements-3cbafd34f2cd-20261127T145949Z, deployment 20261127T150012Z-7f65af63d564, passed signed admission, verified COPY_ONLY/CHECKSUM backup, binary/application/database checks and release-history recording. Migration 338 was applied through the first Development activation; the final code-only activation executed zero migrations. Final receipt, migration receipt, health, release gates.

Implementation commits pushed to codex/word-companion-native-phase1-20261104:

  • 0e5a3805: hierarchical picker, canonical taxonomy, shared Attributes and both consumers.
  • 2fb6423c: preserve the older canonical type-list API and authenticated regression coverage.
  • 3cbafd34: preserve picker/palette semantic colours, with seven-theme computed-colour assertions.

Validation completed:

  • Clean solution build: zero warnings/errors; executable regression harness: 889 PASS, exit 0.
  • Two fresh migration clones: all 208 other original business tables unchanged, all 16 old type rows and IDs unchanged, 81 new canonical types and 105 metadata rows; identical resulting schema hashes, DBCC and constraints passed. Migration qualification. The code-only qualification retained all 210 business-table fingerprints and the same schema. Final qualification.
  • Focused SQL tests: three-level acyclic taxonomy, grouping/assignable separation, Office contexts, generic/specialised and bulk assignments, exact prior-value Undo, unchanged physical containment and provenance, server rejection of grouping keys. All fixtures roll back. SQL results.
  • Existing location SQL tests and real Dapper contracts passed with the expanded catalogue, including hierarchy/concurrency guards, scene/reference/merge preservation, exact datetime2 merge binding, typed classification export and generic restore. SQL, Dapper.
  • Actual compiled Razor/shared assets, with isolated synthetic HTTP mutations: new picker/taxonomy suite at 50/500/1,000 records; around 100 containment levels, wide roots/siblings, repeated names, aliases, long paths and descriptions. Native bidirectional drag, bulk/Undo, generic selection, descendant filtering/counts, nested menus, explicit merge confirmation, branch exclusions, root selection, keyboard navigation, empty/clear search, and saved nested expansion passed. Browser, installed PWA.
  • Existing Characters browser/PWA suites passed at 10/100/500; existing Locations browser/PWA suites passed at 50/200/500/1,000. These exercise the existing cards, biographies, inline operations, relationship/navigation links, selection, live-refresh guards, hierarchy drag and panel persistence.
  • Both palettes passed one-session cross-workspace navigation with independent widths/group state, aligned columns at narrow/wide bounds, seven themes and 1024/1440/1920 viewport checks. Character card node counts, full fixture biographies and variable heights remain intact. Shared browser check, shared installed-PWA check.
  • Authenticated final Development browser: real type assignment/bulk/Undo/filtering, aliases, Create/Edit parent/type controls, relationship target, workspace parent/alias picker, native attribute drag in both directions, cycle/heading rejection, reviewed workspace merge, traditional merge confirmation, and real Characters creation/bulk/filter/Undo with variable biographies. Actual browser.
  • Actual installed Development Chromium PWA: 105-node catalogue, legacy 97-ID response without a duplicate NULL choice, Office disambiguation, alias picker, both palettes, card descriptions, resize and same-window Details. Actual installed PWA.

All screenshots and mutation tests use synthetic fixtures. The dedicated account and its owned project/book/locations/characters were removed through the existing account hard-delete workflow; its credential file and all three task-specific qualification databases were removed. Development was never restored or reset. Cleanup.

Representative rendered evidence

Demonstration Screenshots
Wide hierarchical picker with selected full path Browser, installed PWA
Deep hierarchy / long path Browser, PWA
Expanded taxonomy, light/dark Light, dark
Shared Locations palette Light, dark
Shared Characters palette Light, dark
Character cards retained Browser, installed PWA
Deployed parent and traditional merge pickers Parent, merge
Deployed taxonomy and Characters Locations, Characters
Deployed installed PWA Type picker, location picker, Locations, Characters

The evidence directory also includes all seven theme screenshots for both palettes and modes. Representative new-workspace load timings (milliseconds; single synthetic HTTP-fixture passes):

Locations Browser Installed Chromium PWA
50 287 316
500 490 773
1000 756 1181

These are rendered fixture measurements, not authenticated service benchmarks or statistical speedup claims. Full descriptions/cards remain unvirtualised, as before. Deep-picker interaction measurements include search, pointer actions, a screenshot and deliberate settling waits.

Acceptance boundaries

Requirement Status Evidence / limit
Hierarchical picker, sibling/root order, paths, aliases, duplicate names Passed Rendered suites and actual forms
Root choice, operation exclusions, keyboard, clear/empty search Passed Browser/PWA; actual server rejection retained
Workspace and traditional merge confirmation Passed Authenticated final Development run
Existing IDs/values, generic levels, three-level taxonomy Passed SQL fingerprints, graph checks, actual assignments
Parent filters/counts, bulk, drag and exact Undo Passed Both rendered consumers; SQL and actual mutation checks
Shared styling, semantic colours, narrow/wide aligned columns Passed Seven themes, computed colour checks and screenshots
Independent preferences, resize, scrolling and restored expansion Passed Same-session browser/PWA navigation
Characters cards and existing Locations workflows Passed Existing browser suites, SQL and authenticated smoke
Maps, Floor Plans, Context, import and Word contracts Passed Existing harness/contracts; unchanged IDs/providers, no interface redesign
No added AI/geocoding or focus/Hold/Follow writes Passed New command/read paths and migration inspected; existing focus harness
Development deployment and fixture removal Passed Signed receipts, healthy exact source/database, cleanup record
Physical Windows/Edge/Word end-to-end use Not verified Linux browser + genuinely installed Chromium PWA were available
Collections above 1,000; exhaustive assistive-technology audit Not verified No claim beyond exercised cases

No unresolved failing check remains. Catalogue authoring UI is not included; extensions use reviewed forward-only migrations. Specialised Maps/Floor Plans selectors and Context/Assets interfaces remain unchanged by design. No general application redesign was undertaken.