@sanctuary-framework/mcp-server 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +2072 -51
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2073 -53
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +2043 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +262 -1
- package/dist/index.d.ts +262 -1
- package/dist/index.js +2036 -88
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var hmac = require('@noble/hashes/hmac');
|
|
|
5
5
|
var promises = require('fs/promises');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var os = require('os');
|
|
8
|
+
var module$1 = require('module');
|
|
8
9
|
var crypto = require('crypto');
|
|
9
10
|
var aes_js = require('@noble/ciphers/aes.js');
|
|
10
11
|
var ed25519 = require('@noble/curves/ed25519');
|
|
@@ -15,7 +16,9 @@ var types_js = require('@modelcontextprotocol/sdk/types.js');
|
|
|
15
16
|
var http = require('http');
|
|
16
17
|
var https = require('https');
|
|
17
18
|
var fs = require('fs');
|
|
19
|
+
var child_process = require('child_process');
|
|
18
20
|
|
|
21
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
19
22
|
var __defProp = Object.defineProperty;
|
|
20
23
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
21
24
|
var __esm = (fn, res) => function __init() {
|
|
@@ -204,9 +207,11 @@ var init_hashing = __esm({
|
|
|
204
207
|
init_encoding();
|
|
205
208
|
}
|
|
206
209
|
});
|
|
210
|
+
var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
211
|
+
var { version: PKG_VERSION } = require2("../package.json");
|
|
207
212
|
function defaultConfig() {
|
|
208
213
|
return {
|
|
209
|
-
version:
|
|
214
|
+
version: PKG_VERSION,
|
|
210
215
|
storage_path: path.join(os.homedir(), ".sanctuary"),
|
|
211
216
|
state: {
|
|
212
217
|
encryption: "aes-256-gcm",
|
|
@@ -332,6 +337,18 @@ function validateConfig(config) {
|
|
|
332
337
|
`Unimplemented config value: disclosure.proof_system = "${config.disclosure.proof_system}". Only ${[...implementedProofSystem].map((v) => `"${v}"`).join(", ")} is currently implemented. Using an unimplemented proof system would silently degrade security.`
|
|
333
338
|
);
|
|
334
339
|
}
|
|
340
|
+
const implementedDisclosurePolicy = /* @__PURE__ */ new Set(["minimum-necessary"]);
|
|
341
|
+
if (!implementedDisclosurePolicy.has(config.disclosure.default_policy)) {
|
|
342
|
+
errors.push(
|
|
343
|
+
`Unimplemented config value: disclosure.default_policy = "${config.disclosure.default_policy}". Only ${[...implementedDisclosurePolicy].map((v) => `"${v}"`).join(", ")} is currently implemented. Using an unimplemented disclosure policy would silently skip disclosure controls.`
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
const implementedReputationMode = /* @__PURE__ */ new Set(["self-custodied"]);
|
|
347
|
+
if (!implementedReputationMode.has(config.reputation.mode)) {
|
|
348
|
+
errors.push(
|
|
349
|
+
`Unimplemented config value: reputation.mode = "${config.reputation.mode}". Only ${[...implementedReputationMode].map((v) => `"${v}"`).join(", ")} is currently implemented. Using an unimplemented reputation mode would silently skip reputation verification.`
|
|
350
|
+
);
|
|
351
|
+
}
|
|
335
352
|
if (errors.length > 0) {
|
|
336
353
|
throw new Error(
|
|
337
354
|
`Sanctuary configuration references unimplemented features:
|
|
@@ -1037,6 +1054,8 @@ var StateStore = class {
|
|
|
1037
1054
|
};
|
|
1038
1055
|
}
|
|
1039
1056
|
};
|
|
1057
|
+
var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
1058
|
+
var { version: PKG_VERSION2 } = require3("../package.json");
|
|
1040
1059
|
var MAX_STRING_BYTES = 1048576;
|
|
1041
1060
|
var MAX_BUNDLE_BYTES = 5242880;
|
|
1042
1061
|
var BUNDLE_FIELDS = /* @__PURE__ */ new Set(["bundle"]);
|
|
@@ -1119,7 +1138,7 @@ function createServer(tools, options) {
|
|
|
1119
1138
|
const server = new index_js.Server(
|
|
1120
1139
|
{
|
|
1121
1140
|
name: "sanctuary-mcp-server",
|
|
1122
|
-
version:
|
|
1141
|
+
version: PKG_VERSION2
|
|
1123
1142
|
},
|
|
1124
1143
|
{
|
|
1125
1144
|
capabilities: {
|
|
@@ -3573,7 +3592,9 @@ var DEFAULT_POLICY = {
|
|
|
3573
3592
|
"state_delete",
|
|
3574
3593
|
"identity_rotate",
|
|
3575
3594
|
"reputation_import",
|
|
3576
|
-
"
|
|
3595
|
+
"reputation_export",
|
|
3596
|
+
"bootstrap_provide_guarantee",
|
|
3597
|
+
"decommission_certificate"
|
|
3577
3598
|
],
|
|
3578
3599
|
tier2_anomaly: DEFAULT_TIER2,
|
|
3579
3600
|
tier3_always_allow: [
|
|
@@ -3590,7 +3611,6 @@ var DEFAULT_POLICY = {
|
|
|
3590
3611
|
"disclosure_evaluate",
|
|
3591
3612
|
"reputation_record",
|
|
3592
3613
|
"reputation_query",
|
|
3593
|
-
"reputation_export",
|
|
3594
3614
|
"bootstrap_create_escrow",
|
|
3595
3615
|
"exec_attest",
|
|
3596
3616
|
"monitor_health",
|
|
@@ -3612,7 +3632,14 @@ var DEFAULT_POLICY = {
|
|
|
3612
3632
|
"zk_prove",
|
|
3613
3633
|
"zk_verify",
|
|
3614
3634
|
"zk_range_prove",
|
|
3615
|
-
"zk_range_verify"
|
|
3635
|
+
"zk_range_verify",
|
|
3636
|
+
"context_gate_set_policy",
|
|
3637
|
+
"context_gate_apply_template",
|
|
3638
|
+
"context_gate_recommend",
|
|
3639
|
+
"context_gate_filter",
|
|
3640
|
+
"context_gate_list_policies",
|
|
3641
|
+
"l2_hardening_status",
|
|
3642
|
+
"l2_verify_isolation"
|
|
3616
3643
|
],
|
|
3617
3644
|
approval_channel: DEFAULT_CHANNEL
|
|
3618
3645
|
};
|
|
@@ -3714,6 +3741,7 @@ tier1_always_approve:
|
|
|
3714
3741
|
- state_delete
|
|
3715
3742
|
- identity_rotate
|
|
3716
3743
|
- reputation_import
|
|
3744
|
+
- reputation_export
|
|
3717
3745
|
- bootstrap_provide_guarantee
|
|
3718
3746
|
|
|
3719
3747
|
# \u2500\u2500\u2500 Tier 2: Behavioral Anomaly Detection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -3743,7 +3771,6 @@ tier3_always_allow:
|
|
|
3743
3771
|
- disclosure_evaluate
|
|
3744
3772
|
- reputation_record
|
|
3745
3773
|
- reputation_query
|
|
3746
|
-
- reputation_export
|
|
3747
3774
|
- bootstrap_create_escrow
|
|
3748
3775
|
- exec_attest
|
|
3749
3776
|
- monitor_health
|
|
@@ -3766,6 +3793,11 @@ tier3_always_allow:
|
|
|
3766
3793
|
- zk_verify
|
|
3767
3794
|
- zk_range_prove
|
|
3768
3795
|
- zk_range_verify
|
|
3796
|
+
- context_gate_set_policy
|
|
3797
|
+
- context_gate_apply_template
|
|
3798
|
+
- context_gate_recommend
|
|
3799
|
+
- context_gate_filter
|
|
3800
|
+
- context_gate_list_policies
|
|
3769
3801
|
|
|
3770
3802
|
# \u2500\u2500\u2500 Approval Channel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
3771
3803
|
# How Sanctuary reaches you when approval is needed.
|
|
@@ -4560,8 +4592,14 @@ function generateDashboardHTML(options) {
|
|
|
4560
4592
|
}
|
|
4561
4593
|
|
|
4562
4594
|
// src/principal-policy/dashboard.ts
|
|
4595
|
+
var require4 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
4596
|
+
var { version: PKG_VERSION3 } = require4("../../package.json");
|
|
4563
4597
|
var SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
4564
4598
|
var MAX_SESSIONS = 1e3;
|
|
4599
|
+
var RATE_LIMIT_WINDOW_MS = 6e4;
|
|
4600
|
+
var RATE_LIMIT_GENERAL = 120;
|
|
4601
|
+
var RATE_LIMIT_DECISIONS = 20;
|
|
4602
|
+
var MAX_RATE_LIMIT_ENTRIES = 1e4;
|
|
4565
4603
|
var DashboardApprovalChannel = class {
|
|
4566
4604
|
config;
|
|
4567
4605
|
pending = /* @__PURE__ */ new Map();
|
|
@@ -4576,13 +4614,15 @@ var DashboardApprovalChannel = class {
|
|
|
4576
4614
|
/** SEC-012: Short-lived session store. Sessions replace URL query tokens. */
|
|
4577
4615
|
sessions = /* @__PURE__ */ new Map();
|
|
4578
4616
|
sessionCleanupTimer = null;
|
|
4617
|
+
/** Rate limiting: per-IP request tracking */
|
|
4618
|
+
rateLimits = /* @__PURE__ */ new Map();
|
|
4579
4619
|
constructor(config) {
|
|
4580
4620
|
this.config = config;
|
|
4581
4621
|
this.authToken = config.auth_token;
|
|
4582
4622
|
this.useTLS = !!(config.tls?.cert_path && config.tls?.key_path);
|
|
4583
4623
|
this.dashboardHTML = generateDashboardHTML({
|
|
4584
4624
|
timeoutSeconds: config.timeout_seconds,
|
|
4585
|
-
serverVersion:
|
|
4625
|
+
serverVersion: PKG_VERSION3,
|
|
4586
4626
|
authToken: this.authToken
|
|
4587
4627
|
});
|
|
4588
4628
|
this.sessionCleanupTimer = setInterval(() => this.cleanupSessions(), 6e4);
|
|
@@ -4661,6 +4701,7 @@ var DashboardApprovalChannel = class {
|
|
|
4661
4701
|
clearInterval(this.sessionCleanupTimer);
|
|
4662
4702
|
this.sessionCleanupTimer = null;
|
|
4663
4703
|
}
|
|
4704
|
+
this.rateLimits.clear();
|
|
4664
4705
|
if (this.httpServer) {
|
|
4665
4706
|
return new Promise((resolve) => {
|
|
4666
4707
|
this.httpServer.close(() => resolve());
|
|
@@ -4786,6 +4827,61 @@ var DashboardApprovalChannel = class {
|
|
|
4786
4827
|
}
|
|
4787
4828
|
}
|
|
4788
4829
|
}
|
|
4830
|
+
// ── Rate Limiting ─────────────────────────────────────────────────
|
|
4831
|
+
/**
|
|
4832
|
+
* Get the remote address from a request, normalizing IPv6-mapped IPv4.
|
|
4833
|
+
*/
|
|
4834
|
+
getRemoteAddr(req) {
|
|
4835
|
+
const addr = req.socket.remoteAddress ?? "unknown";
|
|
4836
|
+
return addr.startsWith("::ffff:") ? addr.slice(7) : addr;
|
|
4837
|
+
}
|
|
4838
|
+
/**
|
|
4839
|
+
* Check rate limit for a request. Returns true if allowed, false if rate-limited.
|
|
4840
|
+
* When rate-limited, sends a 429 response.
|
|
4841
|
+
*/
|
|
4842
|
+
checkRateLimit(req, res, type) {
|
|
4843
|
+
const addr = this.getRemoteAddr(req);
|
|
4844
|
+
const now = Date.now();
|
|
4845
|
+
const windowStart = now - RATE_LIMIT_WINDOW_MS;
|
|
4846
|
+
let entry = this.rateLimits.get(addr);
|
|
4847
|
+
if (!entry) {
|
|
4848
|
+
if (this.rateLimits.size >= MAX_RATE_LIMIT_ENTRIES) {
|
|
4849
|
+
this.pruneRateLimits(now);
|
|
4850
|
+
}
|
|
4851
|
+
entry = { general: [], decisions: [] };
|
|
4852
|
+
this.rateLimits.set(addr, entry);
|
|
4853
|
+
}
|
|
4854
|
+
entry.general = entry.general.filter((t) => t > windowStart);
|
|
4855
|
+
entry.decisions = entry.decisions.filter((t) => t > windowStart);
|
|
4856
|
+
const limit = type === "decisions" ? RATE_LIMIT_DECISIONS : RATE_LIMIT_GENERAL;
|
|
4857
|
+
const timestamps = entry[type];
|
|
4858
|
+
if (timestamps.length >= limit) {
|
|
4859
|
+
const retryAfter = Math.ceil((timestamps[0] + RATE_LIMIT_WINDOW_MS - now) / 1e3);
|
|
4860
|
+
res.writeHead(429, {
|
|
4861
|
+
"Content-Type": "application/json",
|
|
4862
|
+
"Retry-After": String(Math.max(1, retryAfter))
|
|
4863
|
+
});
|
|
4864
|
+
res.end(JSON.stringify({
|
|
4865
|
+
error: "Rate limit exceeded",
|
|
4866
|
+
retry_after_seconds: Math.max(1, retryAfter)
|
|
4867
|
+
}));
|
|
4868
|
+
return false;
|
|
4869
|
+
}
|
|
4870
|
+
timestamps.push(now);
|
|
4871
|
+
return true;
|
|
4872
|
+
}
|
|
4873
|
+
/**
|
|
4874
|
+
* Remove stale entries from the rate limit map.
|
|
4875
|
+
*/
|
|
4876
|
+
pruneRateLimits(now) {
|
|
4877
|
+
const windowStart = now - RATE_LIMIT_WINDOW_MS;
|
|
4878
|
+
for (const [addr, entry] of this.rateLimits) {
|
|
4879
|
+
const hasRecent = entry.general.some((t) => t > windowStart) || entry.decisions.some((t) => t > windowStart);
|
|
4880
|
+
if (!hasRecent) {
|
|
4881
|
+
this.rateLimits.delete(addr);
|
|
4882
|
+
}
|
|
4883
|
+
}
|
|
4884
|
+
}
|
|
4789
4885
|
// ── HTTP Request Handler ────────────────────────────────────────────
|
|
4790
4886
|
handleRequest(req, res) {
|
|
4791
4887
|
const url = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
|
|
@@ -4804,6 +4900,7 @@ var DashboardApprovalChannel = class {
|
|
|
4804
4900
|
return;
|
|
4805
4901
|
}
|
|
4806
4902
|
if (!this.checkAuth(req, url, res)) return;
|
|
4903
|
+
if (!this.checkRateLimit(req, res, "general")) return;
|
|
4807
4904
|
try {
|
|
4808
4905
|
if (method === "POST" && url.pathname === "/auth/session") {
|
|
4809
4906
|
this.handleSessionExchange(req, res);
|
|
@@ -4820,9 +4917,11 @@ var DashboardApprovalChannel = class {
|
|
|
4820
4917
|
} else if (method === "GET" && url.pathname === "/api/audit-log") {
|
|
4821
4918
|
this.handleAuditLog(url, res);
|
|
4822
4919
|
} else if (method === "POST" && url.pathname.startsWith("/api/approve/")) {
|
|
4920
|
+
if (!this.checkRateLimit(req, res, "decisions")) return;
|
|
4823
4921
|
const id = url.pathname.slice("/api/approve/".length);
|
|
4824
4922
|
this.handleDecision(id, "approve", res);
|
|
4825
4923
|
} else if (method === "POST" && url.pathname.startsWith("/api/deny/")) {
|
|
4924
|
+
if (!this.checkRateLimit(req, res, "decisions")) return;
|
|
4826
4925
|
const id = url.pathname.slice("/api/deny/".length);
|
|
4827
4926
|
this.handleDecision(id, "deny", res);
|
|
4828
4927
|
} else {
|
|
@@ -5565,14 +5664,14 @@ function generateSHR(identityId, opts) {
|
|
|
5565
5664
|
code: "PROCESS_ISOLATION_ONLY",
|
|
5566
5665
|
severity: "warning",
|
|
5567
5666
|
description: "Process-level isolation only (no TEE)",
|
|
5568
|
-
mitigation: "TEE support planned for
|
|
5667
|
+
mitigation: "TEE support planned for a future release"
|
|
5569
5668
|
});
|
|
5570
5669
|
degradations.push({
|
|
5571
5670
|
layer: "l2",
|
|
5572
5671
|
code: "SELF_REPORTED_ATTESTATION",
|
|
5573
5672
|
severity: "warning",
|
|
5574
5673
|
description: "Attestation is self-reported (no hardware root of trust)",
|
|
5575
|
-
mitigation: "TEE attestation planned for
|
|
5674
|
+
mitigation: "TEE attestation planned for a future release"
|
|
5576
5675
|
});
|
|
5577
5676
|
}
|
|
5578
5677
|
if (config.disclosure.proof_system === "commitment-only") {
|
|
@@ -5716,6 +5815,245 @@ function assessSovereigntyLevel(body) {
|
|
|
5716
5815
|
return "minimal";
|
|
5717
5816
|
}
|
|
5718
5817
|
|
|
5818
|
+
// src/shr/gateway-adapter.ts
|
|
5819
|
+
var LAYER_WEIGHTS = {
|
|
5820
|
+
l1: 100,
|
|
5821
|
+
l2: 100,
|
|
5822
|
+
l3: 100,
|
|
5823
|
+
l4: 100
|
|
5824
|
+
};
|
|
5825
|
+
var DEGRADATION_IMPACT = {
|
|
5826
|
+
critical: 40,
|
|
5827
|
+
warning: 25,
|
|
5828
|
+
info: 10
|
|
5829
|
+
};
|
|
5830
|
+
function transformSHRForGateway(shr) {
|
|
5831
|
+
const { body, signed_by, signature } = shr;
|
|
5832
|
+
const layerScores = calculateLayerScores(body);
|
|
5833
|
+
const overallScore = calculateOverallScore(layerScores);
|
|
5834
|
+
const trustLevel = determineTrustLevel(overallScore);
|
|
5835
|
+
const signals = extractAuthorizationSignals(body);
|
|
5836
|
+
const degradations = transformDegradations(body.degradations);
|
|
5837
|
+
const constraints = generateAuthorizationConstraints(body);
|
|
5838
|
+
return {
|
|
5839
|
+
shr_version: body.shr_version,
|
|
5840
|
+
agent_identity: signed_by,
|
|
5841
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5842
|
+
context_expires_at: body.expires_at,
|
|
5843
|
+
overall_score: overallScore,
|
|
5844
|
+
recommended_trust_level: trustLevel,
|
|
5845
|
+
layer_scores: {
|
|
5846
|
+
l1_cognitive: layerScores.l1,
|
|
5847
|
+
l2_operational: layerScores.l2,
|
|
5848
|
+
l3_disclosure: layerScores.l3,
|
|
5849
|
+
l4_reputation: layerScores.l4
|
|
5850
|
+
},
|
|
5851
|
+
layer_status: {
|
|
5852
|
+
l1_cognitive: body.layers.l1.status,
|
|
5853
|
+
l2_operational: body.layers.l2.status,
|
|
5854
|
+
l3_disclosure: body.layers.l3.status,
|
|
5855
|
+
l4_reputation: body.layers.l4.status
|
|
5856
|
+
},
|
|
5857
|
+
authorization_signals: signals,
|
|
5858
|
+
degradations,
|
|
5859
|
+
recommended_constraints: constraints,
|
|
5860
|
+
shr_signature: signature,
|
|
5861
|
+
shr_signed_by: signed_by
|
|
5862
|
+
};
|
|
5863
|
+
}
|
|
5864
|
+
function calculateLayerScores(body) {
|
|
5865
|
+
const layers = body.layers;
|
|
5866
|
+
const degradations = body.degradations;
|
|
5867
|
+
let l1Score = LAYER_WEIGHTS.l1;
|
|
5868
|
+
let l2Score = LAYER_WEIGHTS.l2;
|
|
5869
|
+
let l3Score = LAYER_WEIGHTS.l3;
|
|
5870
|
+
let l4Score = LAYER_WEIGHTS.l4;
|
|
5871
|
+
for (const deg of degradations) {
|
|
5872
|
+
const impact = DEGRADATION_IMPACT[deg.severity] || 10;
|
|
5873
|
+
if (deg.layer === "l1") {
|
|
5874
|
+
l1Score = Math.max(0, l1Score - impact);
|
|
5875
|
+
} else if (deg.layer === "l2") {
|
|
5876
|
+
l2Score = Math.max(0, l2Score - impact);
|
|
5877
|
+
} else if (deg.layer === "l3") {
|
|
5878
|
+
l3Score = Math.max(0, l3Score - impact);
|
|
5879
|
+
} else if (deg.layer === "l4") {
|
|
5880
|
+
l4Score = Math.max(0, l4Score - impact);
|
|
5881
|
+
}
|
|
5882
|
+
}
|
|
5883
|
+
if (layers.l1.status === "active" && l1Score > 50) l1Score = Math.min(100, l1Score + 5);
|
|
5884
|
+
if (layers.l2.status === "active" && l2Score > 50) l2Score = Math.min(100, l2Score + 5);
|
|
5885
|
+
if (layers.l3.status === "active" && l3Score > 50) l3Score = Math.min(100, l3Score + 5);
|
|
5886
|
+
if (layers.l4.status === "active" && l4Score > 50) l4Score = Math.min(100, l4Score + 5);
|
|
5887
|
+
if (layers.l1.status === "inactive") l1Score = 0;
|
|
5888
|
+
if (layers.l2.status === "inactive") l2Score = 0;
|
|
5889
|
+
if (layers.l3.status === "inactive") l3Score = 0;
|
|
5890
|
+
if (layers.l4.status === "inactive") l4Score = 0;
|
|
5891
|
+
return {
|
|
5892
|
+
l1: Math.round(l1Score),
|
|
5893
|
+
l2: Math.round(l2Score),
|
|
5894
|
+
l3: Math.round(l3Score),
|
|
5895
|
+
l4: Math.round(l4Score)
|
|
5896
|
+
};
|
|
5897
|
+
}
|
|
5898
|
+
function calculateOverallScore(layerScores) {
|
|
5899
|
+
const average = (layerScores.l1 + layerScores.l2 + layerScores.l3 + layerScores.l4) / 4;
|
|
5900
|
+
return Math.round(average);
|
|
5901
|
+
}
|
|
5902
|
+
function determineTrustLevel(score) {
|
|
5903
|
+
if (score >= 80) return "full";
|
|
5904
|
+
if (score >= 60) return "elevated";
|
|
5905
|
+
if (score >= 40) return "standard";
|
|
5906
|
+
return "restricted";
|
|
5907
|
+
}
|
|
5908
|
+
function extractAuthorizationSignals(body) {
|
|
5909
|
+
const l1 = body.layers.l1;
|
|
5910
|
+
const l3 = body.layers.l3;
|
|
5911
|
+
const l4 = body.layers.l4;
|
|
5912
|
+
return {
|
|
5913
|
+
approval_gate_active: body.capabilities.handshake,
|
|
5914
|
+
// Handshake implies human loop capability
|
|
5915
|
+
context_gating_active: body.capabilities.encrypted_channel,
|
|
5916
|
+
// Proxy for gating capability
|
|
5917
|
+
encryption_at_rest: l1.encryption !== "none" && l1.encryption !== "unencrypted",
|
|
5918
|
+
behavioral_baseline_active: false,
|
|
5919
|
+
// Would need explicit field in SHR v1.1
|
|
5920
|
+
identity_verified: l1.identity_type === "ed25519" || l1.identity_type !== "none",
|
|
5921
|
+
zero_knowledge_capable: l3.status === "active" && l3.proof_system !== "commitment-only",
|
|
5922
|
+
selective_disclosure_active: l3.selective_disclosure,
|
|
5923
|
+
reputation_portable: l4.reputation_portable,
|
|
5924
|
+
handshake_capable: body.capabilities.handshake
|
|
5925
|
+
};
|
|
5926
|
+
}
|
|
5927
|
+
function transformDegradations(degradations) {
|
|
5928
|
+
return degradations.map((deg) => {
|
|
5929
|
+
let authzImpact = "";
|
|
5930
|
+
if (deg.code === "NO_TEE") {
|
|
5931
|
+
authzImpact = "Restricted to read-only operations until TEE available";
|
|
5932
|
+
} else if (deg.code === "PROCESS_ISOLATION_ONLY") {
|
|
5933
|
+
authzImpact = "Requires additional identity verification";
|
|
5934
|
+
} else if (deg.code === "COMMITMENT_ONLY") {
|
|
5935
|
+
authzImpact = "Limited data sharing scope \u2014 no zero-knowledge proofs";
|
|
5936
|
+
} else if (deg.code === "NO_ZK_PROOFS") {
|
|
5937
|
+
authzImpact = "Cannot perform confidential disclosures";
|
|
5938
|
+
} else if (deg.code === "SELF_REPORTED_ATTESTATION") {
|
|
5939
|
+
authzImpact = "Attestation trust degraded \u2014 human verification recommended";
|
|
5940
|
+
} else if (deg.code === "NO_SELECTIVE_DISCLOSURE") {
|
|
5941
|
+
authzImpact = "Must share entire data context, cannot redact";
|
|
5942
|
+
} else if (deg.code === "BASIC_SYBIL_ONLY") {
|
|
5943
|
+
authzImpact = "Restrict to interactions with known agents only";
|
|
5944
|
+
} else {
|
|
5945
|
+
authzImpact = "Unknown authorization impact";
|
|
5946
|
+
}
|
|
5947
|
+
return {
|
|
5948
|
+
layer: deg.layer,
|
|
5949
|
+
code: deg.code,
|
|
5950
|
+
severity: deg.severity,
|
|
5951
|
+
description: deg.description,
|
|
5952
|
+
authorization_impact: authzImpact
|
|
5953
|
+
};
|
|
5954
|
+
});
|
|
5955
|
+
}
|
|
5956
|
+
function generateAuthorizationConstraints(body, _degradations) {
|
|
5957
|
+
const constraints = [];
|
|
5958
|
+
const layers = body.layers;
|
|
5959
|
+
if (layers.l1.status === "degraded" || layers.l1.key_custody !== "self") {
|
|
5960
|
+
constraints.push({
|
|
5961
|
+
type: "identity_verification_required",
|
|
5962
|
+
description: "Additional identity verification required for sensitive operations",
|
|
5963
|
+
rationale: "L1 is degraded or key custody is not self-managed",
|
|
5964
|
+
priority: "high"
|
|
5965
|
+
});
|
|
5966
|
+
}
|
|
5967
|
+
if (!layers.l1.state_portable) {
|
|
5968
|
+
constraints.push({
|
|
5969
|
+
type: "location_bound",
|
|
5970
|
+
description: "Agent state is not portable \u2014 restrict to home environment",
|
|
5971
|
+
rationale: "State cannot be safely migrated across boundaries",
|
|
5972
|
+
priority: "medium"
|
|
5973
|
+
});
|
|
5974
|
+
}
|
|
5975
|
+
if (layers.l2.status === "degraded" || layers.l2.isolation_type === "local-process") {
|
|
5976
|
+
constraints.push({
|
|
5977
|
+
type: "read_only",
|
|
5978
|
+
description: "Restrict to read-only operations until operational isolation improves",
|
|
5979
|
+
rationale: "L2 isolation is process-level only (no TEE)",
|
|
5980
|
+
priority: "high"
|
|
5981
|
+
});
|
|
5982
|
+
}
|
|
5983
|
+
if (!layers.l2.attestation_available) {
|
|
5984
|
+
constraints.push({
|
|
5985
|
+
type: "requires_approval",
|
|
5986
|
+
description: "Human approval required for writes and sensitive reads",
|
|
5987
|
+
rationale: "No attestation available \u2014 self-reported integrity only",
|
|
5988
|
+
priority: "high"
|
|
5989
|
+
});
|
|
5990
|
+
}
|
|
5991
|
+
if (layers.l3.status === "degraded" || !layers.l3.selective_disclosure) {
|
|
5992
|
+
constraints.push({
|
|
5993
|
+
type: "restricted_scope",
|
|
5994
|
+
description: "Limit data sharing to minimal required scope \u2014 no selective disclosure",
|
|
5995
|
+
rationale: "Agent cannot redact data or prove predicates without revealing all context",
|
|
5996
|
+
priority: "high"
|
|
5997
|
+
});
|
|
5998
|
+
}
|
|
5999
|
+
if (layers.l3.proof_system === "commitment-only") {
|
|
6000
|
+
constraints.push({
|
|
6001
|
+
type: "restricted_scope",
|
|
6002
|
+
description: "No zero-knowledge proofs available \u2014 entire state context may be visible",
|
|
6003
|
+
rationale: "Proof system is commitment-only (no ZK)",
|
|
6004
|
+
priority: "medium"
|
|
6005
|
+
});
|
|
6006
|
+
}
|
|
6007
|
+
if (layers.l4.status === "degraded") {
|
|
6008
|
+
constraints.push({
|
|
6009
|
+
type: "known_agents_only",
|
|
6010
|
+
description: "Restrict interactions to known, pre-approved agents",
|
|
6011
|
+
rationale: "Reputation layer is degraded",
|
|
6012
|
+
priority: "medium"
|
|
6013
|
+
});
|
|
6014
|
+
}
|
|
6015
|
+
if (!layers.l4.reputation_portable) {
|
|
6016
|
+
constraints.push({
|
|
6017
|
+
type: "location_bound",
|
|
6018
|
+
description: "Reputation is not portable \u2014 restrict to home environment",
|
|
6019
|
+
rationale: "Cannot present reputation to external parties",
|
|
6020
|
+
priority: "low"
|
|
6021
|
+
});
|
|
6022
|
+
}
|
|
6023
|
+
const layerScores = calculateLayerScores(body);
|
|
6024
|
+
const overallScore = calculateOverallScore(layerScores);
|
|
6025
|
+
if (overallScore < 40) {
|
|
6026
|
+
constraints.push({
|
|
6027
|
+
type: "restricted_scope",
|
|
6028
|
+
description: "Overall sovereignty score below threshold \u2014 restrict to non-sensitive operations",
|
|
6029
|
+
rationale: `Overall sovereignty score is ${overallScore}/100`,
|
|
6030
|
+
priority: "high"
|
|
6031
|
+
});
|
|
6032
|
+
}
|
|
6033
|
+
return constraints;
|
|
6034
|
+
}
|
|
6035
|
+
function transformSHRGeneric(shr) {
|
|
6036
|
+
const context = transformSHRForGateway(shr);
|
|
6037
|
+
return {
|
|
6038
|
+
agent_id: context.agent_identity,
|
|
6039
|
+
sovereignty_score: context.overall_score,
|
|
6040
|
+
trust_level: context.recommended_trust_level,
|
|
6041
|
+
layer_scores: {
|
|
6042
|
+
l1: context.layer_scores.l1_cognitive,
|
|
6043
|
+
l2: context.layer_scores.l2_operational,
|
|
6044
|
+
l3: context.layer_scores.l3_disclosure,
|
|
6045
|
+
l4: context.layer_scores.l4_reputation
|
|
6046
|
+
},
|
|
6047
|
+
capabilities: context.authorization_signals,
|
|
6048
|
+
constraints: context.recommended_constraints.map((c) => ({
|
|
6049
|
+
type: c.type,
|
|
6050
|
+
description: c.description
|
|
6051
|
+
})),
|
|
6052
|
+
expires_at: context.context_expires_at,
|
|
6053
|
+
signature: context.shr_signature
|
|
6054
|
+
};
|
|
6055
|
+
}
|
|
6056
|
+
|
|
5719
6057
|
// src/shr/tools.ts
|
|
5720
6058
|
function createSHRTools(config, identityManager, masterKey, auditLog) {
|
|
5721
6059
|
const generatorOpts = {
|
|
@@ -5778,6 +6116,53 @@ function createSHRTools(config, identityManager, masterKey, auditLog) {
|
|
|
5778
6116
|
);
|
|
5779
6117
|
return toolResult(result);
|
|
5780
6118
|
}
|
|
6119
|
+
},
|
|
6120
|
+
{
|
|
6121
|
+
name: "sanctuary/shr_gateway_export",
|
|
6122
|
+
description: "Export this instance's Sovereignty Health Report formatted for Ping Identity's Agent Gateway or other identity providers. Transforms the SHR into an authorization context with sovereignty scores, capability flags, and recommended access constraints.",
|
|
6123
|
+
inputSchema: {
|
|
6124
|
+
type: "object",
|
|
6125
|
+
properties: {
|
|
6126
|
+
format: {
|
|
6127
|
+
type: "string",
|
|
6128
|
+
enum: ["ping", "generic"],
|
|
6129
|
+
description: "Output format: 'ping' (Ping Identity Gateway format) or 'generic' (format-agnostic). Default: 'ping'."
|
|
6130
|
+
},
|
|
6131
|
+
identity_id: {
|
|
6132
|
+
type: "string",
|
|
6133
|
+
description: "Identity to sign the SHR with. Defaults to primary identity."
|
|
6134
|
+
},
|
|
6135
|
+
validity_minutes: {
|
|
6136
|
+
type: "number",
|
|
6137
|
+
description: "How long the SHR is valid (minutes). Default: 60."
|
|
6138
|
+
}
|
|
6139
|
+
}
|
|
6140
|
+
},
|
|
6141
|
+
handler: async (args) => {
|
|
6142
|
+
const format = args.format || "ping";
|
|
6143
|
+
const validityMs = args.validity_minutes ? args.validity_minutes * 60 * 1e3 : void 0;
|
|
6144
|
+
const shrResult = generateSHR(args.identity_id, {
|
|
6145
|
+
...generatorOpts,
|
|
6146
|
+
validityMs
|
|
6147
|
+
});
|
|
6148
|
+
if (typeof shrResult === "string") {
|
|
6149
|
+
return toolResult({ error: shrResult });
|
|
6150
|
+
}
|
|
6151
|
+
let context;
|
|
6152
|
+
if (format === "generic") {
|
|
6153
|
+
context = transformSHRGeneric(shrResult);
|
|
6154
|
+
} else {
|
|
6155
|
+
context = transformSHRForGateway(shrResult);
|
|
6156
|
+
}
|
|
6157
|
+
auditLog.append(
|
|
6158
|
+
"l2",
|
|
6159
|
+
"shr_gateway_export",
|
|
6160
|
+
shrResult.body.instance_id,
|
|
6161
|
+
void 0,
|
|
6162
|
+
"success"
|
|
6163
|
+
);
|
|
6164
|
+
return toolResult(context);
|
|
6165
|
+
}
|
|
5781
6166
|
}
|
|
5782
6167
|
];
|
|
5783
6168
|
return { tools };
|
|
@@ -7056,9 +7441,11 @@ var L1_INTEGRITY_VERIFICATION = 8;
|
|
|
7056
7441
|
var L1_STATE_PORTABLE = 7;
|
|
7057
7442
|
var L2_THREE_TIER_GATE = 10;
|
|
7058
7443
|
var L2_BINARY_GATE = 3;
|
|
7059
|
-
var L2_ANOMALY_DETECTION =
|
|
7060
|
-
var L2_ENCRYPTED_AUDIT =
|
|
7061
|
-
var L2_TOOL_SANDBOXING =
|
|
7444
|
+
var L2_ANOMALY_DETECTION = 5;
|
|
7445
|
+
var L2_ENCRYPTED_AUDIT = 4;
|
|
7446
|
+
var L2_TOOL_SANDBOXING = 2;
|
|
7447
|
+
var L2_CONTEXT_GATING = 4;
|
|
7448
|
+
var L2_PROCESS_HARDENING = 5;
|
|
7062
7449
|
var L3_COMMITMENT_SCHEME = 8;
|
|
7063
7450
|
var L3_ZK_PROOFS = 7;
|
|
7064
7451
|
var L3_DISCLOSURE_POLICIES = 5;
|
|
@@ -7072,6 +7459,35 @@ var SEVERITY_ORDER = {
|
|
|
7072
7459
|
medium: 2,
|
|
7073
7460
|
low: 3
|
|
7074
7461
|
};
|
|
7462
|
+
var INCIDENT_META_SEV1 = {
|
|
7463
|
+
id: "META-SEV1-2026",
|
|
7464
|
+
name: "Meta Sev 1: Unauthorized autonomous data exposure",
|
|
7465
|
+
date: "2026-03-18",
|
|
7466
|
+
description: "AI agent autonomously posted proprietary code, business strategies, and user datasets to an internal forum without human approval. Two-hour exposure window."
|
|
7467
|
+
};
|
|
7468
|
+
var INCIDENT_OPENCLAW_SANDBOX = {
|
|
7469
|
+
id: "OPENCLAW-CVE-2026",
|
|
7470
|
+
name: "OpenClaw sandbox escape via privilege inheritance",
|
|
7471
|
+
date: "2026-03-18",
|
|
7472
|
+
description: "Nine CVEs in four days. Child processes inherited sandbox.mode=off from parent, bypassing runtime confinement. 42,900+ internet-exposed instances, 15,200 vulnerable to RCE.",
|
|
7473
|
+
cves: [
|
|
7474
|
+
"CVE-2026-32048",
|
|
7475
|
+
"CVE-2026-32915",
|
|
7476
|
+
"CVE-2026-32918"
|
|
7477
|
+
]
|
|
7478
|
+
};
|
|
7479
|
+
var INCIDENT_CONTEXT_LEAKAGE = {
|
|
7480
|
+
id: "CONTEXT-LEAK-CLASS",
|
|
7481
|
+
name: "Context leakage: Full state exposure to inference providers",
|
|
7482
|
+
date: "2026-03",
|
|
7483
|
+
description: "Agents send full context \u2014 conversation history, memory, secrets, internal reasoning \u2014 to remote LLM providers on every inference call with no filtering mechanism."
|
|
7484
|
+
};
|
|
7485
|
+
var INCIDENT_CLAUDE_CODE_LEAK = {
|
|
7486
|
+
id: "CLAUDE-CODE-LEAK-2026",
|
|
7487
|
+
name: "Claude Code source leak: 512K lines exposed via npm source map",
|
|
7488
|
+
date: "2026-03-31",
|
|
7489
|
+
description: "Anthropic accidentally shipped a 59.8 MB source map in npm package v2.1.88, exposing the full Claude Code TypeScript source \u2014 1,900 files, internal model codenames, unreleased features, OAuth flows, and multi-agent coordination logic."
|
|
7490
|
+
};
|
|
7075
7491
|
function analyzeSovereignty(env, config) {
|
|
7076
7492
|
const l1 = assessL1(env, config);
|
|
7077
7493
|
const l2 = assessL2(env);
|
|
@@ -7144,14 +7560,18 @@ function assessL2(env, _config) {
|
|
|
7144
7560
|
let auditTrailEncrypted = false;
|
|
7145
7561
|
let auditTrailExists = false;
|
|
7146
7562
|
let toolSandboxing = "none";
|
|
7563
|
+
let contextGating = false;
|
|
7564
|
+
let processIsolationHardening = "none";
|
|
7147
7565
|
if (sanctuaryActive) {
|
|
7148
7566
|
approvalGate = "three-tier";
|
|
7149
7567
|
behavioralAnomalyDetection = true;
|
|
7150
7568
|
auditTrailEncrypted = true;
|
|
7151
7569
|
auditTrailExists = true;
|
|
7570
|
+
contextGating = true;
|
|
7152
7571
|
findings.push("Three-tier Principal Policy gate active");
|
|
7153
7572
|
findings.push("Behavioral anomaly detection (BaselineTracker) enabled");
|
|
7154
7573
|
findings.push("Encrypted audit trail active");
|
|
7574
|
+
findings.push("Context gating available (sanctuary/context_gate_set_policy)");
|
|
7155
7575
|
}
|
|
7156
7576
|
if (env.openclaw_detected && env.openclaw_config) {
|
|
7157
7577
|
if (env.openclaw_config.require_approval_enabled) {
|
|
@@ -7169,6 +7589,7 @@ function assessL2(env, _config) {
|
|
|
7169
7589
|
);
|
|
7170
7590
|
}
|
|
7171
7591
|
}
|
|
7592
|
+
processIsolationHardening = "none";
|
|
7172
7593
|
const status = approvalGate === "three-tier" && auditTrailEncrypted ? "active" : approvalGate !== "none" || auditTrailExists ? "partial" : "inactive";
|
|
7173
7594
|
return {
|
|
7174
7595
|
status,
|
|
@@ -7177,6 +7598,8 @@ function assessL2(env, _config) {
|
|
|
7177
7598
|
audit_trail_encrypted: auditTrailEncrypted,
|
|
7178
7599
|
audit_trail_exists: auditTrailExists,
|
|
7179
7600
|
tool_sandboxing: sanctuaryActive ? "policy-enforced" : toolSandboxing,
|
|
7601
|
+
context_gating: contextGating,
|
|
7602
|
+
process_isolation_hardening: processIsolationHardening,
|
|
7180
7603
|
findings
|
|
7181
7604
|
};
|
|
7182
7605
|
}
|
|
@@ -7191,8 +7614,10 @@ function assessL3(env, _config) {
|
|
|
7191
7614
|
zkProofs = true;
|
|
7192
7615
|
selectiveDisclosurePolicy = true;
|
|
7193
7616
|
findings.push("SHA-256 + Pedersen commitment schemes active");
|
|
7194
|
-
findings.push("Schnorr
|
|
7617
|
+
findings.push("Schnorr zero-knowledge proofs (Fiat-Shamir) enabled \u2014 genuine ZK proofs");
|
|
7618
|
+
findings.push("Range proofs (bit-decomposition + OR-proofs) enabled \u2014 genuine ZK proofs");
|
|
7195
7619
|
findings.push("Selective disclosure policies configurable");
|
|
7620
|
+
findings.push("Non-interactive proofs with replay-resistant domain separation");
|
|
7196
7621
|
}
|
|
7197
7622
|
const status = commitmentScheme === "pedersen+sha256" && zkProofs ? "active" : commitmentScheme !== "none" ? "partial" : "inactive";
|
|
7198
7623
|
return {
|
|
@@ -7244,6 +7669,9 @@ function scoreL2(l2) {
|
|
|
7244
7669
|
if (l2.audit_trail_encrypted) score += L2_ENCRYPTED_AUDIT;
|
|
7245
7670
|
if (l2.tool_sandboxing === "policy-enforced") score += L2_TOOL_SANDBOXING;
|
|
7246
7671
|
else if (l2.tool_sandboxing === "basic") score += 1;
|
|
7672
|
+
if (l2.context_gating) score += L2_CONTEXT_GATING;
|
|
7673
|
+
if (l2.process_isolation_hardening === "hardened") score += L2_PROCESS_HARDENING;
|
|
7674
|
+
else if (l2.process_isolation_hardening === "basic") score += 2;
|
|
7247
7675
|
return score;
|
|
7248
7676
|
}
|
|
7249
7677
|
function scoreL3(l3) {
|
|
@@ -7273,7 +7701,8 @@ function generateGaps(env, l1, l2, l3, l4) {
|
|
|
7273
7701
|
title: "Agent memory stored in plaintext",
|
|
7274
7702
|
description: "Your agent's memory (MEMORY.md, daily notes, SQLite index) is stored in plaintext at ~/.openclaw/workspace/. Any process with file access can read your agent's full context \u2014 preferences, decisions, conversation history.",
|
|
7275
7703
|
openclaw_relevance: "Stock OpenClaw stores all agent memory in plaintext files. There is no built-in encryption for agent state.",
|
|
7276
|
-
sanctuary_solution: "Sanctuary encrypts all state at rest with AES-256-GCM using a key derived from Argon2id, making state opaque to any process that doesn't hold the master key. Use sanctuary/state_write to migrate sensitive state to the encrypted store."
|
|
7704
|
+
sanctuary_solution: "Sanctuary encrypts all state at rest with AES-256-GCM using a key derived from Argon2id, making state opaque to any process that doesn't hold the master key. Use sanctuary/state_write to migrate sensitive state to the encrypted store.",
|
|
7705
|
+
incident_class: INCIDENT_META_SEV1
|
|
7277
7706
|
});
|
|
7278
7707
|
}
|
|
7279
7708
|
if (oc && oc.env_file_exposed) {
|
|
@@ -7306,7 +7735,8 @@ function generateGaps(env, l1, l2, l3, l4) {
|
|
|
7306
7735
|
title: "Binary approval gate (no anomaly detection)",
|
|
7307
7736
|
description: "Your approval gate provides binary approve/deny gating without behavioral anomaly detection. Routine operations require the same manual approval as sensitive ones.",
|
|
7308
7737
|
openclaw_relevance: env.openclaw_detected ? "OpenClaw's requireApproval hook provides binary approve/deny gating. Sanctuary's three-tier Principal Policy adds behavioral anomaly detection (auto-escalation when agent behavior deviates from baseline), encrypted audit trails, and graduated approval tiers \u2014 so routine operations auto-proceed while sensitive operations require explicit consent." : null,
|
|
7309
|
-
sanctuary_solution: "Sanctuary's three-tier Principal Policy gate auto-allows routine operations (Tier 3), escalates anomalous behavior (Tier 2), and always requires human approval for irreversible operations (Tier 1). Use sanctuary/principal_policy_view to inspect."
|
|
7738
|
+
sanctuary_solution: "Sanctuary's three-tier Principal Policy gate auto-allows routine operations (Tier 3), escalates anomalous behavior (Tier 2), and always requires human approval for irreversible operations (Tier 1). Use sanctuary/principal_policy_view to inspect.",
|
|
7739
|
+
incident_class: INCIDENT_META_SEV1
|
|
7310
7740
|
});
|
|
7311
7741
|
} else if (l2.approval_gate === "none") {
|
|
7312
7742
|
gaps.push({
|
|
@@ -7316,7 +7746,8 @@ function generateGaps(env, l1, l2, l3, l4) {
|
|
|
7316
7746
|
title: "No approval gate",
|
|
7317
7747
|
description: "No approval gate is configured. All tool calls execute without oversight.",
|
|
7318
7748
|
openclaw_relevance: null,
|
|
7319
|
-
sanctuary_solution: "Sanctuary's Principal Policy evaluates every tool call before execution. Enable it to get three-tier approval gating with behavioral anomaly detection."
|
|
7749
|
+
sanctuary_solution: "Sanctuary's Principal Policy evaluates every tool call before execution. Enable it to get three-tier approval gating with behavioral anomaly detection.",
|
|
7750
|
+
incident_class: INCIDENT_META_SEV1
|
|
7320
7751
|
});
|
|
7321
7752
|
}
|
|
7322
7753
|
if (l2.tool_sandboxing === "basic") {
|
|
@@ -7327,18 +7758,32 @@ function generateGaps(env, l1, l2, l3, l4) {
|
|
|
7327
7758
|
title: "Basic tool sandboxing (no cryptographic attestation)",
|
|
7328
7759
|
description: "Your tool sandbox enforces allow/deny lists but provides no cryptographic attestation of execution context.",
|
|
7329
7760
|
openclaw_relevance: env.openclaw_detected ? "OpenClaw's sandbox tool policy (tools.sandbox.tools) enforces allow/deny lists. Sanctuary adds cryptographic attestation of execution context \u2014 a verifiable proof that an operation ran within policy, not just that a policy was configured." : null,
|
|
7330
|
-
sanctuary_solution: "Sanctuary provides cryptographic execution attestation via sanctuary/exec_attest and policy-enforced sandboxing with encrypted audit trails."
|
|
7761
|
+
sanctuary_solution: "Sanctuary provides cryptographic execution attestation via sanctuary/exec_attest and policy-enforced sandboxing with encrypted audit trails.",
|
|
7762
|
+
incident_class: INCIDENT_OPENCLAW_SANDBOX
|
|
7331
7763
|
});
|
|
7332
7764
|
}
|
|
7333
|
-
if (!l2.
|
|
7765
|
+
if (!l2.context_gating) {
|
|
7334
7766
|
gaps.push({
|
|
7335
7767
|
id: "GAP-L2-003",
|
|
7336
7768
|
layer: "L2",
|
|
7337
7769
|
severity: "high",
|
|
7770
|
+
title: "No context gating for outbound inference calls",
|
|
7771
|
+
description: "Your agent sends its full context \u2014 conversation history, memory, preferences, internal reasoning \u2014 to remote LLM providers on every inference call. There is no mechanism to filter what leaves the sovereignty boundary. The provider sees everything the agent knows.",
|
|
7772
|
+
openclaw_relevance: env.openclaw_detected ? "OpenClaw sends full agent context (including MEMORY.md, tool results, and conversation history) to the configured LLM provider with every API call. There is no built-in context filtering." : null,
|
|
7773
|
+
sanctuary_solution: "Sanctuary's context gating (sanctuary/context_gate_set_policy + sanctuary/context_gate_filter) lets you define per-provider policies that control exactly what context flows outbound. Redact secrets, hash identifiers, and send only minimum-necessary context for each call.",
|
|
7774
|
+
incident_class: INCIDENT_CONTEXT_LEAKAGE
|
|
7775
|
+
});
|
|
7776
|
+
}
|
|
7777
|
+
if (!l2.audit_trail_exists) {
|
|
7778
|
+
gaps.push({
|
|
7779
|
+
id: "GAP-L2-004",
|
|
7780
|
+
layer: "L2",
|
|
7781
|
+
severity: "high",
|
|
7338
7782
|
title: "No audit trail",
|
|
7339
7783
|
description: "No audit trail exists for tool call history. There is no record of what operations were executed, when, or by whom.",
|
|
7340
7784
|
openclaw_relevance: null,
|
|
7341
|
-
sanctuary_solution: "Sanctuary maintains an encrypted audit log of all operations, queryable via sanctuary/monitor_audit_log."
|
|
7785
|
+
sanctuary_solution: "Sanctuary maintains an encrypted audit log of all operations, queryable via sanctuary/monitor_audit_log.",
|
|
7786
|
+
incident_class: INCIDENT_CLAUDE_CODE_LEAK
|
|
7342
7787
|
});
|
|
7343
7788
|
}
|
|
7344
7789
|
if (l3.commitment_scheme === "none") {
|
|
@@ -7347,9 +7792,10 @@ function generateGaps(env, l1, l2, l3, l4) {
|
|
|
7347
7792
|
layer: "L3",
|
|
7348
7793
|
severity: "high",
|
|
7349
7794
|
title: "No selective disclosure capability",
|
|
7350
|
-
description: "Your agent has no
|
|
7795
|
+
description: "Your agent has no cryptographic mechanism to prove facts about its state without revealing the state itself. Every disclosure is all-or-nothing: no commitments, no zero-knowledge proofs, no selective disclosure policies.",
|
|
7351
7796
|
openclaw_relevance: env.openclaw_detected ? "OpenClaw has no selective disclosure mechanism. When your agent shares information, it shares everything or nothing \u2014 there is no way to prove a claim without revealing the underlying data." : null,
|
|
7352
|
-
sanctuary_solution: "Sanctuary's L3 provides SHA-256 + Pedersen commitments
|
|
7797
|
+
sanctuary_solution: "Sanctuary's L3 provides SHA-256 + Pedersen commitments with genuine zero-knowledge proofs (Schnorr + range proofs via Fiat-Shamir transform). Your agent can prove it has a valid credential, sufficient reputation, or a completed transaction without exposing the underlying data. Use sanctuary/zk_commit and sanctuary/zk_prove.",
|
|
7798
|
+
incident_class: INCIDENT_META_SEV1
|
|
7353
7799
|
});
|
|
7354
7800
|
}
|
|
7355
7801
|
if (!l4.reputation_portable) {
|
|
@@ -7401,9 +7847,18 @@ function generateRecommendations(env, l1, l2, l3, l4) {
|
|
|
7401
7847
|
impact: "high"
|
|
7402
7848
|
});
|
|
7403
7849
|
}
|
|
7404
|
-
if (!
|
|
7850
|
+
if (!l2.context_gating) {
|
|
7405
7851
|
recs.push({
|
|
7406
7852
|
priority: 5,
|
|
7853
|
+
action: "Configure context gating to control what flows to LLM providers",
|
|
7854
|
+
tool: "sanctuary/context_gate_set_policy",
|
|
7855
|
+
effort: "minutes",
|
|
7856
|
+
impact: "high"
|
|
7857
|
+
});
|
|
7858
|
+
}
|
|
7859
|
+
if (!l4.reputation_signed) {
|
|
7860
|
+
recs.push({
|
|
7861
|
+
priority: 6,
|
|
7407
7862
|
action: "Start recording reputation attestations from completed interactions",
|
|
7408
7863
|
tool: "sanctuary/reputation_record",
|
|
7409
7864
|
effort: "minutes",
|
|
@@ -7412,7 +7867,7 @@ function generateRecommendations(env, l1, l2, l3, l4) {
|
|
|
7412
7867
|
}
|
|
7413
7868
|
if (!l3.selective_disclosure_policy) {
|
|
7414
7869
|
recs.push({
|
|
7415
|
-
priority:
|
|
7870
|
+
priority: 7,
|
|
7416
7871
|
action: "Configure selective disclosure policies for data sharing",
|
|
7417
7872
|
tool: "sanctuary/disclosure_set_policy",
|
|
7418
7873
|
effort: "hours",
|
|
@@ -7461,6 +7916,10 @@ function formatAuditReport(result) {
|
|
|
7461
7916
|
`;
|
|
7462
7917
|
report += ` \u2502 L2 Operational Isolation \u2502 ${padStatus(layers.l2_operational.status)} \u2502 ${padScore(l2Score, 25)} \u2502
|
|
7463
7918
|
`;
|
|
7919
|
+
if (layers.l2_operational.context_gating) {
|
|
7920
|
+
report += ` \u2502 \u2514 Context Gating \u2502 ACTIVE \u2502 \u2502
|
|
7921
|
+
`;
|
|
7922
|
+
}
|
|
7464
7923
|
report += ` \u2502 L3 Selective Disclosure \u2502 ${padStatus(layers.l3_selective_disclosure.status)} \u2502 ${padScore(l3Score, 20)} \u2502
|
|
7465
7924
|
`;
|
|
7466
7925
|
report += ` \u2502 L4 Verifiable Reputation \u2502 ${padStatus(layers.l4_reputation.status)} \u2502 ${padScore(l4Score, 20)} \u2502
|
|
@@ -7478,6 +7937,12 @@ function formatAuditReport(result) {
|
|
|
7478
7937
|
const descLines = wordWrap(gap.description, 66);
|
|
7479
7938
|
for (const line of descLines) {
|
|
7480
7939
|
report += ` ${line}
|
|
7940
|
+
`;
|
|
7941
|
+
}
|
|
7942
|
+
if (gap.incident_class) {
|
|
7943
|
+
const ic = gap.incident_class;
|
|
7944
|
+
const cveStr = ic.cves?.length ? ` (${ic.cves.join(", ")})` : "";
|
|
7945
|
+
report += ` \u2192 Incident precedent: ${ic.name}${cveStr} [${ic.date}]
|
|
7481
7946
|
`;
|
|
7482
7947
|
}
|
|
7483
7948
|
report += ` \u2192 Fix: ${gap.sanctuary_solution.split(".")[0]}.
|
|
@@ -7572,78 +8037,1554 @@ function createAuditTools(config) {
|
|
|
7572
8037
|
return { tools };
|
|
7573
8038
|
}
|
|
7574
8039
|
|
|
7575
|
-
// src/
|
|
8040
|
+
// src/l2-operational/context-gate.ts
|
|
7576
8041
|
init_encoding();
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
var
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
8042
|
+
init_hashing();
|
|
8043
|
+
var MAX_CONTEXT_FIELDS = 1e3;
|
|
8044
|
+
var MAX_POLICY_RULES = 50;
|
|
8045
|
+
var MAX_PATTERNS_PER_ARRAY = 500;
|
|
8046
|
+
function evaluateField(policy, provider, field) {
|
|
8047
|
+
const exactRule = policy.rules.find((r) => r.provider === provider);
|
|
8048
|
+
const wildcardRule = policy.rules.find((r) => r.provider === "*");
|
|
8049
|
+
const matchedRule = exactRule ?? wildcardRule;
|
|
8050
|
+
if (!matchedRule) {
|
|
8051
|
+
return {
|
|
8052
|
+
field,
|
|
8053
|
+
action: policy.default_action === "deny" ? "deny" : "redact",
|
|
8054
|
+
reason: `No rule matches provider "${provider}"; applying default (${policy.default_action})`
|
|
8055
|
+
};
|
|
7583
8056
|
}
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
}
|
|
8057
|
+
if (matchesPattern(field, matchedRule.redact)) {
|
|
8058
|
+
return {
|
|
8059
|
+
field,
|
|
8060
|
+
action: "redact",
|
|
8061
|
+
reason: `Field "${field}" is explicitly redacted for ${matchedRule.provider} provider`
|
|
8062
|
+
};
|
|
7590
8063
|
}
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
8064
|
+
if (matchesPattern(field, matchedRule.hash)) {
|
|
8065
|
+
return {
|
|
8066
|
+
field,
|
|
8067
|
+
action: "hash",
|
|
8068
|
+
reason: `Field "${field}" is hashed for ${matchedRule.provider} provider`
|
|
8069
|
+
};
|
|
7595
8070
|
}
|
|
7596
|
-
|
|
7597
|
-
return
|
|
8071
|
+
if (matchesPattern(field, matchedRule.summarize)) {
|
|
8072
|
+
return {
|
|
8073
|
+
field,
|
|
8074
|
+
action: "summarize",
|
|
8075
|
+
reason: `Field "${field}" should be summarized for ${matchedRule.provider} provider`
|
|
8076
|
+
};
|
|
7598
8077
|
}
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
if (prefix && !key.startsWith(prefix)) continue;
|
|
7606
|
-
entries.push({
|
|
7607
|
-
key,
|
|
7608
|
-
namespace,
|
|
7609
|
-
size_bytes: entry.data.length,
|
|
7610
|
-
modified_at: entry.modified_at
|
|
7611
|
-
});
|
|
7612
|
-
}
|
|
7613
|
-
return entries.sort((a, b) => a.key.localeCompare(b.key));
|
|
8078
|
+
if (matchesPattern(field, matchedRule.allow)) {
|
|
8079
|
+
return {
|
|
8080
|
+
field,
|
|
8081
|
+
action: "allow",
|
|
8082
|
+
reason: `Field "${field}" is allowed for ${matchedRule.provider} provider`
|
|
8083
|
+
};
|
|
7614
8084
|
}
|
|
7615
|
-
|
|
7616
|
-
|
|
8085
|
+
return {
|
|
8086
|
+
field,
|
|
8087
|
+
action: policy.default_action === "deny" ? "deny" : "redact",
|
|
8088
|
+
reason: `Field "${field}" not addressed in ${matchedRule.provider} rule; applying default (${policy.default_action})`
|
|
8089
|
+
};
|
|
8090
|
+
}
|
|
8091
|
+
function filterContext(policy, provider, context) {
|
|
8092
|
+
const fields = Object.keys(context);
|
|
8093
|
+
if (fields.length > MAX_CONTEXT_FIELDS) {
|
|
8094
|
+
throw new Error(
|
|
8095
|
+
`Context object has ${fields.length} fields, exceeding limit of ${MAX_CONTEXT_FIELDS}`
|
|
8096
|
+
);
|
|
7617
8097
|
}
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
8098
|
+
const decisions = [];
|
|
8099
|
+
let allowed = 0;
|
|
8100
|
+
let redacted = 0;
|
|
8101
|
+
let hashed = 0;
|
|
8102
|
+
let summarized = 0;
|
|
8103
|
+
let denied = 0;
|
|
8104
|
+
for (const field of fields) {
|
|
8105
|
+
const result = evaluateField(policy, provider, field);
|
|
8106
|
+
if (result.action === "hash") {
|
|
8107
|
+
const value = typeof context[field] === "string" ? context[field] : JSON.stringify(context[field]);
|
|
8108
|
+
result.hash_value = hashToString(stringToBytes(value));
|
|
8109
|
+
}
|
|
8110
|
+
decisions.push(result);
|
|
8111
|
+
switch (result.action) {
|
|
8112
|
+
case "allow":
|
|
8113
|
+
allowed++;
|
|
8114
|
+
break;
|
|
8115
|
+
case "redact":
|
|
8116
|
+
redacted++;
|
|
8117
|
+
break;
|
|
8118
|
+
case "hash":
|
|
8119
|
+
hashed++;
|
|
8120
|
+
break;
|
|
8121
|
+
case "summarize":
|
|
8122
|
+
summarized++;
|
|
8123
|
+
break;
|
|
8124
|
+
case "deny":
|
|
8125
|
+
denied++;
|
|
8126
|
+
break;
|
|
7622
8127
|
}
|
|
7623
|
-
return total;
|
|
7624
8128
|
}
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
8129
|
+
const originalHash = hashToString(
|
|
8130
|
+
stringToBytes(JSON.stringify(context))
|
|
8131
|
+
);
|
|
8132
|
+
const filteredOutput = {};
|
|
8133
|
+
for (const decision of decisions) {
|
|
8134
|
+
switch (decision.action) {
|
|
8135
|
+
case "allow":
|
|
8136
|
+
filteredOutput[decision.field] = context[decision.field];
|
|
8137
|
+
break;
|
|
8138
|
+
case "redact":
|
|
8139
|
+
filteredOutput[decision.field] = "[REDACTED]";
|
|
8140
|
+
break;
|
|
8141
|
+
case "hash":
|
|
8142
|
+
filteredOutput[decision.field] = `[HASH:${decision.hash_value}]`;
|
|
8143
|
+
break;
|
|
8144
|
+
case "summarize":
|
|
8145
|
+
filteredOutput[decision.field] = "[SUMMARIZE]";
|
|
8146
|
+
break;
|
|
8147
|
+
}
|
|
7628
8148
|
}
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
// src/index.ts
|
|
7632
|
-
async function createSanctuaryServer(options) {
|
|
7633
|
-
const config = await loadConfig(options?.configPath);
|
|
7634
|
-
await promises.mkdir(config.storage_path, { recursive: true, mode: 448 });
|
|
7635
|
-
const storage = options?.storage ?? new FilesystemStorage(
|
|
7636
|
-
`${config.storage_path}/state`
|
|
8149
|
+
const filteredHash = hashToString(
|
|
8150
|
+
stringToBytes(JSON.stringify(filteredOutput))
|
|
7637
8151
|
);
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
8152
|
+
return {
|
|
8153
|
+
policy_id: policy.policy_id,
|
|
8154
|
+
provider,
|
|
8155
|
+
fields_allowed: allowed,
|
|
8156
|
+
fields_redacted: redacted,
|
|
8157
|
+
fields_hashed: hashed,
|
|
8158
|
+
fields_summarized: summarized,
|
|
8159
|
+
fields_denied: denied,
|
|
8160
|
+
decisions,
|
|
8161
|
+
original_context_hash: originalHash,
|
|
8162
|
+
filtered_context_hash: filteredHash,
|
|
8163
|
+
filtered_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
8164
|
+
};
|
|
8165
|
+
}
|
|
8166
|
+
function matchesPattern(field, patterns) {
|
|
8167
|
+
const normalizedField = field.toLowerCase();
|
|
8168
|
+
for (const pattern of patterns) {
|
|
8169
|
+
if (pattern === "*") return true;
|
|
8170
|
+
const normalizedPattern = pattern.toLowerCase();
|
|
8171
|
+
if (normalizedPattern === normalizedField) return true;
|
|
8172
|
+
if (normalizedPattern.endsWith("*") && normalizedField.startsWith(normalizedPattern.slice(0, -1))) return true;
|
|
8173
|
+
if (normalizedPattern.startsWith("*") && normalizedField.endsWith(normalizedPattern.slice(1))) return true;
|
|
8174
|
+
}
|
|
8175
|
+
return false;
|
|
8176
|
+
}
|
|
8177
|
+
var ContextGatePolicyStore = class {
|
|
8178
|
+
storage;
|
|
8179
|
+
encryptionKey;
|
|
8180
|
+
policies = /* @__PURE__ */ new Map();
|
|
8181
|
+
constructor(storage, masterKey) {
|
|
8182
|
+
this.storage = storage;
|
|
8183
|
+
this.encryptionKey = derivePurposeKey(masterKey, "l2-context-gate");
|
|
8184
|
+
}
|
|
8185
|
+
/**
|
|
8186
|
+
* Create and store a new context-gating policy.
|
|
8187
|
+
*/
|
|
8188
|
+
async create(policyName, rules, defaultAction, identityId) {
|
|
8189
|
+
const policyId = `cg-${Date.now()}-${toBase64url(randomBytes(8))}`;
|
|
8190
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
8191
|
+
const policy = {
|
|
8192
|
+
policy_id: policyId,
|
|
8193
|
+
policy_name: policyName,
|
|
8194
|
+
rules,
|
|
8195
|
+
default_action: defaultAction,
|
|
8196
|
+
identity_id: identityId,
|
|
8197
|
+
created_at: now,
|
|
8198
|
+
updated_at: now
|
|
8199
|
+
};
|
|
8200
|
+
await this.persist(policy);
|
|
8201
|
+
this.policies.set(policyId, policy);
|
|
8202
|
+
return policy;
|
|
8203
|
+
}
|
|
8204
|
+
/**
|
|
8205
|
+
* Get a policy by ID.
|
|
8206
|
+
*/
|
|
8207
|
+
async get(policyId) {
|
|
8208
|
+
if (this.policies.has(policyId)) {
|
|
8209
|
+
return this.policies.get(policyId);
|
|
8210
|
+
}
|
|
8211
|
+
const raw = await this.storage.read("_context_gate_policies", policyId);
|
|
8212
|
+
if (!raw) return null;
|
|
7645
8213
|
try {
|
|
7646
|
-
const
|
|
8214
|
+
const encrypted = JSON.parse(bytesToString(raw));
|
|
8215
|
+
const decrypted = decrypt(encrypted, this.encryptionKey);
|
|
8216
|
+
const policy = JSON.parse(bytesToString(decrypted));
|
|
8217
|
+
this.policies.set(policyId, policy);
|
|
8218
|
+
return policy;
|
|
8219
|
+
} catch {
|
|
8220
|
+
return null;
|
|
8221
|
+
}
|
|
8222
|
+
}
|
|
8223
|
+
/**
|
|
8224
|
+
* List all context-gating policies.
|
|
8225
|
+
*/
|
|
8226
|
+
async list() {
|
|
8227
|
+
await this.loadAll();
|
|
8228
|
+
return Array.from(this.policies.values());
|
|
8229
|
+
}
|
|
8230
|
+
/**
|
|
8231
|
+
* Load all persisted policies into memory.
|
|
8232
|
+
*/
|
|
8233
|
+
async loadAll() {
|
|
8234
|
+
try {
|
|
8235
|
+
const entries = await this.storage.list("_context_gate_policies");
|
|
8236
|
+
for (const meta of entries) {
|
|
8237
|
+
if (this.policies.has(meta.key)) continue;
|
|
8238
|
+
const raw = await this.storage.read("_context_gate_policies", meta.key);
|
|
8239
|
+
if (!raw) continue;
|
|
8240
|
+
try {
|
|
8241
|
+
const encrypted = JSON.parse(bytesToString(raw));
|
|
8242
|
+
const decrypted = decrypt(encrypted, this.encryptionKey);
|
|
8243
|
+
const policy = JSON.parse(bytesToString(decrypted));
|
|
8244
|
+
this.policies.set(policy.policy_id, policy);
|
|
8245
|
+
} catch {
|
|
8246
|
+
}
|
|
8247
|
+
}
|
|
8248
|
+
} catch {
|
|
8249
|
+
}
|
|
8250
|
+
}
|
|
8251
|
+
async persist(policy) {
|
|
8252
|
+
const serialized = stringToBytes(JSON.stringify(policy));
|
|
8253
|
+
const encrypted = encrypt(serialized, this.encryptionKey);
|
|
8254
|
+
await this.storage.write(
|
|
8255
|
+
"_context_gate_policies",
|
|
8256
|
+
policy.policy_id,
|
|
8257
|
+
stringToBytes(JSON.stringify(encrypted))
|
|
8258
|
+
);
|
|
8259
|
+
}
|
|
8260
|
+
};
|
|
8261
|
+
|
|
8262
|
+
// src/l2-operational/context-gate-templates.ts
|
|
8263
|
+
var ALWAYS_REDACT_SECRETS = [
|
|
8264
|
+
"api_key",
|
|
8265
|
+
"secret_*",
|
|
8266
|
+
"*_secret",
|
|
8267
|
+
"*_token",
|
|
8268
|
+
"*_key",
|
|
8269
|
+
"password",
|
|
8270
|
+
"*_password",
|
|
8271
|
+
"credential",
|
|
8272
|
+
"*_credential",
|
|
8273
|
+
"private_key",
|
|
8274
|
+
"recovery_key",
|
|
8275
|
+
"passphrase",
|
|
8276
|
+
"auth_*"
|
|
8277
|
+
];
|
|
8278
|
+
var PII_PATTERNS = [
|
|
8279
|
+
"*_pii",
|
|
8280
|
+
"name",
|
|
8281
|
+
"full_name",
|
|
8282
|
+
"email",
|
|
8283
|
+
"email_address",
|
|
8284
|
+
"phone",
|
|
8285
|
+
"phone_number",
|
|
8286
|
+
"address",
|
|
8287
|
+
"ssn",
|
|
8288
|
+
"date_of_birth",
|
|
8289
|
+
"ip_address",
|
|
8290
|
+
"credit_card",
|
|
8291
|
+
"card_number",
|
|
8292
|
+
"cvv",
|
|
8293
|
+
"bank_account",
|
|
8294
|
+
"account_number",
|
|
8295
|
+
"routing_number"
|
|
8296
|
+
];
|
|
8297
|
+
var INTERNAL_STATE_PATTERNS = [
|
|
8298
|
+
"memory",
|
|
8299
|
+
"agent_memory",
|
|
8300
|
+
"internal_reasoning",
|
|
8301
|
+
"internal_state",
|
|
8302
|
+
"reasoning_trace",
|
|
8303
|
+
"chain_of_thought",
|
|
8304
|
+
"private_notes",
|
|
8305
|
+
"soul",
|
|
8306
|
+
"personality",
|
|
8307
|
+
"system_prompt"
|
|
8308
|
+
];
|
|
8309
|
+
var ID_PATTERNS = [
|
|
8310
|
+
"user_id",
|
|
8311
|
+
"session_id",
|
|
8312
|
+
"agent_id",
|
|
8313
|
+
"identity_id",
|
|
8314
|
+
"conversation_id",
|
|
8315
|
+
"thread_id"
|
|
8316
|
+
];
|
|
8317
|
+
var HISTORY_PATTERNS = [
|
|
8318
|
+
"conversation_history",
|
|
8319
|
+
"message_history",
|
|
8320
|
+
"chat_history",
|
|
8321
|
+
"context_window",
|
|
8322
|
+
"previous_messages"
|
|
8323
|
+
];
|
|
8324
|
+
var INFERENCE_MINIMAL = {
|
|
8325
|
+
id: "inference-minimal",
|
|
8326
|
+
name: "Inference Minimal",
|
|
8327
|
+
description: "Maximum privacy. Only the current task and query reach the LLM provider.",
|
|
8328
|
+
use_when: "You want the strictest possible context control for inference calls. The LLM sees only what it needs for the immediate task.",
|
|
8329
|
+
rules: [
|
|
8330
|
+
{
|
|
8331
|
+
provider: "inference",
|
|
8332
|
+
allow: [
|
|
8333
|
+
"task",
|
|
8334
|
+
"task_description",
|
|
8335
|
+
"current_query",
|
|
8336
|
+
"query",
|
|
8337
|
+
"prompt",
|
|
8338
|
+
"question",
|
|
8339
|
+
"instruction"
|
|
8340
|
+
],
|
|
8341
|
+
redact: [
|
|
8342
|
+
...ALWAYS_REDACT_SECRETS,
|
|
8343
|
+
...PII_PATTERNS,
|
|
8344
|
+
...INTERNAL_STATE_PATTERNS,
|
|
8345
|
+
...HISTORY_PATTERNS,
|
|
8346
|
+
"tool_results",
|
|
8347
|
+
"previous_results"
|
|
8348
|
+
],
|
|
8349
|
+
hash: [...ID_PATTERNS],
|
|
8350
|
+
summarize: []
|
|
8351
|
+
}
|
|
8352
|
+
],
|
|
8353
|
+
default_action: "redact"
|
|
8354
|
+
};
|
|
8355
|
+
var INFERENCE_STANDARD = {
|
|
8356
|
+
id: "inference-standard",
|
|
8357
|
+
name: "Inference Standard",
|
|
8358
|
+
description: "Balanced privacy. Task, query, and tool results pass through. History flagged for summarization. Secrets and PII redacted.",
|
|
8359
|
+
use_when: "You need the LLM to have enough context for multi-step tasks while keeping secrets, PII, and internal reasoning private.",
|
|
8360
|
+
rules: [
|
|
8361
|
+
{
|
|
8362
|
+
provider: "inference",
|
|
8363
|
+
allow: [
|
|
8364
|
+
"task",
|
|
8365
|
+
"task_description",
|
|
8366
|
+
"current_query",
|
|
8367
|
+
"query",
|
|
8368
|
+
"prompt",
|
|
8369
|
+
"question",
|
|
8370
|
+
"instruction",
|
|
8371
|
+
"tool_results",
|
|
8372
|
+
"tool_output",
|
|
8373
|
+
"previous_results",
|
|
8374
|
+
"current_step",
|
|
8375
|
+
"remaining_steps",
|
|
8376
|
+
"objective",
|
|
8377
|
+
"constraints",
|
|
8378
|
+
"format",
|
|
8379
|
+
"output_format"
|
|
8380
|
+
],
|
|
8381
|
+
redact: [
|
|
8382
|
+
...ALWAYS_REDACT_SECRETS,
|
|
8383
|
+
...PII_PATTERNS,
|
|
8384
|
+
...INTERNAL_STATE_PATTERNS
|
|
8385
|
+
],
|
|
8386
|
+
hash: [...ID_PATTERNS],
|
|
8387
|
+
summarize: [...HISTORY_PATTERNS]
|
|
8388
|
+
}
|
|
8389
|
+
],
|
|
8390
|
+
default_action: "redact"
|
|
8391
|
+
};
|
|
8392
|
+
var LOGGING_STRICT = {
|
|
8393
|
+
id: "logging-strict",
|
|
8394
|
+
name: "Logging Strict",
|
|
8395
|
+
description: "Redacts all content for logging and analytics providers. Only operation metadata passes through.",
|
|
8396
|
+
use_when: "You send telemetry to logging or analytics services and want usage metrics without any content exposure.",
|
|
8397
|
+
rules: [
|
|
8398
|
+
{
|
|
8399
|
+
provider: "logging",
|
|
8400
|
+
allow: [
|
|
8401
|
+
"operation",
|
|
8402
|
+
"operation_name",
|
|
8403
|
+
"tool_name",
|
|
8404
|
+
"timestamp",
|
|
8405
|
+
"duration_ms",
|
|
8406
|
+
"status",
|
|
8407
|
+
"error_code",
|
|
8408
|
+
"event_type"
|
|
8409
|
+
],
|
|
8410
|
+
redact: [
|
|
8411
|
+
...ALWAYS_REDACT_SECRETS,
|
|
8412
|
+
...PII_PATTERNS,
|
|
8413
|
+
...INTERNAL_STATE_PATTERNS,
|
|
8414
|
+
...HISTORY_PATTERNS
|
|
8415
|
+
],
|
|
8416
|
+
hash: [...ID_PATTERNS],
|
|
8417
|
+
summarize: []
|
|
8418
|
+
},
|
|
8419
|
+
{
|
|
8420
|
+
provider: "analytics",
|
|
8421
|
+
allow: [
|
|
8422
|
+
"event_type",
|
|
8423
|
+
"timestamp",
|
|
8424
|
+
"duration_ms",
|
|
8425
|
+
"status",
|
|
8426
|
+
"tool_name"
|
|
8427
|
+
],
|
|
8428
|
+
redact: [
|
|
8429
|
+
...ALWAYS_REDACT_SECRETS,
|
|
8430
|
+
...PII_PATTERNS,
|
|
8431
|
+
...INTERNAL_STATE_PATTERNS,
|
|
8432
|
+
...HISTORY_PATTERNS
|
|
8433
|
+
],
|
|
8434
|
+
hash: [...ID_PATTERNS],
|
|
8435
|
+
summarize: []
|
|
8436
|
+
}
|
|
8437
|
+
],
|
|
8438
|
+
default_action: "redact"
|
|
8439
|
+
};
|
|
8440
|
+
var TOOL_API_SCOPED = {
|
|
8441
|
+
id: "tool-api-scoped",
|
|
8442
|
+
name: "Tool API Scoped",
|
|
8443
|
+
description: "Allows tool-specific parameters for external API calls. Redacts memory, history, secrets, and PII.",
|
|
8444
|
+
use_when: "Your agent calls external APIs (search, database, web) and you want to send query parameters without full agent context. Note: 'headers' and 'body' are redacted by default because they frequently carry authorization tokens. Add them to 'allow' only if you verify they contain no credentials for your use case.",
|
|
8445
|
+
rules: [
|
|
8446
|
+
{
|
|
8447
|
+
provider: "tool-api",
|
|
8448
|
+
allow: [
|
|
8449
|
+
"task",
|
|
8450
|
+
"task_description",
|
|
8451
|
+
"query",
|
|
8452
|
+
"search_query",
|
|
8453
|
+
"tool_input",
|
|
8454
|
+
"tool_parameters",
|
|
8455
|
+
"url",
|
|
8456
|
+
"endpoint",
|
|
8457
|
+
"method",
|
|
8458
|
+
"filter",
|
|
8459
|
+
"sort",
|
|
8460
|
+
"limit",
|
|
8461
|
+
"offset"
|
|
8462
|
+
],
|
|
8463
|
+
redact: [
|
|
8464
|
+
...ALWAYS_REDACT_SECRETS,
|
|
8465
|
+
...PII_PATTERNS,
|
|
8466
|
+
...INTERNAL_STATE_PATTERNS,
|
|
8467
|
+
...HISTORY_PATTERNS
|
|
8468
|
+
],
|
|
8469
|
+
hash: [...ID_PATTERNS],
|
|
8470
|
+
summarize: []
|
|
8471
|
+
}
|
|
8472
|
+
],
|
|
8473
|
+
default_action: "redact"
|
|
8474
|
+
};
|
|
8475
|
+
var TEMPLATES = {
|
|
8476
|
+
"inference-minimal": INFERENCE_MINIMAL,
|
|
8477
|
+
"inference-standard": INFERENCE_STANDARD,
|
|
8478
|
+
"logging-strict": LOGGING_STRICT,
|
|
8479
|
+
"tool-api-scoped": TOOL_API_SCOPED
|
|
8480
|
+
};
|
|
8481
|
+
function listTemplateIds() {
|
|
8482
|
+
return Object.keys(TEMPLATES);
|
|
8483
|
+
}
|
|
8484
|
+
function getTemplate(id) {
|
|
8485
|
+
return TEMPLATES[id];
|
|
8486
|
+
}
|
|
8487
|
+
|
|
8488
|
+
// src/l2-operational/context-gate-recommend.ts
|
|
8489
|
+
var CLASSIFICATION_RULES = [
|
|
8490
|
+
// ── Secrets (always redact, high confidence) ─────────────────────
|
|
8491
|
+
{
|
|
8492
|
+
patterns: [
|
|
8493
|
+
"api_key",
|
|
8494
|
+
"apikey",
|
|
8495
|
+
"api_secret",
|
|
8496
|
+
"secret",
|
|
8497
|
+
"secret_key",
|
|
8498
|
+
"secret_token",
|
|
8499
|
+
"password",
|
|
8500
|
+
"passwd",
|
|
8501
|
+
"pass",
|
|
8502
|
+
"credential",
|
|
8503
|
+
"credentials",
|
|
8504
|
+
"private_key",
|
|
8505
|
+
"privkey",
|
|
8506
|
+
"recovery_key",
|
|
8507
|
+
"passphrase",
|
|
8508
|
+
"token",
|
|
8509
|
+
"access_token",
|
|
8510
|
+
"refresh_token",
|
|
8511
|
+
"bearer_token",
|
|
8512
|
+
"auth_token",
|
|
8513
|
+
"auth_header",
|
|
8514
|
+
"authorization",
|
|
8515
|
+
"encryption_key",
|
|
8516
|
+
"master_key",
|
|
8517
|
+
"signing_key",
|
|
8518
|
+
"webhook_secret",
|
|
8519
|
+
"client_secret",
|
|
8520
|
+
"connection_string"
|
|
8521
|
+
],
|
|
8522
|
+
action: "redact",
|
|
8523
|
+
confidence: "high",
|
|
8524
|
+
reason: "Matches known secret/credential pattern"
|
|
8525
|
+
},
|
|
8526
|
+
// ── PII (always redact, high confidence) ─────────────────────────
|
|
8527
|
+
{
|
|
8528
|
+
patterns: [
|
|
8529
|
+
"name",
|
|
8530
|
+
"full_name",
|
|
8531
|
+
"first_name",
|
|
8532
|
+
"last_name",
|
|
8533
|
+
"display_name",
|
|
8534
|
+
"email",
|
|
8535
|
+
"email_address",
|
|
8536
|
+
"phone",
|
|
8537
|
+
"phone_number",
|
|
8538
|
+
"mobile",
|
|
8539
|
+
"address",
|
|
8540
|
+
"street_address",
|
|
8541
|
+
"mailing_address",
|
|
8542
|
+
"ssn",
|
|
8543
|
+
"social_security",
|
|
8544
|
+
"date_of_birth",
|
|
8545
|
+
"dob",
|
|
8546
|
+
"birthday",
|
|
8547
|
+
"ip_address",
|
|
8548
|
+
"ip",
|
|
8549
|
+
"location",
|
|
8550
|
+
"geolocation",
|
|
8551
|
+
"coordinates",
|
|
8552
|
+
"credit_card",
|
|
8553
|
+
"card_number",
|
|
8554
|
+
"cvv",
|
|
8555
|
+
"bank_account",
|
|
8556
|
+
"routing_number",
|
|
8557
|
+
"passport",
|
|
8558
|
+
"drivers_license",
|
|
8559
|
+
"license_number"
|
|
8560
|
+
],
|
|
8561
|
+
action: "redact",
|
|
8562
|
+
confidence: "high",
|
|
8563
|
+
reason: "Matches known PII pattern"
|
|
8564
|
+
},
|
|
8565
|
+
// ── Internal agent state (redact, high confidence) ───────────────
|
|
8566
|
+
{
|
|
8567
|
+
patterns: [
|
|
8568
|
+
"memory",
|
|
8569
|
+
"agent_memory",
|
|
8570
|
+
"long_term_memory",
|
|
8571
|
+
"internal_reasoning",
|
|
8572
|
+
"reasoning_trace",
|
|
8573
|
+
"chain_of_thought",
|
|
8574
|
+
"internal_state",
|
|
8575
|
+
"agent_state",
|
|
8576
|
+
"private_notes",
|
|
8577
|
+
"scratchpad",
|
|
8578
|
+
"soul",
|
|
8579
|
+
"personality",
|
|
8580
|
+
"persona",
|
|
8581
|
+
"system_prompt",
|
|
8582
|
+
"system_message",
|
|
8583
|
+
"system_instruction",
|
|
8584
|
+
"preferences",
|
|
8585
|
+
"user_preferences",
|
|
8586
|
+
"agent_preferences",
|
|
8587
|
+
"beliefs",
|
|
8588
|
+
"goals",
|
|
8589
|
+
"motivations"
|
|
8590
|
+
],
|
|
8591
|
+
action: "redact",
|
|
8592
|
+
confidence: "high",
|
|
8593
|
+
reason: "Matches known internal agent state pattern"
|
|
8594
|
+
},
|
|
8595
|
+
// ── IDs (hash, medium confidence) ────────────────────────────────
|
|
8596
|
+
{
|
|
8597
|
+
patterns: [
|
|
8598
|
+
"user_id",
|
|
8599
|
+
"userid",
|
|
8600
|
+
"session_id",
|
|
8601
|
+
"sessionid",
|
|
8602
|
+
"agent_id",
|
|
8603
|
+
"agentid",
|
|
8604
|
+
"identity_id",
|
|
8605
|
+
"conversation_id",
|
|
8606
|
+
"thread_id",
|
|
8607
|
+
"threadid",
|
|
8608
|
+
"request_id",
|
|
8609
|
+
"requestid",
|
|
8610
|
+
"correlation_id",
|
|
8611
|
+
"trace_id",
|
|
8612
|
+
"traceid",
|
|
8613
|
+
"account_id",
|
|
8614
|
+
"accountid"
|
|
8615
|
+
],
|
|
8616
|
+
action: "hash",
|
|
8617
|
+
confidence: "medium",
|
|
8618
|
+
reason: "Matches known identifier pattern \u2014 hash preserves correlation without exposing value"
|
|
8619
|
+
},
|
|
8620
|
+
// ── History (summarize, medium confidence) ───────────────────────
|
|
8621
|
+
{
|
|
8622
|
+
patterns: [
|
|
8623
|
+
"conversation_history",
|
|
8624
|
+
"chat_history",
|
|
8625
|
+
"message_history",
|
|
8626
|
+
"messages",
|
|
8627
|
+
"previous_messages",
|
|
8628
|
+
"prior_messages",
|
|
8629
|
+
"context_window",
|
|
8630
|
+
"interaction_history",
|
|
8631
|
+
"audit_log",
|
|
8632
|
+
"event_log"
|
|
8633
|
+
],
|
|
8634
|
+
action: "summarize",
|
|
8635
|
+
confidence: "medium",
|
|
8636
|
+
reason: "Matches known history/log pattern \u2014 summarize to reduce exposure"
|
|
8637
|
+
},
|
|
8638
|
+
// ── Task/query (allow, medium confidence) ────────────────────────
|
|
8639
|
+
{
|
|
8640
|
+
patterns: [
|
|
8641
|
+
"task",
|
|
8642
|
+
"task_description",
|
|
8643
|
+
"query",
|
|
8644
|
+
"current_query",
|
|
8645
|
+
"search_query",
|
|
8646
|
+
"prompt",
|
|
8647
|
+
"user_prompt",
|
|
8648
|
+
"question",
|
|
8649
|
+
"current_question",
|
|
8650
|
+
"instruction",
|
|
8651
|
+
"instructions",
|
|
8652
|
+
"objective",
|
|
8653
|
+
"goal",
|
|
8654
|
+
"current_step",
|
|
8655
|
+
"next_step",
|
|
8656
|
+
"remaining_steps",
|
|
8657
|
+
"constraints",
|
|
8658
|
+
"requirements",
|
|
8659
|
+
"output_format",
|
|
8660
|
+
"format",
|
|
8661
|
+
"tool_results",
|
|
8662
|
+
"tool_output",
|
|
8663
|
+
"tool_input",
|
|
8664
|
+
"tool_parameters"
|
|
8665
|
+
],
|
|
8666
|
+
action: "allow",
|
|
8667
|
+
confidence: "medium",
|
|
8668
|
+
reason: "Matches known task/query pattern \u2014 likely needed for inference"
|
|
8669
|
+
}
|
|
8670
|
+
];
|
|
8671
|
+
function classifyField(fieldName) {
|
|
8672
|
+
const normalized = fieldName.toLowerCase().trim();
|
|
8673
|
+
for (const rule of CLASSIFICATION_RULES) {
|
|
8674
|
+
for (const pattern of rule.patterns) {
|
|
8675
|
+
if (matchesFieldPattern(normalized, pattern)) {
|
|
8676
|
+
return {
|
|
8677
|
+
field: fieldName,
|
|
8678
|
+
recommended_action: rule.action,
|
|
8679
|
+
reason: rule.reason,
|
|
8680
|
+
confidence: rule.confidence,
|
|
8681
|
+
matched_pattern: pattern
|
|
8682
|
+
};
|
|
8683
|
+
}
|
|
8684
|
+
}
|
|
8685
|
+
}
|
|
8686
|
+
return {
|
|
8687
|
+
field: fieldName,
|
|
8688
|
+
recommended_action: "redact",
|
|
8689
|
+
reason: "No known pattern matched \u2014 defaulting to redact (conservative)",
|
|
8690
|
+
confidence: "low",
|
|
8691
|
+
matched_pattern: null
|
|
8692
|
+
};
|
|
8693
|
+
}
|
|
8694
|
+
function recommendPolicy(context, provider = "inference") {
|
|
8695
|
+
const fields = Object.keys(context);
|
|
8696
|
+
const classifications = fields.map(classifyField);
|
|
8697
|
+
const warnings = [];
|
|
8698
|
+
const allow = [];
|
|
8699
|
+
const redact = [];
|
|
8700
|
+
const hash2 = [];
|
|
8701
|
+
const summarize = [];
|
|
8702
|
+
for (const c of classifications) {
|
|
8703
|
+
switch (c.recommended_action) {
|
|
8704
|
+
case "allow":
|
|
8705
|
+
allow.push(c.field);
|
|
8706
|
+
break;
|
|
8707
|
+
case "redact":
|
|
8708
|
+
redact.push(c.field);
|
|
8709
|
+
break;
|
|
8710
|
+
case "hash":
|
|
8711
|
+
hash2.push(c.field);
|
|
8712
|
+
break;
|
|
8713
|
+
case "summarize":
|
|
8714
|
+
summarize.push(c.field);
|
|
8715
|
+
break;
|
|
8716
|
+
}
|
|
8717
|
+
}
|
|
8718
|
+
const lowConfidence = classifications.filter((c) => c.confidence === "low");
|
|
8719
|
+
if (lowConfidence.length > 0) {
|
|
8720
|
+
warnings.push(
|
|
8721
|
+
`${lowConfidence.length} field(s) could not be classified by pattern and will default to redact: ${lowConfidence.map((c) => c.field).join(", ")}. Review these manually.`
|
|
8722
|
+
);
|
|
8723
|
+
}
|
|
8724
|
+
for (const [key, value] of Object.entries(context)) {
|
|
8725
|
+
if (typeof value === "string" && value.length > 5e3) {
|
|
8726
|
+
const existing = classifications.find((c) => c.field === key);
|
|
8727
|
+
if (existing && existing.recommended_action === "allow") {
|
|
8728
|
+
warnings.push(
|
|
8729
|
+
`Field "${key}" is allowed but contains ${value.length} characters. Consider summarizing it to reduce context size and exposure.`
|
|
8730
|
+
);
|
|
8731
|
+
}
|
|
8732
|
+
}
|
|
8733
|
+
}
|
|
8734
|
+
return {
|
|
8735
|
+
provider,
|
|
8736
|
+
classifications,
|
|
8737
|
+
recommended_rules: { allow, redact, hash: hash2, summarize },
|
|
8738
|
+
default_action: "redact",
|
|
8739
|
+
summary: {
|
|
8740
|
+
total_fields: fields.length,
|
|
8741
|
+
allow: allow.length,
|
|
8742
|
+
redact: redact.length,
|
|
8743
|
+
hash: hash2.length,
|
|
8744
|
+
summarize: summarize.length
|
|
8745
|
+
},
|
|
8746
|
+
warnings
|
|
8747
|
+
};
|
|
8748
|
+
}
|
|
8749
|
+
function matchesFieldPattern(normalizedField, pattern) {
|
|
8750
|
+
if (normalizedField === pattern) return true;
|
|
8751
|
+
if (pattern.length >= 3 && normalizedField.includes(pattern)) {
|
|
8752
|
+
const idx = normalizedField.indexOf(pattern);
|
|
8753
|
+
const before = idx === 0 || normalizedField[idx - 1] === "_" || normalizedField[idx - 1] === "-";
|
|
8754
|
+
const after = idx + pattern.length === normalizedField.length || normalizedField[idx + pattern.length] === "_" || normalizedField[idx + pattern.length] === "-";
|
|
8755
|
+
return before && after;
|
|
8756
|
+
}
|
|
8757
|
+
return false;
|
|
8758
|
+
}
|
|
8759
|
+
|
|
8760
|
+
// src/l2-operational/context-gate-tools.ts
|
|
8761
|
+
function createContextGateTools(storage, masterKey, auditLog) {
|
|
8762
|
+
const policyStore = new ContextGatePolicyStore(storage, masterKey);
|
|
8763
|
+
const tools = [
|
|
8764
|
+
// ── Set Policy ──────────────────────────────────────────────────
|
|
8765
|
+
{
|
|
8766
|
+
name: "sanctuary/context_gate_set_policy",
|
|
8767
|
+
description: "Create a context-gating policy that controls what information flows to remote providers (LLM APIs, tool APIs, logging services). Each rule specifies a provider category and which context fields to allow, redact, hash, or flag for summarization. Redact rules take absolute priority \u2014 if a field is in both 'allow' and 'redact', it is redacted. Default action applies to any field not mentioned in any rule. Use this to prevent your full agent context from being sent to remote LLM providers during inference calls.",
|
|
8768
|
+
inputSchema: {
|
|
8769
|
+
type: "object",
|
|
8770
|
+
properties: {
|
|
8771
|
+
policy_name: {
|
|
8772
|
+
type: "string",
|
|
8773
|
+
description: "Human-readable name for this policy (e.g., 'inference-minimal', 'tool-api-strict')"
|
|
8774
|
+
},
|
|
8775
|
+
rules: {
|
|
8776
|
+
type: "array",
|
|
8777
|
+
description: "Array of rules. Each rule has: provider (inference|tool-api|logging|analytics|peer-agent|custom|*), allow (fields to pass through), redact (fields to remove \u2014 highest priority), hash (fields to replace with SHA-256 hash), summarize (fields to flag for compression).",
|
|
8778
|
+
items: {
|
|
8779
|
+
type: "object",
|
|
8780
|
+
properties: {
|
|
8781
|
+
provider: {
|
|
8782
|
+
type: "string",
|
|
8783
|
+
description: "Provider category: inference, tool-api, logging, analytics, peer-agent, custom, or * for all"
|
|
8784
|
+
},
|
|
8785
|
+
allow: {
|
|
8786
|
+
type: "array",
|
|
8787
|
+
items: { type: "string" },
|
|
8788
|
+
description: "Fields/patterns to allow through (e.g., 'task_description', 'current_query', 'tool_*')"
|
|
8789
|
+
},
|
|
8790
|
+
redact: {
|
|
8791
|
+
type: "array",
|
|
8792
|
+
items: { type: "string" },
|
|
8793
|
+
description: "Fields/patterns to redact (e.g., 'conversation_history', 'secret_*', '*_pii'). Takes absolute priority."
|
|
8794
|
+
},
|
|
8795
|
+
hash: {
|
|
8796
|
+
type: "array",
|
|
8797
|
+
items: { type: "string" },
|
|
8798
|
+
description: "Fields/patterns to replace with SHA-256 hash (e.g., 'user_id', 'session_id')"
|
|
8799
|
+
},
|
|
8800
|
+
summarize: {
|
|
8801
|
+
type: "array",
|
|
8802
|
+
items: { type: "string" },
|
|
8803
|
+
description: "Fields/patterns to flag for summarization (advisory \u2014 agent should compress these before sending)"
|
|
8804
|
+
}
|
|
8805
|
+
},
|
|
8806
|
+
required: ["provider", "allow", "redact"]
|
|
8807
|
+
}
|
|
8808
|
+
},
|
|
8809
|
+
default_action: {
|
|
8810
|
+
type: "string",
|
|
8811
|
+
enum: ["redact", "deny"],
|
|
8812
|
+
description: "Action for fields not matched by any rule. 'redact' removes the field value; 'deny' blocks the entire request. Default: 'redact'."
|
|
8813
|
+
},
|
|
8814
|
+
identity_id: {
|
|
8815
|
+
type: "string",
|
|
8816
|
+
description: "Bind this policy to a specific identity (optional)"
|
|
8817
|
+
}
|
|
8818
|
+
},
|
|
8819
|
+
required: ["policy_name", "rules"]
|
|
8820
|
+
},
|
|
8821
|
+
handler: async (args) => {
|
|
8822
|
+
const policyName = args.policy_name;
|
|
8823
|
+
const rawRules = args.rules;
|
|
8824
|
+
const defaultAction = args.default_action ?? "redact";
|
|
8825
|
+
const identityId = args.identity_id;
|
|
8826
|
+
if (!Array.isArray(rawRules)) {
|
|
8827
|
+
return toolResult({ error: "invalid_rules", message: "rules must be an array" });
|
|
8828
|
+
}
|
|
8829
|
+
if (rawRules.length > MAX_POLICY_RULES) {
|
|
8830
|
+
return toolResult({
|
|
8831
|
+
error: "too_many_rules",
|
|
8832
|
+
message: `Policy has ${rawRules.length} rules, exceeding limit of ${MAX_POLICY_RULES}`
|
|
8833
|
+
});
|
|
8834
|
+
}
|
|
8835
|
+
const rules = [];
|
|
8836
|
+
for (const r of rawRules) {
|
|
8837
|
+
const allow = Array.isArray(r.allow) ? r.allow : [];
|
|
8838
|
+
const redact = Array.isArray(r.redact) ? r.redact : [];
|
|
8839
|
+
const hash2 = Array.isArray(r.hash) ? r.hash : [];
|
|
8840
|
+
const summarize = Array.isArray(r.summarize) ? r.summarize : [];
|
|
8841
|
+
for (const [name, arr] of [["allow", allow], ["redact", redact], ["hash", hash2], ["summarize", summarize]]) {
|
|
8842
|
+
if (arr.length > MAX_PATTERNS_PER_ARRAY) {
|
|
8843
|
+
return toolResult({
|
|
8844
|
+
error: "too_many_patterns",
|
|
8845
|
+
message: `Rule ${name} array has ${arr.length} patterns, exceeding limit of ${MAX_PATTERNS_PER_ARRAY}`
|
|
8846
|
+
});
|
|
8847
|
+
}
|
|
8848
|
+
}
|
|
8849
|
+
rules.push({
|
|
8850
|
+
provider: r.provider ?? "*",
|
|
8851
|
+
allow,
|
|
8852
|
+
redact,
|
|
8853
|
+
hash: hash2,
|
|
8854
|
+
summarize
|
|
8855
|
+
});
|
|
8856
|
+
}
|
|
8857
|
+
const policy = await policyStore.create(
|
|
8858
|
+
policyName,
|
|
8859
|
+
rules,
|
|
8860
|
+
defaultAction,
|
|
8861
|
+
identityId
|
|
8862
|
+
);
|
|
8863
|
+
auditLog.append("l2", "context_gate_set_policy", identityId ?? "system", {
|
|
8864
|
+
policy_id: policy.policy_id,
|
|
8865
|
+
policy_name: policyName,
|
|
8866
|
+
rule_count: rules.length,
|
|
8867
|
+
default_action: defaultAction
|
|
8868
|
+
});
|
|
8869
|
+
return toolResult({
|
|
8870
|
+
policy_id: policy.policy_id,
|
|
8871
|
+
policy_name: policy.policy_name,
|
|
8872
|
+
rules: policy.rules,
|
|
8873
|
+
default_action: policy.default_action,
|
|
8874
|
+
created_at: policy.created_at,
|
|
8875
|
+
message: "Context-gating policy created. Use sanctuary/context_gate_filter to apply this policy before making outbound calls."
|
|
8876
|
+
});
|
|
8877
|
+
}
|
|
8878
|
+
},
|
|
8879
|
+
// ── Apply Template ───────────────────────────────────────────────
|
|
8880
|
+
{
|
|
8881
|
+
name: "sanctuary/context_gate_apply_template",
|
|
8882
|
+
description: "Apply a starter context-gating template. Available templates: inference-minimal (strictest \u2014 only task and query pass through), inference-standard (balanced \u2014 adds tool results, summarizes history), logging-strict (redacts all content for telemetry services), tool-api-scoped (allows tool parameters, redacts agent state). Templates are starting points \u2014 customize after applying.",
|
|
8883
|
+
inputSchema: {
|
|
8884
|
+
type: "object",
|
|
8885
|
+
properties: {
|
|
8886
|
+
template_id: {
|
|
8887
|
+
type: "string",
|
|
8888
|
+
description: "Template to apply: inference-minimal, inference-standard, logging-strict, or tool-api-scoped"
|
|
8889
|
+
},
|
|
8890
|
+
identity_id: {
|
|
8891
|
+
type: "string",
|
|
8892
|
+
description: "Bind this policy to a specific identity (optional)"
|
|
8893
|
+
}
|
|
8894
|
+
},
|
|
8895
|
+
required: ["template_id"]
|
|
8896
|
+
},
|
|
8897
|
+
handler: async (args) => {
|
|
8898
|
+
const templateId = args.template_id;
|
|
8899
|
+
const identityId = args.identity_id;
|
|
8900
|
+
const template = getTemplate(templateId);
|
|
8901
|
+
if (!template) {
|
|
8902
|
+
return toolResult({
|
|
8903
|
+
error: "template_not_found",
|
|
8904
|
+
message: `Unknown template "${templateId}"`,
|
|
8905
|
+
available_templates: listTemplateIds().map((id) => {
|
|
8906
|
+
const t = TEMPLATES[id];
|
|
8907
|
+
return { id, name: t.name, description: t.description };
|
|
8908
|
+
})
|
|
8909
|
+
});
|
|
8910
|
+
}
|
|
8911
|
+
const policy = await policyStore.create(
|
|
8912
|
+
template.name,
|
|
8913
|
+
template.rules,
|
|
8914
|
+
template.default_action,
|
|
8915
|
+
identityId
|
|
8916
|
+
);
|
|
8917
|
+
auditLog.append("l2", "context_gate_apply_template", identityId ?? "system", {
|
|
8918
|
+
policy_id: policy.policy_id,
|
|
8919
|
+
template_id: templateId
|
|
8920
|
+
});
|
|
8921
|
+
return toolResult({
|
|
8922
|
+
policy_id: policy.policy_id,
|
|
8923
|
+
template_applied: templateId,
|
|
8924
|
+
policy_name: template.name,
|
|
8925
|
+
description: template.description,
|
|
8926
|
+
use_when: template.use_when,
|
|
8927
|
+
rules: policy.rules,
|
|
8928
|
+
default_action: policy.default_action,
|
|
8929
|
+
created_at: policy.created_at,
|
|
8930
|
+
message: "Template applied. Use sanctuary/context_gate_filter with this policy_id to filter context before outbound calls. Customize rules with sanctuary/context_gate_set_policy if needed."
|
|
8931
|
+
});
|
|
8932
|
+
}
|
|
8933
|
+
},
|
|
8934
|
+
// ── Recommend Policy ────────────────────────────────────────────
|
|
8935
|
+
{
|
|
8936
|
+
name: "sanctuary/context_gate_recommend",
|
|
8937
|
+
description: "Analyze a sample context object and recommend a context-gating policy based on field name heuristics. Classifies each field as allow, redact, hash, or summarize with confidence levels. Returns a ready-to-apply rule set. When in doubt, recommends redact (conservative). Review the recommendations before applying.",
|
|
8938
|
+
inputSchema: {
|
|
8939
|
+
type: "object",
|
|
8940
|
+
properties: {
|
|
8941
|
+
context: {
|
|
8942
|
+
type: "object",
|
|
8943
|
+
description: "A sample context object to analyze. Each top-level key will be classified. Values are inspected for size warnings but not stored."
|
|
8944
|
+
},
|
|
8945
|
+
provider: {
|
|
8946
|
+
type: "string",
|
|
8947
|
+
description: "Provider category to generate rules for. Default: 'inference'."
|
|
8948
|
+
}
|
|
8949
|
+
},
|
|
8950
|
+
required: ["context"]
|
|
8951
|
+
},
|
|
8952
|
+
handler: async (args) => {
|
|
8953
|
+
const context = args.context;
|
|
8954
|
+
const provider = args.provider ?? "inference";
|
|
8955
|
+
const contextKeys = Object.keys(context);
|
|
8956
|
+
if (contextKeys.length > MAX_CONTEXT_FIELDS) {
|
|
8957
|
+
return toolResult({
|
|
8958
|
+
error: "context_too_large",
|
|
8959
|
+
message: `Context has ${contextKeys.length} fields, exceeding limit of ${MAX_CONTEXT_FIELDS}`
|
|
8960
|
+
});
|
|
8961
|
+
}
|
|
8962
|
+
const recommendation = recommendPolicy(context, provider);
|
|
8963
|
+
auditLog.append("l2", "context_gate_recommend", "system", {
|
|
8964
|
+
provider,
|
|
8965
|
+
fields_analyzed: recommendation.summary.total_fields,
|
|
8966
|
+
fields_allow: recommendation.summary.allow,
|
|
8967
|
+
fields_redact: recommendation.summary.redact,
|
|
8968
|
+
fields_hash: recommendation.summary.hash,
|
|
8969
|
+
fields_summarize: recommendation.summary.summarize
|
|
8970
|
+
});
|
|
8971
|
+
return toolResult({
|
|
8972
|
+
...recommendation,
|
|
8973
|
+
next_steps: "Review the classifications above. If they look correct, you can apply them directly with sanctuary/context_gate_set_policy using the recommended_rules. Or start with a template via sanctuary/context_gate_apply_template and customize from there.",
|
|
8974
|
+
available_templates: listTemplateIds().map((id) => {
|
|
8975
|
+
const t = TEMPLATES[id];
|
|
8976
|
+
return { id, name: t.name, description: t.description };
|
|
8977
|
+
})
|
|
8978
|
+
});
|
|
8979
|
+
}
|
|
8980
|
+
},
|
|
8981
|
+
// ── Filter Context ──────────────────────────────────────────────
|
|
8982
|
+
{
|
|
8983
|
+
name: "sanctuary/context_gate_filter",
|
|
8984
|
+
description: "Filter agent context through a gating policy before sending to a remote provider. Returns per-field decisions (allow, redact, hash, summarize) and content hashes for the audit trail. Call this BEFORE making any outbound API call to ensure you are only sending the minimum necessary context. The filtered output tells you exactly what can be sent safely.",
|
|
8985
|
+
inputSchema: {
|
|
8986
|
+
type: "object",
|
|
8987
|
+
properties: {
|
|
8988
|
+
policy_id: {
|
|
8989
|
+
type: "string",
|
|
8990
|
+
description: "ID of the context-gating policy to apply"
|
|
8991
|
+
},
|
|
8992
|
+
provider: {
|
|
8993
|
+
type: "string",
|
|
8994
|
+
description: "Provider category for this call: inference, tool-api, logging, analytics, peer-agent, or custom"
|
|
8995
|
+
},
|
|
8996
|
+
context: {
|
|
8997
|
+
type: "object",
|
|
8998
|
+
description: "The context object to filter. Each top-level key is evaluated against the policy. Example keys: task_description, conversation_history, user_preferences, api_keys, memory, internal_reasoning"
|
|
8999
|
+
}
|
|
9000
|
+
},
|
|
9001
|
+
required: ["policy_id", "provider", "context"]
|
|
9002
|
+
},
|
|
9003
|
+
handler: async (args) => {
|
|
9004
|
+
const policyId = args.policy_id;
|
|
9005
|
+
const provider = args.provider;
|
|
9006
|
+
const context = args.context;
|
|
9007
|
+
const contextKeys = Object.keys(context);
|
|
9008
|
+
if (contextKeys.length > MAX_CONTEXT_FIELDS) {
|
|
9009
|
+
return toolResult({
|
|
9010
|
+
error: "context_too_large",
|
|
9011
|
+
message: `Context has ${contextKeys.length} fields, exceeding limit of ${MAX_CONTEXT_FIELDS}`
|
|
9012
|
+
});
|
|
9013
|
+
}
|
|
9014
|
+
const policy = await policyStore.get(policyId);
|
|
9015
|
+
if (!policy) {
|
|
9016
|
+
return toolResult({
|
|
9017
|
+
error: "policy_not_found",
|
|
9018
|
+
message: `No context-gating policy found with ID "${policyId}"`
|
|
9019
|
+
});
|
|
9020
|
+
}
|
|
9021
|
+
const result = filterContext(policy, provider, context);
|
|
9022
|
+
const deniedFields = result.decisions.filter((d) => d.action === "deny");
|
|
9023
|
+
if (deniedFields.length > 0) {
|
|
9024
|
+
auditLog.append("l2", "context_gate_deny", policy.identity_id ?? "system", {
|
|
9025
|
+
policy_id: policyId,
|
|
9026
|
+
provider,
|
|
9027
|
+
denied_fields: deniedFields.map((d) => d.field),
|
|
9028
|
+
original_context_hash: result.original_context_hash
|
|
9029
|
+
});
|
|
9030
|
+
return toolResult({
|
|
9031
|
+
blocked: true,
|
|
9032
|
+
reason: "Context contains fields that trigger deny action",
|
|
9033
|
+
denied_fields: deniedFields.map((d) => ({
|
|
9034
|
+
field: d.field,
|
|
9035
|
+
reason: d.reason
|
|
9036
|
+
})),
|
|
9037
|
+
recommendation: "Remove the denied fields from context before retrying, or update the policy to handle these fields differently."
|
|
9038
|
+
});
|
|
9039
|
+
}
|
|
9040
|
+
const safeContext = {};
|
|
9041
|
+
for (const decision of result.decisions) {
|
|
9042
|
+
switch (decision.action) {
|
|
9043
|
+
case "allow":
|
|
9044
|
+
safeContext[decision.field] = context[decision.field];
|
|
9045
|
+
break;
|
|
9046
|
+
case "redact":
|
|
9047
|
+
break;
|
|
9048
|
+
case "hash":
|
|
9049
|
+
safeContext[decision.field] = decision.hash_value;
|
|
9050
|
+
break;
|
|
9051
|
+
case "summarize":
|
|
9052
|
+
safeContext[decision.field] = context[decision.field];
|
|
9053
|
+
break;
|
|
9054
|
+
}
|
|
9055
|
+
}
|
|
9056
|
+
auditLog.append("l2", "context_gate_filter", policy.identity_id ?? "system", {
|
|
9057
|
+
policy_id: policyId,
|
|
9058
|
+
provider,
|
|
9059
|
+
fields_total: Object.keys(context).length,
|
|
9060
|
+
fields_allowed: result.fields_allowed,
|
|
9061
|
+
fields_redacted: result.fields_redacted,
|
|
9062
|
+
fields_hashed: result.fields_hashed,
|
|
9063
|
+
fields_summarized: result.fields_summarized,
|
|
9064
|
+
original_context_hash: result.original_context_hash,
|
|
9065
|
+
filtered_context_hash: result.filtered_context_hash
|
|
9066
|
+
});
|
|
9067
|
+
return toolResult({
|
|
9068
|
+
blocked: false,
|
|
9069
|
+
safe_context: safeContext,
|
|
9070
|
+
summary: {
|
|
9071
|
+
total_fields: Object.keys(context).length,
|
|
9072
|
+
allowed: result.fields_allowed,
|
|
9073
|
+
redacted: result.fields_redacted,
|
|
9074
|
+
hashed: result.fields_hashed,
|
|
9075
|
+
summarized: result.fields_summarized
|
|
9076
|
+
},
|
|
9077
|
+
decisions: result.decisions,
|
|
9078
|
+
audit: {
|
|
9079
|
+
original_context_hash: result.original_context_hash,
|
|
9080
|
+
filtered_context_hash: result.filtered_context_hash,
|
|
9081
|
+
filtered_at: result.filtered_at
|
|
9082
|
+
},
|
|
9083
|
+
guidance: result.fields_summarized > 0 ? "Some fields are marked for summarization. Consider compressing them before sending to reduce context size and information exposure." : void 0
|
|
9084
|
+
});
|
|
9085
|
+
}
|
|
9086
|
+
},
|
|
9087
|
+
// ── List Policies ───────────────────────────────────────────────
|
|
9088
|
+
{
|
|
9089
|
+
name: "sanctuary/context_gate_list_policies",
|
|
9090
|
+
description: "List all configured context-gating policies. Returns policy IDs, names, rule summaries, and default actions.",
|
|
9091
|
+
inputSchema: {
|
|
9092
|
+
type: "object",
|
|
9093
|
+
properties: {}
|
|
9094
|
+
},
|
|
9095
|
+
handler: async () => {
|
|
9096
|
+
const policies = await policyStore.list();
|
|
9097
|
+
auditLog.append("l2", "context_gate_list_policies", "system", {
|
|
9098
|
+
policy_count: policies.length
|
|
9099
|
+
});
|
|
9100
|
+
return toolResult({
|
|
9101
|
+
policies: policies.map((p) => ({
|
|
9102
|
+
policy_id: p.policy_id,
|
|
9103
|
+
policy_name: p.policy_name,
|
|
9104
|
+
rule_count: p.rules.length,
|
|
9105
|
+
providers: p.rules.map((r) => r.provider),
|
|
9106
|
+
default_action: p.default_action,
|
|
9107
|
+
identity_id: p.identity_id ?? null,
|
|
9108
|
+
created_at: p.created_at,
|
|
9109
|
+
updated_at: p.updated_at
|
|
9110
|
+
})),
|
|
9111
|
+
count: policies.length,
|
|
9112
|
+
message: policies.length === 0 ? "No context-gating policies configured. Use sanctuary/context_gate_set_policy to create one." : `${policies.length} context-gating ${policies.length === 1 ? "policy" : "policies"} configured.`
|
|
9113
|
+
});
|
|
9114
|
+
}
|
|
9115
|
+
}
|
|
9116
|
+
];
|
|
9117
|
+
return { tools, policyStore };
|
|
9118
|
+
}
|
|
9119
|
+
function checkMemoryProtection() {
|
|
9120
|
+
const checks = {
|
|
9121
|
+
aslr_enabled: checkASLR(),
|
|
9122
|
+
stack_canaries: true,
|
|
9123
|
+
// Enabled by default in Node.js runtime
|
|
9124
|
+
secure_buffer_zeros: true,
|
|
9125
|
+
// We use crypto.randomBytes and explicit zeroing
|
|
9126
|
+
argon2id_kdf: true
|
|
9127
|
+
// Master key derivation uses Argon2id
|
|
9128
|
+
};
|
|
9129
|
+
const activeCount = Object.values(checks).filter((v) => v).length;
|
|
9130
|
+
const overall = activeCount >= 4 ? "full" : activeCount >= 3 ? "partial" : "minimal";
|
|
9131
|
+
return {
|
|
9132
|
+
...checks,
|
|
9133
|
+
overall
|
|
9134
|
+
};
|
|
9135
|
+
}
|
|
9136
|
+
function checkASLR() {
|
|
9137
|
+
if (process.platform === "linux") {
|
|
9138
|
+
try {
|
|
9139
|
+
const result = child_process.execSync("cat /proc/sys/kernel/randomize_va_space", {
|
|
9140
|
+
encoding: "utf-8",
|
|
9141
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
9142
|
+
}).trim();
|
|
9143
|
+
return result === "2";
|
|
9144
|
+
} catch {
|
|
9145
|
+
return false;
|
|
9146
|
+
}
|
|
9147
|
+
}
|
|
9148
|
+
if (process.platform === "darwin") {
|
|
9149
|
+
return true;
|
|
9150
|
+
}
|
|
9151
|
+
return false;
|
|
9152
|
+
}
|
|
9153
|
+
function checkProcessIsolation() {
|
|
9154
|
+
const isContainer = detectContainer();
|
|
9155
|
+
const isVM = detectVM();
|
|
9156
|
+
const isSandboxed = detectSandbox();
|
|
9157
|
+
let isolationLevel = "none";
|
|
9158
|
+
if (isContainer) isolationLevel = "hardened";
|
|
9159
|
+
else if (isVM) isolationLevel = "hardened";
|
|
9160
|
+
else if (isSandboxed) isolationLevel = "basic";
|
|
9161
|
+
const details = {};
|
|
9162
|
+
if (isContainer && isContainer !== true) details.container_type = isContainer;
|
|
9163
|
+
if (isVM && isVM !== true) details.vm_type = isVM;
|
|
9164
|
+
if (isSandboxed && isSandboxed !== true) details.sandbox_type = isSandboxed;
|
|
9165
|
+
return {
|
|
9166
|
+
isolation_level: isolationLevel,
|
|
9167
|
+
is_container: isContainer !== false,
|
|
9168
|
+
is_vm: isVM !== false,
|
|
9169
|
+
is_sandboxed: isSandboxed !== false,
|
|
9170
|
+
is_tee: false,
|
|
9171
|
+
details
|
|
9172
|
+
};
|
|
9173
|
+
}
|
|
9174
|
+
function detectContainer() {
|
|
9175
|
+
try {
|
|
9176
|
+
if (process.env.DOCKER_HOST) return "docker";
|
|
9177
|
+
try {
|
|
9178
|
+
fs.statSync("/.dockerenv");
|
|
9179
|
+
return "docker";
|
|
9180
|
+
} catch {
|
|
9181
|
+
}
|
|
9182
|
+
if (process.platform === "linux") {
|
|
9183
|
+
const cgroup = child_process.execSync("cat /proc/1/cgroup 2>/dev/null || echo ''", {
|
|
9184
|
+
encoding: "utf-8"
|
|
9185
|
+
});
|
|
9186
|
+
if (cgroup.includes("docker")) return "docker";
|
|
9187
|
+
if (cgroup.includes("lxc")) return "lxc";
|
|
9188
|
+
if (cgroup.includes("kubepods") || cgroup.includes("kubernetes")) return "kubernetes";
|
|
9189
|
+
}
|
|
9190
|
+
if (process.env.container === "podman") return "podman";
|
|
9191
|
+
if (process.env.CONTAINER_ID) return "oci";
|
|
9192
|
+
return false;
|
|
9193
|
+
} catch {
|
|
9194
|
+
return false;
|
|
9195
|
+
}
|
|
9196
|
+
}
|
|
9197
|
+
function detectVM() {
|
|
9198
|
+
if (process.platform === "linux") {
|
|
9199
|
+
try {
|
|
9200
|
+
const dmidecode = child_process.execSync("dmidecode -s system-product-name 2>/dev/null || echo ''", {
|
|
9201
|
+
encoding: "utf-8"
|
|
9202
|
+
}).toLowerCase();
|
|
9203
|
+
if (dmidecode.includes("vmware")) return "vmware";
|
|
9204
|
+
if (dmidecode.includes("virtualbox")) return "virtualbox";
|
|
9205
|
+
if (dmidecode.includes("kvm")) return "kvm";
|
|
9206
|
+
if (dmidecode.includes("xen")) return "xen";
|
|
9207
|
+
if (dmidecode.includes("hyper-v")) return "hyper-v";
|
|
9208
|
+
const cpuinfo = child_process.execSync("grep -i hypervisor /proc/cpuinfo || echo ''", {
|
|
9209
|
+
encoding: "utf-8"
|
|
9210
|
+
});
|
|
9211
|
+
if (cpuinfo.length > 0) return "detected";
|
|
9212
|
+
} catch {
|
|
9213
|
+
}
|
|
9214
|
+
}
|
|
9215
|
+
if (process.platform === "darwin") {
|
|
9216
|
+
try {
|
|
9217
|
+
const bootargs = child_process.execSync(
|
|
9218
|
+
"nvram boot-args 2>/dev/null | grep -i 'parallels\\|vmware\\|virtualbox' || echo ''",
|
|
9219
|
+
{
|
|
9220
|
+
encoding: "utf-8"
|
|
9221
|
+
}
|
|
9222
|
+
);
|
|
9223
|
+
if (bootargs.length > 0) return "detected";
|
|
9224
|
+
} catch {
|
|
9225
|
+
}
|
|
9226
|
+
}
|
|
9227
|
+
return false;
|
|
9228
|
+
}
|
|
9229
|
+
function detectSandbox() {
|
|
9230
|
+
if (process.platform === "darwin") {
|
|
9231
|
+
if (process.env.APP_SANDBOX_READ_ONLY_HOME === "1") return "app-sandbox";
|
|
9232
|
+
if (process.env.TMPDIR && process.env.TMPDIR.includes("AppSandbox")) return "app-sandbox";
|
|
9233
|
+
}
|
|
9234
|
+
if (process.platform === "openbsd") {
|
|
9235
|
+
try {
|
|
9236
|
+
const pledge = child_process.execSync("pledge -v 2>/dev/null || echo ''", {
|
|
9237
|
+
encoding: "utf-8"
|
|
9238
|
+
});
|
|
9239
|
+
if (pledge.length > 0) return "pledge";
|
|
9240
|
+
} catch {
|
|
9241
|
+
}
|
|
9242
|
+
}
|
|
9243
|
+
if (process.platform === "linux") {
|
|
9244
|
+
if (process.env.container === "lxc") return "lxc";
|
|
9245
|
+
try {
|
|
9246
|
+
const context = child_process.execSync("getenforce 2>/dev/null || echo ''", {
|
|
9247
|
+
encoding: "utf-8"
|
|
9248
|
+
}).trim();
|
|
9249
|
+
if (context === "Enforcing") return "selinux";
|
|
9250
|
+
} catch {
|
|
9251
|
+
}
|
|
9252
|
+
}
|
|
9253
|
+
return false;
|
|
9254
|
+
}
|
|
9255
|
+
function checkFilesystemPermissions(storagePath) {
|
|
9256
|
+
try {
|
|
9257
|
+
const stats = fs.statSync(storagePath);
|
|
9258
|
+
const mode = stats.mode & parseInt("777", 8);
|
|
9259
|
+
const modeString = mode.toString(8).padStart(3, "0");
|
|
9260
|
+
const isSecure = mode === parseInt("700", 8);
|
|
9261
|
+
const groupReadable = (mode & parseInt("040", 8)) !== 0;
|
|
9262
|
+
const othersReadable = (mode & parseInt("007", 8)) !== 0;
|
|
9263
|
+
const currentUid = process.getuid?.() || -1;
|
|
9264
|
+
const ownerIsCurrentUser = stats.uid === currentUid;
|
|
9265
|
+
let overall = "secure";
|
|
9266
|
+
if (groupReadable || othersReadable) overall = "insecure";
|
|
9267
|
+
else if (!ownerIsCurrentUser) overall = "warning";
|
|
9268
|
+
return {
|
|
9269
|
+
sanctuary_storage_protected: isSecure,
|
|
9270
|
+
sanctuary_storage_mode: modeString,
|
|
9271
|
+
owner_is_current_user: ownerIsCurrentUser,
|
|
9272
|
+
group_readable: groupReadable,
|
|
9273
|
+
others_readable: othersReadable,
|
|
9274
|
+
overall
|
|
9275
|
+
};
|
|
9276
|
+
} catch {
|
|
9277
|
+
return {
|
|
9278
|
+
sanctuary_storage_protected: false,
|
|
9279
|
+
sanctuary_storage_mode: "unknown",
|
|
9280
|
+
owner_is_current_user: false,
|
|
9281
|
+
group_readable: false,
|
|
9282
|
+
others_readable: false,
|
|
9283
|
+
overall: "warning"
|
|
9284
|
+
};
|
|
9285
|
+
}
|
|
9286
|
+
}
|
|
9287
|
+
function checkRuntimeIntegrity() {
|
|
9288
|
+
return {
|
|
9289
|
+
config_hash_stable: true,
|
|
9290
|
+
environment_state: "clean",
|
|
9291
|
+
discrepancies: []
|
|
9292
|
+
};
|
|
9293
|
+
}
|
|
9294
|
+
function assessL2Hardening(storagePath) {
|
|
9295
|
+
const memory = checkMemoryProtection();
|
|
9296
|
+
const isolation = checkProcessIsolation();
|
|
9297
|
+
const filesystem = checkFilesystemPermissions(storagePath);
|
|
9298
|
+
const integrity = checkRuntimeIntegrity();
|
|
9299
|
+
let checksPassed = 0;
|
|
9300
|
+
let checksTotal = 0;
|
|
9301
|
+
if (memory.aslr_enabled) checksPassed++;
|
|
9302
|
+
checksTotal++;
|
|
9303
|
+
if (memory.stack_canaries) checksPassed++;
|
|
9304
|
+
checksTotal++;
|
|
9305
|
+
if (memory.secure_buffer_zeros) checksPassed++;
|
|
9306
|
+
checksTotal++;
|
|
9307
|
+
if (memory.argon2id_kdf) checksPassed++;
|
|
9308
|
+
checksTotal++;
|
|
9309
|
+
if (isolation.is_container) checksPassed++;
|
|
9310
|
+
checksTotal++;
|
|
9311
|
+
if (isolation.is_vm) checksPassed++;
|
|
9312
|
+
checksTotal++;
|
|
9313
|
+
if (isolation.is_sandboxed) checksPassed++;
|
|
9314
|
+
checksTotal++;
|
|
9315
|
+
if (filesystem.sanctuary_storage_protected) checksPassed++;
|
|
9316
|
+
checksTotal++;
|
|
9317
|
+
{
|
|
9318
|
+
checksPassed++;
|
|
9319
|
+
}
|
|
9320
|
+
checksTotal++;
|
|
9321
|
+
let hardeningLevel = isolation.isolation_level;
|
|
9322
|
+
if (filesystem.overall === "insecure" || memory.overall === "none" || memory.overall === "minimal") {
|
|
9323
|
+
if (hardeningLevel === "hardened") {
|
|
9324
|
+
hardeningLevel = "basic";
|
|
9325
|
+
} else if (hardeningLevel === "basic") {
|
|
9326
|
+
hardeningLevel = "none";
|
|
9327
|
+
}
|
|
9328
|
+
}
|
|
9329
|
+
const summaryParts = [];
|
|
9330
|
+
if (isolation.is_container || isolation.is_vm) {
|
|
9331
|
+
summaryParts.push(`Running in ${isolation.details.container_type || isolation.details.vm_type || "isolated environment"}`);
|
|
9332
|
+
}
|
|
9333
|
+
if (memory.aslr_enabled) {
|
|
9334
|
+
summaryParts.push("ASLR enabled");
|
|
9335
|
+
}
|
|
9336
|
+
if (filesystem.sanctuary_storage_protected) {
|
|
9337
|
+
summaryParts.push("Storage permissions secured (0700)");
|
|
9338
|
+
}
|
|
9339
|
+
const summary = summaryParts.length > 0 ? summaryParts.join("; ") : "No process-level hardening detected";
|
|
9340
|
+
return {
|
|
9341
|
+
hardening_level: hardeningLevel,
|
|
9342
|
+
memory_protection: memory,
|
|
9343
|
+
process_isolation: isolation,
|
|
9344
|
+
filesystem_permissions: filesystem,
|
|
9345
|
+
runtime_integrity: integrity,
|
|
9346
|
+
checks_passed: checksPassed,
|
|
9347
|
+
checks_total: checksTotal,
|
|
9348
|
+
summary
|
|
9349
|
+
};
|
|
9350
|
+
}
|
|
9351
|
+
|
|
9352
|
+
// src/l2-operational/hardening-tools.ts
|
|
9353
|
+
function createL2HardeningTools(storagePath, auditLog) {
|
|
9354
|
+
return [
|
|
9355
|
+
{
|
|
9356
|
+
name: "sanctuary/l2_hardening_status",
|
|
9357
|
+
description: "L2 Process Hardening Status \u2014 Verify software-based operational isolation. Reports memory protection, process isolation level, filesystem permissions, and overall hardening assessment. Read-only. Tier 3 \u2014 always allowed.",
|
|
9358
|
+
inputSchema: {
|
|
9359
|
+
type: "object",
|
|
9360
|
+
properties: {
|
|
9361
|
+
include_details: {
|
|
9362
|
+
type: "boolean",
|
|
9363
|
+
description: "If true, include detailed check results for memory, process, and filesystem. If false, show summary only.",
|
|
9364
|
+
default: false
|
|
9365
|
+
}
|
|
9366
|
+
}
|
|
9367
|
+
},
|
|
9368
|
+
handler: async (args) => {
|
|
9369
|
+
const includeDetails = args.include_details ?? false;
|
|
9370
|
+
const status = assessL2Hardening(storagePath);
|
|
9371
|
+
auditLog.append(
|
|
9372
|
+
"l2",
|
|
9373
|
+
"l2_hardening_status",
|
|
9374
|
+
"system",
|
|
9375
|
+
{ include_details: includeDetails }
|
|
9376
|
+
);
|
|
9377
|
+
if (includeDetails) {
|
|
9378
|
+
return toolResult({
|
|
9379
|
+
hardening_level: status.hardening_level,
|
|
9380
|
+
summary: status.summary,
|
|
9381
|
+
checks_passed: status.checks_passed,
|
|
9382
|
+
checks_total: status.checks_total,
|
|
9383
|
+
memory_protection: {
|
|
9384
|
+
aslr_enabled: status.memory_protection.aslr_enabled,
|
|
9385
|
+
stack_canaries: status.memory_protection.stack_canaries,
|
|
9386
|
+
secure_buffer_zeros: status.memory_protection.secure_buffer_zeros,
|
|
9387
|
+
argon2id_kdf: status.memory_protection.argon2id_kdf,
|
|
9388
|
+
overall: status.memory_protection.overall
|
|
9389
|
+
},
|
|
9390
|
+
process_isolation: {
|
|
9391
|
+
isolation_level: status.process_isolation.isolation_level,
|
|
9392
|
+
is_container: status.process_isolation.is_container,
|
|
9393
|
+
is_vm: status.process_isolation.is_vm,
|
|
9394
|
+
is_sandboxed: status.process_isolation.is_sandboxed,
|
|
9395
|
+
is_tee: status.process_isolation.is_tee,
|
|
9396
|
+
details: status.process_isolation.details
|
|
9397
|
+
},
|
|
9398
|
+
filesystem_permissions: {
|
|
9399
|
+
sanctuary_storage_protected: status.filesystem_permissions.sanctuary_storage_protected,
|
|
9400
|
+
sanctuary_storage_mode: status.filesystem_permissions.sanctuary_storage_mode,
|
|
9401
|
+
owner_is_current_user: status.filesystem_permissions.owner_is_current_user,
|
|
9402
|
+
group_readable: status.filesystem_permissions.group_readable,
|
|
9403
|
+
others_readable: status.filesystem_permissions.others_readable,
|
|
9404
|
+
overall: status.filesystem_permissions.overall
|
|
9405
|
+
},
|
|
9406
|
+
runtime_integrity: {
|
|
9407
|
+
config_hash_stable: status.runtime_integrity.config_hash_stable,
|
|
9408
|
+
environment_state: status.runtime_integrity.environment_state,
|
|
9409
|
+
discrepancies: status.runtime_integrity.discrepancies
|
|
9410
|
+
}
|
|
9411
|
+
});
|
|
9412
|
+
} else {
|
|
9413
|
+
return toolResult({
|
|
9414
|
+
hardening_level: status.hardening_level,
|
|
9415
|
+
summary: status.summary,
|
|
9416
|
+
checks_passed: status.checks_passed,
|
|
9417
|
+
checks_total: status.checks_total,
|
|
9418
|
+
note: "Pass include_details: true to see full breakdown of memory, process isolation, and filesystem checks."
|
|
9419
|
+
});
|
|
9420
|
+
}
|
|
9421
|
+
}
|
|
9422
|
+
},
|
|
9423
|
+
{
|
|
9424
|
+
name: "sanctuary/l2_verify_isolation",
|
|
9425
|
+
description: "Verify L2 process isolation at runtime. Checks whether the Sanctuary server is running in an isolated environment (container, VM, sandbox) and validates filesystem and memory protections. Reports isolation level and any issues. Read-only. Tier 3 \u2014 always allowed.",
|
|
9426
|
+
inputSchema: {
|
|
9427
|
+
type: "object",
|
|
9428
|
+
properties: {
|
|
9429
|
+
check_filesystem: {
|
|
9430
|
+
type: "boolean",
|
|
9431
|
+
description: "If true, verify Sanctuary storage directory permissions.",
|
|
9432
|
+
default: true
|
|
9433
|
+
},
|
|
9434
|
+
check_memory: {
|
|
9435
|
+
type: "boolean",
|
|
9436
|
+
description: "If true, verify memory protection mechanisms (ASLR, etc.).",
|
|
9437
|
+
default: true
|
|
9438
|
+
},
|
|
9439
|
+
check_process: {
|
|
9440
|
+
type: "boolean",
|
|
9441
|
+
description: "If true, detect container, VM, or sandbox environment.",
|
|
9442
|
+
default: true
|
|
9443
|
+
}
|
|
9444
|
+
}
|
|
9445
|
+
},
|
|
9446
|
+
handler: async (args) => {
|
|
9447
|
+
const checkFilesystem = args.check_filesystem ?? true;
|
|
9448
|
+
const checkMemory = args.check_memory ?? true;
|
|
9449
|
+
const checkProcess = args.check_process ?? true;
|
|
9450
|
+
const status = assessL2Hardening(storagePath);
|
|
9451
|
+
auditLog.append(
|
|
9452
|
+
"l2",
|
|
9453
|
+
"l2_verify_isolation",
|
|
9454
|
+
"system",
|
|
9455
|
+
{
|
|
9456
|
+
check_filesystem: checkFilesystem,
|
|
9457
|
+
check_memory: checkMemory,
|
|
9458
|
+
check_process: checkProcess
|
|
9459
|
+
}
|
|
9460
|
+
);
|
|
9461
|
+
const results = {
|
|
9462
|
+
isolation_level: status.hardening_level,
|
|
9463
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
9464
|
+
};
|
|
9465
|
+
if (checkFilesystem) {
|
|
9466
|
+
const fs = status.filesystem_permissions;
|
|
9467
|
+
results.filesystem = {
|
|
9468
|
+
sanctuary_storage_protected: fs.sanctuary_storage_protected,
|
|
9469
|
+
storage_mode: fs.sanctuary_storage_mode,
|
|
9470
|
+
is_secure: fs.overall === "secure",
|
|
9471
|
+
issues: fs.overall === "insecure" ? [
|
|
9472
|
+
"Storage directory is readable by group or others. Recommend: chmod 700 on Sanctuary storage path."
|
|
9473
|
+
] : fs.overall === "warning" ? [
|
|
9474
|
+
"Storage directory not owned by current user. Verify correct user is running Sanctuary."
|
|
9475
|
+
] : []
|
|
9476
|
+
};
|
|
9477
|
+
}
|
|
9478
|
+
if (checkMemory) {
|
|
9479
|
+
const mem = status.memory_protection;
|
|
9480
|
+
const issues = [];
|
|
9481
|
+
if (!mem.aslr_enabled) {
|
|
9482
|
+
issues.push(
|
|
9483
|
+
"ASLR not detected. On Linux, enable with: echo 2 | sudo tee /proc/sys/kernel/randomize_va_space"
|
|
9484
|
+
);
|
|
9485
|
+
}
|
|
9486
|
+
results.memory = {
|
|
9487
|
+
aslr_enabled: mem.aslr_enabled,
|
|
9488
|
+
stack_canaries: mem.stack_canaries,
|
|
9489
|
+
secure_buffer_handling: mem.secure_buffer_zeros,
|
|
9490
|
+
argon2id_key_derivation: mem.argon2id_kdf,
|
|
9491
|
+
protection_level: mem.overall,
|
|
9492
|
+
issues
|
|
9493
|
+
};
|
|
9494
|
+
}
|
|
9495
|
+
if (checkProcess) {
|
|
9496
|
+
const iso = status.process_isolation;
|
|
9497
|
+
results.process = {
|
|
9498
|
+
isolation_level: iso.isolation_level,
|
|
9499
|
+
in_container: iso.is_container,
|
|
9500
|
+
in_vm: iso.is_vm,
|
|
9501
|
+
sandboxed: iso.is_sandboxed,
|
|
9502
|
+
has_tee: iso.is_tee,
|
|
9503
|
+
environment: iso.details,
|
|
9504
|
+
recommendation: iso.isolation_level === "none" ? "Consider running Sanctuary in a container or VM for improved isolation." : iso.isolation_level === "basic" ? "Basic isolation detected. Container or VM would provide stronger guarantees." : "Running in isolated environment \u2014 process-level isolation is strong."
|
|
9505
|
+
};
|
|
9506
|
+
}
|
|
9507
|
+
return toolResult({
|
|
9508
|
+
status: "verified",
|
|
9509
|
+
results
|
|
9510
|
+
});
|
|
9511
|
+
}
|
|
9512
|
+
}
|
|
9513
|
+
];
|
|
9514
|
+
}
|
|
9515
|
+
|
|
9516
|
+
// src/index.ts
|
|
9517
|
+
init_encoding();
|
|
9518
|
+
|
|
9519
|
+
// src/storage/memory.ts
|
|
9520
|
+
var MemoryStorage = class {
|
|
9521
|
+
store = /* @__PURE__ */ new Map();
|
|
9522
|
+
storageKey(namespace, key) {
|
|
9523
|
+
return `${namespace}/${key}`;
|
|
9524
|
+
}
|
|
9525
|
+
async write(namespace, key, data) {
|
|
9526
|
+
this.store.set(this.storageKey(namespace, key), {
|
|
9527
|
+
data: new Uint8Array(data),
|
|
9528
|
+
// Copy to prevent external mutation
|
|
9529
|
+
modified_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
9530
|
+
});
|
|
9531
|
+
}
|
|
9532
|
+
async read(namespace, key) {
|
|
9533
|
+
const entry = this.store.get(this.storageKey(namespace, key));
|
|
9534
|
+
if (!entry) return null;
|
|
9535
|
+
return new Uint8Array(entry.data);
|
|
9536
|
+
}
|
|
9537
|
+
async delete(namespace, key, _secureOverwrite) {
|
|
9538
|
+
return this.store.delete(this.storageKey(namespace, key));
|
|
9539
|
+
}
|
|
9540
|
+
async list(namespace, prefix) {
|
|
9541
|
+
const entries = [];
|
|
9542
|
+
const nsPrefix = `${namespace}/`;
|
|
9543
|
+
for (const [storeKey, entry] of this.store) {
|
|
9544
|
+
if (!storeKey.startsWith(nsPrefix)) continue;
|
|
9545
|
+
const key = storeKey.slice(nsPrefix.length);
|
|
9546
|
+
if (prefix && !key.startsWith(prefix)) continue;
|
|
9547
|
+
entries.push({
|
|
9548
|
+
key,
|
|
9549
|
+
namespace,
|
|
9550
|
+
size_bytes: entry.data.length,
|
|
9551
|
+
modified_at: entry.modified_at
|
|
9552
|
+
});
|
|
9553
|
+
}
|
|
9554
|
+
return entries.sort((a, b) => a.key.localeCompare(b.key));
|
|
9555
|
+
}
|
|
9556
|
+
async exists(namespace, key) {
|
|
9557
|
+
return this.store.has(this.storageKey(namespace, key));
|
|
9558
|
+
}
|
|
9559
|
+
async totalSize() {
|
|
9560
|
+
let total = 0;
|
|
9561
|
+
for (const entry of this.store.values()) {
|
|
9562
|
+
total += entry.data.length;
|
|
9563
|
+
}
|
|
9564
|
+
return total;
|
|
9565
|
+
}
|
|
9566
|
+
/** Clear all stored data (useful in tests) */
|
|
9567
|
+
clear() {
|
|
9568
|
+
this.store.clear();
|
|
9569
|
+
}
|
|
9570
|
+
};
|
|
9571
|
+
|
|
9572
|
+
// src/index.ts
|
|
9573
|
+
async function createSanctuaryServer(options) {
|
|
9574
|
+
const config = await loadConfig(options?.configPath);
|
|
9575
|
+
await promises.mkdir(config.storage_path, { recursive: true, mode: 448 });
|
|
9576
|
+
const storage = options?.storage ?? new FilesystemStorage(
|
|
9577
|
+
`${config.storage_path}/state`
|
|
9578
|
+
);
|
|
9579
|
+
let masterKey;
|
|
9580
|
+
let keyProtection;
|
|
9581
|
+
let recoveryKey;
|
|
9582
|
+
const passphrase = options?.passphrase ?? process.env.SANCTUARY_PASSPHRASE;
|
|
9583
|
+
if (passphrase) {
|
|
9584
|
+
keyProtection = "passphrase";
|
|
9585
|
+
let existingParams;
|
|
9586
|
+
try {
|
|
9587
|
+
const raw = await storage.read("_meta", "key-params");
|
|
7647
9588
|
if (raw) {
|
|
7648
9589
|
const { bytesToString: bytesToString2 } = await Promise.resolve().then(() => (init_encoding(), encoding_exports));
|
|
7649
9590
|
existingParams = JSON.parse(bytesToString2(raw));
|
|
@@ -7793,7 +9734,7 @@ async function createSanctuaryServer(options) {
|
|
|
7793
9734
|
layer: "l2",
|
|
7794
9735
|
description: "Process-level isolation only (no TEE)",
|
|
7795
9736
|
severity: "warning",
|
|
7796
|
-
mitigation: "TEE support planned for
|
|
9737
|
+
mitigation: "TEE support planned for a future release"
|
|
7797
9738
|
});
|
|
7798
9739
|
if (config.disclosure.proof_system === "commitment-only") {
|
|
7799
9740
|
degradations.push({
|
|
@@ -7933,7 +9874,7 @@ async function createSanctuaryServer(options) {
|
|
|
7933
9874
|
},
|
|
7934
9875
|
limitations: [
|
|
7935
9876
|
"L1 identity uses ed25519 only; KERI support planned for v0.2.0",
|
|
7936
|
-
"L2 isolation is process-level only; TEE support planned for
|
|
9877
|
+
"L2 isolation is process-level only; TEE support planned for a future release",
|
|
7937
9878
|
"L3 uses commitment schemes only; ZK proofs planned for v0.2.0",
|
|
7938
9879
|
"L4 Sybil resistance is escrow-based only",
|
|
7939
9880
|
"Spec license: CC-BY-4.0 | Code license: Apache-2.0"
|
|
@@ -7954,7 +9895,7 @@ async function createSanctuaryServer(options) {
|
|
|
7954
9895
|
masterKey,
|
|
7955
9896
|
auditLog
|
|
7956
9897
|
);
|
|
7957
|
-
const { tools: l4Tools
|
|
9898
|
+
const { tools: l4Tools} = createL4Tools(
|
|
7958
9899
|
storage,
|
|
7959
9900
|
masterKey,
|
|
7960
9901
|
identityManager,
|
|
@@ -7973,6 +9914,12 @@ async function createSanctuaryServer(options) {
|
|
|
7973
9914
|
handshakeResults
|
|
7974
9915
|
);
|
|
7975
9916
|
const { tools: auditTools } = createAuditTools(config);
|
|
9917
|
+
const { tools: contextGateTools } = createContextGateTools(
|
|
9918
|
+
storage,
|
|
9919
|
+
masterKey,
|
|
9920
|
+
auditLog
|
|
9921
|
+
);
|
|
9922
|
+
const hardeningTools = createL2HardeningTools(config.storage_path, auditLog);
|
|
7976
9923
|
const policy = await loadPrincipalPolicy(config.storage_path);
|
|
7977
9924
|
const baseline = new BaselineTracker(storage, masterKey);
|
|
7978
9925
|
await baseline.load();
|
|
@@ -8022,6 +9969,8 @@ async function createSanctuaryServer(options) {
|
|
|
8022
9969
|
...federationTools,
|
|
8023
9970
|
...bridgeTools,
|
|
8024
9971
|
...auditTools,
|
|
9972
|
+
...contextGateTools,
|
|
9973
|
+
...hardeningTools,
|
|
8025
9974
|
manifestTool
|
|
8026
9975
|
];
|
|
8027
9976
|
const server = createServer(allTools, { gate });
|
|
@@ -8051,8 +10000,10 @@ exports.ApprovalGate = ApprovalGate;
|
|
|
8051
10000
|
exports.AuditLog = AuditLog;
|
|
8052
10001
|
exports.AutoApproveChannel = AutoApproveChannel;
|
|
8053
10002
|
exports.BaselineTracker = BaselineTracker;
|
|
10003
|
+
exports.CONTEXT_GATE_TEMPLATES = TEMPLATES;
|
|
8054
10004
|
exports.CallbackApprovalChannel = CallbackApprovalChannel;
|
|
8055
10005
|
exports.CommitmentStore = CommitmentStore;
|
|
10006
|
+
exports.ContextGatePolicyStore = ContextGatePolicyStore;
|
|
8056
10007
|
exports.DashboardApprovalChannel = DashboardApprovalChannel;
|
|
8057
10008
|
exports.FederationRegistry = FederationRegistry;
|
|
8058
10009
|
exports.FilesystemStorage = FilesystemStorage;
|
|
@@ -8064,6 +10015,7 @@ exports.StderrApprovalChannel = StderrApprovalChannel;
|
|
|
8064
10015
|
exports.TIER_WEIGHTS = TIER_WEIGHTS;
|
|
8065
10016
|
exports.WebhookApprovalChannel = WebhookApprovalChannel;
|
|
8066
10017
|
exports.canonicalize = canonicalize;
|
|
10018
|
+
exports.classifyField = classifyField;
|
|
8067
10019
|
exports.completeHandshake = completeHandshake;
|
|
8068
10020
|
exports.computeWeightedScore = computeWeightedScore;
|
|
8069
10021
|
exports.createBridgeCommitment = createBridgeCommitment;
|
|
@@ -8071,10 +10023,15 @@ exports.createPedersenCommitment = createPedersenCommitment;
|
|
|
8071
10023
|
exports.createProofOfKnowledge = createProofOfKnowledge;
|
|
8072
10024
|
exports.createRangeProof = createRangeProof;
|
|
8073
10025
|
exports.createSanctuaryServer = createSanctuaryServer;
|
|
10026
|
+
exports.evaluateField = evaluateField;
|
|
10027
|
+
exports.filterContext = filterContext;
|
|
8074
10028
|
exports.generateSHR = generateSHR;
|
|
10029
|
+
exports.getTemplate = getTemplate;
|
|
8075
10030
|
exports.initiateHandshake = initiateHandshake;
|
|
10031
|
+
exports.listTemplateIds = listTemplateIds;
|
|
8076
10032
|
exports.loadConfig = loadConfig;
|
|
8077
10033
|
exports.loadPrincipalPolicy = loadPrincipalPolicy;
|
|
10034
|
+
exports.recommendPolicy = recommendPolicy;
|
|
8078
10035
|
exports.resolveTier = resolveTier;
|
|
8079
10036
|
exports.respondToHandshake = respondToHandshake;
|
|
8080
10037
|
exports.signPayload = signPayload;
|