diff --git a/AGENTS.md b/AGENTS.md index bb87454d..84335fbe 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,6 +26,7 @@ py tools/sync_docs.py --check # exit 1 if any is stale py tools/resolve_chain.py --roots # every root a project can pick py tools/resolve_chain.py # one root's resolved file list py tools/resolve_chain.py --emit ... # root file and task skills +py tools/resolve_chain.py --emit --sections ... # map and section files py tests/run.py smoke # structure and resolution py tests/run.py conformance # the templates' own checks, run here py tests/run.py fork_sync # the change merged into a simulated fork diff --git a/docs/architecture/05-building-block-view.md b/docs/architecture/05-building-block-view.md index c2d636b0..a9c4a380 100644 --- a/docs/architecture/05-building-block-view.md +++ b/docs/architecture/05-building-block-view.md @@ -89,6 +89,7 @@ misses it and reports nothing, because nothing declares what is absent. | `--emit ...` | Roots and the declined list | The root file and one skill per kind of task | FR-06-03, FR-06-04, FR-06-06 | | `--inline-skills` | As `--emit` | One root file with the skills inlined, for an agent without skills | ADR-058 | | `--mirror ` | As `--emit` | A copy of the skills where an agent reads only its own folder | ADR-058 | +| `--sections` | As `--emit` | A root file that maps each topic to its file, and one file per topic under `.agents/sections/`, read on demand | FR-06-08, FR-06-09 | ## 5.5 Level 2: self-checks diff --git a/docs/architecture/08-crosscutting-concepts.md b/docs/architecture/08-crosscutting-concepts.md index 6c7ee35a..804faa55 100644 --- a/docs/architecture/08-crosscutting-concepts.md +++ b/docs/architecture/08-crosscutting-concepts.md @@ -160,6 +160,7 @@ These elements are not frozen. | The wording inside a section | Prose is free while the section keeps its ID | ADR-051 | | The declaration block | A target with no producer and no reader | ADR-053 | | The fixture, `stack-fixture` and `platform-fixture` | Test input; no listing offers it and no project resolves it | - | +| The emitter's `--sections` flag and the `.agents/sections/` layout it writes | Opt-in and not yet measured; a benchmark round decides whether it is a delivery | ADR-060 | | The helpers `bind()` hands `fork_checks.py` | Every name in the smoke modules; a change to one is listed in the changelog | - | ## 8.8 Deprecation diff --git a/docs/architecture/09-architecture-decisions.md b/docs/architecture/09-architecture-decisions.md index 27da1e92..90ee15e4 100644 --- a/docs/architecture/09-architecture-decisions.md +++ b/docs/architecture/09-architecture-decisions.md @@ -43,6 +43,7 @@ What a project's generated files hold, and how the rules reach them. | [ADR-052](../decisions/052-hybrid-is-the-delivery-floor.md) | A context file delivers rules inline or hybrid, never by reference alone, and inlines every rule whose breach is silent and which no tool enforces | Accepted | | [ADR-053](../decisions/053-declaration-block-is-a-target.md) | The declaration block leaves the frozen surface until a release ships a tool that writes it and one that reads it | Accepted | | [ADR-058](../decisions/058-task-procedures-load-on-demand.md) | Each section declares where its rules load, and a tool builds the root file and one skill per kind of task from the adopted rules | Accepted | +| [ADR-060](../decisions/060-section-files-load-on-demand.md) | The emitter can build one file per topic, each with every rule it depends on, and a root file that maps each topic to its file, read on demand | Accepted | ## 9.3 Template content diff --git a/docs/architecture/12-glossary.md b/docs/architecture/12-glossary.md index 157cebd9..4b21e8ed 100644 --- a/docs/architecture/12-glossary.md +++ b/docs/architecture/12-glossary.md @@ -30,6 +30,7 @@ requirement in [requirements.md](../requirements.md). | Platform | A fork's template mapping CI and security tools to one hosting platform | | Root | A template a project picks directly, as a stack, a platform or an extra. Upstream has no stack, so every one of its templates except the fixture is a root | | Root file | The context file at a project's root, read on every turn, which lists the task skills that load on demand | +| Section file | A file under `.agents/sections/` holding one heading of a template with every rule it depends on, read when the work first touches its topic | | Stack | A fork's technology-specific template, the main root of a chain | | Task kind | A kind of task, such as `release`, that a load directive names and a skill serves, listed under the manifest's `tasks:` | | Task skill | A folder under `.agents/skills/` holding the rules for one task kind, loaded when that task starts | diff --git a/docs/decisions/060-section-files-load-on-demand.md b/docs/decisions/060-section-files-load-on-demand.md new file mode 100644 index 00000000..ce48db3b --- /dev/null +++ b/docs/decisions/060-section-files-load-on-demand.md @@ -0,0 +1,123 @@ +--- +id: "060" +status: Accepted +date: 2026-11-15 +category: composition +supersedes: [] +superseded_by: [] +--- + +# ADR-060: The emitter can build section files that load on demand + +## Context + +The emitter's root file holds every rule without a load directive, so an +agent reads most of its chain on every turn, whatever the task touches. +The benchmark measures other deliveries against it, each built by script +from the same chain (solid-ai-dev/solid-ai-benchmark#169). + +- Whole templates read on demand from a map, the benchmark's `lazyref` + arm, read 11 of 13 templates, about 46k tokens, by turn 3 in its round + 5e (15 runs), so an agent that needs one topic reads the whole file + (#2466) +- A template holds several topics; the benchmark chain's run from about + 450 to 1,700 words each, and nothing hands an agent one topic of one +- A topic's rules can depend on rules elsewhere: the rules under the + template's title, a section it extends, a section its prose names by + ID or by heading, and an extension a later template adds on top of it +- Template paths and section IDs are frozen for 3.x, so a delivery that + splits templates or anchors each heading changes the frozen surface + +## Decision + +The emitter gains an opt-in mode, `--sections`, that builds one file per +topic, each a heading of a template with every rule it depends on, and a +root file that maps each topic to its file, to be read when the work +first touches it. + +## Rationale + +- One topic, one read: an agent reads the rules of the topic at hand, not + the whole template that holds it +- Same rules, same precedence: the mode applies the overrides, the + declined list and the checked cut the other modes apply, so only + packaging and loading differ, which is what the benchmark compares +- Nothing frozen changes: the files are built from the templates as they + are, with no new anchor, path or ID +- Measured before it is endorsed: the mode stays opt-in and outside the + frozen surface until a benchmark round compares it with the root file + and with whole templates on demand + +## Design + +1. **Topic** — each heading one level under a template's title, with its + subheadings, is a topic with a file of its own. The rules under a + title alone get a file only where no topic's file carries them +2. **Carried rules** — a topic's file carries, in chain order, the rules + under its template's title, each section it extends, each section its + prose names by ID in backticks or by heading, each extension of its own + sections, and what each of those carries in turn. A heading is named + by its exact text in double quotes, after "see", or as a link to its + anchor, read across a wrapped line, and resolves in the naming + template first, then anywhere in the chain. Each relationship is read + from the template as written and resolved through the overrides to the + rules that survive. Rules carried only because they sit under a title + do not bring that title's extensions (MUST) +3. **Same rule set** — the files together hold exactly the rules the + inlined root file holds, and every copy of a rule matches its source + (MUST) +4. **The map** — the root file keeps the facts, states + `Model: root and sections`, and lists each template by its title and + manifest description, with one row per topic naming its file. It holds + no rule, and tells the agent not to read the files before the work + starts (MUST) +5. **Paths** — a file is written to + `.agents/sections/