@lucern/contracts 0.1.0 → 0.1.2-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +3 -0
  3. package/dist/agents/v1.d.ts +2 -0
  4. package/dist/agents/v1.js +3 -0
  5. package/dist/agents/v1.js.map +1 -0
  6. package/dist/api-enums.contract.d.ts +30 -29
  7. package/dist/api-enums.contract.js +145 -133
  8. package/dist/api-enums.contract.js.map +1 -1
  9. package/dist/auth-context.contract.d.ts +2 -0
  10. package/dist/auth-context.contract.js +48 -0
  11. package/dist/auth-context.contract.js.map +1 -0
  12. package/dist/auth-session.contract.d.ts +2 -54
  13. package/dist/auth-session.contract.js +41 -43
  14. package/dist/auth-session.contract.js.map +1 -1
  15. package/dist/auth.contract.d.ts +92 -0
  16. package/dist/auth.contract.js +48 -0
  17. package/dist/auth.contract.js.map +1 -0
  18. package/dist/beliefs/v1.d.ts +2 -0
  19. package/dist/beliefs/v1.js +3 -0
  20. package/dist/beliefs/v1.js.map +1 -0
  21. package/dist/context-pack.contract.d.ts +55 -54
  22. package/dist/context-pack.contract.js +88 -160
  23. package/dist/context-pack.contract.js.map +1 -1
  24. package/dist/convex-admin.contract.d.ts +7 -0
  25. package/dist/convex-admin.contract.js +3 -0
  26. package/dist/convex-admin.contract.js.map +1 -0
  27. package/dist/events-types.contract.d.ts +1 -0
  28. package/dist/events-types.contract.js +136 -0
  29. package/dist/events-types.contract.js.map +1 -0
  30. package/dist/events.contract.d.ts +178 -0
  31. package/dist/events.contract.js +136 -0
  32. package/dist/events.contract.js.map +1 -0
  33. package/dist/evidence/v1.d.ts +2 -0
  34. package/dist/evidence/v1.js +3 -0
  35. package/dist/evidence/v1.js.map +1 -0
  36. package/dist/gateway.contract.d.ts +17 -12
  37. package/dist/gateway.contract.js +11 -11
  38. package/dist/gateway.contract.js.map +1 -1
  39. package/dist/graph/v1.d.ts +2 -0
  40. package/dist/graph/v1.js +3 -0
  41. package/dist/graph/v1.js.map +1 -0
  42. package/dist/ids.contract.d.ts +9 -0
  43. package/dist/ids.contract.js +29 -0
  44. package/dist/ids.contract.js.map +1 -0
  45. package/dist/index.d.ts +15 -22
  46. package/dist/index.js +5525 -21
  47. package/dist/index.js.map +1 -1
  48. package/dist/lens-filter.contract.d.ts +10 -9
  49. package/dist/lens-filter.contract.js +59 -84
  50. package/dist/lens-filter.contract.js.map +1 -1
  51. package/dist/lens-workflow.contract.d.ts +23 -21
  52. package/dist/lens-workflow.contract.js +116 -48
  53. package/dist/lens-workflow.contract.js.map +1 -1
  54. package/dist/mcp-tools.contract-D8kXcP6d.d.ts +254 -0
  55. package/dist/mcp-tools.contract.d.ts +1 -152
  56. package/dist/mcp-tools.contract.js +2984 -3280
  57. package/dist/mcp-tools.contract.js.map +1 -1
  58. package/dist/ontologies/v1.d.ts +2 -0
  59. package/dist/ontologies/v1.js +3 -0
  60. package/dist/ontologies/v1.js.map +1 -0
  61. package/dist/ontology-matching.contract.d.ts +1 -0
  62. package/dist/ontology-matching.contract.js +346 -0
  63. package/dist/ontology-matching.contract.js.map +1 -0
  64. package/dist/prompt.contract.d.ts +5 -4
  65. package/dist/prompt.contract.js +10 -23
  66. package/dist/prompt.contract.js.map +1 -1
  67. package/dist/questions/v1.d.ts +2 -0
  68. package/dist/questions/v1.js +3 -0
  69. package/dist/questions/v1.js.map +1 -0
  70. package/dist/sdk-methods.contract.d.ts +51 -45
  71. package/dist/sdk-methods.contract.js +2 -16
  72. package/dist/sdk-methods.contract.js.map +1 -1
  73. package/dist/sdk-tools.contract-BnV0hKLp.d.ts +150 -0
  74. package/dist/sdk-tools.contract.d.ts +2 -93
  75. package/dist/sdk-tools.contract.js +4220 -1397
  76. package/dist/sdk-tools.contract.js.map +1 -1
  77. package/dist/text-matching.contract.d.ts +55 -0
  78. package/dist/text-matching.contract.js +246 -0
  79. package/dist/text-matching.contract.js.map +1 -0
  80. package/dist/topic-scope.contract.d.ts +1 -0
  81. package/dist/topic-scope.contract.js +54 -0
  82. package/dist/topic-scope.contract.js.map +1 -0
  83. package/dist/topics/v1.d.ts +2 -0
  84. package/dist/topics/v1.js +3 -0
  85. package/dist/topics/v1.js.map +1 -0
  86. package/dist/v1/agents/v1.d.ts +2 -0
  87. package/dist/v1/agents/v1.js +3 -0
  88. package/dist/v1/agents/v1.js.map +1 -0
  89. package/dist/v1/beliefs/v1.d.ts +2 -0
  90. package/dist/v1/beliefs/v1.js +3 -0
  91. package/dist/v1/beliefs/v1.js.map +1 -0
  92. package/dist/v1/evidence/v1.d.ts +2 -0
  93. package/dist/v1/evidence/v1.js +3 -0
  94. package/dist/v1/evidence/v1.js.map +1 -0
  95. package/dist/v1/graph/v1.d.ts +2 -0
  96. package/dist/v1/graph/v1.js +3 -0
  97. package/dist/v1/graph/v1.js.map +1 -0
  98. package/dist/v1/ontologies/v1.d.ts +78 -0
  99. package/dist/v1/ontologies/v1.js +346 -0
  100. package/dist/v1/ontologies/v1.js.map +1 -0
  101. package/dist/v1/questions/v1.d.ts +2 -0
  102. package/dist/v1/questions/v1.js +3 -0
  103. package/dist/v1/questions/v1.js.map +1 -0
  104. package/dist/v1/topics/v1.d.ts +21 -0
  105. package/dist/v1/topics/v1.js +54 -0
  106. package/dist/v1/topics/v1.js.map +1 -0
  107. package/dist/v1/worktrees/v1.d.ts +2 -0
  108. package/dist/v1/worktrees/v1.js +3 -0
  109. package/dist/v1/worktrees/v1.js.map +1 -0
  110. package/dist/workflow-runtime.contract.d.ts +46 -45
  111. package/dist/workflow-runtime.contract.js +228 -241
  112. package/dist/workflow-runtime.contract.js.map +1 -1
  113. package/dist/worktrees/v1.d.ts +2 -0
  114. package/dist/worktrees/v1.js +3 -0
  115. package/dist/worktrees/v1.js.map +1 -0
  116. package/package.json +19 -13
  117. package/dist/api-enums.contract.d.ts.map +0 -1
  118. package/dist/auth-session.contract.d.ts.map +0 -1
  119. package/dist/context-pack.contract.d.ts.map +0 -1
  120. package/dist/gateway.contract.d.ts.map +0 -1
  121. package/dist/index.d.ts.map +0 -1
  122. package/dist/lens-filter.contract.d.ts.map +0 -1
  123. package/dist/lens-workflow.contract.d.ts.map +0 -1
  124. package/dist/mcp-tools.contract.d.ts.map +0 -1
  125. package/dist/prompt.contract.d.ts.map +0 -1
  126. package/dist/sdk-methods.contract.d.ts.map +0 -1
  127. package/dist/sdk-tools.contract.d.ts.map +0 -1
  128. package/dist/workflow-runtime.contract.d.ts.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@lucern/contracts` are tracked in this repository.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @lucern/contracts
2
+
3
+ Machine-readable Lucern contracts for the public SDK, gateway, and MCP surfaces.
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=v1.js.map
3
+ //# sourceMappingURL=v1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"v1.js"}
@@ -9,41 +9,41 @@
9
9
  * Removing or renaming an existing value is a BREAKING CHANGE.
10
10
  */
11
11
  /** Fork reasons — why a scored belief was branched */
12
- export declare const FORK_REASONS: readonly ["refinement", "contradiction_response", "scope_change", "confidence_collapse", "manual"];
13
- export type ForkReason = (typeof FORK_REASONS)[number];
12
+ declare const FORK_REASONS: readonly ["refinement", "contradiction_response", "scope_change", "confidence_collapse", "manual"];
13
+ type ForkReason = (typeof FORK_REASONS)[number];
14
14
  /** Confidence modulation triggers — what caused a confidence change */
15
- export declare const CONFIDENCE_TRIGGERS: readonly ["evidence_added", "contradiction_detected", "merge_outcome", "manual", "decay"];
16
- export type ConfidenceTrigger = (typeof CONFIDENCE_TRIGGERS)[number];
15
+ declare const CONFIDENCE_TRIGGERS: readonly ["evidence_added", "contradiction_detected", "merge_outcome", "manual", "decay"];
16
+ type ConfidenceTrigger = (typeof CONFIDENCE_TRIGGERS)[number];
17
17
  /** Belief status — lifecycle state */
18
- export declare const BELIEF_STATUSES: readonly ["unscored", "scored", "archived"];
19
- export type BeliefStatus = (typeof BELIEF_STATUSES)[number];
18
+ declare const BELIEF_STATUSES: readonly ["unscored", "scored", "archived"];
19
+ type BeliefStatus = (typeof BELIEF_STATUSES)[number];
20
20
  /** Reasoning methods — how an edge relationship was determined */
21
- export declare const REASONING_METHODS: readonly ["deductive", "inductive", "abductive", "analogical", "empirical"];
22
- export type ReasoningMethod = (typeof REASONING_METHODS)[number];
21
+ declare const REASONING_METHODS: readonly ["deductive", "inductive", "abductive", "analogical", "empirical"];
22
+ type ReasoningMethod = (typeof REASONING_METHODS)[number];
23
23
  /** Defeat types (Pollock taxonomy) — how a contradiction operates */
24
- export declare const DEFEAT_TYPES: readonly ["rebuts", "undercuts", "undermines"];
25
- export type DefeatType = (typeof DEFEAT_TYPES)[number];
24
+ declare const DEFEAT_TYPES: readonly ["rebuts", "undercuts", "undermines"];
25
+ type DefeatType = (typeof DEFEAT_TYPES)[number];
26
26
  /** Contradiction severity levels */
27
- export declare const CONTRADICTION_SEVERITIES: readonly ["low", "medium", "high", "critical"];
28
- export type ContradictionSeverity = (typeof CONTRADICTION_SEVERITIES)[number];
27
+ declare const CONTRADICTION_SEVERITIES: readonly ["low", "medium", "high", "critical"];
28
+ type ContradictionSeverity = (typeof CONTRADICTION_SEVERITIES)[number];
29
29
  /** Contradiction resolution status */
30
- export declare const CONTRADICTION_STATUSES: readonly ["unresolved", "resolved", "accepted"];
31
- export type ContradictionStatus = (typeof CONTRADICTION_STATUSES)[number];
30
+ declare const CONTRADICTION_STATUSES: readonly ["unresolved", "resolved", "accepted"];
31
+ type ContradictionStatus = (typeof CONTRADICTION_STATUSES)[number];
32
32
  /** Merge outcome types — how a worktree merge resolved */
33
- export declare const MERGE_OUTCOMES: readonly ["validated", "invalidated", "forked", "inconclusive"];
34
- export type MergeOutcome = (typeof MERGE_OUTCOMES)[number];
33
+ declare const MERGE_OUTCOMES: readonly ["validated", "invalidated", "forked", "inconclusive"];
34
+ type MergeOutcome = (typeof MERGE_OUTCOMES)[number];
35
35
  /** Worktree phases — investigation lifecycle within a checked-out worktree */
36
- export declare const WORKTREE_PHASES: readonly ["hypothesis", "investigation", "evaluation", "resolution"];
37
- export type WorktreePhase = (typeof WORKTREE_PHASES)[number];
36
+ declare const WORKTREE_PHASES: readonly ["hypothesis", "investigation", "evaluation", "resolution"];
37
+ type WorktreePhase = (typeof WORKTREE_PHASES)[number];
38
38
  /** Branch status — thematic branch lifecycle */
39
- export declare const BRANCH_STATUSES: readonly ["dormant", "active", "archived"];
40
- export type BranchStatus = (typeof BRANCH_STATUSES)[number];
39
+ declare const BRANCH_STATUSES: readonly ["dormant", "active", "archived"];
40
+ type BranchStatus = (typeof BRANCH_STATUSES)[number];
41
41
  /** Pull request status — review lifecycle before merge */
42
- export declare const PULL_REQUEST_STATUSES: readonly ["pending_review", "changes_requested", "approved", "blocked"];
43
- export type PullRequestStatus = (typeof PULL_REQUEST_STATUSES)[number];
42
+ declare const PULL_REQUEST_STATUSES: readonly ["pending_review", "changes_requested", "approved", "blocked"];
43
+ type PullRequestStatus = (typeof PULL_REQUEST_STATUSES)[number];
44
44
  /** Epistemic layers — the hierarchy of knowledge */
45
- export declare const EPISTEMIC_LAYERS: readonly ["L1", "L2", "L3", "L4"];
46
- export type EpistemicLayer = (typeof EPISTEMIC_LAYERS)[number];
45
+ declare const EPISTEMIC_LAYERS: readonly ["L1", "L2", "L3", "L4"];
46
+ type EpistemicLayer = (typeof EPISTEMIC_LAYERS)[number];
47
47
  /**
48
48
  * Judgment type — classification of the determination.
49
49
  *
@@ -51,9 +51,10 @@ export type EpistemicLayer = (typeof EPISTEMIC_LAYERS)[number];
51
51
  * The existing code uses "Decision" — these are the forward-looking terms
52
52
  * that will eventually replace the Decision vocabulary (Phase 2-3).
53
53
  */
54
- export declare const JUDGMENT_TYPES: readonly ["investment_thesis", "thesis_maturity", "contradiction_ruling", "scope_determination", "confidence_ruling"];
55
- export type JudgmentType = (typeof JUDGMENT_TYPES)[number];
54
+ declare const JUDGMENT_TYPES: readonly ["investment_thesis", "thesis_maturity", "contradiction_ruling", "scope_determination", "confidence_ruling"];
55
+ type JudgmentType = (typeof JUDGMENT_TYPES)[number];
56
56
  /** Core edge types used in the Integration Surfaces */
57
- export declare const INTEGRATION_EDGE_TYPES: readonly ["informs", "grounds", "answers", "contradicts", "supports", "depends_on", "derived_from", "contains", "supersedes", "tests"];
58
- export type IntegrationEdgeType = (typeof INTEGRATION_EDGE_TYPES)[number];
59
- //# sourceMappingURL=api-enums.contract.d.ts.map
57
+ declare const INTEGRATION_EDGE_TYPES: readonly ["informs", "grounds", "answers", "contradicts", "supports", "depends_on", "derived_from", "contains", "supersedes", "tests"];
58
+ type IntegrationEdgeType = (typeof INTEGRATION_EDGE_TYPES)[number];
59
+
60
+ export { BELIEF_STATUSES, BRANCH_STATUSES, type BeliefStatus, type BranchStatus, CONFIDENCE_TRIGGERS, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, type ConfidenceTrigger, type ContradictionSeverity, type ContradictionStatus, DEFEAT_TYPES, type DefeatType, EPISTEMIC_LAYERS, type EpistemicLayer, FORK_REASONS, type ForkReason, INTEGRATION_EDGE_TYPES, type IntegrationEdgeType, JUDGMENT_TYPES, type JudgmentType, MERGE_OUTCOMES, type MergeOutcome, PULL_REQUEST_STATUSES, type PullRequestStatus, REASONING_METHODS, type ReasoningMethod, WORKTREE_PHASES, type WorktreePhase };
@@ -1,148 +1,160 @@
1
- /**
2
- * API Enum Contract Definitions
3
- *
4
- * Canonical enum values for all API-facing enumerations.
5
- * These are co-equal with MCP contracts as external contracts.
6
- * SDK types are DERIVED from these — not independently authored.
7
- *
8
- * CONTRACT SURFACE: Adding a new enum value is additive (non-breaking).
9
- * Removing or renaming an existing value is a BREAKING CHANGE.
10
- */
11
- // =============================================================================
12
- // BELIEF ENUMS
13
- // =============================================================================
14
- /** Fork reasons — why a scored belief was branched */
15
- export const FORK_REASONS = [
16
- "refinement", // Belief text evolved based on new understanding
17
- "contradiction_response", // Created in response to a detected contradiction
18
- "scope_change", // Belief scope narrowed or broadened
19
- "confidence_collapse", // Confidence dropped below viability threshold
20
- "manual", // User-initiated fork without specific trigger
1
+ // src/api-enums.contract.ts
2
+ var FORK_REASONS = [
3
+ "refinement",
4
+ // Belief text evolved based on new understanding
5
+ "contradiction_response",
6
+ // Created in response to a detected contradiction
7
+ "scope_change",
8
+ // Belief scope narrowed or broadened
9
+ "confidence_collapse",
10
+ // Confidence dropped below viability threshold
11
+ "manual"
12
+ // User-initiated fork without specific trigger
21
13
  ];
22
- /** Confidence modulation triggers — what caused a confidence change */
23
- export const CONFIDENCE_TRIGGERS = [
24
- "evidence_added", // New evidence bore on the belief
25
- "contradiction_detected", // A contradiction was flagged involving this belief
26
- "merge_outcome", // Merge scoring determined this confidence
27
- "manual", // User manually adjusted confidence
28
- "decay", // Time-based confidence erosion
14
+ var CONFIDENCE_TRIGGERS = [
15
+ "evidence_added",
16
+ // New evidence bore on the belief
17
+ "contradiction_detected",
18
+ // A contradiction was flagged involving this belief
19
+ "merge_outcome",
20
+ // Merge scoring determined this confidence
21
+ "manual",
22
+ // User manually adjusted confidence
23
+ "decay"
24
+ // Time-based confidence erosion
29
25
  ];
30
- /** Belief status — lifecycle state */
31
- export const BELIEF_STATUSES = [
32
- "unscored", // Draft — editable in worktree (on feature branch, pre-merge)
33
- "scored", // Merged — formulation frozen (merged to main)
34
- "archived", // Soft-deletedpreserved in history (git rm)
26
+ var BELIEF_STATUSES = [
27
+ "unscored",
28
+ // Draft — editable in worktree (on feature branch, pre-merge)
29
+ "scored",
30
+ // Mergedformulation frozen (merged to main)
31
+ "archived"
32
+ // Soft-deleted — preserved in history (git rm)
35
33
  ];
36
- // =============================================================================
37
- // EDGE ENUMS
38
- // =============================================================================
39
- /** Reasoning methods — how an edge relationship was determined */
40
- export const REASONING_METHODS = [
41
- "deductive", // Logically entailed
42
- "inductive", // Generalized from instances
43
- "abductive", // Best explanation inference
44
- "analogical", // Reasoning by analogy
45
- "empirical", // Direct observation/measurement
34
+ var REASONING_METHODS = [
35
+ "deductive",
36
+ // Logically entailed
37
+ "inductive",
38
+ // Generalized from instances
39
+ "abductive",
40
+ // Best explanation inference
41
+ "analogical",
42
+ // Reasoning by analogy
43
+ "empirical"
44
+ // Direct observation/measurement
46
45
  ];
47
- /** Defeat types (Pollock taxonomy) — how a contradiction operates */
48
- export const DEFEAT_TYPES = [
49
- "rebuts", // Direct contradiction — reasons for the negation
50
- "undercuts", // Breaks the inference link between evidence and belief
51
- "undermines", // Attacks a premise the belief depends on
46
+ var DEFEAT_TYPES = [
47
+ "rebuts",
48
+ // Direct contradiction — reasons for the negation
49
+ "undercuts",
50
+ // Breaks the inference link between evidence and belief
51
+ "undermines"
52
+ // Attacks a premise the belief depends on
52
53
  ];
53
- /** Contradiction severity levels */
54
- export const CONTRADICTION_SEVERITIES = [
55
- "low", // Minor tension, may not require action
56
- "medium", // Moderate conflict, should be investigated
57
- "high", // Significant contradiction, likely needs resolution
58
- "critical", // Blocks progress — must be addressed before judgment
54
+ var CONTRADICTION_SEVERITIES = [
55
+ "low",
56
+ // Minor tension, may not require action
57
+ "medium",
58
+ // Moderate conflict, should be investigated
59
+ "high",
60
+ // Significant contradiction, likely needs resolution
61
+ "critical"
62
+ // Blocks progress — must be addressed before judgment
59
63
  ];
60
- /** Contradiction resolution status */
61
- export const CONTRADICTION_STATUSES = [
62
- "unresolved", // Open conflict — may persist indefinitely
63
- "resolved", // Conflict addressed (one belief forked, archived, or confidence adjusted)
64
- "accepted", // Explicitly accepted as irreconcilable both beliefs maintained
64
+ var CONTRADICTION_STATUSES = [
65
+ "unresolved",
66
+ // Open conflict — may persist indefinitely
67
+ "resolved",
68
+ // Conflict addressed (one belief forked, archived, or confidence adjusted)
69
+ "accepted"
70
+ // Explicitly accepted as irreconcilable — both beliefs maintained
65
71
  ];
66
- // =============================================================================
67
- // WORKTREE ENUMS (git worktree lifecycle)
68
- // =============================================================================
69
- /** Merge outcome types — how a worktree merge resolved */
70
- export const MERGE_OUTCOMES = [
71
- "validated", // Beliefs confirmed — clean merge to main
72
- "invalidated", // Defeat recorded confidence collapsed (merge with revert)
73
- "forked", // Beliefs split into competing versions (fork from merge point)
74
- "inconclusive", // Insufficient evidence — stashed (git stash)
72
+ var MERGE_OUTCOMES = [
73
+ "validated",
74
+ // Beliefs confirmed — clean merge to main
75
+ "invalidated",
76
+ // Defeat recorded confidence collapsed (merge with revert)
77
+ "forked",
78
+ // Beliefs split into competing versions (fork from merge point)
79
+ "inconclusive"
80
+ // Insufficient evidence — stashed (git stash)
75
81
  ];
76
- /** Worktree phases — investigation lifecycle within a checked-out worktree */
77
- export const WORKTREE_PHASES = [
78
- "hypothesis", // Form testable claims (write the code — commits)
79
- "investigation", // Collect evidence (run the tests — more commits)
80
- "evaluation", // Update credences (review the resultsamend as needed)
81
- "resolution", // Determine outcome (merge to main, fork, or stash)
82
+ var WORKTREE_PHASES = [
83
+ "hypothesis",
84
+ // Form testable claims (write the code — commits)
85
+ "investigation",
86
+ // Collect evidence (run the testsmore commits)
87
+ "evaluation",
88
+ // Update credences (review the results — amend as needed)
89
+ "resolution"
90
+ // Determine outcome (merge to main, fork, or stash)
82
91
  ];
83
- // =============================================================================
84
- // BRANCH ENUMS (git branch lifecycle)
85
- // =============================================================================
86
- /** Branch status — thematic branch lifecycle */
87
- export const BRANCH_STATUSES = [
88
- "dormant", // Branch exists but no active worktree (no one investigating)
89
- "active", // At least one worktree is investigating this branch
90
- "archived", // Branch retired — no longer a relevant thematic container
92
+ var BRANCH_STATUSES = [
93
+ "dormant",
94
+ // Branch exists but no active worktree (no one investigating)
95
+ "active",
96
+ // At least one worktree is investigating this branch
97
+ "archived"
98
+ // Branch retired no longer a relevant thematic container
91
99
  ];
92
- // =============================================================================
93
- // PULL REQUEST ENUMS (git pull request lifecycle)
94
- // =============================================================================
95
- /** Pull request status — review lifecycle before merge */
96
- export const PULL_REQUEST_STATUSES = [
97
- "pending_review", // PR opened — awaiting reviewer feedback
98
- "changes_requested", // Reviewer requests changes before merge
99
- "approved", // Approved — ready to merge
100
- "blocked", // Blocked — cannot merge until contradiction is resolved
100
+ var PULL_REQUEST_STATUSES = [
101
+ "pending_review",
102
+ // PR opened — awaiting reviewer feedback
103
+ "changes_requested",
104
+ // Reviewer requests changes before merge
105
+ "approved",
106
+ // Approved ready to merge
107
+ "blocked"
108
+ // Blocked — cannot merge until contradiction is resolved
101
109
  ];
102
- // =============================================================================
103
- // LAYER ENUMS
104
- // =============================================================================
105
- /** Epistemic layers — the hierarchy of knowledge */
106
- export const EPISTEMIC_LAYERS = [
107
- "L1", // Source — the given (vendored deps)
108
- "L2", // Evidence — the interpreted (test suite)
109
- "L3", // Belief — the structural (source files)
110
- "L4", // Judgment — the committed (release tags)
110
+ var EPISTEMIC_LAYERS = [
111
+ "L1",
112
+ // Source — the given (vendored deps)
113
+ "L2",
114
+ // Evidence the interpreted (test suite)
115
+ "L3",
116
+ // Belief — the structural (source files)
117
+ "L4"
118
+ // Judgment — the committed (release tags)
111
119
  ];
112
- // =============================================================================
113
- // JUDGMENT ENUMS (Phase 1: new vocabulary)
114
- // =============================================================================
115
- /**
116
- * Judgment type classification of the determination.
117
- *
118
- * Phase 1: These are new enum values for the Judgment (L4) vocabulary.
119
- * The existing code uses "Decision" — these are the forward-looking terms
120
- * that will eventually replace the Decision vocabulary (Phase 2-3).
121
- */
122
- export const JUDGMENT_TYPES = [
123
- "investment_thesis", // Judgment on an investment opportunity
124
- "thesis_maturity", // Judgment that a thesis is ready for IC presentation
125
- "contradiction_ruling", // Judgment on how to handle an irreconcilable contradiction
126
- "scope_determination", // Judgment that defines or redefines investigation scope
127
- "confidence_ruling", // Judgment that overrides automated confidence for policy reasons
120
+ var JUDGMENT_TYPES = [
121
+ "investment_thesis",
122
+ // Judgment on an investment opportunity
123
+ "thesis_maturity",
124
+ // Judgment that a thesis is ready for IC presentation
125
+ "contradiction_ruling",
126
+ // Judgment on how to handle an irreconcilable contradiction
127
+ "scope_determination",
128
+ // Judgment that defines or redefines investigation scope
129
+ "confidence_ruling"
130
+ // Judgment that overrides automated confidence for policy reasons
128
131
  ];
129
- // =============================================================================
130
- // SUPPORT RELATION ENUMS
131
- // =============================================================================
132
- /** Core edge types used in the Integration Surfaces */
133
- export const INTEGRATION_EDGE_TYPES = [
134
- // Support relations
135
- "informs", // Evidence bears on a belief (weight = direction/strength)
136
- "grounds", // Source provides raw basis for evidence
137
- "answers", // Evidence or belief resolves a question
138
- // Defeat relations (Pollock) — weight carries direction
139
- "contradicts", // Rebuts — direct contradiction
140
- "supports", // Weight carries valence (negative = weakens/undercuts)
141
- // Structural relations
142
- "depends_on", // Belief B requires Belief A
143
- "derived_from", // Provenance lineage
144
- "contains", // Hierarchical containment
145
- "supersedes", // New version replaces old (lineage)
146
- "tests", // Question tests a belief
132
+ var INTEGRATION_EDGE_TYPES = [
133
+ // Support relations
134
+ "informs",
135
+ // Evidence bears on a belief (weight = direction/strength)
136
+ "grounds",
137
+ // Source provides raw basis for evidence
138
+ "answers",
139
+ // Evidence or belief resolves a question
140
+ // Defeat relations (Pollock) weight carries direction
141
+ "contradicts",
142
+ // Rebuts — direct contradiction
143
+ "supports",
144
+ // Weight carries valence (negative = weakens/undercuts)
145
+ // Structural relations
146
+ "depends_on",
147
+ // Belief B requires Belief A
148
+ "derived_from",
149
+ // Provenance lineage
150
+ "contains",
151
+ // Hierarchical containment
152
+ "supersedes",
153
+ // New version replaces old (lineage)
154
+ "tests"
155
+ // Question tests a belief
147
156
  ];
157
+
158
+ export { BELIEF_STATUSES, BRANCH_STATUSES, CONFIDENCE_TRIGGERS, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, DEFEAT_TYPES, EPISTEMIC_LAYERS, FORK_REASONS, INTEGRATION_EDGE_TYPES, JUDGMENT_TYPES, MERGE_OUTCOMES, PULL_REQUEST_STATUSES, REASONING_METHODS, WORKTREE_PHASES };
159
+ //# sourceMappingURL=api-enums.contract.js.map
148
160
  //# sourceMappingURL=api-enums.contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-enums.contract.js","sourceRoot":"","sources":["../src/api-enums.contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF,sDAAsD;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,YAAY,EAAE,iDAAiD;IAC/D,wBAAwB,EAAE,kDAAkD;IAC5E,cAAc,EAAE,qCAAqC;IACrD,qBAAqB,EAAE,+CAA+C;IACtE,QAAQ,EAAE,+CAA+C;CACjD,CAAC;AAGX,uEAAuE;AACvE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,gBAAgB,EAAE,kCAAkC;IACpD,wBAAwB,EAAE,oDAAoD;IAC9E,eAAe,EAAE,2CAA2C;IAC5D,QAAQ,EAAE,oCAAoC;IAC9C,OAAO,EAAE,gCAAgC;CACjC,CAAC;AAGX,sCAAsC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU,EAAE,8DAA8D;IAC1E,QAAQ,EAAE,+CAA+C;IACzD,UAAU,EAAE,+CAA+C;CACnD,CAAC;AAGX,gFAAgF;AAChF,aAAa;AACb,gFAAgF;AAEhF,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,6BAA6B;IAC1C,WAAW,EAAE,6BAA6B;IAC1C,YAAY,EAAE,uBAAuB;IACrC,WAAW,EAAE,iCAAiC;CACtC,CAAC;AAGX,qEAAqE;AACrE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,kDAAkD;IAC5D,WAAW,EAAE,wDAAwD;IACrE,YAAY,EAAE,0CAA0C;CAChD,CAAC;AAGX,oCAAoC;AACpC,MAAM,CAAC,MAAM,wBAAwB,GAAG;IAC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AA;AAAA,EACA,UAAA;AAAA;AAAA;AAAA,EAEA,YAAA;AAAA;AAAA,EACA,cAAA;AAAA;AAAA,EACA,UAAA;AAAA;AAAA,EACA,YAAA;AAAA;AAAA,EACA;AAAA;AACF","file":"api-enums.contract.js","sourcesContent":["/**\n * API Enum Contract Definitions\n *\n * Canonical enum values for all API-facing enumerations.\n * These are co-equal with MCP contracts as external contracts.\n * SDK types are DERIVED from these — not independently authored.\n *\n * CONTRACT SURFACE: Adding a new enum value is additive (non-breaking).\n * Removing or renaming an existing value is a BREAKING CHANGE.\n */\n\n// =============================================================================\n// BELIEF ENUMS\n// =============================================================================\n\n/** Fork reasons — why a scored belief was branched */\nexport const FORK_REASONS = [\n \"refinement\", // Belief text evolved based on new understanding\n \"contradiction_response\", // Created in response to a detected contradiction\n \"scope_change\", // Belief scope narrowed or broadened\n \"confidence_collapse\", // Confidence dropped below viability threshold\n \"manual\", // User-initiated fork without specific trigger\n] as const;\nexport type ForkReason = (typeof FORK_REASONS)[number];\n\n/** Confidence modulation triggers — what caused a confidence change */\nexport const CONFIDENCE_TRIGGERS = [\n \"evidence_added\", // New evidence bore on the belief\n \"contradiction_detected\", // A contradiction was flagged involving this belief\n \"merge_outcome\", // Merge scoring determined this confidence\n \"manual\", // User manually adjusted confidence\n \"decay\", // Time-based confidence erosion\n] as const;\nexport type ConfidenceTrigger = (typeof CONFIDENCE_TRIGGERS)[number];\n\n/** Belief status — lifecycle state */\nexport const BELIEF_STATUSES = [\n \"unscored\", // Draft — editable in worktree (on feature branch, pre-merge)\n \"scored\", // Merged — formulation frozen (merged to main)\n \"archived\", // Soft-deleted — preserved in history (git rm)\n] as const;\nexport type BeliefStatus = (typeof BELIEF_STATUSES)[number];\n\n// =============================================================================\n// EDGE ENUMS\n// =============================================================================\n\n/** Reasoning methods — how an edge relationship was determined */\nexport const REASONING_METHODS = [\n \"deductive\", // Logically entailed\n \"inductive\", // Generalized from instances\n \"abductive\", // Best explanation inference\n \"analogical\", // Reasoning by analogy\n \"empirical\", // Direct observation/measurement\n] as const;\nexport type ReasoningMethod = (typeof REASONING_METHODS)[number];\n\n/** Defeat types (Pollock taxonomy) — how a contradiction operates */\nexport const DEFEAT_TYPES = [\n \"rebuts\", // Direct contradiction — reasons for the negation\n \"undercuts\", // Breaks the inference link between evidence and belief\n \"undermines\", // Attacks a premise the belief depends on\n] as const;\nexport type DefeatType = (typeof DEFEAT_TYPES)[number];\n\n/** Contradiction severity levels */\nexport const CONTRADICTION_SEVERITIES = [\n \"low\", // Minor tension, may not require action\n \"medium\", // Moderate conflict, should be investigated\n \"high\", // Significant contradiction, likely needs resolution\n \"critical\", // Blocks progress — must be addressed before judgment\n] as const;\nexport type ContradictionSeverity = (typeof CONTRADICTION_SEVERITIES)[number];\n\n/** Contradiction resolution status */\nexport const CONTRADICTION_STATUSES = [\n \"unresolved\", // Open conflict — may persist indefinitely\n \"resolved\", // Conflict addressed (one belief forked, archived, or confidence adjusted)\n \"accepted\", // Explicitly accepted as irreconcilable — both beliefs maintained\n] as const;\nexport type ContradictionStatus = (typeof CONTRADICTION_STATUSES)[number];\n\n// =============================================================================\n// WORKTREE ENUMS (git worktree lifecycle)\n// =============================================================================\n\n/** Merge outcome types — how a worktree merge resolved */\nexport const MERGE_OUTCOMES = [\n \"validated\", // Beliefs confirmed — clean merge to main\n \"invalidated\", // Defeat recorded — confidence collapsed (merge with revert)\n \"forked\", // Beliefs split into competing versions (fork from merge point)\n \"inconclusive\", // Insufficient evidence — stashed (git stash)\n] as const;\nexport type MergeOutcome = (typeof MERGE_OUTCOMES)[number];\n\n/** Worktree phases — investigation lifecycle within a checked-out worktree */\nexport const WORKTREE_PHASES = [\n \"hypothesis\", // Form testable claims (write the code — commits)\n \"investigation\", // Collect evidence (run the tests — more commits)\n \"evaluation\", // Update credences (review the results — amend as needed)\n \"resolution\", // Determine outcome (merge to main, fork, or stash)\n] as const;\nexport type WorktreePhase = (typeof WORKTREE_PHASES)[number];\n\n// =============================================================================\n// BRANCH ENUMS (git branch lifecycle)\n// =============================================================================\n\n/** Branch status — thematic branch lifecycle */\nexport const BRANCH_STATUSES = [\n \"dormant\", // Branch exists but no active worktree (no one investigating)\n \"active\", // At least one worktree is investigating this branch\n \"archived\", // Branch retired — no longer a relevant thematic container\n] as const;\nexport type BranchStatus = (typeof BRANCH_STATUSES)[number];\n\n// =============================================================================\n// PULL REQUEST ENUMS (git pull request lifecycle)\n// =============================================================================\n\n/** Pull request status — review lifecycle before merge */\nexport const PULL_REQUEST_STATUSES = [\n \"pending_review\", // PR opened — awaiting reviewer feedback\n \"changes_requested\", // Reviewer requests changes before merge\n \"approved\", // Approved — ready to merge\n \"blocked\", // Blocked — cannot merge until contradiction is resolved\n] as const;\nexport type PullRequestStatus = (typeof PULL_REQUEST_STATUSES)[number];\n\n// =============================================================================\n// LAYER ENUMS\n// =============================================================================\n\n/** Epistemic layers — the hierarchy of knowledge */\nexport const EPISTEMIC_LAYERS = [\n \"L1\", // Source — the given (vendored deps)\n \"L2\", // Evidence — the interpreted (test suite)\n \"L3\", // Belief — the structural (source files)\n \"L4\", // Judgment — the committed (release tags)\n] as const;\nexport type EpistemicLayer = (typeof EPISTEMIC_LAYERS)[number];\n\n// =============================================================================\n// JUDGMENT ENUMS (Phase 1: new vocabulary)\n// =============================================================================\n\n/**\n * Judgment type — classification of the determination.\n *\n * Phase 1: These are new enum values for the Judgment (L4) vocabulary.\n * The existing code uses \"Decision\" — these are the forward-looking terms\n * that will eventually replace the Decision vocabulary (Phase 2-3).\n */\nexport const JUDGMENT_TYPES = [\n \"investment_thesis\", // Judgment on an investment opportunity\n \"thesis_maturity\", // Judgment that a thesis is ready for IC presentation\n \"contradiction_ruling\", // Judgment on how to handle an irreconcilable contradiction\n \"scope_determination\", // Judgment that defines or redefines investigation scope\n \"confidence_ruling\", // Judgment that overrides automated confidence for policy reasons\n] as const;\nexport type JudgmentType = (typeof JUDGMENT_TYPES)[number];\n\n// =============================================================================\n// SUPPORT RELATION ENUMS\n// =============================================================================\n\n/** Core edge types used in the Integration Surfaces */\nexport const INTEGRATION_EDGE_TYPES = [\n // Support relations\n \"informs\", // Evidence bears on a belief (weight = direction/strength)\n \"grounds\", // Source provides raw basis for evidence\n \"answers\", // Evidence or belief resolves a question\n // Defeat relations (Pollock) — weight carries direction\n \"contradicts\", // Rebuts — direct contradiction\n \"supports\", // Weight carries valence (negative = weakens/undercuts)\n // Structural relations\n \"depends_on\", // Belief B requires Belief A\n \"derived_from\", // Provenance lineage\n \"contains\", // Hierarchical containment\n \"supersedes\", // New version replaces old (lineage)\n \"tests\", // Question tests a belief\n] as const;\nexport type IntegrationEdgeType = (typeof INTEGRATION_EDGE_TYPES)[number];\n"]}
@@ -0,0 +1,2 @@
1
+ export { AuthContext, LucernSdkClient, McpTransportKind, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, SessionAuditEnvelope, SessionAuditOutcome, SessionAuthMode, SessionDelegationHop, SessionLifecycleStatus, SessionPrincipalType, inferSessionPrincipalType, lastDelegator, normalizeDelegationChain } from './auth.contract.js';
2
+ import './convex-admin.contract.js';
@@ -0,0 +1,48 @@
1
+ // src/auth.contract.ts
2
+ var SESSION_AUTH_MODES = [
3
+ "interactive_user",
4
+ "service_principal",
5
+ "tenant_api_key",
6
+ "session_token"
7
+ ];
8
+ var SESSION_PRINCIPAL_TYPES = ["human", "service", "agent"];
9
+ var SESSION_LIFECYCLE_STATUSES = [
10
+ "active",
11
+ "expired",
12
+ "revoked"
13
+ ];
14
+ function inferSessionPrincipalType(principalId) {
15
+ if (principalId.startsWith("user:")) {
16
+ return "human";
17
+ }
18
+ if (principalId.startsWith("agent:")) {
19
+ return "agent";
20
+ }
21
+ return "service";
22
+ }
23
+ function normalizeDelegationChain(args) {
24
+ if (args.delegationChain && args.delegationChain.length > 0) {
25
+ return [...args.delegationChain];
26
+ }
27
+ if (!args.delegatedBy) {
28
+ return;
29
+ }
30
+ return [
31
+ {
32
+ principalId: args.delegatedBy,
33
+ principalType: args.delegatedByType ?? inferSessionPrincipalType(args.delegatedBy),
34
+ delegatedAt: args.delegatedAt,
35
+ reason: args.reason
36
+ }
37
+ ];
38
+ }
39
+ function lastDelegator(delegationChain) {
40
+ if (!delegationChain || delegationChain.length === 0) {
41
+ return;
42
+ }
43
+ return delegationChain[delegationChain.length - 1]?.principalId;
44
+ }
45
+
46
+ export { SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, inferSessionPrincipalType, lastDelegator, normalizeDelegationChain };
47
+ //# sourceMappingURL=auth-context.contract.js.map
48
+ //# sourceMappingURL=auth-context.contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/auth.contract.ts"],"names":[],"mappings":";AAgBO,IAAM,kBAAA,GAAqB;AAAA,EAChC,kBAAA;AAAA,EACA,mBAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF;AAGO,IAAM,uBAAA,GAA0B,CAAC,OAAA,EAAS,SAAA,EAAW,OAAO;AAG5D,IAAM,0BAAA,GAA6B;AAAA,EACxC,QAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF;AA2CO,SAAS,0BACd,WAAA,EACsB;AACtB,EAAA,IAAI,WAAA,CAAY,UAAA,CAAW,OAAO,CAAA,EAAG;AACnC,IAAA,OAAO,OAAA;AAAA,EACT;AACA,EAAA,IAAI,WAAA,CAAY,UAAA,CAAW,QAAQ,CAAA,EAAG;AACpC,IAAA,OAAO,OAAA;AAAA,EACT;AACA,EAAA,OAAO,SAAA;AACT;AAEO,SAAS,yBAAyB,IAAA,EAMF;AACrC,EAAA,IAAI,IAAA,CAAK,eAAA,IAAmB,IAAA,CAAK,eAAA,CAAgB,SAAS,CAAA,EAAG;AAC3D,IAAA,OAAO,CAAC,GAAG,IAAA,CAAK,eAAe,CAAA;AAAA,EACjC;AACA,EAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACrB,IAAA;AAAA,EACF;AACA,EAAA,OAAO;AAAA,IACL;AAAA,MACE,aAAa,IAAA,CAAK,WAAA;AAAA,MAClB,aAAA,EACE,IAAA,CAAK,eAAA,IAAmB,yBAAA,CAA0B,KAAK,WAAW,CAAA;AAAA,MACpE,aAAa,IAAA,CAAK,WAAA;AAAA,MAClB,QAAQ,IAAA,CAAK;AAAA;AACf,GACF;AACF;AAEO,SAAS,cACd,eAAA,EACoB;AACpB,EAAA,IAAI,CAAC,eAAA,IAAmB,eAAA,CAAgB,MAAA,KAAW,CAAA,EAAG;AACpD,IAAA;AAAA,EACF;AACA,EAAA,OAAO,eAAA,CAAgB,eAAA,CAAgB,MAAA,GAAS,CAAC,CAAA,EAAG,WAAA;AACtD","file":"auth-context.contract.js","sourcesContent":["/**\n * @lucern/contracts — auth (canonical support contract)\n *\n * Consolidated flat support surface for Lucern authentication:\n * - Session primitives (auth modes, principal types, lifecycle)\n * - AuthContext shape + McpTransportKind + LucernSdkClient alias\n *\n * Consolidated from src/auth-session.contract.ts and src/auth-context.contract.ts\n * in EK-16 T1 PR 3a. Compat shims remain at both old paths until Lucern 1.0.0 (D12).\n */\n\n// =============================================================================\n// SESSION PRIMITIVES\n// (Formerly src/auth-session.contract.ts)\n// =============================================================================\n\nexport const SESSION_AUTH_MODES = [\n \"interactive_user\",\n \"service_principal\",\n \"tenant_api_key\",\n \"session_token\",\n] as const;\nexport type SessionAuthMode = (typeof SESSION_AUTH_MODES)[number];\n\nexport const SESSION_PRINCIPAL_TYPES = [\"human\", \"service\", \"agent\"] as const;\nexport type SessionPrincipalType = (typeof SESSION_PRINCIPAL_TYPES)[number];\n\nexport const SESSION_LIFECYCLE_STATUSES = [\n \"active\",\n \"expired\",\n \"revoked\",\n] as const;\nexport type SessionLifecycleStatus =\n (typeof SESSION_LIFECYCLE_STATUSES)[number];\n\nexport type SessionDelegationHop = {\n principalId: string;\n principalType: SessionPrincipalType;\n authMode?: SessionAuthMode;\n sessionId?: string;\n delegatedAt?: number;\n reason?: string;\n};\n\nexport type SessionAuditOutcome =\n | \"accepted\"\n | \"rejected\"\n | \"revoked\"\n | \"expired\";\n\nexport type SessionAuditEnvelope = {\n sessionId: string;\n authMode: SessionAuthMode;\n principalId: string;\n principalType: SessionPrincipalType;\n tenantId: string;\n workspaceId?: string;\n apiKeyId?: string;\n scopes: readonly string[];\n roles?: readonly string[];\n delegationChain?: readonly SessionDelegationHop[];\n sourceSessionId?: string;\n expiresAt?: number;\n request?: {\n endpoint?: string;\n method?: string;\n correlationId?: string;\n };\n result?: {\n outcome: SessionAuditOutcome;\n reason?: string;\n };\n};\n\nexport function inferSessionPrincipalType(\n principalId: string\n): SessionPrincipalType {\n if (principalId.startsWith(\"user:\")) {\n return \"human\";\n }\n if (principalId.startsWith(\"agent:\")) {\n return \"agent\";\n }\n return \"service\";\n}\n\nexport function normalizeDelegationChain(args: {\n delegationChain?: readonly SessionDelegationHop[];\n delegatedBy?: string;\n delegatedByType?: SessionPrincipalType;\n delegatedAt?: number;\n reason?: string;\n}): SessionDelegationHop[] | undefined {\n if (args.delegationChain && args.delegationChain.length > 0) {\n return [...args.delegationChain];\n }\n if (!args.delegatedBy) {\n return;\n }\n return [\n {\n principalId: args.delegatedBy,\n principalType:\n args.delegatedByType ?? inferSessionPrincipalType(args.delegatedBy),\n delegatedAt: args.delegatedAt,\n reason: args.reason,\n },\n ];\n}\n\nexport function lastDelegator(\n delegationChain?: readonly SessionDelegationHop[]\n): string | undefined {\n if (!delegationChain || delegationChain.length === 0) {\n return;\n }\n return delegationChain[delegationChain.length - 1]?.principalId;\n}\n\n// =============================================================================\n// AUTH CONTEXT\n// (Formerly src/auth-context.contract.ts)\n// =============================================================================\n\nimport type { ConvexAdminClient } from \"./convex-admin.contract\";\n\nexport type McpTransportKind = \"stdio\" | \"hosted\";\n\nexport type LucernSdkClient = unknown;\n\n/**\n * Session authentication context — injected by withAuth() middleware.\n *\n * Built from TenantConfig at dispatch time. Agent sessions get\n * AGENT_IDENTITY + \"agent:internal\" role + unrestricted access.\n * User sessions get Clerk userId + resolved role + tool ACLs.\n */\nexport type AuthContext = {\n sessionType: \"agent\" | \"user\";\n userId: string; // AGENT_IDENTITY for agents, Clerk userId for users\n tenantId: string;\n role: string; // \"agent:internal\" | \"platform_admin\" | \"tenant_admin\" | \"editor\" | \"viewer\" | ...\n allowedTopics: string[] | null; // null = unrestricted (agents, admins). Block 11D populates this.\n // Layer 2a: Group-pack binding — resolved at boot from MC resolveUserPackAccess\n groupIds: string[]; // Groups this user belongs to (empty for agents)\n permittedPackKeys: string[]; // Packs accessible via group assignments (empty = no pack filtering)\n sessionId: string; // S2-13K: MCP process session UUID for audit attribution\n principalId?: string;\n principalType?: SessionPrincipalType;\n workspaceId?: string;\n scopes?: string[];\n authMode?: SessionAuthMode;\n roles?: string[];\n transportKind?: McpTransportKind;\n lucernClient?: LucernSdkClient;\n convex?: ConvexAdminClient;\n setDefaultScopeContext?: (scopeId: string) => Promise<unknown>;\n matchesWorkspaceReasoningScope?: (\n node: unknown,\n scope: unknown\n ) => boolean;\n};\n"]}
@@ -1,54 +1,2 @@
1
- /**
2
- * Session + Delegation Contract
3
- *
4
- * Canonical session lifecycle vocabulary shared by platform gateway auth,
5
- * hosted MCP auth, Master Control persistence, and SDK session tokens.
6
- */
7
- export declare const SESSION_AUTH_MODES: readonly ["interactive_user", "service_principal", "tenant_api_key", "session_token"];
8
- export type SessionAuthMode = (typeof SESSION_AUTH_MODES)[number];
9
- export declare const SESSION_PRINCIPAL_TYPES: readonly ["human", "service", "agent"];
10
- export type SessionPrincipalType = (typeof SESSION_PRINCIPAL_TYPES)[number];
11
- export declare const SESSION_LIFECYCLE_STATUSES: readonly ["active", "expired", "revoked"];
12
- export type SessionLifecycleStatus = (typeof SESSION_LIFECYCLE_STATUSES)[number];
13
- export type SessionDelegationHop = {
14
- principalId: string;
15
- principalType: SessionPrincipalType;
16
- authMode?: SessionAuthMode;
17
- sessionId?: string;
18
- delegatedAt?: number;
19
- reason?: string;
20
- };
21
- export type SessionAuditOutcome = "accepted" | "rejected" | "revoked" | "expired";
22
- export type SessionAuditEnvelope = {
23
- sessionId: string;
24
- authMode: SessionAuthMode;
25
- principalId: string;
26
- principalType: SessionPrincipalType;
27
- tenantId: string;
28
- workspaceId?: string;
29
- apiKeyId?: string;
30
- scopes: readonly string[];
31
- roles?: readonly string[];
32
- delegationChain?: readonly SessionDelegationHop[];
33
- sourceSessionId?: string;
34
- expiresAt?: number;
35
- request?: {
36
- endpoint?: string;
37
- method?: string;
38
- correlationId?: string;
39
- };
40
- result?: {
41
- outcome: SessionAuditOutcome;
42
- reason?: string;
43
- };
44
- };
45
- export declare function inferSessionPrincipalType(principalId: string): SessionPrincipalType;
46
- export declare function normalizeDelegationChain(args: {
47
- delegationChain?: readonly SessionDelegationHop[];
48
- delegatedBy?: string;
49
- delegatedByType?: SessionPrincipalType;
50
- delegatedAt?: number;
51
- reason?: string;
52
- }): SessionDelegationHop[] | undefined;
53
- export declare function lastDelegator(delegationChain?: readonly SessionDelegationHop[]): string | undefined;
54
- //# sourceMappingURL=auth-session.contract.d.ts.map
1
+ export { AuthContext, LucernSdkClient, McpTransportKind, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, SessionAuditEnvelope, SessionAuditOutcome, SessionAuthMode, SessionDelegationHop, SessionLifecycleStatus, SessionPrincipalType, inferSessionPrincipalType, lastDelegator, normalizeDelegationChain } from './auth.contract.js';
2
+ import './convex-admin.contract.js';