From 4c19e15898e2760ce3707fdad7aac8ad145e57c8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 14 Jun 2026 02:34:05 +0000 Subject: [PATCH] =?UTF-8?q?refactor(rescript):=20VCL=20rename=20stage=20B?= =?UTF-8?q?=20(3/5)=20=E2=80=94=20parser,=20playground,=20ReScript=20SDK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Renames the deprecated "VQL" misnomer to "VCL" (VeriSim Consonance Language) across all three independent ReScript projects, completing the bucket skipped by stage 2/5. ReScript source: - src/vql/ -> src/vcl/, VQL*.res -> VCL*.res (parser, type checker, bidir, subtyping, proof obligations, circuits, explain) — module renames carried through all intra-project references - playground/: VqlKeywords.res -> VclKeywords.res, /vql/execute -> /vcl/execute, "VQL Playground" -> "VCL Playground" (configs + public assets) - connectors/clients/rescript/: VeriSimVql.res -> VeriSimVcl.res, /api/v1/vql/{execute,explain} -> /vcl/{execute,explain}, vqlResult -> vclResult, VqlParseError/VqlExecutionError -> Vcl*; acronym gloss corrected from "Query Language" to "Consonance Language" per CLAUDE.md Functional couplings updated so nothing breaks on rebuild/CI: - vql-bridge/vql_parser_port.js: compiled-module imports retargeted to src/vcl/VCL*.res.mjs (filename kept so the Elixir spawn path stays valid) - .hypatia-ignore: renamed .res whitelist paths - .github/CODEOWNERS: /src/vql/ -> /src/vcl/ - contractiles Must/Dust: dir assertions retargeted to src/vcl Verification: no ReScript toolchain in this environment or CI, so validated statically — zero residual "vql" (any case) in the three projects + bridge + fixed configs, symmetric token diff, and no dangling old module references. Deferred (other stages): Elixir VCLBridge/VCLExecutor + benches + vql-bridge dir rename (4/5); docs, machine-readable specs, provenance octads, *.vql examples (5/5). Note: ffi/zig still calls the rust core's old /vql/execute and .clusterfuzzlite names fuzz_vql_parser — pre-existing leftovers from the 1/5 endpoint rename, tracked separately. https://claude.ai/code/session_01W9Voe3JceP66Bna9FT4jME --- .github/CODEOWNERS | 2 +- .hypatia-ignore | 30 +++---- .../contractiles/dust/Dustfile.a2ml | 2 +- .../contractiles/must/Mustfile.a2ml | 10 +-- .../clients/rescript/src/VeriSimError.res | 12 +-- .../rescript/src/VeriSimFederation.res | 2 +- .../clients/rescript/src/VeriSimTypes.res | 12 +-- .../src/{VeriSimVql.res => VeriSimVcl.res} | 32 ++++---- playground/deno.json | 2 +- playground/package.json | 4 +- playground/public/index.html | 24 +++--- playground/public/manifest.json | 6 +- playground/public/style.css | 10 +-- playground/public/sw.js | 4 +- playground/rescript.json | 2 +- playground/src/ApiClient.res | 22 +++--- playground/src/App.res | 48 ++++++------ playground/src/DemoExecutor.res | 12 +-- playground/src/Examples.res | 62 +++++++-------- playground/src/Formatter.res | 6 +- playground/src/Highlighter.res | 10 +-- playground/src/Linter.res | 52 ++++++------- .../src/{VqlKeywords.res => VclKeywords.res} | 8 +- src/{vql/VQLBidir.res => vcl/VCLBidir.res} | 20 ++--- .../VQLCircuit.res => vcl/VCLCircuit.res} | 10 +-- .../VQLContext.res => vcl/VCLContext.res} | 10 +-- src/{vql/VQLError.res => vcl/VCLError.res} | 48 ++++++------ .../VQLExplain.res => vcl/VCLExplain.res} | 12 +-- src/{vql/VQLParser.res => vcl/VCLParser.res} | 4 +- .../VCLParser_test.res} | 6 +- .../VCLProofObligation.res} | 8 +- .../VQLSubtyping.res => vcl/VCLSubtyping.res} | 22 +++--- .../VCLTypeChecker.res} | 18 ++--- src/{vql/VQLTypes.res => vcl/VCLTypes.res} | 24 +++--- vql-bridge/vql_parser_port.js | 78 +++++++++---------- 35 files changed, 317 insertions(+), 317 deletions(-) rename connectors/clients/rescript/src/{VeriSimVql.res => VeriSimVcl.res} (61%) rename playground/src/{VqlKeywords.res => VclKeywords.res} (87%) rename src/{vql/VQLBidir.res => vcl/VCLBidir.res} (98%) rename src/{vql/VQLCircuit.res => vcl/VCLCircuit.res} (86%) rename src/{vql/VQLContext.res => vcl/VCLContext.res} (97%) rename src/{vql/VQLError.res => vcl/VCLError.res} (93%) rename src/{vql/VQLExplain.res => vcl/VCLExplain.res} (97%) rename src/{vql/VQLParser.res => vcl/VCLParser.res} (99%) rename src/{vql/VQLParser_test.res => vcl/VCLParser_test.res} (99%) rename src/{vql/VQLProofObligation.res => vcl/VCLProofObligation.res} (98%) rename src/{vql/VQLSubtyping.res => vcl/VCLSubtyping.res} (94%) rename src/{vql/VQLTypeChecker.res => vcl/VCLTypeChecker.res} (96%) rename src/{vql/VQLTypes.res => vcl/VCLTypes.res} (93%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 22811bc..890c0e0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,6 +5,6 @@ * @hyperpolymath /rust-core/ @hyperpolymath /elixir-orchestration/ @hyperpolymath -/src/vql/ @hyperpolymath +/src/vcl/ @hyperpolymath /container/ @hyperpolymath /.github/ @hyperpolymath diff --git a/.hypatia-ignore b/.hypatia-ignore index f0b90f9..7461107 100644 --- a/.hypatia-ignore +++ b/.hypatia-ignore @@ -2,10 +2,10 @@ # # ReScript (.res) files are permitted in this repository per CLAUDE.md # language policy. ReScript powers: -# - src/vql/ — VQL parser, type checker, circuits, subtyping +# - src/vcl/ — VCL parser, type checker, circuits, subtyping # - src/registry/ — federation registry (Kraft consensus, metadata log) # - src/abi/ — Idris2/ReScript ABI bridge -# - playground/ — VQL Playground web UI +# - playground/ — VCL Playground web UI # - connectors/clients/rescript/ — ReScript client SDK # # Each file is whitelisted by absolute repo path. @@ -18,7 +18,7 @@ cicd_rules/banned_language_file:connectors/clients/rescript/src/VeriSimHexad.res cicd_rules/banned_language_file:connectors/clients/rescript/src/VeriSimProvenance.res cicd_rules/banned_language_file:connectors/clients/rescript/src/VeriSimSearch.res cicd_rules/banned_language_file:connectors/clients/rescript/src/VeriSimTypes.res -cicd_rules/banned_language_file:connectors/clients/rescript/src/VeriSimVql.res +cicd_rules/banned_language_file:connectors/clients/rescript/src/VeriSimVcl.res cicd_rules/banned_language_file:debugger/examples/SafeDOMExample.res cicd_rules/banned_language_file:examples/SafeDOMExample.res cicd_rules/banned_language_file:playground/src/ApiClient.res @@ -28,22 +28,22 @@ cicd_rules/banned_language_file:playground/src/Examples.res cicd_rules/banned_language_file:playground/src/Formatter.res cicd_rules/banned_language_file:playground/src/Highlighter.res cicd_rules/banned_language_file:playground/src/Linter.res -cicd_rules/banned_language_file:playground/src/VqlKeywords.res +cicd_rules/banned_language_file:playground/src/VclKeywords.res cicd_rules/banned_language_file:src/registry/KRaftCluster.res cicd_rules/banned_language_file:src/registry/KRaftSerializer.res cicd_rules/banned_language_file:src/registry/MetadataLog.res cicd_rules/banned_language_file:src/registry/Registry.res -cicd_rules/banned_language_file:src/vql/VQLBidir.res -cicd_rules/banned_language_file:src/vql/VQLCircuit.res -cicd_rules/banned_language_file:src/vql/VQLContext.res -cicd_rules/banned_language_file:src/vql/VQLError.res -cicd_rules/banned_language_file:src/vql/VQLExplain.res -cicd_rules/banned_language_file:src/vql/VQLParser.res -cicd_rules/banned_language_file:src/vql/VQLParser_test.res -cicd_rules/banned_language_file:src/vql/VQLProofObligation.res -cicd_rules/banned_language_file:src/vql/VQLSubtyping.res -cicd_rules/banned_language_file:src/vql/VQLTypeChecker.res -cicd_rules/banned_language_file:src/vql/VQLTypes.res +cicd_rules/banned_language_file:src/vcl/VCLBidir.res +cicd_rules/banned_language_file:src/vcl/VCLCircuit.res +cicd_rules/banned_language_file:src/vcl/VCLContext.res +cicd_rules/banned_language_file:src/vcl/VCLError.res +cicd_rules/banned_language_file:src/vcl/VCLExplain.res +cicd_rules/banned_language_file:src/vcl/VCLParser.res +cicd_rules/banned_language_file:src/vcl/VCLParser_test.res +cicd_rules/banned_language_file:src/vcl/VCLProofObligation.res +cicd_rules/banned_language_file:src/vcl/VCLSubtyping.res +cicd_rules/banned_language_file:src/vcl/VCLTypeChecker.res +cicd_rules/banned_language_file:src/vcl/VCLTypes.res # verisimdb-registry uses ReScript v11; rescript.json is its build config. cicd_rules/banned_config_file:rescript.json diff --git a/.machine_readable/contractiles/dust/Dustfile.a2ml b/.machine_readable/contractiles/dust/Dustfile.a2ml index f5a5418..bcc91f2 100644 --- a/.machine_readable/contractiles/dust/Dustfile.a2ml +++ b/.machine_readable/contractiles/dust/Dustfile.a2ml @@ -60,7 +60,7 @@ nothing is deleted without --apply and per-item approval. Audit trail preserved. ### no-tracked-rescript-mjs - description: No compiled ReScript .res.mjs output tracked in git -- target: src/vql +- target: src/vcl - reason: Compiled output regenerated from .res sources - probe: test -z "$(git ls-files '*.res.mjs' 2>/dev/null)" - status: declared diff --git a/.machine_readable/contractiles/must/Mustfile.a2ml b/.machine_readable/contractiles/must/Mustfile.a2ml index 2cdcf85..e63685a 100644 --- a/.machine_readable/contractiles/must/Mustfile.a2ml +++ b/.machine_readable/contractiles/must/Mustfile.a2ml @@ -9,7 +9,7 @@ @abstract: Physical-state invariants for VeriSimDB — the cross-modal (octad) entity -consistency engine. Rust core + Elixir/OTP orchestration + ReScript VQL. +consistency engine. Rust core + Elixir/OTP orchestration + ReScript VCL. These are hard requirements: CI and pre-commit hooks fail if any check fails. @end @@ -77,11 +77,11 @@ These are hard requirements: CI and pre-commit hooks fail if any check fails. - run: test -f .editorconfig - severity: warning -## VQL (VeriSim Consonance Language) +## VCL (VeriSim Consonance Language) -### vql-rescript-parser -- description: ReScript VQL parser source must exist -- run: test -d src/vql +### vcl-rescript-parser +- description: ReScript VCL parser source must exist +- run: test -d src/vcl - severity: critical ### vql-elixir-bridge diff --git a/connectors/clients/rescript/src/VeriSimError.res b/connectors/clients/rescript/src/VeriSimError.res index 8b5a81e..de9c30a 100644 --- a/connectors/clients/rescript/src/VeriSimError.res +++ b/connectors/clients/rescript/src/VeriSimError.res @@ -31,8 +31,8 @@ type t = | ModalityUnavailable(string) | DriftComputationError(string) | ProvenanceInvalid(string) - | VqlParseError(string) - | VqlExecutionError(string) + | VclParseError(string) + | VclExecutionError(string) | FederationError(string) // --- Client-side errors --- | ConnectionError(string) @@ -60,8 +60,8 @@ let message = (err: t): string => { | ModalityUnavailable(msg) => `Modality unavailable: ${msg}` | DriftComputationError(msg) => `Drift computation error: ${msg}` | ProvenanceInvalid(msg) => `Provenance invalid: ${msg}` - | VqlParseError(msg) => `VQL parse error: ${msg}` - | VqlExecutionError(msg) => `VQL execution error: ${msg}` + | VclParseError(msg) => `VCL parse error: ${msg}` + | VclExecutionError(msg) => `VCL execution error: ${msg}` | FederationError(msg) => `Federation error: ${msg}` | ConnectionError(msg) => `Connection error: ${msg}` | TimeoutError(msg) => `Timeout error: ${msg}` @@ -119,8 +119,8 @@ let isRetryable = (err: t): bool => { | ModalityUnavailable(_) => false | DriftComputationError(_) => false | ProvenanceInvalid(_) => false - | VqlParseError(_) => false - | VqlExecutionError(_) => false + | VclParseError(_) => false + | VclExecutionError(_) => false | FederationError(_) => false | SerializationError(_) => false | UnknownError(_) => false diff --git a/connectors/clients/rescript/src/VeriSimFederation.res b/connectors/clients/rescript/src/VeriSimFederation.res index a1d8c2f..77c430b 100644 --- a/connectors/clients/rescript/src/VeriSimFederation.res +++ b/connectors/clients/rescript/src/VeriSimFederation.res @@ -67,7 +67,7 @@ let listPeers = async ( } } -/** Execute a VQL query across one or more federation peers. +/** Execute a VCL query across one or more federation peers. * * If peerIds is empty, the query is broadcast to all active peers. * diff --git a/connectors/clients/rescript/src/VeriSimTypes.res b/connectors/clients/rescript/src/VeriSimTypes.res index f9f52ef..3753116 100644 --- a/connectors/clients/rescript/src/VeriSimTypes.res +++ b/connectors/clients/rescript/src/VeriSimTypes.res @@ -274,19 +274,19 @@ type searchResult = { } // -------------------------------------------------------------------------- -// VQL types +// VCL types // -------------------------------------------------------------------------- -/** Result of a VQL query execution. */ -type vqlResult = { +/** Result of a VCL query execution. */ +type vclResult = { columns: array, rows: array>, count: int, elapsedMs: float, } -/** Query execution plan explanation for a VQL statement. */ -type vqlExplanation = { +/** Query execution plan explanation for a VCL statement. */ +type vclExplanation = { query: string, plan: string, cost: float, @@ -311,7 +311,7 @@ type federationPeer = { type peerQueryResult = { peerId: string, peerName: string, - result: vqlResult, + result: vclResult, elapsedMs: float, error: option, } diff --git a/connectors/clients/rescript/src/VeriSimVql.res b/connectors/clients/rescript/src/VeriSimVcl.res similarity index 61% rename from connectors/clients/rescript/src/VeriSimVql.res rename to connectors/clients/rescript/src/VeriSimVcl.res index 3049520..a3afed6 100644 --- a/connectors/clients/rescript/src/VeriSimVql.res +++ b/connectors/clients/rescript/src/VeriSimVcl.res @@ -1,22 +1,22 @@ // SPDX-License-Identifier: MPL-2.0 // Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) // -// VeriSimDB ReScript Client — VQL (VeriSimDB Query Language) operations. +// VeriSimDB ReScript Client — VCL (VeriSim Consonance Language) operations. // -// VQL is VeriSimDB's native query language for multi-modal queries that span +// VCL is VeriSimDB's native consonance language for multi-modal queries that span // graph traversals, vector similarity, spatial filters, and temporal constraints // in a single statement. This module provides execution and explain functions. -/** VQL request payload for executing or explaining a query. */ -type vqlRequest = { +/** VCL request payload for executing or explaining a query. */ +type vclRequest = { query: string, params: Dict.t, } -/** Execute a VQL query and return the result set. +/** Execute a VCL query and return the result set. * * @param client The authenticated client. - * @param query The VQL query string. + * @param query The VCL query string. * @param params Optional named parameters for parameterised queries. * @returns The query result with columns, rows, and timing, or an error. */ @@ -24,11 +24,11 @@ let execute = async ( client: VeriSimClient.t, query: string, ~params: Dict.t=Dict.make(), -): result => { +): result => { try { - let req: vqlRequest = {query, params} + let req: vclRequest = {query, params} let body = req->Obj.magic->JSON.stringify->JSON.parseExn - let resp = await VeriSimClient.doPost(client, "/api/v1/vql/execute", body) + let resp = await VeriSimClient.doPost(client, "/api/v1/vcl/execute", body) if resp.ok { let json = await VeriSimClient.jsonBody(resp) Ok(json->Obj.magic) @@ -36,14 +36,14 @@ let execute = async ( Error(VeriSimError.fromStatus(resp.status)) } } catch { - | _ => Error(VeriSimError.ConnectionError("VQL execution failed")) + | _ => Error(VeriSimError.ConnectionError("VCL execution failed")) } } -/** Explain a VQL query's execution plan without running it. +/** Explain a VCL query's execution plan without running it. * * @param client The authenticated client. - * @param query The VQL query string. + * @param query The VCL query string. * @param params Optional named parameters. * @returns The query plan, estimated cost, and any warnings, or an error. */ @@ -51,11 +51,11 @@ let explain = async ( client: VeriSimClient.t, query: string, ~params: Dict.t=Dict.make(), -): result => { +): result => { try { - let req: vqlRequest = {query, params} + let req: vclRequest = {query, params} let body = req->Obj.magic->JSON.stringify->JSON.parseExn - let resp = await VeriSimClient.doPost(client, "/api/v1/vql/explain", body) + let resp = await VeriSimClient.doPost(client, "/api/v1/vcl/explain", body) if resp.ok { let json = await VeriSimClient.jsonBody(resp) Ok(json->Obj.magic) @@ -63,6 +63,6 @@ let explain = async ( Error(VeriSimError.fromStatus(resp.status)) } } catch { - | _ => Error(VeriSimError.ConnectionError("VQL explain failed")) + | _ => Error(VeriSimError.ConnectionError("VCL explain failed")) } } diff --git a/playground/deno.json b/playground/deno.json index 6905d5d..e736ae5 100644 --- a/playground/deno.json +++ b/playground/deno.json @@ -1,5 +1,5 @@ { - "name": "vql-playground", + "name": "vcl-playground", "version": "0.1.0", "tasks": { "res:build": "rescript", diff --git a/playground/package.json b/playground/package.json index 975aedb..411242b 100644 --- a/playground/package.json +++ b/playground/package.json @@ -1,7 +1,7 @@ { - "name": "vql-playground", + "name": "vcl-playground", "version": "0.1.0", - "description": "VQL Playground — Interactive query editor for VeriSimDB", + "description": "VCL Playground — Interactive query editor for VeriSimDB", "type": "module", "license": "MPL-2.0", "author": "Jonathan D.A. Jewell ", diff --git a/playground/public/index.html b/playground/public/index.html index a53290d..13ccca8 100644 --- a/playground/public/index.html +++ b/playground/public/index.html @@ -4,9 +4,9 @@ - + - VQL Playground — VeriSimDB + VCL Playground — VeriSimDB @@ -15,15 +15,15 @@
-

VQL Playground

+

VCL Playground

- -
+ +
- - VQL + + VCL
@@ -41,7 +41,7 @@

VQL Playground

autocomplete="off" autocorrect="off" autocapitalize="off" - placeholder="-- Enter your VQL query here SELECT GRAPH, VECTOR FROM HEXAD WHERE name = 'example' LIMIT 10" + placeholder="-- Enter your VCL query here SELECT GRAPH, VECTOR FROM HEXAD WHERE name = 'example' LIMIT 10" >
@@ -61,9 +61,9 @@

VQL Playground

table
-Welcome to the VQL Playground! +Welcome to the VCL Playground! -VQL (VeriSim Query Language) is the native query interface for VeriSimDB, +VCL (VeriSim Query Language) is the native query interface for VeriSimDB, the octad multimodal database with drift detection and self-normalisation. Octad modalities: GRAPH, VECTOR, TENSOR, SEMANTIC, DOCUMENT, TEMPORAL, PROVENANCE, SPATIAL @@ -71,7 +71,7 @@

VQL Playground

When verisim-api is running on localhost:8080, queries execute against the real backend. Otherwise, demo mode simulates responses offline. -Toggle VQL-DT mode for dependent-type features including: +Toggle VCL-DT mode for dependent-type features including: - PROOF clause (11 types: EXISTENCE, INTEGRITY, CONSISTENCY, PROVENANCE, FRESHNESS, etc.) - THRESHOLD constraints - Multi-proof composition: PROOF A AND B AND C @@ -83,7 +83,7 @@

VQL Playground

- Mode: VQL + Mode: VCL playground.verisimdb.org Demo mode (offline)
diff --git a/playground/public/manifest.json b/playground/public/manifest.json index fd4801f..8d51a1d 100644 --- a/playground/public/manifest.json +++ b/playground/public/manifest.json @@ -1,7 +1,7 @@ { - "name": "VQL Playground", - "short_name": "VQL Play", - "description": "Interactive VQL query editor for VeriSimDB with VQL-DT mode", + "name": "VCL Playground", + "short_name": "VCL Play", + "description": "Interactive VCL query editor for VeriSimDB with VCL-DT mode", "start_url": "/", "display": "standalone", "background_color": "#0f172a", diff --git a/playground/public/style.css b/playground/public/style.css index ec583c6..c153207 100644 --- a/playground/public/style.css +++ b/playground/public/style.css @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: MPL-2.0 */ -/* VQL Playground — Dark theme matching VeriSimDB branding */ +/* VCL Playground — Dark theme matching VeriSimDB branding */ :root { --bg-primary: #0f172a; @@ -69,7 +69,7 @@ body { gap: 1rem; } -/* VQL-DT Toggle */ +/* VCL-DT Toggle */ .mode-toggle { display: flex; align-items: center; @@ -120,13 +120,13 @@ body { letter-spacing: 0.05em; } -.mode-badge.vql { +.mode-badge.vcl { background: rgba(59, 130, 246, 0.2); color: var(--accent); border: 1px solid rgba(59, 130, 246, 0.3); } -.mode-badge.vql-dt { +.mode-badge.vcl-dt { background: rgba(196, 181, 253, 0.2); color: var(--proof); border: 1px solid rgba(196, 181, 253, 0.3); @@ -344,7 +344,7 @@ body { flex-shrink: 0; } -.status-bar.vql-dt { +.status-bar.vcl-dt { background: #7c3aed; } diff --git a/playground/public/sw.js b/playground/public/sw.js index 5ff03c6..f778a45 100644 --- a/playground/public/sw.js +++ b/playground/public/sw.js @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MPL-2.0 -// Service Worker for VQL Playground PWA — offline support. +// Service Worker for VCL Playground PWA — offline support. -const CACHE_NAME = "vql-playground-v1"; +const CACHE_NAME = "vcl-playground-v1"; const ASSETS = ["/", "/index.html", "/app.js", "/style.css", "/manifest.json"]; self.addEventListener("install", (event) => { diff --git a/playground/rescript.json b/playground/rescript.json index 6d65245..f7f1d55 100644 --- a/playground/rescript.json +++ b/playground/rescript.json @@ -1,5 +1,5 @@ { - "name": "vql-playground", + "name": "vcl-playground", "sources": [ { "dir": "src", diff --git a/playground/src/ApiClient.res b/playground/src/ApiClient.res index 165fdef..263f5d7 100644 --- a/playground/src/ApiClient.res +++ b/playground/src/ApiClient.res @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Playground API client — connects to a real verisim-api backend. +// VCL Playground API client — connects to a real verisim-api backend. // Falls back gracefully to demo mode when the backend is unreachable. -/// Response shape from POST /api/v1/vql/execute. -type vqlResponse = { +/// Response shape from POST /api/v1/vcl/execute. +type vclResponse = { success: bool, statement_type: string, row_count: int, @@ -54,10 +54,10 @@ let checkHealth = async (): result => { } } -/// Execute a VQL query against the real backend. -/// Returns Ok(vqlResponse) on success, Error(string) on failure. -let executeQuery = async (query: string): result => { - let url = getBaseUrl() ++ "/api/v1/vql/execute" +/// Execute a VCL query against the real backend. +/// Returns Ok(vclResponse) on success, Error(string) on failure. +let executeQuery = async (query: string): result => { + let url = getBaseUrl() ++ "/api/v1/vcl/execute" let bodyDict = Dict.make() Dict.set(bodyDict, "query", JSON.Encode.string(query)) let body = JSON.Encode.object(bodyDict) @@ -197,8 +197,8 @@ let formatExplainResponse = (data: JSON.t): string => { text.contents } -/// Convert a VQL response with a JSON data array into a table result. -let formatAsTable = (response: vqlResponse): DemoExecutor.executeResult => { +/// Convert a VCL response with a JSON data array into a table result. +let formatAsTable = (response: vclResponse): DemoExecutor.executeResult => { switch JSON.Classify.classify(response.data) { | JSON.Classify.Array(items) => if Array.length(items) == 0 { @@ -258,9 +258,9 @@ let formatAsTable = (response: vqlResponse): DemoExecutor.executeResult => { } } -/// Convert a VQL API response into a DemoExecutor-compatible result. +/// Convert a VCL API response into a DemoExecutor-compatible result. /// This bridges the real backend response format to the existing rendering code. -let toExecuteResult = (response: vqlResponse): DemoExecutor.executeResult => { +let toExecuteResult = (response: vclResponse): DemoExecutor.executeResult => { if !response.success { DemoExecutor.Error( switch response.message { diff --git a/playground/src/App.res b/playground/src/App.res index 6fdf91c..4c94b8b 100644 --- a/playground/src/App.res +++ b/playground/src/App.res @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Playground — main application entry point. -// Wires up the editor, VQL-DT toggle, linter, formatter, and query executor. +// VCL Playground — main application entry point. +// Wires up the editor, VCL-DT toggle, linter, formatter, and query executor. // Tries the real verisim-api backend first, falls back to demo mode. // === DOM helpers === @@ -13,7 +13,7 @@ let addEventListener = (el: {..}, event: string, handler: {..} => unit): unit => // === State === -let vqlDtMode = ref(false) +let vclDtMode = ref(false) let backendConnected = ref(false) let queryInFlight = ref(false) @@ -28,30 +28,30 @@ let rec init = () => { let statusMode = getElementById("status-mode") let statusBar = getElementById("status-bar") let statusConnection = getElementById("status-connection") - let toggle = getElementById("vql-dt-toggle") + let toggle = getElementById("vcl-dt-toggle") // === Check backend connectivity === checkBackend(statusConnection)->ignore - // === VQL-DT Toggle === + // === VCL-DT Toggle === let updateMode = () => { - if vqlDtMode.contents { + if vclDtMode.contents { toggle["classList"]["add"]("active")->ignore - modeBadge["className"] = "mode-badge vql-dt" - modeBadge["textContent"] = "VQL-DT" - statusMode["textContent"] = "Mode: VQL-DT (Dependent Types)" - statusBar["classList"]["add"]("vql-dt")->ignore + modeBadge["className"] = "mode-badge vcl-dt" + modeBadge["textContent"] = "VCL-DT" + statusMode["textContent"] = "Mode: VCL-DT (Dependent Types)" + statusBar["classList"]["add"]("vcl-dt")->ignore } else { toggle["classList"]["remove"]("active")->ignore - modeBadge["className"] = "mode-badge vql" - modeBadge["textContent"] = "VQL" - statusMode["textContent"] = "Mode: VQL" - statusBar["classList"]["remove"]("vql-dt")->ignore + modeBadge["className"] = "mode-badge vcl" + modeBadge["textContent"] = "VCL" + statusMode["textContent"] = "Mode: VCL" + statusBar["classList"]["remove"]("vcl-dt")->ignore } } addEventListener(toggle, "click", _ => { - vqlDtMode := !vqlDtMode.contents + vclDtMode := !vclDtMode.contents updateMode()->ignore // Re-lint current query let query = editor["value"] @@ -65,7 +65,7 @@ let rec init = () => { let key: string = e["key"] if key == " " || key == "Enter" { e["preventDefault"]() - vqlDtMode := !vqlDtMode.contents + vclDtMode := !vclDtMode.contents updateMode() } }) @@ -128,7 +128,7 @@ let rec init = () => { addEventListener(getElementById("lint-btn"), "click", _ => { let query: string = editor["value"] if String.trim(query) !== "" { - let diagnostics = Linter.lint(query, ~vqlDt=vqlDtMode.contents) + let diagnostics = Linter.lint(query, ~vclDt=vclDtMode.contents) if Array.length(diagnostics) == 0 { output["innerHTML"] = `No lint issues found.` } else { @@ -151,7 +151,7 @@ let rec init = () => { addEventListener(getElementById("format-btn"), "click", _ => { let query: string = editor["value"] if String.trim(query) !== "" { - editor["value"] = Formatter.formatVql(query) + editor["value"] = Formatter.formatVcl(query) // Trigger input event to update char count let inputEvent = document["createEvent"]("Event") inputEvent["initEvent"]("input", true, true)->ignore @@ -167,13 +167,13 @@ let rec init = () => { }) addEventListener(getElementById("examples-btn"), "click", _ => { - let exs = Examples.forMode(vqlDtMode.contents) + let exs = Examples.forMode(vclDtMode.contents) let html = exs ->Array.map(ex => { let escaped = String.replaceAll(String.replaceAll(ex.query, "<", "<"), ">", ">") - let dtBadge = if ex.vqlDt { - ` DT` + let dtBadge = if ex.vclDt { + ` DT` } else { "" } @@ -239,7 +239,7 @@ and executeAndDisplay = (query: string, output: {..}) => { executeOnBackend(query, output)->ignore } else { // Fall back to demo executor (synchronous). - let result = DemoExecutor.execute(query, ~vqlDt=vqlDtMode.contents) + let result = DemoExecutor.execute(query, ~vclDt=vclDtMode.contents) renderResult(result, output) } } @@ -268,7 +268,7 @@ and executeOnBackend = async (query: string, output: {..}): unit => { `Backend error: ${msg}\n` ++ `Falling back to demo mode...` let _ = setTimeout(() => { - let result = DemoExecutor.execute(query, ~vqlDt=vqlDtMode.contents) + let result = DemoExecutor.execute(query, ~vclDt=vclDtMode.contents) renderResult(result, output) }, 300) } @@ -322,7 +322,7 @@ and renderResult = (result: DemoExecutor.executeResult, output: {..}) => { // === Lint helper === and runLint = (query: string, lintBar: {..}) => { - let diagnostics = Linter.lint(query, ~vqlDt=vqlDtMode.contents) + let diagnostics = Linter.lint(query, ~vclDt=vclDtMode.contents) let errors = diagnostics->Array.filter(d => d.severity == Linter.Error)->Array.length let warnings = diagnostics->Array.filter(d => d.severity == Linter.Warning)->Array.length let hints = diagnostics->Array.filter(d => d.severity == Linter.Hint)->Array.length diff --git a/playground/src/DemoExecutor.res b/playground/src/DemoExecutor.res index bfe2273..e68891e 100644 --- a/playground/src/DemoExecutor.res +++ b/playground/src/DemoExecutor.res @@ -15,13 +15,13 @@ type executeResult = | Error(string) /// Generate demo data based on the query modalities. -let execute = (query: string, ~vqlDt: bool=false): executeResult => { +let execute = (query: string, ~vclDt: bool=false): executeResult => { let upper = String.toUpperCase(query) let startTime = Date.now() // EXPLAIN mode if String.includes(upper, "EXPLAIN") { - let modalities = VqlKeywords.modalities->Array.filter(m => String.includes(upper, m)) + let modalities = VclKeywords.modalities->Array.filter(m => String.includes(upper, m)) let plan = ref("=== EXPLAIN OUTPUT ===\n\n") plan := plan.contents ++ "Strategy: " ++ (if Array.length(modalities) >= 2 { "Parallel" } else { "Sequential" }) ++ "\n\n" @@ -41,7 +41,7 @@ let execute = (query: string, ~vqlDt: bool=false): executeResult => { plan := plan.contents ++ ` Selectivity: 0.5\n\n` }) - if vqlDt && String.includes(upper, "PROOF") { + if vclDt && String.includes(upper, "PROOF") { plan := plan.contents ++ "Proof verification: ENABLED\n" plan := plan.contents ++ "ZKP scheme: PLONK\n" plan := plan.contents ++ "Circuit compilation: deferred\n" @@ -57,7 +57,7 @@ let execute = (query: string, ~vqlDt: bool=false): executeResult => { } // SELECT queries — generate demo data else if String.includes(upper, "SELECT") { - let modalities = VqlKeywords.modalities->Array.filter(m => String.includes(upper, m)) + let modalities = VclKeywords.modalities->Array.filter(m => String.includes(upper, m)) if Array.length(modalities) == 0 { Error("No modalities specified in SELECT clause") } else { @@ -72,7 +72,7 @@ let execute = (query: string, ~vqlDt: bool=false): executeResult => { | "GRAPH" => `{edges: ${Int.toString(3 + i)}, type: "Entity"}` | "VECTOR" => `[${Float.toFixed(Float.fromInt(i) *. 0.1, ~digits=2)}, 0.50, 0.30]` | "TENSOR" => `shape=[3,3], dtype=f32` - | "SEMANTIC" => if vqlDt { `{proof: "verified", scheme: "PLONK"}` } else { `{types: ["Thing"]}` } + | "SEMANTIC" => if vclDt { `{proof: "verified", scheme: "PLONK"}` } else { `{types: ["Thing"]}` } | "DOCUMENT" => `"Sample document ${Int.toString(i + 1)}"` | "TEMPORAL" => `{version: ${Int.toString(i + 1)}, ts: "2026-02-28"}` | "PROVENANCE" => `{source: "scan-v1", actor: "hypatia", chain_length: ${Int.toString(i + 1)}}` @@ -93,6 +93,6 @@ let execute = (query: string, ~vqlDt: bool=false): executeResult => { }) } } else { - Error("Unrecognized query — VQL queries must start with SELECT, EXPLAIN, INSERT, UPDATE, or DELETE") + Error("Unrecognized query — VCL queries must start with SELECT, EXPLAIN, INSERT, UPDATE, or DELETE") } } diff --git a/playground/src/Examples.res b/playground/src/Examples.res index cdbcd13..6ecf379 100644 --- a/playground/src/Examples.res +++ b/playground/src/Examples.res @@ -1,107 +1,107 @@ // SPDX-License-Identifier: MPL-2.0 -// Example VQL queries for the playground. -// Covers all 8 octad modalities, real backend queries, and VQL-DT proof types. +// Example VCL queries for the playground. +// Covers all 8 octad modalities, real backend queries, and VCL-DT proof types. type example = { label: string, query: string, - vqlDt: bool, + vclDt: bool, } let examples = [ - // --- Standard VQL examples --- + // --- Standard VCL examples --- { label: "List all hexads", query: "SELECT * FROM hexads LIMIT 10", - vqlDt: false, + vclDt: false, }, { label: "Full-text search", query: "SEARCH TEXT 'multimodal database' LIMIT 10", - vqlDt: false, + vclDt: false, }, { label: "Vector similarity search", query: "SEARCH VECTOR [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8] LIMIT 5", - vqlDt: false, + vclDt: false, }, { label: "Graph traversal", query: "SEARCH RELATED 'entity-1' BY 'relates_to'", - vqlDt: false, + vclDt: false, }, { label: "Insert a hexad", query: "INSERT INTO hexads (title, body)\nVALUES ('My Entity', 'A multimodal entity in VeriSimDB')", - vqlDt: false, + vclDt: false, }, { label: "Show server status", query: "SHOW STATUS", - vqlDt: false, + vclDt: false, }, { label: "Show drift metrics", query: "SHOW DRIFT", - vqlDt: false, + vclDt: false, }, { label: "Explain a query", query: "EXPLAIN SELECT * FROM hexads WHERE id = 'my-entity' LIMIT 1", - vqlDt: false, + vclDt: false, }, { label: "Count hexads", query: "COUNT hexads", - vqlDt: false, + vclDt: false, }, { label: "Multi-modality query (demo)", query: "SELECT GRAPH, VECTOR, DOCUMENT, PROVENANCE\nFROM HEXAD\nWHERE name CONTAINS 'example'\nORDER BY score DESC\nLIMIT 20", - vqlDt: false, + vclDt: false, }, { label: "Temporal query (demo)", query: "SELECT TEMPORAL, PROVENANCE\nFROM HEXAD\nAT TIME '2026-02-28T00:00:00Z'\nWHERE id = 'entity-123'\nLIMIT 1", - vqlDt: false, + vclDt: false, }, { label: "Federation query (demo)", query: "SELECT GRAPH\nFROM FEDERATION STORE 'remote-cluster-1'\nHEXAD\nWHERE region = 'eu-west'\nLIMIT 25", - vqlDt: false, + vclDt: false, }, - // --- VQL-DT examples --- + // --- VCL-DT examples --- { - label: "Proof of existence (VQL-DT)", + label: "Proof of existence (VCL-DT)", query: "SELECT SEMANTIC\nFROM HEXAD\nPROOF EXISTENCE\nTHRESHOLD 0.95\nWHERE type = 'Certificate'\nLIMIT 10", - vqlDt: true, + vclDt: true, }, { - label: "Integrity proof (VQL-DT)", + label: "Integrity proof (VCL-DT)", query: "SELECT SEMANTIC, DOCUMENT\nFROM HEXAD\nPROOF INTEGRITY\nTHRESHOLD 0.99\nWHERE classification = 'audit-trail'\nLIMIT 5", - vqlDt: true, + vclDt: true, }, { - label: "Consistency check (VQL-DT)", + label: "Consistency check (VCL-DT)", query: "SELECT GRAPH, SEMANTIC\nFROM HEXAD\nPROOF CONSISTENCY\nTHRESHOLD 0.9\nWHERE DRIFT THRESHOLD 0.1\nLIMIT 20", - vqlDt: true, + vclDt: true, }, { - label: "Provenance proof (VQL-DT)", + label: "Provenance proof (VCL-DT)", query: "SELECT PROVENANCE, SEMANTIC\nFROM HEXAD\nPROOF PROVENANCE\nTHRESHOLD 0.95\nWHERE source = 'verified-origin'\nLIMIT 10", - vqlDt: true, + vclDt: true, }, { - label: "Freshness proof (VQL-DT)", + label: "Freshness proof (VCL-DT)", query: "SELECT TEMPORAL, SEMANTIC\nFROM HEXAD\nPROOF FRESHNESS\nTHRESHOLD 0.99\nWHERE age_ms < 86400000\nLIMIT 10", - vqlDt: true, + vclDt: true, }, { - label: "Multi-proof composition (VQL-DT)", + label: "Multi-proof composition (VCL-DT)", query: "SELECT SEMANTIC, PROVENANCE, TEMPORAL\nFROM HEXAD\nPROOF EXISTENCE AND INTEGRITY AND FRESHNESS\nTHRESHOLD 0.95\nWHERE type = 'critical-entity'\nLIMIT 5", - vqlDt: true, + vclDt: true, }, ] -let forMode = (vqlDt: bool): array => - examples->Array.filter(e => !e.vqlDt || vqlDt) +let forMode = (vclDt: bool): array => + examples->Array.filter(e => !e.vclDt || vclDt) diff --git a/playground/src/Formatter.res b/playground/src/Formatter.res index 1413149..8ad3a2d 100644 --- a/playground/src/Formatter.res +++ b/playground/src/Formatter.res @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL formatter — canonical formatting for queries. +// VCL formatter — canonical formatting for queries. /// Clause-starting keywords that get their own line. let clauseStarters = [ @@ -8,7 +8,7 @@ let clauseStarters = [ "TRAVERSE", "PROOF", "EXPLAIN", ] -let formatVql = (query: string): string => { +let formatVcl = (query: string): string => { let upper = String.toUpperCase let tokens = String.splitByRe(query, %re("/(\s+|'[^']*'|\"[^\"]*\")/")) @@ -30,7 +30,7 @@ let formatVql = (query: string): string => { result := result.contents ++ trimmed } else { let word = upper(trimmed) - let formatted = if VqlKeywords.isKeyword(word) || VqlKeywords.isModality(word) { + let formatted = if VclKeywords.isKeyword(word) || VclKeywords.isModality(word) { word } else { trimmed diff --git a/playground/src/Highlighter.res b/playground/src/Highlighter.res index 280c0a9..9d0e869 100644 --- a/playground/src/Highlighter.res +++ b/playground/src/Highlighter.res @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL syntax highlighting for the playground editor. +// VCL syntax highlighting for the playground editor. // Produces HTML spans with CSS classes for keyword colouring. -let highlightVql = (text: string, ~vqlDt: bool=false): string => { +let highlightVcl = (text: string, ~vclDt: bool=false): string => { let result = ref("") let chars = String.split(text, "") let len = Array.length(chars) @@ -46,11 +46,11 @@ let highlightVql = (text: string, ~vqlDt: bool=false): string => { let word = String.slice(text, ~start, ~end=i.contents) let upper = String.toUpperCase(word) - if VqlKeywords.isModality(upper) { + if VclKeywords.isModality(upper) { result := result.contents ++ `${word}` - } else if VqlKeywords.isProofType(upper) && vqlDt { + } else if VclKeywords.isProofType(upper) && vclDt { result := result.contents ++ `${word}` - } else if VqlKeywords.isKeyword(upper) { + } else if VclKeywords.isKeyword(upper) { result := result.contents ++ `${word}` } else { result := result.contents ++ word diff --git a/playground/src/Linter.res b/playground/src/Linter.res index 2b06ffa..dbde6be 100644 --- a/playground/src/Linter.res +++ b/playground/src/Linter.res @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL client-side linter — mirrors the Rust linter rules (VQL001–VQL011). +// VCL client-side linter — mirrors the Rust linter rules (VCL001–VCL011). type severity = Hint | Warning | Error @@ -16,7 +16,7 @@ let severityToString = s => | Error => "error" } -let lint = (query: string, ~vqlDt: bool=false): array => { +let lint = (query: string, ~vclDt: bool=false): array => { let diagnostics = [] let upper = String.toUpperCase(query) let tokens = @@ -30,98 +30,98 @@ let lint = (query: string, ~vqlDt: bool=false): array => { let isUpdate = has("UPDATE") let isExplain = has("EXPLAIN") - // VQL001: Missing LIMIT + // VCL001: Missing LIMIT if isSelect && !has("LIMIT") && !isExplain { diagnostics->Array.push({ - code: "VQL001", + code: "VCL001", severity: Warning, message: "Query lacks LIMIT clause — may return unbounded results", }) } - // VQL002: SELECT all modalities + // VCL002: SELECT all modalities if isSelect { let count = - VqlKeywords.modalities->Array.filter(m => has(m))->Array.length + VclKeywords.modalities->Array.filter(m => has(m))->Array.length if count >= 6 { diagnostics->Array.push({ - code: "VQL002", + code: "VCL002", severity: Hint, message: "Query selects " ++ Int.toString(count) ++ " of 8 modalities — consider selecting only what you need", }) } } - // VQL003: Semantic without PROOF + // VCL003: Semantic without PROOF if has("SEMANTIC") && !has("PROOF") && isSelect { diagnostics->Array.push({ - code: "VQL003", - severity: if vqlDt { Error } else { Warning }, + code: "VCL003", + severity: if vclDt { Error } else { Warning }, message: "Semantic modality accessed without PROOF clause", }) } - // VQL004: TRAVERSE without DEPTH + // VCL004: TRAVERSE without DEPTH if has("TRAVERSE") && !has("DEPTH") { diagnostics->Array.push({ - code: "VQL004", + code: "VCL004", severity: Error, message: "TRAVERSE without DEPTH limit — may explore entire graph", }) } - // VQL005: DRIFT without THRESHOLD + // VCL005: DRIFT without THRESHOLD if (has("DRIFT") || has("CONSISTENCY")) && !has("THRESHOLD") { diagnostics->Array.push({ - code: "VQL005", + code: "VCL005", severity: Hint, message: "DRIFT/CONSISTENCY check without THRESHOLD — using implicit default", }) } - // VQL006: ORDER BY without LIMIT + // VCL006: ORDER BY without LIMIT if has("ORDER") && !has("LIMIT") && isSelect { diagnostics->Array.push({ - code: "VQL006", + code: "VCL006", severity: Warning, message: "ORDER BY without LIMIT — sorting potentially unbounded result set", }) } - // VQL007: Dangerous write without WHERE + // VCL007: Dangerous write without WHERE if (isDelete || isUpdate) && !has("WHERE") { diagnostics->Array.push({ - code: "VQL007", + code: "VCL007", severity: Error, message: "DELETE/UPDATE without WHERE clause — affects all entities", }) } - // VQL010: Multi-modality without EXPLAIN + // VCL010: Multi-modality without EXPLAIN if isSelect && !isExplain { let count = - VqlKeywords.modalities->Array.filter(m => has(m))->Array.length + VclKeywords.modalities->Array.filter(m => has(m))->Array.length if count >= 3 { diagnostics->Array.push({ - code: "VQL010", + code: "VCL010", severity: Hint, message: "Multi-modality query — consider running EXPLAIN first", }) } } - // VQL011: FEDERATION without STORE + // VCL011: FEDERATION without STORE if has("FEDERATION") && !has("STORE") { diagnostics->Array.push({ - code: "VQL011", + code: "VCL011", severity: Warning, message: "FEDERATION query without STORE — will query all federated instances", }) } - // VQL-DT specific: PROOF required for all semantic access - if vqlDt && isSelect && has("SEMANTIC") && !has("PROOF") { - // Already covered by VQL003 with Error severity + // VCL-DT specific: PROOF required for all semantic access + if vclDt && isSelect && has("SEMANTIC") && !has("PROOF") { + // Already covered by VCL003 with Error severity ignore() } diff --git a/playground/src/VqlKeywords.res b/playground/src/VclKeywords.res similarity index 87% rename from playground/src/VqlKeywords.res rename to playground/src/VclKeywords.res index 611b613..bfe6670 100644 --- a/playground/src/VqlKeywords.res +++ b/playground/src/VclKeywords.res @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL keyword definitions shared across syntax highlighting, completion, and linting. +// VCL keyword definitions shared across syntax highlighting, completion, and linting. // Updated for the octad architecture (8 modalities) and 11 proof types. let keywords = [ @@ -20,15 +20,15 @@ let modalities = [ "PROVENANCE", "SPATIAL", ] -/// All 11 proof types supported by the VQL-DT type checker. +/// All 11 proof types supported by the VCL-DT type checker. let proofTypes = [ "EXISTENCE", "CONSISTENCY", "INTEGRITY", "PROVENANCE", "FRESHNESS", "ACCESS", "CITATION", "CUSTOM", "ZKP", "PROVEN", "SANCTIFY", ] -/// VQL-DT specific keywords (only active in VQL-DT mode). -let vqlDtKeywords = [ +/// VCL-DT specific keywords (only active in VCL-DT mode). +let vclDtKeywords = [ "PROOF", "THRESHOLD", "VERIFY", "CERTIFY", "ATTEST", "WITNESS", "CIRCUIT", "COMMITMENT", ] diff --git a/src/vql/VQLBidir.res b/src/vcl/VCLBidir.res similarity index 98% rename from src/vql/VQLBidir.res rename to src/vcl/VCLBidir.res index 561b740..427a509 100644 --- a/src/vql/VQLBidir.res +++ b/src/vcl/VCLBidir.res @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Bidirectional Type Inference +// VCL Bidirectional Type Inference // -// Implements bidirectional type checking for VQL queries: +// Implements bidirectional type checking for VCL queries: // - synthesize: infer the type of a query from its structure // - check: verify a query expression has an expected type // @@ -9,17 +9,17 @@ // verifying that all field references, operators, aggregates, and // proof obligations are well-typed. -module AST = VQLParser.AST -module Types = VQLTypes -module Ctx = VQLContext -module Sub = VQLSubtyping +module AST = VCLParser.AST +module Types = VCLTypes +module Ctx = VCLContext +module Sub = VCLSubtyping // ============================================================================ // Type Error // ============================================================================ type typeError = - | SubtypingFailed({expected: Types.vqlType, got: Types.vqlType, reason: string}) + | SubtypingFailed({expected: Types.vclType, got: Types.vclType, reason: string}) | FieldTypeMismatch({field: string, expected: Types.primitiveType, got: Types.primitiveType}) | OperatorTypeMismatch({op: string, leftType: Types.primitiveType, rightType: Types.primitiveType}) | VectorDimensionMismatch({expected: int, got: int}) @@ -49,7 +49,7 @@ type typeError = let formatTypeError = (err: typeError): string => { switch err { | SubtypingFailed({expected, got, reason}) => - `Subtyping failed: expected ${Types.vqlTypeToString(expected)}, got ${Types.vqlTypeToString(got)}: ${reason}` + `Subtyping failed: expected ${Types.vclTypeToString(expected)}, got ${Types.vclTypeToString(got)}: ${reason}` | FieldTypeMismatch({field, expected, got}) => `Field '${field}' type mismatch: expected ${Types.primitiveTypeToString(expected)}, got ${Types.primitiveTypeToString(got)}` | OperatorTypeMismatch({op, leftType, rightType}) => @@ -87,7 +87,7 @@ let formatTypeError = (err: typeError): string => { // Synthesize: Infer type of a complete query // ============================================================================ -type synthesizeResult = Result +type synthesizeResult = Result let synthesizeQuery = (ctx: Ctx.context, query: AST.query): synthesizeResult => { // 1. Resolve modalities to type-level representations @@ -160,7 +160,7 @@ let synthesizeQuery = (ctx: Ctx.context, query: AST.query): synthesizeResult => let checkQuery = ( ctx: Ctx.context, query: AST.query, - expectedType: Types.vqlType, + expectedType: Types.vclType, ): Result => { switch synthesizeQuery(ctx, query) { | Error(e) => Error(e) diff --git a/src/vql/VQLCircuit.res b/src/vcl/VCLCircuit.res similarity index 86% rename from src/vql/VQLCircuit.res rename to src/vcl/VCLCircuit.res index 1c8ff10..2fc2e83 100644 --- a/src/vql/VQLCircuit.res +++ b/src/vcl/VCLCircuit.res @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Circuit DSL — Defines types for custom ZKP circuits in VQL. +// VCL Circuit DSL — Defines types for custom ZKP circuits in VCL. // -// Usage in VQL: +// Usage in VCL: // PROOF CUSTOM "circuit-name" WITH (threshold=0.5, min_score=0.1) /// Gate types available in custom circuits @@ -34,7 +34,7 @@ type constraint = { c: array<(int, float)>, } -/// A circuit definition from VQL PROOF CUSTOM clause +/// A circuit definition from VCL PROOF CUSTOM clause type circuitDef = { name: string, wires: array, @@ -42,7 +42,7 @@ type circuitDef = { parameters: array, } -/// Parameters passed via VQL WITH clause +/// Parameters passed via VCL WITH clause type circuitParams = { values: Js.Dict.t, } @@ -56,7 +56,7 @@ type verificationResult = { totalConstraints: int, } -/// Parse a PROOF CUSTOM clause from VQL +/// Parse a PROOF CUSTOM clause from VCL let parseCustomProof = (circuitName: string, withParams: array<(string, string)>): (string, circuitParams) => { let dict = Js.Dict.empty() withParams->Array.forEach(((key, value)) => { diff --git a/src/vql/VQLContext.res b/src/vcl/VCLContext.res similarity index 97% rename from src/vql/VQLContext.res rename to src/vcl/VCLContext.res index 35d35ff..937ec4f 100644 --- a/src/vql/VQLContext.res +++ b/src/vcl/VCLContext.res @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Context — Typing environment for bidirectional type checking +// VCL Context — Typing environment for bidirectional type checking // // Maintains bindings, contract registry, modality field registries, // and store capabilities. -module Types = VQLTypes +module Types = VCLTypes // ============================================================================ // Contract Specification @@ -32,7 +32,7 @@ type fieldEntry = { // ============================================================================ type context = { - bindings: Js.Dict.t, + bindings: Js.Dict.t, contracts: Js.Dict.t, modalityFields: Js.Dict.t>, storeModalities: Js.Dict.t>, @@ -139,13 +139,13 @@ let defaultContext = (): context => { // Lookup operations // ============================================================================ -let bind = (ctx: context, name: string, ty: Types.vqlType): context => { +let bind = (ctx: context, name: string, ty: Types.vclType): context => { let newBindings = Js.Dict.fromArray(Js.Dict.entries(ctx.bindings)) Js.Dict.set(newBindings, name, ty) {...ctx, bindings: newBindings} } -let lookup = (ctx: context, name: string): option => { +let lookup = (ctx: context, name: string): option => { Js.Dict.get(ctx.bindings, name) } diff --git a/src/vql/VQLError.res b/src/vcl/VCLError.res similarity index 93% rename from src/vql/VQLError.res rename to src/vcl/VCLError.res index 1eed41c..6383693 100644 --- a/src/vql/VQLError.res +++ b/src/vcl/VCLError.res @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MPL-2.0 /** - * VQL Error Types - Structured error representation + * VCL Error Types - Structured error representation * - * Provides comprehensive error types for all VQL failure modes: + * Provides comprehensive error types for all VCL failure modes: * - Parse errors (syntax) * - Type errors (dependent-type verification) * - Runtime errors (execution) @@ -194,13 +194,13 @@ type federationError = { // Composite Error Type // ============================================================================ -type vqlError = +type vclError = | ParseError(parseError) | TypeError(typeError) | RuntimeError(runtimeError) | ModalityError(modalityError) | FederationError(federationError) - | MultipleErrors(array) + | MultipleErrors(array) // ============================================================================ // Error Formatting @@ -398,7 +398,7 @@ let formatFederationError = (err: federationError): string => { `Federation Error [${err.federation_pattern}]: ${kindStr}` } -let format = (err: vqlError): string => { +let format = (err: vclError): string => { switch err { | ParseError(e) => formatParseError(e) | TypeError(e) => formatTypeError(e) @@ -419,7 +419,7 @@ let format = (err: vqlError): string => { // Error Helpers // ============================================================================ -let isRecoverable = (err: vqlError): bool => { +let isRecoverable = (err: vclError): bool => { switch err { | RuntimeError(e) => e.recoverable | FederationError({kind: PartialResults(_)}) => true @@ -428,28 +428,28 @@ let isRecoverable = (err: vqlError): bool => { } } -let getErrorCode = (err: vqlError): string => { +let getErrorCode = (err: vclError): string => { switch err { - | ParseError(_) => "VQL_PARSE_ERROR" - | TypeError(_) => "VQL_TYPE_ERROR" - | RuntimeError({kind: StoreUnavailable(_)}) => "VQL_STORE_UNAVAILABLE" - | RuntimeError({kind: QueryTimeout(_)}) => "VQL_QUERY_TIMEOUT" - | RuntimeError({kind: DriftDetected(_)}) => "VQL_DRIFT_DETECTED" - | RuntimeError({kind: PermissionDenied(_)}) => "VQL_PERMISSION_DENIED" - | RuntimeError({kind: ResourceExhausted(_)}) => "VQL_RESOURCE_EXHAUSTED" - | RuntimeError(_) => "VQL_RUNTIME_ERROR" - | ModalityError(GraphError(_)) => "VQL_GRAPH_ERROR" - | ModalityError(VectorError(_)) => "VQL_VECTOR_ERROR" - | ModalityError(TensorError(_)) => "VQL_TENSOR_ERROR" - | ModalityError(SemanticError(_)) => "VQL_SEMANTIC_ERROR" - | ModalityError(DocumentError(_)) => "VQL_DOCUMENT_ERROR" - | ModalityError(TemporalError(_)) => "VQL_TEMPORAL_ERROR" - | FederationError(_) => "VQL_FEDERATION_ERROR" - | MultipleErrors(_) => "VQL_MULTIPLE_ERRORS" + | ParseError(_) => "VCL_PARSE_ERROR" + | TypeError(_) => "VCL_TYPE_ERROR" + | RuntimeError({kind: StoreUnavailable(_)}) => "VCL_STORE_UNAVAILABLE" + | RuntimeError({kind: QueryTimeout(_)}) => "VCL_QUERY_TIMEOUT" + | RuntimeError({kind: DriftDetected(_)}) => "VCL_DRIFT_DETECTED" + | RuntimeError({kind: PermissionDenied(_)}) => "VCL_PERMISSION_DENIED" + | RuntimeError({kind: ResourceExhausted(_)}) => "VCL_RESOURCE_EXHAUSTED" + | RuntimeError(_) => "VCL_RUNTIME_ERROR" + | ModalityError(GraphError(_)) => "VCL_GRAPH_ERROR" + | ModalityError(VectorError(_)) => "VCL_VECTOR_ERROR" + | ModalityError(TensorError(_)) => "VCL_TENSOR_ERROR" + | ModalityError(SemanticError(_)) => "VCL_SEMANTIC_ERROR" + | ModalityError(DocumentError(_)) => "VCL_DOCUMENT_ERROR" + | ModalityError(TemporalError(_)) => "VCL_TEMPORAL_ERROR" + | FederationError(_) => "VCL_FEDERATION_ERROR" + | MultipleErrors(_) => "VCL_MULTIPLE_ERRORS" } } -let toJson = (err: vqlError): Js.Json.t => { +let toJson = (err: vclError): Js.Json.t => { Js.Dict.fromArray([ ("error_code", Js.Json.string(getErrorCode(err))), ("message", Js.Json.string(format(err))), diff --git a/src/vql/VQLExplain.res b/src/vcl/VCLExplain.res similarity index 97% rename from src/vql/VQLExplain.res rename to src/vcl/VCLExplain.res index fd7abd7..8414538 100644 --- a/src/vql/VQLExplain.res +++ b/src/vcl/VCLExplain.res @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL EXPLAIN - Query Plan Visualization +// VCL EXPLAIN - Query Plan Visualization -module AST = VQLParser.AST +module AST = VCLParser.AST type planNode = { step: int, @@ -46,7 +46,7 @@ let formatPlan = (plan: executionPlan): string => { // Header lines->Js.Array2.push("╔════════════════════════════════════════════════════════════════╗") - lines->Js.Array2.push("║ VQL QUERY EXECUTION PLAN ║") + lines->Js.Array2.push("║ VCL QUERY EXECUTION PLAN ║") lines->Js.Array2.push("╚════════════════════════════════════════════════════════════════╝") lines->Js.Array2.push("") @@ -183,7 +183,7 @@ let explainQuery = (query: string): Result => { switch parseExplain(query) { | Ok((true, actualQuery)) => { // Parse the query - switch VQLParser.parse(actualQuery) { + switch VCLParser.parse(actualQuery) { | Ok(ast) => { // Generate plan (this would call Elixir QueryPlanner) let plan = generatePlanFromAst(ast) @@ -198,7 +198,7 @@ let explainQuery = (query: string): Result => { } // Generate plan based on actual AST analysis (replaces hardcoded mock) -let generatePlanFromAst = (ast: VQLParser.query): executionPlan => { +let generatePlanFromAst = (ast: VCLParser.query): executionPlan => { let nodes = ast.modalities->Belt.Array.mapWithIndex((idx, modality) => { let modalityStr = switch modality { | Graph => "GRAPH" @@ -383,7 +383,7 @@ let generatePlanFromAst = (ast: VQLParser.query): executionPlan => { } // Deprecated: Use generatePlanFromAst instead. Kept for test compatibility only. -let generateMockPlan = (ast: VQLParser.query): executionPlan => { +let generateMockPlan = (ast: VCLParser.query): executionPlan => { let nodes = ast.modalities->Belt.Array.mapWithIndex((idx, modality) => { let modalityStr = switch modality { | Graph => "GRAPH" diff --git a/src/vql/VQLParser.res b/src/vcl/VCLParser.res similarity index 99% rename from src/vql/VQLParser.res rename to src/vcl/VCLParser.res index 8fc89e5..94be0d2 100644 --- a/src/vql/VQLParser.res +++ b/src/vcl/VCLParser.res @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Slipstream Parser - Untyped AST +// VCL Slipstream Parser - Untyped AST // Phase 1: Simple parser for slipstream queries (no dependent types) // ============================================================================ @@ -353,7 +353,7 @@ module Parser = { } // ============================================================================ -// VQL Grammar Parsers +// VCL Grammar Parsers // ============================================================================ module Grammar = { diff --git a/src/vql/VQLParser_test.res b/src/vcl/VCLParser_test.res similarity index 99% rename from src/vql/VQLParser_test.res rename to src/vcl/VCLParser_test.res index e127e92..ccc5f97 100644 --- a/src/vql/VQLParser_test.res +++ b/src/vcl/VCLParser_test.res @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Parser Tests +// VCL Parser Tests -open VQLParser +open VCLParser // Test helper let assertOk = (result: Result<'a, 'b>, testName: string) => { @@ -22,7 +22,7 @@ let assertError = (result: Result<'a, 'b>, testName: string) => { // Test Suite // ============================================================================ -Js.Console.log("\n=== VQL Parser Tests ===\n") +Js.Console.log("\n=== VCL Parser Tests ===\n") // Test 1: Simple hexad query let test1 = ` diff --git a/src/vql/VQLProofObligation.res b/src/vcl/VCLProofObligation.res similarity index 98% rename from src/vql/VQLProofObligation.res rename to src/vcl/VCLProofObligation.res index 9de8c8d..edcaf4e 100644 --- a/src/vql/VQLProofObligation.res +++ b/src/vcl/VCLProofObligation.res @@ -1,13 +1,13 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Proof Obligation — Generates typed proof obligations from queries +// VCL Proof Obligation — Generates typed proof obligations from queries // // For each PROOF spec in a dependent-type query, generates a structured // obligation that the executor must satisfy. Handles multi-proof // composition validation and conflict detection. -module AST = VQLParser.AST -module Types = VQLTypes -module Ctx = VQLContext +module AST = VCLParser.AST +module Types = VCLTypes +module Ctx = VCLContext // ============================================================================ // Proof Obligation Types diff --git a/src/vql/VQLSubtyping.res b/src/vcl/VCLSubtyping.res similarity index 94% rename from src/vql/VQLSubtyping.res rename to src/vcl/VCLSubtyping.res index 26b6f28..cd1092d 100644 --- a/src/vql/VQLSubtyping.res +++ b/src/vcl/VCLSubtyping.res @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Subtyping — Subtype relation for the VQL type system +// VCL Subtyping — Subtype relation for the VCL type system // // Implements the 6 subtyping rules from the formal spec (Section 4): // 1. Reflexivity: t <: t @@ -9,13 +9,13 @@ // 5. Hexad modality contravariance: requesting fewer modalities subtypes requesting more // 6. Refinement subsumption: DEFERRED (needs SMT solver) -module Types = VQLTypes +module Types = VCLTypes type subtypeResult = Result and subtypeError = { - expected: Types.vqlType, - got: Types.vqlType, + expected: Types.vclType, + got: Types.vclType, reason: string, } @@ -37,7 +37,7 @@ let isSubPrimitive = (sub: Types.primitiveType, sup: Types.primitiveType): bool // Core subtype relation // ============================================================================ -let rec isSubtype = (sub: Types.vqlType, sup: Types.vqlType): subtypeResult => { +let rec isSubtype = (sub: Types.vclType, sup: Types.vclType): subtypeResult => { // Rule 1: Reflexivity if Types.eqType(sub, sup) { Ok() @@ -46,7 +46,7 @@ let rec isSubtype = (sub: Types.vqlType, sup: Types.vqlType): subtypeResult => { } } -and checkStructuralSubtype = (sub: Types.vqlType, sup: Types.vqlType): subtypeResult => { +and checkStructuralSubtype = (sub: Types.vclType, sup: Types.vclType): subtypeResult => { switch (sub, sup) { // Primitive widening | (Primitive(ps), Primitive(pp)) => @@ -145,7 +145,7 @@ and checkStructuralSubtype = (sub: Types.vqlType, sup: Types.vqlType): subtypeRe Error({ expected: sup, got: sub, - reason: `${Types.vqlTypeToString(sub)} is not a subtype of ${Types.vqlTypeToString(sup)}`, + reason: `${Types.vclTypeToString(sub)} is not a subtype of ${Types.vclTypeToString(sup)}`, }) } } @@ -178,9 +178,9 @@ and isSubQueryResult = ( // ============================================================================ let transitiveSubtype = ( - a: Types.vqlType, - b: Types.vqlType, - c: Types.vqlType, + a: Types.vclType, + b: Types.vclType, + c: Types.vclType, ): subtypeResult => { switch isSubtype(a, b) { | Ok() => @@ -209,7 +209,7 @@ let transitiveSubtype = ( // Given two types and an operator, check if comparison is valid let checkOperatorTypes = ( leftType: Types.primitiveType, - op: VQLParser.AST.operator, + op: VCLParser.AST.operator, rightType: Types.primitiveType, ): subtypeResult => { // Types must be compatible (one subtype of the other, or same) diff --git a/src/vql/VQLTypeChecker.res b/src/vcl/VCLTypeChecker.res similarity index 96% rename from src/vql/VQLTypeChecker.res rename to src/vcl/VCLTypeChecker.res index 792126c..ec03e92 100644 --- a/src/vql/VQLTypeChecker.res +++ b/src/vcl/VCLTypeChecker.res @@ -1,15 +1,15 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Type Checker — Thin facade over VQLBidir bidirectional type inference +// VCL Type Checker — Thin facade over VCLBidir bidirectional type inference // // Maintains backward-compatible public API (checkQuery, planProofGeneration) -// while delegating to the real type system in VQLBidir. +// while delegating to the real type system in VCLBidir. -module AST = VQLParser.AST -module Error = VQLError -module Types = VQLTypes -module Ctx = VQLContext -module Bidir = VQLBidir -module ProofObl = VQLProofObligation +module AST = VCLParser.AST +module Error = VCLError +module Types = VCLTypes +module Ctx = VCLContext +module Bidir = VCLBidir +module ProofObl = VCLProofObligation // ============================================================================ // Type Context (backward-compatible) @@ -113,7 +113,7 @@ let checkQuery = (query: AST.query, context: typeContext): typeCheckResult => { switch Bidir.synthesizeQuery(bidirCtx, query) { | Ok(_type) => Ok() | Error(typeErr) => - // Convert Bidir.typeError to VQLError.typeError + // Convert Bidir.typeError to VCLError.typeError Error({ kind: Error.TypeMismatch({ expected: "well-typed query", diff --git a/src/vql/VQLTypes.res b/src/vcl/VCLTypes.res similarity index 93% rename from src/vql/VQLTypes.res rename to src/vcl/VCLTypes.res index 3f0a6a1..8b2a32a 100644 --- a/src/vql/VQLTypes.res +++ b/src/vcl/VCLTypes.res @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -// VQL Types — Core type definitions for the bidirectional type checker +// VCL Types — Core type definitions for the bidirectional type checker // // Implements the type system from vcl-type-system.adoc: // - Pi types (dependent function types) @@ -9,7 +9,7 @@ // - Query result types // - Proof types -module AST = VQLParser.AST +module AST = VCLParser.AST // ============================================================================ // Modality Types (type-level representation) @@ -40,19 +40,19 @@ type primitiveType = | TimestampType // ============================================================================ -// Core VQL Type System +// Core VCL Type System // ============================================================================ -type rec vqlType = +type rec vclType = | Primitive(primitiveType) - | ArrayType(vqlType) + | ArrayType(vclType) | ModalityType(modalityType) | HexadType(array) // hexad carrying specific modalities | QueryResultType(queryResultInfo) // result of a SELECT query | ProofType(proofKind, string) // Proof | ProvedResultType(queryResultInfo, proofKind, string) // Sigma(result, proof) - | PiType(string, vqlType, vqlType) // Pi(x, domain, codomain) - | SigmaType(string, vqlType, vqlType) // Sigma(x, fst, snd) + | PiType(string, vclType, vclType) // Pi(x, domain, codomain) + | SigmaType(string, vclType, vclType) // Sigma(x, fst, snd) | UnitType | NeverType @@ -198,10 +198,10 @@ let proofKindToString = (pk: proofKind): string => { } } -let rec vqlTypeToString = (t: vqlType): string => { +let rec vclTypeToString = (t: vclType): string => { switch t { | Primitive(pt) => primitiveTypeToString(pt) - | ArrayType(inner) => `Array<${vqlTypeToString(inner)}>` + | ArrayType(inner) => `Array<${vclTypeToString(inner)}>` | ModalityType(m) => modalityTypeToString(m) | HexadType(mods) => { let modStrs = mods->Belt.Array.map(modalityTypeToString)->Js.Array2.joinWith(", ") @@ -217,9 +217,9 @@ let rec vqlTypeToString = (t: vqlType): string => { `Sigma(QueryResult<${modStrs}>, Proof<${proofKindToString(kind)}, ${contract}>)` } | PiType(x, domain, codomain) => - `Pi(${x}: ${vqlTypeToString(domain)}) -> ${vqlTypeToString(codomain)}` + `Pi(${x}: ${vclTypeToString(domain)}) -> ${vclTypeToString(codomain)}` | SigmaType(x, fst, snd) => - `Sigma(${x}: ${vqlTypeToString(fst)}, ${vqlTypeToString(snd)})` + `Sigma(${x}: ${vclTypeToString(fst)}, ${vclTypeToString(snd)})` | UnitType => "Unit" | NeverType => "Never" } @@ -262,7 +262,7 @@ let eqModalityType = (a: modalityType, b: modalityType): bool => { } } -let rec eqType = (a: vqlType, b: vqlType): bool => { +let rec eqType = (a: vclType, b: vclType): bool => { switch (a, b) { | (Primitive(pa), Primitive(pb)) => eqPrimitiveType(pa, pb) | (ArrayType(ia), ArrayType(ib)) => eqType(ia, ib) diff --git a/vql-bridge/vql_parser_port.js b/vql-bridge/vql_parser_port.js index efd6846..3476dcc 100644 --- a/vql-bridge/vql_parser_port.js +++ b/vql-bridge/vql_parser_port.js @@ -1,54 +1,54 @@ #!/usr/bin/env -S deno run --allow-read // SPDX-License-Identifier: MPL-2.0 -// VQL Parser Port — stdin/stdout JSON bridge for Elixir +// VCL Parser Port — stdin/stdout JSON bridge for Elixir // -// Reads JSON messages (one per line) from stdin, parses VQL queries -// using the compiled ReScript VQLParser, and writes JSON results to stdout. +// Reads JSON messages (one per line) from stdin, parses VCL queries +// using the compiled ReScript VCLParser, and writes JSON results to stdout. // // Protocol: newline-delimited JSON // Request: {"id": 1, "action": "parse", "query": "SELECT ..."} // Response: {"id": 1, "ok": {...ast...}} or {"id": 1, "error": "..."} -// Import compiled ReScript VQL parser and type checker. -// The compiled JS output will be at ../src/vql/*.res.mjs (ReScript compiler output). -let VQLParser; -let VQLTypeChecker; -let VQLBidir; +// Import compiled ReScript VCL parser and type checker. +// The compiled JS output will be at ../src/vcl/*.res.mjs (ReScript compiler output). +let VCLParser; +let VCLTypeChecker; +let VCLBidir; try { - VQLParser = await import("../src/vql/VQLParser.res.mjs"); + VCLParser = await import("../src/vcl/VCLParser.res.mjs"); } catch (_e) { try { // Legacy .bs.js suffix (older ReScript versions) - VQLParser = await import("../src/vql/VQLParser.bs.js"); + VCLParser = await import("../src/vcl/VCLParser.bs.js"); } catch (_e2) { - VQLParser = null; + VCLParser = null; } } try { - VQLTypeChecker = await import("../src/vql/VQLTypeChecker.res.mjs"); + VCLTypeChecker = await import("../src/vcl/VCLTypeChecker.res.mjs"); } catch (_e) { try { - VQLTypeChecker = await import("../src/vql/VQLTypeChecker.bs.js"); + VCLTypeChecker = await import("../src/vcl/VCLTypeChecker.bs.js"); } catch (_e2) { - VQLTypeChecker = null; + VCLTypeChecker = null; } } try { - VQLBidir = await import("../src/vql/VQLBidir.res.mjs"); + VCLBidir = await import("../src/vcl/VCLBidir.res.mjs"); } catch (_e) { try { - VQLBidir = await import("../src/vql/VQLBidir.bs.js"); + VCLBidir = await import("../src/vcl/VCLBidir.bs.js"); } catch (_e2) { - VQLBidir = null; + VCLBidir = null; } } /** - * Minimal VQL parser fallback (when compiled ReScript is unavailable). - * Produces AST compatible with VQLParser.res types. + * Minimal VCL parser fallback (when compiled ReScript is unavailable). + * Produces AST compatible with VCLParser.res types. */ function fallbackParse(query) { const tokens = query.trim().split(/\s+/); @@ -260,8 +260,8 @@ function fallbackParse(query) { } /** - * Minimal VQL mutation parser fallback (INSERT / UPDATE / DELETE). - * Produces AST compatible with VQLParser.res mutation types. + * Minimal VCL mutation parser fallback (INSERT / UPDATE / DELETE). + * Produces AST compatible with VCLParser.res mutation types. */ function fallbackParseMutation(input) { const tokens = input.trim().split(/\s+/); @@ -375,7 +375,7 @@ function fallbackParseMutation(input) { } /** - * Parse a VQL statement (query or mutation) using fallback parser. + * Parse a VCL statement (query or mutation) using fallback parser. */ function fallbackParseStatement(input) { const trimmed = input.trim(); @@ -389,26 +389,26 @@ function fallbackParseStatement(input) { } /** - * Parse a VQL query using the ReScript parser or fallback. + * Parse a VCL query using the ReScript parser or fallback. */ function parseQuery(query, action) { - if (VQLParser) { + if (VCLParser) { let result; switch (action) { case "parse_slipstream": - result = VQLParser.parseSlipstream(query); + result = VCLParser.parseSlipstream(query); break; case "parse_dependent": - result = VQLParser.parseDependentType(query); + result = VCLParser.parseDependentType(query); break; case "parse_mutation": - result = VQLParser.parseMutation(query); + result = VCLParser.parseMutation(query); break; case "parse_statement": - result = VQLParser.parseStatement(query); + result = VCLParser.parseStatement(query); break; default: - result = VQLParser.parse(query); + result = VCLParser.parse(query); } // ReScript Result type: { TAG: "Ok", _0: value } or { TAG: "Error", _0: error } if (result.TAG === "Ok") return { ok: result._0 }; @@ -427,36 +427,36 @@ function parseQuery(query, action) { } // --------------------------------------------------------------------------- -// Type checking: invoke ReScript VQLBidir or extract obligations from AST +// Type checking: invoke ReScript VCLBidir or extract obligations from AST // --------------------------------------------------------------------------- /** - * Type-check a parsed VQL-DT AST. + * Type-check a parsed VCL-DT AST. * - * If compiled ReScript is available, delegates to VQLBidir.synthesizeQuery + * If compiled ReScript is available, delegates to VCLBidir.synthesizeQuery * for full bidirectional type inference. Otherwise, extracts proof obligations * directly from the AST's proof clause — a sound but less precise fallback. * - * @param {object} ast - Parsed VQL query AST + * @param {object} ast - Parsed VCL query AST * @returns {{ ok: object } | { error: string }} - Type info or error */ function typecheckAST(ast) { // Try the full ReScript type checker first - if (VQLBidir) { + if (VCLBidir) { try { - const result = VQLBidir.synthesizeQuery(ast); + const result = VCLBidir.synthesizeQuery(ast); if (result.TAG === "Ok") { return { ok: result._0 }; } return { error: result._0?.message || JSON.stringify(result._0) }; } catch (e) { - // If VQLBidir crashes, fall through to the lightweight fallback + // If VCLBidir crashes, fall through to the lightweight fallback } } - if (VQLTypeChecker) { + if (VCLTypeChecker) { try { - const result = VQLTypeChecker.checkQuery(ast); + const result = VCLTypeChecker.checkQuery(ast); if (result.TAG === "Ok") { return { ok: result._0 }; } @@ -475,7 +475,7 @@ function typecheckAST(ast) { /** * Fallback type checking: extract proof obligations from an AST's proof clause. * - * Returns a structure matching what VQLBidir.synthesizeQuery would produce: + * Returns a structure matching what VCLBidir.synthesizeQuery would produce: * { proof_obligations, composition_strategy, inferred_types } */ function fallbackTypecheck(ast) {