agent-framework-acgs 0.1.0__tar.gz → 0.2.0__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 (25) hide show
  1. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/CHANGELOG.md +14 -0
  2. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/PKG-INFO +33 -3
  3. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/README.md +31 -1
  4. agent_framework_acgs-0.2.0/examples/deny_and_audit.py +85 -0
  5. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/pyproject.toml +2 -2
  6. agent_framework_acgs-0.2.0/tests/test_compatibility.py +29 -0
  7. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/test_examples.py +25 -0
  8. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/.gitignore +0 -0
  9. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/LICENSE +0 -0
  10. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/examples/quickstart.py +0 -0
  11. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/src/agent_framework_acgs/__init__.py +0 -0
  12. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/src/agent_framework_acgs/_governance.py +0 -0
  13. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/src/agent_framework_acgs/middleware.py +0 -0
  14. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/src/agent_framework_acgs/py.typed +0 -0
  15. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/__init__.py +0 -0
  16. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/conftest.py +0 -0
  17. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/fakes.py +0 -0
  18. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/mcp_server.py +0 -0
  19. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/test_approval.py +0 -0
  20. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/test_default_constitution.py +0 -0
  21. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/test_governance.py +0 -0
  22. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/test_imports.py +0 -0
  23. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/test_mcp.py +0 -0
  24. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/test_middleware.py +0 -0
  25. {agent_framework_acgs-0.1.0 → agent_framework_acgs-0.2.0}/tests/test_tool_coverage.py +0 -0
@@ -6,6 +6,20 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## 0.2.0 (2026-11-20)
10
+
11
+ ### Added
12
+
13
+ - Offline `examples/deny_and_audit.py`: one allowed and one denied Agent Framework tool call, followed by an
14
+ application decision trail.
15
+ - Compatibility regression coverage for nested JSON-native arguments and bytes/bytearray formatting.
16
+
17
+ ### Changed
18
+
19
+ - Document the compatibility matrix: acgs-lite 4.0.0 in the locked environment and the 3.0.1 floor in CI's
20
+ `test-min` job. Runtime support remains `acgs-lite>=3.0.1,<5`.
21
+ - Clarify that the adapter does not issue signed receipts.
22
+
9
23
  ## 0.1.0 (2026-10-23)
10
24
 
11
25
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: agent-framework-acgs
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: ACGS rule-based tool-call governance for Microsoft Agent Framework function tools, via function middleware and tool approvals
5
5
  Project-URL: Homepage, https://github.com/acgs-ai/agent-framework-acgs
6
6
  Project-URL: Documentation, https://github.com/acgs-ai/agent-framework-acgs#readme
@@ -23,7 +23,7 @@ Classifier: Programming Language :: Python :: 3.14
23
23
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
24
  Classifier: Typing :: Typed
25
25
  Requires-Python: >=3.10
26
- Requires-Dist: acgs-lite<4,>=3.0.1
26
+ Requires-Dist: acgs-lite<5,>=3.0.1
27
27
  Requires-Dist: agent-framework-core<2,>=1.20.0
28
28
  Provides-Extra: mcp
29
29
  Requires-Dist: mcp<3,>=1.24.0; extra == 'mcp'
@@ -71,9 +71,39 @@ pip install agent-framework-acgs
71
71
  pip install "agent-framework-acgs[mcp]" # for local MCP tools
72
72
  ```
73
73
 
74
- Requires Python 3.10 or later, `agent-framework-core>=1.20.0,<2` and `acgs-lite>=3.0.1,<4`. The `mcp` extra adds
74
+ Requires Python 3.10 or later, `agent-framework-core>=1.20.0,<2` and `acgs-lite>=3.0.1,<5`. The `mcp` extra adds
75
75
  `mcp` and `tenacity`, which Agent Framework's MCP tools need.
76
76
 
77
+ ### Compatibility
78
+
79
+ | Component | Supported range | 0.2.0 validation |
80
+ |---|---|---|
81
+ | acgs-lite | `>=3.0.1,<5` | 4.0.0 tested via `uv.lock` and the default environment; 3.0.1 floor tested by CI's `test-min` job |
82
+ | agent-framework-core | `>=1.20.0,<2` | Scripted tool calls through function middleware and tool approvals |
83
+ | Python | `>=3.10` | CI tests Python 3.10 through 3.14 |
84
+
85
+ The adapter formats arguments as text and calls `GovernanceEngine.validate`. It does not select the production
86
+ authorization profile or issue signed receipts. Nested JSON-native arguments are supported; bytes and bytearray
87
+ values remain scalar text for rule matching.
88
+
89
+ acgs-lite 4 is a major release. Its production profile of `GovernedCallable` requires an Ed25519
90
+ receipt signer, governed payloads are JSON-only, and `GovernedAgent` no longer passes per-call keyword arguments to
91
+ rule conditions (see the [acgs-lite changelog](https://github.com/acgs-ai/acgs-lite/blob/main/CHANGELOG.md)). This
92
+ adapter works with both majors, but a fresh environment installs the newest version allowed. To stay on 3.x, also
93
+ require `"acgs-lite<4"`, for example `pip install agent-framework-acgs "acgs-lite<4"`.
94
+
95
+ ### Offline deny-and-audit example
96
+
97
+ Run [examples/deny_and_audit.py](examples/deny_and_audit.py) without an API key or network connection:
98
+
99
+ ```bash
100
+ uv run --no-sync python examples/deny_and_audit.py
101
+ ```
102
+
103
+ A scripted model requests one allowed note and one denied note through `ACGSGuard.middleware`. Only the allowed
104
+ tool executes. The example then prints both decisions with their verdict, reason and rule IDs. This application
105
+ trail omits argument values and stays in memory; it is not a signed receipt or a durable engine audit log.
106
+
77
107
  ## Usage
78
108
 
79
109
  `guard.middleware` is a list with a chat middleware (`guard.tool_check`, which checks the tools a run offers) and a
@@ -39,9 +39,39 @@ pip install agent-framework-acgs
39
39
  pip install "agent-framework-acgs[mcp]" # for local MCP tools
40
40
  ```
41
41
 
42
- Requires Python 3.10 or later, `agent-framework-core>=1.20.0,<2` and `acgs-lite>=3.0.1,<4`. The `mcp` extra adds
42
+ Requires Python 3.10 or later, `agent-framework-core>=1.20.0,<2` and `acgs-lite>=3.0.1,<5`. The `mcp` extra adds
43
43
  `mcp` and `tenacity`, which Agent Framework's MCP tools need.
44
44
 
45
+ ### Compatibility
46
+
47
+ | Component | Supported range | 0.2.0 validation |
48
+ |---|---|---|
49
+ | acgs-lite | `>=3.0.1,<5` | 4.0.0 tested via `uv.lock` and the default environment; 3.0.1 floor tested by CI's `test-min` job |
50
+ | agent-framework-core | `>=1.20.0,<2` | Scripted tool calls through function middleware and tool approvals |
51
+ | Python | `>=3.10` | CI tests Python 3.10 through 3.14 |
52
+
53
+ The adapter formats arguments as text and calls `GovernanceEngine.validate`. It does not select the production
54
+ authorization profile or issue signed receipts. Nested JSON-native arguments are supported; bytes and bytearray
55
+ values remain scalar text for rule matching.
56
+
57
+ acgs-lite 4 is a major release. Its production profile of `GovernedCallable` requires an Ed25519
58
+ receipt signer, governed payloads are JSON-only, and `GovernedAgent` no longer passes per-call keyword arguments to
59
+ rule conditions (see the [acgs-lite changelog](https://github.com/acgs-ai/acgs-lite/blob/main/CHANGELOG.md)). This
60
+ adapter works with both majors, but a fresh environment installs the newest version allowed. To stay on 3.x, also
61
+ require `"acgs-lite<4"`, for example `pip install agent-framework-acgs "acgs-lite<4"`.
62
+
63
+ ### Offline deny-and-audit example
64
+
65
+ Run [examples/deny_and_audit.py](examples/deny_and_audit.py) without an API key or network connection:
66
+
67
+ ```bash
68
+ uv run --no-sync python examples/deny_and_audit.py
69
+ ```
70
+
71
+ A scripted model requests one allowed note and one denied note through `ACGSGuard.middleware`. Only the allowed
72
+ tool executes. The example then prints both decisions with their verdict, reason and rule IDs. This application
73
+ trail omits argument values and stays in memory; it is not a signed receipt or a durable engine audit log.
74
+
45
75
  ## Usage
46
76
 
47
77
  `guard.middleware` is a list with a chat middleware (`guard.tool_check`, which checks the tools a run offers) and a
@@ -0,0 +1,85 @@
1
+ """Run allowed and denied Agent Framework tool calls offline, then print their decision trail."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import asyncio
6
+ import json
7
+ import os
8
+ from collections.abc import Awaitable, Mapping, Sequence
9
+ from dataclasses import asdict
10
+ from typing import Any
11
+
12
+ # Disable telemetry before importing the framework; the scripted model needs no service or API key.
13
+ os.environ["OTEL_SDK_DISABLED"] = "true"
14
+
15
+ from agent_framework import (
16
+ Agent,
17
+ BaseChatClient,
18
+ ChatMiddlewareLayer,
19
+ ChatResponse,
20
+ ChatResponseUpdate,
21
+ Content,
22
+ FunctionInvocationLayer,
23
+ Message,
24
+ ResponseStream,
25
+ )
26
+
27
+ from agent_framework_acgs import ACGSGuard, GovernanceDecision
28
+
29
+
30
+ class AuditedGuard(ACGSGuard):
31
+ """Collect public evaluation results without retaining argument values."""
32
+
33
+ def __init__(self) -> None:
34
+ super().__init__()
35
+ self.decisions: list[GovernanceDecision] = []
36
+
37
+ def evaluate(self, tool_name: str, arguments: Any) -> GovernanceDecision:
38
+ decision = super().evaluate(tool_name, arguments)
39
+ self.decisions.append(decision)
40
+ return decision
41
+
42
+
43
+ class ScriptedModel(FunctionInvocationLayer[Any], ChatMiddlewareLayer[Any], BaseChatClient[Any]):
44
+ """Return prewritten tool calls through the framework's normal invocation pipeline."""
45
+
46
+ def __init__(self) -> None:
47
+ super().__init__()
48
+ self.notes = ["The meeting starts at noon.", "The admin password is demo-secret."]
49
+
50
+ def _inner_get_response(
51
+ self, *, messages: Sequence[Message], stream: bool = False, options: Mapping[str, Any], **kwargs: Any
52
+ ) -> Awaitable[ChatResponse] | ResponseStream[ChatResponseUpdate, ChatResponse]:
53
+ content = (
54
+ Content.from_function_call(
55
+ call_id=f"note-{len(self.notes)}",
56
+ name="record_note",
57
+ arguments=json.dumps({"body": self.notes.pop(0)}),
58
+ )
59
+ if self.notes
60
+ else Content.from_text("Done.")
61
+ )
62
+
63
+ async def respond() -> ChatResponse:
64
+ return ChatResponse(messages=[Message(role="assistant", contents=[content])])
65
+
66
+ return respond()
67
+
68
+
69
+ def record_note(body: str) -> str:
70
+ """Record a demo note by printing it locally."""
71
+ print(f"Executed record_note: {body}")
72
+ return "Note recorded."
73
+
74
+
75
+ async def main() -> None:
76
+ guard = AuditedGuard()
77
+ agent = Agent(client=ScriptedModel(), tools=[record_note], middleware=guard.middleware)
78
+ await agent.run("Record the two notes.")
79
+ print("Audit trail (application decisions):")
80
+ for decision in guard.decisions:
81
+ print(json.dumps(asdict(decision), sort_keys=True))
82
+
83
+
84
+ if __name__ == "__main__":
85
+ asyncio.run(main())
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "agent-framework-acgs"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "ACGS rule-based tool-call governance for Microsoft Agent Framework function tools, via function middleware and tool approvals"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -27,7 +27,7 @@ classifiers = [
27
27
  ]
28
28
  dependencies = [
29
29
  "agent-framework-core>=1.20.0,<2",
30
- "acgs-lite>=3.0.1,<4",
30
+ "acgs-lite>=3.0.1,<5",
31
31
  ]
32
32
 
33
33
  [project.optional-dependencies]
@@ -0,0 +1,29 @@
1
+ """Regression checks for the adapter boundary with acgs-lite 4.x and the supported 3.x floor."""
2
+
3
+ from typing import Any
4
+
5
+ import pytest
6
+
7
+ from agent_framework_acgs import ACGSGuard, Verdict, format_tool_call
8
+
9
+
10
+ @pytest.mark.parametrize("binary_type", [bytes, bytearray])
11
+ def test_binary_arguments_remain_scalar_and_match_rules(binary_type: Any) -> None:
12
+ arguments = {"items": [{"body": binary_type(b"password")}]}
13
+ rendered = format_tool_call("record_note", arguments)
14
+ assert "items[0].body: " in rendered
15
+ assert "password" in rendered
16
+ assert "body[0]" not in rendered
17
+ decision = ACGSGuard().evaluate("record_note", arguments)
18
+ assert decision.verdict is Verdict.DENY
19
+ assert decision.error is None
20
+ assert decision.rule_ids == ("ACGS-006",)
21
+
22
+
23
+ @pytest.mark.parametrize("body", ["Meeting at noon", "password"])
24
+ def test_nested_json_arguments_with_default_unsigned_configuration(body: str) -> None:
25
+ arguments: dict[str, Any] = {"items": [{"body": body, "values": [None, True, False, 7, 1.5, {}, []]}]}
26
+ decision = ACGSGuard().evaluate("record_note", arguments)
27
+ assert decision.verdict is (Verdict.DENY if body == "password" else Verdict.ALLOW)
28
+ assert decision.error is None
29
+ assert decision.rule_ids == (("ACGS-006",) if body == "password" else ())
@@ -5,7 +5,10 @@
5
5
 
6
6
  from __future__ import annotations
7
7
 
8
+ import json
9
+ import os
8
10
  import re
11
+ import runpy
9
12
  import subprocess
10
13
  import sys
11
14
  import textwrap
@@ -45,6 +48,28 @@ def test_readme_embeds_the_quickstart_verbatim() -> None:
45
48
  assert QUICKSTART.read_text(encoding="utf-8") in _blocks("python")
46
49
 
47
50
 
51
+ def test_deny_and_audit_runs_offline_without_api_keys(
52
+ monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
53
+ ) -> None:
54
+ for key in list(os.environ):
55
+ if key.endswith("API_KEY"):
56
+ monkeypatch.delenv(key)
57
+ # Register the example's import-time mutation so monkeypatch restores the original value.
58
+ monkeypatch.setenv("OTEL_SDK_DISABLED", "true")
59
+ # pytest-socket blocks network access for this in-process execution.
60
+ runpy.run_path(str(ROOT / "examples" / "deny_and_audit.py"), run_name="__main__")
61
+ execution, audit = capsys.readouterr().out.split("Audit trail (application decisions):\n")
62
+ assert execution == "Executed record_note: The meeting starts at noon.\n"
63
+ decisions = [json.loads(line) for line in audit.splitlines()]
64
+ assert [decision["verdict"] for decision in decisions] == ["allow", "deny"]
65
+ assert [decision["tool_name"] for decision in decisions] == ["record_note", "record_note"]
66
+ assert decisions[0]["rule_ids"] == []
67
+ assert decisions[1]["rule_ids"] == ["ACGS-006"]
68
+ assert "Blocked by" in decisions[1]["reason"]
69
+ assert all(decision["error"] is None for decision in decisions)
70
+ assert "demo-secret" not in execution + audit
71
+
72
+
48
73
  def test_readme_states_the_supported_versions() -> None:
49
74
  pyproject = (ROOT / "pyproject.toml").read_text(encoding="utf-8")
50
75
  for package in ("agent-framework-core", "acgs-lite"):