This specification defines the Qualia SHACL Extension Vocabulary, a set of SHACL (Shapes Constraint Language) extensions for validating configuration parameters across the Qualia Protocol Ecosystem. These extensions provide constraints for client features, specialized libraries, core modalities, and infrastructure components, ensuring data integrity, security, and regulatory compliance across distributed semantic graph operations.

This document is an editor's draft and does not carry the endorsement of any standards body. It is intended for review and feedback within the Qualia Protocol Ecosystem community.

Introduction

SHACL (Shapes Constraint Language) is a W3C recommendation for validating RDF graphs against shapes. The Qualia Protocol Ecosystem extends SHACL with domain-specific constraints for scientific computing, financial modeling, medical data processing, and quantum computing operations.

Motivation

Standard SHACL provides general-purpose constraint mechanisms but lacks domain-specific validations needed for:

Scope

This specification defines SHACL extension constraints for four major categories:

  1. Client Features (13 constraint types) - Logging, system tray, settings
  2. Specialized Libraries (30+ constraint types) - Linear algebra, ML, physics, chemistry, medical, financial, engineering, statistics, cryptography, QPU, quantum biology
  3. Core Modalities (30+ constraint types) - Epistemic, paraconsistent, temporal LTL, spatio-temporal, graph theory, calculus, argumentation, dialectical, ASP, probabilistic, DL, diffusion
  4. Legal-Logic Stack (42 configuration shapes, logic_modalities_shacl.rs) - the computational legal-logic surface (legal_logic.md §1–§30): SDL⁺ deontic lifecycle & extensions, the Hohfeldian jural square, STIT agency, mens rea, causal/but-for, responsibility (allegation→adjudication), juridical capacity, delegation chains, contract formation, value-flow, capability gap, resilient identity, ZK-gate, proportionality, sense-translation, consensus, manifold logic, carrier binding, systemic meta-guard. One q42:<Name>ConfigurationShape per modality, gated by an engine↔SHACL completeness test.
  5. Infrastructure (20 constraint types) - Domains, obfuscation, solvers, geometric algebra

A conforming implementation MUST:

The following terms are used in this specification:

Constraint Type
A SHACL shape definition that validates specific configuration parameters
SlgOpcode
A low-level operation code for the SLG (Semantic Logic Graph) Virtual Machine
Severity Level
The classification of constraint violations: Violation (critical), Warning (non-critical), Info (informational)
Opcode Generation
The process of converting high-level SHACL constraints into executable SlgOpcode sequences

Client Feature Constraints

Client feature constraints validate parameters for the Qualia Client application including logging, system tray, and settings.

Logging System Constraints

q42:LogConfiguration

Validates logging system configuration parameters.

PropertyTypeRangeDescription
maxMemoryLogsxsd:integer1-100,000Maximum logs in memory
maxDiskLogsxsd:integer1-1,000,000Maximum logs on disk
flushIntervalMsxsd:integer100-60,000Buffer flush interval (ms)

Severity: Violation for limits, Warning for flush interval

q42:LogLevel

Validates log level enumeration values.

Allowed Values: DEBUG, INFO, WARN, ERROR, CRITICAL

Severity: Violation

q42:LogEntry

Validates individual log entry structure.

PropertyTypeRequirement
timestampxsd:dateTimeRequired, minCount=1
levelxsd:stringRequired, minCount=1
messagexsd:stringRequired, maxLength=10,000
contextxsd:stringOptional, maxLength=100

Severity: Violation for required fields, Warning for length limits

System Tray Constraints

q42:SystemTrayConfiguration

Validates system tray menu configuration.

PropertyTypeRange
maxMenuItemsxsd:integer1-20
requireSeparatorLogicxsd:booleanBoolean flag
allowNestedMenusxsd:booleanBoolean flag

q42:TrayMenuItem

Validates individual system tray menu items.

PropertyTypeRange
labelxsd:stringRequired, maxLength=50
actionxsd:stringRequired
iconxsd:stringOptional

Enhanced Settings Constraints

q42:StorageConfiguration

Validates storage path and quota settings.

PropertyTypeRange
storagePathxsd:stringRequired, pattern="^[/\\]"
storageQuotaGbxsd:integer1-1,000

Security: Pattern validation prevents directory traversal

q42:NetworkConfiguration

Validates daemon network settings.

PropertyTypeRange
daemonPortxsd:integer1,024-65,535
daemonHostxsd:stringlocalhost, 127.0.0.1, 0.0.0.0, ::1

Security: Host addresses restricted to safe values

q42:TaxRecipientConfiguration

Validates ILP tax recipient configuration.

PropertyTypeRange
ilpAddressxsd:stringRequired, pattern="^\\$ilp."
sharePercentxsd:integer0-100

Security: ILP address validation prevents payment routing errors

q42:SecurityConfiguration

Validates security-related settings.

PropertyTypeRange
minKeyLengthBitsxsd:integer128-4,096
requireEncryptionxsd:booleanBoolean flag

Security: Minimum key length ensures adequate encryption strength

Specialized Library Constraints

Specialized library constraints validate parameters for scientific and engineering libraries including linear algebra, machine learning, physics simulation, chemistry modeling, medical computing, financial modeling, engineering analysis, statistical computing, cryptographic library, QPU bridge, and quantum biology.

Linear Algebra Constraints

q42:MatrixConfiguration

Validates matrix storage and computation configuration.

PropertyTypeRange
maxMatrixSizexsd:integer1-1,000,000
maxZoneCapacityxsd:integer1KB-1TB
allowedZoneTypesxsd:stringDense, Sparse, Structured, Temporary

Safety: Numerical stability enforced via condition number limits

Machine Learning Constraints

q42:ModelConfiguration

Validates ML model configuration.

PropertyTypeRange
maxModelSizeMbxsd:integer1-100,000
maxParametersxsd:integer1-10,000,000,000

q42:TrainingConfiguration

Validates training hyperparameters.

PropertyTypeRange
maxEpochsxsd:integer1-10,000
learningRateRangexsd:float0.0-1.0

Physics Simulation Constraints

q42:SimulationConfiguration

Validates physics simulation configuration.

PropertyTypeRange
maxTimeStepsxsd:integer1-1,000,000,000
maxCflNumberxsd:float≤ 1.0

Safety: CFL number ≤ 1.0 ensures numerical stability

Chemistry Modeling Constraints

q42:MoleculeConfiguration

Validates molecular structure configuration.

PropertyTypeRange
maxAtomsxsd:integer1-10,000
requireValenceSatisfactionxsd:booleanBoolean flag

Safety: Valence satisfaction ensures chemically valid structures

q42:ReactionConfiguration

Validates chemical reaction parameters.

PropertyTypeRange
requireMassBalancexsd:booleanBoolean flag
requireChargeBalancexsd:booleanBoolean flag

Safety: Mass and charge balance ensure physical realism

Medical Computing Constraints

q42:MedicalDataConfiguration

Validates medical data parameters.

PropertyTypeRequirement
requireHipaaCompliancexsd:booleanRequired
requireDeIdentificationxsd:booleanRequired
allowedDataTypesxsd:stringFHIR, DICOM, HL7

Compliance: HIPAA compliance requirements enforced

q42:ClinicalDecisionConfiguration

Validates clinical decision support parameters.

PropertyTypeRange
requireEvidenceBasedxsd:booleanBoolean flag
requirePhysicianReviewxsd:booleanBoolean flag

Safety: Evidence-based and physician oversight requirements

q42:MedicalImagingConfiguration

Validates medical imaging parameters.

PropertyTypeRange
requireDicomCompliancexsd:booleanBoolean flag
allowedModalitiesxsd:stringMRI, CT, X-ray, ultrasound

Compliance: DICOM compliance enforcement

Financial Modeling Constraints

q42:FinancialModelConfiguration

Validates financial model parameters.

PropertyTypeRange
maxLeverageRatioxsd:float0-100
maxTimeHorizonDaysxsd:integer1-36,500 (100 years)

Risk Management: Leverage and time horizon limits enforced

q42:RiskCalculation

Validates risk calculation parameters.

PropertyTypeRange
confidenceLevelRangexsd:float0.9-0.999
maxLookbackDaysxsd:integer1-3,650 (10 years)

Cryptographic Library Constraints

q42:CryptographicConfiguration

Validates cryptographic operation parameters.

PropertyTypeRange
minKeyLengthBitsxsd:integer128-4,096
allowedAlgorithmsxsd:stringAES, RSA, ECC, SHA256, Ed25519

Security: Key length requirements and algorithm validation

q42:KeyManagementConfiguration

Validates key management parameters.

PropertyTypeRange
maxKeyLifetimeDaysxsd:integer1-3,650 (10 years)
requireKeyRotationxsd:booleanBoolean flag

Security: Key rotation and lifetime management

QPU Bridge Constraints

q42:QPUConfiguration

Validates quantum processing unit parameters.

PropertyTypeRange
maxQubitsxsd:integer1-10,000
maxCircuitDepthxsd:integer1-100,000

Core Modality Constraints

Core modality constraints validate parameters for logical reasoning modalities including epistemic logic, paraconsistent logic, temporal LTL, spatio-temporal reasoning, graph theory, calculus, argumentation, dialectical logic, ASP, probabilistic reasoning, description logic, diffusion, linear logic, control feedback, and interval reasoning.

Epistemic Logic Constraints

q42:EpistemicConfiguration

Validates epistemic reasoning parameters.

PropertyTypeRange
maxCertaintyxsd:unsignedByte0-255
maxNestingDepthxsd:unsignedByte≤ 10 (RDF-Star depth)
maxAgentContextsxsd:integer1-1,000

Temporal LTL Constraints

q42:LTLConfiguration

Validates temporal LTL formula parameters.

PropertyTypeRange
maxTraceLengthxsd:integer1-1,000,000
maxFormulaDepthxsd:unsignedByte≤ 20
allowedOperatorsxsd:stringG, F, X, U, R

Graph Theory Constraints

q42:GraphConfiguration

Validates graph structure parameters.

PropertyTypeRange
maxNodesxsd:integer1-10,000,000
maxEdgesxsd:integer0-100,000,000
maxNodeDegreexsd:integer1-100,000

Calculus Constraints

q42:CalculusConfiguration

Validates numerical integration parameters.

PropertyTypeRange
maxGridPointsxsd:integer1-1,000,000,000
maxIntegrationStepsxsd:integer1-100,000,000

q42:ODEConfiguration

Validates ODE solver parameters.

PropertyTypeRange
maxOdeOrderxsd:unsignedByte≤ 10
maxStepSizexsd:float1e-15 - 1.0
minStepSizexsd:float1e-15 - 1.0

Computational Mathematics Constraints

The computational-mathematics engine — units & dimensional analysis, number theory, special functions, interpolation, integral transforms, vector calculus, arbitrary-precision exact arithmetic, the symbolic CAS, and general-dimension numerical methods — carries a SHACL q42:*ConfigurationShape per capability. Each shape bounds the capability's resource parameters (compiled to a bounded Vec<SlgOpcode> at config time, off the hot path) and restricts its operation set with sh:in. Namespace q42: <https://webizen.org/q42#>. The normative shapes are emitted by get_computational_maths_shacl_ttl() in crates/qualia-core-db/src/modalities/logic/computational_maths_shacl.rs (mirrors the in-browser computational engine — see the Computational Engine demo).

q42:UnitsConfigurationShape

Bounds SI dimensional analysis and the supported unit systems.

PropertyTypeRange / values
q42:dimensionComponentsxsd:integer1 – 7 (SI base-dimension vector)
q42:allowedUnitSystemssh:insi | cgs | imperial

q42:NumberTheoryConfigurationShape

Bounds number-theory input size and the supported primitives.

PropertyTypeRange / values
q42:maxInputBitsxsd:integer1 – 4096
q42:allowedOperationssh:inprimality | factorization | gcd | totient | modular | combinatorics

q42:SpecialFunctionConfigurationShape

Bounds series truncation and the supported special-function families.

PropertyTypeRange / values
q42:maxSeriesTermsxsd:integer1 – 100,000
q42:allowedFamiliessh:inbessel | airy | zeta | legendre | chebyshev | hermite | laguerre

q42:InterpolationConfigurationShape

Bounds interpolation node count and the supported methods.

PropertyTypeRange / values
q42:maxNodesxsd:integer2 – 1,000,000
q42:allowedMethodssh:inlagrange | newton | cubic_spline | least_squares

q42:IntegralTransformConfigurationShape

Bounds transform sample count and the supported transforms.

PropertyTypeRange / values
q42:maxSamplesxsd:integer2 – 16,777,216
q42:allowedTransformssh:indft | laplace | ztransform

q42:VectorCalculusConfigurationShape

Bounds the spatial dimension and the supported differential/integral operators.

PropertyTypeRange / values
q42:maxSpatialDimensionxsd:integer2 – 3 (2-D / 3-D fields)
q42:allowedOperatorssh:ingradient | divergence | curl | laplacian | line_integral | surface_integral

q42:ExactArithmeticConfigurationShape

Bounds arbitrary-precision digit count and the supported exact types.

PropertyTypeRange / values
q42:maxDigitsxsd:integer1 – 1,000,000
q42:allowedTypessh:inbigint | bigrational

q42:SymbolicCalculusConfigurationShape

Bounds the symbolic CAS order and the supported symbolic operations.

PropertyTypeRange / values
q42:maxOrderxsd:integer1 – 1024
q42:allowedOperationssh:inintegrate | series | limit | solve | ode_solve | pde_classify | gradient | jacobian | hessian

q42:AssumptionConfigurationShape

Keeps assumption-gated symbolic rewrites sound, and restricts the sign-assumption domain.

PropertyTypeRange / values
q42:requireSoundRewritexsd:booleantrue ⇒ rewrites must preserve soundness
q42:allowedSignssh:inpositive | nonnegative | negative | nonpositive | nonzero

q42:NumericalMethodConfigurationShape

Bounds the ODE state dimension and the supported general-dimension integrators.

PropertyTypeRange / values
q42:maxStateDimensionxsd:integer1 – 100,000
q42:allowedIntegratorssh:inrk4 | simpson | shooting_bvp

Infrastructure Constraints

Infrastructure constraints validate parameters for domain-specific engines, obfuscation, solvers, and geometric algebra.

Domain-Specific Constraints

q42:BiologicalDomainConfiguration

Validates biological domain parameters.

PropertyTypeRange
maxSequenceLengthxsd:integer1-1,000,000
allowedSequenceTypesxsd:stringDNA, RNA, protein

q42:ChemicalDomainConfiguration

Validates chemical domain parameters.

PropertyTypeRange
maxMolecularWeightxsd:float1-1,000,000 Da
maxAtomCountxsd:integer1-10,000

q42:FinancialDomainConfiguration

Validates financial domain parameters.

PropertyTypeRange
maxTransactionValuexsd:float0-1e15
requireComplianceCheckxsd:booleanBoolean flag

Compliance: Regulatory compliance requirements

Obfuscation Constraints

q42:ObfuscationConfiguration

Validates obfuscation parameters.

PropertyTypeRange
maxObfuscationDepthxsd:unsignedByte≤ 10
minEntropyBitsxsd:unsignedByte≥ 64

Security: Minimum entropy requirements for data privacy

q42:SemanticStripperConfiguration

Validates semantic stripping parameters.

PropertyTypeRange
allowedContextTypesxsd:stringClinical, financial, personal
requireAnonymityxsd:booleanBoolean flag

Privacy: Context stripping for sensitive data

Solver Constraints

q42:SolverConfiguration

Validates general solver parameters.

PropertyTypeRange
maxIterationsxsd:integer1-1,000,000
convergenceTolerancexsd:float1e-15 - 1.0
maxStepSizexsd:float1e-15 - 1.0

q42:QuantumOptimizerConfiguration

Validates quantum optimizer parameters.

PropertyTypeRange
maxQubitsxsd:unsignedShort≤ 1,000
requireErrorCorrectionxsd:booleanBoolean flag

Opcode Generation

All constraint types implement a to_opcodes() method that generates appropriate SlgOpcode sequences for validation in the SLG Virtual Machine.

impl ConstraintType {
    pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
        vec![
            SlgOpcode::CheckMaxInclusive(self.max_value as f64),
            SlgOpcode::CheckMinInclusive(self.min_value as f64),
        ]
    }
}

Common opcode types include:

Severity Levels

Constraints use three severity levels to classify validation failures:

Violation
Critical validation failure. Data is rejected and not processed. Used for security-critical validations, data integrity checks, and regulatory compliance requirements.
Warning
Non-critical issue. Data is accepted but a warning is logged. Used for configuration recommendations, deprecated features, and non-critical safety checks.
Info
Informational validation. No action required. Used for informational constraints and validation metadata.

Security Considerations

Medical Data Security

Medical computing constraints enforce HIPAA compliance through:

Financial Risk Management

Financial modeling constraints enforce risk management through:

Cryptographic Security

Cryptographic constraints enforce security through:

Scientific Computing Safety

Scientific computing constraints enforce safety through:

Implementation Considerations

Performance

Extensibility

References

Acknowledgements

This specification was developed by the Qualia Protocol Ecosystem community with contributions from the QualiaDB development team.