reasonledger-core 0.3.0a6__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 (181) hide show
  1. reasonledger_core-0.3.0a6/.gitignore +51 -0
  2. reasonledger_core-0.3.0a6/LICENSE +201 -0
  3. reasonledger_core-0.3.0a6/NOTICE +4 -0
  4. reasonledger_core-0.3.0a6/PKG-INFO +75 -0
  5. reasonledger_core-0.3.0a6/README.md +43 -0
  6. reasonledger_core-0.3.0a6/pyproject.toml +56 -0
  7. reasonledger_core-0.3.0a6/src/reasonledger_core/__init__.py +26 -0
  8. reasonledger_core-0.3.0a6/src/reasonledger_core/consent.py +216 -0
  9. reasonledger_core-0.3.0a6/src/reasonledger_core/decisions/__init__.py +41 -0
  10. reasonledger_core-0.3.0a6/src/reasonledger_core/decisions/fingerprint.py +113 -0
  11. reasonledger_core-0.3.0a6/src/reasonledger_core/decisions/format.py +99 -0
  12. reasonledger_core-0.3.0a6/src/reasonledger_core/decisions/identity_check.py +85 -0
  13. reasonledger_core-0.3.0a6/src/reasonledger_core/decisions/ids.py +49 -0
  14. reasonledger_core-0.3.0a6/src/reasonledger_core/decisions/lifecycle.py +113 -0
  15. reasonledger_core-0.3.0a6/src/reasonledger_core/decisions/service.py +231 -0
  16. reasonledger_core-0.3.0a6/src/reasonledger_core/harvest/__init__.py +15 -0
  17. reasonledger_core-0.3.0a6/src/reasonledger_core/harvest/batch.py +77 -0
  18. reasonledger_core-0.3.0a6/src/reasonledger_core/harvest/deterministic.py +108 -0
  19. reasonledger_core-0.3.0a6/src/reasonledger_core/harvest/llm_replay.py +28 -0
  20. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/__init__.py +60 -0
  21. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/adapters.py +91 -0
  22. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/agent_route.py +207 -0
  23. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/config.py +134 -0
  24. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/endpoint.py +64 -0
  25. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/extractor.py +59 -0
  26. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/llm.py +306 -0
  27. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/outgoing.py +86 -0
  28. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/probe.py +90 -0
  29. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/prompt.py +53 -0
  30. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/propose.py +242 -0
  31. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/scan.py +206 -0
  32. reasonledger_core-0.3.0a6/src/reasonledger_core/importer/service.py +77 -0
  33. reasonledger_core-0.3.0a6/src/reasonledger_core/ingest/classify.py +75 -0
  34. reasonledger_core-0.3.0a6/src/reasonledger_core/ingest/contributors.py +14 -0
  35. reasonledger_core-0.3.0a6/src/reasonledger_core/ingest/github_types.py +54 -0
  36. reasonledger_core-0.3.0a6/src/reasonledger_core/ingest/normalize.py +69 -0
  37. reasonledger_core-0.3.0a6/src/reasonledger_core/metrics.py +172 -0
  38. reasonledger_core-0.3.0a6/src/reasonledger_core/models/decision.py +261 -0
  39. reasonledger_core-0.3.0a6/src/reasonledger_core/models/oversight.py +29 -0
  40. reasonledger_core-0.3.0a6/src/reasonledger_core/models/policy.py +82 -0
  41. reasonledger_core-0.3.0a6/src/reasonledger_core/models/provenance.py +51 -0
  42. reasonledger_core-0.3.0a6/src/reasonledger_core/models/reasoning.py +143 -0
  43. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/__init__.py +35 -0
  44. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/agent_route.py +155 -0
  45. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/buckets.py +61 -0
  46. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/config.py +374 -0
  47. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/decision_suggest.py +108 -0
  48. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/digest.py +136 -0
  49. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/drift.py +143 -0
  50. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/editing.py +189 -0
  51. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/files.py +84 -0
  52. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/fold.py +133 -0
  53. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/globs.py +127 -0
  54. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/hand_placement.py +102 -0
  55. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/labels.py +55 -0
  56. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/llm_mapper.py +239 -0
  57. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/manifest.py +156 -0
  58. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/mapper_check.py +128 -0
  59. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/mapping.py +260 -0
  60. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/models.py +156 -0
  61. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/organize.py +267 -0
  62. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/placement.py +87 -0
  63. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/quick_map.py +47 -0
  64. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/resolve.py +274 -0
  65. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/review.py +23 -0
  66. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/scan.py +126 -0
  67. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/signals/__init__.py +1 -0
  68. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/signals/cochange.py +112 -0
  69. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/signals/codeowners.py +76 -0
  70. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/signals/convention.py +96 -0
  71. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/signals/layout.py +130 -0
  72. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/signals/specs.py +96 -0
  73. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/signals/tooling.py +25 -0
  74. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/signals/workspace.py +126 -0
  75. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/suggest.py +240 -0
  76. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/tier_split.py +135 -0
  77. reasonledger_core-0.3.0a6/src/reasonledger_core/modules/tiers.py +53 -0
  78. reasonledger_core-0.3.0a6/src/reasonledger_core/oversight/classify.py +29 -0
  79. reasonledger_core-0.3.0a6/src/reasonledger_core/paths/critical.py +13 -0
  80. reasonledger_core-0.3.0a6/src/reasonledger_core/policy/__init__.py +19 -0
  81. reasonledger_core-0.3.0a6/src/reasonledger_core/policy/evaluate.py +118 -0
  82. reasonledger_core-0.3.0a6/src/reasonledger_core/policy/parse.py +75 -0
  83. reasonledger_core-0.3.0a6/src/reasonledger_core/privacy/data_minimization.py +22 -0
  84. reasonledger_core-0.3.0a6/src/reasonledger_core/privacy/pii_linter.py +134 -0
  85. reasonledger_core-0.3.0a6/src/reasonledger_core/provenance/classify.py +41 -0
  86. reasonledger_core-0.3.0a6/src/reasonledger_core/provenance/detectors.py +197 -0
  87. reasonledger_core-0.3.0a6/src/reasonledger_core/py.typed +0 -0
  88. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/__init__.py +148 -0
  89. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/agent_judge.py +164 -0
  90. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/anchors.py +74 -0
  91. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/cache.py +75 -0
  92. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/config.py +82 -0
  93. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/conflict_config.py +172 -0
  94. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/conflicts.py +197 -0
  95. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/conflicts_replay.py +56 -0
  96. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/dismissals.py +218 -0
  97. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/embeddings.py +142 -0
  98. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/judge.py +292 -0
  99. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/pr_opener.py +33 -0
  100. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/related.py +201 -0
  101. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/retrieval.py +87 -0
  102. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/symbols.py +116 -0
  103. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/ts_symbols.py +323 -0
  104. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/verdicts.py +162 -0
  105. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/watchers.py +120 -0
  106. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/why.py +230 -0
  107. reasonledger_core-0.3.0a6/src/reasonledger_core/reasoning/why_nearby.py +139 -0
  108. reasonledger_core-0.3.0a6/src/reasonledger_core/repo_files.py +42 -0
  109. reasonledger_core-0.3.0a6/src/reasonledger_core/settings.py +21 -0
  110. reasonledger_core-0.3.0a6/src/reasonledger_core/sync/__init__.py +39 -0
  111. reasonledger_core-0.3.0a6/src/reasonledger_core/sync/repo.py +305 -0
  112. reasonledger_core-0.3.0a6/src/reasonledger_core/sync/state.py +62 -0
  113. reasonledger_core-0.3.0a6/src/reasonledger_core/views/__init__.py +33 -0
  114. reasonledger_core-0.3.0a6/src/reasonledger_core/views/cache.py +84 -0
  115. reasonledger_core-0.3.0a6/src/reasonledger_core/views/homeless.py +99 -0
  116. reasonledger_core-0.3.0a6/src/reasonledger_core/views/inbox.py +208 -0
  117. reasonledger_core-0.3.0a6/src/reasonledger_core/views/ledger.py +383 -0
  118. reasonledger_core-0.3.0a6/src/reasonledger_core/views/map_models.py +90 -0
  119. reasonledger_core-0.3.0a6/src/reasonledger_core/views/map_view.py +265 -0
  120. reasonledger_core-0.3.0a6/src/reasonledger_core/views/organize_files.py +113 -0
  121. reasonledger_core-0.3.0a6/src/reasonledger_core/views/related_view.py +121 -0
  122. reasonledger_core-0.3.0a6/src/reasonledger_core/views/stats.py +80 -0
  123. reasonledger_core-0.3.0a6/tests/modules_helpers.py +50 -0
  124. reasonledger_core-0.3.0a6/tests/test_agent_judge.py +204 -0
  125. reasonledger_core-0.3.0a6/tests/test_anchor_drift.py +189 -0
  126. reasonledger_core-0.3.0a6/tests/test_conflict_config.py +206 -0
  127. reasonledger_core-0.3.0a6/tests/test_consent.py +111 -0
  128. reasonledger_core-0.3.0a6/tests/test_data_minimization.py +21 -0
  129. reasonledger_core-0.3.0a6/tests/test_decision_format.py +116 -0
  130. reasonledger_core-0.3.0a6/tests/test_decision_import_schema.py +82 -0
  131. reasonledger_core-0.3.0a6/tests/test_decision_lifecycle.py +188 -0
  132. reasonledger_core-0.3.0a6/tests/test_decision_suggest.py +83 -0
  133. reasonledger_core-0.3.0a6/tests/test_docs_policy_examples.py +33 -0
  134. reasonledger_core-0.3.0a6/tests/test_find_nearby.py +128 -0
  135. reasonledger_core-0.3.0a6/tests/test_fold.py +151 -0
  136. reasonledger_core-0.3.0a6/tests/test_hand_placement.py +182 -0
  137. reasonledger_core-0.3.0a6/tests/test_harvest.py +191 -0
  138. reasonledger_core-0.3.0a6/tests/test_import_adapters.py +252 -0
  139. reasonledger_core-0.3.0a6/tests/test_import_agent_route.py +135 -0
  140. reasonledger_core-0.3.0a6/tests/test_import_config.py +89 -0
  141. reasonledger_core-0.3.0a6/tests/test_import_endpoint.py +162 -0
  142. reasonledger_core-0.3.0a6/tests/test_import_extractor.py +29 -0
  143. reasonledger_core-0.3.0a6/tests/test_import_ids.py +35 -0
  144. reasonledger_core-0.3.0a6/tests/test_import_outgoing.py +127 -0
  145. reasonledger_core-0.3.0a6/tests/test_import_probe.py +86 -0
  146. reasonledger_core-0.3.0a6/tests/test_import_propose.py +289 -0
  147. reasonledger_core-0.3.0a6/tests/test_import_scan.py +117 -0
  148. reasonledger_core-0.3.0a6/tests/test_import_service.py +65 -0
  149. reasonledger_core-0.3.0a6/tests/test_inbox.py +380 -0
  150. reasonledger_core-0.3.0a6/tests/test_ingest_classify.py +44 -0
  151. reasonledger_core-0.3.0a6/tests/test_judge.py +249 -0
  152. reasonledger_core-0.3.0a6/tests/test_judge_quality.py +75 -0
  153. reasonledger_core-0.3.0a6/tests/test_ledger_stats.py +129 -0
  154. reasonledger_core-0.3.0a6/tests/test_ledger_view.py +632 -0
  155. reasonledger_core-0.3.0a6/tests/test_ledger_view_reasoning.py +59 -0
  156. reasonledger_core-0.3.0a6/tests/test_map_view.py +253 -0
  157. reasonledger_core-0.3.0a6/tests/test_mapper_buckets.py +378 -0
  158. reasonledger_core-0.3.0a6/tests/test_mapper_core.py +267 -0
  159. reasonledger_core-0.3.0a6/tests/test_mapper_flow.py +239 -0
  160. reasonledger_core-0.3.0a6/tests/test_metrics.py +320 -0
  161. reasonledger_core-0.3.0a6/tests/test_module_editing.py +208 -0
  162. reasonledger_core-0.3.0a6/tests/test_modules_scan.py +344 -0
  163. reasonledger_core-0.3.0a6/tests/test_modules_signals.py +319 -0
  164. reasonledger_core-0.3.0a6/tests/test_organize.py +201 -0
  165. reasonledger_core-0.3.0a6/tests/test_oversight_classify.py +25 -0
  166. reasonledger_core-0.3.0a6/tests/test_pii_linter.py +104 -0
  167. reasonledger_core-0.3.0a6/tests/test_policy_evaluate.py +147 -0
  168. reasonledger_core-0.3.0a6/tests/test_policy_strict.py +41 -0
  169. reasonledger_core-0.3.0a6/tests/test_provenance_detectors.py +55 -0
  170. reasonledger_core-0.3.0a6/tests/test_quick_map.py +66 -0
  171. reasonledger_core-0.3.0a6/tests/test_reasoning_cache.py +104 -0
  172. reasonledger_core-0.3.0a6/tests/test_reasoning_conflicts.py +221 -0
  173. reasonledger_core-0.3.0a6/tests/test_reasoning_dismissals.py +222 -0
  174. reasonledger_core-0.3.0a6/tests/test_reasoning_embeddings.py +157 -0
  175. reasonledger_core-0.3.0a6/tests/test_reasoning_retrieval.py +85 -0
  176. reasonledger_core-0.3.0a6/tests/test_reasoning_watchers.py +88 -0
  177. reasonledger_core-0.3.0a6/tests/test_reasoning_why.py +237 -0
  178. reasonledger_core-0.3.0a6/tests/test_related_and_verdicts.py +180 -0
  179. reasonledger_core-0.3.0a6/tests/test_repo_boundary.py +116 -0
  180. reasonledger_core-0.3.0a6/tests/test_sync_state.py +137 -0
  181. reasonledger_core-0.3.0a6/tests/test_tier_split.py +154 -0
@@ -0,0 +1,51 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ .venv/
5
+ venv/
6
+ .env
7
+ .env.*
8
+ !.env.example
9
+ *.egg-info/
10
+ .pytest_cache/
11
+ .ruff_cache/
12
+ .mypy_cache/
13
+ .hypothesis/
14
+ .coverage
15
+ coverage.xml
16
+ htmlcov/
17
+
18
+ # Build output
19
+ dist/
20
+
21
+ # Local / editor
22
+ .DS_Store
23
+ *.local
24
+ .idea/
25
+ .vscode/
26
+
27
+ # Claude Code local settings and worktrees
28
+ .claude/
29
+
30
+ # Local ledger caches (embeddings / view)
31
+ .reasonledger/cache/
32
+
33
+ # Per-checkout watermark of the files `import` has already read
34
+ .reasonledger/import-seen.yml
35
+
36
+ # Opt-in pilot metrics. Local-only by design — committing it would publish a
37
+ # per-developer usage record to everyone with a clone.
38
+ .reasonledger/metrics.jsonl
39
+
40
+ # Machine-specific editor MCP configs (absolute paths) - `reasonledger init` generates them
41
+ .mcp.json
42
+ .cursor/mcp.json
43
+
44
+ # Personal scratch sheets
45
+ *.numbers
46
+
47
+ # A cloned project used to try ReasonLedger on a real codebase
48
+ .test-ts-project/
49
+
50
+ # Local-only material that must never reach a commit or the public repository.
51
+ private/
@@ -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 2026 SphotaLabs Inc.
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,4 @@
1
+ ReasonLedger
2
+ Copyright 2026 SphotaLabs Inc.
3
+
4
+ This product includes software developed at SphotaLabs Inc.
@@ -0,0 +1,75 @@
1
+ Metadata-Version: 2.5
2
+ Name: reasonledger-core
3
+ Version: 0.3.0a6
4
+ Summary: Framework-free domain logic for ReasonLedger
5
+ Project-URL: Homepage, https://github.com/Sphotalabs-Inc/ReasonLedger
6
+ Project-URL: Repository, https://github.com/Sphotalabs-Inc/ReasonLedger
7
+ Project-URL: Issues, https://github.com/Sphotalabs-Inc/ReasonLedger/issues
8
+ Author: SphotaLabs Inc.
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: numpy<3,>=2.0
22
+ Requires-Dist: pydantic-settings>=2.7
23
+ Requires-Dist: pydantic>=2.10
24
+ Requires-Dist: pyyaml>=6.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: hypothesis>=6.120; extra == 'dev'
27
+ Requires-Dist: pytest-cov>=6.0; extra == 'dev'
28
+ Requires-Dist: pytest>=8.3; extra == 'dev'
29
+ Provides-Extra: embeddings
30
+ Requires-Dist: fastembed>=0.5; extra == 'embeddings'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # reasonledger-core
34
+
35
+ Framework-free domain logic for [ReasonLedger](https://github.com/Sphotalabs-Inc/ReasonLedger) —
36
+ the audit-critical heart shared by the CLI and the MCP server.
37
+
38
+ This is a library. Most people want [`reasonledger`](https://pypi.org/project/reasonledger/)
39
+ (the CLI) instead; install this directly only if you are building your own surface on top
40
+ of the same domain model.
41
+
42
+ ## What's in it
43
+
44
+ | Area | What it does |
45
+ |---|---|
46
+ | `decisions` | The Decision record format — frontmatter parse/write, round-trip, on-disk layout |
47
+ | `importer` | Bring-your-own-model extraction, propose-and-confirm staging, connection probe |
48
+ | `reasoning` | `why` resolution, conflict detection, staleness watchers, pluggable embeddings |
49
+ | `views` | `build_ledger_view` — a read-only projection of a repo's `.reasonledger/` state |
50
+ | `policy` | Policy evaluation for CI gates |
51
+ | `privacy` | The PII linter |
52
+ | `provenance` | AI-authorship signals read from commit metadata |
53
+
54
+ No web framework, no ORM session, and no I/O beyond the files it is pointed at — so the
55
+ same implementation backs every surface rather than being reimplemented per app.
56
+
57
+ ## Design properties worth knowing
58
+
59
+ - **Secrets are structurally excluded.** `ExtractorConfig` has no field capable of holding
60
+ a raw API key — only the *name* of the environment variable that supplies one.
61
+ - **Views never write.** `build_ledger_view` re-evaluates watcher conditions on read; it
62
+ cannot modify a decision file.
63
+ - **Deterministic by default.** Embeddings resolve to a deterministic stub unless the
64
+ local model is enabled, so tests and CI need no network and no model. Embeddings never use the
65
+ network.
66
+
67
+ ## Requirements
68
+
69
+ Python 3.12+.
70
+
71
+ ```bash
72
+ # --pre: every release is a pre-release for now, and pip skips those unless told otherwise
73
+ pip install --pre reasonledger-core
74
+ pip install --pre "reasonledger-core[embeddings]" # real embeddings via fastembed
75
+ ```
@@ -0,0 +1,43 @@
1
+ # reasonledger-core
2
+
3
+ Framework-free domain logic for [ReasonLedger](https://github.com/Sphotalabs-Inc/ReasonLedger) —
4
+ the audit-critical heart shared by the CLI and the MCP server.
5
+
6
+ This is a library. Most people want [`reasonledger`](https://pypi.org/project/reasonledger/)
7
+ (the CLI) instead; install this directly only if you are building your own surface on top
8
+ of the same domain model.
9
+
10
+ ## What's in it
11
+
12
+ | Area | What it does |
13
+ |---|---|
14
+ | `decisions` | The Decision record format — frontmatter parse/write, round-trip, on-disk layout |
15
+ | `importer` | Bring-your-own-model extraction, propose-and-confirm staging, connection probe |
16
+ | `reasoning` | `why` resolution, conflict detection, staleness watchers, pluggable embeddings |
17
+ | `views` | `build_ledger_view` — a read-only projection of a repo's `.reasonledger/` state |
18
+ | `policy` | Policy evaluation for CI gates |
19
+ | `privacy` | The PII linter |
20
+ | `provenance` | AI-authorship signals read from commit metadata |
21
+
22
+ No web framework, no ORM session, and no I/O beyond the files it is pointed at — so the
23
+ same implementation backs every surface rather than being reimplemented per app.
24
+
25
+ ## Design properties worth knowing
26
+
27
+ - **Secrets are structurally excluded.** `ExtractorConfig` has no field capable of holding
28
+ a raw API key — only the *name* of the environment variable that supplies one.
29
+ - **Views never write.** `build_ledger_view` re-evaluates watcher conditions on read; it
30
+ cannot modify a decision file.
31
+ - **Deterministic by default.** Embeddings resolve to a deterministic stub unless the
32
+ local model is enabled, so tests and CI need no network and no model. Embeddings never use the
33
+ network.
34
+
35
+ ## Requirements
36
+
37
+ Python 3.12+.
38
+
39
+ ```bash
40
+ # --pre: every release is a pre-release for now, and pip skips those unless told otherwise
41
+ pip install --pre reasonledger-core
42
+ pip install --pre "reasonledger-core[embeddings]" # real embeddings via fastembed
43
+ ```
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27,<2"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "reasonledger-core"
7
+ version = "0.3.0a6"
8
+ description = "Framework-free domain logic for ReasonLedger"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE", "NOTICE"]
13
+ authors = [{ name = "SphotaLabs Inc." }]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Topic :: Software Development :: Libraries",
21
+ "Topic :: Software Development :: Quality Assurance",
22
+ "Typing :: Typed",
23
+ ]
24
+ dependencies = [
25
+ "numpy>=2.0,<3",
26
+ "pydantic>=2.10",
27
+ "pydantic-settings>=2.7",
28
+ "pyyaml>=6.0",
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ embeddings = [
33
+ "fastembed>=0.5",
34
+ ]
35
+ dev = [
36
+ "pytest>=8.3",
37
+ "pytest-cov>=6.0",
38
+ "hypothesis>=6.120",
39
+ ]
40
+
41
+ [project.urls]
42
+ Homepage = "https://github.com/Sphotalabs-Inc/ReasonLedger"
43
+ Repository = "https://github.com/Sphotalabs-Inc/ReasonLedger"
44
+ Issues = "https://github.com/Sphotalabs-Inc/ReasonLedger/issues"
45
+
46
+ [tool.hatch.build.targets.wheel]
47
+ packages = ["src/reasonledger_core"]
48
+
49
+ [tool.pytest.ini_options]
50
+ testpaths = ["tests"]
51
+ pythonpath = ["src"]
52
+ addopts = "-q --strict-markers"
53
+
54
+ [tool.coverage.run]
55
+ source = ["reasonledger_core"]
56
+ branch = true
@@ -0,0 +1,26 @@
1
+ """Framework-free domain logic for ReasonLedger."""
2
+
3
+ from reasonledger_core.models.oversight import OversightClassification
4
+ from reasonledger_core.models.policy import CheckOutcome, PolicyEvaluationResult
5
+ from reasonledger_core.models.provenance import (
6
+ ProvenanceFinding,
7
+ ProvenanceStatus,
8
+ SignalConfidence,
9
+ )
10
+ from reasonledger_core.oversight.classify import classify_oversight
11
+ from reasonledger_core.policy import evaluate_policy
12
+ from reasonledger_core.provenance.classify import classify_provenance
13
+ from reasonledger_core.provenance.detectors import detect_provenance_signals
14
+
15
+ __all__ = [
16
+ "CheckOutcome",
17
+ "OversightClassification",
18
+ "PolicyEvaluationResult",
19
+ "ProvenanceFinding",
20
+ "ProvenanceStatus",
21
+ "SignalConfidence",
22
+ "classify_oversight",
23
+ "classify_provenance",
24
+ "detect_provenance_signals",
25
+ "evaluate_policy",
26
+ ]
@@ -0,0 +1,216 @@
1
+ """Consent to send repo data to a model that is not on this machine.
2
+
3
+ Nothing leaves the machine until a person says so, per repo, per kind of data, and for the
4
+ destination they saw. A model on this machine (a loopback address) needs no consent. The
5
+ record lives in the user's own config directory, never in the repo and never committed, so a
6
+ clone or a CI run starts with nothing granted and fails closed.
7
+
8
+ Three kinds of data can be sent, and each is its own grant:
9
+
10
+ * ``decision_text``: each decision's context and choice (``judge``).
11
+ * ``paths``: file paths and route paths, never file contents (``map``).
12
+ * ``repo_text``: text of your docs and your commit messages, subject and body (``import``,
13
+ ``catchup``). Before it is sent, a doc or commit that matches the PII/secret patterns is held
14
+ back whole and reported (``importer.outgoing``).
15
+
16
+ A grant is bound to the destination origin (scheme, host and port) it was given for. Point the
17
+ repo at a different provider, or the same host over another scheme or port, and it asks again;
18
+ so does a new kind of data. Grants recorded before origins were used named a bare host, match
19
+ no origin, and so are asked for again.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import contextlib
25
+ import os
26
+ import subprocess
27
+ import sys
28
+ from datetime import UTC, datetime
29
+ from enum import StrEnum
30
+ from pathlib import Path
31
+ from typing import Any
32
+
33
+ import yaml
34
+
35
+ from reasonledger_core.importer.config import ExtractorConfig, ExtractorProvider
36
+ from reasonledger_core.importer.endpoint import is_loopback, origin
37
+ from reasonledger_core.importer.llm import ANTHROPIC_DEFAULT_BASE_URL
38
+
39
+ CONSENT_DIR_ENV = "RL_CONSENT_DIR"
40
+ CONSENT_FILE = "consent.yml"
41
+ CONSENT_VERSION = "1"
42
+
43
+
44
+ class DataClass(StrEnum):
45
+ DECISION_TEXT = "decision_text"
46
+ PATHS = "paths"
47
+ REPO_TEXT = "repo_text"
48
+
49
+
50
+ LABELS: dict[DataClass, str] = {
51
+ DataClass.DECISION_TEXT: "Decision text",
52
+ DataClass.PATHS: "File and route paths",
53
+ DataClass.REPO_TEXT: "Docs and commit messages",
54
+ }
55
+
56
+ DESCRIPTIONS: dict[DataClass, str] = {
57
+ DataClass.DECISION_TEXT: (
58
+ "the context and choice of your recorded decisions, to judge which related ones conflict"
59
+ ),
60
+ DataClass.PATHS: (
61
+ "file paths and HTTP route paths, to propose your module map; never file contents"
62
+ ),
63
+ DataClass.REPO_TEXT: (
64
+ "the text of your docs and of your commit messages (subject and body), to extract "
65
+ "decisions from them; a doc or commit matching the PII/secret check is held back; "
66
+ "never diffs or author names"
67
+ ),
68
+ }
69
+
70
+
71
+ class ConsentError(ValueError):
72
+ """Raised for a request that cannot be a grant (an unknown class, a local model)."""
73
+
74
+
75
+ def parse_classes(names: list[str]) -> list[DataClass]:
76
+ """Class names as typed on the command line or sent by the UI."""
77
+ parsed: list[DataClass] = []
78
+ for name in names:
79
+ try:
80
+ parsed.append(DataClass(name))
81
+ except ValueError as exc:
82
+ valid = ", ".join(item.value for item in DataClass)
83
+ raise ConsentError(f"unknown data class {name!r} (choose from {valid})") from exc
84
+ return parsed
85
+
86
+
87
+ def destination(config: ExtractorConfig) -> str | None:
88
+ """The origin a prompt goes to, or ``None`` when it never leaves this machine.
89
+
90
+ A disabled provider sends nothing. Anthropic is always off the machine; any other
91
+ provider is local only when its base URL is a loopback address.
92
+ """
93
+ if config.provider is ExtractorProvider.DISABLED:
94
+ return None
95
+ if config.provider is ExtractorProvider.ANTHROPIC:
96
+ return origin(config.base_url or ANTHROPIC_DEFAULT_BASE_URL)
97
+ if is_loopback(config.base_url):
98
+ return None
99
+ return origin(config.base_url) if config.base_url else "(no base_url set)"
100
+
101
+
102
+ def consent_dir() -> Path:
103
+ """User-scope config directory: outside every repo, so it can never be committed."""
104
+ override = os.environ.get(CONSENT_DIR_ENV)
105
+ if override:
106
+ return Path(override)
107
+ if sys.platform == "win32":
108
+ base = os.environ.get("APPDATA") or str(Path.home() / "AppData" / "Roaming")
109
+ return Path(base) / "reasonledger"
110
+ base = os.environ.get("XDG_CONFIG_HOME") or str(Path.home() / ".config")
111
+ return Path(base) / "reasonledger"
112
+
113
+
114
+ def repo_key(root: Path) -> str:
115
+ """The repo's first commit hash (stable across clones), else its resolved path."""
116
+ resolved = root.resolve()
117
+ try:
118
+ out = subprocess.run( # noqa: S603
119
+ ["git", "-C", str(resolved), "rev-list", "--max-parents=0", "HEAD"], # noqa: S607
120
+ capture_output=True,
121
+ text=True,
122
+ timeout=10,
123
+ check=False,
124
+ )
125
+ except (OSError, subprocess.SubprocessError):
126
+ return str(resolved)
127
+ first = out.stdout.split()
128
+ return first[0] if out.returncode == 0 and first else str(resolved)
129
+
130
+
131
+ def _load() -> dict[str, Any]:
132
+ path = consent_dir() / CONSENT_FILE
133
+ try:
134
+ raw = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
135
+ except (OSError, yaml.YAMLError):
136
+ return {} # unreadable means nothing is granted: fail closed
137
+ repos = raw.get("repos") if isinstance(raw, dict) else None
138
+ return {"repos": repos} if isinstance(repos, dict) else {}
139
+
140
+
141
+ def _save(repos: dict[str, Any]) -> None:
142
+ directory = consent_dir()
143
+ directory.mkdir(parents=True, exist_ok=True)
144
+ path = directory / CONSENT_FILE
145
+ payload = {"version": CONSENT_VERSION, "repos": repos}
146
+ path.write_text(yaml.safe_dump(payload, sort_keys=True), encoding="utf-8")
147
+ with contextlib.suppress(OSError): # best effort on filesystems without POSIX modes
148
+ path.chmod(0o600)
149
+
150
+
151
+ def granted_classes(root: Path, config: ExtractorConfig) -> set[DataClass]:
152
+ """Classes granted for this repo to the destination the config points at now."""
153
+ host = destination(config)
154
+ if host is None:
155
+ return set()
156
+ entry = _load().get("repos", {}).get(repo_key(root), {})
157
+ granted = entry.get("granted", {}) if isinstance(entry, dict) else {}
158
+ found: set[DataClass] = set()
159
+ for name, record in granted.items() if isinstance(granted, dict) else []:
160
+ if isinstance(record, dict) and record.get("destination") == host:
161
+ try:
162
+ found.add(DataClass(name))
163
+ except ValueError:
164
+ continue
165
+ return found
166
+
167
+
168
+ def missing_classes(
169
+ root: Path, config: ExtractorConfig, classes: list[DataClass]
170
+ ) -> list[DataClass]:
171
+ """Classes this call needs that nobody has allowed yet. Empty for a model on this machine."""
172
+ if destination(config) is None:
173
+ return []
174
+ have = granted_classes(root, config)
175
+ return [item for item in classes if item not in have]
176
+
177
+
178
+ def grant(
179
+ root: Path,
180
+ config: ExtractorConfig,
181
+ classes: list[DataClass],
182
+ *,
183
+ now: datetime | None = None,
184
+ ) -> None:
185
+ """Record that these classes may go to the configured destination for this repo."""
186
+ host = destination(config)
187
+ if host is None:
188
+ raise ConsentError("the configured model runs on this machine; nothing to allow")
189
+ repos = _load().get("repos", {})
190
+ entry = repos.setdefault(repo_key(root), {})
191
+ entry["path"] = str(root.resolve())
192
+ granted = entry.setdefault("granted", {})
193
+ stamp = (now or datetime.now(UTC)).isoformat()
194
+ for item in classes:
195
+ granted[item.value] = {"destination": host, "granted_at": stamp}
196
+ _save(repos)
197
+
198
+
199
+ def revoke(root: Path, classes: list[DataClass] | None = None) -> None:
200
+ """Withdraw consent for these classes, or for everything when none are named."""
201
+ repos = _load().get("repos", {})
202
+ key = repo_key(root)
203
+ entry = repos.get(key)
204
+ if not isinstance(entry, dict):
205
+ return
206
+ granted = entry.get("granted", {})
207
+ if classes is None:
208
+ granted = {}
209
+ else:
210
+ for item in classes:
211
+ granted.pop(item.value, None)
212
+ if granted:
213
+ entry["granted"] = granted
214
+ else:
215
+ repos.pop(key, None)
216
+ _save(repos)