Implementation Plan: SEA-DSL Toolchain

Build the SEA-DSL parsing, validation, formatting, and compilation toolchain with IDE/LSP support, ensuring deterministic AST → IR → Manifest output and strict flow annotation contracts.

Provenance & Traceability

Architectural Decisions (ADRs)

ADR ID Decision Title Impact on This Plan
ADR-004 Semantic Core Formalization SEA-DSL is the canonical source of semantics.
ADR-023 SEA-DSL Policy Shift SBVR is historical/import-only; SEA-DSL is runtime.
ADR-012 Delivery Pipeline Toolchain is the front-end of the spec → code pipeline.
ADR-017 MCP-LSP Integration Architecture LSP hover/diagnostics are authoritative semantic probes.

Product Requirements (PRDs)

PRD ID Requirement Title Satisfied By (SDS) Acceptance Criteria
PRD-001 Unified Business Semantics SDS-002 DSL parsing + validation
PRD-002 Automated Rule Enforcement SDS-002 Policy validation + evaluation

Software Design Specifications (SDS)

SDS ID Service/Component Bounded Context SEA-DSL Spec File Implementation Status
SDS-002 Semantic Core DSL Service semantic-core N/A MVP (doc)
SDS-027 Isomorphic Semantic Compiler shared N/A Proposed

Provenance Chain

graph TD
  ADR4[ADR-004: Semantic Core] --> PRD1[PRD-001: Unified Semantics]
  ADR23[ADR-023: SEA-DSL Policy Shift] --> PRD2[PRD-002: Rule Enforcement]
  PRD1 --> SDS2[SDS-002: DSL Service]
  PRD2 --> SDS2

Architecture and Design

Design Principles Applied

Dependency Justification

Updated 2025-12-30: Added specific dependencies from gap analysis section 1.2 (SEA-DSL Parsing & Compilation).

Dependency Type Version NPM/PyPI Package Justification ADR/SDS Reference
Tree-sitter Parser Framework 0.24.x tree-sitter, tree-sitter-cli (Node); tree-sitter (Python) High-performance incremental parser for SEA-DSL grammar. Enables IDE-grade parse performance. ADR-004, SDS-002
SEA™ Grammar Custom N/A Custom tree-sitter grammar in tools/grammars/sea/ Define .sea file syntax for parsing into AST. ADR-004, REF-001
Babel Traverse Node.js Library 7.x @babel/traverse, @babel/types Navigate and transform parsed AST nodes using visitor pattern. Developer Tooling REF-001
OPA (Rego) Policy Engine 0.70.x @open-policy-agent/opa-wasm (Node); opa (CLI binary) Execute SEA-DSL policies at runtime. Deterministic policy evaluation. SDS-002, ADR-028

Installation Commands

1
2
3
4
5
6
7
8
# Node.js dependencies
pnpm add tree-sitter tree-sitter-cli @babel/traverse @babel/types @open-policy-agent/opa-wasm

# Python dependencies (in pyproject.toml)
pip install tree-sitter

# OPA CLI (via mise)
mise use opa@0.70.0

SEA-DSL Parsing Pipeline

1
2
3
4
5
6
7
8
9
10
11
// SEA-DSL Parser Port
interface SeaDslParserPort {
  parse(source: string): Promise<SeaAst>;
  validate(ast: SeaAst): Promise<ValidationReport>;
}

// Policy Evaluator Port (wraps OPA)
interface PolicyEvaluatorPort {
  evaluatePolicy(policyId: string, input: object): Promise<PolicyResult>;
  compileRego(regoSource: string): Promise<CompiledPolicy>;
}

Existing Toolchain Components

Expected Filetree

1
2
3
4
5
6
/
├── tools/flow_lint.py
├── tools/ast_to_ir.py
├── tools/schemas/ast-v3.schema.json
├── tools/schemas/sea_ir.schema.json
└── docs/reference/sea_dsl_language_reference.yml

Proposed Cycles

Cycle Branch Wave Files Modified Files Created Specs Implemented
C1A cycle/p015-c1a-dsl-contract 1 docs/reference/sea_dsl_language_reference.yml Grammar and idioms
C1B cycle/p015-c1b-ast-lint 1 tools/flow_lint.py, tools/schemas/ast-v3.schema.json Flow annotation contract
C2A cycle/p015-c2a-ide-support 2 docs/specs/shared/sds/041-ultimate-lsp-hover-specification.md LSP hover + diagnostics

Task Breakdown

Wave 1 (Parallel)

Wave 2 (Depends on Wave 1)


Validation & Verification

Spec Validation

Implementation Validation


Open Questions

  1. Should ast_to_ir.py reject dotted annotation keys entirely (to match the “nested JSON only” rule)? Reject entirely
  2. Where is the canonical formatter spec for SEA-DSL (and should it be enforced in CI)? sea_dsl_language_reference.yml + CI
  3. Is LSP a separate binary or embedded in an editor extension for MVP? Embedded in extension (MVP)

Risks & Mitigation

Risk Likelihood Impact Mitigation Strategy
Authoring friction due to strict annotations Medium Medium Provide examples + editor hints; allow warn-only mode temporarily.
Schema/tool mismatch Medium High Treat schemas as canonical; update docs + tests together.

Rollback Strategy

  1. Run lint in warn-only mode while updating legacy specs, then re-enable strict mode.

Linked Specifications

Type ID/Doc Document
ADR ADR-004 docs/specs/shared/adr/004-semantic-core-formalization.md
ADR ADR-023 docs/specs/shared/adr/023-sea-dsl-policy-shift.md
PRD PRD-001 docs/specs/semantic-core/prd/001-unified-business-semantics.md
PRD PRD-002 docs/specs/semantic-core/prd/002-automated-rule-enforcement.md
SDS SDS-002 docs/specs/semantic-core/sds/002-semantic-core-dsl-service.md
SDS SDS-052 docs/specs/shared/sds/052-semantic-tooling-ide-integration.md

Note: SDS-041 (Ultimate LSP Hover) has been superseded by SDS-052 per ADR-017.