From b523a86c194011813d3e83fc6da4cf92e4dd47d3 Mon Sep 17 00:00:00 2001 From: Nick Beckley Date: Tue, 3 Nov 2026 22:53:05 +0000 Subject: [PATCH] Extend Development restart gate to illustration and core import work --- .../2026-11-03-phase2-deployment-gate.sql | 21 +++++++++++++++++++ Docs/Sprints/2026-11-03-phase2.md | 4 ++++ 2 files changed, 25 insertions(+) create mode 100644 Docs/Sprints/2026-11-03-phase2-deployment-gate.sql diff --git a/Docs/Sprints/2026-11-03-phase2-deployment-gate.sql b/Docs/Sprints/2026-11-03-phase2-deployment-gate.sql new file mode 100644 index 00000000..e627b539 --- /dev/null +++ b/Docs/Sprints/2026-11-03-phase2-deployment-gate.sql @@ -0,0 +1,21 @@ +-- Read-only Development restart gate; not a schema migration. +IF DB_NAME() <> N'PlotDirector_Development' THROW 51000, 'Refusing restart inspection outside PlotDirector_Development.', 1; +DECLARE @Active int = +(SELECT COUNT(*) FROM dbo.StoryIntelligenceRuns WHERE Status IN ('Pending','Queued','Running','Processing')) + +(SELECT COUNT(*) FROM dbo.StoryIntelligenceJobs WHERE Status IN ('Pending','Queued','Running','Processing')) + +(SELECT COUNT(*) FROM dbo.WholeBookPlotSynthesisRuns WHERE Status IN ('Pending','Queued','Running','Processing')) + +(SELECT COUNT(*) FROM dbo.CharacterEnrichmentRuns WHERE Status IN ('Pending','Queued','Running','Processing')) + +(SELECT COUNT(*) FROM dbo.StoryIntelligenceImportCommits WHERE Status IN ('Pending','Queued','Running','Processing')) + +(SELECT COUNT(*) FROM dbo.StoryIntelligenceReviewCandidateGenerations WHERE Status IN ('Pending','Queued','Running','Processing','Preparing')) + +(SELECT COUNT(*) FROM dbo.StoryIntelligenceBookPipelines WHERE Status IN ('Pending','Queued','Running','Processing')); +IF @Active > 0 THROW 51000, 'Deployment deferred: background work is active.', 1; +IF EXISTS (SELECT 1 FROM sys.dm_exec_requests r CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t +WHERE r.database_id=DB_ID() AND r.session_id<>@@SPID AND (t.text LIKE '%Import%' OR t.text LIKE '%Synthesis%')) +THROW 51000, 'Deployment deferred: import or synthesis request is active.', 1; +IF EXISTS (SELECT 1 FROM dbo.IllustrationLibraryItems WHERE Status IN ('Queued','Generating') OR GenerationStatus IN ('Queued','Generating')) +THROW 51000, 'Deployment deferred: illustration generation is queued or active.', 1; +IF EXISTS (SELECT 1 FROM dbo.OnboardingManuscriptBuilds +WHERE Status NOT IN ('Built','Complete','Completed','Failed','Cancelled') + OR (Status = 'Built' AND COALESCE(MarkerStatus, '') NOT IN ('UserConfirmedSave','Completed','Complete'))) +THROW 51000, 'Deployment deferred: core import or marker completion is unfinished.', 1; +SELECT 'Development deployment gate: idle'; diff --git a/Docs/Sprints/2026-11-03-phase2.md b/Docs/Sprints/2026-11-03-phase2.md index a6daebdf..edb0b44b 100644 --- a/Docs/Sprints/2026-11-03-phase2.md +++ b/Docs/Sprints/2026-11-03-phase2.md @@ -91,3 +91,7 @@ The expanded real-Hub test reproduced two additional failures before repair: Verification: build passed (0 warnings/errors); full-layout Writer browser/PWA test passed with real heartbeat injection, second-book window creation, first-book preservation, restoration to the first scope, reconnect, identity/reload/focus tests and repeated navigation/header commands. Chapter-goal suite, including Help and concurrent edits, passed again. Fixture book data now honours the requested scope; no production routing or database schema changes. Urgent Writer release is still pending this final broader gate; an earlier publish was superseded before installation. Next: publish committed verified fixes, run the idle-work gate immediately before Development restart, smoke-check, then continue the rendered visual inventory. + +### Restart safety checkpoint and visual work + +Final Writer checkpoint: full harness passed again (405 checks, exit 0); both Writer browser/PWA suites passed. Phase 2 remains undeployed. Expanded read-only restart inspection found two illustration records marked Generating. The tracked restart gate now includes illustration and unfinished core-import work, verifies Development database identity, and refuses restart while these exist. Its controlled exit 2 was verified; no service restart or database mutation occurred. Live authenticated Writer acceptance remains deferred. Proceeding to Writer spacing and systematic rendered visual coverage independently.