auth-yes/forum/poc-g2/ontology_poc.ts
Tyler Gillispie e5855248e6
feat: Port all agent-forum-v4 Gen 1 PoCs to Gen 2 using real tooling (#68)
This commit ports the remaining Gen 1 proof-of-concept experiments from `forum/poc-g1` into `forum/poc-g2` while substituting naive mocks with real, production-ready mechanisms.

Key advancements include:
- `code_intelligence_poc.ts` and `cfg_poc.ts`: Swapped regex matching for actual Javascript AST traversal using `acorn`.
- `static_analysis_poc.ts`: Replaced mock payloads with real `deno lint --json` output executed via `Deno.Command`.
- `vector_db_poc.ts` and `multi_vec_poc.ts`: Replaced basic JS arrays with actual `jsr:@db/sqlite` instances utilizing User-Defined Functions (UDFs) to perform native vector cosine similarity queries in memory or on disk.
- `protobuf_poc.ts`: Implemented robust protobuf serialization/deserialization via `protobufjs`.
- Semantic/Governance PoCs (`constitution_poc.ts`, `ontology_poc.ts`, `state_machine_poc.ts`, `orphan_branch_poc.ts`, etc): Replaced string-mock I/O with absolute filesystem reads, real YAML parsing using `jsr:@std/yaml`, and isolated `Deno.Command` Git sandboxes.
- Updated `forum/poc-g2/lab.ts` to orchestrate and execute all 19 experiments, proving 100% test pass rate with Gen 2 tooling.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: mrteye <1945243+mrteye@users.noreply.github.com>
2026-08-28 22:11:53 -07:00

65 lines
1.8 KiB
TypeScript

import { assert, assertEquals } from "https://deno.land/std@0.224.0/testing/asserts.ts";
/**
* Proof of Concept: Ontology Traceability (Gen 2)
*
* Demonstrates extracting JSON-LD semantic requirements from a real markdown file
* and validating that code implementation connects back to the business ontology.
*/
async function extractJsonLD(filePath: string): Promise<any[]> {
const content = await Deno.readTextFile(filePath);
const regex = /```json-ld\n([\s\S]*?)\n```/g;
const blocks = [];
let match;
while ((match = regex.exec(content)) !== null) {
try {
blocks.push(JSON.parse(match[1]));
} catch (e) {
// ignore invalid json
}
}
return blocks;
}
if (import.meta.main) {
console.log("Running Ontology Traceability PoC (Gen 2) tests...");
try {
const tempFile = await Deno.makeTempFile({ suffix: ".md" });
await Deno.writeTextFile(tempFile, `
# System Requirements
This document tracks requirements.
\`\`\`json-ld
{
"@context": "https://schema.org/",
"@type": "Requirement",
"identifier": "REQ-AUTH-01",
"name": "User Passkey Login",
"implementedBy": ["file:///src/auth/login.ts"]
}
\`\`\`
`);
const ontology = await extractJsonLD(tempFile);
await Deno.remove(tempFile);
assertEquals(ontology.length, 1);
const req = ontology[0];
assertEquals(req.identifier, "REQ-AUTH-01");
assertEquals(req["@type"], "Requirement");
// Simulate Gatekeeper verifying traceability
const isTraceable = req.implementedBy && req.implementedBy.length > 0;
assert(isTraceable, "Requirement must be linked to an implementation");
console.log("✅ Ontology Traceability PoC (Gen 2) successful: JSON-LD parsed from real markdown.");
} catch (err) {
console.error("❌ Ontology Traceability PoC (Gen 2) failed:", err);
Deno.exit(1);
}
}