feat(engine): per-repo heading alias closes the Non-goals/nb-repo gap
The Non-goals contract is one literal English heading, matched case-insensitively but never translated — a repo whose readers were declared `nb` in `locales` could only go green by planting an English heading inside an otherwise-Norwegian document. Measured on ki-produktivitetsmodell (order, census 09): `## Virkeområde og forbehold` already does the job Non-goals exists for, HEADING-MISSING fired anyway. `heading_aliases` in the register is the same shape `titles` already is for the README H1 — decision in the repo, bookkeeping here — keyed per repo so two nb-repos need not share a Norwegian phrasing. Satisfying a requirement through it is its own OK (HEADING-ALIAS), never folded silently into the aggregate. Also books two operator title decisions verified against the live clones (not the coord messages that reported them): .profile's H1 became "From AI to Chitta — open" (org landing page rebuild, commit 9898a6e), and ki-produktivitetsmodell's H1 "Tre nivå av organisatorisk produktivitet med KI" is deliberate, not drift. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gh6T6iHHkMvgeBbGaLmLQD
This commit is contained in:
parent
e061c1d219
commit
45a2bf30de
5 changed files with 118 additions and 6 deletions
|
|
@ -575,16 +575,32 @@ export function checkRequiredFiles({ present, klass, traits }, register) {
|
|||
// on a predictable heading is what agents pattern-match on, and `## Non-goals`
|
||||
// is the cheapest trust-builder there is: it proves someone thought about the
|
||||
// boundary, and it stops misuse before it starts.
|
||||
export function checkHeadings({ readme, klass, traits }, register) {
|
||||
export function checkHeadings({ readme, klass, traits, name }, register) {
|
||||
const { headings: required } = requirementsFor(klass, traits, register);
|
||||
const text = String(readme ?? '');
|
||||
const present = new Set(
|
||||
text.split('\n').map((l) => l.trim()).filter((l) => l.startsWith('#')),
|
||||
);
|
||||
const aliases = register.heading_aliases?.[name] ?? {};
|
||||
const findings = [];
|
||||
for (const h of required) {
|
||||
if ([...present].some((p) => p.toLowerCase() === h.toLowerCase())) continue;
|
||||
|
||||
// Same job `titles` does for a README H1, one requirement over: the
|
||||
// decision (this repo's readers were declared `nb`, so the contract's
|
||||
// English wording is the wrong test) is taken in the repo, the bookkeeping
|
||||
// happens here. Keyed per repo, not per locale — two nb-repos need not
|
||||
// phrase the same section the same way.
|
||||
const alias = aliases[h];
|
||||
if (alias && [...present].some((p) => p.toLowerCase() === alias.toLowerCase())) {
|
||||
findings.push({
|
||||
level: 'OK',
|
||||
code: 'HEADING-ALIAS',
|
||||
msg: `\`${alias}\` satisfies \`${h}\` — the registered heading alias for \`${name}\``,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// Same title, wrong depth: say that, rather than "missing". The contract
|
||||
// wants a predictable top-level heading because that is what an agent
|
||||
// pattern-matches on — but the section does exist, and the fix is a
|
||||
|
|
@ -1556,7 +1572,7 @@ export function classifyRepo(
|
|||
...checkInstallBlock({ readme, name, klass }, register),
|
||||
...checkInstallTruth({ name, klass, catalogNames }),
|
||||
...checkInstallPins({ readme, forgeTagsByRepo }, register),
|
||||
...checkHeadings({ readme, klass, traits }, register),
|
||||
...checkHeadings({ readme, klass, traits, name }, register),
|
||||
...checkRequiredFiles({ present, klass, traits }, register),
|
||||
...checkLinks({ files }, register),
|
||||
...checkInternalLinks({ files, present }),
|
||||
|
|
|
|||
|
|
@ -770,6 +770,27 @@ test('org-profile requires no headings at all', () => {
|
|||
assert.equal(f.filter((x) => x.level === 'ERROR').length, 0);
|
||||
});
|
||||
|
||||
// The Non-goals contract is written in English and matched literally, which
|
||||
// cannot be satisfied by a repo whose readers were declared `nb` — the fix is
|
||||
// per-repo, not per-locale, because two nb-repos need not phrase the same
|
||||
// section the same way. Same shape as `titles`: the decision is taken in the
|
||||
// repo, the bookkeeping happens in the register.
|
||||
test('a registered heading alias satisfies a required heading for a different-language reader', () => {
|
||||
const aliasRegister = {
|
||||
...REGISTER,
|
||||
heading_aliases: { 'ki-produktivitetsmodell': { '## Non-goals': '## Virkeområde og forbehold' } },
|
||||
};
|
||||
const readme = '# x\n## Virkeområde og forbehold\n';
|
||||
const f = checkHeadings({ readme, klass: 'shared-asset', name: 'ki-produktivitetsmodell' }, aliasRegister);
|
||||
assert.equal(f.some((x) => x.level === 'ERROR'), false);
|
||||
assert.equal(f.some((x) => x.code === 'HEADING-ALIAS'), true);
|
||||
|
||||
// The alias is keyed per-repo: a different repo with the same Norwegian
|
||||
// heading still misses the literal `## Non-goals`.
|
||||
const other = checkHeadings({ readme, klass: 'shared-asset', name: 'some-other-repo' }, aliasRegister);
|
||||
assert.equal(other.some((x) => x.code === 'HEADING-MISSING'), true);
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------- file: URL links
|
||||
|
||||
// A `file:///Users/ktg/...` link is dead for every reader but its author, and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue