SDS-002: Semantic Core & DSL Management Service


sds: id: SDS-002 title: Semantic Core & DSL Management Service bounded_context: semantic-core satisfies_prds: [PRD-001, PRD-003] satisfies_adrs: [ADR-001, ADR-002] version: 1.1.0 status: approved owners: [“sea-core-team”] created: 2025-12-01 —

Addresses Requirements

MVP Status

MVP


Component Description

This service is responsible for managing the core DSL definitions and policies. It provides APIs for defining, validating, and retrieving semantic concepts and rules, ensuring a single source of truth for business semantics across the enterprise. It also includes a Policy Evaluator for automated enforcement.


Technical Details

Interfaces

Direction Description Format
Input DSL definitions YAML/JSON
Input SEA™ DSL policy statements Structured text
Output Validated SEA™ DSL JSON
Output Query results for semantic concepts JSON
Output Policy enforcement outcomes JSON

Protocols


Data Model

Refer to SDS-001: Data Model Schemas for:


API Specification

Endpoints

Endpoint Method Description
/dsl/define POST Define new DSL concept
/dsl/concepts GET Query semantic concepts
/policy/evaluate POST Evaluate SEA™ DSL policy against data

Request/Response

Define DSL Concept

1
2
3
4
5
6
7
8
POST /dsl/define
{
  "concept": {
    "name": "Customer",
    "type": "Entity",
    "attributes": {...}
  }
}

Evaluate Policy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
POST /policy/evaluate
{
  "policyId": "order-minimum-value",
  "data": {
    "orderId": "123",
    "totalValue": 5.00
  }
}

// Response
{
  "valid": false,
  "violations": [
    {
      "rule": "order-minimum-value",
      "message": "Order total must be at least $10"
    }
  ]
}

Error Codes

Code Description
400 Bad Request Invalid SEA™ DSL/Policy syntax
409 Conflict Semantic inconsistency with existing definitions

Dependencies

Dependency Type Version Justification
PostgreSQL Database 16.x Primary persistence layer
OPA Policy Engine 0.68.x SEA™ DSL Policy Engine runtime

Port Reference

This service integrates with the following hexagonal ports:

Port Location Purpose
PolicyEnginePort libs/skeleton/policy/ports Policy evaluation interface

The PolicyEnginePort provides:


Error Handling


Performance Considerations


Security Considerations


Testing Strategy


8. Semantic Authority Protocol

This section defines the versioning and synchronization contract that ensures downstream consumers (particularly the Isomorphic Semantic Compiler, SDS-027) operate on consistent semantic model snapshots.

8.1. Version Counter

Every mutation to the semantic model increments a monotonic version counter:

Field Type Description
semanticVersion integer Monotonically increasing, starts at 1
lastUpdated datetime Timestamp of last mutation

8.2. Versioned Query API

Endpoint Method Description
/dsl/version GET Returns current semanticVersion and lastUpdated
/dsl/concepts?version={v} GET Returns snapshot at version v (or 409 if stale)
/policy/evaluate?version={v} POST Evaluates policy against version v model

Stale Query Behavior:

8.3. Change Notification Events

On every semantic model mutation, emit:

1
2
3
4
5
6
7
8
9
10
11
{
  "type": "governance.semantic-model.updated",
  "source": "//core/semantic-registry",
  "data": {
    "previousVersion": 5,
    "currentVersion": 6,
    "changedConcepts": ["Customer", "Order"],
    "changedPolicies": ["order-minimum-value"],
    "timestamp": "2025-12-31T10:00:00Z"
  }
}

8.4. Consumer Contract

Downstream services (e.g., SDS-027 Isomorphic Semantic Compiler) MUST:

  1. Query with explicit version parameter
  2. Subscribe to governance.semantic-model.updated for cache invalidation
  3. Include semanticVersion in output provenance for audit trail