feat(context): add semantic handshake gate [Story 483.1] - #717
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds a deterministic SemanticHandshakeEngine that derives and stores planning constraints, validates proposed code (no LLM calls), produces compliance reports/correction prompts, and a ChangesSemantic Handshake Engine and Verification Gate
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📊 Coverage ReportCoverage report not available
Generated by PR Automation (Story 6.1) |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
.aiox-core/core/synapse/context/index.js (1)
12-12: ⚡ Quick winUse absolute import style for the new semantic-handshake export.
Line 12 adds a relative import, which diverges from the repository rule for JS/TS files.
🔧 Proposed fix
'use strict'; +const path = require('path'); const contextTracker = require('./context-tracker'); const contextBuilder = require('./context-builder'); const hierarchicalContext = require('./hierarchical-context-manager'); -const semanticHandshake = require('./semantic-handshake-engine'); +const semanticHandshake = require(path.resolve(__dirname, './semantic-handshake-engine.js'));As per coding guidelines, Use absolute imports instead of relative imports in all code.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.aiox-core/core/synapse/context/index.js at line 12, The file index.js uses a relative require for semanticHandshake (const semanticHandshake = require('./semantic-handshake-engine')), violating the repo rule to use absolute imports; update that require to the absolute module path used by the project (e.g., require('core/synapse/context/semantic-handshake-engine') or the repo's configured root alias) so the semanticHandshake import follows the absolute-import convention.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.aiox-core/core/ids/gates/g5-semantic-handshake.js:
- Around line 32-39: The persistent SemanticHandshakeEngine instance
(this._engine) is being mutated by _registerContextConstraints during each
_doVerify run, causing constraints to leak between verifications; modify
_doVerify to avoid mutating the long-lived this._engine by creating a temporary
engine instance for each verification (e.g., clone or instantiate a new
SemanticHandshakeEngine using the base engine's configuration/constraints and
then apply context constraints) or ensure _registerContextConstraints returns a
new constraints array rather than pushing into this._engine; update references
to use the temp engine for the verification process (keeping this._engine
unchanged) and preserve backward compatibility by deriving the new engine from
the original this._engine/SemanticHandshakeEngine configuration.
In @.aiox-core/core/synapse/context/semantic-handshake-engine.js:
- Around line 260-265: The normalization code in the semantic-handshake engine
(the block computing const id = String(input.id || input.description)... ) can
produce an empty string (e.g., input.description === '---'), leading to silent
collisions in this._constraints; update the public API path that adds
constraints (where this normalization runs) to validate the normalized id and
reject the input if id === '' (throw a clear Error or return a rejection), so
the method that uses this normalization never inserts a constraint with an empty
key into this._constraints.
- Around line 425-433: In validateExecutionIntent, the call to
constraint.validator can throw and currently bubbles out; wrap the await
constraint.validator(...) call in a try/catch inside validateExecutionIntent,
and on catch construct a validator-result shaped object (e.g., mark as invalid
and include a single violation with type like "validator-error" and
message/details from the caught error) then pass that object to
this._normalizeValidatorResult(...) (still using
this._publicConstraint(constraint) for context); ensure the catch preserves
useful error context (error.message and stack) when creating the violation so
downstream logic receives a deterministic compliance result instead of an
exception.
---
Nitpick comments:
In @.aiox-core/core/synapse/context/index.js:
- Line 12: The file index.js uses a relative require for semanticHandshake
(const semanticHandshake = require('./semantic-handshake-engine')), violating
the repo rule to use absolute imports; update that require to the absolute
module path used by the project (e.g.,
require('core/synapse/context/semantic-handshake-engine') or the repo's
configured root alias) so the semanticHandshake import follows the
absolute-import convention.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7fcb60d9-4e0e-4a85-a80d-5ddb00a58a8b
📒 Files selected for processing (10)
.aiox-core/core/ids/gates/g5-semantic-handshake.js.aiox-core/core/ids/index.js.aiox-core/core/synapse/context/README.md.aiox-core/core/synapse/context/index.js.aiox-core/core/synapse/context/semantic-handshake-engine.js.aiox-core/install-manifest.yamldocs/stories/epic-483-semantic-handshake/EPIC-483-SEMANTIC-HANDSHAKE.mddocs/stories/epic-483-semantic-handshake/STORY-483.1-SEMANTIC-HANDSHAKE-CONTRACT-GATE.mdtests/core/ids/semantic-handshake-gate.test.jstests/synapse/semantic-handshake-engine.test.js
ed51ece to
be17cc6
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/stories/epic-483-semantic-handshake/EPIC-483-SEMANTIC-HANDSHAKE.md (1)
36-38: 💤 Low valueOptional: Consider varying the sentence structure in Non-Goals.
The three Non-Goals bullets all start with "Não". While this is grammatically correct, varying the sentence structure could improve readability. For example:
- "Não importar o protótipo TypeScript..."
- "A extração de restrições não deve depender de LLM..."
- "Evitar reabrir PRs antigos fechados..."
This is purely a stylistic suggestion and does not affect the clarity of the documentation.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/stories/epic-483-semantic-handshake/EPIC-483-SEMANTIC-HANDSHAKE.md` around lines 36 - 38, The three Non-Goals bullet points in the "Non-Goals" section all begin with "Não", making them repetitive; rewrite them to vary sentence structure while preserving meaning—for example change "Não importar o protótipo TypeScript do anexo como código de produção." to a phrasing like "Evitar importar o protótipo TypeScript do anexo como código de produção.", change "Não depender de LLM para extrair restrições no primeiro slice." to "A extração de restrições não deve depender de LLM no primeiro slice.", and change "Não reabrir PRs antigos fechados; usar apenas evidência e padrões úteis." to "Evitar reabrir PRs antigos fechados; usar apenas evidência e padrões úteis."; update the three bullet lines in the Non-Goals list accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@docs/stories/epic-483-semantic-handshake/EPIC-483-SEMANTIC-HANDSHAKE.md`:
- Around line 36-38: The three Non-Goals bullet points in the "Non-Goals"
section all begin with "Não", making them repetitive; rewrite them to vary
sentence structure while preserving meaning—for example change "Não importar o
protótipo TypeScript do anexo como código de produção." to a phrasing like
"Evitar importar o protótipo TypeScript do anexo como código de produção.",
change "Não depender de LLM para extrair restrições no primeiro slice." to "A
extração de restrições não deve depender de LLM no primeiro slice.", and change
"Não reabrir PRs antigos fechados; usar apenas evidência e padrões úteis." to
"Evitar reabrir PRs antigos fechados; usar apenas evidência e padrões úteis.";
update the three bullet lines in the Non-Goals list accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ade5ef1f-7023-4e5c-9a53-c8820c03bd17
📒 Files selected for processing (10)
.aiox-core/core/ids/gates/g5-semantic-handshake.js.aiox-core/core/ids/index.js.aiox-core/core/synapse/context/README.md.aiox-core/core/synapse/context/index.js.aiox-core/core/synapse/context/semantic-handshake-engine.js.aiox-core/install-manifest.yamldocs/stories/epic-483-semantic-handshake/EPIC-483-SEMANTIC-HANDSHAKE.mddocs/stories/epic-483-semantic-handshake/STORY-483.1-SEMANTIC-HANDSHAKE-CONTRACT-GATE.mdtests/core/ids/semantic-handshake-gate.test.jstests/synapse/semantic-handshake-engine.test.js
✅ Files skipped from review due to trivial changes (1)
- .aiox-core/core/synapse/context/README.md
🚧 Files skipped from review as they are similar to previous changes (7)
- .aiox-core/core/ids/index.js
- tests/synapse/semantic-handshake-engine.test.js
- .aiox-core/core/ids/gates/g5-semantic-handshake.js
- .aiox-core/core/synapse/context/index.js
- tests/core/ids/semantic-handshake-gate.test.js
- .aiox-core/install-manifest.yaml
- .aiox-core/core/synapse/context/semantic-handshake-engine.js
|
🎉 This PR is included in version 5.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Implements the first governed slice for issue #483: a deterministic Semantic Handshake contract engine plus a blocking IDS pre-execution gate.
SemanticHandshakeEngineunder SYNAPSE context runtime and exports it fromaiox-core/core/synapse/contextG5SemanticHandshakeGatefor@devpre-execution validation with blocker/warning semanticsRefs #483.
Validation
npm test -- --runTestsByPath tests/synapse/semantic-handshake-engine.test.js tests/core/ids/semantic-handshake-gate.test.jsnpm test -- --runTestsByPath tests/synapse/hierarchical-context-manager.test.js tests/core/ids/verification-gates.test.js tests/synapse/semantic-handshake-engine.test.js tests/core/ids/semantic-handshake-gate.test.jsnpx eslint .aiox-core/core/synapse/context/semantic-handshake-engine.js .aiox-core/core/ids/gates/g5-semantic-handshake.js tests/synapse/semantic-handshake-engine.test.js tests/core/ids/semantic-handshake-gate.test.jsnpm run validate:manifestnpm run lintnpm run typecheckSummary by CodeRabbit
New Features
Documentation
Tests