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