Schema: robos:CodeSnippet
Formal W3C SHACL constraint shape and OSLC JSON-LD specification for robos:CodeSnippet in the documentation package store.
Table of contents
- Specification Metadata
- Upstream Schema Basis (Refers From) & Global Standards Provenance
- Entity Relationship & Schema Context
- Property Constraints & SHACL Rules
- Canonical OSLC JSON-LD Example
- Programmatic SHACL Validation
Specification Metadata
- RDF / OWL Class:
robos:CodeSnippet - Aliases / Target Classes:
robos:CodeSnippet,robos:CodeSample - SHACL Shape ID:
urn:robos:shape:CodeSnippetShape - Governing Package: Documentation & Diagrams (robos.docs) (
documentation) - Namespace:
robos.docs - Schema.org Classification: https://schema.org/SoftwareSourceCode
- Domain De Facto Standard: https://schema.org/SoftwareSourceCode
- Upstream Schema Basis (Refers From): https://schema.org/SoftwareSourceCode
Upstream Schema Basis (Refers From) & Global Standards Provenance
This RobOS schema is modeled after and directly aligns with two levels of global standards:
- Universal Schema.org Class: https://schema.org/SoftwareSourceCode (100% interoperability with search engines, web indexers, and general AI reasoning)
- Specialized Domain Standard: https://schema.org/SoftwareSourceCode (de facto standard for domain-specific ALM, BDD, or infrastructure operations)
- Canonical Reference: https://schema.org/SoftwareSourceCode
- Agent Guidelines: When autonomous agents generate, expand, or validate instances of
robos:CodeSnippet, they MUST adhere to and base their output on this referred schema object and universal Schema.org parent class, extending it with RobOS SDLC properties.
Entity Relationship & Schema Context
Code Snippet robos:CodeSnippet
Governed by W3C SHACL shape urn:robos:shape:CodeSnippetShape within the Documentation & Diagrams (robos.docs) (robos.docs) package store.
dcterms:title robos:language robos:code Property Constraints & SHACL Rules
| Property Path | Name | Multiplicity | Data Type | Constraint Rule / Validation Message |
|---|---|---|---|---|
dcterms:title | Title / Display Name | 1..* | xsd:string | Code Snippet must have a title. |
robos:language | Programming Language | 1..* | xsd:string | Code Snippet must specify a programming language. |
robos:code | Source Code Content | 1..* | xsd:string | Code Snippet must provide source code text. |
Canonical OSLC JSON-LD Example
{
"@id": "urn:robos:snippet:shacl-custom-validation",
"@type": [
"oslc_am:Resource",
"robos:CodeSnippet",
"robos:CodeSample",
"schema:SoftwareSourceCode"
],
"dcterms:title": "SHACL Custom Shape Programmatic Validation",
"robos:language": "javascript",
"robos:code": "const { SHACLValidator } = require('robos-graph');\nconst validator = new SHACLValidator();\nconst report = validator.validate(graphStore.parser);\nconsole.log('Conforms:', report.conforms);",
"dcterms:description": "Canonical example of running in-memory SHACL validation against a parsed OSLC knowledge graph.",
"robos:package": "documentation",
"robos:namespace": "robos.docs",
"robos:schemaOrgType": "https://schema.org/SoftwareSourceCode",
"robos:domainStandard": "https://schema.org/SoftwareSourceCode"
}
Programmatic SHACL Validation
const { SHACLValidator } = require('/usr/local/share/robos/robos-graph/lib/shacl-validator');
const { OSLCGraphParser, OSLC_CONTEXT } = require('/usr/local/share/robos/robos-graph/lib/oslc-parser');
const validator = new SHACLValidator();
const result = validator.validateGraph(new OSLCGraphParser({
"@context": OSLC_CONTEXT,
"robos:nodes": [
{
"@id": "urn:robos:snippet:shacl-custom-validation",
"@type": [
"oslc_am:Resource",
"robos:CodeSnippet",
"robos:CodeSample",
"schema:SoftwareSourceCode"
],
"dcterms:title": "SHACL Custom Shape Programmatic Validation",
"robos:language": "javascript",
"robos:code": "const { SHACLValidator } = require('robos-graph');\nconst validator = new SHACLValidator();\nconst report = validator.validate(graphStore.parser);\nconsole.log('Conforms:', report.conforms);",
"dcterms:description": "Canonical example of running in-memory SHACL validation against a parsed OSLC knowledge graph.",
"robos:package": "documentation",
"robos:namespace": "robos.docs",
"robos:schemaOrgType": "https://schema.org/SoftwareSourceCode",
"robos:domainStandard": "https://schema.org/SoftwareSourceCode"
}
],
}));
console.log("Conforms:", result.conforms); // Expected: true