@coderifts/agent-guard 1.4.0 → 1.5.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/dist/cjs/deploy-gate.d.ts +103 -0
- package/dist/cjs/deploy-gate.d.ts.map +1 -0
- package/dist/cjs/deploy-gate.js +159 -0
- package/dist/cjs/deploy-gate.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/deploy-gate.d.ts +103 -0
- package/dist/esm/deploy-gate.d.ts.map +1 -0
- package/dist/esm/deploy-gate.js +156 -0
- package/dist/esm/deploy-gate.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deploy-gate (#8) — the PURE deploy authorization decision (deploy-gate-SPEC §1). The DEPLOY sibling
|
|
3
|
+
* of the merge gate: it answers "may THIS artifact deploy to THIS environment, given the finished
|
|
4
|
+
* receipt and the observed pipeline-enforcement state?"
|
|
5
|
+
*
|
|
6
|
+
* Same shape as the merge gate, different operation. It is a PURE function — NO I/O, NO CD-API call
|
|
7
|
+
* (pipeline enforcement is an INPUT, observed by the host and passed in). It does NOT re-decide: it
|
|
8
|
+
* reads only the finished receipt fields — the deterministic verdict stays the server's (D7). Same
|
|
9
|
+
* inputs → same output (D9).
|
|
10
|
+
*
|
|
11
|
+
* The three deploy-specific binds are the whole point: T7 (a MERGE — or operation-less — receipt can
|
|
12
|
+
* never deploy), environment binding (a staging ALLOW never authorizes production), and artifact
|
|
13
|
+
* binding (an old artifact's ALLOW never deploys a newer one). Scope honesty mirrors the merge gate:
|
|
14
|
+
* `inescapable_deploy` is true ONLY in the fully-enforcing, non-bypassable case; otherwise the check
|
|
15
|
+
* may be `success` for visibility but the claim is false with the residual named.
|
|
16
|
+
*
|
|
17
|
+
* Public source (ships in the npm package): references only receipt/target/enforcement fields and
|
|
18
|
+
* generic deploy-gate concepts — no scoring logic, weights, thresholds, pattern names, endpoints, or
|
|
19
|
+
* secrets.
|
|
20
|
+
*/
|
|
21
|
+
import type { GateStatusState, EnforcementState } from './merge-gate.js';
|
|
22
|
+
export type { GateStatusState, EnforcementState } from './merge-gate.js';
|
|
23
|
+
/** The 13 deploy-gate reason codes (§1.1). Success uses allow_current_deploy; enforcement_not_configured
|
|
24
|
+
* and bypass_open name the honesty residual on an otherwise-green check. */
|
|
25
|
+
export type DeployGateReason = 'allow_current_deploy' | 'no_receipt' | 'receipt_not_authorized' | 'operation_mismatch' | 'env_mismatch' | 'stale_artifact' | 'fingerprint_mismatch' | 'body_hash_mismatch' | 'target_mismatch' | 'decision_not_allow' | 'inputs_incomplete' | 'enforcement_not_configured' | 'bypass_open';
|
|
26
|
+
/** What is being deployed — all fields are INPUTS (the pure function performs no discovery). */
|
|
27
|
+
export type DeployTarget = {
|
|
28
|
+
environment: string;
|
|
29
|
+
/** Immutable artifact identity: content digest, or a commit SHA when that is the deploy unit. */
|
|
30
|
+
artifact_id: string;
|
|
31
|
+
service?: string;
|
|
32
|
+
pipeline_run_id?: string;
|
|
33
|
+
};
|
|
34
|
+
/** A view of the finished receipt. Reuses the shipped field names + the deploy analogs of bound_head_sha. */
|
|
35
|
+
export type DeployReceiptView = {
|
|
36
|
+
currently_authorized: boolean;
|
|
37
|
+
authz_reason?: string;
|
|
38
|
+
decision: 'ALLOW' | 'WARN' | 'REQUIRE_APPROVAL' | 'BLOCK' | string;
|
|
39
|
+
execution_action?: 'CONTINUE' | 'CONTINUE_WITH_MONITORING' | 'REQUEST_APPROVAL' | 'STOP' | string;
|
|
40
|
+
/** MUST be 'deploy' for success (T7). */
|
|
41
|
+
operation?: 'merge' | 'deploy' | 'tool_call' | 'publish' | string;
|
|
42
|
+
/** The environment this receipt authorizes (deploy analog of bound_head_sha). */
|
|
43
|
+
bound_environment?: string | null;
|
|
44
|
+
/** The artifact/commit this receipt was issued for (deploy analog of bound_head_sha). */
|
|
45
|
+
bound_artifact_id?: string | null;
|
|
46
|
+
verdict_fingerprint?: string;
|
|
47
|
+
body_hash?: string;
|
|
48
|
+
target_id?: string;
|
|
49
|
+
signature_valid?: boolean;
|
|
50
|
+
};
|
|
51
|
+
/** Pipeline-enforcement observation (from the host's CD-config read — the pure gate consumes it). */
|
|
52
|
+
export type DeployEnforcementState = {
|
|
53
|
+
enforcement: EnforcementState;
|
|
54
|
+
bypass_possible: boolean;
|
|
55
|
+
required_step_name?: string;
|
|
56
|
+
};
|
|
57
|
+
export type DeployRequiredContext = {
|
|
58
|
+
operation?: 'deploy' | string;
|
|
59
|
+
repository?: string;
|
|
60
|
+
service?: string;
|
|
61
|
+
expected_fingerprint?: string;
|
|
62
|
+
expected_body_hash?: string;
|
|
63
|
+
enforcement: DeployEnforcementState;
|
|
64
|
+
/** Default true: a missing bound_environment on the receipt → env_mismatch. */
|
|
65
|
+
require_bound_environment?: boolean;
|
|
66
|
+
/** Default true: a missing bound_artifact_id → stale_artifact. */
|
|
67
|
+
require_bound_artifact?: boolean;
|
|
68
|
+
allowWarnDeploy?: boolean;
|
|
69
|
+
allowPrefixCompare?: boolean;
|
|
70
|
+
allowPending?: boolean;
|
|
71
|
+
};
|
|
72
|
+
export type DeployGateInput = {
|
|
73
|
+
deployTarget: DeployTarget;
|
|
74
|
+
receipt: DeployReceiptView | null;
|
|
75
|
+
requiredContext: DeployRequiredContext;
|
|
76
|
+
/** Incomplete/no-receipt → pending when true, else failure (default false). */
|
|
77
|
+
allowPending?: boolean;
|
|
78
|
+
/** Green the gate on WARN as well as ALLOW (default false; stricter for prod-shaped envs). */
|
|
79
|
+
allowWarnDeploy?: boolean;
|
|
80
|
+
/** Compare env/artifact by prefix instead of full equality (default false). */
|
|
81
|
+
allowPrefixCompare?: boolean;
|
|
82
|
+
};
|
|
83
|
+
export type DeployGateDecision = {
|
|
84
|
+
deploy_allowed: boolean;
|
|
85
|
+
state: GateStatusState;
|
|
86
|
+
reason: DeployGateReason;
|
|
87
|
+
enforcement_state: EnforcementState;
|
|
88
|
+
inescapable_deploy: boolean;
|
|
89
|
+
/** Named residual when the check is green but NOT inescapable (honesty channel, §3.2). */
|
|
90
|
+
residual?: DeployGateReason;
|
|
91
|
+
detail: {
|
|
92
|
+
environment: string;
|
|
93
|
+
artifact_id: string;
|
|
94
|
+
bound_environment: string | null;
|
|
95
|
+
bound_artifact_id: string | null;
|
|
96
|
+
operation: string | null;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* §1.4 — the normative, first-match-wins deploy decision. Pure; no I/O; deterministic.
|
|
101
|
+
*/
|
|
102
|
+
export declare function deployGate(input: DeployGateInput): DeployGateDecision;
|
|
103
|
+
//# sourceMappingURL=deploy-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-gate.d.ts","sourceRoot":"","sources":["../../src/deploy-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEzE;6EAC6E;AAC7E,MAAM,MAAM,gBAAgB,GACxB,sBAAsB,GACtB,YAAY,GACZ,wBAAwB,GACxB,oBAAoB,GACpB,cAAc,GACd,gBAAgB,GAChB,sBAAsB,GACtB,oBAAoB,GACpB,iBAAiB,GACjB,oBAAoB,GACpB,mBAAmB,GACnB,4BAA4B,GAC5B,aAAa,CAAC;AAElB,gGAAgG;AAChG,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,iGAAiG;IACjG,WAAW,EAAE,MAAM,CAAC;IAC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answers "may THIS artifact deploy to THIS environment, given the finished
|
|
5
|
+
* receipt and the observed pipeline-enforcement state?"
|
|
6
|
+
*
|
|
7
|
+
* Same shape as the merge gate, different operation. It is a PURE function — NO I/O, NO CD-API call
|
|
8
|
+
* (pipeline enforcement is an INPUT, observed by the host and passed in). It does NOT re-decide: it
|
|
9
|
+
* reads only the finished receipt fields — the deterministic verdict stays the server's (D7). Same
|
|
10
|
+
* inputs → same output (D9).
|
|
11
|
+
*
|
|
12
|
+
* The three deploy-specific binds are the whole point: T7 (a MERGE — or operation-less — receipt can
|
|
13
|
+
* never deploy), environment binding (a staging ALLOW never authorizes production), and artifact
|
|
14
|
+
* binding (an old artifact's ALLOW never deploys a newer one). Scope honesty mirrors the merge gate:
|
|
15
|
+
* `inescapable_deploy` is true ONLY in the fully-enforcing, non-bypassable case; otherwise the check
|
|
16
|
+
* may be `success` for visibility but the claim is false with the residual named.
|
|
17
|
+
*
|
|
18
|
+
* Public source (ships in the npm package): references only receipt/target/enforcement fields and
|
|
19
|
+
* generic deploy-gate concepts — no scoring logic, weights, thresholds, pattern names, endpoints, or
|
|
20
|
+
* secrets.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.deployGate = deployGate;
|
|
24
|
+
// ── helpers (pure) ────────────────────────────────────────────────────────────────────────────────
|
|
25
|
+
function norm(s) {
|
|
26
|
+
return String(s == null ? '' : s).trim().toLowerCase();
|
|
27
|
+
}
|
|
28
|
+
/** §1.2 — full lowercase equality by default (env exact; artifact digest/sha); prefix opt-in. */
|
|
29
|
+
function sameNorm(a, b, allowPrefix) {
|
|
30
|
+
const na = norm(a);
|
|
31
|
+
const nb = norm(b);
|
|
32
|
+
if (!na || !nb)
|
|
33
|
+
return false;
|
|
34
|
+
if (na === nb)
|
|
35
|
+
return true;
|
|
36
|
+
if (allowPrefix && na.length >= 7 && nb.length >= 7 && (na.startsWith(nb) || nb.startsWith(na)))
|
|
37
|
+
return true;
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
/** §1.3 — allow-class for deploy: ALLOW (or WARN only when opted in) + a continue-class action. */
|
|
41
|
+
function isAllowClass(receipt, allowWarnDeploy) {
|
|
42
|
+
const dec = receipt.decision;
|
|
43
|
+
const decisionOk = dec === 'ALLOW' || (dec === 'WARN' && allowWarnDeploy === true);
|
|
44
|
+
if (!decisionOk)
|
|
45
|
+
return false;
|
|
46
|
+
const ea = receipt.execution_action;
|
|
47
|
+
if (ea === undefined || ea === null || ea === '')
|
|
48
|
+
return true;
|
|
49
|
+
return ea === 'CONTINUE' || ea === 'CONTINUE_WITH_MONITORING';
|
|
50
|
+
}
|
|
51
|
+
/** target_id must name this service/repository (exact or `svc:`/`repo:`/path/colon suffix). */
|
|
52
|
+
function idMatchesName(targetId, name) {
|
|
53
|
+
const t = norm(targetId);
|
|
54
|
+
const r = norm(name);
|
|
55
|
+
return t === r || t === `svc:${r}` || t === `repo:${r}` || t.endsWith(`:${r}`) || t.endsWith(`/${r}`);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* §1.4 — the normative, first-match-wins deploy decision. Pure; no I/O; deterministic.
|
|
59
|
+
*/
|
|
60
|
+
function deployGate(input) {
|
|
61
|
+
const target = input.deployTarget || {};
|
|
62
|
+
const rc = input.requiredContext || {};
|
|
63
|
+
const enf = rc.enforcement || { enforcement: 'UNKNOWN', bypass_possible: true };
|
|
64
|
+
const enforcement_state = enf.enforcement;
|
|
65
|
+
const opRequired = rc.operation ?? 'deploy';
|
|
66
|
+
const requireEnv = rc.require_bound_environment !== false; // default true
|
|
67
|
+
const requireArt = rc.require_bound_artifact !== false; // default true
|
|
68
|
+
const allowPending = input.allowPending ?? rc.allowPending ?? false;
|
|
69
|
+
const allowWarnDeploy = input.allowWarnDeploy ?? rc.allowWarnDeploy ?? false;
|
|
70
|
+
const allowPrefix = input.allowPrefixCompare ?? rc.allowPrefixCompare ?? false;
|
|
71
|
+
const receipt = input.receipt;
|
|
72
|
+
const detail = {
|
|
73
|
+
environment: norm(target.environment),
|
|
74
|
+
artifact_id: norm(target.artifact_id),
|
|
75
|
+
bound_environment: receipt && receipt.bound_environment != null ? norm(receipt.bound_environment) : null,
|
|
76
|
+
bound_artifact_id: receipt && receipt.bound_artifact_id != null ? norm(receipt.bound_artifact_id) : null,
|
|
77
|
+
operation: receipt && receipt.operation != null ? String(receipt.operation) : null,
|
|
78
|
+
};
|
|
79
|
+
const deny = (state, reason) => ({
|
|
80
|
+
deploy_allowed: false, state, reason, enforcement_state, inescapable_deploy: false, detail,
|
|
81
|
+
});
|
|
82
|
+
// 0) incomplete target → pending/failure (fail-closed on missing evaluation input).
|
|
83
|
+
if (!target.environment || String(target.environment).trim() === ''
|
|
84
|
+
|| !target.artifact_id || String(target.artifact_id).trim() === '') {
|
|
85
|
+
return deny(allowPending ? 'pending' : 'failure', 'inputs_incomplete');
|
|
86
|
+
}
|
|
87
|
+
// 1) no receipt → fail-closed (D4).
|
|
88
|
+
if (receipt === null || receipt === undefined) {
|
|
89
|
+
return deny(allowPending ? 'pending' : 'failure', 'no_receipt');
|
|
90
|
+
}
|
|
91
|
+
// 2) lifecycle authorization — a valid signature alone is NOT sufficient (D5).
|
|
92
|
+
if (receipt.currently_authorized !== true) {
|
|
93
|
+
return deny('failure', 'receipt_not_authorized');
|
|
94
|
+
}
|
|
95
|
+
// 3) T7 — operation MUST be deploy. A merge (or any other) receipt cannot deploy, and a MISSING
|
|
96
|
+
// operation also fails closed (stricter than the merge gate — deploy is higher-risk) (D1).
|
|
97
|
+
if (receipt.operation == null || norm(receipt.operation) !== norm(opRequired)) {
|
|
98
|
+
return deny('failure', 'operation_mismatch');
|
|
99
|
+
}
|
|
100
|
+
// 4) ENVIRONMENT binding — a staging ALLOW never authorizes production (D2).
|
|
101
|
+
if (requireEnv) {
|
|
102
|
+
if (!receipt.bound_environment || !sameNorm(receipt.bound_environment, target.environment, allowPrefix)) {
|
|
103
|
+
return deny('failure', 'env_mismatch');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (receipt.bound_environment && !sameNorm(receipt.bound_environment, target.environment, allowPrefix)) {
|
|
107
|
+
return deny('failure', 'env_mismatch');
|
|
108
|
+
}
|
|
109
|
+
// 5) ARTIFACT binding — an old artifact's ALLOW never deploys a newer one (D3, the stale analog).
|
|
110
|
+
if (requireArt) {
|
|
111
|
+
if (!receipt.bound_artifact_id || !sameNorm(receipt.bound_artifact_id, target.artifact_id, allowPrefix)) {
|
|
112
|
+
return deny('failure', 'stale_artifact');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else if (receipt.bound_artifact_id && !sameNorm(receipt.bound_artifact_id, target.artifact_id, allowPrefix)) {
|
|
116
|
+
return deny('failure', 'stale_artifact');
|
|
117
|
+
}
|
|
118
|
+
// 6) optional re-bind to the current change set.
|
|
119
|
+
if (rc.expected_fingerprint != null && receipt.verdict_fingerprint !== rc.expected_fingerprint) {
|
|
120
|
+
return deny('failure', 'fingerprint_mismatch');
|
|
121
|
+
}
|
|
122
|
+
if (rc.expected_body_hash != null && receipt.body_hash !== rc.expected_body_hash) {
|
|
123
|
+
return deny('failure', 'body_hash_mismatch');
|
|
124
|
+
}
|
|
125
|
+
// 7) optional service / repository target binding.
|
|
126
|
+
if (rc.service && receipt.target_id) {
|
|
127
|
+
if (!idMatchesName(receipt.target_id, rc.service))
|
|
128
|
+
return deny('failure', 'target_mismatch');
|
|
129
|
+
}
|
|
130
|
+
else if (rc.repository && receipt.target_id) {
|
|
131
|
+
if (!idMatchesName(receipt.target_id, rc.repository))
|
|
132
|
+
return deny('failure', 'target_mismatch');
|
|
133
|
+
}
|
|
134
|
+
// 8) decision class — only an allow-class verdict greens the deploy gate (D6).
|
|
135
|
+
if (!isAllowClass(receipt, allowWarnDeploy)) {
|
|
136
|
+
return deny('failure', 'decision_not_allow');
|
|
137
|
+
}
|
|
138
|
+
// 9) success for the CHECK / pipeline step — green for visibility regardless of enforcement strength.
|
|
139
|
+
// 10) inescapable_deploy claim (STRICT, §1.4 step 10 / D8): only when the pipeline actually enforces
|
|
140
|
+
// the step AND no bypass is possible. Never true otherwise.
|
|
141
|
+
const inescapable_deploy = enforcement_state === 'ENFORCING' && enf.bypass_possible === false;
|
|
142
|
+
let residual;
|
|
143
|
+
if (!inescapable_deploy) {
|
|
144
|
+
if (enforcement_state === 'ENFORCING')
|
|
145
|
+
residual = 'bypass_open'; // enforced, but a bypass exists
|
|
146
|
+
else
|
|
147
|
+
residual = 'enforcement_not_configured'; // ADVISORY / ABSENT / UNKNOWN
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
deploy_allowed: true,
|
|
151
|
+
state: 'success',
|
|
152
|
+
reason: 'allow_current_deploy',
|
|
153
|
+
enforcement_state,
|
|
154
|
+
inescapable_deploy,
|
|
155
|
+
...(residual ? { residual } : {}),
|
|
156
|
+
detail,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=deploy-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-gate.js","sourceRoot":"","sources":["../../src/deploy-gate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AA0IH,gCAiGC;AApID,qGAAqG;AACrG,SAAS,IAAI,CAAC,CAA4B;IACxC,OAAO,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACzD,CAAC;AAED,iGAAiG;AACjG,SAAS,QAAQ,CAAC,CAA4B,EAAE,CAA4B,EAAE,WAAoB;IAChG,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACnB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;IAC7B,IAAI,E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AM;KACP,CAAC;AACJ,CAAC"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -34,4 +34,6 @@ export { guardToolRegistry, RegistryConstructionError } from './tool-registry.js
|
|
|
34
34
|
export type { RawTool, ProtectedTool, ToolMutationClass, EnforcementCoverage, RegistryCoverageReport, GuardToolRegistryConfig, RegistryResult, ToolBinder, RegistryConstructionErrorCode, } from './tool-registry.js';
|
|
35
35
|
export { gateDecision } from './merge-gate.js';
|
|
36
36
|
export type { GateDecisionInput, GateDecision, ReceiptView, RequiredContext, ProtectionState, GateReason, GateStatusState, EnforcementState, } from './merge-gate.js';
|
|
37
|
+
export { deployGate } from './deploy-gate.js';
|
|
38
|
+
export type { DeployGateInput, DeployGateDecision, DeployReceiptView, DeployRequiredContext, DeployEnforcementState, DeployTarget, DeployGateReason, } from './deploy-gate.js';
|
|
37
39
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7F,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGxG,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAC1G,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EACL,mBAAmB,EAAE,qBAAqB,EAAE,aAAa,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AAa,EAAE,gBAAgB,EAAE,eAAe,EAC7E,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,IAAI,oBAAoB,GAClG,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAClF,YAAY,EACV,OAAO,EACP,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,UAAU,EACV,6BAA6B,GAC9B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EACV,iBAAiB,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAC9E,UAAU,EAAE,eAAe,EAAE,gBAAgB,GAC9C,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EACV,eAAe,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,qBAAqB,EAC7E,sBAAsB,EAAE,YAAY,EAAE,gBAAgB,GACvD,MAAM,kBAAkB,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.gateDecision = exports.RegistryConstructionError = exports.guardToolRegistry = exports.globToRegExp = exports.matchGlob = exports.resolveArtifacts = exports.deriveKeySignal = exports.pathClass = exports.classifyCommand = exports.projectState = exports.emptySessionState = exports.computeTainted = exports.evaluate = exports.updateSession = exports.SESSION_TAINT_VERSION = exports.SessionTaintTracker = exports.readDecision = exports.computeBundleFingerprint = exports.computeArtifactDigest = exports.evaluateEnvelope = exports.canonicalJson = exports.computeBodyHash = exports.bindReceiptToEnvelope = exports.DETECTOR_VERSION = exports.builtinDetector = exports.guardToolCall = void 0;
|
|
22
|
+
exports.deployGate = exports.gateDecision = exports.RegistryConstructionError = exports.guardToolRegistry = exports.globToRegExp = exports.matchGlob = exports.resolveArtifacts = exports.deriveKeySignal = exports.pathClass = exports.classifyCommand = exports.projectState = exports.emptySessionState = exports.computeTainted = exports.evaluate = exports.updateSession = exports.SESSION_TAINT_VERSION = exports.SessionTaintTracker = exports.readDecision = exports.computeBundleFingerprint = exports.computeArtifactDigest = exports.evaluateEnvelope = exports.canonicalJson = exports.computeBodyHash = exports.bindReceiptToEnvelope = exports.DETECTOR_VERSION = exports.builtinDetector = exports.guardToolCall = void 0;
|
|
23
23
|
var guard_js_1 = require("./guard.js");
|
|
24
24
|
Object.defineProperty(exports, "guardToolCall", { enumerable: true, get: function () { return guard_js_1.guardToolCall; } });
|
|
25
25
|
var detector_js_1 = require("./detector.js");
|
|
@@ -64,4 +64,7 @@ Object.defineProperty(exports, "RegistryConstructionError", { enumerable: true,
|
|
|
64
64
|
// repo-merge-gate (#7) — the PURE repo-side merge decision (Placement B). No I/O; protection is input.
|
|
65
65
|
var merge_gate_js_1 = require("./merge-gate.js");
|
|
66
66
|
Object.defineProperty(exports, "gateDecision", { enumerable: true, get: function () { return merge_gate_js_1.gateDecision; } });
|
|
67
|
+
// deploy-gate (#8) — the PURE deploy authorization decision. No I/O; pipeline enforcement is input.
|
|
68
|
+
var deploy_gate_js_1 = require("./deploy-gate.js");
|
|
69
|
+
Object.defineProperty(exports, "deployGate", { enumerable: true, get: function () { return deploy_gate_js_1.deployGate; } });
|
|
67
70
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAEH,uCAA2C;AAAlC,yGAAA,aAAa,OAAA;AACtB,6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AAa,OAAA;AAE9D,sGAAsG;AACtG,+DAA+D;AAC/D,6DAA0G;AAAjG,uHAAA,gBAAgB,OAAA;AAAE,4HAAA,qBAAqB,OAAA;AAAE,+HAAA,wBAAwB,OAAA;AAE1E,sCAA8C;AAArC,mGAAA,YAAY,OAAA;AACrB,+FAA+F;AAC/F,uDAG4B;AAF1B,uHAAA,mBAAmB,OAAA;AAAE,yHAAA,qBAAqB,OAAA;AAAE,iHAAA,aAAa,OAAA;AAAE,4GAAA,QAAQ,OAAA;AAAE,kHAAA,cAAc,OAAA;AACnF,qHAAA,iBAAiB,OAAA;AAAE,gHAAA,YAAY,OAAA;AAAE,mHAAA,eAAe,OAAA;AAAE,6GAAA,SAAS,OAAA;AAAE,mHAAA,eAAe,OAAA;AA2B9E,kGAAkG;AAClG,wFAAwF;AACxF,+DAAqE;AAA5D,wHAAA,OAAO,OAAoB;AAKpC,uDAA6D;AAApD,6GAAA,SAAS,OAAA;AAAE,gHAAA,YAAY,OAAA;AAEhC,qGAAqG;AACrG,uDAAkF;AAAzE,qHAAA,iBAAiB,OAAA;AAAE,6HAAA,yBAAyB,OAAA;AAarD,uGAAuG;AACvG,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAMrB,oGAAoG;AACpG,mDAA8C;AAArC,4GAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deploy-gate (#8) — the PURE deploy authorization decision (deploy-gate-SPEC §1). The DEPLOY sibling
|
|
3
|
+
* of the merge gate: it answers "may THIS artifact deploy to THIS environment, given the finished
|
|
4
|
+
* receipt and the observed pipeline-enforcement state?"
|
|
5
|
+
*
|
|
6
|
+
* Same shape as the merge gate, different operation. It is a PURE function — NO I/O, NO CD-API call
|
|
7
|
+
* (pipeline enforcement is an INPUT, observed by the host and passed in). It does NOT re-decide: it
|
|
8
|
+
* reads only the finished receipt fields — the deterministic verdict stays the server's (D7). Same
|
|
9
|
+
* inputs → same output (D9).
|
|
10
|
+
*
|
|
11
|
+
* The three deploy-specific binds are the whole point: T7 (a MERGE — or operation-less — receipt can
|
|
12
|
+
* never deploy), environment binding (a staging ALLOW never authorizes production), and artifact
|
|
13
|
+
* binding (an old artifact's ALLOW never deploys a newer one). Scope honesty mirrors the merge gate:
|
|
14
|
+
* `inescapable_deploy` is true ONLY in the fully-enforcing, non-bypassable case; otherwise the check
|
|
15
|
+
* may be `success` for visibility but the claim is false with the residual named.
|
|
16
|
+
*
|
|
17
|
+
* Public source (ships in the npm package): references only receipt/target/enforcement fields and
|
|
18
|
+
* generic deploy-gate concepts — no scoring logic, weights, thresholds, pattern names, endpoints, or
|
|
19
|
+
* secrets.
|
|
20
|
+
*/
|
|
21
|
+
import type { GateStatusState, EnforcementState } from './merge-gate.js';
|
|
22
|
+
export type { GateStatusState, EnforcementState } from './merge-gate.js';
|
|
23
|
+
/** The 13 deploy-gate reason codes (§1.1). Success uses allow_current_deploy; enforcement_not_configured
|
|
24
|
+
* and bypass_open name the honesty residual on an otherwise-green check. */
|
|
25
|
+
export type DeployGateReason = 'allow_current_deploy' | 'no_receipt' | 'receipt_not_authorized' | 'operation_mismatch' | 'env_mismatch' | 'stale_artifact' | 'fingerprint_mismatch' | 'body_hash_mismatch' | 'target_mismatch' | 'decision_not_allow' | 'inputs_incomplete' | 'enforcement_not_configured' | 'bypass_open';
|
|
26
|
+
/** What is being deployed — all fields are INPUTS (the pure function performs no discovery). */
|
|
27
|
+
export type DeployTarget = {
|
|
28
|
+
environment: string;
|
|
29
|
+
/** Immutable artifact identity: content digest, or a commit SHA when that is the deploy unit. */
|
|
30
|
+
artifact_id: string;
|
|
31
|
+
service?: string;
|
|
32
|
+
pipeline_run_id?: string;
|
|
33
|
+
};
|
|
34
|
+
/** A view of the finished receipt. Reuses the shipped field names + the deploy analogs of bound_head_sha. */
|
|
35
|
+
export type DeployReceiptView = {
|
|
36
|
+
currently_authorized: boolean;
|
|
37
|
+
authz_reason?: string;
|
|
38
|
+
decision: 'ALLOW' | 'WARN' | 'REQUIRE_APPROVAL' | 'BLOCK' | string;
|
|
39
|
+
execution_action?: 'CONTINUE' | 'CONTINUE_WITH_MONITORING' | 'REQUEST_APPROVAL' | 'STOP' | string;
|
|
40
|
+
/** MUST be 'deploy' for success (T7). */
|
|
41
|
+
operation?: 'merge' | 'deploy' | 'tool_call' | 'publish' | string;
|
|
42
|
+
/** The environment this receipt authorizes (deploy analog of bound_head_sha). */
|
|
43
|
+
bound_environment?: string | null;
|
|
44
|
+
/** The artifact/commit this receipt was issued for (deploy analog of bound_head_sha). */
|
|
45
|
+
bound_artifact_id?: string | null;
|
|
46
|
+
verdict_fingerprint?: string;
|
|
47
|
+
body_hash?: string;
|
|
48
|
+
target_id?: string;
|
|
49
|
+
signature_valid?: boolean;
|
|
50
|
+
};
|
|
51
|
+
/** Pipeline-enforcement observation (from the host's CD-config read — the pure gate consumes it). */
|
|
52
|
+
export type DeployEnforcementState = {
|
|
53
|
+
enforcement: EnforcementState;
|
|
54
|
+
bypass_possible: boolean;
|
|
55
|
+
required_step_name?: string;
|
|
56
|
+
};
|
|
57
|
+
export type DeployRequiredContext = {
|
|
58
|
+
operation?: 'deploy' | string;
|
|
59
|
+
repository?: string;
|
|
60
|
+
service?: string;
|
|
61
|
+
expected_fingerprint?: string;
|
|
62
|
+
expected_body_hash?: string;
|
|
63
|
+
enforcement: DeployEnforcementState;
|
|
64
|
+
/** Default true: a missing bound_environment on the receipt → env_mismatch. */
|
|
65
|
+
require_bound_environment?: boolean;
|
|
66
|
+
/** Default true: a missing bound_artifact_id → stale_artifact. */
|
|
67
|
+
require_bound_artifact?: boolean;
|
|
68
|
+
allowWarnDeploy?: boolean;
|
|
69
|
+
allowPrefixCompare?: boolean;
|
|
70
|
+
allowPending?: boolean;
|
|
71
|
+
};
|
|
72
|
+
export type DeployGateInput = {
|
|
73
|
+
deployTarget: DeployTarget;
|
|
74
|
+
receipt: DeployReceiptView | null;
|
|
75
|
+
requiredContext: DeployRequiredContext;
|
|
76
|
+
/** Incomplete/no-receipt → pending when true, else failure (default false). */
|
|
77
|
+
allowPending?: boolean;
|
|
78
|
+
/** Green the gate on WARN as well as ALLOW (default false; stricter for prod-shaped envs). */
|
|
79
|
+
allowWarnDeploy?: boolean;
|
|
80
|
+
/** Compare env/artifact by prefix instead of full equality (default false). */
|
|
81
|
+
allowPrefixCompare?: boolean;
|
|
82
|
+
};
|
|
83
|
+
export type DeployGateDecision = {
|
|
84
|
+
deploy_allowed: boolean;
|
|
85
|
+
state: GateStatusState;
|
|
86
|
+
reason: DeployGateReason;
|
|
87
|
+
enforcement_state: EnforcementState;
|
|
88
|
+
inescapable_deploy: boolean;
|
|
89
|
+
/** Named residual when the check is green but NOT inescapable (honesty channel, §3.2). */
|
|
90
|
+
residual?: DeployGateReason;
|
|
91
|
+
detail: {
|
|
92
|
+
environment: string;
|
|
93
|
+
artifact_id: string;
|
|
94
|
+
bound_environment: string | null;
|
|
95
|
+
bound_artifact_id: string | null;
|
|
96
|
+
operation: string | null;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* §1.4 — the normative, first-match-wins deploy decision. Pure; no I/O; deterministic.
|
|
101
|
+
*/
|
|
102
|
+
export declare function deployGate(input: DeployGateInput): DeployGateDecision;
|
|
103
|
+
//# sourceMappingURL=deploy-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-gate.d.ts","sourceRoot":"","sources":["../../src/deploy-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEzE;6EAC6E;AAC7E,MAAM,MAAM,gBAAgB,GACxB,sBAAsB,GACtB,YAAY,GACZ,wBAAwB,GACxB,oBAAoB,GACpB,cAAc,GACd,g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F;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,kBAAkB,CAiGrE"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deploy-gate (#8) — the PURE deploy authorization decision (deploy-gate-SPEC §1). The DEPLOY sibling
|
|
3
|
+
* of the merge gate: it answers "may THIS artifact deploy to THIS environment, given the finished
|
|
4
|
+
* receipt and the observed pipeline-enforcement state?"
|
|
5
|
+
*
|
|
6
|
+
* Same shape as the merge gate, different operation. It is a PURE function — NO I/O, NO CD-API call
|
|
7
|
+
* (pipeline enforcement is an INPUT, observed by the host and passed in). It does NOT re-decide: it
|
|
8
|
+
* reads only the finished receipt fields — the deterministic verdict stays the server's (D7). Same
|
|
9
|
+
* inputs → same output (D9).
|
|
10
|
+
*
|
|
11
|
+
* The three deploy-specific binds are the whole point: T7 (a MERGE — or operation-less — receipt can
|
|
12
|
+
* never deploy), environment binding (a staging ALLOW never authorizes production), and artifact
|
|
13
|
+
* binding (an old artifact's ALLOW never deploys a newer one). Scope honesty mirrors the merge gate:
|
|
14
|
+
* `inescapable_deploy` is true ONLY in the fully-enforcing, non-bypassable case; otherwise the check
|
|
15
|
+
* may be `success` for visibility but the claim is false with the residual named.
|
|
16
|
+
*
|
|
17
|
+
* Public source (ships in the npm package): references only receipt/target/enforcement fields and
|
|
18
|
+
* generic deploy-gate concepts — no scoring logic, weights, thresholds, pattern names, endpoints, or
|
|
19
|
+
* secrets.
|
|
20
|
+
*/
|
|
21
|
+
// ── helpers (pure) ────────────────────────────────────────────────────────────────────────────────
|
|
22
|
+
function norm(s) {
|
|
23
|
+
return String(s == null ? '' : s).trim().toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
/** §1.2 — full lowercase equality by default (env exact; artifact digest/sha); prefix opt-in. */
|
|
26
|
+
function sameNorm(a, b, allowPrefix) {
|
|
27
|
+
const na = norm(a);
|
|
28
|
+
const nb = norm(b);
|
|
29
|
+
if (!na || !nb)
|
|
30
|
+
return false;
|
|
31
|
+
if (na === nb)
|
|
32
|
+
return true;
|
|
33
|
+
if (allowPrefix && na.length >= 7 && nb.length >= 7 && (na.startsWith(nb) || nb.startsWith(na)))
|
|
34
|
+
return true;
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
/** §1.3 — allow-class for deploy: ALLOW (or WARN only when opted in) + a continue-class action. */
|
|
38
|
+
function isAllowClass(receipt, allowWarnDeploy) {
|
|
39
|
+
const dec = receipt.decision;
|
|
40
|
+
const decisionOk = dec === 'ALLOW' || (dec === 'WARN' && allowWarnDeploy === true);
|
|
41
|
+
if (!decisionOk)
|
|
42
|
+
return false;
|
|
43
|
+
const ea = receipt.execution_action;
|
|
44
|
+
if (ea === undefined || ea === null || ea === '')
|
|
45
|
+
return true;
|
|
46
|
+
return ea === 'CONTINUE' || ea === 'CONTINUE_WITH_MONITORING';
|
|
47
|
+
}
|
|
48
|
+
/** target_id must name this service/repository (exact or `svc:`/`repo:`/path/colon suffix). */
|
|
49
|
+
function idMatchesName(targetId, name) {
|
|
50
|
+
const t = norm(targetId);
|
|
51
|
+
const r = norm(name);
|
|
52
|
+
return t === r || t === `svc:${r}` || t === `repo:${r}` || t.endsWith(`:${r}`) || t.endsWith(`/${r}`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* §1.4 — the normative, first-match-wins deploy decision. Pure; no I/O; deterministic.
|
|
56
|
+
*/
|
|
57
|
+
export function deployGate(input) {
|
|
58
|
+
const target = input.deployTarget || {};
|
|
59
|
+
const rc = input.requiredContext || {};
|
|
60
|
+
const enf = rc.enforcement || { enforcement: 'UNKNOWN', bypass_possible: true };
|
|
61
|
+
const enforcement_state = enf.enforcement;
|
|
62
|
+
const opRequired = rc.operation ?? 'deploy';
|
|
63
|
+
const requireEnv = rc.require_bound_environment !== false; // default true
|
|
64
|
+
const requireArt = rc.require_bound_artifact !== false; // default true
|
|
65
|
+
const allowPending = input.allowPending ?? rc.allowPending ?? false;
|
|
66
|
+
const allowWarnDeploy = input.allowWarnDeploy ?? rc.allowWarnDeploy ?? false;
|
|
67
|
+
const allowPrefix = input.allowPrefixCompare ?? rc.allowPrefixCompare ?? false;
|
|
68
|
+
const receipt = input.receipt;
|
|
69
|
+
const detail = {
|
|
70
|
+
environment: norm(target.environment),
|
|
71
|
+
artifact_id: norm(target.artifact_id),
|
|
72
|
+
bound_environment: receipt && receipt.bound_environment != null ? norm(receipt.bound_environment) : null,
|
|
73
|
+
bound_artifact_id: receipt && receipt.bound_artifact_id != null ? norm(receipt.bound_artifact_id) : null,
|
|
74
|
+
operation: receipt && receipt.operation != null ? String(receipt.operation) : null,
|
|
75
|
+
};
|
|
76
|
+
const deny = (state, reason) => ({
|
|
77
|
+
deploy_allowed: false, state, reason, enforcement_state, inescapable_deploy: false, detail,
|
|
78
|
+
});
|
|
79
|
+
// 0) incomplete target → pending/failure (fail-closed on missing evaluation input).
|
|
80
|
+
if (!target.environment || String(target.environment).trim() === ''
|
|
81
|
+
|| !target.artifact_id || String(target.artifact_id).trim() === '') {
|
|
82
|
+
return deny(allowPending ? 'pending' : 'failure', 'inputs_incomplete');
|
|
83
|
+
}
|
|
84
|
+
// 1) no receipt → fail-closed (D4).
|
|
85
|
+
if (receipt === null || receipt === undefined) {
|
|
86
|
+
return deny(allowPending ? 'pending' : 'failure', 'no_receipt');
|
|
87
|
+
}
|
|
88
|
+
// 2) lifecycle authorization — a valid signature alone is NOT sufficient (D5).
|
|
89
|
+
if (receipt.currently_authorized !== true) {
|
|
90
|
+
return deny('failure', 'receipt_not_authorized');
|
|
91
|
+
}
|
|
92
|
+
// 3) T7 — operation MUST be deploy. A merge (or any other) receipt cannot deploy, and a MISSING
|
|
93
|
+
// operation also fails closed (stricter than the merge gate — deploy is higher-risk) (D1).
|
|
94
|
+
if (receipt.operation == null || norm(receipt.operation) !== norm(opRequired)) {
|
|
95
|
+
return deny('failure', 'operation_mismatch');
|
|
96
|
+
}
|
|
97
|
+
// 4) ENVIRONMENT binding — a staging ALLOW never authorizes production (D2).
|
|
98
|
+
if (requireEnv) {
|
|
99
|
+
if (!receipt.bound_environment || !sameNorm(receipt.bound_environment, target.environment, allowPrefix)) {
|
|
100
|
+
return deny('failure', 'env_mismatch');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (receipt.bound_environment && !sameNorm(receipt.bound_environment, target.environment, allowPrefix)) {
|
|
104
|
+
return deny('failure', 'env_mismatch');
|
|
105
|
+
}
|
|
106
|
+
// 5) ARTIFACT binding — an old artifact's ALLOW never deploys a newer one (D3, the stale analog).
|
|
107
|
+
if (requireArt) {
|
|
108
|
+
if (!receipt.bound_artifact_id || !sameNorm(receipt.bound_artifact_id, target.artifact_id, allowPrefix)) {
|
|
109
|
+
return deny('failure', 'stale_artifact');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (receipt.bound_artifact_id && !sameNorm(receipt.bound_artifact_id, target.artifact_id, allowPrefix)) {
|
|
113
|
+
return deny('failure', 'stale_artifact');
|
|
114
|
+
}
|
|
115
|
+
// 6) optional re-bind to the current change set.
|
|
116
|
+
if (rc.expected_fingerprint != null && receipt.verdict_fingerprint !== rc.expected_fingerprint) {
|
|
117
|
+
return deny('failure', 'fingerprint_mismatch');
|
|
118
|
+
}
|
|
119
|
+
if (rc.expected_body_hash != null && receipt.body_hash !== rc.expected_body_hash) {
|
|
120
|
+
return deny('failure', 'body_hash_mismatch');
|
|
121
|
+
}
|
|
122
|
+
// 7) optional service / repository target binding.
|
|
123
|
+
if (rc.service && receipt.target_id) {
|
|
124
|
+
if (!idMatchesName(receipt.target_id, rc.service))
|
|
125
|
+
return deny('failure', 'target_mismatch');
|
|
126
|
+
}
|
|
127
|
+
else if (rc.repository && receipt.target_id) {
|
|
128
|
+
if (!idMatchesName(receipt.target_id, rc.repository))
|
|
129
|
+
return deny('failure', 'target_mismatch');
|
|
130
|
+
}
|
|
131
|
+
// 8) decision class — only an allow-class verdict greens the deploy gate (D6).
|
|
132
|
+
if (!isAllowClass(receipt, allowWarnDeploy)) {
|
|
133
|
+
return deny('failure', 'decision_not_allow');
|
|
134
|
+
}
|
|
135
|
+
// 9) success for the CHECK / pipeline step — green for visibility regardless of enforcement strength.
|
|
136
|
+
// 10) inescapable_deploy claim (STRICT, §1.4 step 10 / D8): only when the pipeline actually enforces
|
|
137
|
+
// the step AND no bypass is possible. Never true otherwise.
|
|
138
|
+
const inescapable_deploy = enforcement_state === 'ENFORCING' && enf.bypass_possible === false;
|
|
139
|
+
let residual;
|
|
140
|
+
if (!inescapable_deploy) {
|
|
141
|
+
if (enforcement_state === 'ENFORCING')
|
|
142
|
+
residual = 'bypass_open'; // enforced, but a bypass exists
|
|
143
|
+
else
|
|
144
|
+
residual = 'enforcement_not_configured'; // ADVISORY / ABSENT / UNKNOWN
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
deploy_allowed: true,
|
|
148
|
+
state: 'success',
|
|
149
|
+
reason: 'allow_current_deploy',
|
|
150
|
+
enforcement_state,
|
|
151
|
+
inescapable_deploy,
|
|
152
|
+
...(residual ? { residual } : {}),
|
|
153
|
+
detail,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=deploy-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-gate.js","sourceRoot":"","sources":["../../src/deploy-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAuGH,qGAAqG;AACrG,SAAS,IAAI,CAAC,CAA4B;IACxC,OAAO,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACzD,CAAC;AAED,iGAAiG;AACjG,SAAS,QAAQ,CAAC,CAA4B,EAAE,CAA4B,EAAE,WAAoB;IAChG,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC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AAsB;QAC9B,iBAAiB;QACjB,kBAAkB;QAClB,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,MAAM;KACP,CAAC;AACJ,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -34,4 +34,6 @@ export { guardToolRegistry, RegistryConstructionError } from './tool-registry.js
|
|
|
34
34
|
export type { RawTool, ProtectedTool, ToolMutationClass, EnforcementCoverage, RegistryCoverageReport, GuardToolRegistryConfig, RegistryResult, ToolBinder, RegistryConstructionErrorCode, } from './tool-registry.js';
|
|
35
35
|
export { gateDecision } from './merge-gate.js';
|
|
36
36
|
export type { GateDecisionInput, GateDecision, ReceiptView, RequiredContext, ProtectionState, GateReason, GateStatusState, EnforcementState, } from './merge-gate.js';
|
|
37
|
+
export { deployGate } from './deploy-gate.js';
|
|
38
|
+
export type { DeployGateInput, DeployGateDecision, DeployReceiptView, DeployRequiredContext, DeployEnforcementState, DeployTarget, DeployGateReason, } from './deploy-gate.js';
|
|
37
39
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7F,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGxG,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAC1G,YAAY,EAAE,U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Q,GACT,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACrE,YAAY,EACV,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAC7E,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,IAAI,oBAAoB,GAClG,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAClF,YAAY,EACV,OAAO,EACP,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,UAAU,EACV,6BAA6B,GAC9B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EACV,iBAAiB,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAC9E,UAAU,EAAE,eAAe,EAAE,gBAAgB,GAC9C,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EACV,eAAe,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,qBAAqB,EAC7E,sBAAsB,EAAE,YAAY,EAAE,gBAAgB,GACvD,MAAM,kBAAkB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -35,4 +35,6 @@ export { matchGlob, globToRegExp } from './resolver-glob.js';
|
|
|
35
35
|
export { guardToolRegistry, RegistryConstructionError } from './tool-registry.js';
|
|
36
36
|
// repo-merge-gate (#7) — the PURE repo-side merge decision (Placement B). No I/O; protection is input.
|
|
37
37
|
export { gateDecision } from './merge-gate.js';
|
|
38
|
+
// deploy-gate (#8) — the PURE deploy authorization decision. No I/O; pipeline enforcement is input.
|
|
39
|
+
export { deployGate } from './deploy-gate.js';
|
|
38
40
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAClE,2FAA2F;AAC3F,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE7F,sGAAsG;AACtG,+DAA+D;AAC/D,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAE1G,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,+FAA+F;AAC/F,OAAO,EACL,mBAAmB,EAAE,qBAAqB,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EACnF,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,GAC7E,MAAM,oBAAoB,CAAC;AA0B5B,kGAAkG;AAClG,wFAAwF;AACxF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAKrE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE7D,qGAAqG;AACrG,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAalF,uGAAuG;AACvG,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAClE,2FAA2F;AAC3F,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE7F,sGAAsG;AACtG,+DAA+D;AAC/D,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAE1G,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,+FAA+F;AAC/F,OAAO,EACL,mBAAmB,EAAE,qBAAqB,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EACnF,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,GAC7E,MAAM,oBAAoB,CAAC;AA0B5B,kGAAkG;AAClG,wFAAwF;AACxF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAKrE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE7D,qGAAqG;AACrG,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAalF,uGAAuG;AACvG,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAM/C,oGAAoG;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderifts/agent-guard",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Fail-closed guard for AI agent tool calls — preflight contract changes before they execute. Security core frozen (agent-guard-api v1.0); v1.1 adds client-side enforcement: receipt→envelope binding, decision↔action reconciliation, safe_for_agent + degraded fail-closed, and enforced⟺executed (P0 client-enforcement pack).",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|