Knowledge Graph SOP

Standard Operating Procedure for querying and maintaining the SEA-Forge™ Knowledge Graph using SPARQL and SHACL.


Purpose

Query semantic concepts, validate relationships, and maintain ontology integrity using the DomainForge™ Knowledge Graph.


When to Use


Process

Phase 1: Query Planning

Input: Information need

Steps:

  1. Identify query goal (find concept, validate existence, discover relationships)
  2. Determine required triples (subject-predicate-object)
  3. Choose query type (SELECT, ASK, CONSTRUCT, DESCRIBE)

Output: Query skeleton


Phase 2: Query Execution

Input: SPARQL query

Steps:

  1. Execute via Knowledge Graph Service API
  2. Handle pagination if result set large
  3. Parse results (JSON or Turtle format)

Output: Query results


Phase 3: Result Interpretation

Input: Query results

Steps:

  1. Validate result structure
  2. Extract relevant information
  3. Check for empty results (concept not found)

Output: Interpreted semantic data


Phase 4: Validation (If Updating)

Input: Proposed changes

Steps:

  1. Check SHACL shapes
  2. Validate constraints
  3. Ensure no duplicate concepts

Output: Validated changes or error report


Phase 5: Update (If Modifying)

Input: Validated changes

Steps:

  1. Create UPDATE query (SPARQL 1.1)
  2. Execute transaction
  3. Verify change applied

Output: Updated Knowledge Graph


Common Query Patterns

1. Validate ConceptId Exists

1
2
3
4
5
PREFIX sea: <http://sea-forge.org/ontology#>

ASK {
  sea:BoundedContext a sea:Concept .
}

Result: true or false


2. Find All Concepts in Namespace

1
2
3
4
5
6
7
8
9
PREFIX sea: <http://sea-forge.org/ontology#>

SELECT ?concept ?label ?description
WHERE {
  ?concept a sea:Concept ;
           rdfs:label ?label ;
           sea:description ?description .
}
ORDER BY ?label

1
2
3
4
5
6
7
PREFIX sea: <http://sea-forge.org/ontology#>

SELECT ?related ?relationship
WHERE {
  sea:Deployment ?relationship ?related .
  ?related a sea:Concept .
}

4. Find Concept Hierarchy

1
2
3
4
5
6
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?child ?parent
WHERE {
  ?child rdfs:subClassOf ?parent .
}

5. Check SHACL Constraints

1
2
3
4
5
6
7
8
9
10
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX sea: <http://sea-forge.org/ontology#>

SELECT ?shape ?constraint ?message
WHERE {
  ?shape a sh:NodeShape ;
         sh:targetClass sea:Artifact ;
         sh:property ?constraint .
  ?constraint sh:message ?message .
}

Example Workflow: Semantic Anchoring

Goal

Validate semantic references in cognitive artifact before generation.

Steps

  1. Extract conceptIds from artifact definition: ```yaml semanticRefs:
  2. Query Knowledge Graph:
    1
    2
    3
    4
    5
    6
    7
    
    PREFIX sea: <http://sea-forge.org/ontology#>
    
    ASK {
      { sea:Deployment a sea:Concept . }
      UNION
      { sea:QualityGate a sea:Concept . }
    }
    
  3. Validate result:
    1
    2
    3
    4
    5
    6
    7
    
    PREFIX sea: <http://sea-forge.org/ontology#>
    
    SELECT ?concept ?exists
    WHERE {
      VALUES ?concept { sea:Deployment sea:QualityGate }
      OPTIONAL { ?concept a sea:Concept . BIND(true AS ?exists) }
    }
    
  4. Handle missing concepts:

Maintenance Tasks

Add New Concept

1
2
3
4
5
6
7
8
9
PREFIX sea: <http://sea-forge.org/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

INSERT DATA {
  sea:NewConcept a sea:Concept ;
                 rdfs:label "New Concept" ;
                 sea:description "Description of new concept" ;
                 rdfs:subClassOf sea:ParentConcept .
}
1
2
3
4
5
PREFIX sea: <http://sea-forge.org/ontology#>

INSERT DATA {
  sea:Concept1 sea:relatedTo sea:Concept2 .
}

Validate Ontology

1
2
3
4
5
6
7
# Run SHACL validation
curl -X POST http://localhost:8080/api/validate \
  -H "Content-Type: application/json" \
  -d '{
    "shapes": "@prefix ...",
    "data": "@prefix ..."
  }'

Quality Gates