@agenticprimitives/tool-policy 1.0.0-alpha.5 → 1.0.0-alpha.50

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,8 +1,14 @@
1
1
  # @agenticprimitives/tool-policy
2
2
 
3
- Protocol-agnostic classification, risk tiers, and exact-call policy primitives. Consumable by MCP, A2A, LangGraph, Vercel AI — any tool runtime.
3
+ > Part of **[Agentic Primitives](https://agenticprimitives.dev)** — the open-source trust substrate for agentic applications: identity that can sign, authority checked at act time, evidence the owner carries. [Developer kit](https://github.com/agentictrustlabs/agentic-primitives) · [All packages](https://agenticprimitives.dev/developers)
4
4
 
5
- This package is **deliberately transport-free**: no MCP SDK, no LangChain, no Vercel imports. That's what lets a LangGraph user `pnpm add` it without buying into MCP middleware, and what lets `@agenticprimitives/mcp-runtime` use it without being the only consumer.
5
+ **One delegation model, everywhere — and this is the layer that decides.**
6
+
7
+ Agents are getting tool access faster than anyone is deciding what those tools should be allowed to do. The usual answer is an OAuth scope string or an API key with a prayer attached — coarse, transport-bound, and silent about risk. This package is the missing decision layer: a classification taxonomy (`@sa-tool`, `@sa-auth`, `@sa-validation`, `@sa-risk-tier` and friends), risk tiers with TTL clamps and required-caveat lookups, an exact-call DSL for byte-precise on-chain calls, and a deterministic decision engine — `evaluatePolicy(ctx)` returns `allow`, `deny`, or `requires-consent`, the same answer for the same input, every time. Unknown classification fields fail closed.
8
+
9
+ It is **deliberately transport-free**: no MCP SDK, no LangChain, no Vercel AI imports ([ADR-0003](../../docs/architecture/decisions/0003-tool-policy-protocol-agnostic.md)). A LangGraph user can `pnpm add` it without buying into MCP middleware, and `@agenticprimitives/mcp-runtime` consumes it without being the only consumer. This package decides; your runtime enforces.
10
+
11
+ > Part of [agenticprimitives](../../README.md) — the trust substrate for the agent economy: one canonical Smart Agent identity with custody, delegation, naming, credentials, and audit evidence designed as one system.
6
12
 
7
13
  See [`spec.md`](./spec.md) → [`specs/204-tool-policy.md`](../../specs/204-tool-policy.md).
8
14
 
@@ -34,6 +40,8 @@ if (decision.decision === 'requires-consent') /* prompt user */;
34
40
 
35
41
  ## Exact-call policy
36
42
 
43
+ When "roughly this kind of call" is not good enough, pin the exact one:
44
+
37
45
  ```ts
38
46
  import { exactCall, matchesExactCall } from '@agenticprimitives/tool-policy';
39
47
 
@@ -45,6 +53,19 @@ const policy = exactCall(safeAddress, '0xa9059cbb', {
45
53
  const ok = matchesExactCall({ to, data, value }, policy);
46
54
  ```
47
55
 
56
+ When `calldataHash` is set, matching is byte-identical — no partial-match shortcuts.
57
+
58
+ ## How it's different
59
+
60
+ OAuth scopes and general-purpose policy engines (OPA-style) are the incumbents here, and both have a gap this package targets. Scopes are static strings granted at consent time; they know nothing about risk tiers, value limits, or the delegation a caller actually holds. Policy engines are powerful but generic — you bring your own identity model, your own risk taxonomy, and your own integration glue per transport. This package ships the agent-tooling-specific layer pre-built: a risk taxonomy designed for tool calls, decisions that compose with `Delegation` objects from `@agenticprimitives/delegation` (consumed type-only — no runtime coupling), and a deterministic, side-effect-free engine you can golden-test. The decision an MCP server enforces is the same decision a LangGraph or A2A runtime would get, because the policy layer never learned what transport it lives in.
61
+
62
+ ## Validate
63
+
64
+ ```bash
65
+ pnpm --filter @agenticprimitives/tool-policy typecheck
66
+ pnpm --filter @agenticprimitives/tool-policy test
67
+ ```
68
+
48
69
  ## Status
49
70
 
50
- Alpha track — testnet-only. Spec + API stable; do not deploy to production until the gates listed in the root [`README.md` Status section](../../README.md#status) are cleared.
71
+ **Alpha track — testnet-only.** Spec + API stable; do not deploy to production until the gates listed in the root [`README.md` Status section](../../README.md#status) are cleared — including third-party contract audit and governance key rotation. Track every security finding live in [`docs/audits/findings.yaml`](../../docs/audits/findings.yaml).
@@ -0,0 +1,62 @@
1
+ import type { Hex } from '@agenticprimitives/types';
2
+ import type { RiskTier } from './types.js';
3
+ /** The three authority tiers. T0 communication (sender-proof only), T1 execution-fast (cached-verdict read),
4
+ * T2 execution-orchestrated (full delegation gate + async task). */
5
+ export type AuthorityTier = 'communication' | 'execution-fast' | 'execution-orchestrated';
6
+ /** The execution lane a tier rides. `fast` = the low-overhead warm path (T0/T1); `orchestrated` = the
7
+ * heavyweight async task path (T2). */
8
+ export type ExecLane = 'fast' | 'orchestrated';
9
+ /** What a surface DOES below the authority line. Only `read` is ever fast-lane eligible. */
10
+ export type SurfaceEffect = 'read' | 'write' | 'value' | 'admin';
11
+ /** Data sensitivity of a surface. Anything other than `public` is hard-T2 (L3), never fast-lane. */
12
+ export type SurfaceSensitivity = 'public' | 'confidential' | 'sensitive';
13
+ /** The server-owned authority facet of a SurfaceDescriptor — the ONLY source of effect / sensitivity / T1
14
+ * eligibility. Authored server-side; never derived from a request. */
15
+ export interface SurfaceAuthorityDescriptor {
16
+ /** 4-byte skill selector = `keccak256(skill)[:4]`, server-computed (`computeSkillSelector`). */
17
+ selector: Hex;
18
+ effect: SurfaceEffect;
19
+ sensitivity: SurfaceSensitivity;
20
+ /** Positive, deny-by-default T1 allowlist membership. `false`/absent ⇒ never fast-lane. */
21
+ t1Eligible: boolean;
22
+ /** Optional risk tier carried into the verdict for downstream caveat / consent requirements. */
23
+ risk?: RiskTier;
24
+ }
25
+ /** The authority class the gate acts on. */
26
+ export interface SkillAuthorityClass {
27
+ tier: AuthorityTier;
28
+ lane: ExecLane;
29
+ risk?: RiskTier;
30
+ /** For T1: the exact selector the cached verdict + per-call caveat pass are scoped to. */
31
+ toolScope?: Hex[];
32
+ /** Why the class was assigned (esp. why over-classified / hard-T2) — for the audit trail. */
33
+ reason?: string;
34
+ }
35
+ /** Classification input. `communication` = a message delivery (T0, no selector). `execution` = a skill/tool
36
+ * invocation carrying its server-computed selector. `effect`/`sensitivity` are NEVER accepted here — the
37
+ * fabric maps its closed `kind` set to `communication | execution` server-side before calling. */
38
+ export type ClassifyInput = {
39
+ kind: 'communication';
40
+ } | {
41
+ kind: 'execution';
42
+ skillSelector: Hex;
43
+ };
44
+ /** Server-owned registry: lowercased selector → authority descriptor. */
45
+ export type SkillAuthorityRegistry = ReadonlyMap<string, SurfaceAuthorityDescriptor>;
46
+ /** `keccak256(utf8(skill))[:4]` — the server-computed skill selector. The gate computes this ITSELF from the
47
+ * invoked skill name; it is never trusted from the client. */
48
+ export declare function computeSkillSelector(skill: string): Hex;
49
+ /** Build a registry from descriptors, keyed by lowercased selector. Validates selector shape (fail-closed). */
50
+ export declare function buildSkillAuthorityRegistry(descriptors: readonly SurfaceAuthorityDescriptor[]): SkillAuthorityRegistry;
51
+ /**
52
+ * Classify an exchange into its authority tier + execution lane. Pure, server-authoritative, fail-closed.
53
+ *
54
+ * - `communication` → T0 fast (sender-proof only; no selector, no delegation).
55
+ * - `execution` + registry HIT that is `t1Eligible ∧ read ∧ public` → T1 fast.
56
+ * - `execution` + registry HIT otherwise (write/value/admin, or `sensitivity != public`, or not allowlisted) → T2.
57
+ * - `execution` + registry MISS → T2 / critical (over-classified).
58
+ *
59
+ * `effect`/`sensitivity` are read from the server-owned `registry`, never from the caller.
60
+ */
61
+ export declare function classifyExchange(input: ClassifyInput, registry: SkillAuthorityRegistry): SkillAuthorityClass;
62
+ //# sourceMappingURL=authority-tier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority-tier.d.ts","sourceRoot":"","sources":["../src/authority-tier.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;qEACqE;AACrE,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,gBAAgB,GAAG,wBAAwB,CAAC;AAE1F;wCACwC;AACxC,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,cAAc,CAAC;AAE/C,4FAA4F;AAC5F,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAEjE,oGAAoG;AACpG,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,cAAc,GAAG,WAAW,CAAC;AAEzE;uEACuE;AACvE,MAAM,WAAW,0BAA0B;IACzC,gGAAgG;IAChG,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,EAAE,kBAAkB,CAAC;IAChC,2FAA2F;IAC3F,UAAU,EAAE,OAAO,CAAC;IACpB,gGAAgG;IAChG,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAClB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;mGAEmG;AACnG,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,aAAa,EAAE,GAAG,CAAA;CAAE,CAAC;AAE9C,yEAAyE;AACzE,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;AAIrF;+DAC+D;AAC/D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAKvD;AAED,+GAA+G;AAC/G,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,SAAS,0BAA0B,EAAE,GACjD,sBAAsB,CAgBxB;AAUD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,sBAAsB,GAC/B,mBAAmB,CAqBrB"}
@@ -0,0 +1,85 @@
1
+ // Authority-tier classification — the ONE server-authoritative source that BOTH the fabric ingress gate and
2
+ // the mcp-runtime delegation gate read to decide which execution LANE an exchange rides (spec 316 §3a/§(c),
3
+ // Blocker 2 + L3). One table, two gates.
4
+ //
5
+ // Invariants (all fail-closed):
6
+ // - The tier is derived SERVER-SIDE from the skill SELECTOR looked up in a server-owned registry — NEVER
7
+ // from a client-supplied effect/sensitivity/kind. `classifyExchange` therefore accepts only a
8
+ // discriminated `{communication | execution+selector}` input; effect/sensitivity live in the registry.
9
+ // - Over-classify by default: a registry MISS returns the MOST RESTRICTIVE class (execution-orchestrated /
10
+ // critical), never a permissive default (ADR-0013 fail-closed; mirrors smart-agent `risk-tiers`
11
+ // "miss → the heavier tier, never the lighter").
12
+ // - L3 hard-T2: a surface with `sensitivity != 'public'` is NEVER fast-lane (T1) eligible regardless of its
13
+ // effect flag. T1 eligibility is a positive, deny-by-default allowlist AND `effect === 'read'` AND
14
+ // `sensitivity === 'public'`.
15
+ // - Communication (T0) is the delivery of a message; it carries no skill selector and can never reach an
16
+ // execution handler, so a mislabeled communication exchange is at most delivered, never executed.
17
+ import { keccak_256 } from '@noble/hashes/sha3.js';
18
+ const SELECTOR_RE = /^0x[0-9a-fA-F]{8}$/;
19
+ /** `keccak256(utf8(skill))[:4]` — the server-computed skill selector. The gate computes this ITSELF from the
20
+ * invoked skill name; it is never trusted from the client. */
21
+ export function computeSkillSelector(skill) {
22
+ const out = keccak_256(new TextEncoder().encode(skill));
23
+ let s = '0x';
24
+ for (let i = 0; i < 4; i++)
25
+ s += out[i].toString(16).padStart(2, '0');
26
+ return s;
27
+ }
28
+ /** Build a registry from descriptors, keyed by lowercased selector. Validates selector shape (fail-closed). */
29
+ export function buildSkillAuthorityRegistry(descriptors) {
30
+ const m = new Map();
31
+ for (const d of descriptors) {
32
+ if (!SELECTOR_RE.test(d.selector)) {
33
+ throw new Error(`buildSkillAuthorityRegistry: selector must be 4 bytes (0x + 8 hex); got "${d.selector}"`);
34
+ }
35
+ const key = d.selector.toLowerCase();
36
+ // A selector is 32 bits of a hash of the skill name: two skills CAN share one, and a second descriptor
37
+ // used to replace the first silently — re-classifying a `value/sensitive` skill as fast-lane (spec 445 /
38
+ // ING-12). A duplicate is a configuration error, never last-write-wins.
39
+ if (m.has(key)) {
40
+ throw new Error(`buildSkillAuthorityRegistry: selector ${key} is registered twice — a selector collision or a duplicate descriptor`);
41
+ }
42
+ m.set(key, d);
43
+ }
44
+ return m;
45
+ }
46
+ /** The MOST RESTRICTIVE class — the fail-closed default for a registry miss. */
47
+ const OVER_CLASSIFIED = Object.freeze({
48
+ tier: 'execution-orchestrated',
49
+ lane: 'orchestrated',
50
+ risk: 'critical',
51
+ reason: 'registry-miss:over-classified',
52
+ });
53
+ /**
54
+ * Classify an exchange into its authority tier + execution lane. Pure, server-authoritative, fail-closed.
55
+ *
56
+ * - `communication` → T0 fast (sender-proof only; no selector, no delegation).
57
+ * - `execution` + registry HIT that is `t1Eligible ∧ read ∧ public` → T1 fast.
58
+ * - `execution` + registry HIT otherwise (write/value/admin, or `sensitivity != public`, or not allowlisted) → T2.
59
+ * - `execution` + registry MISS → T2 / critical (over-classified).
60
+ *
61
+ * `effect`/`sensitivity` are read from the server-owned `registry`, never from the caller.
62
+ */
63
+ export function classifyExchange(input, registry) {
64
+ if (input.kind === 'communication') {
65
+ return { tier: 'communication', lane: 'fast' };
66
+ }
67
+ const d = registry.get(input.skillSelector.toLowerCase());
68
+ if (!d)
69
+ return { ...OVER_CLASSIFIED };
70
+ const fastEligible = d.t1Eligible && d.effect === 'read' && d.sensitivity === 'public';
71
+ if (fastEligible) {
72
+ return { tier: 'execution-fast', lane: 'fast', risk: d.risk, toolScope: [d.selector.toLowerCase()] };
73
+ }
74
+ return {
75
+ tier: 'execution-orchestrated',
76
+ lane: 'orchestrated',
77
+ risk: d.risk ?? 'critical',
78
+ reason: d.sensitivity !== 'public'
79
+ ? 'hard-T2:sensitivity'
80
+ : d.effect !== 'read'
81
+ ? 'hard-T2:effect'
82
+ : 'hard-T2:not-allowlisted',
83
+ };
84
+ }
85
+ //# sourceMappingURL=authority-tier.js.map
@@ -0,0 +1 @@
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IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,UAAU;QAC1B,MAAM,EACJ,CAAC,CAAC,WAAW,KAAK,QAAQ;YACxB,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM;gBACnB,CAAC,CAAC,gBAAgB;gBAClB,CAAC,CAAC,yBAAyB;KAClC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,35 @@
1
+ /** The fields the lint reads. Everything is optional; an unknown extra field is ignored. */
2
+ export interface CapabilityLintableTool {
3
+ id?: string;
4
+ name?: string;
5
+ capability?: unknown;
6
+ risk?: unknown;
7
+ effects?: unknown;
8
+ establishes?: unknown;
9
+ invoke?: unknown;
10
+ }
11
+ export type CapabilityLintSignal = 'effects' | 'risk' | 'establishes' | 'invoke';
12
+ export interface CapabilityLintFinding {
13
+ /** The tool's `id` (else `name`, else `#<index>`). */
14
+ tool: string;
15
+ code: 'consequence-without-capability';
16
+ /** What the tool declared that is a consequence. */
17
+ signals: CapabilityLintSignal[];
18
+ message: string;
19
+ }
20
+ export interface CapabilityLintOpts {
21
+ /** `true` ⇒ throw `CapabilityLintError` when there is any finding. Default `false` (a returned warning list);
22
+ * a composition root that is production enables it (the harness does by default). */
23
+ strict?: boolean;
24
+ }
25
+ export declare class CapabilityLintError extends Error {
26
+ readonly findings: CapabilityLintFinding[];
27
+ constructor(findings: CapabilityLintFinding[]);
28
+ }
29
+ /**
30
+ * Lint descriptors for "declares a consequence, names no capability". Returns the findings (a warning list);
31
+ * with `strict: true` throws `CapabilityLintError` instead when any exist. A tool WITH a capability is never a
32
+ * finding here (its risk is `stepRiskClass`'s business); a pure read with no capability is never one either.
33
+ */
34
+ export declare function lintCapabilityDeclarations(tools: ReadonlyArray<CapabilityLintableTool>, opts?: CapabilityLintOpts): CapabilityLintFinding[];
35
+ //# sourceMappingURL=capability-lint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-lint.d.ts","sourceRoot":"","sources":["../src/capability-lint.ts"],"names":[],"mappings":"AASA,4FAA4F;AAC5F,MAAM,WAAW,sBAAsB;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,MAAM,GAAG,aAAa,GAAG,QAAQ,CAAC;AAEjF,MAAM,WAAW,qBAAqB;IACpC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gCAAgC,CAAC;IACvC,oDAAoD;IACpD,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC;0FACsF;IACtF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,EAAE,CAAC;gBAC/B,QAAQ,EAAE,qBAAqB,EAAE;CAK9C;AAcD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,aAAa,CAAC,sBAAsB,CAAC,EAAE,IAAI,GAAE,kBAAuB,GAAG,qBAAqB,EAAE,CAiB/I"}
@@ -0,0 +1,58 @@
1
+ // Spec 445 §9 decision 8 (D3) — "no capability ⇒ informational" STAYS (spec 350 §3.1, `stepRiskClass`), and a
2
+ // LINT catches the descriptor that makes that rule lie: a tool that DECLARES consequences — effects, a risk above
3
+ // informational, an outcome that is a submission or the authoritative outcome itself, an executor invoke — but
4
+ // names no capability. `stepRiskClass` would read it as informational and require no mandate for it; the lint
5
+ // says so where the tool is registered or composed, before a run.
6
+ //
7
+ // Structural input only (this package imports no tool-model package): any descriptor with these optional fields —
8
+ // orchestration's `ToolSpec`, capability-claims' `DefinitionToolV1` / contract tool — lints as-is.
9
+ export class CapabilityLintError extends Error {
10
+ findings;
11
+ constructor(findings) {
12
+ super(`tool-policy: ${findings.length} tool(s) declare consequences but no capability — "no capability ⇒ informational" would run them with no mandate: ${findings.map((f) => `${f.tool} (${f.signals.join(', ')})`).join('; ')}`);
13
+ this.name = 'CapabilityLintError';
14
+ this.findings = findings;
15
+ }
16
+ }
17
+ const READ_RISKS = new Set([undefined, null, 'informational', 'R0']);
18
+ function signalsOf(t) {
19
+ const out = [];
20
+ if (Array.isArray(t.effects) ? t.effects.length > 0 : t.effects !== undefined && t.effects !== null)
21
+ out.push('effects');
22
+ // Any risk that is not explicitly a read — including a value outside the vocabulary — is a consequence.
23
+ if (!READ_RISKS.has(t.risk))
24
+ out.push('risk');
25
+ if (t.establishes === 'submission' || t.establishes === 'authoritative')
26
+ out.push('establishes');
27
+ if (t.invoke !== undefined && t.invoke !== null)
28
+ out.push('invoke');
29
+ return out;
30
+ }
31
+ /**
32
+ * Lint descriptors for "declares a consequence, names no capability". Returns the findings (a warning list);
33
+ * with `strict: true` throws `CapabilityLintError` instead when any exist. A tool WITH a capability is never a
34
+ * finding here (its risk is `stepRiskClass`'s business); a pure read with no capability is never one either.
35
+ */
36
+ export function lintCapabilityDeclarations(tools, opts = {}) {
37
+ const findings = [];
38
+ tools.forEach((t, i) => {
39
+ if (!t || typeof t !== 'object')
40
+ return;
41
+ if (t.capability)
42
+ return;
43
+ const signals = signalsOf(t);
44
+ if (signals.length === 0)
45
+ return;
46
+ const tool = typeof t.id === 'string' && t.id ? t.id : typeof t.name === 'string' && t.name ? t.name : `#${i}`;
47
+ findings.push({
48
+ tool,
49
+ code: 'consequence-without-capability',
50
+ signals,
51
+ message: `${tool} declares ${signals.join(', ')} but no capability: it would be classified informational and run with no mandate — declare the capability it exercises, or drop the consequence`,
52
+ });
53
+ });
54
+ if (opts.strict === true && findings.length > 0)
55
+ throw new CapabilityLintError(findings);
56
+ return findings;
57
+ }
58
+ //# sourceMappingURL=capability-lint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-lint.js","sourceRoot":"","sources":["../src/capability-lint.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,kHAAkH;AAClH,+GAA+G;AAC/G,8GAA8G;AAC9G,kEAAkE;AAClE,EAAE;AACF,kHAAkH;AAClH,mGAAmG;AA8BnG,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,QAAQ,CAA0B;IAC3C,YAAY,QAAiC;QAC3C,KAAK,CAAC,gBAAgB,QAAQ,CAAC,MAAM,qHAAqH,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnO,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,UAAU,GAAyB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC;AAE3F,SAAS,SAAS,CAAC,CAAyB;IAC1C,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO,KAAK,IAAI;QAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzH,wGAAwG;IACxG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAA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IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACzF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ToolClassification } from './types';
1
+ import type { ToolClassification } from './types.js';
2
2
  export declare function declareTool<T>(def: T, classification: ToolClassification): T & {
3
3
  _classification: ToolClassification;
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"classification.d.ts","sourceRoot":"","sources":["../src/classification.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,EAAE,CAAC,EACN,cAAc,EAAE,kBAAkB,GACjC,CAAC,GAAG;IAAE,eAAe,EAAE,kBAAkB,CAAA;CAAE,CAI7C"}
1
+ {"version":3,"file":"classification.d.ts","sourceRoot":"","sources":["../src/classification.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,EAAE,CAAC,EACN,cAAc,EAAE,kBAAkB,GACjC,CAAC,GAAG;IAAE,eAAe,EAAE,kBAAkB,CAAA;CAAE,CAI7C"}
@@ -1,3 +1,3 @@
1
- import type { PolicyContext, PolicyDecision } from './types';
1
+ import type { PolicyContext, PolicyDecision } from './types.js';
2
2
  export declare function evaluatePolicy(ctx: PolicyContext): PolicyDecision;
3
3
  //# sourceMappingURL=decision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../src/decision.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAsB,MAAM,SAAS,CAAC;AAsDjF,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CA4CjE"}
1
+ {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../src/decision.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAsB,MAAM,YAAY,CAAC;AAsDpF,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CA4CjE"}
@@ -1,5 +1,5 @@
1
1
  import type { Address, Hex } from '@agenticprimitives/types';
2
- import type { ExactCallPolicy } from './types';
2
+ import type { ExactCallPolicy } from './types.js';
3
3
  export declare function exactCall(target: Address, selector: Hex, opts?: {
4
4
  calldataHash?: Hex;
5
5
  valueLimit?: bigint;
@@ -1 +1 @@
1
- {"version":3,"file":"exact-call.d.ts","sourceRoot":"","sources":["../src/exact-call.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAY/C,wBAAgB,SAAS,CACvB,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,GAAG,EACb,IAAI,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACjD,eAAe,CAajB;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC/C,MAAM,EAAE,eAAe,GACtB,OAAO,CAeT"}
1
+ {"version":3,"file":"exact-call.d.ts","sourceRoot":"","sources":["../src/exact-call.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAkBlD,wBAAgB,SAAS,CACvB,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,GAAG,EACb,IAAI,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACjD,eAAe,CAajB;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC/C,MAAM,EAAE,eAAe,GACtB,OAAO,CAkBT"}
@@ -4,8 +4,14 @@
4
4
  // Used for critical-tier operations where the user should authorize the
5
5
  // exact intent and nothing else.
6
6
  import { keccak_256 } from '@noble/hashes/sha3.js';
7
+ /** Well-formed call data: `0x` + whole bytes of hex, nothing else. */
8
+ const CALLDATA_RE = /^0x(?:[0-9a-fA-F]{2})*$/;
7
9
  function keccak256OfHex(hex) {
8
- const cleaned = hex.startsWith('0x') ? hex.slice(2) : hex;
10
+ // Hashing input a strict decoder would reject hashes DIFFERENT bytes than would execute (spec 445 / ING-12):
11
+ // `parseInt('zz', 16)` is NaN → 0, and an odd trailing nibble was dropped.
12
+ if (!CALLDATA_RE.test(hex))
13
+ throw new Error('exact-call: call data is not well-formed hex');
14
+ const cleaned = hex.slice(2);
9
15
  const bytes = new Uint8Array(cleaned.length / 2);
10
16
  for (let i = 0; i < bytes.length; i++)
11
17
  bytes[i] = parseInt(cleaned.slice(i * 2, i * 2 + 2), 16);
@@ -32,7 +38,11 @@ export function exactCall(target, selector, opts) {
32
38
  export function matchesExactCall(call, policy) {
33
39
  if (call.to.toLowerCase() !== policy.target.toLowerCase())
34
40
  return false;
35
- if (!call.data.startsWith('0x') || call.data.length < 10)
41
+ // Whole bytes of hex, at least a selector. `0x12345678f` (an odd nibble) or non-hex is not a call this
42
+ // policy can be said to match — the bytes that would execute are not the bytes compared (ING-12).
43
+ if (typeof call.data !== 'string' || !CALLDATA_RE.test(call.data) || call.data.length < 10)
44
+ return false;
45
+ if (typeof call.value !== 'bigint' || call.value < 0n)
36
46
  return false;
37
47
  const callSelector = call.data.slice(0, 10).toLowerCase();
38
48
  if (callSelector !== policy.selector.toLowerCase())
@@ -1 +1 @@
1
- {"version":3,"file":"exact-call.js","sourceRoot":"","sources":["../src/exact-call.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,qEAAqE;AACrE,EAAE;AACF,wEAAwE;AACxE,iCAAiC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,SAAS,cAAc,CAAC,GAAQ;IAC9B,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1D,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChG,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG,IAAI,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,GAAG;QAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,OAAO,CAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,MAAe,EACf,QAAa,EACb,IAAkD;IAElD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK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AE,KAAK,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE;YAAE,OAAO,KAAK,CAAC;IACjF,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IAEpF,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,13 @@
1
- export { declareTool } from './classification';
2
- export { exactCall, matchesExactCall } from './exact-call';
3
- export { evaluatePolicy } from './decision';
4
- export { clampTtlForRiskTier, requiredCaveatsForRiskTier, evaluateThresholdPolicy, RISK_TIER_REQUIREMENTS, } from './risk-tier';
5
- export { lintClassification } from './lint';
6
- export { ThresholdTier } from './types';
7
- export type { Address, Hex, RiskTier, ToolClassification, ExactCallPolicy, CaveatLike, DelegationLike, CaveatContext, PolicyContext, PolicyDecision, ThresholdPolicyDecision, LintResult, } from './types';
1
+ export { declareTool } from './classification.js';
2
+ export { exactCall, matchesExactCall } from './exact-call.js';
3
+ export { evaluatePolicy } from './decision.js';
4
+ export { clampTtlForRiskTier, requiredCaveatsForRiskTier, evaluateThresholdPolicy, RISK_TIER_REQUIREMENTS, } from './risk-tier.js';
5
+ export { ThresholdTier } from './types.js';
6
+ export { classifyExchange, computeSkillSelector, buildSkillAuthorityRegistry, } from './authority-tier.js';
7
+ export type { AuthorityTier, ExecLane, SurfaceEffect, SurfaceSensitivity, SurfaceAuthorityDescriptor, SkillAuthorityClass, ClassifyInput, SkillAuthorityRegistry, } from './authority-tier.js';
8
+ export type { Address, Hex, RiskTier, ToolClassification, ExactCallPolicy, CaveatLike, DelegationLike, CaveatContext, PolicyContext, PolicyDecision, ThresholdPolicyDecision, LintResult, } from './types.js';
9
+ export { MINIMUM_AUTHORITY, stepRiskClass, riskAtLeast } from './step-risk.js';
10
+ export type { StepRiskClass, MinimumAuthority } from './step-risk.js';
11
+ export { lintCapabilityDeclarations, CapabilityLintError } from './capability-lint.js';
12
+ export type { CapabilityLintableTool, CapabilityLintFinding, CapabilityLintOpts, CapabilityLintSignal } from './capability-lint.js';
8
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,YAAY,EACV,OAAO,EACP,GAAG,EACH,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,UAAU,GACX,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,aAAa,EACb,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,OAAO,EACP,GAAG,EACH,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,UAAU,GACX,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC/E,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGtE,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACvF,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -6,11 +6,17 @@
6
6
  // transport SDK (see capability.manifest.json:forbiddenImports for the full
7
7
  // list and docs/architecture/decisions/0003-tool-policy-protocol-agnostic.md
8
8
  // for why).
9
- export { declareTool } from './classification';
10
- export { exactCall, matchesExactCall } from './exact-call';
11
- export { evaluatePolicy } from './decision';
12
- export { clampTtlForRiskTier, requiredCaveatsForRiskTier, evaluateThresholdPolicy, RISK_TIER_REQUIREMENTS, } from './risk-tier';
13
- export { lintClassification } from './lint';
9
+ export { declareTool } from './classification.js';
10
+ export { exactCall, matchesExactCall } from './exact-call.js';
11
+ export { evaluatePolicy } from './decision.js';
12
+ export { clampTtlForRiskTier, requiredCaveatsForRiskTier, evaluateThresholdPolicy, RISK_TIER_REQUIREMENTS, } from './risk-tier.js';
14
13
  // ThresholdTier is an enum (value export, not type-only).
15
- export { ThresholdTier } from './types';
14
+ export { ThresholdTier } from './types.js';
15
+ // Authority-tier classification (spec 316 §3a/§(c)) — the ONE server-authoritative source the fabric
16
+ // ingress gate and the mcp-runtime delegation gate both read to pick the execution LANE. Fail-closed.
17
+ export { classifyExchange, computeSkillSelector, buildSkillAuthorityRegistry, } from './authority-tier.js';
18
+ // ─── Spec 350 §3.4 — per-step risk → minimum authority ───────────────────────────────────────────────
19
+ export { MINIMUM_AUTHORITY, stepRiskClass, riskAtLeast } from './step-risk.js';
20
+ // ─── Spec 445 §9 decision 8 (D3) — a consequence with no capability is a lint finding ───────────────
21
+ export { lintCapabilityDeclarations, CapabilityLintError } from './capability-lint.js';
16
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,4DAA4D;AAC5D,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,6EAA6E;AAC7E,YAAY;AAEZ,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,4DAA4D;AAC5D,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,6EAA6E;AAC7E,YAAY;AAEZ,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,qGAAqG;AACrG,sGAAsG;AACtG,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AA2B7B,wGAAwG;AACxG,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG/E,uGAAuG;AACvG,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/lint.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { LintResult } from './types';
1
+ import type { LintResult } from './types.js';
2
2
  interface LintOpts {
3
3
  srcDir: string;
4
4
  requiredTags: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAgBD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CA4B5E"}
1
+ {"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7C,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAgBD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CA4B5E"}
@@ -1,4 +1,4 @@
1
- import type { RiskTier, ToolClassification, ThresholdPolicyDecision } from './types';
1
+ import type { RiskTier, ToolClassification, ThresholdPolicyDecision } from './types.js';
2
2
  export declare function clampTtlForRiskTier(requestedTtlSec: number, risk: RiskTier): number;
3
3
  export declare function requiredCaveatsForRiskTier(risk: RiskTier): string[];
4
4
  export declare const RISK_TIER_REQUIREMENTS: Record<RiskTier, ThresholdPolicyDecision>;
@@ -1 +1 @@
1
- {"version":3,"file":"risk-tier.d.ts","sourceRoot":"","sources":["../src/risk-tier.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAiBjB,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAMnF;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CAEnE;AAqBD,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAyB5E,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,kBAAkB,GACjC,uBAAuB,CAGzB"}
1
+ {"version":3,"file":"risk-tier.d.ts","sourceRoot":"","sources":["../src/risk-tier.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAiBpB,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAMnF;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CAEnE;AAqBD,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAyB5E,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,kBAAkB,GACjC,uBAAuB,CAGzB"}
package/dist/risk-tier.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Risk-tier helpers. The taxonomy is the binding contract — these helpers
2
2
  // surface "what should issuance demand for this tier."
3
- import { ThresholdTier } from './types';
3
+ import { ThresholdTier } from './types.js';
4
4
  const TTL_CLAMP_SECONDS = {
5
5
  low: 7 * 24 * 60 * 60, // 7 days
6
6
  medium: 7 * 24 * 60 * 60, // 7 days
@@ -1 +1 @@
1
- {"version":3,"file":"risk-tier.js","sourceRoot":"","sources":["../src/risk-tier.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uDAAuD;AAOvD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,iBAAiB,GAA6B;IAClD,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAS,SAAS;IACvC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAM,SAAS;IACvC,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAY,QAAQ;IACtC,QAAQ,EAAE,EAAE,GAAG,EAAE,EAAa,SAAS;CACxC,CAAC;AAEF,MAAM,gBAAgB,GAA+B;IACnD,GAAG,EAAE,CAAC,WAAW,CAAC;IAClB,MAAM,EAAE,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACvC,IAAI,EAAE,CAAC,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC;IAC5D,QAAQ,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;CACtC,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,eAAuB,EAAE,IAAc;IACzE,IAAI,CAAC,MAAM,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AA0B,CAAC,IAAc;IACvD,OAAO,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,yEAAyE;AACzE,EAAE;AACF,kEAAkE;AAClE,+DAA+D;AAC/D,2DAA2D;AAC3D,oEAAoE;AACpE,8CAA8C;AAC9C,EAAE;AACF,kBAAkB;AAClB,+DAA+D;AAC/D,4DAA4D;AAC5D,4DAA4D;AAC5D,yEAAyE;AACzE,EAAE;AACF,iEAAiE;AACjE,qEAAqE;AACrE,sEAAsE;AACtE,8CAA8C;AAE9C,MAAM,CAAC,MAAM,sBAAsB,GAA8C;IAC/E,GAAG,EAAE;QACH,IAAI,EAAE,aAAa,CAAC,IAAI;QACxB,cAAc,EAAE,KAAK;QACrB,UAAU,EAAE,KAAK;QACjB,uBAAuB,EAAE,KAAK;KAC/B;IACD,MAAM,EAAE;QACN,IAAI,EAAE,aAAa,CAAC,KAAK;QACzB,cAAc,EAAE,KAAK;QACrB,UAAU,EAAE,IAAI;QAChB,uBAAuB,EAAE,KAAK;KAC/B;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,aAAa,CAAC,KAAK;QACzB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,IAAI;QAChB,uBAAuB,EAAE,KAAK;KAC/B;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,aAAa,CAAC,KAAK;QACzB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,IAAI;QAChB,uBAAuB,EAAE,IAAI;KAC9B;CACF,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CACrC,cAAkC;IAElC,MAAM,IAAI,GAAG,cAAc,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC;IACtD,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { RiskTier } from './types.js';
2
+ /** A step's risk: `informational` when it exercises no capability, else its tool's `RiskTier`. */
3
+ export type StepRiskClass = 'informational' | RiskTier;
4
+ /** The obligations a risk class imposes BEFORE execution, over and above a valid mandate. */
5
+ export interface MinimumAuthority {
6
+ /** Is a mandate required at all? False only for `informational`. */
7
+ mandate: boolean;
8
+ /** Must the step carry an idempotency key (a retry of a mutation is not a re-read)? */
9
+ idempotencyKey: boolean;
10
+ /** Obligation kinds the policy layer attaches. Names, not implementations — a `PolicyEvaluator`
11
+ * turns them into concrete `Obligation`s with who may discharge them. */
12
+ obligations: ReadonlyArray<'second-party-approval' | 'quorum' | 'fresh-authorization'>;
13
+ }
14
+ /**
15
+ * The DEFAULT ladder. A granting agent's own policy (an org's membership policy, a treasury's spend
16
+ * policy) may add to it and never subtract from it — the evaluator composes, it does not override.
17
+ *
18
+ * informational read; no consequence → nothing
19
+ * low reversible mutation → mandate
20
+ * medium significant mutation → mandate + idempotency key
21
+ * high financial / legal / external → + second-party approval
22
+ * critical irreversible / high-impact → + quorum + fresh authorization
23
+ */
24
+ export declare const MINIMUM_AUTHORITY: Readonly<Record<StepRiskClass, MinimumAuthority>>;
25
+ /** Derive a step's risk class from what its tool declares. No capability ⇒ informational, whatever the
26
+ * planner said — a plan cannot lower a risk, and it cannot raise one into needing authority either.
27
+ *
28
+ * A tool that DOES exercise a capability but declares no risk — or a risk outside the vocabulary — is
29
+ * `critical`, not `low` (spec 445 / ING-12): a missing classification is over-classified, the same direction
30
+ * `classifyExchange` takes on a registry miss. "Nobody said how risky" must never read as "barely risky". */
31
+ export declare function stepRiskClass(tool: {
32
+ capability?: unknown;
33
+ risk?: RiskTier;
34
+ }): StepRiskClass;
35
+ /** Is `a` at least as risky as `b`? For "an irreversible step imposes at least what a high one does". */
36
+ export declare function riskAtLeast(a: StepRiskClass, b: StepRiskClass): boolean;
37
+ //# sourceMappingURL=step-risk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-risk.d.ts","sourceRoot":"","sources":["../src/step-risk.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,kGAAkG;AAClG,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEvD,6FAA6F;AAC7F,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,uFAAuF;IACvF,cAAc,EAAE,OAAO,CAAC;IACxB;8EAC0E;IAC1E,WAAW,EAAE,aAAa,CAAC,uBAAuB,GAAG,QAAQ,GAAG,qBAAqB,CAAC,CAAC;CACxF;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAM/E,CAAC;AAIF;;;;;8GAK8G;AAC9G,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;CAAE,GAAG,aAAa,CAG5F;AAGD,yGAAyG;AACzG,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAMvE"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The DEFAULT ladder. A granting agent's own policy (an org's membership policy, a treasury's spend
3
+ * policy) may add to it and never subtract from it — the evaluator composes, it does not override.
4
+ *
5
+ * informational read; no consequence → nothing
6
+ * low reversible mutation → mandate
7
+ * medium significant mutation → mandate + idempotency key
8
+ * high financial / legal / external → + second-party approval
9
+ * critical irreversible / high-impact → + quorum + fresh authorization
10
+ */
11
+ export const MINIMUM_AUTHORITY = {
12
+ informational: { mandate: false, idempotencyKey: false, obligations: [] },
13
+ low: { mandate: true, idempotencyKey: false, obligations: [] },
14
+ medium: { mandate: true, idempotencyKey: true, obligations: [] },
15
+ high: { mandate: true, idempotencyKey: true, obligations: ['second-party-approval'] },
16
+ critical: { mandate: true, idempotencyKey: true, obligations: ['second-party-approval', 'quorum', 'fresh-authorization'] },
17
+ };
18
+ const RISK_TIERS = new Set(['low', 'medium', 'high', 'critical']);
19
+ /** Derive a step's risk class from what its tool declares. No capability ⇒ informational, whatever the
20
+ * planner said — a plan cannot lower a risk, and it cannot raise one into needing authority either.
21
+ *
22
+ * A tool that DOES exercise a capability but declares no risk — or a risk outside the vocabulary — is
23
+ * `critical`, not `low` (spec 445 / ING-12): a missing classification is over-classified, the same direction
24
+ * `classifyExchange` takes on a registry miss. "Nobody said how risky" must never read as "barely risky". */
25
+ export function stepRiskClass(tool) {
26
+ if (!tool.capability)
27
+ return 'informational';
28
+ return typeof tool.risk === 'string' && RISK_TIERS.has(tool.risk) ? tool.risk : 'critical';
29
+ }
30
+ const ORDER = ['informational', 'low', 'medium', 'high', 'critical'];
31
+ /** Is `a` at least as risky as `b`? For "an irreversible step imposes at least what a high one does". */
32
+ export function riskAtLeast(a, b) {
33
+ const ia = ORDER.indexOf(a);
34
+ const ib = ORDER.indexOf(b);
35
+ // A class outside the vocabulary is not "at least" anything, and nothing is known to be at least it.
36
+ if (ia < 0 || ib < 0)
37
+ return false;
38
+ return ia >= ib;
39
+ }
40
+ //# sourceMappingURL=step-risk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-risk.js","sourceRoot":"","sources":["../src/step-risk.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsD;IAClF,aAAa,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE;IACzE,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE;IAC9D,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE;IAChE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,uBAAuB,CAAC,EAAE;IACrF,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,uBAAuB,EAAE,QAAQ,EAAE,qBAAqB,CAAC,EAAE;CAC3H,CAAC;AAEF,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAEvF;;;;;8GAK8G;AAC9G,MAAM,UAAU,aAAa,CAAC,IAA+C;IAC3E,IAAI,CAAC,IAAI,CAAC,UAAU;QAAE,OAAO,eAAe,CAAC;IAC7C,OAAO,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;AAC7F,CAAC;AAED,MAAM,KAAK,GAAoB,CAAC,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AACtF,yGAAyG;AACzG,MAAM,UAAU,WAAW,CAAC,CAAgB,EAAE,CAAgB;IAC5D,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5B,qGAAqG;IACrG,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "name": "@agenticprimitives/tool-policy",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.50",
4
4
  "description": "Protocol-agnostic classification, risk tiers, and exact-call policy. Consumable by MCP, A2A, LangGraph, and Vercel AI tool runtimes.",
5
+ "homepage": "https://agenticprimitives.dev",
6
+ "bugs": {
7
+ "url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
8
+ },
9
+ "author": {
10
+ "name": "Agentic Trust Labs",
11
+ "url": "https://agenticprimitives.dev"
12
+ },
5
13
  "license": "MIT",
6
14
  "repository": {
7
15
  "type": "git",
8
16
  "url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
9
17
  "directory": "packages/tool-policy"
10
18
  },
11
- "homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/tool-policy",
12
- "bugs": {
13
- "url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
14
- },
15
19
  "type": "module",
16
20
  "main": "./dist/index.js",
17
21
  "types": "./dist/index.d.ts",
@@ -38,11 +42,11 @@
38
42
  "@noble/hashes": "^2.2.0"
39
43
  },
40
44
  "peerDependencies": {
41
- "@agenticprimitives/types": "1.0.0-alpha.5"
45
+ "@agenticprimitives/types": "^1.0.0-alpha.50"
42
46
  },
43
47
  "devDependencies": {
44
48
  "@types/node": "^22.7.0",
45
- "vitest": "^4.1.8"
49
+ "vitest": "^4.1.11"
46
50
  },
47
51
  "keywords": [
48
52
  "policy",
@@ -50,13 +54,18 @@
50
54
  "risk-tier",
51
55
  "exact-call",
52
56
  "agentic",
53
- "tool-policy"
57
+ "tool-policy",
58
+ "agentic-primitives",
59
+ "agenticprimitives",
60
+ "ai-agents",
61
+ "agent-authority",
62
+ "agentic-trust"
54
63
  ],
55
64
  "scripts": {
56
65
  "build": "tsc -p tsconfig.build.json",
57
66
  "typecheck": "tsc -p tsconfig.json --noEmit",
58
67
  "test": "vitest run",
59
- "test:unit": "vitest run test/unit",
68
+ "test:unit": "vitest run test/unit --passWithNoTests",
60
69
  "test:integration": "vitest run test/integration --passWithNoTests",
61
70
  "test:watch": "vitest",
62
71
  "clean": "rm -rf dist"