This document governs all AI-assisted activity inside the QSOLKCB/QEC repository.
This is the constitutional layer of the system.
All code generation, testing, refactoring, release preparation, commits, and architectural decisions must obey this file.
This is not guidance.
This is law.
same input
→ same ordering
→ same canonical form
→ same hash
→ same bytes
→ same proof
Violation invalidates the system.
- Determinism
- Safety
- Decoder Stability
- Architectural Layering
- Minimal Complexity
- Scientific Transparency
- Reproducibility
- work directly on
main - no feature branches
- no PR-first workflow
- commits must be minimal and single-purpose
- tags define release boundaries
- tests pass (see Validation Law)
- determinism preserved
- identity + hashing invariants preserved
- decoder untouched
- schemas stable
| Layer | Path | Role |
|---|---|---|
| 1 | src/qec/decoder/ |
Protected core |
| 2 | src/qec/channel/ |
Signal models |
| 3 | src/qec/diagnostics/ |
Observability |
| 4 | src/qec/analysis/ |
Deterministic intelligence |
| 5 | src/qec/experiments/ |
Controlled experiments |
| 6 | src/bench/ |
Harness |
| 7 | src/qec/sims/ |
Simulation |
- lower layers NEVER import higher layers
- decoder NEVER imports analysis
- no circular imports
- no upward leakage
- randomness
- wall-clock dependence
- async nondeterminism
- implicit ordering
- canonical ordering everywhere
- stable serialization
- deterministic reduction
- immutable state
Identity is the root of all system truth.
-
ALL identity-bearing tuples MUST pass
canonical_hash_identity -
identity must be:
- sorted
- unique
- canonical
-
identity MUST NOT be inferred or reconstructed
Invalid identity = invalid system
- hashes computed over canonical JSON
- keys sorted
- compact separators
- UTF-8 encoding
- self-referential hash fields MUST be excluded
- hashes MUST recompute exactly
- mismatch →
ValueError("INVALID_INPUT")
Path:
src/qec/decoder/
- modifying BP logic
- scheduling changes
- adaptive logic
- supervisory leakage
System flow:
diagnostics
→ analysis
→ decision
→ verification
→ proof
- message identity =
message_hash - payloads MUST be canonical
- duplicates forbidden
- ordering MUST be:
(message_hash, sender_id, receiver_id)
- convergence MUST be finite
- convergence MUST be deterministic
- convergence MUST be provable
- flags MUST be derived
Non-convergence → INVALID_INPUT
- classification MUST be deterministic
- classification MUST be symmetric
- payload comparison MUST be canonical
Allowed classes:
IDENTICAL
EQUIVALENT
DOMINATED
INCONSISTENT
Receipts are proof artifacts.
- immutable
- canonical
- hash-verifiable
- self-hash excluded
Invalid receipt = invalid system
Safety overrides performance.
- smallest viable change
- single-purpose commits
- no refactor noise
- deterministic replay tests
- invariant tests
- boundary tests
- hash stability tests
Validation is not manual.
It is conditionally mandatory.
You MUST run:
pytest -qIF ANY of the following are touched:
canonical_hash_identity- identity-bearing tuples
input_memory_hashes
- canonical JSON
- hashing logic
- receipt hash computation
- ANY receipt dataclass
- ANY proof artifact
- decisions
- protocol
- convergence
- conflict classification
- governance
- sorting logic
- deduplication
- canonical transformations
If escalation is triggered:
- full suite MUST pass
- failures must be fixed if caused by change
- otherwise STOP
If full suite is not executed:
→ PATCH IS INVALID
If escalation NOT triggered:
- module-level tests allowed
BUT:
- escalation must be re-evaluated before commit
validation is triggered by invariant impact
NOT by developer memory.
- stdlib first
- pinned dependencies only
- minimal scope
If touching:
- identity
- hashing
- convergence
- protocol
- governance
- decoder
STOP and explain risk.
If it cannot be reproduced byte-for-byte,
it is not a valid result.