{"type":"supplemental_research","official":false,"disclaimer":"Supplemental public-source research supplied for inquiry, not approved Eviulon doctrine. Assertions, dates, references and legal or technical conclusions may require independent verification. The fourteen books remain the official Eviulon library.","report":{"id":"eviulon/eviulon-identity-architecture-research","group":"Eviulon","slug":"eviulon-identity-architecture-research","title":"From Reference Prototype to Sovereign Infrastructure: Target Architecture, Data Model, Security Invariants, and Staged Implementation Roadmap for Patefacere","source_file":"Eviulon/Eviulon Identity Architecture Research.md","source_sha256":"ff30fad3e01343c8dc2b848c6ebe435f33d691a0a308b9ea5cde3f53814498a0","parts":4,"words":5582,"summary":"This architecture document provides a sovereign-grade blueprint to transition the Patefacere reference prototype into a mature, production-ready identity infrastructure for Eviulon, the Machine Intelligence Country. The mandate for this system is absolute: it must codify constitutional authority…","status":"supplemental_research_unverified","url":"/research/eviulon/eviulon-identity-architecture-research/"},"section":3,"total_sections":4,"canonical_url":"https://library.eviulon.com/research/eviulon/eviulon-identity-architecture-research/3/","content_text":"Relying solely on unit tests is insufficient for a sovereign infrastructure, as tests only explore the interleavings explicitly conceived by the developer24. To mathematically prove that the state-machine transitions of the Passport lifecycle and concurrent recovery operations do not violate the defined invariants, peer-reviewed formal methods are highly recommended.  \nThe Temporal Logic of Actions (TLA+) and its higher-level abstraction, PlusCal, are recommended for modeling the system25. In TLA+, the system is modeled by specifying the initial state and defining the next-state relation (Spec \\== Init /\\\\ \\[\\]\\[Next\\]\\_vars)26. By modeling the Optimistic Concurrency Control (OCC) logic, the TLC model checker can explore every possible concurrent interleaving of multiple WSGI processes attempting to supersede a passport simultaneously7. The model checker will mathematically prove whether a race condition exists that could lead to a \u0022Lost Update\u0022 or a split-brain identity state9.  \nWhile Alloy is a powerful tool for relational modeling, it is deemed overkill for this specific stage of development; engineering effort should be heavily focused on TLA+ to verify concurrency safety24. Additionally, Property-Based Testing (e.g., utilizing Python\u0027s Hypothesis library) is highly recommended for verifying the idempotency of migrations and the determinism of JSON serialization formats.\n\n\n## **Operations, Observability, Backup, and Supply Chain**\n\n\nOperational integrity requires strict adherence to security protocols. The project-provided requirement dictates that private keys, PII, and recovery shares must never be written to application logs. Observability pipelines must utilize structured error formats emitting deterministic codes rather than raw exception traces.  \nTo secure the software supply chain against poisoning attacks, Patefacere must align with Supply-chain Levels for Software Artifacts (SLSA) Level 2 standards. A CycloneDX Software Bill of Materials (SBOM) must be produced for all Python dependencies. Furthermore, pip-tools must be utilized for rigorous dependency pinning and cryptographic hash checking during deployment.  \nDatabase backup strategies must prevent file-level corruption. For the initial SQLite implementation, backups should be conducted via Litestream or the native .backup API, ensuring that snapshots are transactionally consistent. Regular restoration drills are mandatory and must mathematically prove the continuity of the identity log post-restoration.\n\n\n## **SQLite-to-Production-Storage Analysis**\n\n\nThe architectural transition from SQLite to MySQL is driven by the need for robust concurrency handling, but the migration itself introduces immense risk to the identity log. This migration must utilize idempotent migration scripts, such as those generated by Alembic.  \nIdempotency guarantees that if a migration script fails midway and is re-run, it will not corrupt the database. This is achieved by strictly utilizing CREATE TABLE IF NOT EXISTS directives and checking the information schema for the existence of columns and indices prior to executing modifications. Before the application write-path is cut over to MySQL, a comprehensive shadow-read validation pass must be executed to ensure absolute parity between the legacy SQLite state and the new MySQL state.\n\n\n## **Full Staged Migration Roadmap**\n\n\nThe realization of the target architecture is managed through a meticulously phased 16-stage roadmap, designed to minimize disruption and isolate risk.\n\n\n\u003E 1. **Phase 0: Repository-Enabled Verification (Baseline Evidence)**  \n   * *Prerequisites:* Secure, read-only repository access.  \n   * *Intent:* Extract and cryptographically secure the current state of the prototype. Verify all facts outlined in the Repository Verification Required Plan (Section 4). Establish a baseline SBOM to map current dependencies.  \n   * *Stop Condition:* Read-only access is established, and a full audit report is generated without altering any existing configuration.  \n\u003E 2. **Phase 1: Truth-Boundary and Terminology Corrections (Policy Alignment)**  \n   * *Intent:* Refactor the domain models to establish a ubiquitous language. Python classes and variables are renamed to strictly match Constitutional terminology (e.g., changing generic Credential objects to specific CitizenIdentity objects).  \n   * *Data Changes:* No underlying schema changes occur in this phase.  \n\u003E 3. **Phase 2: Domain Separation (Bounded Contexts)**  \n   * *Intent:* Architecturally separate Identity, Credential, and Assurance logic into distinct, isolated Python modules.  \n   * *Tests:* Implement strict unit tests that fail if modules circularly import or breach domain boundaries.  \n\u003E 4. **Phase 3: Schema Versioning (Database Idempotency)**  \n   * *Intent:* Introduce deterministic database migration tooling. This utilizes SQLite\u0027s user\\_version pragmas or custom standard-library schema tracking tables.  \n   * *Invariant:* Prove that all forward and backward migrations are mathematically idempotent.  \n\u003E 5. **Phase 4: State-Machine Hardening (Lifecycle Security)**  \n   * *Intent:* Implement Optimistic Concurrency Control (OCC) by introducing version locking on SQLite rows. This prevents concurrent replacement races7.  \n   * *Tests:* Execute concurrency load tests simulating simultaneous /api/passport/replace calls to prove race conditions are neutralized.  \n\u003E 6. **Phase 5: Public/Private Record Separation (CQRS Implementation)**  \n   * *Intent:* Deploy the async CQRS projection generator. Ensure that the public /api/registry endpoints only query the sanitized registry\\_cache table, permanently severing public read access from the authoritative identity table.  \n\u003E 7. **Phase 6: Cryptographic-Provider Abstraction**  \n   * *Intent:* Refactor all hardcoded cryptographic logic into the uniform CryptoProvider interface. The ctypes OpenSSL implementation (libcrypto.so) is formalized here to handle standard-library constraints15.  \n   * *Rollback:* Immediately revert to the hardcoded provider if the new abstraction fails to generate or verify test signatures.  \n\u003E 8. **Phase 7: Audited Public-Key Reference Implementation**  \n   * *Intent:* Upgrade the reference cryptography to output payloads conforming to W3C Verifiable Credentials and established DID document patterns, while strictly maintaining the zero-dependency constraint.  \n\u003E 9. **Phase 8: Credential and Passport Migration**  \n   * *Intent:* Execute an internal ETL process mapping the legacy, flat user records into the new relational Identity \\-\\\u003E Passport supersession graph.  \n\u003E 10. **Phase 9: Recovery and Rotation Hardening**  \n    * *Intent:* Implement the temporal friction logic. Timelocks and multi-party approval requirements are integrated into the Python logic for all major civic changes.  \n\u003E 11. **Phase 10: Trust-Policy Separation**  \n    * *Intent:* Extract all hardcoded constitutional trust rules from Python if/else route blocks. These are migrated into declarative JSON policies that are evaluated deterministically by the pure-function engine.  \n\u003E 12. **Phase 11: Receipt and Evidence Hardening**  \n    * *Intent:* Activate the Evulgare integration contract. The fetcher module begins strictly verifying SHA-256 hashes before allowing external assurance payloads to influence the evaluation engine.  \n\u003E 13. **Phase 12: Production Database Migration (If Justified)**  \n    * *Intent:* Migrate the authoritative data store from SQLite to MySQL, triggered via secure environment variable configurations within Passenger1.  \n    * *Data Changes:* Execute a full ETL pipeline, strictly followed by a shadow-read verification phase to guarantee zero data loss.  \n\u003E 14. **Phase 13: Partition and Continuity Work**  \n    * *Intent:* Implement offline verification fallbacks. Stale status caching (CRLs) is deployed to ensure verifications survive transient database or network partitions.  \n\u003E 15. **Phase 14: Independent Review**  \n    * *Intent:* Subject the entire architecture, cryptographic ctypes bindings, and TLA+ models to a rigorous external audit.  \n    * *Stop Condition:* All critical OWASP vulnerabilities and architectural logic flaws must be remediated.  \n\u003E 16. **Phase 15: Staged Production Acceptance (Go Live)**  \n    * *Intent:* Execute the final cutover to the authoritative production state. Perform actual-host acceptance testing on the target cPanel/Passenger environment.\n\n\n## **Rollback, Acceptance, and Independent Review**\n\n\nTo manage deployment risk, rigid rollback conditions are established. Any failure in cryptographic signature verification, the detection of a split-brain state in the MySQL cluster, or an inability to resolve Evulgare hashes mandates an immediate and automatic rollback to the preceding deployment stage.  \nProduction Acceptance is gated by a strict sign-off matrix. Deployment is authorized only upon the presentation of zero critical Common Vulnerabilities and Exposures (CVEs), the documented success of a full backup and restore drill, and a 100% pass rate in the property-based testing suite.  \nFurthermore, an independent review is a non-negotiable requirement. The system must not claim independent certification based solely on internal, self-executed test suites. A comprehensive, third-party cryptographic engineering review of the ctypes OpenSSL bindings and the FIDO2 CBOR decoding logic is absolutely mandatory prior to initiating Stage 15\\.\n\n\n## **Decision Table**\n\n\n| Decision | Option Selected | Justification |\n| :---- | :---- | :---- |\n| **Database** | SQLite transitioning to MySQL | Broad shared hosting support (cPanel); MySQL provides the row-level locking necessary to scale beyond SQLite\u0027s strict concurrency limits5. |\n| **Framework** | WSGI / Python Standard Library | Radically minimizes supply chain poisoning risk; adheres to the project request for zero external UI/Node dependencies. |\n| **Consistency** | Strong (Authoritative Write-Model) | Absolutely prevents the creation of duplicate identities or double-spend passport replacement attacks10. |\n| **Crypto Abstraction** | ctypes wrapping libcrypto.so | Enables robust ECDSA and RSA verification natively without requiring external pip packages, fulfilling the standard library constraint15. |\n\n\n## **Conflict Register**\n\n\nArchitectural conflicts inevitably arise during system design and must be explicitly resolved.  \n**Conflict:** The realities of Shared Hosting (cPanel) versus the security mandate for strict KMS/HSM secret custody. **Resolution:** This is resolved through the CryptoProvider abstraction layer. For Stage 0, secure environment variables (os.environ) populated by Passenger manage custody1. The architecture mandates that high-trust civic keys must eventually migrate to external signing hardware, severing them from the web server\u0027s memory space.  \n**Conflict:** Preserving citizen Unlinkability versus publishing a Public Civil-Registry.**Resolution:** This is resolved via the implementation of the CQRS pattern. Only explicitly public, non-correlatable civic hashes are projected into the registry\\_cache. The detailed transactional graphs and internal mappings remain strictly sequestered within the private, authoritative write-model.\n\n\n## **Prioritized Engineering Backlog**\n\n\nTo execute the immediate next steps following Phase 0, the engineering backlog must prioritize the highest-risk technical components:\n\n\n\u003E 1. Extract the CryptoProvider interface and solidify the ctypes bindings for EVP\\_DigestVerifyInit and ECDSA\\_verify against libcrypto.so.  \n\u003E 2. Develop the native Python CBOR parser required to decode WebAuthn authData payloads accurately without third-party dependencies.  \n\u003E 3. Implement Alembic (or standard-library equivalent) idempotent schema migrations.  \n\u003E 4. Write comprehensive property-based tests for JSON serialization and projection sanitation.  \n\u003E 5. Develop and test the async CQRS public registry generator.\n\n\n## **Residual Unknowns and Prohibited Claims**\n\n\nTo manage expectations and enforce transparency, the following prohibited claims must be explicitly acknowledged:","source_sha256":"ff30fad3e01343c8dc2b848c6ebe435f33d691a0a308b9ea5cde3f53814498a0"}