Skip to content
Merged
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
284 changes: 284 additions & 0 deletions docs/api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3779,6 +3779,17 @@
"null"
]
},
"exploration": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/components/schemas/RunExploration",
"description": "What the run explored: the repository's code map brought to the base\nbefore planning, and the build's tool calls before its first write.\nAbsent for a run that neither planned nor built."
}
]
},
"files_modified": {
"description": "The files the run changed.",
"examples": [
Expand Down Expand Up @@ -4162,6 +4173,17 @@
}
]
},
"traceability": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/components/schemas/RunTrace",
"description": "Each acceptance criterion of the ticket (or of the plan's criteria\nmap) traced to the files and definitions changed for it, the tests\nthat cover it, and what proves it on the pull request's head. A row\nwhose proof isn't `proven`, or with no code or no tests, is an open\ngap. Absent until the run's pull request has a description built for\nits head."
}
]
},
"trigger": {
"$ref": "#/components/schemas/RunTrigger",
"description": "How the run was started and by whom (as in the runs list)."
Expand Down Expand Up @@ -4437,6 +4459,103 @@
],
"type": "object"
},
"RunCodeMapRefresh": {
"description": "What bringing the code map to the base did (`common::code_map`).",
"properties": {
"commit": {
"description": "The commit the map describes now.",
"examples": [
"c0ffee1234567890c0ffee1234567890c0ffee12"
],
"type": "string"
},
"missed": {
"description": "Sections to rebuild that the model left out: the next run rebuilds\nthem.",
"examples": [
[]
],
"items": {
"type": "string"
},
"type": "array"
},
"rebuilt": {
"description": "Sections written again from the base.",
"examples": [
[
"build"
]
],
"items": {
"type": "string"
},
"type": "array"
},
"reused": {
"description": "Sections kept as they were.",
"examples": [
[
"architecture",
"stack",
"area:apps"
]
],
"items": {
"type": "string"
},
"type": "array"
},
"why": {
"description": "`new`, `current`, `changed` or `unknown changes`.",
"examples": [
"changed"
],
"type": "string"
}
},
"required": [
"commit",
"why"
],
"type": "object"
},
"RunCoderExploration": {
"description": "The build's tool calls before its first write, and the map it had.",
"properties": {
"calls_before_first_write": {
"description": "Tool calls before the first file was written; absent when it wrote\nnone.",
"examples": [
4
],
"format": "int32",
"minimum": 0,
"type": [
"integer",
"null"
]
},
"map_commit": {
"description": "The code map's commit the build started from; absent when it had\nnone.",
"examples": [
"c0ffee1234567890c0ffee1234567890c0ffee12"
],
"type": [
"string",
"null"
]
},
"tool_calls": {
"description": "All the build's tool calls.",
"examples": [
31
],
"format": "int32",
"minimum": 0,
"type": "integer"
}
},
"type": "object"
},
"RunCoveredBy": {
"description": "The open pull request that already does a run's work.",
"properties": {
Expand Down Expand Up @@ -4673,6 +4792,34 @@
],
"type": "object"
},
"RunExploration": {
"description": "What a run explored, and what it started from.",
"properties": {
"code_map": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/components/schemas/RunCodeMapRefresh",
"description": "The repository's code map, brought to the run's base before\nplanning; absent when the run didn't plan."
}
]
},
"coder": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/components/schemas/RunCoderExploration",
"description": "The build's exploration; absent before it built."
}
]
}
},
"type": "object"
},
"RunMergeStanding": {
"description": "Where a run's pull request stands on its way to merge.",
"properties": {
Expand Down Expand Up @@ -5307,6 +5454,143 @@
],
"type": "object"
},
"RunTrace": {
"description": "Each acceptance criterion traced to the code, tests and proof of one\nhead (`common::trace`).",
"properties": {
"head": {
"description": "The pull request's head the trace is of.",
"examples": [
"c0ffee1234567890c0ffee1234567890c0ffee12"
],
"type": "string"
},
"rows": {
"description": "One row per criterion.",
"items": {
"$ref": "#/components/schemas/RunTraceRow"
},
"type": "array"
}
},
"required": [
"head",
"rows"
],
"type": "object"
},
"RunTraceCode": {
"description": "A changed file traced to a criterion.",
"properties": {
"path": {
"description": "The file's path in the repository.",
"examples": [
"src/utils/filters.ts"
],
"type": "string"
},
"symbols": {
"description": "Functions, types and constants it adds or changes.",
"examples": [
[
"dedupeBySlug"
]
],
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"path"
],
"type": "object"
},
"RunTraceProof": {
"description": "What proves a criterion on the head.",
"properties": {
"by": {
"description": "What ran: `end to end on staging and the preview` or `tests with and\nwithout the change`; empty when nothing did.",
"examples": [
"end to end on staging and the preview"
],
"type": "string"
},
"detail": {
"description": "What the run showed.",
"examples": [
"fails on staging (1 failed) and passes on the preview (1 passed)"
],
"type": "string"
},
"state": {
"description": "`proven`, `not_the_ticket` (passes without the change), `failing`,\n`missing` (no test), `unverified` (a side couldn't run) or `not_run`.",
"examples": [
"proven"
],
"type": "string"
}
},
"required": [
"state"
],
"type": "object"
},
"RunTraceRow": {
"description": "One criterion's row of the trace.",
"properties": {
"code": {
"description": "The changed files traced to it, each with the definitions it adds\nor changes there.",
"items": {
"$ref": "#/components/schemas/RunTraceCode"
},
"type": "array"
},
"criterion": {
"description": "The criterion, as written.",
"examples": [
"Only one sport filter chip shows on /camps"
],
"type": "string"
},
"page": {
"description": "The site path it is about, when it names one.",
"examples": [
"/camps"
],
"type": "string"
},
"proof": {
"$ref": "#/components/schemas/RunTraceProof",
"description": "What proves it on the head."
},
"source": {
"description": "Where it was written: `ticket` or `plan` (the plan's criteria map).",
"examples": [
"ticket"
],
"type": "string"
},
"tests": {
"description": "The tests that cover it (`file` or `file › title`).",
"examples": [
[
"e2e/camps.spec.ts › shows one chip"
]
],
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"criterion",
"source",
"proof"
],
"type": "object"
},
"RunTrigger": {
"description": "How a run was started, in words, with a link to what started it.",
"properties": {
Expand Down
80 changes: 80 additions & 0 deletions docs/code-map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# The code map

What CoderHelm knows about each repository's code, kept current with its
default branch, so the planner and the coder start from it instead of
exploring the layout again on every run.

Code: `services/common/src/code_map.rs` (the rules, pure) and
`services/worker/src/passes/code_map.rs` (reading, writing, recording).

## What it holds

The map is kept on the repository's agent file record (settings table,
`sk = AGENTS#REPO#<owner/repo>`, attribute `code_map`), beside the agent
file. It is made of sections:

| Section | What it says | Read from |
| --- | --- | --- |
| `architecture` | What the repository is for, its main parts, how requests and jobs flow, where each part is deployed | README, agent guidance, infrastructure roots |
| `stack` | Languages, frameworks, runtimes and the versions the manifests pin | Top-level manifests and toolchain files |
| `build` | Install, build, type-check, lint, test (each suite) and run commands, and what CI runs | CI workflows, manifests, test and lint config |
| `conventions` | Style, lint and format rules, naming, error handling, logging, test layout, guidance and the pull request template | Agent guidance, tooling config, the template |
| `dependencies` | Which packages, services and infrastructure depend on which | Every package manifest up to two levels deep, compose files |
| `area:<folder>` | One per top-level folder (at most 12): what it holds, its packages and entry points by path, where each concern lives | The folder's listing, its manifests and entry points |

Each section is stamped with the commit it describes. The map is stamped
with the commit and the tree it was last brought to.

## Kept current, section by section

Before the planner starts, the map is brought to the run's base:

1. **Same commit, or same tree.** Every section is reused. No tree is read and
no model is called.
2. **Otherwise** GitHub's comparison from the map's commit to the base gives
the changed paths, and each path marks the sections it touches:
- a top-level manifest touches `stack`, `build` and `dependencies`;
- a package manifest deeper in the tree touches `stack`, `dependencies`
and its area;
- CI touches `build`;
- lint and format config touch `conventions` and `build`;
- guidance and the pull request template touch `conventions`;
- the README touches `architecture`;
- infrastructure (Terraform, CDK, CloudFormation, Kubernetes, compose)
touches `architecture` and `dependencies`;
- a file added, removed or renamed in an area, or an entry point
(`main`, `index`, `lib`, `app`, `server`, `handler`, route tables)
changed there, touches that area;
- an area added or gone touches `architecture`.

A plain edit inside a source file touches nothing: the map describes
structure, not every line.
3. **A comparison that can't be read, or that GitHub cut** (300 files or
more), rebuilds every section.

Only the touched sections are read again (their own files, at most ten each)
and written, all in one model call. The rest are kept. A section the reply
left out keeps its older stamp. The map tells the agents it may be out of
date, and the next run rebuilds it.

## Who reads it

- **The planner** gets the map in its system prompt, after the repository's
instruction files.
- **The coder** gets the stored map in every round's system prompt. The coder
reads the map without refreshing it, so its prompt stays the same across a
run's rounds.

## What it saves, on the run

Two run attributes, served by `GET /api/runs/{run_id}` under `exploration`:

- `code_map_refresh` (`exploration.code_map`): the commit the map was
brought to, why (`new`, `current`, `changed`, `unknown changes`), and the
sections reused, rebuilt and missed.
- `exploration` (`exploration.coder`): the build's tool calls before its
first write (`calls_before_first_write`), all its tool calls, and the
map's commit when it started from one (`map_commit`). Comparing runs with
and without a `map_commit` shows how much exploration the map saves.

The replay case is `services/worker/src/passes/incidents/dg_code_map_kept_current.rs`.
Loading
Loading