Repository navigation
[EPIC] Semantic Handshake: Closing the Context Drift Gap #483
Description
Activity
Boa epic @LorenzaVolponi. O context drift é um problema real em sessões longas. Nosso módulo de Decision Memory (#564) e Agent Reflection Engine (#565) já atacam parte desse problema — mantêm contexto cross-session e aprendem com decisões passadas. Junto com o Strategy Optimizer (#567), conseguimos reduzir drift significativamente. Se quiser alinhamos a implementação com essa epic.
A epic de Semantic Handshake é muito relevante para o context drift. Alguns dos nossos PRs tocam diretamente nesse problema:
- PR feat(memory): add decision-memory module for cross-session agent learning #564 (DecisionMemory) — persiste decisões entre sessões, reduzindo drift
- PR feat(memory): add Agent Reflection Engine for cross-session learning #565 (AgentReflectionEngine) — auto-avaliação detecta quando o agente está divergindo do objetivo
Se houver interesse, podemos criar um módulo específico de Semantic Handshake que integre esses dois componentes.
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed in 7 days if no further activity occurs.If this issue is still relevant, please leave a comment to keep it open.
Implemented and merged via PR #717 into main.\n\nEvidence:\n- Merge commit: 96d7f59\n- Added SemanticHandshakeEngine under SYNAPSE context runtime.\n- Added blocking G5SemanticHandshakeGate under IDS.\n- Added deterministic extraction for PostgreSQL, serverless local-state, absolute imports and no-eval constraints.\n- Added regression hardening from CodeRabbit: scoped gate engine clone, empty normalized id rejection, deterministic validator-error violations.\n- CI green: ESLint, TypeScript, Jest Node 18/20/22/24/25, manifest validation, story validation, semantic lint, compatibility parity, brownfield install, CodeQL, Coverage, CodeRabbit.\n\nClosing #483 as resolved.
🎯 The "Context Drift" Problem
Pedro validated that SYNAPSE handles context injection, and Claude handles compression. However, there is a gap between Intent Definition (Planning) and Intent Execution (Development).
When a story moves from @architect to @dev, constraints can be "compressed away" or ignored. The @dev might choose a library that contradicts the Architecture Doc simply because it was the path of least resistance.
🛠 Solution: The Semantic Handshake Protocol
A middleware layer that treats Architectural Decisions as Code, not just comments.
How it works:
Constraint Extraction: During Planning, the engine scans docs for "Hard Constraints" (Tech Stack, Security Patterns).
Intent Lock: These constraints are converted into executable validators (Assertions).
Pre-Execution Gate: Before @dev writes code, the engine runs a "Semantic Diff". If the code violates a constraint, the execution is blocked and a correction prompt is injected.
📈 Impact on AIOS
Zero Context Drift: Guarantees that "Serverless Architecture" in the PRD results in Serverless Code.
Automated Governance: The @architect gains "supervisory power" over the @dev without human intervention.
Trust: Stakeholders know that what was planned is exactly what is built.
Semantic Handshake.js