-- Only executed after the specialist harness verifies its literal synthetic-only database. DECLARE @secondScene int, @otherLocation int, @otherAsset int, @state int, @metric int, @attribute int, @custody int, @floorPlan int, @floor int, @validation int, @scenario int, @scenarioValidation int; INSERT dbo.Scenes(ChapterID,SceneNumber,SceneTitle,Summary,SortOrder,RevisionStatusID,TimeModeID,TimeConfidenceID) VALUES(@chapter,2.5,N'Second empty scene',N'',2,@revision,@timeMode,@confidence); SET @secondScene=SCOPE_IDENTITY(); INSERT dbo.Locations(ProjectID,LocationName,ParentLocationID) VALUES(@project,N'Corridor 雪',@location); SET @otherLocation=SCOPE_IDENTITY(); INSERT dbo.StoryAssets(ProjectID,AssetName,AssetKindID) VALUES(@project,N'Envelope Ω',@kind); SET @otherAsset=SCOPE_IDENTITY(); INSERT dbo.AssetStates(ProjectID,AssetKindID,StateName,SortOrder,Description) VALUES(@project,@kind,N'Sealed Ω',1,N'Authored state café'); SET @state=SCOPE_IDENTITY(); UPDATE dbo.StoryAssets SET CurrentStateID=@state,CurrentLocationID=@location WHERE StoryAssetID=@asset; INSERT dbo.ScenePurposes(SceneID,ScenePurposeTypeID) SELECT @scene,MIN(ScenePurposeTypeID) FROM dbo.ScenePurposeTypes; INSERT dbo.SceneOutcomes(SceneID,OutcomeDescription) VALUES(@scene,N'An outcome — 雨'); INSERT dbo.SceneMetricTypes(ProjectID,MetricName,Description,MinValue,MaxValue,DefaultValue,SortOrder) VALUES(@project,N'Tension Ω',N'Custom metric 雪',0,20,7,1); SET @metric=SCOPE_IDENTITY(); INSERT dbo.SceneMetricValues(SceneID,MetricTypeID,Value,Notes) VALUES(@scene,@metric,8,N'Escalates café'); IF NOT EXISTS(SELECT 1 FROM dbo.ProjectTimelineSettings WHERE ProjectID=@project) INSERT dbo.ProjectTimelineSettings(ProjectID,ShowStoryAssets,ShowCharacterAppearances) VALUES(@project,1,1); UPDATE dbo.ProjectTimelineSettings SET ShowSceneCards=0,ShowStoryAssets=1 WHERE ProjectID=@project; INSERT dbo.ProjectTimelineMetricSettings(ProjectID,MetricTypeID,SortOrder) VALUES(@project,@metric,2); INSERT dbo.TimelineViewPresets(ProjectID,BookID,PresetName,FilterJson,VisibilityJson,FocusType,FocusID) VALUES(@project,@book,N'Authored view Ω',N'{"query":"café"}',N'{"warnings":true}',N'Character',@character); UPDATE dbo.TimelineViewPresets SET FilterJson=CONCAT(N'{"ProjectID":',@project,N',"BookID":',@book,N',"SelectedSceneID":',@scene,N',"ChapterFromID":',@chapter,N',"ChapterToID":',@chapter,N',"SceneFromID":',@scene,N',"SceneToID":',@secondScene,N',"PlotLineID":',@line,N',"PlotThreadID":',@thread,N',"StoryAssetID":',@asset,N',"CharacterID":',@character,N',"POVCharacterID":',@character,N',"LocationID":',@location,N',"FocusType":"character","FocusID":',@character,N',"ShowWarningsOnly":true,"extension":{"query":"café"}}') WHERE ProjectID=@project; INSERT dbo.AssetEvents(StoryAssetID,SceneID,AssetEventTypeID,ToStateID,EventTitle,EventDescription) SELECT @asset,@scene,MIN(AssetEventTypeID),@state,N'Sealed Ω',N'Unicode event 雨' FROM dbo.AssetEventTypes; INSERT dbo.AssetDependencies(SourceAssetID,TargetAssetID,AssetDependencyTypeID,SourceRequiredStateID,TargetBlockedStateID,Description) SELECT @asset,@otherAsset,MIN(AssetDependencyTypeID),@state,@state,N'Asset prerequisite 雪' FROM dbo.AssetDependencyTypes; INSERT dbo.AssetCustodyEvents(StoryAssetID,SceneID,AssetCustodyEventTypeID,Description) SELECT @asset,@scene,MIN(AssetCustodyEventTypeID),N'Custody café' FROM dbo.AssetCustodyEventTypes; SET @custody=SCOPE_IDENTITY(); INSERT dbo.AssetCustodyEventCharacters(AssetCustodyEventID,CharacterID,CustodyRoleID) SELECT @custody,@character,MIN(CustodyRoleID) FROM dbo.CustodyRoles; INSERT dbo.SceneCharacters(SceneID,CharacterID,RoleInSceneTypeID,PresenceTypeID,LocationID,EntryLocationID,ExitLocationID,AppearanceNotes,OutfitDescription,EmotionalState,MatchSource,MatchedText,OccurrenceCount,FirstOccurrenceIndex) SELECT @scene,@character,(SELECT MIN(CharacterRoleInSceneTypeID) FROM dbo.CharacterRoleInSceneTypes),MIN(PresenceTypeID),@location,@location,@otherLocation,N'Appears 雪',N'Coat Ω',N'Uneasy café',N'Manual',N'Narrator Ω',2,5 FROM dbo.PresenceTypes; INSERT dbo.CharacterAttributeTypes(ProjectID,AttributeName,DataType,SortOrder) VALUES(@project,N'Voice Ω',N'Text',1); SET @attribute=SCOPE_IDENTITY(); INSERT dbo.CharacterAttributeEvents(CharacterID,CharacterAttributeTypeID,SceneID,AttributeValue,Description) VALUES(@character,@attribute,@scene,N'Whispering 雨',N'Authored trait'); INSERT dbo.CharacterKnowledge(CharacterID,StoryAssetID,PlotThreadID,SceneID,KnowledgeStateID,SourceEventID,Description,SourceReviewKey) SELECT @character,@asset,@thread,@scene,MIN(KnowledgeStateID),@threadEvent,N'Knows the secret 雨',N'synthetic-knowledge-review' FROM dbo.KnowledgeStates; INSERT dbo.LocationRelationships(FromLocationID,ToLocationID,LocationRelationshipTypeID,IsBidirectional,CanTravelDirectly,Notes) SELECT @location,@otherLocation,MIN(LocationRelationshipTypeID),1,1,N'Connected rooms 雨' FROM dbo.LocationRelationshipTypes; INSERT dbo.FloorPlans(ProjectID,Name,Description,LocationID) VALUES(@project,N'Layout Ω',N'Floor plan café',@location); SET @floorPlan=SCOPE_IDENTITY(); INSERT dbo.FloorPlanFloors(FloorPlanID,Name,SortOrder,GridWidth,GridHeight,LocationID,BackgroundOpacity,BackgroundScale,BackgroundOffsetX,BackgroundOffsetY,Description) VALUES(@floorPlan,N'Ground 雪',1,30,20,@location,.6,1.5,3,4,N'Floor notes Ω'); SET @floor=SCOPE_IDENTITY(); INSERT dbo.FloorPlanBlocks(FloorPlanFloorID,LocationID,X,Y,WidthCells,HeightCells,BlockType,LabelOverride,Notes) VALUES(@floor,@location,2,3,6,4,N'Room',N'Room label 雪',N'Block notes café'); INSERT dbo.FloorPlanTransitions(FloorPlanFloorID,FromLocationID,ToLocationID,TransitionType,Notes,IsLocked,DisplayLabel) VALUES(@floor,@location,@otherLocation,N'Door',N'Transition Ω',1,N'Locked café'); UPDATE dbo.Scenes SET FloorPlanID=@floorPlan,InitialFloorPlanFloorID=@floor WHERE SceneID=@scene; INSERT dbo.SceneAssetLocations(SceneID,StoryAssetID,LocationID,Description) VALUES(@scene,@asset,@location,N'On desk 雨'); INSERT dbo.SceneFloorPlanOccupancy(SceneID,FloorPlanID,FloorPlanFloorID,CharacterID,LocationID) VALUES(@scene,@floorPlan,@floor,@character,@location); INSERT dbo.SceneDependencies(SourceSceneID,TargetSceneID,SceneDependencyTypeID,Description,ProjectID,IsHardDependency) SELECT @scene,@secondScene,MIN(SceneDependencyTypeID),N'Before the next scene 雨',@project,1 FROM dbo.SceneDependencyTypes; INSERT dbo.ValidationRuns(ProjectID,BookID,CompletedDate,TriggeredBy,ScopeDescription) VALUES(@project,@book,'2026-11-03',N'Synthetic fixture',N'Book Ω'); SET @validation=SCOPE_IDENTITY(); INSERT dbo.ContinuityWarnings(ValidationRunID,ProjectID,BookID,ChapterID,SceneID,EntityType,EntityID,WarningTypeID,WarningSeverityID,Message,Details,IsIntentional) SELECT @validation,@project,@book,@chapter,@scene,N'Character',@character,(SELECT MIN(WarningTypeID) FROM dbo.WarningTypes),MIN(WarningSeverityID),N'Warning café',N'Intentional 雨',1 FROM dbo.WarningSeverities; INSERT dbo.SceneNotes(SceneID,SceneNoteTypeID,NoteTitle,NoteText,SortOrder,IsPinned) SELECT @scene,MIN(SceneNoteTypeID),N'Note Ω',N'Long-form author note “雨”',1,1 FROM dbo.SceneNoteTypes; INSERT dbo.SceneWorkflow(SceneID,DraftStatus,EstimatedWordCount,ActualWordCount,ReadyForDraft,IsBlocked,BlockedReason,Priority) VALUES(@scene,N'Drafting',2500,1234,1,1,N'Needs research café',2); INSERT dbo.SceneChecklistItems(SceneID,ItemText,IsCompleted,SortOrder) VALUES(@scene,N'Check continuity 雨',1,3); INSERT dbo.SceneAttachments(SceneID,SceneAttachmentTypeID,Title,ExternalUrl,Notes) SELECT @scene,MIN(SceneAttachmentTypeID),N'Research Ω',N'https://example.invalid/synthetic',N'External link only; no file-byte claim' FROM dbo.SceneAttachmentTypes; INSERT dbo.ChapterGoals(ChapterID,GoalSummary,EmotionalGoal,ReaderTakeaway,MustInclude,RisksOrConcerns) VALUES(@chapter,N'Goal Ω',N'Unease 雨',N'Question café',N'A clue',N'Ambiguity'); SELECT @scenario=ScenarioID FROM dbo.Scenarios WHERE ProjectID=@project; INSERT dbo.ScenarioSceneOrder(ScenarioID,SceneID,ProposedChapterID,ProposedSortOrder,Notes) VALUES(@scenario,@scene,@chapter,2,N'Alternative sequence 雨'); INSERT dbo.ScenarioValidationRuns(ScenarioID,CompletedDate,WarningCount) VALUES(@scenario,'2026-11-03',1); SET @scenarioValidation=SCOPE_IDENTITY(); INSERT dbo.ScenarioWarnings(ScenarioValidationRunID,ScenarioID,SceneID,EntityType,EntityID,WarningTypeName,SeverityName,Message,Details) VALUES(@scenarioValidation,@scenario,@scene,N'Character',@character,N'SyntheticWarning',N'Warning',N'Scenario warning 雨',N'Alternative detail café'); INSERT dbo.MapJourneyNotes(MapID,CharacterID,FromSceneID,ToSceneID,TravelMethod,TypicalMinutes) VALUES(@map,@character,@scene,@secondScene,N'Walking café',18); UPDATE dbo.StoryMaps SET AppearanceJson=JSON_MODIFY(AppearanceJson,'$.extension',JSON_QUERY(N'{"texture":"雨"}')), ReferenceJson=JSON_MODIFY(ReferenceJson,'$.extension',JSON_QUERY(N'{"source":"café"}')) WHERE MapID=@map; UPDATE dbo.Locations SET DetectionPriority=7,ExcludeFromCompanionDetection=1 WHERE LocationID=@otherLocation; UPDATE dbo.ThreadEvents SET Source=N'Manual',SourceKey=CONCAT(N'synthetic-event-source-key-',@project),Confidence=.85 WHERE ThreadEventID=@threadEvent; INSERT dbo.WordCompanionSceneAssets(SceneID,StoryAssetID) VALUES(@scene,@asset); INSERT dbo.WordCompanionSceneLocations(SceneID,LocationID) VALUES(@scene,@otherLocation); DECLARE @completedBuild int; INSERT dbo.OnboardingManuscriptBuilds(PreviewID,UserID,ProjectID,BookID,ManuscriptDocumentID,Status,MarkerStatus,ChaptersCreated,ScenesCreated,CharactersCreated,MarkerSyncMessage,MarkerSyncCompletedUtc) SELECT NEWID(),@user,@project,@book,ManuscriptDocumentID,N'Built',N'UserConfirmedSave',1,2,1,N'Synthetic completed marker history',SYSUTCDATETIME() FROM dbo.Scenes WHERE SceneID=@scene; SET @completedBuild=SCOPE_IDENTITY(); INSERT dbo.OnboardingManuscriptBuildChapterMap(OnboardingManuscriptBuildID,TemporaryChapterKey,ChapterID) VALUES(@completedBuild,N'fixture-chapter-Ω',@chapter); INSERT dbo.OnboardingManuscriptBuildSceneMap(OnboardingManuscriptBuildID,TemporarySceneKey,SceneID) VALUES(@completedBuild,N'fixture-scene-雨',@scene),(@completedBuild,N'fixture-scene-雪',@secondScene); INSERT dbo.OnboardingManuscriptBuildCharacterMap(OnboardingManuscriptBuildID,TemporaryCharacterKey,CharacterID,Created) VALUES(@completedBuild,N'fixture-narrator-Ω',@character,1); INSERT dbo.SceneAssetSuggestions(SceneID,AssetID,Status,Confidence,Reason,CreatedByUserID,ReviewedByUserID,ReviewedUtc) VALUES(@scene,@asset,N'Accepted',N'Medium',N'Author accepted asset 雨',@user,@user,'2026-10-02'); INSERT dbo.SceneCharacterSuggestions(SceneID,CharacterID,Status,Confidence,Reason,CreatedByUserID,ReviewedByUserID,ReviewedUtc) VALUES(@scene,@character,N'Rejected',N'Low',N'Author rejected identity Ω',@user,@user,'2026-10-03'); INSERT dbo.SceneLocationSuggestions(SceneID,LocationID,Status,Confidence,Reason,CreatedByUserID) VALUES(@scene,@location,N'Pending',N'High',N'Awaiting author café',@user); INSERT dbo.SceneTextStatistics(SceneID,TotalWordCount,DialogueWordCount,ProseWordCount,TotalParagraphCount,DialogueParagraphCount,ProseParagraphCount) VALUES(@scene,1234,234,1000,8,2,6); INSERT dbo.SceneAssetSuggestions(SceneID,AssetID,Status,Confidence,Reason,CreatedByUserID,ReviewedByUserID,ReviewedUtc) SELECT @scene,@asset,v.Status,N'Medium',N'Synthetic complete status coverage 雨',@user,CASE WHEN v.Status=N'Pending' THEN NULL ELSE @user END,CASE WHEN v.Status=N'Pending' THEN NULL ELSE CONVERT(datetime2,'2026-10-04') END FROM (VALUES(N'Pending'),(N'Accepted'),(N'Rejected'),(N'Dismissed')) v(Status) WHERE NOT EXISTS(SELECT 1 FROM dbo.SceneAssetSuggestions x WHERE x.SceneID=@scene AND x.AssetID=@asset AND x.Status=v.Status); INSERT dbo.SceneCharacterSuggestions(SceneID,CharacterID,Status,Confidence,Reason,CreatedByUserID,ReviewedByUserID,ReviewedUtc) SELECT @scene,@character,v.Status,N'Medium',N'Synthetic complete status coverage 雨',@user,CASE WHEN v.Status=N'Pending' THEN NULL ELSE @user END,CASE WHEN v.Status=N'Pending' THEN NULL ELSE CONVERT(datetime2,'2026-10-04') END FROM (VALUES(N'Pending'),(N'Accepted'),(N'Rejected'),(N'Dismissed')) v(Status) WHERE NOT EXISTS(SELECT 1 FROM dbo.SceneCharacterSuggestions x WHERE x.SceneID=@scene AND x.CharacterID=@character AND x.Status=v.Status); INSERT dbo.SceneLocationSuggestions(SceneID,LocationID,Status,Confidence,Reason,CreatedByUserID,ReviewedByUserID,ReviewedUtc) SELECT @scene,@location,v.Status,N'Medium',N'Synthetic complete status coverage 雨',@user,CASE WHEN v.Status=N'Pending' THEN NULL ELSE @user END,CASE WHEN v.Status=N'Pending' THEN NULL ELSE CONVERT(datetime2,'2026-10-04') END FROM (VALUES(N'Pending'),(N'Accepted'),(N'Rejected'),(N'Dismissed')) v(Status) WHERE NOT EXISTS(SELECT 1 FROM dbo.SceneLocationSuggestions x WHERE x.SceneID=@scene AND x.LocationID=@location AND x.Status=v.Status); DECLARE @locationReview int,@locationCandidate int; INSERT dbo.CoreImportBasicLocationReviews(PreviewID,UserID,ProjectID,BookID,BuildID,Status,RawObservationCount,CandidateCount,CompletedUtc) SELECT PreviewID,@user,@project,@book,@completedBuild,N'Completed',1,1,'2026-11-03' FROM dbo.OnboardingManuscriptBuilds WHERE OnboardingManuscriptBuildID=@completedBuild; SET @locationReview=SCOPE_IDENTITY(); INSERT dbo.CoreImportBasicLocationCandidates(CoreImportBasicLocationReviewID,StableKey,ProposedName,PreferredName,KnownNamesJson,ParentLocationID,ExistingLocationID,Action,SameAsLocationID,ResultLocationID,FirstChapterNumber,FirstSceneNumber,FirstOccurrenceIndex,ObservationCount,SortOrder) VALUES(@locationReview,N'synthetic-location-Ω',N'Room detected 雨',N'Room approved Ω',N'["Room Ω","Chamber café"]',@otherLocation,@location,N'SameLocation',@location,@location,1,1,3,1,1); SET @locationCandidate=SCOPE_IDENTITY(); INSERT dbo.CoreImportBasicLocationEvidence(CoreImportBasicLocationCandidateID,SceneID,ChapterID,ChapterNumber,SceneNumber,OccurrenceIndex,EvidenceText,SortOrder) VALUES(@locationCandidate,@scene,@chapter,1,1,3,N'“Entered the room”—exact evidence 雨',1); DECLARE @siRun int,@siChapter int,@siRaw nvarchar(max); SET @siRaw=N'{"source":"retained audit 雨","originalSceneID":'+CONVERT(nvarchar(20),@scene)+N',"text":"'+REPLICATE(CONVERT(nvarchar(max),N'Quoted Ω café—雪. '),10000)+N'"}'; INSERT dbo.StoryIntelligenceRuns(UserID,ProjectID,BookID,ChapterID,ChapterNumber,Status,SourceType,PromptVersion,Model,StartedUtc,CompletedUtc,SourceFileName,SourceFileSizeBytes,SourceWordCount,SourceCharacterCount,SourceChapterCount,SourceParagraphCount,SourceLabel,SourceText,KnownCharactersJson,TotalInputTokens,TotalOutputTokens,TotalTokens,TotalDurationMs,EstimatedCostGBP,EstimatedCostUSD,CurrentStage,CurrentMessage,TotalDetectedScenes,CompletedScenes,FailedScenes) VALUES(@user,@project,@book,@chapter,1,N'Completed',N'Manuscript',N'synthetic-v1',N'synthetic-no-provider','2026-11-01','2026-11-02',N'Synthetic café.docx',4096,1234,9000,1,8,N'Original source Ω',N'“Source text”—雪'+CHAR(13)+CHAR(10)+N'Another paragraph',N'[{"name":"Narrator Ω"}]',150,60,210,4250,.005,.007,N'Completed',N'Retained synthetic audit',2,2,0); SET @siRun=SCOPE_IDENTITY(); INSERT dbo.StoryIntelligenceChapterResults(StoryIntelligenceRunID,ProjectID,BookID,ChapterID,ChapterNumber,SourceLabel,PromptVersion,Model,RawResponseJson,OutputTextJson,ParsedJson,ValidationErrorsCount,ValidationWarningsCount,InputTokens,OutputTokens,TotalTokens,DurationMs) VALUES(@siRun,@project,@book,@chapter,1,N'Chapter audit Ω',N'synthetic-v1',N'synthetic-no-provider',@siRaw,N'{"chapter":"雨"}',N'{"scenes":[]}',0,1,100,40,140,3000); SET @siChapter=SCOPE_IDENTITY(); INSERT dbo.StoryIntelligenceSceneResults(StoryIntelligenceRunID,ChapterResultID,ProjectID,BookID,ChapterID,SceneID,TemporarySceneNumber,StartParagraph,EndParagraph,SourceLabel,PromptVersion,Model,RawResponseJson,OutputTextJson,ParsedJson,ValidationErrorsCount,ValidationWarningsCount,InputTokens,OutputTokens,TotalTokens,DurationMs) VALUES(@siRun,@siChapter,@project,@book,@chapter,@scene,1,1,8,N'Scene audit 雨',N'synthetic-v1',N'synthetic-no-provider',@siRaw,N'{"scene":"Ω"}',N'{"observations":[]}',0,1,50,20,70,1250); INSERT dbo.StoryIntelligenceImportCommits(StoryIntelligenceRunID,ProjectID,BookID,ChapterID,CommittedByUserID,ScenesCreated,MetricsCreated,Status,Notes) VALUES(@siRun,@project,@book,@chapter,@user,2,1,N'Completed',N'Synthetic canonical materialization audit Ω'); UPDATE dbo.Scenes SET ImportRunID=@siRun WHERE SceneID=@scene;