civicmetric 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 (30) hide show
  1. civicmetric-0.2.0/LICENSE +21 -0
  2. civicmetric-0.2.0/PKG-INFO +208 -0
  3. civicmetric-0.2.0/README.md +181 -0
  4. civicmetric-0.2.0/pyproject.toml +54 -0
  5. civicmetric-0.2.0/setup.cfg +4 -0
  6. civicmetric-0.2.0/src/civicmetric/__init__.py +104 -0
  7. civicmetric-0.2.0/src/civicmetric/adapters/__init__.py +11 -0
  8. civicmetric-0.2.0/src/civicmetric/adapters/djpk.py +123 -0
  9. civicmetric-0.2.0/src/civicmetric/adapters/ocds.py +105 -0
  10. civicmetric-0.2.0/src/civicmetric/background.py +81 -0
  11. civicmetric-0.2.0/src/civicmetric/cli.py +324 -0
  12. civicmetric-0.2.0/src/civicmetric/composite.py +206 -0
  13. civicmetric-0.2.0/src/civicmetric/fiscal.py +430 -0
  14. civicmetric-0.2.0/src/civicmetric/network.py +402 -0
  15. civicmetric-0.2.0/src/civicmetric/policy.py +171 -0
  16. civicmetric-0.2.0/src/civicmetric/report.py +79 -0
  17. civicmetric-0.2.0/src/civicmetric/schemas.py +186 -0
  18. civicmetric-0.2.0/src/civicmetric/technocracy.py +204 -0
  19. civicmetric-0.2.0/src/civicmetric/wealth.py +248 -0
  20. civicmetric-0.2.0/src/civicmetric.egg-info/PKG-INFO +208 -0
  21. civicmetric-0.2.0/src/civicmetric.egg-info/SOURCES.txt +28 -0
  22. civicmetric-0.2.0/src/civicmetric.egg-info/dependency_links.txt +1 -0
  23. civicmetric-0.2.0/src/civicmetric.egg-info/entry_points.txt +2 -0
  24. civicmetric-0.2.0/src/civicmetric.egg-info/requires.txt +3 -0
  25. civicmetric-0.2.0/src/civicmetric.egg-info/top_level.txt +1 -0
  26. civicmetric-0.2.0/tests/test_composite_cli.py +54 -0
  27. civicmetric-0.2.0/tests/test_djpk_adapter.py +46 -0
  28. civicmetric-0.2.0/tests/test_fiscal.py +69 -0
  29. civicmetric-0.2.0/tests/test_governance.py +225 -0
  30. civicmetric-0.2.0/tests/test_v02_upgrades.py +200 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Muhammad Nizar
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,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: civicmetric
3
+ Version: 0.2.0
4
+ Summary: Open-source mathematical toolkit for public fiscal auditing, technocratic competency scoring, policy outcome evaluation, and conflict-of-interest network analysis.
5
+ Author: Muhammad Nizar
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/xlixzolit/civicmetric
8
+ Project-URL: Repository, https://github.com/xlixzolit/civicmetric
9
+ Project-URL: Issues, https://github.com/xlixzolit/civicmetric/issues
10
+ Keywords: civic-tech,public-finance,benford-law,anti-corruption,governance,network-analysis,statistics,audit
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
20
+ Classifier: Topic :: Office/Business :: Financial
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # civicmetric
29
+
30
+ [![CI](https://github.com/xlixzolit/civicmetric/actions/workflows/ci.yml/badge.svg)](https://github.com/xlixzolit/civicmetric/actions/workflows/ci.yml)
31
+ [![PyPI](https://img.shields.io/pypi/v/civicmetric.svg)](https://pypi.org/project/civicmetric/)
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
33
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
34
+
35
+ **Open-source, zero-dependency Python toolkit for quantitative public fiscal auditing, technocratic competency scoring, causal policy evaluation, and conflict-of-interest network analysis.**
36
+
37
+ `civicmetric` bridges the gap between procurement red-flag tools (such as OCDS engines) and institutional governance analysis. It unifies **public budget & tender econometrics**, **official competency alignment**, **causal policy outcome evaluation**, **wealth disclosure anomalies**, and **actor–vendor graph analysis** into a single deterministic, auditable Python library and CLI.
38
+
39
+ > **Methodology Disclaimer:** `civicmetric` computes statistical anomaly indicators and structural risk scores from public records to guide human, journalistic, and academic verification. Output flags are **not** legal proof of wrongdoing.
40
+
41
+ ---
42
+
43
+ ## Architecture & Mathematical Foundations
44
+
45
+ | Module | Core Question | Mathematical & Econometric Methods |
46
+ |---|---|---|
47
+ | `technocracy` | Do officials match the agency's technical mandate? | Mandate–domain overlap, career depth & relevance ratio, degree weighting, and **time-aligned program accreditation/ranking at enrollment year** |
48
+ | `policy` | Did programs deliver real outcomes efficiently? | Target attainment, budget execution efficiency, **Goodhart's Law guard** (`administrative_output` capped & down-weighted vs `independent_outcome`), and **Difference-in-Differences (DiD)**: $(\bar{Y}_{T,1}-\bar{Y}_{T,0})-(\bar{Y}_{C,1}-\bar{Y}_{C,0})$ |
49
+ | `network` | Are there structural nepotism, cartel, or capture risks? | **Dijkstra risk-weighted shortest path**, **closed-loop conflict triangles**, Brandes betweenness centrality, **Label Propagation community detection**, **Fazekas–Wachs bipartite buyer–supplier lock-in**, `REVOLVING_DOOR`, & deliberation openness |
50
+ | `background` | Are there verified adverse audit/legal/ethics records? | Evidence-linked weighted risk flags (unsourced claims discounted; missing data yields `0%` completeness rather than inflating scores) |
51
+ | `wealth` | Is pre- vs post-tenure wealth growth anomalous? | **Unexplained net inflow** $W_1 - W_0(1+r)^t - s \cdot I_{\text{official}}$, CAGR, cash/debt composition surges, multi-year YoY jump detection, & peer Z-score |
52
+ | `fiscal` | Are cash flows or tenders statistically irregular? | Benford 1st & 2nd digit (micro-data guarded), **Last-Two-Digits rounding**, **McCrary-style Threshold Bunching** (preset Indonesia Perpres 16/2018 & 12/2021: Rp200M / Rp100M), **Single Bidding**, participation drop-off, short submission windows, HHI, Q4 spikes, & thin HPS saving |
53
+
54
+ ### Aggregation & Robustness (OECD/JRC Best Practices)
55
+ - **Non-Compensatory Weighted Geometric Mean:** $\exp\left(\frac{\sum w_i \ln(\max(1, S_i))}{\sum w_i}\right)$ prevents high administrative scores from masking severe fiscal or legal red flags (reported alongside Linear average).
56
+ - **Hard Veto Risk Cap:** Automatically caps the risk tier when critical verified flags (`legal_conviction`, `procurement_blacklist`, or compound `threshold_bunching + monopoly`) occur.
57
+ - **Data Completeness / Confidence Score (0–100%):** Explicitly separates *"clean"* from *"missing public data"*.
58
+ - **Monte Carlo Perturbation Sensitivity:** Perturbs module weights (±25% across 200 trials) to test tier stability.
59
+
60
+ ---
61
+
62
+ ## Native Open-Data Adapters
63
+
64
+ - **Indonesia DJPK Kemenkeu APBD (`.xls` SpreadsheetML XML):** Directly parses regional budget exports downloaded from `djpk.kemenkeu.go.id` without external Excel/XML dependencies, deduplicating repeated rows and guarding macro aggregates against micro-level Benford false positives.
65
+ - **Open Contracting Data Standard (OCDS JSON):** Parses standard international `releases[]` (`buyer`, `tender`, `awards`, `suppliers`, `numberOfTenderers`, `tenderPeriod`) out of the box.
66
+ - **Flexible CSV & Multi-Module JSON Bundles:** Includes native Indonesian Rupiah (`"Rp 1.250.000,50"`) and international currency parsing.
67
+
68
+ ---
69
+
70
+ ## Installation
71
+
72
+ Requires Python 3.10+. **Zero external runtime dependencies.**
73
+
74
+ ```bash
75
+ pip install civicmetric
76
+ ```
77
+
78
+ For local editable installation from source:
79
+
80
+ ```bash
81
+ pip install -e .
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Quickstart (CLI)
87
+
88
+ ```bash
89
+ # 1. Full 6-module institutional governance audit
90
+ civicmetric audit examples/indonesia_public_demo/agency_bundle.json --format markdown
91
+
92
+ # 2. Official DJPK Kemenkeu APBD SpreadsheetML (.xls) audit
93
+ civicmetric djpk examples/indonesia_public_demo/djpk_apbd_2024_sample.xls \
94
+ --entity "DJPK APBD 2024" -o report_apbd.md
95
+
96
+ # 3. International OCDS JSON procurement audit
97
+ civicmetric ocds examples/indonesia_public_demo/ocds_sample.json --entity "OCDS City Works"
98
+
99
+ # 4. CSV procurement / cash-flow audit
100
+ civicmetric fiscal examples/indonesia_public_demo/budget_sample.csv --format json
101
+ ```
102
+
103
+ ### Example Output (`civicmetric ocds`)
104
+
105
+ ```markdown
106
+ # CivicMetric Audit Report: OCDS City Works
107
+
108
+ - **Composite Score (geometric):** `5.00 / 100` (`high_risk`)
109
+ - **Aggregation Comparison:** Geometric `5.00` vs Linear `5.00`
110
+ - **Data Confidence / Completeness:** `77.5%`
111
+ - **Hard Veto Risk Cap Active:** `critical_module_failure:fiscal(5.0), compound_procurement_capture:bunching+monopoly`
112
+ - **Sensitivity (±25% weight perturbation, n=200):** range `5.00–5.00` (sd=0.00, tier_stable=True)
113
+
114
+ ## Module Breakdown
115
+
116
+ | Module | Score (/100) | Completeness | Weight | Flags |
117
+ |---|---:|---:|---:|---|
118
+ | `fiscal` | 5.00 | 78% | 0.20 | high_vendor_concentration(hhi=10000), repeated_thin_hps_saving(3/3), threshold_bunching_below_200000000(3_vs_0) (+2 more) |
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Quickstart (Python API)
124
+
125
+ ```python
126
+ from civicmetric import (
127
+ EducationRecord,
128
+ FiscalTransaction,
129
+ OfficialProfile,
130
+ compute_composite_index,
131
+ difference_in_differences,
132
+ evaluate_fiscal_audit,
133
+ evaluate_technocracy,
134
+ parse_currency,
135
+ to_markdown,
136
+ )
137
+
138
+ officials = [
139
+ OfficialProfile(
140
+ official_id="OFF-01",
141
+ name="Director A",
142
+ institution="Public Works",
143
+ role="Director",
144
+ institution_domains=("civil_engineering", "urban_planning"),
145
+ education_fields=("civil_engineering",),
146
+ education_level="master",
147
+ relevant_years=11,
148
+ total_career_years=13,
149
+ education_records=(
150
+ EducationRecord(
151
+ institution_name="Institut Teknologi Bandung",
152
+ program_name="Civil Engineering",
153
+ enrollment_year=2008,
154
+ accreditation_tier="A",
155
+ program_rank_percentile=98.0,
156
+ ranking_source_url="https://banpt.or.id/",
157
+ ),
158
+ ),
159
+ source_url="https://example.go.id/profile/off-01",
160
+ )
161
+ ]
162
+
163
+ txs = [
164
+ FiscalTransaction(
165
+ tx_id="TX-01",
166
+ institution="Public Works",
167
+ region="West Java",
168
+ category="road",
169
+ amount=parse_currency("Rp 196.000.000") or 0.0,
170
+ month=11,
171
+ vendor_id="VND-1",
172
+ hps_estimate=parse_currency("Rp 198.000.000"),
173
+ bidder_count=1,
174
+ submission_days=3,
175
+ source_url="https://example.go.id/lpse/tx-01",
176
+ )
177
+ ]
178
+
179
+ did_effect = difference_in_differences(
180
+ treat_pre=62.0, treat_post=78.0, control_pre=61.0, control_post=66.0
181
+ )
182
+
183
+ result = compute_composite_index(
184
+ entity_name="Public Works Demo",
185
+ modules=[evaluate_technocracy(officials), evaluate_fiscal_audit(txs)],
186
+ )
187
+ print(to_markdown(result))
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Running Tests
193
+
194
+ ```bash
195
+ python3 -m unittest discover -s tests -v
196
+ # or with pytest:
197
+ pytest -v
198
+ ```
199
+
200
+ ---
201
+
202
+ ## Contributing
203
+
204
+ Contributions are welcome—especially open-data adapters for national/regional procurement and budget portals, econometric tests, and case-study notebooks. See [CONTRIBUTING.md](CONTRIBUTING.md).
205
+
206
+ ## License
207
+
208
+ MIT License — see [LICENSE](LICENSE).
@@ -0,0 +1,181 @@
1
+ # civicmetric
2
+
3
+ [![CI](https://github.com/xlixzolit/civicmetric/actions/workflows/ci.yml/badge.svg)](https://github.com/xlixzolit/civicmetric/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/civicmetric.svg)](https://pypi.org/project/civicmetric/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
7
+
8
+ **Open-source, zero-dependency Python toolkit for quantitative public fiscal auditing, technocratic competency scoring, causal policy evaluation, and conflict-of-interest network analysis.**
9
+
10
+ `civicmetric` bridges the gap between procurement red-flag tools (such as OCDS engines) and institutional governance analysis. It unifies **public budget & tender econometrics**, **official competency alignment**, **causal policy outcome evaluation**, **wealth disclosure anomalies**, and **actor–vendor graph analysis** into a single deterministic, auditable Python library and CLI.
11
+
12
+ > **Methodology Disclaimer:** `civicmetric` computes statistical anomaly indicators and structural risk scores from public records to guide human, journalistic, and academic verification. Output flags are **not** legal proof of wrongdoing.
13
+
14
+ ---
15
+
16
+ ## Architecture & Mathematical Foundations
17
+
18
+ | Module | Core Question | Mathematical & Econometric Methods |
19
+ |---|---|---|
20
+ | `technocracy` | Do officials match the agency's technical mandate? | Mandate–domain overlap, career depth & relevance ratio, degree weighting, and **time-aligned program accreditation/ranking at enrollment year** |
21
+ | `policy` | Did programs deliver real outcomes efficiently? | Target attainment, budget execution efficiency, **Goodhart's Law guard** (`administrative_output` capped & down-weighted vs `independent_outcome`), and **Difference-in-Differences (DiD)**: $(\bar{Y}_{T,1}-\bar{Y}_{T,0})-(\bar{Y}_{C,1}-\bar{Y}_{C,0})$ |
22
+ | `network` | Are there structural nepotism, cartel, or capture risks? | **Dijkstra risk-weighted shortest path**, **closed-loop conflict triangles**, Brandes betweenness centrality, **Label Propagation community detection**, **Fazekas–Wachs bipartite buyer–supplier lock-in**, `REVOLVING_DOOR`, & deliberation openness |
23
+ | `background` | Are there verified adverse audit/legal/ethics records? | Evidence-linked weighted risk flags (unsourced claims discounted; missing data yields `0%` completeness rather than inflating scores) |
24
+ | `wealth` | Is pre- vs post-tenure wealth growth anomalous? | **Unexplained net inflow** $W_1 - W_0(1+r)^t - s \cdot I_{\text{official}}$, CAGR, cash/debt composition surges, multi-year YoY jump detection, & peer Z-score |
25
+ | `fiscal` | Are cash flows or tenders statistically irregular? | Benford 1st & 2nd digit (micro-data guarded), **Last-Two-Digits rounding**, **McCrary-style Threshold Bunching** (preset Indonesia Perpres 16/2018 & 12/2021: Rp200M / Rp100M), **Single Bidding**, participation drop-off, short submission windows, HHI, Q4 spikes, & thin HPS saving |
26
+
27
+ ### Aggregation & Robustness (OECD/JRC Best Practices)
28
+ - **Non-Compensatory Weighted Geometric Mean:** $\exp\left(\frac{\sum w_i \ln(\max(1, S_i))}{\sum w_i}\right)$ prevents high administrative scores from masking severe fiscal or legal red flags (reported alongside Linear average).
29
+ - **Hard Veto Risk Cap:** Automatically caps the risk tier when critical verified flags (`legal_conviction`, `procurement_blacklist`, or compound `threshold_bunching + monopoly`) occur.
30
+ - **Data Completeness / Confidence Score (0–100%):** Explicitly separates *"clean"* from *"missing public data"*.
31
+ - **Monte Carlo Perturbation Sensitivity:** Perturbs module weights (±25% across 200 trials) to test tier stability.
32
+
33
+ ---
34
+
35
+ ## Native Open-Data Adapters
36
+
37
+ - **Indonesia DJPK Kemenkeu APBD (`.xls` SpreadsheetML XML):** Directly parses regional budget exports downloaded from `djpk.kemenkeu.go.id` without external Excel/XML dependencies, deduplicating repeated rows and guarding macro aggregates against micro-level Benford false positives.
38
+ - **Open Contracting Data Standard (OCDS JSON):** Parses standard international `releases[]` (`buyer`, `tender`, `awards`, `suppliers`, `numberOfTenderers`, `tenderPeriod`) out of the box.
39
+ - **Flexible CSV & Multi-Module JSON Bundles:** Includes native Indonesian Rupiah (`"Rp 1.250.000,50"`) and international currency parsing.
40
+
41
+ ---
42
+
43
+ ## Installation
44
+
45
+ Requires Python 3.10+. **Zero external runtime dependencies.**
46
+
47
+ ```bash
48
+ pip install civicmetric
49
+ ```
50
+
51
+ For local editable installation from source:
52
+
53
+ ```bash
54
+ pip install -e .
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Quickstart (CLI)
60
+
61
+ ```bash
62
+ # 1. Full 6-module institutional governance audit
63
+ civicmetric audit examples/indonesia_public_demo/agency_bundle.json --format markdown
64
+
65
+ # 2. Official DJPK Kemenkeu APBD SpreadsheetML (.xls) audit
66
+ civicmetric djpk examples/indonesia_public_demo/djpk_apbd_2024_sample.xls \
67
+ --entity "DJPK APBD 2024" -o report_apbd.md
68
+
69
+ # 3. International OCDS JSON procurement audit
70
+ civicmetric ocds examples/indonesia_public_demo/ocds_sample.json --entity "OCDS City Works"
71
+
72
+ # 4. CSV procurement / cash-flow audit
73
+ civicmetric fiscal examples/indonesia_public_demo/budget_sample.csv --format json
74
+ ```
75
+
76
+ ### Example Output (`civicmetric ocds`)
77
+
78
+ ```markdown
79
+ # CivicMetric Audit Report: OCDS City Works
80
+
81
+ - **Composite Score (geometric):** `5.00 / 100` (`high_risk`)
82
+ - **Aggregation Comparison:** Geometric `5.00` vs Linear `5.00`
83
+ - **Data Confidence / Completeness:** `77.5%`
84
+ - **Hard Veto Risk Cap Active:** `critical_module_failure:fiscal(5.0), compound_procurement_capture:bunching+monopoly`
85
+ - **Sensitivity (±25% weight perturbation, n=200):** range `5.00–5.00` (sd=0.00, tier_stable=True)
86
+
87
+ ## Module Breakdown
88
+
89
+ | Module | Score (/100) | Completeness | Weight | Flags |
90
+ |---|---:|---:|---:|---|
91
+ | `fiscal` | 5.00 | 78% | 0.20 | high_vendor_concentration(hhi=10000), repeated_thin_hps_saving(3/3), threshold_bunching_below_200000000(3_vs_0) (+2 more) |
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Quickstart (Python API)
97
+
98
+ ```python
99
+ from civicmetric import (
100
+ EducationRecord,
101
+ FiscalTransaction,
102
+ OfficialProfile,
103
+ compute_composite_index,
104
+ difference_in_differences,
105
+ evaluate_fiscal_audit,
106
+ evaluate_technocracy,
107
+ parse_currency,
108
+ to_markdown,
109
+ )
110
+
111
+ officials = [
112
+ OfficialProfile(
113
+ official_id="OFF-01",
114
+ name="Director A",
115
+ institution="Public Works",
116
+ role="Director",
117
+ institution_domains=("civil_engineering", "urban_planning"),
118
+ education_fields=("civil_engineering",),
119
+ education_level="master",
120
+ relevant_years=11,
121
+ total_career_years=13,
122
+ education_records=(
123
+ EducationRecord(
124
+ institution_name="Institut Teknologi Bandung",
125
+ program_name="Civil Engineering",
126
+ enrollment_year=2008,
127
+ accreditation_tier="A",
128
+ program_rank_percentile=98.0,
129
+ ranking_source_url="https://banpt.or.id/",
130
+ ),
131
+ ),
132
+ source_url="https://example.go.id/profile/off-01",
133
+ )
134
+ ]
135
+
136
+ txs = [
137
+ FiscalTransaction(
138
+ tx_id="TX-01",
139
+ institution="Public Works",
140
+ region="West Java",
141
+ category="road",
142
+ amount=parse_currency("Rp 196.000.000") or 0.0,
143
+ month=11,
144
+ vendor_id="VND-1",
145
+ hps_estimate=parse_currency("Rp 198.000.000"),
146
+ bidder_count=1,
147
+ submission_days=3,
148
+ source_url="https://example.go.id/lpse/tx-01",
149
+ )
150
+ ]
151
+
152
+ did_effect = difference_in_differences(
153
+ treat_pre=62.0, treat_post=78.0, control_pre=61.0, control_post=66.0
154
+ )
155
+
156
+ result = compute_composite_index(
157
+ entity_name="Public Works Demo",
158
+ modules=[evaluate_technocracy(officials), evaluate_fiscal_audit(txs)],
159
+ )
160
+ print(to_markdown(result))
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Running Tests
166
+
167
+ ```bash
168
+ python3 -m unittest discover -s tests -v
169
+ # or with pytest:
170
+ pytest -v
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Contributing
176
+
177
+ Contributions are welcome—especially open-data adapters for national/regional procurement and budget portals, econometric tests, and case-study notebooks. See [CONTRIBUTING.md](CONTRIBUTING.md).
178
+
179
+ ## License
180
+
181
+ MIT License — see [LICENSE](LICENSE).
@@ -0,0 +1,54 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "civicmetric"
7
+ version = "0.2.0"
8
+ description = "Open-source mathematical toolkit for public fiscal auditing, technocratic competency scoring, policy outcome evaluation, and conflict-of-interest network analysis."
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ {name = "Muhammad Nizar"}
14
+ ]
15
+ keywords = [
16
+ "civic-tech",
17
+ "public-finance",
18
+ "benford-law",
19
+ "anti-corruption",
20
+ "governance",
21
+ "network-analysis",
22
+ "statistics",
23
+ "audit",
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 3 - Alpha",
27
+ "Intended Audience :: Science/Research",
28
+ "Intended Audience :: Developers",
29
+ "License :: OSI Approved :: MIT License",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.10",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Topic :: Scientific/Engineering :: Mathematics",
35
+ "Topic :: Office/Business :: Financial",
36
+ ]
37
+ dependencies = []
38
+
39
+ [project.optional-dependencies]
40
+ dev = ["pytest>=8.0"]
41
+
42
+ [project.scripts]
43
+ civicmetric = "civicmetric.cli:main"
44
+
45
+ [project.urls]
46
+ Homepage = "https://github.com/xlixzolit/civicmetric"
47
+ Repository = "https://github.com/xlixzolit/civicmetric"
48
+ Issues = "https://github.com/xlixzolit/civicmetric/issues"
49
+
50
+ [tool.setuptools.packages.find]
51
+ where = ["src"]
52
+
53
+ [tool.pytest.ini_options]
54
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,104 @@
1
+ """civicmetric: Open-source mathematical toolkit for public fiscal & governance auditing."""
2
+
3
+ from .adapters import DJPKBudgetLine, djpk_lines_to_transactions, load_djpk_apbd, load_ocds_releases
4
+ from .background import evaluate_background
5
+ from .composite import (
6
+ DEFAULT_WEIGHTS,
7
+ CompositeAuditResult,
8
+ compute_composite_index,
9
+ weight_sensitivity_analysis,
10
+ )
11
+ from .fiscal import (
12
+ BENFORD_EXPECTED,
13
+ BENFORD_SECOND_EXPECTED,
14
+ INDONESIA_LEGAL_THRESHOLDS,
15
+ benford_first_digit_test,
16
+ benford_second_digit_test,
17
+ detect_amount_outliers,
18
+ detect_threshold_bunching,
19
+ evaluate_fiscal_audit,
20
+ last_two_digits_rounding_test,
21
+ vendor_concentration_hhi,
22
+ year_end_spending_spike,
23
+ )
24
+ from .network import (
25
+ analyze_bipartite_procurement_graph,
26
+ brandes_betweenness_centrality,
27
+ build_adjacency,
28
+ detect_communities_label_propagation,
29
+ detect_conflict_triangles,
30
+ evaluate_network_risk,
31
+ shortest_path_distance,
32
+ weighted_risk_distance,
33
+ )
34
+ from .policy import difference_in_differences, evaluate_policies, score_policy_program
35
+ from .report import to_json, to_markdown
36
+ from .schemas import (
37
+ BackgroundSignal,
38
+ EducationRecord,
39
+ FiscalTransaction,
40
+ ModuleScore,
41
+ OfficialProfile,
42
+ PolicyProgram,
43
+ RelationEdge,
44
+ WealthRecord,
45
+ WealthSnapshot,
46
+ parse_currency,
47
+ )
48
+ from .technocracy import evaluate_technocracy, score_education_quality, score_official_technocracy
49
+ from .wealth import compute_cagr, compute_unexplained_inflow, evaluate_wealth_delta
50
+
51
+ __version__ = "0.2.0"
52
+
53
+ __all__ = [
54
+ "__version__",
55
+ "BENFORD_EXPECTED",
56
+ "BENFORD_SECOND_EXPECTED",
57
+ "DEFAULT_WEIGHTS",
58
+ "DJPKBudgetLine",
59
+ "INDONESIA_LEGAL_THRESHOLDS",
60
+ "BackgroundSignal",
61
+ "CompositeAuditResult",
62
+ "EducationRecord",
63
+ "FiscalTransaction",
64
+ "ModuleScore",
65
+ "OfficialProfile",
66
+ "PolicyProgram",
67
+ "RelationEdge",
68
+ "WealthRecord",
69
+ "WealthSnapshot",
70
+ "analyze_bipartite_procurement_graph",
71
+ "benford_first_digit_test",
72
+ "benford_second_digit_test",
73
+ "brandes_betweenness_centrality",
74
+ "build_adjacency",
75
+ "compute_cagr",
76
+ "compute_composite_index",
77
+ "compute_unexplained_inflow",
78
+ "detect_amount_outliers",
79
+ "detect_communities_label_propagation",
80
+ "detect_conflict_triangles",
81
+ "detect_threshold_bunching",
82
+ "difference_in_differences",
83
+ "djpk_lines_to_transactions",
84
+ "evaluate_background",
85
+ "evaluate_fiscal_audit",
86
+ "evaluate_network_risk",
87
+ "evaluate_policies",
88
+ "evaluate_technocracy",
89
+ "evaluate_wealth_delta",
90
+ "last_two_digits_rounding_test",
91
+ "load_djpk_apbd",
92
+ "load_ocds_releases",
93
+ "parse_currency",
94
+ "score_education_quality",
95
+ "score_official_technocracy",
96
+ "score_policy_program",
97
+ "shortest_path_distance",
98
+ "to_json",
99
+ "to_markdown",
100
+ "vendor_concentration_hhi",
101
+ "weight_sensitivity_analysis",
102
+ "weighted_risk_distance",
103
+ "year_end_spending_spike",
104
+ ]
@@ -0,0 +1,11 @@
1
+ """Public data adapters for Indonesian & international open-government formats."""
2
+
3
+ from .djpk import DJPKBudgetLine, djpk_lines_to_transactions, load_djpk_apbd
4
+ from .ocds import load_ocds_releases
5
+
6
+ __all__ = [
7
+ "DJPKBudgetLine",
8
+ "djpk_lines_to_transactions",
9
+ "load_djpk_apbd",
10
+ "load_ocds_releases",
11
+ ]