@lucern/pack-host 0.1.0-alpha.2

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 (104) hide show
  1. package/README.md +64 -0
  2. package/dist/contracts.d.ts +77 -0
  3. package/dist/contracts.js +21 -0
  4. package/dist/contracts.js.map +1 -0
  5. package/dist/convex.config.d.ts +5 -0
  6. package/dist/convex.config.js +9 -0
  7. package/dist/convex.config.js.map +1 -0
  8. package/dist/dependencyResolution.d.ts +18 -0
  9. package/dist/dependencyResolution.js +131 -0
  10. package/dist/dependencyResolution.js.map +1 -0
  11. package/dist/domain-pack/authoring.d.ts +172 -0
  12. package/dist/domain-pack/authoring.js +1896 -0
  13. package/dist/domain-pack/authoring.js.map +1 -0
  14. package/dist/domain-pack/contracts.d.ts +183 -0
  15. package/dist/domain-pack/contracts.js +65 -0
  16. package/dist/domain-pack/contracts.js.map +1 -0
  17. package/dist/domain-pack/index.d.ts +8 -0
  18. package/dist/domain-pack/index.js +3813 -0
  19. package/dist/domain-pack/index.js.map +1 -0
  20. package/dist/domain-pack/ontology/software-entities-v1.d.ts +102 -0
  21. package/dist/domain-pack/ontology/software-entities-v1.js +104 -0
  22. package/dist/domain-pack/ontology/software-entities-v1.js.map +1 -0
  23. package/dist/domain-pack/packs/developer-reasoning.d.ts +14 -0
  24. package/dist/domain-pack/packs/developer-reasoning.js +339 -0
  25. package/dist/domain-pack/packs/developer-reasoning.js.map +1 -0
  26. package/dist/domain-pack/packs/engineering-accelerator.d.ts +11 -0
  27. package/dist/domain-pack/packs/engineering-accelerator.js +1348 -0
  28. package/dist/domain-pack/packs/engineering-accelerator.js.map +1 -0
  29. package/dist/domain-pack/packs/index.d.ts +18 -0
  30. package/dist/domain-pack/packs/index.js +2653 -0
  31. package/dist/domain-pack/packs/index.js.map +1 -0
  32. package/dist/domain-pack/shaping.d.ts +54 -0
  33. package/dist/domain-pack/shaping.js +1013 -0
  34. package/dist/domain-pack/shaping.js.map +1 -0
  35. package/dist/domain-pack/validation.d.ts +26 -0
  36. package/dist/domain-pack/validation.js +775 -0
  37. package/dist/domain-pack/validation.js.map +1 -0
  38. package/dist/domain-pack.d.ts +8 -0
  39. package/dist/domain-pack.js +3813 -0
  40. package/dist/domain-pack.js.map +1 -0
  41. package/dist/index.d.ts +29 -0
  42. package/dist/index.js +5520 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/lifecycle.d.ts +27 -0
  45. package/dist/lifecycle.js +98 -0
  46. package/dist/lifecycle.js.map +1 -0
  47. package/dist/manifestValidation.d.ts +28 -0
  48. package/dist/manifestValidation.js +253 -0
  49. package/dist/manifestValidation.js.map +1 -0
  50. package/dist/manifests/chat-v1.d.ts +10 -0
  51. package/dist/manifests/chat-v1.js +87 -0
  52. package/dist/manifests/chat-v1.js.map +1 -0
  53. package/dist/manifests/deals-v1.d.ts +10 -0
  54. package/dist/manifests/deals-v1.js +107 -0
  55. package/dist/manifests/deals-v1.js.map +1 -0
  56. package/dist/manifests/decisions-v1.d.ts +10 -0
  57. package/dist/manifests/decisions-v1.js +103 -0
  58. package/dist/manifests/decisions-v1.js.map +1 -0
  59. package/dist/manifests/documents-v1.d.ts +10 -0
  60. package/dist/manifests/documents-v1.js +88 -0
  61. package/dist/manifests/documents-v1.js.map +1 -0
  62. package/dist/manifests/epistemic-algorithms-v1.d.ts +10 -0
  63. package/dist/manifests/epistemic-algorithms-v1.js +107 -0
  64. package/dist/manifests/epistemic-algorithms-v1.js.map +1 -0
  65. package/dist/manifests/graph-visualization-v1.d.ts +10 -0
  66. package/dist/manifests/graph-visualization-v1.js +88 -0
  67. package/dist/manifests/graph-visualization-v1.js.map +1 -0
  68. package/dist/manifests/index.d.ts +23 -0
  69. package/dist/manifests/index.js +955 -0
  70. package/dist/manifests/index.js.map +1 -0
  71. package/dist/manifests/news-v1.d.ts +10 -0
  72. package/dist/manifests/news-v1.js +93 -0
  73. package/dist/manifests/news-v1.js.map +1 -0
  74. package/dist/manifests/philosophy-mode-v1.d.ts +10 -0
  75. package/dist/manifests/philosophy-mode-v1.js +100 -0
  76. package/dist/manifests/philosophy-mode-v1.js.map +1 -0
  77. package/dist/manifests/task-management-v1.d.ts +10 -0
  78. package/dist/manifests/task-management-v1.js +86 -0
  79. package/dist/manifests/task-management-v1.js.map +1 -0
  80. package/dist/manifests/team-analysis-v1.d.ts +10 -0
  81. package/dist/manifests/team-analysis-v1.js +93 -0
  82. package/dist/manifests/team-analysis-v1.js.map +1 -0
  83. package/dist/manifests/themes-v1.d.ts +10 -0
  84. package/dist/manifests/themes-v1.js +118 -0
  85. package/dist/manifests/themes-v1.js.map +1 -0
  86. package/dist/manifests/user-profiles-v1.d.ts +10 -0
  87. package/dist/manifests/user-profiles-v1.js +100 -0
  88. package/dist/manifests/user-profiles-v1.js.map +1 -0
  89. package/dist/manifests.d.ts +14 -0
  90. package/dist/manifests.js +955 -0
  91. package/dist/manifests.js.map +1 -0
  92. package/dist/namespacePolicy.d.ts +26 -0
  93. package/dist/namespacePolicy.js +129 -0
  94. package/dist/namespacePolicy.js.map +1 -0
  95. package/dist/registry.d.ts +13 -0
  96. package/dist/registry.js +1710 -0
  97. package/dist/registry.js.map +1 -0
  98. package/dist/runtime.d.ts +19 -0
  99. package/dist/runtime.js +638 -0
  100. package/dist/runtime.js.map +1 -0
  101. package/dist/serviceContracts.d.ts +18 -0
  102. package/dist/serviceContracts.js +64 -0
  103. package/dist/serviceContracts.js.map +1 -0
  104. package/package.json +48 -0
@@ -0,0 +1,1710 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/dependencyResolution.ts
4
+ function toIssue(code, message, path, severity = "error") {
5
+ return {
6
+ code,
7
+ severity,
8
+ message,
9
+ path
10
+ };
11
+ }
12
+ function buildManifestMap(manifests) {
13
+ return new Map(manifests.map((manifest) => [manifest.key, manifest]));
14
+ }
15
+ function walkDependencyClosure(manifestKey, manifestsByKey, path, closure, issues) {
16
+ const manifest = manifestsByKey.get(manifestKey);
17
+ if (!manifest) {
18
+ return;
19
+ }
20
+ for (const dependency of manifest.dependencies) {
21
+ if (!manifestsByKey.has(dependency)) {
22
+ issues.push(
23
+ toIssue(
24
+ "PACK_DEPENDENCY_MISSING",
25
+ `Pack "${manifestKey}" depends on unknown pack "${dependency}".`,
26
+ `dependencies:${manifestKey}`
27
+ )
28
+ );
29
+ continue;
30
+ }
31
+ if (path.includes(dependency)) {
32
+ const cycle = [...path, dependency].join(" -> ");
33
+ issues.push(
34
+ toIssue(
35
+ "PACK_DEPENDENCY_CYCLE",
36
+ `Cycle detected: ${cycle}`,
37
+ `dependencies:${manifestKey}`
38
+ )
39
+ );
40
+ continue;
41
+ }
42
+ if (closure.has(dependency)) {
43
+ continue;
44
+ }
45
+ closure.add(dependency);
46
+ walkDependencyClosure(
47
+ dependency,
48
+ manifestsByKey,
49
+ [...path, dependency],
50
+ closure,
51
+ issues
52
+ );
53
+ }
54
+ }
55
+ function resolvePackDependencyGraph(manifests) {
56
+ const issues = [];
57
+ const manifestsByKey = buildManifestMap(manifests);
58
+ const indegree = /* @__PURE__ */ new Map();
59
+ const adjacency = /* @__PURE__ */ new Map();
60
+ for (const manifest of manifests) {
61
+ indegree.set(manifest.key, indegree.get(manifest.key) ?? 0);
62
+ adjacency.set(manifest.key, []);
63
+ }
64
+ for (const manifest of manifests) {
65
+ for (const dependency of manifest.dependencies) {
66
+ if (!manifestsByKey.has(dependency)) {
67
+ issues.push(
68
+ toIssue(
69
+ "PACK_DEPENDENCY_MISSING",
70
+ `Pack "${manifest.key}" depends on unknown pack "${dependency}".`,
71
+ `dependencies:${manifest.key}`
72
+ )
73
+ );
74
+ continue;
75
+ }
76
+ const dependencyDependents = adjacency.get(dependency) ?? [];
77
+ dependencyDependents.push(manifest.key);
78
+ adjacency.set(dependency, dependencyDependents);
79
+ indegree.set(manifest.key, (indegree.get(manifest.key) ?? 0) + 1);
80
+ }
81
+ }
82
+ const queue = [...indegree.entries()].filter(([, value]) => value === 0).map(([packKey]) => packKey).sort();
83
+ const orderedPackKeys = [];
84
+ while (queue.length > 0) {
85
+ const nextKey = queue.shift();
86
+ if (!nextKey) {
87
+ break;
88
+ }
89
+ orderedPackKeys.push(nextKey);
90
+ const dependents = adjacency.get(nextKey) ?? [];
91
+ for (const dependent of dependents) {
92
+ const current = indegree.get(dependent) ?? 0;
93
+ const updated = current - 1;
94
+ indegree.set(dependent, updated);
95
+ if (updated === 0) {
96
+ queue.push(dependent);
97
+ }
98
+ }
99
+ queue.sort();
100
+ }
101
+ if (orderedPackKeys.length !== manifestsByKey.size) {
102
+ const unresolved = [...indegree.entries()].filter(([, value]) => value > 0).map(([key]) => key).sort();
103
+ issues.push(
104
+ toIssue(
105
+ "PACK_DEPENDENCY_CYCLE",
106
+ `Dependency graph is not acyclic; unresolved packs: ${unresolved.join(", ")}`,
107
+ "dependencies"
108
+ )
109
+ );
110
+ }
111
+ const dependencyClosureByPack = {};
112
+ for (const manifest of manifests) {
113
+ const closure = /* @__PURE__ */ new Set();
114
+ walkDependencyClosure(
115
+ manifest.key,
116
+ manifestsByKey,
117
+ [manifest.key],
118
+ closure,
119
+ issues
120
+ );
121
+ dependencyClosureByPack[manifest.key] = [...closure].sort();
122
+ }
123
+ return {
124
+ orderedPackKeys,
125
+ dependencyClosureByPack,
126
+ issues,
127
+ valid: issues.every((issue) => issue.severity !== "error")
128
+ };
129
+ }
130
+
131
+ // src/lifecycle.ts
132
+ var DEFAULT_ALLOWED_LIFECYCLES = [
133
+ "active",
134
+ "beta",
135
+ "experimental"
136
+ ];
137
+ function toSet(values) {
138
+ return new Set(values ?? []);
139
+ }
140
+ function evaluatePackEnablement(packKey, registry, policy = {}) {
141
+ const manifest = registry[packKey];
142
+ if (!manifest) {
143
+ return {
144
+ packKey,
145
+ allowed: false,
146
+ reason: "pack_not_found",
147
+ missingDependencies: []
148
+ };
149
+ }
150
+ const allowedLifecycles = new Set(
151
+ policy.allowedLifecycles ?? DEFAULT_ALLOWED_LIFECYCLES
152
+ );
153
+ if (!allowedLifecycles.has(manifest.lifecycle)) {
154
+ return {
155
+ packKey,
156
+ allowed: false,
157
+ reason: "lifecycle_blocked",
158
+ missingDependencies: []
159
+ };
160
+ }
161
+ const requireExplicitEntitlement = policy.requireExplicitEntitlement ?? false;
162
+ if (requireExplicitEntitlement) {
163
+ const entitled = /* @__PURE__ */ new Set([
164
+ ...toSet(policy.tenantEntitledPackKeys),
165
+ ...toSet(policy.workspaceEntitledPackKeys)
166
+ ]);
167
+ if (!entitled.has(packKey)) {
168
+ return {
169
+ packKey,
170
+ allowed: false,
171
+ reason: "license_missing",
172
+ missingDependencies: []
173
+ };
174
+ }
175
+ }
176
+ const missingDependencies = manifest.dependencies.filter(
177
+ (dependency) => !registry[dependency]
178
+ );
179
+ if (missingDependencies.length > 0) {
180
+ return {
181
+ packKey,
182
+ allowed: false,
183
+ reason: "dependency_missing",
184
+ missingDependencies
185
+ };
186
+ }
187
+ const installed = toSet(policy.installedPackKeys);
188
+ if (installed.size > 0) {
189
+ const notInstalled = manifest.dependencies.filter(
190
+ (dependency) => !installed.has(dependency)
191
+ );
192
+ if (notInstalled.length > 0) {
193
+ return {
194
+ packKey,
195
+ allowed: false,
196
+ reason: "dependency_not_installed",
197
+ missingDependencies: notInstalled
198
+ };
199
+ }
200
+ }
201
+ const enabled = toSet(policy.enabledPackKeys);
202
+ if (enabled.size > 0) {
203
+ const notEnabled = manifest.dependencies.filter(
204
+ (dependency) => !enabled.has(dependency)
205
+ );
206
+ if (notEnabled.length > 0) {
207
+ return {
208
+ packKey,
209
+ allowed: false,
210
+ reason: "dependency_not_enabled",
211
+ missingDependencies: notEnabled
212
+ };
213
+ }
214
+ }
215
+ return {
216
+ packKey,
217
+ allowed: true,
218
+ reason: "allowed",
219
+ missingDependencies: []
220
+ };
221
+ }
222
+ function evaluateCatalogEnablement(registry, policy = {}) {
223
+ return Object.keys(registry).sort().map((packKey) => evaluatePackEnablement(packKey, registry, policy));
224
+ }
225
+
226
+ // src/contracts.ts
227
+ function normalizeStringArray(values) {
228
+ const normalized = values.map((value) => value.trim()).filter((value) => value.length > 0);
229
+ return Array.from(new Set(normalized));
230
+ }
231
+ function defineAppPackManifest(manifest) {
232
+ const sharedServices = (manifest.sharedServices ?? []).map((integration) => ({
233
+ ...integration,
234
+ contracts: normalizeStringArray(integration.contracts)
235
+ }));
236
+ return {
237
+ ...manifest,
238
+ dependencies: normalizeStringArray(manifest.dependencies),
239
+ capabilityFlags: normalizeStringArray(manifest.capabilityFlags),
240
+ sharedServices
241
+ };
242
+ }
243
+
244
+ // src/manifests/chat-v1.ts
245
+ var chatV1Manifest = defineAppPackManifest({
246
+ key: "chat-v1",
247
+ name: "Chat",
248
+ version: "1.0.0",
249
+ lifecycle: "active",
250
+ category: "conversation",
251
+ description: "Core conversational runtime, streaming orchestration, and tool invocation shell.",
252
+ dependencies: [],
253
+ capabilityFlags: [
254
+ "chat.streaming",
255
+ "chat.history",
256
+ "tool.invocation",
257
+ "slash.commands",
258
+ "voice.mode"
259
+ ],
260
+ routeNamespace: {
261
+ web: ["/(chat)/chat", "/(chat)/chat/[id]"],
262
+ api: [
263
+ "/(chat)/api/chat",
264
+ "/(chat)/api/coach",
265
+ "/(chat)/api/history",
266
+ "/(chat)/api/suggestions",
267
+ "/(chat)/api/vote"
268
+ ]
269
+ },
270
+ surfaces: {
271
+ components: [
272
+ "components/chat/*",
273
+ "components/chat/sidebars/*",
274
+ "components/chat/viewers/*"
275
+ ],
276
+ convex: ["convex/chats.ts", "convex/messages.ts", "convex/chatState.ts"],
277
+ tools: ["lib/ai/tools/project-tools.ts"]
278
+ },
279
+ policyProfile: {
280
+ audiences: ["internal", "lp", "public"],
281
+ rules: [
282
+ { resource: "project", actions: ["read", "summarize"] },
283
+ {
284
+ resource: "tool_action",
285
+ actions: ["read", "mutate"],
286
+ notes: "Mutation tools must pass server-side policy checks."
287
+ },
288
+ { resource: "artifact", actions: ["read", "summarize"] }
289
+ ]
290
+ },
291
+ dataContract: {
292
+ requiredNodeTypes: ["belief", "question", "evidence", "theme", "deal"],
293
+ requiredEdgeTypes: ["informs", "answers", "belongs_to"],
294
+ requiredTables: ["chats", "messages", "chatState", "projects"],
295
+ projectionBehavior: "inherits_policy"
296
+ },
297
+ templates: {
298
+ workflows: ["chat/default", "chat/voice-mode"],
299
+ prompts: ["chat/main-system-prompt", "chat/voice-mode-style"],
300
+ reports: [],
301
+ uiLabels: ["chat", "assistant", "conversation"]
302
+ },
303
+ testSuite: {
304
+ parity: ["chat-streaming-parity", "slash-command-parity"],
305
+ policy: ["chat-context-filtering", "tool-deny-enforcement"],
306
+ contract: ["chat-pack-contract-v1"]
307
+ }
308
+ });
309
+
310
+ // src/manifests/deals-v1.ts
311
+ var dealsV1Manifest = defineAppPackManifest({
312
+ key: "deals-v1",
313
+ name: "Deals",
314
+ version: "1.0.0",
315
+ lifecycle: "beta",
316
+ category: "domain",
317
+ description: "Deal diligence application using shared reasoning graph primitives with deal-calibrated workflows.",
318
+ dependencies: [
319
+ "chat-v1",
320
+ "documents-v1",
321
+ "news-v1",
322
+ "decisions-v1"
323
+ ],
324
+ capabilityFlags: [
325
+ "deal.lifecycle",
326
+ "diligence.workflow",
327
+ "deal.risk-assessment",
328
+ "decision.integration"
329
+ ],
330
+ routeNamespace: {
331
+ web: ["/(projects)/projects", "/(projects)/projects/[projectId]"],
332
+ api: ["/api/research/*", "/api/tasks/*", "/api/reports/*"]
333
+ },
334
+ surfaces: {
335
+ components: [
336
+ "app/(projects)/projects/page.tsx",
337
+ "components/project/*",
338
+ "components/workspace/views/*"
339
+ ],
340
+ convex: ["convex/projects.ts", "convex/epistemicDecisions.ts"],
341
+ tools: [
342
+ "lib/ai/tools/navigation-tools.ts",
343
+ "lib/ai/tools/decision-tools.ts"
344
+ ]
345
+ },
346
+ policyProfile: {
347
+ audiences: ["internal", "lp"],
348
+ rules: [
349
+ { resource: "project", actions: ["read", "summarize", "mutate"] },
350
+ { resource: "node", actions: ["read", "summarize", "mutate"] },
351
+ { resource: "artifact", actions: ["read", "summarize", "export"] },
352
+ { resource: "tool_action", actions: ["read", "mutate"] }
353
+ ]
354
+ },
355
+ dataContract: {
356
+ requiredNodeTypes: ["deal", "belief", "question", "evidence", "decision"],
357
+ requiredEdgeTypes: [
358
+ "evaluates",
359
+ "informs",
360
+ "depends_on",
361
+ "based_on_belief"
362
+ ],
363
+ requiredTables: [
364
+ "projects",
365
+ "epistemicNodes",
366
+ "epistemicEdges",
367
+ "decisionEvents"
368
+ ],
369
+ projectionBehavior: "projection_required"
370
+ },
371
+ templates: {
372
+ workflows: ["deals/diligence-default", "deals/ic-prep"],
373
+ prompts: ["deals/main-system-prompt", "deals/risk-ledger-draft"],
374
+ reports: ["deal-memo", "knowledge-map"],
375
+ uiLabels: ["deal", "diligence", "investment_case", "ic_readiness"]
376
+ },
377
+ testSuite: {
378
+ parity: ["deal-workflow-parity"],
379
+ policy: ["deal-data-audience-filtering"],
380
+ contract: ["deals-pack-contract-v1"]
381
+ },
382
+ sharedServices: [
383
+ {
384
+ service: "decision-kernel",
385
+ mode: "required",
386
+ contracts: ["decision-kernel-v1"]
387
+ },
388
+ {
389
+ service: "knowledge-compiler",
390
+ mode: "required",
391
+ contracts: ["knowledge-compiler-v1"]
392
+ }
393
+ ]
394
+ });
395
+
396
+ // src/manifests/decisions-v1.ts
397
+ var decisionsV1Manifest = defineAppPackManifest({
398
+ key: "decisions-v1",
399
+ name: "Decisions",
400
+ version: "1.0.0",
401
+ lifecycle: "beta",
402
+ category: "decision",
403
+ description: "Graph-native decision workflow with belief-level voting, risk ledgers, and snapshot locking.",
404
+ dependencies: ["epistemic-algorithms-v1"],
405
+ capabilityFlags: [
406
+ "decision.workflow",
407
+ "belief.level-voting",
408
+ "risk.ledger",
409
+ "decision.snapshot"
410
+ ],
411
+ routeNamespace: {
412
+ web: ["/(projects)/projects/[projectId]/decisions"],
413
+ api: ["/api/thesis-audit/*", "/api/reports/*"]
414
+ },
415
+ surfaces: {
416
+ components: ["app/(projects)/projects/[projectId]/decisions/page.tsx"],
417
+ convex: ["convex/epistemicDecisions.ts", "convex/convictionEngine.ts"],
418
+ tools: [
419
+ "lib/ai/tools/decision-tools.ts",
420
+ "lib/ai/tools/conviction-tools.ts"
421
+ ]
422
+ },
423
+ policyProfile: {
424
+ audiences: ["internal", "lp"],
425
+ rules: [
426
+ { resource: "project", actions: ["read", "summarize", "mutate"] },
427
+ { resource: "node", actions: ["read", "summarize", "mutate"] },
428
+ { resource: "edge", actions: ["read", "mutate"] },
429
+ { resource: "artifact", actions: ["read", "export"] }
430
+ ]
431
+ },
432
+ dataContract: {
433
+ requiredNodeTypes: ["decision", "belief", "question", "evidence", "theme"],
434
+ requiredEdgeTypes: [
435
+ "based_on_belief",
436
+ "based_on_question",
437
+ "informed_by_theme",
438
+ "blocked_by_contradiction"
439
+ ],
440
+ requiredTables: [
441
+ "epistemicNodes",
442
+ "epistemicEdges",
443
+ "decisionEvents",
444
+ "beliefVotes",
445
+ "decisionRiskLedger",
446
+ "decisionSnapshots"
447
+ ],
448
+ projectionBehavior: "projection_required"
449
+ },
450
+ templates: {
451
+ workflows: ["decisions/pre-ic", "decisions/in-ic", "decisions/post-ic"],
452
+ prompts: [
453
+ "decisions/main-system-prompt",
454
+ "decisions/risk-ledger-assistant"
455
+ ],
456
+ reports: ["decision-brief", "ic-memo"],
457
+ uiLabels: ["decision", "risk_ledger", "vote_map", "snapshot"]
458
+ },
459
+ testSuite: {
460
+ parity: ["decision-flow-parity"],
461
+ policy: ["decision-lineage-visibility"],
462
+ contract: ["decisions-pack-contract-v1"]
463
+ },
464
+ sharedServices: [
465
+ {
466
+ service: "decision-kernel",
467
+ mode: "required",
468
+ contracts: ["decision-kernel-v1"]
469
+ },
470
+ {
471
+ service: "knowledge-compiler",
472
+ mode: "required",
473
+ contracts: ["knowledge-compiler-v1"]
474
+ }
475
+ ]
476
+ });
477
+
478
+ // src/manifests/documents-v1.ts
479
+ var documentsV1Manifest = defineAppPackManifest({
480
+ key: "documents-v1",
481
+ name: "Documents",
482
+ version: "1.0.0",
483
+ lifecycle: "active",
484
+ category: "documents",
485
+ description: "Document upload, extraction, annotation, and conversion into graph-grounded evidence.",
486
+ dependencies: ["chat-v1"],
487
+ capabilityFlags: [
488
+ "document.ingestion",
489
+ "document.extraction",
490
+ "document.annotation",
491
+ "document.rag"
492
+ ],
493
+ routeNamespace: {
494
+ web: [
495
+ "/(projects)/projects/[projectId]/documents",
496
+ "/(projects)/projects/[projectId]/documents/[documentId]"
497
+ ],
498
+ api: ["/api/documents/*", "/api/rag/document", "/api/rag/extract-pdf"]
499
+ },
500
+ surfaces: {
501
+ components: ["components/documents/*", "components/document/*"],
502
+ convex: [
503
+ "convex/projectDocuments.ts",
504
+ "convex/documents.ts",
505
+ "convex/documentAnnotations.ts",
506
+ "convex/projectDocumentsActions.ts"
507
+ ],
508
+ tools: ["lib/ai/tools/create-document.ts"]
509
+ },
510
+ policyProfile: {
511
+ audiences: ["internal", "lp"],
512
+ rules: [
513
+ { resource: "artifact", actions: ["read", "summarize", "mutate"] },
514
+ { resource: "project", actions: ["read", "summarize", "mutate"] },
515
+ { resource: "tool_action", actions: ["read", "mutate"] }
516
+ ]
517
+ },
518
+ dataContract: {
519
+ requiredNodeTypes: ["source", "excerpt", "evidence", "synthesis"],
520
+ requiredEdgeTypes: ["extracted_from", "based_on", "informs"],
521
+ requiredTables: [
522
+ "projectDocuments",
523
+ "projectDocumentsSyncLog",
524
+ "documentAnnotations",
525
+ "epistemicNodes"
526
+ ],
527
+ projectionBehavior: "inherits_policy"
528
+ },
529
+ templates: {
530
+ workflows: [
531
+ "documents/upload-extract-link",
532
+ "documents/annotate-to-evidence"
533
+ ],
534
+ prompts: ["documents/extraction", "documents/summarization"],
535
+ reports: [],
536
+ uiLabels: ["documents", "annotations", "excerpts", "sources"]
537
+ },
538
+ testSuite: {
539
+ parity: ["documents-page-parity"],
540
+ policy: ["document-access-enforcement"],
541
+ contract: ["documents-pack-contract-v1"]
542
+ }
543
+ });
544
+
545
+ // src/manifests/epistemic-algorithms-v1.ts
546
+ var epistemicAlgorithmsV1Manifest = defineAppPackManifest({
547
+ key: "epistemic-algorithms-v1",
548
+ name: "Epistemic Algorithms",
549
+ version: "1.0.0",
550
+ lifecycle: "active",
551
+ category: "analytics",
552
+ description: "Reasoning quality engines: contradiction detection, conviction dynamics, and graph intelligence analytics.",
553
+ dependencies: ["graph-visualization-v1", "chat-v1"],
554
+ capabilityFlags: [
555
+ "contradiction.detection",
556
+ "conviction.analytics",
557
+ "reasoning.depth",
558
+ "bias.detection"
559
+ ],
560
+ routeNamespace: {
561
+ web: [
562
+ "/(projects)/projects/[projectId]/contradictions",
563
+ "/(projects)/projects/[projectId]/thesis-audit"
564
+ ],
565
+ api: ["/api/thesis-audit", "/api/graph-explain", "/api/lucern/*"]
566
+ },
567
+ surfaces: {
568
+ components: ["components/epistemic/*", "components/contradiction/*"],
569
+ convex: [
570
+ "convex/contradictions.ts",
571
+ "convex/convictionEngine.ts",
572
+ "convex/graphIntelligence.ts",
573
+ "convex/thesisAuditAgents.ts"
574
+ ],
575
+ tools: ["lib/ai/tools/graph-intelligence-tools.ts"]
576
+ },
577
+ policyProfile: {
578
+ audiences: ["internal", "lp"],
579
+ rules: [
580
+ { resource: "node", actions: ["read", "summarize"] },
581
+ { resource: "edge", actions: ["read", "summarize"] },
582
+ { resource: "artifact", actions: ["read", "summarize", "export"] }
583
+ ]
584
+ },
585
+ dataContract: {
586
+ requiredNodeTypes: ["belief", "question", "evidence", "theme", "decision"],
587
+ requiredEdgeTypes: [
588
+ "informs",
589
+ "contradicts",
590
+ "depends_on",
591
+ "strengthened_by",
592
+ "weakened_by",
593
+ "collapses_if"
594
+ ],
595
+ requiredTables: [
596
+ "contradictions",
597
+ "beliefConfidence",
598
+ "epistemicAudit",
599
+ "graphAnalysisResults"
600
+ ],
601
+ projectionBehavior: "inherits_policy"
602
+ },
603
+ templates: {
604
+ workflows: ["epistemic/contradiction-resolution", "epistemic/thesis-audit"],
605
+ prompts: [
606
+ "graph-intelligence/full-guide",
607
+ "graph-intelligence/bias-detection"
608
+ ],
609
+ reports: ["knowledge_map"],
610
+ uiLabels: [
611
+ "contradiction",
612
+ "conviction",
613
+ "thesis_audit",
614
+ "epistemic_health"
615
+ ]
616
+ },
617
+ testSuite: {
618
+ parity: ["epistemic-algorithm-output-parity"],
619
+ policy: ["epistemic-output-scope-filtering"],
620
+ contract: ["epistemic-algorithms-pack-contract-v1"]
621
+ },
622
+ sharedServices: [
623
+ {
624
+ service: "knowledge-compiler",
625
+ mode: "required",
626
+ contracts: ["knowledge-compiler-v1"]
627
+ }
628
+ ]
629
+ });
630
+
631
+ // src/manifests/graph-visualization-v1.ts
632
+ var graphVisualizationV1Manifest = defineAppPackManifest({
633
+ key: "graph-visualization-v1",
634
+ name: "Graph Visualization",
635
+ version: "1.0.0",
636
+ lifecycle: "active",
637
+ category: "graph",
638
+ description: "Interactive graph explorer for node/edge traversal, neighborhood inspection, and query rendering.",
639
+ dependencies: ["chat-v1"],
640
+ capabilityFlags: [
641
+ "graph.rendering",
642
+ "graph.query",
643
+ "graph.highlighting",
644
+ "graph.neighborhood"
645
+ ],
646
+ routeNamespace: {
647
+ web: ["/(projects)/projects/[projectId]/graph"],
648
+ api: ["/api/graph", "/api/graph-query", "/api/graph-suggestions"]
649
+ },
650
+ surfaces: {
651
+ components: [
652
+ "app/(projects)/projects/[projectId]/graph/components/*",
653
+ "components/workspace/views/ProjectHomeView.tsx"
654
+ ],
655
+ convex: ["convex/epistemicQueries.ts", "convex/neo4jQueries.ts"],
656
+ tools: [
657
+ "lib/ai/tools/knowledge-graph-tools.ts",
658
+ "lib/ai/tools/cypher-tools.ts"
659
+ ]
660
+ },
661
+ policyProfile: {
662
+ audiences: ["internal", "lp"],
663
+ rules: [
664
+ { resource: "node", actions: ["read", "summarize"] },
665
+ { resource: "edge", actions: ["read", "summarize"] },
666
+ { resource: "tool_action", actions: ["read"] }
667
+ ]
668
+ },
669
+ dataContract: {
670
+ requiredNodeTypes: [
671
+ "belief",
672
+ "question",
673
+ "evidence",
674
+ "theme",
675
+ "deal",
676
+ "decision"
677
+ ],
678
+ requiredEdgeTypes: ["informs", "answers", "belongs_to", "depends_on"],
679
+ requiredTables: ["epistemicNodes", "epistemicEdges"],
680
+ projectionBehavior: "inherits_policy"
681
+ },
682
+ templates: {
683
+ workflows: ["graph/query-and-traverse"],
684
+ prompts: [
685
+ "graph-intelligence/query",
686
+ "graph-intelligence/suggestions-extraction"
687
+ ],
688
+ reports: [],
689
+ uiLabels: ["graph", "nodes", "edges", "lineage"]
690
+ },
691
+ testSuite: {
692
+ parity: ["graph-query-parity", "graph-render-parity"],
693
+ policy: ["graph-node-visibility-filtering"],
694
+ contract: ["graph-visualization-pack-contract-v1"]
695
+ }
696
+ });
697
+
698
+ // src/manifests/news-v1.ts
699
+ var newsV1Manifest = defineAppPackManifest({
700
+ key: "news-v1",
701
+ name: "News",
702
+ version: "1.0.0",
703
+ lifecycle: "active",
704
+ category: "news",
705
+ description: "News ingestion, curation, and contextual linkage into the reasoning graph.",
706
+ dependencies: ["chat-v1"],
707
+ capabilityFlags: [
708
+ "news.search",
709
+ "news.ingestion",
710
+ "news.curation",
711
+ "news.graph-linkage"
712
+ ],
713
+ routeNamespace: {
714
+ web: [
715
+ "/(projects)/projects/[projectId]/news-v3",
716
+ "/(projects)/projects/[projectId]/news-v3/[articleId]"
717
+ ],
718
+ api: ["/api/news/search", "/api/intelligence/smart-news-search"]
719
+ },
720
+ surfaces: {
721
+ components: ["components/news/*"],
722
+ convex: [
723
+ "convex/projectNews.ts",
724
+ "convex/newsArticles.ts",
725
+ "convex/newsCurationJobs.ts",
726
+ "convex/articleCache.ts"
727
+ ],
728
+ tools: ["lib/ai/tools/research-tools.ts"]
729
+ },
730
+ policyProfile: {
731
+ audiences: ["internal", "lp", "public"],
732
+ rules: [
733
+ { resource: "project", actions: ["read", "summarize", "mutate"] },
734
+ { resource: "artifact", actions: ["read", "summarize", "export"] },
735
+ { resource: "node", actions: ["read", "summarize"] }
736
+ ]
737
+ },
738
+ dataContract: {
739
+ requiredNodeTypes: ["source", "evidence", "synthesis", "theme", "deal"],
740
+ requiredEdgeTypes: ["extracted_from", "informs", "belongs_to"],
741
+ requiredTables: [
742
+ "projectNews",
743
+ "savedNewsArticles",
744
+ "newsCurationJobs",
745
+ "articleCache",
746
+ "epistemicNodes"
747
+ ],
748
+ projectionBehavior: "inherits_policy"
749
+ },
750
+ templates: {
751
+ workflows: ["news/search-import-curate", "news/evidence-linking"],
752
+ prompts: ["news/summary", "news/relevance-scoring"],
753
+ reports: ["news-digest"],
754
+ uiLabels: ["news", "articles", "curation", "signals"]
755
+ },
756
+ testSuite: {
757
+ parity: ["news-v3-parity"],
758
+ policy: ["news-audience-redaction"],
759
+ contract: ["news-pack-contract-v1"]
760
+ },
761
+ sharedServices: [
762
+ {
763
+ service: "knowledge-compiler",
764
+ mode: "required",
765
+ contracts: ["knowledge-compiler-v1"]
766
+ }
767
+ ]
768
+ });
769
+
770
+ // src/manifests/philosophy-mode-v1.ts
771
+ var philosophyModeV1Manifest = defineAppPackManifest({
772
+ key: "philosophy-mode-v1",
773
+ name: "Philosophy Mode",
774
+ version: "1.0.0",
775
+ lifecycle: "active",
776
+ category: "domain",
777
+ description: "Investor worldview extraction, archetype synthesis, and philosophy profile management.",
778
+ dependencies: ["chat-v1", "user-profiles-v1"],
779
+ capabilityFlags: [
780
+ "philosophy.extraction",
781
+ "philosophy.profiles",
782
+ "archetype.classification",
783
+ "worldview.synthesis"
784
+ ],
785
+ routeNamespace: {
786
+ web: ["/(chat)/chat/[id]"],
787
+ api: [
788
+ "/api/philosophy/detect",
789
+ "/api/philosophy/extract",
790
+ "/api/philosophy/get-profile",
791
+ "/api/philosophy/ingest",
792
+ "/api/philosophy/synthesize"
793
+ ]
794
+ },
795
+ surfaces: {
796
+ components: [
797
+ "components/chat/sidebars/PhilosophyModeSidebar.tsx",
798
+ "components/philosophy/ArchetypeDisplay.tsx"
799
+ ],
800
+ convex: [
801
+ "convex/philosophy.ts",
802
+ "convex/philosophyQueries.ts",
803
+ "convex/projectPhilosophy.ts"
804
+ ],
805
+ tools: ["lib/ai/tools/philosophy-tools.ts"]
806
+ },
807
+ policyProfile: {
808
+ audiences: ["internal"],
809
+ rules: [
810
+ { resource: "user_profile", actions: ["read", "mutate"] },
811
+ { resource: "project", actions: ["read", "summarize"] },
812
+ { resource: "tool_action", actions: ["read", "mutate"] }
813
+ ]
814
+ },
815
+ dataContract: {
816
+ requiredNodeTypes: ["belief", "question", "theme"],
817
+ requiredEdgeTypes: ["belongs_to", "relates_to_thesis"],
818
+ requiredTables: [
819
+ "marketPhilosophyProfiles",
820
+ "marketPhilosophyAtoms",
821
+ "marketPhilosophyContent",
822
+ "philosophyUploads"
823
+ ],
824
+ projectionBehavior: "inherits_policy"
825
+ },
826
+ templates: {
827
+ workflows: ["philosophy/conversation-to-profile"],
828
+ prompts: [
829
+ "philosophy/deep-thinker",
830
+ "philosophy/welcome-back",
831
+ "philosophy/detect-philosophical-statement",
832
+ "philosophy/content-classifier",
833
+ "philosophy/atom-extractor",
834
+ "philosophy/summarize-investor-profile",
835
+ "philosophy/team-aggregator",
836
+ "philosophy/market-synthesis",
837
+ "thematic/extractor"
838
+ ],
839
+ reports: [],
840
+ uiLabels: ["philosophy_mode", "investor_worldview", "archetype"]
841
+ },
842
+ testSuite: {
843
+ parity: ["philosophy-profile-parity"],
844
+ policy: ["philosophy-profile-isolation"],
845
+ contract: ["philosophy-pack-contract-v1"]
846
+ }
847
+ });
848
+
849
+ // src/manifests/task-management-v1.ts
850
+ var taskManagementV1Manifest = defineAppPackManifest({
851
+ key: "task-management-v1",
852
+ name: "Task Management",
853
+ version: "1.0.0",
854
+ lifecycle: "active",
855
+ category: "operations",
856
+ description: "Operational task system linked to beliefs, questions, worktrees, and AI-assisted execution.",
857
+ dependencies: ["chat-v1"],
858
+ capabilityFlags: [
859
+ "task.lifecycle",
860
+ "task.assignment",
861
+ "task.attachments",
862
+ "task.ai-execution",
863
+ "task.evidence-capture"
864
+ ],
865
+ routeNamespace: {
866
+ web: ["/(projects)/projects/[projectId]/tasks"],
867
+ api: [
868
+ "/api/tasks/execute",
869
+ "/api/tasks/execute-workflow",
870
+ "/api/tasks/refresh-call-script"
871
+ ]
872
+ },
873
+ surfaces: {
874
+ components: ["components/task/*"],
875
+ convex: [
876
+ "convex/tasks.ts",
877
+ "convex/_taskHelpers.ts",
878
+ "convex/_taskQueryLogic.ts"
879
+ ],
880
+ tools: ["lib/ai/tools/task-tools.ts"]
881
+ },
882
+ policyProfile: {
883
+ audiences: ["internal", "lp"],
884
+ rules: [
885
+ { resource: "task", actions: ["read", "mutate", "admin"] },
886
+ { resource: "project", actions: ["read", "summarize", "mutate"] },
887
+ { resource: "tool_action", actions: ["read", "mutate"] },
888
+ { resource: "artifact", actions: ["read", "summarize", "mutate"] }
889
+ ]
890
+ },
891
+ dataContract: {
892
+ requiredNodeTypes: ["belief", "question", "evidence", "synthesis"],
893
+ requiredEdgeTypes: ["informs", "tests", "belongs_to"],
894
+ requiredTables: ["tasks", "projects", "epistemicNodes", "epistemicEdges"],
895
+ projectionBehavior: "inherits_policy"
896
+ },
897
+ templates: {
898
+ workflows: [
899
+ "tasks/research-plan",
900
+ "tasks/execution-loop",
901
+ "tasks/evidence-capture"
902
+ ],
903
+ prompts: ["tasks/call-script", "tasks/research-plan-generator"],
904
+ reports: [],
905
+ uiLabels: ["tasks", "assignee", "checklist", "workflow_status"]
906
+ },
907
+ testSuite: {
908
+ parity: ["task-management-parity"],
909
+ policy: ["task-project-access-enforcement"],
910
+ contract: ["task-management-pack-contract-v1"]
911
+ }
912
+ });
913
+
914
+ // src/manifests/team-analysis-v1.ts
915
+ var teamAnalysisV1Manifest = defineAppPackManifest({
916
+ key: "team-analysis-v1",
917
+ name: "Team Analysis",
918
+ version: "1.0.0",
919
+ lifecycle: "active",
920
+ category: "analytics",
921
+ description: "Team-level behavioral analytics, archetype distribution, and comparative operating patterns.",
922
+ dependencies: ["user-profiles-v1"],
923
+ capabilityFlags: [
924
+ "team.analytics",
925
+ "team.behavioral-summary",
926
+ "team.archetype-distribution",
927
+ "team.activity-heatmap"
928
+ ],
929
+ routeNamespace: {
930
+ web: ["/(team)/team"],
931
+ api: ["/api/coaching/*"]
932
+ },
933
+ surfaces: {
934
+ components: ["components/charts/*", "components/coaching/*"],
935
+ convex: [
936
+ "convex/users.ts",
937
+ "convex/userAnalytics.ts",
938
+ "convex/projectCards.ts"
939
+ ],
940
+ tools: []
941
+ },
942
+ policyProfile: {
943
+ audiences: ["internal", "tenant_admin"],
944
+ rules: [
945
+ { resource: "team_analytics", actions: ["read", "admin"] },
946
+ { resource: "user_profile", actions: ["read"] },
947
+ { resource: "project", actions: ["read"] }
948
+ ]
949
+ },
950
+ dataContract: {
951
+ requiredNodeTypes: ["belief", "question", "evidence"],
952
+ requiredEdgeTypes: ["informs", "tests"],
953
+ requiredTables: [
954
+ "users",
955
+ "userEpistemicJourney",
956
+ "epistemicAudit",
957
+ "proposalEvents",
958
+ "biSuggestions",
959
+ "beliefConfidence",
960
+ "contradictions",
961
+ "worktrees",
962
+ "tasks"
963
+ ],
964
+ projectionBehavior: "none"
965
+ },
966
+ templates: {
967
+ workflows: ["team/behavioral-summary", "team/coverage-gap-analysis"],
968
+ prompts: ["coaching/team-summary", "coaching/team-recommendations"],
969
+ reports: ["team-operating-review"],
970
+ uiLabels: ["team", "behavior", "distribution", "coverage"]
971
+ },
972
+ testSuite: {
973
+ parity: ["team-page-parity"],
974
+ policy: ["team-analytics-admin-scope"],
975
+ contract: ["team-analysis-pack-contract-v1"]
976
+ },
977
+ sharedServices: [
978
+ {
979
+ service: "knowledge-compiler",
980
+ mode: "required",
981
+ contracts: ["knowledge-compiler-v1"]
982
+ }
983
+ ]
984
+ });
985
+
986
+ // src/manifests/themes-v1.ts
987
+ var themesV1Manifest = defineAppPackManifest({
988
+ key: "themes-v1",
989
+ name: "Themes",
990
+ version: "1.0.0",
991
+ lifecycle: "active",
992
+ category: "domain",
993
+ description: "Thematic research lifecycle built on graph primitives, worktree workflows, and conviction analytics.",
994
+ dependencies: [
995
+ "chat-v1",
996
+ "epistemic-algorithms-v1",
997
+ "news-v1",
998
+ "documents-v1"
999
+ ],
1000
+ capabilityFlags: [
1001
+ "theme.lifecycle",
1002
+ "belief.question.evidence",
1003
+ "thesis.development",
1004
+ "reporting"
1005
+ ],
1006
+ routeNamespace: {
1007
+ web: [
1008
+ "/(projects)/projects",
1009
+ "/(projects)/projects/[projectId]",
1010
+ "/(projects)/projects/[projectId]/beliefs-v2",
1011
+ "/(projects)/projects/[projectId]/questions",
1012
+ "/(projects)/projects/[projectId]/research",
1013
+ "/(projects)/projects/[projectId]/reports"
1014
+ ],
1015
+ api: ["/api/research/*", "/api/reports/*", "/api/questions/*"]
1016
+ },
1017
+ surfaces: {
1018
+ components: [
1019
+ "components/project/*",
1020
+ "components/belief/*",
1021
+ "components/question/*",
1022
+ "components/research/*",
1023
+ "components/reports/*"
1024
+ ],
1025
+ convex: [
1026
+ "convex/themes.ts",
1027
+ "convex/projects.ts",
1028
+ "convex/thematicWorkflow.ts",
1029
+ "convex/reports.ts"
1030
+ ],
1031
+ tools: [
1032
+ "lib/ai/tools/belief-tools.ts",
1033
+ "lib/ai/tools/question-tools.ts",
1034
+ "lib/ai/tools/navigation-tools.ts"
1035
+ ]
1036
+ },
1037
+ policyProfile: {
1038
+ audiences: ["internal", "lp", "public"],
1039
+ rules: [
1040
+ { resource: "project", actions: ["read", "summarize", "mutate"] },
1041
+ { resource: "node", actions: ["read", "summarize", "mutate"] },
1042
+ { resource: "edge", actions: ["read", "mutate"] },
1043
+ { resource: "report_section", actions: ["read", "summarize", "export"] }
1044
+ ]
1045
+ },
1046
+ dataContract: {
1047
+ requiredNodeTypes: ["theme", "belief", "question", "evidence", "synthesis"],
1048
+ requiredEdgeTypes: ["belongs_to", "relates_to_thesis", "informs", "tests"],
1049
+ requiredTables: [
1050
+ "projects",
1051
+ "epistemicNodes",
1052
+ "epistemicEdges",
1053
+ "reports",
1054
+ "reportSections",
1055
+ "reportTemplates"
1056
+ ],
1057
+ projectionBehavior: "projection_required"
1058
+ },
1059
+ templates: {
1060
+ workflows: ["themes/default-lifecycle", "themes/worktree-thesis-loop"],
1061
+ prompts: [
1062
+ "thematic/extractor",
1063
+ "reports/thematic-long-form/thesis-statement",
1064
+ "reports/thematic-long-form/belief-map"
1065
+ ],
1066
+ reports: ["thematic-long-form", "knowledge-map"],
1067
+ uiLabels: ["theme", "belief", "question", "evidence", "conviction"]
1068
+ },
1069
+ testSuite: {
1070
+ parity: ["themes-v1-parity-against-current"],
1071
+ policy: ["theme-compilation-entitlement-filtering"],
1072
+ contract: ["themes-pack-contract-v1"]
1073
+ },
1074
+ sharedServices: [
1075
+ {
1076
+ service: "knowledge-compiler",
1077
+ mode: "required",
1078
+ contracts: ["knowledge-compiler-v1"]
1079
+ }
1080
+ ]
1081
+ });
1082
+
1083
+ // src/manifests/user-profiles-v1.ts
1084
+ var userProfilesV1Manifest = defineAppPackManifest({
1085
+ key: "user-profiles-v1",
1086
+ name: "User Profiles",
1087
+ version: "1.0.0",
1088
+ lifecycle: "active",
1089
+ category: "identity",
1090
+ description: "Individual cognition and operating profile layer including journey progression, archetypes, and behavioral telemetry.",
1091
+ dependencies: [],
1092
+ capabilityFlags: [
1093
+ "user.profile",
1094
+ "user.journey",
1095
+ "user.analytics",
1096
+ "voice.preferences"
1097
+ ],
1098
+ routeNamespace: {
1099
+ web: ["/(team)/team/[userId]"],
1100
+ api: ["/api/philosophy/get-profile", "/api/mobile/v1/session"]
1101
+ },
1102
+ surfaces: {
1103
+ components: [
1104
+ "components/user/*",
1105
+ "components/philosophy/ArchetypeDisplay.tsx"
1106
+ ],
1107
+ convex: [
1108
+ "convex/users.ts",
1109
+ "convex/userJourney.ts",
1110
+ "convex/userSessions.ts",
1111
+ "convex/userAnalytics.ts"
1112
+ ],
1113
+ tools: []
1114
+ },
1115
+ policyProfile: {
1116
+ audiences: ["internal", "tenant_admin"],
1117
+ rules: [
1118
+ {
1119
+ resource: "user_profile",
1120
+ actions: ["read", "mutate"],
1121
+ notes: "Users can edit self; tenant admins can read broader profiles."
1122
+ },
1123
+ { resource: "project", actions: ["read"] },
1124
+ { resource: "team_analytics", actions: ["read"] }
1125
+ ]
1126
+ },
1127
+ dataContract: {
1128
+ requiredNodeTypes: [],
1129
+ requiredEdgeTypes: [],
1130
+ requiredTables: [
1131
+ "users",
1132
+ "userEpistemicJourney",
1133
+ "userSessions",
1134
+ "investorProfiles",
1135
+ "investorProfileAtoms",
1136
+ "voiceProfiles",
1137
+ "userVoiceSettings",
1138
+ "archetypeHistory"
1139
+ ],
1140
+ projectionBehavior: "none"
1141
+ },
1142
+ templates: {
1143
+ workflows: ["user/profile-synthesis", "user/journey-update"],
1144
+ prompts: ["coaching/user-eval", "philosophy/profile-synthesis"],
1145
+ reports: ["user-profile-summary"],
1146
+ uiLabels: ["profile", "journey", "archetype", "calibration"]
1147
+ },
1148
+ testSuite: {
1149
+ parity: ["user-profile-page-parity"],
1150
+ policy: ["user-profile-self-vs-admin-access"],
1151
+ contract: ["user-profiles-pack-contract-v1"]
1152
+ },
1153
+ sharedServices: [
1154
+ {
1155
+ service: "knowledge-compiler",
1156
+ mode: "required",
1157
+ contracts: ["knowledge-compiler-v1"]
1158
+ }
1159
+ ]
1160
+ });
1161
+
1162
+ // src/manifests/index.ts
1163
+ var allAppPackManifests = [
1164
+ philosophyModeV1Manifest,
1165
+ chatV1Manifest,
1166
+ graphVisualizationV1Manifest,
1167
+ epistemicAlgorithmsV1Manifest,
1168
+ themesV1Manifest,
1169
+ dealsV1Manifest,
1170
+ decisionsV1Manifest,
1171
+ newsV1Manifest,
1172
+ documentsV1Manifest,
1173
+ userProfilesV1Manifest,
1174
+ teamAnalysisV1Manifest,
1175
+ taskManagementV1Manifest
1176
+ ];
1177
+ var manifestKeyPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+$/;
1178
+ var semverPattern = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;
1179
+ var appPackManifestSchema = z.object({
1180
+ key: z.string().regex(manifestKeyPattern),
1181
+ name: z.string().min(1),
1182
+ version: z.string().regex(semverPattern),
1183
+ lifecycle: z.enum(["active", "beta", "experimental"]),
1184
+ category: z.enum([
1185
+ "conversation",
1186
+ "research",
1187
+ "graph",
1188
+ "analytics",
1189
+ "workflow",
1190
+ "decision",
1191
+ "news",
1192
+ "documents",
1193
+ "identity",
1194
+ "operations",
1195
+ "domain"
1196
+ ]),
1197
+ description: z.string().min(1),
1198
+ dependencies: z.array(z.string().min(1)),
1199
+ capabilityFlags: z.array(z.string().min(1)),
1200
+ routeNamespace: z.object({
1201
+ web: z.array(z.string().min(1)),
1202
+ api: z.array(z.string().min(1))
1203
+ }),
1204
+ surfaces: z.object({
1205
+ components: z.array(z.string().min(1)),
1206
+ convex: z.array(z.string().min(1)),
1207
+ tools: z.array(z.string().min(1))
1208
+ }),
1209
+ policyProfile: z.object({
1210
+ audiences: z.array(z.string().min(1)).min(1),
1211
+ rules: z.array(
1212
+ z.object({
1213
+ resource: z.enum([
1214
+ "project",
1215
+ "node",
1216
+ "edge",
1217
+ "artifact",
1218
+ "report_section",
1219
+ "tool_action",
1220
+ "task",
1221
+ "user_profile",
1222
+ "team_analytics"
1223
+ ]),
1224
+ actions: z.array(z.enum(["read", "summarize", "export", "mutate", "admin"])).min(1),
1225
+ notes: z.string().optional()
1226
+ })
1227
+ ).min(1)
1228
+ }),
1229
+ dataContract: z.object({
1230
+ requiredNodeTypes: z.array(z.string().min(1)),
1231
+ requiredEdgeTypes: z.array(z.string().min(1)),
1232
+ requiredTables: z.array(z.string().min(1)).min(1),
1233
+ projectionBehavior: z.enum([
1234
+ "none",
1235
+ "inherits_policy",
1236
+ "projection_required"
1237
+ ])
1238
+ }),
1239
+ templates: z.object({
1240
+ workflows: z.array(z.string().min(1)),
1241
+ prompts: z.array(z.string().min(1)),
1242
+ reports: z.array(z.string().min(1)),
1243
+ uiLabels: z.array(z.string().min(1))
1244
+ }),
1245
+ testSuite: z.object({
1246
+ parity: z.array(z.string().min(1)).min(1),
1247
+ policy: z.array(z.string().min(1)).min(1),
1248
+ contract: z.array(z.string().min(1)).min(1)
1249
+ }),
1250
+ sharedServices: z.array(
1251
+ z.object({
1252
+ service: z.enum([
1253
+ "decision-kernel",
1254
+ "knowledge-compiler",
1255
+ "learning-loop"
1256
+ ]),
1257
+ mode: z.enum(["required", "optional"]),
1258
+ contracts: z.array(z.string().min(1)).min(1)
1259
+ })
1260
+ )
1261
+ });
1262
+ function toIssue2(code, message, path, severity = "error") {
1263
+ return {
1264
+ code,
1265
+ severity,
1266
+ message,
1267
+ path
1268
+ };
1269
+ }
1270
+ function collectDuplicateValues(values) {
1271
+ const counts = /* @__PURE__ */ new Map();
1272
+ for (const value of values) {
1273
+ counts.set(value, (counts.get(value) ?? 0) + 1);
1274
+ }
1275
+ return [...counts.entries()].filter(([, count]) => count > 1).map(([value]) => value).sort();
1276
+ }
1277
+ function collectUnknownValues(values, knownValues) {
1278
+ const known = new Set(knownValues);
1279
+ return values.filter((value) => !known.has(value));
1280
+ }
1281
+ function validateManifestShape(manifest) {
1282
+ const parsed = appPackManifestSchema.safeParse(manifest);
1283
+ if (parsed.success) {
1284
+ return [];
1285
+ }
1286
+ return parsed.error.issues.map(
1287
+ (issue) => toIssue2(
1288
+ "PACK_MANIFEST_SCHEMA_INVALID",
1289
+ issue.message,
1290
+ issue.path.join(".") || "(root)"
1291
+ )
1292
+ );
1293
+ }
1294
+ function validateManifestUniqueness(manifest) {
1295
+ const issues = [];
1296
+ const duplicateDependencies = collectDuplicateValues(manifest.dependencies);
1297
+ if (duplicateDependencies.length > 0) {
1298
+ issues.push(
1299
+ toIssue2(
1300
+ "PACK_DEPENDENCIES_DUPLICATE",
1301
+ `Duplicate dependencies declared: ${duplicateDependencies.join(", ")}`,
1302
+ "dependencies"
1303
+ )
1304
+ );
1305
+ }
1306
+ if (manifest.dependencies.includes(manifest.key)) {
1307
+ issues.push(
1308
+ toIssue2(
1309
+ "PACK_DEPENDENCY_SELF_REFERENCE",
1310
+ `Pack "${manifest.key}" cannot depend on itself.`,
1311
+ "dependencies"
1312
+ )
1313
+ );
1314
+ }
1315
+ const duplicateCapabilities = collectDuplicateValues(
1316
+ manifest.capabilityFlags
1317
+ );
1318
+ if (duplicateCapabilities.length > 0) {
1319
+ issues.push(
1320
+ toIssue2(
1321
+ "PACK_CAPABILITIES_DUPLICATE",
1322
+ `Duplicate capability flags declared: ${duplicateCapabilities.join(", ")}`,
1323
+ "capabilityFlags"
1324
+ )
1325
+ );
1326
+ }
1327
+ const duplicateWebRoutes = collectDuplicateValues(
1328
+ manifest.routeNamespace.web
1329
+ );
1330
+ if (duplicateWebRoutes.length > 0) {
1331
+ issues.push(
1332
+ toIssue2(
1333
+ "PACK_WEB_ROUTES_DUPLICATE",
1334
+ `Duplicate web routes declared: ${duplicateWebRoutes.join(", ")}`,
1335
+ "routeNamespace.web"
1336
+ )
1337
+ );
1338
+ }
1339
+ const duplicateApiRoutes = collectDuplicateValues(
1340
+ manifest.routeNamespace.api
1341
+ );
1342
+ if (duplicateApiRoutes.length > 0) {
1343
+ issues.push(
1344
+ toIssue2(
1345
+ "PACK_API_ROUTES_DUPLICATE",
1346
+ `Duplicate api routes declared: ${duplicateApiRoutes.join(", ")}`,
1347
+ "routeNamespace.api"
1348
+ )
1349
+ );
1350
+ }
1351
+ const duplicateServices = collectDuplicateValues(
1352
+ manifest.sharedServices.map((integration) => integration.service)
1353
+ );
1354
+ if (duplicateServices.length > 0) {
1355
+ issues.push(
1356
+ toIssue2(
1357
+ "PACK_SHARED_SERVICE_DUPLICATE",
1358
+ `Duplicate shared-service integrations declared: ${duplicateServices.join(", ")}`,
1359
+ "sharedServices"
1360
+ )
1361
+ );
1362
+ }
1363
+ return issues;
1364
+ }
1365
+ function validateManifestDictionary(manifest, dictionary) {
1366
+ if (!dictionary) {
1367
+ return [];
1368
+ }
1369
+ const issues = [];
1370
+ const unknownNodeTypes = collectUnknownValues(
1371
+ manifest.dataContract.requiredNodeTypes,
1372
+ dictionary.nodeTypes
1373
+ );
1374
+ const unknownEdgeTypes = collectUnknownValues(
1375
+ manifest.dataContract.requiredEdgeTypes,
1376
+ dictionary.edgeTypes
1377
+ );
1378
+ const unknownTables = collectUnknownValues(
1379
+ manifest.dataContract.requiredTables,
1380
+ dictionary.tables
1381
+ );
1382
+ if (unknownNodeTypes.length > 0) {
1383
+ issues.push(
1384
+ toIssue2(
1385
+ "PACK_UNKNOWN_NODE_TYPES",
1386
+ `Unknown required node types: ${unknownNodeTypes.join(", ")}`,
1387
+ "dataContract.requiredNodeTypes"
1388
+ )
1389
+ );
1390
+ }
1391
+ if (unknownEdgeTypes.length > 0) {
1392
+ issues.push(
1393
+ toIssue2(
1394
+ "PACK_UNKNOWN_EDGE_TYPES",
1395
+ `Unknown required edge types: ${unknownEdgeTypes.join(", ")}`,
1396
+ "dataContract.requiredEdgeTypes"
1397
+ )
1398
+ );
1399
+ }
1400
+ if (unknownTables.length > 0) {
1401
+ issues.push(
1402
+ toIssue2(
1403
+ "PACK_UNKNOWN_TABLES",
1404
+ `Unknown required tables: ${unknownTables.join(", ")}`,
1405
+ "dataContract.requiredTables"
1406
+ )
1407
+ );
1408
+ }
1409
+ return issues;
1410
+ }
1411
+ function validateAppPackManifest(manifest, dictionary) {
1412
+ const issues = [
1413
+ ...validateManifestShape(manifest),
1414
+ ...validateManifestUniqueness(manifest),
1415
+ ...validateManifestDictionary(manifest, dictionary)
1416
+ ];
1417
+ return {
1418
+ manifestKey: manifest.key,
1419
+ valid: issues.every((issue) => issue.severity !== "error"),
1420
+ issues
1421
+ };
1422
+ }
1423
+
1424
+ // src/namespacePolicy.ts
1425
+ var PACK_NAMESPACE_COLLISION_ALLOWLIST = [
1426
+ {
1427
+ surface: "web",
1428
+ namespace: "/(chat)/chat/[id]",
1429
+ allowedPackKeys: ["chat-v1", "philosophy-mode-v1"],
1430
+ rationale: "Philosophy mode extends the chat surface and intentionally shares the chat detail route."
1431
+ },
1432
+ {
1433
+ surface: "web",
1434
+ namespace: "/(projects)/projects",
1435
+ allowedPackKeys: ["deals-v1", "themes-v1"],
1436
+ rationale: "Deals and themes intentionally share the topic index shell mounted under the legacy /projects customer-zero shell."
1437
+ },
1438
+ {
1439
+ surface: "web",
1440
+ namespace: "/(projects)/projects/[projectId]",
1441
+ allowedPackKeys: ["deals-v1", "themes-v1"],
1442
+ rationale: "Deals and themes intentionally share topic detail shell routing while the outer customer-zero shell still uses legacy project path segments."
1443
+ },
1444
+ {
1445
+ surface: "api",
1446
+ namespace: "/api/philosophy/get-profile",
1447
+ allowedPackKeys: ["philosophy-mode-v1", "user-profiles-v1"],
1448
+ rationale: "User profiles and philosophy mode share profile retrieval endpoint for compatibility."
1449
+ },
1450
+ {
1451
+ surface: "api",
1452
+ namespace: "/api/research/*",
1453
+ allowedPackKeys: ["deals-v1", "themes-v1"],
1454
+ rationale: "Deals and themes share research API namespace until productized API gateway split."
1455
+ },
1456
+ {
1457
+ surface: "api",
1458
+ namespace: "/api/reports/*",
1459
+ allowedPackKeys: ["deals-v1", "decisions-v1", "themes-v1"],
1460
+ rationale: "Domain packs intentionally consume shared report compiler endpoints in the same namespace."
1461
+ }
1462
+ ];
1463
+ function toIssue3(code, message, path, severity = "error") {
1464
+ return {
1465
+ code,
1466
+ severity,
1467
+ message,
1468
+ path
1469
+ };
1470
+ }
1471
+ function normalizeKeySet(values) {
1472
+ return [...new Set(values)].sort().join("|");
1473
+ }
1474
+ function detectNamespaceCollisions(manifests) {
1475
+ const collisions = [];
1476
+ for (const surface of ["web", "api"]) {
1477
+ const namespaceToPacks = /* @__PURE__ */ new Map();
1478
+ for (const manifest of manifests) {
1479
+ const namespaces = manifest.routeNamespace[surface];
1480
+ for (const namespace of namespaces) {
1481
+ const existing = namespaceToPacks.get(namespace) ?? [];
1482
+ existing.push(manifest.key);
1483
+ namespaceToPacks.set(namespace, existing);
1484
+ }
1485
+ }
1486
+ for (const [namespace, packKeys] of namespaceToPacks.entries()) {
1487
+ if (packKeys.length <= 1) {
1488
+ continue;
1489
+ }
1490
+ collisions.push({
1491
+ surface,
1492
+ namespace,
1493
+ packKeys: [...new Set(packKeys)].sort()
1494
+ });
1495
+ }
1496
+ }
1497
+ return collisions.sort((left, right) => {
1498
+ if (left.surface !== right.surface) {
1499
+ return left.surface.localeCompare(right.surface);
1500
+ }
1501
+ return left.namespace.localeCompare(right.namespace);
1502
+ });
1503
+ }
1504
+ function validatePackNamespacePolicies(manifests) {
1505
+ const issues = [];
1506
+ const collisions = detectNamespaceCollisions(manifests);
1507
+ const allowlistByKey = /* @__PURE__ */ new Map();
1508
+ for (const entry of PACK_NAMESPACE_COLLISION_ALLOWLIST) {
1509
+ const key = `${entry.surface}:${entry.namespace}`;
1510
+ if (allowlistByKey.has(key)) {
1511
+ issues.push(
1512
+ toIssue3(
1513
+ "PACK_NAMESPACE_ALLOWLIST_DUPLICATE",
1514
+ `Duplicate allowlist entry for ${key}.`,
1515
+ "namespacePolicy.allowlist"
1516
+ )
1517
+ );
1518
+ continue;
1519
+ }
1520
+ allowlistByKey.set(key, entry);
1521
+ }
1522
+ for (const collision of collisions) {
1523
+ const key = `${collision.surface}:${collision.namespace}`;
1524
+ const allowlistEntry = allowlistByKey.get(key);
1525
+ if (!allowlistEntry) {
1526
+ issues.push(
1527
+ toIssue3(
1528
+ "PACK_NAMESPACE_COLLISION_UNAPPROVED",
1529
+ `Unapproved ${collision.surface} namespace collision for "${collision.namespace}" across packs: ${collision.packKeys.join(", ")}`,
1530
+ `namespacePolicy.${collision.surface}`
1531
+ )
1532
+ );
1533
+ continue;
1534
+ }
1535
+ const collidedSet = normalizeKeySet(collision.packKeys);
1536
+ const allowedSet = normalizeKeySet(allowlistEntry.allowedPackKeys);
1537
+ if (collidedSet !== allowedSet) {
1538
+ issues.push(
1539
+ toIssue3(
1540
+ "PACK_NAMESPACE_COLLISION_MISMATCH",
1541
+ `Collision set mismatch for "${collision.namespace}". collided=${collidedSet} allowlist=${allowedSet}`,
1542
+ `namespacePolicy.${collision.surface}`
1543
+ )
1544
+ );
1545
+ }
1546
+ }
1547
+ return issues;
1548
+ }
1549
+
1550
+ // src/serviceContracts.ts
1551
+ function hasSharedService(manifest, service) {
1552
+ return manifest.sharedServices.some(
1553
+ (integration) => integration.service === service
1554
+ );
1555
+ }
1556
+ function hasDecisionIntegrationSignals(manifest) {
1557
+ if (manifest.category === "decision") {
1558
+ return true;
1559
+ }
1560
+ return manifest.capabilityFlags.some(
1561
+ (flag) => flag.startsWith("decision.") || flag.includes("decision.integration")
1562
+ );
1563
+ }
1564
+ function hasReportIntegrationSignals(manifest) {
1565
+ if (manifest.templates.reports.length > 0) {
1566
+ return true;
1567
+ }
1568
+ return manifest.routeNamespace.api.some(
1569
+ (namespace) => namespace.includes("/api/reports")
1570
+ );
1571
+ }
1572
+ function hasLearningIntegrationSignals(manifest) {
1573
+ return manifest.capabilityFlags.some(
1574
+ (flag) => flag.startsWith("learning.") || flag.includes("policy.injection") || flag.includes("adaptive-learning")
1575
+ );
1576
+ }
1577
+ function validatePackSharedServiceContracts(manifests) {
1578
+ const issues = [];
1579
+ for (const manifest of manifests) {
1580
+ if (hasReportIntegrationSignals(manifest) && !hasSharedService(manifest, "knowledge-compiler")) {
1581
+ issues.push({
1582
+ packKey: manifest.key,
1583
+ service: "knowledge-compiler",
1584
+ severity: "error",
1585
+ code: "PACK_REPORT_SERVICE_MISSING",
1586
+ message: "Pack declares report outputs/routes but is missing knowledge-compiler shared service integration."
1587
+ });
1588
+ }
1589
+ if (hasDecisionIntegrationSignals(manifest) && !hasSharedService(manifest, "decision-kernel")) {
1590
+ issues.push({
1591
+ packKey: manifest.key,
1592
+ service: "decision-kernel",
1593
+ severity: "error",
1594
+ code: "PACK_DECISION_SERVICE_MISSING",
1595
+ message: "Pack declares decision behavior but is missing decision-kernel shared service integration."
1596
+ });
1597
+ }
1598
+ if (hasLearningIntegrationSignals(manifest) && !hasSharedService(manifest, "learning-loop")) {
1599
+ issues.push({
1600
+ packKey: manifest.key,
1601
+ service: "learning-loop",
1602
+ severity: "error",
1603
+ code: "PACK_LEARNING_SERVICE_MISSING",
1604
+ message: "Pack declares adaptive learning behavior but is missing learning-loop shared service integration."
1605
+ });
1606
+ }
1607
+ }
1608
+ return issues;
1609
+ }
1610
+
1611
+ // src/runtime.ts
1612
+ function toIssue4(code, message, path, severity = "error") {
1613
+ return {
1614
+ code,
1615
+ severity,
1616
+ message,
1617
+ path
1618
+ };
1619
+ }
1620
+ function validateRegistryIdentity(manifests) {
1621
+ const issues = [];
1622
+ const keyCounts = /* @__PURE__ */ new Map();
1623
+ const identityCounts = /* @__PURE__ */ new Map();
1624
+ for (const manifest of manifests) {
1625
+ keyCounts.set(manifest.key, (keyCounts.get(manifest.key) ?? 0) + 1);
1626
+ const identity = `${manifest.key}@${manifest.version}`;
1627
+ identityCounts.set(identity, (identityCounts.get(identity) ?? 0) + 1);
1628
+ }
1629
+ for (const [key, count] of keyCounts.entries()) {
1630
+ if (count > 1) {
1631
+ issues.push(
1632
+ toIssue4(
1633
+ "PACK_KEY_DUPLICATE",
1634
+ `Duplicate pack key registered: ${key}`,
1635
+ "registry.keys"
1636
+ )
1637
+ );
1638
+ }
1639
+ }
1640
+ for (const [identity, count] of identityCounts.entries()) {
1641
+ if (count > 1) {
1642
+ issues.push(
1643
+ toIssue4(
1644
+ "PACK_VERSION_DUPLICATE",
1645
+ `Duplicate pack identity registered: ${identity}`,
1646
+ "registry.versions"
1647
+ )
1648
+ );
1649
+ }
1650
+ }
1651
+ return issues;
1652
+ }
1653
+ function validatePackRegistry(manifests, dictionary) {
1654
+ const manifestResults = manifests.map(
1655
+ (manifest) => validateAppPackManifest(manifest, dictionary)
1656
+ );
1657
+ const dependencyResult = resolvePackDependencyGraph(manifests);
1658
+ const sharedServiceIssues = validatePackSharedServiceContracts(manifests).map(
1659
+ (issue) => toIssue4(
1660
+ issue.code,
1661
+ `[${issue.packKey}] ${issue.message}`,
1662
+ `sharedServices:${issue.packKey}`,
1663
+ issue.severity
1664
+ )
1665
+ );
1666
+ const namespaceIssues = validatePackNamespacePolicies(manifests);
1667
+ const issues = [
1668
+ ...validateRegistryIdentity(manifests),
1669
+ ...manifestResults.flatMap((result) => result.issues),
1670
+ ...dependencyResult.issues,
1671
+ ...sharedServiceIssues,
1672
+ ...namespaceIssues
1673
+ ];
1674
+ return {
1675
+ valid: issues.every((issue) => issue.severity !== "error"),
1676
+ manifestResults,
1677
+ dependencyOrder: dependencyResult.orderedPackKeys,
1678
+ dependencyClosureByPack: dependencyResult.dependencyClosureByPack,
1679
+ issues
1680
+ };
1681
+ }
1682
+
1683
+ // src/registry.ts
1684
+ var appPackRegistry = allAppPackManifests.reduce(
1685
+ (acc, manifest) => {
1686
+ acc[manifest.key] = manifest;
1687
+ return acc;
1688
+ },
1689
+ {}
1690
+ );
1691
+ function getAppPackManifest(key) {
1692
+ return appPackRegistry[key] ?? null;
1693
+ }
1694
+ function listAppPackManifests() {
1695
+ return allAppPackManifests;
1696
+ }
1697
+ function getDependencyClosure(packKey) {
1698
+ const resolution = resolvePackDependencyGraph(allAppPackManifests);
1699
+ return resolution.dependencyClosureByPack[packKey] ?? [];
1700
+ }
1701
+ function validateAppPackRegistry(dictionary) {
1702
+ return validatePackRegistry(allAppPackManifests, dictionary);
1703
+ }
1704
+ function evaluateAppPackEnablement(policy = {}) {
1705
+ return evaluateCatalogEnablement(appPackRegistry, policy);
1706
+ }
1707
+
1708
+ export { appPackRegistry, evaluateAppPackEnablement, getAppPackManifest, getDependencyClosure, listAppPackManifests, validateAppPackRegistry };
1709
+ //# sourceMappingURL=registry.js.map
1710
+ //# sourceMappingURL=registry.js.map