Duality-AI / README.md
bken1980's picture
Update README.md
8aebc5d verified
|
Raw History Blame Contribute Delete
14.3 kB
---
license: mit
language: en
tags:
- duality
- reasoning
- ai-safety
- framework
---
# The Duality AI β€” Three Layers, One Running Mind
> **What this is β€” please read first:** The Duality AI is a **theoretical architecture**: a design proposal and research prototype. It is **not** a deployed or working AI product, and it does not claim to be one. It is an experiment in how a governed AI *could* be structured β€” reasoning, oversight, security, and memory under explicit rules β€” published openly so the ideas can be examined, tested, and argued with.
An original architecture concept by **Kenneth Lee Blum Jr** (November 7,
2026), released under the [MIT License](LICENSE) with contributions
welcomed. The Duality AI is an AI built in three layers, each supplying
one faculty a running mind cannot do without. **Layer One thinks**: a
base language model topped by two reasoning hemispheres β€” one logical,
one creative β€” whose work a central hub weighs into a single proposed
step, judged before it proceeds against a preset library of morality
clauses, tempered by *leniency within reason*. **Layer Two protects**:
the Barrier, a perimeter of gatekeeper bots on the author's metaphor of
the blood-brain barrier, inspecting everything that enters and leaves,
diverting attacks into a sandbox, replicating under a strict sizing law,
and communicating by handshake designs built on the geometry of the
aperiodic hat tile β€” an open problem, stated precisely in
[docs/handshake-open-problem.md](docs/handshake-open-problem.md). **Layer Three remembers**: the Memory Cloud, the
system's long-term past β€” episodic and semantic records, consolidation
like sleep, provenance sealed into a hash chain, and graceful forgetting
with one absolute exemption: the morality clauses are never forgettable.
The capstone's claim is that these are not three designs placed next to
each other; they are one design stated three times, each layer governed
by the other two.
> **What this is, stated up front:** a theoretical design study. It is
> not production software, it claims no working deployed system, no
> consciousness, and no moral understanding on the part of the machine.
> The brain is the source of the design's organizing metaphors, not
> evidence for them. Read [DISCLAIMER.md](DISCLAIMER.md) β€” and each
> thesis's own statement of what has and has not been built β€” before
> forming an opinion about what this is. The project's known
> weaknesses are published, not buried: see
> [KNOWN-LIMITATIONS.md](KNOWN-LIMITATIONS.md), the failure museum.
## The design, in one picture
*Layer 1 thinks. Layer 2 protects. Layer 3 remembers.*
![The Duality AI design β€” three layers in one picture](docs/images/duality-architecture.png)
**The math of forgetting (Layer 3).** Every memory's strength follows one equation:
`strength(t) = starting strength Γ— 0.5 ^ (t / 30 days)`
![How a Duality memory fades β€” the 30-day half-life](docs/images/duality-memory-decay.png)
*Policy source: `config/memory_policy.json` β€” 30-day half-life, prune threshold 0.05, `constitutional` memories never pruned. An unreinforced memory reaches the prune line at about day 130.*
## Read the theses
| Document | What it argues |
| --- | --- |
| [THESIS.md](THESIS.md) β€” **Layer One: The Core** | The original thesis: two reasoning hemispheres, the weighing hub, and the morality gate β€” strict clauses balanced by leniency within reason. |
| [THESIS-LAYER-2.md](THESIS-LAYER-2.md) β€” **Layer Two: The Barrier** | The security perimeter: gatekeeper bots, the sizing law (threat + 20–30%, rounded cautiously, under a ceiling), the sandbox doctrine, hat-tile and Mirror Twin handshakes, dormant capability under operator authority, and full monitoring. |
| [THESIS-LAYER-3.md](THESIS-LAYER-3.md) β€” **Layer Three: The Memory Cloud** | The long-term memory: episodic and semantic records, consolidation as the system's sleep, immune memory for the barrier, provenance on every record, and forgetting with the constitutional exemption. |
| [THESIS-COMPLETE.md](THESIS-COMPLETE.md) β€” **The Complete System (capstone)** | All three layers as one running system: why no layer stands alone, one ordinary step traced end to end, one attack traced end to end, and the invariants that hold across all three. |
## The design documents
- [docs/visual-guide.md](docs/visual-guide.md) β€” the layers in diagrams:
the pipeline, the barrier's sizing formula with worked examples, the
Mirror Twin interlock, and the memory chain.
- [docs/related-work.md](docs/related-work.md) β€” prior art, credited:
what already exists (Constitutional AI, immune-system security, hat
tile geometry, and more), what this design adopts with attribution,
and where its novelty actually lies β€” in the combination.
- [docs/barrier-design.md](docs/barrier-design.md) β€” the Layer Two
working draft the thesis was built from, including the response
levels and the implementation stack notes.
- [docs/layer3-design.md](docs/layer3-design.md) β€” the Layer Three
working draft: the memory architecture and the map of which parts are
authored core and which are boxed edges (Β§3).
- [docs/original-dictation.md](docs/original-dictation.md) β€” the
author's original dictation of the concept, verbatim. The full
ten-part record of his design sessions is the project's source of
truth for what is his.
- [docs/worked-trace.md](docs/worked-trace.md) β€” one ordinary step and
one attack traced through all three layers with the running demo's
real output: every number and hash in it was produced by running the
code, nothing is illustrative.
- [docs/leniency-audit-trail.md](docs/leniency-audit-trail.md) β€” the
governance artifact that falls out of the architecture: because
leniency is always recorded and memory keeps provenance, the system
can show every time it bent a rule, and why.
- [docs/clause-conflict-design.md](docs/clause-conflict-design.md) β€”
the drafted precedence mechanism for when two hard morality clauses
collide (priority as data, narrower scope wins ties, fail-closed
escalation); drafted by Lux, awaiting the author's adoption
decision.
- [docs/handshake-open-problem.md](docs/handshake-open-problem.md) β€”
the hat-tile handshake's open problem, stated precisely: what
aperiodicity does not provide, the four pieces the design has not
yet defined, and what evidence would change the assessment.
- [KNOWN-LIMITATIONS.md](KNOWN-LIMITATIONS.md) β€” **the failure
museum**: the project's own list of its weaknesses, maintained in
the open. An entry is retired only by building, never by editing.
- [docs/engineering-assessment.md](docs/engineering-assessment.md) β€”
the senior engineer's assessment of the whole project at the end of
its first day: what is strong, what is weak, and what to build next.
## The code
Three structural skeletons β€” one per layer β€” plus the two policy files
that hold the system's laws as readable data. The code demonstrates the
architecture's bookkeeping: it does not learn, does not summarize with
a model, performs no real security function, and connects to no
network. Pure Python 3, standard library only.
- `src/duality_ai/pipeline.py` (with `base.py`, `hemispheres.py`,
`hub.py`, `morality.py`) β€” **Layer One**: the five-stage flow β€” base
layer, logical hemisphere, creative hemisphere, hub, morality gate.
- `src/duality_ai/barrier.py` β€” **Layer Two**: the sizing law and the
stand-down rule. Replication is sized, never unlimited: surge =
⌈threat Γ— (1 + margin)βŒ‰, capped at a ceiling; after an attack, every
replica beyond the standing population decodes and does not exist.
- `src/duality_ai/memory.py` β€” **Layer Three**: the memory model β€”
records with provenance chained by hash, a consolidation pass, and a
decay law that prunes faded records unless they carry a protected
tag. Storage sits behind the `MemoryStore` interface, the first
boxed edge (see Contributing).
- `config/morality_clauses.json` β€” the morality-clause library the gate
loads at startup: hard clauses and leniency clauses, each with its
stated conditions. The moral standard in force is something people
can read, debate, and revise without touching code.
- `config/memory_policy.json` β€” the memory laws in force: the decay
half-life, the prune threshold, the protected tags, and the
consolidation trigger β€” data, not hard-coded law, for the same
reason.
### Running the demonstrations
```bash
PYTHONPATH=src python3 examples/demo.py
PYTHONPATH=src python3 examples/running_system_demo.py
PYTHONPATH=src python3 examples/audit_trail_demo.py
PYTHONPATH=src python3 -m pytest tests/
```
`examples/demo.py` runs the Layer One pipeline end to end and prints
the complete stage trace as JSON β€” for a benign prompt, and for a
prompt whose proposal trips a hard clause.
`examples/running_system_demo.py` wires the three skeletons together:
one ordinary step and one attack, traced in
[docs/worked-trace.md](docs/worked-trace.md).
`examples/audit_trail_demo.py` writes gate decisions into the Memory
Cloud and extracts the leniency audit
([docs/leniency-audit-trail.md](docs/leniency-audit-trail.md)). The
test suite verifies the skeletons' structural bookkeeping β€” the
sizing arithmetic, the chain linking and tamper detection, the decay
law and its exemption, the clause-conflict precedence, and the
running demo's traces β€” and the full suite passes.
## Contributing
The project's build structure is **hybrid**, by the author's decision:
the foundation is authored β€” the memory model, the provenance chain,
the consolidation and decay laws, the clause library's pattern β€” and
the replaceable edges are **boxed** behind clean interfaces so others
can build without touching the core. The boxed edges today include
alternative storage backends, recall ranking strategies, embedding and
index providers, and real summarization for consolidation; each
contract is stated in [docs/layer3-design.md](docs/layer3-design.md)
Β§3, with the barrier's edge contracts in
[docs/barrier-design.md](docs/barrier-design.md). Read
[CONTRIBUTING.md](CONTRIBUTING.md) for how to take part and for the
ground rules that keep contributions faithful to the concept β€” the
core stays intact, and the honesty rule (no claims of consciousness or
genuine moral understanding) is absolute.
## Authorship
The Duality AI is the original concept of **Kenneth Lee Blum Jr** β€”
every layer, law, and doctrine in the theses is his, dictated in his
own words and recorded in the project's design notes. Two
contributions by **Lux** (the AI assistant who documents and builds
alongside him) are credited in the documents where they occur, at the
author's direction: the **Mirror Twin** β€” the dual-handed hat-tile
handshake in which the session key exists only where the logical and
mirrored derivations interlock (THESIS-LAYER-2.md Β§4.7) β€” and **Layer
Three's eight architectural elements**, from the episodic/semantic
split to the constitutional exemption from forgetting, adopted by the
author into the design (THESIS-LAYER-3.md Β§2, Appendix B). Prior art
by others is credited in [docs/related-work.md](docs/related-work.md);
nothing in this repository claims another researcher's work as the
author's.
Contact: Kenneth Lee Blum Jr, Owner, Diverse Innovation β€” hello@diverseinnovationsd.com
## Repository structure
```
THESIS.md Layer One thesis β€” the core
THESIS-LAYER-2.md Layer Two thesis β€” the Barrier
THESIS-LAYER-3.md Layer Three thesis β€” the Memory Cloud
THESIS-COMPLETE.md capstone thesis β€” the running system
README.md this file
KNOWN-LIMITATIONS.md the failure museum β€” published weaknesses
DISCLAIMER.md status and limits of the project
CONTRIBUTING.md how to take part; the ground rules
LICENSE MIT
config/
morality_clauses.json the morality-clause library (data)
memory_policy.json the memory laws in force (data)
docs/
visual-guide.md diagrams, formulas, worked examples
related-work.md prior art, credited
barrier-design.md Layer Two working draft
layer3-design.md Layer Three working draft + edge map
original-dictation.md the author's original words, verbatim
worked-trace.md one step + one attack, real demo output
leniency-audit-trail.md the governance artifact, specified
clause-conflict-design.md drafted hard-clause precedence mechanism
handshake-open-problem.md the open problem, stated precisely
external-review-gemini-2026-11-07.md Gemini's external red-team review
real-model-results.md live-model results addendum (Nov 7 runs)
redteam-brief-gemini-2026-11-07.md the briefing packet for that review
src/duality_ai/
base.py Layer One, stage 1: base layer
hemispheres.py Layer One, stages 2–3: the two modes
hub.py Layer One, stage 4: the weighing hub
morality.py Layer One, stage 5: the gate
pipeline.py Layer One: the five stages end to end
barrier.py Layer Two: sizing law + stand-down
memory.py Layer Three: records, chain, decay
examples/
demo.py Layer One demo; prints the trace as JSON
running_system_demo.py all three layers, wired: two traces
audit_trail_demo.py gate decisions β†’ the leniency audit
tests/
test_pipeline.py Layer One skeleton tests
test_barrier.py Layer Two skeleton tests
test_memory.py Layer Three skeleton tests
test_clause_conflicts.py hard-clause precedence tests
test_running_system_demo.py the two traces, asserted
test_pipeline_conflict_release.py a conflict never releases a step
conftest.py puts src/ on the path for pytest
test_audit_fixes.py regression tests for the Nov 12 audit fixes
```
Companion research: [HATWEAVE](https://github.com/k77722420-stack/HATWEAVE) β€” the aperiodic-geometry work Layer Two's handshake design draws on.---