Skip to content
Open
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
12 changes: 12 additions & 0 deletions .orchestration/active_intents.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
active_intents:
- id: "INT-001"
name: "Build Weather API"
status: "IN_PROGRESS"
owned_scope:
- "src/api/**"
constraints:
- "Use REST conventions"
- "Return JSON"
acceptance_criteria:
- "GET /weather returns 200 with location and temperature"

4 changes: 4 additions & 0 deletions .orchestration/agent_trace.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"id":"e7b89cb4-6121-45f5-bc17-b43d641f6cc3","timestamp":"2026-02-21T18:32:36.210Z","vcs":{"revision_id":"abc123"},"files":[{"relative_path":"src/api/weather.ts","conversations":[{"url":"session-1","contributor":{"entity_type":"AI","model_identifier":"test-model"},"ranges":[{"start_line":1,"end_line":2,"content_hash":"sha256:2e4ec5cf14cfeb55ef32cb663ffd2c4fe6ab22bb2d2fe77ee8e284fe62866cac"}],"related":[{"type":"specification","value":"INT-001"}]}]}]}
{"id":"c446252d-db42-480f-bde7-1336b81a03cd","timestamp":"2026-02-21T18:32:36.223Z","files":[{"relative_path":"src/api/forecast.ts","conversations":[{"contributor":{"entity_type":"AI","model_identifier":"unknown"},"ranges":[{"start_line":1,"end_line":1,"content_hash":"sha256:c47272be41ffa9d8a897b81b3f9f6d5e13fbb5d6dd4609a7b20c282950f11842"}],"related":[{"type":"specification","value":"INT-001"}]}]}]}
{"id":"c5b3ffd3-d912-41dd-95c6-bcf76fbe08a3","timestamp":"2026-02-21T18:32:36.226Z","files":[{"relative_path":"src/api/trace.ts","conversations":[{"contributor":{"entity_type":"AI","model_identifier":"unknown"},"ranges":[{"start_line":1,"end_line":1,"content_hash":"sha256:a3d4bb671e8b19ed161b408c183193afc9fa361f573c5187dded809930d14413"}],"related":[{"type":"specification","value":"INT-001"},{"type":"request","value":"REQ-12345"}]}]}]}
{"id":"26635dad-41f9-4ced-b73a-a555f2d3071e","timestamp":"2026-02-21T18:32:36.257Z","vcs":{"revision_id":"rev-1"},"files":[{"relative_path":"src/api/demo.ts","conversations":[{"url":"log-1","contributor":{"entity_type":"AI","model_identifier":"model-1"},"ranges":[{"start_line":1,"end_line":1,"content_hash":"sha256:bd994c26b795571c7c1e0357cba348f1d0238b648b748b9ec7a4d0de264d212f"}],"related":[{"type":"specification","value":"INT-001"}]}]}]}
78 changes: 78 additions & 0 deletions docs/testing-traceability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Testing the AI-Native Git Layer (Traceability)

How to test the semantic tracking ledger and `agent_trace.jsonl` **in the terminal**.

## Prerequisites

- From the **repo root**: `.orchestration/active_intents.yaml` must exist (it does in this repo).
- Node/pnpm: `pnpm install` already run.

## 1. Run the full hook test suite

Runs content-hash, context-loader, scope, pre-hook, post-hook, and middleware:

```bash
pnpm test:hooks
```

Or without pnpm:

```bash
npx tsx scripts/test-hooks.ts
```

## 2. Run the trace scenario (one flow end-to-end)

Simulates: **select_active_intent** → **write_to_file** (pre-hook) → **post-hook** appends to `agent_trace.jsonl`, then prints the last trace entry.

```bash
pnpm test:trace-scenario
```

Or:

```bash
npx tsx scripts/test-trace-scenario.ts
```

You should see:

- Intent `INT-001` loaded
- `write_to_file` allowed (in scope)
- A new line in `.orchestration/agent_trace.jsonl`
- The last entry printed with `intent_id`, `content_hash`, and **REQ-ID** in `related`

## 3. Inspect the trace file yourself

After running the scenario (or after real agent writes):

```bash
# Last 3 trace entries (pretty-printed)
tail -n 3 .orchestration/agent_trace.jsonl | while read line; do echo "$line" | jq .; done

# Or just the raw last line
tail -n 1 .orchestration/agent_trace.jsonl
```

## 4. Create your own scenario

Copy `scripts/test-trace-scenario.ts` and change:

- `intent_id` (must exist in `.orchestration/active_intents.yaml`)
- `path` (must be under that intent’s `owned_scope`, e.g. `src/api/**`)
- `content` and `mutation_class` (`AST_REFACTOR` | `INTENT_EVOLUTION` | `NEW_FILE`)

Then run:

```bash
pnpm exec tsx scripts/your-scenario.ts
```

## Summary

| Command | What it does |
| -------------------------- | ----------------------------------------------------------------------- |
| `pnpm test:hooks` | All hook unit-style checks (content-hash, pre/post-hook, middleware). |
| `pnpm test:trace-scenario` | One full flow: select intent → write → append trace → print last entry. |

Both run in the terminal with no VS Code or extension required.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"lint": "turbo lint --log-order grouped --output-logs new-only",
"check-types": "turbo check-types --log-order grouped --output-logs new-only",
"test": "turbo test --log-order grouped --output-logs new-only",
"test:hooks": "pnpm exec tsx scripts/test-hooks.ts",
"test:trace-scenario": "pnpm exec tsx scripts/test-trace-scenario.ts",
"format": "turbo format --log-order grouped --output-logs new-only",
"build": "turbo build --log-order grouped --output-logs new-only",
"bundle": "turbo bundle --log-order grouped --output-logs new-only",
Expand All @@ -32,7 +34,7 @@
"@dotenvx/dotenvx": "^1.34.0",
"@roo-code/config-typescript": "workspace:^",
"@types/glob": "^9.0.0",
"@types/node": "^24.1.0",
"@types/node": "^24.2.1",
"@vscode/vsce": "3.3.2",
"esbuild": "^0.25.0",
"eslint": "^9.27.0",
Expand All @@ -45,6 +47,7 @@
"ovsx": "0.10.4",
"prettier": "^3.4.2",
"rimraf": "^6.0.1",
"ts-node": "^10.9.2",
"tsx": "^4.19.3",
"turbo": "^2.5.6",
"typescript": "5.8.3"
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const toolNames = [
"run_slash_command",
"skill",
"generate_image",
"append_lesson_learned",
"custom_tool",
] as const

Expand Down
Loading
Loading