entrix 0.1.5__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 (50) hide show
  1. entrix-0.1.5/.gitignore +6 -0
  2. entrix-0.1.5/LICENSE +21 -0
  3. entrix-0.1.5/PKG-INFO +446 -0
  4. entrix-0.1.5/README.md +414 -0
  5. entrix-0.1.5/entrix/__init__.py +3 -0
  6. entrix-0.1.5/entrix/__main__.py +6 -0
  7. entrix-0.1.5/entrix/cli.py +634 -0
  8. entrix-0.1.5/entrix/engine.py +248 -0
  9. entrix-0.1.5/entrix/evidence.py +5 -0
  10. entrix-0.1.5/entrix/file_budgets.py +257 -0
  11. entrix-0.1.5/entrix/governance.py +75 -0
  12. entrix-0.1.5/entrix/loaders/__init__.py +5 -0
  13. entrix-0.1.5/entrix/loaders/evidence_loader.py +180 -0
  14. entrix-0.1.5/entrix/model.py +189 -0
  15. entrix-0.1.5/entrix/presets/__init__.py +9 -0
  16. entrix-0.1.5/entrix/presets/base.py +27 -0
  17. entrix-0.1.5/entrix/presets/routa.py +91 -0
  18. entrix-0.1.5/entrix/reporters/__init__.py +0 -0
  19. entrix-0.1.5/entrix/reporters/json_reporter.py +25 -0
  20. entrix-0.1.5/entrix/reporters/terminal.py +86 -0
  21. entrix-0.1.5/entrix/reporting.py +51 -0
  22. entrix-0.1.5/entrix/review_trigger.py +207 -0
  23. entrix-0.1.5/entrix/runners/__init__.py +0 -0
  24. entrix-0.1.5/entrix/runners/graph.py +674 -0
  25. entrix-0.1.5/entrix/runners/shell.py +123 -0
  26. entrix-0.1.5/entrix/scoring.py +63 -0
  27. entrix-0.1.5/entrix/server.py +136 -0
  28. entrix-0.1.5/entrix/structure/__init__.py +0 -0
  29. entrix-0.1.5/entrix/structure/adapter.py +102 -0
  30. entrix-0.1.5/entrix/structure/builtin.py +1545 -0
  31. entrix-0.1.5/entrix/structure/impact.py +132 -0
  32. entrix-0.1.5/entrix/structure/protocol.py +49 -0
  33. entrix-0.1.5/entrix/structure/queries.py +40 -0
  34. entrix-0.1.5/file_budgets.json +23 -0
  35. entrix-0.1.5/pyproject.toml +57 -0
  36. entrix-0.1.5/tests/__init__.py +0 -0
  37. entrix-0.1.5/tests/test_builtin_graph.py +274 -0
  38. entrix-0.1.5/tests/test_cli.py +264 -0
  39. entrix-0.1.5/tests/test_engine.py +128 -0
  40. entrix-0.1.5/tests/test_evidence.py +253 -0
  41. entrix-0.1.5/tests/test_file_budgets.py +226 -0
  42. entrix-0.1.5/tests/test_governance.py +106 -0
  43. entrix-0.1.5/tests/test_graph_runner.py +299 -0
  44. entrix-0.1.5/tests/test_loaders.py +27 -0
  45. entrix-0.1.5/tests/test_model.py +105 -0
  46. entrix-0.1.5/tests/test_presets.py +37 -0
  47. entrix-0.1.5/tests/test_review_trigger.py +83 -0
  48. entrix-0.1.5/tests/test_scoring.py +136 -0
  49. entrix-0.1.5/tests/test_shell_runner.py +114 -0
  50. entrix-0.1.5/tests/test_structure_adapter.py +31 -0
@@ -0,0 +1,6 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .pytest_cache/
entrix-0.1.5/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Phodal
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.
entrix-0.1.5/PKG-INFO ADDED
@@ -0,0 +1,446 @@
1
+ Metadata-Version: 2.4
2
+ Name: entrix
3
+ Version: 0.1.5
4
+ Summary: A Harness Engineering tool for turning quality rules, architecture constraints, and validation steps into executable guardrails.
5
+ Project-URL: Homepage, https://github.com/phodal/entrix
6
+ Project-URL: Repository, https://github.com/phodal/entrix
7
+ Project-URL: Issues, https://github.com/phodal/entrix/issues
8
+ Author: Phodal
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: architecture,ci,code-review,fitness-functions,quality-gates
12
+ Classifier: Development Status :: 3 - Alpha
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 :: Software Development :: Quality Assurance
20
+ Classifier: Topic :: Software Development :: Testing
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: pyyaml<7,>=6.0
23
+ Requires-Dist: tree-sitter-language-pack<1,>=0.13
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest<9,>=8.0; extra == 'dev'
26
+ Requires-Dist: ruff<1,>=0.3.0; extra == 'dev'
27
+ Provides-Extra: graph
28
+ Requires-Dist: code-review-graph<2,>=1.8; extra == 'graph'
29
+ Provides-Extra: mcp
30
+ Requires-Dist: fastmcp<2,>=0.1.0; extra == 'mcp'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # Entrix
34
+
35
+ **Guardrails Embedded in the Change Lifecycle**
36
+
37
+ Entrix is a Harness Engineering tool for turning quality rules, architecture
38
+ constraints, and validation steps into executable guardrails.
39
+
40
+ Instead of relying on manual review at the end of delivery, Entrix moves
41
+ validation forward: checks become codified, evidence becomes traceable, and
42
+ quality gates become part of the engineering system itself.
43
+
44
+ It is designed for teams building in the AI era, where code can be generated
45
+ faster than it can be governed.
46
+
47
+ Entrix helps teams answer three questions continuously:
48
+
49
+ - should this change pass baseline quality gates?
50
+ - what level of confidence do we have in the current change?
51
+ - when should the system route the change to deeper validation or human review?
52
+
53
+ ## Lifecycle View
54
+
55
+ ```mermaid
56
+ flowchart LR
57
+ A[Requirements / AI-generated Change] --> B[Rule Definition]
58
+ B --> C[Baseline Quality Gates]
59
+ C --> D[Risk Identification and Routing]
60
+ D --> E[Deep Validation]
61
+ E --> F[Release and Feedback]
62
+
63
+ B -.-> B1[metrics]
64
+ B -.-> B2[thresholds]
65
+ B -.-> B3[hard gates]
66
+ B -.-> B4[evidence]
67
+
68
+ C -.-> C1[compile]
69
+ C -.-> C2[lint]
70
+ C -.-> C3[tests]
71
+ C -.-> C4[coverage]
72
+
73
+ D -.-> D1[API and schema]
74
+ D -.-> D2[impact radius]
75
+ D -.-> D3[suspicious expansion]
76
+ D -.-> D4[missing evidence]
77
+
78
+ E -.-> E1[API parity]
79
+ E -.-> E2[E2E and visual]
80
+ E -.-> E3[semgrep and audit]
81
+ E -.-> E4[human review]
82
+
83
+ F -.-> F1[merge and release]
84
+ F -.-> F2[update rules]
85
+ F -.-> F3[tune thresholds]
86
+ F -.-> F4[close the loop]
87
+ ```
88
+
89
+ The further to the right, the higher the fix cost, the lower the certainty of
90
+ automation, and the more human judgment is required.
91
+
92
+ Possible outcomes:
93
+
94
+ - `PASS`: continue to review, merge, and release
95
+ - `WARN`: strengthen evidence or escalate review depth
96
+ - `BLOCK`: do not merge
97
+
98
+ System foundation:
99
+
100
+ ```text
101
+ docs/fitness -> entrix orchestration -> hard gates + weighted score + review triggers
102
+ ```
103
+
104
+ Feedback loop:
105
+
106
+ ```text
107
+ production issue / missed detection
108
+ -> update docs/fitness
109
+ -> refine thresholds
110
+ -> add stronger verification templates
111
+ ```
112
+
113
+ ## What It Does
114
+
115
+ Today the package provides:
116
+
117
+ - architecture fitness checks grouped by dimension
118
+ - fast / normal / deep execution tiers
119
+ - change-aware execution against the current git diff
120
+ - hard-gate and weighted-score orchestration
121
+ - `review-trigger` rules that ask for human review on risky changes
122
+
123
+ It is useful both as:
124
+
125
+ - a repository-local fitness runner for monorepos and application repos
126
+ - the beginning of a more reusable fitness engine
127
+
128
+ ## Installation
129
+
130
+ ### Install from PyPI with `uv`
131
+
132
+ ```bash
133
+ uv tool install entrix
134
+ ```
135
+
136
+ Run without installing globally:
137
+
138
+ ```bash
139
+ uvx entrix --help
140
+ uvx entrix run --tier fast
141
+ uvx entrix review-trigger --base HEAD~1
142
+ ```
143
+
144
+ ### Install from PyPI with `pip`
145
+
146
+ ```bash
147
+ pip install entrix
148
+ ```
149
+
150
+ ### Run in a project without global install
151
+
152
+ ```bash
153
+ uvx --from entrix entrix --help
154
+ uvx --from entrix entrix run --tier fast
155
+ ```
156
+
157
+ ### Develop the package itself from source
158
+
159
+ If you are working on the `entrix` package source itself, clone this repository and install it from the repository root.
160
+
161
+ From the repository root:
162
+
163
+ ```bash
164
+ git clone https://github.com/phodal/entrix.git
165
+ cd entrix
166
+ uv pip install -e .
167
+ ```
168
+
169
+ With `pip`:
170
+
171
+ ```bash
172
+ git clone https://github.com/phodal/entrix.git
173
+ cd entrix
174
+ pip install -e .
175
+ ```
176
+
177
+ ## Quick Start
178
+
179
+ ### 1. Create a fitness spec
180
+
181
+ By default, `entrix run` looks for specs under the current project's:
182
+
183
+ ```text
184
+ docs/fitness/*.md
185
+ ```
186
+
187
+ Example `docs/fitness/code-quality.md`:
188
+
189
+ ```yaml
190
+ ---
191
+ dimension: code_quality
192
+ weight: 20
193
+ threshold:
194
+ pass: 90
195
+ warn: 80
196
+ metrics:
197
+ - name: lint
198
+ command: npm run lint 2>&1
199
+ hard_gate: true
200
+ tier: fast
201
+ description: ESLint must pass
202
+
203
+ - name: unit_tests
204
+ command: npm run test:run 2>&1
205
+ pattern: "Tests\\s+\\d+\\s+passed"
206
+ hard_gate: true
207
+ tier: normal
208
+ description: unit tests must pass
209
+ ---
210
+
211
+ # Code Quality
212
+
213
+ Narrative evidence, rules, and ownership notes can live below the frontmatter.
214
+ ```
215
+
216
+ ### 2. Run the checks
217
+
218
+ ```bash
219
+ entrix run --tier fast
220
+ entrix run --tier normal
221
+ entrix run --changed-only --base HEAD~1
222
+ entrix validate
223
+ ```
224
+
225
+ ### 3. Add review triggers
226
+
227
+ By default, `review-trigger` loads the current project's:
228
+
229
+ ```text
230
+ docs/fitness/review-triggers.yaml
231
+ ```
232
+
233
+ Example `docs/fitness/review-triggers.yaml`:
234
+
235
+ ```yaml
236
+ review_triggers:
237
+ - name: high_risk_directory_change
238
+ type: changed_paths
239
+ paths:
240
+ - src/core/acp/**
241
+ - src/core/orchestration/**
242
+ - services/api/**
243
+ severity: high
244
+ action: require_human_review
245
+
246
+ - name: oversized_change
247
+ type: diff_size
248
+ max_files: 12
249
+ max_added_lines: 600
250
+ max_deleted_lines: 400
251
+ severity: medium
252
+ action: require_human_review
253
+ ```
254
+
255
+ Run it:
256
+
257
+ ```bash
258
+ entrix review-trigger --base HEAD~1
259
+ entrix review-trigger --base HEAD~1 --json
260
+ ```
261
+
262
+ Example output:
263
+
264
+ ```json
265
+ {
266
+ "human_review_required": true,
267
+ "base": "HEAD~1",
268
+ "changed_files": [
269
+ "services/api/src/routes/acp_routes.rs"
270
+ ],
271
+ "diff_stats": {
272
+ "file_count": 13,
273
+ "added_lines": 936,
274
+ "deleted_lines": 20
275
+ },
276
+ "triggers": [
277
+ {
278
+ "name": "high_risk_directory_change",
279
+ "severity": "high",
280
+ "action": "require_human_review",
281
+ "reasons": [
282
+ "changed path: services/api/src/routes/acp_routes.rs"
283
+ ]
284
+ }
285
+ ]
286
+ }
287
+ ```
288
+
289
+ ## Commands
290
+
291
+ ### `entrix run`
292
+
293
+ Runs dimension-based fitness checks loaded from `docs/fitness/*.md`.
294
+
295
+ Common flags:
296
+
297
+ ```bash
298
+ entrix run --tier fast
299
+ entrix run --parallel
300
+ entrix run --dry-run
301
+ entrix run --verbose
302
+ entrix run --changed-only --base HEAD~1
303
+ ```
304
+
305
+ ### `entrix validate`
306
+
307
+ Checks that dimension weights sum to `100%`.
308
+
309
+ ```bash
310
+ entrix validate
311
+ ```
312
+
313
+ ### `entrix review-trigger`
314
+
315
+ Evaluates governance-oriented trigger rules for risky changes.
316
+
317
+ Common flags:
318
+
319
+ ```bash
320
+ entrix review-trigger --base HEAD~1
321
+ entrix review-trigger --json
322
+ entrix review-trigger --fail-on-trigger
323
+ entrix review-trigger --config docs/fitness/review-triggers.yaml
324
+ ```
325
+
326
+ ### `entrix graph ...`
327
+
328
+ Graph-backed commands support impact analysis, test radius, and AI-friendly review context.
329
+
330
+ Examples:
331
+
332
+ ```bash
333
+ entrix graph impact --base HEAD~1
334
+ entrix graph test-radius --base HEAD~1
335
+ entrix graph review-context --base HEAD~1 --json
336
+ ```
337
+
338
+ ## AI-Friendly Authoring Notes
339
+
340
+ If an AI agent is generating or updating fitness specs, these conventions work best:
341
+
342
+ - keep one dimension per file
343
+ - make the frontmatter executable and the body explanatory
344
+ - prefer stable command outputs over fragile text matching
345
+ - use `hard_gate: true` only when failure should really block progress
346
+ - keep review-trigger rules separate from scoring metrics
347
+ - treat markdown as the narrative layer, not the only source of structure
348
+
349
+ Recommended file layout:
350
+
351
+ ```text
352
+ your-project/
353
+ docs/
354
+ fitness/
355
+ README.md
356
+ code-quality.md
357
+ security.md
358
+ review-triggers.yaml
359
+ ```
360
+
361
+ Minimal bootstrap flow for a new repository:
362
+
363
+ ```bash
364
+ mkdir -p docs/fitness
365
+ cat > docs/fitness/code-quality.md <<'EOF'
366
+ ---
367
+ dimension: code_quality
368
+ weight: 100
369
+ threshold:
370
+ pass: 100
371
+ warn: 80
372
+ metrics:
373
+ - name: lint
374
+ command: npm run lint 2>&1
375
+ hard_gate: true
376
+ tier: fast
377
+ ---
378
+
379
+ # Code Quality
380
+ EOF
381
+
382
+ entrix validate
383
+ entrix run --tier fast
384
+ ```
385
+
386
+ ## Python API
387
+
388
+ ### Review trigger example
389
+
390
+ ```python
391
+ from pathlib import Path
392
+
393
+ from entrix.review_trigger import (
394
+ collect_changed_files,
395
+ collect_diff_stats,
396
+ evaluate_review_triggers,
397
+ load_review_triggers,
398
+ )
399
+
400
+ repo_root = Path(".").resolve()
401
+ rules = load_review_triggers(repo_root / "docs" / "fitness" / "review-triggers.yaml")
402
+ changed_files = collect_changed_files(repo_root, "HEAD~1")
403
+ diff_stats = collect_diff_stats(repo_root, "HEAD~1")
404
+ report = evaluate_review_triggers(rules, changed_files, diff_stats, base="HEAD~1")
405
+ print(report.to_dict())
406
+ ```
407
+
408
+ ### Fitness spec loading example
409
+
410
+ ```python
411
+ from pathlib import Path
412
+
413
+ from entrix.evidence import load_dimensions
414
+
415
+ dimensions = load_dimensions(Path("docs/fitness"))
416
+ for dimension in dimensions:
417
+ print(dimension.name, len(dimension.metrics))
418
+ ```
419
+
420
+ ## Recommended Hook Integration
421
+
422
+ For local repositories, a practical pattern is:
423
+
424
+ - `pre-commit`: run quick lint only
425
+ - `pre-push`: run full checks, then print review-trigger warnings
426
+ - CI: run `entrix run` and publish JSON/report output
427
+
428
+ That lets automation catch deterministic failures early while still escalating ambiguous risky changes to humans.
429
+
430
+ ## Known Constraints
431
+
432
+ Current constraints to be aware of:
433
+
434
+ - the package name on PyPI is `entrix`
435
+ - the default authoring format is still markdown frontmatter under `docs/fitness`
436
+ - the project is evolving toward a cleaner core / adapter / preset split
437
+ - graph commands require the optional graph dependency set
438
+
439
+ ## Status
440
+
441
+ Current status:
442
+
443
+ - stable for production use in real repository workflows
444
+ - installable as a standalone PyPI package
445
+ - suitable for AI-assisted project configuration
446
+ - evolving toward a reusable fitness engine architecture