@voyant-travel/action-ledger 0.105.1 → 0.105.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.
@@ -0,0 +1,159 @@
1
+ CREATE TYPE "public"."action_ledger_action_kind" AS ENUM('read', 'create', 'update', 'delete', 'execute', 'approve', 'reject', 'reverse', 'compensate', 'duplicate');--> statement-breakpoint
2
+ CREATE TYPE "public"."action_ledger_approval_status" AS ENUM('pending', 'approved', 'denied', 'expired', 'cancelled', 'superseded');--> statement-breakpoint
3
+ CREATE TYPE "public"."action_ledger_principal_type" AS ENUM('user', 'api_key', 'agent', 'workflow', 'system');--> statement-breakpoint
4
+ CREATE TYPE "public"."action_ledger_redaction_status" AS ENUM('none', 'redacted', 'tombstoned', 'crypto_shredded');--> statement-breakpoint
5
+ CREATE TYPE "public"."action_ledger_relay_status" AS ENUM('pending', 'processing', 'succeeded', 'failed', 'dead_letter');--> statement-breakpoint
6
+ CREATE TYPE "public"."action_ledger_reversal_kind" AS ENUM('none', 'revert', 'compensate', 'domain_command');--> statement-breakpoint
7
+ CREATE TYPE "public"."action_ledger_reversal_outcome" AS ENUM('full', 'partial', 'failed');--> statement-breakpoint
8
+ CREATE TYPE "public"."action_ledger_reversal_state" AS ENUM('not_reversible', 'available', 'requested', 'running', 'completed', 'failed', 'expired');--> statement-breakpoint
9
+ CREATE TYPE "public"."action_ledger_risk" AS ENUM('low', 'medium', 'high', 'critical');--> statement-breakpoint
10
+ CREATE TYPE "public"."action_ledger_status" AS ENUM('requested', 'awaiting_approval', 'approved', 'denied', 'succeeded', 'failed', 'reversed', 'compensated', 'expired', 'cancelled', 'superseded');--> statement-breakpoint
11
+ CREATE TABLE "action_approvals" (
12
+ "id" text PRIMARY KEY NOT NULL,
13
+ "requested_action_id" text NOT NULL,
14
+ "status" "action_ledger_approval_status" DEFAULT 'pending' NOT NULL,
15
+ "requested_by_principal_id" text NOT NULL,
16
+ "assigned_to_principal_id" text,
17
+ "decided_by_principal_id" text,
18
+ "delegated_from_principal_id" text,
19
+ "policy_name" text NOT NULL,
20
+ "policy_version" text NOT NULL,
21
+ "target_snapshot_ref" text,
22
+ "risk_snapshot" "action_ledger_risk" NOT NULL,
23
+ "reason_code" text,
24
+ "expires_at" timestamp with time zone,
25
+ "decided_at" timestamp with time zone,
26
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
27
+ );
28
+ --> statement-breakpoint
29
+ CREATE TABLE "action_delegations" (
30
+ "id" text PRIMARY KEY NOT NULL,
31
+ "root_principal_type" "action_ledger_principal_type" NOT NULL,
32
+ "root_principal_id" text NOT NULL,
33
+ "parent_principal_type" "action_ledger_principal_type" NOT NULL,
34
+ "parent_principal_id" text NOT NULL,
35
+ "child_principal_type" "action_ledger_principal_type" NOT NULL,
36
+ "child_principal_id" text NOT NULL,
37
+ "grant_source" text NOT NULL,
38
+ "capability_scope_ref" text,
39
+ "budget_scope_ref" text,
40
+ "expires_at" timestamp with time zone,
41
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
42
+ );
43
+ --> statement-breakpoint
44
+ CREATE TABLE "action_ledger_entries" (
45
+ "id" text PRIMARY KEY NOT NULL,
46
+ "occurred_at" timestamp with time zone DEFAULT now() NOT NULL,
47
+ "action_name" text NOT NULL,
48
+ "action_version" text NOT NULL,
49
+ "action_kind" "action_ledger_action_kind" NOT NULL,
50
+ "status" "action_ledger_status" NOT NULL,
51
+ "evaluated_risk" "action_ledger_risk" NOT NULL,
52
+ "actor_type" text,
53
+ "principal_type" "action_ledger_principal_type" NOT NULL,
54
+ "principal_id" text NOT NULL,
55
+ "principal_subtype" text,
56
+ "session_id" text,
57
+ "api_token_id" text,
58
+ "internal_request" boolean DEFAULT false NOT NULL,
59
+ "delegated_by_principal_type" "action_ledger_principal_type",
60
+ "delegated_by_principal_id" text,
61
+ "delegation_id" text,
62
+ "caller_type" text,
63
+ "organization_id" text,
64
+ "route_or_tool_name" text,
65
+ "workflow_run_id" text,
66
+ "workflow_step_id" text,
67
+ "correlation_id" text,
68
+ "causation_action_id" text,
69
+ "idempotency_scope" text,
70
+ "idempotency_key" text,
71
+ "idempotency_fingerprint" text,
72
+ "target_type" text NOT NULL,
73
+ "target_id" text NOT NULL,
74
+ "capability_id" text,
75
+ "capability_version" text,
76
+ "authorization_source" text,
77
+ "approval_id" text,
78
+ "amends_action_id" text,
79
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
80
+ );
81
+ --> statement-breakpoint
82
+ CREATE TABLE "action_ledger_payloads" (
83
+ "id" text PRIMARY KEY NOT NULL,
84
+ "action_id" text NOT NULL,
85
+ "payload_kind" text NOT NULL,
86
+ "schema_tag" text NOT NULL,
87
+ "redaction_status" "action_ledger_redaction_status" DEFAULT 'none' NOT NULL,
88
+ "retention_policy" text NOT NULL,
89
+ "storage_ref" text NOT NULL,
90
+ "hash" text,
91
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
92
+ "expires_at" timestamp with time zone
93
+ );
94
+ --> statement-breakpoint
95
+ CREATE TABLE "action_ledger_outbox" (
96
+ "id" text PRIMARY KEY NOT NULL,
97
+ "action_id" text NOT NULL,
98
+ "organization_id" text,
99
+ "relay_status" "action_ledger_relay_status" DEFAULT 'pending' NOT NULL,
100
+ "payload_ref" text,
101
+ "attempt_count" integer DEFAULT 0 NOT NULL,
102
+ "next_retry_at" timestamp with time zone,
103
+ "last_error" text,
104
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
105
+ "processed_at" timestamp with time zone
106
+ );
107
+ --> statement-breakpoint
108
+ CREATE TABLE "action_mutation_details" (
109
+ "action_id" text PRIMARY KEY NOT NULL,
110
+ "command_input_ref" text,
111
+ "command_result_ref" text,
112
+ "summary" text,
113
+ "reversal_kind" "action_ledger_reversal_kind" DEFAULT 'none' NOT NULL,
114
+ "reversal_command_id" text,
115
+ "reversal_command_version" text,
116
+ "reversal_args_ref" text,
117
+ "reversal_state_projection" "action_ledger_reversal_state",
118
+ "reversal_outcome_projection" "action_ledger_reversal_outcome",
119
+ "reverses_action_id" text,
120
+ "reversed_by_action_id_projection" text
121
+ );
122
+ --> statement-breakpoint
123
+ CREATE TABLE "action_sensitive_read_details" (
124
+ "action_id" text PRIMARY KEY NOT NULL,
125
+ "reason_code" text,
126
+ "disclosed_field_set" jsonb,
127
+ "disclosure_summary" text,
128
+ "decision_policy" text
129
+ );
130
+ --> statement-breakpoint
131
+ ALTER TABLE "action_approvals" ADD CONSTRAINT "action_approvals_requested_action_id_action_ledger_entries_id_fk" FOREIGN KEY ("requested_action_id") REFERENCES "public"."action_ledger_entries"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
132
+ ALTER TABLE "action_ledger_payloads" ADD CONSTRAINT "action_ledger_payloads_action_id_action_ledger_entries_id_fk" FOREIGN KEY ("action_id") REFERENCES "public"."action_ledger_entries"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
133
+ ALTER TABLE "action_ledger_outbox" ADD CONSTRAINT "action_ledger_outbox_action_id_action_ledger_entries_id_fk" FOREIGN KEY ("action_id") REFERENCES "public"."action_ledger_entries"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
134
+ ALTER TABLE "action_mutation_details" ADD CONSTRAINT "action_mutation_details_action_id_action_ledger_entries_id_fk" FOREIGN KEY ("action_id") REFERENCES "public"."action_ledger_entries"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
135
+ ALTER TABLE "action_sensitive_read_details" ADD CONSTRAINT "action_sensitive_read_details_action_id_action_ledger_entries_id_fk" FOREIGN KEY ("action_id") REFERENCES "public"."action_ledger_entries"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
136
+ CREATE INDEX "idx_action_approvals_requested_action" ON "action_approvals" USING btree ("requested_action_id");--> statement-breakpoint
137
+ CREATE INDEX "idx_action_approvals_status_expires" ON "action_approvals" USING btree ("status","expires_at");--> statement-breakpoint
138
+ CREATE INDEX "idx_action_approvals_assignee" ON "action_approvals" USING btree ("assigned_to_principal_id","created_at");--> statement-breakpoint
139
+ CREATE INDEX "idx_action_delegations_root" ON "action_delegations" USING btree ("root_principal_type","root_principal_id");--> statement-breakpoint
140
+ CREATE INDEX "idx_action_delegations_child" ON "action_delegations" USING btree ("child_principal_type","child_principal_id");--> statement-breakpoint
141
+ CREATE INDEX "idx_action_delegations_parent" ON "action_delegations" USING btree ("parent_principal_type","parent_principal_id");--> statement-breakpoint
142
+ CREATE INDEX "idx_action_ledger_entries_principal" ON "action_ledger_entries" USING btree ("principal_type","principal_id","occurred_at");--> statement-breakpoint
143
+ CREATE INDEX "idx_action_ledger_entries_api_token" ON "action_ledger_entries" USING btree ("api_token_id","occurred_at");--> statement-breakpoint
144
+ CREATE INDEX "idx_action_ledger_entries_session" ON "action_ledger_entries" USING btree ("session_id","occurred_at");--> statement-breakpoint
145
+ CREATE INDEX "idx_action_ledger_entries_target" ON "action_ledger_entries" USING btree ("target_type","target_id","occurred_at");--> statement-breakpoint
146
+ CREATE INDEX "idx_action_ledger_entries_workflow" ON "action_ledger_entries" USING btree ("workflow_run_id","workflow_step_id","occurred_at");--> statement-breakpoint
147
+ CREATE INDEX "idx_action_ledger_entries_correlation" ON "action_ledger_entries" USING btree ("correlation_id","occurred_at");--> statement-breakpoint
148
+ CREATE INDEX "idx_action_ledger_entries_causation" ON "action_ledger_entries" USING btree ("causation_action_id");--> statement-breakpoint
149
+ CREATE INDEX "idx_action_ledger_entries_control_state" ON "action_ledger_entries" USING btree ("evaluated_risk","status","occurred_at");--> statement-breakpoint
150
+ CREATE INDEX "idx_action_ledger_entries_capability" ON "action_ledger_entries" USING btree ("capability_id","capability_version","occurred_at");--> statement-breakpoint
151
+ CREATE UNIQUE INDEX "idx_action_ledger_entries_idempotency" ON "action_ledger_entries" USING btree ("idempotency_scope","action_name","target_type","target_id","idempotency_key") WHERE
152
+ "action_ledger_entries"."idempotency_key" IS NOT NULL
153
+ ;--> statement-breakpoint
154
+ CREATE INDEX "idx_action_ledger_payloads_action" ON "action_ledger_payloads" USING btree ("action_id");--> statement-breakpoint
155
+ CREATE INDEX "idx_action_ledger_payloads_expiry" ON "action_ledger_payloads" USING btree ("expires_at");--> statement-breakpoint
156
+ CREATE INDEX "idx_action_ledger_outbox_action" ON "action_ledger_outbox" USING btree ("action_id");--> statement-breakpoint
157
+ CREATE INDEX "idx_action_ledger_outbox_status_retry" ON "action_ledger_outbox" USING btree ("relay_status","next_retry_at");--> statement-breakpoint
158
+ CREATE INDEX "idx_action_mutation_details_reverses" ON "action_mutation_details" USING btree ("reverses_action_id");--> statement-breakpoint
159
+ CREATE INDEX "idx_action_mutation_details_reversal_state" ON "action_mutation_details" USING btree ("reversal_state_projection");
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1781942390744,
9
+ "tag": "0000_action_ledger_baseline",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyant-travel/action-ledger",
3
- "version": "0.105.1",
3
+ "version": "0.105.2",
4
4
  "description": "Action ledger schema, append-only write helpers, and idempotency primitives for Voyant control surfaces.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -61,16 +61,19 @@
61
61
  "hono": "^4.12.10",
62
62
  "zod": "^4.3.6",
63
63
  "@voyant-travel/core": "^0.110.0",
64
- "@voyant-travel/db": "^0.108.2",
65
- "@voyant-travel/hono": "^0.112.0"
64
+ "@voyant-travel/db": "^0.108.3",
65
+ "@voyant-travel/hono": "^0.112.2"
66
66
  },
67
67
  "devDependencies": {
68
+ "drizzle-kit": "^0.31.10",
68
69
  "typescript": "^6.0.2",
69
70
  "vitest": "^4.1.2",
70
71
  "@voyant-travel/voyant-typescript-config": "^0.1.0"
71
72
  },
72
73
  "files": [
73
- "dist"
74
+ "dist",
75
+ "migrations/*.sql",
76
+ "migrations/meta/_journal.json"
74
77
  ],
75
78
  "publishConfig": {
76
79
  "access": "public"
@@ -91,7 +94,8 @@
91
94
  "lint": "biome check src/ tests/",
92
95
  "test": "vitest run --passWithNoTests",
93
96
  "build": "tsc -p tsconfig.json",
94
- "clean": "rm -rf dist tsconfig.tsbuildinfo"
97
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
98
+ "db:generate": "drizzle-kit generate --config=drizzle.migrations.config.ts --name=action_ledger_baseline"
95
99
  },
96
100
  "main": "./dist/index.js",
97
101
  "types": "./dist/index.d.ts"