Skip to content

Latest commit

 

History

History
1077 lines (874 loc) · 24.1 KB

File metadata and controls

1077 lines (874 loc) · 24.1 KB

VeriSim Consonance Language (VCL) Examples

Table of Contents

1. Overview

This document provides 63 comprehensive examples of VCL queries and mutations for both dependent-type (formally verified) and slipstream (fast, unverified) paths, including backwards compatibility (VERSION), drift handling (DRIFT REPAIR), SQL-compatible extensions (ORDER BY, GROUP BY, HAVING, aggregates, column projections), multi-proof composition, cross-modal correlation conditions, and write path mutations (INSERT/UPDATE/DELETE).

2. Basic Queries

2.1. Example 1: Simple Octad Retrieval

Slipstream (no proof):

SELECT *
FROM HEXAD 550e8400-e29b-41d4-a716-446655440000

Dependent-Type (with proof):

SELECT *
FROM HEXAD 550e8400-e29b-41d4-a716-446655440000
PROOF EXISTENCE(ExistenceContract)

2.2. Example 2: Modality-Specific Selection

Graph Only:

SELECT GRAPH
FROM HEXAD 550e8400-e29b-41d4-a716-446655440000
WHERE (h)-[:CITES]->(target)

Vector Only:

SELECT VECTOR
FROM HEXAD 550e8400-e29b-41d4-a716-446655440000
WHERE h.embedding SIMILAR TO [0.1, 0.2, 0.3, 0.4]

Multiple Modalities:

SELECT GRAPH, VECTOR, SEMANTIC
FROM HEXAD 550e8400-e29b-41d4-a716-446655440000
PROOF INTEGRITY(DataIntegrityContract)

3. Graph Queries (Oxigraph)

3.1. Example 3: Citation Chain Traversal

Slipstream:

SELECT GRAPH
FROM FEDERATION /universities/*
WHERE (h)-[:CITES*1..5]->(paper)
  AND paper.title LIKE "%climate change%"
LIMIT 100

Dependent-Type:

SELECT GRAPH
FROM FEDERATION /universities/* WITH DRIFT STRICT
WHERE (h)-[:CITES*1..5]->(paper)
  AND paper.title LIKE "%climate change%"
  AND SATISFIES CitationContract
PROOF CITATION(CitationChainContract)
LIMIT 100

3.2. Example 4: Bidirectional Graph Traversal

SELECT GRAPH
FROM HEXAD abc12345-0000-0000-0000-000000000000
WHERE (h)-[:CO_AUTHOR]-(colleague)
  AND (colleague)-[:AFFILIATED_WITH]->(institution)
  AND institution.country == "USA"

3.3. Example 5: Property Graph Query

SELECT GRAPH
FROM STORE oxigraph-node-1
WHERE (author)-[:WROTE]->(paper)
  AND paper.citations > 100
  AND paper.year >= 2020
PROOF ACCESS(ReadAccessContract)

4. Vector Queries (Milvus)

4.1. Example 6: Similarity Search (ANN)

Slipstream:

SELECT VECTOR
FROM FEDERATION /embeddings/*
WHERE h.embedding SIMILAR TO [0.12, 0.45, 0.78, ...] WITHIN 0.8
LIMIT 10

Dependent-Type:

SELECT VECTOR
FROM FEDERATION /embeddings/* WITH DRIFT REPAIR
WHERE h.embedding SIMILAR TO [0.12, 0.45, 0.78, ...]
  WITHIN 0.9
  USING COSINE
  AND SATISFIES EmbeddingQualityContract(min_dimension=768)
PROOF INTEGRITY(VectorIntegrityContract)
LIMIT 20

4.2. Example 7: K-Nearest Neighbors

SELECT VECTOR
FROM HEXAD query-embedding-uuid
WHERE h.embedding NEAREST 15 USING DOT_PRODUCT
  AND h.metadata.domain == "neuroscience"
SELECT VECTOR, DOCUMENT
FROM FEDERATION /research-papers/*
WHERE h.embedding SIMILAR TO [0.5, 0.3, 0.2, ...]
  AND FULLTEXT CONTAINS "deep learning"
  AND h.year >= 2023
LIMIT 50

5. Semantic Queries (verisim-semantic + proven)

5.1. Example 9: ZKP-Verified Access

Dependent-Type:

SELECT SEMANTIC, DOCUMENT
FROM HEXAD confidential-data-uuid
WHERE SATISFIES AccessControlContract(role=researcher, institution=MIT)
  AND HAS PROOF ACCESS
PROOF ACCESS(InstitutionalAccessContract) WITH verifier=ethics-board

5.2. Example 10: Provenance Verification

Dependent-Type:

SELECT SEMANTIC, TEMPORAL
FROM FEDERATION /clinical-trials/*
WHERE SATISFIES ProvenanceContract
  AND VERIFIED BY fda-validator
  AND AS OF 2025-01-01T00:00:00Z
PROOF PROVENANCE(ClinicalTrialContract)

5.3. Example 11: Multi-Contract Validation

Dependent-Type:

SELECT *
FROM HEXAD research-dataset-uuid
WHERE SATISFIES GDPRContract(anonymized=true)
  AND SATISFIES FAIRContract(findable=true, accessible=true)
  AND SATISFIES LicenseContract(license=CC-BY-4.0)
PROOF CUSTOM(ComplianceContract) WITH auditor=legal-team

6. Document Queries (Tantivy)

Slipstream:

SELECT DOCUMENT
FROM FEDERATION /archives/*
WHERE FULLTEXT CONTAINS "quantum computing"
LIMIT 1000

Dependent-Type:

SELECT DOCUMENT
FROM FEDERATION /archives/* WITH DRIFT TOLERATE
WHERE FULLTEXT CONTAINS "quantum computing"
  AND SATISFIES CitationContract
PROOF EXISTENCE(ArchiveContract)
LIMIT 100

6.2. Example 13: Regex Pattern Matching

SELECT DOCUMENT
FROM STORE tantivy-node-3
WHERE FULLTEXT MATCHES /\b(AI|ML|DL)\b.*ethics/
  AND FIELD author == "Jane Doe"
  AND FIELD year >= 2020

6.3. Example 14: Structured Field Queries

SELECT DOCUMENT, SEMANTIC
FROM FEDERATION /journals/*
WHERE FIELD doi LIKE "10.1234/%"
  AND FIELD impact_factor >= 5.0
  AND SATISFIES PeerReviewContract

7. Tensor Queries (Burn/ndarray)

7.1. Example 15: Tensor Shape Filtering

SELECT TENSOR
FROM HEXAD tensor-data-uuid
WHERE tensor.data SHAPE == [256, 256, 3]
  AND tensor.dtype == "float32"

7.2. Example 16: Tensor Operations

SELECT TENSOR
FROM STORE burn-node-2
WHERE tensor.data RANK == 3
  AND tensor.statistics.mean > 0.5
  AND tensor.statistics.std < 0.2

8. Temporal Queries (verisim-temporal)

8.1. Example 17: Point-in-Time Query

Dependent-Type:

SELECT TEMPORAL, DOCUMENT
FROM HEXAD legal-document-uuid
WHERE AS OF 2024-06-15T10:30:00Z
PROOF PROVENANCE(TemporalContract)

8.2. Example 18: Version Range Query

SELECT TEMPORAL, GRAPH
FROM FEDERATION /contracts/*
WHERE BETWEEN 2024-01-01T00:00:00Z AND 2024-12-31T23:59:59Z
  AND MODIFIED BY legal-team

8.3. Example 19: Specific Version

Dependent-Type:

SELECT *
FROM HEXAD retracted-paper-uuid
WHERE VERSION v3-final
  AND SATISFIES RetractionContract(reason=error-in-methodology)
PROOF PROVENANCE(RetractionContract)

9. Multi-Modal Queries

9.1. Example 20: Neurosymbolic AI Query

Dependent-Type:

-- Find papers similar to embedding that cite a specific work
SELECT GRAPH, VECTOR, DOCUMENT
FROM FEDERATION /research-db/* WITH DRIFT REPAIR
WHERE h.embedding SIMILAR TO [0.1, 0.2, ...] WITHIN 0.85
  AND (h)-[:CITES]->(target_paper)
  AND target_paper.uuid == "123e4567-e89b-12d3-a456-426614174000"
  AND FULLTEXT CONTAINS "neural-symbolic integration"
  AND SATISFIES CitationContract
PROOF CITATION(NeurosymbolicContract)
LIMIT 50

9.2. Example 21: Cross-Modal Consistency Check

Dependent-Type:

-- Verify document content matches vector embedding
SELECT DOCUMENT, VECTOR, SEMANTIC
FROM HEXAD suspicious-entry-uuid
WHERE SATISFIES ConsistencyContract(
    vector_matches_text=true,
    semantic_alignment=high
  )
PROOF INTEGRITY(CrossModalContract)

9.3. Example 22: Federated Provenance Audit

Dependent-Type:

-- Audit trail across multiple institutions
SELECT TEMPORAL, SEMANTIC, GRAPH
FROM FEDERATION /universities/* WITH DRIFT STRICT
WHERE AS OF 2025-01-01T00:00:00Z
  AND (h)-[:DERIVED_FROM]->(source)
  AND VERIFIED BY institutional-review-board
  AND SATISFIES ProvenanceContract
  AND SATISFIES EthicsContract(irb_approved=true)
PROOF PROVENANCE(MultiInstitutionalContract) WITH auditor=nsf

10. Drift Handling Queries

10.1. Example 23: Strict Drift (Fail on Inconsistency)

Dependent-Type:

SELECT *
FROM FEDERATION /legal-records/* WITH DRIFT STRICT
WHERE AS OF 2024-01-01T00:00:00Z
PROOF INTEGRITY(LegalContract)

Behavior: Query fails if any node has drifted from the specified timestamp.

10.2. Example 24: Auto-Repair Drift

Dependent-Type:

SELECT GRAPH, DOCUMENT
FROM FEDERATION /collaborative-wiki/* WITH DRIFT REPAIR
WHERE (h)-[:LINKS_TO]->(target)
  AND FULLTEXT CONTAINS "VeriSimDB"
PROOF EXISTENCE(WikiContract)

Behavior: Elixir DriftMonitor detects and repairs inconsistencies before returning results.

10.3. Example 25: Tolerate Drift (Return Inconsistent Data)

Slipstream:

SELECT *
FROM FEDERATION /mirrors/* WITH DRIFT TOLERATE
WHERE FULLTEXT CONTAINS "archived content"
LIMIT 1000

Behavior: Returns data even if nodes are inconsistent. Useful for exploratory queries.

10.4. Example 26: Latest Version (Ignore Drift)

Slipstream:

SELECT DOCUMENT
FROM FEDERATION /news-feeds/* WITH DRIFT LATEST
WHERE FULLTEXT CONTAINS "breaking news"
LIMIT 10

Behavior: Uses the most recent version from each node, ignoring temporal consistency.

11. Performance Optimization Examples

11.1. Example 27: Pagination for Large Result Sets

SELECT DOCUMENT
FROM FEDERATION /archives/*
WHERE FULLTEXT CONTAINS "machine learning"
LIMIT 100
OFFSET 500

11.2. Example 28: Store-Specific Query (Bypass Federation)

-- Query specific store for lowest latency
SELECT VECTOR
FROM STORE milvus-us-east-1
WHERE h.embedding NEAREST 20 USING COSINE

11.3. Example 29: Minimal Modality Selection

-- Only request needed modalities to reduce data transfer
SELECT GRAPH(nodes, edges)
FROM HEXAD abc-123
WHERE (h)-[:CITES]->(target)

12. Error Handling Examples

12.1. Example 30: Proof Verification Failure

Query:

SELECT SEMANTIC
FROM HEXAD protected-data-uuid
WHERE SATISFIES AccessControlContract(role=guest)
PROOF ACCESS(GuestAccessContract)

Expected Error:

{
  "error": "ProofVerificationFailed",
  "message": "ZKP verification failed for AccessControlContract",
  "details": {
    "contract": "GuestAccessContract",
    "reason": "Insufficient permissions (requires role=researcher)"
  }
}

12.2. Example 31: Drift Detection Failure

Query:

SELECT *
FROM FEDERATION /distributed-ledger/* WITH DRIFT STRICT
WHERE AS OF 2024-01-01T00:00:00Z

Expected Error:

{
  "error": "DriftDetected",
  "message": "Inconsistency detected across federated nodes",
  "details": {
    "divergent_nodes": ["node-2", "node-5"],
    "drift_type": "TemporalInconsistency",
    "suggestion": "Use DRIFT REPAIR or DRIFT TOLERATE"
  }
}

12.3. Example 32: Malformed Query

Query:

SELECT GRAPH
FROM HEXAD not-a-valid-uuid
WHERE (h)-[:INVALID_SYNTAX

Expected Error:

{
  "error": "ParseError",
  "message": "Failed to parse VCL query",
  "details": {
    "line": 3,
    "column": 27,
    "expected": "]->"
  }
}

13. Advanced Use Cases

13.1. Example 33: Recursive Citation Network

Dependent-Type:

-- Find all papers in transitive citation closure
SELECT GRAPH
FROM FEDERATION /research-db/* WITH DRIFT REPAIR
WHERE (seed_paper)-[:CITES*1..10]->(h)
  AND seed_paper.uuid == "root-paper-uuid"
  AND h.year >= 2020
  AND SATISFIES CitationContract
PROOF CITATION(TransitiveClosureContract)
LIMIT 1000

13.2. Example 34: Multi-Institutional Data Aggregation

Dependent-Type:

-- Aggregate COVID-19 data from multiple hospitals
SELECT SEMANTIC, TEMPORAL, DOCUMENT
FROM FEDERATION /hospitals/* WITH DRIFT STRICT
WHERE AS OF 2024-12-31T23:59:59Z
  AND SATISFIES HIPAAContract(anonymized=true, aggregated=true)
  AND SATISFIES IRBContract(protocol=COVID-2024-001)
  AND FIELD diagnosis LIKE "%COVID%"
PROOF PROVENANCE(MultiInstitutionalHealthContract)
  WITH auditor=cdc

13.3. Example 35: Real-Time Embeddings Query

Slipstream:

-- Fast similarity search for recommendation system
SELECT VECTOR
FROM STORE milvus-cache
WHERE h.embedding SIMILAR TO [0.5, 0.3, ...] WITHIN 0.75
  AND h.metadata.category == "electronics"
  AND h.metadata.in_stock == true
LIMIT 20

14. Comparison: Dependent-Type vs Slipstream

14.1. Same Query, Two Paths

Slipstream (Fast, Unverified):

SELECT GRAPH, VECTOR
FROM FEDERATION /papers/*
WHERE (h)-[:CITES]->(target)
  AND h.embedding SIMILAR TO [0.1, 0.2, 0.3]
LIMIT 100

Dependent-Type (Slow, Verified):

SELECT GRAPH, VECTOR
FROM FEDERATION /papers/* WITH DRIFT STRICT
WHERE (h)-[:CITES]->(target)
  AND h.embedding SIMILAR TO [0.1, 0.2, 0.3]
  AND SATISFIES CitationContract
  AND SATISFIES EmbeddingQualityContract(dimension=768)
PROOF CITATION(VerifiedCitationContract)
LIMIT 100

Performance Comparison:

Metric Slipstream Dependent-Type

Latency

~50ms

~300ms (includes ZKP generation)

Guarantees

None

Formal verification via ZKP

Use Case

Exploratory analysis

Audit-ready queries

Audit Trail

Logged to verisim-temporal

Logged with proof to verisim-temporal

15. Summary

VCL provides two execution paths:

  1. Dependent-Type Path (PROOF clause present):

    • Formal verification via proven-library

    • Drift detection/repair via Elixir DriftMonitor

    • ZKP generation for audit trails

    • Slower but audit-ready

  2. Slipstream Path (no PROOF clause):

    • Fast, unverified execution

    • No proof generation overhead

    • Suitable for exploratory queries

    • Still logged for audit (but without proofs)

Recommendation: Use dependent-type path for: - Compliance queries (GDPR, HIPAA, FAIR) - Multi-institutional data sharing - Citation verification - Provenance audits

Use slipstream path for: - Real-time recommendations - Exploratory data analysis - Performance-critical applications - Internal queries with trusted data

16. Backwards Compatibility Queries

16.1. Example 36: Version Pinning

Query with explicit VCL version:

VERSION 1.0;

SELECT GRAPH, DOCUMENT
FROM verisim:semantic
WHERE octad.types INCLUDES "https://schema.org/Person"
LIMIT 10;

Query using deprecated syntax (with warning):

VERSION 0.9;  -- Deprecated syntax accepted

FROM verisim:semantic
SELECT GRAPH, DOCUMENT
WHERE octad.types INCLUDES "https://schema.org/Person"
LIMIT 10;

16.2. Example 37: Federation Version Negotiation

Query with version compatibility check:

VERSION 1.0;

SELECT *
FROM FEDERATION /universities/*
WITH DRIFT LATEST  -- Use latest schema version
WHERE octad.types INCLUDES "Paper"
LIMIT 100;

17. Drift Handling Queries

17.1. Example 38: Drift Detection

Detect cross-modal drift:

SELECT DRIFT
FROM verisim:all_modalities
WHERE octad.id = @octad_id;

-- Returns: {
--   "drifts": [
--     {"type": "title_mismatch", "graph": "ML Paper", "document": "Machine Learning Paper"}
--   ]
-- }

17.2. Example 39: Drift Repair - Latest Wins

Repair using most recent version:

DRIFT REPAIR
FROM verisim:graph
WHERE octad.id = @id
USING STRATEGY latest_wins;

17.3. Example 40: Drift Repair - Quorum

Repair using majority voting:

DRIFT REPAIR
FROM verisim:federation /universities/*
WHERE octad.id = @id
USING STRATEGY quorum;

17.4. Example 41: Drift-Aware Query

Query with drift tolerance:

SELECT GRAPH, DOCUMENT
FROM FEDERATION /universities/*
WITH DRIFT TOLERATE  -- Return data despite drift
WHERE octad.types INCLUDES "Paper"
LIMIT 100;

17.5. Example 42: Byzantine-Resistant Query

Query with drift repair:

SELECT GRAPH, DOCUMENT
FROM FEDERATION /universities/*
WITH DRIFT REPAIR  -- Auto-repair detected drift
WHERE octad.types INCLUDES "Paper"
LIMIT 100;

18. SQL-Compatible Extensions

18.1. Example 43: Column Selection within Modality

Select specific fields from a modality (slipstream):

SELECT DOCUMENT.name, DOCUMENT.severity
FROM HEXAD 550e8400-e29b-41d4-a716-446655440000

Mixed modalities and column projections:

SELECT GRAPH, DOCUMENT.name, DOCUMENT.severity
FROM FEDERATION /universities/*
LIMIT 50

18.2. Example 44: ORDER BY — Sort Results

Sort by severity descending:

SELECT DOCUMENT
FROM STORE archive-1
WHERE FULLTEXT CONTAINS "security"
ORDER BY DOCUMENT.severity DESC
LIMIT 50

Multi-field sort:

SELECT DOCUMENT.name, DOCUMENT.severity
FROM FEDERATION /archives/*
ORDER BY DOCUMENT.severity DESC, DOCUMENT.name ASC
LIMIT 100

18.3. Example 45: COUNT(*), SUM, AVG — Aggregate Functions

Count all matching octads:

SELECT COUNT(*)
FROM FEDERATION /archives/*
WHERE FULLTEXT CONTAINS "vulnerability"

Aggregate with field reference:

SELECT AVG(DOCUMENT.severity), MIN(DOCUMENT.severity), MAX(DOCUMENT.severity)
FROM FEDERATION /scans/*

Sum and count together:

SELECT COUNT(*), SUM(DOCUMENT.severity)
FROM STORE tantivy-node-1
WHERE FIELD severity > 3

18.4. Example 46: GROUP BY / HAVING — Grouping with Filters

Group results by field:

SELECT DOCUMENT.name, COUNT(*), AVG(DOCUMENT.severity)
FROM FEDERATION /universities/*
GROUP BY DOCUMENT.name
LIMIT 100

GROUP BY with HAVING filter:

SELECT DOCUMENT.name, COUNT(*)
FROM FEDERATION /archives/*
GROUP BY DOCUMENT.name
HAVING FIELD count > 3
ORDER BY DOCUMENT.name ASC
LIMIT 50

18.5. Example 47: Full SQL-Compatible Query

Combining all SQL-compatible features with VCL’s model:

SELECT DOCUMENT.name, DOCUMENT.severity, COUNT(*), SUM(DOCUMENT.severity), AVG(DOCUMENT.severity)
FROM FEDERATION /universities/* WITH DRIFT REPAIR
WHERE FIELD severity > 3
GROUP BY DOCUMENT.name, DOCUMENT.severity
HAVING FIELD total > 10
ORDER BY DOCUMENT.severity DESC, DOCUMENT.name ASC
LIMIT 100
OFFSET 20

18.6. Example 48: SQL-Compatible with Dependent-Type Verification

Combining aggregates with formal verification (VCL-dt path):

SELECT DOCUMENT.name, COUNT(*)
FROM FEDERATION /universities/* WITH DRIFT STRICT
GROUP BY DOCUMENT.name
PROOF INTEGRITY(DataIntegrityContract)
ORDER BY DOCUMENT.name ASC
LIMIT 50
Note
In the dependent-type path, aggregation results are also covered by the proof guarantee — the ZKP witnesses include the aggregate computation, ensuring verified totals.

19. Multi-Proof Composition (v2.0)

19.1. Example 49: Dual Proof — Existence and Integrity

Dependent-Type:

SELECT *
FROM HEXAD 550e8400-e29b-41d4-a716-446655440000
PROOF EXISTENCE(ExistenceContract) AND INTEGRITY(DataIntegrityContract)

Both proofs must pass before results are returned. The ZKP witnesses for each proof are generated independently and composed into a single proof bundle.

19.2. Example 50: Triple Proof — Access, Provenance, and Integrity

Dependent-Type:

SELECT SEMANTIC, TEMPORAL, DOCUMENT
FROM FEDERATION /hospitals/* WITH DRIFT STRICT
WHERE SATISFIES HIPAAContract(anonymized=true)
PROOF ACCESS(InstitutionalAccessContract) AND PROVENANCE(ClinicalTrialContract) AND INTEGRITY(DataIntegrityContract)
LIMIT 100

Multi-proof composition validates that the user has access, the data lineage is verifiable, and the data has not been tampered with — all three conditions must hold simultaneously.

19.3. Example 51: Citation and Custom Proof

Dependent-Type:

SELECT GRAPH, DOCUMENT
FROM FEDERATION /journals/* WITH DRIFT REPAIR
WHERE (h)-[:CITES]->(target)
  AND FULLTEXT CONTAINS "reproducibility crisis"
PROOF CITATION(CitationChainContract) AND CUSTOM(ReproducibilityContract)
LIMIT 50

20. Cross-Modal Correlation Queries (v2.0)

20.1. Example 52: Cross-Modal Field Compare

Compare fields across modalities:

SELECT DOCUMENT, GRAPH
FROM HEXAD 550e8400-e29b-41d4-a716-446655440000
WHERE DOCUMENT.severity > GRAPH.centrality

Evaluates after both modalities are fetched, comparing the document severity field against the graph centrality field on the same octad.

20.2. Example 53: Drift Between Modalities

Detect embedding drift:

SELECT VECTOR, DOCUMENT
FROM FEDERATION /research-papers/*
WHERE DRIFT(VECTOR, DOCUMENT) > 0.3
LIMIT 50

Returns octads where the vector embedding has drifted more than 0.3 from the document representation. Useful for identifying stale embeddings.

20.3. Example 54: Consistency Check

Verify cross-modal consistency:

SELECT VECTOR, SEMANTIC
FROM HEXAD suspicious-entry-uuid
WHERE CONSISTENT(VECTOR, SEMANTIC) USING COSINE
PROOF INTEGRITY(CrossModalContract)

Checks that the vector representation and semantic annotation are consistent using cosine similarity as the metric.

20.4. Example 55: Modality Existence Check

Filter by available modalities:

SELECT *
FROM FEDERATION /archives/*
WHERE VECTOR EXISTS
  AND TENSOR NOT EXISTS
LIMIT 100

Returns octads that have vector embeddings but lack tensor data. Useful for identifying octads that need tensor representations generated.

20.5. Example 56: Combined Cross-Modal and Standard Conditions

Mix cross-modal with single-modality conditions:

SELECT GRAPH, VECTOR, DOCUMENT
FROM FEDERATION /research-db/* WITH DRIFT REPAIR
WHERE FULLTEXT CONTAINS "neural networks"
  AND DRIFT(VECTOR, DOCUMENT) < 0.2
  AND VECTOR EXISTS
  AND GRAPH EXISTS
PROOF CITATION(NeuralNetworkContract) AND INTEGRITY(DataIntegrityContract)
LIMIT 50

Pushdown conditions (FULLTEXT CONTAINS) are sent to individual stores, while cross-modal conditions (DRIFT, EXISTS) are evaluated post-fetch on full octad data.

21. Write Path: INSERT / UPDATE / DELETE (v2.0)

21.1. Example 57: Insert a New Octad

Insert with document and vector data:

INSERT HEXAD WITH
  DOCUMENT(title = "New Research Paper", author = "Jane Doe", severity = 3),
  VECTOR([0.12, 0.45, 0.78, 0.23, 0.91])

Creates a new octad with document and vector modalities populated. The octad ID is auto-generated and returned in the result.

21.2. Example 58: Insert with Graph Relationship

Insert with cross-modal data:

INSERT HEXAD WITH
  DOCUMENT(title = "Follow-Up Study", year = 2026),
  VECTOR([0.5, 0.3, 0.2, 0.8]),
  GRAPH(CITES, 550e8400-e29b-41d4-a716-446655440000)

Creates a octad with document content, embedding, and a graph edge (CITES relationship to an existing octad).

21.3. Example 59: Verified Insert with Proof

Insert with integrity verification:

INSERT HEXAD WITH
  DOCUMENT(title = "Clinical Trial Result", status = "verified"),
  SEMANTIC(ClinicalTrialContract),
  TEMPORAL(2026-02-13T10:30:00Z)
PROOF INTEGRITY(WriteContract) AND PROVENANCE(AuditTrailContract)

The ZKP proofs are generated for the write operation itself, ensuring the insert is verified and auditable.

21.4. Example 60: Update Octad Fields

Update specific fields:

UPDATE HEXAD 550e8400-e29b-41d4-a716-446655440000
SET DOCUMENT.title = "Corrected Title", DOCUMENT.severity = 5

Updates the document modality fields without affecting other modalities. Drift detection will fire if the change creates cross-modal inconsistency.

21.5. Example 61: Verified Update with Proof

Update with access proof:

UPDATE HEXAD 550e8400-e29b-41d4-a716-446655440000
SET DOCUMENT.status = "retracted", DOCUMENT.retraction_reason = "Data fabrication"
PROOF ACCESS(EditAccessContract) AND PROVENANCE(RetractionContract)

The update requires proof of edit access and creates a provenance record of the retraction in the audit trail.

21.6. Example 62: Delete a Octad

Simple deletion:

DELETE HEXAD 550e8400-e29b-41d4-a716-446655440000

Removes the octad and all its modality data. This operation is logged in verisim-temporal for auditability.

21.7. Example 63: Verified Delete with Proof

Delete with access and provenance proof:

DELETE HEXAD 550e8400-e29b-41d4-a716-446655440000
PROOF ACCESS(AdminAccessContract) AND PROVENANCE(DeletionAuditContract)

Requires proof of admin access before deletion. The provenance proof ensures the deletion is recorded in the audit chain.