You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs/knowledge/ mixes two kinds of content. The first kind is harvested from the source
documents. The second kind is written by hand during implementation. Nothing separates them,
and the hand-written content is not durable.
A harvested entry carries a <sub> line with a sha. The sha is a digest of the whole source
file, not of the entry. An edit to the text of an entry therefore does not change the sha.
The next harvest cannot see the edit. The harvest then regenerates the original text, or it
creates a duplicate.
The corpus also has two slots for implementation knowledge, and both are unused. The role review holds 1 entry. The Superseded section is empty across all 39 topic files. The
channel that is actually used is an edit inside a harvested Conflicts entry.
Separately, the query surface cannot support an audit. An audit reads a complete group of
rules and checks the system against them. Today a group can only be one topic, and a
subsystem cannot be selected at all.
Evidence
Source manifest, from docs/knowledge/SOURCES.md. 48 files in three roots:
Root
Files
Entries
Role
docs/product-spec/
22
827
spec
docs/sdk-design-nodejs/
10
169
design
The styleguide repository, an absolute path on the harvest machine
16
478
styleguide
A comparison of each recorded sha256 against the current file gives 44 matches and 4
mismatches. All four mismatches sit in docs/sdk-design-nodejs/:
Each of the four is a file that a phase edited to record an outcome. Phase 6c wrote the PAGE-11 erratum into 07-…md §7.1. The tooling decisions changed 02-…md and 09-…md.
Phase 9 and Phase 10 extended the deviation register.
The specification tree has not drifted. The styleguide tree has not drifted. The design tree
is the live one.
The deviation register is the clearest case. The source is 177 lines and 18,505 bytes, and it
is a numbered ledger that later phases append to. The harvested copy is 39 lines and 6,163
bytes in 13 entries, so it holds about one third of the register. The copy is also stale:
Fails. HTTP is not a canonical ID, and no prefix filter exists.
One topic is not a group. A search of the Rules section for the word "public" returns hits
in eight topics: api-design, http-domain-model, documentation, type-system, module-organization, error-handling, tooling-and-quality-gates, and styleguide-overview. An audit that queries api-design alone reports a clean result over an
incomplete set.
The CLI applies no cap to the output, so a group query is complete once the group is correct.
Proposed change
1. Two trees
docs/knowledge/
harvested/ the topic files, INDEX.md, SOURCES.md <- generated, never edited by hand
notes/ topic files, created only when a note exists <- written by hand
The notes tree mirrors the topic names. Both trees stay under docs/knowledge/, so a query
never leaves that directory.
Section
Tree
Rules, Constraints, Conclusions, Reference
harvested/
Superseded
notes/
Conflicts
The statement stays in harvested/. The resolution moves to notes/.
An entry in notes/ carries the role review, a source path, and a manual sha marker. The
existing pagination.md entry is the precedent. It uses sha:manual-6c-erratum.
A note overrides a harvested rule only when following the rule causes damage. The PAGE-11
entry is the one case in the corpus that meets that bar, and it moves to Superseded.
2. A register is not harvested
A description states an approach, and it changes slowly. Harvest it.
A register accumulates rows over time, and the implementation appends to it. Do not harvest
it. Point to it.
docs/sdk-design-nodejs/10-deliberate-deviations-from-the-reference-contract.md is a
register, and it becomes project documentation outside the corpus. docs/open-items.md is
also a register. The other design chapters stay harvested, because their 169 entries carry
the TypeScript mapping that the lookup skill depends on.
The corpus drops to 38 topic files and 1457 entries. One pointer entry in notes/ names the
path of the register and says to read it at the start of a phase.
3. Audit-scale queries
A group is expressed on the command line. No group definition file is added.
--topic a,b,c --section rules already works, and it becomes the documented audit query.
Add --prefix HTTP. It selects every entry that cites an ID of that family. The CLI already
derives the list of prefixes from appendix C in derivePrefixes().
Add a stable key per entry. Use the first 8 hex characters of a digest of the entry text,
prefixed by the topic, for example api-design/3f2a91c7. The key survives a re-order and a
re-harvest. The key changes when the rule changes, which is correct, because a changed rule
needs a new check.
The audit loop then closes. The audit reads a group, checks the system, and writes a note for
each broken rule. The note names the rule by its key. The next audit reads the notes first and
reports which rules already carry one.
4. Checks
A structural check runs in CI and needs no external file:
No entry under harvested/ carries the role review.
No file under harvested/ holds a Superseded entry.
Every <sub> line under harvested/ cites one of the three source roots.
A drift check compares each sha256 in SOURCES.md against the current source file. It reports
the state. It does not gate, at least at first. The styleguide root is outside the repository,
so those 16 files are absent in CI. The check reports them as "not verifiable", never as a
failure.
Tasks
Create docs/knowledge/harvested/ and docs/knowledge/notes/, and move the 39 topic
files, INDEX.md, and SOURCES.md into harvested/.
Split the 4 resolved Conflicts entries. Keep each statement. Move each resolution to notes/.
Move the single review entry in pagination.md to notes/, in the Superseded
section.
Remove deliberate-deviations.md from the corpus. Add the pointer entry in notes/.
scripts/knowledge.mjs: read both roots, add an origin field per entry, add --origin, add --prefix, and add the stable entry key. Line 19 defines the single
root today, and lines 243 and 248 read it.
scripts/knowledge.test.mjs: add cases for the second tree, --prefix, --origin, and
the stability of the key.
Add the structural check. Wire it into CI.
Add the drift check. Run it by hand at first.
Point the knowledge-harvest skill at docs/knowledge/harvested through its --corpus
argument.
Rewrite .claude/skills/knowledge-lookup/SKILL.md.
Update CLAUDE.md. It states "39 topic files" and a byte count, and both change.
The rewrite of the skill
The phase-start step becomes one query, --origin note, in place of three.
Add one sentence on how to read a result. A role of spec, design, or styleguide states
what the documents say. A role of review states what the implementation found, and it
overrides the first.
Add the audit query as a stated exception. The skill currently forbids a broad topic query,
and that advice is right for a lookup and wrong for an audit.
Record the topic set of each audit group in the skill, so an audit is repeatable.
Remove the frozen counts. Point to --coverage and --list-topics instead.
Shorten the section "Never read a whole topic file". It uses three paragraphs for one rule.
Every query in the skill stays inside docs/knowledge/.
Out of scope
A fan-out query across the phase checklists, docs/open-items.md, and the citations in packages/*/src. The skill queries docs/knowledge/ only.
A gate on the drift check. The first version reports.
A change to how the CLI reads docs/product-spec/appendix-c-consolidated-normative-requirement-index.md. The CLI derives
the allowlist of the requirement IDs from that file at run time, and it cannot run without
it.
Settled
A reference to docs/product-spec/ is normal, and the skill keeps the three references at
lines 50, 63, and 151. The limit to docs/knowledge/ applies to the query surface only. The
rewrite also completes the roll-up path with the mapping from an ID prefix to its owning
specification chapter. The prompt in the comment below carries that mapping.
Problem
docs/knowledge/mixes two kinds of content. The first kind is harvested from the sourcedocuments. The second kind is written by hand during implementation. Nothing separates them,
and the hand-written content is not durable.
A harvested entry carries a
<sub>line with a sha. The sha is a digest of the whole sourcefile, not of the entry. An edit to the text of an entry therefore does not change the sha.
The next harvest cannot see the edit. The harvest then regenerates the original text, or it
creates a duplicate.
The corpus also has two slots for implementation knowledge, and both are unused. The role
reviewholds 1 entry. TheSupersededsection is empty across all 39 topic files. Thechannel that is actually used is an edit inside a harvested
Conflictsentry.Separately, the query surface cannot support an audit. An audit reads a complete group of
rules and checks the system against them. Today a group can only be one topic, and a
subsystem cannot be selected at all.
Evidence
Source manifest, from
docs/knowledge/SOURCES.md. 48 files in three roots:docs/product-spec/specdocs/sdk-design-nodejs/designstyleguideA comparison of each recorded sha256 against the current file gives 44 matches and 4
mismatches. All four mismatches sit in
docs/sdk-design-nodejs/:Each of the four is a file that a phase edited to record an outcome. Phase 6c wrote the
PAGE-11erratum into07-…md§7.1. The tooling decisions changed02-…mdand09-…md.Phase 9 and Phase 10 extended the deviation register.
The specification tree has not drifted. The styleguide tree has not drifted. The design tree
is the live one.
The deviation register is the clearest case. The source is 177 lines and 18,505 bytes, and it
is a numbered ledger that later phases append to. The harvested copy is 39 lines and 6,163
bytes in 13 entries, so it holds about one third of the register. The copy is also stale:
Audit-scale query measurements:
--section rulesover the whole corpus--topic http-domain-model --section rules--topic api-design --section rules--req HTTPHTTPis not a canonical ID, and no prefix filter exists.One topic is not a group. A search of the
Rulessection for the word "public" returns hitsin eight topics:
api-design,http-domain-model,documentation,type-system,module-organization,error-handling,tooling-and-quality-gates, andstyleguide-overview. An audit that queriesapi-designalone reports a clean result over anincomplete set.
The CLI applies no cap to the output, so a group query is complete once the group is correct.
Proposed change
1. Two trees
The notes tree mirrors the topic names. Both trees stay under
docs/knowledge/, so a querynever leaves that directory.
harvested/notes/harvested/. The resolution moves tonotes/.An entry in
notes/carries the rolereview, a source path, and a manual sha marker. Theexisting
pagination.mdentry is the precedent. It usessha:manual-6c-erratum.A note overrides a harvested rule only when following the rule causes damage. The
PAGE-11entry is the one case in the corpus that meets that bar, and it moves to
Superseded.2. A register is not harvested
A description states an approach, and it changes slowly. Harvest it.
A register accumulates rows over time, and the implementation appends to it. Do not harvest
it. Point to it.
docs/sdk-design-nodejs/10-deliberate-deviations-from-the-reference-contract.mdis aregister, and it becomes project documentation outside the corpus.
docs/open-items.mdisalso a register. The other design chapters stay harvested, because their 169 entries carry
the TypeScript mapping that the lookup skill depends on.
The corpus drops to 38 topic files and 1457 entries. One pointer entry in
notes/names thepath of the register and says to read it at the start of a phase.
3. Audit-scale queries
A group is expressed on the command line. No group definition file is added.
--topic a,b,c --section rulesalready works, and it becomes the documented audit query.--prefix HTTP. It selects every entry that cites an ID of that family. The CLI alreadyderives the list of prefixes from appendix C in
derivePrefixes().prefixed by the topic, for example
api-design/3f2a91c7. The key survives a re-order and are-harvest. The key changes when the rule changes, which is correct, because a changed rule
needs a new check.
The audit loop then closes. The audit reads a group, checks the system, and writes a note for
each broken rule. The note names the rule by its key. The next audit reads the notes first and
reports which rules already carry one.
4. Checks
A structural check runs in CI and needs no external file:
harvested/carries the rolereview.harvested/holds aSupersededentry.<sub>line underharvested/cites one of the three source roots.A drift check compares each sha256 in
SOURCES.mdagainst the current source file. It reportsthe state. It does not gate, at least at first. The styleguide root is outside the repository,
so those 16 files are absent in CI. The check reports them as "not verifiable", never as a
failure.
Tasks
docs/knowledge/harvested/anddocs/knowledge/notes/, and move the 39 topicfiles,
INDEX.md, andSOURCES.mdintoharvested/.Conflictsentries. Keep each statement. Move each resolution tonotes/.reviewentry inpagination.mdtonotes/, in theSupersededsection.
deliberate-deviations.mdfrom the corpus. Add the pointer entry innotes/.scripts/knowledge.mjs: read both roots, add anoriginfield per entry, add--origin, add--prefix, and add the stable entry key. Line 19 defines the singleroot today, and lines 243 and 248 read it.
scripts/knowledge.test.mjs: add cases for the second tree,--prefix,--origin, andthe stability of the key.
knowledge-harvestskill atdocs/knowledge/harvestedthrough its--corpusargument.
.claude/skills/knowledge-lookup/SKILL.md.CLAUDE.md. It states "39 topic files" and a byte count, and both change.The rewrite of the skill
--origin note, in place of three.spec,design, orstyleguidestateswhat the documents say. A role of
reviewstates what the implementation found, and itoverrides the first.
and that advice is right for a lookup and wrong for an audit.
--coverageand--list-topicsinstead.docs/knowledge/.Out of scope
docs/open-items.md, and the citations inpackages/*/src. The skill queriesdocs/knowledge/only.docs/product-spec/appendix-c-consolidated-normative-requirement-index.md. The CLI derivesthe allowlist of the requirement IDs from that file at run time, and it cannot run without
it.
Settled
A reference to
docs/product-spec/is normal, and the skill keeps the three references atlines 50, 63, and 151. The limit to
docs/knowledge/applies to the query surface only. Therewrite also completes the roll-up path with the mapping from an ID prefix to its owning
specification chapter. The prompt in the comment below carries that mapping.