@intutic/shared-types 1.9.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/anomaly.d.ts +11 -0
- package/dist/anomaly.d.ts.map +1 -1
- package/dist/api-contracts.d.ts +97 -9
- package/dist/api-contracts.d.ts.map +1 -1
- package/dist/api-contracts.js +9 -0
- package/dist/api-contracts.js.map +1 -1
- package/dist/auth.d.ts +157 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +39 -1
- package/dist/auth.js.map +1 -1
- package/dist/billing.d.ts +2 -99
- package/dist/billing.d.ts.map +1 -1
- package/dist/billing.js +2 -17
- package/dist/billing.js.map +1 -1
- package/dist/enums.d.ts +341 -4
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +369 -6
- package/dist/enums.js.map +1 -1
- package/dist/errors.d.ts +20 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +20 -1
- package/dist/errors.js.map +1 -1
- package/dist/finops.d.ts +97 -1
- package/dist/finops.d.ts.map +1 -1
- package/dist/governanceCoverage.d.ts +82 -0
- package/dist/governanceCoverage.d.ts.map +1 -0
- package/dist/governanceCoverage.js +72 -0
- package/dist/governanceCoverage.js.map +1 -0
- package/dist/guardrailIr.d.ts +287 -0
- package/dist/guardrailIr.d.ts.map +1 -0
- package/dist/guardrailIr.js +301 -0
- package/dist/guardrailIr.js.map +1 -0
- package/dist/guardrailRender.d.ts +154 -0
- package/dist/guardrailRender.d.ts.map +1 -0
- package/dist/guardrailRender.js +440 -0
- package/dist/guardrailRender.js.map +1 -0
- package/dist/identity.d.ts +75 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +5 -1
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +34 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +124 -2
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +37 -11
- package/dist/intelligence.d.ts.map +1 -1
- package/dist/intelligence.js.map +1 -1
- package/dist/modelCatalog.d.ts +89 -0
- package/dist/modelCatalog.d.ts.map +1 -0
- package/dist/modelCatalog.generated.d.ts +7204 -0
- package/dist/modelCatalog.generated.d.ts.map +1 -0
- package/dist/modelCatalog.generated.js +576 -0
- package/dist/modelCatalog.generated.js.map +1 -0
- package/dist/modelCatalog.js +112 -0
- package/dist/modelCatalog.js.map +1 -0
- package/dist/notifications.d.ts +134 -2
- package/dist/notifications.d.ts.map +1 -1
- package/dist/observability.d.ts +4 -0
- package/dist/observability.d.ts.map +1 -1
- package/dist/policyGuardrails.d.ts +433 -0
- package/dist/policyGuardrails.d.ts.map +1 -0
- package/dist/policyGuardrails.js +91 -0
- package/dist/policyGuardrails.js.map +1 -0
- package/dist/posturePresets.d.ts +74 -0
- package/dist/posturePresets.d.ts.map +1 -0
- package/dist/posturePresets.js +139 -0
- package/dist/posturePresets.js.map +1 -0
- package/dist/providerVerification.d.ts +64 -0
- package/dist/providerVerification.d.ts.map +1 -0
- package/dist/providerVerification.js +184 -0
- package/dist/providerVerification.js.map +1 -0
- package/dist/providers.d.ts +93 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +176 -0
- package/dist/providers.js.map +1 -0
- package/dist/rulePredicateDsl.d.ts +101 -0
- package/dist/rulePredicateDsl.d.ts.map +1 -0
- package/dist/rulePredicateDsl.js +263 -0
- package/dist/rulePredicateDsl.js.map +1 -0
- package/dist/rulePredicateEval.d.ts +38 -0
- package/dist/rulePredicateEval.d.ts.map +1 -0
- package/dist/rulePredicateEval.js +124 -0
- package/dist/rulePredicateEval.js.map +1 -0
- package/dist/scriptScan.d.ts +162 -0
- package/dist/scriptScan.d.ts.map +1 -0
- package/dist/scriptScan.js +362 -0
- package/dist/scriptScan.js.map +1 -0
- package/dist/secretPatterns.d.ts +43 -0
- package/dist/secretPatterns.d.ts.map +1 -0
- package/dist/secretPatterns.js +73 -0
- package/dist/secretPatterns.js.map +1 -0
- package/dist/skillScan.d.ts +166 -0
- package/dist/skillScan.d.ts.map +1 -0
- package/dist/skillScan.js +398 -0
- package/dist/skillScan.js.map +1 -0
- package/dist/sop.d.ts +188 -9
- package/dist/sop.d.ts.map +1 -1
- package/dist/sop.js +54 -2
- package/dist/sop.js.map +1 -1
- package/dist/sourceProviders.d.ts +41 -0
- package/dist/sourceProviders.d.ts.map +1 -0
- package/dist/sourceProviders.js +48 -0
- package/dist/sourceProviders.js.map +1 -0
- package/dist/sync.d.ts +98 -8
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js.map +1 -1
- package/dist/toon.d.ts +80 -0
- package/dist/toon.d.ts.map +1 -0
- package/dist/toon.js +278 -0
- package/dist/toon.js.map +1 -0
- package/dist/usage.d.ts +23 -0
- package/dist/usage.d.ts.map +1 -1
- package/dist/wasmHost.d.ts +58 -0
- package/dist/wasmHost.d.ts.map +1 -0
- package/dist/wasmHost.js +80 -0
- package/dist/wasmHost.js.map +1 -0
- package/dist/workspaceSettings.d.ts +463 -21
- package/dist/workspaceSettings.d.ts.map +1 -1
- package/dist/workspaceSettings.js +86 -1
- package/dist/workspaceSettings.js.map +1 -1
- package/package.json +4 -3
package/dist/finops.d.ts
CHANGED
|
@@ -40,8 +40,20 @@ export interface TraceEntry {
|
|
|
40
40
|
complexityScore: number;
|
|
41
41
|
/** Raw input tokens before compression. */
|
|
42
42
|
rawInputTokens: number;
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Input tokens after compression.
|
|
45
|
+
*
|
|
46
|
+
* Written equal to `rawInputTokens` by every proxy trace path — the input
|
|
47
|
+
* compressor is not wired. Do not derive a saving from the difference.
|
|
48
|
+
*/
|
|
44
49
|
compressedInputTokens: number;
|
|
50
|
+
/**
|
|
51
|
+
* Bytes the SnipCompactor removed from the response body.
|
|
52
|
+
*
|
|
53
|
+
* The measured saving, in bytes rather than tokens, and response-side: it
|
|
54
|
+
* reduces the *next* turn's prompt, not this trace's input count.
|
|
55
|
+
*/
|
|
56
|
+
toolResultBytesSaved?: number;
|
|
45
57
|
/** Output tokens generated. */
|
|
46
58
|
outputTokens: number;
|
|
47
59
|
/** Cost at the raw model rate (USD). */
|
|
@@ -124,6 +136,10 @@ export interface TraceSummary {
|
|
|
124
136
|
complianceScore: number;
|
|
125
137
|
actualCostUsd: number;
|
|
126
138
|
anomalyDetected: AnomalyType | string | null;
|
|
139
|
+
/** True when the request was served under a valid break-glass token, global or scoped (migration 170). */
|
|
140
|
+
breakGlass?: boolean;
|
|
141
|
+
/** The approval this trace ran under, joinable to `break_glass_requests`; null when `breakGlass` is false. */
|
|
142
|
+
breakGlassRequestId?: string | null;
|
|
127
143
|
}
|
|
128
144
|
/** Paginated result from trace listing. */
|
|
129
145
|
export interface TraceListResult {
|
|
@@ -132,6 +148,26 @@ export interface TraceListResult {
|
|
|
132
148
|
limit: number;
|
|
133
149
|
offset: number;
|
|
134
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* One persisted detector finding on a trace, from `detector_findings`
|
|
153
|
+
* (migration 115). Distinct from `TraceDetail.anomalyDetected` /
|
|
154
|
+
* `anomalyConfidenceScore`, which carry only the single winning finding —
|
|
155
|
+
* this is every detector that fired, which is what lets a reviewer see two
|
|
156
|
+
* independent detectors agreeing (`detector_findings.md`-shaped corroboration)
|
|
157
|
+
* instead of one winner masking the rest.
|
|
158
|
+
*/
|
|
159
|
+
export interface TraceFindingSummary {
|
|
160
|
+
findingId: string;
|
|
161
|
+
detectorId: string;
|
|
162
|
+
anomalyKind: string;
|
|
163
|
+
severity: string;
|
|
164
|
+
/** STEER | REASK | ASK | KILL — what this finding actually did. */
|
|
165
|
+
disposition: string;
|
|
166
|
+
confidence: number;
|
|
167
|
+
reason: string;
|
|
168
|
+
/** True when the workspace was in shadow mode — recorded, not enforced. */
|
|
169
|
+
shadowed: boolean;
|
|
170
|
+
}
|
|
135
171
|
export interface TraceStep {
|
|
136
172
|
logId: string;
|
|
137
173
|
toolName: string;
|
|
@@ -157,10 +193,13 @@ export interface TraceDetail {
|
|
|
157
193
|
complexityScore: number;
|
|
158
194
|
rawInputTokens: number;
|
|
159
195
|
compressedInputTokens: number;
|
|
196
|
+
toolResultBytesSaved?: number;
|
|
160
197
|
outputTokens: number;
|
|
161
198
|
rawCostUsd: number;
|
|
162
199
|
actualCostUsd: number;
|
|
163
200
|
savingsUsd: number;
|
|
201
|
+
/** Who re-classified this trace, if anyone. Null when it holds its insert-time value. */
|
|
202
|
+
tokenUtilityClassifiedBy?: string | null;
|
|
164
203
|
tokenUtility: TokenUtility | string;
|
|
165
204
|
tokenUtilityScore: number;
|
|
166
205
|
complianceScore: number;
|
|
@@ -171,8 +210,65 @@ export interface TraceDetail {
|
|
|
171
210
|
rootCauseAttribution: unknown | null;
|
|
172
211
|
correctivePromptCard: unknown | null;
|
|
173
212
|
reasoningTokens?: number | null;
|
|
213
|
+
/**
|
|
214
|
+
* Provider-reported prompt-cache token counts (TD-347; migration 165) —
|
|
215
|
+
* Anthropic's `usage.cache_read_input_tokens` / `cache_creation_input_tokens`
|
|
216
|
+
* today. Null when the provider/proxy build doesn't report them; distinct
|
|
217
|
+
* from `cacheHit`/`cacheSavingsUsd` (the proxy's own semantic response
|
|
218
|
+
* cache) — see `execution_traces.cache_read_input_tokens`'s column comment.
|
|
219
|
+
*/
|
|
220
|
+
cacheReadInputTokens?: number | null;
|
|
221
|
+
cacheCreationInputTokens?: number | null;
|
|
174
222
|
toolCallMetrics?: unknown | null;
|
|
223
|
+
/**
|
|
224
|
+
* 0–100 integrity score backing a WASTED `tokenUtility` verdict; null when
|
|
225
|
+
* the trace was never scored (e.g. it wasn't a candidate for waste
|
|
226
|
+
* classification). Written at ingest; previously selected nowhere, so a
|
|
227
|
+
* WASTED badge had no way to explain itself — see `qualityFault` below.
|
|
228
|
+
*/
|
|
229
|
+
responseIntegrity?: number | null;
|
|
230
|
+
/**
|
|
231
|
+
* The specific check that failed when `responseIntegrity` is low — e.g.
|
|
232
|
+
* the first-failing-check name. Pairs with `responseIntegrity`; both are
|
|
233
|
+
* null together.
|
|
234
|
+
*/
|
|
235
|
+
qualityFault?: string | null;
|
|
236
|
+
/**
|
|
237
|
+
* The model a shadow-routing evaluation would have picked for this trace,
|
|
238
|
+
* if the workspace has shadow routing configured; null otherwise. Written
|
|
239
|
+
* at ingest on both the streaming and non-streaming ingest paths; reading
|
|
240
|
+
* it back is what the shadow-routing savings report aggregates.
|
|
241
|
+
*/
|
|
242
|
+
routingShadowModel?: string | null;
|
|
243
|
+
/** True when the request was served under a valid break-glass token, global or scoped (migration 170). */
|
|
244
|
+
breakGlass?: boolean;
|
|
245
|
+
/** The approval this trace ran under; what it skipped is that approval's `policyId`. */
|
|
246
|
+
breakGlassRequestId?: string | null;
|
|
247
|
+
/**
|
|
248
|
+
* What this request touched (migration 105). `toolCallMetrics` is token
|
|
249
|
+
* accounting per tool; this is the files, URLs and commands they named.
|
|
250
|
+
*/
|
|
251
|
+
changeManifest?: ChangeManifestEntry[] | null;
|
|
175
252
|
steps?: TraceStep[];
|
|
253
|
+
/**
|
|
254
|
+
* Every detector finding persisted for this trace, most severe first —
|
|
255
|
+
* see {@link TraceFindingSummary}. `anomalyDetected`/`anomalyConfidenceScore`
|
|
256
|
+
* above stay as the single winner for backward compatibility; this is the
|
|
257
|
+
* full set, present on allowed traces as well as blocked ones.
|
|
258
|
+
*/
|
|
259
|
+
findings?: TraceFindingSummary[];
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* One thing an agent touched, as recorded by the proxy's change manifest.
|
|
263
|
+
* Mirrors `ChangeEntry` in `packages/proxy/src/manifest.rs`.
|
|
264
|
+
*/
|
|
265
|
+
export interface ChangeManifestEntry {
|
|
266
|
+
tool: string;
|
|
267
|
+
op: 'write' | 'edit' | 'delete' | 'move' | 'execute' | 'read' | 'fetch' | 'unknown';
|
|
268
|
+
target: string;
|
|
269
|
+
target_kind: 'path' | 'url' | 'command' | 'opaque';
|
|
270
|
+
risk?: string[];
|
|
271
|
+
bytes?: number;
|
|
176
272
|
}
|
|
177
273
|
/** Filters for trace query. */
|
|
178
274
|
export interface TraceFilters {
|
package/dist/finops.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finops.d.ts","sourceRoot":"","sources":["../src/finops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,YAAY,EACb,MAAM,YAAY,CAAA;AAInB;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAA;IAEf,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAA;IAEjB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAA;IAEjB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAA;IAEjB,qDAAqD;IACrD,gBAAgB,EAAE,MAAM,CAAA;IAGxB,yCAAyC;IACzC,cAAc,EAAE,MAAM,CAAA;IAEtB,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,CAAA;IAEzB,kCAAkC;IAClC,WAAW,EAAE,WAAW,CAAA;IAExB,mDAAmD;IACnD,eAAe,EAAE,MAAM,CAAA;IAGvB,2CAA2C;IAC3C,cAAc,EAAE,MAAM,CAAA;IAEtB
|
|
1
|
+
{"version":3,"file":"finops.d.ts","sourceRoot":"","sources":["../src/finops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,YAAY,EACb,MAAM,YAAY,CAAA;AAInB;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAA;IAEf,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAA;IAEjB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAA;IAEjB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAA;IAEjB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E,CAAA;IACnB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAA;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;IACnF,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAA;IAClD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,+BAA+B;AAC/B,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Governance-coverage enforcement-input mapping — declared once.
|
|
3
|
+
*
|
|
4
|
+
* `POST /api/v1/governance-coverage/snapshot` takes four booleans
|
|
5
|
+
* (`mcpProxyActive`, `nativeHookActive`, `llmProxyActive`, `hasRulesFile`)
|
|
6
|
+
* that grade one harness's enforcement tier. Two independent producers
|
|
7
|
+
* compute them from the same underlying signal — an agent's reported
|
|
8
|
+
* `facets` — with what used to be the identical mapping written out twice:
|
|
9
|
+
*
|
|
10
|
+
* - `services/control-plane/src/services/harnessGradeSweep.ts`'s
|
|
11
|
+
* `deriveEnforcementInputs`, run hourly for every workspace, reading
|
|
12
|
+
* `agents.facets` back out of Postgres.
|
|
13
|
+
* - `services/sync-daemon/src/syncLoop.ts`'s `runSyncIteration` (step 5b),
|
|
14
|
+
* run every sync cycle, reading the `facets` object `collectAgentReport`
|
|
15
|
+
* just built in memory for the same cycle's `POST /api/v1/agents/report`
|
|
16
|
+
* call.
|
|
17
|
+
*
|
|
18
|
+
* Hand-copying this mapping between the two is how it drifted (TD-443):
|
|
19
|
+
* `syncLoop.ts`'s copy read `report.facets.mcp_tools.length > 0` with no
|
|
20
|
+
* `Array.isArray` guard, while `harnessGradeSweep.ts`'s copy guarded it —
|
|
21
|
+
* the exact two-hand-kept-copies failure `secretPatterns.ts`'s module doc
|
|
22
|
+
* comment describes for credential-value patterns. This module is the fix:
|
|
23
|
+
* one mapping, one source, both sides import it.
|
|
24
|
+
*
|
|
25
|
+
* `EnforcementFacets` is deliberately a NEW, narrower structural type, not a
|
|
26
|
+
* re-export of either service's own facets type. Neither service's
|
|
27
|
+
* `AgentFacets` moves here — `services/control-plane/src/lib/agentPosture.ts`'s
|
|
28
|
+
* and `services/sync-daemon/src/agentReporter.ts`'s each carry a great deal
|
|
29
|
+
* more shape (skills, sops, budgets, memory, …) than this mapping needs, and
|
|
30
|
+
* `services/sync-daemon` is publicly mirrored byte-identical into the
|
|
31
|
+
* open-core `intutic` repo and must not import from `services/control-plane`
|
|
32
|
+
* (or any enterprise-only package) — so there is no single existing type both
|
|
33
|
+
* sides could share directly even if one of them exported it. Both services'
|
|
34
|
+
* `AgentFacets` are structurally assignable to `EnforcementFacets` as it
|
|
35
|
+
* stands (checked, not just asserted — see this module's tests and the two
|
|
36
|
+
* call sites), which is all a structural type needs.
|
|
37
|
+
*
|
|
38
|
+
* @module
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* The narrow slice of an agent's reported `facets` this mapping reads. Both
|
|
42
|
+
* `services/control-plane/src/lib/agentPosture.ts#AgentFacets` and
|
|
43
|
+
* `services/sync-daemon/src/agentReporter.ts`'s local `AgentFacets` are
|
|
44
|
+
* structurally assignable to this — neither type moves here, this is a new
|
|
45
|
+
* narrower type they both already satisfy.
|
|
46
|
+
*/
|
|
47
|
+
export interface EnforcementFacets {
|
|
48
|
+
/** Only `Array.isArray` and `.length` are read — element shape differs
|
|
49
|
+
* between the two producers' real facets types, so it is not narrowed
|
|
50
|
+
* further here. */
|
|
51
|
+
mcp_tools?: readonly unknown[];
|
|
52
|
+
guardrails?: {
|
|
53
|
+
hook_gate?: boolean;
|
|
54
|
+
pcas?: boolean;
|
|
55
|
+
};
|
|
56
|
+
harness?: {
|
|
57
|
+
config_synced?: boolean;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The four enforcement inputs `POST /api/v1/governance-coverage/snapshot`
|
|
62
|
+
* (and `resolveEnforcementTier` on the control-plane side) expect.
|
|
63
|
+
*/
|
|
64
|
+
export interface GovernanceCoverageInputs {
|
|
65
|
+
mcpProxyActive: boolean;
|
|
66
|
+
nativeHookActive: boolean;
|
|
67
|
+
llmProxyActive: boolean;
|
|
68
|
+
hasRulesFile: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Map reported facets onto the four enforcement inputs a harness's
|
|
72
|
+
* enforcement tier is graded from. Pure function — no I/O, testable without
|
|
73
|
+
* a DB or a running daemon.
|
|
74
|
+
*
|
|
75
|
+
* Every field is read with the same strictness the original control-plane
|
|
76
|
+
* implementation used: `Array.isArray` (not just truthy) for `mcp_tools`,
|
|
77
|
+
* and `=== true` (not merely truthy) for every guardrail/harness boolean —
|
|
78
|
+
* a wrong mapping overstates enforcement, which is worse than an empty grid,
|
|
79
|
+
* so a loosely-truthy value (e.g. `hook_gate: 'yes'`) must not pass.
|
|
80
|
+
*/
|
|
81
|
+
export declare function deriveEnforcementInputs(facets: EnforcementFacets | null | undefined): GovernanceCoverageInputs;
|
|
82
|
+
//# sourceMappingURL=governanceCoverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governanceCoverage.d.ts","sourceRoot":"","sources":["../src/governanceCoverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;wBAEoB;IACpB,SAAS,CAAC,EAAE,SAAS,OAAO,EAAE,CAAA;IAC9B,UAAU,CAAC,EAAE;QACX,SAAS,CAAC,EAAE,OAAO,CAAA;QACnB,IAAI,CAAC,EAAE,OAAO,CAAA;KACf,CAAA;IACD,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,OAAO,CAAA;KACxB,CAAA;CACF;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,OAAO,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;IACzB,cAAc,EAAE,OAAO,CAAA;IACvB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,GAC3C,wBAAwB,CAiB1B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Governance-coverage enforcement-input mapping — declared once.
|
|
4
|
+
*
|
|
5
|
+
* `POST /api/v1/governance-coverage/snapshot` takes four booleans
|
|
6
|
+
* (`mcpProxyActive`, `nativeHookActive`, `llmProxyActive`, `hasRulesFile`)
|
|
7
|
+
* that grade one harness's enforcement tier. Two independent producers
|
|
8
|
+
* compute them from the same underlying signal — an agent's reported
|
|
9
|
+
* `facets` — with what used to be the identical mapping written out twice:
|
|
10
|
+
*
|
|
11
|
+
* - `services/control-plane/src/services/harnessGradeSweep.ts`'s
|
|
12
|
+
* `deriveEnforcementInputs`, run hourly for every workspace, reading
|
|
13
|
+
* `agents.facets` back out of Postgres.
|
|
14
|
+
* - `services/sync-daemon/src/syncLoop.ts`'s `runSyncIteration` (step 5b),
|
|
15
|
+
* run every sync cycle, reading the `facets` object `collectAgentReport`
|
|
16
|
+
* just built in memory for the same cycle's `POST /api/v1/agents/report`
|
|
17
|
+
* call.
|
|
18
|
+
*
|
|
19
|
+
* Hand-copying this mapping between the two is how it drifted (TD-443):
|
|
20
|
+
* `syncLoop.ts`'s copy read `report.facets.mcp_tools.length > 0` with no
|
|
21
|
+
* `Array.isArray` guard, while `harnessGradeSweep.ts`'s copy guarded it —
|
|
22
|
+
* the exact two-hand-kept-copies failure `secretPatterns.ts`'s module doc
|
|
23
|
+
* comment describes for credential-value patterns. This module is the fix:
|
|
24
|
+
* one mapping, one source, both sides import it.
|
|
25
|
+
*
|
|
26
|
+
* `EnforcementFacets` is deliberately a NEW, narrower structural type, not a
|
|
27
|
+
* re-export of either service's own facets type. Neither service's
|
|
28
|
+
* `AgentFacets` moves here — `services/control-plane/src/lib/agentPosture.ts`'s
|
|
29
|
+
* and `services/sync-daemon/src/agentReporter.ts`'s each carry a great deal
|
|
30
|
+
* more shape (skills, sops, budgets, memory, …) than this mapping needs, and
|
|
31
|
+
* `services/sync-daemon` is publicly mirrored byte-identical into the
|
|
32
|
+
* open-core `intutic` repo and must not import from `services/control-plane`
|
|
33
|
+
* (or any enterprise-only package) — so there is no single existing type both
|
|
34
|
+
* sides could share directly even if one of them exported it. Both services'
|
|
35
|
+
* `AgentFacets` are structurally assignable to `EnforcementFacets` as it
|
|
36
|
+
* stands (checked, not just asserted — see this module's tests and the two
|
|
37
|
+
* call sites), which is all a structural type needs.
|
|
38
|
+
*
|
|
39
|
+
* @module
|
|
40
|
+
*/
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.deriveEnforcementInputs = deriveEnforcementInputs;
|
|
43
|
+
/**
|
|
44
|
+
* Map reported facets onto the four enforcement inputs a harness's
|
|
45
|
+
* enforcement tier is graded from. Pure function — no I/O, testable without
|
|
46
|
+
* a DB or a running daemon.
|
|
47
|
+
*
|
|
48
|
+
* Every field is read with the same strictness the original control-plane
|
|
49
|
+
* implementation used: `Array.isArray` (not just truthy) for `mcp_tools`,
|
|
50
|
+
* and `=== true` (not merely truthy) for every guardrail/harness boolean —
|
|
51
|
+
* a wrong mapping overstates enforcement, which is worse than an empty grid,
|
|
52
|
+
* so a loosely-truthy value (e.g. `hook_gate: 'yes'`) must not pass.
|
|
53
|
+
*/
|
|
54
|
+
function deriveEnforcementInputs(facets) {
|
|
55
|
+
const f = facets ?? {};
|
|
56
|
+
return {
|
|
57
|
+
// Tool calls are mediated only if the agent actually has MCP tools
|
|
58
|
+
// routed through the governance proxy. An empty list means nothing to
|
|
59
|
+
// mediate.
|
|
60
|
+
mcpProxyActive: Array.isArray(f.mcp_tools) && f.mcp_tools.length > 0,
|
|
61
|
+
// The daemon writes the hook gate for every harness it supports, so this
|
|
62
|
+
// is a genuine "native hooks installed" signal rather than a constant.
|
|
63
|
+
nativeHookActive: f.guardrails?.hook_gate === true,
|
|
64
|
+
// pcas is set from the presence of a control-plane URL, i.e. LLM traffic
|
|
65
|
+
// is being proxied through governance rather than going direct.
|
|
66
|
+
llmProxyActive: f.guardrails?.pcas === true,
|
|
67
|
+
// A synced harness config is the rules file being in place and
|
|
68
|
+
// undrifted.
|
|
69
|
+
hasRulesFile: f.harness?.config_synced === true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=governanceCoverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governanceCoverage.js","sourceRoot":"","sources":["../src/governanceCoverage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;;AA6CH,0DAmBC;AA9BD;;;;;;;;;;GAUG;AACH,SAAgB,uBAAuB,CACrC,MAA4C;IAE5C,MAAM,CAAC,GAAG,MAAM,IAAI,EAAE,CAAA;IACtB,OAAO;QACL,mEAAmE;QACnE,sEAAsE;QACtE,WAAW;QACX,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;QACpE,yEAAyE;QACzE,uEAAuE;QACvE,gBAAgB,EAAE,CAAC,CAAC,UAAU,EAAE,SAAS,KAAK,IAAI;QAClD,yEAAyE;QACzE,gEAAgE;QAChE,cAAc,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,KAAK,IAAI;QAC3C,+DAA+D;QAC/D,aAAa;QACb,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI;KAChD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guardrail IR — the only thing a policy compiler may say (LLD #71).
|
|
3
|
+
*
|
|
4
|
+
* An LLM reading corporate policy prose is allowed to propose exactly two
|
|
5
|
+
* things: a verbatim quote anchored to a passage it was shown, and a clause in
|
|
6
|
+
* this closed IR. Everything after that is deterministic code: the validator
|
|
7
|
+
* (`services/control-plane/src/lib/guardrailValidator.ts`) checks the quote by
|
|
8
|
+
* containment and the IR against the grammar the proxy and the harness gates
|
|
9
|
+
* already enforce, the renderers in `./guardrailRender.ts` turn it into the
|
|
10
|
+
* exact bytes those enforcers read, and cross-language parity fixtures prove
|
|
11
|
+
* the renderers and the Rust / gate-script parsers agree.
|
|
12
|
+
*
|
|
13
|
+
* The grammar is a subset of what a human may author, on purpose:
|
|
14
|
+
*
|
|
15
|
+
* - `hook_rule` — a per-call condition on a tool and its arguments, enforced
|
|
16
|
+
* by the sync daemon's emitted harness gate scripts. Regexes are never model
|
|
17
|
+
* output: the tool pattern is rendered from literal tool tokens and the
|
|
18
|
+
* argument pattern from literal substrings (`argContains` / `argNotContains`),
|
|
19
|
+
* escaped and composed as lookaheads — the dialect JS `RegExp` and Python
|
|
20
|
+
* `re` share, so the bash gates' `python3` clause and the JS gates agree.
|
|
21
|
+
* - the six union-safe SOP front-matter keys the Rust proxy enforces
|
|
22
|
+
* (`deny_tools`, `review_before`, `requires_before`, `forbid_after`,
|
|
23
|
+
* `max_calls`, `forbid_with`). `~>` adjacency is not offered; `->` only.
|
|
24
|
+
* - `wasm_predicate` — the existing closed predicate DSL, verdict 3 (reask)
|
|
25
|
+
* only. A generated rule can never originate a block.
|
|
26
|
+
* - `none` — "this passage contains no enforceable rule", so the corpus can
|
|
27
|
+
* measure over-generation.
|
|
28
|
+
*
|
|
29
|
+
* Deliberately absent: the three allowlist keys (`allow_harnesses`,
|
|
30
|
+
* `plan_steps`, `scope_paths` — intersection-composed, empty-means-unrestricted;
|
|
31
|
+
* a generated allowlist can silently deny everything), raw regexes, raw
|
|
32
|
+
* AssemblyScript, `BLOCK:` titles, DLP patterns, SSL graphs, verdict 1, OR.
|
|
33
|
+
*
|
|
34
|
+
* Structural impossibilities match the Rust parser's own refusals: a token with
|
|
35
|
+
* whitespace (a shell command) cannot exist, a `forbid_with` taint is an enum,
|
|
36
|
+
* and an ordering rule is one pair.
|
|
37
|
+
*
|
|
38
|
+
* @module
|
|
39
|
+
*/
|
|
40
|
+
import { z } from 'zod';
|
|
41
|
+
/**
|
|
42
|
+
* The eight `action:` tokens the proxy's classifier synthesises from tool
|
|
43
|
+
* calls. Moved here from `services/control-plane/src/services/learnedHoldService.ts`
|
|
44
|
+
* so the IR, the validator and the hold miner read one list; that file
|
|
45
|
+
* re-exports it. A token outside this set and outside the observed tool names
|
|
46
|
+
* compiles into a control that can never fire.
|
|
47
|
+
*/
|
|
48
|
+
export declare const ACTION_TOKENS: readonly ["action:deploy", "action:publish", "action:release", "action:db_write", "action:secret_read", "action:http_post", "action:pii_export", "action:run_tests"];
|
|
49
|
+
export type ActionToken = (typeof ACTION_TOKENS)[number];
|
|
50
|
+
export declare function isActionToken(value: string): value is ActionToken;
|
|
51
|
+
/**
|
|
52
|
+
* A tool name the harness could plausibly call: `Bash`, `run_command`,
|
|
53
|
+
* `mcp__github__create_issue`, `developer__shell`. No whitespace, so a shell
|
|
54
|
+
* command can never be mistaken for a tool (sops.rs `parse_ordering` refuses
|
|
55
|
+
* the same shape for the same reason). `.`, `:` and `-` are allowed because
|
|
56
|
+
* namespaced harness tools carry them.
|
|
57
|
+
*/
|
|
58
|
+
export declare const TOOL_TOKEN_RE: RegExp;
|
|
59
|
+
export declare const MAX_HOOK_TOOLS = 8;
|
|
60
|
+
export declare const MAX_LIST_TOKENS = 16;
|
|
61
|
+
export declare const MAX_LITERALS = 4;
|
|
62
|
+
export declare const MAX_LITERAL_CHARS = 64;
|
|
63
|
+
export declare const MAX_ROLES = 8;
|
|
64
|
+
export declare const MAX_TITLE_CHARS = 80;
|
|
65
|
+
export declare const MAX_RATIONALE_CHARS = 480;
|
|
66
|
+
export declare const MAX_CALLS_LIMIT = 1000;
|
|
67
|
+
declare const HookRuleSchema: z.ZodObject<{
|
|
68
|
+
kind: z.ZodLiteral<"hook_rule">;
|
|
69
|
+
title: z.ZodString;
|
|
70
|
+
tools: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
71
|
+
argContains: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
72
|
+
argNotContains: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
73
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
74
|
+
}, "strict", z.ZodTypeAny, {
|
|
75
|
+
kind: "hook_rule";
|
|
76
|
+
title: string;
|
|
77
|
+
tools: string[];
|
|
78
|
+
argContains?: string[] | undefined;
|
|
79
|
+
argNotContains?: string[] | undefined;
|
|
80
|
+
roles?: string[] | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
kind: "hook_rule";
|
|
83
|
+
title: string;
|
|
84
|
+
tools: string[];
|
|
85
|
+
argContains?: string[] | undefined;
|
|
86
|
+
argNotContains?: string[] | undefined;
|
|
87
|
+
roles?: string[] | undefined;
|
|
88
|
+
}>;
|
|
89
|
+
declare const WasmPredicateSchema: z.ZodObject<{
|
|
90
|
+
kind: z.ZodLiteral<"wasm_predicate">;
|
|
91
|
+
title: z.ZodString;
|
|
92
|
+
rationale: z.ZodString;
|
|
93
|
+
predicate: z.ZodUnknown;
|
|
94
|
+
verdict: z.ZodLiteral<3>;
|
|
95
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
96
|
+
}, "strict", z.ZodTypeAny, {
|
|
97
|
+
kind: "wasm_predicate";
|
|
98
|
+
title: string;
|
|
99
|
+
rationale: string;
|
|
100
|
+
verdict: 3;
|
|
101
|
+
roles?: string[] | undefined;
|
|
102
|
+
predicate?: unknown;
|
|
103
|
+
}, {
|
|
104
|
+
kind: "wasm_predicate";
|
|
105
|
+
title: string;
|
|
106
|
+
rationale: string;
|
|
107
|
+
verdict: 3;
|
|
108
|
+
roles?: string[] | undefined;
|
|
109
|
+
predicate?: unknown;
|
|
110
|
+
}>;
|
|
111
|
+
export declare const GuardrailIrSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
112
|
+
kind: z.ZodLiteral<"hook_rule">;
|
|
113
|
+
title: z.ZodString;
|
|
114
|
+
tools: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
115
|
+
argContains: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
116
|
+
argNotContains: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
117
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
118
|
+
}, "strict", z.ZodTypeAny, {
|
|
119
|
+
kind: "hook_rule";
|
|
120
|
+
title: string;
|
|
121
|
+
tools: string[];
|
|
122
|
+
argContains?: string[] | undefined;
|
|
123
|
+
argNotContains?: string[] | undefined;
|
|
124
|
+
roles?: string[] | undefined;
|
|
125
|
+
}, {
|
|
126
|
+
kind: "hook_rule";
|
|
127
|
+
title: string;
|
|
128
|
+
tools: string[];
|
|
129
|
+
argContains?: string[] | undefined;
|
|
130
|
+
argNotContains?: string[] | undefined;
|
|
131
|
+
roles?: string[] | undefined;
|
|
132
|
+
}>, z.ZodObject<{
|
|
133
|
+
kind: z.ZodLiteral<"deny_tools">;
|
|
134
|
+
tools: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
135
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
136
|
+
}, "strict", z.ZodTypeAny, {
|
|
137
|
+
kind: "deny_tools";
|
|
138
|
+
tools: string[];
|
|
139
|
+
roles?: string[] | undefined;
|
|
140
|
+
}, {
|
|
141
|
+
kind: "deny_tools";
|
|
142
|
+
tools: string[];
|
|
143
|
+
roles?: string[] | undefined;
|
|
144
|
+
}>, z.ZodObject<{
|
|
145
|
+
kind: z.ZodLiteral<"review_before">;
|
|
146
|
+
tokens: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
147
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
148
|
+
}, "strict", z.ZodTypeAny, {
|
|
149
|
+
kind: "review_before";
|
|
150
|
+
tokens: string[];
|
|
151
|
+
roles?: string[] | undefined;
|
|
152
|
+
}, {
|
|
153
|
+
kind: "review_before";
|
|
154
|
+
tokens: string[];
|
|
155
|
+
roles?: string[] | undefined;
|
|
156
|
+
}>, z.ZodObject<{
|
|
157
|
+
first: z.ZodEffects<z.ZodString, string, string>;
|
|
158
|
+
then: z.ZodEffects<z.ZodString, string, string>;
|
|
159
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
160
|
+
kind: z.ZodLiteral<"requires_before">;
|
|
161
|
+
}, "strict", z.ZodTypeAny, {
|
|
162
|
+
kind: "requires_before";
|
|
163
|
+
first: string;
|
|
164
|
+
then: string;
|
|
165
|
+
roles?: string[] | undefined;
|
|
166
|
+
}, {
|
|
167
|
+
kind: "requires_before";
|
|
168
|
+
first: string;
|
|
169
|
+
then: string;
|
|
170
|
+
roles?: string[] | undefined;
|
|
171
|
+
}>, z.ZodObject<{
|
|
172
|
+
first: z.ZodEffects<z.ZodString, string, string>;
|
|
173
|
+
then: z.ZodEffects<z.ZodString, string, string>;
|
|
174
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
175
|
+
kind: z.ZodLiteral<"forbid_after">;
|
|
176
|
+
}, "strict", z.ZodTypeAny, {
|
|
177
|
+
kind: "forbid_after";
|
|
178
|
+
first: string;
|
|
179
|
+
then: string;
|
|
180
|
+
roles?: string[] | undefined;
|
|
181
|
+
}, {
|
|
182
|
+
kind: "forbid_after";
|
|
183
|
+
first: string;
|
|
184
|
+
then: string;
|
|
185
|
+
roles?: string[] | undefined;
|
|
186
|
+
}>, z.ZodObject<{
|
|
187
|
+
kind: z.ZodLiteral<"max_calls">;
|
|
188
|
+
token: z.ZodEffects<z.ZodString, string, string>;
|
|
189
|
+
limit: z.ZodNumber;
|
|
190
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
191
|
+
}, "strict", z.ZodTypeAny, {
|
|
192
|
+
token: string;
|
|
193
|
+
kind: "max_calls";
|
|
194
|
+
limit: number;
|
|
195
|
+
roles?: string[] | undefined;
|
|
196
|
+
}, {
|
|
197
|
+
token: string;
|
|
198
|
+
kind: "max_calls";
|
|
199
|
+
limit: number;
|
|
200
|
+
roles?: string[] | undefined;
|
|
201
|
+
}>, z.ZodObject<{
|
|
202
|
+
kind: z.ZodLiteral<"forbid_with">;
|
|
203
|
+
taint: z.ZodEnum<["secrets()", "pii()"]>;
|
|
204
|
+
token: z.ZodEffects<z.ZodString, string, string>;
|
|
205
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
206
|
+
}, "strict", z.ZodTypeAny, {
|
|
207
|
+
token: string;
|
|
208
|
+
kind: "forbid_with";
|
|
209
|
+
taint: "secrets()" | "pii()";
|
|
210
|
+
roles?: string[] | undefined;
|
|
211
|
+
}, {
|
|
212
|
+
token: string;
|
|
213
|
+
kind: "forbid_with";
|
|
214
|
+
taint: "secrets()" | "pii()";
|
|
215
|
+
roles?: string[] | undefined;
|
|
216
|
+
}>, z.ZodObject<{
|
|
217
|
+
kind: z.ZodLiteral<"wasm_predicate">;
|
|
218
|
+
title: z.ZodString;
|
|
219
|
+
rationale: z.ZodString;
|
|
220
|
+
predicate: z.ZodUnknown;
|
|
221
|
+
verdict: z.ZodLiteral<3>;
|
|
222
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
223
|
+
}, "strict", z.ZodTypeAny, {
|
|
224
|
+
kind: "wasm_predicate";
|
|
225
|
+
title: string;
|
|
226
|
+
rationale: string;
|
|
227
|
+
verdict: 3;
|
|
228
|
+
roles?: string[] | undefined;
|
|
229
|
+
predicate?: unknown;
|
|
230
|
+
}, {
|
|
231
|
+
kind: "wasm_predicate";
|
|
232
|
+
title: string;
|
|
233
|
+
rationale: string;
|
|
234
|
+
verdict: 3;
|
|
235
|
+
roles?: string[] | undefined;
|
|
236
|
+
predicate?: unknown;
|
|
237
|
+
}>, z.ZodObject<{
|
|
238
|
+
kind: z.ZodLiteral<"none">;
|
|
239
|
+
reason: z.ZodString;
|
|
240
|
+
}, "strict", z.ZodTypeAny, {
|
|
241
|
+
reason: string;
|
|
242
|
+
kind: "none";
|
|
243
|
+
}, {
|
|
244
|
+
reason: string;
|
|
245
|
+
kind: "none";
|
|
246
|
+
}>]>;
|
|
247
|
+
export type GuardrailIr = z.infer<typeof GuardrailIrSchema>;
|
|
248
|
+
export type HookRuleIr = z.infer<typeof HookRuleSchema>;
|
|
249
|
+
export type WasmPredicateIr = z.infer<typeof WasmPredicateSchema>;
|
|
250
|
+
export type FrontMatterIr = Extract<GuardrailIr, {
|
|
251
|
+
kind: 'deny_tools' | 'review_before' | 'requires_before' | 'forbid_after' | 'max_calls' | 'forbid_with';
|
|
252
|
+
}>;
|
|
253
|
+
export type IrKind = GuardrailIr['kind'];
|
|
254
|
+
/** Every kind, in one place, for the lint gate (`check-guardrail-ir-keys.js`). */
|
|
255
|
+
export declare const IR_KINDS: readonly ["hook_rule", "deny_tools", "review_before", "requires_before", "forbid_after", "max_calls", "forbid_with", "wasm_predicate", "none"];
|
|
256
|
+
/** The kinds that render to a SOP front-matter key the Rust proxy reads. */
|
|
257
|
+
export declare const FRONT_MATTER_KINDS: readonly ["deny_tools", "review_before", "requires_before", "forbid_after", "max_calls", "forbid_with"];
|
|
258
|
+
export declare function isFrontMatterIr(ir: GuardrailIr): ir is FrontMatterIr;
|
|
259
|
+
export type IrValidation = {
|
|
260
|
+
ok: true;
|
|
261
|
+
ir: GuardrailIr;
|
|
262
|
+
} | {
|
|
263
|
+
ok: false;
|
|
264
|
+
reason: string;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Parse an untrusted value into the IR, or say why it is not one. Never
|
|
268
|
+
* throws. This — not `GuardrailIrSchema.parse` — is the entry point: the
|
|
269
|
+
* shape parse cannot express "the two ordering tokens differ" or "the wasm
|
|
270
|
+
* predicate is in the closed DSL", so both are checked here.
|
|
271
|
+
*/
|
|
272
|
+
export declare function validateGuardrailIr(value: unknown): IrValidation;
|
|
273
|
+
/**
|
|
274
|
+
* The identity of a control, as a stable string.
|
|
275
|
+
*
|
|
276
|
+
* Two proposals that name the same control from the same passage are one
|
|
277
|
+
* proposal — `policy_clauses` is unique on `(passage_hash, ir_canonical)` —
|
|
278
|
+
* so the title and rationale, which change nothing about what is enforced,
|
|
279
|
+
* are not part of it. Lists are sorted and deduplicated; roles are lower-case
|
|
280
|
+
* (the proxy lowercases them too); tool tokens keep their case (the proxy
|
|
281
|
+
* matches `Bash` case-sensitively).
|
|
282
|
+
*/
|
|
283
|
+
export declare function canonicalizeIr(ir: GuardrailIr): string;
|
|
284
|
+
/** Every token (tool or action) an IR names — the set a validator must find in the cited passage. */
|
|
285
|
+
export declare function irTokens(ir: GuardrailIr): string[];
|
|
286
|
+
export {};
|
|
287
|
+
//# sourceMappingURL=guardrailIr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guardrailIr.d.ts","sourceRoot":"","sources":["../src/guardrailIr.ts"],"names":[],"mappings":"AAAA;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