@lucern/contracts 0.3.0-alpha.17 → 0.3.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -10
- package/dist/api-enums.contract.d.ts +3 -5
- package/dist/api-enums.contract.js +12 -14
- package/dist/api-enums.contract.js.map +1 -1
- package/dist/auth-context.contract.js +2 -14
- package/dist/auth-context.contract.js.map +1 -1
- package/dist/auth-session.contract.js +2 -14
- package/dist/auth-session.contract.js.map +1 -1
- package/dist/auth.contract.d.ts +1 -1
- package/dist/auth.contract.js +2 -14
- package/dist/auth.contract.js.map +1 -1
- package/dist/context-pack.contract.d.ts +3 -5
- package/dist/context-pack.contract.js.map +1 -1
- package/dist/{defineTable-t1wr5wgn.d.ts → defineTable-CBQ03FXl.d.ts} +1 -1
- package/dist/{dsl-DVPthQGY.d.ts → dsl-BgpoVOVQ.d.ts} +2 -2
- package/dist/dsl.d.ts +2 -2
- package/dist/dsl.js +4 -1
- package/dist/dsl.js.map +1 -1
- package/dist/function-registry/beliefs.d.ts +51 -64
- package/dist/function-registry/beliefs.js +57 -817
- package/dist/function-registry/beliefs.js.map +1 -1
- package/dist/function-registry/coding.d.ts +6 -15
- package/dist/function-registry/coding.js +43 -866
- package/dist/function-registry/coding.js.map +1 -1
- package/dist/function-registry/context.d.ts +16 -22
- package/dist/function-registry/context.js +46 -805
- package/dist/function-registry/context.js.map +1 -1
- package/dist/function-registry/contracts.d.ts +3 -9
- package/dist/function-registry/contracts.js +39 -770
- package/dist/function-registry/contracts.js.map +1 -1
- package/dist/function-registry/coordination.d.ts +9 -21
- package/dist/function-registry/coordination.js +39 -770
- package/dist/function-registry/coordination.js.map +1 -1
- package/dist/function-registry/edges.d.ts +2 -167
- package/dist/function-registry/edges.js +71 -978
- package/dist/function-registry/edges.js.map +1 -1
- package/dist/function-registry/evidence.d.ts +41 -52
- package/dist/function-registry/evidence.js +62 -826
- package/dist/function-registry/evidence.js.map +1 -1
- package/dist/function-registry/graph.d.ts +66 -162
- package/dist/function-registry/graph.js +46 -886
- package/dist/function-registry/graph.js.map +1 -1
- package/dist/function-registry/helpers.d.ts +4 -7
- package/dist/function-registry/helpers.js +40 -771
- package/dist/function-registry/helpers.js.map +1 -1
- package/dist/function-registry/identity.d.ts +16 -62
- package/dist/function-registry/identity.js +45 -793
- package/dist/function-registry/identity.js.map +1 -1
- package/dist/function-registry/index.d.ts +3 -5
- package/dist/function-registry/index.js +43 -777
- package/dist/function-registry/index.js.map +1 -1
- package/dist/function-registry/judgments.d.ts +11 -16
- package/dist/function-registry/judgments.js +42 -782
- package/dist/function-registry/judgments.js.map +1 -1
- package/dist/function-registry/legacy.d.ts +1 -5
- package/dist/function-registry/legacy.js +39 -770
- package/dist/function-registry/legacy.js.map +1 -1
- package/dist/function-registry/lenses.d.ts +21 -28
- package/dist/function-registry/lenses.js +42 -793
- package/dist/function-registry/lenses.js.map +1 -1
- package/dist/function-registry/manifest.d.ts +6 -6
- package/dist/function-registry/manifest.js +2 -19
- package/dist/function-registry/manifest.js.map +1 -1
- package/dist/function-registry/ontologies.d.ts +56 -70
- package/dist/function-registry/ontologies.js +45 -788
- package/dist/function-registry/ontologies.js.map +1 -1
- package/dist/function-registry/pipeline.d.ts +16 -22
- package/dist/function-registry/pipeline.js +42 -779
- package/dist/function-registry/pipeline.js.map +1 -1
- package/dist/function-registry/questions.d.ts +61 -76
- package/dist/function-registry/questions.js +52 -869
- package/dist/function-registry/questions.js.map +1 -1
- package/dist/function-registry/tasks.d.ts +21 -28
- package/dist/function-registry/tasks.js +48 -845
- package/dist/function-registry/tasks.js.map +1 -1
- package/dist/function-registry/topics.d.ts +26 -114
- package/dist/function-registry/topics.js +43 -852
- package/dist/function-registry/topics.js.map +1 -1
- package/dist/function-registry/types.d.ts +3 -7
- package/dist/function-registry/worktrees.d.ts +51 -104
- package/dist/function-registry/worktrees.js +51 -925
- package/dist/function-registry/worktrees.js.map +1 -1
- package/dist/gateway.contract.d.ts +0 -6
- package/dist/gateway.contract.js.map +1 -1
- package/dist/generated/convexSchemas.d.ts +3 -3
- package/dist/generated/convexSchemas.js +18 -39
- package/dist/generated/convexSchemas.js.map +1 -1
- package/dist/generated/schema-manifest.json +98 -1244
- package/dist/generated/tableOwnership.d.ts +28 -49
- package/dist/generated/tableOwnership.js +26 -68
- package/dist/generated/tableOwnership.js.map +1 -1
- package/dist/generated/tier-expectations.json +9 -66
- package/dist/graph-types/index.d.ts +1 -5
- package/dist/graph-types/index.js +4 -15
- package/dist/graph-types/index.js.map +1 -1
- package/dist/index-CV-0_VWJ.d.ts +25 -0
- package/dist/index.d.ts +414 -30
- package/dist/index.js +342 -35266
- package/dist/index.js.map +1 -1
- package/dist/lens-filter.contract.js +3 -4
- package/dist/lens-filter.contract.js.map +1 -1
- package/dist/lens-workflow.contract.js +3 -4
- package/dist/lens-workflow.contract.js.map +1 -1
- package/dist/schema-helpers/enumValidation.js +5 -2
- package/dist/schema-helpers/enumValidation.js.map +1 -1
- package/dist/schema-helpers/spine/nodes/decision.js +1 -2
- 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/schemas/component-table-manifest.d.ts +6 -6
- package/dist/schemas/component-table-manifest.js +2 -2
- package/dist/schemas/component-table-manifest.js.map +1 -1
- package/dist/schemas/enums.d.ts +2 -5
- package/dist/schemas/enums.js +2 -5
- package/dist/schemas/enums.js.map +1 -1
- package/dist/schemas/index.d.ts +3 -3
- package/dist/schemas/index.js +139 -1165
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/manifest.d.ts +932 -3042
- package/dist/schemas/manifest.js +137 -1163
- package/dist/schemas/manifest.js.map +1 -1
- package/dist/schemas/sl-opinion.d.ts +4 -4
- package/dist/schemas/tables/{controlPlane → identity}/agent.d.ts +1 -1
- package/dist/schemas/tables/{controlPlane → identity}/agent.js +3 -3
- package/dist/schemas/tables/identity/agent.js.map +1 -0
- package/dist/schemas/tables/{controlPlane → identity}/epistemic.d.ts +1 -1
- package/dist/schemas/tables/{controlPlane → identity}/epistemic.js +3 -3
- package/dist/schemas/tables/identity/epistemic.js.map +1 -0
- package/dist/schemas/tables/{controlPlane → identity}/model.d.ts +1 -1
- package/dist/schemas/tables/{controlPlane → identity}/model.js +6 -6
- package/dist/schemas/tables/identity/model.js.map +1 -0
- package/dist/schemas/tables/{controlPlane → identity}/platform.d.ts +11 -11
- package/dist/schemas/tables/{controlPlane → identity}/platform.js +18 -18
- package/dist/schemas/tables/identity/platform.js.map +1 -0
- package/dist/schemas/tables/{controlPlane → identity}/project.d.ts +1 -1
- package/dist/schemas/tables/{controlPlane → identity}/project.js +3 -3
- package/dist/schemas/tables/identity/project.js.map +1 -0
- package/dist/schemas/tables/{controlPlane → identity}/user.d.ts +1 -1
- package/dist/schemas/tables/{controlPlane → identity}/user.js +3 -3
- package/dist/schemas/tables/identity/user.js.map +1 -0
- package/dist/schemas/tables/kernel/config.d.ts +1 -1
- package/dist/schemas/tables/kernel/config.js.map +1 -1
- package/dist/schemas/tables/kernel/coordination.d.ts +1 -1
- package/dist/schemas/tables/kernel/coordination.js.map +1 -1
- package/dist/schemas/tables/kernel/decision.d.ts +1 -1
- package/dist/schemas/tables/kernel/decision.js.map +1 -1
- package/dist/schemas/tables/kernel/embedding.d.ts +1 -1
- package/dist/schemas/tables/kernel/embedding.js.map +1 -1
- package/dist/schemas/tables/kernel/epistemic.d.ts +7 -7
- package/dist/schemas/tables/kernel/epistemic.js.map +1 -1
- package/dist/schemas/tables/kernel/idempotency.d.ts +1 -1
- package/dist/schemas/tables/kernel/idempotency.js.map +1 -1
- package/dist/schemas/tables/kernel/infra.d.ts +5 -5
- package/dist/schemas/tables/kernel/infra.js.map +1 -1
- package/dist/schemas/tables/kernel/intelligence.d.ts +11 -11
- package/dist/schemas/tables/kernel/intelligence.js.map +1 -1
- package/dist/schemas/tables/kernel/lens.d.ts +5 -5
- package/dist/schemas/tables/kernel/lens.js.map +1 -1
- package/dist/schemas/tables/kernel/ontology.d.ts +1 -1
- package/dist/schemas/tables/kernel/ontology.js.map +1 -1
- package/dist/schemas/tables/kernel/platform.d.ts +13 -13
- package/dist/schemas/tables/kernel/platform.js.map +1 -1
- package/dist/schemas/tables/kernel/spine.d.ts +4 -5
- package/dist/schemas/tables/kernel/spine.js +2 -6
- package/dist/schemas/tables/kernel/spine.js.map +1 -1
- package/dist/schemas/tables/kernel/task.d.ts +43 -43
- package/dist/schemas/tables/kernel/task.js.map +1 -1
- package/dist/schemas/tables/kernel/topic.d.ts +1 -1
- package/dist/schemas/tables/kernel/topic.js +1 -5
- package/dist/schemas/tables/kernel/topic.js.map +1 -1
- package/dist/schemas/tables/kernel/workflow.d.ts +1 -1
- package/dist/schemas/tables/kernel/workflow.js.map +1 -1
- package/dist/schemas/tables/kernel/worktree.d.ts +55 -55
- package/dist/schemas/tables/kernel/worktree.js.map +1 -1
- package/dist/schemas/tables/mc/identity.d.ts +4 -44
- package/dist/schemas/tables/mc/identity.js +1 -66
- package/dist/schemas/tables/mc/identity.js.map +1 -1
- package/dist/schemas/tables/mc/methodology.d.ts +1 -1
- package/dist/schemas/tables/mc/methodology.js.map +1 -1
- package/dist/schemas/tables/mc/pack.d.ts +21 -21
- package/dist/schemas/tables/mc/pack.js.map +1 -1
- package/dist/schemas/tables/mc/policy.d.ts +2 -2
- package/dist/schemas/tables/mc/policy.js +1 -1
- package/dist/schemas/tables/mc/policy.js.map +1 -1
- package/dist/schemas/tables/mc/registry.d.ts +5 -5
- package/dist/schemas/tables/mc/registry.js.map +1 -1
- package/dist/schemas/tables/mc/runtime.d.ts +3 -109
- package/dist/schemas/tables/mc/runtime.js +104 -330
- package/dist/schemas/tables/mc/runtime.js.map +1 -1
- package/dist/schemas/tables/mc/tenant.d.ts +2 -4
- package/dist/schemas/tables/mc/tenant.js +1 -3
- package/dist/schemas/tables/mc/tenant.js.map +1 -1
- package/dist/schemas/tables/mc/workspace.d.ts +5 -28
- package/dist/schemas/tables/mc/workspace.js +2 -36
- package/dist/schemas/tables/mc/workspace.js.map +1 -1
- package/dist/sdk-methods.contract.d.ts +2 -2
- package/dist/{sdk-tools.contract-CKmSsrZ2.d.ts → sdk-tools.contract-S4ia0TTo.d.ts} +2 -2
- package/dist/sdk-tools.contract.d.ts +2 -2
- package/dist/sdk-tools.contract.js +27 -719
- package/dist/sdk-tools.contract.js.map +1 -1
- package/dist/{tool-contracts-C_xvM9q2.d.ts → tool-contracts-C92-9ueT.d.ts} +2 -38
- package/dist/tool-contracts.d.ts +1 -1
- package/dist/tool-contracts.js +28 -720
- package/dist/tool-contracts.js.map +1 -1
- package/package.json +1 -30
- package/dist/component-boundary.contract.d.ts +0 -14
- package/dist/component-boundary.contract.js +0 -175
- package/dist/component-boundary.contract.js.map +0 -1
- package/dist/component-host-boundary.contract.d.ts +0 -46
- package/dist/component-host-boundary.contract.js +0 -60
- package/dist/component-host-boundary.contract.js.map +0 -1
- package/dist/edge-policy-manifest-Dw5IhT1L.d.ts +0 -133
- package/dist/function-registry/nodes.d.ts +0 -412
- package/dist/function-registry/nodes.js +0 -5354
- package/dist/function-registry/nodes.js.map +0 -1
- package/dist/function-registry-input-audit.d.ts +0 -13
- package/dist/function-registry-input-audit.js +0 -166
- package/dist/function-registry-input-audit.js.map +0 -1
- package/dist/generated/infisicalRuntimeEnv.d.ts +0 -70
- package/dist/generated/infisicalRuntimeEnv.js +0 -27345
- package/dist/generated/infisicalRuntimeEnv.js.map +0 -1
- package/dist/generated/lucernGatewayEnv.d.ts +0 -17
- package/dist/generated/lucernGatewayEnv.js +0 -38
- package/dist/generated/lucernGatewayEnv.js.map +0 -1
- package/dist/generated/lucernWebPublicEnv.d.ts +0 -26
- package/dist/generated/lucernWebPublicEnv.js +0 -32
- package/dist/generated/lucernWebPublicEnv.js.map +0 -1
- package/dist/generated/lucernWebServerEnv.d.ts +0 -33
- package/dist/generated/lucernWebServerEnv.js +0 -51
- package/dist/generated/lucernWebServerEnv.js.map +0 -1
- package/dist/graph-intelligence.contract.d.ts +0 -506
- package/dist/graph-intelligence.contract.js +0 -595
- package/dist/graph-intelligence.contract.js.map +0 -1
- package/dist/index-CM1Pl_vI.d.ts +0 -28
- package/dist/infisical-runtime.contract.d.ts +0 -1889
- package/dist/infisical-runtime.contract.js +0 -3235
- package/dist/infisical-runtime.contract.js.map +0 -1
- package/dist/manifests/edge-policy-manifest.d.ts +0 -2
- package/dist/manifests/edge-policy-manifest.data.d.ts +0 -13
- package/dist/manifests/edge-policy-manifest.data.js +0 -26
- package/dist/manifests/edge-policy-manifest.data.js.map +0 -1
- package/dist/manifests/edge-policy-manifest.js +0 -92
- package/dist/manifests/edge-policy-manifest.js.map +0 -1
- package/dist/manifests/infisical-runtime-manifest.d.ts +0 -1792
- package/dist/manifests/infisical-runtime-manifest.js +0 -3090
- package/dist/manifests/infisical-runtime-manifest.js.map +0 -1
- package/dist/manifests/invariant-manifest.d.ts +0 -65
- package/dist/manifests/invariant-manifest.js +0 -18
- package/dist/manifests/invariant-manifest.js.map +0 -1
- package/dist/manifests/invariants/ast-utils.d.ts +0 -14
- package/dist/manifests/invariants/ast-utils.js +0 -54
- package/dist/manifests/invariants/ast-utils.js.map +0 -1
- package/dist/manifests/invariants/index.d.ts +0 -15
- package/dist/manifests/invariants/index.js +0 -183
- package/dist/manifests/invariants/index.js.map +0 -1
- package/dist/manifests/invariants/inv-1-beliefs-append-only.d.ts +0 -12
- package/dist/manifests/invariants/inv-1-beliefs-append-only.js +0 -94
- package/dist/manifests/invariants/inv-1-beliefs-append-only.js.map +0 -1
- package/dist/manifests/invariants/inv-14-no-silent-transitions.d.ts +0 -12
- package/dist/manifests/invariants/inv-14-no-silent-transitions.js +0 -99
- package/dist/manifests/invariants/inv-14-no-silent-transitions.js.map +0 -1
- package/dist/manifests/invariants/manifest-1-projections-declare-audit.d.ts +0 -12
- package/dist/manifests/invariants/manifest-1-projections-declare-audit.js +0 -42
- package/dist/manifests/invariants/manifest-1-projections-declare-audit.js.map +0 -1
- package/dist/manifests/tenant-client-manifest.d.ts +0 -327
- package/dist/manifests/tenant-client-manifest.js +0 -449
- package/dist/manifests/tenant-client-manifest.js.map +0 -1
- package/dist/mcp-gateway-boundary.contract.d.ts +0 -201
- package/dist/mcp-gateway-boundary.contract.js +0 -45
- package/dist/mcp-gateway-boundary.contract.js.map +0 -1
- package/dist/permit-principal-projection.contract.d.ts +0 -74
- package/dist/permit-principal-projection.contract.js +0 -167
- package/dist/permit-principal-projection.contract.js.map +0 -1
- package/dist/projections/check-convex-args-shape.d.ts +0 -3
- package/dist/projections/check-convex-args-shape.js +0 -403
- package/dist/projections/check-convex-args-shape.js.map +0 -1
- package/dist/projections/create-evidence.projection.d.ts +0 -176
- package/dist/projections/create-evidence.projection.js +0 -130
- package/dist/projections/create-evidence.projection.js.map +0 -1
- package/dist/projections/index.d.ts +0 -102
- package/dist/projections/index.js +0 -352
- package/dist/projections/index.js.map +0 -1
- package/dist/projections/list-beliefs.projection.d.ts +0 -36
- package/dist/projections/list-beliefs.projection.js +0 -54
- package/dist/projections/list-beliefs.projection.js.map +0 -1
- package/dist/projections/list-tasks.projection.d.ts +0 -44
- package/dist/projections/list-tasks.projection.js +0 -57
- package/dist/projections/list-tasks.projection.js.map +0 -1
- package/dist/projections/modulate-confidence.projection.d.ts +0 -219
- package/dist/projections/modulate-confidence.projection.js +0 -148
- package/dist/projections/modulate-confidence.projection.js.map +0 -1
- package/dist/projections/projection-dsl.d.ts +0 -11
- package/dist/projections/projection-dsl.js +0 -8
- package/dist/projections/projection-dsl.js.map +0 -1
- package/dist/proof-attestation.json +0 -45
- package/dist/schemas/tables/controlPlane/accessControl.d.ts +0 -260
- package/dist/schemas/tables/controlPlane/accessControl.js +0 -658
- package/dist/schemas/tables/controlPlane/accessControl.js.map +0 -1
- package/dist/schemas/tables/controlPlane/agent.js.map +0 -1
- package/dist/schemas/tables/controlPlane/epistemic.js.map +0 -1
- package/dist/schemas/tables/controlPlane/model.js.map +0 -1
- package/dist/schemas/tables/controlPlane/platform.js.map +0 -1
- package/dist/schemas/tables/controlPlane/project.js.map +0 -1
- package/dist/schemas/tables/controlPlane/user.js.map +0 -1
- package/dist/schemas/tables/kernel/events.d.ts +0 -21
- package/dist/schemas/tables/kernel/events.js +0 -43
- package/dist/schemas/tables/kernel/events.js.map +0 -1
- package/dist/tenant-bootstrap-seed.contract.d.ts +0 -1289
- package/dist/tenant-bootstrap-seed.contract.js +0 -764
- package/dist/tenant-bootstrap-seed.contract.js.map +0 -1
- package/dist/tenant-bootstrap-seed.defaults.d.ts +0 -16
- package/dist/tenant-bootstrap-seed.defaults.js +0 -321
- package/dist/tenant-bootstrap-seed.defaults.js.map +0 -1
- package/dist/tenant-client.contract.d.ts +0 -354
- package/dist/tenant-client.contract.js +0 -505
- package/dist/tenant-client.contract.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
All notable changes to `@lucern/contracts` are tracked in this repository.
|
|
4
|
-
|
|
5
|
-
## [0.3.0-alpha.16] - 2026-05-14
|
|
6
|
-
- Adds the exact-row reasoning-kernel migration surface required for tenant identity/scope repairs.
|
|
7
|
-
- Keeps the coherent Lucern package line aligned for StackOS and reasoning-environment adoption.
|
|
8
|
-
|
|
9
|
-
## [0.3.0-alpha.7] - 2026-05-03
|
|
10
|
-
- Rebuild the coherent Lucern package line after Campaign 1 SDK hardening fixes.
|
|
11
|
-
|
|
12
|
-
## [0.3.0-alpha.17] - 2026-05-19
|
|
13
|
-
- Release notes pending.
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/** Reasoning methods supported by the kernel edge schema. */
|
|
2
|
-
declare const REASONING_METHODS: readonly ["deductive", "inductive", "abductive", "analogical", "causal", "correlational", "testimonial", "statistical", "implicit", "pattern_match"];
|
|
3
|
-
type ReasoningMethod = (typeof REASONING_METHODS)[number];
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* API Enum Contract Definitions
|
|
7
3
|
*
|
|
@@ -21,7 +17,9 @@ type ConfidenceTrigger = (typeof CONFIDENCE_TRIGGERS)[number];
|
|
|
21
17
|
/** Belief status — lifecycle state */
|
|
22
18
|
declare const BELIEF_STATUSES: readonly ["unscored", "scored", "archived"];
|
|
23
19
|
type BeliefStatus = (typeof BELIEF_STATUSES)[number];
|
|
24
|
-
|
|
20
|
+
/** Reasoning methods — how an edge relationship was determined */
|
|
21
|
+
declare const REASONING_METHODS: readonly ["deductive", "inductive", "abductive", "analogical", "empirical"];
|
|
22
|
+
type ReasoningMethod = (typeof REASONING_METHODS)[number];
|
|
25
23
|
/** Defeat types (Pollock taxonomy) — how a contradiction operates */
|
|
26
24
|
declare const DEFEAT_TYPES: readonly ["rebuts", "undercuts", "undermines"];
|
|
27
25
|
type DefeatType = (typeof DEFEAT_TYPES)[number];
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
// src/types/reasoning-method.ts
|
|
2
|
-
var REASONING_METHODS = [
|
|
3
|
-
"deductive",
|
|
4
|
-
"inductive",
|
|
5
|
-
"abductive",
|
|
6
|
-
"analogical",
|
|
7
|
-
"causal",
|
|
8
|
-
"correlational",
|
|
9
|
-
"testimonial",
|
|
10
|
-
"statistical",
|
|
11
|
-
"implicit",
|
|
12
|
-
"pattern_match"
|
|
13
|
-
];
|
|
14
|
-
|
|
15
1
|
// src/api-enums.contract.ts
|
|
16
2
|
var FORK_REASONS = [
|
|
17
3
|
"refinement",
|
|
@@ -59,6 +45,18 @@ var BELIEF_STATUSES = [
|
|
|
59
45
|
"archived"
|
|
60
46
|
// Soft-deleted — preserved in history (git rm)
|
|
61
47
|
];
|
|
48
|
+
var REASONING_METHODS = [
|
|
49
|
+
"deductive",
|
|
50
|
+
// Logically entailed
|
|
51
|
+
"inductive",
|
|
52
|
+
// Generalized from instances
|
|
53
|
+
"abductive",
|
|
54
|
+
// Best explanation inference
|
|
55
|
+
"analogical",
|
|
56
|
+
// Reasoning by analogy
|
|
57
|
+
"empirical"
|
|
58
|
+
// Direct observation/measurement
|
|
59
|
+
];
|
|
62
60
|
var DEFEAT_TYPES = [
|
|
63
61
|
"rebuts",
|
|
64
62
|
// Direct contradiction — reasons for the negation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/reasoning-method.ts","../src/api-enums.contract.ts"],"names":[],"mappings":";AACO,IAAM,iBAAA,GAAoB;AAAA,EAC/B,WAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF;;;ACIO,IAAM,YAAA,GAAe;AAAA,EAC1B,YAAA;AAAA;AAAA,EACA,wBAAA;AAAA;AAAA,EACA,cAAA;AAAA;AAAA,EACA,qBAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,mBAAA,GAAsB;AAAA,EACjC,gBAAA;AAAA;AAAA,EACA,kBAAA;AAAA;AAAA,EACA,wBAAA;AAAA;AAAA,EACA,wBAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA,OAAA;AAAA;AAAA,EACA,kBAAA;AAAA;AAAA,EACA,kBAAA;AAAA;AAAA,EACA,oBAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA,UAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,eAAA,GAAkB;AAAA,EAC7B,UAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA;AAAA;AACF;AAaO,IAAM,YAAA,GAAe;AAAA,EAC1B,QAAA;AAAA;AAAA,EACA,WAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,wBAAA,GAA2B;AAAA,EACtC,KAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA,MAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,sBAAA,GAAyB;AAAA,EACpC,YAAA;AAAA;AAAA,EACA,UAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,cAAA,GAAiB;AAAA,EAC5B,WAAA;AAAA;AAAA,EACA,aAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,eAAA,GAAkB;AAAA,EAC7B,YAAA;AAAA;AAAA,EACA,eAAA;AAAA;AAAA,EACA,YAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,eAAA,GAAkB;AAAA,EAC7B,SAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,qBAAA,GAAwB;AAAA,EACnC,gBAAA;AAAA;AAAA,EACA,mBAAA;AAAA;AAAA,EACA,UAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,IAAA;AAAA;AAAA,EACA,IAAA;AAAA;AAAA,EACA,IAAA;AAAA;AAAA,EACA;AAAA;AACF;AAcO,IAAM,cAAA,GAAiB;AAAA,EAC5B,mBAAA;AAAA;AAAA,EACA,iBAAA;AAAA;AAAA,EACA,sBAAA;AAAA;AAAA,EACA,qBAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,sBAAA,GAAyB;AAAA;AAAA,EAEpC,SAAA;AAAA;AAAA,EACA,SAAA;AAAA;AAAA,EACA,SAAA;AAAA;AAAA;AAAA,EAEA,aAAA;AAAA;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":["/** Reasoning methods supported by the kernel edge schema. */\nexport const REASONING_METHODS = [\n \"deductive\",\n \"inductive\",\n \"abductive\",\n \"analogical\",\n \"causal\",\n \"correlational\",\n \"testimonial\",\n \"statistical\",\n \"implicit\",\n \"pattern_match\",\n] as const;\n\nexport type ReasoningMethod = (typeof REASONING_METHODS)[number];\n","/**\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 \"evidence_removed\", // Evidence was removed or invalidated\n \"contradiction_detected\", // A contradiction was flagged involving this belief\n \"contradiction_resolved\", // A contradiction was resolved\n \"manual\", // User manually adjusted confidence\n \"decay\", // Time-based confidence erosion\n \"agent_assessment\", // An agent provided a structured assessment\n \"worktree_outcome\", // Worktree outcome determined this confidence\n \"worktree_completed\", // Worktree completed and closed this scoring loop\n \"fusion\", // Confidence came from subjective-logic fusion\n \"discount\", // Confidence came from trust discounting\n \"deduction\", // Confidence came from conditional deduction\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\nexport {\n REASONING_METHODS,\n type ReasoningMethod,\n} from \"./types/reasoning-method.js\";\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"]}
|
|
1
|
+
{"version":3,"sources":["../src/api-enums.contract.ts"],"names":[],"mappings":";AAgBO,IAAM,YAAA,GAAe;AAAA,EAC1B,YAAA;AAAA;AAAA,EACA,wBAAA;AAAA;AAAA,EACA,cAAA;AAAA;AAAA,EACA,qBAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,mBAAA,GAAsB;AAAA,EACjC,gBAAA;AAAA;AAAA,EACA,kBAAA;AAAA;AAAA,EACA,wBAAA;AAAA;AAAA,EACA,wBAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA,OAAA;AAAA;AAAA,EACA,kBAAA;AAAA;AAAA,EACA,kBAAA;AAAA;AAAA,EACA,oBAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA,UAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,eAAA,GAAkB;AAAA,EAC7B,UAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,iBAAA,GAAoB;AAAA,EAC/B,WAAA;AAAA;AAAA,EACA,WAAA;AAAA;AAAA,EACA,WAAA;AAAA;AAAA,EACA,YAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,YAAA,GAAe;AAAA,EAC1B,QAAA;AAAA;AAAA,EACA,WAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,wBAAA,GAA2B;AAAA,EACtC,KAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA,MAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,sBAAA,GAAyB;AAAA,EACpC,YAAA;AAAA;AAAA,EACA,UAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,cAAA,GAAiB;AAAA,EAC5B,WAAA;AAAA;AAAA,EACA,aAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA;AAAA;AACF;AAIO,IAAM,eAAA,GAAkB;AAAA,EAC7B,YAAA;AAAA;AAAA,EACA,eAAA;AAAA;AAAA,EACA,YAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,eAAA,GAAkB;AAAA,EAC7B,SAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,qBAAA,GAAwB;AAAA,EACnC,gBAAA;AAAA;AAAA,EACA,mBAAA;AAAA;AAAA,EACA,UAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,IAAA;AAAA;AAAA,EACA,IAAA;AAAA;AAAA,EACA,IAAA;AAAA;AAAA,EACA;AAAA;AACF;AAcO,IAAM,cAAA,GAAiB;AAAA,EAC5B,mBAAA;AAAA;AAAA,EACA,iBAAA;AAAA;AAAA,EACA,sBAAA;AAAA;AAAA,EACA,qBAAA;AAAA;AAAA,EACA;AAAA;AACF;AAQO,IAAM,sBAAA,GAAyB;AAAA;AAAA,EAEpC,SAAA;AAAA;AAAA,EACA,SAAA;AAAA;AAAA,EACA,SAAA;AAAA;AAAA;AAAA,EAEA,aAAA;AAAA;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 \"evidence_removed\", // Evidence was removed or invalidated\n \"contradiction_detected\", // A contradiction was flagged involving this belief\n \"contradiction_resolved\", // A contradiction was resolved\n \"manual\", // User manually adjusted confidence\n \"decay\", // Time-based confidence erosion\n \"agent_assessment\", // An agent provided a structured assessment\n \"worktree_outcome\", // Worktree outcome determined this confidence\n \"worktree_completed\", // Worktree completed and closed this scoring loop\n \"fusion\", // Confidence came from subjective-logic fusion\n \"discount\", // Confidence came from trust discounting\n \"deduction\", // Confidence came from conditional deduction\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"]}
|
|
@@ -5,31 +5,19 @@ var SESSION_AUTH_MODES = [
|
|
|
5
5
|
"tenant_api_key",
|
|
6
6
|
"session_token"
|
|
7
7
|
];
|
|
8
|
-
var SESSION_PRINCIPAL_TYPES = [
|
|
9
|
-
"human",
|
|
10
|
-
"service",
|
|
11
|
-
"agent",
|
|
12
|
-
"group",
|
|
13
|
-
"external_viewer"
|
|
14
|
-
];
|
|
8
|
+
var SESSION_PRINCIPAL_TYPES = ["human", "service", "agent"];
|
|
15
9
|
var SESSION_LIFECYCLE_STATUSES = [
|
|
16
10
|
"active",
|
|
17
11
|
"expired",
|
|
18
12
|
"revoked"
|
|
19
13
|
];
|
|
20
14
|
function inferSessionPrincipalType(principalId) {
|
|
21
|
-
if (
|
|
15
|
+
if (principalId.startsWith("user:")) {
|
|
22
16
|
return "human";
|
|
23
17
|
}
|
|
24
18
|
if (principalId.startsWith("agent:")) {
|
|
25
19
|
return "agent";
|
|
26
20
|
}
|
|
27
|
-
if (principalId.startsWith("group:")) {
|
|
28
|
-
return "group";
|
|
29
|
-
}
|
|
30
|
-
if (principalId.startsWith("external:") || principalId.startsWith("external_viewer:")) {
|
|
31
|
-
return "external_viewer";
|
|
32
|
-
}
|
|
33
21
|
return "service";
|
|
34
22
|
}
|
|
35
23
|
function normalizeDelegationChain(args) {
|
|
@@ -1 +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
|
|
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"]}
|
|
@@ -5,31 +5,19 @@ var SESSION_AUTH_MODES = [
|
|
|
5
5
|
"tenant_api_key",
|
|
6
6
|
"session_token"
|
|
7
7
|
];
|
|
8
|
-
var SESSION_PRINCIPAL_TYPES = [
|
|
9
|
-
"human",
|
|
10
|
-
"service",
|
|
11
|
-
"agent",
|
|
12
|
-
"group",
|
|
13
|
-
"external_viewer"
|
|
14
|
-
];
|
|
8
|
+
var SESSION_PRINCIPAL_TYPES = ["human", "service", "agent"];
|
|
15
9
|
var SESSION_LIFECYCLE_STATUSES = [
|
|
16
10
|
"active",
|
|
17
11
|
"expired",
|
|
18
12
|
"revoked"
|
|
19
13
|
];
|
|
20
14
|
function inferSessionPrincipalType(principalId) {
|
|
21
|
-
if (
|
|
15
|
+
if (principalId.startsWith("user:")) {
|
|
22
16
|
return "human";
|
|
23
17
|
}
|
|
24
18
|
if (principalId.startsWith("agent:")) {
|
|
25
19
|
return "agent";
|
|
26
20
|
}
|
|
27
|
-
if (principalId.startsWith("group:")) {
|
|
28
|
-
return "group";
|
|
29
|
-
}
|
|
30
|
-
if (principalId.startsWith("external:") || principalId.startsWith("external_viewer:")) {
|
|
31
|
-
return "external_viewer";
|
|
32
|
-
}
|
|
33
21
|
return "service";
|
|
34
22
|
}
|
|
35
23
|
function normalizeDelegationChain(args) {
|
|
@@ -1 +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
|
|
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-session.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"]}
|
package/dist/auth.contract.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { ConvexAdminClient } from './convex-admin.contract.js';
|
|
|
12
12
|
*/
|
|
13
13
|
declare const SESSION_AUTH_MODES: readonly ["interactive_user", "service_principal", "tenant_api_key", "session_token"];
|
|
14
14
|
type SessionAuthMode = (typeof SESSION_AUTH_MODES)[number];
|
|
15
|
-
declare const SESSION_PRINCIPAL_TYPES: readonly ["human", "service", "agent"
|
|
15
|
+
declare const SESSION_PRINCIPAL_TYPES: readonly ["human", "service", "agent"];
|
|
16
16
|
type SessionPrincipalType = (typeof SESSION_PRINCIPAL_TYPES)[number];
|
|
17
17
|
declare const SESSION_LIFECYCLE_STATUSES: readonly ["active", "expired", "revoked"];
|
|
18
18
|
type SessionLifecycleStatus = (typeof SESSION_LIFECYCLE_STATUSES)[number];
|
package/dist/auth.contract.js
CHANGED
|
@@ -5,31 +5,19 @@ var SESSION_AUTH_MODES = [
|
|
|
5
5
|
"tenant_api_key",
|
|
6
6
|
"session_token"
|
|
7
7
|
];
|
|
8
|
-
var SESSION_PRINCIPAL_TYPES = [
|
|
9
|
-
"human",
|
|
10
|
-
"service",
|
|
11
|
-
"agent",
|
|
12
|
-
"group",
|
|
13
|
-
"external_viewer"
|
|
14
|
-
];
|
|
8
|
+
var SESSION_PRINCIPAL_TYPES = ["human", "service", "agent"];
|
|
15
9
|
var SESSION_LIFECYCLE_STATUSES = [
|
|
16
10
|
"active",
|
|
17
11
|
"expired",
|
|
18
12
|
"revoked"
|
|
19
13
|
];
|
|
20
14
|
function inferSessionPrincipalType(principalId) {
|
|
21
|
-
if (
|
|
15
|
+
if (principalId.startsWith("user:")) {
|
|
22
16
|
return "human";
|
|
23
17
|
}
|
|
24
18
|
if (principalId.startsWith("agent:")) {
|
|
25
19
|
return "agent";
|
|
26
20
|
}
|
|
27
|
-
if (principalId.startsWith("group:")) {
|
|
28
|
-
return "group";
|
|
29
|
-
}
|
|
30
|
-
if (principalId.startsWith("external:") || principalId.startsWith("external_viewer:")) {
|
|
31
|
-
return "external_viewer";
|
|
32
|
-
}
|
|
33
21
|
return "service";
|
|
34
22
|
}
|
|
35
23
|
function normalizeDelegationChain(args) {
|
|
@@ -1 +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
|
|
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.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"]}
|
|
@@ -450,13 +450,11 @@ type ContextPackV1 = {
|
|
|
450
450
|
};
|
|
451
451
|
/**
|
|
452
452
|
* The canonical input schema for `compile_context`.
|
|
453
|
-
* `topicId` is
|
|
454
|
-
* resolves the best topic from the query and other available signals.
|
|
455
|
-
* `projectId` remains an optional compatibility alias.
|
|
453
|
+
* `topicId` is canonical. `projectId` remains an optional compatibility alias.
|
|
456
454
|
*/
|
|
457
455
|
type ContextPackRequestV1 = {
|
|
458
|
-
/** Topic scope ID
|
|
459
|
-
topicId
|
|
456
|
+
/** Topic scope ID (required). */
|
|
457
|
+
topicId: string;
|
|
460
458
|
/** Deprecated compatibility alias for older callers. */
|
|
461
459
|
projectId?: string;
|
|
462
460
|
/** 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,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,GAAA;AAAA,IACT,UAAA,EAAY,GAAA;AAAA,IACZ,UAAA,EAAY;AAAA,GACd;AAAA,EACA,aAAA,EAAe;AAAA,IACb,KAAA,EAAO,IAAA;AAAA,IACP,OAAA,EAAS,GAAA;AAAA,IACT,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,KAAA,EAAO,GAAA;AAAA,IACP,OAAA,EAAS;AAAA,GACX;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,KAAA,EAAO,GAAA;AAAA,IACP,OAAA,EAAS,GAAA;AAAA,IACT,QAAA,EAAU;AAAA;AAEd;AAGO,IAAM,sBAAA,GAAyB;AAQ/B,IAAM,sBAAA,GAAyB;AAAA,EACpC,KAAA,EAAO,GAAA;AAAA,EACP,YAAA,EAAc;AAChB;AAGO,IAAM,oBAAA,GAAuB;AAG7B,IAAM,gBAAA,GAAmB;AAUzB,IAAM,iBAAA,GAAsD;AAAA,EACjE,SAAA,EAAW,CAAA;AAAA,EACX,KAAA,EAAO,GAAA;AAAA,EACP,SAAA,EAAW;AACb;AAEO,IAAM,yBAAA,GAA4B;AAMlC,IAAM,eAAA,GAAoD;AAAA,EAC/D,QAAA,EAAU,CAAA;AAAA,EACV,IAAA,EAAM,IAAA;AAAA,EACN,MAAA,EAAQ,IAAA;AAAA,EACR,GAAA,EAAK;AACP;AAEO,IAAM,sBAAA,GAAyB;AAE/B,IAAM,eAAA,GAAoD;AAAA,EAC/D,QAAA,EAAU,CAAA;AAAA,EACV,IAAA,EAAM,IAAA;AAAA,EACN,MAAA,EAAQ,GAAA;AAAA,EACR,GAAA,EAAK;AACP;AAEO,IAAM,sBAAA,GAAyB;AA6b/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 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"]}
|
|
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,GAAA;AAAA,IACT,UAAA,EAAY,GAAA;AAAA,IACZ,UAAA,EAAY;AAAA,GACd;AAAA,EACA,aAAA,EAAe;AAAA,IACb,KAAA,EAAO,IAAA;AAAA,IACP,OAAA,EAAS,GAAA;AAAA,IACT,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,KAAA,EAAO,GAAA;AAAA,IACP,OAAA,EAAS;AAAA,GACX;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,KAAA,EAAO,GAAA;AAAA,IACP,OAAA,EAAS,GAAA;AAAA,IACT,QAAA,EAAU;AAAA;AAEd;AAGO,IAAM,sBAAA,GAAyB;AAQ/B,IAAM,sBAAA,GAAyB;AAAA,EACpC,KAAA,EAAO,GAAA;AAAA,EACP,YAAA,EAAc;AAChB;AAGO,IAAM,oBAAA,GAAuB;AAG7B,IAAM,gBAAA,GAAmB;AAUzB,IAAM,iBAAA,GAAsD;AAAA,EACjE,SAAA,EAAW,CAAA;AAAA,EACX,KAAA,EAAO,GAAA;AAAA,EACP,SAAA,EAAW;AACb;AAEO,IAAM,yBAAA,GAA4B;AAMlC,IAAM,eAAA,GAAoD;AAAA,EAC/D,QAAA,EAAU,CAAA;AAAA,EACV,IAAA,EAAM,IAAA;AAAA,EACN,MAAA,EAAQ,IAAA;AAAA,EACR,GAAA,EAAK;AACP;AAEO,IAAM,sBAAA,GAAyB;AAE/B,IAAM,eAAA,GAAoD;AAAA,EAC/D,QAAA,EAAU,CAAA;AAAA,EACV,IAAA,EAAM,IAAA;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,5 +1,5 @@
|
|
|
1
1
|
import { a as FunctionContract, F as FunctionEffect, d as defineFunction } from './defineFunction-DO97DKs4.js';
|
|
2
|
-
import { a as TableIndex, b as TableComponent, T as TableContract, c as TableDeprecation, d as defineTable } from './defineTable-
|
|
2
|
+
import { a as TableIndex, b as TableComponent, T as TableContract, c as TableDeprecation, d as defineTable } from './defineTable-CBQ03FXl.js';
|
|
3
3
|
import { a as CONVEX_ID_TABLE, C as ConvexIdSchema, g as getConvexIdTable, i as idOf } from './idOf-DR8tkhQS.js';
|
|
4
4
|
import { z, ZodTypeAny } from 'zod';
|
|
5
5
|
|
|
@@ -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 AdapterKind as A, type CliOptionKind as C, type JsonSchema as J, SchemaAdapterError as S, type ZodToCliOptions as Z, type AdapterPurpose as a, type AdapterContext as b, type CliOptionSpec as c, dsl as d, type CliCommandSpec as e, type ConvexDefault as f, type ZodToConvexOptions as g, type ZodToConvexResult as h, zodToConvex as i, type ZodToJsonSchemaOptions 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
|
-
export { b as TableComponent, T as TableContract, c as TableDeprecation, a as TableIndex, d as defineTable } from './defineTable-
|
|
3
|
-
export {
|
|
2
|
+
export { b as TableComponent, T as TableContract, c as TableDeprecation, a as TableIndex, d as defineTable } from './defineTable-CBQ03FXl.js';
|
|
3
|
+
export { b as AdapterContext, A as AdapterKind, a as AdapterPurpose, e as CliCommandSpec, C as CliOptionKind, c as CliOptionSpec, f as ConvexDefault, J as JsonSchema, S as SchemaAdapterError, Z as ZodToCliOptions, g as ZodToConvexOptions, h as ZodToConvexResult, j as ZodToJsonSchemaOptions, s as schemaAdapterError, t as tableIndexToConvexSource, z as zodToCli, i as zodToConvex, k as zodToJsonSchema } from './dsl-BgpoVOVQ.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,6 +208,9 @@ function encodeLiteral(value) {
|
|
|
208
208
|
}
|
|
209
209
|
return JSON.stringify(value);
|
|
210
210
|
}
|
|
211
|
+
function quoteKey(value) {
|
|
212
|
+
return JSON.stringify(value);
|
|
213
|
+
}
|
|
211
214
|
function sortEntries(entries) {
|
|
212
215
|
return [...entries].sort(([left], [right]) => left.localeCompare(right));
|
|
213
216
|
}
|
|
@@ -370,7 +373,7 @@ function convertSchemaInner(schema, state, path) {
|
|
|
370
373
|
convertSchema(value, state, [...path, key])
|
|
371
374
|
]);
|
|
372
375
|
return {
|
|
373
|
-
source: `v.object({ ${convertedFields.map(([key, converted]) => `${
|
|
376
|
+
source: `v.object({ ${convertedFields.map(([key, converted]) => `${quoteKey(key)}: ${converted.source}`).join(", ")} })`,
|
|
374
377
|
defaults: convertedFields.flatMap(([, converted]) => converted.defaults)
|
|
375
378
|
};
|
|
376
379
|
}
|