wicked-crew 0.7.1 → 0.7.2
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/api/delivery-index.d.ts +61 -0
- package/dist/api/delivery-index.d.ts.map +1 -0
- package/dist/api/delivery-index.js +87 -0
- package/dist/api/delivery-index.js.map +1 -0
- package/dist/api/governance-wiki.d.ts +28 -0
- package/dist/api/governance-wiki.d.ts.map +1 -0
- package/dist/api/governance-wiki.js +97 -0
- package/dist/api/governance-wiki.js.map +1 -0
- package/dist/api/routes.d.ts +17 -12
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +81 -4
- package/dist/api/routes.js.map +1 -1
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +56 -1
- package/dist/api/server.js.map +1 -1
- package/dist/campaign/supervision.d.ts +296 -0
- package/dist/campaign/supervision.d.ts.map +1 -0
- package/dist/campaign/supervision.js +515 -0
- package/dist/campaign/supervision.js.map +1 -0
- package/dist/campaigns/plan.d.ts +64 -0
- package/dist/campaigns/plan.d.ts.map +1 -0
- package/dist/campaigns/plan.js +201 -0
- package/dist/campaigns/plan.js.map +1 -0
- package/dist/campaigns/routes.d.ts +28 -0
- package/dist/campaigns/routes.d.ts.map +1 -0
- package/dist/campaigns/routes.js +177 -0
- package/dist/campaigns/routes.js.map +1 -0
- package/dist/core/adapter.d.ts +72 -1
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +145 -0
- package/dist/core/adapter.js.map +1 -1
- package/dist/projects/routes.d.ts +2 -2
- package/dist/qe/acceptance.d.ts +20 -1
- package/dist/qe/acceptance.d.ts.map +1 -1
- package/dist/qe/acceptance.js +32 -0
- package/dist/qe/acceptance.js.map +1 -1
- package/dist/qe/conformance.d.ts +158 -0
- package/dist/qe/conformance.d.ts.map +1 -0
- package/dist/qe/conformance.js +244 -0
- package/dist/qe/conformance.js.map +1 -0
- package/dist/studio/assets/index-C8rx24F1.js +530 -0
- package/dist/studio/assets/index-CwmIj-f2.css +32 -0
- package/dist/studio/index.html +2 -2
- package/dist/studio/testid-inventory.json +3924 -0
- package/endpoint-manifest.json +83 -3
- package/package.json +3 -3
- package/dist/studio/assets/index-D-BFUYnY.js +0 -530
- package/dist/studio/assets/index-D6S9zUtO.css +0 -32
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The acceptance view's CONFORMANCE section (AW-14 / arch-R13a + arch-R16).
|
|
3
|
+
*
|
|
4
|
+
* `GET /runs/:id/acceptance` used to resolve ONLY the QE ledger verdict, while
|
|
5
|
+
* governance conformance claims were served on a separate route
|
|
6
|
+
* (`/governance/claims`) nobody stands in front of — so a wiki-rule violation
|
|
7
|
+
* never appeared where humans actually look at a run's "is it done?". This
|
|
8
|
+
* module derives the missing half and `buildAcceptanceView` serves it BESIDE
|
|
9
|
+
* the QE gate: two verdicts, one page, deny-dominates on both.
|
|
10
|
+
*
|
|
11
|
+
* Three honesty rules, all deny-dominant:
|
|
12
|
+
*
|
|
13
|
+
* 1. **Run-scoped claims, cited.** Claims are filtered to THIS run's scope
|
|
14
|
+
* (`wicked-agent/<runId>/shared` | `wicked-agent/<runId>/unit/<u>`, the
|
|
15
|
+
* engine's `scope.rs` grammar) and each `conform:` obligation is parsed
|
|
16
|
+
* back into the wiki/conformance rule it cites (severity, rule id,
|
|
17
|
+
* statement — the `attach_recalled_rules` format), so a denial names the
|
|
18
|
+
* rule that was violated instead of an opaque string.
|
|
19
|
+
*
|
|
20
|
+
* 2. **"Guardrailed" is a verified claim, never a default.** A run whose
|
|
21
|
+
* workflow declared governed units but whose CLI has no gate-hook adapter
|
|
22
|
+
* runs with UNCHECKED tool calls and only leaves a `governanceUnenforced`
|
|
23
|
+
* event behind (gate-hook injection is claude-only — FINDING-063,
|
|
24
|
+
* `execute_wrapped.rs`). This section reads the run's durable event log and
|
|
25
|
+
* reports `enforcement.status` accordingly; `guardrailed` is true ONLY when
|
|
26
|
+
* enforcement was positively observed armed and nothing reported unenforced.
|
|
27
|
+
* An unreadable event log is `unverifiable` — unknown is never guardrailed.
|
|
28
|
+
*
|
|
29
|
+
* 3. **Unreadable is not clean.** A claims wire that cannot be read yields
|
|
30
|
+
* `claimsAvailable: false` plus the error — never an empty list wearing a
|
|
31
|
+
* "no denials" face.
|
|
32
|
+
*
|
|
33
|
+
* COVERAGE BOUNDARY (write-it-down half of arch-R16): deterministic per-tool-
|
|
34
|
+
* call input governance exists for claude only. Units routed to any other CLI
|
|
35
|
+
* (Antigravity, Codex, local, …) get phase-boundary coverage only — the
|
|
36
|
+
* in-process `apply_unit` output gate and the deliverable floor — which
|
|
37
|
+
* evaluates the unit's OUTPUT after the fact and cannot block a tool call
|
|
38
|
+
* mid-flight. A governed unit on a non-claude CLI is therefore reported here
|
|
39
|
+
* as `unenforced`, not silently folded into "guardrailed". The same boundary
|
|
40
|
+
* is documented in the README's acceptance section.
|
|
41
|
+
*
|
|
42
|
+
* Coordinates crew#311 (vacuous unit completion passes gates): same
|
|
43
|
+
* gate-honesty seam, different defect — #311 is about "done" being asserted
|
|
44
|
+
* from an empty turn; this section is about governance claims/enforcement
|
|
45
|
+
* being invisible or overclaimed. Neither fix closes the other.
|
|
46
|
+
*/
|
|
47
|
+
import type { GovernanceClaim, RecordedEvent } from '../core/types.js';
|
|
48
|
+
/** A wiki/conformance rule cited by a claim's `conform:` obligation. */
|
|
49
|
+
export interface ConformanceRuleCitation {
|
|
50
|
+
/** `Critical` | `Error` | `Warn` | `Info` — the rule's `ConfSeverity`, as serialized. */
|
|
51
|
+
severity: string;
|
|
52
|
+
/** The conformance-rule id (`PAT-*` / `POL-*`) — the wiki rule the claim cites. */
|
|
53
|
+
ruleId: string;
|
|
54
|
+
/** The rule's prescriptive statement. */
|
|
55
|
+
statement: string;
|
|
56
|
+
}
|
|
57
|
+
/** One of this run's governance decisions, run-scoped and with its rule citations parsed. */
|
|
58
|
+
export interface RunConformanceClaimView {
|
|
59
|
+
claimId: string;
|
|
60
|
+
scope: string;
|
|
61
|
+
phase: string;
|
|
62
|
+
decision: 'allow' | 'deny' | 'allow_with_conditions';
|
|
63
|
+
policyIds: string[];
|
|
64
|
+
/** Wiki/conformance rules cited by `conform:` obligations — the ruleset the output had to meet. */
|
|
65
|
+
rules: ConformanceRuleCitation[];
|
|
66
|
+
/** Every obligation, verbatim (includes the unparsed originals of `rules`). */
|
|
67
|
+
obligations: string[];
|
|
68
|
+
evaluator: string;
|
|
69
|
+
/** Unix-seconds timestamp of evaluation. */
|
|
70
|
+
evaluatedAt: number;
|
|
71
|
+
/**
|
|
72
|
+
* True for an ADVISORY boundary READ deny: the tool call WAS blocked, but a blocked read leaks
|
|
73
|
+
* nothing, so it is audit-only and not unit-fatal (core#219). Mirrors the engine's
|
|
74
|
+
* `is_advisory_boundary_read_deny` exactly — evaluator identity AND claim-id prefix, so a policy
|
|
75
|
+
* deny can never be downgraded to advisory.
|
|
76
|
+
*/
|
|
77
|
+
advisory: boolean;
|
|
78
|
+
}
|
|
79
|
+
/** A unit the workflow declared governed that ran with UNCHECKED tool calls (FINDING-063). */
|
|
80
|
+
export interface UnenforcedUnit {
|
|
81
|
+
ord: number;
|
|
82
|
+
attempt: number;
|
|
83
|
+
cli: string;
|
|
84
|
+
reason: string;
|
|
85
|
+
}
|
|
86
|
+
/** What the run's durable event log says about whether governance was actually IN FORCE. */
|
|
87
|
+
export interface GovernanceEnforcementView {
|
|
88
|
+
/**
|
|
89
|
+
* - `enforced` — enforcement positively observed armed; nothing reported unenforced.
|
|
90
|
+
* - `unenforced` — ≥1 governed unit ran with unchecked tool calls (`governanceUnenforced`).
|
|
91
|
+
* - `ungoverned` — the log is readable and carries no governance signal at all: the run never
|
|
92
|
+
* asked for governance. Not a failure — but never "guardrailed" either.
|
|
93
|
+
* - `unverifiable` — the event log could not be read; unknown is never guardrailed.
|
|
94
|
+
*/
|
|
95
|
+
status: 'enforced' | 'unenforced' | 'ungoverned' | 'unverifiable';
|
|
96
|
+
/** The governed-but-unchecked units, verbatim from their events. Empty unless `unenforced`. */
|
|
97
|
+
unenforced: UnenforcedUnit[];
|
|
98
|
+
/** Ords of units whose governance context was confirmed armed (`governanceContextArmed`). */
|
|
99
|
+
armedUnits: number[];
|
|
100
|
+
/** Why the status is what it is — always populated. */
|
|
101
|
+
reason: string;
|
|
102
|
+
}
|
|
103
|
+
/** The conformance half of the acceptance view — served beside the QE gate. */
|
|
104
|
+
export interface RunConformance {
|
|
105
|
+
/** Whether the claims wire could be read at all. False is NOT "no denials". */
|
|
106
|
+
claimsAvailable: boolean;
|
|
107
|
+
/** The read failure, when `claimsAvailable` is false for a reason other than a missing binding. */
|
|
108
|
+
claimsError?: string;
|
|
109
|
+
/** This run's claims (run-scope filtered), oldest first. */
|
|
110
|
+
claims: RunConformanceClaimView[];
|
|
111
|
+
/** Non-advisory deny claims — the ones that stand against the run. */
|
|
112
|
+
denials: number;
|
|
113
|
+
/** Advisory boundary-read denies — blocked, audited, not unit-fatal. */
|
|
114
|
+
advisoryDenials: number;
|
|
115
|
+
/** Deny-dominates over the run's READ claims: true when any non-advisory deny stands. */
|
|
116
|
+
denied: boolean;
|
|
117
|
+
enforcement: GovernanceEnforcementView;
|
|
118
|
+
/**
|
|
119
|
+
* The ONE headline, deny-dominates across everything above: true ONLY when the claims wire was
|
|
120
|
+
* readable, no non-advisory denial stands, AND enforcement was positively verified. An
|
|
121
|
+
* unenforced, ungoverned, or unverifiable run is NEVER guardrailed (arch-R16).
|
|
122
|
+
*/
|
|
123
|
+
guardrailed: boolean;
|
|
124
|
+
/** One honest sentence for the surface beside the QE verdict. */
|
|
125
|
+
summary: string;
|
|
126
|
+
}
|
|
127
|
+
/** Whether `scope` belongs to run `runId` under the engine's scope grammar. */
|
|
128
|
+
export declare function isRunScope(scope: string, runId: string): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Parse one `conform:<Severity>:<id>:<statement>` obligation (the `attach_recalled_rules` format)
|
|
131
|
+
* into its rule citation. Statements may contain `:` freely — only the first three separators
|
|
132
|
+
* split. Returns null for any obligation that is not a rule citation (boundary reasons, policy
|
|
133
|
+
* obligations, free text): those stay visible verbatim in `obligations`.
|
|
134
|
+
*/
|
|
135
|
+
export declare function parseRuleCitation(obligation: string): ConformanceRuleCitation | null;
|
|
136
|
+
/** Mirror of the engine's `is_advisory_boundary_read_deny` (`gate_hook.rs`). */
|
|
137
|
+
export declare function isAdvisoryBoundaryReadDeny(claim: GovernanceClaim): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Derive the enforcement view from the run's durable event log.
|
|
140
|
+
*
|
|
141
|
+
* `events === null` means the log could NOT be read (no binding, or the loader was not wired) —
|
|
142
|
+
* which is `unverifiable`, never a quiet "enforced". An empty log is a real answer: no governance
|
|
143
|
+
* signal ⇒ `ungoverned`.
|
|
144
|
+
*/
|
|
145
|
+
export declare function resolveEnforcement(events: RecordedEvent[] | null): GovernanceEnforcementView;
|
|
146
|
+
/**
|
|
147
|
+
* Assemble the conformance section: run-scoped claims + enforcement, resolved deny-dominates.
|
|
148
|
+
*
|
|
149
|
+
* `claims === null` means the claims wire could not be read (`claimsError` says why when known) —
|
|
150
|
+
* reported as unavailable, never as an empty clean list.
|
|
151
|
+
*/
|
|
152
|
+
export declare function resolveConformance(opts: {
|
|
153
|
+
runId: string;
|
|
154
|
+
claims: GovernanceClaim[] | null;
|
|
155
|
+
claimsError?: string;
|
|
156
|
+
events: RecordedEvent[] | null;
|
|
157
|
+
}): RunConformance;
|
|
158
|
+
//# sourceMappingURL=conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../src/qe/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAUvE,wEAAwE;AACxE,MAAM,WAAW,uBAAuB;IAC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C,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,eAAe,EAAE,MAAM,CAAC;IACxB,yFAAyF;IACzF,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,yBAAyB,CAAC;IACvC;;;;OAIG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAMhE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAYpF;AAED,gFAAgF;AAChF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAM1E;AA+BD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,GAAG,yBAAyB,CAyE5F;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;CAChC,GAAG,cAAc,CA6CjB"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The acceptance view's CONFORMANCE section (AW-14 / arch-R13a + arch-R16).
|
|
3
|
+
*
|
|
4
|
+
* `GET /runs/:id/acceptance` used to resolve ONLY the QE ledger verdict, while
|
|
5
|
+
* governance conformance claims were served on a separate route
|
|
6
|
+
* (`/governance/claims`) nobody stands in front of — so a wiki-rule violation
|
|
7
|
+
* never appeared where humans actually look at a run's "is it done?". This
|
|
8
|
+
* module derives the missing half and `buildAcceptanceView` serves it BESIDE
|
|
9
|
+
* the QE gate: two verdicts, one page, deny-dominates on both.
|
|
10
|
+
*
|
|
11
|
+
* Three honesty rules, all deny-dominant:
|
|
12
|
+
*
|
|
13
|
+
* 1. **Run-scoped claims, cited.** Claims are filtered to THIS run's scope
|
|
14
|
+
* (`wicked-agent/<runId>/shared` | `wicked-agent/<runId>/unit/<u>`, the
|
|
15
|
+
* engine's `scope.rs` grammar) and each `conform:` obligation is parsed
|
|
16
|
+
* back into the wiki/conformance rule it cites (severity, rule id,
|
|
17
|
+
* statement — the `attach_recalled_rules` format), so a denial names the
|
|
18
|
+
* rule that was violated instead of an opaque string.
|
|
19
|
+
*
|
|
20
|
+
* 2. **"Guardrailed" is a verified claim, never a default.** A run whose
|
|
21
|
+
* workflow declared governed units but whose CLI has no gate-hook adapter
|
|
22
|
+
* runs with UNCHECKED tool calls and only leaves a `governanceUnenforced`
|
|
23
|
+
* event behind (gate-hook injection is claude-only — FINDING-063,
|
|
24
|
+
* `execute_wrapped.rs`). This section reads the run's durable event log and
|
|
25
|
+
* reports `enforcement.status` accordingly; `guardrailed` is true ONLY when
|
|
26
|
+
* enforcement was positively observed armed and nothing reported unenforced.
|
|
27
|
+
* An unreadable event log is `unverifiable` — unknown is never guardrailed.
|
|
28
|
+
*
|
|
29
|
+
* 3. **Unreadable is not clean.** A claims wire that cannot be read yields
|
|
30
|
+
* `claimsAvailable: false` plus the error — never an empty list wearing a
|
|
31
|
+
* "no denials" face.
|
|
32
|
+
*
|
|
33
|
+
* COVERAGE BOUNDARY (write-it-down half of arch-R16): deterministic per-tool-
|
|
34
|
+
* call input governance exists for claude only. Units routed to any other CLI
|
|
35
|
+
* (Antigravity, Codex, local, …) get phase-boundary coverage only — the
|
|
36
|
+
* in-process `apply_unit` output gate and the deliverable floor — which
|
|
37
|
+
* evaluates the unit's OUTPUT after the fact and cannot block a tool call
|
|
38
|
+
* mid-flight. A governed unit on a non-claude CLI is therefore reported here
|
|
39
|
+
* as `unenforced`, not silently folded into "guardrailed". The same boundary
|
|
40
|
+
* is documented in the README's acceptance section.
|
|
41
|
+
*
|
|
42
|
+
* Coordinates crew#311 (vacuous unit completion passes gates): same
|
|
43
|
+
* gate-honesty seam, different defect — #311 is about "done" being asserted
|
|
44
|
+
* from an empty turn; this section is about governance claims/enforcement
|
|
45
|
+
* being invisible or overclaimed. Neither fix closes the other.
|
|
46
|
+
*/
|
|
47
|
+
/** Scope prefix the engine stamps on every run-scoped governance artifact (`scope.rs`). */
|
|
48
|
+
const RUN_SCOPE_PREFIX = 'wicked-agent/';
|
|
49
|
+
/** Evaluator identity of filesystem-boundary denies (`gate_hook.rs` BOUNDARY_EVALUATOR). */
|
|
50
|
+
const BOUNDARY_EVALUATOR = 'wicked-governance-boundary';
|
|
51
|
+
/** Claim-id prefix of an ADVISORY boundary READ deny (`gate_hook.rs` BOUNDARY_READ_DENY_PREFIX). */
|
|
52
|
+
const BOUNDARY_READ_DENY_PREFIX = 'boundary-read-deny:';
|
|
53
|
+
/** Whether `scope` belongs to run `runId` under the engine's scope grammar. */
|
|
54
|
+
export function isRunScope(scope, runId) {
|
|
55
|
+
if (!scope.startsWith(RUN_SCOPE_PREFIX))
|
|
56
|
+
return false;
|
|
57
|
+
const rest = scope.slice(RUN_SCOPE_PREFIX.length);
|
|
58
|
+
// `<runId>/shared` or `<runId>/unit/<discriminator>` — exact segment match, so run id `r-1`
|
|
59
|
+
// can never claim `r-10`'s scope by prefix accident.
|
|
60
|
+
return rest === `${runId}/shared` || rest.startsWith(`${runId}/unit/`);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parse one `conform:<Severity>:<id>:<statement>` obligation (the `attach_recalled_rules` format)
|
|
64
|
+
* into its rule citation. Statements may contain `:` freely — only the first three separators
|
|
65
|
+
* split. Returns null for any obligation that is not a rule citation (boundary reasons, policy
|
|
66
|
+
* obligations, free text): those stay visible verbatim in `obligations`.
|
|
67
|
+
*/
|
|
68
|
+
export function parseRuleCitation(obligation) {
|
|
69
|
+
if (!obligation.startsWith('conform:'))
|
|
70
|
+
return null;
|
|
71
|
+
const rest = obligation.slice('conform:'.length);
|
|
72
|
+
const sevEnd = rest.indexOf(':');
|
|
73
|
+
if (sevEnd <= 0)
|
|
74
|
+
return null;
|
|
75
|
+
const idEnd = rest.indexOf(':', sevEnd + 1);
|
|
76
|
+
if (idEnd <= sevEnd + 1)
|
|
77
|
+
return null;
|
|
78
|
+
const severity = rest.slice(0, sevEnd);
|
|
79
|
+
const ruleId = rest.slice(sevEnd + 1, idEnd);
|
|
80
|
+
const statement = rest.slice(idEnd + 1);
|
|
81
|
+
if (statement === '')
|
|
82
|
+
return null;
|
|
83
|
+
return { severity, ruleId, statement };
|
|
84
|
+
}
|
|
85
|
+
/** Mirror of the engine's `is_advisory_boundary_read_deny` (`gate_hook.rs`). */
|
|
86
|
+
export function isAdvisoryBoundaryReadDeny(claim) {
|
|
87
|
+
return (claim.decision === 'deny' &&
|
|
88
|
+
claim.evaluator_identity === BOUNDARY_EVALUATOR &&
|
|
89
|
+
claim.claim_id.startsWith(BOUNDARY_READ_DENY_PREFIX));
|
|
90
|
+
}
|
|
91
|
+
/** Map one store claim to its view row (citations parsed, advisory flagged). */
|
|
92
|
+
function toClaimView(claim) {
|
|
93
|
+
const rules = [];
|
|
94
|
+
for (const ob of claim.obligations) {
|
|
95
|
+
const cite = parseRuleCitation(ob);
|
|
96
|
+
if (cite !== null)
|
|
97
|
+
rules.push(cite);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
claimId: claim.claim_id,
|
|
101
|
+
scope: claim.scope,
|
|
102
|
+
phase: claim.phase,
|
|
103
|
+
decision: claim.decision,
|
|
104
|
+
policyIds: claim.policy_ids,
|
|
105
|
+
rules,
|
|
106
|
+
obligations: claim.obligations,
|
|
107
|
+
evaluator: claim.evaluator_identity,
|
|
108
|
+
evaluatedAt: claim.evaluated_at,
|
|
109
|
+
advisory: isAdvisoryBoundaryReadDeny(claim),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** Safe field reads off the loose `RecordedEvent` bag. */
|
|
113
|
+
function num(v) {
|
|
114
|
+
return typeof v === 'number' && Number.isFinite(v) ? v : -1;
|
|
115
|
+
}
|
|
116
|
+
function str(v) {
|
|
117
|
+
return typeof v === 'string' ? v : '';
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Derive the enforcement view from the run's durable event log.
|
|
121
|
+
*
|
|
122
|
+
* `events === null` means the log could NOT be read (no binding, or the loader was not wired) —
|
|
123
|
+
* which is `unverifiable`, never a quiet "enforced". An empty log is a real answer: no governance
|
|
124
|
+
* signal ⇒ `ungoverned`.
|
|
125
|
+
*/
|
|
126
|
+
export function resolveEnforcement(events) {
|
|
127
|
+
if (events === null) {
|
|
128
|
+
return {
|
|
129
|
+
status: 'unverifiable',
|
|
130
|
+
unenforced: [],
|
|
131
|
+
armedUnits: [],
|
|
132
|
+
reason: 'run event log unavailable — enforcement cannot be verified (unknown is never guardrailed)',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const unenforced = [];
|
|
136
|
+
const armed = new Set();
|
|
137
|
+
let governedSignal = false;
|
|
138
|
+
for (const ev of events) {
|
|
139
|
+
switch (ev.type) {
|
|
140
|
+
case 'governanceUnenforced':
|
|
141
|
+
unenforced.push({
|
|
142
|
+
ord: num(ev['ord']),
|
|
143
|
+
attempt: num(ev['attempt']),
|
|
144
|
+
cli: str(ev['cli']),
|
|
145
|
+
reason: str(ev['reason']),
|
|
146
|
+
});
|
|
147
|
+
break;
|
|
148
|
+
case 'governanceContextArmed':
|
|
149
|
+
armed.add(num(ev['ord']));
|
|
150
|
+
governedSignal = true;
|
|
151
|
+
break;
|
|
152
|
+
case 'governanceHookFired':
|
|
153
|
+
case 'validationPinAttached':
|
|
154
|
+
governedSignal = true;
|
|
155
|
+
break;
|
|
156
|
+
case 'unitOutputCaptured':
|
|
157
|
+
if (ev['governed'] === true)
|
|
158
|
+
governedSignal = true;
|
|
159
|
+
break;
|
|
160
|
+
default:
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const armedUnits = [...armed].sort((a, b) => a - b);
|
|
165
|
+
if (unenforced.length > 0) {
|
|
166
|
+
// Deny-dominates: ONE unchecked governed unit breaks the whole run's guardrail claim, even
|
|
167
|
+
// when every other unit was armed — a chain with a named missing link.
|
|
168
|
+
const clis = [...new Set(unenforced.map((u) => u.cli))].join(', ');
|
|
169
|
+
return {
|
|
170
|
+
status: 'unenforced',
|
|
171
|
+
unenforced,
|
|
172
|
+
armedUnits,
|
|
173
|
+
reason: `${unenforced.length} governed unit(s) ran with UNCHECKED tool calls on ${clis} ` +
|
|
174
|
+
'(gate-hook injection is claude-only; phase-boundary output gating still applied)',
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
if (governedSignal) {
|
|
178
|
+
return {
|
|
179
|
+
status: 'enforced',
|
|
180
|
+
unenforced: [],
|
|
181
|
+
armedUnits,
|
|
182
|
+
reason: armedUnits.length > 0
|
|
183
|
+
? `input governance confirmed armed for unit(s) ${armedUnits.join(', ')}; none reported unenforced`
|
|
184
|
+
: 'governance activity recorded and no unit reported unenforced',
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
status: 'ungoverned',
|
|
189
|
+
unenforced: [],
|
|
190
|
+
armedUnits: [],
|
|
191
|
+
reason: 'the run recorded no governance signal — nothing was enforced, so nothing is claimed guardrailed',
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Assemble the conformance section: run-scoped claims + enforcement, resolved deny-dominates.
|
|
196
|
+
*
|
|
197
|
+
* `claims === null` means the claims wire could not be read (`claimsError` says why when known) —
|
|
198
|
+
* reported as unavailable, never as an empty clean list.
|
|
199
|
+
*/
|
|
200
|
+
export function resolveConformance(opts) {
|
|
201
|
+
const enforcement = resolveEnforcement(opts.events);
|
|
202
|
+
const claimsAvailable = opts.claims !== null;
|
|
203
|
+
const claims = (opts.claims ?? [])
|
|
204
|
+
.filter((c) => isRunScope(c.scope, opts.runId))
|
|
205
|
+
.sort((a, b) => a.evaluated_at - b.evaluated_at)
|
|
206
|
+
.map(toClaimView);
|
|
207
|
+
const denials = claims.filter((c) => c.decision === 'deny' && !c.advisory).length;
|
|
208
|
+
const advisoryDenials = claims.filter((c) => c.decision === 'deny' && c.advisory).length;
|
|
209
|
+
const denied = denials > 0;
|
|
210
|
+
// The headline. Every conjunct is a positive verification; absence of evidence never passes.
|
|
211
|
+
const guardrailed = claimsAvailable && !denied && enforcement.status === 'enforced';
|
|
212
|
+
let summary;
|
|
213
|
+
if (!claimsAvailable) {
|
|
214
|
+
summary = `conformance claims unreadable${opts.claimsError !== undefined ? `: ${opts.claimsError}` : ''} — not claimed clean (unreadable is not clean)`;
|
|
215
|
+
}
|
|
216
|
+
else if (denied) {
|
|
217
|
+
const cited = claims
|
|
218
|
+
.filter((c) => c.decision === 'deny' && !c.advisory)
|
|
219
|
+
.flatMap((c) => c.rules.map((r) => r.ruleId));
|
|
220
|
+
summary =
|
|
221
|
+
`${denials} governance denial(s) stand against this run` +
|
|
222
|
+
(cited.length > 0 ? ` (rules cited: ${[...new Set(cited)].join(', ')})` : '') +
|
|
223
|
+
` — deny-dominates`;
|
|
224
|
+
}
|
|
225
|
+
else if (enforcement.status === 'enforced') {
|
|
226
|
+
summary = `guardrailed — enforcement verified and ${claims.length} claim(s) carry no standing denial`;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
// No denial read, but enforcement not verified: the enforcement reason IS the story.
|
|
230
|
+
summary = `no standing denial, but NOT guardrailed — ${enforcement.reason}`;
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
claimsAvailable,
|
|
234
|
+
...(opts.claimsError !== undefined ? { claimsError: opts.claimsError } : {}),
|
|
235
|
+
claims,
|
|
236
|
+
denials,
|
|
237
|
+
advisoryDenials,
|
|
238
|
+
denied,
|
|
239
|
+
enforcement,
|
|
240
|
+
guardrailed,
|
|
241
|
+
summary,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=conformance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.js","sourceRoot":"","sources":["../../src/qe/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAIH,2FAA2F;AAC3F,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEzC,4FAA4F;AAC5F,MAAM,kBAAkB,GAAG,4BAA4B,CAAC;AACxD,oGAAoG;AACpG,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AAsFxD,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,KAAa;IACrD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAClD,4FAA4F;IAC5F,qDAAqD;IACrD,OAAO,IAAI,KAAK,GAAG,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC;AACzE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC;IACpD,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,MAAM,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IAC5C,IAAI,KAAK,IAAI,M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