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>
This commit is contained in:
parent
9cef5715d4
commit
4df94c2a19
@ -4,6 +4,12 @@ This document serves as the comprehensive list and reference for all data struct
|
|||||||
|
|
||||||
## 1. Storage Layers (Git-Native Storage)
|
## 1. Storage Layers (Git-Native Storage)
|
||||||
|
|
||||||
|
### 1.0 Protocol Buffers (Protobuf)
|
||||||
|
- **Purpose**: Facilitates high-performance, conversion-less data transfer between agents.
|
||||||
|
- **Content**: Serialized binary representations of agent state, telemetry, and index data.
|
||||||
|
- **Integration**: Works natively with SCIP indexes and TurboQuant compressed vector math to drastically reduce I/O latency.
|
||||||
|
|
||||||
|
|
||||||
### 1.1 Git Notes (`refs/notes/commits`)
|
### 1.1 Git Notes (`refs/notes/commits`)
|
||||||
- **Purpose**: Attaches arbitrary metadata directly to Git commits without altering the commit hash or polluting the working directory.
|
- **Purpose**: Attaches arbitrary metadata directly to Git commits without altering the commit hash or polluting the working directory.
|
||||||
- **Content**: Primarily JSON payloads containing:
|
- **Content**: Primarily JSON payloads containing:
|
||||||
@ -25,8 +31,19 @@ This document serves as the comprehensive list and reference for all data struct
|
|||||||
- **Content**: Highly compressed, quantized embeddings of concepts (PRDs, ADRs, documentation).
|
- **Content**: Highly compressed, quantized embeddings of concepts (PRDs, ADRs, documentation).
|
||||||
- **Structure**: Isolated SQLite files (e.g., `docs_graph.sqlite`, `telemetry_graph.sqlite`) to prevent cross-contamination of semantic data.
|
- **Structure**: Isolated SQLite files (e.g., `docs_graph.sqlite`, `telemetry_graph.sqlite`) to prevent cross-contamination of semantic data.
|
||||||
|
|
||||||
|
### 1.4 TurboQuant
|
||||||
|
- **Purpose**: Compresses high-dimensional semantic concepts into binary hashes using 2-bit to 4-bit quantization.
|
||||||
|
- **Content**: Extremely lightweight local embedded indexes (often under 30MB) facilitating millisecond vector search inside `sqlite-vec`.
|
||||||
|
|
||||||
|
|
||||||
## 2. Process & Governance Structures
|
## 2. Process & Governance Structures
|
||||||
|
|
||||||
|
### 2.0 Declarative Frontmatter (YAML UUIDs)
|
||||||
|
- **Purpose**: Uniquely identifies Markdown artifacts to maintain traceability within the project DAG and the vector databases.
|
||||||
|
- **Content**: YAML blocks containing a unique UUID (Artifact-ID).
|
||||||
|
- **Format Note**: MUST be compatible with UUIDv7 (time-ordered) to allow historical sorting and chronological sequence inference directly from the identifier, acting as a strict primary key.
|
||||||
|
|
||||||
|
|
||||||
### 2.1 The Project DAG (YAML)
|
### 2.1 The Project DAG (YAML)
|
||||||
- **Purpose**: Replaces traditional flat project management tools (like Jira or Markdown task lists). Dictates execution order mathematically.
|
- **Purpose**: Replaces traditional flat project management tools (like Jira or Markdown task lists). Dictates execution order mathematically.
|
||||||
- **Content**: YAML files representing a Directed Acyclic Graph.
|
- **Content**: YAML files representing a Directed Acyclic Graph.
|
||||||
@ -47,6 +64,11 @@ This document serves as the comprehensive list and reference for all data struct
|
|||||||
|
|
||||||
## 3. Code Intelligence Structures
|
## 3. Code Intelligence Structures
|
||||||
|
|
||||||
|
### 3.0 Git Merkle DAG Diffing
|
||||||
|
- **Purpose**: Ensures O(1) context updates for agents by identifying exact modified file hashes without reading raw file strings.
|
||||||
|
- **Content**: Hashes resulting from zero-overhead diffing (e.g., `git ls-tree` and `git diff-tree`).
|
||||||
|
|
||||||
|
|
||||||
### 3.1 SCIP Indexes (Semantic Code Intelligence Protocol)
|
### 3.1 SCIP Indexes (Semantic Code Intelligence Protocol)
|
||||||
- **Purpose**: Replaces unreliable regex-based searching with a statically guaranteed mapping of code symbols.
|
- **Purpose**: Replaces unreliable regex-based searching with a statically guaranteed mapping of code symbols.
|
||||||
- **Content**: A lightweight database mapping definitions, references, and relationships across the codebase. Extracted typically via Tree-sitter.
|
- **Content**: A lightweight database mapping definitions, references, and relationships across the codebase. Extracted typically via Tree-sitter.
|
||||||
@ -59,6 +81,10 @@ This document serves as the comprehensive list and reference for all data struct
|
|||||||
- **Purpose**: Represents the "blast radius" and effectiveness of test suites.
|
- **Purpose**: Represents the "blast radius" and effectiveness of test suites.
|
||||||
- **Content**: Structured outputs from tools like Stryker or Mutmut that indicate how many injected bugs were successfully caught by the test physics.
|
- **Content**: Structured outputs from tools like Stryker or Mutmut that indicate how many injected bugs were successfully caught by the test physics.
|
||||||
|
|
||||||
|
### 3.4 Dependency Graphing (Adjacency Matrices)
|
||||||
|
- **Purpose**: Mathematically calculates the exact "blast radius" of any code change.
|
||||||
|
- **Content**: Adjacency matrices (generated by tools like CodeSee or Madge) that map the downstream and upstream impact across components.
|
||||||
|
|
||||||
## 4. Semantic & Telemetry Structures
|
## 4. Semantic & Telemetry Structures
|
||||||
|
|
||||||
### 4.1 Ontologies (JSON-LD)
|
### 4.1 Ontologies (JSON-LD)
|
||||||
|
|||||||
@ -2,41 +2,103 @@
|
|||||||
|
|
||||||
## 1. Overview & Usefulness
|
## 1. Overview & Usefulness
|
||||||
|
|
||||||
The `agent-forum-v4` blueprint outlines a "Git-Native Agent Collaboration Ecosystem." By shifting from flat Markdown files to structured data (YAML DAGs, SCIP indexes, local vector graphs), the protocol addresses a core limitation of modern AI agents: context window collapse and dependency amnesia.
|
The `agent-forum-v4` blueprint outlines a "Git-Native Agent Collaboration
|
||||||
|
Ecosystem." By shifting from flat Markdown files to structured data (YAML DAGs,
|
||||||
|
SCIP indexes, local vector graphs), the protocol addresses a core limitation of
|
||||||
|
modern AI agents: context window collapse and dependency amnesia.
|
||||||
|
|
||||||
**Solving the Pain Points:**
|
**Solving the Pain Points:** You noted that agents frequently lose context and
|
||||||
You noted that agents frequently lose context and struggle to understand if they are fulfilling requirements without constant spoon-feeding. The proposed shift to a **Semantic Project Management** system directly solves this:
|
struggle to understand if they are fulfilling requirements without constant
|
||||||
- **Dependencies:** Instead of relying on an agent to read a folder and "figure out" what to do, the system uses strict YAML Directed Acyclic Graphs (DAGs). An Evaluator script mathematically determines the critical path. An agent is only ever handed an explicitly unblocked task.
|
spoon-feeding. The proposed shift to a **Semantic Project Management** system
|
||||||
- **Context:** Instead of feeding the agent the entire codebase as raw text, the system uses Git Merkle DAG diffing and embedded SQLite vector search to feed the agent precisely the context it needs in milliseconds.
|
directly solves this:
|
||||||
|
|
||||||
|
- **Dependencies:** Instead of relying on an agent to read a folder and "figure
|
||||||
|
out" what to do, the system uses strict YAML Directed Acyclic Graphs (DAGs).
|
||||||
|
An Evaluator script mathematically determines the critical path. An agent is
|
||||||
|
only ever handed an explicitly unblocked task.
|
||||||
|
- **Context:** Instead of feeding the agent the entire codebase as raw text, the
|
||||||
|
system uses Git Merkle DAG diffing and embedded SQLite vector search to feed
|
||||||
|
the agent precisely the context it needs in milliseconds.
|
||||||
|
|
||||||
## 2. Compatibility with the Repository
|
## 2. Compatibility with the Repository
|
||||||
|
|
||||||
The Auth-Yes repository is characterized by a strict, zero-dependency, hermetic environment prioritizing Deno, minimal external SaaS dependencies, and self-contained runtime operations.
|
The Auth-Yes repository is characterized by a strict, zero-dependency, hermetic
|
||||||
|
environment prioritizing Deno, minimal external SaaS dependencies, and
|
||||||
|
self-contained runtime operations.
|
||||||
|
|
||||||
- **High Alignment:** The agent-forum's philosophy of "Local-First / Git-Native" is in perfect harmony with your project's ethos. Eliminating third-party databases in favor of Git Notes and orphan branches ensures the protocol remains portable, cryptographically secure, and isolated.
|
- **High Alignment:** The agent-forum's philosophy of "Local-First / Git-Native"
|
||||||
- **Implementation Challenges:** The blueprint relies heavily on advanced tooling (Tree-sitter, SCIP, `sqlite-vec`). Integrating these into a Deno environment without polluting the repository with heavy binary dependencies will require careful execution. We should lean towards WebAssembly (WASM) ports of these tools (e.g., `tree-sitter.wasm`, or Deno's native FFI for SQLite) to keep the repository lightweight.
|
is in perfect harmony with your project's ethos. Eliminating third-party
|
||||||
|
databases in favor of Git Notes and orphan branches ensures the protocol
|
||||||
|
remains portable, cryptographically secure, and isolated.
|
||||||
|
- **Implementation Challenges:** The blueprint relies heavily on advanced
|
||||||
|
tooling (Tree-sitter, SCIP, `sqlite-vec`). Integrating these into a Deno
|
||||||
|
environment without polluting the repository with heavy binary dependencies
|
||||||
|
will require careful execution. We should lean towards WebAssembly (WASM)
|
||||||
|
ports of these tools (e.g., `tree-sitter.wasm`, or Deno's native FFI for
|
||||||
|
SQLite) to keep the repository lightweight.
|
||||||
|
|
||||||
## 3. Isolation Strategy (Preventing Bleed)
|
## 3. Isolation Strategy (Preventing Bleed)
|
||||||
|
|
||||||
To ensure this new protocol does not interfere with the primary intent of Auth-Yes or other target projects, we must implement strict physical and logical boundaries:
|
To ensure this new protocol does not interfere with the primary intent of
|
||||||
|
Auth-Yes or other target projects, we must implement strict physical and logical
|
||||||
|
boundaries:
|
||||||
|
|
||||||
1. **The `.forum/` (or `.agents/`) Namespace:** All protocol-specific files, state machines (`transitions.json`), schemas, and tooling scripts must be entirely contained within a hidden root directory (e.g., `.forum/`). The target repository should have zero awareness of these files.
|
1. **The `.forum/` (or `.agents/`) Namespace:** All protocol-specific files,
|
||||||
2. **Git Meta-State (Orphan Branches):** The most powerful isolation technique proposed is the use of an Orphan Branch. Dynamic state (telemetry, task completion status, graphs) will be committed to a branch (e.g., `forum/meta-state`) that shares no history with `main`. This ensures the primary branch's `git log` remains pristine and untouched by agent automation.
|
state machines (`transitions.json`), schemas, and tooling scripts must be
|
||||||
3. **Git Notes for Meta-Thoughts:** By using custom Git Note refs (e.g., `refs/notes/forum/reasoning`), agents can attach vast amounts of JSON metadata, risk assessments, and historical context to a commit without altering the commit hash or the working directory tree.
|
entirely contained within a hidden root directory (e.g., `.forum/`). The
|
||||||
|
target repository should have zero awareness of these files.
|
||||||
|
2. **Git Meta-State (Orphan Branches):** The most powerful isolation technique
|
||||||
|
proposed is the use of an Orphan Branch. Dynamic state (telemetry, task
|
||||||
|
completion status, graphs) will be committed to a branch (e.g.,
|
||||||
|
`forum/meta-state`) that shares no history with `main`. This ensures the
|
||||||
|
primary branch's `git log` remains pristine and untouched by agent
|
||||||
|
automation.
|
||||||
|
3. **Git Notes for Meta-Thoughts:** By using custom Git Note refs (e.g.,
|
||||||
|
`refs/notes/forum/reasoning`), agents can attach vast amounts of JSON
|
||||||
|
metadata, risk assessments, and historical context to a commit without
|
||||||
|
altering the commit hash or the working directory tree.
|
||||||
|
|
||||||
## 4. Adapting the Legacy `/tasks` Workflow
|
## 4. Adapting the Legacy `/tasks` Workflow
|
||||||
|
|
||||||
You mentioned appreciating the file naming conventions (visual history), risk assessments, and meta-thoughts of the old system. The goal is to preserve the *value* of these features while upgrading their *format* to be machine-readable.
|
You mentioned appreciating the file naming conventions (visual history), risk
|
||||||
|
assessments, and meta-thoughts of the old system. The goal is to preserve the
|
||||||
|
_value_ of these features while upgrading their _format_ to be machine-readable.
|
||||||
|
|
||||||
- **UUIDv7 & Legacy Identifiers:** To align with the strict blueprint, **UUIDv7** will be the primary and required identifier (Artifact-ID/Key) for all items in YAML DAGs. The old file naming convention (`YYYY-MMDD.[sequence]...[short-description]`) will be stored strictly as an optional `legacy_slug` metadata field inside the YAML structure. This preserves visual history and backwards compatibility for human readers while completely detaching it from filenames and the core machine-communication ID system, avoiding string-parsing errors or pollution of the core concept.
|
- **UUIDv7 & Legacy Identifiers:** To align with the strict blueprint,
|
||||||
- **Visual History:** To preserve the human visual experience, a simple Deno script (e.g., `deno task forum:view`) can parse the DAG and the optional `legacy_slug` metadata from the orphan branch history to output an interactive terminal UI or a generated HTML report showing the exact progression of work.
|
**UUIDv7** will be the primary and required identifier (Artifact-ID/Key) for
|
||||||
- **Risk Assessment & Meta-Thoughts:** In the old system, these were markdown headers. In the new system, an "Adversary" agent will generate these risk assessments as structured JSON. We will store this JSON in **Git Notes** attached to the relevant commits. This ensures the data is tightly coupled to the code changes, never gets lost in a stale markdown file, and can be queried instantly by other agents.
|
all items in YAML DAGs. The old file naming convention
|
||||||
- **Human-Readable Projections:** If we ever need a standard Markdown view, a "Translator" agent or script can compile the DAGs, Git Notes, and ASTs and generate a static `tasks-report.md` on demand.
|
(`YYYY-MMDD.[sequence]...[short-description]`) will be stored strictly as an
|
||||||
|
optional `legacy_slug` metadata field inside the YAML structure. This
|
||||||
|
preserves visual history and backwards compatibility for human readers while
|
||||||
|
completely detaching it from filenames and the core machine-communication ID
|
||||||
|
system, avoiding string-parsing errors or pollution of the core concept.
|
||||||
|
- **Visual History:** To preserve the human visual experience, a simple Deno
|
||||||
|
script (e.g., `deno task forum:view`) can parse the DAG and the optional
|
||||||
|
`legacy_slug` metadata from the orphan branch history to output an interactive
|
||||||
|
terminal UI or a generated HTML report showing the exact progression of work.
|
||||||
|
- **Risk Assessment & Meta-Thoughts:** In the old system, these were markdown
|
||||||
|
headers. In the new system, an "Adversary" agent will generate these risk
|
||||||
|
assessments as structured JSON. We will store this JSON in **Git Notes**
|
||||||
|
attached to the relevant commits. This ensures the data is tightly coupled to
|
||||||
|
the code changes, never gets lost in a stale markdown file, and can be queried
|
||||||
|
instantly by other agents.
|
||||||
|
- **Human-Readable Projections:** If we ever need a standard Markdown view, a
|
||||||
|
"Translator" agent or script can compile the DAGs, Git Notes, and ASTs and
|
||||||
|
generate a static `tasks-report.md` on demand.
|
||||||
|
|
||||||
## 5. Proposed Experimental Path (Proof of Concept)
|
## 5. Proposed Experimental Path (Proof of Concept)
|
||||||
|
|
||||||
We will not build the fully automated loop yet. Instead, we will build foundational experiments in `forum/experiments/` to verify the hard concepts:
|
We will not build the fully automated loop yet. Instead, we will build
|
||||||
|
foundational experiments in `forum/experiments/` to verify the hard concepts:
|
||||||
|
|
||||||
1. **Git Storage PoC (`git_storage_poc.ts`):** Verify that Deno can programmatically read/write to Git Notes and manipulate an orphan branch without disrupting the current working tree. This proves we can store agent state invisibly.
|
1. **Git Storage PoC (`git_storage_poc.ts`):** Verify that Deno can
|
||||||
2. **DAG Engine PoC (`dag_engine_poc.ts`):** Create a minimal script that parses a YAML task graph, resolves dependencies (`blocked_by`), and mathematically outputs the exact next task an agent should work on.
|
programmatically read/write to Git Notes and manipulate an orphan branch
|
||||||
3. **Local Intelligence PoC (`code_intelligence_poc.ts`):** Experiment with lightweight semantic parsing (e.g., extracting exports or AST structure from a file) to prove we can feed agents structured code intelligence rather than raw strings.
|
without disrupting the current working tree. This proves we can store agent
|
||||||
|
state invisibly.
|
||||||
|
2. **DAG Engine PoC (`dag_engine_poc.ts`):** Create a minimal script that parses
|
||||||
|
a YAML task graph, resolves dependencies (`blocked_by`), and mathematically
|
||||||
|
outputs the exact next task an agent should work on.
|
||||||
|
3. **Local Intelligence PoC (`code_intelligence_poc.ts`):** Experiment with
|
||||||
|
lightweight semantic parsing (e.g., extracting exports or AST structure from
|
||||||
|
a file) to prove we can feed agents structured code intelligence rather than
|
||||||
|
raw strings.
|
||||||
|
|||||||
@ -21,7 +21,8 @@ export function extractExports(sourceCode: string): ExportSymbol[] {
|
|||||||
|
|
||||||
// A naive regex for PoC purposes to find exported functions
|
// A naive regex for PoC purposes to find exported functions
|
||||||
// Matches: export function foo(bar: string): void {
|
// Matches: export function foo(bar: string): void {
|
||||||
const functionRegex = /export\s+(?:async\s+)?function\s+([a-zA-Z0-9_]+)\s*\(([^)]*)\)(?:\s*:\s*([^ {]+))?/g;
|
const functionRegex =
|
||||||
|
/export\s+(?:async\s+)?function\s+([a-zA-Z0-9_]+)\s*\(([^)]*)\)(?:\s*:\s*([^ {]+))?/g;
|
||||||
|
|
||||||
let match;
|
let match;
|
||||||
while ((match = functionRegex.exec(sourceCode)) !== null) {
|
while ((match = functionRegex.exec(sourceCode)) !== null) {
|
||||||
@ -80,24 +81,28 @@ export function doSomethingElse(): void {
|
|||||||
|
|
||||||
assertEquals(extracted.length, 3);
|
assertEquals(extracted.length, 3);
|
||||||
|
|
||||||
const calcFunc = extracted.find(e => e.name === "calculateValue");
|
const calcFunc = extracted.find((e) => e.name === "calculateValue");
|
||||||
assertEquals(calcFunc?.type, "function");
|
assertEquals(calcFunc?.type, "function");
|
||||||
assertEquals(calcFunc?.signature, "(input: number, mode: string) => Promise<number>");
|
assertEquals(
|
||||||
|
calcFunc?.signature,
|
||||||
|
"(input: number, mode: string) => Promise<number>",
|
||||||
|
);
|
||||||
|
|
||||||
const maxRetries = extracted.find(e => e.name === "MAX_RETRIES");
|
const maxRetries = extracted.find((e) => e.name === "MAX_RETRIES");
|
||||||
assertEquals(maxRetries?.type, "const");
|
assertEquals(maxRetries?.type, "const");
|
||||||
|
|
||||||
const doSomething = extracted.find(e => e.name === "doSomethingElse");
|
const doSomething = extracted.find((e) => e.name === "doSomethingElse");
|
||||||
assertEquals(doSomething?.type, "function");
|
assertEquals(doSomething?.type, "function");
|
||||||
assertEquals(doSomething?.signature, "() => void");
|
assertEquals(doSomething?.signature, "() => void");
|
||||||
|
|
||||||
console.log("✅ Local Code Intelligence PoC successful: Extracted structured context from raw source.");
|
console.log(
|
||||||
|
"✅ Local Code Intelligence PoC successful: Extracted structured context from raw source.",
|
||||||
|
);
|
||||||
|
|
||||||
// Simulate what the agent would actually see:
|
// Simulate what the agent would actually see:
|
||||||
console.log("\n--- Agent Context Payload ---");
|
console.log("\n--- Agent Context Payload ---");
|
||||||
console.log(JSON.stringify(extracted, null, 2));
|
console.log(JSON.stringify(extracted, null, 2));
|
||||||
console.log("-----------------------------\n");
|
console.log("-----------------------------\n");
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("❌ Local Code Intelligence PoC failed:", err);
|
console.error("❌ Local Code Intelligence PoC failed:", err);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,7 @@ export class TaskDAG {
|
|||||||
if (node.status === "complete") continue;
|
if (node.status === "complete") continue;
|
||||||
|
|
||||||
const isBlocked = node.blocked_by.some(
|
const isBlocked = node.blocked_by.some(
|
||||||
(depId) => this.nodes.get(depId)?.status !== "complete"
|
(depId) => this.nodes.get(depId)?.status !== "complete",
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isBlocked) {
|
if (!isBlocked) {
|
||||||
@ -95,10 +95,12 @@ if (import.meta.main) {
|
|||||||
|
|
||||||
// Unblocked should now be task_3 and task_4
|
// Unblocked should now be task_3 and task_4
|
||||||
assertEquals(unblocked.length, 2);
|
assertEquals(unblocked.length, 2);
|
||||||
assertEquals(unblocked.find(t => t.id === "task_3")?.id, "task_3");
|
assertEquals(unblocked.find((t) => t.id === "task_3")?.id, "task_3");
|
||||||
assertEquals(unblocked.find(t => t.id === "task_4")?.id, "task_4");
|
assertEquals(unblocked.find((t) => t.id === "task_4")?.id, "task_4");
|
||||||
|
|
||||||
console.log("✅ DAG Engine PoC successful: Correctly calculated unblocked tasks.");
|
console.log(
|
||||||
|
"✅ DAG Engine PoC successful: Correctly calculated unblocked tasks.",
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("❌ DAG Engine PoC failed:", err);
|
console.error("❌ DAG Engine PoC failed:", err);
|
||||||
}
|
}
|
||||||
|
|||||||
66
forum/experiments/dependency_graph_poc.ts
Normal file
66
forum/experiments/dependency_graph_poc.ts
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import { assertEquals } from "https://deno.land/std@0.224.0/testing/asserts.ts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proof of Concept: Dependency Graphing (Adjacency Matrices)
|
||||||
|
*
|
||||||
|
* Demonstrates mathematically calculating the "blast radius" of a code change
|
||||||
|
* by representing component dependencies as an adjacency matrix and using
|
||||||
|
* graph traversal to find impacted nodes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Adjacency matrix for a simple app:
|
||||||
|
// Nodes: [0: Auth, 1: Database, 2: API Route, 3: UI Component]
|
||||||
|
// Matrix[i][j] = 1 means Node i depends on Node j
|
||||||
|
const matrix = [
|
||||||
|
[0, 1, 0, 0], // Auth depends on Database
|
||||||
|
[0, 0, 0, 0], // Database has no outgoing dependencies
|
||||||
|
[1, 1, 0, 0], // API Route depends on Auth and Database
|
||||||
|
[0, 0, 1, 0], // UI Component depends on API Route
|
||||||
|
];
|
||||||
|
|
||||||
|
const nodes = ["Auth", "Database", "API Route", "UI Component"];
|
||||||
|
|
||||||
|
// Find all nodes that depend on a given node (blast radius)
|
||||||
|
function calculateBlastRadius(changedNodeIndex: number): number[] {
|
||||||
|
const impacted = new Set<number>();
|
||||||
|
const queue = [changedNodeIndex];
|
||||||
|
|
||||||
|
while (queue.length > 0) {
|
||||||
|
const current = queue.shift()!;
|
||||||
|
// Find who depends on `current`
|
||||||
|
for (let i = 0; i < matrix.length; i++) {
|
||||||
|
if (matrix[i][current] === 1 && !impacted.has(i)) {
|
||||||
|
impacted.add(i);
|
||||||
|
queue.push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Array.from(impacted);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (import.meta.main) {
|
||||||
|
console.log("Running Dependency Graphing PoC tests...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
const changedNode = 1; // "Database" changed
|
||||||
|
console.log(
|
||||||
|
`If '${nodes[changedNode]}' changes, calculating blast radius...`,
|
||||||
|
);
|
||||||
|
|
||||||
|
const impactedIndices = calculateBlastRadius(changedNode);
|
||||||
|
const impactedNames = impactedIndices.map((i) => nodes[i]);
|
||||||
|
|
||||||
|
console.log(`Impacted components:`, impactedNames);
|
||||||
|
|
||||||
|
// If Database changes, Auth and API Route depend on it directly.
|
||||||
|
// UI Component depends on API Route. So all others should be impacted.
|
||||||
|
assertEquals(impactedIndices.length, 3);
|
||||||
|
console.log(
|
||||||
|
"✅ Dependency Graphing PoC successful: Blast radius calculated correctly.",
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("❌ Dependency Graphing PoC failed:", err);
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,6 @@
|
|||||||
import { assert, assertEquals } from "https://deno.land/std@0.224.0/testing/asserts.ts";
|
import {
|
||||||
|
assertEquals,
|
||||||
|
} from "https://deno.land/std@0.224.0/testing/asserts.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Proof of Concept: Git Storage (Notes & Orphan Branches)
|
* Proof of Concept: Git Storage (Notes & Orphan Branches)
|
||||||
@ -24,13 +26,29 @@ async function runGitCmd(args: string[]): Promise<string> {
|
|||||||
return stdout;
|
return stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addGitNote(ref: string, message: string, targetRef: string = "HEAD") {
|
export async function addGitNote(
|
||||||
|
ref: string,
|
||||||
|
message: string,
|
||||||
|
targetRef: string = "HEAD",
|
||||||
|
) {
|
||||||
// First, check if a note already exists to avoid overwriting blindly
|
// First, check if a note already exists to avoid overwriting blindly
|
||||||
// For this PoC, we will append or overwrite
|
// For this PoC, we will append or overwrite
|
||||||
await runGitCmd(["notes", "--ref", ref, "add", "-f", "-m", message, targetRef]);
|
await runGitCmd([
|
||||||
|
"notes",
|
||||||
|
"--ref",
|
||||||
|
ref,
|
||||||
|
"add",
|
||||||
|
"-f",
|
||||||
|
"-m",
|
||||||
|
message,
|
||||||
|
targetRef,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function readGitNote(ref: string, targetRef: string = "HEAD"): Promise<string> {
|
export async function readGitNote(
|
||||||
|
ref: string,
|
||||||
|
targetRef: string = "HEAD",
|
||||||
|
): Promise<string> {
|
||||||
try {
|
try {
|
||||||
return await runGitCmd(["notes", "--ref", ref, "show", targetRef]);
|
return await runGitCmd(["notes", "--ref", ref, "show", targetRef]);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@ -50,7 +68,7 @@ if (import.meta.main) {
|
|||||||
const testMessage = JSON.stringify({
|
const testMessage = JSON.stringify({
|
||||||
agent: "poc-agent",
|
agent: "poc-agent",
|
||||||
risk: "low",
|
risk: "low",
|
||||||
thought: "This is a hidden thought stored in a git note."
|
thought: "This is a hidden thought stored in a git note.",
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -1,16 +1,82 @@
|
|||||||
import { join, dirname, fromFileUrl } from "https://deno.land/std@0.224.0/path/mod.ts";
|
import {
|
||||||
import { blue, green, red, yellow, bold } from "https://deno.land/std@0.224.0/fmt/colors.ts";
|
dirname,
|
||||||
|
fromFileUrl,
|
||||||
|
join,
|
||||||
|
} from "https://deno.land/std@0.224.0/path/mod.ts";
|
||||||
|
import {
|
||||||
|
blue,
|
||||||
|
bold,
|
||||||
|
green,
|
||||||
|
red,
|
||||||
|
yellow,
|
||||||
|
} from "https://deno.land/std@0.224.0/fmt/colors.ts";
|
||||||
|
|
||||||
// Define the experiments to run
|
// Define the experiments to run
|
||||||
const EXPERIMENTS = [
|
const EXPERIMENTS = [
|
||||||
{ name: "Git Storage PoC", file: "git_storage_poc.ts", description: "Verifies ability to read/write Git Notes and manipulate orphan branches." },
|
{
|
||||||
{ name: "DAG Engine PoC", file: "dag_engine_poc.ts", description: "Verifies mathematical dependency resolution of YAML task graphs." },
|
name: "Git Storage PoC",
|
||||||
{ name: "Code Intelligence PoC", file: "code_intelligence_poc.ts", description: "Verifies structural code parsing (AST/Exports) instead of raw text reading." },
|
file: "git_storage_poc.ts",
|
||||||
{ name: "State Machine PoC", file: "state_machine_poc.ts", description: "Verifies Bounded Model Checking for pipeline governance." },
|
description:
|
||||||
{ name: "Ontology Traceability PoC", file: "ontology_poc.ts", description: "Verifies linking business requirements to code using JSON-LD graphs." }
|
"Verifies ability to read/write Git Notes and manipulate orphan branches.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "DAG Engine PoC",
|
||||||
|
file: "dag_engine_poc.ts",
|
||||||
|
description:
|
||||||
|
"Verifies mathematical dependency resolution of YAML task graphs.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Code Intelligence PoC",
|
||||||
|
file: "code_intelligence_poc.ts",
|
||||||
|
description:
|
||||||
|
"Verifies structural code parsing (AST/Exports) instead of raw text reading.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "State Machine PoC",
|
||||||
|
file: "state_machine_poc.ts",
|
||||||
|
description: "Verifies Bounded Model Checking for pipeline governance.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ontology Traceability PoC",
|
||||||
|
file: "ontology_poc.ts",
|
||||||
|
description:
|
||||||
|
"Verifies linking business requirements to code using JSON-LD graphs.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Protocol Buffers PoC",
|
||||||
|
file: "protobuf_poc.ts",
|
||||||
|
description:
|
||||||
|
"Verifies high-performance binary serialization concepts for agent state.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Git Merkle DAG Diffing PoC",
|
||||||
|
file: "merkle_diff_poc.ts",
|
||||||
|
description:
|
||||||
|
"Verifies O(1) diffing using native Git tree hashes without opening files.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Embedded Vector DB PoC",
|
||||||
|
file: "vector_db_poc.ts",
|
||||||
|
description:
|
||||||
|
"Verifies fuzzy semantic match using cosine similarity (mocking sqlite-vec/TurboQuant).",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Dependency Graphing PoC",
|
||||||
|
file: "dependency_graph_poc.ts",
|
||||||
|
description:
|
||||||
|
"Verifies calculating code blast radius using adjacency matrices.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Telemetry Parsing PoC",
|
||||||
|
file: "telemetry_poc.ts",
|
||||||
|
description:
|
||||||
|
"Verifies Analyst and Adversary agents' ability to ingest structured JSON telemetry.",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
async function runExperiment(file: string): Promise<{ success: boolean; output: string }> {
|
async function runExperiment(
|
||||||
|
file: string,
|
||||||
|
): Promise<{ success: boolean; output: string }> {
|
||||||
const currentDir = dirname(fromFileUrl(import.meta.url));
|
const currentDir = dirname(fromFileUrl(import.meta.url));
|
||||||
const filePath = join(currentDir, file);
|
const filePath = join(currentDir, file);
|
||||||
|
|
||||||
@ -28,12 +94,12 @@ async function runExperiment(file: string): Promise<{ success: boolean; output:
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
success: code === 0,
|
success: code === 0,
|
||||||
output: outputString.trim()
|
output: outputString.trim(),
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
output: `Failed to execute ${file}: ${error}`
|
output: `Failed to execute ${file}: ${error}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
73
forum/experiments/merkle_diff_poc.ts
Normal file
73
forum/experiments/merkle_diff_poc.ts
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import {
|
||||||
|
assertNotEquals,
|
||||||
|
} from "https://deno.land/std@0.224.0/testing/asserts.ts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proof of Concept: Git Merkle DAG Diffing
|
||||||
|
*
|
||||||
|
* This module demonstrates using Git's fundamental Merkle Tree structure
|
||||||
|
* (`git diff-tree` and `git ls-tree`) to perform zero-overhead, O(1) diffing
|
||||||
|
* to find exactly which file hashes changed without reading the file string content.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (import.meta.main) {
|
||||||
|
console.log("Running Git Merkle DAG Diffing PoC tests...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Get the current HEAD commit hash
|
||||||
|
const headHash = await runGitCmd(["rev-parse", "HEAD"]);
|
||||||
|
console.log(`Current HEAD: ${headHash}`);
|
||||||
|
|
||||||
|
// 2. Get the tree hash of HEAD
|
||||||
|
const treeHash = await runGitCmd(["rev-parse", "HEAD^{tree}"]);
|
||||||
|
console.log(`Tree Hash of HEAD: ${treeHash}`);
|
||||||
|
|
||||||
|
// 3. Diff HEAD against HEAD~1 (if available) to see what changed purely by hash
|
||||||
|
try {
|
||||||
|
const diffTreeOutput = await runGitCmd([
|
||||||
|
"diff-tree",
|
||||||
|
"--no-commit-id",
|
||||||
|
"--name-only",
|
||||||
|
"-r",
|
||||||
|
"HEAD",
|
||||||
|
]);
|
||||||
|
console.log(
|
||||||
|
`\nChanged files in HEAD (O(1) diffing):\n${
|
||||||
|
diffTreeOutput || "(No changes or no parent)"
|
||||||
|
}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
assertNotEquals(treeHash, "");
|
||||||
|
console.log(
|
||||||
|
"\n✅ Git Merkle DAG Diffing PoC successful: Read tree hashes without opening files.",
|
||||||
|
);
|
||||||
|
} catch (e: any) {
|
||||||
|
if (e.message.includes("ambiguous argument")) {
|
||||||
|
console.log(
|
||||||
|
"Skipping diff-tree as there might not be enough commits in this repo for a diff.",
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("❌ Git Merkle DAG Diffing PoC failed:", err);
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,7 +16,7 @@ const mockReq1: JsonLdNode = {
|
|||||||
"@type": "BusinessRequirement",
|
"@type": "BusinessRequirement",
|
||||||
"@id": "REQ-001",
|
"@id": "REQ-001",
|
||||||
name: "User Authentication",
|
name: "User Authentication",
|
||||||
description: "The system must authenticate users securely."
|
description: "The system must authenticate users securely.",
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTask1: JsonLdNode = {
|
const mockTask1: JsonLdNode = {
|
||||||
@ -24,7 +24,7 @@ const mockTask1: JsonLdNode = {
|
|||||||
"@type": "EngineeringTask",
|
"@type": "EngineeringTask",
|
||||||
"@id": "urn:uuid:018f6c3a-1234-7890-abcd-ef0123456789",
|
"@id": "urn:uuid:018f6c3a-1234-7890-abcd-ef0123456789",
|
||||||
name: "Implement Login Endpoint",
|
name: "Implement Login Endpoint",
|
||||||
satisfies: ["REQ-001"] // This links the technical task to the business requirement
|
satisfies: ["REQ-001"], // This links the technical task to the business requirement
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTest1: JsonLdNode = {
|
const mockTest1: JsonLdNode = {
|
||||||
@ -32,7 +32,7 @@ const mockTest1: JsonLdNode = {
|
|||||||
"@type": "TestCase",
|
"@type": "TestCase",
|
||||||
"@id": "TEST-AUTH-01",
|
"@id": "TEST-AUTH-01",
|
||||||
name: "Test invalid passwords return 401",
|
name: "Test invalid passwords return 401",
|
||||||
satisfies: ["urn:uuid:018f6c3a-1234-7890-abcd-ef0123456789"] // This links the test to the task
|
satisfies: ["urn:uuid:018f6c3a-1234-7890-abcd-ef0123456789"], // This links the test to the task
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,7 +68,10 @@ function buildOntologyGraph(nodes: JsonLdNode[]): Map<string, string[]> {
|
|||||||
/**
|
/**
|
||||||
* Recursively find all technical artifacts that trace back to a specific requirement.
|
* Recursively find all technical artifacts that trace back to a specific requirement.
|
||||||
*/
|
*/
|
||||||
function traceRequirement(graph: Map<string, string[]>, startId: string): string[] {
|
function traceRequirement(
|
||||||
|
graph: Map<string, string[]>,
|
||||||
|
startId: string,
|
||||||
|
): string[] {
|
||||||
const visited = new Set<string>();
|
const visited = new Set<string>();
|
||||||
const stack = [startId];
|
const stack = [startId];
|
||||||
|
|
||||||
@ -100,19 +103,29 @@ async function runOntologyPoC() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Trace the requirement
|
// Trace the requirement
|
||||||
console.log(`\nTracing impact for Business Requirement: ${mockReq1["@id"]}...`);
|
console.log(
|
||||||
|
`\nTracing impact for Business Requirement: ${mockReq1["@id"]}...`,
|
||||||
|
);
|
||||||
const traceResults = traceRequirement(graph, mockReq1["@id"]);
|
const traceResults = traceRequirement(graph, mockReq1["@id"]);
|
||||||
|
|
||||||
console.log(`Artifacts tracing back to ${mockReq1["@id"]}:`, traceResults);
|
console.log(`Artifacts tracing back to ${mockReq1["@id"]}:`, traceResults);
|
||||||
|
|
||||||
assert(traceResults.includes(mockTask1["@id"]), "Graph failed to link Task to Requirement");
|
assert(
|
||||||
assert(traceResults.includes(mockTest1["@id"]), "Graph failed to link Test to Task and up to Requirement");
|
traceResults.includes(mockTask1["@id"]),
|
||||||
|
"Graph failed to link Task to Requirement",
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
traceResults.includes(mockTest1["@id"]),
|
||||||
|
"Graph failed to link Test to Task and up to Requirement",
|
||||||
|
);
|
||||||
|
|
||||||
console.log("\nPoC Successful: Deep traceability achieved via mathematical graph traversal.");
|
console.log(
|
||||||
|
"\nPoC Successful: Deep traceability achieved via mathematical graph traversal.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (import.meta.main) {
|
if (import.meta.main) {
|
||||||
runOntologyPoC().catch(err => {
|
runOntologyPoC().catch((err) => {
|
||||||
console.error("PoC Failed:", err);
|
console.error("PoC Failed:", err);
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
52
forum/experiments/protobuf_poc.ts
Normal file
52
forum/experiments/protobuf_poc.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import { assertEquals } from "https://deno.land/std@0.224.0/testing/asserts.ts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proof of Concept: Protocol Buffers (Protobuf) Serialization Mock
|
||||||
|
*
|
||||||
|
* This module demonstrates the concept of serializing and deserializing
|
||||||
|
* agent state using a fast binary format instead of JSON, showing how
|
||||||
|
* we might achieve high-performance I/O for vector math and state passing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// A simple mock of what a protobuf encoder/decoder would do.
|
||||||
|
// Real implementation would use something like `protobufjs` or a Deno-native library
|
||||||
|
// generated from `.proto` files.
|
||||||
|
|
||||||
|
const mockAgentState = {
|
||||||
|
agentId: "adversary-01",
|
||||||
|
status: "active",
|
||||||
|
memoryUsage: 1024,
|
||||||
|
};
|
||||||
|
|
||||||
|
function mockSerialize(data: object): Uint8Array {
|
||||||
|
// In a real scenario, this would be a highly efficient binary serialization
|
||||||
|
const str = JSON.stringify(data);
|
||||||
|
return new TextEncoder().encode(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
function mockDeserialize(data: Uint8Array): object {
|
||||||
|
const str = new TextDecoder().decode(data);
|
||||||
|
return JSON.parse(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (import.meta.main) {
|
||||||
|
console.log("Running Protocol Buffers PoC tests...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
console.log("Original Data:", mockAgentState);
|
||||||
|
|
||||||
|
const serialized = mockSerialize(mockAgentState);
|
||||||
|
console.log(`Serialized Size: ${serialized.length} bytes`);
|
||||||
|
|
||||||
|
const deserialized = mockDeserialize(serialized);
|
||||||
|
console.log("Deserialized Data:", deserialized);
|
||||||
|
|
||||||
|
assertEquals(deserialized, mockAgentState);
|
||||||
|
console.log(
|
||||||
|
"✅ Protocol Buffers PoC successful: Serialization/Deserialization worked.",
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("❌ Protocol Buffers PoC failed:", err);
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -31,14 +31,20 @@ const currentSystemState = {
|
|||||||
* The Evaluator script that mathematically enforces pipeline progression.
|
* The Evaluator script that mathematically enforces pipeline progression.
|
||||||
* It checks the transitions matrix to see if a specific Agent Role is allowed to execute based on the current flags.
|
* It checks the transitions matrix to see if a specific Agent Role is allowed to execute based on the current flags.
|
||||||
*/
|
*/
|
||||||
function canAgentExecute(roleName: string, config: TransitionsConfig, currentState: Set<string>): boolean {
|
function canAgentExecute(
|
||||||
|
roleName: string,
|
||||||
|
config: TransitionsConfig,
|
||||||
|
currentState: Set<string>,
|
||||||
|
): boolean {
|
||||||
const rule = config[roleName];
|
const rule = config[roleName];
|
||||||
if (!rule) {
|
if (!rule) {
|
||||||
throw new Error(`Role ${roleName} is not defined in the transitions matrix. Execution denied.`);
|
throw new Error(
|
||||||
|
`Role ${roleName} is not defined in the transitions matrix. Execution denied.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bounded Model Checking: All required flags must be present in the current state.
|
// Bounded Model Checking: All required flags must be present in the current state.
|
||||||
return rule.requires.every(req => currentState.has(req));
|
return rule.requires.every((req) => currentState.has(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runStateMachinePoC() {
|
async function runStateMachinePoC() {
|
||||||
@ -49,14 +55,27 @@ async function runStateMachinePoC() {
|
|||||||
console.log("Loaded Transitions Matrix:", Object.keys(matrix));
|
console.log("Loaded Transitions Matrix:", Object.keys(matrix));
|
||||||
|
|
||||||
// 2. Attempt to run Coder BEFORE Gatekeeper has approved
|
// 2. Attempt to run Coder BEFORE Gatekeeper has approved
|
||||||
console.log("\nScenario 1: Attempting to run 'Coder' with empty system state...");
|
console.log(
|
||||||
const canCoderRunInitial = canAgentExecute("Coder", matrix, currentSystemState.activeFlags);
|
"\nScenario 1: Attempting to run 'Coder' with empty system state...",
|
||||||
|
);
|
||||||
|
const canCoderRunInitial = canAgentExecute(
|
||||||
|
"Coder",
|
||||||
|
matrix,
|
||||||
|
currentSystemState.activeFlags,
|
||||||
|
);
|
||||||
console.log(`Result: Coder execution allowed? ${canCoderRunInitial}`);
|
console.log(`Result: Coder execution allowed? ${canCoderRunInitial}`);
|
||||||
assert(canCoderRunInitial === false, "Coder should NOT be able to run without Gatekeeper_Approval");
|
assert(
|
||||||
|
canCoderRunInitial === false,
|
||||||
|
"Coder should NOT be able to run without Gatekeeper_Approval",
|
||||||
|
);
|
||||||
|
|
||||||
// 3. Gatekeeper runs (it has no requirements)
|
// 3. Gatekeeper runs (it has no requirements)
|
||||||
console.log("\nScenario 2: Running 'Gatekeeper'...");
|
console.log("\nScenario 2: Running 'Gatekeeper'...");
|
||||||
const canGatekeeperRun = canAgentExecute("Gatekeeper", matrix, currentSystemState.activeFlags);
|
const canGatekeeperRun = canAgentExecute(
|
||||||
|
"Gatekeeper",
|
||||||
|
matrix,
|
||||||
|
currentSystemState.activeFlags,
|
||||||
|
);
|
||||||
console.log(`Result: Gatekeeper execution allowed? ${canGatekeeperRun}`);
|
console.log(`Result: Gatekeeper execution allowed? ${canGatekeeperRun}`);
|
||||||
assert(canGatekeeperRun === true, "Gatekeeper should be able to run");
|
assert(canGatekeeperRun === true, "Gatekeeper should be able to run");
|
||||||
|
|
||||||
@ -65,16 +84,27 @@ async function runStateMachinePoC() {
|
|||||||
currentSystemState.activeFlags.add("Gatekeeper_Approval");
|
currentSystemState.activeFlags.add("Gatekeeper_Approval");
|
||||||
|
|
||||||
// 4. Attempt to run Coder AFTER Gatekeeper has approved
|
// 4. Attempt to run Coder AFTER Gatekeeper has approved
|
||||||
console.log("\nScenario 3: Attempting to run 'Coder' with updated system state...");
|
console.log(
|
||||||
const canCoderRunNow = canAgentExecute("Coder", matrix, currentSystemState.activeFlags);
|
"\nScenario 3: Attempting to run 'Coder' with updated system state...",
|
||||||
|
);
|
||||||
|
const canCoderRunNow = canAgentExecute(
|
||||||
|
"Coder",
|
||||||
|
matrix,
|
||||||
|
currentSystemState.activeFlags,
|
||||||
|
);
|
||||||
console.log(`Result: Coder execution allowed? ${canCoderRunNow}`);
|
console.log(`Result: Coder execution allowed? ${canCoderRunNow}`);
|
||||||
assert(canCoderRunNow === true, "Coder SHOULD be able to run now that Gatekeeper_Approval is present");
|
assert(
|
||||||
|
canCoderRunNow === true,
|
||||||
|
"Coder SHOULD be able to run now that Gatekeeper_Approval is present",
|
||||||
|
);
|
||||||
|
|
||||||
console.log("\nPoC Successful: Bounded Model Checking mathematically prevents out-of-order execution.");
|
console.log(
|
||||||
|
"\nPoC Successful: Bounded Model Checking mathematically prevents out-of-order execution.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (import.meta.main) {
|
if (import.meta.main) {
|
||||||
runStateMachinePoC().catch(err => {
|
runStateMachinePoC().catch((err) => {
|
||||||
console.error("PoC Failed:", err);
|
console.error("PoC Failed:", err);
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
70
forum/experiments/telemetry_poc.ts
Normal file
70
forum/experiments/telemetry_poc.ts
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import {
|
||||||
|
assertEquals,
|
||||||
|
} from "https://deno.land/std@0.224.0/testing/asserts.ts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proof of Concept: Telemetry parsing (OpenTelemetry / Team Friction)
|
||||||
|
*
|
||||||
|
* Demonstrates the Analyst agent's ability to ingest structured JSON telemetry
|
||||||
|
* (like MTTR, PR comment ratios) to optimize workflows.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const mockTeamTelemetry = {
|
||||||
|
sprint: "Sprint 42",
|
||||||
|
metrics: {
|
||||||
|
meanTimeToResolution: 14.5, // hours
|
||||||
|
prCommentToCodeRatio: 0.8,
|
||||||
|
idleHandoffDuration: 5.2, // hours
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockOpenTelemetryTrace = {
|
||||||
|
traceId: "5b8aa5a2d2c8646c14e4d97e6cdbc134",
|
||||||
|
spans: [
|
||||||
|
{ name: "db_query", duration_ms: 250 },
|
||||||
|
{ name: "serialize_json", duration_ms: 12 },
|
||||||
|
{ name: "http_request", duration_ms: 300 },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
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 tests...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
const frictionFlags = analyzeFriction(mockTeamTelemetry);
|
||||||
|
console.log("Team Friction Analysis:", frictionFlags);
|
||||||
|
assertEquals(frictionFlags.length, 2);
|
||||||
|
|
||||||
|
const bottlenecks = findPerformanceBottlenecks(mockOpenTelemetryTrace);
|
||||||
|
console.log("Performance Bottlenecks:", bottlenecks);
|
||||||
|
assertEquals(bottlenecks.length, 2);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"✅ Telemetry Parsing PoC successful: Flags and bottlenecks identified.",
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("❌ Telemetry Parsing PoC failed:", err);
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
76
forum/experiments/vector_db_poc.ts
Normal file
76
forum/experiments/vector_db_poc.ts
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
import {
|
||||||
|
assert,
|
||||||
|
assertEquals,
|
||||||
|
} from "https://deno.land/std@0.224.0/testing/asserts.ts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proof of Concept: Embedded Vector Database (Mocking sqlite-vec & TurboQuant)
|
||||||
|
*
|
||||||
|
* This module demonstrates the concept of hashing semantic concepts into vectors
|
||||||
|
* and performing cosine similarity to achieve fuzzy retrieval of associative memory
|
||||||
|
* without needing an external vector database.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Simple mock for cosine similarity of 1D arrays
|
||||||
|
function cosineSimilarity(vecA: number[], vecB: number[]): number {
|
||||||
|
let dotProduct = 0;
|
||||||
|
let normA = 0;
|
||||||
|
let normB = 0;
|
||||||
|
for (let i = 0; i < vecA.length; i++) {
|
||||||
|
dotProduct += vecA[i] * vecB[i];
|
||||||
|
normA += vecA[i] ** 2;
|
||||||
|
normB += vecB[i] ** 2;
|
||||||
|
}
|
||||||
|
if (normA === 0 || normB === 0) return 0;
|
||||||
|
return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock of quantized vectors (e.g. TurboQuant 2-bit/4-bit compression)
|
||||||
|
const MOCK_VECTOR_DB = [
|
||||||
|
{ id: "docs-1", text: "How to run the server", vector: [0.8, 0.1, 0.1, 0.0] },
|
||||||
|
{
|
||||||
|
id: "docs-2",
|
||||||
|
text: "Database connection logic",
|
||||||
|
vector: [0.1, 0.9, 0.2, 0.1],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "telemetry-1",
|
||||||
|
text: "Server latency spikes",
|
||||||
|
vector: [0.2, 0.1, 0.9, 0.3],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
if (import.meta.main) {
|
||||||
|
console.log("Running Embedded Vector Database PoC tests...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Query representing "I have a slow server issue"
|
||||||
|
const queryVector = [0.3, 0.0, 0.9, 0.2];
|
||||||
|
|
||||||
|
console.log("Querying Vector DB...");
|
||||||
|
|
||||||
|
const results = MOCK_VECTOR_DB.map((doc) => ({
|
||||||
|
...doc,
|
||||||
|
score: cosineSimilarity(queryVector, doc.vector),
|
||||||
|
})).sort((a, b) => b.score - a.score);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"Top result:",
|
||||||
|
results[0].text,
|
||||||
|
`(Score: ${results[0].score.toFixed(2)})`,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
results[0].score > 0.8,
|
||||||
|
"The telemetry doc should be the highest match",
|
||||||
|
);
|
||||||
|
assertEquals(results[0].id, "telemetry-1");
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"✅ Embedded Vector DB PoC successful: Fuzzy semantic match found.",
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("❌ Embedded Vector DB PoC failed:", err);
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user