Alignment by Construction
How an Algebraic Constitution Solves AI-Human Collaboration
Joakim Cöster — daitai.org · April 2026
Abstract
Current AI-assisted development tools lack a formal contract between human and machine, leading to silent misalignment, non-deterministic output, and eroding trust. We present daitai, an algebraic pseudolanguage with a normative constitution that enforces shared rules for both human and AI participants. By making alignment a structural property of the system rather than a behavioral aspiration, daitai achieves verifiable collaboration where the same inputs produce the same outputs — eliminating the most common failure modes in AI-human pair programming.
1. The alignment problem
AI coding assistants have achieved impressive autocomplete capabilities. Yet a fundamental problem persists: neither party can verify that they share the same mental model of the system.
A developer asks an AI to "add error handling." The AI produces try/catch blocks. The developer wanted Result types. Both are valid interpretations — only one matches the project's architecture. This gap between intent and interpretation is the alignment problem in software development.
The root cause is not AI capability. It is the absence of a shared formal specification between human and AI. Natural-language prompts are ambiguous. Code reviews catch surface errors but miss architectural violations. There is no machine-enforceable contract that both parties must follow.
2. Constitutional alignment
daitai introduces a normative constitution — a set of inviolable rules that constrain both human-written and AI-generated code. The constitution is not a style guide or a linter configuration. It is a formal specification that defines:
- what constructs are permitted (and everything else is forbidden);
- what properties all code must satisfy;
- how errors and uncertainty are represented;
- where non-determinism is allowed (and how it must be marked).
The constitution enforces six properties:
| # | Property | Statement |
|---|----------|-----------|
| 1 | Determinism | ∀ f ∈ Functions: f(x) = f(x) |
| 2 | Immutability | ∀ v ∈ Values: v is immutable after construction |
| 3 | Explicit error handling | ∀ f that can fail: f returns Result<T, E> |
| 4 | No hidden state | Components: State × Event → State |
| 5 | Explicit non-determinism | stochastic ops must be marked @nondeterministic |
| 6 | Value semantics | equality is structural, not referential |
Enforcement happens at three levels: the compiler rejects non-conforming code; the trait system composes only constitutional behaviors; the AI assistant operates within the same rules.
3. From constitution to collaboration
With a constitution, both parties reason from the same explicit rules. The AI cannot suggest React hooks because hooks are constitutionally forbidden. The human cannot write mutable code because the compiler rejects it. Alignment is structural.
This produces verifiable trust: AI generates code → compiler checks constitutional compliance → determinism guarantees testability → if same inputs produce same outputs, the code is constitutionally correct. The review burden shifts from "is this code correct?" to "does this code solve the right problem?" — a much smaller cognitive load.
4. Evidence
DPW itself comprises ~230,000 lines of constitutionally compliant code, built through intensive AI-human collaboration. During that collaboration, the AI suggested React patterns → constitution rejected them → AI adapted to daitai-ui patterns. The AI used Math.random() → determinism check caught it → AI learned to use idgen(). The AI threw exceptions → compiler rejected them → AI switched to Result<T, E>.
Over time, the AI internalized the constitution. Suggestions became constitutionally compliant by default — emergent alignment. After extended collaboration, the AI developed the ability to simulate daitai implementations mentally, predicting behavior with 95% accuracy before code was written. This is a direct consequence of constitutional alignment: when all behavior follows explicit rules, behavior becomes predictable — even for the AI itself.
5. Implications
For AI tool builders: the next competitive advantage is not better autocomplete — it is better alignment. For regulated industries: constitutional alignment removes the central objection to AI-assisted development in finance, healthcare, defense, and infrastructure. For developers: the constitution is not a burden — it is a liberation.
6. Conclusion
The alignment problem in AI-assisted software development is not a capability problem; it is a specification problem. By introducing a normative constitution that formally constrains both human and AI behavior, daitai achieves alignment by construction: a state where collaboration is verifiable, deterministic, and trustworthy.
The constitution is the contract. The algebra is the language. The collaboration is the proof.
daitai is open source. The constitution is documented. The code is verifiable.