Software Engineer & Independent AI Researcher
Matheus Pereira
Exploring memory, intelligent agents, and systems built to evolve.
I investigate how intelligent and conventional systems preserve context, coordinate decisions, and remain understandable as they evolve over time.

About me
Engineering systems. Investigating intelligence.
I am Matheus Pereira, a software engineer and independent AI researcher working at the intersection of software architecture, memory systems, and intelligent agents.
I build practical software and investigate how intelligent systems preserve context, coordinate decisions, form interpretable representations, and evolve without losing coherence.
Current investigations
Research that treats memory and architecture as living systems.
Artificial Intelligence and Memory Architectures
DREAM
DREAM is a model-independent architecture for persistent, opt-in, and governed episodic memory in artificial intelligence agents. It investigates how long-running systems can preserve useful continuity without allowing accumulated memories to become an uncontrolled source of outdated assumptions, semantic drift, recursive reinforcement, or false coherence. The architecture evolved from adaptive retention and lifecycle management toward explicit governance of memory influence. Its central principle is that retaining or retrieving a memory does not automatically authorize that memory to influence current reasoning. DREAM therefore treats persistence, retrieval, authorization, consolidation, correction, and deletion as distinct architectural responsibilities. The current version includes a Python reference implementation, formal data contracts, automated tests, a local governance playground, controlled synthetic benchmarks, component-ablation experiments, and auditable decision traces.
Software Architecture and Sustainability
Legacy-First Design
Legacy-First Design (LFD) is a conceptual software architecture methodology that treats time as a primary design constraint. It distinguishes between permanent elements, which preserve the identity and essential behavior of a system, and transient elements, such as frameworks, databases, protocols, and infrastructure, which must remain replaceable. Through six fundamental principles, LFD proposes that software should preserve meaning, resist technological obsolescence, evolve without losing its identity, remain understandable to future maintainers, and continue to make sense during prolonged periods without maintenance. Rather than replacing established approaches such as Clean Architecture, Domain-Driven Design, or Hexagonal Architecture, LFD provides temporal criteria for deciding what must endure and what may change.
Artificial General Intelligence and Cognitive Architectures
MQ-AGI
MQ-AGI is a neuroinspired, modular, and quantum-extended architecture for Artificial General Intelligence. It proposes an alternative to increasingly large monolithic models by separating perception, specialized reasoning, memory, integration, metacognition, and safety into components with explicit responsibilities. The architecture combines Domain Expert Networks, a Global Integrator Network, hierarchical long-term memory, distributed orchestration, and a quantum-inspired optimization core. Specialized experts generate parallel hypotheses, while the integrator constructs a coherent working representation, resolves conflicts, coordinates memory retrieval, and supports deliberative reasoning. Rather than sending large volumes of raw data to a quantum processor, MQ-AGI reserves quantum or quantum-inspired computation for bounded combinatorial problems such as expert-coalition selection, hypothesis optimization, and constraint satisfaction. This design reduces exposure to the quantum data-loading bottleneck while establishing a possible development path through classical emulation, NISQ-era optimization, and future quantum-native components. The research includes an architectural proposal, a mathematical formalization based on QUBO and Ising Hamiltonians, category-theoretic integration, and active inference, as well as a critical theoretical evaluation of its scientific coherence, engineering limitations, and long-term feasibility.
Papers, notes & articles
Published thinking.
Legacy-First Design: Building Software That Outlives Its Technology Stack
Legacy-First Design treats time as a primary architectural constraint. By separating the permanent identity of a system from its replaceable technologies, LFD proposes a way to build software that remains coherent long after its original stack, team, and context have changed.
A Memory Can Be Stored Without Being Trusted: Inside DREAM v3
DREAM v3 separates memory retention from cognitive influence, introducing provenance, contradiction handling, epistemic hygiene, controlled context construction, and auditable decision traces for persistent AI memory.
Software Contracts Show Structure. Raygon Makes Dependency Explicit.
Traditional software contracts describe what is available, but rarely reveal what each consumer actually depends on. Raygon explores a projection-based model in which dependency, compatibility, and evolution become explicit and observable.
DREAM: Dynamic Retention Episodic Architecture for Memory: Governed Memory through the Separation of Retention and Influence
DREAM v3 presents a model-independent reference architecture for governed episodic memory in artificial intelligence agents. The architecture addresses a central risk of persistent memory systems: information that remains stored may become outdated, contradicted, weakly grounded, or recursively reinforced, yet still be retrieved and treated as authoritative context. The proposal separates memory retention from query-conditioned memory influence. A Retention Policy Engine determines whether an Episodic Unit should remain active, move between storage tiers, be consolidated, archived, or become eligible for pruning. An independent Influence Policy Engine evaluates whether a retrieved memory may affect the current reasoning process and with what level of authority. Retrieval therefore produces a candidate memory rather than automatic authorization. DREAM v3 introduces versioned Episodic Units, auditable meta-memory, provenance and compression lineage, contradiction handling, temporal validity, epistemic recalibration, governed context construction, and immutable decision traces. A state-aware Hygiene Gate acts as the single authorization point between retrieval and context injection, allowing the system to authorize, qualify, arbitrate, reduce, quarantine, consolidate, or block memories according to their epistemic state. The accompanying reference implementation includes an interactive governance playground, automated tests, synthetic benchmarks, and component-ablation experiments. In a controlled synthetic evaluation, the complete architecture achieved 100% grounding fidelity, 0% false reinforcement, 0% continuity loss, and 100% quarantine recall. Removing the separation between retention and influence produced the largest degradation, reaching approximately 34.3% false reinforcement. These results provide architecture-level evidence in a controlled environment. They do not establish generalization to natural conversations, arbitrary language models, multilingual conditions, adversarial workloads, or production-scale deployments. DREAM v3 is presented as an executable and falsifiable research prototype, not as a universal truth-determination system or a production-ready memory service.
Open-source laboratory
Tools, frameworks, and experiments.
OPEN-SOURCE DISCORD RPG ENGINE
Roll & Play — Modular RPG Engine for Discord
Roll & Play is a modular, open-source RPG engine for Discord that brings interactive character sheets, NPC management, dice rolling, combat calculations, inventories, skills, pets, and private campaign notes directly into a server. Built with Python and discord.py, it supports multiple tabletop RPG systems through reusable rules, interactive interfaces, and localized commands for players and Game Masters.
Semantic Contract Model
Raygon — Semantic Contracts for Explicit Software Evolution
Raygon is a language-independent semantic contract model that makes dependencies, consumer intent, compatibility, and software evolution explicit. Its projection-based approach allows each consumer to declare exactly which contract fields it depends on, localizing the impact of change and preserving semantic history over time.