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>
75 lines
2.4 KiB
TypeScript
75 lines
2.4 KiB
TypeScript
import { assertEquals } from "https://deno.land/std@0.224.0/testing/asserts.ts";
|
|
|
|
/**
|
|
* Proof of Concept: Telemetry parsing (Gen 2)
|
|
*
|
|
* Demonstrates the Analyst agent's ability to ingest structured JSON telemetry
|
|
* by simulating reading actual files from disk rather than hardcoded mock variables.
|
|
*/
|
|
|
|
async function readTelemetry(filePath: string) {
|
|
const data = await Deno.readTextFile(filePath);
|
|
return JSON.parse(data);
|
|
}
|
|
|
|
function analyzeFriction(telemetry: any): string[] {
|
|
const flags = [];
|
|
if (telemetry.metrics.idleHandoffDuration > 4) {
|
|
flags.push("High idle handoff duration detected. Workflow optimization required.");
|
|
}
|
|
if (telemetry.metrics.prCommentToCodeRatio > 0.5) {
|
|
flags.push("High comment-to-code ratio. Potential ambiguity in requirements.");
|
|
}
|
|
return flags;
|
|
}
|
|
|
|
function findPerformanceBottlenecks(trace: any): string[] {
|
|
return trace.spans
|
|
.filter((span: any) => span.duration_ms > 100)
|
|
.map((span: any) => `Bottleneck in ${span.name}: ${span.duration_ms}ms`);
|
|
}
|
|
|
|
if (import.meta.main) {
|
|
console.log("Running Telemetry Parsing PoC (Gen 2) tests...");
|
|
|
|
try {
|
|
const tempFriction = await Deno.makeTempFile({ suffix: ".json" });
|
|
const tempTrace = await Deno.makeTempFile({ suffix: ".json" });
|
|
|
|
await Deno.writeTextFile(tempFriction, JSON.stringify({
|
|
sprint: "Sprint 42",
|
|
metrics: {
|
|
meanTimeToResolution: 14.5,
|
|
prCommentToCodeRatio: 0.8,
|
|
idleHandoffDuration: 5.2,
|
|
},
|
|
}));
|
|
|
|
await Deno.writeTextFile(tempTrace, JSON.stringify({
|
|
traceId: "5b8aa5a2d2c8646c14e4d97e6cdbc134",
|
|
spans: [
|
|
{ name: "db_query", duration_ms: 250 },
|
|
{ name: "serialize_json", duration_ms: 12 },
|
|
{ name: "http_request", duration_ms: 300 },
|
|
],
|
|
}));
|
|
|
|
const frictionData = await readTelemetry(tempFriction);
|
|
const traceData = await readTelemetry(tempTrace);
|
|
|
|
const frictionFlags = analyzeFriction(frictionData);
|
|
assertEquals(frictionFlags.length, 2);
|
|
|
|
const bottlenecks = findPerformanceBottlenecks(traceData);
|
|
assertEquals(bottlenecks.length, 2);
|
|
|
|
await Deno.remove(tempFriction);
|
|
await Deno.remove(tempTrace);
|
|
|
|
console.log("✅ Telemetry Parsing PoC (Gen 2) successful: Parsed telemetry from files.");
|
|
} catch (err) {
|
|
console.error("❌ Telemetry Parsing PoC (Gen 2) failed:", err);
|
|
Deno.exit(1);
|
|
}
|
|
}
|