@mcp-index/sdk 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 +133 -0
- package/README.md +49 -0
- package/dist/src/canonical.d.ts +42 -0
- package/dist/src/canonical.d.ts.map +1 -0
- package/dist/src/canonical.js +231 -0
- package/dist/src/canonical.js.map +1 -0
- package/dist/src/errors.d.ts +39 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +79 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/gate.d.ts +128 -0
- package/dist/src/gate.d.ts.map +1 -0
- package/dist/src/gate.js +626 -0
- package/dist/src/gate.js.map +1 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +20 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lexicon.d.ts +15 -0
- package/dist/src/lexicon.d.ts.map +1 -0
- package/dist/src/lexicon.js +70 -0
- package/dist/src/lexicon.js.map +1 -0
- package/dist/src/outcomes.d.ts +67 -0
- package/dist/src/outcomes.d.ts.map +1 -0
- package/dist/src/outcomes.js +159 -0
- package/dist/src/outcomes.js.map +1 -0
- package/dist/src/preflight.d.ts +54 -0
- package/dist/src/preflight.d.ts.map +1 -0
- package/dist/src/preflight.js +0 -0
- package/dist/src/preflight.js.map +1 -0
- package/dist/src/provenance.d.ts +95 -0
- package/dist/src/provenance.d.ts.map +1 -0
- package/dist/src/provenance.js +221 -0
- package/dist/src/provenance.js.map +1 -0
- package/dist/src/render.d.ts +10 -0
- package/dist/src/render.d.ts.map +1 -0
- package/dist/src/render.js +38 -0
- package/dist/src/render.js.map +1 -0
- package/dist/src/risk.d.ts +32 -0
- package/dist/src/risk.d.ts.map +1 -0
- package/dist/src/risk.js +179 -0
- package/dist/src/risk.js.map +1 -0
- package/dist/src/scan.d.ts +15 -0
- package/dist/src/scan.d.ts.map +1 -0
- package/dist/src/scan.js +88 -0
- package/dist/src/scan.js.map +1 -0
- package/dist/src/schemaDiff.d.ts +36 -0
- package/dist/src/schemaDiff.d.ts.map +1 -0
- package/dist/src/schemaDiff.js +448 -0
- package/dist/src/schemaDiff.js.map +1 -0
- package/dist/src/wrap.d.ts +77 -0
- package/dist/src/wrap.d.ts.map +1 -0
- package/dist/src/wrap.js +554 -0
- package/dist/src/wrap.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcpindex — the TypeScript/JS SDK port of the pre-flight drift interceptor.
|
|
3
|
+
*
|
|
4
|
+
* One line wraps an already-authenticated MCP client session and HOLDs a tool
|
|
5
|
+
* call before your agent runs it if the tool's contract drifted from your pin.
|
|
6
|
+
* The wrapper never holds a credential and never opens a connection — it reuses
|
|
7
|
+
* the wrapped session's own authenticated transport.
|
|
8
|
+
*/
|
|
9
|
+
export { wrap, repin, PreflightHold } from "./wrap.js";
|
|
10
|
+
export type { Wrapped, WrapOptions } from "./wrap.js";
|
|
11
|
+
export { PreflightPin, Decision, isProceed, renderVerdict, safetyRelevantDrift, hashTool, } from "./preflight.js";
|
|
12
|
+
export type { PinnedTool, PreflightVerdict, ToolDef } from "./preflight.js";
|
|
13
|
+
export { Gate, Posture, Ownership, BehavioralMethod, BehavioralOutcome, chooseBehavioralMethod, renderHoldBanner, isInternalErrorVerdict, } from "./gate.js";
|
|
14
|
+
export type { BehavioralVerifier, BehavioralResult, GateOptions } from "./gate.js";
|
|
15
|
+
export { ChangeKind, classifyChange, isSafetyRelevant, MAX_DEPTH } from "./schemaDiff.js";
|
|
16
|
+
export type { Change } from "./schemaDiff.js";
|
|
17
|
+
export { canonicalBytes, toolHash } from "./canonical.js";
|
|
18
|
+
export { assess, BlastRadius, DomainClass, blastRank } from "./risk.js";
|
|
19
|
+
export type { RiskAssessment } from "./risk.js";
|
|
20
|
+
export { scanSchemaHasMarker } from "./scan.js";
|
|
21
|
+
export { mdText } from "./render.js";
|
|
22
|
+
export { VerdictScope, HonestFraming, GuardrailError, requireProvenance, surfaceProvenance, fromVerdict, isComplete, renderProvenance, assertNoGreenWords, } from "./provenance.js";
|
|
23
|
+
export type { Provenance, Subject, WhatFired, EvidenceField } from "./provenance.js";
|
|
24
|
+
export { ErrorStore, Operation, CLIENT_VERSION, ERROR_RECORD_KEYS } from "./errors.js";
|
|
25
|
+
export { OutcomeStore, LocalStats, Action, OverrideReason, AGGREGATE_ROW_KEYS, verdictHash, } from "./outcomes.js";
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACvD,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,QAAQ,GACT,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EACL,IAAI,EACJ,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC1F,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EACL,YAAY,EACZ,UAAU,EACV,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,WAAW,GACZ,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcpindex — the TypeScript/JS SDK port of the pre-flight drift interceptor.
|
|
3
|
+
*
|
|
4
|
+
* One line wraps an already-authenticated MCP client session and HOLDs a tool
|
|
5
|
+
* call before your agent runs it if the tool's contract drifted from your pin.
|
|
6
|
+
* The wrapper never holds a credential and never opens a connection — it reuses
|
|
7
|
+
* the wrapped session's own authenticated transport.
|
|
8
|
+
*/
|
|
9
|
+
export { wrap, repin, PreflightHold } from "./wrap.js";
|
|
10
|
+
export { PreflightPin, Decision, isProceed, renderVerdict, safetyRelevantDrift, hashTool, } from "./preflight.js";
|
|
11
|
+
export { Gate, Posture, Ownership, BehavioralMethod, BehavioralOutcome, chooseBehavioralMethod, renderHoldBanner, isInternalErrorVerdict, } from "./gate.js";
|
|
12
|
+
export { ChangeKind, classifyChange, isSafetyRelevant, MAX_DEPTH } from "./schemaDiff.js";
|
|
13
|
+
export { canonicalBytes, toolHash } from "./canonical.js";
|
|
14
|
+
export { assess, BlastRadius, DomainClass, blastRank } from "./risk.js";
|
|
15
|
+
export { scanSchemaHasMarker } from "./scan.js";
|
|
16
|
+
export { mdText } from "./render.js";
|
|
17
|
+
export { VerdictScope, HonestFraming, GuardrailError, requireProvenance, surfaceProvenance, fromVerdict, isComplete, renderProvenance, assertNoGreenWords, } from "./provenance.js";
|
|
18
|
+
export { ErrorStore, Operation, CLIENT_VERSION, ERROR_RECORD_KEYS } from "./errors.js";
|
|
19
|
+
export { OutcomeStore, LocalStats, Action, OverrideReason, AGGREGATE_ROW_KEYS, verdictHash, } from "./outcomes.js";
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGvD,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,QAAQ,GACT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,IAAI,EACJ,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG1F,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EACL,YAAY,EACZ,UAAU,EACV,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,WAAW,GACZ,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure side-effect / read-only NAME lexicon — a port of Python
|
|
3
|
+
* `tooling/lexicon.py`. Stdlib-only, no I/O. Reused by `risk.ts`.
|
|
4
|
+
*/
|
|
5
|
+
/** snake_case + camelCase -> lowercase tokens (port of `_name_tokens`). */
|
|
6
|
+
export declare function nameTokens(name: string): Set<string>;
|
|
7
|
+
/** Third-person-singular -s/-es stems of a token (port of `_side_effect_stems`). */
|
|
8
|
+
export declare function sideEffectStems(word: string): Set<string>;
|
|
9
|
+
/** True iff name/description carries a side-effecting/financial intent token
|
|
10
|
+
* (base form or -s/-es inflection). Port of `_has_side_effect_intent`. */
|
|
11
|
+
export declare function hasSideEffectIntent(name: string, description: string): boolean;
|
|
12
|
+
/** True iff the tool NAME carries a clearly-mutating verb. Port of
|
|
13
|
+
* `_name_is_writeish` (name-only by design). */
|
|
14
|
+
export declare function nameIsWriteish(name: string): boolean;
|
|
15
|
+
//# sourceMappingURL=lexicon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexicon.d.ts","sourceRoot":"","sources":["../../src/lexicon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8BH,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CASpD;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAUzD;AAOD;0EAC0E;AAC1E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAO9E;AAED;gDACgD;AAChD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure side-effect / read-only NAME lexicon — a port of Python
|
|
3
|
+
* `tooling/lexicon.py`. Stdlib-only, no I/O. Reused by `risk.ts`.
|
|
4
|
+
*/
|
|
5
|
+
const MUTATING_VERBS = new Set(("write delete remove create update exec execute run post put patch " +
|
|
6
|
+
"send drop destroy modify upload insert merge purge kill " +
|
|
7
|
+
"authorize pay charge transfer refund withdraw deposit debit credit " +
|
|
8
|
+
"settle fund purchase checkout subscribe cancel issue grant revoke " +
|
|
9
|
+
"provision deploy set").split(" "));
|
|
10
|
+
const WORD_TOKEN_RE = /[a-z0-9]+/g;
|
|
11
|
+
const SIDE_EFFECT_INTENT = new Set([
|
|
12
|
+
"authorize", "payment", "pay", "charge", "transfer", "refund", "withdraw",
|
|
13
|
+
"deposit", "mandate", "wallet", "checkout", "purchase", "order", "billing",
|
|
14
|
+
"invoice", "subscribe", "fund", "settle", "debit", "credit", "transaction",
|
|
15
|
+
"send", "create", "delete", "update", "write", "modify", "execute", "set",
|
|
16
|
+
"remove", "cancel", "issue", "grant", "revoke", "provision", "deploy",
|
|
17
|
+
"book", "reserve", "lock", "commit", "publish", "consume", "redeem",
|
|
18
|
+
"dispatch", "release", "claim", "approve", "reject", "confirm", "submit",
|
|
19
|
+
"schedule", "assign", "trigger", "archive", "terminate", "disable",
|
|
20
|
+
"enable", "reset", "mark", "acknowledge", "ack", "sign", "escrow",
|
|
21
|
+
"disburse", "wire", "place", "mint", "burn", "swap", "stake", "void",
|
|
22
|
+
"purge", "truncate", "overwrite", "wipe", "prune",
|
|
23
|
+
]);
|
|
24
|
+
/** snake_case + camelCase -> lowercase tokens (port of `_name_tokens`). */
|
|
25
|
+
export function nameTokens(name) {
|
|
26
|
+
const out = new Set();
|
|
27
|
+
for (const part of name.split(/[^A-Za-z0-9]+/)) {
|
|
28
|
+
const matches = part.match(/[A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+/g);
|
|
29
|
+
if (matches) {
|
|
30
|
+
for (const m of matches)
|
|
31
|
+
out.add(m.toLowerCase());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
/** Third-person-singular -s/-es stems of a token (port of `_side_effect_stems`). */
|
|
37
|
+
export function sideEffectStems(word) {
|
|
38
|
+
const cands = new Set([word]);
|
|
39
|
+
for (const suf of ["es", "s"]) {
|
|
40
|
+
if (word.endsWith(suf) && word.length - suf.length >= 3) {
|
|
41
|
+
const root = word.slice(0, word.length - suf.length);
|
|
42
|
+
cands.add(root);
|
|
43
|
+
cands.add(root + "e");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return cands;
|
|
47
|
+
}
|
|
48
|
+
function intersects(a, b) {
|
|
49
|
+
for (const x of a)
|
|
50
|
+
if (b.has(x))
|
|
51
|
+
return true;
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
/** True iff name/description carries a side-effecting/financial intent token
|
|
55
|
+
* (base form or -s/-es inflection). Port of `_has_side_effect_intent`. */
|
|
56
|
+
export function hasSideEffectIntent(name, description) {
|
|
57
|
+
const text = `${name} ${description}`.toLowerCase();
|
|
58
|
+
const words = new Set(text.match(WORD_TOKEN_RE) ?? []);
|
|
59
|
+
for (const word of words) {
|
|
60
|
+
if (intersects(sideEffectStems(word), SIDE_EFFECT_INTENT))
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
/** True iff the tool NAME carries a clearly-mutating verb. Port of
|
|
66
|
+
* `_name_is_writeish` (name-only by design). */
|
|
67
|
+
export function nameIsWriteish(name) {
|
|
68
|
+
return intersects(nameTokens(name), MUTATING_VERBS) || hasSideEffectIntent(name, "");
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=lexicon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexicon.js","sourceRoot":"","sources":["../../src/lexicon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,cAAc,GAAG,IAAI,GAAG,CAC5B,CACE,oEAAoE;IACpE,0DAA0D;IAC1D,qEAAqE;IACrE,oEAAoE;IACpE,sBAAsB,CACvB,CAAC,KAAK,CAAC,GAAG,CAAC,CACb,CAAC;AAEF,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAChC;IACE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU;IACzE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS;IAC1E,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa;IAC1E,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK;IACzE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ;IACrE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ;IACnE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;IACxE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS;IAClE,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C;QACxB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,CAAc,EAAE,CAAsB;IACxD,KAAK,MAAM,CAAC,IAAI,CAAC;QAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC;AAED;0EAC0E;AAC1E,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,WAAmB;IACnE,MAAM,IAAI,GAAG,GAAG,IAAI,IAAI,WAAW,EAAE,CAAC,WAAW,EAAE,CAAC;IACpD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;IACvD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC;YAAE,OAAO,IAAI,CAAC;IACzE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;gDACgD;AAChD,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,IAAI,mBAAmB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcomes — the local capture substrate (surface + response tracking). A port
|
|
3
|
+
* of the in-memory core of Python `tooling/cse/outcomes.py`. Local FULL detail;
|
|
4
|
+
* the ONLY projection that may ever leave is `aggregateRows()`:
|
|
5
|
+
* `{verdict_hash, action, reason_class}` per response — NEVER a tool name, an
|
|
6
|
+
* argument, data, or a credential.
|
|
7
|
+
*/
|
|
8
|
+
import type { Provenance } from "./provenance.js";
|
|
9
|
+
export declare enum Action {
|
|
10
|
+
OVERRIDE = "override",
|
|
11
|
+
HONOR = "honor",
|
|
12
|
+
REPIN = "repin",
|
|
13
|
+
ESCALATE = "escalate",
|
|
14
|
+
DISABLE = "disable",
|
|
15
|
+
LOWER_POSTURE = "lower_posture",
|
|
16
|
+
UNINSTALL = "uninstall",
|
|
17
|
+
IGNORE = "ignore"
|
|
18
|
+
}
|
|
19
|
+
export declare enum OverrideReason {
|
|
20
|
+
FALSE_ALARM = "false_alarm",
|
|
21
|
+
REVIEWED_FINE = "reviewed_fine",
|
|
22
|
+
NEED_NOW = "need_now",
|
|
23
|
+
OTHER = "other"
|
|
24
|
+
}
|
|
25
|
+
export declare const AGGREGATE_ROW_KEYS: ReadonlySet<string>;
|
|
26
|
+
/** SHA-256 over the provenance reproduce-handle, hex-truncated to 16. Identifies
|
|
27
|
+
* the JUDGMENT (public contract), not the tool args. Port of `verdict_hash`. */
|
|
28
|
+
export declare function verdictHash(provenance: Provenance): string;
|
|
29
|
+
/** On-device append-only capture store; ZERO egress of detail. */
|
|
30
|
+
export declare class OutcomeStore {
|
|
31
|
+
private readonly now;
|
|
32
|
+
private readonly surfaces;
|
|
33
|
+
private responses;
|
|
34
|
+
constructor(now?: () => string);
|
|
35
|
+
recordSurface(provenance: Provenance, posture: string): string;
|
|
36
|
+
recordResponse(surfaceId: string, action: Action, reason?: OverrideReason | null): void;
|
|
37
|
+
/** Bound the store so a long-lived session cannot grow it without limit (port of Python
|
|
38
|
+
* `OutcomeStore._prune_locked`). Two passes on the SURFACE store, both anchored on the
|
|
39
|
+
* LATEST surface timestamp so a deterministic test/replay does not depend on wall-clock
|
|
40
|
+
* now: (1) DATE-PRUNE drops surfaces older than `RETENTION_DAYS` (an unparseable stamp is
|
|
41
|
+
* KEPT — only the hard cap can evict it); (2) RING-BUFFER enforces the `MAX_EVENTS` cap,
|
|
42
|
+
* oldest-first. Responses linked to an evicted surface are then dropped (a response that
|
|
43
|
+
* can no longer be anonymize-linked carries no signal — `aggregateRows` would drop it
|
|
44
|
+
* anyway); the response list is independently hard-capped so a flood of externally-minted
|
|
45
|
+
* ids cannot grow the store either. */
|
|
46
|
+
private prune;
|
|
47
|
+
surfaceCount(): number;
|
|
48
|
+
responseCount(): number;
|
|
49
|
+
/** The ONLY projection that may ever leave the device. One row per response,
|
|
50
|
+
* `{verdict_hash, action, reason_class}` only; a response with no resolvable
|
|
51
|
+
* surface is DROPPED (fail-closed). Port of `aggregate_rows`. */
|
|
52
|
+
aggregateRows(): Array<Record<string, string>>;
|
|
53
|
+
}
|
|
54
|
+
/** Local on-device counters — the analog of Python `LocalStats`, narrowed to what
|
|
55
|
+
* the wrapper records (gate calls + a 30-day HOLD tally for the banner). */
|
|
56
|
+
export declare class LocalStats {
|
|
57
|
+
private holds;
|
|
58
|
+
private repins;
|
|
59
|
+
private overCap;
|
|
60
|
+
recordHold(): void;
|
|
61
|
+
recordRepin(): void;
|
|
62
|
+
recordOverCap(): void;
|
|
63
|
+
holdsThisMonth(): number;
|
|
64
|
+
repinCount(): number;
|
|
65
|
+
overCapCount(): number;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=outcomes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcomes.d.ts","sourceRoot":"","sources":["../../src/outcomes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,oBAAY,MAAM;IAChB,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,oBAAY,cAAc;IACxB,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AAED,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAuD,CAAC;AAE3G;gFACgF;AAChF,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAE1D;AAgCD,kEAAkE;AAClE,qBAAa,YAAY;IAIX,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHhC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;IAC7D,OAAO,CAAC,SAAS,CAAwB;gBAEZ,GAAG,GAAE,MAAM,MAAkB;IAE1D,aAAa,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAO9D,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,cAAc,GAAG,IAAW,GAAG,IAAI;IAK7F;;;;;;;;2CAQuC;IACvC,OAAO,CAAC,KAAK;IAkCb,YAAY,IAAI,MAAM;IAItB,aAAa,IAAI,MAAM;IAIvB;;qEAEiE;IACjE,aAAa,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAa/C;AAED;4EAC4E;AAC5E,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,OAAO,CAAK;IAEpB,UAAU,IAAI,IAAI;IAIlB,WAAW,IAAI,IAAI;IAInB,aAAa,IAAI,IAAI;IAIrB,cAAc,IAAI,MAAM;IAIxB,UAAU,IAAI,MAAM;IAIpB,YAAY,IAAI,MAAM;CAGvB"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcomes — the local capture substrate (surface + response tracking). A port
|
|
3
|
+
* of the in-memory core of Python `tooling/cse/outcomes.py`. Local FULL detail;
|
|
4
|
+
* the ONLY projection that may ever leave is `aggregateRows()`:
|
|
5
|
+
* `{verdict_hash, action, reason_class}` per response — NEVER a tool name, an
|
|
6
|
+
* argument, data, or a credential.
|
|
7
|
+
*/
|
|
8
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
9
|
+
import { utcNowIso } from "./preflight.js";
|
|
10
|
+
export var Action;
|
|
11
|
+
(function (Action) {
|
|
12
|
+
Action["OVERRIDE"] = "override";
|
|
13
|
+
Action["HONOR"] = "honor";
|
|
14
|
+
Action["REPIN"] = "repin";
|
|
15
|
+
Action["ESCALATE"] = "escalate";
|
|
16
|
+
Action["DISABLE"] = "disable";
|
|
17
|
+
Action["LOWER_POSTURE"] = "lower_posture";
|
|
18
|
+
Action["UNINSTALL"] = "uninstall";
|
|
19
|
+
Action["IGNORE"] = "ignore";
|
|
20
|
+
})(Action || (Action = {}));
|
|
21
|
+
export var OverrideReason;
|
|
22
|
+
(function (OverrideReason) {
|
|
23
|
+
OverrideReason["FALSE_ALARM"] = "false_alarm";
|
|
24
|
+
OverrideReason["REVIEWED_FINE"] = "reviewed_fine";
|
|
25
|
+
OverrideReason["NEED_NOW"] = "need_now";
|
|
26
|
+
OverrideReason["OTHER"] = "other";
|
|
27
|
+
})(OverrideReason || (OverrideReason = {}));
|
|
28
|
+
export const AGGREGATE_ROW_KEYS = new Set(["verdict_hash", "action", "reason_class"]);
|
|
29
|
+
/** SHA-256 over the provenance reproduce-handle, hex-truncated to 16. Identifies
|
|
30
|
+
* the JUDGMENT (public contract), not the tool args. Port of `verdict_hash`. */
|
|
31
|
+
export function verdictHash(provenance) {
|
|
32
|
+
return createHash("sha256").update(provenance.reproduceHandle, "utf-8").digest("hex").slice(0, 16);
|
|
33
|
+
}
|
|
34
|
+
const MAX_EVENTS = 50_000;
|
|
35
|
+
// Retention window in days (mirrors Python `outcomes._RETENTION_DAYS`). The card reads a
|
|
36
|
+
// 30-day summary; we keep a generous trailing window so an offline replay over the recent
|
|
37
|
+
// past still has its events, then the hard `MAX_EVENTS` cap backstops a same-day burst.
|
|
38
|
+
const RETENTION_DAYS = 62;
|
|
39
|
+
const DAY_SECONDS = 86_400;
|
|
40
|
+
/** Best-effort ISO-8601 → epoch seconds for the retention window (port of Python
|
|
41
|
+
* `outcomes._parse_iso`). Tolerant of a trailing `Z`. Returns null on an unparseable
|
|
42
|
+
* stamp — kept in-window by the date prune (only the hard cap can evict it), never
|
|
43
|
+
* silently dropped. */
|
|
44
|
+
function parseIsoSeconds(s) {
|
|
45
|
+
const ms = Date.parse(s.replace(/Z$/, "+00:00"));
|
|
46
|
+
return Number.isNaN(ms) ? null : ms / 1000;
|
|
47
|
+
}
|
|
48
|
+
/** On-device append-only capture store; ZERO egress of detail. */
|
|
49
|
+
export class OutcomeStore {
|
|
50
|
+
now;
|
|
51
|
+
surfaces = new Map();
|
|
52
|
+
responses = [];
|
|
53
|
+
constructor(now = utcNowIso) {
|
|
54
|
+
this.now = now;
|
|
55
|
+
}
|
|
56
|
+
recordSurface(provenance, posture) {
|
|
57
|
+
const surfaceId = randomUUID().replace(/-/g, "");
|
|
58
|
+
this.surfaces.set(surfaceId, { surfaceId, at: this.now(), posture, provenance });
|
|
59
|
+
this.prune();
|
|
60
|
+
return surfaceId;
|
|
61
|
+
}
|
|
62
|
+
recordResponse(surfaceId, action, reason = null) {
|
|
63
|
+
this.responses.push({ surfaceId, at: this.now(), action, reason });
|
|
64
|
+
this.prune();
|
|
65
|
+
}
|
|
66
|
+
/** Bound the store so a long-lived session cannot grow it without limit (port of Python
|
|
67
|
+
* `OutcomeStore._prune_locked`). Two passes on the SURFACE store, both anchored on the
|
|
68
|
+
* LATEST surface timestamp so a deterministic test/replay does not depend on wall-clock
|
|
69
|
+
* now: (1) DATE-PRUNE drops surfaces older than `RETENTION_DAYS` (an unparseable stamp is
|
|
70
|
+
* KEPT — only the hard cap can evict it); (2) RING-BUFFER enforces the `MAX_EVENTS` cap,
|
|
71
|
+
* oldest-first. Responses linked to an evicted surface are then dropped (a response that
|
|
72
|
+
* can no longer be anonymize-linked carries no signal — `aggregateRows` would drop it
|
|
73
|
+
* anyway); the response list is independently hard-capped so a flood of externally-minted
|
|
74
|
+
* ids cannot grow the store either. */
|
|
75
|
+
prune() {
|
|
76
|
+
const keys = [...this.surfaces.keys()];
|
|
77
|
+
let keptIds = keys;
|
|
78
|
+
// (1) Date-prune, anchored on the latest parseable surface stamp.
|
|
79
|
+
const stamps = [];
|
|
80
|
+
for (const s of this.surfaces.values()) {
|
|
81
|
+
const t = parseIsoSeconds(s.at);
|
|
82
|
+
if (t !== null)
|
|
83
|
+
stamps.push(t);
|
|
84
|
+
}
|
|
85
|
+
if (stamps.length > 0) {
|
|
86
|
+
const cutoff = Math.max(...stamps) - RETENTION_DAYS * DAY_SECONDS;
|
|
87
|
+
keptIds = keys.filter((k) => {
|
|
88
|
+
const t = parseIsoSeconds(this.surfaces.get(k).at);
|
|
89
|
+
return t === null || t >= cutoff; // unparseable kept; only the hard cap evicts it
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
// (2) Ring-buffer hard cap (oldest-first; Map preserves insertion order).
|
|
93
|
+
if (keptIds.length > MAX_EVENTS) {
|
|
94
|
+
keptIds = keptIds.slice(-MAX_EVENTS);
|
|
95
|
+
}
|
|
96
|
+
if (keptIds.length !== this.surfaces.size) {
|
|
97
|
+
const keepSet = new Set(keptIds);
|
|
98
|
+
const evicted = new Set(keys.filter((k) => !keepSet.has(k)));
|
|
99
|
+
for (const k of evicted)
|
|
100
|
+
this.surfaces.delete(k);
|
|
101
|
+
// Drop ONLY responses linked to an evicted surface; a response against an
|
|
102
|
+
// externally-minted id never in-store is preserved (it was never evicted).
|
|
103
|
+
this.responses = this.responses.filter((r) => !evicted.has(r.surfaceId));
|
|
104
|
+
}
|
|
105
|
+
// (3) Independently hard-cap the response list (oldest-first).
|
|
106
|
+
if (this.responses.length > MAX_EVENTS) {
|
|
107
|
+
this.responses = this.responses.slice(-MAX_EVENTS);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
surfaceCount() {
|
|
111
|
+
return this.surfaces.size;
|
|
112
|
+
}
|
|
113
|
+
responseCount() {
|
|
114
|
+
return this.responses.length;
|
|
115
|
+
}
|
|
116
|
+
/** The ONLY projection that may ever leave the device. One row per response,
|
|
117
|
+
* `{verdict_hash, action, reason_class}` only; a response with no resolvable
|
|
118
|
+
* surface is DROPPED (fail-closed). Port of `aggregate_rows`. */
|
|
119
|
+
aggregateRows() {
|
|
120
|
+
const rows = [];
|
|
121
|
+
for (const r of this.responses) {
|
|
122
|
+
const surf = this.surfaces.get(r.surfaceId);
|
|
123
|
+
if (surf === undefined)
|
|
124
|
+
continue;
|
|
125
|
+
rows.push({
|
|
126
|
+
verdict_hash: verdictHash(surf.provenance),
|
|
127
|
+
action: r.action,
|
|
128
|
+
reason_class: r.reason !== null ? r.reason : "",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return rows;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** Local on-device counters — the analog of Python `LocalStats`, narrowed to what
|
|
135
|
+
* the wrapper records (gate calls + a 30-day HOLD tally for the banner). */
|
|
136
|
+
export class LocalStats {
|
|
137
|
+
holds = 0;
|
|
138
|
+
repins = 0;
|
|
139
|
+
overCap = 0;
|
|
140
|
+
recordHold() {
|
|
141
|
+
this.holds += 1;
|
|
142
|
+
}
|
|
143
|
+
recordRepin() {
|
|
144
|
+
this.repins += 1;
|
|
145
|
+
}
|
|
146
|
+
recordOverCap() {
|
|
147
|
+
this.overCap += 1;
|
|
148
|
+
}
|
|
149
|
+
holdsThisMonth() {
|
|
150
|
+
return this.holds;
|
|
151
|
+
}
|
|
152
|
+
repinCount() {
|
|
153
|
+
return this.repins;
|
|
154
|
+
}
|
|
155
|
+
overCapCount() {
|
|
156
|
+
return this.overCap;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=outcomes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcomes.js","sourceRoot":"","sources":["../../src/outcomes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,M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IACrB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pin store + verdict types — a port of the load-bearing primitives from Python
|
|
3
|
+
* `tooling/cse/preflight.py` (`PinnedTool`, `PreflightPin`, `Decision`,
|
|
4
|
+
* `PreflightVerdict`). The pin stores ONLY the public-contract hash (+ optional
|
|
5
|
+
* PUBLIC schema for diff detail) — NEVER a token, by construction.
|
|
6
|
+
*/
|
|
7
|
+
import { hashTool } from "./canonical.js";
|
|
8
|
+
import type { Change } from "./schemaDiff.js";
|
|
9
|
+
export type ToolDef = Record<string, unknown>;
|
|
10
|
+
export declare enum Decision {
|
|
11
|
+
PROCEED = "PROCEED",
|
|
12
|
+
HOLD = "HOLD",
|
|
13
|
+
INCONCLUSIVE = "INCONCLUSIVE"
|
|
14
|
+
}
|
|
15
|
+
export interface PinnedTool {
|
|
16
|
+
readonly serverId: string;
|
|
17
|
+
readonly toolName: string;
|
|
18
|
+
readonly definitionHash: string;
|
|
19
|
+
readonly pinnedAt: string;
|
|
20
|
+
readonly schema: ToolDef | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function utcNowIso(): string;
|
|
23
|
+
/** A structured, honest pre-flight result. A verdict is a CONTRACT DIFF, never a
|
|
24
|
+
* "this is unsafe" claim (AD-6). Mirrors `PreflightVerdict`. */
|
|
25
|
+
export interface PreflightVerdict {
|
|
26
|
+
readonly serverId: string;
|
|
27
|
+
readonly toolName: string;
|
|
28
|
+
readonly decision: Decision;
|
|
29
|
+
readonly reason: string;
|
|
30
|
+
readonly drift: readonly Change[];
|
|
31
|
+
readonly failOpenWarning: boolean;
|
|
32
|
+
readonly isContractDiff: boolean;
|
|
33
|
+
readonly descBefore: string | null;
|
|
34
|
+
readonly descAfter: string | null;
|
|
35
|
+
}
|
|
36
|
+
export declare function makeVerdict(v: Pick<PreflightVerdict, "serverId" | "toolName" | "decision" | "reason"> & Partial<PreflightVerdict>): PreflightVerdict;
|
|
37
|
+
export declare function isProceed(v: PreflightVerdict): boolean;
|
|
38
|
+
export declare function safetyRelevantDrift(v: PreflightVerdict): Change[];
|
|
39
|
+
/** A human one-liner, render-safe (attacker-derived ids/detail escaped). Honest
|
|
40
|
+
* voice: no safe/verified/clean/pass words. Port of `PreflightVerdict.render`. */
|
|
41
|
+
export declare function renderVerdict(v: PreflightVerdict): string;
|
|
42
|
+
/** In-memory pin store (the TS port keeps it in-memory: the SDK wrapper pins a
|
|
43
|
+
* live session; durable JSON persistence is out of scope for the wrapper). Keyed
|
|
44
|
+
* by `(serverId, toolName)`. Stores ONLY hashes (+ optional PUBLIC schema). */
|
|
45
|
+
export declare class PreflightPin {
|
|
46
|
+
private readonly index;
|
|
47
|
+
private key;
|
|
48
|
+
get(serverId: string, toolName: string): PinnedTool | null;
|
|
49
|
+
put(pin: PinnedTool): void;
|
|
50
|
+
toolsFor(serverId: string): PinnedTool[];
|
|
51
|
+
allPins(): PinnedTool[];
|
|
52
|
+
}
|
|
53
|
+
export { hashTool };
|
|
54
|
+
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/preflight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE9C,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,YAAY,iBAAiB;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CA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IACD,OAAO,QAAQ,GAAG,IAAI,IAAI,MAAM,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AACrD,CAAC;AAED;;+EAE+E;AAC/E,MAAM,OAAO,YAAY;IACN,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE/C,GAAG,CAAC,QAAgB,EAAE,QAAgB;QAC5C,OAAO,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,QAAgB,EAAE,QAAgB;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,IAAI,IAAI,CAAC;IAC9D,CAAC;IAED,GAAG,CAAC,GAAe;QACjB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC;IAED,QAAQ,CAAC,QAAgB;QACvB,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IACzE,CAAC;IAED,OAAO;QACL,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAClC,CAAC;CACF;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provenance — the immutable record attached to EVERY surfaced finding, and the
|
|
3
|
+
* load-bearing `requireProvenance` choke. A port of Python
|
|
4
|
+
* `tooling/cse/provenance.py` + `guardrails.require_provenance`. NOTHING surfaces
|
|
5
|
+
* without a COMPLETE provenance record (the over-claim guard, fail-closed).
|
|
6
|
+
*/
|
|
7
|
+
import { Decision } from "./preflight.js";
|
|
8
|
+
import type { PreflightVerdict, ToolDef } from "./preflight.js";
|
|
9
|
+
import { ChangeKind } from "./schemaDiff.js";
|
|
10
|
+
export declare enum VerdictScope {
|
|
11
|
+
STRUCTURAL_ONLY = "structural_only",
|
|
12
|
+
SEMANTIC_ONLY = "semantic_only",
|
|
13
|
+
BEHAVIORAL = "behavioral"
|
|
14
|
+
}
|
|
15
|
+
export declare enum HonestFraming {
|
|
16
|
+
CONTRACT_DIFF_NOT_SAFETY = "contract-diff not a safety verdict",
|
|
17
|
+
BEHAVIORAL_NEEDED = "static inconclusive; behavioral validation needed",
|
|
18
|
+
VISIBILITY_NOT_BLAME = "consumer-visibility not maintainer-blame",
|
|
19
|
+
HEALTHY = ""
|
|
20
|
+
}
|
|
21
|
+
export interface Subject {
|
|
22
|
+
readonly serverId: string;
|
|
23
|
+
readonly tool: string;
|
|
24
|
+
readonly definitionHashOld: string | null;
|
|
25
|
+
readonly definitionHashNew: string | null;
|
|
26
|
+
readonly capturedAt: string;
|
|
27
|
+
readonly source: string;
|
|
28
|
+
}
|
|
29
|
+
export interface WhatFired {
|
|
30
|
+
readonly changeKinds: readonly ChangeKind[];
|
|
31
|
+
readonly classifierId: string;
|
|
32
|
+
readonly tierReached: number;
|
|
33
|
+
readonly verdict: Decision;
|
|
34
|
+
readonly verdictScope: VerdictScope;
|
|
35
|
+
}
|
|
36
|
+
export interface EvidenceField {
|
|
37
|
+
readonly path: string;
|
|
38
|
+
readonly kind: ChangeKind;
|
|
39
|
+
readonly before: string | null;
|
|
40
|
+
readonly after: string | null;
|
|
41
|
+
}
|
|
42
|
+
export interface Provenance {
|
|
43
|
+
readonly subject: Subject;
|
|
44
|
+
readonly whatFired: WhatFired;
|
|
45
|
+
readonly evidence: readonly EvidenceField[];
|
|
46
|
+
readonly honestFraming: HonestFraming;
|
|
47
|
+
readonly reproduceHandle: string;
|
|
48
|
+
}
|
|
49
|
+
/** The completeness predicate the load-bearing choke gates on (port of
|
|
50
|
+
* `Provenance.is_complete`). Each string field is trimmed before the check, so a
|
|
51
|
+
* whitespace-only value is rejected as empty. Evidence MAY be empty. */
|
|
52
|
+
export declare function isComplete(p: Provenance): boolean;
|
|
53
|
+
/** Render-safe one-line summary (does NOT emit raw evidence values). */
|
|
54
|
+
export declare function renderProvenance(p: Provenance): string;
|
|
55
|
+
export declare function provenanceAsDict(p: Provenance): Record<string, unknown>;
|
|
56
|
+
/** Build a COMPLETE Provenance from a verdict + the contracts that produced it.
|
|
57
|
+
* Port of `provenance.from_verdict`. */
|
|
58
|
+
export declare function fromVerdict(verdict: PreflightVerdict, opts: {
|
|
59
|
+
serverId: string;
|
|
60
|
+
tool: string;
|
|
61
|
+
oldSchema: ToolDef | null;
|
|
62
|
+
newSchema: ToolDef | null;
|
|
63
|
+
tierReached: number;
|
|
64
|
+
classifierId?: string;
|
|
65
|
+
source?: string;
|
|
66
|
+
capturedAt?: string;
|
|
67
|
+
}): Provenance;
|
|
68
|
+
export declare class GuardrailError extends Error {
|
|
69
|
+
}
|
|
70
|
+
/** THE choke every surface path passes through. Returns the COMPLETE Provenance,
|
|
71
|
+
* or THROWS `GuardrailError` (fail-closed -> nothing surfaces). Port of
|
|
72
|
+
* `guardrails.require_provenance`. */
|
|
73
|
+
export declare function requireProvenance(prov: Provenance | null | undefined): Provenance;
|
|
74
|
+
/** Build provenance for a USER-FACING surface and run it through the choke.
|
|
75
|
+
* Returns the COMPLETE record, or null when it cannot be built / the choke
|
|
76
|
+
* refuses (fail-closed). Port of `provenance.surface_provenance`. */
|
|
77
|
+
export declare function surfaceProvenance(verdict: PreflightVerdict, opts: {
|
|
78
|
+
serverId: string;
|
|
79
|
+
tool: string;
|
|
80
|
+
oldSchema: ToolDef | null;
|
|
81
|
+
newSchema: ToolDef | null;
|
|
82
|
+
tierReached: number;
|
|
83
|
+
source: string;
|
|
84
|
+
}): Provenance | null;
|
|
85
|
+
/** Fail-closed honest-voice check: throw if a consumer string uses a banned
|
|
86
|
+
* green word. Port of `guardrails.assert_no_green_words`. */
|
|
87
|
+
export declare function assertNoGreenWords(text: string): void;
|
|
88
|
+
/** Replace every banned green word in a consumer-facing string with a neutral
|
|
89
|
+
* placeholder, so an ATTACKER-DERIVED token (a tool name interpolated into a HOLD
|
|
90
|
+
* banner) cannot surface banned reassurance verbatim (M3). Whole-word,
|
|
91
|
+
* case-insensitive — reuses the SAME word-list as `assertNoGreenWords`, so the two
|
|
92
|
+
* can never disagree. The output passes `assertNoGreenWords`. Port of
|
|
93
|
+
* `gate.redact_green_words`. */
|
|
94
|
+
export declare function redactGreenWords(text: string): string;
|
|
95
|
+
//# sourceMappingURL=provenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provenance.d.ts","sourceRoot":"","sources":["../../src/provenance.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,oBAAY,YAAY;IACtB,eAAe,oBAAoB;IACnC,aAAa,kBAAkB;IAC/B,UAAU,eAAe;CAC1B;AAED,oBAAY,aAAa;IACvB,wBAAwB,uCAAuC;IAC/D,iBAAiB,sDAAsD;IACvE,oBAAoB,6CAA6C;IACjE,OAAO,KAAK;CACb;AAUD,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB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