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>
96 lines
2.6 KiB
TypeScript
96 lines
2.6 KiB
TypeScript
import {
|
|
assert,
|
|
assertEquals,
|
|
} from "https://deno.land/std@0.224.0/testing/asserts.ts";
|
|
// import { parse as yamlParse } from "jsr:@std/yaml";
|
|
|
|
/**
|
|
* Proof of Concept: The Constitution (Gen 2)
|
|
*
|
|
* Demonstrates a mechanism to parse an actual markdown file with YAML frontmatter
|
|
* and Markdown AST or structured regex to programmatically restrict an agent's
|
|
* proposed actions. Here we read from real filesystem I/O instead of a string mock.
|
|
*/
|
|
|
|
export async function parseConstitution(filePath: string) {
|
|
const content = await Deno.readTextFile(filePath);
|
|
|
|
const allowedSection = content.match(
|
|
/## Allowed Tech Stack\n([\s\S]*?)(?=##|$)/,
|
|
);
|
|
const deniedSection = content.match(
|
|
/## Denied Libraries\n([\s\S]*?)(?=##|$)/,
|
|
);
|
|
|
|
const allowed = allowedSection
|
|
? allowedSection[1].split("\n").map((l) => l.replace(/^- /, "").trim())
|
|
.filter(Boolean)
|
|
: [];
|
|
const denied = deniedSection
|
|
? deniedSection[1].split("\n").map((l) => l.replace(/^- /, "").trim())
|
|
.filter(Boolean)
|
|
: [];
|
|
|
|
return { allowed, denied };
|
|
}
|
|
|
|
function evaluateAgentProposal(
|
|
proposal: string[],
|
|
allowed: string[],
|
|
denied: string[],
|
|
): { valid: boolean; violations: string[] } {
|
|
const violations = [];
|
|
|
|
for (const tech of proposal) {
|
|
if (denied.includes(tech)) {
|
|
violations.push(`${tech} is explicitly forbidden.`);
|
|
} else if (!allowed.includes(tech)) {
|
|
violations.push(`${tech} is not in the approved tech stack.`);
|
|
}
|
|
}
|
|
|
|
return { valid: violations.length === 0, violations };
|
|
}
|
|
|
|
if (import.meta.main) {
|
|
console.log("Running The Constitution PoC (Gen 2) tests...");
|
|
|
|
try {
|
|
const tempFile = await Deno.makeTempFile({ suffix: ".md" });
|
|
await Deno.writeTextFile(
|
|
tempFile,
|
|
`
|
|
# System Constitution
|
|
|
|
## Allowed Tech Stack
|
|
- Deno
|
|
- TypeScript
|
|
- PostgreSQL
|
|
|
|
## Denied Libraries
|
|
- React
|
|
- MongoDB
|
|
`,
|
|
);
|
|
|
|
const { allowed, denied } = await parseConstitution(tempFile);
|
|
await Deno.remove(tempFile);
|
|
|
|
const safeProposal = ["Deno", "TypeScript"];
|
|
const safeResult = evaluateAgentProposal(safeProposal, allowed, denied);
|
|
assert(safeResult.valid, "Expected safe proposal to be valid");
|
|
|
|
const unsafeProposal = ["Deno", "React", "MongoDB"];
|
|
const unsafeResult = evaluateAgentProposal(unsafeProposal, allowed, denied);
|
|
assert(!unsafeResult.valid, "Expected unsafe proposal to be invalid");
|
|
assertEquals(unsafeResult.violations.length, 2);
|
|
|
|
console.log(
|
|
"✅ The Constitution PoC (Gen 2) successful: Real File I/O constraints parsed and enforced.",
|
|
);
|
|
} catch (err) {
|
|
console.error("❌ The Constitution PoC (Gen 2) failed:", err);
|
|
Deno.exit(1);
|
|
}
|
|
}
|