Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ qdrant_storage/
plans/

roo-cli-*.tar.gz*

# Orchestration
.orchestration/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding .orchestration/ to .gitignore only prevents new untracked files from being staged. .orchestration/intent_map.md is already tracked (confirmed via git ls-files), so it will remain in the repository and continue to produce diffs on changes. You need to run git rm --cached .orchestration/intent_map.md (and commit the removal) for the .gitignore entry to take effect.

Fix it with Roo Code or mention @roomote and request a fix.

8 changes: 8 additions & 0 deletions .orchestration/intent_map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Intent Map (Interim)

# Maps high-level business intents to files and AST nodes

# Populated in final submission

| Intent ID | Related Files | Notes |
| --------- | ------------- | ----- |
112 changes: 112 additions & 0 deletions ARCHITECTURE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# ARCHITECTURE_NOTES.md

## TRP1 Week 1 – Interim Submission

### 1. Purpose

This document outlines the architecture and hook system implemented for the interim submission of the TRP1 Week 1 challenge: **AI-Native IDE & Intent-Code Traceability**.
The goal of this submission is to demonstrate the initial hook middleware structure, context injection, and intent validation mechanisms.

---

### 2. Hook Architecture Overview

The hook system acts as a **middleware layer** intercepting all tool execution in the AI IDE extension.
It consists of:

1. **Pre-Hooks**: Executed **before tool actions**, responsible for:

- Validating that the agent has selected a valid intent (`intentValidator`)
- Loading intent context from `.orchestration/active_intents.yaml` (`contextLoader`)

2. **Post-Hooks**: Executed **after tool actions**, currently placeholders for:
- Logging tool execution (`traceLogger`)
- Updating shared documentation (`docUpdater`)

**Design Principles:**

- Hooks are **isolated, composable, and type-safe** (via TypeScript interfaces).
- The middleware pattern enforces **strict privilege separation** between UI, extension host, and agent execution.
- Aligns with the **Master Thinker philosophy**: the agent cannot write code before selecting an intent.

---

### 3. Directory Structure

```

src/hooks/
├── index.ts # Hook registration and execution middleware
├── preHooks/
│ ├── contextLoader.ts # Loads intent context before tool execution
│ └── intentValidator.ts# Validates selected intent_id
├── postHooks/
│ ├── traceLogger.ts # Logs tool execution (placeholder)
│ └── docUpdater.ts # Updates shared documentation (placeholder)
├── types.ts # Shared hook interfaces and types
└── utils/
├── fileUtils.ts # Helper for .orchestration file read/write
└── hashUtils.ts # Placeholder for content hashing

```

---

### 4. Execution Flow

**Step 1 – Tool Execution Request**
User/agent triggers a tool action (e.g., `write_file`) through the extension host.

**Step 2 – Pre-Hooks Execution**

1. `intentValidator`: ensures a valid `intent_id` is selected
2. `contextLoader`: loads constraints, scope, and acceptance criteria from `.orchestration/active_intents.yaml`

**Step 3 – Tool Execution**
Tool executes (currently mocked for interim) after passing all pre-hooks.

**Step 4 – Post-Hooks Execution**

1. `traceLogger`: logs the execution for future traceability
2. `docUpdater`: placeholder for documentation updates (e.g., CLAUDE.md)

**Diagram:**

```

[User/Agent]
|
v
[Tool Execution Request]
|
v
[Pre-Hooks Middleware] ---> [intentValidator] ---> [contextLoader]
|
v
[Tool Execution]
|
v
[Post-Hooks Middleware] ---> [traceLogger] ---> [docUpdater]
|
v
[Result / Response]

```

---

### 5. Notes for Interim Submission

- **No actual `agent_trace.jsonl` yet** — post-hooks currently placeholders.
- **Intent-AST correlation** and **content hashing** are deferred to final submission.
- Hooks demonstrate **composable middleware** architecture, meeting interim rubric criteria.
- Prepares for Phase 1 (Handshake / Reasoning Loop) and Phase 2 (Middleware & Security Boundary).

---

### 6. Next Steps (Final Submission)

- Implement **agent_trace.jsonl logging** in post-hooks.
- Extend `contextLoader` to include **recent history for selected intents**.
- Integrate **AST-based intent verification** for full Intent-Code traceability.
- Support **parallel orchestration** and shared CLAUDE.md updates.
19 changes: 19 additions & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Hook registry for the governed execution pipeline.
*
* NOTE:
* This module is intentionally not wired yet.
* Integration will occur at the tool execution boundary
* (agent → tool runner) in Phase 1.
*
* Planned call site:
* extension → toolRunner → HookEngine(preHooks/postHooks)
*/

import { contextLoader } from "./preHooks/contextLoader"
import { intentValidator } from "./preHooks/intentValidator"
import { traceLogger } from "./postHooks/traceLogger"
import { docUpdater } from "./postHooks/docUpdater"

export const preHooks = [contextLoader, intentValidator]
export const postHooks = [traceLogger, docUpdater]
Comment on lines +13 to +19
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module is not imported or referenced anywhere in the existing codebase, making all exports dead code. Nothing calls into preHooks or postHooks, and the hook engine described in the PR description (intercepting tool executions) has no integration point with the actual tool execution path in the extension. Without at least a call site or a clear TODO comment pointing to where this will be wired in, this code has no effect and could be silently forgotten.

Fix it with Roo Code or mention @roomote and request a fix.

3 changes: 3 additions & 0 deletions src/hooks/postHooks/docUpdater.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { PostHook } from "../types"

export const docUpdater: PostHook = async (_ctx, _result) => {}
3 changes: 3 additions & 0 deletions src/hooks/postHooks/traceLogger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { PostHook } from "../types"

export const traceLogger: PostHook = async (_ctx, _result) => {}
3 changes: 3 additions & 0 deletions src/hooks/preHooks/contextLoader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { PreHook } from "../types"

export const contextLoader: PreHook = async (_ctx) => {}
3 changes: 3 additions & 0 deletions src/hooks/preHooks/intentValidator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { PreHook } from "../types"

export const intentValidator: PreHook = async (_ctx) => {}
8 changes: 8 additions & 0 deletions src/hooks/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface HookContext {
intentId?: string
metadata?: Record<string, unknown>
}

export type PreHook = (ctx: HookContext) => Promise<void>

export type PostHook = (ctx: HookContext, result: unknown) => Promise<void>
Empty file added src/hooks/utils/fileUtils.ts
Empty file.
Empty file added src/hooks/utils/hashUtils.ts
Empty file.
Loading