cortexhub 0.5.5__tar.gz → 0.5.7__tar.gz
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.
- {cortexhub-0.5.5 → cortexhub-0.5.7}/PKG-INFO +1 -1
- {cortexhub-0.5.5 → cortexhub-0.5.7}/pyproject.toml +1 -1
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/backend/client.py +56 -1
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/client.py +117 -5
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/policy/evaluator.py +16 -15
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/version.py +1 -1
- {cortexhub-0.5.5 → cortexhub-0.5.7}/.gitignore +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/LICENSE +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/README.md +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/__init__.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/audit/__init__.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/audit/events.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/backend/__init__.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/config.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/constants.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/context/__init__.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/context/enricher.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/errors.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/__init__.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/injection.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/__init__.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/LICENSE +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/LICENSES_SOURCES +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/README.md +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/accuracy.json +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/attribute_ruler/patterns +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/config.cfg +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/lemmatizer/lookups/lookups.bin +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/meta.json +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/cfg +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/model +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/moves +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/cfg +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/model +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/moves +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/senter/cfg +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/senter/model +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tagger/cfg +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tagger/model +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tok2vec/cfg +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tok2vec/model +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tokenizer +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/key2row +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/lookups.bin +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/strings.json +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/vectors +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/vectors.cfg +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/meta.json +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/pii.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/secrets.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/interceptors/__init__.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/interceptors/mcp.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/logging.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/policy/__init__.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/policy/absence.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/policy/effects.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/policy/loader.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/policy/models.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/policy/sync.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/signing.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/telemetry/__init__.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/telemetry/otel.py +0 -0
- {cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/tool.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cortexhub
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.7
|
|
4
4
|
Summary: CortexHub Python SDK — Runtime governance for AI systems. One decorator, any tool, any framework.
|
|
5
5
|
Project-URL: Homepage, https://cortexhub.ai
|
|
6
6
|
Project-URL: Documentation, https://docs.cortexhub.ai
|
|
@@ -168,8 +168,34 @@ class BackendClient:
|
|
|
168
168
|
(is_valid, SDKConfig or None)
|
|
169
169
|
|
|
170
170
|
SDKConfig includes governed ``agent_id`` (ObjectId string), display metadata, and policies.
|
|
171
|
+
|
|
172
|
+
Side effects: stores a machine-readable failure hint on
|
|
173
|
+
``self.last_validation_error_kind`` so the outer ``CortexHub``
|
|
174
|
+
init can emit an actionable message instead of a generic
|
|
175
|
+
"rotate your key." Possible values:
|
|
176
|
+
|
|
177
|
+
* ``"network"`` — DNS/TLS/connection/timeout failure. The
|
|
178
|
+
key was never checked. Tell the user to check network,
|
|
179
|
+
VPN, or flush DNS cache.
|
|
180
|
+
* ``"rejected"`` — Backend returned a well-formed
|
|
181
|
+
``{valid: false}`` or a 401/403. The key is genuinely
|
|
182
|
+
wrong / revoked.
|
|
183
|
+
* ``"http_error"`` — Backend returned a non-200 with no
|
|
184
|
+
parseable body (5xx, upstream hiccup). Transient.
|
|
185
|
+
* ``"malformed_response"`` — 200 but body not JSON / missing
|
|
186
|
+
fields. Version drift between SDK and backend.
|
|
187
|
+
* ``"unconfigured"`` — No agent key at all.
|
|
188
|
+
* ``None`` — success, or never attempted.
|
|
171
189
|
"""
|
|
190
|
+
self.last_validation_error_kind: str | None = None
|
|
191
|
+
self.last_validation_error_detail: str | None = None
|
|
192
|
+
|
|
172
193
|
if not self.agent_key or not self._client:
|
|
194
|
+
self.last_validation_error_kind = "unconfigured"
|
|
195
|
+
self.last_validation_error_detail = (
|
|
196
|
+
"No agent key supplied — set CORTEXHUB_AGENT_KEY or "
|
|
197
|
+
"pass ``agent_key=`` to ``cortexhub.init()``."
|
|
198
|
+
)
|
|
173
199
|
return False, None
|
|
174
200
|
|
|
175
201
|
try:
|
|
@@ -196,11 +222,21 @@ class BackendClient:
|
|
|
196
222
|
preview=(response.text or "")[:300],
|
|
197
223
|
error=str(parse_err),
|
|
198
224
|
)
|
|
225
|
+
self.last_validation_error_kind = "malformed_response"
|
|
226
|
+
self.last_validation_error_detail = (
|
|
227
|
+
"Backend returned 200 but body was not JSON — "
|
|
228
|
+
"likely an SDK/backend version mismatch."
|
|
229
|
+
)
|
|
199
230
|
return False, None
|
|
200
231
|
|
|
201
232
|
# Check if valid
|
|
202
233
|
if not data.get("valid", False):
|
|
203
234
|
logger.warning("Agent key validation failed", message=data.get("message"))
|
|
235
|
+
self.last_validation_error_kind = "rejected"
|
|
236
|
+
self.last_validation_error_detail = (
|
|
237
|
+
data.get("message")
|
|
238
|
+
or "Backend returned valid=false without detail."
|
|
239
|
+
)
|
|
204
240
|
return False, None
|
|
205
241
|
|
|
206
242
|
# Parse policy bundle from backend
|
|
@@ -418,16 +454,35 @@ class BackendClient:
|
|
|
418
454
|
(response.text or "")[:500] or f"HTTP {response.status_code}"
|
|
419
455
|
)
|
|
420
456
|
logger.warning("Agent key validation failed", error=error_detail)
|
|
457
|
+
# 401/403 are authoritative rejections; 5xx / other codes
|
|
458
|
+
# are transient HTTP errors that shouldn't trigger a
|
|
459
|
+
# "rotate your key" panic in the outer init.
|
|
460
|
+
if response.status_code in (401, 403):
|
|
461
|
+
self.last_validation_error_kind = "rejected"
|
|
462
|
+
else:
|
|
463
|
+
self.last_validation_error_kind = "http_error"
|
|
464
|
+
self.last_validation_error_detail = (
|
|
465
|
+
f"HTTP {response.status_code}: {error_detail}"
|
|
466
|
+
)
|
|
421
467
|
return False, None
|
|
422
468
|
|
|
423
|
-
except httpx.ConnectError:
|
|
469
|
+
except (httpx.ConnectError, httpx.ConnectTimeout, httpx.ReadTimeout) as e:
|
|
424
470
|
logger.warning(
|
|
425
471
|
"Backend unreachable - running in offline observation mode",
|
|
426
472
|
backend_url=self.backend_url,
|
|
473
|
+
error=str(e),
|
|
474
|
+
)
|
|
475
|
+
self.last_validation_error_kind = "network"
|
|
476
|
+
self.last_validation_error_detail = (
|
|
477
|
+
f"Could not reach {self.backend_url}: {type(e).__name__} — {e}. "
|
|
478
|
+
"Check DNS / VPN / firewall; the agent key itself was "
|
|
479
|
+
"never sent to the backend."
|
|
427
480
|
)
|
|
428
481
|
return False, None
|
|
429
482
|
except Exception as e:
|
|
430
483
|
logger.error("Agent key validation error", error=str(e))
|
|
484
|
+
self.last_validation_error_kind = "http_error"
|
|
485
|
+
self.last_validation_error_detail = f"{type(e).__name__}: {e}"
|
|
431
486
|
return False, None
|
|
432
487
|
|
|
433
488
|
def close(self):
|
|
@@ -387,11 +387,67 @@ class CortexHub:
|
|
|
387
387
|
)
|
|
388
388
|
self.agent_id = os.getenv("CORTEXHUB_OFFLINE_AGENT_ID", "offline")
|
|
389
389
|
else:
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
390
|
+
# Emit a targeted error based on WHY validation failed.
|
|
391
|
+
# The generic "rotate your key" message sent users on
|
|
392
|
+
# wild goose chases every time DNS / VPN / a transient
|
|
393
|
+
# 5xx hiccuped — the key was never actually rejected
|
|
394
|
+
# in those cases. ``BackendClient.validate_agent_key``
|
|
395
|
+
# stores the failure kind on the client so we can be
|
|
396
|
+
# specific here.
|
|
397
|
+
kind = getattr(self.backend, "last_validation_error_kind", None)
|
|
398
|
+
detail = getattr(self.backend, "last_validation_error_detail", None)
|
|
399
|
+
if kind == "network":
|
|
400
|
+
message = (
|
|
401
|
+
"Could not reach the CortexHub backend — the agent "
|
|
402
|
+
"key was never validated.\n"
|
|
403
|
+
f" Reason: {detail}\n"
|
|
404
|
+
" Fixes in order of likelihood:\n"
|
|
405
|
+
" 1. Check that you're online and DNS is working "
|
|
406
|
+
"(``dig api.cortexhub.ai``). On macOS, flush a stale "
|
|
407
|
+
"cache with ``sudo dscacheutil -flushcache && sudo "
|
|
408
|
+
"killall -HUP mDNSResponder``.\n"
|
|
409
|
+
" 2. If on a corporate VPN, confirm it isn't "
|
|
410
|
+
"blocking api.cortexhub.ai.\n"
|
|
411
|
+
" 3. If this is a restricted environment, run "
|
|
412
|
+
"with ``CORTEXHUB_ALLOW_OFFLINE_ENFORCEMENT=true`` "
|
|
413
|
+
"and a cached policy bundle on disk."
|
|
414
|
+
)
|
|
415
|
+
elif kind == "rejected":
|
|
416
|
+
message = (
|
|
417
|
+
"The CortexHub backend rejected the agent key. It "
|
|
418
|
+
"is missing, wrong, or has been revoked.\n"
|
|
419
|
+
f" Backend said: {detail}\n"
|
|
420
|
+
" Create or rotate the key in "
|
|
421
|
+
"https://app.cortexhub.ai and update the "
|
|
422
|
+
"``CORTEXHUB_AGENT_KEY`` environment variable "
|
|
423
|
+
"(or the ``agent_key=`` argument to ``cortexhub.init()``)."
|
|
424
|
+
)
|
|
425
|
+
elif kind == "unconfigured":
|
|
426
|
+
message = (
|
|
427
|
+
"No agent key supplied. Set "
|
|
428
|
+
"``CORTEXHUB_AGENT_KEY`` in your environment, "
|
|
429
|
+
"or pass ``agent_key=...`` to ``cortexhub.init()``.\n"
|
|
430
|
+
" Get a key from https://app.cortexhub.ai."
|
|
431
|
+
)
|
|
432
|
+
elif kind == "malformed_response":
|
|
433
|
+
message = (
|
|
434
|
+
"The CortexHub backend returned an unexpected "
|
|
435
|
+
"response to the validate call — likely an SDK / "
|
|
436
|
+
"backend version mismatch.\n"
|
|
437
|
+
f" Detail: {detail}\n"
|
|
438
|
+
" Try ``pip install -U cortexhub``. If the problem "
|
|
439
|
+
"persists, share this message with the CortexHub team."
|
|
440
|
+
)
|
|
441
|
+
else: # "http_error" or unknown
|
|
442
|
+
message = (
|
|
443
|
+
"Agent key validation failed with an unexpected "
|
|
444
|
+
"error — the key itself may still be valid.\n"
|
|
445
|
+
f" Detail: {detail}\n"
|
|
446
|
+
" This is usually transient. Retry in a few seconds. "
|
|
447
|
+
"If it persists, check the CortexHub status page or "
|
|
448
|
+
"contact support."
|
|
449
|
+
)
|
|
450
|
+
raise ConfigurationError(message)
|
|
395
451
|
else:
|
|
396
452
|
self._apply_sdk_config(sdk_config)
|
|
397
453
|
if not sdk_config.has_policies:
|
|
@@ -1767,6 +1823,18 @@ class CortexHub:
|
|
|
1767
1823
|
)
|
|
1768
1824
|
span.set_attribute("cortexhub.policy.decision", decision.effect.value)
|
|
1769
1825
|
|
|
1826
|
+
# Observe-mode dry-run audit. When the evaluator
|
|
1827
|
+
# rewrote a blocking decision to PERMIT under
|
|
1828
|
+
# Observe, would_have_effect carries the original
|
|
1829
|
+
# outcome. Surface it on the span so the Decisions
|
|
1830
|
+
# page can show "permitted this time, but your
|
|
1831
|
+
# policy would have denied under Enforce".
|
|
1832
|
+
if decision and getattr(decision, "would_have_effect", None):
|
|
1833
|
+
span.set_attribute(
|
|
1834
|
+
"cortexhub.policy.would_have_effect",
|
|
1835
|
+
decision.would_have_effect,
|
|
1836
|
+
)
|
|
1837
|
+
|
|
1770
1838
|
# MODIFY and DEFER must not silently fall through to
|
|
1771
1839
|
# ``call_original()``. The in‑process closure already
|
|
1772
1840
|
# captured the original args, so we can't safely rewrite
|
|
@@ -1922,6 +1990,20 @@ class CortexHub:
|
|
|
1922
1990
|
_this_tool_governed_a = bool(
|
|
1923
1991
|
_tool_policies_a and isinstance(_tool_policies_a, dict) and tool_name in _tool_policies_a
|
|
1924
1992
|
)
|
|
1993
|
+
# Async interceptor path (e.g. MCP client wrapper) doesn't
|
|
1994
|
+
# receive a ``classification`` kwarg — the caller is a runtime
|
|
1995
|
+
# interceptor, not a decorator. Look up the classification from
|
|
1996
|
+
# the bundle's ``tool_classifications`` map instead so the span
|
|
1997
|
+
# still carries the same attribute the sync path emits. Fall
|
|
1998
|
+
# back to ``None`` (attribute omitted) if unknown.
|
|
1999
|
+
_classification_a: str | None = None
|
|
2000
|
+
_tool_classifications_a = (
|
|
2001
|
+
getattr(_tp_a, "tool_classifications", None) if _tp_a else None
|
|
2002
|
+
)
|
|
2003
|
+
if isinstance(_tool_classifications_a, dict):
|
|
2004
|
+
_cls_entry = _tool_classifications_a.get(tool_name)
|
|
2005
|
+
if isinstance(_cls_entry, dict):
|
|
2006
|
+
_classification_a = _cls_entry.get("bucket")
|
|
1925
2007
|
|
|
1926
2008
|
# Step 3: Create tool.invoke span
|
|
1927
2009
|
with self._tracer.start_as_current_span(
|
|
@@ -1933,6 +2015,24 @@ class CortexHub:
|
|
|
1933
2015
|
span.set_attribute("cortexhub.tool.name", tool_name)
|
|
1934
2016
|
span.set_attribute("cortexhub.tool.framework", framework)
|
|
1935
2017
|
span.set_attribute("cortexhub.tool.governed", _this_tool_governed_a)
|
|
2018
|
+
# Parity with the sync path: emit the tool classification
|
|
2019
|
+
# (looked up from the bundle on the async/interceptor path
|
|
2020
|
+
# because the caller is a runtime interceptor, not a
|
|
2021
|
+
# decorator) and its source on every span. Without this,
|
|
2022
|
+
# async-executed tools were silently missing the data the
|
|
2023
|
+
# backend uses to populate ``ToolInventory`` and the Type
|
|
2024
|
+
# badge in the UI.
|
|
2025
|
+
if _classification_a:
|
|
2026
|
+
span.set_attribute(
|
|
2027
|
+
"cortexhub.tool.classification", _classification_a
|
|
2028
|
+
)
|
|
2029
|
+
# On this path the classification came from the bundle
|
|
2030
|
+
# (i.e. whatever was decided on the server — connector
|
|
2031
|
+
# classifier, operator override, or an earlier SDK
|
|
2032
|
+
# span). Label the source accordingly.
|
|
2033
|
+
span.set_attribute(
|
|
2034
|
+
"cortexhub.tool.classification_source", "policy_bundle"
|
|
2035
|
+
)
|
|
1936
2036
|
# Per-tool governance mode + default decision — see the sync
|
|
1937
2037
|
# path for the full rationale. Keeps both execution paths
|
|
1938
2038
|
# emitting the same shape so the ingest pipeline is path-agnostic.
|
|
@@ -2190,6 +2290,18 @@ class CortexHub:
|
|
|
2190
2290
|
)
|
|
2191
2291
|
span.set_attribute("cortexhub.policy.decision", decision.effect.value)
|
|
2192
2292
|
|
|
2293
|
+
# Observe-mode dry-run audit. When the evaluator
|
|
2294
|
+
# rewrote a blocking decision to PERMIT under
|
|
2295
|
+
# Observe, would_have_effect carries the original
|
|
2296
|
+
# outcome. Surface it on the span so the Decisions
|
|
2297
|
+
# page can show "permitted this time, but your
|
|
2298
|
+
# policy would have denied under Enforce".
|
|
2299
|
+
if decision and getattr(decision, "would_have_effect", None):
|
|
2300
|
+
span.set_attribute(
|
|
2301
|
+
"cortexhub.policy.would_have_effect",
|
|
2302
|
+
decision.would_have_effect,
|
|
2303
|
+
)
|
|
2304
|
+
|
|
2193
2305
|
# MODIFY / DEFER handling — see the sync path for rationale.
|
|
2194
2306
|
if decision and decision.effect in (Effect.MODIFY, Effect.DEFER):
|
|
2195
2307
|
span.add_event(
|
|
@@ -162,7 +162,12 @@ class PolicyEvaluator:
|
|
|
162
162
|
"""
|
|
163
163
|
from cortexhub.policy.absence import resolve_policy_absence_decision
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
# For ``tool.invoke`` the action name is the verb ("tool.invoke")
|
|
166
|
+
# and the *tool identity* is on the resource (e.g. "delete_user").
|
|
167
|
+
# ``tool_classifications`` is keyed by the resource id in the
|
|
168
|
+
# bundle, so prefer resource.id and only fall back to the action
|
|
169
|
+
# for non-tool.invoke actions (reserved for future action types).
|
|
170
|
+
tool_name = request.resource.id or getattr(request.action, "name", None) or "unknown"
|
|
166
171
|
absence = resolve_policy_absence_decision(
|
|
167
172
|
enforcement_mode=self._enforcement_mode(),
|
|
168
173
|
effective_classification=self._tool_classification(tool_name),
|
|
@@ -249,23 +254,19 @@ class PolicyEvaluator:
|
|
|
249
254
|
entry = candidate
|
|
250
255
|
|
|
251
256
|
if tool_policies or bucket_policies:
|
|
252
|
-
# Per-tool / bucket mode — evaluate the resolved entry, or
|
|
253
|
-
# through
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
# Per-tool / bucket mode — evaluate the resolved entry, or
|
|
258
|
+
# route through the shared absence resolver if nothing
|
|
259
|
+
# matched. Before 0.5.5+fix, this branch returned an
|
|
260
|
+
# unconditional ``permit`` which meant Enforce + destructive
|
|
261
|
+
# + no-policy-for-this-tool got a silent permit on the SDK
|
|
262
|
+
# while the gateway denied — a CVE-class divergence. Route
|
|
263
|
+
# through ``_default_behavior_decision`` so both runtimes
|
|
264
|
+
# honour the hard gate identically.
|
|
265
|
+
if entry is None or not (entry.get("cedar") or ""):
|
|
266
|
+
return self._default_behavior_decision(request)
|
|
260
267
|
cedar = entry.get("cedar") or ""
|
|
261
268
|
schema = entry.get("schema") if isinstance(entry.get("schema"), dict) else None
|
|
262
269
|
policy_map = entry.get("policy_metadata") or {}
|
|
263
|
-
if not cedar:
|
|
264
|
-
return Decision.permit(
|
|
265
|
-
f"No active policy for tool '{tool_name}' (ungoverned)",
|
|
266
|
-
policy_id="ungoverned",
|
|
267
|
-
policy_decisions=[],
|
|
268
|
-
)
|
|
269
270
|
else:
|
|
270
271
|
cedar = self.policy_bundle.policies
|
|
271
272
|
schema = None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cortexhub-0.5.5 → cortexhub-0.5.7}/src/cortexhub/guardrails/models/en_core_web_sm/meta.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|