This commit implements the missing Proof of Concepts (PoCs) required by the `agent-forum-v4` architecture blueprint as identified in `CONCEPTS.md`.
Updates include:
- `execution_flywheel_poc.ts`: Implemented mock version (Gen 1) using in-memory state and physical version (Gen 2) utilizing actual file I/O tracking to prove state management bounds.
- `tool_sandbox_poc.ts`: Implemented mock version (Gen 1) yielding simulated telemetry and physical version (Gen 2) utilizing real production-grade tool invocations (Semgrep via CLI and Tree-sitter via WASM module).
- `git_hooks_poc.ts`: Implemented mock version (Gen 1) intercepting simulated events and physical version (Gen 2) configuring a physical Git temp directory executing native `.git/hooks/pre-commit` hooks.
- `BOUNDARIES.md`: Documented explicit technical boundaries in both `poc-g1` and `poc-g2` to enforce strict isolation vs production file-system operation.
- Fixed Deno Linting constraints across `poc-g2/` scripts.
- `CONCEPTS.md`: Status flags updated to ✅.
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>
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
import { assertEquals } from "https://deno.land/std@0.224.0/testing/asserts.ts";
|
|
|
|
/**
|
|
* Proof of Concept: Static Analysis Payloads (Gen 2)
|
|
*
|
|
* Simulates a real CI/CD integration where we spawn Deno.Command to run a local
|
|
* static analysis tool (like deno lint), capture its JSON output, and feed it
|
|
* as structured data for the Adversary agent.
|
|
*/
|
|
|
|
async function runStaticAnalysis(code: string): Promise<any> {
|
|
// Write the temp code to a file
|
|
const tempFile = await Deno.makeTempFile({ suffix: ".ts" });
|
|
await Deno.writeTextFile(tempFile, code);
|
|
|
|
// We use deno lint as our real "static analysis tool" for this PoC
|
|
const command = new Deno.Command("deno", {
|
|
args: ["lint", "--json", tempFile],
|
|
stdout: "piped",
|
|
stderr: "piped",
|
|
});
|
|
|
|
const { stdout } = await command.output();
|
|
const outputStr = new TextDecoder().decode(stdout);
|
|
|
|
// Cleanup
|
|
await Deno.remove(tempFile);
|
|
|
|
try {
|
|
return JSON.parse(outputStr);
|
|
} catch (_e) {
|
|
return { diagnostics: [] }; // Empty if no output or parse error
|
|
}
|
|
}
|
|
|
|
if (import.meta.main) {
|
|
console.log("Running Static Analysis Payloads PoC (Gen 2) tests...");
|
|
|
|
// We write some intentionally bad code that triggers deno lint
|
|
const badCode = `
|
|
const unusedVar = 42;
|
|
function anyFunc(a: any) {
|
|
return a == null;
|
|
}
|
|
`;
|
|
|
|
try {
|
|
const analysisReport = await runStaticAnalysis(badCode) as any;
|
|
|
|
console.log("Agent received real structured static analysis report:");
|
|
console.log(`Found ${analysisReport.diagnostics.length} lint issues.`);
|
|
|
|
// We expect deno lint to catch 'no-unused-vars'
|
|
assertEquals(analysisReport.diagnostics.length > 0, true);
|
|
|
|
const hasUnusedVar = analysisReport.diagnostics.some((e: any) =>
|
|
e.code === "no-unused-vars"
|
|
);
|
|
assertEquals(hasUnusedVar, true);
|
|
|
|
console.log(
|
|
"✅ Static Analysis Payloads PoC (Gen 2) successful: Spawned real tool (deno lint) and parsed JSON payload.",
|
|
);
|
|
} catch (err) {
|
|
console.error("❌ Static Analysis Payloads PoC (Gen 2) failed:", err);
|
|
Deno.exit(1);
|
|
}
|
|
}
|