cortexhub 0.5.3__tar.gz → 0.5.4__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.3 → cortexhub-0.5.4}/PKG-INFO +1 -1
- {cortexhub-0.5.3 → cortexhub-0.5.4}/pyproject.toml +1 -1
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/policy/evaluator.py +59 -1
- {cortexhub-0.5.3 → cortexhub-0.5.4}/.gitignore +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/LICENSE +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/README.md +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/__init__.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/audit/__init__.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/audit/events.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/backend/__init__.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/backend/client.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/client.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/config.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/constants.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/context/__init__.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/context/enricher.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/errors.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/__init__.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/injection.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/__init__.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/LICENSE +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/LICENSES_SOURCES +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/README.md +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/accuracy.json +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/attribute_ruler/patterns +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/config.cfg +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/lemmatizer/lookups/lookups.bin +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/meta.json +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/cfg +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/model +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/moves +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/cfg +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/model +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/moves +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/senter/cfg +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/senter/model +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tagger/cfg +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tagger/model +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tok2vec/cfg +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tok2vec/model +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tokenizer +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/key2row +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/lookups.bin +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/strings.json +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/vectors +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/vectors.cfg +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/models/en_core_web_sm/meta.json +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/pii.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/guardrails/secrets.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/interceptors/__init__.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/interceptors/mcp.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/logging.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/policy/__init__.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/policy/effects.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/policy/loader.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/policy/models.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/policy/sync.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/signing.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/telemetry/__init__.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/telemetry/otel.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/tool.py +0 -0
- {cortexhub-0.5.3 → cortexhub-0.5.4}/src/cortexhub/version.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.4
|
|
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
|
|
@@ -200,8 +200,44 @@ class PolicyEvaluator:
|
|
|
200
200
|
schema = None
|
|
201
201
|
policy_map = self.policy_bundle.metadata.get("policy_map", {}) if self.policy_bundle else {}
|
|
202
202
|
|
|
203
|
+
# Cedar ``context`` parity contract with the backend evaluator
|
|
204
|
+
# (``backend/app/services/studio/studio_governance.py::_cedar_allows``).
|
|
205
|
+
# Both runtimes must populate the same top-level keys so a
|
|
206
|
+
# single compiled policy evaluates to the same decision on both.
|
|
207
|
+
# When you change either side, update the other and the parity
|
|
208
|
+
# test (``tests/test_cedar_context_parity.py``).
|
|
209
|
+
#
|
|
210
|
+
# ``args``
|
|
211
|
+
# Tool arguments with every string value lowercased. String
|
|
212
|
+
# comparisons in compiled policies are case-insensitive (the
|
|
213
|
+
# compiler lowercases string literals at emit time), so we
|
|
214
|
+
# lowercase on the value side here to meet at the same casing.
|
|
215
|
+
# Non-string values (numbers, bools, nested objects) pass
|
|
216
|
+
# through untouched. Keys are preserved so
|
|
217
|
+
# ``context.args.<field>`` references still resolve.
|
|
218
|
+
#
|
|
219
|
+
# ``runtime``
|
|
220
|
+
# ``{"framework": "sdk"}``. Lets a policy author gate on the
|
|
221
|
+
# execution mode (e.g. ``context.runtime.framework == "sdk"``).
|
|
222
|
+
# The backend gateway path sets ``"studio"`` here.
|
|
223
|
+
#
|
|
224
|
+
# ``gateway``
|
|
225
|
+
# Empty dict on the SDK path. The MCP gateway populates it
|
|
226
|
+
# with request metadata (session id, declared intent, etc.).
|
|
227
|
+
# Injecting an empty record means Cedar policies that
|
|
228
|
+
# reference ``context.gateway.<field>`` evaluate to a missing
|
|
229
|
+
# attribute cleanly instead of raising a Cedar error. Any
|
|
230
|
+
# such policy was authored for the gateway runtime; on the
|
|
231
|
+
# SDK path it'll produce a non-match naturally, and the
|
|
232
|
+
# ``has context.gateway.<field>`` guard the UI generates
|
|
233
|
+
# short-circuits.
|
|
203
234
|
context_args = request.context.get("args") if isinstance(request.context, dict) else {}
|
|
204
|
-
|
|
235
|
+
normalised_args = self._lowercase_strings(context_args) if context_args is not None else {}
|
|
236
|
+
cedar_context = {
|
|
237
|
+
"args": self._json_safe(normalised_args),
|
|
238
|
+
"runtime": {"framework": "sdk"},
|
|
239
|
+
"gateway": {},
|
|
240
|
+
}
|
|
205
241
|
|
|
206
242
|
cedar_request = {
|
|
207
243
|
"principal": f'{principal_type}::"{principal_id}"',
|
|
@@ -346,6 +382,28 @@ class PolicyEvaluator:
|
|
|
346
382
|
policy_decisions=policy_decisions,
|
|
347
383
|
)
|
|
348
384
|
|
|
385
|
+
def _lowercase_strings(self, value: Any) -> Any:
|
|
386
|
+
"""Return a deep copy with every string *value* lowercased.
|
|
387
|
+
|
|
388
|
+
Powers the case-insensitive string comparison contract shared
|
|
389
|
+
with the backend (see ``studio_governance._cedar_allows`` for
|
|
390
|
+
the mirror). Non-strings pass through untouched; nested dicts
|
|
391
|
+
and lists recurse. Keys are preserved as-is — they're field
|
|
392
|
+
names that compiled Cedar references (``context.args.foo``)
|
|
393
|
+
and lowercasing them breaks lookup.
|
|
394
|
+
|
|
395
|
+
Keep this function and the backend's helper in lock-step. The
|
|
396
|
+
two are the contract that makes case-insensitive matching work
|
|
397
|
+
across both runtimes.
|
|
398
|
+
"""
|
|
399
|
+
if isinstance(value, str):
|
|
400
|
+
return value.lower()
|
|
401
|
+
if isinstance(value, dict):
|
|
402
|
+
return {k: self._lowercase_strings(v) for k, v in value.items()}
|
|
403
|
+
if isinstance(value, list):
|
|
404
|
+
return [self._lowercase_strings(i) for i in value]
|
|
405
|
+
return value
|
|
406
|
+
|
|
349
407
|
def _json_safe(self, value: Any) -> Any:
|
|
350
408
|
if value is None:
|
|
351
409
|
return 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
|
|
File without changes
|
|
File without changes
|
{cortexhub-0.5.3 → cortexhub-0.5.4}/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.3 → cortexhub-0.5.4}/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
|