codex-ledger 0.1.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 (68) hide show
  1. codex_ledger-0.1.0/.gitignore +24 -0
  2. codex_ledger-0.1.0/LICENSE +21 -0
  3. codex_ledger-0.1.0/PKG-INFO +161 -0
  4. codex_ledger-0.1.0/README.md +141 -0
  5. codex_ledger-0.1.0/pricing/README.md +31 -0
  6. codex_ledger-0.1.0/pricing/rules/README.md +19 -0
  7. codex_ledger-0.1.0/pricing/rules/reference_usd_openai_standard_2026_04_07.json +59 -0
  8. codex_ledger-0.1.0/pyproject.toml +72 -0
  9. codex_ledger-0.1.0/schemas/reports/README.md +15 -0
  10. codex_ledger-0.1.0/schemas/reports/agent-diagnostics-v1.schema.json +37 -0
  11. codex_ledger-0.1.0/schemas/reports/aggregate-report-v1.schema.json +37 -0
  12. codex_ledger-0.1.0/schemas/reports/explain-report-v1.schema.json +40 -0
  13. codex_ledger-0.1.0/schemas/reports/workspace-report-v1.schema.json +37 -0
  14. codex_ledger-0.1.0/scripts/README.md +4 -0
  15. codex_ledger-0.1.0/src/codex_ledger/__init__.py +5 -0
  16. codex_ledger-0.1.0/src/codex_ledger/__main__.py +3 -0
  17. codex_ledger-0.1.0/src/codex_ledger/cli/__init__.py +1 -0
  18. codex_ledger-0.1.0/src/codex_ledger/cli/main.py +826 -0
  19. codex_ledger-0.1.0/src/codex_ledger/domain/__init__.py +1 -0
  20. codex_ledger-0.1.0/src/codex_ledger/domain/records.py +157 -0
  21. codex_ledger-0.1.0/src/codex_ledger/ingest/__init__.py +1 -0
  22. codex_ledger-0.1.0/src/codex_ledger/ingest/discovery.py +25 -0
  23. codex_ledger-0.1.0/src/codex_ledger/ingest/service.py +395 -0
  24. codex_ledger-0.1.0/src/codex_ledger/migrations/0001_initial.sql +5 -0
  25. codex_ledger-0.1.0/src/codex_ledger/migrations/0002_phase1_ledger.sql +152 -0
  26. codex_ledger-0.1.0/src/codex_ledger/migrations/0003_phase2_workspace_lineage.sql +14 -0
  27. codex_ledger-0.1.0/src/codex_ledger/migrations/0004_phase21_agent_observability.sql +33 -0
  28. codex_ledger-0.1.0/src/codex_ledger/migrations/0005_phase3_pricing.sql +32 -0
  29. codex_ledger-0.1.0/src/codex_ledger/migrations/__init__.py +1 -0
  30. codex_ledger-0.1.0/src/codex_ledger/normalize/__init__.py +1 -0
  31. codex_ledger-0.1.0/src/codex_ledger/normalize/privacy.py +22 -0
  32. codex_ledger-0.1.0/src/codex_ledger/normalize/workspaces.py +85 -0
  33. codex_ledger-0.1.0/src/codex_ledger/paths.py +32 -0
  34. codex_ledger-0.1.0/src/codex_ledger/pricing/__init__.py +1 -0
  35. codex_ledger-0.1.0/src/codex_ledger/pricing/rules.py +333 -0
  36. codex_ledger-0.1.0/src/codex_ledger/pricing/rules_data/reference_usd_openai_standard_2026_04_07.json +59 -0
  37. codex_ledger-0.1.0/src/codex_ledger/pricing/service.py +681 -0
  38. codex_ledger-0.1.0/src/codex_ledger/providers/__init__.py +1 -0
  39. codex_ledger-0.1.0/src/codex_ledger/providers/codex/__init__.py +1 -0
  40. codex_ledger-0.1.0/src/codex_ledger/providers/codex/parser.py +570 -0
  41. codex_ledger-0.1.0/src/codex_ledger/reconcile/__init__.py +1 -0
  42. codex_ledger-0.1.0/src/codex_ledger/reconcile/service.py +120 -0
  43. codex_ledger-0.1.0/src/codex_ledger/render/__init__.py +5 -0
  44. codex_ledger-0.1.0/src/codex_ledger/render/service.py +237 -0
  45. codex_ledger-0.1.0/src/codex_ledger/reports/__init__.py +1 -0
  46. codex_ledger-0.1.0/src/codex_ledger/reports/agents.py +653 -0
  47. codex_ledger-0.1.0/src/codex_ledger/reports/aggregate.py +206 -0
  48. codex_ledger-0.1.0/src/codex_ledger/reports/artifacts.py +13 -0
  49. codex_ledger-0.1.0/src/codex_ledger/reports/common.py +425 -0
  50. codex_ledger-0.1.0/src/codex_ledger/reports/explain.py +323 -0
  51. codex_ledger-0.1.0/src/codex_ledger/reports/schema.py +113 -0
  52. codex_ledger-0.1.0/src/codex_ledger/reports/schemas_data/agent-diagnostics-v1.schema.json +37 -0
  53. codex_ledger-0.1.0/src/codex_ledger/reports/schemas_data/aggregate-report-v1.schema.json +37 -0
  54. codex_ledger-0.1.0/src/codex_ledger/reports/schemas_data/explain-report-v1.schema.json +40 -0
  55. codex_ledger-0.1.0/src/codex_ledger/reports/schemas_data/workspace-report-v1.schema.json +37 -0
  56. codex_ledger-0.1.0/src/codex_ledger/reports/workspaces.py +187 -0
  57. codex_ledger-0.1.0/src/codex_ledger/storage/__init__.py +1 -0
  58. codex_ledger-0.1.0/src/codex_ledger/storage/archive.py +33 -0
  59. codex_ledger-0.1.0/src/codex_ledger/storage/migrations.py +76 -0
  60. codex_ledger-0.1.0/src/codex_ledger/storage/repository.py +697 -0
  61. codex_ledger-0.1.0/src/codex_ledger/utils/__init__.py +1 -0
  62. codex_ledger-0.1.0/src/codex_ledger/utils/hashing.py +20 -0
  63. codex_ledger-0.1.0/src/codex_ledger/utils/json.py +8 -0
  64. codex_ledger-0.1.0/src/codex_ledger/utils/time.py +19 -0
  65. codex_ledger-0.1.0/src/codex_ledger/verify/__init__.py +1 -0
  66. codex_ledger-0.1.0/src/codex_ledger/verify/service.py +250 -0
  67. codex_ledger-0.1.0/tests/fixtures/README.md +3 -0
  68. codex_ledger-0.1.0/tests/snapshots/README.md +3 -0
@@ -0,0 +1,24 @@
1
+ .DS_Store
2
+ .coverage
3
+ __pycache__/
4
+ .mypy_cache/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ .venv/
8
+ .python-version
9
+ build/
10
+ dist/
11
+ htmlcov/
12
+ *.egg-info/
13
+ *.py[cod]
14
+ *.sqlite
15
+ *.sqlite3
16
+ *.db
17
+ uv.lock
18
+ codex-ledger-implementation-brief.md
19
+ codex-ledger-implementation-brief-v2.md
20
+ codex-ledger-implementation-brief-v3.md
21
+ codex-ledger-implementation-brief-v4.md
22
+ codex-ledger-implementation-brief-v5.md
23
+ codex-ledger-implementation-brief-v6.md
24
+ codex-ledger-implementation-brief-v7.md
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: codex-ledger
3
+ Version: 0.1.0
4
+ Summary: Local-first, auditable usage ledger for Codex session artifacts.
5
+ Author: Mark Hardy
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: cli,codex,ledger,sqlite,usage
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Utilities
17
+ Requires-Python: >=3.12
18
+ Requires-Dist: pillow>=10.4
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Codex Ledger
22
+
23
+ Codex Ledger is a local-first, auditable CLI for importing Codex session artifacts into
24
+ an event-level SQLite ledger, deriving deterministic reports, estimating reference USD
25
+ cost at the event level, and rendering privacy-safe delivery artifacts from saved report
26
+ JSON.
27
+
28
+ ## Status
29
+
30
+ The repository now includes the full v1 delivery layer:
31
+
32
+ - immutable raw artifact archiving and canonical event ledger
33
+ - workspace resolution with redaction, alias, and full-path modes
34
+ - agent and subagent lineage plus observability diagnostics
35
+ - deterministic event-level reference USD pricing
36
+ - aggregate, workspace, agent, and explain report surfaces
37
+ - deterministic report JSON artifact writing
38
+ - offline schema validation for saved report JSON
39
+ - PNG heatmap and static workspace HTML rendering from saved report JSON
40
+ - read-only verify and reconcile diagnostics
41
+ - release workflow scaffolding and release-readiness docs
42
+
43
+ ## Install
44
+
45
+ Local development uses `uv` and Python 3.12+.
46
+
47
+ ```bash
48
+ uv sync --group dev
49
+ uv run codex-ledger --help
50
+ ```
51
+
52
+ For local wheel validation before publication:
53
+
54
+ ```bash
55
+ uv build
56
+ pipx install ./dist/codex_ledger-0.1.0-py3-none-any.whl
57
+ ```
58
+
59
+ After the package is actually published, the intended install surface is:
60
+
61
+ ```bash
62
+ pipx install codex-ledger
63
+ ```
64
+
65
+ ## Quickstart
66
+
67
+ Inspect the current environment and migration status:
68
+
69
+ ```bash
70
+ codex-ledger doctor
71
+ ```
72
+
73
+ Import locally persisted rollout files:
74
+
75
+ ```bash
76
+ codex-ledger sync
77
+ ```
78
+
79
+ Import an explicit Codex JSON file:
80
+
81
+ ```bash
82
+ codex-ledger import codex-json --input ./sample-report.json
83
+ ```
84
+
85
+ Recalculate reference USD pricing:
86
+
87
+ ```bash
88
+ codex-ledger price recalc --rule-set reference_usd_openai_standard_2026_04_07
89
+ ```
90
+
91
+ Write a deterministic aggregate report JSON artifact:
92
+
93
+ ```bash
94
+ codex-ledger report aggregate \
95
+ --period month \
96
+ --as-of 2026-04-30 \
97
+ --output ./artifacts/aggregate.json
98
+ ```
99
+
100
+ Render a heatmap from the saved report JSON:
101
+
102
+ ```bash
103
+ codex-ledger render heatmap \
104
+ --report ./artifacts/aggregate.json \
105
+ --output ./artifacts/aggregate.png
106
+ ```
107
+
108
+ Render static workspace HTML from a workspace report JSON artifact:
109
+
110
+ ```bash
111
+ codex-ledger report workspace \
112
+ --period month \
113
+ --as-of 2026-04-30 \
114
+ --output ./artifacts/workspaces.json
115
+
116
+ codex-ledger render workspace-html \
117
+ --report ./artifacts/workspaces.json \
118
+ --output ./artifacts/workspaces.html
119
+ ```
120
+
121
+ Run read-only verification:
122
+
123
+ ```bash
124
+ codex-ledger verify ledger
125
+ codex-ledger verify reports
126
+ ```
127
+
128
+ Compare a reference summary against current derived totals:
129
+
130
+ ```bash
131
+ codex-ledger reconcile reference --input ./reference-summary.json
132
+ ```
133
+
134
+ ## Privacy Defaults
135
+
136
+ The ledger keeps raw provenance locally, including original source paths in SQLite.
137
+ Default outward-facing report, explain, and render output stays redacted unless you
138
+ explicitly request `--redaction-mode alias` or `--redaction-mode full`.
139
+
140
+ Rendered PNG and HTML artifacts are traced by sidecar JSON manifests that record report
141
+ schema version, generator version, pricing rule-set selection, redaction mode, and
142
+ source-report hashes without leaking absolute source paths by default.
143
+
144
+ ## Verification
145
+
146
+ The standard local verification suite is:
147
+
148
+ ```bash
149
+ uv run ruff check .
150
+ uv run mypy src
151
+ uv run pytest
152
+ uv build
153
+ uv run ruff format --check .
154
+ ```
155
+
156
+ Release-readiness details live in [docs/RELEASE_READINESS.md](docs/RELEASE_READINESS.md).
157
+
158
+ ## Scope
159
+
160
+ The v1 scope is a Python CLI with deterministic local storage, pricing, reporting,
161
+ rendering, explainability, and verification. Interactive web UI work is out of scope.
@@ -0,0 +1,141 @@
1
+ # Codex Ledger
2
+
3
+ Codex Ledger is a local-first, auditable CLI for importing Codex session artifacts into
4
+ an event-level SQLite ledger, deriving deterministic reports, estimating reference USD
5
+ cost at the event level, and rendering privacy-safe delivery artifacts from saved report
6
+ JSON.
7
+
8
+ ## Status
9
+
10
+ The repository now includes the full v1 delivery layer:
11
+
12
+ - immutable raw artifact archiving and canonical event ledger
13
+ - workspace resolution with redaction, alias, and full-path modes
14
+ - agent and subagent lineage plus observability diagnostics
15
+ - deterministic event-level reference USD pricing
16
+ - aggregate, workspace, agent, and explain report surfaces
17
+ - deterministic report JSON artifact writing
18
+ - offline schema validation for saved report JSON
19
+ - PNG heatmap and static workspace HTML rendering from saved report JSON
20
+ - read-only verify and reconcile diagnostics
21
+ - release workflow scaffolding and release-readiness docs
22
+
23
+ ## Install
24
+
25
+ Local development uses `uv` and Python 3.12+.
26
+
27
+ ```bash
28
+ uv sync --group dev
29
+ uv run codex-ledger --help
30
+ ```
31
+
32
+ For local wheel validation before publication:
33
+
34
+ ```bash
35
+ uv build
36
+ pipx install ./dist/codex_ledger-0.1.0-py3-none-any.whl
37
+ ```
38
+
39
+ After the package is actually published, the intended install surface is:
40
+
41
+ ```bash
42
+ pipx install codex-ledger
43
+ ```
44
+
45
+ ## Quickstart
46
+
47
+ Inspect the current environment and migration status:
48
+
49
+ ```bash
50
+ codex-ledger doctor
51
+ ```
52
+
53
+ Import locally persisted rollout files:
54
+
55
+ ```bash
56
+ codex-ledger sync
57
+ ```
58
+
59
+ Import an explicit Codex JSON file:
60
+
61
+ ```bash
62
+ codex-ledger import codex-json --input ./sample-report.json
63
+ ```
64
+
65
+ Recalculate reference USD pricing:
66
+
67
+ ```bash
68
+ codex-ledger price recalc --rule-set reference_usd_openai_standard_2026_04_07
69
+ ```
70
+
71
+ Write a deterministic aggregate report JSON artifact:
72
+
73
+ ```bash
74
+ codex-ledger report aggregate \
75
+ --period month \
76
+ --as-of 2026-04-30 \
77
+ --output ./artifacts/aggregate.json
78
+ ```
79
+
80
+ Render a heatmap from the saved report JSON:
81
+
82
+ ```bash
83
+ codex-ledger render heatmap \
84
+ --report ./artifacts/aggregate.json \
85
+ --output ./artifacts/aggregate.png
86
+ ```
87
+
88
+ Render static workspace HTML from a workspace report JSON artifact:
89
+
90
+ ```bash
91
+ codex-ledger report workspace \
92
+ --period month \
93
+ --as-of 2026-04-30 \
94
+ --output ./artifacts/workspaces.json
95
+
96
+ codex-ledger render workspace-html \
97
+ --report ./artifacts/workspaces.json \
98
+ --output ./artifacts/workspaces.html
99
+ ```
100
+
101
+ Run read-only verification:
102
+
103
+ ```bash
104
+ codex-ledger verify ledger
105
+ codex-ledger verify reports
106
+ ```
107
+
108
+ Compare a reference summary against current derived totals:
109
+
110
+ ```bash
111
+ codex-ledger reconcile reference --input ./reference-summary.json
112
+ ```
113
+
114
+ ## Privacy Defaults
115
+
116
+ The ledger keeps raw provenance locally, including original source paths in SQLite.
117
+ Default outward-facing report, explain, and render output stays redacted unless you
118
+ explicitly request `--redaction-mode alias` or `--redaction-mode full`.
119
+
120
+ Rendered PNG and HTML artifacts are traced by sidecar JSON manifests that record report
121
+ schema version, generator version, pricing rule-set selection, redaction mode, and
122
+ source-report hashes without leaking absolute source paths by default.
123
+
124
+ ## Verification
125
+
126
+ The standard local verification suite is:
127
+
128
+ ```bash
129
+ uv run ruff check .
130
+ uv run mypy src
131
+ uv run pytest
132
+ uv build
133
+ uv run ruff format --check .
134
+ ```
135
+
136
+ Release-readiness details live in [docs/RELEASE_READINESS.md](docs/RELEASE_READINESS.md).
137
+
138
+ ## Scope
139
+
140
+ The v1 scope is a Python CLI with deterministic local storage, pricing, reporting,
141
+ rendering, explainability, and verification. Interactive web UI work is out of scope.
@@ -0,0 +1,31 @@
1
+ # Pricing Rules
2
+
3
+ Phase 3 adds repo-tracked, offline pricing rules under `pricing/rules/`.
4
+
5
+ The pricing layer in this phase is intentionally narrow:
6
+
7
+ - event-level only
8
+ - deterministic and reproducible
9
+ - based on observed execution models
10
+ - labeled as `reference_usd`, not invoice parity
11
+
12
+ Rule files are versioned JSON documents. Each rule set declares:
13
+
14
+ - `rule_set_id`
15
+ - `pricing_plane`
16
+ - `currency`
17
+ - effective date windows
18
+ - token-field mapping
19
+ - provider/model match rules
20
+ - provenance metadata
21
+ - confidence and stability flags
22
+
23
+ The seeded rule set is conservative and only covers explicitly configured models. Unknown
24
+ or preview models remain unsupported until a rule file opts into a rate.
25
+
26
+ Use:
27
+
28
+ ```bash
29
+ codex-ledger price recalc --rule-set reference_usd_openai_standard_2026_04_07
30
+ codex-ledger price coverage --rule-set reference_usd_openai_standard_2026_04_07
31
+ ```
@@ -0,0 +1,19 @@
1
+ # Pricing Rule Files
2
+
3
+ Each file in this directory is a versioned pricing rule snapshot.
4
+
5
+ Current schema:
6
+
7
+ - `pricing-rule-set-v1`
8
+
9
+ Each file should define:
10
+
11
+ - rule-set identity and pricing plane
12
+ - effective date window
13
+ - token-field mapping
14
+ - provider/model match rules
15
+ - provenance metadata
16
+ - confidence and stability labels
17
+
18
+ Rules are loaded offline from the local repository. They are validated before use, and
19
+ invalid or overlapping rule windows fail fast.
@@ -0,0 +1,59 @@
1
+ {
2
+ "schema_version": "pricing-rule-set-v1",
3
+ "rule_set_id": "reference_usd_openai_standard_2026_04_07",
4
+ "pricing_plane": "reference_usd",
5
+ "currency": "USD",
6
+ "version": "2026-04-07",
7
+ "effective_from_utc": "2026-03-05T00:00:00Z",
8
+ "effective_to_utc": null,
9
+ "stability": "reference",
10
+ "confidence": "high",
11
+ "token_mapping": {
12
+ "input_tokens_field": "input_tokens",
13
+ "cached_input_tokens_field": "cached_input_tokens",
14
+ "output_tokens_field": "output_tokens",
15
+ "cached_input_behavior": "subtract_from_input"
16
+ },
17
+ "provenance": {
18
+ "source_urls": [
19
+ "https://openai.com/api/pricing/",
20
+ "https://developers.openai.com/api/docs/models/gpt-5.4",
21
+ "https://developers.openai.com/api/docs/models/gpt-5.4-mini"
22
+ ],
23
+ "notes": "Reference USD estimate using public OpenAI standard token pricing for observed execution models only."
24
+ },
25
+ "rules": [
26
+ {
27
+ "rule_id": "gpt-5.4-standard-2026-03-05",
28
+ "provider": "codex",
29
+ "model_id": "gpt-5.4",
30
+ "effective_from_utc": "2026-03-05T00:00:00Z",
31
+ "effective_to_utc": null,
32
+ "input_usd_per_1m": "2.50",
33
+ "cached_input_usd_per_1m": "0.25",
34
+ "output_usd_per_1m": "15.00",
35
+ "stability": "reference",
36
+ "confidence": "high",
37
+ "provenance": {
38
+ "source_url": "https://developers.openai.com/api/docs/models/gpt-5.4",
39
+ "notes": "GPT-5.4 model page lists standard input, cached input, and output token pricing."
40
+ }
41
+ },
42
+ {
43
+ "rule_id": "gpt-5.4-mini-standard-2026-03-17",
44
+ "provider": "codex",
45
+ "model_id": "gpt-5.4-mini",
46
+ "effective_from_utc": "2026-03-17T00:00:00Z",
47
+ "effective_to_utc": null,
48
+ "input_usd_per_1m": "0.75",
49
+ "cached_input_usd_per_1m": "0.075",
50
+ "output_usd_per_1m": "4.50",
51
+ "stability": "reference",
52
+ "confidence": "high",
53
+ "provenance": {
54
+ "source_url": "https://developers.openai.com/api/docs/models/gpt-5.4-mini",
55
+ "notes": "GPT-5.4 mini model page lists standard input, cached input, and output token pricing."
56
+ }
57
+ }
58
+ ]
59
+ }
@@ -0,0 +1,72 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "codex-ledger"
7
+ version = "0.1.0"
8
+ description = "Local-first, auditable usage ledger for Codex session artifacts."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.12"
12
+ authors = [
13
+ { name = "Mark Hardy" },
14
+ ]
15
+ keywords = ["codex", "cli", "ledger", "sqlite", "usage"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Operating System :: MacOS",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Utilities",
25
+ ]
26
+ dependencies = [
27
+ "Pillow>=10.4",
28
+ ]
29
+
30
+ [project.scripts]
31
+ codex-ledger = "codex_ledger.cli.main:main"
32
+
33
+ [dependency-groups]
34
+ dev = [
35
+ "mypy>=1.18",
36
+ "pytest>=8.4",
37
+ "ruff>=0.13",
38
+ ]
39
+
40
+ [tool.hatch.build]
41
+ include = [
42
+ "src/codex_ledger/**/*.py",
43
+ "src/codex_ledger/migrations/*.sql",
44
+ "src/codex_ledger/pricing/rules_data/*.json",
45
+ "src/codex_ledger/reports/schemas_data/*.json",
46
+ "pricing/README.md",
47
+ "pricing/rules/*.json",
48
+ "pricing/rules/README.md",
49
+ "schemas/reports/*.json",
50
+ "schemas/reports/README.md",
51
+ "README.md",
52
+ "LICENSE",
53
+ ]
54
+
55
+ [tool.hatch.build.targets.wheel]
56
+ packages = ["src/codex_ledger"]
57
+
58
+ [tool.mypy]
59
+ python_version = "3.12"
60
+ strict = true
61
+ warn_unused_configs = true
62
+
63
+ [tool.pytest.ini_options]
64
+ addopts = "-ra"
65
+ testpaths = ["tests"]
66
+
67
+ [tool.ruff]
68
+ line-length = 100
69
+ target-version = "py312"
70
+
71
+ [tool.ruff.lint]
72
+ select = ["E", "F", "I", "UP", "B"]
@@ -0,0 +1,15 @@
1
+ # Report Schemas
2
+
3
+ Phase 4 adds lightweight JSON Schema documents for the stable report and explain payloads.
4
+
5
+ Current schema files:
6
+
7
+ - `aggregate-report-v1.schema.json`
8
+ - `workspace-report-v1.schema.json`
9
+ - `agent-diagnostics-v1.schema.json`
10
+ - `explain-report-v1.schema.json`
11
+
12
+ The schemas intentionally validate the stable top-level contract and major blocks rather
13
+ than every nested analytic detail.
14
+
15
+ Saved report JSON artifacts are validated against these schemas before render time.
@@ -0,0 +1,37 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Agent Diagnostics",
4
+ "type": "object",
5
+ "required": [
6
+ "schema_version",
7
+ "generated_at_utc",
8
+ "generator_version",
9
+ "filters",
10
+ "timezone",
11
+ "pricing",
12
+ "summary"
13
+ ],
14
+ "properties": {
15
+ "schema_version": {
16
+ "const": "phase2.1-agent-diagnostics-v1"
17
+ },
18
+ "generated_at_utc": {
19
+ "type": "string"
20
+ },
21
+ "generator_version": {
22
+ "type": "string"
23
+ },
24
+ "filters": {
25
+ "type": "object"
26
+ },
27
+ "timezone": {
28
+ "const": "UTC"
29
+ },
30
+ "pricing": {
31
+ "type": "object"
32
+ },
33
+ "summary": {
34
+ "type": "object"
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Aggregate Report",
4
+ "type": "object",
5
+ "required": [
6
+ "schema_version",
7
+ "generated_at_utc",
8
+ "generator_version",
9
+ "filters",
10
+ "timezone",
11
+ "pricing",
12
+ "data"
13
+ ],
14
+ "properties": {
15
+ "schema_version": {
16
+ "const": "phase4-aggregate-report-v1"
17
+ },
18
+ "generated_at_utc": {
19
+ "type": "string"
20
+ },
21
+ "generator_version": {
22
+ "type": "string"
23
+ },
24
+ "filters": {
25
+ "type": "object"
26
+ },
27
+ "timezone": {
28
+ "const": "UTC"
29
+ },
30
+ "pricing": {
31
+ "type": "object"
32
+ },
33
+ "data": {
34
+ "type": "object"
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Explain Report",
4
+ "type": "object",
5
+ "required": [
6
+ "schema_version",
7
+ "generated_at_utc",
8
+ "generator_version",
9
+ "filters",
10
+ "timezone",
11
+ "pricing",
12
+ "summary"
13
+ ],
14
+ "properties": {
15
+ "schema_version": {
16
+ "enum": [
17
+ "phase4-explain-report-v1",
18
+ "phase2.1-agent-diagnostics-v1"
19
+ ]
20
+ },
21
+ "generated_at_utc": {
22
+ "type": "string"
23
+ },
24
+ "generator_version": {
25
+ "type": "string"
26
+ },
27
+ "filters": {
28
+ "type": "object"
29
+ },
30
+ "timezone": {
31
+ "const": "UTC"
32
+ },
33
+ "pricing": {
34
+ "type": "object"
35
+ },
36
+ "summary": {
37
+ "type": "object"
38
+ }
39
+ }
40
+ }