@trigguard/protocol 0.1.0

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,77 @@
1
+ # `@trigguard/protocol`
2
+
3
+ The TrigGuard protocol defines the **contract for deterministic authorization decisions** between AI systems and execution surfaces: vocabulary (`PERMIT`, `DENY`, `SILENCE`), enforcement semantics, and the `DecisionRecord` shape used across aligned products and tooling.
4
+
5
+ **This package is governance and types only** — not runtime evaluation, policy engines, or business logic. Those live elsewhere in the monorepo and **conform** to this contract.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @trigguard/protocol
11
+ ```
12
+
13
+ *(Requires the package to be published to the npm registry under the `@trigguard` scope; see `docs/release/PROTOCOL_RELEASE.md`.)*
14
+
15
+ Until publish is configured, depend on the repo:
16
+
17
+ ```json
18
+ "@trigguard/protocol": "file:../packages/protocol"
19
+ ```
20
+
21
+ or install from a Git URL / workspace as documented in the main [TrigGuard repository](https://github.com/TrigGuard-AI/TrigGuard).
22
+
23
+ ## Decision model
24
+
25
+ | Decision | Meaning (high level) |
26
+ |------------|----------------------|
27
+ | **PERMIT** | Authorization to proceed under policy (subject to enforcement and deployment rules). |
28
+ | **DENY** | Action must not proceed as requested. |
29
+ | **SILENCE**| No authorization was issued; without authorization, execution cannot proceed (see `SILENCE_DEFINITION` export). |
30
+
31
+ Policy-only layers may restrict emitted decisions to **PERMIT** / **DENY**; full protocol surfaces also use **SILENCE** where applicable.
32
+
33
+ ## Example import (TypeScript)
34
+
35
+ ```typescript
36
+ import {
37
+ type Decision,
38
+ type DecisionRecord,
39
+ DECISION,
40
+ DECISIONS,
41
+ SILENCE_DEFINITION,
42
+ } from "@trigguard/protocol";
43
+
44
+ const d: Decision = "PERMIT";
45
+ const record: DecisionRecord = {
46
+ decision: DECISION.PERMIT,
47
+ enforcement: "EXECUTED",
48
+ reason_code: "NO_POLICY_VIOLATION",
49
+ timestamp: new Date().toISOString(),
50
+ };
51
+ ```
52
+
53
+ There is **no** `evaluate()` in this package — evaluation lives in TrigGuard services and kernels. This package supplies **types and canonical constants** so callers and SDKs share one contract.
54
+
55
+ ## Build (maintainers / CI)
56
+
57
+ From `packages/protocol`:
58
+
59
+ ```bash
60
+ npm install
61
+ npm run build
62
+ ```
63
+
64
+ `build` runs `sync-contract` (when the full monorepo is present), `tsc`, and asset copy into `dist/`. Published tarballs are built via `prepack` / `prepare` before `npm publish`.
65
+
66
+ ## Repository
67
+
68
+ Canonical source: [github.com/TrigGuard-AI/TrigGuard](https://github.com/TrigGuard-AI/TrigGuard) — `packages/protocol/`.
69
+
70
+ For installation paths and release tagging, see:
71
+
72
+ - `docs/developers/INSTALL_PROTOCOL.md`
73
+ - `docs/release/PROTOCOL_RELEASE.md`
74
+
75
+ ## Legacy note (snapshot)
76
+
77
+ `src/contracts/decision_contract.json` is kept in sync with `core/contracts/decision_contract.json` via `npm run sync-contract` in the monorepo. **Do not edit kernel contracts from this README** — follow governance and protocol integrity processes in the main repo.
@@ -0,0 +1,9 @@
1
+ {
2
+ "decision": ["PERMIT", "DENY"],
3
+ "reasonCode": [
4
+ "NO_POLICY_VIOLATION",
5
+ "HIGH_RISK_SPEND",
6
+ "RSD_AUTOMATION_CONFLICT",
7
+ "NO_MATCHING_POLICY"
8
+ ]
9
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @trigguard/protocol — canonical vocabulary and record shape for TrigGuard surfaces.
3
+ * Policy/evaluation layers may emit only PERMIT|DENY; full protocol includes SILENCE.
4
+ * Reason codes are snapshotted from core/contracts/decision_contract.json (see sync-contract script).
5
+ */
6
+ import decisionContract from "./contracts/decision_contract.json";
7
+ /** Full protocol decision set (remote eval / product surfaces). */
8
+ export type Decision = "PERMIT" | "DENY" | "SILENCE";
9
+ /** Policy contract layer decisions only (matches decision_contract.json `decision`). */
10
+ export type PolicyDecision = "PERMIT" | "DENY";
11
+ export type Enforcement = "EXECUTED" | "BLOCKED";
12
+ export declare const DECISION: {
13
+ readonly PERMIT: "PERMIT";
14
+ readonly DENY: "DENY";
15
+ readonly SILENCE: "SILENCE";
16
+ };
17
+ export declare const ENFORCEMENT: {
18
+ readonly EXECUTED: "EXECUTED";
19
+ readonly BLOCKED: "BLOCKED";
20
+ };
21
+ /** Ordered canonical sets for consumers (CI, SDKs). */
22
+ export declare const DECISIONS: readonly ["PERMIT", "DENY", "SILENCE"];
23
+ export declare const ENFORCEMENTS: readonly ["EXECUTED", "BLOCKED"];
24
+ /**
25
+ * Canonical SILENCE explanation for public and SDK surfaces.
26
+ * Keep in sync with site governance / protocol docs.
27
+ */
28
+ export declare const SILENCE_DEFINITION = "SILENCE means no authorization was issued. Without authorization, execution cannot proceed.";
29
+ /** Reason codes derived from core/contracts/decision_contract.json (kept in sync by sync-contract). */
30
+ export declare const REASON_CODES: readonly string[];
31
+ export type ReasonCode = (typeof decisionContract.reasonCode)[number];
32
+ export interface DecisionRecord {
33
+ decision: Decision;
34
+ enforcement: Enforcement;
35
+ /** Prefer values from REASON_CODES when representing policy outcomes. */
36
+ reason_code: string;
37
+ timestamp: string;
38
+ }
39
+ /** Embedded contract snapshot (authoritative registry for reason codes at policy layer). */
40
+ export { decisionContract };
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,gBAAgB,MAAM,oCAAoC,CAAC;AAElE,mEAAmE;AACnE,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAErD,wFAAwF;AACxF,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAEjD,eAAO,MAAM,QAAQ;;;;CAIwB,CAAC;AAE9C,eAAO,MAAM,WAAW;;;CAGwB,CAAC;AAEjD,uDAAuD;AACvD,eAAO,MAAM,SAAS,wCAAyC,CAAC;AAEhE,eAAO,MAAM,YAAY,kCAAmC,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,kBAAkB,gGACgE,CAAC;AAEhG,uGAAuG;AACvG,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAAgC,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,gBAAgB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;IACzB,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,4FAA4F;AAC5F,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /**
3
+ * @trigguard/protocol — canonical vocabulary and record shape for TrigGuard surfaces.
4
+ * Policy/evaluation layers may emit only PERMIT|DENY; full protocol includes SILENCE.
5
+ * Reason codes are snapshotted from core/contracts/decision_contract.json (see sync-contract script).
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.decisionContract = exports.REASON_CODES = exports.SILENCE_DEFINITION = exports.ENFORCEMENTS = exports.DECISIONS = exports.ENFORCEMENT = exports.DECISION = void 0;
12
+ const decision_contract_json_1 = __importDefault(require("./contracts/decision_contract.json"));
13
+ exports.decisionContract = decision_contract_json_1.default;
14
+ exports.DECISION = {
15
+ PERMIT: "PERMIT",
16
+ DENY: "DENY",
17
+ SILENCE: "SILENCE",
18
+ };
19
+ exports.ENFORCEMENT = {
20
+ EXECUTED: "EXECUTED",
21
+ BLOCKED: "BLOCKED",
22
+ };
23
+ /** Ordered canonical sets for consumers (CI, SDKs). */
24
+ exports.DECISIONS = ["PERMIT", "DENY", "SILENCE"];
25
+ exports.ENFORCEMENTS = ["EXECUTED", "BLOCKED"];
26
+ /**
27
+ * Canonical SILENCE explanation for public and SDK surfaces.
28
+ * Keep in sync with site governance / protocol docs.
29
+ */
30
+ exports.SILENCE_DEFINITION = "SILENCE means no authorization was issued. Without authorization, execution cannot proceed.";
31
+ /** Reason codes derived from core/contracts/decision_contract.json (kept in sync by sync-contract). */
32
+ exports.REASON_CODES = decision_contract_json_1.default.reasonCode;
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "TrigGuardCanonicalDecisionRecord",
4
+ "description": "Authoritative shape for protocol decision records. reason_code values align with core/contracts/decision_contract.json reasonCode registry.",
5
+ "type": "object",
6
+ "required": ["decision", "enforcement", "reason_code", "timestamp"],
7
+ "properties": {
8
+ "decision": {
9
+ "type": "string",
10
+ "enum": ["PERMIT", "DENY", "SILENCE"]
11
+ },
12
+ "enforcement": {
13
+ "type": "string",
14
+ "enum": ["EXECUTED", "BLOCKED"]
15
+ },
16
+ "reason_code": {
17
+ "type": "string"
18
+ },
19
+ "timestamp": {
20
+ "type": "string"
21
+ }
22
+ }
23
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@trigguard/protocol",
3
+ "version": "0.1.0",
4
+ "description": "Canonical TrigGuard protocol types and contract snapshots (governance layer, not business logic).",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
11
+ "scripts": {
12
+ "sync-contract": "node scripts/sync-contract.mjs",
13
+ "build": "npm run sync-contract && tsc && node scripts/copy-assets.mjs",
14
+ "prepare": "npm run build",
15
+ "prepack": "npm run build"
16
+ },
17
+ "keywords": [
18
+ "trigguard",
19
+ "protocol",
20
+ "governance"
21
+ ],
22
+ "license": "SEE LICENSE IN REPO",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/TrigGuard-AI/TrigGuard"
26
+ },
27
+ "devDependencies": {
28
+ "typescript": "~5.6.3"
29
+ }
30
+ }