pebra 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 (191) hide show
  1. pebra-0.1.0/CONTRIBUTING.md +88 -0
  2. pebra-0.1.0/LICENSE +201 -0
  3. pebra-0.1.0/MANIFEST.in +10 -0
  4. pebra-0.1.0/PKG-INFO +242 -0
  5. pebra-0.1.0/README.md +189 -0
  6. pebra-0.1.0/RELEASING.md +95 -0
  7. pebra-0.1.0/SECURITY.md +39 -0
  8. pebra-0.1.0/pebra/__init__.py +0 -0
  9. pebra-0.1.0/pebra/__main__.py +10 -0
  10. pebra-0.1.0/pebra/adapters/__init__.py +0 -0
  11. pebra-0.1.0/pebra/adapters/_ast_utils.py +265 -0
  12. pebra-0.1.0/pebra/adapters/_paths.py +41 -0
  13. pebra-0.1.0/pebra/adapters/architecture_map.py +91 -0
  14. pebra-0.1.0/pebra/adapters/ast_diff_adapter.py +256 -0
  15. pebra-0.1.0/pebra/adapters/ast_import_graph.py +228 -0
  16. pebra-0.1.0/pebra/adapters/bandit_adapter.py +100 -0
  17. pebra-0.1.0/pebra/adapters/calibration_store.py +31 -0
  18. pebra-0.1.0/pebra/adapters/candidate_application.py +161 -0
  19. pebra-0.1.0/pebra/adapters/candidate_binding.py +352 -0
  20. pebra-0.1.0/pebra/adapters/candidate_edits.py +63 -0
  21. pebra-0.1.0/pebra/adapters/candidate_gate.py +16 -0
  22. pebra-0.1.0/pebra/adapters/candidate_replay_cache.py +134 -0
  23. pebra-0.1.0/pebra/adapters/codegraph_adapter.py +1610 -0
  24. pebra-0.1.0/pebra/adapters/codegraph_candidate_refinement.py +943 -0
  25. pebra-0.1.0/pebra/adapters/codegraph_graph_reader.py +271 -0
  26. pebra-0.1.0/pebra/adapters/codegraph_materialized_diff.py +323 -0
  27. pebra-0.1.0/pebra/adapters/composite_evidence.py +89 -0
  28. pebra-0.1.0/pebra/adapters/continuity_witness.py +331 -0
  29. pebra-0.1.0/pebra/adapters/contract_surface.py +19 -0
  30. pebra-0.1.0/pebra/adapters/enforcement_capability.py +180 -0
  31. pebra-0.1.0/pebra/adapters/evidence_merge.py +125 -0
  32. pebra-0.1.0/pebra/adapters/gate_check_adapter.py +549 -0
  33. pebra-0.1.0/pebra/adapters/git_adapter.py +76 -0
  34. pebra-0.1.0/pebra/adapters/git_change_verifier.py +276 -0
  35. pebra-0.1.0/pebra/adapters/import_graph_cache.py +332 -0
  36. pebra-0.1.0/pebra/adapters/learning_store.py +39 -0
  37. pebra-0.1.0/pebra/adapters/patch_header_adapter.py +93 -0
  38. pebra-0.1.0/pebra/adapters/patch_materializer.py +125 -0
  39. pebra-0.1.0/pebra/adapters/paths.py +66 -0
  40. pebra-0.1.0/pebra/adapters/rca_adapter.py +256 -0
  41. pebra-0.1.0/pebra/adapters/repository_registry.py +20 -0
  42. pebra-0.1.0/pebra/adapters/request_evidence.py +58 -0
  43. pebra-0.1.0/pebra/adapters/sanction_store.py +27 -0
  44. pebra-0.1.0/pebra/adapters/snapshot_read_store.py +95 -0
  45. pebra-0.1.0/pebra/adapters/store/__init__.py +0 -0
  46. pebra-0.1.0/pebra/adapters/store/db.py +2033 -0
  47. pebra-0.1.0/pebra/adapters/structural_feature_adapter.py +151 -0
  48. pebra-0.1.0/pebra/adapters/yaml_config.py +169 -0
  49. pebra-0.1.0/pebra/app/__init__.py +0 -0
  50. pebra-0.1.0/pebra/app/accept_risk_controller.py +74 -0
  51. pebra-0.1.0/pebra/app/assess_controller.py +1328 -0
  52. pebra-0.1.0/pebra/app/candidate_apply_controller.py +124 -0
  53. pebra-0.1.0/pebra/app/finalize_outcome_controller.py +110 -0
  54. pebra-0.1.0/pebra/app/human_approval_controller.py +178 -0
  55. pebra-0.1.0/pebra/app/learning_controller.py +105 -0
  56. pebra-0.1.0/pebra/app/observatory_query_controller.py +92 -0
  57. pebra-0.1.0/pebra/app/promotion_controller.py +325 -0
  58. pebra-0.1.0/pebra/app/record_outcome_controller.py +50 -0
  59. pebra-0.1.0/pebra/app/verify_controller.py +165 -0
  60. pebra-0.1.0/pebra/cli/__init__.py +0 -0
  61. pebra-0.1.0/pebra/cli/accept_risk.py +113 -0
  62. pebra-0.1.0/pebra/cli/agent_init.py +187 -0
  63. pebra-0.1.0/pebra/cli/apply_candidate.py +51 -0
  64. pebra-0.1.0/pebra/cli/assess.py +157 -0
  65. pebra-0.1.0/pebra/cli/candidate_patch.py +37 -0
  66. pebra-0.1.0/pebra/cli/capabilities.py +58 -0
  67. pebra-0.1.0/pebra/cli/dashboard.py +83 -0
  68. pebra-0.1.0/pebra/cli/dependents.py +46 -0
  69. pebra-0.1.0/pebra/cli/finalize_outcome.py +86 -0
  70. pebra-0.1.0/pebra/cli/gate_check.py +49 -0
  71. pebra-0.1.0/pebra/cli/gate_hook.py +62 -0
  72. pebra-0.1.0/pebra/cli/graph_stats.py +40 -0
  73. pebra-0.1.0/pebra/cli/learn.py +66 -0
  74. pebra-0.1.0/pebra/cli/main.py +125 -0
  75. pebra-0.1.0/pebra/cli/promote.py +90 -0
  76. pebra-0.1.0/pebra/cli/record_outcome.py +64 -0
  77. pebra-0.1.0/pebra/cli/scorecard.py +88 -0
  78. pebra-0.1.0/pebra/cli/setup_graph.py +457 -0
  79. pebra-0.1.0/pebra/cli/tui.py +53 -0
  80. pebra-0.1.0/pebra/cli/verify.py +103 -0
  81. pebra-0.1.0/pebra/composition.py +398 -0
  82. pebra-0.1.0/pebra/core/__init__.py +0 -0
  83. pebra-0.1.0/pebra/core/apply_snapshot.py +512 -0
  84. pebra-0.1.0/pebra/core/assessment_builder.py +314 -0
  85. pebra-0.1.0/pebra/core/benefit_aggregation.py +38 -0
  86. pebra-0.1.0/pebra/core/benefit_model.py +139 -0
  87. pebra-0.1.0/pebra/core/calibrated_priors.py +29 -0
  88. pebra-0.1.0/pebra/core/candidate_aggregation.py +99 -0
  89. pebra-0.1.0/pebra/core/candidate_parser.py +37 -0
  90. pebra-0.1.0/pebra/core/candidate_refinement.py +162 -0
  91. pebra-0.1.0/pebra/core/change_classifier.py +275 -0
  92. pebra-0.1.0/pebra/core/confidence_gate.py +29 -0
  93. pebra-0.1.0/pebra/core/constants.py +195 -0
  94. pebra-0.1.0/pebra/core/dashboard_metrics.py +50 -0
  95. pebra-0.1.0/pebra/core/decision_engine.py +733 -0
  96. pebra-0.1.0/pebra/core/destructive_op_model.py +108 -0
  97. pebra-0.1.0/pebra/core/engine_argv.py +34 -0
  98. pebra-0.1.0/pebra/core/engine_paths.py +67 -0
  99. pebra-0.1.0/pebra/core/explanation_generator.py +116 -0
  100. pebra-0.1.0/pebra/core/exposure_model.py +28 -0
  101. pebra-0.1.0/pebra/core/file_risk_aggregation.py +45 -0
  102. pebra-0.1.0/pebra/core/graph_trust.py +32 -0
  103. pebra-0.1.0/pebra/core/graph_version.py +55 -0
  104. pebra-0.1.0/pebra/core/high_risk_controls.py +64 -0
  105. pebra-0.1.0/pebra/core/language_capability.py +121 -0
  106. pebra-0.1.0/pebra/core/learning_eval.py +138 -0
  107. pebra-0.1.0/pebra/core/model_guidance.py +187 -0
  108. pebra-0.1.0/pebra/core/models.py +553 -0
  109. pebra-0.1.0/pebra/core/modify_risk_model.py +206 -0
  110. pebra-0.1.0/pebra/core/outcome_labels.py +58 -0
  111. pebra-0.1.0/pebra/core/patch_paths.py +188 -0
  112. pebra-0.1.0/pebra/core/post_assessment_guardrails.py +304 -0
  113. pebra-0.1.0/pebra/core/prediction_capture.py +218 -0
  114. pebra-0.1.0/pebra/core/prediction_error.py +224 -0
  115. pebra-0.1.0/pebra/core/promotion_evaluator.py +488 -0
  116. pebra-0.1.0/pebra/core/query_validator.py +20 -0
  117. pebra-0.1.0/pebra/core/rca_engine_paths.py +57 -0
  118. pebra-0.1.0/pebra/core/request_validator.py +57 -0
  119. pebra-0.1.0/pebra/core/risk_fact_decay.py +56 -0
  120. pebra-0.1.0/pebra/core/score_math.py +155 -0
  121. pebra-0.1.0/pebra/core/score_normalizer.py +106 -0
  122. pebra-0.1.0/pebra/core/snapshot_reconciler.py +66 -0
  123. pebra-0.1.0/pebra/core/structural_features.py +104 -0
  124. pebra-0.1.0/pebra/core/variance_bounds.py +50 -0
  125. pebra-0.1.0/pebra/core/warm_prior.py +193 -0
  126. pebra-0.1.0/pebra/core/weight_resolver.py +51 -0
  127. pebra-0.1.0/pebra/dashboard/__init__.py +0 -0
  128. pebra-0.1.0/pebra/dashboard/api.py +232 -0
  129. pebra-0.1.0/pebra/dashboard/auth.py +36 -0
  130. pebra-0.1.0/pebra/dashboard/ports.py +56 -0
  131. pebra-0.1.0/pebra/dashboard/server.py +179 -0
  132. pebra-0.1.0/pebra/dashboard/static/app.js +579 -0
  133. pebra-0.1.0/pebra/dashboard/static/style.css +219 -0
  134. pebra-0.1.0/pebra/dashboard/static/vendor/uplot.LICENSE.txt +21 -0
  135. pebra-0.1.0/pebra/dashboard/static/vendor/uplot.iife.min.js +2 -0
  136. pebra-0.1.0/pebra/dashboard/static/vendor/uplot.min.css +1 -0
  137. pebra-0.1.0/pebra/dashboard/templates/index.html +43 -0
  138. pebra-0.1.0/pebra/learning_composition.py +21 -0
  139. pebra-0.1.0/pebra/mcp_server/__init__.py +0 -0
  140. pebra-0.1.0/pebra/mcp_server/__main__.py +17 -0
  141. pebra-0.1.0/pebra/mcp_server/server.py +288 -0
  142. pebra-0.1.0/pebra/observatory_context.py +51 -0
  143. pebra-0.1.0/pebra/ports/__init__.py +0 -0
  144. pebra-0.1.0/pebra/ports/architecture_knowledge_port.py +18 -0
  145. pebra-0.1.0/pebra/ports/blast_radius_port.py +11 -0
  146. pebra-0.1.0/pebra/ports/calibration_port.py +13 -0
  147. pebra-0.1.0/pebra/ports/candidate_application_port.py +33 -0
  148. pebra-0.1.0/pebra/ports/candidate_binding_port.py +15 -0
  149. pebra-0.1.0/pebra/ports/candidate_replay_port.py +15 -0
  150. pebra-0.1.0/pebra/ports/change_verifier_port.py +17 -0
  151. pebra-0.1.0/pebra/ports/config_port.py +57 -0
  152. pebra-0.1.0/pebra/ports/contract_surface_port.py +17 -0
  153. pebra-0.1.0/pebra/ports/evidence_port.py +13 -0
  154. pebra-0.1.0/pebra/ports/fanin_port.py +38 -0
  155. pebra-0.1.0/pebra/ports/file_fanin_port.py +18 -0
  156. pebra-0.1.0/pebra/ports/graph_risk_refinement_port.py +16 -0
  157. pebra-0.1.0/pebra/ports/language_capability_port.py +27 -0
  158. pebra-0.1.0/pebra/ports/learning_port.py +38 -0
  159. pebra-0.1.0/pebra/ports/materialized_diff_port.py +25 -0
  160. pebra-0.1.0/pebra/ports/observatory_read_port.py +34 -0
  161. pebra-0.1.0/pebra/ports/outcome_port.py +16 -0
  162. pebra-0.1.0/pebra/ports/repository_registry_port.py +18 -0
  163. pebra-0.1.0/pebra/ports/sanction_port.py +19 -0
  164. pebra-0.1.0/pebra/ports/snapshot_read_port.py +21 -0
  165. pebra-0.1.0/pebra/ports/store_port.py +114 -0
  166. pebra-0.1.0/pebra/ports/structural_feature_port.py +18 -0
  167. pebra-0.1.0/pebra/ports/symbol_diff_port.py +11 -0
  168. pebra-0.1.0/pebra/tui/__init__.py +6 -0
  169. pebra-0.1.0/pebra/tui/app.py +70 -0
  170. pebra-0.1.0/pebra/tui/data.py +99 -0
  171. pebra-0.1.0/pebra/tui/screens/__init__.py +1 -0
  172. pebra-0.1.0/pebra/tui/screens/detail.py +73 -0
  173. pebra-0.1.0/pebra/tui/screens/observatory.py +200 -0
  174. pebra-0.1.0/pebra/tui/theme.py +64 -0
  175. pebra-0.1.0/pebra/tui/theme.tcss +33 -0
  176. pebra-0.1.0/pebra/tui/widgets/__init__.py +1 -0
  177. pebra-0.1.0/pebra/tui/widgets/ledger_table.py +103 -0
  178. pebra-0.1.0/pebra/tui/widgets/score_sparklines.py +54 -0
  179. pebra-0.1.0/pebra/tui/widgets/status_header.py +31 -0
  180. pebra-0.1.0/pebra.egg-info/PKG-INFO +242 -0
  181. pebra-0.1.0/pebra.egg-info/SOURCES.txt +189 -0
  182. pebra-0.1.0/pebra.egg-info/dependency_links.txt +1 -0
  183. pebra-0.1.0/pebra.egg-info/entry_points.txt +3 -0
  184. pebra-0.1.0/pebra.egg-info/requires.txt +34 -0
  185. pebra-0.1.0/pebra.egg-info/top_level.txt +1 -0
  186. pebra-0.1.0/pyproject.toml +117 -0
  187. pebra-0.1.0/requirements-release.in +4 -0
  188. pebra-0.1.0/requirements-release.txt +404 -0
  189. pebra-0.1.0/setup.cfg +4 -0
  190. pebra-0.1.0/tests/test_core_only_import.py +46 -0
  191. pebra-0.1.0/tests/test_core_stdlib_only.py +106 -0
@@ -0,0 +1,88 @@
1
+ # Contributing To PEBRA
2
+
3
+ PEBRA accepts focused contributions that preserve its deterministic decision core, explicit trust
4
+ boundaries, and testable CLI behavior.
5
+
6
+ ## Contribution Terms
7
+
8
+ PEBRA accepts contributions under the Apache License 2.0, without additional terms or conditions.
9
+ Alternative terms require prior written agreement from a project maintainer. By submitting a
10
+ contribution, you confirm that you have the **right to submit** it under the accepted terms.
11
+
12
+ Apache License 2.0 permits commercial use, modification, and redistribution subject to its terms.
13
+ Do not submit code, data, generated artifacts, or other material that you do not have the right to
14
+ license. Identify copied or adapted third-party material and preserve its required notices.
15
+
16
+ ## Development Setup
17
+
18
+ Use Python 3.11 or newer. A minimal Windows setup is:
19
+
20
+ ```powershell
21
+ python -m venv .venv
22
+ .\.venv\Scripts\python.exe -m pip install --upgrade pip
23
+ .\.venv\Scripts\python.exe -m pip install -e .
24
+ .\.venv\Scripts\python.exe -m pip install pytest pytest-cov hypothesis syrupy jsonschema ruff import-linter nox textual-dev pytest-textual-snapshot==1.1.0
25
+ ```
26
+
27
+ Use the equivalent activation and executable paths on macOS or Linux.
28
+
29
+ Run `nox -s tests lint e2e-fast` for the normal source checkout. Before release, run
30
+ `nox -s dev-package` to build and verify the tracked source as a clean wheel and source distribution;
31
+ use `nox -s dev-package -- --open` to open the installed wheel's dashboard.
32
+
33
+ ### Developing the Observatory TUI
34
+
35
+ `pebra tui` is a Textual surface. To iterate with the Textual devtools, run the console in one terminal
36
+ and the app in another:
37
+
38
+ ```powershell
39
+ .\.venv\Scripts\textual.exe console
40
+ .\.venv\Scripts\textual.exe run --dev -c "pebra tui --read-only --db path\to\pebra.db --repo-id <id>"
41
+ ```
42
+
43
+ The `--dev` run hot-reloads `pebra/tui/theme.tcss`, and `self.log(...)` output routes to the console
44
+ instead of corrupting the TUI. TUI diagnostics log identifiers, counts, timing, and error categories
45
+ only — never source, tokens, candidate payloads, or sanction data (the TUI never handles those). After a
46
+ deliberate visual change, regenerate the SVG baselines with
47
+ `.\.venv\Scripts\python.exe -m pytest tests\snapshots --snapshot-update` and review them before
48
+ committing.
49
+
50
+ ## Engineering Rules
51
+
52
+ - Keep `pebra.core` deterministic and standard-library-only.
53
+ - Respect the established core, application, port, adapter, composition, CLI, dashboard, and E2E
54
+ boundaries. Import contracts enforce these relationships.
55
+ - Exercise production behavior through real public surfaces where an end-to-end test is intended.
56
+ - Do not weaken fail-closed behavior, candidate hash binding, approval binding, or audit-chain
57
+ integrity to make a test pass.
58
+ - Keep changes focused. Avoid unrelated refactors and generated metadata churn.
59
+ - Add a regression test for every bug fix and focused coverage for new behavior.
60
+
61
+ ## Validation
62
+
63
+ Run the smallest relevant tests while developing, then the repository checks before requesting
64
+ review:
65
+
66
+ ```powershell
67
+ .\.venv\Scripts\python.exe -m pytest -q
68
+ .\.venv\Scripts\ruff.exe check .
69
+ .\.venv\Scripts\lint-imports.exe
70
+ .\.venv\Scripts\python.exe -m pytest e2e\test_boundary_discipline.py -q
71
+ ```
72
+
73
+ Some external-engine, browser, and paid-model lanes are gated. State clearly which gated checks were
74
+ not run and why; never report them as passing without evidence.
75
+
76
+ ## Pull Requests
77
+
78
+ - Explain the user-visible or architectural problem and why the change is scoped correctly.
79
+ - Include verification commands and results.
80
+ - Call out behavior changes, trust-boundary changes, migration needs, and deferred work.
81
+ - Keep commits reviewable and do not include local databases, credentials, paid-run artifacts, or
82
+ unrelated experiment output.
83
+ - Address review findings with tests when the finding describes a reproducible failure mode.
84
+
85
+ ## Security Reports
86
+
87
+ Follow [SECURITY.md](SECURITY.md) for suspected vulnerabilities. **Do not open a public issue** for an
88
+ undisclosed security problem.
pebra-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,10 @@
1
+ include LICENSE
2
+ include SECURITY.md
3
+ include CONTRIBUTING.md
4
+ include RELEASING.md
5
+ include requirements-release.in
6
+ include requirements-release.txt
7
+ include README.md
8
+ recursive-include pebra/dashboard/templates *.html
9
+ recursive-include pebra/dashboard/static *.js *.css *.txt
10
+ recursive-include pebra/tui *.tcss
pebra-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,242 @@
1
+ Metadata-Version: 2.4
2
+ Name: pebra
3
+ Version: 0.1.0
4
+ Summary: Pre-Edit Benefit-Risk Assessment for coding agents — a deterministic, hexagonal decision controller.
5
+ Author: PEBRA contributors
6
+ License-Expression: Apache-2.0 AND MIT
7
+ Project-URL: Homepage, https://github.com/Rajioba1/pebra
8
+ Project-URL: Repository, https://github.com/Rajioba1/pebra
9
+ Project-URL: Issues, https://github.com/Rajioba1/pebra/issues
10
+ Project-URL: Releases, https://github.com/Rajioba1/pebra/releases
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ License-File: pebra/dashboard/static/vendor/uplot.LICENSE.txt
24
+ Requires-Dist: numpy
25
+ Requires-Dist: scikit-learn>=1.2
26
+ Requires-Dist: cryptography
27
+ Requires-Dist: mapie
28
+ Requires-Dist: bandit
29
+ Requires-Dist: pyyaml
30
+ Requires-Dist: fastapi
31
+ Requires-Dist: starlette
32
+ Requires-Dist: uvicorn
33
+ Requires-Dist: jinja2
34
+ Requires-Dist: mcp<2,>=1.0
35
+ Requires-Dist: textual<9,>=8.2
36
+ Provides-Extra: bench
37
+ Requires-Dist: pandas; extra == "bench"
38
+ Requires-Dist: scipy; extra == "bench"
39
+ Requires-Dist: matplotlib; extra == "bench"
40
+ Requires-Dist: seaborn; extra == "bench"
41
+ Provides-Extra: bench-szz
42
+ Requires-Dist: pydriller; extra == "bench-szz"
43
+ Provides-Extra: bench-agent
44
+ Requires-Dist: swebench; extra == "bench-agent"
45
+ Provides-Extra: bench-external
46
+ Requires-Dist: datasets; extra == "bench-external"
47
+ Provides-Extra: ui-e2e
48
+ Requires-Dist: playwright; extra == "ui-e2e"
49
+ Requires-Dist: pytest-playwright; extra == "ui-e2e"
50
+ Provides-Extra: agent-ab
51
+ Requires-Dist: anthropic>=0.30; extra == "agent-ab"
52
+ Dynamic: license-file
53
+
54
+ # PEBRA
55
+
56
+ PEBRA is a **Pre-Edit Benefit-Risk Assessment** controller for coding agents.
57
+
58
+ It evaluates a proposed code edit before the agent applies it, returns a deterministic decision and
59
+ math packet, verifies the actual post-edit diff against the approved envelope, records outcomes, and
60
+ uses measured calibration data to promote learned facts for future assessments.
61
+
62
+ ## Current Capabilities
63
+
64
+ - Pre-edit `assess` with expected loss, expected utility, RAU, edit confidence, and ordered gates.
65
+ - Post-edit `verify` against the approved safe scope and required checks.
66
+ - Candidate-bound pre-edit enforcement: an impactful host edit must produce the same normalized file
67
+ contents as the patch that was assessed; same repository/HEAD/path alone is not sufficient.
68
+ - Outcome recording, shadow learning, promotion, scorecards, and learned-fact reapplication.
69
+ - Read-only local Risk Observatory dashboard for assessment, calibration, learning, and graph state.
70
+ - Explicit graph-engine setup and diagnostics through `pebra setup-graph` and `pebra doctor`.
71
+ - CodeGraph-backed evidence:
72
+ - per-symbol fan-in;
73
+ - DELETE file fan-in roll-up;
74
+ - MODIFY graph-wide blast over callers/references/implementers/subclasses;
75
+ - contract-surface metadata for interface/base-class edits;
76
+ - containing class/namespace/module hierarchy roll-up;
77
+ - file metadata / parse-error confidence penalties;
78
+ - bounded revised-candidate refinement: cheap deterministic ranking first, then one materialized
79
+ before/after graph by default. Structural continuity adjusts only the exact owner-scoped risk
80
+ event; RAU remains authoritative. Set `PEBRA_GRAPH_REFINEMENT=0` to disable this path.
81
+ - Benchmark harnesses for math-oracle validation and deterministic learning-loop wiring proof.
82
+ - True CLI-boundary e2e lanes, including a gated external C# repo lane.
83
+
84
+ ## Install For Development
85
+
86
+ ```powershell
87
+ python -m venv .venv
88
+ .\.venv\Scripts\python.exe -m pip install --upgrade pip
89
+ .\.venv\Scripts\python.exe -m pip install -e .
90
+ ```
91
+
92
+ The graph engine is explicit, not a pip dependency:
93
+
94
+ ```powershell
95
+ pebra setup-graph --fix
96
+ pebra doctor
97
+ ```
98
+
99
+ `assess` never silently installs external binaries.
100
+
101
+ The **benefit signal** (multi-language complexity + maintainability index) is likewise an explicit
102
+ external binary — [`rust-code-analysis`](https://github.com/mozilla/rust-code-analysis) (MPL-2.0),
103
+ invoked as a subprocess. Build it from git (crates.io's release does not compile against current
104
+ tree-sitter):
105
+
106
+ ```powershell
107
+ cargo install --git https://github.com/mozilla/rust-code-analysis `
108
+ --rev 37e5d83c056c8cbf827223d5814a93c5218df1a9 rust-code-analysis-cli
109
+ ```
110
+
111
+ Point PEBRA at it via `PEBRA_RCA_BIN` or ensure it is on `PATH`. PEBRA accepts runtime version
112
+ `0.0.25` when Cargo install metadata identifies the pinned source revision. For a copied or packaged
113
+ binary without Cargo metadata, set `PEBRA_RCA_SHA256` to its expected lowercase SHA-256. Live experiment
114
+ metadata records the executable SHA-256 and refuses to resume a run with a different fingerprint.
115
+ Cargo metadata is install provenance, not tamper-proof byte attestation. For copied binaries, shared
116
+ machines, or any environment where local binary replacement is in scope, set `PEBRA_RCA_SHA256`; an
117
+ explicit hash is authoritative and a mismatch disables RCA benefit evidence even when Cargo metadata
118
+ matches.
119
+ When absent or version-mismatched, benefit evidence fails
120
+ safe to *projected* (no maintainability credit) — it never blocks an assessment and never affects risk.
121
+ Supported languages: Python, JavaScript/JSX, TypeScript/TSX, Java, Rust, C/C++.
122
+
123
+ ## Basic Workflow
124
+
125
+ ```text
126
+ assess proposed edit -> agent decides -> apply edit -> verify actual diff ->
127
+ finalize trusted outcome -> future assess uses promoted learned snapshot
128
+ ```
129
+
130
+ Example command surface:
131
+
132
+ ```powershell
133
+ pebra assess request.json --json
134
+ pebra verify --assessment-id <assessment_id> --json
135
+ pebra record-outcome --assessment-id <assessment_id> --status completed --detail '{"actual_success": true}'
136
+ pebra learn --assessment-id <assessment_id>
137
+ pebra promote --repo-root <repo_root>
138
+ # Preferred host path: one idempotent record + measure + gated-promotion operation.
139
+ pebra finalize-outcome --trusted-outcome-file outcome.json --repo-root <repo_root> --json
140
+ pebra scorecard --repo-root <repo_root>
141
+ pebra dashboard --port 4500 --open
142
+ pebra capabilities --repo-root <repo_root>
143
+ ```
144
+
145
+ `outcome.json` contains `assessment_id`, terminal `status`, and an optional `detail` object. The
146
+ `finalize-outcome` command is host-only: MCP outcome reports are retained for lifecycle telemetry but
147
+ their self-reported learning labels are censored. The legacy three-command sequence remains available
148
+ for diagnosis and manual operation.
149
+
150
+ ## Agent Enforcement
151
+
152
+ Install the repository protocol for either host. Add `--with-hook` when you want pre-edit interception,
153
+ not only instructions:
154
+
155
+ ```powershell
156
+ pebra agent-init --target claude --repo-root . --with-hook
157
+ pebra agent-init --target codex --repo-root . --with-hook
158
+ pebra capabilities --repo-root .
159
+ ```
160
+
161
+ The guarantees are deliberately different:
162
+
163
+ | Host surface | Reported mode | Guarantee |
164
+ |---|---|---|
165
+ | Claude Code PreToolUse hook | `configured_enforcing` | Exact enabled hook config, matching gate capability handshake, graph, and Git HEAD were observed. Candidate-bound checks deny or ask before supported structured edits; this does not prove the host invoked every event. |
166
+ | Codex repo-local hook | `best_effort` | Candidate-bound gate logic is installed, but repo-local hook loading remains host-dependent. |
167
+ | MCP tools | `advisory_only` | Assess/verify tools are available, but MCP alone does not intercept another host's writes. |
168
+
169
+ If graph or Git HEAD evidence is unavailable, an installed gate remains fail-open by policy and
170
+ `capabilities` reports `degraded_fail_open`. The Claude hook also emits the degradation warning as a
171
+ non-blocking system message. Repository-local and user-level `disableAllHooks` settings also degrade
172
+ the reported posture. This is observable configuration, not proof that a host or managed policy invoked
173
+ every event.
174
+
175
+ `trusted_actor_required` is a protocol boundary, not OS-level identity authentication. PEBRA does
176
+ not expose risk acceptance through MCP, and interactive acceptance requires a terminal. A process
177
+ with arbitrary shell access under the same OS account can still invoke local trusted-host surfaces
178
+ or simulate a terminal. Use a separately privileged host or operator account when resistance to an
179
+ adversarial agent is required.
180
+
181
+ For a candidate that changes multiple files, enforcement requires one complete `apply_patch` event containing
182
+ the complete assessed candidate. Structured single-file edits must be assessed as separate single-file
183
+ candidates; one file cannot reuse approval for part of a multi-file candidate.
184
+
185
+ The dashboard is read-only. On a loopback bind (`localhost`, `127.0.0.1`, `::1`) the default is
186
+ token-free for local convenience; `--auth token` forces a bearer token when you want the old locked
187
+ path. Any non-loopback bind requires a token.
188
+
189
+ ```powershell
190
+ # normal local browser UX
191
+ pebra dashboard --port 4500 --open
192
+
193
+ # venv-safe form if the `pebra` console script is not on PATH yet
194
+ python -m pebra dashboard --port 4500 --open
195
+
196
+ # force bearer auth even on loopback
197
+ pebra dashboard --port 4500 --auth token
198
+
199
+ # expose beyond loopback only with a token
200
+ pebra dashboard --host 0.0.0.0 --port 4500 --auth token
201
+ ```
202
+
203
+ It exposes five browser views: overview, score history, calibration, learned facts, and CodeGraph
204
+ hotspots. Graph views are fail-soft when no trusted graph index is bound to the launched repo, and
205
+ graph routes are repo-scoped to avoid replaying one repo's graph under another repo id.
206
+
207
+ ## Validation
208
+
209
+ ```powershell
210
+ .\.venv\Scripts\nox.exe -s tests lint e2e-fast
211
+ ```
212
+
213
+ Dashboard/e2e lanes:
214
+
215
+ ```powershell
216
+ .\.venv\Scripts\python.exe -m pytest tests/integration/test_dashboard_server.py tests/integration/test_dashboard_cli.py -q
217
+ .\.venv\Scripts\python.exe -m pytest e2e/features/dashboard/test_dashboard_metrics_visual.py -q
218
+ .\.venv\Scripts\nox.exe -s e2e-learning
219
+ .\.venv\Scripts\nox.exe -s e2e-ui
220
+ ```
221
+
222
+ External real-repo graph lane:
223
+
224
+ ```powershell
225
+ $env:E2E_EXTERNAL='1'
226
+ $env:E2E_TEMPLATE_BLUEPRINT_REPO='C:\Users\RajLord_new\Desktop\avalonia_template'
227
+ .\.venv\Scripts\nox.exe -s e2e-external
228
+ ```
229
+
230
+ Benchmark lanes:
231
+
232
+ ```powershell
233
+ .\.venv\Scripts\nox.exe -s bench-math
234
+ .\.venv\Scripts\nox.exe -s bench-flow
235
+ ```
236
+
237
+ ## More Docs
238
+
239
+ - [Contributing and development setup](CONTRIBUTING.md)
240
+ - [True e2e suite](e2e/README.md)
241
+ - [Benchmarks](benchmarks/README.md)
242
+ - [Learning-loop wiring benchmark](benchmarks/flow/wiring/README.md)