In this section
- VEDIC Test Translation test · vedic- / tools/test_translation.py lines 1–40
- VEDIC Test V2 Allocation test · vedic- / tools/test_v2_allocation.py lines 1–36
- VEDIC Validate Anatomy ingest · vedic- / tools/validate_anatomy.py lines 1–72
- VEDIC Validate Dictionary ingest · vedic- / tools/validate_dictionary.py lines 1–122
- VEDIC Validate Graph ingest · vedic- / tools/validate_graph.py lines 1–78
- VEDIC Validate Translation ingest · vedic- / tools/validate_translation.py lines 1–65
- VEDIC Validate V2 Allocation ingest · vedic- / tools/validate_v2_allocation.py lines 1–86
- VEDIC Verify Published ingest · vedic- / tools/verify_published.py lines 1–32
- VEDIC Verify Semantic Reuse storage · vedic- / tools/verify_semantic_reuse.mjs lines 1–87
VEDIC Test Translation
A test in the tools folder that checks VEDIC Validate Translation. It is built from the translation tests class (`TranslationTests`).
testvedic- / tools/test_translation.py · lines 1–40 of 40 · Entry point · pattern test_duplicate (shared by 3 files)
- What it does
- It tests its inputs. Defines 7 functions or classes, including TranslationTests, test_valid, test_unknown_target, test_false_identity, test_false_proof. Uses libraries copy, json, hashlib, unittest, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'vedic'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: JSON file translation-geodesy.json; JSON file anatomy.json.
- Downstream impact
- Used directly by 1 file: VEDIC Anatomy Workflow (vedic-).
- What it achieves
- Defines `TranslationTests`, `test_valid`, `test_unknown_target` and 4 more.
- Why it matters
- Run by VEDIC Anatomy Workflow.
- Application
- vedic- · tools · test
- Uses
- VEDIC Validate Translation (import), copy, json, hashlib, unittest, pathlib
- Used by
- run by VEDIC Anatomy Workflow (workflow run)
- Produces
- TranslationTests
- Defines here
- TranslationTests, test_valid, test_unknown_target, test_false_identity, test_false_proof, test_duplicate, test_source
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- vedic-@1c95ee78c2dd3f1f72c0fd5a5f6e247aaf1624e0 tools/test_translation.py:1-40 · blob 0f589bc30fbbb3ae7a0c4210b3938f3c0e916db9 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem · domain stage: agent_infra · users: ai_agent · canonical: unknown
import copy
import json
import hashlib
import unittest
from pathlib import Path
from validate_translation import validate, verify_source
ROOT = Path(__file__).resolve().parents[1]
D = json.loads((ROOT / "data/translation-geodesy.json").read_text())
A = json.loads((ROOT / "data/anatomy.json").read_text())
class TranslationTests(unittest.TestCase):
def test_valid(self):
self.assertEqual(validate(D, A), 5)
def test_unknown_target(self):
d = copy.deepcopy(D)
d["capability"] = "missing"
with self.assertRaises(ValueError): validate(d, A)
def test_false_identity(self):
d = copy.deepcopy(D)
d["records"][0]["family_id"] = 511
with self.assertRaises(ValueError): validate(d, A)
def test_false_proof(self):
d = copy.deepcopy(D)
d["records"][0]["state"] = "TESTED"
with self.assertRaises(ValueError): validate(d, A)
def test_duplicate(self):
d = copy.deepcopy(D)
d["records"].append(d["records"][0])
with self.assertRaises(ValueError): validate(d, A)
def test_source(self):
d = copy.deepcopy(D)
d["records"] = d["records"][:1]
r = d["records"][0]
raw = ("export function " + r["name"] + "(a) {\n return a;\n}\n").encode()
r["source"].update(first=1,last=3,blob=hashlib.sha1(b"blob "+str(len(raw)).encode()+b"\0"+raw).hexdigest())
self.assertEqual(verify_source(d, lambda *args: raw), 1)
with self.assertRaises(ValueError): verify_source(d, lambda *args: raw+b" ")
r["source"]["first"] = 2
with self.assertRaises(ValueError): verify_source(d, lambda *args: raw)VEDIC Test V2 Allocation
A test in the tools folder that checks VEDIC Validate V2 Allocation and VEDIC Validate Dictionary. It sets up (`setUp`) and is built from the v2 tests class (`V2Tests`).
testvedic- / tools/test_v2_allocation.py · lines 1–36 of 36 · Entry point
- What it does
- It tests its inputs. Defines 7 functions or classes, including V2Tests, setUp, test_deterministic_allocation, test_old_entry_mutation, test_duplicate_source. Uses libraries copy, json, unittest, hashlib.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'vedic'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: JSON file tacit15-v2-candidate-decisions.json; JSON file tacit15-v2-allocation.json; JSON file dictionary.json.
- Downstream impact
- Used directly by 1 file: VEDIC Anatomy Workflow (vedic-).
- What it achieves
- Mutation checks for deterministic V2 allocation, independent of the online gate. It reads `data/tacit15-v2-candidate-decisions.json`.
- Why it matters
- Run by VEDIC Anatomy Workflow.
- Application
- vedic- · tools · test
- Uses
- VEDIC Validate V2 Allocation (import), VEDIC Validate Dictionary (import), copy, json, unittest, hashlib
- Used by
- run by VEDIC Anatomy Workflow (workflow run)
- Produces
- V2Tests
- Defines here
- V2Tests, setUp, test_deterministic_allocation, test_old_entry_mutation, test_duplicate_source, test_wrong_blob, test_wrong_span
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- vedic-@1c95ee78c2dd3f1f72c0fd5a5f6e247aaf1624e0 tools/test_v2_allocation.py:1-36 · blob 239ba50cd1206bdae3240d58897e355583492374 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: agent_infra · users: ai_agent · canonical: unknown
"""Mutation checks for deterministic V2 allocation, independent of the online gate."""
import copy
import json
import unittest
from validate_v2_allocation import read, allocate, verify_receipt, git_bytes
from validate_dictionary import verify_source_entries
class V2Tests(unittest.TestCase):
def setUp(self):
self.r=read("data/tacit15-v2-candidate-decisions.json")
self.a=read("data/tacit15-v2-allocation.json")
self.d=json.loads(git_bytes("55ff568b378acff4adae02fb5c758b4f4f8c6bcd", "data/dictionary.json"))
self.old=copy.deepcopy(self.d)
self.old["entries"]=self.old["entries"][:39]
self.old["next_number"]=40
def test_deterministic_allocation(self):
self.assertEqual(allocate(self.old,self.r,self.a),self.d)
self.assertEqual(verify_receipt(self.r,self.a,self.d,self.old),50)
def test_old_entry_mutation(self):
self.d["entries"][0]["application"]["instructions"]="mutated"
with self.assertRaises(ValueError):
verify_receipt(self.r,self.a,self.d,self.old)
def test_duplicate_source(self):
self.r["selected"].append(copy.deepcopy(self.r["selected"][0]))
with self.assertRaises(ValueError):
allocate(self.old,self.r,self.a)
def test_wrong_blob(self):
e=copy.deepcopy(self.d["entries"][39])
with self.assertRaisesRegex(ValueError,"blob mismatch"):
verify_source_entries({"entries":[e]},lambda *args:b"wrong")
def test_wrong_span(self):
import hashlib
e=copy.deepcopy(self.d["entries"][39])
raw=b"function describe(a){\n}\n"
e["source"].update(blob=hashlib.sha1(b"blob "+str(len(raw)).encode()+b"\0"+raw).hexdigest(),first=1,last=3)
with self.assertRaisesRegex(ValueError,"outside file"):
verify_source_entries({"entries":[e]},lambda *args:raw)VEDIC Validate Anatomy
A Python command-line tool in the tools folder that validates VEDIC's read-only anatomy against the pinned producer manifest, using SHA-256. It is built from the get step (`get`).
ingestvedic- / tools/validate_anatomy.py · lines 1–72 of 72 · Entry point · pattern require (shared by 53 files)
- What it does
- It fetches data. Defines require, validate, online, get. Uses libraries argparse, hashlib, json, re, pathlib. Side effects: reads or writes files; makes network requests.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'vedic'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: JSON file current.json; JSON file anatomy.json; command-line arguments.
- Downstream impact
- Used directly by 2 files: VEDIC Test Anatomy (vedic-); VEDIC Anatomy Workflow (vedic-).
- What it achieves
- Defines `require`, `validate`, `online` and 1 more. It accepts `--online`.
- Why it matters
- Run by VEDIC Anatomy Workflow. Checked by VEDIC Test Anatomy.
- Application
- vedic- · tools · Python CLI
- Uses
- argparse, hashlib, json, re, pathlib, urllib.request
- Used by
- imported by VEDIC Test Anatomy (import), run by VEDIC Anatomy Workflow (workflow run)
- Produces
- require, validate, online
- Defines here
- require, validate, online, get
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- vedic-@1c95ee78c2dd3f1f72c0fd5a5f6e247aaf1624e0 tools/validate_anatomy.py:1-72 · blob e018474887e68236b103ccf1bdcb82d0dffc41a6 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem, network · domain stage: agent_infra · users: ai_agent · canonical: unknown
"""Validate VEDIC's read-only anatomy against the pinned producer manifest.
Run python tools/validate_anatomy.py [--online]. No source or release writes.
"""
import argparse
import hashlib
import json
import re
from pathlib import Path
from urllib.request import urlopen
ROOT = Path(__file__).resolve().parents[1]
def require(ok, message):
if not ok:
raise ValueError(message)
def validate(d):
require(d["schema"] == "vedic.anatomy.v1", "schema")
s = d["source"]
require(re.fullmatch(r"[0-9a-f]{40}", s["commit"]), "source commit")
require(re.fullmatch(r"[0-9a-f]{40}", s["git_blob"]), "source blob")
require(s["repo"] == "Ventusltd/gridatlas" and s["manifest"] == "atlas/current.json", "source identity")
bodies = {b["id"]: b for b in d["bodies"]}
require(len(bodies) == len(d["bodies"]) and bodies, "body identity")
for b in bodies.values():
require(re.fullmatch(r"[0-9a-f]{64}", b["sha256"]), "body hash")
require(b["path"].startswith("atlas/") and ".." not in Path(b["path"]).parts, "path")
require(b["unique_lines"] is None and b["proof"] is None, "unmeasured body")
require(b["block_ids"] == [] and b["family_ids"] == [], "unverified IDs")
apps = {a["id"]: a for a in d["apps"]}
require(len(apps) == len(d["apps"]), "app identity")
count = 0
for a in apps.values():
require(a["status"] in {"MANIFEST_DECLARED", "NOT_MAPPED"}, "app state")
require(bool(a["capabilities"]) == (a["status"] == "MANIFEST_DECLARED"), "app coverage")
seen = set()
for c in a["capabilities"]:
require(c["id"] not in seen, "duplicate capability")
seen.add(c["id"])
require(c["body_ids"] and len(set(c["body_ids"])) == len(c["body_ids"]), "membership")
require(set(c["body_ids"]) <= bodies.keys(), "dangling body")
require(c["unique_lines"] is None and c["proof"] is None and c["limit"], "unmeasured capability")
count += 1
return len(apps), count, len(bodies)
def online(d):
s = d["source"]
base = "https://raw.githubusercontent.com/" + s["repo"] + "/" + s["commit"] + "/"
def get(path):
with urlopen(base + path, timeout=30) as r:
return r.read(5_000_001)
raw = get(s["manifest"])
require(hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() == s["git_blob"], "manifest blob differs")
m = json.loads(raw)
require(m["generation"] == s["generation"], "generation differs")
expected = {x["id"]: x for x in m["cartridges"]}
require(set(expected) == {x["id"] for x in d["bodies"]}, "manifest coverage")
for b in d["bodies"]:
e = expected[b["id"]]
require(b["path"] == "atlas/" + e["path"].removeprefix("./"), "path mismatch")
require(b["sha256"] == e["sha256"] and b["declared"] == e.get("capabilities", []), "manifest metadata mismatch")
require(hashlib.sha256(get(b["path"])).hexdigest() == b["sha256"], "source SHA256 mismatch: " + b["id"])
if __name__ == "__main__":
p = argparse.ArgumentParser()
p.add_argument("--online", action="store_true")
args = p.parse_args()
d = json.loads((ROOT / "data/anatomy.json").read_text())
print("apps / capabilities / bodies:", validate(d))
if args.online:
online(d)
print("Pinned manifest and cartridge byte hashes verified.")VEDIC Validate Dictionary
A Python command-line tool in the tools folder that fetches translation geodesy. It verifies source entries (`verify_source_entries`) and is built from the require step (`require`) and the validate step (`validate`).
ingestvedic- / tools/validate_dictionary.py · lines 1–122 of 122 · Entry point · pattern reader (shared by 7 files)
- What it does
- It fetches translation geodesy. Defines require, validate, verify_source_entries, reader. Uses libraries json, hashlib, re, urllib.parse, datetime. Side effects: reads or writes files; makes network requests.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'vedic'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: JSON file dictionary.json; JSON file translation-geodesy.json; command-line arguments.
- Downstream impact
- Used directly by 7 files: VEDIC Allocate Commands (vedic-); VEDIC Family Pulse (vedic-); VEDIC Source Admissions (vedic-); VEDIC Test Dictionary (vedic-); and 3 more. Reached from 7 other entry points, including VEDIC Modular Consumer Workflow (vedic-); VEDIC Daily Operations (vedic-); VEDIC Daily Source Policy (vedic-).
- What it achieves
- Validate the append-only VEDIC dictionary and its initial composition. It accepts `--prior` and `--online`.
- Why it matters
- Imported by 4 files, including VEDIC Allocate Commands, VEDIC Family Pulse and VEDIC Source Admissions. Run by VEDIC Anatomy Workflow. Checked by 2 tests, including VEDIC Test Dictionary.
- Application
- vedic- · tools · Python CLI
- Uses
- VEDIC Source Evidence (import), VEDIC Validate Translation (import), json, hashlib, re, urllib.parse, datetime, pathlib, argparse
- Used by
- imported by VEDIC Allocate Commands (import), imported by VEDIC Family Pulse (import), imported by VEDIC Source Admissions (import), imported by VEDIC Test Dictionary (import), imported by VEDIC Test V2 Allocation (import), imported by VEDIC Validate V2 Allocation (import), run by VEDIC Anatomy Workflow (workflow run)
- Produces
- require, validate, verify_source_entries
- Defines here
- require, validate, verify_source_entries, reader
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- vedic-@1c95ee78c2dd3f1f72c0fd5a5f6e247aaf1624e0 tools/validate_dictionary.py:1-122 · blob 720f5b994a0fbc8c3ba02fa21358e2bcbe9141b8 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, network · domain stage: agent_infra · users: ai_agent · canonical: unknown
"""Validate the append-only VEDIC dictionary and its initial composition."""
import json
import hashlib
from source_evidence import POLICY, POLICY_SCHEMA, POLICY_STATE, source_link, verify_exact_span
from validate_translation import fetch
import re
from urllib.parse import quote
from datetime import datetime
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
# Frozen allocation: do not replace or renumber these entries.
GENESIS = ("MEASURE", "REPRESENT", "VOLTAGE", "DESTINATION", "BEARING", "ORIENT")
DEMO_KEYS = {"distance","point","voltage","destination","bearing","orient"}
def require(ok, message):
if not ok:
raise ValueError(message)
def validate(d, translations, prior=None):
require(d["schema"] == "vedic.dictionary.v1", "wrong schema")
entries = d["entries"]
by_id = {e["gg_id"]: e for e in entries}
by_number = {e["number"]: e for e in entries}
require(len(entries) == len(by_id) == len(by_number), "duplicate identity")
require(len({e["sense_key"] for e in entries}) == len(entries), "duplicate meaning")
require(d["next_number"] == max(by_number, default=0)+1, "wrong next ID")
require(set(by_number) == set(range(1, d["next_number"])), "missing permanent number")
for i, word in enumerate(GENESIS, 1):
require(by_number[i]["word"] == word, "genesis identity changed")
require(by_number[i]["created_utc"] == "2026-11-26T01:35:15Z", "genesis timestamp changed")
require(by_number[i]["creation_evidence"] == "https://github.com/Ventusltd/vedic-/commit/5ddc2e611dbcccb68cc4f7342637fddb912e5ef1", "genesis creation evidence changed")
source = {r["id"]: r for r in translations["records"]}
for e in entries:
require(e["gg_id"] == f'GG2050-VEDIC-{e["number"]:06d}', "invalid GlobalGrid ID")
require(e["demo"] in DEMO_KEYS or (e["demo"] is None and e["kind"] == "FUNCTION" and e["number"] > len(GENESIS) and bool(e.get("demo_unavailable_reason"))), "unregistered demo")
require(isinstance(e["word"], str) and bool(e["word"].strip()), "empty word")
require(bool(re.fullmatch(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z", e["created_utc"])), "timestamp must be UTC")
datetime.fromisoformat(e["created_utc"].replace("Z", "+00:00"))
require(bool(re.fullmatch(r"https://github\.com/Ventusltd/vedic-/commit/[0-9a-f]{40}", e["creation_evidence"])), "missing creation evidence")
for key in ("estate_group","discipline","periodic_category","vedic_class_candidate"):
require(bool(e[key]), "missing classification")
require(e["vedic_class_candidate"] in {"Structure","Movement","Computation","Flow","Data"}, "unknown class")
require(e["classification_state"] == "CURATED_CANDIDATE", "unproven classification")
if e["kind"] == "FUNCTION":
policy = e.get("admission_policy") == POLICY
if e["translation_ref"] not in source:
require(e["demo"] is None, "source-only function cannot claim a demo")
require(all(e.get(k) is None for k in ("family_id","element_id","tablet_id","line_ids","proof")), "unverified identity or proof")
require(all(isinstance(e.get(k), str) and e[k].strip() for k in ("purpose","limits","receipt")), "missing source description")
s = e["source"]
require(bool(re.fullmatch(r"Ventusltd/[A-Za-z0-9_.-]+", s["repo"])), "bad source repo")
require(all(re.fullmatch(r"[0-9a-f]{40}", s[k]) for k in ("commit","blob")), "bad source pin")
require(not s["path"].startswith("/") and ".." not in s["path"].split("/") and bool(s["path"]), "bad source path")
require(type(s["first"]) is int and type(s["last"]) is int and 1 <= s["first"] <= s["last"], "bad source span")
if policy:
receipt = e.get("policy_receipt")
require(isinstance(receipt, dict) and receipt.get("schema") == POLICY_SCHEMA
and receipt.get("policy") == POLICY, "invalid policy receipt")
require(all(isinstance(receipt.get(k), str) and re.fullmatch(r"[0-9a-f]{64}", receipt[k])
for k in ("source_sha256", "contract_sha256")), "invalid policy receipt digest")
require(e["receipt"] == source_link(s), "invalid policy evidence link")
else:
require(re.fullmatch(r"https://github\.com/Ventusltd/neural-link-between-agents/issues/87#issuecomment-[1-9][0-9]*",
e["receipt"]), "missing receipt")
require(e["sense_key"] == "function:" + e["translation_ref"], "invalid function sense key")
require(e["state"] == (POLICY_STATE if policy else "STATIC_SOURCE_REVIEW"), "unsupported proof state")
elif e["kind"] == "COMPOSITION":
require(e["state"] == "DEMO_CANDIDATE", "unsupported composition status")
require(e["composition_mode"] == "shared_inputs", "unsupported composition")
require(e["sense_key"] == "composition:" + e["composition_mode"] + ":" + ",".join(e["components"]), "invalid composition sense key")
components = [by_id[x] for x in e["components"]]
require(len(components) >= 2 and len({x["gg_id"] for x in components}) == len(components), "duplicate or absent components")
require(all(x["number"] < e["number"] for x in components), "forward reference or cycle")
require(all(x["inputs"] == e["inputs"] for x in components), "incompatible component inputs")
else:
raise ValueError("unknown kind")
if prior:
for old in prior["entries"]:
require(old["gg_id"] in by_id, "deleted permanent ID")
for key in ("number","word","kind","translation_ref","components","sense_key","created_utc","creation_evidence","composition_mode"):
require(old.get(key) == by_id[old["gg_id"]].get(key), "changed permanent identity")
return len(entries)
def verify_source_entries(d, reader=None):
raw_cache = {}
legacy_cache = {}
if reader is None:
def reader(repo, commit, path):
return fetch(repo, commit, quote(path, safe="/"))
for e in d["entries"]:
if e["demo"] is not None or "source" not in e:
continue
s = e["source"]
key = (s["repo"],s["commit"],s["path"])
if key not in raw_cache:
raw_cache[key] = reader(*key)
raw = raw_cache[key]
require(len(raw) <= 1_000_000, "source too large")
name = e["translation_ref"].rsplit(":",1)[-1]
if e.get("admission_policy") == POLICY:
verify_exact_span(s, name, raw)
continue
if key not in legacy_cache:
blob = hashlib.sha1(f"blob {len(raw)}\0".encode() + raw).hexdigest()
legacy_cache[key] = (blob, raw.decode("utf-8").splitlines())
blob, lines = legacy_cache[key]
require(blob == s["blob"], f"source blob mismatch {key}: expected {s['blob']}, got {blob}")
require(s["last"] <= len(lines), "source span outside file")
require(re.search(r"\b(?:function\s+"+re.escape(name)+r"\s*\(|"+re.escape(name)+r"\s*:)",lines[s["first"]-1]), f"source start mismatch {e['gg_id']} {name}")
require(lines[s["last"]-1].strip() == "}", f"source end mismatch {e['gg_id']} {name}")
return len(raw_cache)
if __name__ == "__main__":
import argparse
p = argparse.ArgumentParser()
p.add_argument("--prior", type=Path)
p.add_argument("--online", action="store_true")
args = p.parse_args()
d = json.loads((ROOT/"data/dictionary.json").read_text(encoding="utf-8"))
t = json.loads((ROOT/"data/translation-geodesy.json").read_text(encoding="utf-8"))
prior = json.loads(args.prior.read_text(encoding="utf-8")) if args.prior else None
print("Dictionary entries:", validate(d,t,prior))
if args.online:
print("Additional pinned source files:", verify_source_entries(d))VEDIC Validate Graph
A Python command-line tool in the tools folder that reads nearest spider and translation geodesy.
ingestvedic- / tools/validate_graph.py · lines 1–78 of 78 · Entry point · pattern excerpt (shared by 3 files)
- What it does
- It loads nearest spider and translation geodesy. Defines validate, excerpt, occurrence_key, validate_aliases. Uses libraries argparse, hashlib, json, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'vedic'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: JSON file nearest-spider.json; JSON file translation-geodesy.json; command-line arguments.
- Downstream impact
- Used directly by 2 files: VEDIC Test Graph (vedic-); VEDIC Anatomy Workflow (vedic-).
- What it achieves
- It validates aliases (`validate_aliases`) and is built from the validate step (`validate`) and the excerpt step (`excerpt`). Validate the initial static dependency graph. It accepts `--online`.
- Why it matters
- Run by VEDIC Anatomy Workflow. Checked by VEDIC Test Graph.
- Application
- vedic- · tools · Python CLI
- Uses
- VEDIC Validate Translation (import), argparse, hashlib, json, pathlib
- Used by
- imported by VEDIC Test Graph (import), run by VEDIC Anatomy Workflow (workflow run)
- Produces
- validate, occurrence_key, validate_aliases
- Defines here
- validate, excerpt, occurrence_key, validate_aliases
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- vedic-@1c95ee78c2dd3f1f72c0fd5a5f6e247aaf1624e0 tools/validate_graph.py:1-78 · blob 80b5615871033cb66c3f585822703b9c4349e815 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem · domain stage: agent_infra · users: ai_agent · canonical: unknown
"""Validate the initial static dependency graph. No live-use inference."""
import argparse
import hashlib
import json
from pathlib import Path
from validate_translation import fetch, require
ROOT = Path(__file__).resolve().parents[1]
def validate(g, reader=None):
require(g["schema"] == "vedic.static-spider.v1", "schema")
require("not loaded by the live Atlas" in g["scope"], "historical caveat absent")
require(g["receipt"].startswith("https://github.com/Ventusltd/neural-link-between-agents/issues/87#issuecomment-"), "receipt")
nodes = {n["id"]: n for n in g["nodes"]}
require(len(nodes) == len(g["nodes"]) and len(nodes) > 0, "duplicate or empty nodes")
cache = {}
def excerpt(s):
key = (s["repo"], s["commit"], s["path"])
require(key[0] == "Ventusltd/ventus-grid-engine" and key[2] in ("engine/v9-geodesy.js", "engine/v9-nearest-search.js"), "unapproved source")
require(type(s["first"]) is int and type(s["last"]) is int and 1 <= s["first"] <= s["last"], "invalid source range")
if reader is None:
return None
if key not in cache:
cache[key] = reader(*key)
raw = cache[key]
require(hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() == s["blob"], "source blob mismatch")
lines = raw.decode("utf-8").splitlines()
require(s["last"] <= len(lines), "range outside source")
return "\n".join(lines[s["first"]-1:s["last"]])
scope = excerpt(g["scope_source"])
if scope is not None:
require("NOT loaded by the live Atlas" in scope, "historical source caveat not found")
for n in nodes.values():
require(n["id"].startswith("vedic:") and n["rag"] == "grey", "false identity or runtime status")
excerpt(n["source"])
seen = set()
for e in g["edges"]:
key = (e["from"], e["to"], e["type"])
require(key not in seen, "duplicate edge")
seen.add(key)
require(e["from"] in nodes and e["to"] in nodes and e["type"] in {"calls","contains"}, "unknown graph endpoint or relationship")
ev = e["evidence"]
require(bool(ev["contains"]), "missing edge evidence")
text = excerpt(ev)
if text is not None:
require(ev["contains"] in text, "edge evidence absent")
require(bool(seen), "empty graph")
return len(nodes), len(seen)
def occurrence_key(source):
# Physical source range, not a permanent Stars identity.
return tuple(source[k] for k in ("repo", "commit", "path", "blob", "first", "last"))
def validate_aliases(graph, catalogue):
records = catalogue["records"]
by_id = {r["id"]: r for r in records}
by_occurrence = {occurrence_key(r["source"]): r["id"] for r in records}
require(len(by_id) == len(records) == len(by_occurrence), "duplicate catalogue occurrence")
standalone = set()
for n in graph["nodes"]:
key = occurrence_key(n["source"])
alias = n.get("catalogue_ref")
if key in by_occurrence:
require(alias == by_occurrence[key], "shared occurrence must reference catalogue")
else:
require(alias is None, "alias does not match exact source occurrence")
require(key not in standalone, "duplicate standalone graph occurrence")
standalone.add(key)
# Never use this count as global line/family coverage.
return len(by_occurrence) + len(standalone)
if __name__ == "__main__":
p = argparse.ArgumentParser()
p.add_argument("--online", action="store_true")
args = p.parse_args()
graph = json.loads((ROOT / "data/nearest-spider.json").read_text())
print("Static graph nodes / edges:", validate(graph, fetch if args.online else None))
catalogue = json.loads((ROOT / "data/translation-geodesy.json").read_text())
print("Distinct source ranges (not permanent line IDs):", validate_aliases(graph, catalogue))VEDIC Validate Translation
A Python command-line tool in the tools folder that fetches translation geodesy and anatomy from raw.githubusercontent.com.
ingestvedic- / tools/validate_translation.py · lines 1–65 of 65 · Entry point · pattern require (shared by 53 files)
- What it does
- It fetches translation geodesy and anatomy. Defines require, validate, verify_source, fetch. Uses libraries argparse, hashlib, json, re, pathlib. Side effects: reads or writes files; makes network requests.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'vedic'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: data source: raw.githubusercontent.com; JSON file translation-geodesy.json; JSON file anatomy.json; command-line arguments.
- Downstream impact
- Used directly by 8 files: VEDIC Verify Reuse Routes (vedic-); VEDIC Source Admissions (vedic-); VEDIC Stage Demo (vedic-); VEDIC Test Translation (vedic-); and 4 more. Reached from 12 other entry points, including VEDIC Modular Consumer Workflow (vedic-); VEDIC Allocate Commands (vedic-); VEDIC Daily Operations (vedic-).
- What it achieves
- It verifies source (`verify_source`) and is built from the require step (`require`) and the validate step (`validate`). Fail closed on unsupported VEDIC translation claims; read-only source check. It accepts `--online`.
- Why it matters
- Imported by 6 files, including VEDIC Verify Reuse Routes, VEDIC Source Admissions and VEDIC Stage Demo. Run by VEDIC Anatomy Workflow. Checked by VEDIC Test Translation.
- Application
- vedic- · tools · Python CLI
- Uses
- argparse, hashlib, json, re, pathlib, urllib.request
- Used by
- imported by VEDIC Verify Reuse Routes (import), imported by VEDIC Source Admissions (import), imported by VEDIC Stage Demo (import), imported by VEDIC Test Translation (import), imported by VEDIC Validate Dictionary (import), imported by VEDIC Validate Graph (import), imported by VEDIC Validate V2 Allocation (import), run by VEDIC Anatomy Workflow (workflow run)
- Produces
- require, validate, verify_source, fetch
- Defines here
- require, validate, verify_source, fetch
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- vedic-@1c95ee78c2dd3f1f72c0fd5a5f6e247aaf1624e0 tools/validate_translation.py:1-65 · blob 0eee4e16ab718387a4f3b527c6e10fd952132249 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, network · domain stage: agent_infra · users: ai_agent · canonical: unknown
"""Fail closed on unsupported VEDIC translation claims; read-only source check."""
import argparse
import hashlib
import json
import re
from pathlib import Path
from urllib.request import urlopen
ROOT = Path(__file__).resolve().parents[1]
def require(condition, message):
if not condition:
raise ValueError(message)
def validate(data, anatomy):
require(data["schema"] == "vedic.translation.v1", "translation schema")
require(data["receipt"].startswith("https://github.com/Ventusltd/neural-link-between-agents/issues/87#issuecomment-"), "receipt")
apps = [a for a in anatomy["apps"] if a["id"] == data["app"]]
require(len(apps) == 1 and data["capability"] in {c["id"] for c in apps[0]["capabilities"]}, "translation target missing")
require(bool(data["relationship"]), "relationship not explained")
require(bool(data["records"]), "empty translation batch")
ids = set()
for r in data["records"]:
require(r["id"] not in ids, "duplicate translation ID")
ids.add(r["id"])
for key in ("name", "purpose", "inputs", "outputs", "limits", "block_candidate"):
require(isinstance(r[key], str) and bool(r[key].strip()), "missing " + key)
require(r["state"] == "STATIC_SOURCE_REVIEW", "unproven state promotion")
require(r["proof"] is None and r["family_id"] is None and r["line_ids"] is None, "unverified identity or proof")
s = r["source"]
require(s["repo"] == "Ventusltd/ventus-grid-engine" and s["path"] == "engine/v9-geodesy.js", "unexpected producer")
for k in ("commit", "blob"):
require(bool(re.fullmatch(r"[0-9a-f]{40}", s[k])), "bad source " + k)
require(type(s["first"]) is int and type(s["last"]) is int and 1 <= s["first"] <= s["last"], "source range")
return len(ids)
def verify_source(data, reader):
cache = {}
for r in data["records"]:
s = r["source"]
key = (s["repo"], s["commit"], s["path"])
if key not in cache:
cache[key] = reader(*key)
raw = cache[key]
blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
require(blob == s["blob"], "source blob mismatch")
lines = raw.decode("utf-8").splitlines()
require(s["last"] <= len(lines), "range outside source")
excerpt = lines[s["first"]-1:s["last"]]
require(excerpt[0].startswith("export function " + r["name"] + "(") and excerpt[-1] == "}", "function boundary mismatch")
return len(data["records"])
def fetch(repo, commit, path):
with urlopen("https://raw.githubusercontent.com/" + repo + "/" + commit + "/" + path, timeout=30) as response:
return response.read(1_000_001)
if __name__ == "__main__":
p = argparse.ArgumentParser()
p.add_argument("--online", action="store_true")
args = p.parse_args()
d = json.loads((ROOT / "data/translation-geodesy.json").read_text())
a = json.loads((ROOT / "data/anatomy.json").read_text())
print("Translation records:", validate(d, a))
if args.online:
print("Pinned source boundaries verified:", verify_source(d, fetch))VEDIC Validate V2 Allocation
A Python command-line tool in the tools folder that verifies receipt (`verify_receipt`), covering translation geodesy, tacit15 candidate decisions, tacit15 allocation and dictionary, using SHA-256.
ingestvedic- / tools/validate_v2_allocation.py · lines 1–86 of 86 · Entry point · pattern git_bytes (shared by 4 files)
- What it does
- Defines 6 functions or classes, including read, git_bytes, git_blob, allocate, verify_receipt. Uses libraries argparse, hashlib, json, subprocess, pathlib. Side effects: reads or writes files; starts processes.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'vedic'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: JSON file translation-geodesy.json; JSON file tacit15-v2-candidate-decisions.json; JSON file tacit15-v2-allocation.json; JSON file dictionary.json; command-line arguments.
- Downstream impact
- Used directly by 3 files: VEDIC Allocate Commands (vedic-); VEDIC Test V2 Allocation (vedic-); VEDIC Anatomy Workflow (vedic-). Reached from 3 other entry points, including VEDIC Modular Consumer Workflow (vedic-); VEDIC Daily Operations (vedic-); VEDIC Test Daily Operations (vedic-).
- What it achieves
- It is built from the read step (`read`), the git bytes helper (`git_bytes`) and the git blob helper (`git_blob`). Deterministic V2 allocation and source/licence replay; never writes permanent IDs outside this recipe. It reads `data/translation-geodesy.json`. It accepts `--online`.
- Why it matters
- Imported by VEDIC Allocate Commands. Run by VEDIC Anatomy Workflow. Checked by VEDIC Test V2 Allocation.
- Application
- vedic- · tools · Python CLI
- Uses
- VEDIC Validate Translation (import), VEDIC Validate Dictionary (import), argparse, hashlib, json, subprocess, pathlib
- Used by
- imported by VEDIC Allocate Commands (import), imported by VEDIC Test V2 Allocation (import), run by VEDIC Anatomy Workflow (workflow run)
- Produces
- read, git_bytes, git_blob, allocate, verify_receipt, main
- Defines here
- read, git_bytes, git_blob, allocate, verify_receipt, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- vedic-@1c95ee78c2dd3f1f72c0fd5a5f6e247aaf1624e0 tools/validate_v2_allocation.py:1-86 · blob bc11ddf05ffd1d752847539d9ccfebafb6aad5e8 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: agent_infra · users: ai_agent · canonical: unknown
"""Deterministic V2 allocation and source/licence replay; never writes permanent IDs outside this recipe."""
import argparse
import hashlib
import json
import subprocess
from pathlib import Path
from validate_translation import fetch
from validate_dictionary import validate, verify_source_entries, require
ROOT = Path(__file__).resolve().parents[1]
def read(path):
return json.loads((ROOT / path).read_bytes())
def git_bytes(ref, path):
return subprocess.check_output(["git", "show", f"{ref}:{path}"], cwd=ROOT)
def git_blob(raw):
return hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
def allocate(previous, receipt, allocation):
result = json.loads(json.dumps(previous))
for c in receipt["selected"]:
n = result["next_number"]
result["next_number"] += 1
scope = "kuiper" if c["agent"] == 2 else ("gridatlas-search" if "cartridges/" in c["source"]["path"] else "gridatlas-vicinity")
tr = f'tacit15:{scope}:{c["symbol"]}'
entry = dict(number=n, gg_id=f"GG2050-VEDIC-{n:06d}", word=c["word"], kind="FUNCTION",
translation_ref=tr, inputs=c["inputs"], output=c["output"], demo=None,
demo_unavailable_reason="Existing application; exact runtime mapping unverified.",
state="STATIC_SOURCE_REVIEW", estate_group=c["estate_group"], discipline=c["discipline"],
classification_state="CURATED_CANDIDATE", periodic_category=c["periodic_category"],
periodic_block_candidate="Unresolved", vedic_class_candidate=c["vedic_class_candidate"],
created_utc=allocation["created_utc"], sense_key="function:"+tr,
creation_evidence="https://github.com/Ventusltd/vedic-/commit/"+allocation["candidate_receipt_commit"],
priority=2, purpose=c["purpose"], limits=c["limits"], source=c["source"], receipt=c["receipt"],
application=c["application"], family_id=None, element_id=None, tablet_id=None, line_ids=None, proof=None)
for old in result["entries"]:
s, t = old.get("source", {}), entry["source"]
same = all(s.get(k) == t[k] for k in ("repo","commit","path","blob"))
require(not same or s["last"] < t["first"] or t["last"] < s["first"], "overlapping source meaning")
result["entries"].append(entry)
return result
def verify_receipt(receipt, allocation, current, old, online=False, reader=fetch):
require(receipt["proposed"] == len(receipt["selected"])+len(receipt["held"]) == 40, "candidate accounting")
require(len({(c["agent"], c["word"]) for c in receipt["selected"]+receipt["held"]}) == 40, "duplicate candidate")
require(all(c["decision"]=="ACCEPT_CANDIDATE_FOR_CI" and c["span_kind"]=="WHOLE_FUNCTION" for c in receipt["selected"]), "unreviewed candidate")
require(all(c["decision"]=="HELD" and c["reason"] for c in receipt["held"]), "missing hold reason")
require(allocate(old,receipt,allocation)==current, "non-deterministic allocation or modified old entries")
require(len(old["entries"])==allocation["previous_count"] and len(current["entries"])==allocation["new_count"], "row count")
require(current["next_number"]==allocation["next_number"] and len(receipt["held"])==allocation["held"], "identity accounting")
require([{"gg_id":e["gg_id"],"sense_key":e["sense_key"],"source":e["source"]} for e in current["entries"][len(old["entries"]):]]==allocation["accepted"], "allocation receipt mismatch")
validate(current,read("data/translation-geodesy.json"),old)
if online:
verify_source_entries(current, reader)
cache = {}
for c in receipt["selected"]:
s, licence = c["source"], c["licence"]
key = (s["repo"],s["commit"],licence["path"])
if key not in cache:
cache[key] = reader(*key)
raw = cache[key]
require(git_blob(raw)==licence["blob"] and b"Apache License" in raw and b"Version 2.0" in raw, "licence mismatch")
# Emit source excerpt hashes only; do not publish or execute upstream code.
for c in receipt["selected"]:
s=c["source"]
key=(s["repo"],s["commit"],s["path"])
if key not in cache:
cache[key]=reader(*key)
raw=cache[key]
require(git_blob(raw)==s["blob"],"source blob mismatch")
span=b"".join(raw.splitlines(keepends=True)[s["first"]-1:s["last"]])
print(c["word"],hashlib.sha256(span).hexdigest(),flush=True)
return len(current["entries"])
def main():
p=argparse.ArgumentParser()
p.add_argument("--online",action="store_true")
args=p.parse_args()
receipt=read("data/tacit15-v2-candidate-decisions.json")
allocation=read("data/tacit15-v2-allocation.json")
prior=git_bytes(allocation["baseline_commit"],"data/dictionary.json")
source=git_bytes(allocation["candidate_receipt_commit"],"data/tacit15-v2-candidate-decisions.json")
require(git_blob(prior)==allocation["prior_dictionary_blob"],"prior blob mismatch")
require(git_blob(source)==allocation["candidate_receipt_blob"] and source==(ROOT/"data/tacit15-v2-candidate-decisions.json").read_bytes(),"candidate receipt changed")
released_v2 = json.loads(git_bytes("55ff568b378acff4adae02fb5c758b4f4f8c6bcd", "data/dictionary.json"))
current = read("data/dictionary.json")
require(current["entries"][:len(released_v2["entries"])] == released_v2["entries"], "edited V2 entries")
print("Validated historical V2 allocation:", verify_receipt(receipt, allocation, released_v2, json.loads(prior), args.online))
if __name__=="__main__":
main()VEDIC Verify Published
A Python module in the tools folder that verifies public Pages files match exact staged bytes; fail if unavailable, using SHA-256.
ingestvedic- / tools/verify_published.py · lines 1–32 of 32 · Entry point
- What it does
- It fetches data. Uses libraries hashlib, os, time, pathlib, urllib.parse. Side effects: reads or writes files; makes network requests.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'vedic'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Downstream impact
- Used directly by 1 file: VEDIC Anatomy Workflow (vedic-).
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- Run by VEDIC Anatomy Workflow.
- Application
- vedic- · tools · Python module
- Uses
- hashlib, os, time, pathlib, urllib.parse, urllib.request
- Used by
- run by VEDIC Anatomy Workflow (workflow run)
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- vedic-@1c95ee78c2dd3f1f72c0fd5a5f6e247aaf1624e0 tools/verify_published.py:1-32 · blob d68dbf5ba1af0bfcb2c5790460bfab2f5add548f · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem, network · domain stage: agent_infra · users: ai_agent · canonical: unknown
"""Verify public Pages files match exact staged bytes; fail if unavailable."""
import hashlib
import os
import time
from pathlib import Path
from urllib.parse import urljoin
from urllib.request import Request, urlopen
base = os.environ["PAGE_URL"].rstrip("/") + "/"
if not base.startswith("https://"):
raise SystemExit("Missing HTTPS Pages URL")
files = sorted(p for p in Path("_site").rglob("*") if p.is_file() and p.name != ".nojekyll")
if not files:
raise SystemExit("No staged files")
for attempt in range(12):
try:
for p in files:
url = urljoin(base, p.relative_to("_site").as_posix())
req = Request(url, headers={"Cache-Control": "no-cache"})
with urlopen(req, timeout=15) as response:
served = response.read()
expected = p.read_bytes()
if served != expected:
raise ValueError("Served bytes differ: " + url)
print(url, hashlib.sha256(served).hexdigest(), flush=True)
print("Public byte verification passed")
break
except Exception as err:
print(f"Attempt {attempt + 1}: {err}", flush=True)
if attempt == 11:
raise
time.sleep(10)VEDIC Verify Semantic Reuse
A JavaScript module in the tools folder that works with git file (`gitFile`) (units: kV, MVA). It is built from the git file helper (`gitFile`) and the load step (`load`).
storagevedic- / tools/verify_semantic_reuse.mjs · lines 1–87 of 87 · Not reached from any entry point (candidate for review)
- What it does
- Defines gitFile, load. Uses libraries node:assert/strict, node:child_process, node:crypto, node:fs, node:os. Side effects: reads or writes files; starts processes.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'vedic'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: command-line arguments.
- What it achieves
- Replay selected compiled Stars functions and the original firm-capacity engine.
- Why it matters
- No other file in the estate was found to import it.
- Application
- vedic- · tools · JavaScript module
- Uses
- node:assert/strict, node:child_process, node:crypto, node:fs, node:os, node:path, node:url
- Used by
- none found
- Produces
- gitFile, load
- Defines here
- gitFile, load
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- vedic-@1c95ee78c2dd3f1f72c0fd5a5f6e247aaf1624e0 tools/verify_semantic_reuse.mjs:1-87 · blob 53672acd9369987e04786328dea3ab1d85ee47f6 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem, process · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
// Replay selected compiled Stars functions and the original firm-capacity engine.
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { createHash } from 'node:crypto';
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { pathToFileURL } from 'node:url';
const [stars, engine] = process.argv.slice(2);
assert.ok(stars && engine, 'Usage: node tools/verify_semantic_reuse.mjs STARS_REPO ENGINE_REPO');
const starsCommit = '1cf9c7530c7d287ccf9b3cffd70f693fb83c8402';
const engineCommit = '7c2a7b42905674fdcd3aa4bb50af14bc352a7747';
const gitFile = (repo, commit, path, blob) => {
const raw = execFileSync('git', ['-C', repo, 'show', `${commit}:${path}`], {
env: { ...process.env, GIT_NO_LAZY_FETCH: '1', GIT_NO_REPLACE_OBJECTS: '1' },
});
const actual = createHash('sha1').update(`blob ${raw.length}\0`).update(raw).digest('hex');
assert.equal(actual, blob);
return raw;
};
const root = mkdtempSync(join(tmpdir(), 'vedic-semantic-reuse-'));
const load = async (name, raw) => {
const file = join(root, name);
writeFileSync(file, raw);
return import(pathToFileURL(file));
};
try {
const libraryBlob = '0390a4ecbf9d5c7dd171fbd923a58f4be15f05fb';
const library = gitFile(stars, starsCommit, 'library/standalone.mjs', libraryBlob).toString('utf8');
const exportCount = [...library.matchAll(/^export const f\d+_/gm)].length;
assert.equal(exportCount, 766);
const compiledSymbols = ['f8767_representativePoint', 'f8768_voltagesKv', 'f5197_createGeoJSONCircle'];
const excerpts = compiledSymbols.map(name => {
const start = library.indexOf(`\nexport const ${name} = function `);
assert.ok(start >= 0);
const end = library.indexOf('\n// Family #', start + 1);
const excerpt = library.slice(start + 1, end).trimEnd();
assert.ok(excerpt.endsWith('};') && !excerpt.includes('\nexport '));
return excerpt;
});
const compiled = await load('compiled-excerpts.mjs', excerpts.join('\n'));
const geodesy = await load('geodesy.mjs', gitFile(engine, engineCommit, 'engine/v9-geodesy.js',
'14023f06d4ef2ea806437863bd35dee954c46b11'));
const firm = await load('firm.mjs', gitFile(engine, engineCommit, 'engine/firm-capacity.js',
'8c87c71f29cc27970305c3109efeb22b66fbe568'));
const checks = [
[compiled.f8767_representativePoint, geodesy.representativePoint, null, null],
[compiled.f8767_representativePoint, geodesy.representativePoint,
{ type: 'Point', coordinates: [-2, 52, 15] }, [-2, 52]],
[compiled.f8767_representativePoint, geodesy.representativePoint,
{ type: 'Polygon', coordinates: [[[0, 0], [8, 0], [0, 8], [0, 0]]] }, [2, 2]],
[compiled.f8768_voltagesKv, geodesy.voltagesKv, null, []],
[compiled.f8768_voltagesKv, geodesy.voltagesKv, { kv: '132;33;132' }, [132, 33]],
[compiled.f8768_voltagesKv, geodesy.voltagesKv, { KV: '33;0', VOLTAGE: '33000;11000' }, [33, 11]],
];
for (const [a, b, value, expected] of checks) {
assert.deepEqual(a(value), expected);
assert.deepEqual(b(value), expected);
}
const vertex = compiled.f5197_createGeoJSONCircle(0, 80, 500).features[0].geometry.coordinates[0][0];
const compiledRadiusKm = geodesy.distanceKm(0, 80, ...vertex);
assert.ok(Math.abs(compiledRadiusKm - 500) > 1);
const boundary = firm.assessAgainstFirm({ units: [20, 15], demandMva: 15 });
assert.deepEqual([boundary.withinFirm, boundary.firmMva, boundary.shortfallMva], [true, 15, 0]);
const excess = firm.assessAgainstFirm({ units: [20, 15], demandMva: 16 });
assert.deepEqual([excess.withinFirm, excess.withinInstalled, excess.shortfallMva], [false, true, 1]);
const single = firm.assessAgainstFirm({ units: [20], demandMva: 10 });
assert.deepEqual([single.withinFirm, single.firmMva, single.utilisationOfFirm], [false, 0, Infinity]);
assert.throws(() => firm.assessAgainstFirm({ units: [], demandMva: 10 }));
assert.throws(() => firm.assessAgainstFirm({ units: [20] }));
console.log(JSON.stringify({
starsCommit, engineCommit, libraryBlob, exportCount,
existingCompiledMatches: ['GG2050-VEDIC-000002', 'GG2050-VEDIC-000003'],
compiledParityCases: checks.length,
withheldGeodesicAlias: { familyId: 5197, requestedRadiusKm: 500, actualVertexDistanceKm: compiledRadiusKm },
firmCapacityCases: 5, zeroFirmUtilisation: 'Infinity',
packageAdmissions: 0,
}, null, 2));
} finally {
rmSync(root, { recursive: true });
}