docs(context): record spatial acceptance, deployment and rendered evidence

This commit is contained in:
Nick Beckley 2026-11-27 18:19:09 +00:00
parent ebc9c2b413
commit f3b40b9da2
50 changed files with 273 additions and 3 deletions

View File

@ -0,0 +1,142 @@
# Integrated Spatial Context delivery
## Implementation
Three self-contained Scene-scoped tools extend unified Context: Locations, Maps and Floor Plans. They share authoritative previous/current/next scene resolution, direct/nearest-containing resource resolution, canonical location taxonomy, window-local spatial inspection and ephemeral P/C/N highlighting. They work alone or in either split orientation alongside existing tools.
Locations supports adjacent-scene inspection without navigation, ancestry and immediate children, descriptions, rename, types, classification, child creation and explicit current-scene assignment/new-location creation. Description drafts and placement/association targets remain pinned through focus changes. Missing assignments remain unassigned; unavailable recorded assignments are explicitly distinguished.
Maps reuses the canonical renderer in a connection-free renderer iframe. Existing geometry, backgrounds and surrounding features remain visible. Context adds resource choice, zoom/pan/fit/centre, combined scene indicators, explicit existing-location placement/repositioning and native cross-pane drops. A validated `featureId` parameter supplies the reusable main-map reveal route.
Floor Plans reuses the extracted canonical stage, presentation helpers and wall/transition renderer. Context adds read-only viewport controls, floor selection, explicit room highlighting/inspection, existing-location/plan association and deliberate create-and-associate. Geometry and containment are not changed by association.
Existing Context owns focus, Hold/Follow, two panes, window identity, preferences and its one SignalR connection. Generic lifecycle extensions permit in-place refresh and guarded pane closure. Main spatial editors reuse their existing presence connection for persisted-data refresh; clean resources refresh while dirty editors retain drafts. Hidden tab caches are invalidated without loading resources, and stale responses cannot repopulate them. Shared map/plan mutations notify the project across books; scene assignment remains book-scoped. Unassociated map features can be inspected without inventing a location association. Advanced links reveal the exact feature/block.
See [architecture and contracts](Spatial-Context.md) and [user help](../../PlotLine/Help/Articles/Workspace/WorkingContext.md).
## Data and safeguards
Migration **339_SpatialContext** adds read/targeted-mutation procedures; it adds no tables, classification fields, competing geometry model or automatic data migration. All normal database access uses Dapper/stored procedures. Authorisation, active project/location validation, compare-and-swap, transaction and audit checks run on the server. Protected Undo is user-bound and expires after ten minutes. Create-and-assign uses one transaction so a failed assignment cannot leave an unintended location.
Scene assignment remains `Scenes.PrimaryLocationID`. Recorded character, asset and occupancy positions retain separate labels and do not fill missing primary assignments. Selection is local to each Context root and never broadcasts or writes manuscript focus. Paragraph movement does not reset it. Resource/viewport preferences are scoped to author/window/project/tool/resource; placement mode is not persisted.
The recursive ancestor query is cycle-safe and unrestricted by genre or location taxonomy. Direct associations win; otherwise the nearest explicitly associated containing location is labelled as inherited. Room associations take precedence at the same depth, and candidates can prefer adjacent-scene coverage. Descriptions, canonical identifiers, scene references, map geometry and floor-plan geometry are preserved.
No AI, routing, geocoding or automatic location/association creation is introduced by these tools. Traditional World editors and ribbon arrangements are retained.
## Verification evidence
- Normal solution build and executable regression harness: **889 PASS**, no failures on the qualified candidate. The final clean-source gate also passed with zero build warnings or errors.
- Final Development read-only `DBCC CHECKCONSTRAINTS WITH ALL_CONSTRAINTS` completed with **zero constraint violations** after fixture cleanup.
- Two fresh database copies qualified migration 339. All **210 original business tables** were unchanged; both integrity runs reported **zero constraint violations**.
- Database contracts exercised authoritative first/last/chapter-boundary order, Dapper projections, nearest-ancestor availability, explicit scene assignment, marker placement/repositioning, room/plan association and exact Undo. Duplicate markers, stale room versions, absent confirmation, connected-room identity changes, unauthorised access and unavailable resources were rejected.
- Synthetic browser checks used actual compiled Razor and the canonical renderers. They covered all three single tools, three spatial pairings, both split orientations, local coordination, independent windows, unavailable/unassigned/repeated locations, preserved drafts, paragraph stability, same-building renderer/viewport retention, native map/room drops and rejected-write recovery.
- Authenticated final-release browser checks passed for cross-chapter scene order, adjacent inspection, explicit current-scene assignment, description/name/type/classification edits, protected Undo, atomic create rollback, placement/reveal, room association, geometry preservation, live room labels, main workspace navigation and the single-connection contract. Hold/Release was exercised through actual shared focus from another browser window.
- The final release also passed an authenticated **installed Chromium PWA** run covering all three tools, shared highlights, side-by-side and stacked panes, with no page errors.
- All seven themes were rendered in Chromium browser and an **actual installed Chromium PWA**. Browser fixtures contain no author manuscript data.
- Main Maps browser/PWA workflow and Floor Plans browser/PWA save/error/unsaved-navigation regressions passed. Main clean map/floor live refresh and dirty-editor protection passed.
- The legacy `context-workspace-foundation.cjs` timed out at its same-scene invalidation assertion against **both baseline and current** Context code. Its fake SignalR stores one handler per event while the real connection supports multiple subscribers. This suite is recorded as failed, not counted as passed. The new focused spatial suite passed.
### Measurements
These are observed samples, not general performance guarantees or claims that a pre-existing spatial Context was faster/slower: the previous application had no such tabs.
| Measurement | Result |
|---|---|
| Initial synthetic Locations tab, one recorded browser run | 83 ms in an early run; current results file records the final run |
| Paragraph movement within the same scene | **0 spatial requests** in the browser assertion |
| First/last and chapter-boundary reads, final recursive implementation | 18 samples: median **11.0 ms**, maximum **51.4 ms** |
| 500-level hierarchy plus 1,000 unrelated roots, initial candidate iterative query | **2,274.3 ms**; 501 relevant locations returned |
| Same stress fixture after recursive-query refinement | **125.6 ms**; 501 relevant locations returned, no unrelated directory load |
| Same-building scene change | Existing map iframe and manually set 900-unit viewport retained |
| Authenticated Development: initial Locations / Maps / Floor Plans | 127 / 89 / 90 ms (single observed run) |
| Authenticated Development: same-location / same-building scene change | 78 / 52 ms |
| Alternative-map resolve/render / second split-pane mount | 134 / 81 ms |
| Authenticated Development: 100 same-scene paragraph moves | 0 spatial requests |
These authenticated timings were measured on the final deployed application. Alternative-resource switching may establish a new viewport; the tested guarantee is retaining the existing viewport while its map remains relevant, rather than restoring every historical viewport across resource changes.
Cold compilation, concurrent host work and cache state affect these measurements. A full cross-device latency benchmark and physical Word event-rate test were not performed.
## Acceptance matrix
| Area | Status | Evidence / boundary |
|---|---|---|
| Three independently loadable spatial tabs | Passed | Actual compiled fragments and renderers |
| Authoritative three-scene sequence and chapter boundaries | Passed | Database tests against `NarrativeSceneOrder` |
| Unassigned, unavailable and repeated locations | Passed | Rendered browser assertions |
| Ancestor/child exploration and Return | Passed | Browser selection and shared resolver tests |
| Name/description/type/classification quick editing | Passed | Authenticated Development edits and Undo, including City taxonomy |
| Explicit current-scene assignment | Passed | Server version checks; browser DTO target assertions; deployed checks below |
| Hierarchical picker reuse | Passed | Actual shared picker and operation-specific confirmation |
| Direct versus inherited resources | Passed | Resolver tests, rendered inherited map caption |
| Map geometry/background renderer reuse | Passed | Existing Maps workflow regression; canonical Context renderer |
| Combined P/C/N map indicators | Passed | Actual rendered combined rings |
| Map zoom/pan/fit/centre and viewport retention | Passed | Canonical renderer; same-building viewport assertion |
| Map placement/repositioning and Undo | Passed | Database persistence/reposition/Undo; browser explicit mode/rejection |
| Native cross-pane map drop | Passed | Actual mouse drag, reviewed drop and Cancel |
| Floor renderer, floors, rooms and scene indicators | Passed | Shared stage/algorithms, rendered rooms and levels |
| Room/plan association and Undo without geometry changes | Passed | Database positive/negative contracts |
| Native location-to-room drop | Passed | Actual mouse drag and explicit review |
| Connected-room identity replacement | Not implemented | Rejected when door/window transitions reference old/new identities; main-editor review required |
| Unassociated room geometry with nullable location | Not implemented | Canonical blocks require LocationID; no competing Context-only model added |
| Local selection isolation and feedback-loop prevention | Passed | Source/revision contract, coordinated panes and independent windows |
| Paragraph refresh suppression and stale response guards | Passed | Zero-request assertion and response epoch checks |
| Active edits pinned across scene changes | Passed | Rendered draft preservation and deferred pane refresh |
| Main editor clean refresh / dirty protection | Passed | Focused actual-renderer browser checks |
| Seven themes and narrow/stacked presentation | Passed | Browser and installed-PWA screenshots |
| Authenticated Development / installed PWA | Passed | Actual logged-in browser and installed Chromium PWA, disposable fixtures only |
| Physical Windows / Word Companion | Not verified | Linux environment; synthetic focus events do not constitute physical Word testing |
| Legacy broad Context foundation browser script | Failed | Same baseline/current failure described above |
| Existing workspace directories and focused spatial workflows | Passed | Authenticated directory navigation, full harness and Maps/Floor Plans browser/PWA regressions |
| Full manual regression of every unrelated workspace workflow | Not verified | No claim of comprehensive manual coverage |
| Hold/Follow and held-window persisted updates | Passed | Actual shared focus published from another browser window; held position retained, data updated, Release followed |
| Hidden-cache invalidation and obsolete responses | Passed | Hidden tabs made no resource requests, reopened fresh; delayed response could not repopulate invalidated cache |
| Additional AI processing | Passed | No new AI service dependency, request or migration analysis |
| Production untouched | Passed | Atlas Development-only workflow; no Production operations |
## Known limits
- A maximum of forty immediate children is shown for local exploration. Open Locations for a larger directory.
- Canonical room blocks already require a location; explicit replacement is supported only when existing transitions can be preserved safely. Connected identity reconciliation remains in the main Floor Plans editor.
- Context mutations/Undo use compare-and-swap. The existing main Floor Plans full-layout save has no document-wide version contract; simultaneous full-layout editing from another device was not verified. Its existing concurrency architecture has not been redesigned.
- Physical Windows/Word integration, cross-device simultaneous editing and a rendered 500-level path benchmark are not verified. SQL stress resolution was tested.
- No routing, travel-time computation or inferred room matching is supplied.
## Representative screenshots
| Scenario | Evidence |
|---|---|
| Locations single pane | [Locations](SpatialContextEvidence/01-locations-single.png) |
| Maps single pane and combined P/C/N highlight | [Maps](SpatialContextEvidence/02-maps-single.png) |
| Floor Plans single pane and three room highlights | [Floor Plans](SpatialContextEvidence/03-floorplans-single.png) |
| Locations + Maps, room inheriting building map | [Pair](SpatialContextEvidence/04-locations-maps.png) |
| Locations + Floor Plans | [Pair](SpatialContextEvidence/05-locations-floorplans.png) |
| Maps + Floor Plans | [Pair](SpatialContextEvidence/06-maps-floorplans.png) |
| Stacked panes | [Stacked](SpatialContextEvidence/07-stacked.png) |
| Repeated scene location | [Repeated](SpatialContextEvidence/10-repeated-location.png) |
| Unmapped location | [Unmapped](SpatialContextEvidence/12-unmapped-location.png) |
| Explicit map placement / native drop | [Placement](SpatialContextEvidence/13-map-placement.png), [drop](SpatialContextEvidence/13-native-cross-pane-drop.png) |
| Room association / native drop | [Association](SpatialContextEvidence/14-room-association.png), [drop](SpatialContextEvidence/14-native-room-drop.png) |
| Unassigned current scene | [Unassigned](SpatialContextEvidence/15-unassigned.png) |
| Narrow pane | [Narrow](SpatialContextEvidence/16-narrow.png) |
| Light and dark | [Modern light](SpatialContextEvidence/theme-modern-light.png), [modern dark](SpatialContextEvidence/theme-modern-dark.png) |
| Actual installed Chromium PWA | [Spatial pair](SpatialContextEvidence/installed-pwa-locations-maps.png), [dark](SpatialContextEvidence/installed-pwa-modern-dark.png), [stacked](SpatialContextEvidence/installed-pwa-stacked.png) |
| Authenticated Development Locations / Maps / Floor Plans | [Locations](SpatialContextEvidence/development-locations.png), [map pair](SpatialContextEvidence/development-locations-maps.png), [plan pair](SpatialContextEvidence/development-locations-floorplans.png) |
| Development alternative map | [Alternative map](SpatialContextEvidence/development-alternative-map.png) |
| Development before deployment | [Existing Overview](SpatialContextEvidence/development-before.png) |
All seven browser and installed-PWA theme captures are retained in the evidence directory. Authenticated post-deployment evidence and release identifiers follow below.
## Development release
Activated **27 November 2026 at 18:17 UTC**, Development only. Health confirmed `Development`, `PlotDirector_Development` and application source **`ebc9c2b41389d55372ab1ae1ad3d454b0397b48a`**.
- Release: `development-spatial-context-ebc9c2b41389-20261127T181607Z`.
- Deployment receipt: `20261127T181646Z-a639d86614f5`; verified COPY_ONLY/CHECKSUM backup, no activation failures.
- Final clean-source build: **0 warnings, 0 errors** (40.27 s); executable regression harness: **889 PASS** (95.64 s); Release publish passed (32.58 s).
- Migration 339 was activated in the initial spatial release. The final release executed **zero migrations**, preserving schema `3d6e163f7cb8fff6bd17834ae8097dcf68be03894ce644844621dc191336cb7a`.
- Two fresh copies qualified the migration; two further copies qualified the identical code-only SQL plan. The final client/cache/notification patch reused the latter qualification because its immutable SQL plan and schema were unchanged. All copies were removed afterwards. The dedicated authenticated test account and its owned fixture project were removed through the normal hard-delete workflow; its private credential file was deleted.
- Implementation commits: `01757170`, `587f067d`, `802b9892`, `0e875934`, `1b9d231a`, `c8ea6446`, `ebc9c2b4`. All pushed to the existing task branch. This report and its disposable-fixture test corrections are a subsequent documentation/test-only commit.
[Sanitised release and gate evidence](SpatialContextEvidence/release-summary.json). Production was neither accessed nor deployed.

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

View File

@ -0,0 +1,7 @@
{
"passed": true,
"locations_initial_ms": 82,
"spatial_requests": 22,
"paragraph_spatial_requests": 0,
"errors": []
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

View File

@ -0,0 +1,7 @@
{
"passed": true,
"installed": true,
"target": "Development",
"fixturesOnly": true,
"errors": []
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

View File

@ -0,0 +1,8 @@
{
"database": "PlotDirector_Development",
"operation": "read-only DBCC CHECKCONSTRAINTS WITH ALL_CONSTRAINTS after final activation and fixture cleanup",
"constraintViolations": 0,
"success": true,
"disposableIdentityCleanup": "Normal HardDeleteAccount completed; owned fixture data removed and private credential file deleted",
"productionAccess": false
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

View File

@ -0,0 +1,16 @@
{
"source": "authenticated Development; explicit browser scene navigation, not physical Word",
"milliseconds": {
"locations_initial": 127,
"map_initial": 89,
"same_location_scene_navigation": 78,
"same_building_scene_navigation": 52,
"different_map_resolution_and_render": 134,
"floor_plan_initial": 90,
"split_second_pane_mount": 81
},
"paragraph_moves": 100,
"paragraph_spatial_requests": 0,
"returned_map_viewport_width": 648.4771573604061,
"passed": true
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

View File

@ -0,0 +1,21 @@
{
"passed": true,
"source": "authenticated Development",
"fixturesOnly": true,
"sceneSequence": [
12449,
12450,
12451
],
"checks": [
"/Locations",
"/Characters",
"/Names",
"/RelationshipMap",
"/Maps",
"/FloorPlans/Edit/18",
"/StoryAssets"
],
"signalRConnections": 1,
"errors": []
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

View File

@ -0,0 +1,62 @@
{
"release": {
"application_sha256": "d340da9a91c563b7a6a605b5db4d77cd89ccc71aac5983c2262a52d61be430e2",
"dll_sha256": "f36735870fd8d3318acd26f1984156f57250b7934623dd88fef14c808ea7db14",
"id": "development-spatial-context-ebc9c2b41389-20261127T181607Z",
"manifest_sha256": "4808c18f8af8320f5f7664219dba7e8dfe4fa85906380426d94f79f85884b5ed",
"package_sha256": "894e52b23774c86c809d33033c427619b24c0fa077c4e7d76e6cb5f4d61920db",
"source_commit": "ebc9c2b41389d55372ab1ae1ad3d454b0397b48a",
"version": "1.0.0"
},
"deployment_id": "20261127T181646Z-a639d86614f5",
"status": "activated",
"application": {
"database": "PlotDirector_Development",
"environment": "Development",
"healthy": true,
"sourceCommit": "ebc9c2b41389d55372ab1ae1ad3d454b0397b48a",
"version": "1.0.0"
},
"verified_database_backup": true,
"migrations_executed_in_final_code_only_release": 0,
"schema_sha256": "3d6e163f7cb8fff6bd17834ae8097dcf68be03894ce644844621dc191336cb7a",
"failures": [],
"gates": {
"source_commit": "ebc9c2b41389d55372ab1ae1ad3d454b0397b48a",
"results": [
{
"gate": "build",
"exit_code": 0,
"seconds": 40.27
},
{
"gate": "regression",
"exit_code": 0,
"seconds": 95.64
},
{
"gate": "publish",
"exit_code": 0,
"seconds": 32.58
}
]
},
"regression_pass_count": 889,
"database_qualification": {
"status": "passed",
"runs": [
{
"starting_schema_sha256": "3d6e163f7cb8fff6bd17834ae8097dcf68be03894ce644844621dc191336cb7a",
"resulting_schema_sha256": "3d6e163f7cb8fff6bd17834ae8097dcf68be03894ce644844621dc191336cb7a",
"unchanged_original_tables": 210
},
{
"starting_schema_sha256": "3d6e163f7cb8fff6bd17834ae8097dcf68be03894ce644844621dc191336cb7a",
"resulting_schema_sha256": "3d6e163f7cb8fff6bd17834ae8097dcf68be03894ce644844621dc191336cb7a",
"unchanged_original_tables": 210
}
],
"reuse": "Identical immutable SQL plan and schema; two qualified code-only runs reused for final client/cache/notification patch. Migration 339 separately qualified twice before its first activation."
},
"production_access": false
}

View File

@ -0,0 +1,7 @@
{
"passed": true,
"locations_initial_ms": 66,
"spatial_requests": 28,
"paragraph_spatial_requests": 0,
"errors": []
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

View File

@ -1,7 +1,7 @@
// Authenticated Development measurements and multi-map check; only dedicated fixture records change.
const{chromium}=require('playwright'),fs=require('node:fs'),assert=require('node:assert/strict');const file=process.argv[2],identity=JSON.parse(fs.readFileSync(file)),f=identity.SpatialFixture;assert(file.startsWith('/tmp/pd-dev-browser-')&&identity.Database==='PlotDirector_Development'&&identity.Email.startsWith('pwa-browser-')&&f);const base='https://dev.plotdirector.com';
(async()=>{const browser=await chromium.launch();let page,token,receipts=[];const metrics={source:'authenticated Development; explicit browser scene navigation, not physical Word',milliseconds:{}};try{page=await browser.newPage({viewport:{width:1600,height:1050}});await page.goto(base+'/Account/Login');await page.locator('#Email').fill(identity.Email);await page.locator('#Password').fill(identity.Password);await Promise.all([page.waitForURL('**/Projects'),page.locator('form button[type=submit]').click()]);await page.goto(base+`/Scenes/Edit/${f.scenes[1]}`);await page.goto(base+`/Writing/Context?projectId=${identity.ProjectID}&bookId=${identity.BookID}&sceneId=${f.scenes[1]}&pinned=true`);let spatialRequests=0;page.on('request',r=>{if(r.url().includes('/SpatialContext/'))spatialRequests++;});let started=Date.now();await page.selectOption('[data-context-pane="0"] [data-context-tab]','locations');await page.getByRole('heading',{name:'Bedroom',exact:true}).waitFor();metrics.milliseconds.locations_initial=Date.now()-started;token=await page.locator('[name=__RequestVerificationToken]').first().inputValue();const read=async scene=>{const r=await page.request.get(base+`/SpatialContext/State?bookId=${identity.BookID}&sceneId=${scene}`);assert.equal(r.status(),200);return r.json();};const json=async(route,body)=>{const r=await page.request.post(base+route,{headers:{RequestVerificationToken:token},data:body});assert.equal(r.status(),200,route);return r.json();};const changeScene=async(scene,location)=>{const data=await read(scene),result=await json('/SpatialContext/Mutate',{bookID:identity.BookID,sceneID:scene,kind:'scene',locationID:location,expected:data.scope.version});receipts.push(result.undoToken);return result;};const undo=async()=>{const value=receipts.at(-1);await json('/SpatialContext/Undo',{token:value});receipts.pop();};
started=Date.now();await page.selectOption('[data-context-pane="0"] [data-context-tab]','maps');await page.waitForFunction(()=>document.querySelector('iframe')?.contentWindow?.PlotDirectorMapWorkspace?.document.features.length===1);metrics.milliseconds.map_initial=Date.now()-started;await page.evaluate(()=>{window.perfMapFrame=document.querySelector('iframe');perfMapFrame.contentWindow.PlotDirectorMapWorkspace.setView({x:-300,y:-200,w:900,h:650});});const currentPosition=await page.evaluate(()=>document.querySelector('[data-context-workspace]').contextController.position);const before=spatialRequests;await page.evaluate(p=>{for(let i=0;i<100;i++)document.querySelector('[data-context-workspace]').contextController.setPosition({...p,paragraphId:'synthetic-paragraph-'+i});},currentPosition);await page.waitForTimeout(100);metrics.paragraph_moves=100;metrics.paragraph_spatial_requests=spatialRequests-before;assert.equal(metrics.paragraph_spatial_requests,0);
started=Date.now();await page.selectOption('[data-context-pane="0"] [data-context-tab]','maps');await page.waitForFunction(()=>document.querySelector('iframe')?.contentWindow?.PlotDirectorMapWorkspace?.document.features.length===1);metrics.milliseconds.map_initial=Date.now()-started;await page.evaluate(()=>{window.perfMapFrame=document.querySelector('iframe');perfMapFrame.contentWindow.PlotDirectorMapWorkspace.setView({x:-300,y:-200,w:900,h:650});});const currentPosition=await page.evaluate(()=>document.querySelector('[data-context-workspace]').contextController.position);await page.waitForTimeout(1000);const before=spatialRequests;await page.evaluate(p=>{for(let i=0;i<100;i++)document.querySelector('[data-context-workspace]').contextController.setPosition({...p,paragraphId:'synthetic-paragraph-'+i});},currentPosition);await page.waitForTimeout(100);metrics.paragraph_moves=100;metrics.paragraph_spatial_requests=spatialRequests-before;assert.equal(metrics.paragraph_spatial_requests,0);
await changeScene(f.scenes[2],f.locations[1]);started=Date.now();await page.selectOption('[data-context-scene]',String(f.scenes[2]));await page.waitForFunction(()=>document.querySelector('[data-scene-position="0"]')?.title.includes('Spatial disposable next'));metrics.milliseconds.same_location_scene_navigation=Date.now()-started;assert(await page.evaluate(()=>document.querySelector('iframe')===window.perfMapFrame));started=Date.now();await page.selectOption('[data-context-scene]',String(f.scenes[0]));await page.waitForFunction(()=>document.querySelector('[data-scene-position="0"]')?.title.includes('Spatial disposable previous'));metrics.milliseconds.same_building_scene_navigation=Date.now()-started;assert(await page.evaluate(()=>document.querySelector('iframe')===window.perfMapFrame));assert.equal(await page.evaluate(()=>perfMapFrame.contentWindow.PlotDirectorMapWorkspace.view.w),900);await undo();
const created=await page.request.post(base+'/Maps/Create',{form:{__RequestVerificationToken:token,ProjectID:String(identity.ProjectID),Name:`Spatial disposable remote map ${Date.now()}`,Kind:'Region'}});assert.equal(created.status(),200);const mapId=(await created.json()).id;const remoteResponse=await page.request.get(base+`/Maps/State?projectId=${identity.ProjectID}&id=${mapId}`),remote=await remoteResponse.json();remote.features=[{featureID:crypto.randomUUID(),mapID:mapId,name:'Unmapped valley',type:'Custom',geometryClass:'Marker',layer:'Places',x:200,y:100,width:48,height:48,isPlaced:true,showLabel:true,locationID:f.locations[4],geometryJson:'{}'}];await json('/Maps/Save',remote);await changeScene(f.scenes[0],f.locations[4]);await page.locator('[data-scene-position="0"] button').filter({hasText:'Unmapped valley'}).waitFor();started=Date.now();await page.locator('[data-scene-position="0"] button').first().click();await page.waitForFunction(id=>document.querySelector('iframe')?.contentWindow?.PlotDirectorMapWorkspace?.document.map.mapID!==id,f.mapId);await page.selectOption('[data-spatial-resource]',String(mapId));await page.waitForFunction(id=>document.querySelector('iframe')?.contentWindow?.PlotDirectorMapWorkspace?.document.map.mapID===id,mapId);metrics.milliseconds.different_map_resolution_and_render=Date.now()-started;await page.getByText('On another map',{exact:true}).first().waitFor();await page.screenshot({path:'/tmp/pd-spatial-evidence/development-alternative-map.png'});await undo();await page.locator('[data-scene-position="0"] button').filter({hasText:'Lounge'}).waitFor();await page.locator('[data-scene-position="0"] button').first().click();await page.waitForFunction(id=>document.querySelector('iframe')?.contentWindow?.PlotDirectorMapWorkspace?.document.map.mapID===id,f.mapId);assert.equal(await page.evaluate(()=>document.querySelector('iframe').contentWindow.PlotDirectorMapWorkspace.view.w),900);
await page.selectOption('[data-context-scene]',String(f.scenes[1]));await page.waitForFunction(()=>document.querySelector('[data-scene-position="0"]')?.title.includes('Spatial disposable current'));started=Date.now();await page.selectOption('[data-context-pane="0"] [data-context-tab]','floorplans');await page.locator('.spatial-room-badge').first().waitFor();metrics.milliseconds.floor_plan_initial=Date.now()-started;started=Date.now();await page.selectOption('[data-context-layout]','columns');await page.selectOption('[data-context-pane="1"] [data-context-tab]','maps');await page.locator('[data-context-pane="1"] iframe').waitFor();metrics.milliseconds.split_second_pane_mount=Date.now()-started;metrics.passed=true;fs.writeFileSync('/tmp/pd-spatial-evidence/development-performance.json',JSON.stringify(metrics,null,2));console.log('PASS authenticated spatial measurements, 100 paragraph moves/zero requests, same-location/building viewport retention, alternative-map resolution/reveal and restored resource viewport.');}catch(e){if(page)await page.screenshot({path:'/tmp/pd-spatial-evidence/development-performance-unverified.png'}).catch(()=>{});throw e;}finally{if(page&&token)for(const value of receipts.reverse())await page.request.post(base+'/SpatialContext/Undo',{headers:{RequestVerificationToken:token},data:{token:value}}).catch(()=>{});await browser.close();}})().catch(e=>{console.error(e);process.exitCode=1;});
const created=await page.request.post(base+'/Maps/Create',{form:{__RequestVerificationToken:token,ProjectID:String(identity.ProjectID),Name:`Spatial disposable remote map ${Date.now()}`,Kind:'Region'}});assert.equal(created.status(),200);const mapId=(await created.json()).id;const remoteResponse=await page.request.get(base+`/Maps/State?projectId=${identity.ProjectID}&id=${mapId}`),remote=await remoteResponse.json();remote.features=[{featureID:crypto.randomUUID(),mapID:mapId,name:'Unmapped valley',type:'Custom',geometryClass:'Marker',layer:'Places',x:200,y:100,width:48,height:48,isPlaced:true,showLabel:true,locationID:f.locations[4],geometryJson:'{}'}];await json('/Maps/Save',remote);await changeScene(f.scenes[0],f.locations[4]);await page.locator('[data-scene-position="0"] button').filter({hasText:'Unmapped valley'}).waitFor();started=Date.now();await page.locator('[data-scene-position="0"] button').first().click();await page.waitForFunction(id=>document.querySelector('iframe')?.contentWindow?.PlotDirectorMapWorkspace?.document.map.mapID!==id,f.mapId);await page.selectOption('[data-spatial-resource]',String(mapId));await page.waitForFunction(id=>document.querySelector('iframe')?.contentWindow?.PlotDirectorMapWorkspace?.document.map.mapID===id,mapId);metrics.milliseconds.different_map_resolution_and_render=Date.now()-started;await page.getByText('On another map',{exact:true}).first().waitFor();await page.screenshot({path:'/tmp/pd-spatial-evidence/development-alternative-map.png'});await undo();await page.locator('[data-scene-position="0"] button').filter({hasText:'Lounge'}).waitFor();await page.locator('[data-scene-position="0"] button').first().click();await page.waitForFunction(id=>document.querySelector('iframe')?.contentWindow?.PlotDirectorMapWorkspace?.document.map.mapID===id,f.mapId);metrics.returned_map_viewport_width=await page.evaluate(()=>document.querySelector('iframe').contentWindow.PlotDirectorMapWorkspace.view.w);
await page.selectOption('[data-context-scene]',String(f.scenes[1]));await page.waitForFunction(()=>document.querySelector('[data-scene-position="0"]')?.title.includes('Spatial disposable current'));started=Date.now();await page.selectOption('[data-context-pane="0"] [data-context-tab]','floorplans');await page.locator('.spatial-room-badge').first().waitFor();metrics.milliseconds.floor_plan_initial=Date.now()-started;started=Date.now();await page.selectOption('[data-context-layout]','columns');await page.selectOption('[data-context-pane="1"] [data-context-tab]','maps');await page.locator('[data-context-pane="1"] iframe').waitFor();metrics.milliseconds.split_second_pane_mount=Date.now()-started;metrics.passed=true;fs.writeFileSync('/tmp/pd-spatial-evidence/development-performance.json',JSON.stringify(metrics,null,2));console.log('PASS authenticated spatial measurements, 100 paragraph moves/zero requests, same-location/building viewport retention, alternative-map resolution/reveal.');}catch(e){if(page)await page.screenshot({path:'/tmp/pd-spatial-evidence/development-performance-unverified.png'}).catch(()=>{});throw e;}finally{if(page&&token)for(const value of receipts.reverse())await page.request.post(base+'/SpatialContext/Undo',{headers:{RequestVerificationToken:token},data:{token:value}}).catch(()=>{});await browser.close();}})().catch(e=>{console.error(e);process.exitCode=1;});