@lucern/contracts 0.1.0-alpha.3 → 0.1.1-alpha.1
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.
- package/dist/index.d.ts +2003 -29
- package/dist/index.js +5627 -30
- package/package.json +15 -58
- package/src/agents/v1.ts +8 -0
- package/src/api-enums.contract.ts +183 -0
- package/{dist/auth-context.contract.js → src/auth-context.contract.ts} +1 -1
- package/{dist/auth-session.contract.js → src/auth-session.contract.ts} +1 -1
- package/src/auth.contract.ts +162 -0
- package/src/beliefs/v1.ts +8 -0
- package/src/context-pack.contract.ts +704 -0
- package/src/convex-admin.contract.ts +14 -0
- package/{dist/events-types.contract.js → src/events-types.contract.ts} +1 -1
- package/src/events.contract.ts +376 -0
- package/src/evidence/v1.ts +8 -0
- package/src/gateway.contract.ts +151 -0
- package/src/graph/v1.ts +8 -0
- package/src/ids.contract.ts +36 -0
- package/src/index.ts +30 -0
- package/src/lens-filter.contract.ts +183 -0
- package/src/lens-workflow.contract.ts +162 -0
- package/src/mcp-tools.contract.ts +3636 -0
- package/src/ontologies/v1.ts +8 -0
- package/{dist/ontology-matching.contract.js → src/ontology-matching.contract.ts} +1 -1
- package/src/prompt.contract.ts +50 -0
- package/src/questions/v1.ts +8 -0
- package/src/sdk-methods.contract.ts +522 -0
- package/src/sdk-tools.contract.ts +1545 -0
- package/src/text-matching.contract.ts +347 -0
- package/{dist/topic-scope.contract.js → src/topic-scope.contract.ts} +1 -1
- package/src/topics/v1.ts +8 -0
- package/{dist/v1/agents/v1.d.ts → src/v1/agents/v1.ts} +0 -1
- package/{dist/v1/beliefs/v1.d.ts → src/v1/beliefs/v1.ts} +0 -1
- package/{dist/v1/evidence/v1.d.ts → src/v1/evidence/v1.ts} +0 -1
- package/{dist/v1/graph/v1.d.ts → src/v1/graph/v1.ts} +0 -1
- package/src/v1/ontologies/v1.ts +276 -0
- package/{dist/v1/questions/v1.d.ts → src/v1/questions/v1.ts} +0 -1
- package/src/v1/topics/v1.ts +79 -0
- package/{dist/v1/worktrees/v1.d.ts → src/v1/worktrees/v1.ts} +0 -1
- package/src/workflow-runtime.contract.ts +440 -0
- package/src/worktrees/v1.ts +8 -0
- package/tsconfig.json +9 -0
- package/README.md +0 -43
- package/dist/api-enums.contract.d.ts +0 -59
- package/dist/api-enums.contract.d.ts.map +0 -1
- package/dist/api-enums.contract.js +0 -148
- package/dist/api-enums.contract.js.map +0 -1
- package/dist/auth-context.contract.d.ts +0 -9
- package/dist/auth-context.contract.d.ts.map +0 -1
- package/dist/auth-context.contract.js.map +0 -1
- package/dist/auth-session.contract.d.ts +0 -9
- package/dist/auth-session.contract.d.ts.map +0 -1
- package/dist/auth-session.contract.js.map +0 -1
- package/dist/auth.contract.d.ts +0 -89
- package/dist/auth.contract.d.ts.map +0 -1
- package/dist/auth.contract.js +0 -58
- package/dist/auth.contract.js.map +0 -1
- package/dist/context-pack.contract.d.ts +0 -495
- package/dist/context-pack.contract.d.ts.map +0 -1
- package/dist/context-pack.contract.js +0 -170
- package/dist/context-pack.contract.js.map +0 -1
- package/dist/convex-admin.contract.d.ts +0 -6
- package/dist/convex-admin.contract.d.ts.map +0 -1
- package/dist/convex-admin.contract.js +0 -2
- package/dist/convex-admin.contract.js.map +0 -1
- package/dist/events-types.contract.d.ts +0 -9
- package/dist/events-types.contract.d.ts.map +0 -1
- package/dist/events-types.contract.js.map +0 -1
- package/dist/events.contract.d.ts +0 -177
- package/dist/events.contract.d.ts.map +0 -1
- package/dist/events.contract.js +0 -160
- package/dist/events.contract.js.map +0 -1
- package/dist/gateway.contract.d.ts +0 -75
- package/dist/gateway.contract.d.ts.map +0 -1
- package/dist/gateway.contract.js +0 -20
- package/dist/gateway.contract.js.map +0 -1
- package/dist/ids.contract.d.ts +0 -8
- package/dist/ids.contract.d.ts.map +0 -1
- package/dist/ids.contract.js +0 -25
- package/dist/ids.contract.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lens-filter.contract.d.ts +0 -71
- package/dist/lens-filter.contract.d.ts.map +0 -1
- package/dist/lens-filter.contract.js +0 -96
- package/dist/lens-filter.contract.js.map +0 -1
- package/dist/lens-workflow.contract.d.ts +0 -85
- package/dist/lens-workflow.contract.d.ts.map +0 -1
- package/dist/lens-workflow.contract.js +0 -55
- package/dist/lens-workflow.contract.js.map +0 -1
- package/dist/mcp-tools.contract.d.ts +0 -152
- package/dist/mcp-tools.contract.d.ts.map +0 -1
- package/dist/mcp-tools.contract.js +0 -3282
- package/dist/mcp-tools.contract.js.map +0 -1
- package/dist/ontology-matching.contract.d.ts +0 -9
- package/dist/ontology-matching.contract.d.ts.map +0 -1
- package/dist/ontology-matching.contract.js.map +0 -1
- package/dist/prompt.contract.d.ts +0 -25
- package/dist/prompt.contract.d.ts.map +0 -1
- package/dist/prompt.contract.js +0 -25
- package/dist/prompt.contract.js.map +0 -1
- package/dist/sdk-methods.contract.d.ts +0 -356
- package/dist/sdk-methods.contract.d.ts.map +0 -1
- package/dist/sdk-methods.contract.js +0 -17
- package/dist/sdk-methods.contract.js.map +0 -1
- package/dist/sdk-tools.contract.d.ts +0 -93
- package/dist/sdk-tools.contract.d.ts.map +0 -1
- package/dist/sdk-tools.contract.js +0 -1399
- package/dist/sdk-tools.contract.js.map +0 -1
- package/dist/text-matching.contract.d.ts +0 -54
- package/dist/text-matching.contract.d.ts.map +0 -1
- package/dist/text-matching.contract.js +0 -278
- package/dist/text-matching.contract.js.map +0 -1
- package/dist/topic-scope.contract.d.ts +0 -9
- package/dist/topic-scope.contract.d.ts.map +0 -1
- package/dist/topic-scope.contract.js.map +0 -1
- package/dist/v1/agents/v1.d.ts.map +0 -1
- package/dist/v1/agents/v1.js +0 -2
- package/dist/v1/agents/v1.js.map +0 -1
- package/dist/v1/beliefs/v1.d.ts.map +0 -1
- package/dist/v1/beliefs/v1.js +0 -2
- package/dist/v1/beliefs/v1.js.map +0 -1
- package/dist/v1/evidence/v1.d.ts.map +0 -1
- package/dist/v1/evidence/v1.js +0 -2
- package/dist/v1/evidence/v1.js.map +0 -1
- package/dist/v1/graph/v1.d.ts.map +0 -1
- package/dist/v1/graph/v1.js +0 -2
- package/dist/v1/graph/v1.js.map +0 -1
- package/dist/v1/ontologies/v1.d.ts +0 -77
- package/dist/v1/ontologies/v1.d.ts.map +0 -1
- package/dist/v1/ontologies/v1.js +0 -179
- package/dist/v1/ontologies/v1.js.map +0 -1
- package/dist/v1/questions/v1.d.ts.map +0 -1
- package/dist/v1/questions/v1.js +0 -2
- package/dist/v1/questions/v1.js.map +0 -1
- package/dist/v1/topics/v1.d.ts +0 -20
- package/dist/v1/topics/v1.d.ts.map +0 -1
- package/dist/v1/topics/v1.js +0 -62
- package/dist/v1/topics/v1.js.map +0 -1
- package/dist/v1/worktrees/v1.d.ts.map +0 -1
- package/dist/v1/worktrees/v1.js +0 -2
- package/dist/v1/worktrees/v1.js.map +0 -1
- package/dist/workflow-runtime.contract.d.ts +0 -162
- package/dist/workflow-runtime.contract.d.ts.map +0 -1
- package/dist/workflow-runtime.contract.js +0 -258
- package/dist/workflow-runtime.contract.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,2004 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
declare const FORK_REASONS: readonly ["refinement", "contradiction_response", "scope_change", "confidence_collapse", "manual"];
|
|
13
|
+
type ForkReason = (typeof FORK_REASONS)[number];
|
|
14
|
+
/** Confidence modulation triggers — what caused a confidence change */
|
|
15
|
+
declare const CONFIDENCE_TRIGGERS: readonly ["evidence_added", "contradiction_detected", "merge_outcome", "manual", "decay"];
|
|
16
|
+
type ConfidenceTrigger = (typeof CONFIDENCE_TRIGGERS)[number];
|
|
17
|
+
/** Belief status — lifecycle state */
|
|
18
|
+
declare const BELIEF_STATUSES: readonly ["unscored", "scored", "archived"];
|
|
19
|
+
type BeliefStatus = (typeof BELIEF_STATUSES)[number];
|
|
20
|
+
/** Reasoning methods — how an edge relationship was determined */
|
|
21
|
+
declare const REASONING_METHODS: readonly ["deductive", "inductive", "abductive", "analogical", "empirical"];
|
|
22
|
+
type ReasoningMethod = (typeof REASONING_METHODS)[number];
|
|
23
|
+
/** Defeat types (Pollock taxonomy) — how a contradiction operates */
|
|
24
|
+
declare const DEFEAT_TYPES: readonly ["rebuts", "undercuts", "undermines"];
|
|
25
|
+
type DefeatType = (typeof DEFEAT_TYPES)[number];
|
|
26
|
+
/** Contradiction severity levels */
|
|
27
|
+
declare const CONTRADICTION_SEVERITIES: readonly ["low", "medium", "high", "critical"];
|
|
28
|
+
type ContradictionSeverity = (typeof CONTRADICTION_SEVERITIES)[number];
|
|
29
|
+
/** Contradiction resolution status */
|
|
30
|
+
declare const CONTRADICTION_STATUSES: readonly ["unresolved", "resolved", "accepted"];
|
|
31
|
+
type ContradictionStatus = (typeof CONTRADICTION_STATUSES)[number];
|
|
32
|
+
/** Merge outcome types — how a worktree merge resolved */
|
|
33
|
+
declare const MERGE_OUTCOMES: readonly ["validated", "invalidated", "forked", "inconclusive"];
|
|
34
|
+
type MergeOutcome = (typeof MERGE_OUTCOMES)[number];
|
|
35
|
+
/** Worktree phases — investigation lifecycle within a checked-out worktree */
|
|
36
|
+
declare const WORKTREE_PHASES: readonly ["hypothesis", "investigation", "evaluation", "resolution"];
|
|
37
|
+
type WorktreePhase = (typeof WORKTREE_PHASES)[number];
|
|
38
|
+
/** Branch status — thematic branch lifecycle */
|
|
39
|
+
declare const BRANCH_STATUSES: readonly ["dormant", "active", "archived"];
|
|
40
|
+
type BranchStatus = (typeof BRANCH_STATUSES)[number];
|
|
41
|
+
/** Pull request status — review lifecycle before merge */
|
|
42
|
+
declare const PULL_REQUEST_STATUSES: readonly ["pending_review", "changes_requested", "approved", "blocked"];
|
|
43
|
+
type PullRequestStatus = (typeof PULL_REQUEST_STATUSES)[number];
|
|
44
|
+
/** Epistemic layers — the hierarchy of knowledge */
|
|
45
|
+
declare const EPISTEMIC_LAYERS: readonly ["L1", "L2", "L3", "L4"];
|
|
46
|
+
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
|
+
declare const JUDGMENT_TYPES: readonly ["investment_thesis", "thesis_maturity", "contradiction_ruling", "scope_determination", "confidence_ruling"];
|
|
55
|
+
type JudgmentType = (typeof JUDGMENT_TYPES)[number];
|
|
56
|
+
/** Core edge types used in the Integration Surfaces */
|
|
57
|
+
declare const INTEGRATION_EDGE_TYPES: readonly ["informs", "grounds", "answers", "contradicts", "supports", "depends_on", "derived_from", "contains", "supersedes", "tests"];
|
|
58
|
+
type IntegrationEdgeType = (typeof INTEGRATION_EDGE_TYPES)[number];
|
|
59
|
+
|
|
60
|
+
interface ConvexAdminClient {
|
|
61
|
+
query<T = unknown>(functionReference: unknown, args: Record<string, unknown>): Promise<T>;
|
|
62
|
+
mutation<T = unknown>(functionReference: unknown, args: Record<string, unknown>): Promise<T>;
|
|
63
|
+
action<T = unknown>(functionReference: unknown, args: Record<string, unknown>): Promise<T>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @lucern/contracts — auth (canonical support contract)
|
|
68
|
+
*
|
|
69
|
+
* Consolidated flat support surface for Lucern authentication:
|
|
70
|
+
* - Session primitives (auth modes, principal types, lifecycle)
|
|
71
|
+
* - AuthContext shape + McpTransportKind + LucernSdkClient alias
|
|
72
|
+
*
|
|
73
|
+
* Consolidated from src/auth-session.contract.ts and src/auth-context.contract.ts
|
|
74
|
+
* in EK-16 T1 PR 3a. Compat shims remain at both old paths until Lucern 1.0.0 (D12).
|
|
75
|
+
*/
|
|
76
|
+
declare const SESSION_AUTH_MODES: readonly ["interactive_user", "service_principal", "tenant_api_key", "session_token"];
|
|
77
|
+
type SessionAuthMode = (typeof SESSION_AUTH_MODES)[number];
|
|
78
|
+
declare const SESSION_PRINCIPAL_TYPES: readonly ["human", "service", "agent"];
|
|
79
|
+
type SessionPrincipalType = (typeof SESSION_PRINCIPAL_TYPES)[number];
|
|
80
|
+
declare const SESSION_LIFECYCLE_STATUSES: readonly ["active", "expired", "revoked"];
|
|
81
|
+
type SessionLifecycleStatus = (typeof SESSION_LIFECYCLE_STATUSES)[number];
|
|
82
|
+
type SessionDelegationHop = {
|
|
83
|
+
principalId: string;
|
|
84
|
+
principalType: SessionPrincipalType;
|
|
85
|
+
authMode?: SessionAuthMode;
|
|
86
|
+
sessionId?: string;
|
|
87
|
+
delegatedAt?: number;
|
|
88
|
+
reason?: string;
|
|
89
|
+
};
|
|
90
|
+
type SessionAuditOutcome = "accepted" | "rejected" | "revoked" | "expired";
|
|
91
|
+
type SessionAuditEnvelope = {
|
|
92
|
+
sessionId: string;
|
|
93
|
+
authMode: SessionAuthMode;
|
|
94
|
+
principalId: string;
|
|
95
|
+
principalType: SessionPrincipalType;
|
|
96
|
+
tenantId: string;
|
|
97
|
+
workspaceId?: string;
|
|
98
|
+
apiKeyId?: string;
|
|
99
|
+
scopes: readonly string[];
|
|
100
|
+
roles?: readonly string[];
|
|
101
|
+
delegationChain?: readonly SessionDelegationHop[];
|
|
102
|
+
sourceSessionId?: string;
|
|
103
|
+
expiresAt?: number;
|
|
104
|
+
request?: {
|
|
105
|
+
endpoint?: string;
|
|
106
|
+
method?: string;
|
|
107
|
+
correlationId?: string;
|
|
108
|
+
};
|
|
109
|
+
result?: {
|
|
110
|
+
outcome: SessionAuditOutcome;
|
|
111
|
+
reason?: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
declare function inferSessionPrincipalType(principalId: string): SessionPrincipalType;
|
|
115
|
+
declare function normalizeDelegationChain(args: {
|
|
116
|
+
delegationChain?: readonly SessionDelegationHop[];
|
|
117
|
+
delegatedBy?: string;
|
|
118
|
+
delegatedByType?: SessionPrincipalType;
|
|
119
|
+
delegatedAt?: number;
|
|
120
|
+
reason?: string;
|
|
121
|
+
}): SessionDelegationHop[] | undefined;
|
|
122
|
+
declare function lastDelegator(delegationChain?: readonly SessionDelegationHop[]): string | undefined;
|
|
123
|
+
|
|
124
|
+
type McpTransportKind = "stdio" | "hosted";
|
|
125
|
+
type LucernSdkClient = unknown;
|
|
126
|
+
/**
|
|
127
|
+
* Session authentication context — injected by withAuth() middleware.
|
|
128
|
+
*
|
|
129
|
+
* Built from TenantConfig at dispatch time. Agent sessions get
|
|
130
|
+
* AGENT_IDENTITY + "agent:internal" role + unrestricted access.
|
|
131
|
+
* User sessions get Clerk userId + resolved role + tool ACLs.
|
|
132
|
+
*/
|
|
133
|
+
type AuthContext = {
|
|
134
|
+
sessionType: "agent" | "user";
|
|
135
|
+
userId: string;
|
|
136
|
+
tenantId: string;
|
|
137
|
+
role: string;
|
|
138
|
+
allowedTopics: string[] | null;
|
|
139
|
+
groupIds: string[];
|
|
140
|
+
permittedPackKeys: string[];
|
|
141
|
+
sessionId: string;
|
|
142
|
+
principalId?: string;
|
|
143
|
+
principalType?: SessionPrincipalType;
|
|
144
|
+
workspaceId?: string;
|
|
145
|
+
scopes?: string[];
|
|
146
|
+
authMode?: SessionAuthMode;
|
|
147
|
+
roles?: string[];
|
|
148
|
+
transportKind?: McpTransportKind;
|
|
149
|
+
lucernClient?: LucernSdkClient;
|
|
150
|
+
convex?: ConvexAdminClient;
|
|
151
|
+
setDefaultScopeContext?: (scopeId: string) => Promise<unknown>;
|
|
152
|
+
matchesWorkspaceReasoningScope?: (node: unknown, scope: unknown) => boolean;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Gateway contract types — shared between Stack's gateway middleware and
|
|
157
|
+
* Lucern's server-core / gateway route handlers.
|
|
158
|
+
*
|
|
159
|
+
* These types describe the authenticated request context that flows from
|
|
160
|
+
* the gateway into Lucern route handlers. The gateway (Stack-side) creates
|
|
161
|
+
* the context; Lucern consumes it read-only.
|
|
162
|
+
*
|
|
163
|
+
* @module @lucern/contracts/src/gateway
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
type PlatformApiErrorCode = "AUTH_REQUIRED" | "AUTHENTICATION_REQUIRED" | "AUTH_TOKEN_MISSING" | "INVALID_REQUEST" | "IDEMPOTENCY_KEY_REQUIRED" | "FORBIDDEN" | "SCOPE_INSUFFICIENT" | "ENVIRONMENT_MISMATCH" | "KEY_EXPIRED" | "KEY_REVOKED" | "RATE_LIMIT_EXCEEDED" | "NOT_FOUND" | "CONFLICT" | "UPSTREAM_ERROR" | "INTERNAL_ERROR";
|
|
167
|
+
type GatewayScope = {
|
|
168
|
+
tenantId?: string;
|
|
169
|
+
workspaceId?: string;
|
|
170
|
+
};
|
|
171
|
+
type GatewayEnvironment = "sandbox" | "production";
|
|
172
|
+
type GatewayAuthMode = "interactive_user" | "service_principal" | "tenant_api_key" | "session_token";
|
|
173
|
+
type KeyLifecycleStatus = "active" | "rotating" | "rotated" | "expired" | "revoked";
|
|
174
|
+
type CutoverDomain = "graph" | "schema" | "identity" | "policy" | "audit" | "admin" | "agent" | "tool" | "prompt" | "intelligence";
|
|
175
|
+
type CutoverFlagState = "legacy" | "cutover" | "disabled";
|
|
176
|
+
/**
|
|
177
|
+
* Authenticated request context created by the gateway middleware.
|
|
178
|
+
* Lucern route handlers receive this as a read-only parameter.
|
|
179
|
+
*
|
|
180
|
+
* The `convex` field is typed as `unknown` in the contract because Lucern
|
|
181
|
+
* consumers should not use the gateway's Convex client directly — they
|
|
182
|
+
* have their own kernel client. The gateway (Stack-side) narrows this to
|
|
183
|
+
* `ConvexHttpClient` at the construction site.
|
|
184
|
+
*/
|
|
185
|
+
type GatewayAuthContext = {
|
|
186
|
+
userId: string;
|
|
187
|
+
convexToken?: string;
|
|
188
|
+
/** Opaque in contract — narrowed to ConvexHttpClient at the gateway. */
|
|
189
|
+
convex: any;
|
|
190
|
+
authMode: GatewayAuthMode;
|
|
191
|
+
principalId?: string;
|
|
192
|
+
principalType?: SessionPrincipalType;
|
|
193
|
+
tenantId?: string;
|
|
194
|
+
workspaceId?: string;
|
|
195
|
+
roles?: string[];
|
|
196
|
+
sessionId?: string;
|
|
197
|
+
sessionAuthMode?: SessionAuthMode;
|
|
198
|
+
sessionExpiresAt?: number;
|
|
199
|
+
delegationChain?: SessionDelegationHop[];
|
|
200
|
+
servicePrincipalId?: string;
|
|
201
|
+
servicePrincipalKeyId?: string;
|
|
202
|
+
servicePrincipalTenantId?: string;
|
|
203
|
+
servicePrincipalWorkspaceId?: string;
|
|
204
|
+
requestEnvironment: GatewayEnvironment;
|
|
205
|
+
keyEnvironment?: GatewayEnvironment;
|
|
206
|
+
keyStatus: KeyLifecycleStatus | "unknown";
|
|
207
|
+
grantedScopes: Set<string>;
|
|
208
|
+
cutoverDomain: CutoverDomain;
|
|
209
|
+
cutoverState: CutoverFlagState;
|
|
210
|
+
};
|
|
211
|
+
type GatewayErrorArgs = {
|
|
212
|
+
code: PlatformApiErrorCode;
|
|
213
|
+
message: string;
|
|
214
|
+
status: number;
|
|
215
|
+
correlationId: string;
|
|
216
|
+
policyTraceId?: string;
|
|
217
|
+
invariant?: string;
|
|
218
|
+
suggestion?: string;
|
|
219
|
+
details?: unknown;
|
|
220
|
+
headers?: HeadersInit;
|
|
221
|
+
};
|
|
222
|
+
type GatewaySuccessArgs = {
|
|
223
|
+
status?: number;
|
|
224
|
+
correlationId: string;
|
|
225
|
+
policyTraceId?: string;
|
|
226
|
+
idempotentReplay?: boolean;
|
|
227
|
+
};
|
|
228
|
+
declare function requireActorPrincipalId(authContext: GatewayAuthContext): string;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Context-Pack Contract v1
|
|
232
|
+
*
|
|
233
|
+
* Canonical TypeScript types and constants for the context-pack output schema.
|
|
234
|
+
* This is the external contract consumed by:
|
|
235
|
+
* - MCP tool `compile_context` (canonical compiler read)
|
|
236
|
+
* - SDK/HTTP consumers that read compiled context packs programmatically
|
|
237
|
+
* - Benchmark harnesses (context-pack-ab)
|
|
238
|
+
*
|
|
239
|
+
* BREAKING CHANGE RULES:
|
|
240
|
+
* - Adding optional fields to ContextPackV1 is NON-breaking
|
|
241
|
+
* - Removing fields or changing types is BREAKING (bump CONTEXT_PACK_SCHEMA_VERSION)
|
|
242
|
+
* - Changing section budget ratios or ranking weights is NON-breaking (tuning)
|
|
243
|
+
* - Changing the version string is BREAKING (consumers check it)
|
|
244
|
+
*/
|
|
245
|
+
/** Canonical version string. Consumers MUST check this field for compatibility. */
|
|
246
|
+
declare const CONTEXT_PACK_SCHEMA_VERSION: "1.0.0";
|
|
247
|
+
/**
|
|
248
|
+
* Available ranking profiles for context-pack assembly.
|
|
249
|
+
*
|
|
250
|
+
* - `baseline_v1`: Simple token-hit counting. Items with zero query hits are excluded.
|
|
251
|
+
* - `weighted_v1`: Multi-signal scoring combining query relevance, recency, confidence,
|
|
252
|
+
* belief type, priority, and severity with section-specific weight vectors.
|
|
253
|
+
*/
|
|
254
|
+
type ContextRankingProfile = "baseline_v1" | "weighted_v1";
|
|
255
|
+
declare const CONTEXT_RANKING_PROFILES: readonly ContextRankingProfile[];
|
|
256
|
+
declare const DEFAULT_RANKING_PROFILE: ContextRankingProfile;
|
|
257
|
+
/**
|
|
258
|
+
* Context compilation mode.
|
|
259
|
+
*
|
|
260
|
+
* - `standard`: Default — ranked beliefs, questions, evidence, contradictions.
|
|
261
|
+
* - `delta`: Diff-aware — adds failure context, verification obligations,
|
|
262
|
+
* and worktree ledger analysis to the standard context pack.
|
|
263
|
+
*/
|
|
264
|
+
type ContextCompilationMode = "standard" | "delta";
|
|
265
|
+
declare const DEFAULT_COMPILATION_MODE: ContextCompilationMode;
|
|
266
|
+
/**
|
|
267
|
+
* The five canonical sections of a context pack.
|
|
268
|
+
* Order matters: invariants are injected first, contradictions last.
|
|
269
|
+
*/
|
|
270
|
+
type ContextPackSectionKey = "invariants" | "activeBeliefs" | "openQuestions" | "recentEvidence" | "contradictions";
|
|
271
|
+
declare const CONTEXT_PACK_SECTION_KEYS: readonly ContextPackSectionKey[];
|
|
272
|
+
/**
|
|
273
|
+
* Token budget allocation ratios per section.
|
|
274
|
+
* These sum to 1.0 and determine how the total tokenBudget is divided.
|
|
275
|
+
*
|
|
276
|
+
* Rationale:
|
|
277
|
+
* - invariants (0.28): Highest-priority constraints, injected first
|
|
278
|
+
* - activeBeliefs (0.30): Largest section, carries domain knowledge
|
|
279
|
+
* - openQuestions (0.17): Unresolved work items guide agent behavior
|
|
280
|
+
* - recentEvidence (0.17): Implementation context for grounding
|
|
281
|
+
* - contradictions (0.08): Tension signals, smallest section
|
|
282
|
+
*/
|
|
283
|
+
declare const SECTION_BUDGET_RATIOS: Readonly<Record<ContextPackSectionKey, number>>;
|
|
284
|
+
/** Minimum allowed token budget. Below this, context packs lose utility. */
|
|
285
|
+
declare const MIN_TOKEN_BUDGET = 400;
|
|
286
|
+
/** Maximum allowed token budget. Above this, context packs bloat prompts. */
|
|
287
|
+
declare const MAX_TOKEN_BUDGET = 8000;
|
|
288
|
+
/** Default token budget when caller does not specify. */
|
|
289
|
+
declare const DEFAULT_TOKEN_BUDGET = 1800;
|
|
290
|
+
/** Default max items per section. */
|
|
291
|
+
declare const DEFAULT_SECTION_LIMIT = 8;
|
|
292
|
+
/** Hard ceiling on items per section. */
|
|
293
|
+
declare const MAX_SECTION_LIMIT = 25;
|
|
294
|
+
/** Minimum contradiction section budget floor (tokens). */
|
|
295
|
+
declare const MIN_CONTRADICTION_BUDGET = 40;
|
|
296
|
+
/**
|
|
297
|
+
* Weight vectors for the weighted_v1 ranking profile.
|
|
298
|
+
* Each section has a different signal mix:
|
|
299
|
+
*
|
|
300
|
+
* - query: How many query tokens appear in the candidate text
|
|
301
|
+
* - recency: Exponential decay from updatedAt (half-life = 30 days)
|
|
302
|
+
* - confidence: Belief confidence score [0,1]
|
|
303
|
+
* - beliefType: Bonus for invariant > tenet > principle > other
|
|
304
|
+
* - priority: Question priority (critical > high > medium > low)
|
|
305
|
+
* - severity: Contradiction severity (critical > high > medium > low)
|
|
306
|
+
*/
|
|
307
|
+
type RankingWeightVector = {
|
|
308
|
+
query: number;
|
|
309
|
+
recency: number;
|
|
310
|
+
confidence?: number;
|
|
311
|
+
beliefType?: number;
|
|
312
|
+
priority?: number;
|
|
313
|
+
severity?: number;
|
|
314
|
+
};
|
|
315
|
+
declare const RANKING_WEIGHTS: Readonly<Record<ContextPackSectionKey, RankingWeightVector>>;
|
|
316
|
+
/** Recency decay half-life in days. After 30 days, recency score = 0.5. */
|
|
317
|
+
declare const RECENCY_HALF_LIFE_DAYS = 30;
|
|
318
|
+
/**
|
|
319
|
+
* Ranking weight vector for the relatedEntities section.
|
|
320
|
+
* Entities are ranked by query relevance and connectivity (bridge edge count).
|
|
321
|
+
* Separate from RANKING_WEIGHTS because entities are not part of the
|
|
322
|
+
* token-budgeted injection plan.
|
|
323
|
+
*/
|
|
324
|
+
declare const ENTITY_RANKING_WEIGHTS: {
|
|
325
|
+
readonly query: 0.4;
|
|
326
|
+
readonly connectivity: 0.6;
|
|
327
|
+
};
|
|
328
|
+
/** Default max entities to include in the context pack. */
|
|
329
|
+
declare const DEFAULT_ENTITY_LIMIT = 10;
|
|
330
|
+
/** Hard ceiling on entities per context pack. */
|
|
331
|
+
declare const MAX_ENTITY_LIMIT = 50;
|
|
332
|
+
/**
|
|
333
|
+
* Bonus multiplier for belief types in ranking.
|
|
334
|
+
* Invariants get 1.0, unknown types get 0.4.
|
|
335
|
+
*/
|
|
336
|
+
declare const BELIEF_TYPE_BONUS: Readonly<Record<string, number>>;
|
|
337
|
+
declare const DEFAULT_BELIEF_TYPE_BONUS = 0.4;
|
|
338
|
+
declare const PRIORITY_SCORES: Readonly<Record<string, number>>;
|
|
339
|
+
declare const DEFAULT_PRIORITY_SCORE = 0.5;
|
|
340
|
+
declare const SEVERITY_SCORES: Readonly<Record<string, number>>;
|
|
341
|
+
declare const DEFAULT_SEVERITY_SCORE = 0.5;
|
|
342
|
+
/** A ranked belief in the invariants or activeBeliefs section. */
|
|
343
|
+
type ContextPackBelief = {
|
|
344
|
+
nodeId: string;
|
|
345
|
+
canonicalText: string;
|
|
346
|
+
confidence: number | null;
|
|
347
|
+
beliefType: string | null;
|
|
348
|
+
score: number;
|
|
349
|
+
/** Present in activeBeliefs, absent in invariants */
|
|
350
|
+
status?: string;
|
|
351
|
+
updatedAt?: number | null;
|
|
352
|
+
/** Human-readable explanation of why this item was ranked here (RS-2). */
|
|
353
|
+
justification?: string;
|
|
354
|
+
};
|
|
355
|
+
/** A ranked question in the openQuestions section. */
|
|
356
|
+
type ContextPackQuestion = {
|
|
357
|
+
questionId: string;
|
|
358
|
+
text: string;
|
|
359
|
+
status: string;
|
|
360
|
+
priority: string;
|
|
361
|
+
updatedAt?: number | null;
|
|
362
|
+
score: number;
|
|
363
|
+
/** Human-readable explanation of why this item was ranked here (RS-2). */
|
|
364
|
+
justification?: string;
|
|
365
|
+
};
|
|
366
|
+
/** A ranked evidence item in the recentEvidence section. */
|
|
367
|
+
type ContextPackEvidence = {
|
|
368
|
+
nodeId: string;
|
|
369
|
+
canonicalText: string;
|
|
370
|
+
sourceUrl: string | null;
|
|
371
|
+
kind: string;
|
|
372
|
+
createdAt: number | null;
|
|
373
|
+
score: number;
|
|
374
|
+
/** Human-readable explanation of why this item was ranked here (RS-2). */
|
|
375
|
+
justification?: string;
|
|
376
|
+
};
|
|
377
|
+
/** A ranked contradiction in the contradictions section. */
|
|
378
|
+
type ContextPackContradiction = {
|
|
379
|
+
contradictionId: string;
|
|
380
|
+
severity: string;
|
|
381
|
+
status: string;
|
|
382
|
+
description: string;
|
|
383
|
+
score: number;
|
|
384
|
+
/** Human-readable explanation of why this item was ranked here (RS-2). */
|
|
385
|
+
justification?: string;
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* An entity from the ontological layer surfaced in the context pack.
|
|
389
|
+
* Entities are domain objects (companies, people, functions, etc.) connected
|
|
390
|
+
* to beliefs via bridge edges. They provide the "reality anchor" that makes
|
|
391
|
+
* the reasoning graph domain-aware.
|
|
392
|
+
*/
|
|
393
|
+
type ContextPackEntity = {
|
|
394
|
+
/** Convex document ID of the entity node. */
|
|
395
|
+
nodeId: string;
|
|
396
|
+
/** Entity type (e.g., "company", "person", "function"). */
|
|
397
|
+
entityType: string;
|
|
398
|
+
/** Human-readable title/name of the entity. */
|
|
399
|
+
title: string;
|
|
400
|
+
/** Number of beliefs connected to this entity via bridge edges. */
|
|
401
|
+
connectedBeliefCount: number;
|
|
402
|
+
/** Number of evidence items referencing this entity. */
|
|
403
|
+
connectedEvidenceCount: number;
|
|
404
|
+
/** Relevance score from ranking algorithm. */
|
|
405
|
+
score: number;
|
|
406
|
+
/** Entity metadata (structured per ontology schema). */
|
|
407
|
+
metadata?: Record<string, unknown>;
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* A lattice seed entry representing a belief that was auto-generated
|
|
411
|
+
* to cover an ontology entity type within a topic scope.
|
|
412
|
+
*/
|
|
413
|
+
type BeliefLatticeSeed = {
|
|
414
|
+
/** The belief node ID that was created or already existed. */
|
|
415
|
+
beliefNodeId: string;
|
|
416
|
+
/** The entity type this seed belief covers. */
|
|
417
|
+
entityType: string;
|
|
418
|
+
/** Whether this seed was newly created or already existed. */
|
|
419
|
+
created: boolean;
|
|
420
|
+
/** The canonical text of the seed belief. */
|
|
421
|
+
canonicalText: string;
|
|
422
|
+
};
|
|
423
|
+
/** Counts and scoped health signals for the context pack. */
|
|
424
|
+
type ContextPackSummary = {
|
|
425
|
+
totalBeliefs: number;
|
|
426
|
+
invariants: number;
|
|
427
|
+
openQuestions: number;
|
|
428
|
+
evidenceItems: number;
|
|
429
|
+
contradictions: number;
|
|
430
|
+
/** Number of ontological entities in scope (optional, present when entity graph is active). */
|
|
431
|
+
relatedEntities?: number;
|
|
432
|
+
scopedTopics: number;
|
|
433
|
+
descendantDepth: number;
|
|
434
|
+
query: string | null;
|
|
435
|
+
};
|
|
436
|
+
/** A failed approach surfaced from the failure log for anti-repetition. */
|
|
437
|
+
type ContextPackFailure = {
|
|
438
|
+
/** Lucern attempt/evidence node ID. */
|
|
439
|
+
attemptId: string;
|
|
440
|
+
/** What was tried. */
|
|
441
|
+
approach: string;
|
|
442
|
+
/** Why it failed. */
|
|
443
|
+
outcome: string;
|
|
444
|
+
/** When the attempt was recorded (ms since epoch). */
|
|
445
|
+
recordedAt: number;
|
|
446
|
+
/** Relevance score from ranking algorithm. */
|
|
447
|
+
score: number;
|
|
448
|
+
};
|
|
449
|
+
/** Failure context section appended to context packs in delta mode. */
|
|
450
|
+
type ContextPackFailureContext = {
|
|
451
|
+
/** Ranked failed approaches relevant to the current query. */
|
|
452
|
+
failures: ContextPackFailure[];
|
|
453
|
+
/** IDs of items suppressed from other sections due to anti-repetition. */
|
|
454
|
+
suppressedIds: string[];
|
|
455
|
+
};
|
|
456
|
+
/** A verification obligation surfaced by delta compilation. */
|
|
457
|
+
type VerificationObligation = {
|
|
458
|
+
/** What must be verified. */
|
|
459
|
+
description: string;
|
|
460
|
+
/** Source of the obligation (e.g., "belief:xyz confidence drop"). */
|
|
461
|
+
source: string;
|
|
462
|
+
/** Severity: how important it is to verify. */
|
|
463
|
+
severity: "critical" | "high" | "medium" | "low";
|
|
464
|
+
};
|
|
465
|
+
/** Delta report appended to context packs when mode = "delta". */
|
|
466
|
+
type ContextPackDeltaReport = {
|
|
467
|
+
/** Items that changed since the reference point (new, updated, removed). */
|
|
468
|
+
changedItems: Array<{
|
|
469
|
+
id: string;
|
|
470
|
+
section: ContextPackSectionKey;
|
|
471
|
+
changeType: "added" | "updated" | "removed" | "confidence_changed";
|
|
472
|
+
summary: string;
|
|
473
|
+
}>;
|
|
474
|
+
/** Obligations the consuming session must verify. */
|
|
475
|
+
verificationObligations: VerificationObligation[];
|
|
476
|
+
/** Reference point for the delta (worktree ID, timestamp, or commit SHA). */
|
|
477
|
+
referencePoint: string;
|
|
478
|
+
};
|
|
479
|
+
/**
|
|
480
|
+
* Per-section weight overrides that domain packs can apply.
|
|
481
|
+
* Overrides merge with RANKING_WEIGHTS — only specified fields replace defaults.
|
|
482
|
+
*/
|
|
483
|
+
type PackWeightOverride = {
|
|
484
|
+
/** Which section to override weights for. */
|
|
485
|
+
section: ContextPackSectionKey;
|
|
486
|
+
/** Partial weight vector — only specified fields replace defaults. */
|
|
487
|
+
weights: Partial<RankingWeightVector>;
|
|
488
|
+
};
|
|
489
|
+
/** Token-budgeted section selections for prompt injection. */
|
|
490
|
+
type ContextPackInjectionPolicy = {
|
|
491
|
+
/** Total token budget for the entire context pack. */
|
|
492
|
+
tokenBudget: number;
|
|
493
|
+
/** Estimated tokens consumed across all sections. */
|
|
494
|
+
estimatedTokens: number;
|
|
495
|
+
/** Per-section token budgets derived from SECTION_BUDGET_RATIOS. */
|
|
496
|
+
sectionBudgets: Record<ContextPackSectionKey, number>;
|
|
497
|
+
/** Actual token usage per section after greedy fill. */
|
|
498
|
+
sectionUsage: Record<ContextPackSectionKey, number>;
|
|
499
|
+
/** Node/question IDs selected for injection, per section. */
|
|
500
|
+
selected: Record<ContextPackSectionKey, string[]>;
|
|
501
|
+
/** Items that were scored but excluded from injection, with reason (RS-2). */
|
|
502
|
+
excludedItems?: Array<{
|
|
503
|
+
id: string;
|
|
504
|
+
section: ContextPackSectionKey;
|
|
505
|
+
reason: "budget_exceeded" | "anti_repetition" | "below_threshold";
|
|
506
|
+
score: number;
|
|
507
|
+
}>;
|
|
508
|
+
};
|
|
509
|
+
/** Telemetry for context pack assembly. */
|
|
510
|
+
type ContextPackDiagnostics = {
|
|
511
|
+
/** Total candidates scored across all sections. */
|
|
512
|
+
itemsScored: number;
|
|
513
|
+
/** Ratio of estimatedTokens / tokenBudget. Range [0, 1+]. */
|
|
514
|
+
tokenBudgetUtilization: number;
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* Public context surface returned by the SDK-facing context client.
|
|
518
|
+
*
|
|
519
|
+
* This preserves the existing external shape while the canonical compiler
|
|
520
|
+
* contract evolves in parallel as ContextPackV1.
|
|
521
|
+
*/
|
|
522
|
+
type PublicContextBelief = {
|
|
523
|
+
beliefId: string;
|
|
524
|
+
text: string;
|
|
525
|
+
confidence: number | null;
|
|
526
|
+
beliefType?: string | null;
|
|
527
|
+
status?: string;
|
|
528
|
+
updatedAt?: number | null;
|
|
529
|
+
score: number;
|
|
530
|
+
justification?: string;
|
|
531
|
+
};
|
|
532
|
+
type PublicContextQuestion = {
|
|
533
|
+
questionId: string;
|
|
534
|
+
text: string;
|
|
535
|
+
status: string;
|
|
536
|
+
priority: string;
|
|
537
|
+
updatedAt?: number | null;
|
|
538
|
+
score: number;
|
|
539
|
+
justification?: string;
|
|
540
|
+
};
|
|
541
|
+
type PublicContextEvidence = {
|
|
542
|
+
evidenceId: string;
|
|
543
|
+
text: string;
|
|
544
|
+
sourceUrl?: string | null;
|
|
545
|
+
kind: string;
|
|
546
|
+
createdAt?: number | null;
|
|
547
|
+
score: number;
|
|
548
|
+
justification?: string;
|
|
549
|
+
};
|
|
550
|
+
type PublicContextContradiction = {
|
|
551
|
+
contradictionId: string;
|
|
552
|
+
severity: string;
|
|
553
|
+
status: string;
|
|
554
|
+
description: string;
|
|
555
|
+
score: number;
|
|
556
|
+
justification?: string;
|
|
557
|
+
};
|
|
558
|
+
type PublicContextEntity = {
|
|
559
|
+
entityId: string;
|
|
560
|
+
entityType: string;
|
|
561
|
+
title: string;
|
|
562
|
+
text?: string;
|
|
563
|
+
connectedBeliefCount: number;
|
|
564
|
+
connectedEvidenceCount: number;
|
|
565
|
+
score: number;
|
|
566
|
+
metadata?: Record<string, unknown>;
|
|
567
|
+
};
|
|
568
|
+
type PublicContextInjectionPolicy = {
|
|
569
|
+
tokenBudget: number;
|
|
570
|
+
estimatedTokens: number;
|
|
571
|
+
sectionBudgets: Record<string, number>;
|
|
572
|
+
sectionUsage: Record<string, number>;
|
|
573
|
+
selected: Record<string, string[]>;
|
|
574
|
+
excludedItems?: Array<{
|
|
575
|
+
id: string;
|
|
576
|
+
section: string;
|
|
577
|
+
reason: "budget_exceeded" | "anti_repetition" | "below_threshold";
|
|
578
|
+
score: number;
|
|
579
|
+
}>;
|
|
580
|
+
};
|
|
581
|
+
type PublicCompiledContext = {
|
|
582
|
+
schemaVersion: string;
|
|
583
|
+
topicId: string;
|
|
584
|
+
topicName: string;
|
|
585
|
+
scopedTopicIds: string[];
|
|
586
|
+
generatedAt: number;
|
|
587
|
+
ranking: ContextRankingProfile;
|
|
588
|
+
summary: Record<string, unknown>;
|
|
589
|
+
invariants: PublicContextBelief[];
|
|
590
|
+
activeBeliefs: PublicContextBelief[];
|
|
591
|
+
openQuestions: PublicContextQuestion[];
|
|
592
|
+
recentEvidence: PublicContextEvidence[];
|
|
593
|
+
contradictions: PublicContextContradiction[];
|
|
594
|
+
relatedEntities?: PublicContextEntity[];
|
|
595
|
+
contextNarrative: string[];
|
|
596
|
+
injectionPolicy: PublicContextInjectionPolicy;
|
|
597
|
+
diagnostics: Record<string, unknown>;
|
|
598
|
+
compilationMode?: string;
|
|
599
|
+
failureContext?: {
|
|
600
|
+
failures: Array<{
|
|
601
|
+
attemptId: string;
|
|
602
|
+
approach: string;
|
|
603
|
+
outcome: string;
|
|
604
|
+
recordedAt: number;
|
|
605
|
+
score: number;
|
|
606
|
+
}>;
|
|
607
|
+
suppressedIds: string[];
|
|
608
|
+
};
|
|
609
|
+
deltaReport?: {
|
|
610
|
+
changedItems: Array<{
|
|
611
|
+
id: string;
|
|
612
|
+
section: string;
|
|
613
|
+
changeType: string;
|
|
614
|
+
summary: string;
|
|
615
|
+
}>;
|
|
616
|
+
verificationObligations: Array<{
|
|
617
|
+
description: string;
|
|
618
|
+
source: string;
|
|
619
|
+
severity: "critical" | "high" | "medium" | "low";
|
|
620
|
+
}>;
|
|
621
|
+
referencePoint: string;
|
|
622
|
+
};
|
|
623
|
+
appliedWeightOverrides?: unknown[];
|
|
624
|
+
};
|
|
625
|
+
/**
|
|
626
|
+
* The canonical output schema for context compilation responses.
|
|
627
|
+
*
|
|
628
|
+
* This is the contract that consumers depend on. All fields are required
|
|
629
|
+
* in the output. Adding optional fields is non-breaking; removing or
|
|
630
|
+
* changing types is breaking (requires version bump).
|
|
631
|
+
*/
|
|
632
|
+
type ContextPackV1 = {
|
|
633
|
+
/** Schema version for compatibility checking. */
|
|
634
|
+
schemaVersion: typeof CONTEXT_PACK_SCHEMA_VERSION;
|
|
635
|
+
/** Deprecated compatibility alias for the requested scope ID. */
|
|
636
|
+
projectId?: string;
|
|
637
|
+
/** Resolved topic ID after scope resolution. */
|
|
638
|
+
topicId: string;
|
|
639
|
+
/** Human-readable topic name. */
|
|
640
|
+
topicName: string;
|
|
641
|
+
/** All topic IDs included in the neighborhood expansion. */
|
|
642
|
+
scopedTopicIds: string[];
|
|
643
|
+
/** Deterministic freshness watermark for this pack (ms since epoch). */
|
|
644
|
+
generatedAt: number;
|
|
645
|
+
/** Which ranking profile was used. */
|
|
646
|
+
rankingProfile: ContextRankingProfile;
|
|
647
|
+
/** Aggregate counts and health signals. */
|
|
648
|
+
summary: ContextPackSummary;
|
|
649
|
+
/** High-confidence invariant beliefs (beliefType = "invariant"). */
|
|
650
|
+
invariants: ContextPackBelief[];
|
|
651
|
+
/** Active beliefs ranked by query relevance. */
|
|
652
|
+
activeBeliefs: ContextPackBelief[];
|
|
653
|
+
/** Open questions ranked by relevance and priority. */
|
|
654
|
+
openQuestions: ContextPackQuestion[];
|
|
655
|
+
/** Recent evidence ranked by relevance and recency. */
|
|
656
|
+
recentEvidence: ContextPackEvidence[];
|
|
657
|
+
/** Active contradictions ranked by severity. */
|
|
658
|
+
contradictions: ContextPackContradiction[];
|
|
659
|
+
/**
|
|
660
|
+
* Ontological entities connected to beliefs in scope, ranked by connectivity.
|
|
661
|
+
* Optional — present when entity graph substrate is active for this topic.
|
|
662
|
+
* NON-BREAKING addition per contract rules.
|
|
663
|
+
*/
|
|
664
|
+
relatedEntities?: ContextPackEntity[];
|
|
665
|
+
/** Concise instructions for agent context injection. */
|
|
666
|
+
contextNarrative: string[];
|
|
667
|
+
/** Token-budgeted injection selections. */
|
|
668
|
+
injectionPolicy: ContextPackInjectionPolicy;
|
|
669
|
+
/** Assembly telemetry. */
|
|
670
|
+
diagnostics: ContextPackDiagnostics;
|
|
671
|
+
/** Compilation mode used to generate this pack (RS-2). Default: "standard". */
|
|
672
|
+
compilationMode?: ContextCompilationMode;
|
|
673
|
+
/** Failure context for anti-repetition (RS-2). Present when failures are relevant. */
|
|
674
|
+
failureContext?: ContextPackFailureContext;
|
|
675
|
+
/** Delta report (RS-2). Present only when compilationMode = "delta". */
|
|
676
|
+
deltaReport?: ContextPackDeltaReport;
|
|
677
|
+
/** Pack weight overrides applied during ranking (RS-2). */
|
|
678
|
+
appliedWeightOverrides?: PackWeightOverride[];
|
|
679
|
+
};
|
|
680
|
+
/**
|
|
681
|
+
* The canonical input schema for `compile_context`.
|
|
682
|
+
* `topicId` is canonical. `projectId` remains an optional compatibility alias.
|
|
683
|
+
*/
|
|
684
|
+
type ContextPackRequestV1 = {
|
|
685
|
+
/** Topic scope ID (required). */
|
|
686
|
+
topicId: string;
|
|
687
|
+
/** Deprecated compatibility alias for older callers. */
|
|
688
|
+
projectId?: string;
|
|
689
|
+
/** Focus query for relevance ranking. */
|
|
690
|
+
query?: string;
|
|
691
|
+
/** Max items per section. Default: DEFAULT_SECTION_LIMIT. */
|
|
692
|
+
limit?: number;
|
|
693
|
+
/** Ranking profile. Default: DEFAULT_RANKING_PROFILE. */
|
|
694
|
+
rankingProfile?: ContextRankingProfile;
|
|
695
|
+
/** Total token budget. Default: DEFAULT_TOKEN_BUDGET. */
|
|
696
|
+
tokenBudget?: number;
|
|
697
|
+
/** Descendant topic depth for neighborhood expansion. */
|
|
698
|
+
maxDepth?: number;
|
|
699
|
+
/** Include ontological entities connected to beliefs in scope. Default: true. */
|
|
700
|
+
includeEntities?: boolean;
|
|
701
|
+
/** Compilation mode (RS-2). Default: "standard". */
|
|
702
|
+
mode?: ContextCompilationMode;
|
|
703
|
+
/** Include failure log context for anti-repetition (RS-2). Default: false. */
|
|
704
|
+
includeFailures?: boolean;
|
|
705
|
+
/** Active worktree ID for delta mode reference point (RS-2). */
|
|
706
|
+
worktreeId?: string;
|
|
707
|
+
/** Session ID for anti-repetition dedup (RS-2). */
|
|
708
|
+
sessionId?: string;
|
|
709
|
+
/** Pack weight overrides from domain pack binding (RS-2). */
|
|
710
|
+
packWeightOverrides?: PackWeightOverride[];
|
|
711
|
+
};
|
|
712
|
+
/**
|
|
713
|
+
* Question statuses that are considered "resolved" (not open).
|
|
714
|
+
* Used to filter which questions appear in the openQuestions section.
|
|
715
|
+
*/
|
|
716
|
+
declare const RESOLVED_QUESTION_STATUSES: readonly string[];
|
|
717
|
+
/**
|
|
718
|
+
* Tokens-per-word multiplier for rough token estimation.
|
|
719
|
+
* Conservative estimate: ~1.35 tokens per whitespace-delimited word.
|
|
720
|
+
*/
|
|
721
|
+
declare const TOKENS_PER_WORD = 1.35;
|
|
722
|
+
/** Minimum token estimate for any non-empty string. */
|
|
723
|
+
declare const MIN_TOKEN_ESTIMATE = 8;
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* @lucern/contracts — events (canonical support contract)
|
|
727
|
+
*
|
|
728
|
+
* Consolidated flat support surface for Lucern's domain event stream:
|
|
729
|
+
* - Event type definitions, constants, and shared enums
|
|
730
|
+
* - Event construction + cursor helpers
|
|
731
|
+
*
|
|
732
|
+
* Consolidated from the former split type-definition module
|
|
733
|
+
* and the prior src/events.contract.ts (helpers) in EK-16 T1 PR 3b.
|
|
734
|
+
* Compat shim remains at the old events-types path until Lucern 1.0.0 (D12).
|
|
735
|
+
*/
|
|
736
|
+
declare const DOMAIN_EVENT_VERSION: "1.0";
|
|
737
|
+
declare const EVENT_RETENTION_DEFAULT_DAYS = 30;
|
|
738
|
+
declare const WEBHOOK_MAX_ATTEMPTS = 5;
|
|
739
|
+
declare const WEBHOOK_RETRY_DELAYS_MS: readonly [1000, 5000, 30000, 300000];
|
|
740
|
+
declare const DOMAIN_EVENT_TYPES: readonly ["belief.created", "belief.forked", "belief.confidence_updated", "belief.archived", "belief.refined", "belief.contract_created", "belief.contract_evaluated", "belief.lineage_queried", "evidence.created", "evidence.linked", "evidence.search_executed", "question.created", "question.answered", "question.refined", "question.status_updated", "question.archived", "edge.created", "contradiction.flagged", "worktree.created", "worktree.activated", "worktree.merged", "worktree.targets_updated", "worktree.metadata_updated", "topic.created", "topic.updated", "topic.archived", "task.created", "task.completed", "task.updated", "ontology.bound", "context.compiled", "identity.key_created", "identity.key_rotated", "identity.key_revoked", "webhook.test"];
|
|
741
|
+
type DomainEventType = (typeof DOMAIN_EVENT_TYPES)[number];
|
|
742
|
+
type DomainResourceType = "belief" | "evidence" | "question" | "edge" | "contradiction" | "worktree" | "topic" | "task" | "ontology" | "context" | "identity" | "webhook";
|
|
743
|
+
type DomainActorType = "human" | "agent" | "service";
|
|
744
|
+
type DomainEventData = Record<string, unknown>;
|
|
745
|
+
type DomainEvent = {
|
|
746
|
+
eventId: string;
|
|
747
|
+
type: DomainEventType | string;
|
|
748
|
+
version: typeof DOMAIN_EVENT_VERSION;
|
|
749
|
+
timestamp: number;
|
|
750
|
+
tenantId?: string;
|
|
751
|
+
workspaceId?: string;
|
|
752
|
+
topicId: string;
|
|
753
|
+
resourceId: string;
|
|
754
|
+
resourceType: DomainResourceType | string;
|
|
755
|
+
actorId: string;
|
|
756
|
+
actorType: DomainActorType;
|
|
757
|
+
data: DomainEventData;
|
|
758
|
+
correlationId?: string;
|
|
759
|
+
expiresAt: number;
|
|
760
|
+
};
|
|
761
|
+
type CreateDomainEventInput = {
|
|
762
|
+
eventId?: string;
|
|
763
|
+
timestamp?: number;
|
|
764
|
+
tenantId?: string;
|
|
765
|
+
workspaceId?: string;
|
|
766
|
+
topicId: string;
|
|
767
|
+
type: DomainEventType | string;
|
|
768
|
+
resourceId: string;
|
|
769
|
+
resourceType: DomainResourceType | string;
|
|
770
|
+
actorId: string;
|
|
771
|
+
actorType: DomainActorType;
|
|
772
|
+
data?: DomainEventData;
|
|
773
|
+
correlationId?: string;
|
|
774
|
+
retentionDays?: number;
|
|
775
|
+
};
|
|
776
|
+
type EventCursor = {
|
|
777
|
+
timestamp: number;
|
|
778
|
+
eventId: string;
|
|
779
|
+
};
|
|
780
|
+
type EventListQuery = {
|
|
781
|
+
topicId?: string;
|
|
782
|
+
after?: string;
|
|
783
|
+
types?: string[];
|
|
784
|
+
startTime?: number;
|
|
785
|
+
endTime?: number;
|
|
786
|
+
limit?: number;
|
|
787
|
+
};
|
|
788
|
+
type EventListResult = {
|
|
789
|
+
events: DomainEvent[];
|
|
790
|
+
nextCursor: string | null;
|
|
791
|
+
};
|
|
792
|
+
type WebhookSecretMode = "configured";
|
|
793
|
+
type WebhookRecord = {
|
|
794
|
+
id: string;
|
|
795
|
+
webhookId: string;
|
|
796
|
+
tenantId?: string;
|
|
797
|
+
workspaceId?: string;
|
|
798
|
+
topicId?: string;
|
|
799
|
+
url: string;
|
|
800
|
+
events: string[];
|
|
801
|
+
active: boolean;
|
|
802
|
+
secretConfigured: boolean;
|
|
803
|
+
createdAt: number;
|
|
804
|
+
updatedAt: number;
|
|
805
|
+
createdBy: string;
|
|
806
|
+
updatedBy: string;
|
|
807
|
+
lastDeliveryAt?: number;
|
|
808
|
+
lastSuccessfulDeliveryAt?: number;
|
|
809
|
+
};
|
|
810
|
+
type WebhookCreateInput = {
|
|
811
|
+
url: string;
|
|
812
|
+
events: string[];
|
|
813
|
+
secret: string;
|
|
814
|
+
topicId?: string;
|
|
815
|
+
active?: boolean;
|
|
816
|
+
};
|
|
817
|
+
type WebhookUpdateInput = {
|
|
818
|
+
url?: string;
|
|
819
|
+
events?: string[];
|
|
820
|
+
secret?: string;
|
|
821
|
+
topicId?: string | null;
|
|
822
|
+
active?: boolean;
|
|
823
|
+
};
|
|
824
|
+
type WebhookDeliveryStatus = "pending" | "delivering" | "succeeded" | "failed" | "dead_letter";
|
|
825
|
+
type WebhookDeliveryRecord = {
|
|
826
|
+
id: string;
|
|
827
|
+
deliveryId: string;
|
|
828
|
+
webhookId: string;
|
|
829
|
+
eventId: string;
|
|
830
|
+
eventType: string;
|
|
831
|
+
topicId: string;
|
|
832
|
+
status: WebhookDeliveryStatus;
|
|
833
|
+
attemptCount: number;
|
|
834
|
+
maxAttempts: number;
|
|
835
|
+
nextAttemptAt?: number;
|
|
836
|
+
lastAttemptAt?: number;
|
|
837
|
+
lastStatusCode?: number;
|
|
838
|
+
lastError?: string;
|
|
839
|
+
deliveredAt?: number;
|
|
840
|
+
createdAt: number;
|
|
841
|
+
updatedAt: number;
|
|
842
|
+
};
|
|
843
|
+
type WebhookDeliveryAttemptRecord = {
|
|
844
|
+
id: string;
|
|
845
|
+
attemptId: string;
|
|
846
|
+
deliveryId: string;
|
|
847
|
+
webhookId: string;
|
|
848
|
+
eventId: string;
|
|
849
|
+
eventType: string;
|
|
850
|
+
attemptNumber: number;
|
|
851
|
+
status: "succeeded" | "failed";
|
|
852
|
+
statusCode?: number;
|
|
853
|
+
error?: string;
|
|
854
|
+
responseBody?: string;
|
|
855
|
+
durationMs?: number;
|
|
856
|
+
createdAt: number;
|
|
857
|
+
};
|
|
858
|
+
type WebhookDeliveriesResult = {
|
|
859
|
+
deliveries: Array<WebhookDeliveryRecord & {
|
|
860
|
+
attempts?: WebhookDeliveryAttemptRecord[];
|
|
861
|
+
}>;
|
|
862
|
+
};
|
|
863
|
+
type WebhookHealthResult = {
|
|
864
|
+
webhookId: string;
|
|
865
|
+
totalAttempts: number;
|
|
866
|
+
successfulAttempts: number;
|
|
867
|
+
failedAttempts: number;
|
|
868
|
+
successRate: number;
|
|
869
|
+
pendingDeliveries: number;
|
|
870
|
+
deadLetterDeliveries: number;
|
|
871
|
+
lastDeliveryAt?: number;
|
|
872
|
+
lastSuccessfulDeliveryAt?: number;
|
|
873
|
+
};
|
|
874
|
+
type WebhookTestResult = {
|
|
875
|
+
webhookId: string;
|
|
876
|
+
deliveryId: string;
|
|
877
|
+
status: WebhookDeliveryStatus;
|
|
878
|
+
attempts: number;
|
|
879
|
+
};
|
|
880
|
+
type ReplayEventsInput = EventListQuery & {
|
|
881
|
+
webhookId?: string;
|
|
882
|
+
};
|
|
883
|
+
type ReplayEventsResult = EventListResult & {
|
|
884
|
+
replayedDeliveries?: number;
|
|
885
|
+
replayedWebhookId?: string;
|
|
886
|
+
};
|
|
887
|
+
declare function createEventId(): string;
|
|
888
|
+
declare function normalizeRetentionDays(value: number | undefined): number;
|
|
889
|
+
declare function buildDomainEvent(input: CreateDomainEventInput): DomainEvent;
|
|
890
|
+
declare function compareEventCursor(left: EventCursor, right: EventCursor): number;
|
|
891
|
+
declare function encodeEventCursor(cursor: EventCursor): string;
|
|
892
|
+
declare function decodeEventCursor(cursor: string | undefined): EventCursor | null;
|
|
893
|
+
declare function isAfterCursor(event: Pick<DomainEvent, "timestamp" | "eventId">, cursor: EventCursor | null): boolean;
|
|
894
|
+
declare function sortEventsByCursor<T extends Pick<DomainEvent, "timestamp" | "eventId">>(events: readonly T[]): T[];
|
|
895
|
+
declare function inferActorType(args: {
|
|
896
|
+
sessionType?: "agent" | "user";
|
|
897
|
+
authMode?: string;
|
|
898
|
+
principalType?: string;
|
|
899
|
+
}): DomainActorType;
|
|
900
|
+
declare function emitDomainEvent(invokeMutation: (reference: any, args: CreateDomainEventInput) => Promise<unknown>, input: CreateDomainEventInput): Promise<unknown>;
|
|
901
|
+
|
|
902
|
+
type DecodedPrefixedId = {
|
|
903
|
+
prefix: string;
|
|
904
|
+
value: string;
|
|
905
|
+
};
|
|
906
|
+
declare function encodePrefixedId(prefix: string, value: string): string;
|
|
907
|
+
declare function decodePrefixedId(id: string): DecodedPrefixedId;
|
|
908
|
+
declare function hasPrefixedIdPrefix(id: string, prefix: string): boolean;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* MCP Tool Contract Definitions
|
|
912
|
+
*
|
|
913
|
+
* Machine-readable source of truth for all Lucern MCP tool names,
|
|
914
|
+
* descriptions, parameters, and response schemas.
|
|
915
|
+
*
|
|
916
|
+
* CONTRACT SURFACE: These definitions are the external API for AI agents.
|
|
917
|
+
* Renaming a tool or changing its description is a BREAKING CHANGE.
|
|
918
|
+
*
|
|
919
|
+
* Git-native naming rules (enforced by lint):
|
|
920
|
+
* 1. Workflow tools use git verbs directly (add_worktree, merge, push, open_pull_request)
|
|
921
|
+
* 2. Knowledge tools use epistemic verbs (create_belief, fork_belief, modulate_confidence)
|
|
922
|
+
* 3. First sentence of description includes the git analog verb
|
|
923
|
+
* 4. Description includes "Like `git X`" parenthetical
|
|
924
|
+
* 5. Parameter names use domain terms (canonicalText, nodeId, confidence)
|
|
925
|
+
*/
|
|
926
|
+
type McpToolContract = {
|
|
927
|
+
/** Stable tool name — breaking change to rename */
|
|
928
|
+
name: string;
|
|
929
|
+
/** Git-semantic description — breaking change to remove git references */
|
|
930
|
+
description: string;
|
|
931
|
+
/** Parameter schema (JSON Schema subset) */
|
|
932
|
+
parameters: Record<string, McpParameterDef>;
|
|
933
|
+
/** Required parameter names */
|
|
934
|
+
required: string[];
|
|
935
|
+
/** Response shape description */
|
|
936
|
+
response: McpResponseDef;
|
|
937
|
+
/** Which Lucern module owns the implementation */
|
|
938
|
+
ownerModule: string;
|
|
939
|
+
/** Ontology primitive this tool operates on */
|
|
940
|
+
ontologyPrimitive: "belief" | "evidence" | "source" | "question" | "judgment" | "worktree" | "branch" | "lens" | "edge" | "graph" | "task" | "policy" | "ontology" | "identity";
|
|
941
|
+
/** MCP surface tier — showcase (front page, every demo) or workhorse (complete CRUD, discovered when building) */
|
|
942
|
+
tier: "showcase" | "workhorse";
|
|
943
|
+
/** Hide this tool from public discovery surfaces. */
|
|
944
|
+
internal?: boolean;
|
|
945
|
+
/** Deprecation notice shown in contract-driven docs and discovery. */
|
|
946
|
+
deprecated?: string;
|
|
947
|
+
};
|
|
948
|
+
type McpParameterDef = {
|
|
949
|
+
type: "string" | "number" | "boolean" | "array" | "object";
|
|
950
|
+
description: string;
|
|
951
|
+
required?: boolean;
|
|
952
|
+
enum?: string[];
|
|
953
|
+
};
|
|
954
|
+
type McpResponseDef = {
|
|
955
|
+
description: string;
|
|
956
|
+
fields: Record<string, string>;
|
|
957
|
+
};
|
|
958
|
+
declare const CREATE_BELIEF: McpToolContract;
|
|
959
|
+
declare const GET_BELIEF: McpToolContract;
|
|
960
|
+
declare const REFINE_BELIEF: McpToolContract;
|
|
961
|
+
declare const MODULATE_CONFIDENCE: McpToolContract;
|
|
962
|
+
declare const FORK_BELIEF: McpToolContract;
|
|
963
|
+
declare const ARCHIVE_BELIEF: McpToolContract;
|
|
964
|
+
declare const CREATE_EPISTEMIC_CONTRACT: McpToolContract;
|
|
965
|
+
declare const ADD_EVIDENCE: McpToolContract;
|
|
966
|
+
declare const FLAG_CONTRADICTION: McpToolContract;
|
|
967
|
+
declare const ADD_WORKTREE: McpToolContract;
|
|
968
|
+
declare const MERGE: McpToolContract;
|
|
969
|
+
declare const QUERY_LINEAGE: McpToolContract;
|
|
970
|
+
declare const GET_CONFIDENCE_HISTORY: McpToolContract;
|
|
971
|
+
declare const GET_AUDIT_TRAIL: McpToolContract;
|
|
972
|
+
declare const TRAVERSE_GRAPH: McpToolContract;
|
|
973
|
+
declare const GET_GRAPH_NEIGHBORHOOD: McpToolContract;
|
|
974
|
+
declare const TRACE_ENTITY_IMPACT: McpToolContract;
|
|
975
|
+
declare const SEARCH_BELIEFS: McpToolContract;
|
|
976
|
+
declare const SEARCH_RESOURCES: McpToolContract;
|
|
977
|
+
declare const FIND_CONTRADICTIONS: McpToolContract;
|
|
978
|
+
declare const CREATE_EDGE: McpToolContract;
|
|
979
|
+
declare const RECORD_JUDGMENT: McpToolContract;
|
|
980
|
+
declare const CREATE_LENS: McpToolContract;
|
|
981
|
+
declare const LIST_LENSES: McpToolContract;
|
|
982
|
+
declare const APPLY_LENS_TO_TOPIC: McpToolContract;
|
|
983
|
+
declare const REMOVE_LENS_FROM_TOPIC: McpToolContract;
|
|
984
|
+
declare const PUSH: McpToolContract;
|
|
985
|
+
declare const OPEN_PULL_REQUEST: McpToolContract;
|
|
986
|
+
declare const BISECT_CONFIDENCE: McpToolContract;
|
|
987
|
+
declare const DETECT_CONFIRMATION_BIAS: McpToolContract;
|
|
988
|
+
declare const GET_GRAPH_STRUCTURE_ANALYSIS: McpToolContract;
|
|
989
|
+
declare const GET_FALSIFICATION_QUESTIONS: McpToolContract;
|
|
990
|
+
declare const SEARCH_SOURCES: McpToolContract;
|
|
991
|
+
declare const EXECUTE_DEEP_RESEARCH: McpToolContract;
|
|
992
|
+
declare const SEARCH_EVIDENCE: McpToolContract;
|
|
993
|
+
declare const CREATE_EVIDENCE: McpToolContract;
|
|
994
|
+
declare const GET_EVIDENCE: McpToolContract;
|
|
995
|
+
declare const LIST_EVIDENCE: McpToolContract;
|
|
996
|
+
declare const LINK_EVIDENCE: McpToolContract;
|
|
997
|
+
declare const LINK_EVIDENCE_TO_BELIEF: McpToolContract;
|
|
998
|
+
declare const CREATE_QUESTION: McpToolContract;
|
|
999
|
+
declare const GET_QUESTION: McpToolContract;
|
|
1000
|
+
declare const REFINE_QUESTION: McpToolContract;
|
|
1001
|
+
declare const LIST_QUESTIONS: McpToolContract;
|
|
1002
|
+
declare const ANSWER_QUESTION: McpToolContract;
|
|
1003
|
+
declare const UPDATE_QUESTION_STATUS: McpToolContract;
|
|
1004
|
+
declare const ARCHIVE_QUESTION: McpToolContract;
|
|
1005
|
+
declare const LINK_EVIDENCE_TO_QUESTION: McpToolContract;
|
|
1006
|
+
declare const CREATE_ANSWER: McpToolContract;
|
|
1007
|
+
declare const GET_ANSWER: McpToolContract;
|
|
1008
|
+
declare const GET_HIGH_PRIORITY_QUESTIONS: McpToolContract;
|
|
1009
|
+
declare const FIND_MISSING_QUESTIONS: McpToolContract;
|
|
1010
|
+
declare const LIST_BELIEFS: McpToolContract;
|
|
1011
|
+
declare const LIST_WORKTREES: McpToolContract;
|
|
1012
|
+
declare const LIST_ALL_WORKTREES: McpToolContract;
|
|
1013
|
+
declare const ACTIVATE_WORKTREE: McpToolContract;
|
|
1014
|
+
declare const UPDATE_WORKTREE_TARGETS: McpToolContract;
|
|
1015
|
+
declare const UPDATE_WORKTREE_METADATA: McpToolContract;
|
|
1016
|
+
declare const IDENTITY_WHOAMI: McpToolContract;
|
|
1017
|
+
declare const COMPILE_CONTEXT: McpToolContract;
|
|
1018
|
+
declare const CHECK_PERMISSION: McpToolContract;
|
|
1019
|
+
declare const FILTER_BY_PERMISSION: McpToolContract;
|
|
1020
|
+
declare const INGEST_OBSERVATION: McpToolContract;
|
|
1021
|
+
declare const GET_OBSERVATION_CONTEXT: McpToolContract;
|
|
1022
|
+
declare const CREATE_TASK: McpToolContract;
|
|
1023
|
+
declare const COMPLETE_TASK: McpToolContract;
|
|
1024
|
+
declare const UPDATE_TASK$1: McpToolContract;
|
|
1025
|
+
declare const LIST_TASKS$1: McpToolContract;
|
|
1026
|
+
declare const CREATE_TOPIC: McpToolContract;
|
|
1027
|
+
declare const LIST_TOPICS: McpToolContract;
|
|
1028
|
+
declare const GET_TOPIC: McpToolContract;
|
|
1029
|
+
declare const UPDATE_TOPIC: McpToolContract;
|
|
1030
|
+
declare const GET_TOPIC_TREE: McpToolContract;
|
|
1031
|
+
declare const GET_CODE_CONTEXT: McpToolContract;
|
|
1032
|
+
declare const GET_CHANGE_HISTORY: McpToolContract;
|
|
1033
|
+
declare const RECORD_ATTEMPT: McpToolContract;
|
|
1034
|
+
declare const GET_FAILURE_LOG: McpToolContract;
|
|
1035
|
+
declare const GET_TOPIC_COVERAGE: McpToolContract;
|
|
1036
|
+
declare const GET_GRAPH_GAPS: McpToolContract;
|
|
1037
|
+
declare const MANAGE_WRITE_POLICY: McpToolContract;
|
|
1038
|
+
declare const LIST_ONTOLOGIES: McpToolContract;
|
|
1039
|
+
declare const GET_ONTOLOGY: McpToolContract;
|
|
1040
|
+
declare const APPLY_ONTOLOGY: McpToolContract;
|
|
1041
|
+
declare const MATCH_ENTITY_TYPE: McpToolContract;
|
|
1042
|
+
declare const CREATE_ONTOLOGY: McpToolContract;
|
|
1043
|
+
declare const UPDATE_ONTOLOGY: McpToolContract;
|
|
1044
|
+
declare const ARCHIVE_ONTOLOGY: McpToolContract;
|
|
1045
|
+
declare const CREATE_ONTOLOGY_VERSION: McpToolContract;
|
|
1046
|
+
declare const PUBLISH_ONTOLOGY_VERSION: McpToolContract;
|
|
1047
|
+
declare const DEPRECATE_ONTOLOGY_VERSION: McpToolContract;
|
|
1048
|
+
declare const RESOLVE_EFFECTIVE_ONTOLOGY: McpToolContract;
|
|
1049
|
+
/** All MCP tool contracts, indexed by name */
|
|
1050
|
+
declare const MCP_TOOL_CONTRACTS: Record<string, McpToolContract>;
|
|
1051
|
+
/** Tool names that MUST include git-semantic language in descriptions */
|
|
1052
|
+
declare const GIT_SEMANTIC_REQUIRED_TOOLS: string[];
|
|
1053
|
+
/**
|
|
1054
|
+
* Lint validation: every tool description must contain "Like `git" or "Like a `git"
|
|
1055
|
+
* or reference a git operation in the first sentence.
|
|
1056
|
+
*/
|
|
1057
|
+
declare function validateGitSemantics(tool: McpToolContract): {
|
|
1058
|
+
valid: boolean;
|
|
1059
|
+
reason?: string;
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
declare const mcpTools_contract_ACTIVATE_WORKTREE: typeof ACTIVATE_WORKTREE;
|
|
1063
|
+
declare const mcpTools_contract_ADD_EVIDENCE: typeof ADD_EVIDENCE;
|
|
1064
|
+
declare const mcpTools_contract_ADD_WORKTREE: typeof ADD_WORKTREE;
|
|
1065
|
+
declare const mcpTools_contract_ANSWER_QUESTION: typeof ANSWER_QUESTION;
|
|
1066
|
+
declare const mcpTools_contract_APPLY_LENS_TO_TOPIC: typeof APPLY_LENS_TO_TOPIC;
|
|
1067
|
+
declare const mcpTools_contract_APPLY_ONTOLOGY: typeof APPLY_ONTOLOGY;
|
|
1068
|
+
declare const mcpTools_contract_ARCHIVE_BELIEF: typeof ARCHIVE_BELIEF;
|
|
1069
|
+
declare const mcpTools_contract_ARCHIVE_ONTOLOGY: typeof ARCHIVE_ONTOLOGY;
|
|
1070
|
+
declare const mcpTools_contract_ARCHIVE_QUESTION: typeof ARCHIVE_QUESTION;
|
|
1071
|
+
declare const mcpTools_contract_BISECT_CONFIDENCE: typeof BISECT_CONFIDENCE;
|
|
1072
|
+
declare const mcpTools_contract_CHECK_PERMISSION: typeof CHECK_PERMISSION;
|
|
1073
|
+
declare const mcpTools_contract_COMPILE_CONTEXT: typeof COMPILE_CONTEXT;
|
|
1074
|
+
declare const mcpTools_contract_COMPLETE_TASK: typeof COMPLETE_TASK;
|
|
1075
|
+
declare const mcpTools_contract_CREATE_ANSWER: typeof CREATE_ANSWER;
|
|
1076
|
+
declare const mcpTools_contract_CREATE_BELIEF: typeof CREATE_BELIEF;
|
|
1077
|
+
declare const mcpTools_contract_CREATE_EDGE: typeof CREATE_EDGE;
|
|
1078
|
+
declare const mcpTools_contract_CREATE_EPISTEMIC_CONTRACT: typeof CREATE_EPISTEMIC_CONTRACT;
|
|
1079
|
+
declare const mcpTools_contract_CREATE_EVIDENCE: typeof CREATE_EVIDENCE;
|
|
1080
|
+
declare const mcpTools_contract_CREATE_LENS: typeof CREATE_LENS;
|
|
1081
|
+
declare const mcpTools_contract_CREATE_ONTOLOGY: typeof CREATE_ONTOLOGY;
|
|
1082
|
+
declare const mcpTools_contract_CREATE_ONTOLOGY_VERSION: typeof CREATE_ONTOLOGY_VERSION;
|
|
1083
|
+
declare const mcpTools_contract_CREATE_QUESTION: typeof CREATE_QUESTION;
|
|
1084
|
+
declare const mcpTools_contract_CREATE_TASK: typeof CREATE_TASK;
|
|
1085
|
+
declare const mcpTools_contract_CREATE_TOPIC: typeof CREATE_TOPIC;
|
|
1086
|
+
declare const mcpTools_contract_DEPRECATE_ONTOLOGY_VERSION: typeof DEPRECATE_ONTOLOGY_VERSION;
|
|
1087
|
+
declare const mcpTools_contract_DETECT_CONFIRMATION_BIAS: typeof DETECT_CONFIRMATION_BIAS;
|
|
1088
|
+
declare const mcpTools_contract_EXECUTE_DEEP_RESEARCH: typeof EXECUTE_DEEP_RESEARCH;
|
|
1089
|
+
declare const mcpTools_contract_FILTER_BY_PERMISSION: typeof FILTER_BY_PERMISSION;
|
|
1090
|
+
declare const mcpTools_contract_FIND_CONTRADICTIONS: typeof FIND_CONTRADICTIONS;
|
|
1091
|
+
declare const mcpTools_contract_FIND_MISSING_QUESTIONS: typeof FIND_MISSING_QUESTIONS;
|
|
1092
|
+
declare const mcpTools_contract_FLAG_CONTRADICTION: typeof FLAG_CONTRADICTION;
|
|
1093
|
+
declare const mcpTools_contract_FORK_BELIEF: typeof FORK_BELIEF;
|
|
1094
|
+
declare const mcpTools_contract_GET_ANSWER: typeof GET_ANSWER;
|
|
1095
|
+
declare const mcpTools_contract_GET_AUDIT_TRAIL: typeof GET_AUDIT_TRAIL;
|
|
1096
|
+
declare const mcpTools_contract_GET_BELIEF: typeof GET_BELIEF;
|
|
1097
|
+
declare const mcpTools_contract_GET_CHANGE_HISTORY: typeof GET_CHANGE_HISTORY;
|
|
1098
|
+
declare const mcpTools_contract_GET_CODE_CONTEXT: typeof GET_CODE_CONTEXT;
|
|
1099
|
+
declare const mcpTools_contract_GET_CONFIDENCE_HISTORY: typeof GET_CONFIDENCE_HISTORY;
|
|
1100
|
+
declare const mcpTools_contract_GET_EVIDENCE: typeof GET_EVIDENCE;
|
|
1101
|
+
declare const mcpTools_contract_GET_FAILURE_LOG: typeof GET_FAILURE_LOG;
|
|
1102
|
+
declare const mcpTools_contract_GET_FALSIFICATION_QUESTIONS: typeof GET_FALSIFICATION_QUESTIONS;
|
|
1103
|
+
declare const mcpTools_contract_GET_GRAPH_GAPS: typeof GET_GRAPH_GAPS;
|
|
1104
|
+
declare const mcpTools_contract_GET_GRAPH_NEIGHBORHOOD: typeof GET_GRAPH_NEIGHBORHOOD;
|
|
1105
|
+
declare const mcpTools_contract_GET_GRAPH_STRUCTURE_ANALYSIS: typeof GET_GRAPH_STRUCTURE_ANALYSIS;
|
|
1106
|
+
declare const mcpTools_contract_GET_HIGH_PRIORITY_QUESTIONS: typeof GET_HIGH_PRIORITY_QUESTIONS;
|
|
1107
|
+
declare const mcpTools_contract_GET_OBSERVATION_CONTEXT: typeof GET_OBSERVATION_CONTEXT;
|
|
1108
|
+
declare const mcpTools_contract_GET_ONTOLOGY: typeof GET_ONTOLOGY;
|
|
1109
|
+
declare const mcpTools_contract_GET_QUESTION: typeof GET_QUESTION;
|
|
1110
|
+
declare const mcpTools_contract_GET_TOPIC: typeof GET_TOPIC;
|
|
1111
|
+
declare const mcpTools_contract_GET_TOPIC_COVERAGE: typeof GET_TOPIC_COVERAGE;
|
|
1112
|
+
declare const mcpTools_contract_GET_TOPIC_TREE: typeof GET_TOPIC_TREE;
|
|
1113
|
+
declare const mcpTools_contract_GIT_SEMANTIC_REQUIRED_TOOLS: typeof GIT_SEMANTIC_REQUIRED_TOOLS;
|
|
1114
|
+
declare const mcpTools_contract_IDENTITY_WHOAMI: typeof IDENTITY_WHOAMI;
|
|
1115
|
+
declare const mcpTools_contract_INGEST_OBSERVATION: typeof INGEST_OBSERVATION;
|
|
1116
|
+
declare const mcpTools_contract_LINK_EVIDENCE: typeof LINK_EVIDENCE;
|
|
1117
|
+
declare const mcpTools_contract_LINK_EVIDENCE_TO_BELIEF: typeof LINK_EVIDENCE_TO_BELIEF;
|
|
1118
|
+
declare const mcpTools_contract_LINK_EVIDENCE_TO_QUESTION: typeof LINK_EVIDENCE_TO_QUESTION;
|
|
1119
|
+
declare const mcpTools_contract_LIST_ALL_WORKTREES: typeof LIST_ALL_WORKTREES;
|
|
1120
|
+
declare const mcpTools_contract_LIST_BELIEFS: typeof LIST_BELIEFS;
|
|
1121
|
+
declare const mcpTools_contract_LIST_EVIDENCE: typeof LIST_EVIDENCE;
|
|
1122
|
+
declare const mcpTools_contract_LIST_LENSES: typeof LIST_LENSES;
|
|
1123
|
+
declare const mcpTools_contract_LIST_ONTOLOGIES: typeof LIST_ONTOLOGIES;
|
|
1124
|
+
declare const mcpTools_contract_LIST_QUESTIONS: typeof LIST_QUESTIONS;
|
|
1125
|
+
declare const mcpTools_contract_LIST_TOPICS: typeof LIST_TOPICS;
|
|
1126
|
+
declare const mcpTools_contract_LIST_WORKTREES: typeof LIST_WORKTREES;
|
|
1127
|
+
declare const mcpTools_contract_MANAGE_WRITE_POLICY: typeof MANAGE_WRITE_POLICY;
|
|
1128
|
+
declare const mcpTools_contract_MATCH_ENTITY_TYPE: typeof MATCH_ENTITY_TYPE;
|
|
1129
|
+
declare const mcpTools_contract_MCP_TOOL_CONTRACTS: typeof MCP_TOOL_CONTRACTS;
|
|
1130
|
+
declare const mcpTools_contract_MERGE: typeof MERGE;
|
|
1131
|
+
declare const mcpTools_contract_MODULATE_CONFIDENCE: typeof MODULATE_CONFIDENCE;
|
|
1132
|
+
type mcpTools_contract_McpParameterDef = McpParameterDef;
|
|
1133
|
+
type mcpTools_contract_McpResponseDef = McpResponseDef;
|
|
1134
|
+
type mcpTools_contract_McpToolContract = McpToolContract;
|
|
1135
|
+
declare const mcpTools_contract_OPEN_PULL_REQUEST: typeof OPEN_PULL_REQUEST;
|
|
1136
|
+
declare const mcpTools_contract_PUBLISH_ONTOLOGY_VERSION: typeof PUBLISH_ONTOLOGY_VERSION;
|
|
1137
|
+
declare const mcpTools_contract_PUSH: typeof PUSH;
|
|
1138
|
+
declare const mcpTools_contract_QUERY_LINEAGE: typeof QUERY_LINEAGE;
|
|
1139
|
+
declare const mcpTools_contract_RECORD_ATTEMPT: typeof RECORD_ATTEMPT;
|
|
1140
|
+
declare const mcpTools_contract_RECORD_JUDGMENT: typeof RECORD_JUDGMENT;
|
|
1141
|
+
declare const mcpTools_contract_REFINE_BELIEF: typeof REFINE_BELIEF;
|
|
1142
|
+
declare const mcpTools_contract_REFINE_QUESTION: typeof REFINE_QUESTION;
|
|
1143
|
+
declare const mcpTools_contract_REMOVE_LENS_FROM_TOPIC: typeof REMOVE_LENS_FROM_TOPIC;
|
|
1144
|
+
declare const mcpTools_contract_RESOLVE_EFFECTIVE_ONTOLOGY: typeof RESOLVE_EFFECTIVE_ONTOLOGY;
|
|
1145
|
+
declare const mcpTools_contract_SEARCH_BELIEFS: typeof SEARCH_BELIEFS;
|
|
1146
|
+
declare const mcpTools_contract_SEARCH_EVIDENCE: typeof SEARCH_EVIDENCE;
|
|
1147
|
+
declare const mcpTools_contract_SEARCH_RESOURCES: typeof SEARCH_RESOURCES;
|
|
1148
|
+
declare const mcpTools_contract_SEARCH_SOURCES: typeof SEARCH_SOURCES;
|
|
1149
|
+
declare const mcpTools_contract_TRACE_ENTITY_IMPACT: typeof TRACE_ENTITY_IMPACT;
|
|
1150
|
+
declare const mcpTools_contract_TRAVERSE_GRAPH: typeof TRAVERSE_GRAPH;
|
|
1151
|
+
declare const mcpTools_contract_UPDATE_ONTOLOGY: typeof UPDATE_ONTOLOGY;
|
|
1152
|
+
declare const mcpTools_contract_UPDATE_QUESTION_STATUS: typeof UPDATE_QUESTION_STATUS;
|
|
1153
|
+
declare const mcpTools_contract_UPDATE_TOPIC: typeof UPDATE_TOPIC;
|
|
1154
|
+
declare const mcpTools_contract_UPDATE_WORKTREE_METADATA: typeof UPDATE_WORKTREE_METADATA;
|
|
1155
|
+
declare const mcpTools_contract_UPDATE_WORKTREE_TARGETS: typeof UPDATE_WORKTREE_TARGETS;
|
|
1156
|
+
declare const mcpTools_contract_validateGitSemantics: typeof validateGitSemantics;
|
|
1157
|
+
declare namespace mcpTools_contract {
|
|
1158
|
+
export { mcpTools_contract_ACTIVATE_WORKTREE as ACTIVATE_WORKTREE, mcpTools_contract_ADD_EVIDENCE as ADD_EVIDENCE, mcpTools_contract_ADD_WORKTREE as ADD_WORKTREE, mcpTools_contract_ANSWER_QUESTION as ANSWER_QUESTION, mcpTools_contract_APPLY_LENS_TO_TOPIC as APPLY_LENS_TO_TOPIC, mcpTools_contract_APPLY_ONTOLOGY as APPLY_ONTOLOGY, mcpTools_contract_ARCHIVE_BELIEF as ARCHIVE_BELIEF, mcpTools_contract_ARCHIVE_ONTOLOGY as ARCHIVE_ONTOLOGY, mcpTools_contract_ARCHIVE_QUESTION as ARCHIVE_QUESTION, mcpTools_contract_BISECT_CONFIDENCE as BISECT_CONFIDENCE, mcpTools_contract_CHECK_PERMISSION as CHECK_PERMISSION, mcpTools_contract_COMPILE_CONTEXT as COMPILE_CONTEXT, mcpTools_contract_COMPLETE_TASK as COMPLETE_TASK, mcpTools_contract_CREATE_ANSWER as CREATE_ANSWER, mcpTools_contract_CREATE_BELIEF as CREATE_BELIEF, mcpTools_contract_CREATE_EDGE as CREATE_EDGE, mcpTools_contract_CREATE_EPISTEMIC_CONTRACT as CREATE_EPISTEMIC_CONTRACT, mcpTools_contract_CREATE_EVIDENCE as CREATE_EVIDENCE, mcpTools_contract_CREATE_LENS as CREATE_LENS, mcpTools_contract_CREATE_ONTOLOGY as CREATE_ONTOLOGY, mcpTools_contract_CREATE_ONTOLOGY_VERSION as CREATE_ONTOLOGY_VERSION, mcpTools_contract_CREATE_QUESTION as CREATE_QUESTION, mcpTools_contract_CREATE_TASK as CREATE_TASK, mcpTools_contract_CREATE_TOPIC as CREATE_TOPIC, mcpTools_contract_DEPRECATE_ONTOLOGY_VERSION as DEPRECATE_ONTOLOGY_VERSION, mcpTools_contract_DETECT_CONFIRMATION_BIAS as DETECT_CONFIRMATION_BIAS, mcpTools_contract_EXECUTE_DEEP_RESEARCH as EXECUTE_DEEP_RESEARCH, mcpTools_contract_FILTER_BY_PERMISSION as FILTER_BY_PERMISSION, mcpTools_contract_FIND_CONTRADICTIONS as FIND_CONTRADICTIONS, mcpTools_contract_FIND_MISSING_QUESTIONS as FIND_MISSING_QUESTIONS, mcpTools_contract_FLAG_CONTRADICTION as FLAG_CONTRADICTION, mcpTools_contract_FORK_BELIEF as FORK_BELIEF, mcpTools_contract_GET_ANSWER as GET_ANSWER, mcpTools_contract_GET_AUDIT_TRAIL as GET_AUDIT_TRAIL, mcpTools_contract_GET_BELIEF as GET_BELIEF, mcpTools_contract_GET_CHANGE_HISTORY as GET_CHANGE_HISTORY, mcpTools_contract_GET_CODE_CONTEXT as GET_CODE_CONTEXT, mcpTools_contract_GET_CONFIDENCE_HISTORY as GET_CONFIDENCE_HISTORY, mcpTools_contract_GET_EVIDENCE as GET_EVIDENCE, mcpTools_contract_GET_FAILURE_LOG as GET_FAILURE_LOG, mcpTools_contract_GET_FALSIFICATION_QUESTIONS as GET_FALSIFICATION_QUESTIONS, mcpTools_contract_GET_GRAPH_GAPS as GET_GRAPH_GAPS, mcpTools_contract_GET_GRAPH_NEIGHBORHOOD as GET_GRAPH_NEIGHBORHOOD, mcpTools_contract_GET_GRAPH_STRUCTURE_ANALYSIS as GET_GRAPH_STRUCTURE_ANALYSIS, mcpTools_contract_GET_HIGH_PRIORITY_QUESTIONS as GET_HIGH_PRIORITY_QUESTIONS, mcpTools_contract_GET_OBSERVATION_CONTEXT as GET_OBSERVATION_CONTEXT, mcpTools_contract_GET_ONTOLOGY as GET_ONTOLOGY, mcpTools_contract_GET_QUESTION as GET_QUESTION, mcpTools_contract_GET_TOPIC as GET_TOPIC, mcpTools_contract_GET_TOPIC_COVERAGE as GET_TOPIC_COVERAGE, mcpTools_contract_GET_TOPIC_TREE as GET_TOPIC_TREE, mcpTools_contract_GIT_SEMANTIC_REQUIRED_TOOLS as GIT_SEMANTIC_REQUIRED_TOOLS, mcpTools_contract_IDENTITY_WHOAMI as IDENTITY_WHOAMI, mcpTools_contract_INGEST_OBSERVATION as INGEST_OBSERVATION, mcpTools_contract_LINK_EVIDENCE as LINK_EVIDENCE, mcpTools_contract_LINK_EVIDENCE_TO_BELIEF as LINK_EVIDENCE_TO_BELIEF, mcpTools_contract_LINK_EVIDENCE_TO_QUESTION as LINK_EVIDENCE_TO_QUESTION, mcpTools_contract_LIST_ALL_WORKTREES as LIST_ALL_WORKTREES, mcpTools_contract_LIST_BELIEFS as LIST_BELIEFS, mcpTools_contract_LIST_EVIDENCE as LIST_EVIDENCE, mcpTools_contract_LIST_LENSES as LIST_LENSES, mcpTools_contract_LIST_ONTOLOGIES as LIST_ONTOLOGIES, mcpTools_contract_LIST_QUESTIONS as LIST_QUESTIONS, LIST_TASKS$1 as LIST_TASKS, mcpTools_contract_LIST_TOPICS as LIST_TOPICS, mcpTools_contract_LIST_WORKTREES as LIST_WORKTREES, mcpTools_contract_MANAGE_WRITE_POLICY as MANAGE_WRITE_POLICY, mcpTools_contract_MATCH_ENTITY_TYPE as MATCH_ENTITY_TYPE, mcpTools_contract_MCP_TOOL_CONTRACTS as MCP_TOOL_CONTRACTS, mcpTools_contract_MERGE as MERGE, mcpTools_contract_MODULATE_CONFIDENCE as MODULATE_CONFIDENCE, type mcpTools_contract_McpParameterDef as McpParameterDef, type mcpTools_contract_McpResponseDef as McpResponseDef, type mcpTools_contract_McpToolContract as McpToolContract, mcpTools_contract_OPEN_PULL_REQUEST as OPEN_PULL_REQUEST, mcpTools_contract_PUBLISH_ONTOLOGY_VERSION as PUBLISH_ONTOLOGY_VERSION, mcpTools_contract_PUSH as PUSH, mcpTools_contract_QUERY_LINEAGE as QUERY_LINEAGE, mcpTools_contract_RECORD_ATTEMPT as RECORD_ATTEMPT, mcpTools_contract_RECORD_JUDGMENT as RECORD_JUDGMENT, mcpTools_contract_REFINE_BELIEF as REFINE_BELIEF, mcpTools_contract_REFINE_QUESTION as REFINE_QUESTION, mcpTools_contract_REMOVE_LENS_FROM_TOPIC as REMOVE_LENS_FROM_TOPIC, mcpTools_contract_RESOLVE_EFFECTIVE_ONTOLOGY as RESOLVE_EFFECTIVE_ONTOLOGY, mcpTools_contract_SEARCH_BELIEFS as SEARCH_BELIEFS, mcpTools_contract_SEARCH_EVIDENCE as SEARCH_EVIDENCE, mcpTools_contract_SEARCH_RESOURCES as SEARCH_RESOURCES, mcpTools_contract_SEARCH_SOURCES as SEARCH_SOURCES, mcpTools_contract_TRACE_ENTITY_IMPACT as TRACE_ENTITY_IMPACT, mcpTools_contract_TRAVERSE_GRAPH as TRAVERSE_GRAPH, mcpTools_contract_UPDATE_ONTOLOGY as UPDATE_ONTOLOGY, mcpTools_contract_UPDATE_QUESTION_STATUS as UPDATE_QUESTION_STATUS, UPDATE_TASK$1 as UPDATE_TASK, mcpTools_contract_UPDATE_TOPIC as UPDATE_TOPIC, mcpTools_contract_UPDATE_WORKTREE_METADATA as UPDATE_WORKTREE_METADATA, mcpTools_contract_UPDATE_WORKTREE_TARGETS as UPDATE_WORKTREE_TARGETS, mcpTools_contract_validateGitSemantics as validateGitSemantics };
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* @lucern/contracts — OntologiesV1 namespace (resource contracts)
|
|
1163
|
+
*
|
|
1164
|
+
* Ontology Matching Engine — L0 entity type classification and similarity scoring.
|
|
1165
|
+
* Provides bigram-based text similarity for matching free text against
|
|
1166
|
+
* ontology entity types. Domain-agnostic: works identically for companies,
|
|
1167
|
+
* molecules, code modules, or any tenant-defined entity vocabulary.
|
|
1168
|
+
*
|
|
1169
|
+
* Moved from src/ontology-matching.contract.ts in EK-16 T1 PR 2.
|
|
1170
|
+
* Compat shim remains at the old path until the Lucern 1.0.0 cut.
|
|
1171
|
+
*/
|
|
1172
|
+
/** An entity type definition from a resolved ontology version. */
|
|
1173
|
+
type OntologyEntityType = {
|
|
1174
|
+
value: string;
|
|
1175
|
+
label: string;
|
|
1176
|
+
description?: string;
|
|
1177
|
+
subtypes?: Array<{
|
|
1178
|
+
value: string;
|
|
1179
|
+
label: string;
|
|
1180
|
+
description?: string;
|
|
1181
|
+
}>;
|
|
1182
|
+
};
|
|
1183
|
+
/** A scored match between input text and an entity type. */
|
|
1184
|
+
type EntityTypeMatch = {
|
|
1185
|
+
entityType: string;
|
|
1186
|
+
label: string;
|
|
1187
|
+
score: number;
|
|
1188
|
+
reason: string;
|
|
1189
|
+
};
|
|
1190
|
+
/** A candidate entity node that can be matched against a target node. */
|
|
1191
|
+
type EntityMatchCandidate = {
|
|
1192
|
+
nodeId: string;
|
|
1193
|
+
entityType: string;
|
|
1194
|
+
title: string;
|
|
1195
|
+
canonicalText: string;
|
|
1196
|
+
connectedBeliefCount: number;
|
|
1197
|
+
connectedEvidenceCount: number;
|
|
1198
|
+
};
|
|
1199
|
+
/** A scored entity match with suggested bridge edge type. */
|
|
1200
|
+
type EntityConnectionMatch = {
|
|
1201
|
+
entityNodeId: string;
|
|
1202
|
+
entityType: string;
|
|
1203
|
+
title: string;
|
|
1204
|
+
score: number;
|
|
1205
|
+
suggestedEdgeType: string;
|
|
1206
|
+
reason: string;
|
|
1207
|
+
};
|
|
1208
|
+
/**
|
|
1209
|
+
* Score how well input text matches a single entity type definition.
|
|
1210
|
+
* Combines bigram Jaccard similarity, word overlap, and description matching.
|
|
1211
|
+
*/
|
|
1212
|
+
declare function scoreEntityTypeMatch(inputText: string, entityType: OntologyEntityType): EntityTypeMatch;
|
|
1213
|
+
/**
|
|
1214
|
+
* Rank all entity types in an ontology against input text.
|
|
1215
|
+
* Returns matches sorted by score (descending), filtered to score > minScore.
|
|
1216
|
+
*/
|
|
1217
|
+
declare function rankEntityTypeMatches(inputText: string, entityTypes: OntologyEntityType[], options?: {
|
|
1218
|
+
minScore?: number;
|
|
1219
|
+
limit?: number;
|
|
1220
|
+
}): EntityTypeMatch[];
|
|
1221
|
+
/**
|
|
1222
|
+
* Score how well a node's text matches an entity candidate.
|
|
1223
|
+
* Used by discover_entity_connections to suggest missing bridge edges.
|
|
1224
|
+
*/
|
|
1225
|
+
declare function scoreEntityConnection(nodeText: string, candidate: EntityMatchCandidate, options?: {
|
|
1226
|
+
connectivityWeight?: number;
|
|
1227
|
+
}): EntityConnectionMatch;
|
|
1228
|
+
/**
|
|
1229
|
+
* Rank entity candidates against a node's text.
|
|
1230
|
+
* Returns sorted matches above the minimum score threshold.
|
|
1231
|
+
*/
|
|
1232
|
+
declare function rankEntityConnections(nodeText: string, candidates: EntityMatchCandidate[], options?: {
|
|
1233
|
+
minScore?: number;
|
|
1234
|
+
limit?: number;
|
|
1235
|
+
connectivityWeight?: number;
|
|
1236
|
+
}): EntityConnectionMatch[];
|
|
1237
|
+
|
|
1238
|
+
/**
|
|
1239
|
+
* Prompt contract for portable, provider-agnostic prompt artifacts.
|
|
1240
|
+
*/
|
|
1241
|
+
type LucernPromptModelHint = "fast" | "balanced" | "strong";
|
|
1242
|
+
type LucernPrompt = {
|
|
1243
|
+
/** Stable prompt identifier, e.g. "lucern/classify-evidence" */
|
|
1244
|
+
slug: string;
|
|
1245
|
+
/** Semver-ish prompt version, e.g. "1.0.0" */
|
|
1246
|
+
version: string;
|
|
1247
|
+
/** Prompt template text (supports {{variable}} interpolation) */
|
|
1248
|
+
template: string;
|
|
1249
|
+
/** Variables expected by the template */
|
|
1250
|
+
variables: string[];
|
|
1251
|
+
/** Model family hint for runtime model routing */
|
|
1252
|
+
modelHint: LucernPromptModelHint;
|
|
1253
|
+
/** Metadata used for ownership and discovery */
|
|
1254
|
+
metadata: {
|
|
1255
|
+
author: string;
|
|
1256
|
+
createdAt: string;
|
|
1257
|
+
description: string;
|
|
1258
|
+
tags: string[];
|
|
1259
|
+
};
|
|
1260
|
+
};
|
|
1261
|
+
declare function isLucernPrompt(value: unknown): value is LucernPrompt;
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* SDK Method Contract Definitions
|
|
1265
|
+
*
|
|
1266
|
+
* Canonical method signatures for the Lucern TypeScript SDK.
|
|
1267
|
+
* DERIVED from API contracts — not independently authored.
|
|
1268
|
+
*
|
|
1269
|
+
* These types define the public API of `@lucern/sdk`, covering:
|
|
1270
|
+
* - client initialization (formerly @lucern/sdk-core)
|
|
1271
|
+
* - belief, evidence, edge, contradiction operations (formerly @lucern/sdk-graph)
|
|
1272
|
+
* - branch, worktree, merge, push, pull request lifecycle (formerly @lucern/sdk-workflows)
|
|
1273
|
+
*
|
|
1274
|
+
* Historical note: T7.3.2 (2026-04-18) deleted the three sdk-alpha shim
|
|
1275
|
+
* packages; all surfaces now ship in the single `@lucern/sdk` package.
|
|
1276
|
+
*
|
|
1277
|
+
* CONTRACT SURFACE: Method signatures are semver-bound.
|
|
1278
|
+
* Adding optional parameters is non-breaking.
|
|
1279
|
+
* Changing required parameters or return types is BREAKING.
|
|
1280
|
+
*/
|
|
1281
|
+
|
|
1282
|
+
type LucernClientConfig = {
|
|
1283
|
+
apiKey: string;
|
|
1284
|
+
environment: "sandbox" | "production";
|
|
1285
|
+
/** Optional base URL override for self-hosted deployments */
|
|
1286
|
+
baseUrl?: string;
|
|
1287
|
+
};
|
|
1288
|
+
type LucernClient = {
|
|
1289
|
+
/** The authenticated client instance */
|
|
1290
|
+
readonly config: LucernClientConfig;
|
|
1291
|
+
};
|
|
1292
|
+
/** Input to createBelief() */
|
|
1293
|
+
type CreateBeliefInput = {
|
|
1294
|
+
canonicalText: string;
|
|
1295
|
+
topicId: string;
|
|
1296
|
+
/** @deprecated Use topicId. */
|
|
1297
|
+
projectId?: string;
|
|
1298
|
+
layer?: EpistemicLayer;
|
|
1299
|
+
domain?: string;
|
|
1300
|
+
nodeType?: string;
|
|
1301
|
+
};
|
|
1302
|
+
/** Result of createBelief() */
|
|
1303
|
+
type BeliefResult = {
|
|
1304
|
+
nodeId: string;
|
|
1305
|
+
globalId: string;
|
|
1306
|
+
canonicalText: string;
|
|
1307
|
+
status: BeliefStatus;
|
|
1308
|
+
createdAt: number;
|
|
1309
|
+
};
|
|
1310
|
+
/** Input to refineBelief() */
|
|
1311
|
+
type RefineBeliefInput = {
|
|
1312
|
+
canonicalText: string;
|
|
1313
|
+
rationale?: string;
|
|
1314
|
+
};
|
|
1315
|
+
/** Input to modulateConfidence() */
|
|
1316
|
+
type ModulateConfidenceInput = {
|
|
1317
|
+
confidence: number;
|
|
1318
|
+
trigger: ConfidenceTrigger;
|
|
1319
|
+
rationale: string;
|
|
1320
|
+
};
|
|
1321
|
+
/** Result of modulateConfidence() */
|
|
1322
|
+
type ConfidenceResult = {
|
|
1323
|
+
nodeId: string;
|
|
1324
|
+
newConfidence: number;
|
|
1325
|
+
previousConfidence: number | null;
|
|
1326
|
+
trigger: ConfidenceTrigger;
|
|
1327
|
+
};
|
|
1328
|
+
/** Input to forkBelief() */
|
|
1329
|
+
type ForkBeliefInput = {
|
|
1330
|
+
newFormulation: string;
|
|
1331
|
+
forkReason: ForkReason;
|
|
1332
|
+
};
|
|
1333
|
+
/** Result of forkBelief() */
|
|
1334
|
+
type ForkResult = {
|
|
1335
|
+
nodeId: string;
|
|
1336
|
+
parentNodeId: string;
|
|
1337
|
+
forkReason: ForkReason;
|
|
1338
|
+
canonicalText: string;
|
|
1339
|
+
};
|
|
1340
|
+
/** Input to addEvidence() */
|
|
1341
|
+
type AddEvidenceInput = {
|
|
1342
|
+
canonicalText: string;
|
|
1343
|
+
topicId: string;
|
|
1344
|
+
/** @deprecated Use topicId. */
|
|
1345
|
+
projectId?: string;
|
|
1346
|
+
sourceUrl?: string;
|
|
1347
|
+
supports?: {
|
|
1348
|
+
nodeId: string;
|
|
1349
|
+
weight: number;
|
|
1350
|
+
reasoning?: string;
|
|
1351
|
+
};
|
|
1352
|
+
};
|
|
1353
|
+
/** Result of addEvidence() */
|
|
1354
|
+
type EvidenceResult = {
|
|
1355
|
+
nodeId: string;
|
|
1356
|
+
globalId: string;
|
|
1357
|
+
edgeId?: string;
|
|
1358
|
+
};
|
|
1359
|
+
/** Input to flagContradiction() */
|
|
1360
|
+
type FlagContradictionInput = {
|
|
1361
|
+
beliefA: string;
|
|
1362
|
+
beliefB: string;
|
|
1363
|
+
description: string;
|
|
1364
|
+
severity: ContradictionSeverity;
|
|
1365
|
+
topicId: string;
|
|
1366
|
+
/** @deprecated Use topicId. */
|
|
1367
|
+
projectId?: string;
|
|
1368
|
+
defeatType?: DefeatType;
|
|
1369
|
+
};
|
|
1370
|
+
/** Result of flagContradiction() */
|
|
1371
|
+
type ContradictionResult = {
|
|
1372
|
+
contradictionId: string;
|
|
1373
|
+
status: "unresolved";
|
|
1374
|
+
beliefA: string;
|
|
1375
|
+
beliefB: string;
|
|
1376
|
+
defeatType?: DefeatType;
|
|
1377
|
+
};
|
|
1378
|
+
/** Input to createEdge() */
|
|
1379
|
+
type CreateEdgeInput = {
|
|
1380
|
+
sourceId: string;
|
|
1381
|
+
targetId: string;
|
|
1382
|
+
edgeType: string;
|
|
1383
|
+
weight?: number;
|
|
1384
|
+
reasoning?: string;
|
|
1385
|
+
reasoningMethod?: ReasoningMethod;
|
|
1386
|
+
};
|
|
1387
|
+
/** Result of createEdge() */
|
|
1388
|
+
type EdgeResult = {
|
|
1389
|
+
globalId: string;
|
|
1390
|
+
edgeType: string;
|
|
1391
|
+
fromLayer: EpistemicLayer;
|
|
1392
|
+
toLayer: EpistemicLayer;
|
|
1393
|
+
};
|
|
1394
|
+
/** Input to queryLineage() */
|
|
1395
|
+
type QueryLineageInput = {
|
|
1396
|
+
depth?: number;
|
|
1397
|
+
};
|
|
1398
|
+
/** Result of queryLineage() */
|
|
1399
|
+
type LineageResult = {
|
|
1400
|
+
chain: Array<{
|
|
1401
|
+
nodeId: string;
|
|
1402
|
+
canonicalText: string;
|
|
1403
|
+
confidence: number | null;
|
|
1404
|
+
forkedFrom: string | null;
|
|
1405
|
+
scoredAt: number | null;
|
|
1406
|
+
}>;
|
|
1407
|
+
forkTree: Record<string, string[]>;
|
|
1408
|
+
depth: number;
|
|
1409
|
+
};
|
|
1410
|
+
/** Input to searchBeliefs() */
|
|
1411
|
+
type SearchBeliefsInput = {
|
|
1412
|
+
query: string;
|
|
1413
|
+
status?: BeliefStatus;
|
|
1414
|
+
minConfidence?: number;
|
|
1415
|
+
topicId?: string;
|
|
1416
|
+
/** @deprecated Use topicId. */
|
|
1417
|
+
projectId?: string;
|
|
1418
|
+
limit?: number;
|
|
1419
|
+
};
|
|
1420
|
+
/** Input to context.compile() */
|
|
1421
|
+
type CompileContextInput = {
|
|
1422
|
+
query?: string;
|
|
1423
|
+
budget?: number;
|
|
1424
|
+
ranking?: ContextRankingProfile;
|
|
1425
|
+
limit?: number;
|
|
1426
|
+
maxDepth?: number;
|
|
1427
|
+
includeEntities?: boolean;
|
|
1428
|
+
};
|
|
1429
|
+
/** Result of context.compile() */
|
|
1430
|
+
type CompiledContextResult = PublicCompiledContext;
|
|
1431
|
+
/** Input to addWorktree() — like git worktree add <branch> */
|
|
1432
|
+
type AddWorktreeInput = {
|
|
1433
|
+
title: string;
|
|
1434
|
+
topicId: string;
|
|
1435
|
+
/** @deprecated Use topicId. */
|
|
1436
|
+
projectId?: string;
|
|
1437
|
+
branchId?: string;
|
|
1438
|
+
objective?: string;
|
|
1439
|
+
hypothesis?: string;
|
|
1440
|
+
beliefIds?: string[];
|
|
1441
|
+
autoShape?: boolean;
|
|
1442
|
+
domainPackId?: string;
|
|
1443
|
+
executionOrder?: number;
|
|
1444
|
+
dependsOn?: string[];
|
|
1445
|
+
blocks?: string[];
|
|
1446
|
+
gate?: string;
|
|
1447
|
+
};
|
|
1448
|
+
/** Result of addWorktree() */
|
|
1449
|
+
type WorktreeResult = {
|
|
1450
|
+
worktreeId: string;
|
|
1451
|
+
title: string;
|
|
1452
|
+
status: string;
|
|
1453
|
+
hypothesis?: string;
|
|
1454
|
+
questionCount?: number;
|
|
1455
|
+
taskCount?: number;
|
|
1456
|
+
autoShapeApplied?: boolean;
|
|
1457
|
+
};
|
|
1458
|
+
/** Input to merge() */
|
|
1459
|
+
type MergeInput = {
|
|
1460
|
+
outcomes: Array<{
|
|
1461
|
+
beliefId: string;
|
|
1462
|
+
confidence: number;
|
|
1463
|
+
rationale: string;
|
|
1464
|
+
}>;
|
|
1465
|
+
summary?: string;
|
|
1466
|
+
};
|
|
1467
|
+
/** Result of merge() */
|
|
1468
|
+
type MergeResult = {
|
|
1469
|
+
worktreeId: string;
|
|
1470
|
+
status: "merged";
|
|
1471
|
+
outcome: MergeOutcome;
|
|
1472
|
+
beliefsScored: number;
|
|
1473
|
+
};
|
|
1474
|
+
/** Input to recordJudgment() */
|
|
1475
|
+
type RecordJudgmentInput = {
|
|
1476
|
+
title: string;
|
|
1477
|
+
rationale: string;
|
|
1478
|
+
topicId: string;
|
|
1479
|
+
/** @deprecated Use topicId. */
|
|
1480
|
+
projectId?: string;
|
|
1481
|
+
beliefIds?: string[];
|
|
1482
|
+
confidence?: number;
|
|
1483
|
+
judgmentType?: JudgmentType;
|
|
1484
|
+
};
|
|
1485
|
+
/** Result of recordJudgment() */
|
|
1486
|
+
type JudgmentResult = {
|
|
1487
|
+
judgmentId: string;
|
|
1488
|
+
title: string;
|
|
1489
|
+
status: "issued";
|
|
1490
|
+
};
|
|
1491
|
+
/** Input to createBranch() */
|
|
1492
|
+
type CreateBranchInput = {
|
|
1493
|
+
name: string;
|
|
1494
|
+
topicId: string;
|
|
1495
|
+
/** @deprecated Use topicId. */
|
|
1496
|
+
projectId?: string;
|
|
1497
|
+
description?: string;
|
|
1498
|
+
};
|
|
1499
|
+
/** Result of createBranch() */
|
|
1500
|
+
type BranchResult = {
|
|
1501
|
+
branchId: string;
|
|
1502
|
+
name: string;
|
|
1503
|
+
status: BranchStatus;
|
|
1504
|
+
createdAt: number;
|
|
1505
|
+
};
|
|
1506
|
+
/** Input to push() */
|
|
1507
|
+
type PushInput = {
|
|
1508
|
+
targetContext: string;
|
|
1509
|
+
beliefIds?: string[];
|
|
1510
|
+
};
|
|
1511
|
+
/** Result of push() */
|
|
1512
|
+
type PushResult = {
|
|
1513
|
+
pushedCount: number;
|
|
1514
|
+
targetContext: string;
|
|
1515
|
+
pushedAt: number;
|
|
1516
|
+
};
|
|
1517
|
+
/** Input to openPullRequest() */
|
|
1518
|
+
type OpenPullRequestInput = {
|
|
1519
|
+
reviewers?: string[];
|
|
1520
|
+
summary: string;
|
|
1521
|
+
};
|
|
1522
|
+
/** Result of openPullRequest() */
|
|
1523
|
+
type PullRequestResult = {
|
|
1524
|
+
pullRequestId: string;
|
|
1525
|
+
worktreeId: string;
|
|
1526
|
+
status: PullRequestStatus;
|
|
1527
|
+
};
|
|
1528
|
+
/** Input to bisectConfidence() */
|
|
1529
|
+
type BisectConfidenceInput = {
|
|
1530
|
+
expectedDirection: "overconfident" | "underconfident";
|
|
1531
|
+
timeRange?: {
|
|
1532
|
+
start: number;
|
|
1533
|
+
end: number;
|
|
1534
|
+
};
|
|
1535
|
+
};
|
|
1536
|
+
/** Result of bisectConfidence() */
|
|
1537
|
+
type BisectResult = {
|
|
1538
|
+
inflectionEntry: {
|
|
1539
|
+
confidence: number;
|
|
1540
|
+
trigger: ConfidenceTrigger;
|
|
1541
|
+
rationale: string;
|
|
1542
|
+
timestamp: number;
|
|
1543
|
+
};
|
|
1544
|
+
triggerEvent: string;
|
|
1545
|
+
confidenceBefore: number;
|
|
1546
|
+
confidenceAfter: number;
|
|
1547
|
+
};
|
|
1548
|
+
/**
|
|
1549
|
+
* @lucern/sdk (graph) method signatures.
|
|
1550
|
+
*
|
|
1551
|
+
* These define the public API. Implementation must match these signatures.
|
|
1552
|
+
* Parameters are the source of truth — generated from API contracts.
|
|
1553
|
+
*/
|
|
1554
|
+
type LucernGraphMethods = {
|
|
1555
|
+
createBelief(client: LucernClient, input: CreateBeliefInput): Promise<BeliefResult>;
|
|
1556
|
+
refineBelief(client: LucernClient, nodeId: string, input: RefineBeliefInput): Promise<BeliefResult>;
|
|
1557
|
+
modulateConfidence(client: LucernClient, nodeId: string, input: ModulateConfidenceInput): Promise<ConfidenceResult>;
|
|
1558
|
+
forkBelief(client: LucernClient, nodeId: string, input: ForkBeliefInput): Promise<ForkResult>;
|
|
1559
|
+
archiveBelief(client: LucernClient, nodeId: string, rationale?: string): Promise<{
|
|
1560
|
+
nodeId: string;
|
|
1561
|
+
status: "archived";
|
|
1562
|
+
}>;
|
|
1563
|
+
addEvidence(client: LucernClient, input: AddEvidenceInput): Promise<EvidenceResult>;
|
|
1564
|
+
flagContradiction(client: LucernClient, input: FlagContradictionInput): Promise<ContradictionResult>;
|
|
1565
|
+
createEdge(client: LucernClient, input: CreateEdgeInput): Promise<EdgeResult>;
|
|
1566
|
+
queryLineage(client: LucernClient, nodeId: string, input?: QueryLineageInput): Promise<LineageResult>;
|
|
1567
|
+
getConfidenceHistory(client: LucernClient, nodeId: string): Promise<{
|
|
1568
|
+
entries: Array<{
|
|
1569
|
+
confidence: number;
|
|
1570
|
+
trigger: ConfidenceTrigger;
|
|
1571
|
+
rationale: string;
|
|
1572
|
+
timestamp: number;
|
|
1573
|
+
userId: string;
|
|
1574
|
+
}>;
|
|
1575
|
+
}>;
|
|
1576
|
+
getAuditTrail(client: LucernClient, nodeId: string, limit?: number): Promise<{
|
|
1577
|
+
entries: Array<{
|
|
1578
|
+
action: string;
|
|
1579
|
+
actor: string;
|
|
1580
|
+
timestamp: number;
|
|
1581
|
+
rationale?: string;
|
|
1582
|
+
}>;
|
|
1583
|
+
}>;
|
|
1584
|
+
searchBeliefs(client: LucernClient, input: SearchBeliefsInput): Promise<{
|
|
1585
|
+
results: BeliefResult[];
|
|
1586
|
+
}>;
|
|
1587
|
+
findContradictions(client: LucernClient, input: {
|
|
1588
|
+
topicId?: string;
|
|
1589
|
+
projectId?: string;
|
|
1590
|
+
nodeId?: string;
|
|
1591
|
+
status?: string;
|
|
1592
|
+
}): Promise<{
|
|
1593
|
+
contradictions: ContradictionResult[];
|
|
1594
|
+
}>;
|
|
1595
|
+
traverseGraph(client: LucernClient, input: {
|
|
1596
|
+
startNode: string;
|
|
1597
|
+
direction?: "up" | "down" | "both";
|
|
1598
|
+
maxDepth?: number;
|
|
1599
|
+
}): Promise<{
|
|
1600
|
+
nodes: unknown[];
|
|
1601
|
+
edges: unknown[];
|
|
1602
|
+
depth: number;
|
|
1603
|
+
}>;
|
|
1604
|
+
bisectConfidence(client: LucernClient, nodeId: string, input: BisectConfidenceInput): Promise<BisectResult>;
|
|
1605
|
+
recordJudgment(client: LucernClient, input: RecordJudgmentInput): Promise<JudgmentResult>;
|
|
1606
|
+
};
|
|
1607
|
+
/**
|
|
1608
|
+
* @lucern/sdk (workflows) method signatures.
|
|
1609
|
+
*
|
|
1610
|
+
* Lifecycle: createBranch (git branch) → addWorktree (git worktree add) →
|
|
1611
|
+
* openPullRequest (git pull request) → merge (git merge) → push (git push)
|
|
1612
|
+
*/
|
|
1613
|
+
type LucernWorkflowMethods = {
|
|
1614
|
+
createBranch(client: LucernClient, input: CreateBranchInput): Promise<BranchResult>;
|
|
1615
|
+
addWorktree(client: LucernClient, input: AddWorktreeInput): Promise<WorktreeResult>;
|
|
1616
|
+
merge(client: LucernClient, worktreeId: string, input: MergeInput): Promise<MergeResult>;
|
|
1617
|
+
openPullRequest(client: LucernClient, worktreeId: string, input: OpenPullRequestInput): Promise<PullRequestResult>;
|
|
1618
|
+
push(client: LucernClient, worktreeId: string, input: PushInput): Promise<PushResult>;
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
/**
|
|
1622
|
+
* SDK-Only Tool Contract Definitions
|
|
1623
|
+
*
|
|
1624
|
+
* Tools available in @lucern/sdk but NOT in the MCP gateway.
|
|
1625
|
+
* The SDK unfolds deeper capabilities after the MCP gateway shows developers what's possible.
|
|
1626
|
+
*
|
|
1627
|
+
* Total SDK surface = MCP tools (44) + SDK-only tools (44) = 88 tools
|
|
1628
|
+
*
|
|
1629
|
+
* These tools are organized into capability tiers:
|
|
1630
|
+
* - Advanced workflow & phase management (12 tools)
|
|
1631
|
+
* - Deeper graph navigation (6 tools)
|
|
1632
|
+
* - Conviction & analytics (7 tools)
|
|
1633
|
+
* - Extended question & evidence analytics (1 tool; core lifecycle promoted to MCP)
|
|
1634
|
+
* - Task lifecycle (5 tools)
|
|
1635
|
+
* - Domain analytics (8 tools)
|
|
1636
|
+
* - Bias detection suite (5 tools)
|
|
1637
|
+
*
|
|
1638
|
+
* CONTRACT SURFACE: These definitions are the external API for SDK consumers.
|
|
1639
|
+
* Renaming a tool or changing its description is a BREAKING CHANGE.
|
|
1640
|
+
*
|
|
1641
|
+
* Git-native naming rules (same as MCP, enforced by lint):
|
|
1642
|
+
* 1. Workflow tools use git verbs directly
|
|
1643
|
+
* 2. Knowledge tools use epistemic verbs
|
|
1644
|
+
* 3. First sentence of description includes the git analog verb
|
|
1645
|
+
* 4. Description includes "Like `git X`" parenthetical
|
|
1646
|
+
* 5. Parameter names use domain terms (canonicalText, nodeId, confidence)
|
|
1647
|
+
*/
|
|
1648
|
+
|
|
1649
|
+
/** SDK-only tool contract — same shape as MCP but with sdk-only tier marker */
|
|
1650
|
+
interface SdkToolContract extends Omit<McpToolContract, "tier"> {
|
|
1651
|
+
tier: "sdk-only";
|
|
1652
|
+
}
|
|
1653
|
+
declare const START_WORKTREE: SdkToolContract;
|
|
1654
|
+
declare const UPDATE_WORKTREE_PHASE: SdkToolContract;
|
|
1655
|
+
declare const ADVANCE_WORKTREE_PHASE: SdkToolContract;
|
|
1656
|
+
declare const ADD_NOTE_TO_WORKTREE: SdkToolContract;
|
|
1657
|
+
declare const LINK_DOCUMENT_TO_WORKTREE: SdkToolContract;
|
|
1658
|
+
declare const LINK_EVIDENCE_TO_WORKTREE: SdkToolContract;
|
|
1659
|
+
declare const LINK_QUESTION_TO_WORKTREE: SdkToolContract;
|
|
1660
|
+
declare const LINK_BELIEF_TO_WORKTREE: SdkToolContract;
|
|
1661
|
+
declare const CREATE_SYNTHESIZED_BELIEF: SdkToolContract;
|
|
1662
|
+
declare const COMPLETE_HYPOTHESIS_FORMATION: SdkToolContract;
|
|
1663
|
+
declare const COMPLETE_EVIDENCE_REVIEW: SdkToolContract;
|
|
1664
|
+
declare const REFINE_WORKTREE_BELIEF: SdkToolContract;
|
|
1665
|
+
declare const TRACE_PROVENANCE: SdkToolContract;
|
|
1666
|
+
declare const GET_BELIEF_RELATIONSHIPS: SdkToolContract;
|
|
1667
|
+
declare const GET_BELIEF_SUPPORT_CHAIN: SdkToolContract;
|
|
1668
|
+
declare const EXPLORE_CONNECTIONS: SdkToolContract;
|
|
1669
|
+
declare const GET_DEEP_LINEAGE: SdkToolContract;
|
|
1670
|
+
declare const GRAPH_AWARE_SEARCH: SdkToolContract;
|
|
1671
|
+
declare const GET_COLLECTION_CONVICTION: SdkToolContract;
|
|
1672
|
+
declare const GET_CONVICTION_TREND: SdkToolContract;
|
|
1673
|
+
declare const ANALYZE_BELIEF_CRITICALITY: SdkToolContract;
|
|
1674
|
+
declare const ANALYZE_BELIEF_CLUSTER_CANDIDATES: SdkToolContract;
|
|
1675
|
+
declare const CREATE_BELIEF_CONDITIONAL: SdkToolContract;
|
|
1676
|
+
declare const GET_NECESSARY_EVIDENCE: SdkToolContract;
|
|
1677
|
+
declare const ANALYZE_REASONING_DEPTH: SdkToolContract;
|
|
1678
|
+
declare const GET_EVIDENCE_BY_METHODOLOGY: SdkToolContract;
|
|
1679
|
+
declare const CREATE_EVIDENCE_TASK: SdkToolContract;
|
|
1680
|
+
declare const LIST_TASKS: SdkToolContract;
|
|
1681
|
+
declare const UPDATE_TASK: SdkToolContract;
|
|
1682
|
+
declare const GET_TASK_COUNTS: SdkToolContract;
|
|
1683
|
+
declare const ADD_RESEARCH_ACTION: SdkToolContract;
|
|
1684
|
+
declare const GET_PREDICTIONS: SdkToolContract;
|
|
1685
|
+
declare const GET_SURPRISE_DETECTION: SdkToolContract;
|
|
1686
|
+
declare const GET_CHALLENGED_BELIEFS: SdkToolContract;
|
|
1687
|
+
declare const GET_CAUSAL_CHAINS: SdkToolContract;
|
|
1688
|
+
declare const GET_NON_CONSENSUS_BELIEFS: SdkToolContract;
|
|
1689
|
+
declare const GET_BELIEFS_BY_EPISTEMIC_STATUS: SdkToolContract;
|
|
1690
|
+
declare const GET_PRIVILEGED_EVIDENCE: SdkToolContract;
|
|
1691
|
+
declare const GET_PRIVILEGED_SIGNALS: SdkToolContract;
|
|
1692
|
+
declare const DETECT_ANCHORING_BIAS: SdkToolContract;
|
|
1693
|
+
declare const DETECT_SOURCE_CONCENTRATION: SdkToolContract;
|
|
1694
|
+
declare const FIND_SOFT_CONTRADICTIONS: SdkToolContract;
|
|
1695
|
+
declare const FIND_SEMANTIC_BRIDGES: SdkToolContract;
|
|
1696
|
+
declare const FIND_SEMANTIC_ORPHANS: SdkToolContract;
|
|
1697
|
+
/** All SDK-only tool contracts, indexed by name */
|
|
1698
|
+
declare const SDK_ONLY_TOOL_CONTRACTS: Record<string, SdkToolContract>;
|
|
1699
|
+
/** Complete SDK surface: MCP gateway tools + SDK-only advanced tools */
|
|
1700
|
+
declare const ALL_SDK_TOOL_CONTRACTS: Record<string, McpToolContract | SdkToolContract>;
|
|
1701
|
+
/** All SDK-only tool names */
|
|
1702
|
+
declare const SDK_ONLY_TOOL_NAMES: string[];
|
|
1703
|
+
/** All tool names across the complete SDK surface */
|
|
1704
|
+
declare const ALL_SDK_TOOL_NAMES: string[];
|
|
1705
|
+
/**
|
|
1706
|
+
* Lint validation: every SDK tool description must contain "Like `git" reference.
|
|
1707
|
+
* Reuses the same git-semantic validation rule as MCP tools.
|
|
1708
|
+
*/
|
|
1709
|
+
declare function validateSdkGitSemantics(tool: SdkToolContract): {
|
|
1710
|
+
valid: boolean;
|
|
1711
|
+
reason?: string;
|
|
1712
|
+
};
|
|
1713
|
+
|
|
1714
|
+
declare const sdkTools_contract_ADD_NOTE_TO_WORKTREE: typeof ADD_NOTE_TO_WORKTREE;
|
|
1715
|
+
declare const sdkTools_contract_ADD_RESEARCH_ACTION: typeof ADD_RESEARCH_ACTION;
|
|
1716
|
+
declare const sdkTools_contract_ADVANCE_WORKTREE_PHASE: typeof ADVANCE_WORKTREE_PHASE;
|
|
1717
|
+
declare const sdkTools_contract_ALL_SDK_TOOL_CONTRACTS: typeof ALL_SDK_TOOL_CONTRACTS;
|
|
1718
|
+
declare const sdkTools_contract_ALL_SDK_TOOL_NAMES: typeof ALL_SDK_TOOL_NAMES;
|
|
1719
|
+
declare const sdkTools_contract_ANALYZE_BELIEF_CLUSTER_CANDIDATES: typeof ANALYZE_BELIEF_CLUSTER_CANDIDATES;
|
|
1720
|
+
declare const sdkTools_contract_ANALYZE_BELIEF_CRITICALITY: typeof ANALYZE_BELIEF_CRITICALITY;
|
|
1721
|
+
declare const sdkTools_contract_ANALYZE_REASONING_DEPTH: typeof ANALYZE_REASONING_DEPTH;
|
|
1722
|
+
declare const sdkTools_contract_COMPLETE_EVIDENCE_REVIEW: typeof COMPLETE_EVIDENCE_REVIEW;
|
|
1723
|
+
declare const sdkTools_contract_COMPLETE_HYPOTHESIS_FORMATION: typeof COMPLETE_HYPOTHESIS_FORMATION;
|
|
1724
|
+
declare const sdkTools_contract_CREATE_BELIEF_CONDITIONAL: typeof CREATE_BELIEF_CONDITIONAL;
|
|
1725
|
+
declare const sdkTools_contract_CREATE_EVIDENCE_TASK: typeof CREATE_EVIDENCE_TASK;
|
|
1726
|
+
declare const sdkTools_contract_CREATE_SYNTHESIZED_BELIEF: typeof CREATE_SYNTHESIZED_BELIEF;
|
|
1727
|
+
declare const sdkTools_contract_DETECT_ANCHORING_BIAS: typeof DETECT_ANCHORING_BIAS;
|
|
1728
|
+
declare const sdkTools_contract_DETECT_SOURCE_CONCENTRATION: typeof DETECT_SOURCE_CONCENTRATION;
|
|
1729
|
+
declare const sdkTools_contract_EXPLORE_CONNECTIONS: typeof EXPLORE_CONNECTIONS;
|
|
1730
|
+
declare const sdkTools_contract_FIND_SEMANTIC_BRIDGES: typeof FIND_SEMANTIC_BRIDGES;
|
|
1731
|
+
declare const sdkTools_contract_FIND_SEMANTIC_ORPHANS: typeof FIND_SEMANTIC_ORPHANS;
|
|
1732
|
+
declare const sdkTools_contract_FIND_SOFT_CONTRADICTIONS: typeof FIND_SOFT_CONTRADICTIONS;
|
|
1733
|
+
declare const sdkTools_contract_GET_BELIEFS_BY_EPISTEMIC_STATUS: typeof GET_BELIEFS_BY_EPISTEMIC_STATUS;
|
|
1734
|
+
declare const sdkTools_contract_GET_BELIEF_RELATIONSHIPS: typeof GET_BELIEF_RELATIONSHIPS;
|
|
1735
|
+
declare const sdkTools_contract_GET_BELIEF_SUPPORT_CHAIN: typeof GET_BELIEF_SUPPORT_CHAIN;
|
|
1736
|
+
declare const sdkTools_contract_GET_CAUSAL_CHAINS: typeof GET_CAUSAL_CHAINS;
|
|
1737
|
+
declare const sdkTools_contract_GET_CHALLENGED_BELIEFS: typeof GET_CHALLENGED_BELIEFS;
|
|
1738
|
+
declare const sdkTools_contract_GET_COLLECTION_CONVICTION: typeof GET_COLLECTION_CONVICTION;
|
|
1739
|
+
declare const sdkTools_contract_GET_CONVICTION_TREND: typeof GET_CONVICTION_TREND;
|
|
1740
|
+
declare const sdkTools_contract_GET_DEEP_LINEAGE: typeof GET_DEEP_LINEAGE;
|
|
1741
|
+
declare const sdkTools_contract_GET_EVIDENCE_BY_METHODOLOGY: typeof GET_EVIDENCE_BY_METHODOLOGY;
|
|
1742
|
+
declare const sdkTools_contract_GET_NECESSARY_EVIDENCE: typeof GET_NECESSARY_EVIDENCE;
|
|
1743
|
+
declare const sdkTools_contract_GET_NON_CONSENSUS_BELIEFS: typeof GET_NON_CONSENSUS_BELIEFS;
|
|
1744
|
+
declare const sdkTools_contract_GET_PREDICTIONS: typeof GET_PREDICTIONS;
|
|
1745
|
+
declare const sdkTools_contract_GET_PRIVILEGED_EVIDENCE: typeof GET_PRIVILEGED_EVIDENCE;
|
|
1746
|
+
declare const sdkTools_contract_GET_PRIVILEGED_SIGNALS: typeof GET_PRIVILEGED_SIGNALS;
|
|
1747
|
+
declare const sdkTools_contract_GET_SURPRISE_DETECTION: typeof GET_SURPRISE_DETECTION;
|
|
1748
|
+
declare const sdkTools_contract_GET_TASK_COUNTS: typeof GET_TASK_COUNTS;
|
|
1749
|
+
declare const sdkTools_contract_GRAPH_AWARE_SEARCH: typeof GRAPH_AWARE_SEARCH;
|
|
1750
|
+
declare const sdkTools_contract_LINK_BELIEF_TO_WORKTREE: typeof LINK_BELIEF_TO_WORKTREE;
|
|
1751
|
+
declare const sdkTools_contract_LINK_DOCUMENT_TO_WORKTREE: typeof LINK_DOCUMENT_TO_WORKTREE;
|
|
1752
|
+
declare const sdkTools_contract_LINK_EVIDENCE_TO_WORKTREE: typeof LINK_EVIDENCE_TO_WORKTREE;
|
|
1753
|
+
declare const sdkTools_contract_LINK_QUESTION_TO_WORKTREE: typeof LINK_QUESTION_TO_WORKTREE;
|
|
1754
|
+
declare const sdkTools_contract_LIST_TASKS: typeof LIST_TASKS;
|
|
1755
|
+
declare const sdkTools_contract_REFINE_WORKTREE_BELIEF: typeof REFINE_WORKTREE_BELIEF;
|
|
1756
|
+
declare const sdkTools_contract_SDK_ONLY_TOOL_CONTRACTS: typeof SDK_ONLY_TOOL_CONTRACTS;
|
|
1757
|
+
declare const sdkTools_contract_SDK_ONLY_TOOL_NAMES: typeof SDK_ONLY_TOOL_NAMES;
|
|
1758
|
+
declare const sdkTools_contract_START_WORKTREE: typeof START_WORKTREE;
|
|
1759
|
+
type sdkTools_contract_SdkToolContract = SdkToolContract;
|
|
1760
|
+
declare const sdkTools_contract_TRACE_PROVENANCE: typeof TRACE_PROVENANCE;
|
|
1761
|
+
declare const sdkTools_contract_UPDATE_TASK: typeof UPDATE_TASK;
|
|
1762
|
+
declare const sdkTools_contract_UPDATE_WORKTREE_PHASE: typeof UPDATE_WORKTREE_PHASE;
|
|
1763
|
+
declare const sdkTools_contract_validateSdkGitSemantics: typeof validateSdkGitSemantics;
|
|
1764
|
+
declare namespace sdkTools_contract {
|
|
1765
|
+
export { sdkTools_contract_ADD_NOTE_TO_WORKTREE as ADD_NOTE_TO_WORKTREE, sdkTools_contract_ADD_RESEARCH_ACTION as ADD_RESEARCH_ACTION, sdkTools_contract_ADVANCE_WORKTREE_PHASE as ADVANCE_WORKTREE_PHASE, sdkTools_contract_ALL_SDK_TOOL_CONTRACTS as ALL_SDK_TOOL_CONTRACTS, sdkTools_contract_ALL_SDK_TOOL_NAMES as ALL_SDK_TOOL_NAMES, sdkTools_contract_ANALYZE_BELIEF_CLUSTER_CANDIDATES as ANALYZE_BELIEF_CLUSTER_CANDIDATES, sdkTools_contract_ANALYZE_BELIEF_CRITICALITY as ANALYZE_BELIEF_CRITICALITY, sdkTools_contract_ANALYZE_REASONING_DEPTH as ANALYZE_REASONING_DEPTH, sdkTools_contract_COMPLETE_EVIDENCE_REVIEW as COMPLETE_EVIDENCE_REVIEW, sdkTools_contract_COMPLETE_HYPOTHESIS_FORMATION as COMPLETE_HYPOTHESIS_FORMATION, sdkTools_contract_CREATE_BELIEF_CONDITIONAL as CREATE_BELIEF_CONDITIONAL, sdkTools_contract_CREATE_EVIDENCE_TASK as CREATE_EVIDENCE_TASK, sdkTools_contract_CREATE_SYNTHESIZED_BELIEF as CREATE_SYNTHESIZED_BELIEF, sdkTools_contract_DETECT_ANCHORING_BIAS as DETECT_ANCHORING_BIAS, sdkTools_contract_DETECT_SOURCE_CONCENTRATION as DETECT_SOURCE_CONCENTRATION, sdkTools_contract_EXPLORE_CONNECTIONS as EXPLORE_CONNECTIONS, sdkTools_contract_FIND_SEMANTIC_BRIDGES as FIND_SEMANTIC_BRIDGES, sdkTools_contract_FIND_SEMANTIC_ORPHANS as FIND_SEMANTIC_ORPHANS, sdkTools_contract_FIND_SOFT_CONTRADICTIONS as FIND_SOFT_CONTRADICTIONS, sdkTools_contract_GET_BELIEFS_BY_EPISTEMIC_STATUS as GET_BELIEFS_BY_EPISTEMIC_STATUS, sdkTools_contract_GET_BELIEF_RELATIONSHIPS as GET_BELIEF_RELATIONSHIPS, sdkTools_contract_GET_BELIEF_SUPPORT_CHAIN as GET_BELIEF_SUPPORT_CHAIN, sdkTools_contract_GET_CAUSAL_CHAINS as GET_CAUSAL_CHAINS, sdkTools_contract_GET_CHALLENGED_BELIEFS as GET_CHALLENGED_BELIEFS, sdkTools_contract_GET_COLLECTION_CONVICTION as GET_COLLECTION_CONVICTION, sdkTools_contract_GET_CONVICTION_TREND as GET_CONVICTION_TREND, sdkTools_contract_GET_DEEP_LINEAGE as GET_DEEP_LINEAGE, sdkTools_contract_GET_EVIDENCE_BY_METHODOLOGY as GET_EVIDENCE_BY_METHODOLOGY, sdkTools_contract_GET_NECESSARY_EVIDENCE as GET_NECESSARY_EVIDENCE, sdkTools_contract_GET_NON_CONSENSUS_BELIEFS as GET_NON_CONSENSUS_BELIEFS, sdkTools_contract_GET_PREDICTIONS as GET_PREDICTIONS, sdkTools_contract_GET_PRIVILEGED_EVIDENCE as GET_PRIVILEGED_EVIDENCE, sdkTools_contract_GET_PRIVILEGED_SIGNALS as GET_PRIVILEGED_SIGNALS, sdkTools_contract_GET_SURPRISE_DETECTION as GET_SURPRISE_DETECTION, sdkTools_contract_GET_TASK_COUNTS as GET_TASK_COUNTS, sdkTools_contract_GRAPH_AWARE_SEARCH as GRAPH_AWARE_SEARCH, sdkTools_contract_LINK_BELIEF_TO_WORKTREE as LINK_BELIEF_TO_WORKTREE, sdkTools_contract_LINK_DOCUMENT_TO_WORKTREE as LINK_DOCUMENT_TO_WORKTREE, sdkTools_contract_LINK_EVIDENCE_TO_WORKTREE as LINK_EVIDENCE_TO_WORKTREE, sdkTools_contract_LINK_QUESTION_TO_WORKTREE as LINK_QUESTION_TO_WORKTREE, sdkTools_contract_LIST_TASKS as LIST_TASKS, sdkTools_contract_REFINE_WORKTREE_BELIEF as REFINE_WORKTREE_BELIEF, sdkTools_contract_SDK_ONLY_TOOL_CONTRACTS as SDK_ONLY_TOOL_CONTRACTS, sdkTools_contract_SDK_ONLY_TOOL_NAMES as SDK_ONLY_TOOL_NAMES, sdkTools_contract_START_WORKTREE as START_WORKTREE, type sdkTools_contract_SdkToolContract as SdkToolContract, sdkTools_contract_TRACE_PROVENANCE as TRACE_PROVENANCE, sdkTools_contract_UPDATE_TASK as UPDATE_TASK, sdkTools_contract_UPDATE_WORKTREE_PHASE as UPDATE_WORKTREE_PHASE, sdkTools_contract_validateSdkGitSemantics as validateSdkGitSemantics };
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* Shared lexical matching primitives used across MCP handlers and graph utilities.
|
|
1770
|
+
*
|
|
1771
|
+
* The goal is not to replace downstream LLM scoring. It provides a fast,
|
|
1772
|
+
* deterministic substrate for candidate generation, reranking, and light
|
|
1773
|
+
* classification across belief/question/evidence/entity surfaces.
|
|
1774
|
+
*/
|
|
1775
|
+
type LexicalStrategy = "tokenOverlap" | "bigramJaccard" | "wordOverlap";
|
|
1776
|
+
type PreparedLexicalQuery = {
|
|
1777
|
+
raw: string;
|
|
1778
|
+
tokens: string[];
|
|
1779
|
+
words: string[];
|
|
1780
|
+
bigrams: Set<string>;
|
|
1781
|
+
};
|
|
1782
|
+
type LexicalSignal = {
|
|
1783
|
+
strategy?: LexicalStrategy;
|
|
1784
|
+
text: string | null | undefined;
|
|
1785
|
+
weight: number;
|
|
1786
|
+
};
|
|
1787
|
+
type LexicalRerankOptions = {
|
|
1788
|
+
lexicalWeight?: number;
|
|
1789
|
+
rankWeight?: number;
|
|
1790
|
+
};
|
|
1791
|
+
/** Tokenize a string into lowercase words, removing stop words. */
|
|
1792
|
+
declare function tokenizeSearchText(text: string): string[];
|
|
1793
|
+
/** Simple stemmer: strip common English suffixes for fuzzy matching. */
|
|
1794
|
+
declare function stemToken(word: string): string;
|
|
1795
|
+
/** Compute token overlap score between query tokens and text tokens. */
|
|
1796
|
+
declare function tokenOverlapScore(queryTokens: string[], textTokens: string[]): number;
|
|
1797
|
+
/**
|
|
1798
|
+
* Extract character bigrams from text. Normalizes to lowercase, removes
|
|
1799
|
+
* non-alphanumeric characters, and generates overlapping pairs.
|
|
1800
|
+
*/
|
|
1801
|
+
declare function bigramTokenize(text: string): Set<string>;
|
|
1802
|
+
/**
|
|
1803
|
+
* Extract word-level tokens from text (for coarser matching).
|
|
1804
|
+
* Normalizes to lowercase, splits on non-alphanumeric.
|
|
1805
|
+
*/
|
|
1806
|
+
declare function wordTokenize(text: string): string[];
|
|
1807
|
+
/** Jaccard similarity between two sets: |A ∩ B| / |A ∪ B|. */
|
|
1808
|
+
declare function jaccardSimilarity(setA: Set<string>, setB: Set<string>): number;
|
|
1809
|
+
/** Exact word overlap score: fraction of type words found in input text. */
|
|
1810
|
+
declare function wordOverlapScore(inputWords: string[], typeWords: string[]): number;
|
|
1811
|
+
/** Pre-compute reusable lexical structures for a query. */
|
|
1812
|
+
declare function prepareLexicalQuery(query: string): PreparedLexicalQuery;
|
|
1813
|
+
/** Score a single lexical signal against a prepared query. */
|
|
1814
|
+
declare function scoreLexicalSignal(query: PreparedLexicalQuery, signal: LexicalSignal): number;
|
|
1815
|
+
/** Weighted lexical score across multiple textual signals. */
|
|
1816
|
+
declare function scoreLexicalSignals(query: PreparedLexicalQuery, signals: LexicalSignal[]): number;
|
|
1817
|
+
/** Map a candidate's original rank position into a 0..1 prior. */
|
|
1818
|
+
declare function rankWindowScore(index: number, total: number): number;
|
|
1819
|
+
/** Rerank a candidate window by lexical overlap while preserving original-rank prior. */
|
|
1820
|
+
declare function rerankLexicalWindow<T>(query: string, items: T[], getText: (item: T) => string | null | undefined, options?: LexicalRerankOptions): T[];
|
|
1821
|
+
|
|
1822
|
+
/**
|
|
1823
|
+
* @lucern/contracts — TopicsV1 namespace (resource contracts)
|
|
1824
|
+
*
|
|
1825
|
+
* Moved from src/topic-scope.contract.ts in EK-16 T1 PR 2.
|
|
1826
|
+
* Compat shim remains at the old path until the Lucern 1.0.0 cut.
|
|
1827
|
+
*/
|
|
1828
|
+
declare const ROOT_TOPIC_ID = "n17tm38rwet7wqgzrmwahyt1z582590y";
|
|
1829
|
+
type TopicDoc = {
|
|
1830
|
+
_id: string;
|
|
1831
|
+
name?: string;
|
|
1832
|
+
parentTopicId?: string;
|
|
1833
|
+
depth?: number;
|
|
1834
|
+
type?: string;
|
|
1835
|
+
};
|
|
1836
|
+
/**
|
|
1837
|
+
* BFS traversal collecting a topic and its neighborhood:
|
|
1838
|
+
* ancestors up to root + descendants down to maxDescendantDepth.
|
|
1839
|
+
*/
|
|
1840
|
+
declare function collectTopicNeighborhood(topics: TopicDoc[], rootTopicId: string, maxDescendantDepth?: number): string[];
|
|
1841
|
+
|
|
1842
|
+
/**
|
|
1843
|
+
* Workflow Runtime Contract v1
|
|
1844
|
+
*
|
|
1845
|
+
* Canonical TypeScript contract for Lucern's graph-local workflow runtime.
|
|
1846
|
+
* WF-1 defines the typed substrate for:
|
|
1847
|
+
* - workflow definitions and run receipts
|
|
1848
|
+
* - action mutation tiering and approval expectations
|
|
1849
|
+
* - hooks over worktree/question/evidence/inbox events
|
|
1850
|
+
* - output unions for domain-specific artifacts
|
|
1851
|
+
* - deterministic integrity checks and operational metadata
|
|
1852
|
+
*
|
|
1853
|
+
* BREAKING CHANGE RULES:
|
|
1854
|
+
* - Adding optional fields is NON-breaking
|
|
1855
|
+
* - Removing fields or renaming enum values is BREAKING
|
|
1856
|
+
* - Reclassifying a mutation tier is BREAKING
|
|
1857
|
+
* - Changing canonical workflow IDs is BREAKING
|
|
1858
|
+
*/
|
|
1859
|
+
declare const WORKFLOW_RUNTIME_SCHEMA_VERSION: "1.0.0";
|
|
1860
|
+
declare const WORKFLOW_MUTATION_TIERS: readonly ["read_only", "low_risk_write", "high_risk_write"];
|
|
1861
|
+
type WorkflowMutationTier = (typeof WORKFLOW_MUTATION_TIERS)[number];
|
|
1862
|
+
declare const WORKFLOW_APPROVAL_MODES: readonly ["none", "audit_only", "human_required", "auto_approve"];
|
|
1863
|
+
type WorkflowApprovalMode = (typeof WORKFLOW_APPROVAL_MODES)[number];
|
|
1864
|
+
declare const DEFAULT_TIER_APPROVAL_MODE: Readonly<Record<WorkflowMutationTier, WorkflowApprovalMode>>;
|
|
1865
|
+
declare const WORKFLOW_ACTION_KINDS: readonly ["context_pack", "integrity_check", "lucern_tool", "report_compile", "brief_publish", "notification", "custom"];
|
|
1866
|
+
type WorkflowActionKind = (typeof WORKFLOW_ACTION_KINDS)[number];
|
|
1867
|
+
declare const WORKFLOW_HOOK_EVENTS: readonly ["schedule.tick", "worktree.activated", "worktree.completed", "question.created", "question.answered", "evidence.appended", "inbox.item_created"];
|
|
1868
|
+
type WorkflowHookEvent = (typeof WORKFLOW_HOOK_EVENTS)[number];
|
|
1869
|
+
declare const WORKFLOW_OUTPUT_KINDS: readonly ["engineering_brief", "research_memo", "strategy_artifact", "inbox_summary", "pipeline_brief", "structured_payload"];
|
|
1870
|
+
type WorkflowOutputKind = (typeof WORKFLOW_OUTPUT_KINDS)[number];
|
|
1871
|
+
declare const WORKFLOW_RUN_STATUSES: readonly ["queued", "running", "awaiting_approval", "completed", "failed", "cancelled"];
|
|
1872
|
+
type WorkflowRunStatus = (typeof WORKFLOW_RUN_STATUSES)[number];
|
|
1873
|
+
declare const WORKFLOW_TRIGGER_KINDS: readonly ["manual", "schedule", "hook"];
|
|
1874
|
+
type WorkflowTriggerKind = (typeof WORKFLOW_TRIGGER_KINDS)[number];
|
|
1875
|
+
declare const WORKFLOW_PROOF_ARTIFACT_KINDS: readonly ["report", "brief", "artifact", "dashboard", "test_evidence"];
|
|
1876
|
+
type WorkflowProofArtifactKind = (typeof WORKFLOW_PROOF_ARTIFACT_KINDS)[number];
|
|
1877
|
+
declare const WORKFLOW_STAFFING_HINTS: readonly ["solo", "backend+tests", "fullstack", "mcp+tests"];
|
|
1878
|
+
type WorkflowStaffingHint = (typeof WORKFLOW_STAFFING_HINTS)[number];
|
|
1879
|
+
declare const WORKFLOW_AUTO_FIX_MODES: readonly ["disabled", "dry_run", "safe", "aggressive"];
|
|
1880
|
+
type WorkflowAutoFixMode = (typeof WORKFLOW_AUTO_FIX_MODES)[number];
|
|
1881
|
+
declare const WORKFLOW_INTEGRITY_CHECKS: readonly ["null_dependency_refs", "superseded_blockers", "band_order_inconsistency", "sparse_shaping", "failed_completed_gate"];
|
|
1882
|
+
type WorkflowIntegrityCheckId = (typeof WORKFLOW_INTEGRITY_CHECKS)[number];
|
|
1883
|
+
type WorkflowProofArtifact = {
|
|
1884
|
+
kind: WorkflowProofArtifactKind;
|
|
1885
|
+
label: string;
|
|
1886
|
+
required?: boolean;
|
|
1887
|
+
sourceRef?: string;
|
|
1888
|
+
};
|
|
1889
|
+
type WorkflowAutoFixPolicy = {
|
|
1890
|
+
mode: WorkflowAutoFixMode;
|
|
1891
|
+
maxActionsPerRun?: number;
|
|
1892
|
+
permittedMutationTiers?: WorkflowMutationTier[];
|
|
1893
|
+
requireAuditTrail?: boolean;
|
|
1894
|
+
escalationGate?: string;
|
|
1895
|
+
};
|
|
1896
|
+
declare const DEFAULT_WORKFLOW_AUTO_FIX_POLICY: WorkflowAutoFixPolicy;
|
|
1897
|
+
type WorkflowApprovalPolicy = {
|
|
1898
|
+
mode: WorkflowApprovalMode;
|
|
1899
|
+
approvalGate?: string;
|
|
1900
|
+
autoApprovePolicyKey?: string;
|
|
1901
|
+
rationaleRequired?: boolean;
|
|
1902
|
+
};
|
|
1903
|
+
type WorkflowOutputBase = {
|
|
1904
|
+
outputId: string;
|
|
1905
|
+
kind: WorkflowOutputKind;
|
|
1906
|
+
title: string;
|
|
1907
|
+
summary: string;
|
|
1908
|
+
generatedAt?: number;
|
|
1909
|
+
};
|
|
1910
|
+
type EngineeringBriefOutput = WorkflowOutputBase & {
|
|
1911
|
+
kind: "engineering_brief";
|
|
1912
|
+
sections: Array<{
|
|
1913
|
+
heading: string;
|
|
1914
|
+
body: string;
|
|
1915
|
+
}>;
|
|
1916
|
+
touchedPaths?: string[];
|
|
1917
|
+
};
|
|
1918
|
+
type ResearchMemoOutput = WorkflowOutputBase & {
|
|
1919
|
+
kind: "research_memo";
|
|
1920
|
+
claims: string[];
|
|
1921
|
+
evidenceRefs?: string[];
|
|
1922
|
+
};
|
|
1923
|
+
type StrategyArtifactOutput = WorkflowOutputBase & {
|
|
1924
|
+
kind: "strategy_artifact";
|
|
1925
|
+
recommendations: string[];
|
|
1926
|
+
decisionWindow?: string;
|
|
1927
|
+
};
|
|
1928
|
+
type InboxSummaryOutput = WorkflowOutputBase & {
|
|
1929
|
+
kind: "inbox_summary";
|
|
1930
|
+
channel: "developer_portal" | "chat" | "ops";
|
|
1931
|
+
inboxTitle: string;
|
|
1932
|
+
inboxBody: string;
|
|
1933
|
+
};
|
|
1934
|
+
type PipelineBriefOutput = WorkflowOutputBase & {
|
|
1935
|
+
kind: "pipeline_brief";
|
|
1936
|
+
hingeWorktreeId?: string;
|
|
1937
|
+
groupedBlockers: Array<{
|
|
1938
|
+
blocker: string;
|
|
1939
|
+
blockedWorktreeIds: string[];
|
|
1940
|
+
}>;
|
|
1941
|
+
};
|
|
1942
|
+
type StructuredPayloadOutput = WorkflowOutputBase & {
|
|
1943
|
+
kind: "structured_payload";
|
|
1944
|
+
payload: Record<string, unknown>;
|
|
1945
|
+
};
|
|
1946
|
+
type WorkflowOutputContract = EngineeringBriefOutput | ResearchMemoOutput | StrategyArtifactOutput | InboxSummaryOutput | PipelineBriefOutput | StructuredPayloadOutput;
|
|
1947
|
+
type WorkflowActionContract = {
|
|
1948
|
+
actionId: string;
|
|
1949
|
+
kind: WorkflowActionKind;
|
|
1950
|
+
title: string;
|
|
1951
|
+
description: string;
|
|
1952
|
+
mutationTier: WorkflowMutationTier;
|
|
1953
|
+
toolName?: string;
|
|
1954
|
+
produces?: WorkflowOutputKind[];
|
|
1955
|
+
idempotent?: boolean;
|
|
1956
|
+
approval: WorkflowApprovalPolicy;
|
|
1957
|
+
};
|
|
1958
|
+
type WorkflowHookContract = {
|
|
1959
|
+
hookId: string;
|
|
1960
|
+
event: WorkflowHookEvent;
|
|
1961
|
+
description: string;
|
|
1962
|
+
condition?: string;
|
|
1963
|
+
actionIds: string[];
|
|
1964
|
+
};
|
|
1965
|
+
type WorkflowTriggerContract = {
|
|
1966
|
+
kind: "manual";
|
|
1967
|
+
description?: string;
|
|
1968
|
+
} | {
|
|
1969
|
+
kind: "schedule";
|
|
1970
|
+
cadence: "hourly" | "daily" | "weekly";
|
|
1971
|
+
timezone?: string;
|
|
1972
|
+
} | {
|
|
1973
|
+
kind: "hook";
|
|
1974
|
+
event: WorkflowHookEvent;
|
|
1975
|
+
};
|
|
1976
|
+
type WorkflowDefinitionV1 = {
|
|
1977
|
+
workflowId: string;
|
|
1978
|
+
version: typeof WORKFLOW_RUNTIME_SCHEMA_VERSION;
|
|
1979
|
+
title: string;
|
|
1980
|
+
description: string;
|
|
1981
|
+
trigger: WorkflowTriggerContract;
|
|
1982
|
+
staffingHint?: WorkflowStaffingHint;
|
|
1983
|
+
proofArtifacts?: WorkflowProofArtifact[];
|
|
1984
|
+
autoFixPolicy?: WorkflowAutoFixPolicy;
|
|
1985
|
+
actions: readonly WorkflowActionContract[];
|
|
1986
|
+
hooks?: readonly WorkflowHookContract[];
|
|
1987
|
+
outputs: readonly WorkflowOutputKind[];
|
|
1988
|
+
integrityChecks?: readonly WorkflowIntegrityCheckId[];
|
|
1989
|
+
};
|
|
1990
|
+
type WorkflowRunReceiptV1 = {
|
|
1991
|
+
runId: string;
|
|
1992
|
+
workflowId: string;
|
|
1993
|
+
status: WorkflowRunStatus;
|
|
1994
|
+
triggeredBy: WorkflowTriggerKind;
|
|
1995
|
+
startedAt: number;
|
|
1996
|
+
completedAt?: number;
|
|
1997
|
+
outputKinds: WorkflowOutputKind[];
|
|
1998
|
+
approvalsRequired?: number;
|
|
1999
|
+
};
|
|
2000
|
+
declare const NIGHTLY_RECONCILIATION_WORKFLOW_ID: "workflow.pipeline_reconciliation.v1";
|
|
2001
|
+
declare const MORNING_BRIEF_WORKFLOW_ID: "workflow.morning_brief.v1";
|
|
2002
|
+
declare const CANONICAL_WORKFLOW_DEFINITIONS: readonly WorkflowDefinitionV1[];
|
|
2003
|
+
|
|
2004
|
+
export { type AddEvidenceInput, type AddWorktreeInput, type AuthContext, BELIEF_STATUSES, BELIEF_TYPE_BONUS, BRANCH_STATUSES, type BeliefLatticeSeed, type BeliefResult, type BeliefStatus, type BisectConfidenceInput, type BisectResult, type BranchResult, type BranchStatus, CANONICAL_WORKFLOW_DEFINITIONS, CONFIDENCE_TRIGGERS, CONTEXT_PACK_SCHEMA_VERSION, CONTEXT_PACK_SECTION_KEYS, CONTEXT_RANKING_PROFILES, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, type CompileContextInput, type CompiledContextResult, type ConfidenceResult, type ConfidenceTrigger, type ContextCompilationMode, type ContextPackBelief, type ContextPackContradiction, type ContextPackDeltaReport, type ContextPackDiagnostics, type ContextPackEntity, type ContextPackEvidence, type ContextPackFailure, type ContextPackFailureContext, type ContextPackInjectionPolicy, type ContextPackQuestion, type ContextPackRequestV1, type ContextPackSectionKey, type ContextPackSummary, type ContextPackV1, type ContextRankingProfile, type ContradictionResult, type ContradictionSeverity, type ContradictionStatus, type ConvexAdminClient, type CreateBeliefInput, type CreateBranchInput, type CreateDomainEventInput, type CreateEdgeInput, type CutoverDomain, type CutoverFlagState, DEFAULT_BELIEF_TYPE_BONUS, DEFAULT_COMPILATION_MODE, DEFAULT_ENTITY_LIMIT, DEFAULT_PRIORITY_SCORE, DEFAULT_RANKING_PROFILE, DEFAULT_SECTION_LIMIT, DEFAULT_SEVERITY_SCORE, DEFAULT_TIER_APPROVAL_MODE, DEFAULT_TOKEN_BUDGET, DEFAULT_WORKFLOW_AUTO_FIX_POLICY, DEFEAT_TYPES, DOMAIN_EVENT_TYPES, DOMAIN_EVENT_VERSION, type DecodedPrefixedId, type DefeatType, type DomainActorType, type DomainEvent, type DomainEventData, type DomainEventType, type DomainResourceType, ENTITY_RANKING_WEIGHTS, EPISTEMIC_LAYERS, EVENT_RETENTION_DEFAULT_DAYS, type EdgeResult, type EngineeringBriefOutput, type EntityConnectionMatch, type EntityMatchCandidate, type EntityTypeMatch, type EpistemicLayer, type EventCursor, type EventListQuery, type EventListResult, type EvidenceResult, FORK_REASONS, type FlagContradictionInput, type ForkBeliefInput, type ForkReason, type ForkResult, type GatewayAuthContext, type GatewayAuthMode, type GatewayEnvironment, type GatewayErrorArgs, type GatewayScope, type GatewaySuccessArgs, INTEGRATION_EDGE_TYPES, type InboxSummaryOutput, type IntegrationEdgeType, JUDGMENT_TYPES, type JudgmentResult, type JudgmentType, type KeyLifecycleStatus, type LexicalRerankOptions, type LexicalSignal, type LexicalStrategy, type LineageResult, type LucernClient, type LucernClientConfig, type LucernGraphMethods, type LucernPrompt, type LucernPromptModelHint, type LucernSdkClient, type LucernWorkflowMethods, MAX_ENTITY_LIMIT, MAX_SECTION_LIMIT, MAX_TOKEN_BUDGET, MERGE_OUTCOMES, MIN_CONTRADICTION_BUDGET, MIN_TOKEN_BUDGET, MIN_TOKEN_ESTIMATE, MORNING_BRIEF_WORKFLOW_ID, type McpTransportKind, type MergeInput, type MergeOutcome, type MergeResult, type ModulateConfidenceInput, NIGHTLY_RECONCILIATION_WORKFLOW_ID, type OntologyEntityType, type OpenPullRequestInput, PRIORITY_SCORES, PULL_REQUEST_STATUSES, type PackWeightOverride, type PipelineBriefOutput, type PlatformApiErrorCode, type PreparedLexicalQuery, type PublicCompiledContext, type PublicContextBelief, type PublicContextContradiction, type PublicContextEntity, type PublicContextEvidence, type PublicContextInjectionPolicy, type PublicContextQuestion, type PullRequestResult, type PullRequestStatus, type PushInput, type PushResult, type QueryLineageInput, RANKING_WEIGHTS, REASONING_METHODS, RECENCY_HALF_LIFE_DAYS, RESOLVED_QUESTION_STATUSES, ROOT_TOPIC_ID, type RankingWeightVector, type ReasoningMethod, type RecordJudgmentInput, type RefineBeliefInput, type ReplayEventsInput, type ReplayEventsResult, type ResearchMemoOutput, SECTION_BUDGET_RATIOS, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, SEVERITY_SCORES, type SearchBeliefsInput, type SessionAuditEnvelope, type SessionAuditOutcome, type SessionAuthMode, type SessionDelegationHop, type SessionLifecycleStatus, type SessionPrincipalType, type StrategyArtifactOutput, type StructuredPayloadOutput, TOKENS_PER_WORD, type TopicDoc, type VerificationObligation, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_DELAYS_MS, WORKFLOW_ACTION_KINDS, WORKFLOW_APPROVAL_MODES, WORKFLOW_AUTO_FIX_MODES, WORKFLOW_HOOK_EVENTS, WORKFLOW_INTEGRITY_CHECKS, WORKFLOW_MUTATION_TIERS, WORKFLOW_OUTPUT_KINDS, WORKFLOW_PROOF_ARTIFACT_KINDS, WORKFLOW_RUNTIME_SCHEMA_VERSION, WORKFLOW_RUN_STATUSES, WORKFLOW_STAFFING_HINTS, WORKFLOW_TRIGGER_KINDS, WORKTREE_PHASES, type WebhookCreateInput, type WebhookDeliveriesResult, type WebhookDeliveryAttemptRecord, type WebhookDeliveryRecord, type WebhookDeliveryStatus, type WebhookHealthResult, type WebhookRecord, type WebhookSecretMode, type WebhookTestResult, type WebhookUpdateInput, type WorkflowActionContract, type WorkflowActionKind, type WorkflowApprovalMode, type WorkflowApprovalPolicy, type WorkflowAutoFixMode, type WorkflowAutoFixPolicy, type WorkflowDefinitionV1, type WorkflowHookContract, type WorkflowHookEvent, type WorkflowIntegrityCheckId, type WorkflowMutationTier, type WorkflowOutputBase, type WorkflowOutputContract, type WorkflowOutputKind, type WorkflowProofArtifact, type WorkflowProofArtifactKind, type WorkflowRunReceiptV1, type WorkflowRunStatus, type WorkflowStaffingHint, type WorkflowTriggerContract, type WorkflowTriggerKind, type WorktreePhase, type WorktreeResult, bigramTokenize, buildDomainEvent, collectTopicNeighborhood, compareEventCursor, createEventId, decodeEventCursor, decodePrefixedId, emitDomainEvent, encodeEventCursor, encodePrefixedId, hasPrefixedIdPrefix, inferActorType, inferSessionPrincipalType, isAfterCursor, isLucernPrompt, jaccardSimilarity, lastDelegator, mcpTools_contract as mcpToolsContract, normalizeDelegationChain, normalizeRetentionDays, prepareLexicalQuery, rankEntityConnections, rankEntityTypeMatches, rankWindowScore, requireActorPrincipalId, rerankLexicalWindow, scoreEntityConnection, scoreEntityTypeMatch, scoreLexicalSignal, scoreLexicalSignals, sdkTools_contract as sdkToolsContract, sortEventsByCursor, stemToken, tokenOverlapScore, tokenizeSearchText, wordOverlapScore, wordTokenize };
|