Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
344 lines (328 loc) · 14.3 KB
/
Copy pathpyproject.toml
File metadata and controls
344 lines (328 loc) · 14.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
[build-system]
requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "aws-agent-core"
version = "0.1.0"
description = "LangGraph agent on Amazon Bedrock AgentCore Runtime"
readme = "README.md"
requires-python = ">=3.10"
license = { text = "Apache-2.0" }
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"bedrock-agentcore>=1.7.0,<2",
"langgraph>=0.2.0,<2",
"langchain-aws>=0.2.0,<1",
# UsageMetadataCallbackHandler is the load-bearing token-counting seam
# (added in langchain-core 0.3.49).
"langchain-core>=0.3.49,<1",
"pydantic>=2.7.0,<3",
# tenacity drives the half-open probe scheduling in
# InMemoryLlmCircuitBreaker (wait_random_exponential).
"tenacity>=9.0.0,<10",
]
[project.optional-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-cov>=5.0.0",
"coverage[toml]>=7.5.0",
"mypy>=1.10.0",
"ruff>=0.5.0",
"freezegun>=1.5.0",
# Property-based tests on TokenUsage invariants and the budget arithmetic.
"hypothesis>=6.100.0,<7",
# Following Qodo rule: Only add dependencies from the approved third-party registry (ERROR).
# `watchfiles` powers the in-Pod hot-reload loop wired by
# `deploy/local/overlays/host-mount/agent-runtime-patch.yaml`
# (`make local-up-watch`). It is dev-only — production agent runtime
# images MUST NOT install the [dev] extra, so the inotify/native
# filesystem-watcher dependency never ships to AWS. Approval ticket:
# TODO before merge per the approved-deps registry process.
# Following Qodo rule: Pin dependency versions in manifests and lockfiles (WARNING).
# The version range matches the existing convention used by every
# other [dev] / optional-extras entry in this file (caret-style
# >=major.minor,<next-major). Exact-version pinning + lockfile
# generation is the M2.5 deliverable (§14.5).
"watchfiles>=0.21.0,<1",
# Following Qodo rule: Only add dependencies from the approved third-party registry (ERROR).
# `import-linter` enforces the Wave 4 sealed-test-seams contract
# under `[tool.importlinter]` below: production code in the
# `agent` package must not import from
# `agent.composition._test_seams`. The check runs as a
# `lint-imports` step in the same CI lane as `ruff` /
# `mypy` so a regression surfaces at PR-review time. It is
# dev-only — production agent runtime images do not install
# `[dev]`, so the linter never ships to AWS. Approval ticket:
# TODO before merge per the approved-deps registry process.
# Following Qodo rule: Pin dependency versions in manifests and lockfiles (WARNING).
# The version range matches the existing convention used by
# every other `[dev]` / optional-extras entry in this file
# (caret-style `>=major.minor,<next-major`).
"import-linter>=2.0,<3",
# Following Qodo rule: Only add dependencies from the approved third-party registry (ERROR).
# `mutmut` powers the Wave 9 weekly mutation-testing workflow
# (`.github/workflows/mutation.yml`). It is dev-only and runs
# on a separate scheduled job (advisory, not gating) so a
# surviving mutant surfaces in the workflow artifact without
# blocking PRs while the suite is hardened. Production agent
# runtime images do not install `[dev]`, so `mutmut` never
# ships to AWS. Approval ticket: TODO before merge per the
# approved-deps registry process.
# Following Qodo rule: Pin dependency versions in manifests and lockfiles (WARNING).
# The version range matches the existing caret-style convention
# (`>=major.minor,<next-major`) used by every other entry in
# this section; exact-version pinning + lockfile generation is
# the M2.5 deliverable (§14.5).
"mutmut>=3.0,<4",
]
# OpenTelemetry GenAI semantic conventions wiring.
# Kept as an optional extra so the unit-test + mypy jobs do NOT pull
# OpenTelemetry transitive deps; the OtelMeterMetricsRecorder consumes
# the SDK via its structural Protocol surface. AWS production picks
# this extra up via the same `[xray]` install path.
otel = [
"opentelemetry-api>=1.27.0,<2",
"opentelemetry-sdk>=1.27.0,<2",
]
# Following Qodo rule: Only add dependencies from the approved third-party registry (ERROR).
# `langchain-anthropic` powers the local profile's `ChatAnthropic` LLM factory.
# It is isolated as an optional extra so the default install (and the
# 100%-coverage unit-test job) does NOT pull
# Anthropic's transitive deps. Approval ticket: TODO before merge per the
# approved-deps registry process.
# Following Qodo rule: Pin dependency versions in manifests and lockfiles (WARNING).
# The version range here matches the existing convention used by `langchain-aws`
# and `langchain-core` in this file (caret-style >=major.minor,<next-major).
# Exact-version pinning + lockfile generation is M2.5 deliverable (§14.5).
anthropic = [
"langchain-anthropic>=0.3.0,<1",
]
# Following Qodo rule: Only add dependencies from the approved third-party registry (ERROR).
# `aws-xray-sdk` and the OpenTelemetry OTLP exporter power the X-Ray tracer
# (the production-only AWS X-Ray exporter / segment-shape seam). They are
# isolated as an optional extra so the default install (and the
# 100%-coverage unit-test job) does NOT
# pull `aws-xray-sdk` or `opentelemetry-*` transitive deps. Approval ticket:
# TODO before merge per the approved-deps registry process.
# Following Qodo rule: Pin dependency versions in manifests and lockfiles (WARNING).
# The version ranges here match the existing convention used by
# `langchain-aws` / `langchain-core` / `langchain-anthropic` (caret-style
# >=major.minor,<next-major). Exact-version pinning + lockfile generation
# lands as a follow-up promotion deliverable.
xray = [
"aws-xray-sdk>=2.14.0,<3",
"opentelemetry-sdk>=1.26.0,<2",
"opentelemetry-exporter-otlp-proto-http>=1.26.0,<2",
]
# Following Qodo rule: Only add dependencies from the approved third-party registry (ERROR).
# `langchain-mcp-adapters` is the canonical bridge from the MCP `tools/list` /
# `tools/call` JSON-RPC surface to LangChain `StructuredTool`s consumed by
# `model.bind_tools(...)` and `langgraph.prebuilt.ToolNode`. It is isolated as
# an optional extra so the default install (and the
# 100%-coverage unit-test job) does NOT pull `langchain-mcp-adapters` transitive
# deps. Approval ticket: TODO before merge per the approved-deps registry process.
# Following Qodo rule: Pin dependency versions in manifests and lockfiles (WARNING).
# The version range here matches the existing convention used by `langchain-aws` /
# `langchain-core` / `langchain-anthropic` (caret-style >=major.minor,<next-major).
# Exact-version pinning + lockfile generation is a deliverable counterpart
# to the earlier lockfile entry.
mcp = [
"langchain-mcp-adapters>=0.1.0,<1",
]
# Following Qodo rule: Only add dependencies from the approved third-party registry (ERROR).
# `langgraph-checkpoint-aws` provides the AgentCore-backed LangGraph
# checkpointer (`AgentCoreMemorySaver`) and the DynamoDB-backed
# `DynamoDbSaver` consumed by `_default_aws_checkpointer_factory` in
# `agent.composition._shared`. `bedrock-agentcore` is the SDK that
# exposes `AgentCoreMemorySaver` as a fallback when the dedicated
# integration package is missing; it already ships in the base
# `dependencies` block (the runtime entrypoint imports `BedrockAgentCoreApp`
# unconditionally) so this extra restates the version pin for parity
# with the operator-facing `pip install -e '.[aws]'` instruction in
# the lazy-import RuntimeError. The unit-test + 100%-coverage job
# does NOT install this extra, so mypy and pytest stay free of the
# AWS-only transitive deps. Approval ticket: TODO before merge per
# the approved-deps registry process.
# Following Qodo rule: Pin dependency versions in manifests and lockfiles (WARNING).
# The version ranges match the existing caret-style convention used
# by every other extras block in this file
# (`>=major.minor,<next-major`). Exact-version pinning + lockfile
# generation is the M2.5 deliverable (§14.5).
aws = [
"langgraph-checkpoint-aws>=0.1.0,<1",
"bedrock-agentcore>=1.7.0,<2",
]
[tool.setuptools.packages.find]
where = ["src"]
[tool.pytest.ini_options]
minversion = "8.0"
testpaths = ["tests"]
addopts = [
"-ra",
"--strict-markers",
"--strict-config",
"--cov=agent",
"--cov-branch",
"--cov-report=term-missing",
"--cov-report=xml:coverage.xml",
"--cov-report=html:htmlcov",
"--cov-fail-under=100",
# Integration tier (tests/integration/) targets a sandbox AWS
# account / live mcp-internal / Jira instance and is run on
# schedule, NOT per-PR. Excluding it from collection keeps the
# 100% coverage gate scoped to the unit suite. Source of truth:
# tests/integration/README.md.
"--ignore=tests/integration",
]
markers = [
"integration: marks tests requiring a real AWS / Jira / mcp-internal sandbox (managed AgentCore Runtime, KMS / Secrets Manager rotation, live mcp-internal token); not run per-PR",
]
filterwarnings = [
"error",
"ignore::DeprecationWarning",
"ignore::pydantic.warnings.PydanticDeprecatedSince20",
]
[tool.coverage.run]
branch = true
source = ["agent"]
parallel = false
[tool.coverage.report]
fail_under = 100
show_missing = true
skip_covered = false
exclude_lines = [
"pragma: no cover",
"raise NotImplementedError",
"if TYPE_CHECKING:",
"\\.\\.\\.",
]
[tool.coverage.xml]
output = "coverage.xml"
[tool.coverage.html]
directory = "htmlcov"
[tool.mypy]
python_version = "3.10"
strict = true
warn_unused_configs = true
disallow_any_generics = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_return_any = true
no_implicit_reexport = true
strict_equality = true
strict_concatenate = true
files = ["src/agent"]
[[tool.mypy.overrides]]
module = [
"bedrock_agentcore.*",
"langgraph.*",
# Optional [xray] extras — see [project.optional-dependencies] above
# (the production-only AWS X-Ray exporter / segment-shape seam). The
# unit-test / type-check jobs do NOT install these, so mypy must not
# require their stubs to be discoverable. The lazy-import call site in
# `agent.infrastructure.observability.xray_tracer._get_recorder` raises a
# human-friendly RuntimeError pointing at `pip install -e '.[xray]'` when
# the extras are missing at runtime.
"aws_xray_sdk.*",
"opentelemetry.*",
# Optional [mcp] extras — see [project.optional-dependencies] above. The
# unit-test / type-check jobs do NOT install these, so mypy must not
# require their stubs to be discoverable. The lazy-import call site in
# `agent.infrastructure.mcp.langchain_adapter._load_official_mcp_tools`
# raises a human-friendly RuntimeError pointing at
# `pip install -e '.[mcp]'` when the extras are missing at runtime.
"langchain_mcp_adapters.*",
# Optional [aws] extras — see [project.optional-dependencies] above
# (the managed AgentCore Runtime + Memory promotion seam). The
# unit-test / type-check jobs do NOT install
# `langgraph-checkpoint-aws`, so mypy must not require its stubs to be
# discoverable. The lazy-import call site in
# `agent.composition._shared._default_aws_checkpointer_factory`
# raises a human-friendly RuntimeError pointing at
# `pip install -e '.[aws]'` when the extras are missing at runtime.
"langgraph_checkpoint_aws.*",
]
ignore_missing_imports = true
[tool.ruff]
line-length = 100
target-version = "py310"
src = ["src", "tests"]
[tool.ruff.lint]
select = [
"E",
"F",
"I",
"B",
"UP",
"N",
"RUF",
"SIM",
]
ignore = ["E501"]
[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["B011", "S101"]
# Wave 4 sealed-test-seams contract: production code in the ``agent``
# package must NOT import from ``agent.composition._test_seams``. The
# module exists only so the unit-test suite can reach private helpers
# without polluting the public ``agent.composition`` namespace; a
# regression that wires a production import into ``_test_seams`` would
# silently widen the public composition API. Run via ``lint-imports``
# in the same CI lane as ``ruff`` / ``mypy``.
#
# ``source_modules`` enumerates every production-side child of the
# ``agent`` package explicitly because ``agent.composition._test_seams``
# is itself a descendant of ``agent`` (a wildcard ``["agent"]`` source
# would clash with the forbidden module under import-linter's
# "Modules have shared descendants" rule). ``agent.composition`` is
# split into its three production submodules (``_shared``, ``aws``,
# ``local``) plus the package ``__init__`` so the test-only seam stays
# the only sibling that is excluded.
[tool.importlinter]
root_packages = ["agent"]
[[tool.importlinter.contracts]]
name = "Test seams must not leak into production code"
type = "forbidden"
source_modules = [
"agent.application",
"agent.composition._shared",
"agent.composition.aws",
"agent.composition.local",
"agent.contracts",
"agent.domain",
"agent.graph",
"agent.infrastructure",
"agent.main",
"agent.server",
]
forbidden_modules = ["agent.composition._test_seams"]
# Wave 9 mutation-testing configuration.
#
# `mutmut` runs weekly via `.github/workflows/mutation.yml` (advisory,
# not gating). We start narrow — the two modules below carry the
# load-bearing safety invariants (per-event-kind MCP-call minima and
# the recursion-guard short-circuit), so a surviving mutant in either
# would be a load-bearing test gap. As the suite hardens we expand
# the `paths_to_mutate` set to the rest of `src/agent/application`.
[tool.mutmut]
paths_to_mutate = [
"src/agent/application/event_invariants.py",
"src/agent/application/recursion_guard.py",
]
runner = "pytest --no-cov -x -q"
tests_dir = [
"tests/application/test_event_invariants.py",
"tests/application/test_recursion_guard.py",
]