@gridlock/orchestrator 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/LICENSE +21 -0
  2. package/dist/AgentRoute.d.ts +44 -0
  3. package/dist/AgentRoute.d.ts.map +1 -0
  4. package/dist/AgentRoute.js +54 -0
  5. package/dist/AgentRoute.js.map +1 -0
  6. package/dist/CommandRegistry.d.ts +68 -0
  7. package/dist/CommandRegistry.d.ts.map +1 -0
  8. package/dist/CommandRegistry.js +87 -0
  9. package/dist/CommandRegistry.js.map +1 -0
  10. package/dist/ContextFactory.d.ts +62 -0
  11. package/dist/ContextFactory.d.ts.map +1 -0
  12. package/dist/ContextFactory.js +59 -0
  13. package/dist/ContextFactory.js.map +1 -0
  14. package/dist/DialogueGate.d.ts +117 -0
  15. package/dist/DialogueGate.d.ts.map +1 -0
  16. package/dist/DialogueGate.js +101 -0
  17. package/dist/DialogueGate.js.map +1 -0
  18. package/dist/DisclosureEngine.d.ts +160 -0
  19. package/dist/DisclosureEngine.d.ts.map +1 -0
  20. package/dist/DisclosureEngine.js +241 -0
  21. package/dist/DisclosureEngine.js.map +1 -0
  22. package/dist/EvidenceGraph.d.ts +71 -0
  23. package/dist/EvidenceGraph.d.ts.map +1 -0
  24. package/dist/EvidenceGraph.js +177 -0
  25. package/dist/EvidenceGraph.js.map +1 -0
  26. package/dist/InteractionEvaluator.d.ts +50 -0
  27. package/dist/InteractionEvaluator.d.ts.map +1 -0
  28. package/dist/InteractionEvaluator.js +205 -0
  29. package/dist/InteractionEvaluator.js.map +1 -0
  30. package/dist/KnowledgeBoundary.d.ts +74 -0
  31. package/dist/KnowledgeBoundary.d.ts.map +1 -0
  32. package/dist/KnowledgeBoundary.js +76 -0
  33. package/dist/KnowledgeBoundary.js.map +1 -0
  34. package/dist/evaluation/EscalationClock.d.ts +65 -0
  35. package/dist/evaluation/EscalationClock.d.ts.map +1 -0
  36. package/dist/evaluation/EscalationClock.js +106 -0
  37. package/dist/evaluation/EscalationClock.js.map +1 -0
  38. package/dist/evaluation/PerformanceEvaluator.d.ts +54 -0
  39. package/dist/evaluation/PerformanceEvaluator.d.ts.map +1 -0
  40. package/dist/evaluation/PerformanceEvaluator.js +161 -0
  41. package/dist/evaluation/PerformanceEvaluator.js.map +1 -0
  42. package/dist/evaluation/WorldState.d.ts +30 -0
  43. package/dist/evaluation/WorldState.d.ts.map +1 -0
  44. package/dist/evaluation/WorldState.js +43 -0
  45. package/dist/evaluation/WorldState.js.map +1 -0
  46. package/dist/evaluation/index.d.ts +8 -0
  47. package/dist/evaluation/index.d.ts.map +1 -0
  48. package/dist/evaluation/index.js +4 -0
  49. package/dist/evaluation/index.js.map +1 -0
  50. package/dist/evaluation/types.d.ts +26 -0
  51. package/dist/evaluation/types.d.ts.map +1 -0
  52. package/dist/evaluation/types.js +9 -0
  53. package/dist/evaluation/types.js.map +1 -0
  54. package/dist/handlers/AssistantCommandRegistry.d.ts +55 -0
  55. package/dist/handlers/AssistantCommandRegistry.d.ts.map +1 -0
  56. package/dist/handlers/AssistantCommandRegistry.js +59 -0
  57. package/dist/handlers/AssistantCommandRegistry.js.map +1 -0
  58. package/dist/handlers/EvidenceIngestion.d.ts +64 -0
  59. package/dist/handlers/EvidenceIngestion.d.ts.map +1 -0
  60. package/dist/handlers/EvidenceIngestion.js +114 -0
  61. package/dist/handlers/EvidenceIngestion.js.map +1 -0
  62. package/dist/handlers/GameLifecycle.d.ts +71 -0
  63. package/dist/handlers/GameLifecycle.d.ts.map +1 -0
  64. package/dist/handlers/GameLifecycle.js +100 -0
  65. package/dist/handlers/GameLifecycle.js.map +1 -0
  66. package/dist/handlers/GraphPopulation.d.ts +24 -0
  67. package/dist/handlers/GraphPopulation.d.ts.map +1 -0
  68. package/dist/handlers/GraphPopulation.js +21 -0
  69. package/dist/handlers/GraphPopulation.js.map +1 -0
  70. package/dist/handlers/ResolutionGate.d.ts +60 -0
  71. package/dist/handlers/ResolutionGate.d.ts.map +1 -0
  72. package/dist/handlers/ResolutionGate.js +49 -0
  73. package/dist/handlers/ResolutionGate.js.map +1 -0
  74. package/dist/index.d.ts +53 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +54 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/investigation/Analyst.d.ts +80 -0
  79. package/dist/investigation/Analyst.d.ts.map +1 -0
  80. package/dist/investigation/Analyst.js +514 -0
  81. package/dist/investigation/Analyst.js.map +1 -0
  82. package/dist/investigation/AnalystWorkspace.d.ts +182 -0
  83. package/dist/investigation/AnalystWorkspace.d.ts.map +1 -0
  84. package/dist/investigation/AnalystWorkspace.js +405 -0
  85. package/dist/investigation/AnalystWorkspace.js.map +1 -0
  86. package/dist/investigation/CaseFile.d.ts +92 -0
  87. package/dist/investigation/CaseFile.d.ts.map +1 -0
  88. package/dist/investigation/CaseFile.js +117 -0
  89. package/dist/investigation/CaseFile.js.map +1 -0
  90. package/dist/investigation/DiscoveryLayer.d.ts +133 -0
  91. package/dist/investigation/DiscoveryLayer.d.ts.map +1 -0
  92. package/dist/investigation/DiscoveryLayer.js +176 -0
  93. package/dist/investigation/DiscoveryLayer.js.map +1 -0
  94. package/dist/investigation/FactLedger.d.ts +91 -0
  95. package/dist/investigation/FactLedger.d.ts.map +1 -0
  96. package/dist/investigation/FactLedger.js +185 -0
  97. package/dist/investigation/FactLedger.js.map +1 -0
  98. package/dist/investigation/InvestigationTimeline.d.ts +98 -0
  99. package/dist/investigation/InvestigationTimeline.d.ts.map +1 -0
  100. package/dist/investigation/InvestigationTimeline.js +178 -0
  101. package/dist/investigation/InvestigationTimeline.js.map +1 -0
  102. package/dist/investigation/ProfileEngine.d.ts +84 -0
  103. package/dist/investigation/ProfileEngine.d.ts.map +1 -0
  104. package/dist/investigation/ProfileEngine.js +170 -0
  105. package/dist/investigation/ProfileEngine.js.map +1 -0
  106. package/dist/investigation/WorkspaceProjections.d.ts +94 -0
  107. package/dist/investigation/WorkspaceProjections.d.ts.map +1 -0
  108. package/dist/investigation/WorkspaceProjections.js +92 -0
  109. package/dist/investigation/WorkspaceProjections.js.map +1 -0
  110. package/dist/investigation/index.d.ts +18 -0
  111. package/dist/investigation/index.d.ts.map +1 -0
  112. package/dist/investigation/index.js +10 -0
  113. package/dist/investigation/index.js.map +1 -0
  114. package/dist/investigation/types.d.ts +206 -0
  115. package/dist/investigation/types.d.ts.map +1 -0
  116. package/dist/investigation/types.js +20 -0
  117. package/dist/investigation/types.js.map +1 -0
  118. package/dist/types.d.ts +283 -0
  119. package/dist/types.d.ts.map +1 -0
  120. package/dist/types.js +70 -0
  121. package/dist/types.js.map +1 -0
  122. package/package.json +48 -0
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Scenario File (#238, #240, #241)
3
+ *
4
+ * The player's structured record of their progress through a scenario.
5
+ * Combines evidence, profiles, timeline, and findings into a coherent
6
+ * view. Computed from DiscoveryLayer — never stores state independently.
7
+ *
8
+ * Engine-generic: operates on DiscoveryLayer, FactRecords, and Findings.
9
+ * No product vocabulary.
10
+ *
11
+ * MS-28 #887 — Phase 1.2 — Orchestrator migration step 5.5b / 5.9.
12
+ */
13
+ import type { FactSourceType } from './types.js';
14
+ import type { DiscoveryLayer, DiscoveryProgress } from './DiscoveryLayer.js';
15
+ import type { Finding } from '@gridlock/validators';
16
+ /**
17
+ * A snapshot of the scenario file at a point in time.
18
+ */
19
+ export interface CaseFileSnapshot {
20
+ evidence: CaseFileEvidence[];
21
+ entities: CaseFileEntity[];
22
+ findings: CaseFileFinding[];
23
+ summary: CaseFileSummary;
24
+ }
25
+ export interface CaseFileEvidence {
26
+ id: string;
27
+ statement: string;
28
+ sourceType: FactSourceType;
29
+ sourceId: string;
30
+ reliability: string;
31
+ discoveredAt: string;
32
+ }
33
+ export interface CaseFileEntity {
34
+ id: string;
35
+ name: string;
36
+ type: string;
37
+ }
38
+ export interface CaseFileFinding {
39
+ id: string;
40
+ text: string;
41
+ kind: string;
42
+ relatedEntityIds: string[];
43
+ }
44
+ export interface CaseFileSummary {
45
+ totalEvidence: number;
46
+ totalEntities: number;
47
+ totalFindings: number;
48
+ progress: DiscoveryProgress;
49
+ }
50
+ export declare class CaseFile {
51
+ private discoveryLayer;
52
+ private findings;
53
+ constructor(discoveryLayer: DiscoveryLayer, findings: Finding[]);
54
+ /**
55
+ * Build a complete snapshot of the scenario file.
56
+ */
57
+ build(): CaseFileSnapshot;
58
+ /**
59
+ * Get all discovered evidence as file entries.
60
+ */
61
+ getEvidence(): CaseFileEvidence[];
62
+ /**
63
+ * Get all discovered entities.
64
+ */
65
+ getEntities(): CaseFileEntity[];
66
+ /**
67
+ * Get all findings.
68
+ */
69
+ getFindings(): CaseFileFinding[];
70
+ /**
71
+ * Get file summary with completeness metrics (#241).
72
+ */
73
+ getSummary(): CaseFileSummary;
74
+ /**
75
+ * Get evidence related to a specific entity.
76
+ */
77
+ getEvidenceByEntity(entityId: string): CaseFileEvidence[];
78
+ /**
79
+ * Get evidence grouped by source type.
80
+ */
81
+ getEvidenceBySource(sourceType: FactSourceType): CaseFileEvidence[];
82
+ /**
83
+ * Get evidence in chronological discovery order.
84
+ */
85
+ getEvidenceTimeline(): CaseFileEvidence[];
86
+ /**
87
+ * Get evidence grouped by reliability level.
88
+ */
89
+ getEvidenceByReliability(): Record<string, CaseFileEvidence[]>;
90
+ private _toEvidence;
91
+ }
92
+ //# sourceMappingURL=CaseFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CaseFile.d.ts","sourceRoot":"","sources":["../../src/investigation/CaseFile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAkB,MAAM,qBAAqB,CAAC;AAC7F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B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UAAU,EAAE,cAAc,GAAG,gBAAgB,EAAE;IAMnE;;OAEG;IACH,mBAAmB,IAAI,gBAAgB,EAAE;IAMzC;;OAEG;IACH,wBAAwB,IAAI,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAU9D,OAAO,CAAC,WAAW;CAUpB"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Scenario File (#238, #240, #241)
3
+ *
4
+ * The player's structured record of their progress through a scenario.
5
+ * Combines evidence, profiles, timeline, and findings into a coherent
6
+ * view. Computed from DiscoveryLayer — never stores state independently.
7
+ *
8
+ * Engine-generic: operates on DiscoveryLayer, FactRecords, and Findings.
9
+ * No product vocabulary.
10
+ *
11
+ * MS-28 #887 — Phase 1.2 — Orchestrator migration step 5.5b / 5.9.
12
+ */
13
+ export class CaseFile {
14
+ discoveryLayer;
15
+ findings;
16
+ constructor(discoveryLayer, findings) {
17
+ this.discoveryLayer = discoveryLayer;
18
+ this.findings = findings;
19
+ }
20
+ /**
21
+ * Build a complete snapshot of the scenario file.
22
+ */
23
+ build() {
24
+ return {
25
+ evidence: this.getEvidence(),
26
+ entities: this.getEntities(),
27
+ findings: this.getFindings(),
28
+ summary: this.getSummary(),
29
+ };
30
+ }
31
+ /**
32
+ * Get all discovered evidence as file entries.
33
+ */
34
+ getEvidence() {
35
+ return this.discoveryLayer.getDiscoveredFacts().map(r => this._toEvidence(r));
36
+ }
37
+ /**
38
+ * Get all discovered entities.
39
+ */
40
+ getEntities() {
41
+ return this.discoveryLayer.getDiscoveredEntities();
42
+ }
43
+ /**
44
+ * Get all findings.
45
+ */
46
+ getFindings() {
47
+ return this.findings.map(f => ({
48
+ id: f.id,
49
+ text: f.text,
50
+ kind: f.kind,
51
+ relatedEntityIds: f.relatedEntities.map(e => e.id),
52
+ }));
53
+ }
54
+ /**
55
+ * Get file summary with completeness metrics (#241).
56
+ */
57
+ getSummary() {
58
+ return {
59
+ totalEvidence: this.discoveryLayer.getDiscoveredFacts().length,
60
+ totalEntities: this.discoveryLayer.getDiscoveredEntities().length,
61
+ totalFindings: this.findings.length,
62
+ progress: this.discoveryLayer.getDiscoveryProgress(),
63
+ };
64
+ }
65
+ // --- Evidence grouping methods (#240) ---
66
+ /**
67
+ * Get evidence related to a specific entity.
68
+ */
69
+ getEvidenceByEntity(entityId) {
70
+ return this.discoveryLayer.getDiscoveredFacts()
71
+ .filter(r => r.subject === entityId
72
+ || r.relatedCharacterIds.includes(entityId)
73
+ || r.relatedArtifactIds.includes(entityId)
74
+ || r.relatedEntities?.some(e => e.id === entityId))
75
+ .map(r => this._toEvidence(r));
76
+ }
77
+ /**
78
+ * Get evidence grouped by source type.
79
+ */
80
+ getEvidenceBySource(sourceType) {
81
+ return this.discoveryLayer.getDiscoveredFacts()
82
+ .filter(r => r.sourceType === sourceType)
83
+ .map(r => this._toEvidence(r));
84
+ }
85
+ /**
86
+ * Get evidence in chronological discovery order.
87
+ */
88
+ getEvidenceTimeline() {
89
+ return this.discoveryLayer.getDiscoveredFacts()
90
+ .sort((a, b) => a.discoveredAt.localeCompare(b.discoveredAt))
91
+ .map(r => this._toEvidence(r));
92
+ }
93
+ /**
94
+ * Get evidence grouped by reliability level.
95
+ */
96
+ getEvidenceByReliability() {
97
+ const grouped = { low: [], medium: [], high: [] };
98
+ for (const r of this.discoveryLayer.getDiscoveredFacts()) {
99
+ const level = r.reliability ?? r.confidence;
100
+ if (!grouped[level])
101
+ grouped[level] = [];
102
+ grouped[level].push(this._toEvidence(r));
103
+ }
104
+ return grouped;
105
+ }
106
+ _toEvidence(r) {
107
+ return {
108
+ id: r.id,
109
+ statement: r.statement,
110
+ sourceType: r.sourceType,
111
+ sourceId: r.sourceId,
112
+ reliability: r.reliability ?? r.confidence,
113
+ discoveredAt: r.discoveredAt,
114
+ };
115
+ }
116
+ }
117
+ //# sourceMappingURL=CaseFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CaseFile.js","sourceRoot":"","sources":["../../src/investigation/CaseFile.ts"],"names":[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GAAuC,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACtF,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,EAAE,CAAC;YACzD,MAAM,KAAK,GAAG,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,UAAU,CAAC;YAC5C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YACzC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,WAAW,CAAC,CAAa;QAC/B,OAAO;YACL,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,UAAU;YAC1C,YAAY,EAAE,CAAC,CAAC,YAAY;SAC7B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Discovery Layer — engine-generic (#233, #236, #887 step 5.6/5.9)
3
+ *
4
+ * A filtered projection of the scenario representing only what the
5
+ * player has discovered. This is the formal boundary between world
6
+ * truth and player knowledge.
7
+ *
8
+ * Rules:
9
+ * - Analytical subsystems read ONLY from DiscoveryLayer
10
+ * - Profiles are built ONLY from DiscoveryLayer data
11
+ * - Engine may access full scenario for validation
12
+ *
13
+ * Engine-generic: parameterised with ScenarioEntityProvider so the
14
+ * engine never navigates product-specific scenario shapes directly.
15
+ * Products inject a provider that maps their scenario type into
16
+ * the entity/fact lists the DiscoveryLayer needs.
17
+ *
18
+ * No product vocabulary: no suspect, crime, case, accusation,
19
+ * investigation, contradiction.
20
+ */
21
+ import type { FactRecord } from './types.js';
22
+ import type { FactLedger } from './FactLedger.js';
23
+ import type { EvidenceGraph } from '../EvidenceGraph.js';
24
+ /**
25
+ * Structured discovery event (#236).
26
+ * Emitted when a new entity, fact, or relationship is discovered.
27
+ */
28
+ export interface DiscoveryEvent {
29
+ type: 'entity' | 'fact' | 'relationship';
30
+ id: string;
31
+ timestamp: string;
32
+ trigger: string;
33
+ }
34
+ /**
35
+ * Discovery progress — how much of the discoverable content has been found.
36
+ */
37
+ export interface DiscoveryProgress {
38
+ discoveredEntities: number;
39
+ totalEntities: number;
40
+ discoveredFacts: number;
41
+ totalFacts: number;
42
+ discoveredArtifacts: number;
43
+ totalArtifacts: number;
44
+ /**
45
+ * Entities the player has discovered (seen they exist) but cannot yet
46
+ * interact with because they are still gated behind unlock thresholds.
47
+ * Lets the progress percentage be read in context.
48
+ */
49
+ blockedArtifacts: number;
50
+ percentage: number;
51
+ }
52
+ /**
53
+ * An entity descriptor returned by the ScenarioEntityProvider.
54
+ * Minimal shape — just enough for the DiscoveryLayer to work with.
55
+ */
56
+ export interface ScenarioEntity {
57
+ id: string;
58
+ name: string;
59
+ type: string;
60
+ }
61
+ /**
62
+ * ScenarioEntityProvider — product-layer bridge that supplies
63
+ * scenario-specific entity and fact data to the DiscoveryLayer.
64
+ *
65
+ * The engine never navigates the product's scenario shape directly.
66
+ * Instead, the product injects a provider that returns the entity
67
+ * lists and counts the DiscoveryLayer needs. This keeps the
68
+ * DiscoveryLayer engine-generic.
69
+ */
70
+ export interface ScenarioEntityProvider {
71
+ /** All entities in the scenario that can be discovered. */
72
+ getAllEntities(): ScenarioEntity[];
73
+ /** Total count of discoverable facts across all sources. */
74
+ getTotalFactCount(): number;
75
+ /** Total count of discoverable artifacts/evidence items. */
76
+ getTotalArtifactCount(): number;
77
+ }
78
+ export declare class DiscoveryLayer {
79
+ private entityProvider;
80
+ private factLedger;
81
+ private discoveredGraph;
82
+ private discoveredEntityIds;
83
+ private examinedEntityIds;
84
+ private unlockedEntityIds;
85
+ private events;
86
+ /** Cached set of entity IDs referenced by discovered facts. */
87
+ private _factRefCache;
88
+ private _factRefCacheSize;
89
+ constructor(entityProvider: ScenarioEntityProvider, factLedger: FactLedger, discoveredGraph: EvidenceGraph, discoveredEntityIds: Set<string>, examinedEntityIds: Set<string>, unlockedEntityIds: Set<string>);
90
+ /**
91
+ * Get all entities the player has discovered.
92
+ */
93
+ getDiscoveredEntities(): ScenarioEntity[];
94
+ /**
95
+ * Get only facts from examined/talked sources.
96
+ */
97
+ getDiscoveredFacts(): FactRecord[];
98
+ /**
99
+ * Get only relationships where both endpoints are discovered.
100
+ */
101
+ getDiscoveredRelationships(): Array<{
102
+ sourceId: string;
103
+ targetId: string;
104
+ relationship: string;
105
+ }>;
106
+ /**
107
+ * Check if the player knows about an entity.
108
+ * Uses explicit tracking sets first, then falls back to fact references.
109
+ */
110
+ isDiscovered(entityId: string): boolean;
111
+ /**
112
+ * Build/return cached set of entity IDs referenced by discovered facts.
113
+ * Invalidated when ledger size changes.
114
+ */
115
+ private _getFactReferencedEntityIds;
116
+ /**
117
+ * Get discovery progress — % of discoverable content found.
118
+ */
119
+ getDiscoveryProgress(): DiscoveryProgress;
120
+ /**
121
+ * Record a discovery event (#236).
122
+ */
123
+ recordDiscovery(type: DiscoveryEvent['type'], id: string, trigger: string): void;
124
+ /**
125
+ * Get all discovery events in chronological order (#236).
126
+ */
127
+ getDiscoveryEvents(): DiscoveryEvent[];
128
+ /**
129
+ * Get the set of all discovered node IDs.
130
+ */
131
+ private _getDiscoveredNodeIds;
132
+ }
133
+ //# sourceMappingURL=DiscoveryLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiscoveryLayer.d.ts","sourceRoot":"","sources":["../../src/investigation/DiscoveryLayer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CA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BAGrB,cAAc,EAAE,sBAAsB,EACtC,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,aAAa,EAC9B,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,EAChC,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC9B,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC;IAGxC;;OAEG;IACH,qBAAqB,IAAI,cAAc,EAAE;IAIzC;;OAEG;IACH,kBAAkB,IAAI,UAAU,EAAE;IAIlC;;OAEG;IACH,0BAA0B,IAAI,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IAUjG;;;OAGG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAUvC;;;OAGG;IACH,OAAO,CAAC,2BAA2B;IAenC;;OAEG;IACH,oBAAoB,IAAI,iBAAiB;IAuCzC;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAShF;;OAEG;IACH,kBAAkB,IAAI,cAAc,EAAE;IAItC;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAwB9B"}
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Discovery Layer — engine-generic (#233, #236, #887 step 5.6/5.9)
3
+ *
4
+ * A filtered projection of the scenario representing only what the
5
+ * player has discovered. This is the formal boundary between world
6
+ * truth and player knowledge.
7
+ *
8
+ * Rules:
9
+ * - Analytical subsystems read ONLY from DiscoveryLayer
10
+ * - Profiles are built ONLY from DiscoveryLayer data
11
+ * - Engine may access full scenario for validation
12
+ *
13
+ * Engine-generic: parameterised with ScenarioEntityProvider so the
14
+ * engine never navigates product-specific scenario shapes directly.
15
+ * Products inject a provider that maps their scenario type into
16
+ * the entity/fact lists the DiscoveryLayer needs.
17
+ *
18
+ * No product vocabulary: no suspect, crime, case, accusation,
19
+ * investigation, contradiction.
20
+ */
21
+ // ---------------------------------------------------------------------------
22
+ // DiscoveryLayer
23
+ // ---------------------------------------------------------------------------
24
+ export class DiscoveryLayer {
25
+ entityProvider;
26
+ factLedger;
27
+ discoveredGraph;
28
+ discoveredEntityIds;
29
+ examinedEntityIds;
30
+ unlockedEntityIds;
31
+ events = [];
32
+ /** Cached set of entity IDs referenced by discovered facts. */
33
+ _factRefCache = null;
34
+ _factRefCacheSize = -1;
35
+ constructor(entityProvider, factLedger, discoveredGraph, discoveredEntityIds, examinedEntityIds, unlockedEntityIds) {
36
+ this.entityProvider = entityProvider;
37
+ this.factLedger = factLedger;
38
+ this.discoveredGraph = discoveredGraph;
39
+ this.discoveredEntityIds = discoveredEntityIds;
40
+ this.examinedEntityIds = examinedEntityIds;
41
+ this.unlockedEntityIds = unlockedEntityIds;
42
+ }
43
+ /**
44
+ * Get all entities the player has discovered.
45
+ */
46
+ getDiscoveredEntities() {
47
+ return this.entityProvider.getAllEntities().filter(e => this.isDiscovered(e.id));
48
+ }
49
+ /**
50
+ * Get only facts from examined/talked sources.
51
+ */
52
+ getDiscoveredFacts() {
53
+ return this.factLedger.getAll();
54
+ }
55
+ /**
56
+ * Get only relationships where both endpoints are discovered.
57
+ */
58
+ getDiscoveredRelationships() {
59
+ const discoveredIds = this._getDiscoveredNodeIds();
60
+ const subgraph = this.discoveredGraph.getDiscoveredSubgraph(discoveredIds);
61
+ return subgraph.getAllEdges().map(e => ({
62
+ sourceId: e.sourceId,
63
+ targetId: e.targetId,
64
+ relationship: e.relationship,
65
+ }));
66
+ }
67
+ /**
68
+ * Check if the player knows about an entity.
69
+ * Uses explicit tracking sets first, then falls back to fact references.
70
+ */
71
+ isDiscovered(entityId) {
72
+ if (this.discoveredEntityIds.has(entityId)
73
+ || this.unlockedEntityIds.has(entityId)
74
+ || this.examinedEntityIds.has(entityId)) {
75
+ return true;
76
+ }
77
+ return this._getFactReferencedEntityIds().has(entityId);
78
+ }
79
+ /**
80
+ * Build/return cached set of entity IDs referenced by discovered facts.
81
+ * Invalidated when ledger size changes.
82
+ */
83
+ _getFactReferencedEntityIds() {
84
+ if (this._factRefCache && this._factRefCacheSize === this.factLedger.size) {
85
+ return this._factRefCache;
86
+ }
87
+ const ids = new Set();
88
+ for (const fact of this.factLedger.getAll()) {
89
+ for (const ref of fact.relatedEntities ?? []) {
90
+ ids.add(ref.id);
91
+ }
92
+ }
93
+ this._factRefCache = ids;
94
+ this._factRefCacheSize = this.factLedger.size;
95
+ return ids;
96
+ }
97
+ /**
98
+ * Get discovery progress — % of discoverable content found.
99
+ */
100
+ getDiscoveryProgress() {
101
+ const allEntities = this.entityProvider.getAllEntities();
102
+ const discoveredEntities = allEntities.filter(e => this.isDiscovered(e.id)).length;
103
+ const totalEntities = allEntities.length;
104
+ const totalFacts = this.entityProvider.getTotalFactCount();
105
+ const discoveredFacts = this.factLedger.size;
106
+ const totalArtifacts = this.entityProvider.getTotalArtifactCount();
107
+ const discoveredArtifacts = this.examinedEntityIds.size;
108
+ // Blocked count: entities discovered but not yet examinable.
109
+ // Product layers can refine this with RICE threshold checks.
110
+ let blockedArtifacts = 0;
111
+ for (const id of this.discoveredEntityIds) {
112
+ if (this.examinedEntityIds.has(id))
113
+ continue;
114
+ if (!this.unlockedEntityIds.has(id)) {
115
+ blockedArtifacts++;
116
+ }
117
+ }
118
+ const totalDiscoverable = totalEntities + totalFacts + totalArtifacts;
119
+ const totalDiscovered = discoveredEntities + discoveredFacts + discoveredArtifacts;
120
+ const percentage = totalDiscoverable > 0
121
+ ? Math.round((totalDiscovered / totalDiscoverable) * 100)
122
+ : 0;
123
+ return {
124
+ discoveredEntities,
125
+ totalEntities,
126
+ discoveredFacts,
127
+ totalFacts,
128
+ discoveredArtifacts,
129
+ totalArtifacts,
130
+ blockedArtifacts,
131
+ percentage,
132
+ };
133
+ }
134
+ /**
135
+ * Record a discovery event (#236).
136
+ */
137
+ recordDiscovery(type, id, trigger) {
138
+ this.events.push({
139
+ type,
140
+ id,
141
+ timestamp: new Date().toISOString(),
142
+ trigger,
143
+ });
144
+ }
145
+ /**
146
+ * Get all discovery events in chronological order (#236).
147
+ */
148
+ getDiscoveryEvents() {
149
+ return [...this.events];
150
+ }
151
+ /**
152
+ * Get the set of all discovered node IDs.
153
+ */
154
+ _getDiscoveredNodeIds() {
155
+ const ids = new Set();
156
+ for (const e of this.entityProvider.getAllEntities()) {
157
+ if (this.isDiscovered(e.id)) {
158
+ ids.add(e.id);
159
+ }
160
+ }
161
+ // Add all fact IDs from the ledger
162
+ for (const record of this.factLedger.getAll()) {
163
+ if (record.originFactId)
164
+ ids.add(record.originFactId);
165
+ }
166
+ // Add finding IDs
167
+ for (const node of this.discoveredGraph.getNodesByType('finding')) {
168
+ ids.add(node.id);
169
+ }
170
+ for (const node of this.discoveredGraph.getNodesByType('validator')) {
171
+ ids.add(node.id);
172
+ }
173
+ return ids;
174
+ }
175
+ }
176
+ //# sourceMappingURL=DiscoveryLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiscoveryLayer.js","sourceRoot":"","sources":["../../src/investigation/DiscoveryLayer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAoEH,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E,MAAM,OAAO,cAAc;IAOf;IACA;IACA;IACA;IACA;IACA;IAXF,MAAM,GAAqB,EAAE,CAAC;IACtC,+DAA+D;IACvD,aAAa,GAAuB,IAAI,CAAC;IACzC,iBAAiB,GAAG,CAAC,CAAC,CAAC;IAE/B,YACU,cAAsC,EACtC,UAAsB,EACtB,eAA8B,EAC9B,mBAAgC,EAChC,iBAA8B,EAC9B,iBAA8B;QAL9B,mBAAc,GAAd,cAAc,CAAwB;QACtC,eAAU,GAAV,UAAU,CAAY;QACtB,oBAAe,GAAf,eAAe,CAAe;QAC9B,wBAAmB,GAAnB,mBAAmB,CAAa;QAChC,sBAAiB,GAAj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I,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9C,IAAI,MAAM,CAAC,YAAY;gBAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACxD,CAAC;QAED,kBAAkB;QAClB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;YAClE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnB,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;YACpE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnB,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Investigation Layer — Fact Ledger
3
+ *
4
+ * The Fact Ledger is the structured investigation memory for a single run.
5
+ * It stores FactRecords derived from evidence-layer outputs (artifacts,
6
+ * dialogue, validator findings) and organizes them for player-facing tools.
7
+ *
8
+ * Architectural boundary:
9
+ * - The Evidence Layer (Facts, Validators, Findings) produces truth.
10
+ * - The Fact Ledger records and organizes that truth.
11
+ * - The Fact Ledger never modifies validator outcomes or evidence-layer state.
12
+ */
13
+ import { FactRecord, FactStatus, FactConfidence, FactSourceType } from './types.js';
14
+ export declare class FactLedger {
15
+ private records;
16
+ /**
17
+ * Add a new FactRecord to the ledger.
18
+ * Duplicates are detected by (sourceType + sourceId + subject + statement).
19
+ * Returns true if the record was added, false if it was a duplicate.
20
+ */
21
+ add(record: FactRecord): boolean;
22
+ /**
23
+ * Retrieve a record by its unique id.
24
+ */
25
+ getById(id: string): FactRecord | undefined;
26
+ /**
27
+ * Retrieve all records for a given subject.
28
+ */
29
+ getBySubject(subject: string): FactRecord[];
30
+ /**
31
+ * Retrieve all records with a given status.
32
+ */
33
+ getByStatus(status: FactStatus): FactRecord[];
34
+ /**
35
+ * Retrieve all records from a given source type.
36
+ */
37
+ getBySourceType(sourceType: FactSourceType): FactRecord[];
38
+ /**
39
+ * Update the status and optionally the confidence of a record.
40
+ */
41
+ updateStatus(id: string, status: FactStatus, confidence?: FactConfidence): void;
42
+ /**
43
+ * Retrieve a record by its original case-schema fact ID.
44
+ * Bridges FactLedger identity ↔ Evidence Graph node identity.
45
+ */
46
+ getByOriginFactId(originFactId: string): FactRecord | undefined;
47
+ /**
48
+ * Add a related fact link to a record.
49
+ */
50
+ addRelatedFact(id: string, relatedFactId: string): void;
51
+ /**
52
+ * Update the reliability (confidence) of a record without changing its status. (#229)
53
+ */
54
+ updateReliability(id: string, confidence: FactConfidence): void;
55
+ /**
56
+ * Retrieve all records mentioning an entity (via relatedEntities, entityRefs, or legacy fields).
57
+ */
58
+ getByEntity(entityId: string): FactRecord[];
59
+ /**
60
+ * Retrieve all records from a given discovery method (sourceType alias).
61
+ */
62
+ getByMethod(method: FactSourceType): FactRecord[];
63
+ /**
64
+ * Retrieve all records at a given reliability (confidence) level.
65
+ */
66
+ getByReliability(level: FactConfidence): FactRecord[];
67
+ /**
68
+ * Retrieve the full transitive chain of related facts starting from a given fact.
69
+ * Follows relatedFactIds links recursively, avoiding cycles.
70
+ */
71
+ getRelatedFacts(factId: string): FactRecord[];
72
+ /**
73
+ * Trace back to the root source of a fact via relatedFactIds.
74
+ * Returns the chain from the given fact to the earliest ancestor.
75
+ */
76
+ getProvenanceChain(factId: string): FactRecord[];
77
+ /**
78
+ * Get all records in the ledger.
79
+ */
80
+ getAll(): FactRecord[];
81
+ /**
82
+ * Get the total number of records.
83
+ */
84
+ get size(): number;
85
+ /**
86
+ * Duplicate detection using stable identity:
87
+ * sourceType + sourceId + subject + statement
88
+ */
89
+ private _isDuplicate;
90
+ }
91
+ //# sourceMappingURL=FactLedger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FactLedger.d.ts","sourceRoot":"","sources":["../../src/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