@lucern/sdk 0.2.0-alpha.5 → 0.2.0-alpha.7

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 (166) hide show
  1. package/.turbo/turbo-build.log +7 -0
  2. package/.turbo/turbo-typecheck.log +4 -0
  3. package/CHANGELOG.md +13 -0
  4. package/examples/README.md +69 -0
  5. package/examples/contradiction.ts +94 -0
  6. package/examples/investigation-context.ts +118 -0
  7. package/examples/questions-and-tasks.ts +55 -0
  8. package/examples/quickstart.ts +97 -0
  9. package/examples/shared.ts +318 -0
  10. package/examples/strict-public-types.ts +143 -0
  11. package/examples/worktree-lifecycle.ts +79 -0
  12. package/package.json +16 -59
  13. package/src/README.md +6 -0
  14. package/src/adminClient.ts +789 -0
  15. package/{dist/lib/platform/sdk/answersClient.d.ts → src/answersClient.ts} +17 -4
  16. package/src/audiencesClient.ts +209 -0
  17. package/src/auditClient.ts +50 -0
  18. package/src/beliefsClient.ts +319 -0
  19. package/src/client.ts +2647 -0
  20. package/src/contextClient.ts +130 -0
  21. package/src/contextFacade.ts +15 -0
  22. package/src/contextPackCompiler.ts +828 -0
  23. package/src/contextPackSchema.ts +251 -0
  24. package/src/contextTypes.ts +153 -0
  25. package/src/contracts/api-enums.contract.ts +202 -0
  26. package/src/contracts/auth-session.contract.ts +109 -0
  27. package/src/contracts/context-pack.contract.ts +700 -0
  28. package/src/contracts/contextPack.ts +1 -0
  29. package/src/contracts/index.ts +10 -0
  30. package/src/contracts/lens-filter.contract.ts +183 -0
  31. package/src/contracts/lens-workflow.contract.ts +162 -0
  32. package/src/contracts/lensFilter.ts +1 -0
  33. package/src/contracts/lensWorkflow.ts +1 -0
  34. package/src/contracts/mcp-tools.contract.ts +3636 -0
  35. package/src/contracts/mcpTools.ts +1 -0
  36. package/src/contracts/prompt.contract.ts +50 -0
  37. package/src/contracts/prompt.ts +1 -0
  38. package/src/contracts/sdk-tools.contract.ts +1457 -0
  39. package/src/contracts/sdkTools.ts +1 -0
  40. package/src/contracts/workflow-runtime.contract.ts +440 -0
  41. package/src/contracts/workflowRuntime.ts +1 -0
  42. package/src/controlObjectOwnership.ts +286 -0
  43. package/src/coreClient.ts +570 -0
  44. package/src/customTools.ts +398 -0
  45. package/src/decisionsClient.ts +286 -0
  46. package/src/domainContext.ts +15 -0
  47. package/src/events.ts +531 -0
  48. package/src/eventsCore.ts +168 -0
  49. package/src/facade/beliefs.ts +83 -0
  50. package/src/facade/context.ts +110 -0
  51. package/src/facade/contradictions.ts +29 -0
  52. package/src/facade/edges.ts +30 -0
  53. package/src/facade/events.ts +23 -0
  54. package/src/facade/evidence.ts +41 -0
  55. package/src/facade/graph.ts +38 -0
  56. package/src/facade/identity.ts +16 -0
  57. package/src/facade/ontologies.ts +34 -0
  58. package/src/facade/questions.ts +59 -0
  59. package/src/facade/search.ts +16 -0
  60. package/src/facade/tasks.ts +37 -0
  61. package/src/facade/topics.ts +42 -0
  62. package/src/facade/webhooks.ts +58 -0
  63. package/src/facade/worktrees.ts +51 -0
  64. package/src/gatewayFacades.ts +1666 -0
  65. package/src/graphClient.ts +529 -0
  66. package/src/harnessClient.ts +585 -0
  67. package/src/identityClient.ts +278 -0
  68. package/{dist/lib/platform/sdk/index.d.ts → src/index.ts} +3 -0
  69. package/src/learningClient.ts +95 -0
  70. package/src/mcpParityClient.ts +240 -0
  71. package/src/mcpParitySurface.ts +70 -0
  72. package/src/ontologyClient.ts +275 -0
  73. package/src/packRuntime.ts +3 -0
  74. package/src/packsClient.ts +260 -0
  75. package/src/policyClient.ts +572 -0
  76. package/src/promptCatalog.ts +1 -0
  77. package/src/realtime/index.ts +51 -0
  78. package/src/realtime/refs.ts +17 -0
  79. package/src/reportsClient.ts +99 -0
  80. package/src/schemaClient.ts +129 -0
  81. package/src/sdkSurface.ts +190 -0
  82. package/src/topicsClient.ts +243 -0
  83. package/src/types.ts +807 -0
  84. package/src/workflowClient.ts +826 -0
  85. package/tsconfig.json +9 -0
  86. package/dist/.generated +0 -2
  87. package/dist/index.d.ts +0 -3
  88. package/dist/index.js +0 -3
  89. package/dist/lib/platform/auth/credentials.d.ts +0 -5
  90. package/dist/lib/platform/auth/credentials.js +0 -40
  91. package/dist/lib/platform/sdk/adminClient.d.ts +0 -404
  92. package/dist/lib/platform/sdk/adminClient.js +0 -384
  93. package/dist/lib/platform/sdk/answersClient.js +0 -21
  94. package/dist/lib/platform/sdk/audiencesClient.d.ts +0 -93
  95. package/dist/lib/platform/sdk/audiencesClient.js +0 -111
  96. package/dist/lib/platform/sdk/auditClient.d.ts +0 -24
  97. package/dist/lib/platform/sdk/auditClient.js +0 -21
  98. package/dist/lib/platform/sdk/beliefsClient.d.ts +0 -157
  99. package/dist/lib/platform/sdk/beliefsClient.js +0 -124
  100. package/dist/lib/platform/sdk/client.d.ts +0 -2369
  101. package/dist/lib/platform/sdk/client.js +0 -1831
  102. package/dist/lib/platform/sdk/contextClient.d.ts +0 -21
  103. package/dist/lib/platform/sdk/contextClient.js +0 -86
  104. package/dist/lib/platform/sdk/contextPackCompiler.d.ts +0 -100
  105. package/dist/lib/platform/sdk/contextPackCompiler.js +0 -534
  106. package/dist/lib/platform/sdk/contextTypes.d.ts +0 -133
  107. package/dist/lib/platform/sdk/contextTypes.js +0 -1
  108. package/dist/lib/platform/sdk/controlObjectOwnership.d.ts +0 -308
  109. package/dist/lib/platform/sdk/controlObjectOwnership.js +0 -220
  110. package/dist/lib/platform/sdk/coreClient.d.ts +0 -139
  111. package/dist/lib/platform/sdk/coreClient.js +0 -366
  112. package/dist/lib/platform/sdk/customTools.d.ts +0 -83
  113. package/dist/lib/platform/sdk/customTools.js +0 -247
  114. package/dist/lib/platform/sdk/decisionsClient.d.ts +0 -106
  115. package/dist/lib/platform/sdk/decisionsClient.js +0 -129
  116. package/dist/lib/platform/sdk/domainContext.d.ts +0 -1
  117. package/dist/lib/platform/sdk/domainContext.js +0 -1
  118. package/dist/lib/platform/sdk/events.d.ts +0 -176
  119. package/dist/lib/platform/sdk/events.js +0 -261
  120. package/dist/lib/platform/sdk/gatewayFacades.d.ts +0 -586
  121. package/dist/lib/platform/sdk/gatewayFacades.js +0 -845
  122. package/dist/lib/platform/sdk/graphClient.d.ts +0 -266
  123. package/dist/lib/platform/sdk/graphClient.js +0 -235
  124. package/dist/lib/platform/sdk/harnessClient.d.ts +0 -309
  125. package/dist/lib/platform/sdk/harnessClient.js +0 -219
  126. package/dist/lib/platform/sdk/identityClient.d.ts +0 -134
  127. package/dist/lib/platform/sdk/identityClient.js +0 -131
  128. package/dist/lib/platform/sdk/index.js +0 -46
  129. package/dist/lib/platform/sdk/learningClient.d.ts +0 -40
  130. package/dist/lib/platform/sdk/learningClient.js +0 -53
  131. package/dist/lib/platform/sdk/mcpParityClient.d.ts +0 -69
  132. package/dist/lib/platform/sdk/mcpParityClient.js +0 -196
  133. package/dist/lib/platform/sdk/mcpParitySurface.d.ts +0 -10
  134. package/dist/lib/platform/sdk/mcpParitySurface.js +0 -57
  135. package/dist/lib/platform/sdk/ontologyClient.d.ts +0 -131
  136. package/dist/lib/platform/sdk/ontologyClient.js +0 -161
  137. package/dist/lib/platform/sdk/packRuntime.d.ts +0 -1
  138. package/dist/lib/platform/sdk/packRuntime.js +0 -1
  139. package/dist/lib/platform/sdk/packsClient.d.ts +0 -126
  140. package/dist/lib/platform/sdk/packsClient.js +0 -157
  141. package/dist/lib/platform/sdk/policyClient.d.ts +0 -293
  142. package/dist/lib/platform/sdk/policyClient.js +0 -277
  143. package/dist/lib/platform/sdk/promptCatalog.d.ts +0 -1
  144. package/dist/lib/platform/sdk/promptCatalog.js +0 -1
  145. package/dist/lib/platform/sdk/reportsClient.d.ts +0 -34
  146. package/dist/lib/platform/sdk/reportsClient.js +0 -64
  147. package/dist/lib/platform/sdk/schemaClient.d.ts +0 -59
  148. package/dist/lib/platform/sdk/schemaClient.js +0 -71
  149. package/dist/lib/platform/sdk/sdkSurface.d.ts +0 -56
  150. package/dist/lib/platform/sdk/sdkSurface.js +0 -140
  151. package/dist/lib/platform/sdk/topicsClient.d.ts +0 -78
  152. package/dist/lib/platform/sdk/topicsClient.js +0 -118
  153. package/dist/lib/platform/sdk/types.d.ts +0 -692
  154. package/dist/lib/platform/sdk/types.js +0 -1
  155. package/dist/lib/platform/sdk/version.d.ts +0 -2
  156. package/dist/lib/platform/sdk/workflowClient.d.ts +0 -313
  157. package/dist/lib/platform/sdk/workflowClient.js +0 -366
  158. package/dist/lucern/contracts/src/api-enums.contract.d.ts +0 -58
  159. package/dist/lucern/contracts/src/api-enums.contract.js +0 -147
  160. package/dist/lucern/contracts/src/lens-filter.contract.d.ts +0 -70
  161. package/dist/lucern/contracts/src/lens-filter.contract.js +0 -95
  162. package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +0 -84
  163. package/dist/lucern/contracts/src/lens-workflow.contract.js +0 -54
  164. package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +0 -151
  165. package/dist/lucern/contracts/src/mcp-tools.contract.js +0 -3281
  166. /package/{dist/lib/platform/sdk/version.js → src/version.ts} +0 -0
@@ -1,58 +0,0 @@
1
- /**
2
- * API Enum Contract Definitions
3
- *
4
- * Canonical enum values for all API-facing enumerations.
5
- * These are co-equal with MCP contracts as external contracts.
6
- * SDK types are DERIVED from these — not independently authored.
7
- *
8
- * CONTRACT SURFACE: Adding a new enum value is additive (non-breaking).
9
- * Removing or renaming an existing value is a BREAKING CHANGE.
10
- */
11
- /** Fork reasons — why a scored belief was branched */
12
- export declare const FORK_REASONS: readonly ["refinement", "contradiction_response", "scope_change", "confidence_collapse", "manual"];
13
- export type ForkReason = (typeof FORK_REASONS)[number];
14
- /** Confidence modulation triggers — what caused a confidence change */
15
- export declare const CONFIDENCE_TRIGGERS: readonly ["evidence_added", "contradiction_detected", "merge_outcome", "manual", "decay"];
16
- export type ConfidenceTrigger = (typeof CONFIDENCE_TRIGGERS)[number];
17
- /** Belief status — lifecycle state */
18
- export declare const BELIEF_STATUSES: readonly ["unscored", "scored", "archived"];
19
- export type BeliefStatus = (typeof BELIEF_STATUSES)[number];
20
- /** Reasoning methods — how an edge relationship was determined */
21
- export declare const REASONING_METHODS: readonly ["deductive", "inductive", "abductive", "analogical", "empirical"];
22
- export type ReasoningMethod = (typeof REASONING_METHODS)[number];
23
- /** Defeat types (Pollock taxonomy) — how a contradiction operates */
24
- export declare const DEFEAT_TYPES: readonly ["rebuts", "undercuts", "undermines"];
25
- export type DefeatType = (typeof DEFEAT_TYPES)[number];
26
- /** Contradiction severity levels */
27
- export declare const CONTRADICTION_SEVERITIES: readonly ["low", "medium", "high", "critical"];
28
- export type ContradictionSeverity = (typeof CONTRADICTION_SEVERITIES)[number];
29
- /** Contradiction resolution status */
30
- export declare const CONTRADICTION_STATUSES: readonly ["unresolved", "resolved", "accepted"];
31
- export type ContradictionStatus = (typeof CONTRADICTION_STATUSES)[number];
32
- /** Merge outcome types — how a worktree merge resolved */
33
- export declare const MERGE_OUTCOMES: readonly ["validated", "invalidated", "forked", "inconclusive"];
34
- export type MergeOutcome = (typeof MERGE_OUTCOMES)[number];
35
- /** Worktree phases — investigation lifecycle within a checked-out worktree */
36
- export declare const WORKTREE_PHASES: readonly ["hypothesis", "investigation", "evaluation", "resolution"];
37
- export type WorktreePhase = (typeof WORKTREE_PHASES)[number];
38
- /** Branch status — thematic branch lifecycle */
39
- export declare const BRANCH_STATUSES: readonly ["dormant", "active", "archived"];
40
- export type BranchStatus = (typeof BRANCH_STATUSES)[number];
41
- /** Pull request status — review lifecycle before merge */
42
- export declare const PULL_REQUEST_STATUSES: readonly ["pending_review", "changes_requested", "approved", "blocked"];
43
- export type PullRequestStatus = (typeof PULL_REQUEST_STATUSES)[number];
44
- /** Epistemic layers — the hierarchy of knowledge */
45
- export declare const EPISTEMIC_LAYERS: readonly ["L1", "L2", "L3", "L4"];
46
- export type EpistemicLayer = (typeof EPISTEMIC_LAYERS)[number];
47
- /**
48
- * Judgment type — classification of the determination.
49
- *
50
- * Phase 1: These are new enum values for the Judgment (L4) vocabulary.
51
- * The existing code uses "Decision" — these are the forward-looking terms
52
- * that will eventually replace the Decision vocabulary (Phase 2-3).
53
- */
54
- export declare const JUDGMENT_TYPES: readonly ["investment_thesis", "thesis_maturity", "contradiction_ruling", "scope_determination", "confidence_ruling"];
55
- export type JudgmentType = (typeof JUDGMENT_TYPES)[number];
56
- /** Core edge types used in the Integration Surfaces */
57
- export declare const INTEGRATION_EDGE_TYPES: readonly ["informs", "grounds", "answers", "contradicts", "supports", "depends_on", "derived_from", "contains", "supersedes", "tests"];
58
- export type IntegrationEdgeType = (typeof INTEGRATION_EDGE_TYPES)[number];
@@ -1,147 +0,0 @@
1
- /**
2
- * API Enum Contract Definitions
3
- *
4
- * Canonical enum values for all API-facing enumerations.
5
- * These are co-equal with MCP contracts as external contracts.
6
- * SDK types are DERIVED from these — not independently authored.
7
- *
8
- * CONTRACT SURFACE: Adding a new enum value is additive (non-breaking).
9
- * Removing or renaming an existing value is a BREAKING CHANGE.
10
- */
11
- // =============================================================================
12
- // BELIEF ENUMS
13
- // =============================================================================
14
- /** Fork reasons — why a scored belief was branched */
15
- export const FORK_REASONS = [
16
- "refinement", // Belief text evolved based on new understanding
17
- "contradiction_response", // Created in response to a detected contradiction
18
- "scope_change", // Belief scope narrowed or broadened
19
- "confidence_collapse", // Confidence dropped below viability threshold
20
- "manual", // User-initiated fork without specific trigger
21
- ];
22
- /** Confidence modulation triggers — what caused a confidence change */
23
- export const CONFIDENCE_TRIGGERS = [
24
- "evidence_added", // New evidence bore on the belief
25
- "contradiction_detected", // A contradiction was flagged involving this belief
26
- "merge_outcome", // Merge scoring determined this confidence
27
- "manual", // User manually adjusted confidence
28
- "decay", // Time-based confidence erosion
29
- ];
30
- /** Belief status — lifecycle state */
31
- export const BELIEF_STATUSES = [
32
- "unscored", // Draft — editable in worktree (on feature branch, pre-merge)
33
- "scored", // Merged — formulation frozen (merged to main)
34
- "archived", // Soft-deleted — preserved in history (git rm)
35
- ];
36
- // =============================================================================
37
- // EDGE ENUMS
38
- // =============================================================================
39
- /** Reasoning methods — how an edge relationship was determined */
40
- export const REASONING_METHODS = [
41
- "deductive", // Logically entailed
42
- "inductive", // Generalized from instances
43
- "abductive", // Best explanation inference
44
- "analogical", // Reasoning by analogy
45
- "empirical", // Direct observation/measurement
46
- ];
47
- /** Defeat types (Pollock taxonomy) — how a contradiction operates */
48
- export const DEFEAT_TYPES = [
49
- "rebuts", // Direct contradiction — reasons for the negation
50
- "undercuts", // Breaks the inference link between evidence and belief
51
- "undermines", // Attacks a premise the belief depends on
52
- ];
53
- /** Contradiction severity levels */
54
- export const CONTRADICTION_SEVERITIES = [
55
- "low", // Minor tension, may not require action
56
- "medium", // Moderate conflict, should be investigated
57
- "high", // Significant contradiction, likely needs resolution
58
- "critical", // Blocks progress — must be addressed before judgment
59
- ];
60
- /** Contradiction resolution status */
61
- export const CONTRADICTION_STATUSES = [
62
- "unresolved", // Open conflict — may persist indefinitely
63
- "resolved", // Conflict addressed (one belief forked, archived, or confidence adjusted)
64
- "accepted", // Explicitly accepted as irreconcilable — both beliefs maintained
65
- ];
66
- // =============================================================================
67
- // WORKTREE ENUMS (git worktree lifecycle)
68
- // =============================================================================
69
- /** Merge outcome types — how a worktree merge resolved */
70
- export const MERGE_OUTCOMES = [
71
- "validated", // Beliefs confirmed — clean merge to main
72
- "invalidated", // Defeat recorded — confidence collapsed (merge with revert)
73
- "forked", // Beliefs split into competing versions (fork from merge point)
74
- "inconclusive", // Insufficient evidence — stashed (git stash)
75
- ];
76
- /** Worktree phases — investigation lifecycle within a checked-out worktree */
77
- export const WORKTREE_PHASES = [
78
- "hypothesis", // Form testable claims (write the code — commits)
79
- "investigation", // Collect evidence (run the tests — more commits)
80
- "evaluation", // Update credences (review the results — amend as needed)
81
- "resolution", // Determine outcome (merge to main, fork, or stash)
82
- ];
83
- // =============================================================================
84
- // BRANCH ENUMS (git branch lifecycle)
85
- // =============================================================================
86
- /** Branch status — thematic branch lifecycle */
87
- export const BRANCH_STATUSES = [
88
- "dormant", // Branch exists but no active worktree (no one investigating)
89
- "active", // At least one worktree is investigating this branch
90
- "archived", // Branch retired — no longer a relevant thematic container
91
- ];
92
- // =============================================================================
93
- // PULL REQUEST ENUMS (git pull request lifecycle)
94
- // =============================================================================
95
- /** Pull request status — review lifecycle before merge */
96
- export const PULL_REQUEST_STATUSES = [
97
- "pending_review", // PR opened — awaiting reviewer feedback
98
- "changes_requested", // Reviewer requests changes before merge
99
- "approved", // Approved — ready to merge
100
- "blocked", // Blocked — cannot merge until contradiction is resolved
101
- ];
102
- // =============================================================================
103
- // LAYER ENUMS
104
- // =============================================================================
105
- /** Epistemic layers — the hierarchy of knowledge */
106
- export const EPISTEMIC_LAYERS = [
107
- "L1", // Source — the given (vendored deps)
108
- "L2", // Evidence — the interpreted (test suite)
109
- "L3", // Belief — the structural (source files)
110
- "L4", // Judgment — the committed (release tags)
111
- ];
112
- // =============================================================================
113
- // JUDGMENT ENUMS (Phase 1: new vocabulary)
114
- // =============================================================================
115
- /**
116
- * Judgment type — classification of the determination.
117
- *
118
- * Phase 1: These are new enum values for the Judgment (L4) vocabulary.
119
- * The existing code uses "Decision" — these are the forward-looking terms
120
- * that will eventually replace the Decision vocabulary (Phase 2-3).
121
- */
122
- export const JUDGMENT_TYPES = [
123
- "investment_thesis", // Judgment on an investment opportunity
124
- "thesis_maturity", // Judgment that a thesis is ready for IC presentation
125
- "contradiction_ruling", // Judgment on how to handle an irreconcilable contradiction
126
- "scope_determination", // Judgment that defines or redefines investigation scope
127
- "confidence_ruling", // Judgment that overrides automated confidence for policy reasons
128
- ];
129
- // =============================================================================
130
- // SUPPORT RELATION ENUMS
131
- // =============================================================================
132
- /** Core edge types used in the Integration Surfaces */
133
- export const INTEGRATION_EDGE_TYPES = [
134
- // Support relations
135
- "informs", // Evidence bears on a belief (weight = direction/strength)
136
- "grounds", // Source provides raw basis for evidence
137
- "answers", // Evidence or belief resolves a question
138
- // Defeat relations (Pollock) — weight carries direction
139
- "contradicts", // Rebuts — direct contradiction
140
- "supports", // Weight carries valence (negative = weakens/undercuts)
141
- // Structural relations
142
- "depends_on", // Belief B requires Belief A
143
- "derived_from", // Provenance lineage
144
- "contains", // Hierarchical containment
145
- "supersedes", // New version replaces old (lineage)
146
- "tests", // Question tests a belief
147
- ];
@@ -1,70 +0,0 @@
1
- /**
2
- * Lens Filter Criteria Contract
3
- *
4
- * Version-discriminated filter DSL for lenses. Each filter criteria document
5
- * carries a `version` and `kind` discriminator so future shapes can coexist
6
- * without schema migrations. The Convex `filterCriteria` field remains v.any()
7
- * — all type enforcement happens here at the TypeScript contract layer.
8
- *
9
- * Forward-compatibility guarantees:
10
- * - `version` field: new versions add fields, never remove or rename existing ones
11
- * - `kind` field: new filter kinds (temporal, confidence-range) can be added
12
- * without touching taxonomy code paths
13
- * - `entityTypeFilters` array items are open to extension in future versions
14
- * - Resolution logic switches on `version` + `kind` to select the right resolver
15
- *
16
- * @module lucern/contracts/src/lens-filter
17
- */
18
- /**
19
- * A single entity type filter entry. Matches nodes whose `nodeType` equals
20
- * `entityTypeValue`, optionally further narrowed by subtype membership.
21
- *
22
- * V2 will add `propertyMatchers` here for arbitrary JSON Schema facet queries.
23
- */
24
- export type EntityTypeFilterV1 = {
25
- /** References ontologyVersion.entityTypes[].value, e.g. "company" */
26
- entityTypeValue: string;
27
- /** Optional subtype narrowing. If omitted or empty, all subtypes match. */
28
- subtypeValues?: string[];
29
- };
30
- /**
31
- * Optional scope to restrict which ontology the filter resolves against.
32
- * If omitted, resolution uses whatever ontology is active in the workspace.
33
- */
34
- export type OntologyScope = {
35
- /** Restrict to a specific ontology by key, e.g. "vc-investment" */
36
- ontologyKey?: string;
37
- };
38
- /**
39
- * Taxonomy filter criteria v1: entity type + subtype matching over ontology.
40
- */
41
- export type TaxonomyFilterCriteriaV1 = {
42
- version: 1;
43
- kind: "taxonomy";
44
- entityTypeFilters: EntityTypeFilterV1[];
45
- ontologyScope?: OntologyScope;
46
- };
47
- /**
48
- * Discriminated union of all supported filter criteria.
49
- * Resolution logic switches on `version` + `kind`.
50
- *
51
- * To add a new filter kind:
52
- * 1. Define a new type (e.g., TemporalFilterCriteriaV1)
53
- * 2. Add it to this union
54
- * 3. Add a resolver in taxonomy-filter.ts
55
- * 4. No schema migration needed — filterCriteria is v.any()
56
- */
57
- export type LensFilterCriteria = TaxonomyFilterCriteriaV1;
58
- export declare function isLensFilterCriteria(value: unknown): value is LensFilterCriteria;
59
- export declare function isTaxonomyFilterCriteriaV1(value: unknown): value is TaxonomyFilterCriteriaV1;
60
- export type FilterValidationResult = {
61
- valid: true;
62
- } | {
63
- valid: false;
64
- errors: string[];
65
- };
66
- /**
67
- * Validate a filter criteria document at the contract layer.
68
- * This runs before persisting to Convex.
69
- */
70
- export declare function validateFilterCriteria(value: unknown): FilterValidationResult;
@@ -1,95 +0,0 @@
1
- /**
2
- * Lens Filter Criteria Contract
3
- *
4
- * Version-discriminated filter DSL for lenses. Each filter criteria document
5
- * carries a `version` and `kind` discriminator so future shapes can coexist
6
- * without schema migrations. The Convex `filterCriteria` field remains v.any()
7
- * — all type enforcement happens here at the TypeScript contract layer.
8
- *
9
- * Forward-compatibility guarantees:
10
- * - `version` field: new versions add fields, never remove or rename existing ones
11
- * - `kind` field: new filter kinds (temporal, confidence-range) can be added
12
- * without touching taxonomy code paths
13
- * - `entityTypeFilters` array items are open to extension in future versions
14
- * - Resolution logic switches on `version` + `kind` to select the right resolver
15
- *
16
- * @module lucern/contracts/src/lens-filter
17
- */
18
- // Future: | TemporalFilterCriteriaV1 | ConfidenceRangeFilterCriteriaV1 | ...
19
- // ---------------------------------------------------------------------------
20
- // Type guards
21
- // ---------------------------------------------------------------------------
22
- export function isLensFilterCriteria(value) {
23
- if (!value || typeof value !== "object")
24
- return false;
25
- const obj = value;
26
- return typeof obj.version === "number" && typeof obj.kind === "string";
27
- }
28
- export function isTaxonomyFilterCriteriaV1(value) {
29
- if (!isLensFilterCriteria(value))
30
- return false;
31
- return value.version === 1 && value.kind === "taxonomy";
32
- }
33
- /**
34
- * Validate a filter criteria document at the contract layer.
35
- * This runs before persisting to Convex.
36
- */
37
- export function validateFilterCriteria(value) {
38
- if (value === undefined || value === null) {
39
- return { valid: true }; // filterCriteria is optional
40
- }
41
- if (!isLensFilterCriteria(value)) {
42
- return {
43
- valid: false,
44
- errors: [
45
- 'filterCriteria must have numeric "version" and string "kind" fields',
46
- ],
47
- };
48
- }
49
- if (isTaxonomyFilterCriteriaV1(value)) {
50
- return validateTaxonomyFilterV1(value);
51
- }
52
- // Cast to access properties — TypeScript narrows to `never` when all union
53
- // members are exhausted, but at runtime unknown version/kind combos are possible.
54
- const raw = value;
55
- return {
56
- valid: false,
57
- errors: [
58
- `Unsupported filter criteria: version=${raw.version}, kind=${raw.kind}`,
59
- ],
60
- };
61
- }
62
- function validateTaxonomyFilterV1(criteria) {
63
- const errors = [];
64
- if (!Array.isArray(criteria.entityTypeFilters)) {
65
- errors.push("entityTypeFilters must be an array");
66
- return { valid: false, errors };
67
- }
68
- if (criteria.entityTypeFilters.length === 0) {
69
- errors.push("entityTypeFilters must contain at least one entry");
70
- return { valid: false, errors };
71
- }
72
- for (let i = 0; i < criteria.entityTypeFilters.length; i++) {
73
- const filter = criteria.entityTypeFilters[i];
74
- if (!filter || typeof filter.entityTypeValue !== "string") {
75
- errors.push(`entityTypeFilters[${i}].entityTypeValue must be a non-empty string`);
76
- continue;
77
- }
78
- if (filter.entityTypeValue.trim().length === 0) {
79
- errors.push(`entityTypeFilters[${i}].entityTypeValue must be a non-empty string`);
80
- }
81
- if (filter.subtypeValues !== undefined &&
82
- !Array.isArray(filter.subtypeValues)) {
83
- errors.push(`entityTypeFilters[${i}].subtypeValues must be an array`);
84
- }
85
- }
86
- if (criteria.ontologyScope !== undefined) {
87
- if (typeof criteria.ontologyScope !== "object" ||
88
- criteria.ontologyScope === null) {
89
- errors.push("ontologyScope must be an object");
90
- }
91
- }
92
- return errors.length === 0
93
- ? { valid: true }
94
- : { valid: false, errors };
95
- }
@@ -1,84 +0,0 @@
1
- /**
2
- * Canonical lens workflow contract shared across schema, SDK, and MCP surfaces.
3
- */
4
- export type { LensFilterCriteria, TaxonomyFilterCriteriaV1, EntityTypeFilterV1, OntologyScope, FilterValidationResult, } from "./lens-filter.contract";
5
- export { validateFilterCriteria, isLensFilterCriteria, isTaxonomyFilterCriteriaV1, } from "./lens-filter.contract";
6
- export declare const LENS_PERSPECTIVE_TYPES: readonly ["investigation", "monitoring", "analysis", "comparison", "taxonomy"];
7
- export type LensPerspectiveType = (typeof LENS_PERSPECTIVE_TYPES)[number];
8
- export declare const LENS_STATUSES: readonly ["draft", "active", "archived"];
9
- export type LensStatus = (typeof LENS_STATUSES)[number];
10
- export declare const LENS_TASK_TEMPLATE_PRIORITIES: readonly ["critical", "high", "medium", "low"];
11
- export type LensTaskTemplatePriority = (typeof LENS_TASK_TEMPLATE_PRIORITIES)[number];
12
- export type LensLooseMetadata = Record<string, unknown>;
13
- export type LensPromptTemplateReference = {
14
- key: string;
15
- promptRef: string;
16
- phase?: string;
17
- role?: string;
18
- version?: string;
19
- required?: boolean;
20
- metadata?: LensLooseMetadata;
21
- };
22
- export type LensWorkflowStepTemplate = {
23
- key: string;
24
- title: string;
25
- description?: string;
26
- promptTemplateKey?: string;
27
- taskTemplateKeys?: string[];
28
- metadata?: LensLooseMetadata;
29
- };
30
- export type LensWorkflowTemplate = {
31
- key: string;
32
- name: string;
33
- description?: string;
34
- steps: LensWorkflowStepTemplate[];
35
- metadata?: LensLooseMetadata;
36
- };
37
- export type LensTaskTemplate = {
38
- key: string;
39
- title: string;
40
- description?: string;
41
- priority?: LensTaskTemplatePriority;
42
- phase?: string;
43
- metadata?: LensLooseMetadata;
44
- };
45
- export type LensQuestionTemplate = {
46
- key: string;
47
- text: string;
48
- priority?: LensTaskTemplatePriority;
49
- linkedBeliefKey?: string;
50
- metadata?: LensLooseMetadata;
51
- };
52
- export type LensBranchMigrationSuggestion = {
53
- recommendedTool: "create_lens";
54
- perspectiveType: LensPerspectiveType;
55
- message: string;
56
- suggestedPayload: {
57
- name: string;
58
- description?: string;
59
- topicId?: string;
60
- workspaceId?: string;
61
- perspectiveType: LensPerspectiveType;
62
- };
63
- };
64
- export declare const BRANCH_DEPRECATION_MESSAGE = "Branches are deprecated for operational framing. Create a workspace-scoped lens instead.";
65
- export type DeprecatedBranchMetadata = {
66
- deprecated: true;
67
- deprecationMessage: string;
68
- lensSuggestion: LensBranchMigrationSuggestion;
69
- };
70
- export declare function inferLensPerspectiveTypeFromBranchSchema(schema?: string | null): LensPerspectiveType;
71
- export declare function migrateBranchToLens(args: {
72
- name: string;
73
- description?: string;
74
- topicId?: string;
75
- workspaceId?: string;
76
- schema?: string | null;
77
- }): LensBranchMigrationSuggestion;
78
- export declare function buildDeprecatedBranchMetadata(args: {
79
- name: string;
80
- description?: string;
81
- topicId?: string;
82
- workspaceId?: string;
83
- schema?: string | null;
84
- }): DeprecatedBranchMetadata;
@@ -1,54 +0,0 @@
1
- /**
2
- * Canonical lens workflow contract shared across schema, SDK, and MCP surfaces.
3
- */
4
- export { validateFilterCriteria, isLensFilterCriteria, isTaxonomyFilterCriteriaV1, } from "./lens-filter.contract.js";
5
- export const LENS_PERSPECTIVE_TYPES = [
6
- "investigation",
7
- "monitoring",
8
- "analysis",
9
- "comparison",
10
- "taxonomy",
11
- ];
12
- export const LENS_STATUSES = ["draft", "active", "archived"];
13
- export const LENS_TASK_TEMPLATE_PRIORITIES = [
14
- "critical",
15
- "high",
16
- "medium",
17
- "low",
18
- ];
19
- export const BRANCH_DEPRECATION_MESSAGE = "Branches are deprecated for operational framing. Create a workspace-scoped lens instead.";
20
- export function inferLensPerspectiveTypeFromBranchSchema(schema) {
21
- const normalized = schema?.trim().toLowerCase();
22
- if (normalized === "phase") {
23
- return "monitoring";
24
- }
25
- if (normalized === "axis" || normalized === "dimension") {
26
- return "comparison";
27
- }
28
- if (normalized === "track") {
29
- return "investigation";
30
- }
31
- return "analysis";
32
- }
33
- export function migrateBranchToLens(args) {
34
- const perspectiveType = inferLensPerspectiveTypeFromBranchSchema(args.schema);
35
- return {
36
- recommendedTool: "create_lens",
37
- perspectiveType,
38
- message: "Branches are deprecated for operational framing. Create a workspace-scoped lens with the suggested payload instead.",
39
- suggestedPayload: {
40
- name: args.name,
41
- description: args.description,
42
- topicId: args.topicId,
43
- workspaceId: args.workspaceId,
44
- perspectiveType,
45
- },
46
- };
47
- }
48
- export function buildDeprecatedBranchMetadata(args) {
49
- return {
50
- deprecated: true,
51
- deprecationMessage: BRANCH_DEPRECATION_MESSAGE,
52
- lensSuggestion: migrateBranchToLens(args),
53
- };
54
- }
@@ -1,151 +0,0 @@
1
- /**
2
- * MCP Tool Contract Definitions
3
- *
4
- * Machine-readable source of truth for all Lucern MCP tool names,
5
- * descriptions, parameters, and response schemas.
6
- *
7
- * CONTRACT SURFACE: These definitions are the external API for AI agents.
8
- * Renaming a tool or changing its description is a BREAKING CHANGE.
9
- *
10
- * Git-native naming rules (enforced by lint):
11
- * 1. Workflow tools use git verbs directly (add_worktree, merge, push, open_pull_request)
12
- * 2. Knowledge tools use epistemic verbs (create_belief, fork_belief, modulate_confidence)
13
- * 3. First sentence of description includes the git analog verb
14
- * 4. Description includes "Like `git X`" parenthetical
15
- * 5. Parameter names use domain terms (canonicalText, nodeId, confidence)
16
- */
17
- export type McpToolContract = {
18
- /** Stable tool name — breaking change to rename */
19
- name: string;
20
- /** Git-semantic description — breaking change to remove git references */
21
- description: string;
22
- /** Parameter schema (JSON Schema subset) */
23
- parameters: Record<string, McpParameterDef>;
24
- /** Required parameter names */
25
- required: string[];
26
- /** Response shape description */
27
- response: McpResponseDef;
28
- /** Which Lucern module owns the implementation */
29
- ownerModule: string;
30
- /** Ontology primitive this tool operates on */
31
- ontologyPrimitive: "belief" | "evidence" | "source" | "question" | "judgment" | "worktree" | "branch" | "lens" | "edge" | "graph" | "task" | "policy" | "ontology" | "identity";
32
- /** MCP surface tier — showcase (front page, every demo) or workhorse (complete CRUD, discovered when building) */
33
- tier: "showcase" | "workhorse";
34
- /** Hide this tool from public discovery surfaces. */
35
- internal?: boolean;
36
- /** Deprecation notice shown in contract-driven docs and discovery. */
37
- deprecated?: string;
38
- };
39
- export type McpParameterDef = {
40
- type: "string" | "number" | "boolean" | "array" | "object";
41
- description: string;
42
- required?: boolean;
43
- enum?: string[];
44
- };
45
- export type McpResponseDef = {
46
- description: string;
47
- fields: Record<string, string>;
48
- };
49
- export declare const CREATE_BELIEF: McpToolContract;
50
- export declare const GET_BELIEF: McpToolContract;
51
- export declare const REFINE_BELIEF: McpToolContract;
52
- export declare const MODULATE_CONFIDENCE: McpToolContract;
53
- export declare const FORK_BELIEF: McpToolContract;
54
- export declare const ARCHIVE_BELIEF: McpToolContract;
55
- export declare const CREATE_EPISTEMIC_CONTRACT: McpToolContract;
56
- export declare const ADD_EVIDENCE: McpToolContract;
57
- export declare const FLAG_CONTRADICTION: McpToolContract;
58
- export declare const ADD_WORKTREE: McpToolContract;
59
- export declare const MERGE: McpToolContract;
60
- export declare const QUERY_LINEAGE: McpToolContract;
61
- export declare const GET_CONFIDENCE_HISTORY: McpToolContract;
62
- export declare const GET_AUDIT_TRAIL: McpToolContract;
63
- export declare const TRAVERSE_GRAPH: McpToolContract;
64
- export declare const GET_GRAPH_NEIGHBORHOOD: McpToolContract;
65
- export declare const TRACE_ENTITY_IMPACT: McpToolContract;
66
- export declare const SEARCH_BELIEFS: McpToolContract;
67
- export declare const SEARCH_RESOURCES: McpToolContract;
68
- export declare const FIND_CONTRADICTIONS: McpToolContract;
69
- export declare const CREATE_EDGE: McpToolContract;
70
- export declare const RECORD_JUDGMENT: McpToolContract;
71
- export declare const CREATE_LENS: McpToolContract;
72
- export declare const LIST_LENSES: McpToolContract;
73
- export declare const APPLY_LENS_TO_TOPIC: McpToolContract;
74
- export declare const REMOVE_LENS_FROM_TOPIC: McpToolContract;
75
- export declare const PUSH: McpToolContract;
76
- export declare const OPEN_PULL_REQUEST: McpToolContract;
77
- export declare const BISECT_CONFIDENCE: McpToolContract;
78
- export declare const DETECT_CONFIRMATION_BIAS: McpToolContract;
79
- export declare const GET_GRAPH_STRUCTURE_ANALYSIS: McpToolContract;
80
- export declare const GET_FALSIFICATION_QUESTIONS: McpToolContract;
81
- export declare const SEARCH_SOURCES: McpToolContract;
82
- export declare const EXECUTE_DEEP_RESEARCH: McpToolContract;
83
- export declare const SEARCH_EVIDENCE: McpToolContract;
84
- export declare const CREATE_EVIDENCE: McpToolContract;
85
- export declare const GET_EVIDENCE: McpToolContract;
86
- export declare const LIST_EVIDENCE: McpToolContract;
87
- export declare const LINK_EVIDENCE: McpToolContract;
88
- export declare const LINK_EVIDENCE_TO_BELIEF: McpToolContract;
89
- export declare const CREATE_QUESTION: McpToolContract;
90
- export declare const GET_QUESTION: McpToolContract;
91
- export declare const REFINE_QUESTION: McpToolContract;
92
- export declare const LIST_QUESTIONS: McpToolContract;
93
- export declare const ANSWER_QUESTION: McpToolContract;
94
- export declare const UPDATE_QUESTION_STATUS: McpToolContract;
95
- export declare const ARCHIVE_QUESTION: McpToolContract;
96
- export declare const LINK_EVIDENCE_TO_QUESTION: McpToolContract;
97
- export declare const CREATE_ANSWER: McpToolContract;
98
- export declare const GET_ANSWER: McpToolContract;
99
- export declare const GET_HIGH_PRIORITY_QUESTIONS: McpToolContract;
100
- export declare const FIND_MISSING_QUESTIONS: McpToolContract;
101
- export declare const LIST_BELIEFS: McpToolContract;
102
- export declare const LIST_WORKTREES: McpToolContract;
103
- export declare const LIST_ALL_WORKTREES: McpToolContract;
104
- export declare const ACTIVATE_WORKTREE: McpToolContract;
105
- export declare const UPDATE_WORKTREE_TARGETS: McpToolContract;
106
- export declare const UPDATE_WORKTREE_METADATA: McpToolContract;
107
- export declare const IDENTITY_WHOAMI: McpToolContract;
108
- export declare const COMPILE_CONTEXT: McpToolContract;
109
- export declare const CHECK_PERMISSION: McpToolContract;
110
- export declare const FILTER_BY_PERMISSION: McpToolContract;
111
- export declare const INGEST_OBSERVATION: McpToolContract;
112
- export declare const GET_OBSERVATION_CONTEXT: McpToolContract;
113
- export declare const CREATE_TASK: McpToolContract;
114
- export declare const COMPLETE_TASK: McpToolContract;
115
- export declare const UPDATE_TASK: McpToolContract;
116
- export declare const LIST_TASKS: McpToolContract;
117
- export declare const CREATE_TOPIC: McpToolContract;
118
- export declare const LIST_TOPICS: McpToolContract;
119
- export declare const GET_TOPIC: McpToolContract;
120
- export declare const UPDATE_TOPIC: McpToolContract;
121
- export declare const GET_TOPIC_TREE: McpToolContract;
122
- export declare const GET_CODE_CONTEXT: McpToolContract;
123
- export declare const GET_CHANGE_HISTORY: McpToolContract;
124
- export declare const RECORD_ATTEMPT: McpToolContract;
125
- export declare const GET_FAILURE_LOG: McpToolContract;
126
- export declare const GET_TOPIC_COVERAGE: McpToolContract;
127
- export declare const GET_GRAPH_GAPS: McpToolContract;
128
- export declare const MANAGE_WRITE_POLICY: McpToolContract;
129
- export declare const LIST_ONTOLOGIES: McpToolContract;
130
- export declare const GET_ONTOLOGY: McpToolContract;
131
- export declare const APPLY_ONTOLOGY: McpToolContract;
132
- export declare const MATCH_ENTITY_TYPE: McpToolContract;
133
- export declare const CREATE_ONTOLOGY: McpToolContract;
134
- export declare const UPDATE_ONTOLOGY: McpToolContract;
135
- export declare const ARCHIVE_ONTOLOGY: McpToolContract;
136
- export declare const CREATE_ONTOLOGY_VERSION: McpToolContract;
137
- export declare const PUBLISH_ONTOLOGY_VERSION: McpToolContract;
138
- export declare const DEPRECATE_ONTOLOGY_VERSION: McpToolContract;
139
- export declare const RESOLVE_EFFECTIVE_ONTOLOGY: McpToolContract;
140
- /** All MCP tool contracts, indexed by name */
141
- export declare const MCP_TOOL_CONTRACTS: Record<string, McpToolContract>;
142
- /** Tool names that MUST include git-semantic language in descriptions */
143
- export declare const GIT_SEMANTIC_REQUIRED_TOOLS: string[];
144
- /**
145
- * Lint validation: every tool description must contain "Like `git" or "Like a `git"
146
- * or reference a git operation in the first sentence.
147
- */
148
- export declare function validateGitSemantics(tool: McpToolContract): {
149
- valid: boolean;
150
- reason?: string;
151
- };