Skip to content

feat(emit): build section files an agent reads one topic at a time - #2496

Merged
braboj merged 8 commits into
mainfrom
feat/section-files
Nov 19, 2026
Merged

braboj merged 8 commits into
mainfrom
feat/section-files

Conversation

@braboj

@braboj braboj commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

The emitter can now write task-sized section files that an agent reads one topic at a time, from a map in the root. Each file is a complete section plus the rules it depends on.

py tools/resolve_chain.py --emit <dir> [--declined <file>] --sections <root>...
  -> <dir>/AGENTS.md                                    the map, no rules
  -> <dir>/.agents/sections/<template-id>/<slug>.md     one topic each

How a file's rules are chosen, in chain order, until nothing new is pulled in:

  • the rules under its template's title
  • every section it extends, and every extension of its own sections
  • every section ID its prose names in backticks
  • overrides, the declined list and the check cut, as in the other modes
Check What it proves
SYS-28 block by block, the files' rules equal the inline root's; copies identical; a file naming a section carries it; the map lists each file once and says "Do not read them before the work starts"; same bytes under two hash seeds
SYS-27 section files name no template path
existing modes skills and inline output for all 39 roots byte-identical before and after

Sizes, the benchmark's lazyref chain: 125 files, 106 KB (median 106 words); map 11.7 KB. The inline root is 73 KB, so the copies add about 45 %.

Stacked on #2495. Closes #2466.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DpT5xQh3AgRFs2tJwMT4g3

…2466)

`resolve_chain.py --emit <dir> --sections <root>...` builds one file per
heading of each template, under `.agents/sections/<template ID>/`, and a
root file that maps each topic to its file, to be read when the work
first touches it.

- Each file carries the rules under its template's title, each section
  it extends or names by ID, and each extension of its own, in chain
  order, so precedence holds and no rule is left to a reference
- Overrides, the declined list and the checked cut apply as in the other
  modes; the root file and skills, inlined or not, are byte-identical
- SYS-28 checks that the files together hold exactly the inlined root
  file's rules, that copies match, and that the map reads on demand, for
  planted templates and every root, and that two runs agree
- SYS-27 scans the section files for template paths too
- ADR-060 records the mode, outside the frozen surface until a benchmark
  round measures it; FR-06-08 and FR-06-09 state it

Closes #2466.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xQh3AgRFs2tJwMT4g3
@braboj

braboj commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Codex round 1:

# Sev Finding Outcome
1 P2 An EXTEND tag reaches only its own heading, not the whole section it opens Fixing: the relationship covers every topic of the section
2 P2 A three-level override loses the middle alias, so a topic naming the original misses the final rules Fixing: aliases resolve transitively to the surviving replacement

…erride

Two faults in the section files, from the review of #2496:

- An `[EXTEND:]` or `[OVERRIDE:]` reached only the heading whose tags
  named it, though a section runs to the next `[ID:]`. A later heading
  in the same section now carries the section it extends, and that
  section's file carries the later heading
- In a three-level override chain, the middle override's rows are all
  replaced, so the link from the first ID to the last override was lost.
  The relationships are now read before replaced rows are dropped, and
  the last surviving override stands for every ID down the chain, so a
  rule naming or extending the first ID carries it

SYS-28's planted templates gain both cases; each fails without its fix.
The root file and skills, inlined or not, stay byte-identical.

Part of #2466.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xQh3AgRFs2tJwMT4g3
@braboj

braboj commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Round 1 fixes pushed (c5327a9), each with a planted SYS-28 case and a negative control; existing modes and the benchmark chain's section files byte-identical.

@braboj

braboj commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Codex round 2: two P2s, fixing — a reference to an ID that spans headings dropped its rules; relationships attached across a blank line and from overridden rows.

Two more faults in the section files, from the second review of #2496:

- A heading that named its own section's ID dropped the name, though an
  ID can run over several headings. A later heading naming it now
  carries the section's other headings; the visited set stops cycles
- A relationship reached rows it does not govern: the blank line between
  a heading and its new `[ID:]`, and the rows of a replaced subsection.
  Only a surviving rule line now takes one; a replaced section's tags
  still feed the override chain

SYS-28's planted templates gain the three cases; each fails without its
fix. The root file and skills, inlined or not, stay byte-identical.

Part of #2466.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xQh3AgRFs2tJwMT4g3
@braboj

braboj commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Codex round 3: two P2s, fixing — a declined heading drops a relationship its adopted siblings need; an override under an inherited section ID records no edge.

Two more faults in the section files, from the third review of #2496,
both relationship bookkeeping read after rows were filtered out:

- Declining a heading dropped its tags before the relationships were
  read, so an extension that opens at a declined heading no longer
  reached its adopted siblings. The extent of each section is now read
  from every parsed row; only which rules are delivered is filtered. A
  declined override still replaces nothing and relates nothing
- An override was recorded only against an ID its own heading declared,
  so one under an untagged heading inside its title's section was lost
  when a later template overrode that section. It is now recorded
  against the section it sits in, declared or inherited

SYS-28's planted templates gain both cases; each fails without its fix.
The root file and skills, inlined or not, stay byte-identical.

Part of #2466.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xQh3AgRFs2tJwMT4g3
@braboj

braboj commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Round 3 fixes pushed (d53326a). Codex round 4: one P2, fixing — an overridden title-level ID leaves its surviving children without the replacement's governing rules. Sweeping the whole class with one property check.

…relationship

From the fourth review of #2496: where a later template overrides a
title's ID while the title's headings keep IDs of their own, the title's
rules are removed, and the headings' files carried neither them nor
their replacement. A heading under an overridden title is now governed
by the override that replaces it, read from the unfiltered rows.

SYS-28 gains a generic property, a reading of the unfiltered chain apart
from the emitter's: every file carrying a heading must hold what each of
its relationships owes, the rules under its title, each section its
section extends and each ID its prose names, each resolved through the
overrides to what survives. Run against each earlier version of the
mode, it alone reports every omission the four reviews found.

The root file and skills, inlined or not, stay byte-identical.

Part of #2466.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xQh3AgRFs2tJwMT4g3
@braboj

braboj commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Round 4 fix pushed (e1248fa, plus a generic relation check that catches every earlier omission). Codex round 5: one P2, fixing — references by heading name ("see Transport security") are not followed.

From the fifth review of #2496: the templates name another section by
its heading, as the authoring rules ask, but the section files followed
only backticked IDs. Security headers kept "see Transport security" and
lost HSTS's `includeSubDomains` and one-year `max-age`.

- A heading named in the templates' own forms is now carried: its exact
  text in double quotes, after "see", or a link to its anchor, matched
  case and all, so plain prose names none
- It resolves in the naming template first, then anywhere in the chain,
  read from the unfiltered rows and through overrides to what survives
- Every root's references resolve: 8 distinct, 17 across the 39 roots;
  SYS-28 lists any that no chain template has instead of failing

SYS-28's planted templates gain the cases, and its reference reading of
the unfiltered chain follows heading references too; on the 39 roots it
reports 13 omissions without the fix. The root file and skills, inlined
or not, stay byte-identical.

Part of #2466.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xQh3AgRFs2tJwMT4g3
@braboj

braboj commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Round 5 fix pushed (c47f868: heading-name references resolve; 17 in the 39 roots, all resolved). Codex round 6: two P2s, fixing — a quoted heading wrapped across lines is missed; an inherited override ID over-carries unrelated topics.

…wn rules

From the sixth review of #2496:

- A heading named in prose was read line by line, so one quoted across a
  wrapped line was missed. Each paragraph and bullet outside code is now
  read whole. No real root gains a reference: all 39 still resolve the
  same 17
- An override under an untagged heading inherits its title's ID, and
  every heading sharing that ID stood in for the replaced section, those
  before the override included. An override's own rules now replace it
  where they survive; the section it sits in stands in only where that
  section is overridden in turn. No real root's section files change

SYS-28's planted templates gain both cases; each fails without its fix.
Its reference reading joins wrapped lines too, and gains the dual of its
missing-rules check: a file may hold no rule its own topic's
relationships do not reach. Run against the earlier emitters, the dual
reports each rule they carried too far.

The root file and skills, inlined or not, stay byte-identical.

Part of #2466.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xQh3AgRFs2tJwMT4g3
@braboj

braboj commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Codex round 7 (gpt-6-astra, high): no findings.

  • 39 smoke checks, mypy and formatting pass.
  • Ready for the maintainer's approval.

🤖 Generated with Claude Code

Base automatically changed from feat/optional-handoff to main November 19, 2026 11:31
Main added SYS-29, which fails a removed or renamed frozen ID. Both sides
are kept, with no ID shared: SYS-28 (section files) stays, SYS-29 follows
it in the registry, the test index and the smoke module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xQh3AgRFs2tJwMT4g3
@braboj

braboj commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Merged main (#2495, #2499) as ba57635: SYS-28 and SYS-29 kept side by side, no renumbering.

Codex full review after the merge (gpt-6-astra, high): no findings. Smoke 40/40, CI passes. Ready for the maintainer to merge.

🤖 Generated with Claude Code

@braboj
braboj merged commit d6eb434 into main Nov 19, 2026
16 checks passed
@braboj
braboj deleted the feat/section-files branch November 19, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:added Changelog section: Added

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let an agent read one section of a template, not the whole file

1 participant