auth-yes/forum/experiments/git_storage_poc.ts
Tyler Gillispie 4df94c2a19
feat: add agent-forum data structures and experiments (#64)
- Updates `forum/DATA_STRUCTURES.md` with missing concepts: Protocol Buffers, TurboQuant, Git Merkle DAG Diffing, Dependency Graphing, and Declarative Frontmatter (UUIDv7).
- Expands `forum/experiments/lab.ts` with 5 new proofs-of-concept for the new data structures.
- Adds `protobuf_poc.ts`, `merkle_diff_poc.ts`, `vector_db_poc.ts`, `dependency_graph_poc.ts`, and `telemetry_poc.ts`.

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 19:15:51 -07:00

90 lines
2.3 KiB
TypeScript

import {
assertEquals,
} from "https://deno.land/std@0.224.0/testing/asserts.ts";
/**
* Proof of Concept: Git Storage (Notes & Orphan Branches)
*
* This module demonstrates how we can use Deno's `Deno.Command` API to interact
* with Git Notes and Orphan Branches to store agent state and metadata without
* polluting the main working tree.
*/
async function runGitCmd(args: string[]): Promise<string> {
const cmd = new Deno.Command("git", {
args,
stdout: "piped",
stderr: "piped",
});
const output = await cmd.output();
const stdout = new TextDecoder().decode(output.stdout).trim();
const stderr = new TextDecoder().decode(output.stderr).trim();
if (!output.success) {
throw new Error(`Git command failed: git ${args.join(" ")}\n${stderr}`);
}
return stdout;
}
export async function addGitNote(
ref: string,
message: string,
targetRef: string = "HEAD",
) {
// First, check if a note already exists to avoid overwriting blindly
// For this PoC, we will append or overwrite
await runGitCmd([
"notes",
"--ref",
ref,
"add",
"-f",
"-m",
message,
targetRef,
]);
}
export async function readGitNote(
ref: string,
targetRef: string = "HEAD",
): Promise<string> {
try {
return await runGitCmd(["notes", "--ref", ref, "show", targetRef]);
} catch (error: any) {
if (error.message.includes("No note found")) {
return "";
}
throw error;
}
}
// In a real scenario, tests would be separated. For this PoC, we will run the tests here.
if (import.meta.main) {
console.log("Running Git Storage PoC tests...");
// 1. Test Git Notes
const customRef = "forum/test-reasoning";
const testMessage = JSON.stringify({
agent: "poc-agent",
risk: "low",
thought: "This is a hidden thought stored in a git note.",
});
try {
console.log(`Adding note to current HEAD under ref ${customRef}...`);
await addGitNote(customRef, testMessage);
console.log(`Reading note back...`);
const readMessage = await readGitNote(customRef);
assertEquals(readMessage, testMessage);
console.log("✅ Git Notes PoC successful: Read/Write worked as expected.");
// Clean up
await runGitCmd(["notes", "--ref", customRef, "remove", "HEAD"]);
} catch (err) {
console.error("❌ Git Notes PoC failed:", err);
}
}