aid-runtime-python 0.1.122__tar.gz → 0.1.124__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.
Files changed (113) hide show
  1. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/PKG-INFO +1 -1
  2. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/pyproject.toml +1 -1
  3. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/__init__.py +1 -1
  4. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/guardrails.py +22 -5
  5. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/ir.py +6 -0
  6. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime_python.egg-info/PKG-INFO +1 -1
  7. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_guardrails.py +60 -0
  8. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/README.md +0 -0
  9. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/setup.cfg +0 -0
  10. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/__init__.py +0 -0
  11. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/chat_model.py +0 -0
  12. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/deep_agents.py +0 -0
  13. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/engine.py +0 -0
  14. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/loop.py +0 -0
  15. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/managed.py +0 -0
  16. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/memory.py +0 -0
  17. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/policy.py +0 -0
  18. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/agents/state.py +0 -0
  19. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/cache.py +0 -0
  20. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/concurrency.py +0 -0
  21. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/control.py +0 -0
  22. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/cost.py +0 -0
  23. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/decisions.py +0 -0
  24. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/errors.py +0 -0
  25. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/evals/__init__.py +0 -0
  26. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/evals/dataset.py +0 -0
  27. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/evals/gate.py +0 -0
  28. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/evals/metrics.py +0 -0
  29. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/evals/predicate.py +0 -0
  30. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/evals/runner.py +0 -0
  31. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/gateway.py +0 -0
  32. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/local_trace.py +0 -0
  33. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/pipeline.py +0 -0
  34. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/prompts.py +0 -0
  35. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/providers/__init__.py +0 -0
  36. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/providers/anthropic.py +0 -0
  37. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/providers/base.py +0 -0
  38. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/providers/bedrock.py +0 -0
  39. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/providers/fake.py +0 -0
  40. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/providers/gemini.py +0 -0
  41. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/providers/gemini_wire.py +0 -0
  42. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/providers/http.py +0 -0
  43. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/providers/vertex.py +0 -0
  44. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/py.typed +0 -0
  45. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/__init__.py +0 -0
  46. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/chunking.py +0 -0
  47. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/citations.py +0 -0
  48. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/connectors.py +0 -0
  49. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/embedding.py +0 -0
  50. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/gate.py +0 -0
  51. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/hybrid.py +0 -0
  52. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/knowledge_base.py +0 -0
  53. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/metrics.py +0 -0
  54. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/pgvector.py +0 -0
  55. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/rerank.py +0 -0
  56. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/retriever.py +0 -0
  57. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/stores.py +0 -0
  58. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/retrieval/types.py +0 -0
  59. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/steps.py +0 -0
  60. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/structured.py +0 -0
  61. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/tools.py +0 -0
  62. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/tracing.py +0 -0
  63. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime/types.py +0 -0
  64. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime_python.egg-info/SOURCES.txt +0 -0
  65. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime_python.egg-info/dependency_links.txt +0 -0
  66. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime_python.egg-info/requires.txt +0 -0
  67. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/src/aid_runtime_python.egg-info/top_level.txt +0 -0
  68. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_agents_budget.py +0 -0
  69. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_agents_deep_agents.py +0 -0
  70. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_agents_hitl.py +0 -0
  71. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_agents_loop.py +0 -0
  72. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_agents_memory.py +0 -0
  73. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_anthropic_provider.py +0 -0
  74. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_bedrock_provider.py +0 -0
  75. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_cache.py +0 -0
  76. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_concurrency.py +0 -0
  77. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_control.py +0 -0
  78. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_cost.py +0 -0
  79. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_dataset.py +0 -0
  80. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_decisions.py +0 -0
  81. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_evals.py +0 -0
  82. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_evals_assert_gate.py +0 -0
  83. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_evals_decision.py +0 -0
  84. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_evals_gate.py +0 -0
  85. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_evals_predicate.py +0 -0
  86. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_gateway.py +0 -0
  87. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_gemini_provider.py +0 -0
  88. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_guardrails_managed.py +0 -0
  89. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_guardrails_model_armor.py +0 -0
  90. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_http_provider.py +0 -0
  91. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_local_trace.py +0 -0
  92. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_package.py +0 -0
  93. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_pipeline.py +0 -0
  94. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_prompts.py +0 -0
  95. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_chunking.py +0 -0
  96. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_citations.py +0 -0
  97. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_connectors.py +0 -0
  98. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_embedding.py +0 -0
  99. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_gate.py +0 -0
  100. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_hybrid.py +0 -0
  101. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_knowledge_base.py +0 -0
  102. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_metrics.py +0 -0
  103. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_rerank.py +0 -0
  104. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_stores.py +0 -0
  105. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_retrieval_types.py +0 -0
  106. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_steps.py +0 -0
  107. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_streaming.py +0 -0
  108. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_structured.py +0 -0
  109. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_tool_permissions.py +0 -0
  110. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_tools.py +0 -0
  111. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_tracing.py +0 -0
  112. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_types.py +0 -0
  113. {aid_runtime_python-0.1.122 → aid_runtime_python-0.1.124}/tests/test_vertex_provider.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aid-runtime-python
3
- Version: 0.1.122
3
+ Version: 0.1.124
4
4
  Summary: The AID Framework Python runtime: model gateway with pinning and cost budgets, prompt registry, tool executor, OTel GenAI tracing, plain-async pipeline, and an eval harness that gates on statistical regression against a stored baseline.
5
5
  Author: The AID Framework authors
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "aid-runtime-python"
7
- version = "0.1.122"
7
+ version = "0.1.124"
8
8
  description = "The AID Framework Python runtime: model gateway with pinning and cost budgets, prompt registry, tool executor, OTel GenAI tracing, plain-async pipeline, and an eval harness that gates on statistical regression against a stored baseline."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -310,7 +310,7 @@ from aid_runtime.types import (
310
310
  )
311
311
 
312
312
  #: Kept in sync with ``pyproject.toml`` by a test, so the two cannot drift.
313
- __version__ = "0.1.122"
313
+ __version__ = "0.1.124"
314
314
 
315
315
  __all__ = [
316
316
  "ANTHROPIC_VERSION",
@@ -460,10 +460,15 @@ class GuardrailEngine:
460
460
  ) -> GuardrailRecord | None:
461
461
  """Ask one ``choice`` decision and turn its label into a record, or ``None``.
462
462
 
463
- Everything that is not a usable answer is a :class:`GuardrailBlockedError`:
464
- an undeclared decision, an unmapped label, a confidence below the declared
465
- floor, or a call that raised. That is the same rule the policy path follows
466
- -- there is no path from "the check could not run" to "no violation found".
463
+ An undeclared decision, an unmapped label, an unknown outcome, or a confidence
464
+ below the declared floor is a :class:`GuardrailBlockedError`: an answer the
465
+ guardrail can read but cannot act on blocks. A call that produced no label at
466
+ all -- it raised, named no answer, or carried no choice -- follows the
467
+ decision's ``on_error`` instead: ``allow`` returns ``None`` so an advisory check
468
+ does not stop traffic, and ``block`` (the default) raises. ``on_error`` governs
469
+ whether the answer arrived, never what a present answer means, so the policy
470
+ path's rule holds: there is no path from "the check could not run" to "no
471
+ violation found" unless the spec declares one.
467
472
  """
468
473
  name = guardrail.decision or ""
469
474
  definition = self._decisions.get(name)
@@ -494,6 +499,8 @@ class GuardrailEngine:
494
499
  questions={name: question},
495
500
  )
496
501
  except Exception as error:
502
+ if definition.on_error == "allow":
503
+ return None
497
504
  raise GuardrailBlockedError(
498
505
  guardrail.id,
499
506
  "input",
@@ -502,13 +509,23 @@ class GuardrailEngine:
502
509
 
503
510
  answer = response.answers.get(name)
504
511
  if answer is None:
512
+ if definition.on_error == "allow":
513
+ return None
505
514
  raise GuardrailBlockedError(
506
515
  guardrail.id,
507
516
  "input",
508
517
  f"decision {name!r} returned no answer for its own question",
509
518
  )
510
519
  label = answer.choice
511
- if label is None or label not in outcomes:
520
+ if label is None:
521
+ if definition.on_error == "allow":
522
+ return None
523
+ raise GuardrailBlockedError(
524
+ guardrail.id,
525
+ "input",
526
+ f"decision {name!r} returned an answer with no choice",
527
+ )
528
+ if label not in outcomes:
512
529
  raise GuardrailBlockedError(
513
530
  guardrail.id,
514
531
  "input",
@@ -122,6 +122,11 @@ class DecisionDefinition:
122
122
  model: str
123
123
  instructions: str
124
124
  criteria: tuple[str, ...]
125
+ #: What a call that could not answer means: ``allow`` lets the payload through,
126
+ #: ``block`` (the declared default) fails the check closed. It never governs an
127
+ #: answer the guardrail can read but not act on -- an unmapped label or a
128
+ #: confidence under the floor is a policy failure and blocks regardless.
129
+ on_error: str = "block"
125
130
 
126
131
 
127
132
  @dataclass(frozen=True, slots=True)
@@ -443,6 +448,7 @@ def _decision(decision_id: str, entry: Mapping[str, Any]) -> DecisionDefinition:
443
448
  model=_required_str(entry, "model", where),
444
449
  instructions=_required_str(entry, "instructions", where),
445
450
  criteria=labels,
451
+ on_error="allow" if entry.get("onError") == "allow" else "block",
446
452
  )
447
453
 
448
454
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aid-runtime-python
3
- Version: 0.1.122
3
+ Version: 0.1.124
4
4
  Summary: The AID Framework Python runtime: model gateway with pinning and cost budgets, prompt registry, tool executor, OTel GenAI tracing, plain-async pipeline, and an eval harness that gates on statistical regression against a stored baseline.
5
5
  Author: The AID Framework authors
6
6
  License-Expression: Apache-2.0
@@ -15,6 +15,7 @@ be explained by "nothing fired".
15
15
 
16
16
  from __future__ import annotations
17
17
 
18
+ from dataclasses import replace
18
19
  from typing import Any
19
20
 
20
21
  import pytest
@@ -1040,6 +1041,65 @@ async def test_a_decision_call_that_raises_is_a_blocked_check() -> None:
1040
1041
  await decision_engine(client).check_input_async((decision_guardrail(),), CLEAN)
1041
1042
 
1042
1043
 
1044
+ async def test_an_allowed_error_posture_lets_the_text_through_when_the_call_raises() -> None:
1045
+ # The declaration decides: `allow` is an advisory check, so an unreachable vendor
1046
+ # must not stop traffic. Dropping the flag would leave this indistinguishable from
1047
+ # the default, which is exactly the bug this pair of tests exists to catch.
1048
+ client = FakeDecisionClient(error=RuntimeError("502 from Jev"))
1049
+ decisions = {"topical": replace(TOPICAL, on_error="allow")}
1050
+
1051
+ verdict = await decision_engine(client, decisions=decisions).check_input_async(
1052
+ (decision_guardrail(),), CLEAN
1053
+ )
1054
+
1055
+ assert verdict.action is None
1056
+ assert verdict.records == ()
1057
+ assert verdict.text == CLEAN
1058
+
1059
+
1060
+ async def test_an_allowed_error_posture_still_blocks_a_label_it_cannot_act_on() -> None:
1061
+ # `onError` governs whether an answer arrived, never what a present answer means.
1062
+ client = FakeDecisionClient(label="off_topic")
1063
+ decisions = {"topical": replace(TOPICAL, on_error="allow")}
1064
+
1065
+ with pytest.raises(GuardrailBlockedError, match="does not map"):
1066
+ await decision_engine(client, decisions=decisions).check_input_async(
1067
+ (decision_guardrail(on_decision=(("product", "allow"),)),), CLEAN
1068
+ )
1069
+
1070
+
1071
+ async def test_an_allowed_error_posture_still_blocks_under_the_confidence_floor() -> None:
1072
+ client = FakeDecisionClient(label="product", confidence=0.2)
1073
+ decisions = {"topical": replace(TOPICAL, on_error="allow")}
1074
+
1075
+ with pytest.raises(GuardrailBlockedError, match="below the declared minimum"):
1076
+ await decision_engine(client, decisions=decisions).check_input_async(
1077
+ (decision_guardrail(min_confidence=0.8),), CLEAN
1078
+ )
1079
+
1080
+
1081
+ def test_the_ir_keeps_the_declared_error_posture() -> None:
1082
+ """A posture the runtime cannot see is a posture the spec cannot rely on."""
1083
+ document = solo(
1084
+ decisions=[
1085
+ {
1086
+ "id": "topical",
1087
+ "provider": "typesafe",
1088
+ "model": "jev-1.14.0",
1089
+ "type": "choice",
1090
+ "instructions": "Is this message about our product",
1091
+ "criteria": {"product": "asks about us", "off_topic": "anything else"},
1092
+ "onError": "allow",
1093
+ }
1094
+ ],
1095
+ )
1096
+
1097
+ spec = from_ir(document)
1098
+
1099
+ assert spec.decisions["topical"].on_error == "allow"
1100
+ assert spec.decisions["topical"].criteria == ("off_topic", "product")
1101
+
1102
+
1043
1103
  async def test_an_undeclared_decision_is_a_blocked_check() -> None:
1044
1104
  with pytest.raises(GuardrailBlockedError, match="no definition"):
1045
1105
  await decision_engine(FakeDecisionClient(), decisions={}).check_input_async(