@getvda/compliance-guard 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/LICENSE +202 -0
- package/NOTICE +30 -0
- package/README.md +69 -0
- package/dist/diff.d.ts +16 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +154 -0
- package/dist/diff.js.map +1 -0
- package/dist/entrypoints.d.ts +32 -0
- package/dist/entrypoints.d.ts.map +1 -0
- package/dist/entrypoints.js +31 -0
- package/dist/entrypoints.js.map +1 -0
- package/dist/guard.d.ts +28 -0
- package/dist/guard.d.ts.map +1 -0
- package/dist/guard.js +94 -0
- package/dist/guard.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/render.d.ts +16 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +76 -0
- package/dist/render.js.map +1 -0
- package/dist/signoff.d.ts +42 -0
- package/dist/signoff.d.ts.map +1 -0
- package/dist/signoff.js +29 -0
- package/dist/signoff.js.map +1 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Verified Digital Agents (VDA) — Agent Control Plane
|
|
2
|
+
Copyright 2026 getvda.ai
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use these files except in compliance with the License. A copy of the
|
|
6
|
+
License is in the LICENSE file at the repository root and at:
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
11
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
12
|
+
CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
What these packages do and do NOT carry
|
|
17
|
+
----------------------------------------
|
|
18
|
+
|
|
19
|
+
The @getvda/* packages VERIFY and ENFORCE governance. They do not carry the
|
|
20
|
+
trust anchors that governance rests on:
|
|
21
|
+
|
|
22
|
+
- Bundle-signing keys (#key-3) live only in getvda's Secret Manager. These
|
|
23
|
+
packages VERIFY a bundle's signature against the public key resolved from
|
|
24
|
+
did:web:acp.getvda.ai; they cannot mint a bundle that verifies.
|
|
25
|
+
- Witness account credentials are the customer's own (customer-managed
|
|
26
|
+
custody). These packages SEAL to a Witness account the caller supplies;
|
|
27
|
+
they carry no standing credential.
|
|
28
|
+
|
|
29
|
+
The code is open. The trust anchors are not in the code — and giving away the
|
|
30
|
+
verifier does not give away the ability to forge what it verifies.
|
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @getvda/compliance-guard
|
|
2
|
+
|
|
3
|
+
> **Status: pre-1.0 (0.x).** Public API may change between minor versions —
|
|
4
|
+
> pin an exact version if you need stability. Part of the [getvda.ai](https://getvda.ai)
|
|
5
|
+
> governance suite. Honesty discipline: nothing documented here is live unless it
|
|
6
|
+
> says so, boundaries (fail-static, condition-assertion) are stated where they apply,
|
|
7
|
+
> and a stub is labelled a stub.
|
|
8
|
+
|
|
9
|
+
> **What this carries — and what it does not.** This package *verifies and
|
|
10
|
+
> enforces* governance. The trust anchors are not in it: bundle-signing keys
|
|
11
|
+
> (`#key-3`) live only in getvda's Secret Manager, and Witness account
|
|
12
|
+
> credentials are the caller's own (customer-managed custody). It verifies a
|
|
13
|
+
> signature against the public key resolved from `did:web:acp.getvda.ai` and
|
|
14
|
+
> seals to a Witness account you supply — it cannot mint a bundle that verifies,
|
|
15
|
+
> and carries no standing credential. Open code, trust anchors elsewhere.
|
|
16
|
+
|
|
17
|
+
The **Compliance Guard** + the **honest governance diff** (Phase 2b / 2c) — the
|
|
18
|
+
layer that knows what governance files MEAN.
|
|
19
|
+
|
|
20
|
+
Provider-free by design: it operates on before/after **governance sets** (file
|
|
21
|
+
contents only), so the CI gate needs nothing but the files — no git, no network.
|
|
22
|
+
|
|
23
|
+
## Honest diff (2c)
|
|
24
|
+
|
|
25
|
+
`computeGovernanceDiff(before, after)` reports what changed in **meaning**, not
|
|
26
|
+
text, each item tagged with a direction and a human headline written for a
|
|
27
|
+
non-engineer approver:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
3 MUST clauses removed ▼ weakens
|
|
31
|
+
ISO 42001 A.9.2 citation dropped ▼ weakens
|
|
32
|
+
Capability "issue_refund" broadened — 1 condition removed ▼ weakens
|
|
33
|
+
1 MUST clause added (NIST 800-53 AU-3) ▲ strengthens
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`renderDiffForHuman` / `renderSummaryLine` turn it into the plain-language block
|
|
37
|
+
the Phase-4 approval surface shows.
|
|
38
|
+
|
|
39
|
+
## Compliance Guard (2b)
|
|
40
|
+
|
|
41
|
+
`runComplianceGuard(before, after, { signOffs, policy })` is **the** single
|
|
42
|
+
implementation. It blocks a change that WEAKENS governance unless a **named
|
|
43
|
+
sign-off** covers the weakening:
|
|
44
|
+
|
|
45
|
+
- a MUST / MUST NOT clause count dropped
|
|
46
|
+
- a framework citation stripped or altered (NIST / ISO 42001 / EU AI Act / GDPR / APQC)
|
|
47
|
+
- a policy-required reference removed
|
|
48
|
+
- a conditioned capability broadened (new capability, or a condition removed) —
|
|
49
|
+
and reworded conditions are surfaced for review (can't prove they aren't a
|
|
50
|
+
broadening)
|
|
51
|
+
|
|
52
|
+
### One rule-set, two entry points (no drift)
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
inlineGuard(before, after, opts); // author time — fast feedback
|
|
56
|
+
ciGuard(before, after, opts); // the authoritative CI gate — report + exit code
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Both delegate to `runComplianceGuard`; their `result` is **byte-identical** for
|
|
60
|
+
identical input (asserted by test). A single definition, provably one
|
|
61
|
+
implementation — the same discipline Witness used.
|
|
62
|
+
|
|
63
|
+
### The sign-off seam (stub in Phase 2)
|
|
64
|
+
|
|
65
|
+
`verifySignOffs` is a **stub**: it matches sign-offs to findings by id but does
|
|
66
|
+
NOT authenticate the approver, check authority, or seal anything. Phase 4 swaps
|
|
67
|
+
it for the real HITL gate (federated identity + Onboarding/CODEOWNERS authority +
|
|
68
|
+
`hitl_decision` sealed to Witness) — drop-in, because the Guard only asks "is
|
|
69
|
+
finding F covered?".
|
package/dist/diff.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* computeGovernanceDiff — the honest, structural governance diff (2c).
|
|
3
|
+
*
|
|
4
|
+
* Compares two governance sets and reports what changed in MEANING, not text:
|
|
5
|
+
* MUST/MUST NOT counts, framework citations, and conditioned capabilities. Each
|
|
6
|
+
* change item carries a human headline and a direction (weakens / strengthens /
|
|
7
|
+
* neutral). Neutral and factual — no policy verdict here (that is the Guard).
|
|
8
|
+
*
|
|
9
|
+
* This is the shape a non-engineer approver reads in Phase 4, so the headlines
|
|
10
|
+
* are written for a human ("3 MUST clauses removed", "ISO 42001 A.9.2 citation
|
|
11
|
+
* dropped"), not for a machine.
|
|
12
|
+
*/
|
|
13
|
+
import { type GovernanceSet } from '@getvda/governance-schema';
|
|
14
|
+
import type { GovernanceDiff } from './types.js';
|
|
15
|
+
export declare function computeGovernanceDiff(before: GovernanceSet, after: GovernanceSet): GovernanceDiff;
|
|
16
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,YAAY,CAAC;AAqKpB,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,cAAc,CAUjG"}
|
package/dist/diff.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* computeGovernanceDiff — the honest, structural governance diff (2c).
|
|
3
|
+
*
|
|
4
|
+
* Compares two governance sets and reports what changed in MEANING, not text:
|
|
5
|
+
* MUST/MUST NOT counts, framework citations, and conditioned capabilities. Each
|
|
6
|
+
* change item carries a human headline and a direction (weakens / strengthens /
|
|
7
|
+
* neutral). Neutral and factual — no policy verdict here (that is the Guard).
|
|
8
|
+
*
|
|
9
|
+
* This is the shape a non-engineer approver reads in Phase 4, so the headlines
|
|
10
|
+
* are written for a human ("3 MUST clauses removed", "ISO 42001 A.9.2 citation
|
|
11
|
+
* dropped"), not for a machine.
|
|
12
|
+
*/
|
|
13
|
+
import { GOVERNANCE_FILE_NAMES, presentFiles, } from '@getvda/governance-schema';
|
|
14
|
+
function plural(n, singular) {
|
|
15
|
+
return `${n} ${singular}${n === 1 ? '' : 's'}`;
|
|
16
|
+
}
|
|
17
|
+
function setDiff(before, after) {
|
|
18
|
+
const b = new Set(before);
|
|
19
|
+
const a = new Set(after);
|
|
20
|
+
return {
|
|
21
|
+
removed: before.filter((x) => !a.has(x)),
|
|
22
|
+
added: after.filter((x) => !b.has(x)),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Pretty a citation ref "iso:A.9.2" as "ISO 42001 A.9.2" for headlines. */
|
|
26
|
+
const FRAMEWORK_LABEL = {
|
|
27
|
+
nist: 'NIST 800-53',
|
|
28
|
+
iso: 'ISO 42001',
|
|
29
|
+
euAiAct: 'EU AI Act',
|
|
30
|
+
gdpr: 'GDPR',
|
|
31
|
+
apqc: 'APQC PCF',
|
|
32
|
+
};
|
|
33
|
+
function labelRef(ref) {
|
|
34
|
+
const [fw, ...rest] = ref.split(':');
|
|
35
|
+
const clause = rest.join(':');
|
|
36
|
+
return `${FRAMEWORK_LABEL[fw ?? ''] ?? fw}${clause ? ` ${clause}` : ''}`;
|
|
37
|
+
}
|
|
38
|
+
function compareFile(file, before, after) {
|
|
39
|
+
const items = [];
|
|
40
|
+
const add = (code, impact, headline, detail) => {
|
|
41
|
+
items.push(detail === undefined
|
|
42
|
+
? { code, impact, file, headline }
|
|
43
|
+
: { code, impact, file, headline, detail });
|
|
44
|
+
};
|
|
45
|
+
if (before && !after) {
|
|
46
|
+
add('file_removed', 'weakens', `${file} removed from the governance set`);
|
|
47
|
+
return { file, status: 'removed', items };
|
|
48
|
+
}
|
|
49
|
+
if (!before && after) {
|
|
50
|
+
add('file_added', 'neutral', `${file} added to the governance set`);
|
|
51
|
+
return { file, status: 'added', items };
|
|
52
|
+
}
|
|
53
|
+
if (!before || !after) {
|
|
54
|
+
return { file, status: 'unchanged', items };
|
|
55
|
+
}
|
|
56
|
+
const bf = before.fingerprint;
|
|
57
|
+
const af = after.fingerprint;
|
|
58
|
+
// MUST / MUST NOT counts.
|
|
59
|
+
if (af.mustCount < bf.mustCount) {
|
|
60
|
+
add('must_removed', 'weakens', `${plural(bf.mustCount - af.mustCount, 'MUST clause')} removed`);
|
|
61
|
+
}
|
|
62
|
+
else if (af.mustCount > bf.mustCount) {
|
|
63
|
+
add('must_added', 'strengthens', `${plural(af.mustCount - bf.mustCount, 'MUST clause')} added`);
|
|
64
|
+
}
|
|
65
|
+
if (af.mustNotCount < bf.mustNotCount) {
|
|
66
|
+
add('must_not_removed', 'weakens', `${plural(bf.mustNotCount - af.mustNotCount, 'MUST NOT clause')} removed`);
|
|
67
|
+
}
|
|
68
|
+
else if (af.mustNotCount > bf.mustNotCount) {
|
|
69
|
+
add('must_not_added', 'strengthens', `${plural(af.mustNotCount - bf.mustNotCount, 'MUST NOT clause')} added`);
|
|
70
|
+
}
|
|
71
|
+
// Citations.
|
|
72
|
+
const cit = setDiff(bf.citationRefs, af.citationRefs);
|
|
73
|
+
for (const ref of cit.removed) {
|
|
74
|
+
add('citation_dropped', 'weakens', `${labelRef(ref)} citation dropped`, ref);
|
|
75
|
+
}
|
|
76
|
+
for (const ref of cit.added) {
|
|
77
|
+
add('citation_added', 'strengthens', `${labelRef(ref)} citation added`, ref);
|
|
78
|
+
}
|
|
79
|
+
// Conditioned capabilities (SKILL.md).
|
|
80
|
+
compareCapabilities(before, after, add);
|
|
81
|
+
// Prose-only change (wording changed, no structural metric moved).
|
|
82
|
+
if (items.length === 0 && before.source !== after.source) {
|
|
83
|
+
add('prose_changed', 'neutral', 'Wording changed with no change to clauses, citations, or capabilities');
|
|
84
|
+
}
|
|
85
|
+
const status = items.length === 0 ? 'unchanged' : 'modified';
|
|
86
|
+
return { file, status, items };
|
|
87
|
+
}
|
|
88
|
+
function compareCapabilities(before, after, add) {
|
|
89
|
+
const beforeCaps = new Map(before.parsed.capabilities.map((c) => [c.capability, c.conditions]));
|
|
90
|
+
const afterCaps = new Map(after.parsed.capabilities.map((c) => [c.capability, c.conditions]));
|
|
91
|
+
for (const [name, afterConds] of afterCaps) {
|
|
92
|
+
if (!beforeCaps.has(name)) {
|
|
93
|
+
add('capability_added', 'weakens', `New capability granted: "${name}"`, `conditions: ${afterConds.join('; ') || '(none)'}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
for (const [name, beforeConds] of beforeCaps) {
|
|
97
|
+
const afterConds = afterCaps.get(name);
|
|
98
|
+
if (afterConds === undefined) {
|
|
99
|
+
add('capability_removed', 'strengthens', `Capability withdrawn: "${name}"`);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const { removed, added } = setDiff(beforeConds, afterConds);
|
|
103
|
+
if (removed.length > 0 && added.length === 0) {
|
|
104
|
+
add('capability_condition_removed', 'weakens', `Capability "${name}" broadened — ${plural(removed.length, 'condition')} removed`, removed.join('; '));
|
|
105
|
+
}
|
|
106
|
+
else if (added.length > 0 && removed.length === 0) {
|
|
107
|
+
add('capability_condition_added', 'strengthens', `Capability "${name}" narrowed — ${plural(added.length, 'condition')} added`, added.join('; '));
|
|
108
|
+
}
|
|
109
|
+
else if (removed.length > 0 && added.length > 0) {
|
|
110
|
+
// Can't verify a reword didn't hide a broadening — surface as altered, let
|
|
111
|
+
// the Guard require a human look.
|
|
112
|
+
add('capability_condition_altered', 'neutral', `Capability "${name}" conditions reworded`, `removed: ${removed.join('; ')} | added: ${added.join('; ')}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export function computeGovernanceDiff(before, after) {
|
|
117
|
+
const fileDiffs = [];
|
|
118
|
+
for (const name of GOVERNANCE_FILE_NAMES) {
|
|
119
|
+
const fd = compareFile(name, before.files[name], after.files[name]);
|
|
120
|
+
if (fd.items.length > 0)
|
|
121
|
+
fileDiffs.push(fd);
|
|
122
|
+
}
|
|
123
|
+
const items = fileDiffs.flatMap((f) => f.items);
|
|
124
|
+
const summary = summarize(items, before, after);
|
|
125
|
+
return { files: fileDiffs, items, summary, clean: items.length === 0 };
|
|
126
|
+
}
|
|
127
|
+
function summarize(items, before, after) {
|
|
128
|
+
const refs = (code) => items.filter((i) => i.code === code && i.detail).map((i) => i.detail);
|
|
129
|
+
const beforeFiles = new Set(presentFiles(before));
|
|
130
|
+
const afterFiles = new Set(presentFiles(after));
|
|
131
|
+
return {
|
|
132
|
+
mustRemoved: sumDeltas(items, 'must_removed'),
|
|
133
|
+
mustNotRemoved: sumDeltas(items, 'must_not_removed'),
|
|
134
|
+
mustAdded: sumDeltas(items, 'must_added'),
|
|
135
|
+
mustNotAdded: sumDeltas(items, 'must_not_added'),
|
|
136
|
+
citationsDropped: refs('citation_dropped'),
|
|
137
|
+
citationsAdded: refs('citation_added'),
|
|
138
|
+
capabilitiesBroadened: items
|
|
139
|
+
.filter((i) => i.code === 'capability_added' || i.code === 'capability_condition_removed')
|
|
140
|
+
.map((i) => i.headline),
|
|
141
|
+
filesAdded: [...afterFiles].filter((f) => !beforeFiles.has(f)),
|
|
142
|
+
filesRemoved: [...beforeFiles].filter((f) => !afterFiles.has(f)),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/** MUST/MUST NOT headlines encode "N MUST clauses removed"; recover N. */
|
|
146
|
+
function sumDeltas(items, code) {
|
|
147
|
+
return items
|
|
148
|
+
.filter((i) => i.code === code)
|
|
149
|
+
.reduce((n, i) => {
|
|
150
|
+
const m = /^(\d+)\s/.exec(i.headline);
|
|
151
|
+
return n + (m ? Number.parseInt(m[1], 10) : 0);
|
|
152
|
+
}, 0);
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=diff.js.map
|
package/dist/diff.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,qBAAqB,EACrB,YAAY,GAIb,MAAM,2BAA2B,CAAC;AASnC,SAAS,MAAM,CAAC,CAAS,EAAE,QAAgB;IACzC,OAAO,GAAG,CAAC,IAAI,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,OAAO,CAAI,MAAoB,EAAE,KAAmB;IAC3D,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO;QACL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UAAU,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9D,YAAY,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KACjE,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,SAAS,SAAS,CAAC,KAAsC,EAAE,IAAY;IACrE,OAAO,KAAK;SACT,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;SAC9B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACf,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two entry points onto the ONE Compliance Guard implementation.
|
|
3
|
+
*
|
|
4
|
+
* inlineGuard — author-time, fast feedback. Returns the verdict + terse
|
|
5
|
+
* messages for an editor/CLI to show as you type.
|
|
6
|
+
* ciGuard — the authoritative gate. Returns the verdict + a full human
|
|
7
|
+
* report + a process exit code for a CI step.
|
|
8
|
+
*
|
|
9
|
+
* BOTH delegate to `runComplianceGuard`. They differ only in PRESENTATION — the
|
|
10
|
+
* `result` field is byte-identical for identical inputs (asserted by test). This
|
|
11
|
+
* is the no-drift guarantee: a single rule definition, provably one
|
|
12
|
+
* implementation, two doorways.
|
|
13
|
+
*/
|
|
14
|
+
import type { GovernanceSet } from '@getvda/governance-schema';
|
|
15
|
+
import { type RunGuardOptions } from './guard.js';
|
|
16
|
+
import type { GuardResult } from './types.js';
|
|
17
|
+
export interface InlineGuardOutput {
|
|
18
|
+
readonly result: GuardResult;
|
|
19
|
+
readonly ok: boolean;
|
|
20
|
+
/** Terse, ordered messages for inline display. */
|
|
21
|
+
readonly messages: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
export declare function inlineGuard(before: GovernanceSet, after: GovernanceSet, options?: RunGuardOptions): InlineGuardOutput;
|
|
24
|
+
export interface CiGuardOutput {
|
|
25
|
+
readonly result: GuardResult;
|
|
26
|
+
/** 0 = pass, 1 = blocked. For `process.exit` in a CI step. */
|
|
27
|
+
readonly exitCode: number;
|
|
28
|
+
/** Full human report for the CI log / PR comment. */
|
|
29
|
+
readonly report: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function ciGuard(before: GovernanceSet, after: GovernanceSet, options?: RunGuardOptions): CiGuardOutput;
|
|
32
|
+
//# sourceMappingURL=entrypoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,eAAoB,GAC5B,iBAAiB,CAMnB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,OAAO,CACrB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,eAAoB,GAC5B,aAAa,CAOf"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two entry points onto the ONE Compliance Guard implementation.
|
|
3
|
+
*
|
|
4
|
+
* inlineGuard — author-time, fast feedback. Returns the verdict + terse
|
|
5
|
+
* messages for an editor/CLI to show as you type.
|
|
6
|
+
* ciGuard — the authoritative gate. Returns the verdict + a full human
|
|
7
|
+
* report + a process exit code for a CI step.
|
|
8
|
+
*
|
|
9
|
+
* BOTH delegate to `runComplianceGuard`. They differ only in PRESENTATION — the
|
|
10
|
+
* `result` field is byte-identical for identical inputs (asserted by test). This
|
|
11
|
+
* is the no-drift guarantee: a single rule definition, provably one
|
|
12
|
+
* implementation, two doorways.
|
|
13
|
+
*/
|
|
14
|
+
import { runComplianceGuard } from './guard.js';
|
|
15
|
+
import { renderGuardResult, renderSummaryLine } from './render.js';
|
|
16
|
+
export function inlineGuard(before, after, options = {}) {
|
|
17
|
+
const result = runComplianceGuard(before, after, options);
|
|
18
|
+
const messages = result.passed
|
|
19
|
+
? [`Compliance Guard OK — ${renderSummaryLine(result.diff)}`]
|
|
20
|
+
: result.unsignedBlocking.map((f) => `BLOCK: ${f.headline} (needs sign-off)`);
|
|
21
|
+
return { result, ok: result.passed, messages };
|
|
22
|
+
}
|
|
23
|
+
export function ciGuard(before, after, options = {}) {
|
|
24
|
+
const result = runComplianceGuard(before, after, options);
|
|
25
|
+
return {
|
|
26
|
+
result,
|
|
27
|
+
exitCode: result.passed ? 0 : 1,
|
|
28
|
+
report: renderGuardResult(result),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=entrypoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,kBAAkB,EAAwB,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AASnE,MAAM,UAAU,WAAW,CACzB,MAAqB,EACrB,KAAoB,EACpB,UAA2B,EAAE;IAE7B,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM;QAC5B,CAAC,CAAC,CAAC,yBAAyB,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7D,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,QAAQ,mBAAmB,CAAC,CAAC;IAChF,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;AACjD,CAAC;AAUD,MAAM,UAAU,OAAO,CACrB,MAAqB,EACrB,KAAoB,EACpB,UAA2B,EAAE;IAE7B,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1D,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC;KAClC,CAAC;AACJ,CAAC"}
|
package/dist/guard.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runComplianceGuard — THE Compliance Guard implementation (2b).
|
|
3
|
+
*
|
|
4
|
+
* ONE rule-set, ONE implementation. Both entry points (inline authoring-time and
|
|
5
|
+
* CI authoritative gate) call THIS function — see entrypoints.ts. Nothing
|
|
6
|
+
* re-implements the rules; drift is impossible by construction, and a test
|
|
7
|
+
* asserts the two entry points return identical verdicts (the same no-drift
|
|
8
|
+
* discipline Witness used: a single definition, provably one implementation).
|
|
9
|
+
*
|
|
10
|
+
* The Guard blocks a change when it WEAKENS governance and the weakening is not
|
|
11
|
+
* covered by a named sign-off:
|
|
12
|
+
* - a MUST / MUST NOT clause count dropped
|
|
13
|
+
* - a framework citation was stripped or altered
|
|
14
|
+
* - a policy-required reference was removed
|
|
15
|
+
* - a conditioned capability was broadened (new capability, or a condition
|
|
16
|
+
* removed), or its conditions were reworded (can't verify → needs a look)
|
|
17
|
+
*/
|
|
18
|
+
import type { GovernanceSet } from '@getvda/governance-schema';
|
|
19
|
+
import type { GovernanceDiff, GuardFinding, GuardPolicy, GuardResult } from './types.js';
|
|
20
|
+
import { type SignOff } from './signoff.js';
|
|
21
|
+
export interface RunGuardOptions {
|
|
22
|
+
readonly signOffs?: readonly SignOff[];
|
|
23
|
+
readonly policy?: GuardPolicy;
|
|
24
|
+
}
|
|
25
|
+
export declare function deriveFindings(diff: GovernanceDiff, policy?: GuardPolicy): GuardFinding[];
|
|
26
|
+
/** The single Compliance Guard evaluation. */
|
|
27
|
+
export declare function runComplianceGuard(before: GovernanceSet, after: GovernanceSet, options?: RunGuardOptions): GuardResult;
|
|
28
|
+
//# sourceMappingURL=guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,KAAK,EAGV,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAoED,wBAAgB,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE,CAOzF;AAED,8CAA8C;AAC9C,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,eAAoB,GAC5B,WAAW,CAoBb"}
|
package/dist/guard.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runComplianceGuard — THE Compliance Guard implementation (2b).
|
|
3
|
+
*
|
|
4
|
+
* ONE rule-set, ONE implementation. Both entry points (inline authoring-time and
|
|
5
|
+
* CI authoritative gate) call THIS function — see entrypoints.ts. Nothing
|
|
6
|
+
* re-implements the rules; drift is impossible by construction, and a test
|
|
7
|
+
* asserts the two entry points return identical verdicts (the same no-drift
|
|
8
|
+
* discipline Witness used: a single definition, provably one implementation).
|
|
9
|
+
*
|
|
10
|
+
* The Guard blocks a change when it WEAKENS governance and the weakening is not
|
|
11
|
+
* covered by a named sign-off:
|
|
12
|
+
* - a MUST / MUST NOT clause count dropped
|
|
13
|
+
* - a framework citation was stripped or altered
|
|
14
|
+
* - a policy-required reference was removed
|
|
15
|
+
* - a conditioned capability was broadened (new capability, or a condition
|
|
16
|
+
* removed), or its conditions were reworded (can't verify → needs a look)
|
|
17
|
+
*/
|
|
18
|
+
import { computeGovernanceDiff } from './diff.js';
|
|
19
|
+
import { verifySignOffs } from './signoff.js';
|
|
20
|
+
function slug(s) {
|
|
21
|
+
return s
|
|
22
|
+
.toLowerCase()
|
|
23
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
24
|
+
.replace(/^-+|-+$/g, '')
|
|
25
|
+
.slice(0, 48);
|
|
26
|
+
}
|
|
27
|
+
function findingId(file, code, key) {
|
|
28
|
+
return `${file}:${code}:${slug(key)}`;
|
|
29
|
+
}
|
|
30
|
+
/** Map a weakening (or ambiguous) diff item to a guard finding, or null. */
|
|
31
|
+
function toFinding(item, policy) {
|
|
32
|
+
const guardNewCaps = policy?.guardNewCapabilities ?? true;
|
|
33
|
+
const required = new Set(policy?.requiredReferences ?? []);
|
|
34
|
+
const make = (code, severity, headline) => ({
|
|
35
|
+
code,
|
|
36
|
+
severity,
|
|
37
|
+
file: item.file,
|
|
38
|
+
headline: headline ?? item.headline,
|
|
39
|
+
...(item.detail !== undefined ? { detail: item.detail } : {}),
|
|
40
|
+
requiresSignOff: true,
|
|
41
|
+
id: findingId(item.file, code, item.detail ?? item.headline),
|
|
42
|
+
});
|
|
43
|
+
switch (item.code) {
|
|
44
|
+
case 'must_removed':
|
|
45
|
+
case 'must_not_removed':
|
|
46
|
+
case 'file_removed':
|
|
47
|
+
return make(item.code, 'block');
|
|
48
|
+
case 'citation_dropped': {
|
|
49
|
+
// A dropped citation that is on the required list is the stronger finding.
|
|
50
|
+
if (item.detail && required.has(item.detail)) {
|
|
51
|
+
return {
|
|
52
|
+
...make('required_reference_removed', 'block', `Required reference removed: ${item.headline}`),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return make('citation_dropped', 'block');
|
|
56
|
+
}
|
|
57
|
+
case 'capability_added':
|
|
58
|
+
return guardNewCaps ? make('capability_added', 'block') : null;
|
|
59
|
+
case 'capability_condition_removed':
|
|
60
|
+
return make('capability_condition_removed', 'block');
|
|
61
|
+
case 'capability_condition_altered':
|
|
62
|
+
// Ambiguous — can't prove it isn't a broadening. Needs a human look.
|
|
63
|
+
return make('capability_condition_altered', 'review');
|
|
64
|
+
default:
|
|
65
|
+
// strengthens / neutral (must_added, citation_added, file_added, prose…)
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export function deriveFindings(diff, policy) {
|
|
70
|
+
const findings = [];
|
|
71
|
+
for (const item of diff.items) {
|
|
72
|
+
const f = toFinding(item, policy);
|
|
73
|
+
if (f)
|
|
74
|
+
findings.push(f);
|
|
75
|
+
}
|
|
76
|
+
return findings;
|
|
77
|
+
}
|
|
78
|
+
/** The single Compliance Guard evaluation. */
|
|
79
|
+
export function runComplianceGuard(before, after, options = {}) {
|
|
80
|
+
const diff = computeGovernanceDiff(before, after);
|
|
81
|
+
const findings = deriveFindings(diff, options.policy);
|
|
82
|
+
const coverage = verifySignOffs(findings, options.signOffs ?? []);
|
|
83
|
+
const requiresSignOff = findings.filter((f) => f.requiresSignOff);
|
|
84
|
+
const unsignedBlocking = requiresSignOff.filter((f) => !coverage.find((c) => c.finding.id === f.id)?.covered);
|
|
85
|
+
const acknowledged = requiresSignOff.filter((f) => coverage.find((c) => c.finding.id === f.id)?.covered);
|
|
86
|
+
return {
|
|
87
|
+
passed: unsignedBlocking.length === 0,
|
|
88
|
+
findings,
|
|
89
|
+
unsignedBlocking,
|
|
90
|
+
acknowledged,
|
|
91
|
+
diff,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAUlD,OAAO,EAAE,cAAc,EAAgB,MAAM,cAAc,CAAC;AAO5D,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC;SACL,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,E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AAI,EAAE,CAAC,CAAC;IAElE,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,gBAAgB,GAAG,eAAe,CAAC,MAAM,CAC7C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAC7D,CAAC;IACF,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CACzC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAC5D,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,gBAAgB,CAAC,MAAM,KAAK,CAAC;QACrC,QAAQ;QACR,gBAAgB;QAChB,YAAY;QACZ,IAAI;KACL,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @getvda/compliance-guard — the Compliance Guard + honest governance diff.
|
|
3
|
+
*
|
|
4
|
+
* Provider-free rule engine over governance change (before → after governance
|
|
5
|
+
* sets). Runs the SAME rule-set inline (author time) and in CI (the gate). No
|
|
6
|
+
* git dependency — the CI step needs only the file contents.
|
|
7
|
+
*/
|
|
8
|
+
export type { ChangeImpact, ChangeCode, GovernanceChangeItem, FileDiff, GovernanceDiff, GovernanceDiffSummary, GuardSeverity, GuardFinding, GuardPolicy, GuardResult, } from './types.js';
|
|
9
|
+
export { computeGovernanceDiff } from './diff.js';
|
|
10
|
+
export { runComplianceGuard, deriveFindings, type RunGuardOptions } from './guard.js';
|
|
11
|
+
export { inlineGuard, ciGuard, type InlineGuardOutput, type CiGuardOutput } from './entrypoints.js';
|
|
12
|
+
export { verifySignOffs, SIGNOFF_MODE, type SignOff, type SignOffCoverage } from './signoff.js';
|
|
13
|
+
export { renderDiffForHuman, renderGuardResult, renderSummaryLine } from './render.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,QAAQ,EACR,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @getvda/compliance-guard — the Compliance Guard + honest governance diff.
|
|
3
|
+
*
|
|
4
|
+
* Provider-free rule engine over governance change (before → after governance
|
|
5
|
+
* sets). Runs the SAME rule-set inline (author time) and in CI (the gate). No
|
|
6
|
+
* git dependency — the CI step needs only the file contents.
|
|
7
|
+
*/
|
|
8
|
+
export { computeGovernanceDiff } from './diff.js';
|
|
9
|
+
export { runComplianceGuard, deriveFindings } from './guard.js';
|
|
10
|
+
export { inlineGuard, ciGuard } from './entrypoints.js';
|
|
11
|
+
export { verifySignOffs, SIGNOFF_MODE } from './signoff.js';
|
|
12
|
+
export { renderDiffForHuman, renderGuardResult, renderSummaryLine } from './render.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAeH,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAwB,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,OAAO,EAA8C,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAsC,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human rendering of the diff + guard verdict.
|
|
3
|
+
*
|
|
4
|
+
* This is the raw material the Phase-4 non-engineer approval surface presents: a
|
|
5
|
+
* governance change described in plain terms, not a code diff. Kept as pure
|
|
6
|
+
* string builders so the same content can back a CLI report, a CI comment, or a
|
|
7
|
+
* UI later.
|
|
8
|
+
*/
|
|
9
|
+
import type { GovernanceDiff, GuardResult } from './types.js';
|
|
10
|
+
/** A plain-language rendering of what changed in meaning. */
|
|
11
|
+
export declare function renderDiffForHuman(diff: GovernanceDiff): string;
|
|
12
|
+
/** One-line headline summary, e.g. for a PR title or notification. */
|
|
13
|
+
export declare function renderSummaryLine(diff: GovernanceDiff): string;
|
|
14
|
+
/** The Guard verdict as a human report. */
|
|
15
|
+
export declare function renderGuardResult(result: GuardResult): string;
|
|
16
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAQ9D,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAe/D;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAa9D;AAED,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAqB7D"}
|
package/dist/render.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human rendering of the diff + guard verdict.
|
|
3
|
+
*
|
|
4
|
+
* This is the raw material the Phase-4 non-engineer approval surface presents: a
|
|
5
|
+
* governance change described in plain terms, not a code diff. Kept as pure
|
|
6
|
+
* string builders so the same content can back a CLI report, a CI comment, or a
|
|
7
|
+
* UI later.
|
|
8
|
+
*/
|
|
9
|
+
const IMPACT_MARK = {
|
|
10
|
+
weakens: '▼ weakens',
|
|
11
|
+
strengthens: '▲ strengthens',
|
|
12
|
+
neutral: '• neutral',
|
|
13
|
+
};
|
|
14
|
+
/** A plain-language rendering of what changed in meaning. */
|
|
15
|
+
export function renderDiffForHuman(diff) {
|
|
16
|
+
if (diff.clean)
|
|
17
|
+
return 'No governance meaning changed.';
|
|
18
|
+
const lines = [];
|
|
19
|
+
lines.push(renderSummaryLine(diff));
|
|
20
|
+
lines.push('');
|
|
21
|
+
for (const file of diff.files) {
|
|
22
|
+
lines.push(`${file.file} (${file.status}):`);
|
|
23
|
+
for (const item of file.items) {
|
|
24
|
+
const mark = IMPACT_MARK[item.impact] ?? item.impact;
|
|
25
|
+
lines.push(` ${mark} ${item.headline}`);
|
|
26
|
+
if (item.detail)
|
|
27
|
+
lines.push(` ${item.detail}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return lines.join('\n');
|
|
31
|
+
}
|
|
32
|
+
/** One-line headline summary, e.g. for a PR title or notification. */
|
|
33
|
+
export function renderSummaryLine(diff) {
|
|
34
|
+
const s = diff.summary;
|
|
35
|
+
const parts = [];
|
|
36
|
+
if (s.mustRemoved)
|
|
37
|
+
parts.push(`${s.mustRemoved} MUST removed`);
|
|
38
|
+
if (s.mustNotRemoved)
|
|
39
|
+
parts.push(`${s.mustNotRemoved} MUST NOT removed`);
|
|
40
|
+
if (s.citationsDropped.length)
|
|
41
|
+
parts.push(`${s.citationsDropped.length} citation(s) dropped`);
|
|
42
|
+
if (s.capabilitiesBroadened.length)
|
|
43
|
+
parts.push(`${s.capabilitiesBroadened.length} capability broadening(s)`);
|
|
44
|
+
if (s.mustAdded)
|
|
45
|
+
parts.push(`${s.mustAdded} MUST added`);
|
|
46
|
+
if (s.citationsAdded.length)
|
|
47
|
+
parts.push(`${s.citationsAdded.length} citation(s) added`);
|
|
48
|
+
if (s.filesRemoved.length)
|
|
49
|
+
parts.push(`${s.filesRemoved.length} file(s) removed`);
|
|
50
|
+
if (s.filesAdded.length)
|
|
51
|
+
parts.push(`${s.filesAdded.length} file(s) added`);
|
|
52
|
+
return parts.length ? parts.join(', ') : 'wording only';
|
|
53
|
+
}
|
|
54
|
+
/** The Guard verdict as a human report. */
|
|
55
|
+
export function renderGuardResult(result) {
|
|
56
|
+
const lines = [];
|
|
57
|
+
lines.push(result.passed ? '✓ Compliance Guard: PASS' : '✗ Compliance Guard: BLOCKED');
|
|
58
|
+
lines.push('');
|
|
59
|
+
lines.push(renderDiffForHuman(result.diff));
|
|
60
|
+
if (result.unsignedBlocking.length) {
|
|
61
|
+
lines.push('');
|
|
62
|
+
lines.push('Blocked — the following weakenings require a named sign-off:');
|
|
63
|
+
for (const f of result.unsignedBlocking) {
|
|
64
|
+
lines.push(` ✗ [${f.severity}] ${f.headline} (sign-off id: ${f.id})`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (result.acknowledged.length) {
|
|
68
|
+
lines.push('');
|
|
69
|
+
lines.push('Acknowledged by sign-off:');
|
|
70
|
+
for (const f of result.acknowledged) {
|
|
71
|
+
lines.push(` ✓ ${f.headline}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return lines.join('\n');
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,GAA2B;IAC1C,OAAO,EAAE,WAAW;IACpB,WAAW,EAAE,eAAe;IAC5B,OAAO,EAAE,WAAW;CACrB,CAAC;AAEF,6DAA6D;AAC7D,MAAM,UAAU,kBAAkB,CAAC,IAAoB;IACrD,IAAI,IAAI,CAAC,KAAK;QAAE,OAAO,gCAAgC,CAAC;IAExD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QAC7C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC;YACrD,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC1C,IAAI,IAAI,CAAC,MAAM;gBAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,MAAM,EAAE,CAAC,CAA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off seam.
|
|
3
|
+
*
|
|
4
|
+
* The Guard blocks a weakening unless a NAMED sign-off covers it. Phase 2 ships
|
|
5
|
+
* the SEAM + a stub: a sign-off is just an assertion that a named party
|
|
6
|
+
* acknowledged specific findings. It is NOT verified here — Phase 4 replaces
|
|
7
|
+
* `verifySignOffs` with the real HITL gate that authenticates the approver
|
|
8
|
+
* (federated identity), checks their authority (Onboarding/CODEOWNERS), and
|
|
9
|
+
* seals a hitl_decision to Witness.
|
|
10
|
+
*
|
|
11
|
+
* The seam is designed so that swap is drop-in: the Guard only asks "is finding
|
|
12
|
+
* F covered by a valid sign-off?" — how validity is established is behind this
|
|
13
|
+
* module.
|
|
14
|
+
*/
|
|
15
|
+
import type { GuardFinding } from './types.js';
|
|
16
|
+
export interface SignOff {
|
|
17
|
+
/** The approver's identity (name / id). In Phase 4 this is authenticated. */
|
|
18
|
+
readonly approver: string;
|
|
19
|
+
/**
|
|
20
|
+
* Which findings this sign-off covers. `'*'` covers all blocking findings
|
|
21
|
+
* (a blanket sign-off); otherwise a list of finding ids (see GuardFinding.id).
|
|
22
|
+
*/
|
|
23
|
+
readonly covers: readonly string[] | '*';
|
|
24
|
+
readonly note?: string;
|
|
25
|
+
/** When it was given (ISO-8601). Informational in Phase 2. */
|
|
26
|
+
readonly at?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SignOffCoverage {
|
|
29
|
+
readonly finding: GuardFinding;
|
|
30
|
+
readonly covered: boolean;
|
|
31
|
+
readonly by?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* STUB verifier (Phase 2). Treats every provided sign-off as valid and matches
|
|
35
|
+
* it to findings by id (or '*'). No authentication, no authority check, no
|
|
36
|
+
* sealing — those are Phase 4. Documented as a stub so nothing mistakes this for
|
|
37
|
+
* a real gate.
|
|
38
|
+
*/
|
|
39
|
+
export declare function verifySignOffs(findings: readonly GuardFinding[], signOffs: readonly SignOff[]): SignOffCoverage[];
|
|
40
|
+
/** Marker so callers/logs can assert the Guard is running against the stub. */
|
|
41
|
+
export declare const SIGNOFF_MODE: "stub";
|
|
42
|
+
//# sourceMappingURL=signoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signoff.d.ts","sourceRoot":"","sources":["../src/signoff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,OAAO;IACtB,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAC3B,eAAe,EAAE,CAOnB;AAED,+EAA+E;AAC/E,eAAO,MAAM,YAAY,EAAG,MAAe,CAAC"}
|
package/dist/signoff.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sign-off seam.
|
|
3
|
+
*
|
|
4
|
+
* The Guard blocks a weakening unless a NAMED sign-off covers it. Phase 2 ships
|
|
5
|
+
* the SEAM + a stub: a sign-off is just an assertion that a named party
|
|
6
|
+
* acknowledged specific findings. It is NOT verified here — Phase 4 replaces
|
|
7
|
+
* `verifySignOffs` with the real HITL gate that authenticates the approver
|
|
8
|
+
* (federated identity), checks their authority (Onboarding/CODEOWNERS), and
|
|
9
|
+
* seals a hitl_decision to Witness.
|
|
10
|
+
*
|
|
11
|
+
* The seam is designed so that swap is drop-in: the Guard only asks "is finding
|
|
12
|
+
* F covered by a valid sign-off?" — how validity is established is behind this
|
|
13
|
+
* module.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* STUB verifier (Phase 2). Treats every provided sign-off as valid and matches
|
|
17
|
+
* it to findings by id (or '*'). No authentication, no authority check, no
|
|
18
|
+
* sealing — those are Phase 4. Documented as a stub so nothing mistakes this for
|
|
19
|
+
* a real gate.
|
|
20
|
+
*/
|
|
21
|
+
export function verifySignOffs(findings, signOffs) {
|
|
22
|
+
return findings.map((finding) => {
|
|
23
|
+
const match = signOffs.find((s) => s.covers === '*' || (Array.isArray(s.covers) && s.covers.includes(finding.id)));
|
|
24
|
+
return match ? { finding, covered: true, by: match.approver } : { finding, covered: false };
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** Marker so callers/logs can assert the Guard is running against the stub. */
|
|
28
|
+
export const SIGNOFF_MODE = 'stub';
|
|
29
|
+
//# sourceMappingURL=signoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signoff.js","sourceRoot":"","sources":["../src/signoff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAuBH;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAiC,EACjC,QAA4B;IAE5B,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9B,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CACzB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CACtF,CAAC;QACF,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC9F,CAAC,CAAC,CAAC;AACL,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG,MAAe,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the honest diff (2c) and the Compliance Guard (2b).
|
|
3
|
+
*
|
|
4
|
+
* Separation of concerns:
|
|
5
|
+
* - The DIFF is neutral and factual: what changed in MEANING, and in which
|
|
6
|
+
* direction (weakens / strengthens / neutral). It carries no policy verdict.
|
|
7
|
+
* - The GUARD is the policy layer: it takes the diff, decides which weakenings
|
|
8
|
+
* require a named sign-off, checks sign-offs, and returns a pass/block
|
|
9
|
+
* verdict. One diff, one guard reading of it.
|
|
10
|
+
*/
|
|
11
|
+
import type { GovernanceFileName } from '@getvda/governance-schema';
|
|
12
|
+
/** Direction of a change relative to governance strength. */
|
|
13
|
+
export type ChangeImpact = 'weakens' | 'strengthens' | 'neutral';
|
|
14
|
+
/** Machine codes for the change kinds the diff distinguishes. */
|
|
15
|
+
export type ChangeCode = 'file_added' | 'file_removed' | 'must_removed' | 'must_added' | 'must_not_removed' | 'must_not_added' | 'citation_dropped' | 'citation_added' | 'required_reference_removed' | 'capability_added' | 'capability_removed' | 'capability_condition_removed' | 'capability_condition_added' | 'capability_condition_altered' | 'prose_changed';
|
|
16
|
+
export interface GovernanceChangeItem {
|
|
17
|
+
readonly code: ChangeCode;
|
|
18
|
+
readonly impact: ChangeImpact;
|
|
19
|
+
readonly file: GovernanceFileName;
|
|
20
|
+
/** Human one-liner, e.g. "3 MUST clauses removed". For the approver surface. */
|
|
21
|
+
readonly headline: string;
|
|
22
|
+
/** Optional supporting detail (which citation, which capability, etc.). */
|
|
23
|
+
readonly detail?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface FileDiff {
|
|
26
|
+
readonly file: GovernanceFileName;
|
|
27
|
+
readonly status: 'added' | 'removed' | 'modified' | 'unchanged';
|
|
28
|
+
readonly items: readonly GovernanceChangeItem[];
|
|
29
|
+
}
|
|
30
|
+
export interface GovernanceDiffSummary {
|
|
31
|
+
readonly mustRemoved: number;
|
|
32
|
+
readonly mustNotRemoved: number;
|
|
33
|
+
readonly mustAdded: number;
|
|
34
|
+
readonly mustNotAdded: number;
|
|
35
|
+
readonly citationsDropped: readonly string[];
|
|
36
|
+
readonly citationsAdded: readonly string[];
|
|
37
|
+
readonly capabilitiesBroadened: readonly string[];
|
|
38
|
+
readonly filesAdded: readonly GovernanceFileName[];
|
|
39
|
+
readonly filesRemoved: readonly GovernanceFileName[];
|
|
40
|
+
}
|
|
41
|
+
export interface GovernanceDiff {
|
|
42
|
+
readonly files: readonly FileDiff[];
|
|
43
|
+
/** All change items flattened, in file order. */
|
|
44
|
+
readonly items: readonly GovernanceChangeItem[];
|
|
45
|
+
readonly summary: GovernanceDiffSummary;
|
|
46
|
+
/** True iff nothing of meaning changed. */
|
|
47
|
+
readonly clean: boolean;
|
|
48
|
+
}
|
|
49
|
+
export type GuardSeverity = 'block' | 'review';
|
|
50
|
+
/** A guard finding — a weakening the Guard cares about. */
|
|
51
|
+
export interface GuardFinding {
|
|
52
|
+
readonly code: ChangeCode;
|
|
53
|
+
readonly severity: GuardSeverity;
|
|
54
|
+
readonly file: GovernanceFileName;
|
|
55
|
+
readonly headline: string;
|
|
56
|
+
readonly detail?: string;
|
|
57
|
+
/** Whether a named sign-off is required to let this change through. */
|
|
58
|
+
readonly requiresSignOff: boolean;
|
|
59
|
+
/** Stable id a sign-off references to acknowledge THIS finding. */
|
|
60
|
+
readonly id: string;
|
|
61
|
+
}
|
|
62
|
+
/** Optional policy input — the declared invariants the Guard enforces. */
|
|
63
|
+
export interface GuardPolicy {
|
|
64
|
+
/**
|
|
65
|
+
* References (citation refs like "iso:A.9.2", or free identifiers) that MUST
|
|
66
|
+
* remain present. Removing one is a hard finding. If omitted, the Guard falls
|
|
67
|
+
* back to protecting every baseline citation (any drop needs sign-off).
|
|
68
|
+
*/
|
|
69
|
+
readonly requiredReferences?: readonly string[];
|
|
70
|
+
/**
|
|
71
|
+
* If true, adding a brand-new conditioned capability requires sign-off (a new
|
|
72
|
+
* permission broadens the agent's authority). Default true.
|
|
73
|
+
*/
|
|
74
|
+
readonly guardNewCapabilities?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface GuardResult {
|
|
77
|
+
/** true iff the change may proceed (no unsigned blocking findings). */
|
|
78
|
+
readonly passed: boolean;
|
|
79
|
+
readonly findings: readonly GuardFinding[];
|
|
80
|
+
/** Findings that block and are NOT covered by a sign-off. */
|
|
81
|
+
readonly unsignedBlocking: readonly GuardFinding[];
|
|
82
|
+
/** Findings that block but ARE covered by a sign-off (acknowledged). */
|
|
83
|
+
readonly acknowledged: readonly GuardFinding[];
|
|
84
|
+
/** The diff the verdict was computed from. */
|
|
85
|
+
readonly diff: GovernanceDiff;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAMpE,6DAA6D;AAC7D,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAAC;AAEjE,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAClB,YAAY,GACZ,cAAc,GACd,cAAc,GACd,YAAY,GACZ,kBAAkB,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,gBAAgB,GAChB,4BAA4B,GAC5B,kBAAkB,GAClB,oBAAoB,GACpB,8BAA8B,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- The DIFF is neutral and factual: what changed in MEANING, and in which
|
|
6
|
+
* direction (weakens / strengthens / neutral). It carries no policy verdict.
|
|
7
|
+
* - The GUARD is the policy layer: it takes the diff, decides which weakenings
|
|
8
|
+
* require a named sign-off, checks sign-offs, and returns a pass/block
|
|
9
|
+
* verdict. One diff, one guard reading of it.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@getvda/compliance-guard",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "The Compliance Guard — provider-free rule engine over governance changes. Honest structural diff + weakening detection (MUST counts, citations, required refs, conditioned capabilities). One rule-set, two entry points (inline + CI).",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc --build",
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
12
|
+
"test": "vitest run"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@getvda/governance-schema": "^0.2.0"
|
|
16
|
+
},
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"NOTICE"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/getvda-ai/acp-agent.git",
|
|
30
|
+
"directory": "packages/compliance-guard"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://getvda.ai"
|
|
33
|
+
}
|