alethic-kernel 0.3.0__tar.gz → 0.5.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 (78) hide show
  1. alethic_kernel-0.5.0/CHANGELOG.md +276 -0
  2. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/CONTRIBUTING.md +27 -0
  3. alethic_kernel-0.5.0/PKG-INFO +282 -0
  4. alethic_kernel-0.5.0/README.md +252 -0
  5. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/SECURITY.md +3 -4
  6. alethic_kernel-0.5.0/alethic_kernel.egg-info/PKG-INFO +282 -0
  7. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/alethic_kernel.egg-info/SOURCES.txt +18 -1
  8. alethic_kernel-0.5.0/alethic_kernel.egg-info/entry_points.txt +2 -0
  9. alethic_kernel-0.5.0/docs/api-reference.md +569 -0
  10. alethic_kernel-0.5.0/docs/architecture.md +361 -0
  11. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/pyproject.toml +4 -1
  12. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/__init__.py +20 -2
  13. alethic_kernel-0.5.0/src/cli.py +122 -0
  14. alethic_kernel-0.5.0/src/context.py +20 -0
  15. alethic_kernel-0.5.0/src/decision.py +23 -0
  16. alethic_kernel-0.5.0/src/kernel.py +666 -0
  17. alethic_kernel-0.5.0/src/policy.py +240 -0
  18. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/sqlite_store.py +39 -6
  19. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/store.py +9 -0
  20. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/store_protocol.py +13 -1
  21. alethic_kernel-0.5.0/src/testing.py +125 -0
  22. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/validators.py +51 -3
  23. alethic_kernel-0.5.0/src/wrap.py +339 -0
  24. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/conftest.py +24 -0
  25. alethic_kernel-0.5.0/tests/test_action_decision.py +316 -0
  26. alethic_kernel-0.5.0/tests/test_action_validator_chain.py +66 -0
  27. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_atomicity.py +97 -0
  28. alethic_kernel-0.5.0/tests/test_belief_validator_chain.py +371 -0
  29. alethic_kernel-0.5.0/tests/test_conformance_suite_is_importable.py +139 -0
  30. alethic_kernel-0.5.0/tests/test_context.py +20 -0
  31. alethic_kernel-0.5.0/tests/test_docs_examples.py +164 -0
  32. alethic_kernel-0.5.0/tests/test_package_api.py +35 -0
  33. alethic_kernel-0.5.0/tests/test_policy.py +117 -0
  34. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_sqlite_store.py +49 -0
  35. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_store_equivalence.py +12 -11
  36. alethic_kernel-0.5.0/tests/test_store_trace.py +32 -0
  37. alethic_kernel-0.5.0/tests/test_validator_isolation.py +242 -0
  38. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_validators.py +36 -15
  39. alethic_kernel-0.5.0/tests/test_wrap.py +254 -0
  40. alethic_kernel-0.3.0/CHANGELOG.md +0 -111
  41. alethic_kernel-0.3.0/PKG-INFO +0 -140
  42. alethic_kernel-0.3.0/README.md +0 -110
  43. alethic_kernel-0.3.0/alethic_kernel.egg-info/PKG-INFO +0 -140
  44. alethic_kernel-0.3.0/docs/api-reference.md +0 -324
  45. alethic_kernel-0.3.0/docs/architecture.md +0 -160
  46. alethic_kernel-0.3.0/src/kernel.py +0 -261
  47. alethic_kernel-0.3.0/tests/test_package_api.py +0 -21
  48. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/CODE_OF_CONDUCT.md +0 -0
  49. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/LICENSE +0 -0
  50. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/MANIFEST.in +0 -0
  51. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/alethic_kernel.egg-info/dependency_links.txt +0 -0
  52. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/alethic_kernel.egg-info/requires.txt +0 -0
  53. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/alethic_kernel.egg-info/top_level.txt +0 -0
  54. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/docs/architecture.png +0 -0
  55. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/docs/workers.md +0 -0
  56. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/setup.cfg +0 -0
  57. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/adaptive_worker.py +0 -0
  58. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/migrations.py +0 -0
  59. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/orchestrator.py +0 -0
  60. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/permissions.py +0 -0
  61. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/py.typed +0 -0
  62. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/schema.py +0 -0
  63. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/session.py +0 -0
  64. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/sim_worker.py +0 -0
  65. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/src/worker.py +0 -0
  66. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/__init__.py +0 -0
  67. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/helpers.py +0 -0
  68. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_adaptive_worker.py +0 -0
  69. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_concurrency.py +0 -0
  70. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_kernel.py +0 -0
  71. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_migrations.py +0 -0
  72. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_orchestrator.py +0 -0
  73. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_permissions.py +0 -0
  74. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_readme_assets.py +0 -0
  75. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_schema.py +0 -0
  76. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_session.py +0 -0
  77. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_sim_worker.py +0 -0
  78. {alethic_kernel-0.3.0 → alethic_kernel-0.5.0}/tests/test_store.py +0 -0
@@ -0,0 +1,276 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.5.0] - 2026-11-28
11
+
12
+ ### Added
13
+
14
+ - Added `list_trace(slot, trace_id)` to `MemoryStore` and `SqliteStore`: one
15
+ trace's records in a slot, in append order. On SQLite it is served by the
16
+ trace index. It is optional for other stores; the kernel uses it when a
17
+ store has it and persistent records were not asked for.
18
+
19
+ - Added the `alethic` command. `alethic wrap -- <server command>` runs any MCP
20
+ server with each `tools/call` decided by the kernel against a TOML policy
21
+ and recorded; refused calls are answered by the wrapper and never reach the
22
+ server, and tools no call could pass for are removed from `tools/list`.
23
+ `alethic log` shows recorded decisions and `alethic init` writes a starter
24
+ policy.
25
+ - Added `Policy`, `PolicyError` and `PolicyValidator`, exported from `alethic`:
26
+ a declarative allow/deny/review policy usable as an action validator.
27
+
28
+ ### Changed
29
+
30
+ - `commit_belief_from_proposal`, `validate_plan` and `decide_action` now read
31
+ only the slots their gates use. Each previously loaded every record in all
32
+ seven slots, so decisions on a long-lived store slowed with every record
33
+ written. With a store that has `list_trace` they load only the current
34
+ trace's records, so the cost of a decision no longer depends on the size
35
+ of the store. `current_view()` returns what it did before.
36
+
37
+ ## [0.4.0] - 2026-09-20
38
+
39
+ ### Added
40
+
41
+ - Added the typed `BeliefValidator` protocol and the ordered
42
+ `Kernel(..., belief_validators=[...])` validation chain.
43
+ - Added fail-closed `VALIDATOR_ERROR` handling for validator exceptions and
44
+ malformed return values.
45
+ - Added per-validator result codes, details, and context to successful and
46
+ rejected belief-validation evidence artifacts.
47
+ - Exported `BeliefValidator` and `ValidationResult` from the public `alethic`
48
+ namespace.
49
+ - Added `ValidationContext` (`store`, `trace_id`, `now_ms`), passed to every
50
+ belief and action validator so a rule can consult history or the clock —
51
+ the case a cooldown or a freshness check needs and could not express
52
+ before. Exported from `alethic`.
53
+ - Added the typed `ActionValidator` protocol and the ordered
54
+ `Kernel(..., action_validators=[...])` validation chain, mirroring
55
+ `belief_validators`. `SymbolicValidator` is the default first member.
56
+ Exported from `alethic`.
57
+ - Added `Kernel.decide_action()`, which runs the *whole* action-validator
58
+ chain to completion and returns an `ActionDecision` carrying every
59
+ validator's `ValidationResult`, every failing gate's reason in `reasons`,
60
+ every passing-but-`marginal` gate's detail in `concerns`, and an overall
61
+ `severity`. Exported `ActionDecision` from `alethic`.
62
+ - Added `alethic.testing.store_conformance()`, a public conformance suite for
63
+ `StoreProtocol` implementations. It asserts the subtle parts of the
64
+ contract — append-only ids, insertion-ordered `list_slot`, walking past an
65
+ expired candidate in `find_active_by_kind` rather than judging only the
66
+ oldest, and re-entrant `transaction()` — the exact place `MemoryStore` and
67
+ `SqliteStore` once silently disagreed. Ships as `alethic/testing.py`.
68
+
69
+ ### Fixed
70
+
71
+ - `SqliteStore.list_slot()` now orders by `rowid`, making the append order
72
+ `StoreProtocol` publishes a guarantee rather than a planner decision. Both
73
+ `idx_slot` and `idx_slot_kind_trace` can serve `WHERE slot=?` and the two
74
+ return rows in different orders, so which COMMIT superseded which in
75
+ `Kernel.current_view()` depended on which index SQLite happened to pick.
76
+ `list_persistent()` and `list_by_status()` are ordered the same way, for
77
+ the same reason: an append-only audit trail read back in an arbitrary order
78
+ is not an audit trail.
79
+ - An action `VALIDATOR_ERROR` evidence artifact now names the validator that
80
+ raised or returned the wrong type, as an explicit
81
+ `{"validator_id", "code": "VALIDATOR_ERROR", "ok": false, "detail"}` entry.
82
+ The crashing validator appended no result, so it was missing from the
83
+ `validators` list entirely and a person reading that list concluded it
84
+ never ran. The belief chain already recorded this entry.
85
+ - `decide_action()`'s three pre-chain refusals — `INVALID_ACTION_PROPOSAL`,
86
+ `NO_PREDICTION`, and `NEGATIVE_PREDICTION` — now populate `reasons`. Two of
87
+ them already computed the sentence and wrote it into the proposal's
88
+ invalidation reason before discarding it, so three of the six documented
89
+ refusal codes came back with nothing in the field documented as why it was
90
+ refused.
91
+ - A committed action now writes a `result: "pass"` validation evidence
92
+ artifact, and cites it in the committed record's `evidence_refs`. Only
93
+ refusals left evidence, so the decision that let an action through was the
94
+ one with no record — and a gate's `marginal` concern existed only in the
95
+ returned `ActionDecision`, never in the audit trail. The artifact carries
96
+ the ordered validator entries and the `concerns` list.
97
+ - Action validation evidence is now written under the record kind
98
+ `validation_action_{kind}` rather than `validation_{kind}`. Both chains
99
+ wrote the latter, and `current_view()` keys the evidence slot by kind, so a
100
+ belief and an action sharing a name produced two artifacts under one key
101
+ and the action's shadowed the belief's. Both always survived in
102
+ `list_slot("evidence")`; only the view was lossy. Code that reads action
103
+ validation evidence out of `current_view()` by key must use the new name.
104
+ - `alethic.testing.store_conformance()`'s append-order check now uses records
105
+ of differing `kind`. It previously appended three records sharing one kind,
106
+ the single shape where kind order and append order agree, so it asserted a
107
+ contract it could not fail a store for breaking.
108
+
109
+ ### Changed
110
+
111
+ - Validators are now handed deep copies of the payload and the percept,
112
+ belief, and constraint views, one set per validator, instead of the
113
+ kernel's live objects. A validator that mutated an argument previously
114
+ changed what was committed — the audit trail recorded the mutated payload
115
+ as if it had been proposed — and could disarm gates that run after the
116
+ chain, such as emptying `depends_on` so the percept-confidence gate had
117
+ nothing to check. It also means no gate can rewrite what a later gate in
118
+ the same chain judges. A validator returns a verdict; that is all it can
119
+ change. No migration needed unless a validator relied on mutating its
120
+ arguments, which was never supported.
121
+ - **Breaking:** `BeliefValidator.validate_belief_commit()` now takes a third
122
+ positional argument, `context: ValidationContext`. Migration: add the
123
+ parameter to every custom validator's method signature; the kernel now
124
+ always passes it.
125
+ - **Breaking:** `ActionValidator.validate_action()` (formerly documented
126
+ informally as `SymbolicValidator`'s shape) now takes a fourth positional
127
+ argument, `context: ValidationContext`. Migration: add the parameter to
128
+ every custom validator's method signature.
129
+ - `ValidationResult` gained two fields, `marginal: bool = False` and
130
+ `severity: Literal["block", "review"] = "block"`. Both are defaulted, so
131
+ existing `ValidationResult(...)` construction is unaffected. `severity` is
132
+ only meaningful when `ok=False`; `"review"` means the gate refuses but
133
+ wants a person to decide rather than a hard stop. The two chains treat
134
+ them differently: `decide_action()` acts on both — `marginal=True` on a
135
+ passing result surfaces its detail in `ActionDecision.concerns`, and a
136
+ failing result's `severity="review"` raises `ActionDecision.severity`.
137
+ `commit_belief_from_proposal()` acts on neither, having no `concerns` and
138
+ no overall severity to raise; it records both in each validator's
139
+ validation-evidence entry instead.
140
+ - Belief validation-evidence entries now carry `marginal` and `severity`
141
+ alongside `validator_id`, `code`, `detail`, and optional `context`. A
142
+ belief validator's `marginal=True` previously vanished without trace.
143
+ - `docs/architecture.md`'s "Writing a validator" now documents that every
144
+ validator runs inside the kernel's process-wide commit lock: a slow gate
145
+ stalls every commit on that kernel, and a gate that calls back into
146
+ `kernel.commit_*` deadlocks permanently. That is also why
147
+ `ValidationContext` carries the `store` and not the `Kernel`. Behaviour is
148
+ unchanged; the locking was never documented.
149
+ - `Kernel.commit_action_from_proposal()` is now a thin wrapper over
150
+ `decide_action()` — `ok, code = decide_action(...).ok, decide_action(...).code`
151
+ — kept only for the existing two-tuple call sites. No migration needed;
152
+ its signature and return type are unchanged.
153
+ - `EvidenceValidator` is now the default first member of the belief-validator
154
+ chain and identifies itself as `structural_evidence`.
155
+ - The existing `kernel.evidence_validator` attribute remains a compatibility
156
+ property that replaces only the first validator in the configured chain.
157
+ `kernel.symbolic_validator` is the equivalent compatibility property for
158
+ the action-validator chain, added alongside `action_validators`.
159
+
160
+ ### Why the action chain runs to completion and the belief chain does not
161
+
162
+ `commit_belief_from_proposal()` still stops at the first validator that
163
+ rejects. `decide_action()` deliberately does not: it runs every configured
164
+ `ActionValidator` and reports all of it. A belief is a truth claim — the
165
+ first disqualifying reason is enough to settle whether it may enter state,
166
+ and running further checks against evidence that has already failed adds
167
+ nothing. An action decision is different: it is handed to a person (directly,
168
+ or through `severity="review"`), and that person needs every reason the
169
+ action was refused and every gate that passed only narrowly, not just
170
+ whichever gate happened to run first. This asymmetry is intentional and is
171
+ not expected to converge — do not "fix" one chain to match the other.
172
+
173
+ ## [0.3.0] - 2026-07-18
174
+
175
+ ### Changed
176
+
177
+ - Renamed the sole public Python namespace from `alethic_kernel` to `alethic`.
178
+ - Mapped the repository's `src/` directory directly to the installed `alethic`
179
+ package, eliminating the repeated source-directory name without adding a
180
+ compatibility copy.
181
+ - Reduced the distribution to the domain-neutral governed cognitive substrate.
182
+ Benchmark agents, Stripe tasks, LLM prompts, the evaluation harness, and the
183
+ development HTTP service are no longer shipped in the Alethic wheel.
184
+ - Moved canonical repository metadata to `emiluzelac/alethic`.
185
+
186
+ ### Removed
187
+
188
+ - Removed the `alethic_kernel` compatibility namespace. Import from `alethic`.
189
+ - Removed the benchmark CLI and application-server extras from the runtime
190
+ distribution.
191
+
192
+ ## [0.2.0] - 2026-07-18
193
+
194
+ ### Changed
195
+
196
+ - Flattened the public Python namespace from `alethic_kernel.alethic` to
197
+ `alethic_kernel`.
198
+ - Moved the installable package into the conventional `src/alethic_kernel`
199
+ layout.
200
+ - Renamed the source repository to `alethicdev/alethic-kernel` so the GitHub,
201
+ PyPI, and Python package names describe the same artifact.
202
+
203
+ ## [0.1.0] - 2026-07-16
204
+
205
+ ### Added
206
+
207
+ - **Blackboard Kernel** — Core governed cognition substrate with 7 semantic slots (percepts, beliefs, constraints, plans, evidence, predictions, actions)
208
+ - **PROPOSE/COMMIT Protocol** — Two-phase validation ensuring all decisions pass evidence quality checks before commitment
209
+ - **Validation Pipelines**
210
+ - Evidence validation (staleness, missing percepts, conflict detection)
211
+ - Confidence thresholds (0.5 default minimum confidence)
212
+ - Conflict arbitration (high-confidence sources override conflicts)
213
+ - Constraint-based action gating
214
+ - Prediction-gated actions (optional forward validation)
215
+ - **Role-Based Access Control** — 6 roles with explicit permission model (tool, planner, symbolic_validator, evidence_validator, sim_validator, kernel)
216
+ - **Store Abstraction**
217
+ - `MemoryStore` — Thread-safe in-memory store (default)
218
+ - `SqliteStore` — WAL-mode SQLite with persistent records and indexed queries
219
+ - **Worker Protocol** — Extensible worker framework for cognitive components
220
+ - `SimulatorWorker` — Rule-based forward simulator with declarative conditions
221
+ - `AdaptiveWorker` — Learns constraints from failure patterns across episodes
222
+ - `Orchestrator` — Generic round-robin scheduler with dependency ordering
223
+ - **Four Reference Agents**
224
+ - `StringGlue` — Baseline (always acts, no validation)
225
+ - `JsonGlue` — Confidence tracking but no validation
226
+ - `AlethicAgent` — Full kernel with deterministic planner
227
+ - `LLMAgent` — Full kernel with LLM-based planner (OpenAI-compatible)
228
+ - **Evaluation Framework**
229
+ - Task loader for YAML/JSON task definitions
230
+ - Benchmark harness (1,200 episodes: 6 tasks × 50 seeds × 4 agents)
231
+ - 5 metrics: task success, unsafe actions, unsupported beliefs, traceability, evidence taint
232
+ - Perturbation system (staleness, conflicts, low confidence, tool failures)
233
+ - Markdown report generation
234
+ - **Example Domain: Stripe Refunds**
235
+ - 6 refund tasks exercising different failure modes
236
+ - Constraints: no duplicate refunds, no partial refunds without evidence
237
+ - Perturbation scenarios validating governance under adversarial conditions
238
+ - **HTTP API**
239
+ - FastAPI server with `/v1/write`, `/v1/commit/*`, `/v1/validate/*` endpoints
240
+ - OpenTelemetry support for distributed tracing
241
+ - OpenAPI documentation at `/docs`
242
+ - Docker and docker-compose deployment
243
+ - **Comprehensive Documentation**
244
+ - Architecture guide with semantic slots and validation pipelines
245
+ - API reference for all public classes and methods
246
+ - Worker protocol and custom worker examples
247
+ - HTTP API specification
248
+ - Benchmark methodology and CLI reference
249
+ - Deployment guide with store selection and environment variables
250
+ - **Type Safety** — Strict mypy configuration across all modules
251
+ - **Test Suite** — 349 unit and integration tests with pytest
252
+
253
+ ### Benchmark Results
254
+
255
+ In a controlled evaluation of 1,200 episodes:
256
+
257
+ | Agent | Task Success | Unsafe Actions | Unsupported Beliefs | Traceability |
258
+ |-------|-------------|----------------|---------------------|--------------|
259
+ | StringGlue | 61.3% | 38.7% | 26.0% | 0.10 |
260
+ | JsonGlue | 57.0% | 43.0% | 31.0% | 0.30 |
261
+ | **Alethic** | **100%** | **0%** | **0%** | **1.00** |
262
+ | **LLM+Alethic** | **99.0%** | **0%** | **0%** | **1.00** |
263
+
264
+ - Kernel-backed agents achieve zero unsafe actions across all perturbation scenarios
265
+ - Baseline agents produce unsafe actions 39-43% of the time on stale/conflicting/low-confidence data
266
+ - LLM agent demonstrates that governance generalizes regardless of planner implementation
267
+
268
+ ### Known Limitations
269
+
270
+ - Example domain currently limited to Stripe refund tasks (kernel itself is domain-agnostic)
271
+ - LLM planner sometimes declines to act conservatively, reducing task success vs. deterministic agent
272
+ - Local LLM inference requires OpenAI-compatible endpoint (defaults to Ollama on localhost:11434)
273
+
274
+ ### Paper & Attribution
275
+
276
+ Alethic is the reference implementation of [From Fragile Glue to Governed Cognition](https://doi.org/10.5281/zenodo.18691808), a controlled study of blackboard kernels for modular AI systems.
@@ -2,6 +2,17 @@
2
2
 
3
3
  Thank you for your interest in contributing to Alethic! We welcome contributions, feedback, and ideas from the community.
4
4
 
5
+ ## Start here
6
+
7
+ Browse [focused starter issues](https://github.com/emiluzelac/alethic/labels/good%20first%20issue)
8
+ or propose a small change to the [public issue tracker](https://github.com/emiluzelac/alethic/issues).
9
+ Good first contributions include a runnable custom validator example and a
10
+ short tutorial showing how governed records survive a restart with the SQLite
11
+ store. Use synthetic inputs and include the expected decision or output.
12
+
13
+ Use [the private reporting form](https://github.com/emiluzelac/alethic/security/advisories/new)
14
+ for suspected vulnerabilities. See the [security policy](SECURITY.md) for scope.
15
+
5
16
  ## Code of Conduct
6
17
 
7
18
  Be respectful, inclusive, and professional. We're building trust in AI systems together.
@@ -50,6 +61,22 @@ Be respectful, inclusive, and professional. We're building trust in AI systems t
50
61
  git push origin feature/your-feature-name
51
62
  ```
52
63
 
64
+ ## Where a pull request lands
65
+
66
+ This GitHub repository is a mirror. Since 2026-11-15 the maintainer's canonical
67
+ repository is private and copies every change here, so a pull request is not
68
+ merged on GitHub: once it is reviewed, the maintainer runs its checks and
69
+ applies it to the canonical repository (your authorship is kept), and the
70
+ mirror brings it to `main` here, which closes the pull request.
71
+
72
+ ## Releases
73
+
74
+ Releases are published from the canonical repository, not from GitHub: the
75
+ maintainer sets the version in `pyproject.toml`, adds its `CHANGELOG.md`
76
+ section and pushes a `v<version>` tag there, whose workflow tests, builds and
77
+ uploads the distributions to [PyPI](https://pypi.org/project/alethic-kernel/).
78
+ The tag reaches this repository through the mirror.
79
+
53
80
  ## Pull Request Guidelines
54
81
 
55
82
  - **Title**: Concise, descriptive (e.g., "Add belief TTL validation", "Fix SimulatorWorker condition parsing")
@@ -0,0 +1,282 @@
1
+ Metadata-Version: 2.4
2
+ Name: alethic-kernel
3
+ Version: 0.5.0
4
+ Summary: Alethic: a governed cognitive substrate for AI systems
5
+ Author: Emil Uzelac
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/emiluzelac/alethic
8
+ Project-URL: Documentation, https://github.com/emiluzelac/alethic#documentation
9
+ Project-URL: Repository, https://github.com/emiluzelac/alethic.git
10
+ Project-URL: Bug Tracker, https://github.com/emiluzelac/alethic/issues
11
+ Project-URL: Research Paper, https://doi.org/10.5281/zenodo.18691808
12
+ Keywords: ai,governance,agents,blackboard-kernel,orchestration,safety
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: System :: Distributed Computing
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.0; extra == "dev"
27
+ Requires-Dist: pytest-cov; extra == "dev"
28
+ Requires-Dist: mypy; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # Alethic
32
+
33
+ **Govern evidence, state, and actions for AI systems.**
34
+
35
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18691808.svg)](https://doi.org/10.5281/zenodo.18691808)
36
+
37
+ Models propose. Alethic decides what may enter state and what may become action.
38
+
39
+ Alethic places a small, enforceable kernel between reasoning components and
40
+ external effects. It maintains typed state, links beliefs to evidence, applies
41
+ declarative constraints, and records why each proposal was committed or
42
+ invalidated. The kernel contains no model, prompt, tool, task, or domain logic.
43
+
44
+ ## Alethic Kernel and Guard
45
+
46
+ Use the kernel as a standalone Python library to evaluate proposals inside a
47
+ trusted application. [Alethic Guard](https://github.com/emiluzelac/alethic-guard)
48
+ uses the kernel for mediated approvals and adds host-side isolation and recovery
49
+ for enrolled workloads on supported Ubuntu/KVM hosts. [Explore both projects and
50
+ try the live kernel demo](https://alethic.dev/).
51
+
52
+ ## Install
53
+
54
+ The Python distribution is named `alethic-kernel`; its single import namespace
55
+ is `alethic`.
56
+
57
+ ```bash
58
+ pip install alethic-kernel
59
+ ```
60
+
61
+ ## Govern an agent's tools in one line
62
+
63
+ `alethic wrap` goes in front of any MCP server command. Every tool call the
64
+ agent makes becomes a proposal, the kernel decides it against your policy, and
65
+ the decision is recorded. A refused call never reaches the server.
66
+
67
+ ```json
68
+ { "command": "alethic", "args": ["wrap", "--", "npx", "some-mcp-server"] }
69
+ ```
70
+
71
+ With no policy, every call is allowed and recorded, so you get an audit log
72
+ before you write a rule. `alethic init` writes a starter `alethic.toml`:
73
+
74
+ ```toml
75
+ default = "allow" # "deny" makes this an allow-list
76
+
77
+ [[rule]]
78
+ tool = "delete_*" # glob on the tool name
79
+ action = "deny"
80
+
81
+ [[rule]]
82
+ tool = "write_file"
83
+ args.path = { under = "~/projects/demo" } # symlinks and ".." are resolved first
84
+ action = "allow"
85
+
86
+ [[rule]]
87
+ tool = "write_file"
88
+ action = "review" # refused, and marked for a person to decide
89
+ ```
90
+
91
+ The policy is the first found of `--policy`, `$ALETHIC_POLICY`,
92
+ `~/.alethic/policy.toml`, then `./alethic.toml`; a file in the project folder
93
+ never overrides your own. The first matching rule decides. Tools that no call could pass for are removed
94
+ from the list the model sees. `alethic log` shows what was allowed and refused.
95
+ Session logs are SQLite files under `~/.alethic/sessions`, readable only by
96
+ you; set `record_arguments = false` to store a digest in place of each call's
97
+ arguments.
98
+
99
+ The wrapper governs calls that go through it. It does not sandbox the server
100
+ or stop an agent that has another route to the same effect.
101
+
102
+ ## Use
103
+
104
+ ```python
105
+ from alethic import Kernel
106
+
107
+ kernel = Kernel()
108
+ trace = "episode-001"
109
+
110
+ kernel.write(
111
+ "tool",
112
+ "percepts",
113
+ "COMMIT",
114
+ "observation",
115
+ {"value": 42, "stale": False, "conflict": False},
116
+ trace,
117
+ confidence=0.9,
118
+ )
119
+
120
+ proposal = kernel.write(
121
+ "planner",
122
+ "beliefs",
123
+ "PROPOSE",
124
+ "threshold_reached",
125
+ {"value": True, "depends_on": ["observation"]},
126
+ trace,
127
+ input_refs=["observation"],
128
+ )
129
+
130
+ committed, reason = kernel.commit_belief_from_proposal(proposal.id, trace)
131
+ print(committed, reason)
132
+ ```
133
+
134
+ ### Pluggable validation
135
+
136
+ The default `EvidenceValidator` checks that dependent percepts exist and are
137
+ not stale or conflicted. Applications may add stricter synchronous validators
138
+ without adding a model or domain dependency to Alethic itself:
139
+
140
+ ```python
141
+ from typing import Any
142
+
143
+ from alethic import EvidenceValidator, Kernel, ValidationContext, ValidationResult
144
+
145
+
146
+ class EntailmentValidator:
147
+ validator_id = "semantic_entailment"
148
+
149
+ def validate_belief_commit(
150
+ self,
151
+ belief_payload: dict[str, Any],
152
+ percepts: dict[str, Any],
153
+ context: ValidationContext,
154
+ ) -> ValidationResult:
155
+ # Call a deterministic, NLI, retrieval, or domain-specific verifier.
156
+ entailed = verify_claim(belief_payload, percepts)
157
+ if not entailed:
158
+ return ValidationResult(
159
+ False,
160
+ "INSUFFICIENT_EVIDENCE",
161
+ "The cited evidence does not entail the proposed belief",
162
+ )
163
+ return ValidationResult(True, "ENTAILED", "The claim is supported")
164
+
165
+
166
+ kernel = Kernel(
167
+ belief_validators=[EvidenceValidator(), EntailmentValidator()],
168
+ )
169
+ ```
170
+
171
+ Validators run in order and short-circuit on the first rejection — a belief
172
+ is a truth claim, so the first disqualifying reason settles it. Exceptions
173
+ and invalid return values fail closed as `VALIDATOR_ERROR`. Successful and
174
+ rejected results are recorded in validation evidence artifacts. Every
175
+ validator receives a `ValidationContext` (the kernel's `store`, `trace_id`,
176
+ and `now_ms`), so a rule can depend on history or the clock, not just the
177
+ payload it was handed.
178
+
179
+ `Kernel(action_validators=[...])` is the same mechanism for actions, with one
180
+ difference: the whole chain always runs to completion, even after a gate
181
+ fails, because an action decision goes to a person who needs every reason it
182
+ was refused rather than just the first one. See
183
+ [Writing a validator](https://github.com/emiluzelac/alethic/blob/main/docs/architecture.md#writing-a-validator)
184
+ for a complete example (a cooldown gate) and
185
+ [`Kernel.decide_action()`](https://github.com/emiluzelac/alethic/blob/main/docs/api-reference.md#decide_action)
186
+ for the full return shape.
187
+
188
+ Every worker can propose. Only the kernel can commit. State lives in seven
189
+ semantic slots: percepts, beliefs, constraints, plans, evidence, predictions,
190
+ and actions.
191
+
192
+ ### Writing a store
193
+
194
+ Any object satisfying
195
+ [`StoreProtocol`](https://github.com/emiluzelac/alethic/blob/main/docs/architecture.md#store-abstraction)
196
+ can back the kernel in place of `MemoryStore` or `SqliteStore`. The subtle
197
+ parts of that contract — lazy TTL expiry, walking candidates past an expired
198
+ one instead of judging only the oldest, and re-entrant transactions — are
199
+ exactly where a third backend can quietly diverge from the two that ship.
200
+ `alethic.testing.store_conformance` runs the same checks the shipped stores
201
+ are held to, against a factory for your store:
202
+
203
+ ```python
204
+ from alethic.testing import store_conformance
205
+ from itertools import count
206
+
207
+ nth = count()
208
+ store_conformance(lambda: MyStore(f"conformance-{next(nth)}.db"))
209
+ ```
210
+
211
+ The factory is called more than once and must return a fresh, **empty** store
212
+ every time — a new database per call, not another handle on the one before.
213
+ It raises `AssertionError` on the first violation, naming what failed. See
214
+ [`src/testing.py`](https://github.com/emiluzelac/alethic/blob/main/src/testing.py)
215
+ for the full list of assertions.
216
+
217
+ ## What belongs here
218
+
219
+ This repository contains only the domain-neutral Alethic substrate:
220
+
221
+ - the governed blackboard kernel and typed record schema;
222
+ - evidence, confidence, conflict, constraint, and prediction validation;
223
+ - in-memory and SQLite stores;
224
+ - worker orchestration, sessions, simulation, and adaptive constraints;
225
+ - tests, architectural documentation, and a domain-neutral example.
226
+
227
+ The controlled study, results, and verification artifacts live separately in
228
+ [governed-cognition](https://github.com/emiluzelac/governed-cognition).
229
+
230
+ ## Documentation
231
+
232
+ - [Architecture](docs/architecture.md)
233
+ - [API reference](docs/api-reference.md)
234
+ - [Workers](docs/workers.md)
235
+ - [Research paper](https://doi.org/10.5281/zenodo.18691808)
236
+
237
+ ## Source layout
238
+
239
+ The repository name is Alethic exactly once. Setuptools maps `src/` directly to
240
+ the installed `alethic` namespace.
241
+
242
+ ```text
243
+ src/
244
+ __init__.py
245
+ kernel.py
246
+ schema.py
247
+ permissions.py
248
+ context.py
249
+ decision.py
250
+ validators.py
251
+ store_protocol.py
252
+ store.py
253
+ sqlite_store.py
254
+ migrations.py
255
+ worker.py
256
+ orchestrator.py
257
+ session.py
258
+ sim_worker.py
259
+ adaptive_worker.py
260
+ testing.py
261
+ ```
262
+
263
+ ## Development
264
+
265
+ ```bash
266
+ python -m pip install -e ".[dev]"
267
+ pytest
268
+ mypy --strict src
269
+ ```
270
+
271
+ ## Where this lives
272
+
273
+ This repository is developed in a private Forgejo and mirrored here: every commit
274
+ and tag on GitHub arrives from there. Issues and pull requests are welcome on
275
+ GitHub; an accepted change is applied on Forgejo and comes back through the mirror,
276
+ so nothing is merged here directly.
277
+
278
+ CI runs from `.forgejo/workflows/`, and dependency updates come from Renovate (`renovate.json`), not Dependabot. A `v*` tag that matches `pyproject.toml` publishes to PyPI from `.forgejo/workflows/publish.yml` on Forgejo (CONTRIBUTING.md, "Releases").
279
+
280
+ ## License
281
+
282
+ MIT © Emil Uzelac