@lucern/events 0.3.0-alpha.15 → 0.3.0-alpha.17

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/README.md CHANGED
@@ -1,5 +1,17 @@
1
- # packages/events
1
+ # @lucern/events
2
2
 
3
- Event infrastructure: outbox pattern, webhook delivery, replay, projection reconciliation.
3
+ Operational eventing helpers for Lucern: domain event contracts, event matching,
4
+ outbox helper re-exports, webhook validation, webhook signing, retry scheduling,
5
+ and delivery record sanitization.
4
6
 
5
7
  ## Built by: EK-13.8 (Eventing + Async Integrations)
8
+
9
+ ## Replay boundary
10
+
11
+ This package is operational eventing substrate. It is not the final Campaign #4
12
+ bitemporal replay architecture. Source Horizons, Output Objects, Computation
13
+ Runs, Bitemporal Events, Replay Records, and source-horizon-bound artifact
14
+ replay remain roadmap contracts.
15
+
16
+ See `docs/reference/mcp-event-packages.md` for package-boundary truth and
17
+ `docs/development/mcp-eventing-workflows.md` for development workflow examples.
package/dist/index.js CHANGED
@@ -893,6 +893,7 @@ defineTable({
893
893
  shape: z.object({
894
894
  "tenantId": idOf("tenants"),
895
895
  "workspaceId": idOf("workspaces").optional(),
896
+ "environment": z.enum(["dev", "staging", "prod"]).optional(),
896
897
  "keyPrefix": z.enum(["luc", "stk"]),
897
898
  "keyHash": z.string(),
898
899
  "keyHint": z.string(),
@@ -920,7 +921,7 @@ defineTable({
920
921
  shape: z.object({
921
922
  "tenantId": idOf("tenants").optional(),
922
923
  "apiKeyId": idOf("apiKeys").optional(),
923
- "action": z.enum(["key_created", "key_revoked", "key_expired", "key_used", "tenant_secret_created", "tenant_secret_rotated", "tenant_secret_revoked", "tenant_slot_binding_upserted", "tenant_slot_binding_revoked", "proxy_token_minted", "proxy_token_lease_issued", "proxy_token_lease_renewed", "proxy_token_lease_revoked", "proxy_request_recorded", "tenant_created", "tenant_updated", "tenant_suspended", "tenant_archived", "tenant_reactivated", "principal_created", "principal_updated", "principal_suspended", "principal_identity_alias_upserted", "principal_identity_alias_revoked", "membership_created", "membership_updated", "membership_revoked", "group_created", "group_updated", "group_deleted", "group_member_added", "group_member_removed", "workspace_created", "workspace_updated", "workspace_archived", "workspace_deployment_set", "workspace_deployment_removed", "deployment_host_registered", "deployment_host_revoked", "service_key_created", "service_key_rotated", "service_key_revoked", "service_key_used", "service_key_auth_failed", "session_created", "session_validated", "session_revoked", "session_cascade_revoked", "session_expired", "sandbox_created", "sandbox_secret_injected", "sandbox_execution_started", "sandbox_execution_completed", "sandbox_limit_violated", "policy_created", "policy_updated", "policy_enforced", "policy_archived", "permit_sync_enqueued", "permit_sync_succeeded", "permit_sync_failed", "permit_sync_skipped", "agent_registered", "agent_updated", "tool_registered", "tool_updated", "pack_entitled", "pack_installed", "pack_enabled", "pack_disabled", "pack_entitlement_revoked", "pack_upgraded", "pack_upgrade_committed", "pack_upgrade_rolled_back", "pack_group_assigned", "pack_group_unassigned", "methodology_pack_created", "methodology_pack_updated", "methodology_pack_assigned", "methodology_pack_removed", "pack_assigned_to_group", "pack_revoked_from_group", "pack_ontology_materialized", "pack_ontology_topic_bound", "cutover_flag_set", "cutover_flag_cleared"]),
924
+ "action": z.enum(["key_created", "key_revoked", "key_expired", "key_used", "tenant_secret_created", "tenant_secret_rotated", "tenant_secret_revoked", "tenant_slot_binding_upserted", "tenant_slot_binding_revoked", "proxy_token_minted", "proxy_token_lease_issued", "proxy_token_lease_renewed", "proxy_token_lease_revoked", "proxy_request_recorded", "tenant_created", "tenant_updated", "tenant_suspended", "tenant_archived", "tenant_reactivated", "tenant_clerk_organization_linked", "principal_created", "principal_updated", "principal_suspended", "principal_identity_alias_upserted", "principal_identity_alias_revoked", "membership_created", "membership_updated", "membership_revoked", "group_created", "group_updated", "group_deleted", "group_member_added", "group_member_removed", "workspace_created", "workspace_updated", "workspace_archived", "workspace_deployment_set", "workspace_deployment_removed", "deployment_host_registered", "deployment_host_revoked", "service_key_created", "service_key_rotated", "service_key_revoked", "service_key_used", "service_key_auth_failed", "session_created", "session_validated", "session_revoked", "session_cascade_revoked", "session_expired", "sandbox_created", "sandbox_secret_injected", "sandbox_execution_started", "sandbox_execution_completed", "sandbox_limit_violated", "policy_created", "policy_updated", "policy_enforced", "policy_archived", "permit_sync_enqueued", "permit_sync_succeeded", "permit_sync_failed", "permit_sync_skipped", "agent_registered", "agent_updated", "tool_registered", "tool_updated", "pack_entitled", "pack_installed", "pack_enabled", "pack_disabled", "pack_entitlement_revoked", "pack_upgraded", "pack_upgrade_committed", "pack_upgrade_rolled_back", "pack_group_assigned", "pack_group_unassigned", "methodology_pack_created", "methodology_pack_updated", "methodology_pack_assigned", "methodology_pack_removed", "pack_assigned_to_group", "pack_revoked_from_group", "pack_ontology_materialized", "pack_ontology_topic_bound", "cutover_flag_set", "cutover_flag_cleared"]),
924
925
  "actorClerkId": z.string(),
925
926
  "details": z.any().optional(),
926
927
  "createdAt": z.number()
@@ -7049,7 +7050,7 @@ function compactRecord2(input) {
7049
7050
  Object.entries(input).filter(([, value]) => value !== void 0)
7050
7051
  );
7051
7052
  }
7052
- var listBeliefsProjection = defineProjection({
7053
+ defineProjection({
7053
7054
  contractName: "list_beliefs",
7054
7055
  inputSchema: listBeliefsInputSchema,
7055
7056
  project: (input) => compactRecord2({
@@ -9558,7 +9559,7 @@ var IDENTITY_WHOAMI = {
9558
9559
  response: {
9559
9560
  description: "Canonical identity summary for the current session",
9560
9561
  fields: {
9561
- principalId: "string \u2014 canonical federated principal identifier",
9562
+ principalId: "string \u2014 canonical principal identifier; for humans this is the Clerk user_... ID",
9562
9563
  principalType: "string \u2014 human, service, agent, group, or external_viewer",
9563
9564
  tenantId: "string | undefined \u2014 resolved tenant scope",
9564
9565
  workspaceId: "string | undefined \u2014 resolved workspace scope",
@@ -9572,7 +9573,7 @@ var IDENTITY_WHOAMI = {
9572
9573
  };
9573
9574
  var RESOLVE_INTERACTIVE_PRINCIPAL = {
9574
9575
  name: "resolve_interactive_principal",
9575
- description: "Read the Permit-backed Lucern principal context for an authenticated Clerk user. Like `git config --get user.email` plus the repository ACL \u2014 resolves the identity alias into the canonical authorization subject.",
9576
+ description: "Read the Permit-backed Lucern principal context for an authenticated Clerk user. Like `git config --get user.email` plus the repository ACL \u2014 resolves the Clerk subject into tenant/workspace authorization context.",
9576
9577
  parameters: {
9577
9578
  clerkId: {
9578
9579
  type: "string",
@@ -9595,7 +9596,7 @@ var RESOLVE_INTERACTIVE_PRINCIPAL = {
9595
9596
  response: {
9596
9597
  description: "Permit-backed Lucern principal context for tenant SDK bootstrap",
9597
9598
  fields: {
9598
- principalId: "string \u2014 canonical Lucern principal identifier",
9599
+ principalId: "string \u2014 canonical Clerk user_... ID for human sessions",
9599
9600
  principalType: "string \u2014 human, service, agent, group, or external_viewer",
9600
9601
  clerkId: "string \u2014 authenticated Clerk subject alias",
9601
9602
  tenantId: "string \u2014 resolved tenant scope",
@@ -10423,7 +10424,7 @@ var MANAGE_WRITE_POLICY = {
10423
10424
  },
10424
10425
  role: {
10425
10426
  type: "string",
10426
- description: "Role to set policy for (required for 'set'). E.g. 'agent:internal', 'user:analyst'."
10427
+ description: "Role to set policy for (required for 'set'). E.g. 'agent:internal' or a Permit role key such as 'workspace_admin'."
10427
10428
  },
10428
10429
  permission: {
10429
10430
  type: "string",
@@ -12353,11 +12354,8 @@ var identityContracts = [
12353
12354
  sdkNamespace: "identity",
12354
12355
  sdkMethod: "whoami",
12355
12356
  summary: "Describe the current gateway principal.",
12356
- convex: {
12357
- module: "identity",
12358
- functionName: "whoami",
12359
- kind: "query",
12360
- inputProjection: withPrincipal
12357
+ gateway: {
12358
+ handler: "identity.whoami"
12361
12359
  }
12362
12360
  }),
12363
12361
  surfaceContract({
@@ -12377,7 +12375,7 @@ var identityContracts = [
12377
12375
  providerProjectId: z.string().min(1).optional()
12378
12376
  }),
12379
12377
  convex: {
12380
- module: "identity",
12378
+ module: "platform",
12381
12379
  functionName: "resolveInteractivePrincipal",
12382
12380
  kind: "query"
12383
12381
  }
@@ -12461,15 +12459,6 @@ var beliefLookupInput = (input) => compactRecord4({
12461
12459
  var beliefNodeInput = (input) => compactRecord4({
12462
12460
  nodeId: input.nodeId ?? input.id ?? input.beliefId
12463
12461
  });
12464
- var beliefTopicInput = (input) => {
12465
- const parsed = listBeliefsProjection.inputSchema.safeParse(input);
12466
- if (!parsed.success) {
12467
- throw new Error(
12468
- `list_beliefs projection input rejected: ${parsed.error.message}`
12469
- );
12470
- }
12471
- return compactRecord4(listBeliefsProjection.project(parsed.data));
12472
- };
12473
12462
  var createBeliefInput = (input, context) => {
12474
12463
  return withUserId(
12475
12464
  compactRecord4({
@@ -12558,11 +12547,8 @@ var beliefsContracts = [
12558
12547
  sdkNamespace: "beliefs",
12559
12548
  sdkMethod: "listBeliefs",
12560
12549
  summary: "List beliefs for a topic.",
12561
- convex: {
12562
- module: "beliefs",
12563
- functionName: "getByTopic",
12564
- kind: "query",
12565
- inputProjection: beliefTopicInput
12550
+ gateway: {
12551
+ handler: "beliefs.list"
12566
12552
  },
12567
12553
  args: listBeliefsInputSchema
12568
12554
  }),
@@ -12747,12 +12733,6 @@ var evidenceIdInput = (input) => compactRecord4({
12747
12733
  insightId: input.insightId,
12748
12734
  nodeId: input.nodeId ?? input.id ?? input.evidenceId
12749
12735
  });
12750
- var evidenceTopicInput = (input) => compactRecord4({
12751
- topicId: input.topicId,
12752
- status: input.status,
12753
- userId: input.userId,
12754
- limit: input.limit
12755
- });
12756
12736
  var createEvidenceInput = (input, context) => {
12757
12737
  const parsed = createEvidenceProjection.inputSchema.safeParse(input);
12758
12738
  if (!parsed.success) {
@@ -12883,11 +12863,8 @@ var evidenceContracts = [
12883
12863
  sdkNamespace: "evidence",
12884
12864
  sdkMethod: "listEvidence",
12885
12865
  summary: "List evidence for a topic.",
12886
- convex: {
12887
- module: "evidence",
12888
- functionName: "getByTopic",
12889
- kind: "query",
12890
- inputProjection: evidenceTopicInput
12866
+ gateway: {
12867
+ handler: "evidence.list"
12891
12868
  }
12892
12869
  }),
12893
12870
  surfaceContract({
@@ -13122,11 +13099,8 @@ var questionsContracts = [
13122
13099
  sdkNamespace: "questions",
13123
13100
  sdkMethod: "listQuestions",
13124
13101
  summary: "List questions for a topic.",
13125
- convex: {
13126
- module: "questions",
13127
- functionName: "getByTopic",
13128
- kind: "query",
13129
- inputProjection: questionTopicInput
13102
+ gateway: {
13103
+ handler: "questions.list"
13130
13104
  }
13131
13105
  }),
13132
13106
  surfaceContract({
@@ -14231,6 +14205,19 @@ var worktreeEvidenceSignalInputSchema = z.object({
14231
14205
  progress: z.string().optional().describe("Collection progress note for the signal."),
14232
14206
  notes: z.string().optional().describe("Additional evidence collection notes.")
14233
14207
  }).passthrough().describe("Evidence signal embedded in the worktree plan.");
14208
+ var worktreeDocCompanionTargetSchema = z.object({
14209
+ docPath: z.string().describe(
14210
+ "Repo-relative path to a documentation file the worktree promises to update."
14211
+ ),
14212
+ sectionAnchor: z.string().optional().describe(
14213
+ "Markdown heading anchor (e.g. '## Function-surface manifest') that scopes the promised update."
14214
+ ),
14215
+ reason: z.string().describe(
14216
+ "Why this doc section must be updated for the worktree to be complete."
14217
+ )
14218
+ }).passthrough().describe(
14219
+ "Intent-driven docs companion target. pr-gate-reviewer verifies that the PR actually touches each declared (docPath, sectionAnchor). Distinct from the touch-driven docs-loop. See docs/development/docs-sync-discipline.md Lock 3."
14220
+ );
14234
14221
  var worktreeDecisionGateInputSchema = z.object({
14235
14222
  goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
14236
14223
  noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
@@ -14263,6 +14250,9 @@ var addWorktreeArgs = z.object({
14263
14250
  keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
14264
14251
  evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
14265
14252
  decisionGate: worktreeDecisionGateInputSchema.optional(),
14253
+ docCompanionTargets: z.array(worktreeDocCompanionTargetSchema).optional().describe(
14254
+ "Doc sections the worktree promises to update at PR time. Enforced by pr-gate-reviewer (Lock 3)."
14255
+ ),
14266
14256
  goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
14267
14257
  noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
14268
14258
  proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),