Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
338 lines (308 loc) · 12.1 KB
/
Copy pathpyproject.toml
File metadata and controls
338 lines (308 loc) · 12.1 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
[project]
name = "babylon"
version = "0.4.0"
description = "Reference data preparation and operator tools for the Babylon Rust game."
readme = "README.md"
license = "AGPL-3.0-or-later"
authors = [{ name = "Persephone Raskova", email = "percy@babylonrpg.com" }]
keywords = ["ai", "llm", "marxism", "rpg", "dystopian"]
requires-python = ">=3.12,<4.0"
# Static classifiers, transcribed byte-for-byte from the last poetry-core
# wheel's METADATA before the hatchling cutover (2026-07-22; poetry-core
# emits no license classifier under PEP 639 — the [project] license
# expression carries that). Bump the list when requires-python moves.
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
# PyQt6, PyQt6-WebEngine, pydeck removed in Spec 059 follow-up
# (commit chore(ui): delete PyQt6 dashboard) — desktop dashboard at
# src/babylon/ui/dashboard/ and the legacy Django/React client were deleted;
# the live client is the Rust Bevy ``babylon-client`` crate.
dependencies = [
"defusedxml>=0.7.1",
"pydantic>=2.14.3",
"numpy>=2.5.4",
"sqlalchemy>=2.1.8",
"pandas>=3.1.1",
"jsonschema>=4.25.1,<5.0.0",
"referencing>=0.37.0,<0.38.0",
"openpyxl>=3.1.5,<4.0.0",
"httpx2>=2.16.0,<3.0.0",
"typer>=0.28.0",
"rich>=13.9.4",
"h3>=4.2.0,<5.0.0",
"geopandas>=1.2.0",
"pyproj>=3.8.0",
"shapely>=2.2.0",
"pyyaml>=6.0.2",
"python-dotenv>=1.2.4",
"scipy>=1.18.1",
"psycopg>=3.3.8,<4.0.0",
"pyarrow==25.0.0",
"osmium>=4.3.2,<5",
]
[dependency-groups]
dev = [
"pytest>=9.2.0,<10.0.0",
"pytest-xdist>=3.8.0,<4.0.0",
"pytest-cov>=7.0.0,<8.0.0",
"mypy>=1.13.0,<3.0.0",
"ruff>=0.17.4,<0.18.0",
"pre-commit>=4.7.0,<5.0.0",
"commitizen>=4.19.3,<5.0.0",
"types-jsonschema>=4.26.0.20261006,<5.0.0",
"types-pyyaml>=6.0.12.20261113,<7.0.0",
"midiutil>=1.2.1,<2.0.0",
"markdownify>=1.2.2,<2.0.0",
"yamllint>=1.37.1,<2.0.0",
"mido>=1.3.3,<2.0.0",
"pillow>=13.0.0",
"pip-audit>=2.7.3,<3.0.0",
"pytest-randomly>=5.0.0,<6.0.0",
"types-docutils>=0.23.0.20261107,<0.24.0",
"hypothesis>=6.170.15,<7.0.0",
"pytest-json-report>=1.5.0,<2.0.0",
"pytest-html>=4.1.0,<5.0.0",
]
docs = [
"sphinx>=9.1.1,<10",
"sphinx-rtd-theme>=3.0.2,<4.0.0",
"sphinx-autodoc-typehints<3.18",
"myst-parser>=5.0.0,<6.0.0",
"linkify-it-py>=2.1.1,<3.0.0",
"sphinx-autobuild>=2025.8,<2026.0.0",
"sphinxcontrib-mermaid>=2.1.1,<3.0.0",
]
[tool.uv]
# eMudhra/emSign CA incident: reject vulnerable downloaders and bundled roots.
# https://discuss.python.org/t/109576
required-version = ">=0.13.4"
constraint-dependencies = [
"certifi>=2026.10.19",
"filelock>=4.2.1",
"pip>=26.2.2",
# GHSA-cx6f-vjhg-g3cc: reject vulnerable activation prompt expansion.
"virtualenv>=21.14.13",
]
[tool.hatch.build.targets.wheel]
# babylon lives under src/ (src-layout): map src/babylon -> babylon in the
# wheel, explicitly — no backend discovery magic.
# babylon_data (thin wrapper around the data trove at
# /media/user/data/babylon-data/; src/babylon_data is a committed symlink,
# ADR-037) is deliberately NOT packaged: the symlink is dead in every build
# sandbox (CI or `uv build`) and ships in no wheel either way
# (ADR095's "default install slims toward the player closure"). Unlike
# poetry-core — which hard-failed on a declared-but-absent include and
# forced the ADR094/ADR095 workaround note that used to live here —
# hatchling never touches it because it is not under src/babylon.
packages = ["src/babylon"]
[tool.hatch.build.targets.sdist]
# Keep source distributions independent of the external data drive:
# never ship the dead data symlink.
exclude = ["/src/babylon_data"]
[project.urls]
Homepage = "https://babylonrpg.com"
Documentation = "https://github.com/percy-raskova/babylon#readme"
Issues = "https://github.com/percy-raskova/babylon/issues"
Source = "https://github.com/percy-raskova/babylon"
[project.scripts]
babylon = "babylon.cli:app"
[tool.pytest.ini_options]
pythonpath = ["src"]
testpaths = ["tests"]
norecursedirs = ["mutants", ".mutmut-cache", "html", ".hypothesis"]
doctest_optionflags = ["NORMALIZE_WHITESPACE", "ELLIPSIS"]
markers = [
"unit: Fast unit tests for isolated components (no I/O, no AI)",
"math: Deterministic mathematical formulas (fast, pure functions)",
"ledger: Economic/Political state tests (fast, deterministic)",
"topology: Graph/Network operations (fast, deterministic)",
"integration: Database/Postgres tests (medium, I/O bound)",
"ai: AI/RAG evaluation tests (slow, non-deterministic)",
"red_phase: TDD RED phase tests (intentionally failing until GREEN phase)",
"slow: Long-running scenario tests (2000+ ticks, multi-minute runtime)",
"scenario: Full simulation scenario tests (multi-tick arcs, state verification)",
"theory_rent: Imperial rent and unequal exchange mechanics",
"theory_rift: Metabolic rift and ecological limits mechanics",
"theory_solidarity: Solidarity transmission and consciousness mechanics",
"property: Property-based tests using Hypothesis",
"theory: Marxian theory validation tests (Capital Volume 2 reproduction schema)",
"empirical: Empirical validation tests requiring real QCEW data (deselect with '-m \"not empirical\"')",
"benchmark: Performance and memory benchmarks for tensor operations",
"requires_postgres: Tests requiring a running PostgreSQL instance (skipped if unavailable)",
"postgres: Tests using testcontainers ephemeral PostgreSQL (requires Docker)",
"invariant: Marx value-form & software metamorphic invariant tests (spec-060)",
"cross_scale: marks tests for spec 062 cross-scale integration",
"contract: Contract tests pinning cross-boundary interfaces (tests/contract/)",
"requires_reference_db: Tests needing the reference SQLite DB (data/sqlite/marxist-data-3NF.sqlite) — excluded on the dev CI tier; main/nightly include them via the CI subset artifact (item 40)",
"requires_ollama: needs a live local Ollama daemon + chat model (multi-minute, probabilistic) — excluded from every fast gate; runs via `mise run test:ai`. The bare `ai` marker stays taxonomy-only (2026-07-16 re-tier: mock-based ai-suite tests DO run in fast gates)",
]
# Enforce marker/config strictness via ini options: the --strict-markers /
# --strict-config addopts entries were a verified NO-OP under pytest 9.0.3
# (collecting a file with an unknown marker exited 0). The ini options are
# the working form — verified: unknown marker now fails collection (exit 2).
strict_markers = true
strict_config = true
# strict_parametrization_ids (pytest 9): duplicate/ambiguous parametrize IDs
# fail collection instead of silently renaming (audit Phase D, 2026-07-16).
# strict_xfail deliberately NOT enabled yet: ~10 unmarked xfails (refdb leg)
# need an XPASS census first — flipping it blind converts any XPASS to a red.
strict_parametrization_ids = true
# Loud Failure (Constitution III.11) for first-party deprecations: babylon
# code calling deprecated babylon APIs is a bug, not a warning. Third-party
# deprecations stay warnings (their upgrade cadence is not ours).
filterwarnings = ["error::DeprecationWarning:babylon.*"]
addopts = [
"-v", # Verbose output (already have)
"--tb=short", # Short traceback format (already have)
"-ra", # Show summary of all test outcomes (already have)
# Performance
"--durations=10", # Show 10 slowest tests
# Coverage (when running with --cov)
"--cov-report=term-missing", # Show lines missing coverage
"--cov-report=html", # Generate HTML coverage report
# Output control: no --color=yes — pytest's auto default already colors
# TTYs and honors NO_COLOR/agent-ergonomics envs; forcing yes overrode it
# (audit Phase D, 2026-07-16).
# Debugging aids
"-l", # Show locals (shorter alias)
]
# JUnit XML reporting (no-ops unless --junit-xml is passed; the test:* mise
# tasks pass --junit-xml=reports/test-results/<task>/junit.xml).
# Verbose, machine-readable defaults for AI-agent consumption.
junit_suite_name = "babylon"
junit_family = "xunit2" # Modern schema with richer per-testcase metadata
junit_logging = "all" # Embed stdout, stderr, AND log records into the XML
junit_log_passing_tests = true # Capture logs even for passing tests
junit_duration_report = "call" # Test-call duration only (excludes setup/teardown noise)
[tool.ruff]
line-length = 100
target-version = "py312"
src = ["src"]
exclude = [
".codex/host/", # immutable shared Rust host-policy bytes have their own executable law
"tools/audio/music/legacy/",
"specs/",
"**/*.md", # ruff 0.16 formats Python blocks in Markdown by default; docs keep their own style
]
[tool.ruff.lint]
select = ["E", "W", "F", "I", "B", "C4", "C90", "UP", "ARG", "SIM", "S"]
ignore = ["E501"]
[tool.ruff.lint.mccabe]
max-complexity = 15
[tool.ruff.lint.isort]
known-first-party = ["babylon"]
[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"ARG001",
"ARG002",
"S101", # asserts are pytest's language
"S102", # exec in import-surface tests is the point of the test
"S103", # chmod on fixtures (executable-bit setup)
"S105", # fixture passwords
"S106", # fixture passwords
"S108", # /tmp literals as nonexistent-path/scratch fixtures
"S112", # try/except/continue in property-test harnesses
"S301", # pickle round-trip tests exercise serialization deliberately
"S311", # seeded randomness in strategies
"S603", # subprocess smoke tests invoke our own CLIs with literal args
"S607", # subprocess smoke tests invoke our own CLIs with literal args
"S608", # SQL literals in test fixtures
]
"tools/**" = [
"C901",
"SIM",
"S101", # asserts in dev tooling (incl. the qa:regression harness)
"S108", # /tmp scratch in bootstrap tooling
"S112", # audit tooling skips unparseable entries by design
"S311", # seeded sim RNG in benches/monte-carlo — same III.7 rationale as src
"S603", # subprocess for dev tooling
"S607", # subprocess for dev tooling
"S608", # SQL literals in local loaders (operator-run, no external input)
]
"scripts/**" = ["C901", "SIM"]
"src/**" = [
"S311", # seeded determinism IS the product (Constitution III.7) — sim RNG is never a security token
]
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
[tool.mypy]
python_version = "3.12"
strict = true
mypy_path = "src"
explicit_package_bases = true
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
show_error_codes = true
exclude = [
"tests/",
"build/",
"dist/",
"tools/audio/music/legacy/",
"specs/",
"src/babylon_data/",
]
plugins = ["pydantic.mypy"]
[[tool.mypy.overrides]]
module = ["h3", "h3.*", "tomli"]
ignore_missing_imports = true
[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
[tool.commitizen]
name = "cz_conventional_commits"
version_provider = "uv"
version_scheme = "semver"
major_version_zero = true
tag_format = "v$version"
update_changelog_on_bump = true
[tool.babylon.versioning]
# Native cutover baseline; older canonical tags are on disconnected history.
# Once v0.4.0 is reachable, release tags supply the version and commit counter.
bootstrap_commit = "947699e40fe75a65e603e3302d425643f416e917"
bootstrap_version = "0.3.0"
[tool.rstcheck]
report_level = "WARNING"
ignore_roles = ["hope", "hopedim"]
ignore_directives = [
"mermaid",
"todo",
"automodule",
"autoclass",
"autofunction",
"autosummary",
"toctree",
"only",
]
ignore_substitutions = ["release", "version"]
[tool.hypothesis]
deadline = 500
max_examples = 100
[tool.babylon.logging]
default_level = "INFO"
console_level = "INFO"
file_level = "DEBUG"
[tool.babylon.logging.modules]
httpx = "WARNING"
httpcore = "WARNING"
urllib3 = "WARNING"
asyncio = "WARNING"
[build-system]
# hatchling replaced poetry-core 2026-07-22 — the last Poetry artifact in
# the toolchain (tasks/lock/CI went uv in ADR095's train). Chosen over
# uv_build for explicit src-layout packages= control.
requires = ["hatchling>=1.32.4"]
build-backend = "hatchling.build"
[tool.pyright]
extraPaths = ["."]