@axtary/approvals 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # @axtary/approvals
2
+
3
+ Hosted approval queue contract for exact Axtary step-up approvals.
4
+
5
+ This package is private workspace code while the hosted control plane API is being shaped.
6
+
7
+ ## What It Does
8
+
9
+ - Creates pending approval queue items from normalized actions and `step_up` policy decisions.
10
+ - Stores exact action hashes and payload hashes for reviewer trust.
11
+ - Records request provenance so reviewers can tell whether a request came from the proxy, SDK, API, dashboard, or demo tooling.
12
+ - Carries optional provider diff metadata so reviewers can inspect changed files and hunks before approving.
13
+ - Approves queue items by producing `@axtary/actionpass` approval artifacts.
14
+ - Denies queue items without producing executable approval evidence.
15
+ - Exposes a small in-memory queue implementation for API route tests and local demos.
16
+ - Persists hosted approval queue state to local JSON for development and self-hosted demos.
17
+ - Provides an HTTP client and resolver that local proxy runtimes can use to fetch approved artifacts.
18
+
19
+ ## Contract
20
+
21
+ The hosted control plane should coordinate approval state only. It should not hold downstream provider secrets or execute customer tool calls.
22
+
23
+ Local enforcement remains in `@axtary/proxy`. When a queued item is approved, the proxy can fetch the approval artifact and submit it through its `approvalResolver`; ActionPass issuance still validates that the artifact binds to the exact action and payload.
24
+
25
+ Queue items include provenance:
26
+
27
+ ```json
28
+ {
29
+ "provenance": {
30
+ "source": "proxy",
31
+ "createdBy": "agent:codex-prod",
32
+ "sourceId": "codex-cli",
33
+ "createdFrom": "axtary.proxy"
34
+ }
35
+ }
36
+ ```
37
+
38
+ Existing local JSON records without provenance parse as `source: "api"` for compatibility.
39
+
40
+ Queue items can also include provider-specific diff metadata:
41
+
42
+ ```json
43
+ {
44
+ "diff": {
45
+ "provider": "github",
46
+ "summary": "1 modified file, 2 additions, 1 deletion",
47
+ "files": [
48
+ {
49
+ "path": "infra/prod/main.tf",
50
+ "status": "modified",
51
+ "additions": 2,
52
+ "deletions": 1,
53
+ "hunks": [
54
+ {
55
+ "header": "@@ -12,3 +12,4 @@",
56
+ "lines": [
57
+ { "type": "context", "oldLine": 12, "newLine": 12, "content": "..." },
58
+ { "type": "deletion", "oldLine": 13, "content": "..." },
59
+ { "type": "addition", "newLine": 13, "content": "..." }
60
+ ]
61
+ }
62
+ ]
63
+ }
64
+ ]
65
+ }
66
+ }
67
+ ```
68
+
69
+ ## HTTP Shape
70
+
71
+ The Next app exposes the first local hosted API contract:
72
+
73
+ - `POST /api/approvals` creates a pending queue item from `{ action, decision }`.
74
+ - `GET /api/approvals?status=pending` lists queued items.
75
+ - `GET /api/approvals/:id` returns one queue item.
76
+ - `POST /api/approvals/:id/approve` resolves an item and returns an approval artifact.
77
+ - `POST /api/approvals/:id/deny` denies an item without returning approval evidence.
78
+ - `POST /api/approvals/demo` creates a local dashboard exercise request with `source: "demo"`.
79
+
80
+ Only `step_up` decisions can enter the queue.
81
+
82
+ By default, the Next API routes persist local development queue state to `.axtary/approvals.json`, which is ignored by git. Set `AXTARY_APPROVAL_STORE_PATH` to choose a different JSON file, or `AXTARY_APPROVAL_STORE_MODE=memory` for ephemeral tests.
83
+
84
+ ## Proxy Resolver
85
+
86
+ `createHostedApprovalResolver({ baseUrl })` returns a resolver compatible with the proxy `approvalResolver` shape:
87
+
88
+ ```ts
89
+ import { createHostedApprovalResolver } from "@axtary/approvals";
90
+
91
+ const approvalResolver = createHostedApprovalResolver({
92
+ baseUrl: "https://app.axtary.dev",
93
+ requestedBy: "agent:codex-prod",
94
+ });
95
+ ```
96
+
97
+ The resolver creates or reuses a deterministic approval request ID based on the action hash. It returns `null` while the request is pending or denied, and returns an approval artifact only after the hosted queue has approved the exact action payload.