@lucern/contracts 0.3.0-alpha.0 → 0.3.0-alpha.10
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/CHANGELOG.md +4 -0
- package/dist/component-boundary.contract.d.ts +14 -0
- package/dist/component-boundary.contract.js +155 -0
- package/dist/component-boundary.contract.js.map +1 -0
- package/dist/component-host-boundary.contract.d.ts +41 -0
- package/dist/component-host-boundary.contract.js +54 -0
- package/dist/component-host-boundary.contract.js.map +1 -0
- package/dist/context-pack.contract.d.ts +5 -3
- package/dist/context-pack.contract.js.map +1 -1
- package/dist/{dsl-BgpoVOVQ.d.ts → dsl-djCRfuWC.d.ts} +1 -1
- package/dist/dsl.d.ts +1 -1
- package/dist/dsl.js +4 -4
- package/dist/dsl.js.map +1 -1
- package/dist/edge-policy-manifest-Dw5IhT1L.d.ts +133 -0
- package/dist/function-registry/beliefs.d.ts +42 -82
- package/dist/function-registry/beliefs.js +1154 -125
- package/dist/function-registry/beliefs.js.map +1 -1
- package/dist/function-registry/coding.d.ts +7 -31
- package/dist/function-registry/coding.js +958 -112
- package/dist/function-registry/coding.js.map +1 -1
- package/dist/function-registry/context.d.ts +14 -26
- package/dist/function-registry/context.js +923 -97
- package/dist/function-registry/context.js.map +1 -1
- package/dist/function-registry/contracts.d.ts +4 -16
- package/dist/function-registry/contracts.js +860 -82
- package/dist/function-registry/contracts.js.map +1 -1
- package/dist/function-registry/coordination.d.ts +10 -46
- package/dist/function-registry/coordination.js +872 -84
- package/dist/function-registry/coordination.js.map +1 -1
- package/dist/function-registry/edges.d.ts +166 -18
- package/dist/function-registry/edges.js +1188 -97
- package/dist/function-registry/edges.js.map +1 -1
- package/dist/function-registry/evidence.d.ts +42 -74
- package/dist/function-registry/evidence.js +1106 -130
- package/dist/function-registry/evidence.js.map +1 -1
- package/dist/function-registry/graph.d.ts +132 -106
- package/dist/function-registry/graph.js +1006 -100
- package/dist/function-registry/graph.js.map +1 -1
- package/dist/function-registry/helpers.d.ts +8 -10
- package/dist/function-registry/helpers.js +869 -83
- package/dist/function-registry/helpers.js.map +1 -1
- package/dist/function-registry/identity.d.ts +4 -16
- package/dist/function-registry/identity.js +860 -82
- package/dist/function-registry/identity.js.map +1 -1
- package/dist/function-registry/index.d.ts +322 -8
- package/dist/function-registry/index.js +1249 -87
- package/dist/function-registry/index.js.map +1 -1
- package/dist/function-registry/judgments.d.ts +12 -20
- package/dist/function-registry/judgments.js +891 -94
- package/dist/function-registry/judgments.js.map +1 -1
- package/dist/function-registry/legacy.d.ts +2 -6
- package/dist/function-registry/legacy.js +860 -82
- package/dist/function-registry/legacy.js.map +1 -1
- package/dist/function-registry/lenses.d.ts +18 -34
- package/dist/function-registry/lenses.js +928 -88
- package/dist/function-registry/lenses.js.map +1 -1
- package/dist/function-registry/manifest.d.ts +7 -7
- package/dist/function-registry/manifest.js +19 -2
- package/dist/function-registry/manifest.js.map +1 -1
- package/dist/function-registry/ontologies.d.ts +46 -90
- package/dist/function-registry/ontologies.js +908 -109
- package/dist/function-registry/ontologies.js.map +1 -1
- package/dist/function-registry/pipeline.d.ts +14 -26
- package/dist/function-registry/pipeline.js +880 -85
- package/dist/function-registry/pipeline.js.map +1 -1
- package/dist/function-registry/questions.d.ts +50 -98
- package/dist/function-registry/questions.js +1043 -118
- package/dist/function-registry/questions.js.map +1 -1
- package/dist/function-registry/tasks.d.ts +18 -34
- package/dist/function-registry/tasks.js +973 -87
- package/dist/function-registry/tasks.js.map +1 -1
- package/dist/function-registry/topics.d.ts +100 -42
- package/dist/function-registry/topics.js +961 -89
- package/dist/function-registry/topics.js.map +1 -1
- package/dist/function-registry/types.d.ts +2 -2
- package/dist/function-registry/worktrees.d.ts +116 -74
- package/dist/function-registry/worktrees.js +1124 -115
- package/dist/function-registry/worktrees.js.map +1 -1
- package/dist/function-registry-input-audit.d.ts +13 -0
- package/dist/function-registry-input-audit.js +166 -0
- package/dist/function-registry-input-audit.js.map +1 -0
- package/dist/gateway.contract.d.ts +2 -0
- package/dist/gateway.contract.js.map +1 -1
- package/dist/generated/convexSchemas.js +8 -6
- package/dist/generated/convexSchemas.js.map +1 -1
- package/dist/generated/schema-manifest.json +103 -5
- package/dist/generated/tableOwnership.d.ts +4 -2
- package/dist/generated/tableOwnership.js +4 -0
- package/dist/generated/tableOwnership.js.map +1 -1
- package/dist/generated/tier-expectations.json +9 -4
- package/dist/graph-intelligence.contract.d.ts +506 -0
- package/dist/graph-intelligence.contract.js +595 -0
- package/dist/graph-intelligence.contract.js.map +1 -0
- package/dist/graph-types/index.d.ts +5 -1
- package/dist/graph-types/index.js +15 -4
- package/dist/graph-types/index.js.map +1 -1
- package/dist/index-O09U2xHk.d.ts +28 -0
- package/dist/index.d.ts +25 -4
- package/dist/index.js +3989 -236
- package/dist/index.js.map +1 -1
- package/dist/infisical-runtime.contract.d.ts +174 -0
- package/dist/infisical-runtime.contract.js +317 -0
- package/dist/infisical-runtime.contract.js.map +1 -0
- package/dist/lens-filter.contract.js +4 -3
- package/dist/lens-filter.contract.js.map +1 -1
- package/dist/lens-workflow.contract.js +4 -3
- package/dist/lens-workflow.contract.js.map +1 -1
- package/dist/manifests/edge-policy-manifest.d.ts +2 -0
- package/dist/manifests/edge-policy-manifest.data.d.ts +13 -0
- package/dist/manifests/edge-policy-manifest.data.js +26 -0
- package/dist/manifests/edge-policy-manifest.data.js.map +1 -0
- package/dist/manifests/edge-policy-manifest.js +92 -0
- package/dist/manifests/edge-policy-manifest.js.map +1 -0
- package/dist/manifests/infisical-runtime-manifest.d.ts +151 -0
- package/dist/manifests/infisical-runtime-manifest.js +316 -0
- package/dist/manifests/infisical-runtime-manifest.js.map +1 -0
- package/dist/manifests/invariant-manifest.d.ts +65 -0
- package/dist/manifests/invariant-manifest.js +18 -0
- package/dist/manifests/invariant-manifest.js.map +1 -0
- package/dist/manifests/invariants/ast-utils.d.ts +14 -0
- package/dist/manifests/invariants/ast-utils.js +54 -0
- package/dist/manifests/invariants/ast-utils.js.map +1 -0
- package/dist/manifests/invariants/index.d.ts +15 -0
- package/dist/manifests/invariants/index.js +183 -0
- package/dist/manifests/invariants/index.js.map +1 -0
- package/dist/manifests/invariants/inv-1-beliefs-append-only.d.ts +12 -0
- package/dist/manifests/invariants/inv-1-beliefs-append-only.js +94 -0
- package/dist/manifests/invariants/inv-1-beliefs-append-only.js.map +1 -0
- package/dist/manifests/invariants/inv-14-no-silent-transitions.d.ts +12 -0
- package/dist/manifests/invariants/inv-14-no-silent-transitions.js +99 -0
- package/dist/manifests/invariants/inv-14-no-silent-transitions.js.map +1 -0
- package/dist/manifests/invariants/manifest-1-projections-declare-audit.d.ts +12 -0
- package/dist/manifests/invariants/manifest-1-projections-declare-audit.js +42 -0
- package/dist/manifests/invariants/manifest-1-projections-declare-audit.js.map +1 -0
- package/dist/manifests/tenant-client-manifest.d.ts +322 -0
- package/dist/manifests/tenant-client-manifest.js +432 -0
- package/dist/manifests/tenant-client-manifest.js.map +1 -0
- package/dist/mcp-gateway-boundary.contract.d.ts +181 -0
- package/dist/mcp-gateway-boundary.contract.js +43 -0
- package/dist/mcp-gateway-boundary.contract.js.map +1 -0
- package/dist/projections/check-convex-args-shape.d.ts +3 -0
- package/dist/projections/check-convex-args-shape.js +399 -0
- package/dist/projections/check-convex-args-shape.js.map +1 -0
- package/dist/projections/create-evidence.projection.d.ts +176 -0
- package/dist/projections/create-evidence.projection.js +131 -0
- package/dist/projections/create-evidence.projection.js.map +1 -0
- package/dist/projections/index.d.ts +102 -0
- package/dist/projections/index.js +348 -0
- package/dist/projections/index.js.map +1 -0
- package/dist/projections/list-beliefs.projection.d.ts +36 -0
- package/dist/projections/list-beliefs.projection.js +54 -0
- package/dist/projections/list-beliefs.projection.js.map +1 -0
- package/dist/projections/list-tasks.projection.d.ts +32 -0
- package/dist/projections/list-tasks.projection.js +52 -0
- package/dist/projections/list-tasks.projection.js.map +1 -0
- package/dist/projections/modulate-confidence.projection.d.ts +219 -0
- package/dist/projections/modulate-confidence.projection.js +148 -0
- package/dist/projections/modulate-confidence.projection.js.map +1 -0
- package/dist/projections/projection-dsl.d.ts +11 -0
- package/dist/projections/projection-dsl.js +8 -0
- package/dist/projections/projection-dsl.js.map +1 -0
- package/dist/schema-helpers/enumValidation.js +2 -5
- package/dist/schema-helpers/enumValidation.js.map +1 -1
- package/dist/schema-helpers/spine/nodes/decision.js +2 -1
- package/dist/schema-helpers/spine/nodes/decision.js.map +1 -1
- package/dist/schema-helpers/spine/tables/epistemicNodes.js +27 -27
- package/dist/schema-helpers/spine/tables/epistemicNodes.js.map +1 -1
- package/dist/schema-helpers/validators.d.ts +1 -1
- package/dist/schema-helpers/validators.js +1 -1
- package/dist/schema-helpers/validators.js.map +1 -1
- package/dist/schemas/component-table-manifest.d.ts +74 -0
- package/dist/schemas/component-table-manifest.js +26 -0
- package/dist/schemas/component-table-manifest.js.map +1 -0
- package/dist/schemas/enums.d.ts +5 -2
- package/dist/schemas/enums.js +5 -2
- package/dist/schemas/enums.js.map +1 -1
- package/dist/schemas/index.d.ts +3 -1
- package/dist/schemas/index.js +112 -13
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/manifest.d.ts +1154 -949
- package/dist/schemas/manifest.js +80 -12
- package/dist/schemas/manifest.js.map +1 -1
- package/dist/schemas/sl-opinion.d.ts +31 -0
- package/dist/schemas/sl-opinion.js +19 -0
- package/dist/schemas/sl-opinion.js.map +1 -0
- package/dist/schemas/tables/identity/platform.d.ts +10 -10
- package/dist/schemas/tables/kernel/epistemic.d.ts +12 -10
- package/dist/schemas/tables/kernel/epistemic.js +6 -4
- package/dist/schemas/tables/kernel/epistemic.js.map +1 -1
- package/dist/schemas/tables/kernel/infra.d.ts +17 -5
- package/dist/schemas/tables/kernel/infra.js +23 -1
- package/dist/schemas/tables/kernel/infra.js.map +1 -1
- package/dist/schemas/tables/kernel/intelligence.d.ts +10 -10
- package/dist/schemas/tables/kernel/lens.d.ts +4 -4
- package/dist/schemas/tables/kernel/platform.d.ts +12 -12
- package/dist/schemas/tables/kernel/spine.d.ts +3 -3
- package/dist/schemas/tables/kernel/spine.js +5 -2
- package/dist/schemas/tables/kernel/spine.js.map +1 -1
- package/dist/schemas/tables/kernel/task.d.ts +42 -42
- package/dist/schemas/tables/kernel/topic.js +5 -1
- package/dist/schemas/tables/kernel/topic.js.map +1 -1
- package/dist/schemas/tables/kernel/worktree.d.ts +62 -62
- package/dist/schemas/tables/kernel/worktree.js +6 -4
- package/dist/schemas/tables/kernel/worktree.js.map +1 -1
- package/dist/schemas/tables/mc/identity.d.ts +26 -3
- package/dist/schemas/tables/mc/identity.js +35 -1
- package/dist/schemas/tables/mc/identity.js.map +1 -1
- package/dist/schemas/tables/mc/pack.d.ts +20 -20
- package/dist/schemas/tables/mc/registry.d.ts +4 -4
- package/dist/schemas/tables/mc/runtime.d.ts +1 -1
- package/dist/schemas/tables/mc/runtime.js +1 -1
- package/dist/schemas/tables/mc/runtime.js.map +1 -1
- package/dist/schemas/tables/mc/workspace.d.ts +9 -3
- package/dist/schemas/tables/mc/workspace.js +3 -1
- package/dist/schemas/tables/mc/workspace.js.map +1 -1
- package/dist/sdk-methods.contract.d.ts +7 -4
- package/dist/{sdk-tools.contract-C2kQN_Xk.d.ts → sdk-tools.contract-BNklQDfB.d.ts} +2 -2
- package/dist/sdk-tools.contract.d.ts +2 -2
- package/dist/sdk-tools.contract.js +800 -74
- package/dist/sdk-tools.contract.js.map +1 -1
- package/dist/tenant-bootstrap-seed.contract.d.ts +1101 -0
- package/dist/tenant-bootstrap-seed.contract.js +653 -0
- package/dist/tenant-bootstrap-seed.contract.js.map +1 -0
- package/dist/tenant-bootstrap-seed.defaults.d.ts +16 -0
- package/dist/tenant-bootstrap-seed.defaults.js +303 -0
- package/dist/tenant-bootstrap-seed.defaults.js.map +1 -0
- package/dist/tenant-client.contract.d.ts +349 -0
- package/dist/tenant-client.contract.js +488 -0
- package/dist/tenant-client.contract.js.map +1 -0
- package/dist/{tool-contracts-WCnuE9DW.d.ts → tool-contracts-BevD9Ho2.d.ts} +39 -3
- package/dist/tool-contracts.d.ts +1 -1
- package/dist/tool-contracts.js +801 -75
- package/dist/tool-contracts.js.map +1 -1
- package/dist/workflow-runtime.contract.js +1 -1
- package/dist/workflow-runtime.contract.js.map +1 -1
- package/package.json +27 -1
- package/dist/index-DoDXl8KS.d.ts +0 -19
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TableOwnershipLayer, TABLE_OWNERSHIP } from './generated/tableOwnership.js';
|
|
2
|
+
|
|
3
|
+
declare const COMPONENT_BOUNDARY_CONTRACT_VERSION: "2026-04-27";
|
|
4
|
+
declare const COMPONENT_BOUNDARY_COMPONENT_LAYERS: readonly ["I", "K"];
|
|
5
|
+
type ComponentBoundaryComponentLayer = (typeof COMPONENT_BOUNDARY_COMPONENT_LAYERS)[number];
|
|
6
|
+
declare const COMPONENT_BOUNDARY_DIRECT_DB_METHODS: readonly ["insert", "patch", "replace", "delete", "query"];
|
|
7
|
+
type ComponentBoundaryDirectDbMethod = (typeof COMPONENT_BOUNDARY_DIRECT_DB_METHODS)[number];
|
|
8
|
+
declare const COMPONENT_BOUNDARY_HOST_SOURCE_ROOTS: readonly ["services", "apps", "convex"];
|
|
9
|
+
declare const COMPONENT_BOUNDARY_HIGH_RISK_TABLES: readonly ["backgroundJobRuns", "backgroundJobSettings", "systemLogs", "epistemicAudit", "platformPolicyDecisionLogs", "tenantApiKeys", "projectGrants", "userSessions"];
|
|
10
|
+
type ComponentBoundaryHighRiskTable = (typeof COMPONENT_BOUNDARY_HIGH_RISK_TABLES)[number];
|
|
11
|
+
declare function getComponentBoundaryTableLayer(tableName: string): TableOwnershipLayer | undefined;
|
|
12
|
+
declare function isComponentBoundaryComponentOwnedTable(tableName: string): tableName is keyof typeof TABLE_OWNERSHIP;
|
|
13
|
+
|
|
14
|
+
export { COMPONENT_BOUNDARY_COMPONENT_LAYERS, COMPONENT_BOUNDARY_CONTRACT_VERSION, COMPONENT_BOUNDARY_DIRECT_DB_METHODS, COMPONENT_BOUNDARY_HIGH_RISK_TABLES, COMPONENT_BOUNDARY_HOST_SOURCE_ROOTS, type ComponentBoundaryComponentLayer, type ComponentBoundaryDirectDbMethod, type ComponentBoundaryHighRiskTable, getComponentBoundaryTableLayer, isComponentBoundaryComponentOwnedTable };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// src/generated/tableOwnership.ts
|
|
2
|
+
var TABLE_OWNERSHIP = {
|
|
3
|
+
"agentMessages": "K",
|
|
4
|
+
"agentRegistryEntries": "L",
|
|
5
|
+
"agents": "I",
|
|
6
|
+
"agentSessions": "K",
|
|
7
|
+
"apiKeys": "L",
|
|
8
|
+
"auditLog": "L",
|
|
9
|
+
"autofixJobs": "K",
|
|
10
|
+
"backgroundJobRuns": "K",
|
|
11
|
+
"backgroundJobSettings": "K",
|
|
12
|
+
"beliefConfidence": "K",
|
|
13
|
+
"beliefEvidenceLinks": "K",
|
|
14
|
+
"beliefHistory": "K",
|
|
15
|
+
"beliefScenarios": "K",
|
|
16
|
+
"beliefVotes": "K",
|
|
17
|
+
"calibrationScores": "K",
|
|
18
|
+
"compatibilityShims": "L",
|
|
19
|
+
"contractEvaluations": "K",
|
|
20
|
+
"contradictions": "K",
|
|
21
|
+
"controlPlaneTenantModelSlotBindings": "L",
|
|
22
|
+
"controlPlaneTenantProviderSecrets": "L",
|
|
23
|
+
"controlPlaneTenantProxyGatewayUsage": "L",
|
|
24
|
+
"controlPlaneToolAcls": "L",
|
|
25
|
+
"crossProjectConnections": "K",
|
|
26
|
+
"cutoverFlags": "L",
|
|
27
|
+
"decisionComputedSummaries": "K",
|
|
28
|
+
"decisionEvents": "K",
|
|
29
|
+
"decisionParticipants": "K",
|
|
30
|
+
"decisionRiskLedger": "K",
|
|
31
|
+
"decisionSnapshots": "K",
|
|
32
|
+
"deliberationContributions": "K",
|
|
33
|
+
"deliberationSessions": "K",
|
|
34
|
+
"epistemicAudit": "K",
|
|
35
|
+
"epistemicContracts": "K",
|
|
36
|
+
"epistemicEdges": "K",
|
|
37
|
+
"epistemicNodeEmbeddings": "K",
|
|
38
|
+
"epistemicNodes": "K",
|
|
39
|
+
"graphAnalysisCache": "K",
|
|
40
|
+
"graphAnalysisResults": "K",
|
|
41
|
+
"graphSuggestions": "K",
|
|
42
|
+
"groupMemberships": "L",
|
|
43
|
+
"groups": "L",
|
|
44
|
+
"harnessReplays": "K",
|
|
45
|
+
"harnessRuns": "K",
|
|
46
|
+
"idempotencyTokens": "K",
|
|
47
|
+
"lenses": "K",
|
|
48
|
+
"lensTopicBindings": "K",
|
|
49
|
+
"mcpWritePolicy": "I",
|
|
50
|
+
"memberships": "L",
|
|
51
|
+
"methodologyPacks": "L",
|
|
52
|
+
"modelCallLogs": "I",
|
|
53
|
+
"modelFunctionSlots": "I",
|
|
54
|
+
"modelRegistry": "I",
|
|
55
|
+
"modelSlotConfigs": "I",
|
|
56
|
+
"neo4jSyncQueue": "K",
|
|
57
|
+
"oauthDeviceCodes": "L",
|
|
58
|
+
"ontologyDefinitions": "K",
|
|
59
|
+
"ontologyVersions": "K",
|
|
60
|
+
"packAssignments": "L",
|
|
61
|
+
"packDefinitions": "L",
|
|
62
|
+
"packEntitlements": "L",
|
|
63
|
+
"packGroupAssignments": "L",
|
|
64
|
+
"packInstallations": "L",
|
|
65
|
+
"packVersions": "L",
|
|
66
|
+
"platformAgentRunPolicyDecisions": "K",
|
|
67
|
+
"platformAgentRunPromptResolutions": "K",
|
|
68
|
+
"platformAgentRuns": "K",
|
|
69
|
+
"platformAgentRunToolCalls": "K",
|
|
70
|
+
"platformAudienceGrants": "I",
|
|
71
|
+
"platformAudiences": "I",
|
|
72
|
+
"platformHarnessShadowAudit": "K",
|
|
73
|
+
"platformPolicyDecisionLogs": "I",
|
|
74
|
+
"policyBundles": "L",
|
|
75
|
+
"policyDecisionLogs": "L",
|
|
76
|
+
"policySimulations": "L",
|
|
77
|
+
"principals": "L",
|
|
78
|
+
"projectGrants": "I",
|
|
79
|
+
"publicationRules": "K",
|
|
80
|
+
"questionEvidenceLinks": "K",
|
|
81
|
+
"rateLimitWindows": "L",
|
|
82
|
+
"reasoningPermissions": "I",
|
|
83
|
+
"researchJobs": "K",
|
|
84
|
+
"schemaEnumConfig": "K",
|
|
85
|
+
"servicePrincipalKeys": "L",
|
|
86
|
+
"stakeholderGroups": "K",
|
|
87
|
+
"systemLogs": "K",
|
|
88
|
+
"tasks": "K",
|
|
89
|
+
"tenantApiKeys": "I",
|
|
90
|
+
"tenantConfig": "I",
|
|
91
|
+
"tenantDeploymentCredentials": "L",
|
|
92
|
+
"tenantIntegrations": "I",
|
|
93
|
+
"tenantMethodologyAssignments": "L",
|
|
94
|
+
"tenantModelSlotBindings": "I",
|
|
95
|
+
"tenantPolicies": "I",
|
|
96
|
+
"tenantProviderSecrets": "I",
|
|
97
|
+
"tenantProxyGatewayUsage": "I",
|
|
98
|
+
"tenantProxyTokenMints": "I",
|
|
99
|
+
"tenants": "L",
|
|
100
|
+
"tenantSandboxAuditEvents": "I",
|
|
101
|
+
"tenantSecrets": "I",
|
|
102
|
+
"toolAcls": "I",
|
|
103
|
+
"toolCatalog": "L",
|
|
104
|
+
"toolRegistry": "I",
|
|
105
|
+
"toolRegistryEntries": "L",
|
|
106
|
+
"topics": "K",
|
|
107
|
+
"users": "I",
|
|
108
|
+
"userSessions": "L",
|
|
109
|
+
"workflowDefinitions": "K",
|
|
110
|
+
"workflowPullRequests": "K",
|
|
111
|
+
"workflowStages": "K",
|
|
112
|
+
"workspaces": "L",
|
|
113
|
+
"worktreeBeliefCluster": "K",
|
|
114
|
+
"worktrees": "K"
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/component-boundary.contract.ts
|
|
118
|
+
var COMPONENT_BOUNDARY_CONTRACT_VERSION = "2026-04-27";
|
|
119
|
+
var COMPONENT_BOUNDARY_COMPONENT_LAYERS = [
|
|
120
|
+
"I",
|
|
121
|
+
"K"
|
|
122
|
+
];
|
|
123
|
+
var COMPONENT_BOUNDARY_DIRECT_DB_METHODS = [
|
|
124
|
+
"insert",
|
|
125
|
+
"patch",
|
|
126
|
+
"replace",
|
|
127
|
+
"delete",
|
|
128
|
+
"query"
|
|
129
|
+
];
|
|
130
|
+
var COMPONENT_BOUNDARY_HOST_SOURCE_ROOTS = [
|
|
131
|
+
"services",
|
|
132
|
+
"apps",
|
|
133
|
+
"convex"
|
|
134
|
+
];
|
|
135
|
+
var COMPONENT_BOUNDARY_HIGH_RISK_TABLES = [
|
|
136
|
+
"backgroundJobRuns",
|
|
137
|
+
"backgroundJobSettings",
|
|
138
|
+
"systemLogs",
|
|
139
|
+
"epistemicAudit",
|
|
140
|
+
"platformPolicyDecisionLogs",
|
|
141
|
+
"tenantApiKeys",
|
|
142
|
+
"projectGrants",
|
|
143
|
+
"userSessions"
|
|
144
|
+
];
|
|
145
|
+
function getComponentBoundaryTableLayer(tableName) {
|
|
146
|
+
return TABLE_OWNERSHIP[tableName];
|
|
147
|
+
}
|
|
148
|
+
function isComponentBoundaryComponentOwnedTable(tableName) {
|
|
149
|
+
const layer = getComponentBoundaryTableLayer(tableName);
|
|
150
|
+
return layer === "I" || layer === "K";
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export { COMPONENT_BOUNDARY_COMPONENT_LAYERS, COMPONENT_BOUNDARY_CONTRACT_VERSION, COMPONENT_BOUNDARY_DIRECT_DB_METHODS, COMPONENT_BOUNDARY_HIGH_RISK_TABLES, COMPONENT_BOUNDARY_HOST_SOURCE_ROOTS, getComponentBoundaryTableLayer, isComponentBoundaryComponentOwnedTable };
|
|
154
|
+
//# sourceMappingURL=component-boundary.contract.js.map
|
|
155
|
+
//# sourceMappingURL=component-boundary.contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generated/tableOwnership.ts","../src/component-boundary.contract.ts"],"names":[],"mappings":";AA+HO,IAAM,eAAA,GAAkB;AAAA,EAC7B,eAAA,EAAiB,GAAA;AAAA,EACjB,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AAA;AAAA,EACA,QAAA;AAAA,EACA;AACF;AAIO,IAAM,oCAAA,GAAuC;AAAA,EAClD,UAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF;AAEO,IAAM,mCAAA,GAAsC;AAAA,EACjD,mBAAA;AAAA,EACA,uBAAA;AAAA,EACA,YAAA;AAAA,EACA,gBAAA;AAAA,EACA,4BAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF;AAIO,SAAS,+BACd,SAAA,EACiC;AACjC,EAAA,OAAO,gBAAgB,SAAyC,CAAA;AAClE;AAEO,SAAS,uCACd,SAAA,EAC2C;AAC3C,EAAA,MAAM,KAAA,GAAQ,+BAA+B,SAAS,CAAA;AACtD,EAAA,OACE,KAAA,KAAU,OACV,KAAA,KAAU,GAAA;AAEd","file":"component-boundary.contract.js","sourcesContent":["/* GENERATED by scripts/generate-contract-schema.ts. DO NOT EDIT. */\n\nexport type TableOwnershipLayer = \"L\" | \"I\" | \"K\" | \"D\" | \"A\";\n\nexport const TABLES_BY_LAYER = {\n \"L\": [\n \"agentRegistryEntries\",\n \"apiKeys\",\n \"auditLog\",\n \"compatibilityShims\",\n \"controlPlaneTenantModelSlotBindings\",\n \"controlPlaneTenantProviderSecrets\",\n \"controlPlaneTenantProxyGatewayUsage\",\n \"controlPlaneToolAcls\",\n \"cutoverFlags\",\n \"groupMemberships\",\n \"groups\",\n \"memberships\",\n \"methodologyPacks\",\n \"oauthDeviceCodes\",\n \"packAssignments\",\n \"packDefinitions\",\n \"packEntitlements\",\n \"packGroupAssignments\",\n \"packInstallations\",\n \"packVersions\",\n \"policyBundles\",\n \"policyDecisionLogs\",\n \"policySimulations\",\n \"principals\",\n \"rateLimitWindows\",\n \"servicePrincipalKeys\",\n \"tenantDeploymentCredentials\",\n \"tenantMethodologyAssignments\",\n \"tenants\",\n \"toolCatalog\",\n \"toolRegistryEntries\",\n \"userSessions\",\n \"workspaces\"\n ],\n \"I\": [\n \"agents\",\n \"mcpWritePolicy\",\n \"modelCallLogs\",\n \"modelFunctionSlots\",\n \"modelRegistry\",\n \"modelSlotConfigs\",\n \"platformAudienceGrants\",\n \"platformAudiences\",\n \"platformPolicyDecisionLogs\",\n \"projectGrants\",\n \"reasoningPermissions\",\n \"tenantApiKeys\",\n \"tenantConfig\",\n \"tenantIntegrations\",\n \"tenantModelSlotBindings\",\n \"tenantPolicies\",\n \"tenantProviderSecrets\",\n \"tenantProxyGatewayUsage\",\n \"tenantProxyTokenMints\",\n \"tenantSandboxAuditEvents\",\n \"tenantSecrets\",\n \"toolAcls\",\n \"toolRegistry\",\n \"users\"\n ],\n \"K\": [\n \"agentMessages\",\n \"agentSessions\",\n \"autofixJobs\",\n \"backgroundJobRuns\",\n \"backgroundJobSettings\",\n \"beliefConfidence\",\n \"beliefEvidenceLinks\",\n \"beliefHistory\",\n \"beliefScenarios\",\n \"beliefVotes\",\n \"calibrationScores\",\n \"contractEvaluations\",\n \"contradictions\",\n \"crossProjectConnections\",\n \"decisionComputedSummaries\",\n \"decisionEvents\",\n \"decisionParticipants\",\n \"decisionRiskLedger\",\n \"decisionSnapshots\",\n \"deliberationContributions\",\n \"deliberationSessions\",\n \"epistemicAudit\",\n \"epistemicContracts\",\n \"epistemicEdges\",\n \"epistemicNodeEmbeddings\",\n \"epistemicNodes\",\n \"graphAnalysisCache\",\n \"graphAnalysisResults\",\n \"graphSuggestions\",\n \"harnessReplays\",\n \"harnessRuns\",\n \"idempotencyTokens\",\n \"lenses\",\n \"lensTopicBindings\",\n \"neo4jSyncQueue\",\n \"ontologyDefinitions\",\n \"ontologyVersions\",\n \"platformAgentRunPolicyDecisions\",\n \"platformAgentRunPromptResolutions\",\n \"platformAgentRuns\",\n \"platformAgentRunToolCalls\",\n \"platformHarnessShadowAudit\",\n \"publicationRules\",\n \"questionEvidenceLinks\",\n \"researchJobs\",\n \"schemaEnumConfig\",\n \"stakeholderGroups\",\n \"systemLogs\",\n \"tasks\",\n \"topics\",\n \"workflowDefinitions\",\n \"workflowPullRequests\",\n \"workflowStages\",\n \"worktreeBeliefCluster\",\n \"worktrees\"\n ],\n \"D\": [],\n \"A\": []\n} as const;\n\nexport const TABLE_OWNERSHIP = {\n \"agentMessages\": \"K\",\n \"agentRegistryEntries\": \"L\",\n \"agents\": \"I\",\n \"agentSessions\": \"K\",\n \"apiKeys\": \"L\",\n \"auditLog\": \"L\",\n \"autofixJobs\": \"K\",\n \"backgroundJobRuns\": \"K\",\n \"backgroundJobSettings\": \"K\",\n \"beliefConfidence\": \"K\",\n \"beliefEvidenceLinks\": \"K\",\n \"beliefHistory\": \"K\",\n \"beliefScenarios\": \"K\",\n \"beliefVotes\": \"K\",\n \"calibrationScores\": \"K\",\n \"compatibilityShims\": \"L\",\n \"contractEvaluations\": \"K\",\n \"contradictions\": \"K\",\n \"controlPlaneTenantModelSlotBindings\": \"L\",\n \"controlPlaneTenantProviderSecrets\": \"L\",\n \"controlPlaneTenantProxyGatewayUsage\": \"L\",\n \"controlPlaneToolAcls\": \"L\",\n \"crossProjectConnections\": \"K\",\n \"cutoverFlags\": \"L\",\n \"decisionComputedSummaries\": \"K\",\n \"decisionEvents\": \"K\",\n \"decisionParticipants\": \"K\",\n \"decisionRiskLedger\": \"K\",\n \"decisionSnapshots\": \"K\",\n \"deliberationContributions\": \"K\",\n \"deliberationSessions\": \"K\",\n \"epistemicAudit\": \"K\",\n \"epistemicContracts\": \"K\",\n \"epistemicEdges\": \"K\",\n \"epistemicNodeEmbeddings\": \"K\",\n \"epistemicNodes\": \"K\",\n \"graphAnalysisCache\": \"K\",\n \"graphAnalysisResults\": \"K\",\n \"graphSuggestions\": \"K\",\n \"groupMemberships\": \"L\",\n \"groups\": \"L\",\n \"harnessReplays\": \"K\",\n \"harnessRuns\": \"K\",\n \"idempotencyTokens\": \"K\",\n \"lenses\": \"K\",\n \"lensTopicBindings\": \"K\",\n \"mcpWritePolicy\": \"I\",\n \"memberships\": \"L\",\n \"methodologyPacks\": \"L\",\n \"modelCallLogs\": \"I\",\n \"modelFunctionSlots\": \"I\",\n \"modelRegistry\": \"I\",\n \"modelSlotConfigs\": \"I\",\n \"neo4jSyncQueue\": \"K\",\n \"oauthDeviceCodes\": \"L\",\n \"ontologyDefinitions\": \"K\",\n \"ontologyVersions\": \"K\",\n \"packAssignments\": \"L\",\n \"packDefinitions\": \"L\",\n \"packEntitlements\": \"L\",\n \"packGroupAssignments\": \"L\",\n \"packInstallations\": \"L\",\n \"packVersions\": \"L\",\n \"platformAgentRunPolicyDecisions\": \"K\",\n \"platformAgentRunPromptResolutions\": \"K\",\n \"platformAgentRuns\": \"K\",\n \"platformAgentRunToolCalls\": \"K\",\n \"platformAudienceGrants\": \"I\",\n \"platformAudiences\": \"I\",\n \"platformHarnessShadowAudit\": \"K\",\n \"platformPolicyDecisionLogs\": \"I\",\n \"policyBundles\": \"L\",\n \"policyDecisionLogs\": \"L\",\n \"policySimulations\": \"L\",\n \"principals\": \"L\",\n \"projectGrants\": \"I\",\n \"publicationRules\": \"K\",\n \"questionEvidenceLinks\": \"K\",\n \"rateLimitWindows\": \"L\",\n \"reasoningPermissions\": \"I\",\n \"researchJobs\": \"K\",\n \"schemaEnumConfig\": \"K\",\n \"servicePrincipalKeys\": \"L\",\n \"stakeholderGroups\": \"K\",\n \"systemLogs\": \"K\",\n \"tasks\": \"K\",\n \"tenantApiKeys\": \"I\",\n \"tenantConfig\": \"I\",\n \"tenantDeploymentCredentials\": \"L\",\n \"tenantIntegrations\": \"I\",\n \"tenantMethodologyAssignments\": \"L\",\n \"tenantModelSlotBindings\": \"I\",\n \"tenantPolicies\": \"I\",\n \"tenantProviderSecrets\": \"I\",\n \"tenantProxyGatewayUsage\": \"I\",\n \"tenantProxyTokenMints\": \"I\",\n \"tenants\": \"L\",\n \"tenantSandboxAuditEvents\": \"I\",\n \"tenantSecrets\": \"I\",\n \"toolAcls\": \"I\",\n \"toolCatalog\": \"L\",\n \"toolRegistry\": \"I\",\n \"toolRegistryEntries\": \"L\",\n \"topics\": \"K\",\n \"users\": \"I\",\n \"userSessions\": \"L\",\n \"workflowDefinitions\": \"K\",\n \"workflowPullRequests\": \"K\",\n \"workflowStages\": \"K\",\n \"workspaces\": \"L\",\n \"worktreeBeliefCluster\": \"K\",\n \"worktrees\": \"K\",\n} as const satisfies Readonly<Record<string, TableOwnershipLayer>>;\n\nexport type GeneratedTableName = keyof typeof TABLE_OWNERSHIP;\n\nexport function classifyTableOwnership(\n tableName: string\n): TableOwnershipLayer | null {\n return TABLE_OWNERSHIP[tableName as GeneratedTableName] ?? null;\n}\n\nexport function listTablesByOwnership(\n layer: TableOwnershipLayer\n): readonly string[] {\n return TABLES_BY_LAYER[layer];\n}\n\nexport function summarizeTableOwnership(\n tableNames: readonly string[]\n): Record<TableOwnershipLayer, number> {\n const summary: Record<TableOwnershipLayer, number> = {\n L: 0,\n I: 0,\n K: 0,\n D: 0,\n A: 0,\n };\n for (const name of tableNames) {\n const layer = classifyTableOwnership(name);\n if (layer) {\n summary[layer] += 1;\n }\n }\n return summary;\n}\n\nexport function assertTableOwnershipCoverage(tableNames: readonly string[]): void {\n const missing = tableNames.filter((name) => !classifyTableOwnership(name));\n const tableNameSet = new Set(tableNames);\n const extras = Object.keys(TABLE_OWNERSHIP).filter(\n (name) => !tableNameSet.has(name)\n );\n if (missing.length > 0 || extras.length > 0) {\n const lines: string[] = [];\n if (missing.length > 0) {\n lines.push(`Missing ownership classification: ${missing.join(\", \")}`);\n }\n if (extras.length > 0) {\n lines.push(`Ownership map contains unknown tables: ${extras.join(\", \")}`);\n }\n throw new Error(lines.join(\"\\n\"));\n }\n}\n","import {\n TABLE_OWNERSHIP,\n type TableOwnershipLayer,\n} from \"./generated/tableOwnership.js\";\n\nexport const COMPONENT_BOUNDARY_CONTRACT_VERSION = \"2026-04-27\" as const;\n\nexport const COMPONENT_BOUNDARY_COMPONENT_LAYERS = [\n \"I\",\n \"K\",\n] as const satisfies readonly TableOwnershipLayer[];\nexport type ComponentBoundaryComponentLayer =\n (typeof COMPONENT_BOUNDARY_COMPONENT_LAYERS)[number];\n\nexport const COMPONENT_BOUNDARY_DIRECT_DB_METHODS = [\n \"insert\",\n \"patch\",\n \"replace\",\n \"delete\",\n \"query\",\n] as const;\nexport type ComponentBoundaryDirectDbMethod =\n (typeof COMPONENT_BOUNDARY_DIRECT_DB_METHODS)[number];\n\nexport const COMPONENT_BOUNDARY_HOST_SOURCE_ROOTS = [\n \"services\",\n \"apps\",\n \"convex\",\n] as const;\n\nexport const COMPONENT_BOUNDARY_HIGH_RISK_TABLES = [\n \"backgroundJobRuns\",\n \"backgroundJobSettings\",\n \"systemLogs\",\n \"epistemicAudit\",\n \"platformPolicyDecisionLogs\",\n \"tenantApiKeys\",\n \"projectGrants\",\n \"userSessions\",\n] as const;\nexport type ComponentBoundaryHighRiskTable =\n (typeof COMPONENT_BOUNDARY_HIGH_RISK_TABLES)[number];\n\nexport function getComponentBoundaryTableLayer(\n tableName: string\n): TableOwnershipLayer | undefined {\n return TABLE_OWNERSHIP[tableName as keyof typeof TABLE_OWNERSHIP];\n}\n\nexport function isComponentBoundaryComponentOwnedTable(\n tableName: string\n): tableName is keyof typeof TABLE_OWNERSHIP {\n const layer = getComponentBoundaryTableLayer(tableName);\n return (\n layer === \"I\" ||\n layer === \"K\"\n );\n}\n\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component host persistence boundary
|
|
3
|
+
*
|
|
4
|
+
* Host deployments may call component APIs, but they must not create or mutate
|
|
5
|
+
* component-owned tables directly through top-level ctx.db. This contract keeps
|
|
6
|
+
* tenant SDK clients from accidentally recreating Lucern kernel/identity tables
|
|
7
|
+
* as host "ghost tables".
|
|
8
|
+
*/
|
|
9
|
+
declare const COMPONENT_HOST_BOUNDARY_CONTRACT_VERSION: "2026-04-28";
|
|
10
|
+
declare const COMPONENT_HOST_PROTECTED_TABLES: readonly ["backgroundJobRuns", "backgroundJobSettings", "systemLogs", "epistemicAudit", "platformPolicyDecisionLogs", "tenantApiKeys", "projectGrants", "userSessions"];
|
|
11
|
+
type ComponentHostProtectedTable = (typeof COMPONENT_HOST_PROTECTED_TABLES)[number];
|
|
12
|
+
declare const COMPONENT_HOST_PROTECTED_TABLE_OWNERS: {
|
|
13
|
+
readonly backgroundJobRuns: "kernel_component";
|
|
14
|
+
readonly backgroundJobSettings: "kernel_component";
|
|
15
|
+
readonly systemLogs: "kernel_component";
|
|
16
|
+
readonly epistemicAudit: "reasoning_kernel_component";
|
|
17
|
+
readonly platformPolicyDecisionLogs: "identity_component";
|
|
18
|
+
readonly tenantApiKeys: "identity_component";
|
|
19
|
+
readonly projectGrants: "identity_component";
|
|
20
|
+
readonly userSessions: "tenant_or_control_plane_schema";
|
|
21
|
+
};
|
|
22
|
+
declare const COMPONENT_HOST_DB_WRITE_OPERATIONS: readonly ["insert", "patch", "replace", "delete"];
|
|
23
|
+
type ComponentHostDbWriteOperation = (typeof COMPONENT_HOST_DB_WRITE_OPERATIONS)[number];
|
|
24
|
+
declare const COMPONENT_HOST_DB_READ_OPERATIONS: readonly ["query"];
|
|
25
|
+
type ComponentHostDbReadOperation = (typeof COMPONENT_HOST_DB_READ_OPERATIONS)[number];
|
|
26
|
+
type ComponentHostDbOperation = ComponentHostDbWriteOperation | ComponentHostDbReadOperation;
|
|
27
|
+
declare const COMPONENT_HOST_WRITE_AUDIT_ROOTS: readonly ["apps/web/convex", "packages/server-core/src", "services/kernel-template/convex", "services/identity-template/convex", "services/master-control/convex"];
|
|
28
|
+
type ComponentHostWriteAuditRoot = (typeof COMPONENT_HOST_WRITE_AUDIT_ROOTS)[number];
|
|
29
|
+
declare const COMPONENT_HOST_WRITE_ALLOWED_EXCEPTIONS: readonly [{
|
|
30
|
+
readonly file: "services/master-control/convex/userSessions.ts";
|
|
31
|
+
readonly table: "userSessions";
|
|
32
|
+
readonly operation: "insert";
|
|
33
|
+
readonly reason: "Master Control declares and owns its own userSessions table for gateway session validation.";
|
|
34
|
+
}, {
|
|
35
|
+
readonly file: "services/master-control/convex/userSessions.ts";
|
|
36
|
+
readonly table: "userSessions";
|
|
37
|
+
readonly operation: "query";
|
|
38
|
+
readonly reason: "Master Control declares and owns its own userSessions table for gateway session validation.";
|
|
39
|
+
}];
|
|
40
|
+
|
|
41
|
+
export { COMPONENT_HOST_BOUNDARY_CONTRACT_VERSION, COMPONENT_HOST_DB_READ_OPERATIONS, COMPONENT_HOST_DB_WRITE_OPERATIONS, COMPONENT_HOST_PROTECTED_TABLES, COMPONENT_HOST_PROTECTED_TABLE_OWNERS, COMPONENT_HOST_WRITE_ALLOWED_EXCEPTIONS, COMPONENT_HOST_WRITE_AUDIT_ROOTS, type ComponentHostDbOperation, type ComponentHostDbReadOperation, type ComponentHostDbWriteOperation, type ComponentHostProtectedTable, type ComponentHostWriteAuditRoot };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/component-host-boundary.contract.ts
|
|
2
|
+
var COMPONENT_HOST_BOUNDARY_CONTRACT_VERSION = "2026-04-28";
|
|
3
|
+
var COMPONENT_HOST_PROTECTED_TABLES = [
|
|
4
|
+
"backgroundJobRuns",
|
|
5
|
+
"backgroundJobSettings",
|
|
6
|
+
"systemLogs",
|
|
7
|
+
"epistemicAudit",
|
|
8
|
+
"platformPolicyDecisionLogs",
|
|
9
|
+
"tenantApiKeys",
|
|
10
|
+
"projectGrants",
|
|
11
|
+
"userSessions"
|
|
12
|
+
];
|
|
13
|
+
var COMPONENT_HOST_PROTECTED_TABLE_OWNERS = {
|
|
14
|
+
backgroundJobRuns: "kernel_component",
|
|
15
|
+
backgroundJobSettings: "kernel_component",
|
|
16
|
+
systemLogs: "kernel_component",
|
|
17
|
+
epistemicAudit: "reasoning_kernel_component",
|
|
18
|
+
platformPolicyDecisionLogs: "identity_component",
|
|
19
|
+
tenantApiKeys: "identity_component",
|
|
20
|
+
projectGrants: "identity_component",
|
|
21
|
+
userSessions: "tenant_or_control_plane_schema"
|
|
22
|
+
};
|
|
23
|
+
var COMPONENT_HOST_DB_WRITE_OPERATIONS = [
|
|
24
|
+
"insert",
|
|
25
|
+
"patch",
|
|
26
|
+
"replace",
|
|
27
|
+
"delete"
|
|
28
|
+
];
|
|
29
|
+
var COMPONENT_HOST_DB_READ_OPERATIONS = ["query"];
|
|
30
|
+
var COMPONENT_HOST_WRITE_AUDIT_ROOTS = [
|
|
31
|
+
"apps/web/convex",
|
|
32
|
+
"packages/server-core/src",
|
|
33
|
+
"services/kernel-template/convex",
|
|
34
|
+
"services/identity-template/convex",
|
|
35
|
+
"services/master-control/convex"
|
|
36
|
+
];
|
|
37
|
+
var COMPONENT_HOST_WRITE_ALLOWED_EXCEPTIONS = [
|
|
38
|
+
{
|
|
39
|
+
file: "services/master-control/convex/userSessions.ts",
|
|
40
|
+
table: "userSessions",
|
|
41
|
+
operation: "insert",
|
|
42
|
+
reason: "Master Control declares and owns its own userSessions table for gateway session validation."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
file: "services/master-control/convex/userSessions.ts",
|
|
46
|
+
table: "userSessions",
|
|
47
|
+
operation: "query",
|
|
48
|
+
reason: "Master Control declares and owns its own userSessions table for gateway session validation."
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
export { COMPONENT_HOST_BOUNDARY_CONTRACT_VERSION, COMPONENT_HOST_DB_READ_OPERATIONS, COMPONENT_HOST_DB_WRITE_OPERATIONS, COMPONENT_HOST_PROTECTED_TABLES, COMPONENT_HOST_PROTECTED_TABLE_OWNERS, COMPONENT_HOST_WRITE_ALLOWED_EXCEPTIONS, COMPONENT_HOST_WRITE_AUDIT_ROOTS };
|
|
53
|
+
//# sourceMappingURL=component-host-boundary.contract.js.map
|
|
54
|
+
//# sourceMappingURL=component-host-boundary.contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/component-host-boundary.contract.ts"],"names":[],"mappings":";AASO,IAAM,wCAAA,GAA2C;AAEjD,IAAM,+BAAA,GAAkC;AAAA,EAC7C,mBAAA;AAAA,EACA,uBAAA;AAAA,EACA,YAAA;AAAA,EACA,gBAAA;AAAA,EACA,4BAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF;AAIO,IAAM,qCAAA,GAAwC;AAAA,EACnD,iBAAA,EAAmB,kBAAA;AAAA,EACnB,qBAAA,EAAuB,kBAAA;AAAA,EACvB,UAAA,EAAY,kBAAA;AAAA,EACZ,cAAA,EAAgB,4BAAA;AAAA,EAChB,0BAAA,EAA4B,oBAAA;AAAA,EAC5B,aAAA,EAAe,oBAAA;AAAA,EACf,aAAA,EAAe,oBAAA;AAAA,EACf,YAAA,EAAc;AAChB;AAEO,IAAM,kCAAA,GAAqC;AAAA,EAChD,QAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF;AAIO,IAAM,iCAAA,GAAoC,CAAC,OAAO;AAQlD,IAAM,gCAAA,GAAmC;AAAA,EAC9C,iBAAA;AAAA,EACA,0BAAA;AAAA,EACA,iCAAA;AAAA,EACA,mCAAA;AAAA,EACA;AACF;AAIO,IAAM,uCAAA,GAA0C;AAAA,EACrD;AAAA,IACE,IAAA,EAAM,gDAAA;AAAA,IACN,KAAA,EAAO,cAAA;AAAA,IACP,SAAA,EAAW,QAAA;AAAA,IACX,MAAA,EACE;AAAA,GACJ;AAAA,EACA;AAAA,IACE,IAAA,EAAM,gDAAA;AAAA,IACN,KAAA,EAAO,cAAA;AAAA,IACP,SAAA,EAAW,OAAA;AAAA,IACX,MAAA,EACE;AAAA;AAEN","file":"component-host-boundary.contract.js","sourcesContent":["/**\n * Component host persistence boundary\n *\n * Host deployments may call component APIs, but they must not create or mutate\n * component-owned tables directly through top-level ctx.db. This contract keeps\n * tenant SDK clients from accidentally recreating Lucern kernel/identity tables\n * as host \"ghost tables\".\n */\n\nexport const COMPONENT_HOST_BOUNDARY_CONTRACT_VERSION = \"2026-04-28\" as const;\n\nexport const COMPONENT_HOST_PROTECTED_TABLES = [\n \"backgroundJobRuns\",\n \"backgroundJobSettings\",\n \"systemLogs\",\n \"epistemicAudit\",\n \"platformPolicyDecisionLogs\",\n \"tenantApiKeys\",\n \"projectGrants\",\n \"userSessions\",\n] as const;\nexport type ComponentHostProtectedTable =\n (typeof COMPONENT_HOST_PROTECTED_TABLES)[number];\n\nexport const COMPONENT_HOST_PROTECTED_TABLE_OWNERS = {\n backgroundJobRuns: \"kernel_component\",\n backgroundJobSettings: \"kernel_component\",\n systemLogs: \"kernel_component\",\n epistemicAudit: \"reasoning_kernel_component\",\n platformPolicyDecisionLogs: \"identity_component\",\n tenantApiKeys: \"identity_component\",\n projectGrants: \"identity_component\",\n userSessions: \"tenant_or_control_plane_schema\",\n} as const satisfies Record<ComponentHostProtectedTable, string>;\n\nexport const COMPONENT_HOST_DB_WRITE_OPERATIONS = [\n \"insert\",\n \"patch\",\n \"replace\",\n \"delete\",\n] as const;\nexport type ComponentHostDbWriteOperation =\n (typeof COMPONENT_HOST_DB_WRITE_OPERATIONS)[number];\n\nexport const COMPONENT_HOST_DB_READ_OPERATIONS = [\"query\"] as const;\nexport type ComponentHostDbReadOperation =\n (typeof COMPONENT_HOST_DB_READ_OPERATIONS)[number];\n\nexport type ComponentHostDbOperation =\n | ComponentHostDbWriteOperation\n | ComponentHostDbReadOperation;\n\nexport const COMPONENT_HOST_WRITE_AUDIT_ROOTS = [\n \"apps/web/convex\",\n \"packages/server-core/src\",\n \"services/kernel-template/convex\",\n \"services/identity-template/convex\",\n \"services/master-control/convex\",\n] as const;\nexport type ComponentHostWriteAuditRoot =\n (typeof COMPONENT_HOST_WRITE_AUDIT_ROOTS)[number];\n\nexport const COMPONENT_HOST_WRITE_ALLOWED_EXCEPTIONS = [\n {\n file: \"services/master-control/convex/userSessions.ts\",\n table: \"userSessions\",\n operation: \"insert\",\n reason:\n \"Master Control declares and owns its own userSessions table for gateway session validation.\",\n },\n {\n file: \"services/master-control/convex/userSessions.ts\",\n table: \"userSessions\",\n operation: \"query\",\n reason:\n \"Master Control declares and owns its own userSessions table for gateway session validation.\",\n },\n] as const satisfies ReadonlyArray<{\n file: string;\n table: ComponentHostProtectedTable;\n operation: ComponentHostDbOperation;\n reason: string;\n}>;\n"]}
|
|
@@ -450,11 +450,13 @@ type ContextPackV1 = {
|
|
|
450
450
|
};
|
|
451
451
|
/**
|
|
452
452
|
* The canonical input schema for `compile_context`.
|
|
453
|
-
* `topicId` is
|
|
453
|
+
* `topicId` is optional for query-first callers. When omitted, the platform
|
|
454
|
+
* resolves the best topic from the query and other available signals.
|
|
455
|
+
* `projectId` remains an optional compatibility alias.
|
|
454
456
|
*/
|
|
455
457
|
type ContextPackRequestV1 = {
|
|
456
|
-
/** Topic scope ID
|
|
457
|
-
topicId
|
|
458
|
+
/** Topic scope ID. Omit to resolve by query. */
|
|
459
|
+
topicId?: string;
|
|
458
460
|
/** Deprecated compatibility alias for older callers. */
|
|
459
461
|
projectId?: string;
|
|
460
462
|
/** Focus query for relevance ranking. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context-pack.contract.ts"],"names":[],"mappings":";AAqBO,IAAM,2BAAA,GAA8B;AAepC,IAAM,wBAAA,GAA6D;AAAA,EACxE,aAAA;AAAA,EACA;AACF;AAEO,IAAM,uBAAA,GAAiD;AAevD,IAAM,wBAAA,GAAmD;AAiBzD,IAAM,yBAAA,GAA8D;AAAA,EACzE,YAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF;AAiBO,IAAM,qBAAA,GAET;AAAA,EACF,UAAA,EAAY,IAAA;AAAA,EACZ,aAAA,EAAe,GAAA;AAAA,EACf,aAAA,EAAe,IAAA;AAAA,EACf,cAAA,EAAgB,IAAA;AAAA,EAChB,cAAA,EAAgB;AAClB;AAOO,IAAM,gBAAA,GAAmB;AAGzB,IAAM,gBAAA,GAAmB;AAGzB,IAAM,oBAAA,GAAuB;AAG7B,IAAM,qBAAA,GAAwB;AAG9B,IAAM,iBAAA,GA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AAAA,EACN,MAAA,EAAQ,GAAA;AAAA,EACR,GAAA,EAAK;AACP;AAEO,IAAM,sBAAA,GAAyB;AA2b/B,IAAM,0BAAA,GAAgD;AAAA,EAC3D,UAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF;AAUO,IAAM,eAAA,GAAkB;AAGxB,IAAM,kBAAA,GAAqB","file":"context-pack.contract.js","sourcesContent":["/**\n * Context-Pack Contract v1\n *\n * Canonical TypeScript types and constants for the context-pack output schema.\n * This is the external contract consumed by:\n * - MCP tool `compile_context` (canonical compiler read)\n * - SDK/HTTP consumers that read compiled context packs programmatically\n * - Benchmark harnesses (context-pack-ab)\n *\n * BREAKING CHANGE RULES:\n * - Adding optional fields to ContextPackV1 is NON-breaking\n * - Removing fields or changing types is BREAKING (bump CONTEXT_PACK_SCHEMA_VERSION)\n * - Changing section budget ratios or ranking weights is NON-breaking (tuning)\n * - Changing the version string is BREAKING (consumers check it)\n */\n\n// =============================================================================\n// SCHEMA VERSION\n// =============================================================================\n\n/** Canonical version string. Consumers MUST check this field for compatibility. */\nexport const CONTEXT_PACK_SCHEMA_VERSION = \"1.0.0\" as const;\n\n// =============================================================================\n// RANKING PROFILES\n// =============================================================================\n\n/**\n * Available ranking profiles for context-pack assembly.\n *\n * - `baseline_v1`: Simple token-hit counting. Items with zero query hits are excluded.\n * - `weighted_v1`: Multi-signal scoring combining query relevance, recency, confidence,\n * belief type, priority, and severity with section-specific weight vectors.\n */\nexport type ContextRankingProfile = \"baseline_v1\" | \"weighted_v1\";\n\nexport const CONTEXT_RANKING_PROFILES: readonly ContextRankingProfile[] = [\n \"baseline_v1\",\n \"weighted_v1\",\n] as const;\n\nexport const DEFAULT_RANKING_PROFILE: ContextRankingProfile = \"weighted_v1\";\n\n// =============================================================================\n// COMPILATION MODE (RS-2)\n// =============================================================================\n\n/**\n * Context compilation mode.\n *\n * - `standard`: Default — ranked beliefs, questions, evidence, contradictions.\n * - `delta`: Diff-aware — adds failure context, verification obligations,\n * and worktree ledger analysis to the standard context pack.\n */\nexport type ContextCompilationMode = \"standard\" | \"delta\";\n\nexport const DEFAULT_COMPILATION_MODE: ContextCompilationMode = \"standard\";\n\n// =============================================================================\n// SECTION KEYS\n// =============================================================================\n\n/**\n * The five canonical sections of a context pack.\n * Order matters: invariants are injected first, contradictions last.\n */\nexport type ContextPackSectionKey =\n | \"invariants\"\n | \"activeBeliefs\"\n | \"openQuestions\"\n | \"recentEvidence\"\n | \"contradictions\";\n\nexport const CONTEXT_PACK_SECTION_KEYS: readonly ContextPackSectionKey[] = [\n \"invariants\",\n \"activeBeliefs\",\n \"openQuestions\",\n \"recentEvidence\",\n \"contradictions\",\n] as const;\n\n// =============================================================================\n// SECTION BUDGET RATIOS\n// =============================================================================\n\n/**\n * Token budget allocation ratios per section.\n * These sum to 1.0 and determine how the total tokenBudget is divided.\n *\n * Rationale:\n * - invariants (0.28): Highest-priority constraints, injected first\n * - activeBeliefs (0.30): Largest section, carries domain knowledge\n * - openQuestions (0.17): Unresolved work items guide agent behavior\n * - recentEvidence (0.17): Implementation context for grounding\n * - contradictions (0.08): Tension signals, smallest section\n */\nexport const SECTION_BUDGET_RATIOS: Readonly<\n Record<ContextPackSectionKey, number>\n> = {\n invariants: 0.28,\n activeBeliefs: 0.3,\n openQuestions: 0.17,\n recentEvidence: 0.17,\n contradictions: 0.08,\n} as const;\n\n// =============================================================================\n// TOKEN BUDGET CONSTRAINTS\n// =============================================================================\n\n/** Minimum allowed token budget. Below this, context packs lose utility. */\nexport const MIN_TOKEN_BUDGET = 400;\n\n/** Maximum allowed token budget. Above this, context packs bloat prompts. */\nexport const MAX_TOKEN_BUDGET = 8000;\n\n/** Default token budget when caller does not specify. */\nexport const DEFAULT_TOKEN_BUDGET = 1800;\n\n/** Default max items per section. */\nexport const DEFAULT_SECTION_LIMIT = 8;\n\n/** Hard ceiling on items per section. */\nexport const MAX_SECTION_LIMIT = 25;\n\n/** Minimum contradiction section budget floor (tokens). */\nexport const MIN_CONTRADICTION_BUDGET = 40;\n\n// =============================================================================\n// RANKING WEIGHT VECTORS\n// =============================================================================\n\n/**\n * Weight vectors for the weighted_v1 ranking profile.\n * Each section has a different signal mix:\n *\n * - query: How many query tokens appear in the candidate text\n * - recency: Exponential decay from updatedAt (half-life = 30 days)\n * - confidence: Belief confidence score [0,1]\n * - beliefType: Bonus for invariant > tenet > principle > other\n * - priority: Question priority (critical > high > medium > low)\n * - severity: Contradiction severity (critical > high > medium > low)\n */\nexport type RankingWeightVector = {\n query: number;\n recency: number;\n confidence?: number;\n beliefType?: number;\n priority?: number;\n severity?: number;\n};\n\nexport const RANKING_WEIGHTS: Readonly<\n Record<ContextPackSectionKey, RankingWeightVector>\n> = {\n invariants: {\n query: 0.35,\n recency: 0.1,\n confidence: 0.4,\n beliefType: 0.15,\n },\n activeBeliefs: {\n query: 0.5,\n recency: 0.2,\n confidence: 0.2,\n beliefType: 0.1,\n },\n openQuestions: {\n query: 0.55,\n recency: 0.2,\n priority: 0.25,\n },\n recentEvidence: {\n query: 0.6,\n recency: 0.4,\n },\n contradictions: {\n query: 0.4,\n recency: 0.2,\n severity: 0.4,\n },\n} as const;\n\n/** Recency decay half-life in days. After 30 days, recency score = 0.5. */\nexport const RECENCY_HALF_LIFE_DAYS = 30;\n\n/**\n * Ranking weight vector for the relatedEntities section.\n * Entities are ranked by query relevance and connectivity (bridge edge count).\n * Separate from RANKING_WEIGHTS because entities are not part of the\n * token-budgeted injection plan.\n */\nexport const ENTITY_RANKING_WEIGHTS = {\n query: 0.4,\n connectivity: 0.6,\n} as const;\n\n/** Default max entities to include in the context pack. */\nexport const DEFAULT_ENTITY_LIMIT = 10;\n\n/** Hard ceiling on entities per context pack. */\nexport const MAX_ENTITY_LIMIT = 50;\n\n// =============================================================================\n// BELIEF TYPE BONUS MAP\n// =============================================================================\n\n/**\n * Bonus multiplier for belief types in ranking.\n * Invariants get 1.0, unknown types get 0.4.\n */\nexport const BELIEF_TYPE_BONUS: Readonly<Record<string, number>> = {\n invariant: 1.0,\n tenet: 0.8,\n principle: 0.6,\n} as const;\n\nexport const DEFAULT_BELIEF_TYPE_BONUS = 0.4;\n\n// =============================================================================\n// PRIORITY / SEVERITY SCORE MAPS\n// =============================================================================\n\nexport const PRIORITY_SCORES: Readonly<Record<string, number>> = {\n critical: 1.0,\n high: 0.85,\n medium: 0.55,\n low: 0.35,\n} as const;\n\nexport const DEFAULT_PRIORITY_SCORE = 0.5;\n\nexport const SEVERITY_SCORES: Readonly<Record<string, number>> = {\n critical: 1.0,\n high: 0.85,\n medium: 0.6,\n low: 0.35,\n} as const;\n\nexport const DEFAULT_SEVERITY_SCORE = 0.5;\n\n// =============================================================================\n// SECTION ITEM TYPES\n// =============================================================================\n\n/** A ranked belief in the invariants or activeBeliefs section. */\nexport type ContextPackBelief = {\n nodeId: string;\n canonicalText: string;\n confidence: number | null;\n beliefType: string | null;\n score: number;\n /** Present in activeBeliefs, absent in invariants */\n status?: string;\n updatedAt?: number | null;\n /** Human-readable explanation of why this item was ranked here (RS-2). */\n justification?: string;\n};\n\n/** A ranked question in the openQuestions section. */\nexport type ContextPackQuestion = {\n questionId: string;\n text: string;\n status: string;\n priority: string;\n updatedAt?: number | null;\n score: number;\n /** Human-readable explanation of why this item was ranked here (RS-2). */\n justification?: string;\n};\n\n/** A ranked evidence item in the recentEvidence section. */\nexport type ContextPackEvidence = {\n nodeId: string;\n canonicalText: string;\n sourceUrl: string | null;\n kind: string;\n createdAt: number | null;\n score: number;\n /** Human-readable explanation of why this item was ranked here (RS-2). */\n justification?: string;\n};\n\n/** A ranked contradiction in the contradictions section. */\nexport type ContextPackContradiction = {\n contradictionId: string;\n severity: string;\n status: string;\n description: string;\n score: number;\n /** Human-readable explanation of why this item was ranked here (RS-2). */\n justification?: string;\n};\n\n/**\n * An entity from the ontological layer surfaced in the context pack.\n * Entities are domain objects (companies, people, functions, etc.) connected\n * to beliefs via bridge edges. They provide the \"reality anchor\" that makes\n * the reasoning graph domain-aware.\n */\nexport type ContextPackEntity = {\n /** Convex document ID of the entity node. */\n nodeId: string;\n /** Entity type (e.g., \"company\", \"person\", \"function\"). */\n entityType: string;\n /** Human-readable title/name of the entity. */\n title: string;\n /** Number of beliefs connected to this entity via bridge edges. */\n connectedBeliefCount: number;\n /** Number of evidence items referencing this entity. */\n connectedEvidenceCount: number;\n /** Relevance score from ranking algorithm. */\n score: number;\n /** Entity metadata (structured per ontology schema). */\n metadata?: Record<string, unknown>;\n};\n\n/**\n * A lattice seed entry representing a belief that was auto-generated\n * to cover an ontology entity type within a topic scope.\n */\nexport type BeliefLatticeSeed = {\n /** The belief node ID that was created or already existed. */\n beliefNodeId: string;\n /** The entity type this seed belief covers. */\n entityType: string;\n /** Whether this seed was newly created or already existed. */\n created: boolean;\n /** The canonical text of the seed belief. */\n canonicalText: string;\n};\n\n// =============================================================================\n// SUMMARY\n// =============================================================================\n\n/** Counts and scoped health signals for the context pack. */\nexport type ContextPackSummary = {\n totalBeliefs: number;\n invariants: number;\n openQuestions: number;\n evidenceItems: number;\n contradictions: number;\n /** Number of ontological entities in scope (optional, present when entity graph is active). */\n relatedEntities?: number;\n scopedTopics: number;\n descendantDepth: number;\n query: string | null;\n};\n\n// =============================================================================\n// FAILURE CONTEXT (RS-2)\n// =============================================================================\n\n/** A failed approach surfaced from the failure log for anti-repetition. */\nexport type ContextPackFailure = {\n /** Lucern attempt/evidence node ID. */\n attemptId: string;\n /** What was tried. */\n approach: string;\n /** Why it failed. */\n outcome: string;\n /** When the attempt was recorded (ms since epoch). */\n recordedAt: number;\n /** Relevance score from ranking algorithm. */\n score: number;\n};\n\n/** Failure context section appended to context packs in delta mode. */\nexport type ContextPackFailureContext = {\n /** Ranked failed approaches relevant to the current query. */\n failures: ContextPackFailure[];\n /** IDs of items suppressed from other sections due to anti-repetition. */\n suppressedIds: string[];\n};\n\n// =============================================================================\n// DELTA REPORT (RS-2)\n// =============================================================================\n\n/** A verification obligation surfaced by delta compilation. */\nexport type VerificationObligation = {\n /** What must be verified. */\n description: string;\n /** Source of the obligation (e.g., \"belief:xyz confidence drop\"). */\n source: string;\n /** Severity: how important it is to verify. */\n severity: \"critical\" | \"high\" | \"medium\" | \"low\";\n};\n\n/** Delta report appended to context packs when mode = \"delta\". */\nexport type ContextPackDeltaReport = {\n /** Items that changed since the reference point (new, updated, removed). */\n changedItems: Array<{\n id: string;\n section: ContextPackSectionKey;\n changeType: \"added\" | \"updated\" | \"removed\" | \"confidence_changed\";\n summary: string;\n }>;\n /** Obligations the consuming session must verify. */\n verificationObligations: VerificationObligation[];\n /** Reference point for the delta (worktree ID, timestamp, or commit SHA). */\n referencePoint: string;\n};\n\n// =============================================================================\n// PACK WEIGHT OVERRIDES (RS-2)\n// =============================================================================\n\n/**\n * Per-section weight overrides that domain packs can apply.\n * Overrides merge with RANKING_WEIGHTS — only specified fields replace defaults.\n */\nexport type PackWeightOverride = {\n /** Which section to override weights for. */\n section: ContextPackSectionKey;\n /** Partial weight vector — only specified fields replace defaults. */\n weights: Partial<RankingWeightVector>;\n};\n\n// =============================================================================\n// INJECTION POLICY\n// =============================================================================\n\n/** Token-budgeted section selections for prompt injection. */\nexport type ContextPackInjectionPolicy = {\n /** Total token budget for the entire context pack. */\n tokenBudget: number;\n /** Estimated tokens consumed across all sections. */\n estimatedTokens: number;\n /** Per-section token budgets derived from SECTION_BUDGET_RATIOS. */\n sectionBudgets: Record<ContextPackSectionKey, number>;\n /** Actual token usage per section after greedy fill. */\n sectionUsage: Record<ContextPackSectionKey, number>;\n /** Node/question IDs selected for injection, per section. */\n selected: Record<ContextPackSectionKey, string[]>;\n /** Items that were scored but excluded from injection, with reason (RS-2). */\n excludedItems?: Array<{\n id: string;\n section: ContextPackSectionKey;\n reason: \"budget_exceeded\" | \"anti_repetition\" | \"below_threshold\";\n score: number;\n }>;\n};\n\n// =============================================================================\n// DIAGNOSTICS\n// =============================================================================\n\n/** Telemetry for context pack assembly. */\nexport type ContextPackDiagnostics = {\n /** Total candidates scored across all sections. */\n itemsScored: number;\n /** Ratio of estimatedTokens / tokenBudget. Range [0, 1+]. */\n tokenBudgetUtilization: number;\n};\n\n// =============================================================================\n// PUBLIC COMPILED CONTEXT TYPES\n// =============================================================================\n\n/**\n * Public context surface returned by the SDK-facing context client.\n *\n * This preserves the existing external shape while the canonical compiler\n * contract evolves in parallel as ContextPackV1.\n */\nexport type PublicContextBelief = {\n beliefId: string;\n text: string;\n confidence: number | null;\n beliefType?: string | null;\n status?: string;\n updatedAt?: number | null;\n score: number;\n justification?: string;\n};\n\nexport type PublicContextQuestion = {\n questionId: string;\n text: string;\n status: string;\n priority: string;\n updatedAt?: number | null;\n score: number;\n justification?: string;\n};\n\nexport type PublicContextEvidence = {\n evidenceId: string;\n text: string;\n sourceUrl?: string | null;\n kind: string;\n createdAt?: number | null;\n score: number;\n justification?: string;\n};\n\nexport type PublicContextContradiction = {\n contradictionId: string;\n severity: string;\n status: string;\n description: string;\n score: number;\n justification?: string;\n};\n\nexport type PublicContextEntity = {\n entityId: string;\n entityType: string;\n title: string;\n text?: string;\n connectedBeliefCount: number;\n connectedEvidenceCount: number;\n score: number;\n metadata?: Record<string, unknown>;\n};\n\nexport type PublicContextInjectionPolicy = {\n tokenBudget: number;\n estimatedTokens: number;\n sectionBudgets: Record<string, number>;\n sectionUsage: Record<string, number>;\n selected: Record<string, string[]>;\n excludedItems?: Array<{\n id: string;\n section: string;\n reason: \"budget_exceeded\" | \"anti_repetition\" | \"below_threshold\";\n score: number;\n }>;\n};\n\nexport type PublicCompiledContext = {\n schemaVersion: string;\n topicId: string;\n topicName: string;\n scopedTopicIds: string[];\n generatedAt: number;\n ranking: ContextRankingProfile;\n summary: Record<string, unknown>;\n invariants: PublicContextBelief[];\n activeBeliefs: PublicContextBelief[];\n openQuestions: PublicContextQuestion[];\n recentEvidence: PublicContextEvidence[];\n contradictions: PublicContextContradiction[];\n relatedEntities?: PublicContextEntity[];\n contextNarrative: string[];\n injectionPolicy: PublicContextInjectionPolicy;\n diagnostics: Record<string, unknown>;\n compilationMode?: string;\n failureContext?: {\n failures: Array<{\n attemptId: string;\n approach: string;\n outcome: string;\n recordedAt: number;\n score: number;\n }>;\n suppressedIds: string[];\n };\n deltaReport?: {\n changedItems: Array<{\n id: string;\n section: string;\n changeType: string;\n summary: string;\n }>;\n verificationObligations: Array<{\n description: string;\n source: string;\n severity: \"critical\" | \"high\" | \"medium\" | \"low\";\n }>;\n referencePoint: string;\n };\n appliedWeightOverrides?: unknown[];\n};\n\n// =============================================================================\n// CONTEXT PACK V1 (TOP-LEVEL OUTPUT)\n// =============================================================================\n\n/**\n * The canonical output schema for context compilation responses.\n *\n * This is the contract that consumers depend on. All fields are required\n * in the output. Adding optional fields is non-breaking; removing or\n * changing types is breaking (requires version bump).\n */\nexport type ContextPackV1 = {\n /** Schema version for compatibility checking. */\n schemaVersion: typeof CONTEXT_PACK_SCHEMA_VERSION;\n /** Deprecated compatibility alias for the requested scope ID. */\n projectId?: string;\n /** Resolved topic ID after scope resolution. */\n topicId: string;\n /** Human-readable topic name. */\n topicName: string;\n /** All topic IDs included in the neighborhood expansion. */\n scopedTopicIds: string[];\n /** Deterministic freshness watermark for this pack (ms since epoch). */\n generatedAt: number;\n /** Which ranking profile was used. */\n rankingProfile: ContextRankingProfile;\n /** Aggregate counts and health signals. */\n summary: ContextPackSummary;\n /** High-confidence invariant beliefs (beliefType = \"invariant\"). */\n invariants: ContextPackBelief[];\n /** Active beliefs ranked by query relevance. */\n activeBeliefs: ContextPackBelief[];\n /** Open questions ranked by relevance and priority. */\n openQuestions: ContextPackQuestion[];\n /** Recent evidence ranked by relevance and recency. */\n recentEvidence: ContextPackEvidence[];\n /** Active contradictions ranked by severity. */\n contradictions: ContextPackContradiction[];\n /**\n * Ontological entities connected to beliefs in scope, ranked by connectivity.\n * Optional — present when entity graph substrate is active for this topic.\n * NON-BREAKING addition per contract rules.\n */\n relatedEntities?: ContextPackEntity[];\n /** Concise instructions for agent context injection. */\n contextNarrative: string[];\n /** Token-budgeted injection selections. */\n injectionPolicy: ContextPackInjectionPolicy;\n /** Assembly telemetry. */\n diagnostics: ContextPackDiagnostics;\n /** Compilation mode used to generate this pack (RS-2). Default: \"standard\". */\n compilationMode?: ContextCompilationMode;\n /** Failure context for anti-repetition (RS-2). Present when failures are relevant. */\n failureContext?: ContextPackFailureContext;\n /** Delta report (RS-2). Present only when compilationMode = \"delta\". */\n deltaReport?: ContextPackDeltaReport;\n /** Pack weight overrides applied during ranking (RS-2). */\n appliedWeightOverrides?: PackWeightOverride[];\n};\n\n// =============================================================================\n// CONTEXT PACK REQUEST V1 (INPUT)\n// =============================================================================\n\n/**\n * The canonical input schema for `compile_context`.\n * `topicId` is canonical. `projectId` remains an optional compatibility alias.\n */\nexport type ContextPackRequestV1 = {\n /** Topic scope ID (required). */\n topicId: string;\n /** Deprecated compatibility alias for older callers. */\n projectId?: string;\n /** Focus query for relevance ranking. */\n query?: string;\n /** Max items per section. Default: DEFAULT_SECTION_LIMIT. */\n limit?: number;\n /** Ranking profile. Default: DEFAULT_RANKING_PROFILE. */\n rankingProfile?: ContextRankingProfile;\n /** Total token budget. Default: DEFAULT_TOKEN_BUDGET. */\n tokenBudget?: number;\n /** Descendant topic depth for neighborhood expansion. */\n maxDepth?: number;\n /** Include ontological entities connected to beliefs in scope. Default: true. */\n includeEntities?: boolean;\n /** Compilation mode (RS-2). Default: \"standard\". */\n mode?: ContextCompilationMode;\n /** Include failure log context for anti-repetition (RS-2). Default: false. */\n includeFailures?: boolean;\n /** Active worktree ID for delta mode reference point (RS-2). */\n worktreeId?: string;\n /** Session ID for anti-repetition dedup (RS-2). */\n sessionId?: string;\n /** Pack weight overrides from domain pack binding (RS-2). */\n packWeightOverrides?: PackWeightOverride[];\n};\n\n// =============================================================================\n// RESOLVED QUESTION STATUSES\n// =============================================================================\n\n/**\n * Question statuses that are considered \"resolved\" (not open).\n * Used to filter which questions appear in the openQuestions section.\n */\nexport const RESOLVED_QUESTION_STATUSES: readonly string[] = [\n \"answered\",\n \"archived\",\n \"closed\",\n \"resolved\",\n \"resolved_support\",\n \"resolved_contra\",\n \"belief_forked\",\n] as const;\n\n// =============================================================================\n// TOKEN ESTIMATION\n// =============================================================================\n\n/**\n * Tokens-per-word multiplier for rough token estimation.\n * Conservative estimate: ~1.35 tokens per whitespace-delimited word.\n */\nexport const TOKENS_PER_WORD = 1.35;\n\n/** Minimum token estimate for any non-empty string. */\nexport const MIN_TOKEN_ESTIMATE = 8;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/context-pack.contract.ts"],"names":[],"mappings":";AAqBO,IAAM,2BAAA,GAA8B;AAepC,IAAM,wBAAA,GAA6D;AAAA,EACxE,aAAA;AAAA,EACA;AACF;AAEO,IAAM,uBAAA,GAAiD;AAevD,IAAM,wBAAA,GAAmD;AAiBzD,IAAM,yBAAA,GAA8D;AAAA,EACzE,YAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF;AAiBO,IAAM,qBAAA,GAET;AAAA,EACF,UAAA,EAAY,IAAA;AAAA,EACZ,aAAA,EAAe,GAAA;AAAA,EACf,aAAA,EAAe,IAAA;AAAA,EACf,cAAA,EAAgB,IAAA;AAAA,EAChB,cAAA,EAAgB;AAClB;AAOO,IAAM,gBAAA,GAAmB;AAGzB,IAAM,gBAAA,GAAmB;AAGzB,IAAM,oBAAA,GAAuB;AAG7B,IAAM,qBAAA,GAAwB;AAG9B,IAAM,iBAAA,GAAoB;AAG1B,IAAM,wBAAA,GAA2B;AA0BjC,IAAM,eAAA,GAET;AAAA,EACF,UAAA,EAAY;AAAA,IACV,KAAA,EAAO,IAAA;AAAA,IACP,OAAA,EAAS,GAAA;AAAA,IACT,UAAA,EAAY,GAAA;AAAA,IACZ,UAAA,EAAY;AAAA,GACd;AAAA,EACA,aAAA,EAAe;AAAA,IACb,KAAA,EAAO,GAAA;AAAA,IACP,OAAA,EAAS,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AA,GAAqB","file":"context-pack.contract.js","sourcesContent":["/**\n * Context-Pack Contract v1\n *\n * Canonical TypeScript types and constants for the context-pack output schema.\n * This is the external contract consumed by:\n * - MCP tool `compile_context` (canonical compiler read)\n * - SDK/HTTP consumers that read compiled context packs programmatically\n * - Benchmark harnesses (context-pack-ab)\n *\n * BREAKING CHANGE RULES:\n * - Adding optional fields to ContextPackV1 is NON-breaking\n * - Removing fields or changing types is BREAKING (bump CONTEXT_PACK_SCHEMA_VERSION)\n * - Changing section budget ratios or ranking weights is NON-breaking (tuning)\n * - Changing the version string is BREAKING (consumers check it)\n */\n\n// =============================================================================\n// SCHEMA VERSION\n// =============================================================================\n\n/** Canonical version string. Consumers MUST check this field for compatibility. */\nexport const CONTEXT_PACK_SCHEMA_VERSION = \"1.0.0\" as const;\n\n// =============================================================================\n// RANKING PROFILES\n// =============================================================================\n\n/**\n * Available ranking profiles for context-pack assembly.\n *\n * - `baseline_v1`: Simple token-hit counting. Items with zero query hits are excluded.\n * - `weighted_v1`: Multi-signal scoring combining query relevance, recency, confidence,\n * belief type, priority, and severity with section-specific weight vectors.\n */\nexport type ContextRankingProfile = \"baseline_v1\" | \"weighted_v1\";\n\nexport const CONTEXT_RANKING_PROFILES: readonly ContextRankingProfile[] = [\n \"baseline_v1\",\n \"weighted_v1\",\n] as const;\n\nexport const DEFAULT_RANKING_PROFILE: ContextRankingProfile = \"weighted_v1\";\n\n// =============================================================================\n// COMPILATION MODE (RS-2)\n// =============================================================================\n\n/**\n * Context compilation mode.\n *\n * - `standard`: Default — ranked beliefs, questions, evidence, contradictions.\n * - `delta`: Diff-aware — adds failure context, verification obligations,\n * and worktree ledger analysis to the standard context pack.\n */\nexport type ContextCompilationMode = \"standard\" | \"delta\";\n\nexport const DEFAULT_COMPILATION_MODE: ContextCompilationMode = \"standard\";\n\n// =============================================================================\n// SECTION KEYS\n// =============================================================================\n\n/**\n * The five canonical sections of a context pack.\n * Order matters: invariants are injected first, contradictions last.\n */\nexport type ContextPackSectionKey =\n | \"invariants\"\n | \"activeBeliefs\"\n | \"openQuestions\"\n | \"recentEvidence\"\n | \"contradictions\";\n\nexport const CONTEXT_PACK_SECTION_KEYS: readonly ContextPackSectionKey[] = [\n \"invariants\",\n \"activeBeliefs\",\n \"openQuestions\",\n \"recentEvidence\",\n \"contradictions\",\n] as const;\n\n// =============================================================================\n// SECTION BUDGET RATIOS\n// =============================================================================\n\n/**\n * Token budget allocation ratios per section.\n * These sum to 1.0 and determine how the total tokenBudget is divided.\n *\n * Rationale:\n * - invariants (0.28): Highest-priority constraints, injected first\n * - activeBeliefs (0.30): Largest section, carries domain knowledge\n * - openQuestions (0.17): Unresolved work items guide agent behavior\n * - recentEvidence (0.17): Implementation context for grounding\n * - contradictions (0.08): Tension signals, smallest section\n */\nexport const SECTION_BUDGET_RATIOS: Readonly<\n Record<ContextPackSectionKey, number>\n> = {\n invariants: 0.28,\n activeBeliefs: 0.3,\n openQuestions: 0.17,\n recentEvidence: 0.17,\n contradictions: 0.08,\n} as const;\n\n// =============================================================================\n// TOKEN BUDGET CONSTRAINTS\n// =============================================================================\n\n/** Minimum allowed token budget. Below this, context packs lose utility. */\nexport const MIN_TOKEN_BUDGET = 400;\n\n/** Maximum allowed token budget. Above this, context packs bloat prompts. */\nexport const MAX_TOKEN_BUDGET = 8000;\n\n/** Default token budget when caller does not specify. */\nexport const DEFAULT_TOKEN_BUDGET = 1800;\n\n/** Default max items per section. */\nexport const DEFAULT_SECTION_LIMIT = 8;\n\n/** Hard ceiling on items per section. */\nexport const MAX_SECTION_LIMIT = 25;\n\n/** Minimum contradiction section budget floor (tokens). */\nexport const MIN_CONTRADICTION_BUDGET = 40;\n\n// =============================================================================\n// RANKING WEIGHT VECTORS\n// =============================================================================\n\n/**\n * Weight vectors for the weighted_v1 ranking profile.\n * Each section has a different signal mix:\n *\n * - query: How many query tokens appear in the candidate text\n * - recency: Exponential decay from updatedAt (half-life = 30 days)\n * - confidence: Belief confidence score [0,1]\n * - beliefType: Bonus for invariant > tenet > principle > other\n * - priority: Question priority (critical > high > medium > low)\n * - severity: Contradiction severity (critical > high > medium > low)\n */\nexport type RankingWeightVector = {\n query: number;\n recency: number;\n confidence?: number;\n beliefType?: number;\n priority?: number;\n severity?: number;\n};\n\nexport const RANKING_WEIGHTS: Readonly<\n Record<ContextPackSectionKey, RankingWeightVector>\n> = {\n invariants: {\n query: 0.35,\n recency: 0.1,\n confidence: 0.4,\n beliefType: 0.15,\n },\n activeBeliefs: {\n query: 0.5,\n recency: 0.2,\n confidence: 0.2,\n beliefType: 0.1,\n },\n openQuestions: {\n query: 0.55,\n recency: 0.2,\n priority: 0.25,\n },\n recentEvidence: {\n query: 0.6,\n recency: 0.4,\n },\n contradictions: {\n query: 0.4,\n recency: 0.2,\n severity: 0.4,\n },\n} as const;\n\n/** Recency decay half-life in days. After 30 days, recency score = 0.5. */\nexport const RECENCY_HALF_LIFE_DAYS = 30;\n\n/**\n * Ranking weight vector for the relatedEntities section.\n * Entities are ranked by query relevance and connectivity (bridge edge count).\n * Separate from RANKING_WEIGHTS because entities are not part of the\n * token-budgeted injection plan.\n */\nexport const ENTITY_RANKING_WEIGHTS = {\n query: 0.4,\n connectivity: 0.6,\n} as const;\n\n/** Default max entities to include in the context pack. */\nexport const DEFAULT_ENTITY_LIMIT = 10;\n\n/** Hard ceiling on entities per context pack. */\nexport const MAX_ENTITY_LIMIT = 50;\n\n// =============================================================================\n// BELIEF TYPE BONUS MAP\n// =============================================================================\n\n/**\n * Bonus multiplier for belief types in ranking.\n * Invariants get 1.0, unknown types get 0.4.\n */\nexport const BELIEF_TYPE_BONUS: Readonly<Record<string, number>> = {\n invariant: 1.0,\n tenet: 0.8,\n principle: 0.6,\n} as const;\n\nexport const DEFAULT_BELIEF_TYPE_BONUS = 0.4;\n\n// =============================================================================\n// PRIORITY / SEVERITY SCORE MAPS\n// =============================================================================\n\nexport const PRIORITY_SCORES: Readonly<Record<string, number>> = {\n critical: 1.0,\n high: 0.85,\n medium: 0.55,\n low: 0.35,\n} as const;\n\nexport const DEFAULT_PRIORITY_SCORE = 0.5;\n\nexport const SEVERITY_SCORES: Readonly<Record<string, number>> = {\n critical: 1.0,\n high: 0.85,\n medium: 0.6,\n low: 0.35,\n} as const;\n\nexport const DEFAULT_SEVERITY_SCORE = 0.5;\n\n// =============================================================================\n// SECTION ITEM TYPES\n// =============================================================================\n\n/** A ranked belief in the invariants or activeBeliefs section. */\nexport type ContextPackBelief = {\n nodeId: string;\n canonicalText: string;\n confidence: number | null;\n beliefType: string | null;\n score: number;\n /** Present in activeBeliefs, absent in invariants */\n status?: string;\n updatedAt?: number | null;\n /** Human-readable explanation of why this item was ranked here (RS-2). */\n justification?: string;\n};\n\n/** A ranked question in the openQuestions section. */\nexport type ContextPackQuestion = {\n questionId: string;\n text: string;\n status: string;\n priority: string;\n updatedAt?: number | null;\n score: number;\n /** Human-readable explanation of why this item was ranked here (RS-2). */\n justification?: string;\n};\n\n/** A ranked evidence item in the recentEvidence section. */\nexport type ContextPackEvidence = {\n nodeId: string;\n canonicalText: string;\n sourceUrl: string | null;\n kind: string;\n createdAt: number | null;\n score: number;\n /** Human-readable explanation of why this item was ranked here (RS-2). */\n justification?: string;\n};\n\n/** A ranked contradiction in the contradictions section. */\nexport type ContextPackContradiction = {\n contradictionId: string;\n severity: string;\n status: string;\n description: string;\n score: number;\n /** Human-readable explanation of why this item was ranked here (RS-2). */\n justification?: string;\n};\n\n/**\n * An entity from the ontological layer surfaced in the context pack.\n * Entities are domain objects (companies, people, functions, etc.) connected\n * to beliefs via bridge edges. They provide the \"reality anchor\" that makes\n * the reasoning graph domain-aware.\n */\nexport type ContextPackEntity = {\n /** Convex document ID of the entity node. */\n nodeId: string;\n /** Entity type (e.g., \"company\", \"person\", \"function\"). */\n entityType: string;\n /** Human-readable title/name of the entity. */\n title: string;\n /** Number of beliefs connected to this entity via bridge edges. */\n connectedBeliefCount: number;\n /** Number of evidence items referencing this entity. */\n connectedEvidenceCount: number;\n /** Relevance score from ranking algorithm. */\n score: number;\n /** Entity metadata (structured per ontology schema). */\n metadata?: Record<string, unknown>;\n};\n\n/**\n * A lattice seed entry representing a belief that was auto-generated\n * to cover an ontology entity type within a topic scope.\n */\nexport type BeliefLatticeSeed = {\n /** The belief node ID that was created or already existed. */\n beliefNodeId: string;\n /** The entity type this seed belief covers. */\n entityType: string;\n /** Whether this seed was newly created or already existed. */\n created: boolean;\n /** The canonical text of the seed belief. */\n canonicalText: string;\n};\n\n// =============================================================================\n// SUMMARY\n// =============================================================================\n\n/** Counts and scoped health signals for the context pack. */\nexport type ContextPackSummary = {\n totalBeliefs: number;\n invariants: number;\n openQuestions: number;\n evidenceItems: number;\n contradictions: number;\n /** Number of ontological entities in scope (optional, present when entity graph is active). */\n relatedEntities?: number;\n scopedTopics: number;\n descendantDepth: number;\n query: string | null;\n};\n\n// =============================================================================\n// FAILURE CONTEXT (RS-2)\n// =============================================================================\n\n/** A failed approach surfaced from the failure log for anti-repetition. */\nexport type ContextPackFailure = {\n /** Lucern attempt/evidence node ID. */\n attemptId: string;\n /** What was tried. */\n approach: string;\n /** Why it failed. */\n outcome: string;\n /** When the attempt was recorded (ms since epoch). */\n recordedAt: number;\n /** Relevance score from ranking algorithm. */\n score: number;\n};\n\n/** Failure context section appended to context packs in delta mode. */\nexport type ContextPackFailureContext = {\n /** Ranked failed approaches relevant to the current query. */\n failures: ContextPackFailure[];\n /** IDs of items suppressed from other sections due to anti-repetition. */\n suppressedIds: string[];\n};\n\n// =============================================================================\n// DELTA REPORT (RS-2)\n// =============================================================================\n\n/** A verification obligation surfaced by delta compilation. */\nexport type VerificationObligation = {\n /** What must be verified. */\n description: string;\n /** Source of the obligation (e.g., \"belief:xyz confidence drop\"). */\n source: string;\n /** Severity: how important it is to verify. */\n severity: \"critical\" | \"high\" | \"medium\" | \"low\";\n};\n\n/** Delta report appended to context packs when mode = \"delta\". */\nexport type ContextPackDeltaReport = {\n /** Items that changed since the reference point (new, updated, removed). */\n changedItems: Array<{\n id: string;\n section: ContextPackSectionKey;\n changeType: \"added\" | \"updated\" | \"removed\" | \"confidence_changed\";\n summary: string;\n }>;\n /** Obligations the consuming session must verify. */\n verificationObligations: VerificationObligation[];\n /** Reference point for the delta (worktree ID, timestamp, or commit SHA). */\n referencePoint: string;\n};\n\n// =============================================================================\n// PACK WEIGHT OVERRIDES (RS-2)\n// =============================================================================\n\n/**\n * Per-section weight overrides that domain packs can apply.\n * Overrides merge with RANKING_WEIGHTS — only specified fields replace defaults.\n */\nexport type PackWeightOverride = {\n /** Which section to override weights for. */\n section: ContextPackSectionKey;\n /** Partial weight vector — only specified fields replace defaults. */\n weights: Partial<RankingWeightVector>;\n};\n\n// =============================================================================\n// INJECTION POLICY\n// =============================================================================\n\n/** Token-budgeted section selections for prompt injection. */\nexport type ContextPackInjectionPolicy = {\n /** Total token budget for the entire context pack. */\n tokenBudget: number;\n /** Estimated tokens consumed across all sections. */\n estimatedTokens: number;\n /** Per-section token budgets derived from SECTION_BUDGET_RATIOS. */\n sectionBudgets: Record<ContextPackSectionKey, number>;\n /** Actual token usage per section after greedy fill. */\n sectionUsage: Record<ContextPackSectionKey, number>;\n /** Node/question IDs selected for injection, per section. */\n selected: Record<ContextPackSectionKey, string[]>;\n /** Items that were scored but excluded from injection, with reason (RS-2). */\n excludedItems?: Array<{\n id: string;\n section: ContextPackSectionKey;\n reason: \"budget_exceeded\" | \"anti_repetition\" | \"below_threshold\";\n score: number;\n }>;\n};\n\n// =============================================================================\n// DIAGNOSTICS\n// =============================================================================\n\n/** Telemetry for context pack assembly. */\nexport type ContextPackDiagnostics = {\n /** Total candidates scored across all sections. */\n itemsScored: number;\n /** Ratio of estimatedTokens / tokenBudget. Range [0, 1+]. */\n tokenBudgetUtilization: number;\n};\n\n// =============================================================================\n// PUBLIC COMPILED CONTEXT TYPES\n// =============================================================================\n\n/**\n * Public context surface returned by the SDK-facing context client.\n *\n * This preserves the existing external shape while the canonical compiler\n * contract evolves in parallel as ContextPackV1.\n */\nexport type PublicContextBelief = {\n beliefId: string;\n text: string;\n confidence: number | null;\n beliefType?: string | null;\n status?: string;\n updatedAt?: number | null;\n score: number;\n justification?: string;\n};\n\nexport type PublicContextQuestion = {\n questionId: string;\n text: string;\n status: string;\n priority: string;\n updatedAt?: number | null;\n score: number;\n justification?: string;\n};\n\nexport type PublicContextEvidence = {\n evidenceId: string;\n text: string;\n sourceUrl?: string | null;\n kind: string;\n createdAt?: number | null;\n score: number;\n justification?: string;\n};\n\nexport type PublicContextContradiction = {\n contradictionId: string;\n severity: string;\n status: string;\n description: string;\n score: number;\n justification?: string;\n};\n\nexport type PublicContextEntity = {\n entityId: string;\n entityType: string;\n title: string;\n text?: string;\n connectedBeliefCount: number;\n connectedEvidenceCount: number;\n score: number;\n metadata?: Record<string, unknown>;\n};\n\nexport type PublicContextInjectionPolicy = {\n tokenBudget: number;\n estimatedTokens: number;\n sectionBudgets: Record<string, number>;\n sectionUsage: Record<string, number>;\n selected: Record<string, string[]>;\n excludedItems?: Array<{\n id: string;\n section: string;\n reason: \"budget_exceeded\" | \"anti_repetition\" | \"below_threshold\";\n score: number;\n }>;\n};\n\nexport type PublicCompiledContext = {\n schemaVersion: string;\n topicId: string;\n topicName: string;\n scopedTopicIds: string[];\n generatedAt: number;\n ranking: ContextRankingProfile;\n summary: Record<string, unknown>;\n invariants: PublicContextBelief[];\n activeBeliefs: PublicContextBelief[];\n openQuestions: PublicContextQuestion[];\n recentEvidence: PublicContextEvidence[];\n contradictions: PublicContextContradiction[];\n relatedEntities?: PublicContextEntity[];\n contextNarrative: string[];\n injectionPolicy: PublicContextInjectionPolicy;\n diagnostics: Record<string, unknown>;\n compilationMode?: string;\n failureContext?: {\n failures: Array<{\n attemptId: string;\n approach: string;\n outcome: string;\n recordedAt: number;\n score: number;\n }>;\n suppressedIds: string[];\n };\n deltaReport?: {\n changedItems: Array<{\n id: string;\n section: string;\n changeType: string;\n summary: string;\n }>;\n verificationObligations: Array<{\n description: string;\n source: string;\n severity: \"critical\" | \"high\" | \"medium\" | \"low\";\n }>;\n referencePoint: string;\n };\n appliedWeightOverrides?: unknown[];\n};\n\n// =============================================================================\n// CONTEXT PACK V1 (TOP-LEVEL OUTPUT)\n// =============================================================================\n\n/**\n * The canonical output schema for context compilation responses.\n *\n * This is the contract that consumers depend on. All fields are required\n * in the output. Adding optional fields is non-breaking; removing or\n * changing types is breaking (requires version bump).\n */\nexport type ContextPackV1 = {\n /** Schema version for compatibility checking. */\n schemaVersion: typeof CONTEXT_PACK_SCHEMA_VERSION;\n /** Deprecated compatibility alias for the requested scope ID. */\n projectId?: string;\n /** Resolved topic ID after scope resolution. */\n topicId: string;\n /** Human-readable topic name. */\n topicName: string;\n /** All topic IDs included in the neighborhood expansion. */\n scopedTopicIds: string[];\n /** Deterministic freshness watermark for this pack (ms since epoch). */\n generatedAt: number;\n /** Which ranking profile was used. */\n rankingProfile: ContextRankingProfile;\n /** Aggregate counts and health signals. */\n summary: ContextPackSummary;\n /** High-confidence invariant beliefs (beliefType = \"invariant\"). */\n invariants: ContextPackBelief[];\n /** Active beliefs ranked by query relevance. */\n activeBeliefs: ContextPackBelief[];\n /** Open questions ranked by relevance and priority. */\n openQuestions: ContextPackQuestion[];\n /** Recent evidence ranked by relevance and recency. */\n recentEvidence: ContextPackEvidence[];\n /** Active contradictions ranked by severity. */\n contradictions: ContextPackContradiction[];\n /**\n * Ontological entities connected to beliefs in scope, ranked by connectivity.\n * Optional — present when entity graph substrate is active for this topic.\n * NON-BREAKING addition per contract rules.\n */\n relatedEntities?: ContextPackEntity[];\n /** Concise instructions for agent context injection. */\n contextNarrative: string[];\n /** Token-budgeted injection selections. */\n injectionPolicy: ContextPackInjectionPolicy;\n /** Assembly telemetry. */\n diagnostics: ContextPackDiagnostics;\n /** Compilation mode used to generate this pack (RS-2). Default: \"standard\". */\n compilationMode?: ContextCompilationMode;\n /** Failure context for anti-repetition (RS-2). Present when failures are relevant. */\n failureContext?: ContextPackFailureContext;\n /** Delta report (RS-2). Present only when compilationMode = \"delta\". */\n deltaReport?: ContextPackDeltaReport;\n /** Pack weight overrides applied during ranking (RS-2). */\n appliedWeightOverrides?: PackWeightOverride[];\n};\n\n// =============================================================================\n// CONTEXT PACK REQUEST V1 (INPUT)\n// =============================================================================\n\n/**\n * The canonical input schema for `compile_context`.\n * `topicId` is optional for query-first callers. When omitted, the platform\n * resolves the best topic from the query and other available signals.\n * `projectId` remains an optional compatibility alias.\n */\nexport type ContextPackRequestV1 = {\n /** Topic scope ID. Omit to resolve by query. */\n topicId?: string;\n /** Deprecated compatibility alias for older callers. */\n projectId?: string;\n /** Focus query for relevance ranking. */\n query?: string;\n /** Max items per section. Default: DEFAULT_SECTION_LIMIT. */\n limit?: number;\n /** Ranking profile. Default: DEFAULT_RANKING_PROFILE. */\n rankingProfile?: ContextRankingProfile;\n /** Total token budget. Default: DEFAULT_TOKEN_BUDGET. */\n tokenBudget?: number;\n /** Descendant topic depth for neighborhood expansion. */\n maxDepth?: number;\n /** Include ontological entities connected to beliefs in scope. Default: true. */\n includeEntities?: boolean;\n /** Compilation mode (RS-2). Default: \"standard\". */\n mode?: ContextCompilationMode;\n /** Include failure log context for anti-repetition (RS-2). Default: false. */\n includeFailures?: boolean;\n /** Active worktree ID for delta mode reference point (RS-2). */\n worktreeId?: string;\n /** Session ID for anti-repetition dedup (RS-2). */\n sessionId?: string;\n /** Pack weight overrides from domain pack binding (RS-2). */\n packWeightOverrides?: PackWeightOverride[];\n};\n\n// =============================================================================\n// RESOLVED QUESTION STATUSES\n// =============================================================================\n\n/**\n * Question statuses that are considered \"resolved\" (not open).\n * Used to filter which questions appear in the openQuestions section.\n */\nexport const RESOLVED_QUESTION_STATUSES: readonly string[] = [\n \"answered\",\n \"archived\",\n \"closed\",\n \"resolved\",\n \"resolved_support\",\n \"resolved_contra\",\n \"belief_forked\",\n] as const;\n\n// =============================================================================\n// TOKEN ESTIMATION\n// =============================================================================\n\n/**\n * Tokens-per-word multiplier for rough token estimation.\n * Conservative estimate: ~1.35 tokens per whitespace-delimited word.\n */\nexport const TOKENS_PER_WORD = 1.35;\n\n/** Minimum token estimate for any non-empty string. */\nexport const MIN_TOKEN_ESTIMATE = 8;\n"]}
|
|
@@ -107,4 +107,4 @@ declare namespace dsl {
|
|
|
107
107
|
export { type dsl_AdapterContext as AdapterContext, type dsl_AdapterKind as AdapterKind, type dsl_AdapterPurpose as AdapterPurpose, dsl_CONVEX_ID_TABLE as CONVEX_ID_TABLE, type dsl_CliCommandSpec as CliCommandSpec, type dsl_CliOptionKind as CliOptionKind, type dsl_CliOptionSpec as CliOptionSpec, type dsl_ConvexDefault as ConvexDefault, dsl_ConvexIdSchema as ConvexIdSchema, dsl_FunctionContract as FunctionContract, dsl_FunctionEffect as FunctionEffect, type dsl_JsonSchema as JsonSchema, dsl_SchemaAdapterError as SchemaAdapterError, dsl_TableComponent as TableComponent, dsl_TableContract as TableContract, dsl_TableDeprecation as TableDeprecation, dsl_TableIndex as TableIndex, type dsl_ZodToCliOptions as ZodToCliOptions, type dsl_ZodToConvexOptions as ZodToConvexOptions, type dsl_ZodToConvexResult as ZodToConvexResult, type dsl_ZodToJsonSchemaOptions as ZodToJsonSchemaOptions, dsl_defineFunction as defineFunction, dsl_defineTable as defineTable, dsl_getConvexIdTable as getConvexIdTable, dsl_idOf as idOf, dsl_schemaAdapterError as schemaAdapterError, dsl_tableIndexToConvexSource as tableIndexToConvexSource, dsl_zodToCli as zodToCli, dsl_zodToConvex as zodToConvex, dsl_zodToJsonSchema as zodToJsonSchema };
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
export { type
|
|
110
|
+
export { type AdapterContext as A, type CliCommandSpec as C, type JsonSchema as J, SchemaAdapterError as S, type ZodToCliOptions as Z, type AdapterKind as a, type AdapterPurpose as b, type CliOptionKind as c, dsl as d, type CliOptionSpec as e, type ConvexDefault as f, type ZodToConvexOptions as g, type ZodToConvexResult as h, type ZodToJsonSchemaOptions as i, zodToConvex as j, zodToJsonSchema as k, schemaAdapterError as s, tableIndexToConvexSource as t, zodToCli as z };
|
package/dist/dsl.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { a as FunctionContract, F as FunctionEffect, d as defineFunction } from './defineFunction-DO97DKs4.js';
|
|
2
2
|
export { b as TableComponent, T as TableContract, c as TableDeprecation, a as TableIndex, d as defineTable } from './defineTable-CBQ03FXl.js';
|
|
3
|
-
export {
|
|
3
|
+
export { A as AdapterContext, a as AdapterKind, b as AdapterPurpose, C as CliCommandSpec, c as CliOptionKind, e as CliOptionSpec, f as ConvexDefault, J as JsonSchema, S as SchemaAdapterError, Z as ZodToCliOptions, g as ZodToConvexOptions, h as ZodToConvexResult, i as ZodToJsonSchemaOptions, s as schemaAdapterError, t as tableIndexToConvexSource, z as zodToCli, j as zodToConvex, k as zodToJsonSchema } from './dsl-djCRfuWC.js';
|
|
4
4
|
export { a as CONVEX_ID_TABLE, C as ConvexIdSchema, g as getConvexIdTable, i as idOf } from './idOf-DR8tkhQS.js';
|
|
5
5
|
import 'zod';
|
package/dist/dsl.js
CHANGED
|
@@ -208,9 +208,6 @@ function encodeLiteral(value) {
|
|
|
208
208
|
}
|
|
209
209
|
return JSON.stringify(value);
|
|
210
210
|
}
|
|
211
|
-
function quoteKey(value) {
|
|
212
|
-
return JSON.stringify(value);
|
|
213
|
-
}
|
|
214
211
|
function sortEntries(entries) {
|
|
215
212
|
return [...entries].sort(([left], [right]) => left.localeCompare(right));
|
|
216
213
|
}
|
|
@@ -373,7 +370,7 @@ function convertSchemaInner(schema, state, path) {
|
|
|
373
370
|
convertSchema(value, state, [...path, key])
|
|
374
371
|
]);
|
|
375
372
|
return {
|
|
376
|
-
source: `v.object({ ${convertedFields.map(([key, converted]) => `${
|
|
373
|
+
source: `v.object({ ${convertedFields.map(([key, converted]) => `${JSON.stringify(key)}: ${converted.source}`).join(", ")} })`,
|
|
377
374
|
defaults: convertedFields.flatMap(([, converted]) => converted.defaults)
|
|
378
375
|
};
|
|
379
376
|
}
|
|
@@ -417,6 +414,9 @@ function convertSchemaInner(schema, state, path) {
|
|
|
417
414
|
case ZodFirstPartyTypeKind.ZodBranded: {
|
|
418
415
|
return convertSchema(schema._def.type, state, path);
|
|
419
416
|
}
|
|
417
|
+
case ZodFirstPartyTypeKind.ZodEffects: {
|
|
418
|
+
return convertSchema(schema._def.schema, state, path);
|
|
419
|
+
}
|
|
420
420
|
default:
|
|
421
421
|
unsupported2(`Unsupported Zod schema kind ${schema._def.typeName}`, state, path);
|
|
422
422
|
}
|