@voyant-travel/action-ledger 0.105.1 → 0.105.3

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,189 @@
1
+ DO $$ BEGIN
2
+ CREATE TYPE "public"."action_ledger_action_kind" AS ENUM('read', 'create', 'update', 'delete', 'execute', 'approve', 'reject', 'reverse', 'compensate', 'duplicate');
3
+ EXCEPTION WHEN duplicate_object THEN null;
4
+ END $$;--> statement-breakpoint
5
+ DO $$ BEGIN
6
+ CREATE TYPE "public"."action_ledger_approval_status" AS ENUM('pending', 'approved', 'denied', 'expired', 'cancelled', 'superseded');
7
+ EXCEPTION WHEN duplicate_object THEN null;
8
+ END $$;--> statement-breakpoint
9
+ DO $$ BEGIN
10
+ CREATE TYPE "public"."action_ledger_principal_type" AS ENUM('user', 'api_key', 'agent', 'workflow', 'system');
11
+ EXCEPTION WHEN duplicate_object THEN null;
12
+ END $$;--> statement-breakpoint
13
+ DO $$ BEGIN
14
+ CREATE TYPE "public"."action_ledger_redaction_status" AS ENUM('none', 'redacted', 'tombstoned', 'crypto_shredded');
15
+ EXCEPTION WHEN duplicate_object THEN null;
16
+ END $$;--> statement-breakpoint
17
+ DO $$ BEGIN
18
+ CREATE TYPE "public"."action_ledger_relay_status" AS ENUM('pending', 'processing', 'succeeded', 'failed', 'dead_letter');
19
+ EXCEPTION WHEN duplicate_object THEN null;
20
+ END $$;--> statement-breakpoint
21
+ DO $$ BEGIN
22
+ CREATE TYPE "public"."action_ledger_reversal_kind" AS ENUM('none', 'revert', 'compensate', 'domain_command');
23
+ EXCEPTION WHEN duplicate_object THEN null;
24
+ END $$;--> statement-breakpoint
25
+ DO $$ BEGIN
26
+ CREATE TYPE "public"."action_ledger_reversal_outcome" AS ENUM('full', 'partial', 'failed');
27
+ EXCEPTION WHEN duplicate_object THEN null;
28
+ END $$;--> statement-breakpoint
29
+ DO $$ BEGIN
30
+ CREATE TYPE "public"."action_ledger_reversal_state" AS ENUM('not_reversible', 'available', 'requested', 'running', 'completed', 'failed', 'expired');
31
+ EXCEPTION WHEN duplicate_object THEN null;
32
+ END $$;--> statement-breakpoint
33
+ DO $$ BEGIN
34
+ CREATE TYPE "public"."action_ledger_risk" AS ENUM('low', 'medium', 'high', 'critical');
35
+ EXCEPTION WHEN duplicate_object THEN null;
36
+ END $$;--> statement-breakpoint
37
+ DO $$ BEGIN
38
+ CREATE TYPE "public"."action_ledger_status" AS ENUM('requested', 'awaiting_approval', 'approved', 'denied', 'succeeded', 'failed', 'reversed', 'compensated', 'expired', 'cancelled', 'superseded');
39
+ EXCEPTION WHEN duplicate_object THEN null;
40
+ END $$;--> statement-breakpoint
41
+ CREATE TABLE "action_approvals" (
42
+ "id" text PRIMARY KEY NOT NULL,
43
+ "requested_action_id" text NOT NULL,
44
+ "status" "action_ledger_approval_status" DEFAULT 'pending' NOT NULL,
45
+ "requested_by_principal_id" text NOT NULL,
46
+ "assigned_to_principal_id" text,
47
+ "decided_by_principal_id" text,
48
+ "delegated_from_principal_id" text,
49
+ "policy_name" text NOT NULL,
50
+ "policy_version" text NOT NULL,
51
+ "target_snapshot_ref" text,
52
+ "risk_snapshot" "action_ledger_risk" NOT NULL,
53
+ "reason_code" text,
54
+ "expires_at" timestamp with time zone,
55
+ "decided_at" timestamp with time zone,
56
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
57
+ );
58
+ --> statement-breakpoint
59
+ CREATE TABLE "action_delegations" (
60
+ "id" text PRIMARY KEY NOT NULL,
61
+ "root_principal_type" "action_ledger_principal_type" NOT NULL,
62
+ "root_principal_id" text NOT NULL,
63
+ "parent_principal_type" "action_ledger_principal_type" NOT NULL,
64
+ "parent_principal_id" text NOT NULL,
65
+ "child_principal_type" "action_ledger_principal_type" NOT NULL,
66
+ "child_principal_id" text NOT NULL,
67
+ "grant_source" text NOT NULL,
68
+ "capability_scope_ref" text,
69
+ "budget_scope_ref" text,
70
+ "expires_at" timestamp with time zone,
71
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
72
+ );
73
+ --> statement-breakpoint
74
+ CREATE TABLE "action_ledger_entries" (
75
+ "id" text PRIMARY KEY NOT NULL,
76
+ "occurred_at" timestamp with time zone DEFAULT now() NOT NULL,
77
+ "action_name" text NOT NULL,
78
+ "action_version" text NOT NULL,
79
+ "action_kind" "action_ledger_action_kind" NOT NULL,
80
+ "status" "action_ledger_status" NOT NULL,
81
+ "evaluated_risk" "action_ledger_risk" NOT NULL,
82
+ "actor_type" text,
83
+ "principal_type" "action_ledger_principal_type" NOT NULL,
84
+ "principal_id" text NOT NULL,
85
+ "principal_subtype" text,
86
+ "session_id" text,
87
+ "api_token_id" text,
88
+ "internal_request" boolean DEFAULT false NOT NULL,
89
+ "delegated_by_principal_type" "action_ledger_principal_type",
90
+ "delegated_by_principal_id" text,
91
+ "delegation_id" text,
92
+ "caller_type" text,
93
+ "organization_id" text,
94
+ "route_or_tool_name" text,
95
+ "workflow_run_id" text,
96
+ "workflow_step_id" text,
97
+ "correlation_id" text,
98
+ "causation_action_id" text,
99
+ "idempotency_scope" text,
100
+ "idempotency_key" text,
101
+ "idempotency_fingerprint" text,
102
+ "target_type" text NOT NULL,
103
+ "target_id" text NOT NULL,
104
+ "capability_id" text,
105
+ "capability_version" text,
106
+ "authorization_source" text,
107
+ "approval_id" text,
108
+ "amends_action_id" text,
109
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
110
+ );
111
+ --> statement-breakpoint
112
+ CREATE TABLE "action_ledger_payloads" (
113
+ "id" text PRIMARY KEY NOT NULL,
114
+ "action_id" text NOT NULL,
115
+ "payload_kind" text NOT NULL,
116
+ "schema_tag" text NOT NULL,
117
+ "redaction_status" "action_ledger_redaction_status" DEFAULT 'none' NOT NULL,
118
+ "retention_policy" text NOT NULL,
119
+ "storage_ref" text NOT NULL,
120
+ "hash" text,
121
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
122
+ "expires_at" timestamp with time zone
123
+ );
124
+ --> statement-breakpoint
125
+ CREATE TABLE "action_ledger_outbox" (
126
+ "id" text PRIMARY KEY NOT NULL,
127
+ "action_id" text NOT NULL,
128
+ "organization_id" text,
129
+ "relay_status" "action_ledger_relay_status" DEFAULT 'pending' NOT NULL,
130
+ "payload_ref" text,
131
+ "attempt_count" integer DEFAULT 0 NOT NULL,
132
+ "next_retry_at" timestamp with time zone,
133
+ "last_error" text,
134
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
135
+ "processed_at" timestamp with time zone
136
+ );
137
+ --> statement-breakpoint
138
+ CREATE TABLE "action_mutation_details" (
139
+ "action_id" text PRIMARY KEY NOT NULL,
140
+ "command_input_ref" text,
141
+ "command_result_ref" text,
142
+ "summary" text,
143
+ "reversal_kind" "action_ledger_reversal_kind" DEFAULT 'none' NOT NULL,
144
+ "reversal_command_id" text,
145
+ "reversal_command_version" text,
146
+ "reversal_args_ref" text,
147
+ "reversal_state_projection" "action_ledger_reversal_state",
148
+ "reversal_outcome_projection" "action_ledger_reversal_outcome",
149
+ "reverses_action_id" text,
150
+ "reversed_by_action_id_projection" text
151
+ );
152
+ --> statement-breakpoint
153
+ CREATE TABLE "action_sensitive_read_details" (
154
+ "action_id" text PRIMARY KEY NOT NULL,
155
+ "reason_code" text,
156
+ "disclosed_field_set" jsonb,
157
+ "disclosure_summary" text,
158
+ "decision_policy" text
159
+ );
160
+ --> statement-breakpoint
161
+ 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
162
+ 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
163
+ 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
164
+ 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
165
+ 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
166
+ CREATE INDEX "idx_action_approvals_requested_action" ON "action_approvals" USING btree ("requested_action_id");--> statement-breakpoint
167
+ CREATE INDEX "idx_action_approvals_status_expires" ON "action_approvals" USING btree ("status","expires_at");--> statement-breakpoint
168
+ CREATE INDEX "idx_action_approvals_assignee" ON "action_approvals" USING btree ("assigned_to_principal_id","created_at");--> statement-breakpoint
169
+ CREATE INDEX "idx_action_delegations_root" ON "action_delegations" USING btree ("root_principal_type","root_principal_id");--> statement-breakpoint
170
+ CREATE INDEX "idx_action_delegations_child" ON "action_delegations" USING btree ("child_principal_type","child_principal_id");--> statement-breakpoint
171
+ CREATE INDEX "idx_action_delegations_parent" ON "action_delegations" USING btree ("parent_principal_type","parent_principal_id");--> statement-breakpoint
172
+ CREATE INDEX "idx_action_ledger_entries_principal" ON "action_ledger_entries" USING btree ("principal_type","principal_id","occurred_at");--> statement-breakpoint
173
+ CREATE INDEX "idx_action_ledger_entries_api_token" ON "action_ledger_entries" USING btree ("api_token_id","occurred_at");--> statement-breakpoint
174
+ CREATE INDEX "idx_action_ledger_entries_session" ON "action_ledger_entries" USING btree ("session_id","occurred_at");--> statement-breakpoint
175
+ CREATE INDEX "idx_action_ledger_entries_target" ON "action_ledger_entries" USING btree ("target_type","target_id","occurred_at");--> statement-breakpoint
176
+ CREATE INDEX "idx_action_ledger_entries_workflow" ON "action_ledger_entries" USING btree ("workflow_run_id","workflow_step_id","occurred_at");--> statement-breakpoint
177
+ CREATE INDEX "idx_action_ledger_entries_correlation" ON "action_ledger_entries" USING btree ("correlation_id","occurred_at");--> statement-breakpoint
178
+ CREATE INDEX "idx_action_ledger_entries_causation" ON "action_ledger_entries" USING btree ("causation_action_id");--> statement-breakpoint
179
+ CREATE INDEX "idx_action_ledger_entries_control_state" ON "action_ledger_entries" USING btree ("evaluated_risk","status","occurred_at");--> statement-breakpoint
180
+ CREATE INDEX "idx_action_ledger_entries_capability" ON "action_ledger_entries" USING btree ("capability_id","capability_version","occurred_at");--> statement-breakpoint
181
+ 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
182
+ "action_ledger_entries"."idempotency_key" IS NOT NULL
183
+ ;--> statement-breakpoint
184
+ CREATE INDEX "idx_action_ledger_payloads_action" ON "action_ledger_payloads" USING btree ("action_id");--> statement-breakpoint
185
+ CREATE INDEX "idx_action_ledger_payloads_expiry" ON "action_ledger_payloads" USING btree ("expires_at");--> statement-breakpoint
186
+ CREATE INDEX "idx_action_ledger_outbox_action" ON "action_ledger_outbox" USING btree ("action_id");--> statement-breakpoint
187
+ CREATE INDEX "idx_action_ledger_outbox_status_retry" ON "action_ledger_outbox" USING btree ("relay_status","next_retry_at");--> statement-breakpoint
188
+ CREATE INDEX "idx_action_mutation_details_reverses" ON "action_mutation_details" USING btree ("reverses_action_id");--> statement-breakpoint
189
+ 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.3",
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.4",
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 && node ../../scripts/d2/guard-create-type.mjs ./migrations && node ../../scripts/d2/ensure-extensions.mjs ./migrations"
95
99
  },
96
100
  "main": "./dist/index.js",
97
101
  "types": "./dist/index.d.ts"