Skip to content
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <id> # one root's resolved file list
py tools/resolve_chain.py --emit <dir> <root>... # root file and task skills
py tools/resolve_chain.py --emit <dir> --sections <root>... # 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
Expand Down
1 change: 1 addition & 0 deletions docs/architecture/05-building-block-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ misses it and reports nothing, because nothing declares what is absent.
| `--emit <dir> <root>...` | 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 <dir>` | 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

Expand Down
1 change: 1 addition & 0 deletions docs/architecture/08-crosscutting-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/architecture/09-architecture-decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions docs/architecture/12-glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
123 changes: 123 additions & 0 deletions docs/decisions/060-section-files-load-on-demand.md
Original file line number Diff line number Diff line change
@@ -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/<template ID>/<heading>.md`, so no emitted path or
line names a template file (MUST)
6. **Deterministic** — the same chain and declined list give
byte-identical files (MUST)
7. **Not frozen** — the flag and the layout may change or go in a minor
until a benchmark round decides whether the mode is a delivery

## Alternatives considered

| Alternative | Why not |
|---|---|
| Stable anchors per section, the map naming `file#anchor` | Freezes one more name per heading, and an agent's file reader takes no anchor, so it reads the whole file anyway |
| Split a template over a size limit into topic files | Changes template paths, which 3.x freezes, and leaves a topic's dependencies in other files |
| Whole templates read on demand from a map | Already measured: the agent read most of the chain within three turns |
| Leave the root file as it is | Every turn carries most of the chain, which no delivery has yet been measured against topic by topic |

## Consequences

| Consequence | Effect |
|---|---|
| Tool | `resolve_chain.py --emit <dir> --sections <root>...` writes the map and the section files; `--inline-skills` with it is refused |
| Checks | SYS-28 compares the files with the inlined root file's rules, every root built alone, and runs the tool twice under different hash seeds; SYS-27 scans the section files for template paths |
| Requirements | FR-06-08 and FR-06-09 state the mode |
| Frozen surface | The mode is listed as not frozen (chapter 8.7) |
| Benchmark | Builds arm `lazysections` from the mode, beside the arm that reads every template up front and the one that reads whole templates on demand |

## Compatibility

None for an existing project: the root file and skills, inlined or not,
are byte-identical to what the emitter built before. A project that moves
to `--sections` keeps its filled-in facts, and the emitter removes the
skills it wrote before, as it removes any file it no longer emits.

## Security

- Exposes: every rule leaves the root file, a section that guards data,
credentials or authentication included, so it is read only when the
work touches its topic. The root and skills keep such a section in
context on every turn, which is why this mode is opt-in and measured
first, on the benchmark's security and data-protection rows as well as
every other
- Protects: a file carries every section its rules extend or name, so no
rule in it is left to a reference the agent may not follow
- Trust boundary: the section files are built by the tool into the
project's tree, under the same review as the root file

## Related

- solid-ai-dev/solid-ai-benchmark#169, the arms that compare deliveries
2 changes: 2 additions & 0 deletions docs/requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Status: skeleton. Each cluster holds a few requirements until its fill
| FR-06-05 | The system shall reference a section marked `check` by its command and pass condition, never by copying the script body. | ADR-058 | SYS-26, partial, on a planted fixture |
| FR-06-06 | The system shall build byte-identical files from the same input. | ADR-058 | SYS-26 |
| FR-06-07 | The system shall build files that name no template file, since an emitted project carries no templates. | `AGENTS.md` 4.2 | SYS-27 |
| FR-06-08 | Where the project asks for section files, the system shall build one file per heading under a template's title, carrying the rules under that title, each section it extends or names by ID or by heading, and each extension of its own, each resolved through overrides to the rules that survive, so the files together hold every adopted rule and every copy matches its source. | ADR-060 | SYS-28 |
| FR-06-09 | Where the project asks for section files, the system shall map each file in the root file to its topic, to be read when the work first touches it, and hold no rule in the root file. | ADR-060 | SYS-28 |

### 07. Shipped checks

Expand Down
1 change: 1 addition & 0 deletions docs/tests/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ restated in each.
| `SAIT-SMK-SYS-25-001A` | SMK | P1 | A load directive names a listed task, in its heading's tags |
| `SAIT-SMK-SYS-26-001A` | SMK | P1 | The emitter places each section by its load, the same every run |
| `SAIT-SMK-SYS-27-001A` | SMK | P1 | An emitted file names no template file |
| `SAIT-SMK-SYS-28-001A` | SMK | P1 | Section files hold every adopted rule, read on demand from a map |
| `SAIT-SMK-SYS-29-001A` | SMK | P1 | No frozen ID or path leaves the tree inside the major |
| `SAIT-SMK-TPL-04-001A` | SMK | P1 | All EXTEND and OVERRIDE directives reference existing IDs |
| `SAIT-INT-TPL-01-001A` | INT | P0 | DEPENDS ON chain assembles a complete rule set |
Expand Down
11 changes: 6 additions & 5 deletions docs/tests/specs/SAIT-SMK-SYS-27-001A.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ tags: [tooling, composition, delivery]
## Short description

> **Given** every root a project can pick
> **When** the emitter builds each root on its own, with skills and inlined
> **When** the emitter builds each root on its own, with skills, inlined
> and as section files
> **Then** no line of an emitted file names a template file, because an
> emitted project carries the rules and not the templates, so a named
> template is a file the agent cannot open and the rules it stands for
Expand All @@ -31,7 +32,7 @@ names a template in, and the path goes unseen.

| Result | Condition |
|--------|-----------|
| PASSED | The planted template's two named paths are both found in each mode, the planted override hides one only when the roots are built together, and no file emitted from any root alone, in either mode, names a template file |
| PASSED | The planted template's two named paths are both found in each mode, the planted override hides one only when the roots are built together, and no file emitted from any root alone, in any mode, names a template file |
| FAILED | An emitted line names a template file, with or without its `templates/` prefix, or the planted scan misses a form |
| SKIPPED | — |
| BLOCKED | — |
Expand All @@ -55,8 +56,8 @@ file is written)
`templates/` prefix, in a skill, and once without, in a section a
second planted root overrides
2. Build the planted roots together, then each on its own
3. Build every root `--roots` lists on its own, with skills and then with
skills inlined
3. Build every root `--roots` lists on its own, with skills, with skills
inlined, and as section files
4. Scan every emitted line for the path of every template file

### Assertions
Expand All @@ -65,7 +66,7 @@ file is written)
each mode
2. Assert the planted roots built together show one of the two paths, and
built each on its own show both
3. Assert no line emitted from any root, in either mode, names a template
3. Assert no line emitted from any root, in any mode, names a template
file

### Negative controls
Expand Down
Loading