-
Notifications
You must be signed in to change notification settings - Fork 3k
TRP1 – Phase 0: Hook Engine scaffolding, intent sidecar, and architecture notes #11538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
78575a2
64b0e23
bf8a572
b8c6e0b
32caaf2
a93ecdd
1adf2ac
362d6d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,3 +55,6 @@ qdrant_storage/ | |
| plans/ | ||
|
|
||
| roo-cli-*.tar.gz* | ||
|
|
||
| # Orchestration | ||
| .orchestration/ | ||
| 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 | | ||
| | --------- | ------------- | ----- | |
| 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. |
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Fix it with Roo Code or mention @roomote and request a fix. |
||
| 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) => {} |
| 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) => {} |
| 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) => {} |
| 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) => {} |
| 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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
.orchestration/to.gitignoreonly prevents new untracked files from being staged..orchestration/intent_map.mdis already tracked (confirmed viagit ls-files), so it will remain in the repository and continue to produce diffs on changes. You need to rungit rm --cached .orchestration/intent_map.md(and commit the removal) for the.gitignoreentry to take effect.Fix it with Roo Code or mention @roomote and request a fix.