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
8 changes: 7 additions & 1 deletion BOOTSTRAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ The plan lists:
- Each check that Bootstrap will build, and each check spec that an existing check already covers.
- Each conflict and the Owner's answer.
- Each label that Bootstrap will create in the tracker.
- For an existing Project, one `cleanup` issue per module that holds comments, dead code, or duplicate code.

Get the Owner's approval of the plan before Step 5.

Expand Down Expand Up @@ -154,6 +155,11 @@ For each check spec in the plan:
A check that you cannot prove both ways is not done.
After two failed attempts on one check, record it in the plan as open, tell the Owner, and continue with the next check.

When you build [feedback-budget](./checks/feedback-budget.md), measure each Feedback loop once.
A loop that is already over its budget is a conflict for the Owner.
Recommend making the loop fast before the check turns on.
When the Owner chooses a higher budget for now, record it in an ADR with the date to return to the Default, and open a `budget` issue.

## Step 7: prove the setup

1. Start a fresh agent session that has seen none of this work.
Expand All @@ -179,6 +185,6 @@ After two failed attempts on one check, record it in the plan as open, tell the
- which checks run, and where;
- the open items and the known-red list;
- what to do next: usually the first real task.
4. After the merge, create the tracker labels.
4. After the merge, create the tracker labels, then the `cleanup` issues from the plan.

Bootstrap is done when the pull request is merged and the labels exist.
9 changes: 9 additions & 0 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ Its issue carries the `escaped` label and links the pull request that caused it.
**Known-red baseline**:
The list of failing tests that a session records before its first edit.

**Feedback loop**:
One automatic run of checks that an agent or a human waits on before work continues.
A Project has three: the Git hook, the Relevant tier of the check ladder, and the CI gate on each pull request.
The full suite is not a Feedback loop, because it runs only when the Owner asks.

**Feedback budget**:
The maximum wall-clock time of one Feedback loop.
_Avoid_: speed limit, SLA, performance budget.

## Verification

**Verification contract**:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The agent that bootstraps a project reads the project's own stack and fits the k
- One rules file that every coding agent reads, with a short reading map to task pages.
- Task pages for engineering, testing, git, review and merge, delegation, documentation, domain language, the issue tracker, runtime verification, corrections, and security.
- A set of check specs, each built as a real check in the project's own stack and proved with a failing case and a passing case.
- A time budget for the Git hook, the affected tests, and CI, so that checks stay fast as the code grows.
- No code comments, no dead code, and no duplicate code, so that each fact has one home and there is less code to check.
- A risk tier for every change, set by a check from the changed paths, never by the agent.
- A review mode that fits the person who owns the project, from "I review every diff" to "I do not read code".
- Light records that show what to enforce next and when autonomy is earned: corrections, evidence in each pull request, and escaped defects.
Expand Down
4 changes: 4 additions & 0 deletions checks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ A check that a hook runs must also run in CI, because a hook can be skipped on a
| [no-suppressions](./no-suppressions.md) | The Project has a linter or type checker |
| [no-network-in-tests](./no-network-in-tests.md) | The Project has automated tests |
| [merged-result](./merged-result.md) | Always |
| [feedback-budget](./feedback-budget.md) | Always |
| [no-comments](./no-comments.md) | The Project has application code |
| [no-dead-code](./no-dead-code.md) | The Project has application code |
| [no-duplicate-code](./no-duplicate-code.md) | The Project has application code |

## Adding a check spec to a Project

Expand Down
39 changes: 39 additions & 0 deletions checks/feedback-budget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# feedback-budget

**Invariant**:
Each Feedback loop finishes within its Feedback budget, measured in CI on the Project's standard runner.
The Default budgets are 30 seconds for the Git hook, 2 minutes for the Relevant tier, and 10 minutes for the CI gate.
When a loop takes 80% of its budget or more, the check opens one issue with the `budget` label for that loop, or updates the open one.
When a loop takes more than its budget, the check fails.

**Why**:
Code grows with every change, and each Feedback loop grows with it.
A loop that gets a little slower each week stops nobody until agents and humans wait minutes for each answer, or skip the loop.

**Applies when**: always.
Skip a loop that the Project does not have.

**Runs in**: CI, on every pull request.

**How CI measures each loop**:

- Git hook: a CI job runs the hook command on the files that the pull request changes, and records its wall-clock time.
- Relevant tier: a CI job runs the affected-tests command on the files that the pull request changes, and records its wall-clock time.
- CI gate: a final required job records the time from the start of the first required job to the end of the last one.

Local times are not evidence, because local machines differ in speed.

**Budget file**:
The Project keeps its budget numbers in one file that the check reads.
The numbers change only by an ADR.
A change to the budget file is Tier 3; see [test-oracle-guard](./test-oracle-guard.md).

**Failing case**:
The CI gate takes 11 minutes on a pull request.

**Passing case**:
The CI gate takes 7 minutes, and the check opens no issue.
Also passing: the CI gate takes 8 minutes 30 seconds, and the check opens a `budget` issue for the CI gate.

**Error text**:
`<loop> took <time>; its Feedback budget is <budget>. Make the loop faster in this pull request. Never raise the budget to pass; see testing.md.`
38 changes: 38 additions & 0 deletions checks/no-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# no-comments

**Invariant**:
No line that a change adds to a source file holds a comment, except a comment on the allow-list.
The allow-list is:

- a shebang line;
- a license header that the Project's license requires;
- a directive that the language, compiler, or build tool reads, such as an encoding declaration or a build constraint;
- a doc comment on an exported symbol of a published package, when the package's API reference is generated from it.

Generated files are exempt.
A suppression directive is not on the allow-list; [no-suppressions](./no-suppressions.md) owns it.

**Why**:
A comment repeats a fact that the code, an ADR, a test, or the tracker already owns.
No check keeps it true, so it goes stale and misleads the next reader.
More text in each file also means more for agents to read and for checks to scan.

**Applies when**: the Project has application code.

**Runs in**: hook and CI, on the lines that the change adds.
Existing comments stay until their cleanup issue removes them.

**Allow-list file**:
The Project keeps the allow-list in `docs/checks/no-comments.md`.
A change to the allow-list is Tier 3; see [test-oracle-guard](./test-oracle-guard.md).

**Failing case**:
A change adds a comment that says what the next line does.
Also failing: a change adds a line of commented-out code, or a comment that marks work to do later.

**Passing case**:
The change renames the function so that the comment adds nothing, and deletes the comment.
Work to do later is a tracker issue.

**Error text**:
`<file>:<line> adds a comment. Delete it. Put the reason in a name, an ADR, a test name, the commit message, or a tracker issue; see engineering.md.`
29 changes: 29 additions & 0 deletions checks/no-dead-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# no-dead-code

**Invariant**:
A pull request adds no dead symbol.
A dead symbol is a file, function, type, constant, export, or dependency that nothing reachable from a Project entry point uses.
The exported API of a published package is an entry point.
A symbol in application code that only tests use is dead.

The check compares the dead symbols on the pull request head with those on the base branch.
It fails when the head has a dead symbol that the base branch lacks, wherever that symbol is.

**Why**:
Dead code costs build time, test time, and reading time, and returns nothing.
A change often kills code in a file that it does not touch, by deleting the last caller.
A check that reads only the changed lines misses that.

**Applies when**: the Project has application code.

**Runs in**: CI.

**Failing case**:
A pull request deletes the last caller of a function in another file, and leaves the function.

**Passing case**:
The pull request deletes the function too.
Dead symbols that existed on the base branch do not fail the check; their cleanup issue removes them.

**Error text**:
`<symbol> in <file> is dead after this change: nothing reachable from an entry point uses it. Delete it.`
28 changes: 28 additions & 0 deletions checks/no-duplicate-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# no-duplicate-code

**Invariant**:
A change adds no block of code that duplicates another block in the Project.
A duplicate is a block of 10 or more lines, or 100 or more tokens, that appears twice when formatting is ignored.
Test files count.
Generated files are exempt.

The thresholds are Defaults.
The Project keeps them in the check's configuration, changes them only by an ADR, and a change to them is Tier 3; see [test-oracle-guard](./test-oracle-guard.md).

**Why**:
Each copy of a block is more code to build, test, and read.
A fix that reaches one copy and misses the other is a defect.

**Applies when**: the Project has application code.

**Runs in**: hook and CI, on the lines that the change adds.

**Failing case**:
A change copies a 15-line validation block from one handler into another.

**Passing case**:
The change moves the block into one function that both handlers call.
Duplicates that existed before the change do not fail the check; their cleanup issue removes them.

**Error text**:
`<file>:<lines> duplicates <other file>:<lines>. Extract one shared unit and call it from both places.`
1 change: 1 addition & 0 deletions checks/test-oracle-guard.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

**Invariant**:
A pull request that deletes a test, skips a test, removes an assertion, adds a lint or type suppression, raises a test timeout, or changes CI or check configuration is at least Tier 3.
Check configuration includes the Feedback budget file, the comment allow-list, and the duplicate-code thresholds.

**Why**:
An agent can make a failing check pass by weakening the check instead of fixing the code.
Expand Down
1 change: 1 addition & 0 deletions core/agents/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ When you change behavior, update the document that owns it in the same change.
| Task-specific agent instruction | `docs/agents/<task>.md` |
| How to call a module now | That module's `HOW-TO.md` |
| A decision and its reasons | An ADR in `docs/adr/` |
| The reason behind code | Never a code comment; see [engineering.md](./engineering.md#mandatory-no-code-comments) |
| A domain term | The `CONTEXT.md` that owns it; see [domain.md](./domain.md) |
| A check's invariant | `docs/checks/<name>.md` |
| A user-visible feature's verification | Its Feature map; see [verification.md](./verification.md) |
Expand Down
21 changes: 21 additions & 0 deletions core/agents/engineering.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,27 @@ A slower path that removes a class of defects beats a faster path that needs a r
- Do not add a suppression directive to silence a lint or type error.
Fix the cause, or change the rule for the whole Project through an ADR.

## Mandatory: no code comments

Code holds no comments.
A comment repeats a fact that has another home, and no check keeps it true, so it goes stale.

Put each fact in its home instead:

| Fact | Home |
| ---- | ---- |
| What the code does | Names: rename the function or variable until a comment would add nothing |
| Why the code is shaped this way | An ADR for a decision; the commit message for one change |
| Why a workaround exists | A fail-first test named after the upstream defect, so that removing the workaround fails it |
| Work to do later | A tracker issue |
| How to call a module | Its `HOW-TO.md` |
| Old code | Version control; delete commented-out code |

The check spec [no-comments](../../checks/no-comments.md) enforces this rule and holds the allow-list.
The allow-list covers only lines that a tool reads: a shebang, a required license header, a language or build directive, and doc comments on the exported API of a published package.
The check scans only the lines that a change adds.
Existing comments go through their cleanup issue.

## Default: design

- Make invalid states impossible to represent before you add a check that detects them.
Expand Down
2 changes: 2 additions & 0 deletions core/agents/issue-tracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Bootstrap creates these labels:
| `correction` | A repeated agent mistake that needs a check or a better API |
| `escaped` | A bug found after its change merged |
| `needs-triage` | A failure or report that nobody has classified yet |
| `budget` | A Feedback loop took 80% of its Feedback budget or more |
| `cleanup` | Old comments, dead code, or duplicate code in one module that existed before Bootstrap |
| `tier-0` to `tier-4` | The Tier that the tier check gave a pull request |
| `<owner label>` | The person that the working agent works for; one label per person |

Expand Down
2 changes: 1 addition & 1 deletion core/agents/review-and-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The check spec [risk-tier](../../checks/risk-tier.md) defines the check.
| 0 | Mechanical | Formatting, generated code from an approved source, a document fix |
| 1 | Low | A local bug fix with a fail-first test, touching no risk area |
| 2 | Medium | Behavior across modules, a public API, a dependency change, background job behavior |
| 3 | High | Authentication, authorization, isolation between users or tenants, money, schema migrations, secrets, destructive jobs, CI and check configuration |
| 3 | High | Authentication, authorization, isolation between users or tenants, money, schema migrations, secrets, destructive jobs, CI and check configuration, Feedback budgets |
| 4 | Critical | Bulk data changes, production access changes, irreversible operations |

The Project's tier map lists the paths for each Tier.
Expand Down
37 changes: 37 additions & 0 deletions core/agents/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,43 @@ After a tier passes, repeat it only for new changes, new failures, or a concern

A change to documents only needs the document checks, not application tests.

## Mandatory: Feedback budget

Each Feedback loop has a Feedback budget.
Code growth must never make a loop slower than its budget.

| Feedback loop | What it runs | Feedback budget |
| ------------- | ------------ | --------------- |
| Git hook | The hook checks on the changed files | 30 seconds |
| Relevant tier | `<affected tests command>` on the changed files | 2 minutes |
| CI gate | Every required CI job on one revision, wall clock | 10 minutes |

The numbers are Defaults.
Change them only by an ADR; such a change is Tier 3.
Never raise a budget to make a loop pass.

CI measures each loop on its standard runner, as the check spec [feedback-budget](../../checks/feedback-budget.md) says.
Local times are not evidence.

- At 80% of a budget, the check opens one `budget` issue for that loop.
Work that issue before the loop reaches 100%.
- Over the budget, the loop fails.
The change that crosses the budget brings the loop back under it, in the same pull request, even when older growth caused most of the time.
This failure is Introduced, not Pre-existing.
- One run over the budget is a failure.
Do not rerun to get a pass.

## Default: staying inside the Feedback budget

- The hook checks only the staged files.
- The Relevant tier selects affected tests from the dependency graph.
- CI caches dependencies and build outputs.
- CI shards tests across parallel jobs.
- Each check runs once per commit; no two workflows run the same job.
- A change to documents only skips application tests in CI.
- Less code is less to check.
The check specs [no-dead-code](../../checks/no-dead-code.md) and [no-duplicate-code](../../checks/no-duplicate-code.md) stop code that adds time and no value.

## Mandatory: baseline and failure classes

Run the Baseline tier before your first edit.
Expand Down
2 changes: 2 additions & 0 deletions core/rules-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ Find runnable commands in <manifest file> and hook commands in <hook config file
- A requested Code review pauses integration and publishing until approval.
- Approval of a design is not permission to implement it.
- The Tier of a change comes from the tier check, never from the agent.
- Write no code comments outside the allow-list in `docs/checks/no-comments.md`.
Put the reason for code in a name, an ADR, a test name, or the commit message.
- Never add agent attribution or co-author lines to commits, pull requests, issues, or comments.

## Communication
Expand Down
Loading