1Introduction
Producing a document goes through successive layers of defence. Prevention: the stylesheets make certain errors impossible to write. Detection: validators examine the file produced before it is delivered. Audit: a periodic check of what prevention and detection do not see.
None of these layers is enough on its own. An error that a stylesheet cannot prevent must be caught downstream; an error that no tool can detect remains a matter for an audit.
This document is the single reference for all questions of audit, validation and quality. Every “Audit” or “Quality Control” reference in the Kit’s other documents points to this source.
1.1The layers of defence
Every generated document or file potentially goes through the following levels of control, from upstream to downstream:
–Layer 1 — Runtime prevention: checks built into the stylesheet functions. They block errors before the document is even produced. Examples: makeImageRun refuses an invalid format, makeHeader refuses an empty parameter.
–Layer 2 — Session detection: external scripts called around each generation. Checks sit upstream and downstream. Upstream, before execution, kit_check_registry.py checks the Registry and kit_check_setters.py inspects the generator’s source. Downstream, the validators inspect the file produced before delivery — kit_validate_docx.js and kit_validate_xlsx.py —, and kit_check_fidelite.py rebuilds the .docx through the chain to compare it byte for byte. The environment prerequisites are added to these, each checked before the step that uses it — Execution environment §5.
–Layer 3 — Periodic audit: cross-cutting reviews done in a dedicated session. They detect gradual drift. Examples: JSDoc and Reference audit, version alignment audit, L10N coverage audit, maintenance audit.
1.2Principle — fail loud early
An error detected late costs proportionally more. A silent error is never corrected. Whenever a validation can be moved earlier in the pipeline (runtime rather than session-only, session-only rather than periodic audit), it must be.
2Layer 1 — Runtime checks in the stylesheets
Runtime checks live in the exported functions of the stylesheets. They throw an explicit JavaScript exception on an incorrect call — the generator fails immediately with a message identifying the offending line.
2.1documentProps — mandatory fingerprint
Carries the StylesheetVersion and GeneratedAt properties. documentProps(TS, feuilles) adds GlossaryVersion and YamlVersion when the document uses the renderings of those stylesheets: the publication gate compares them with the floor of each stylesheet — HTML Pipeline §7.4. They are passed to the Document constructor, which writes them itself: Packer then produces the complete archive in a single pass. injectCustomProps checks that the document carries them and stops the generation otherwise.
const doc = new Document({
...style.documentProps(TS),
sections: [...],
});
Packer.toBuffer(doc).then(buf => {
fs.writeFileSync(OUTFILE, style.injectCustomProps(buf, TS));
});A document without these properties is refused at publication — HTML Pipeline §7.4. They go through the constructor because injecting them afterwards reopens the archive produced by Packer and disturbs the order of its entries: the document stays valid and opens, but it is served as a generic archive and renamed to .zip on download — check 19, §3.1.
2.2makeImageRun — dimension and format validation
Enforces the type parameter of ImageRun and validates width/height > 0, format ∈ {png, jpg, gif, bmp, svg}. Throws an explicit error instead of silently producing a corrupt file (.docx). An SVG requires a fallback image, fifth parameter.
makeLinkedImageRun(fichier, alt) likewise checks, at the call, the target of a linked image — assets/png/{slug}/ folder, name, extension matching the content, presence of the file —, and is placed only through picture, which sizes it to the level — General Reference §13.5.
2.3makeHeader — parameter validation
makeHeader(title, subtitle) throws an explicit error if title or subtitle is empty, undefined or not a string. In line with the fail loud early principle — every generator must pass both. See General Reference §10.8.
2.4Level discipline — the level comes from the heading
The section level does not live in the function names. h1, h2 and h3 set a current level at module scope, and every other family reads it: writing paragraph(‘text’) under an h2 produces a level 2 paragraph without the generator having to know. A mismatch between a paragraph and its parent heading is inexpressible. Sole exception, lists: an item may step down below its heading, one level at a time and to level 3 — General Reference §4.5, check 22.
Level checking happens downstream: check 11 of kit_validate_docx.js reads the actual indentation of every paragraph in the document produced, without presuming anything about how the generator is written. It is blocking, and it is the sole authority on the matter.
2.5Embedded decision rules
Documented in the Reference of each stylesheet, not enforceable at runtime but clearly explicit:
–Spread mandatory on functions returning an Array: General Reference §13.
–Transitions between Table functions: releaseParagraph() is mandatory between two adjacent Table blocks — General Reference §13.4.
–Numbering: starts at §1, never §0 — General Reference §1.2.
–prompt: reserved for copy-and-paste dialogue. For any code, yamlStyle.rawBlock or codeBlock — General Reference §8.
3Layer 2 — Stable Kit artifacts and session prerequisites
Stable scripts that live in the kit/ folder; a project that needs them uses them from ../kit/, without a copy. The kit_ prefix signals their origin — Unix snake_case naming, a formal exception to the pattern in Naming Convention §2, named in Naming Convention §3.3. The roles: validators (return 0 if all is well, non-zero otherwise, and block delivery on failure), renderers (produce a deterministic artifact — the same input and the same Registry context give the same output), helpers (build reusable fragments without producing a deliverable on their own) and shared modules (carry logic that other scripts require, without being run alone: kit_publication.js, kit_typographie.js).
Stable artifacts have stable logic, reused session after session: they are not regenerated at every session, only when their logic evolves, and their evolution is recorded in a dated changelog at the top of the file itself — Naming Convention §6. Ad hoc document generators (gen-*.js), on the other hand, are written at every session — Kit Prompt §4.1. gen-kit-site.js and gen-glossary-reference.js are stable artifacts despite their prefix — §3.20 and §3.21, Naming Convention §3.5 —, and a project's site generator, gen-[prefix]-site.js, is a durable project file — Common Structure §11.
Rules in it apply to the whole chain: §3.13 sets the mandatory calling order, §3.14 details the module test of the environment check, whose home is Execution environment §5.
3.1kit_validate_docx.js — validator for docx produced by the Kit
Checks the docx produced by the Kit’s Node.js stylesheets. A retained Kit artifact — a standalone Node.js script with no external npm dependency (it uses the standard library’s zlib to read the docx ZIP, plus a small standard-library XML parser for the structural OOXML checks). This section is the single source of truth for its contract: other documents refer to it without restating it.
–Fingerprint check: custom.xml present with StylesheetVersion and GeneratedAt.
–Version check: the stamped StylesheetVersion matches the version passed with --version. Absent or lower: reported. The conditions under which publication refuses a document are those of HTML Pipeline §7.4.
–Glossary and YAML floor check: a document carrying GlossaryVersion or YamlVersion below the stylesheet's minDocumentVersion floor is reported, as the publication gate would refuse it. The floor is read from Kit - Registry.js, looked for first in the validator's folder, its ../kit/ and its kit/, then beside the document, in its parent folder, and in ../kit/ and kit/ of those two folders, never in the current folder; found but unreadable or without a stylesheets block, it is reported as such. --glossary and --yaml set the floor and take precedence. A document carrying GlossaryVersion or YamlVersion with no known floor exits with 2: nothing was checked on that point — §6.
–Paragraphs-in-tables check: if tables are present, the count of inner paragraphs must be greater than zero. Zero with tables present signals a guaranteed loss — the doc.paragraphs trap, HTML Pipeline §7.1.
–Non-empty body check: a document with 0 paragraphs AND 0 tables while the custom properties are present almost always indicates a silent docx-js corruption — the <rootKey>w:p</rootKey> pattern. Established cause: two distinct instances of the docx module in the same chain. Check 13 is the post-generation safety net; the cause and its prevention are in §3.14.
–word/media/ extensions check: every extension present in word/media/ must be declared as a Default Extension in [Content_Types].xml. An orphaned extension — typically.undefined, produced by an ImageRun without the type parameter — makes the file unreadable by Word with no explicit error message. See General Reference §13.3.
–Check 7 — wrapped footer: a footer*.xml carrying an <options/> tag or several <w:ftr> signals a Footer wrapped in new Footer({ children: [...] }) instead of style.makeFooter(...) set directly. Word refuses to open the file; LibreOffice and python-docx accept it without a word — §6, General Reference §10.5.
–Canonical <w:rPr>/<w:pPr> order check: direct children checked against the OOXML order §17.3.1 and §17.3.2. Detects the docx@8.5.0 bug where rFonts is serialised last instead of in 2nd position. Word 365 applies the XSD schema strictly; LibreOffice tolerates it.
–Non-empty table containers check: <w:tr> with no direct <w:tc>, or <w:tbl> with no direct <w:tr>. Word 365 refuses to open; LibreOffice tolerates it silently.
–<w:r> child namespaces check: restricted allow-list (w:, mc:, w14:, w15:, w16se:, w16cid:, w16:). Catches silent docx library bugs such as <type>tab</type>, serialised by docx@8.5.0 on new TextRun({ children: [{ type: 'tab' }] }).
–Heading level and indentation consistency check: for every top-level paragraph of the body, the attribute <w:ind w:left="X"/> must be in the valid set for the level of the most recent Heading. Model taken from the General stylesheet helpers: L1 = {567, 967, 1157}, L2 = {1350, 1750, 1940}, L3 = {2100, 2500, 2690}. A glossary document, recognised by its name — Glossaire - Termes, Glossar - Begriffe, Glossary - Terms, Stylesheet - Glossary - Reference —, additionally accepts 1350 and 1550 under a level 1 heading: the term name and the definition of the Glossary stylesheet. Elsewhere those values remain an anomaly.
–Check 12 — non-breaking blocks: two parts, as non-blocking warnings. Amounts: a number grouped in threes, by spaces or by points, or a plain number, followed by a known currency or typographic unit (€ $ £ ¥ % m² m³ km kg ha ares hectares °C), with an ordinary space (U+0020) instead of a non-breaking one (U+00A0). Dates: an ISO date YYYY-MM-DD written with ordinary hyphens instead of non-breaking hyphens (<w:noBreakHyphen/>). The fixed-width font — prompt, code — is examined in neither part: it stays verbatim. The timestamp of a file name, in parentheses followed by an extension, is not reported: General leaves it in ordinary characters so that it copies as written. General protects both automatically, cells included — General Reference §10.6.
–Check 14 — Strict global XML: for every .xml or .rels entry in the zip, checks that there are no tags with an invalid name (e.g. a stray <0/> injected by forgetting the spread on makeTable) and pairs each opening with its closing on a stack, using the small tokenizeTags parser. It also refuses an entity that XML does not define — a bare &, — and an undeclared element or attribute prefix.
–Check 15 — Heading numbering monotony: extracts the sequence of Heading1/2/3 with their Kit number and checks that each counter advances by +1 within its parent and starts at.1. Catches the h2(level, text) bug instead of h2(number, text), which produces a valid file with broken numbering.
–Check 16 — Orphaned X.1: anti-pattern documented in Kit Prompt §4.1 and General Reference §1.2 — a parent with a single subheading is suspect; its content must move up under the parent. Grouped by parent, solo cases flagged.
–Check 17 — Isolated note or tip after a heading: anti-pattern documented in General §1.2 — never a tip or note after a heading without a parent paragraph. Detected by the width of the first column of the <w:tbl> immediately following a top-level heading: TIP_BULB_COL_WIDTH for a tip, and for a note membership of NOTE_LABEL_COL_WIDTHS, since the label width varies with the language.
–Check 18 — Title page: consistency between the <w:titlePg/> flag of the sectPr and the header or footer references of type first. Without the flag, Word ignores those references and applies the default header and footer from page 1 — the title page loses its bareness. Root cause: style.pageProps does not carry the flag; the documented pattern is properties: {...style.pageProps, titlePage: true } — General Reference §10.4. Symmetrical check: the flag without a first reference is also reported.
–Check 19 — Format identification: first entry of the archive. Packer puts the word/ folder first; any rewrite by a library that does not preserve the order pushes it behind the metadata, and the document is then served as a generic archive — renamed to .zip on download. The document remains valid and opens without warning: this check is the only point in the chain that sees the defect before the recipient does.
–Check 20 — Markup inside an identifier: a marked run — small caps of a brand, italics of a term or a fragment — stuck to / or \, or to a dot, a hyphen or an underscore followed by a letter. It has then fallen inside a slug, a file name or a path: the text stays whole on screen, but the word is cut in the markup. General prevents it, this check verifies it. A hyphen followed by a capital remains a word boundary — a German compound is not reported.
–Check 21 — Linked images: every external image relationship targets ../assets/png/{slug}/{slug}-{section}-{n}.jpg or .png, and the file exists, looked up from the .docx folder. The report counts embedded and linked images separately — General Reference §13.5.
–Check 22 — Cascading lists: a list opens at the level of its heading and steps down one level at a time, to level 3; a sub-list holds at least two items. Check 11 accepts the indentation of an item deeper than its heading — General Reference §4.5.
Usage: node kit_validate_docx.js 'Mon Document (TS).docx' for a simple validation, or node kit_validate_docx.js 'Mon Document (TS).docx' --version {version active} to check the fingerprint as well; --glossary and --yaml set a floor for the specific stylesheets. Exit code 0 = valid, 1 = anomaly, 2 = floor not checked. An option given without a value stops the tool; the --json report carries valid: false on an exit 2.
3.2kit_validate_xlsx.py — xlsx validator
Checks the xlsx produced by the pipelines that create them. The checks below make up its complete contract.
–Checks: zip structure, formatCode balance, cell references, sheet references in formulas, openpyxl double read. Without openpyxl, check 5 is an error, not a warning: a check that does not run does not read as a success.
–Usage: python kit_validate_xlsx.py document.xlsx [--strict].
–Retained artifact: lives in the kit/ folder; a project that produces xlsx uses it from ../kit/, without a copy. Not regenerated at every session.
3.3kit_render_cover_sheet.py — cover sheet renderer
A deterministic renderer that produces the A4 300 dpi PNG of the Cover Sheet, Kit or consumer project, one per rendered language, over one or more pages. Its sources are those named by the Source column of Cover Sheet §3: the table of its §2 and, from its §3, the banner fallback, read from the .docx by pandoc AST parsing; [Prefix] - Document Titles for the banner, the divider titles and the document names; the project language, from the Registry; the internal localisation table for the subtitle and the quote. No Kit-specific value is hard-coded in the renderer — in line with the contract documented in Cover Sheet §3.
CLI: optional, combinable arguments. Without arguments, the renderer renders the Cover Sheet of the project whose Registry is the only one in the current folder, resolved through Registry.documents['cover-sheet'].ts.
–--cover-sheet PATH: Cover Sheet file (.docx) to render. If absent, it is resolved through Registry.documents['cover-sheet'].ts, under the prefix of the Registry named, beside it or in its docx/ folder.
–--registry PATH: project Registry — default: the only [Prefix] - Registry.js in the current folder; if there are several or none, the renderer stops and asks for it to be named. Source of project.docLanguage.
–--output PATH: output PNG. If absent, derived from the source file (.docx) and placed at the project root, outside docx/.
–--language XX: rendered language (FR | EN | DE | LU); default project.docLanguage. It selects the subtitle and the quote from the renderer's localisation table, and the labels from Document Titles.
–[TS], positional: timestamp YYYY-MM-DD - HHhMM of the derived PNG; it renames only the image whose path --output did not give. Default: that of the source .docx — linked-files rule, below.
–Localised numbered-section markers: FR='numérot', EN='numbered', DE='nummeriert', LU='nummeréiert'. Aligned with the semantics of the FR marker (a root longer than the short form of the label) — avoids the false positive where the substring 'number' matched 'no number' in the Tab cells of the reserved rows of an English project Cover Sheet. All four markers are accepted, that of the rendered language first: the Tab column is written in the project language and read whatever language is requested.
–Obsolete keys: a Registry that still carries rendering.coverSheet, or a §3 that still carries the TAB_NUMBERED_MAX line, stops the rendering, naming what to remove — Update Guide §4.4. A section's height always follows its content.
Called on every change to the sources of a Cover Sheet — Prompt §14. A standalone Python script — dependencies Pillow, zoneinfo and pandoc, plus Node, which reads the Registry and Document Titles. Linked-files rule: each PNG produced carries the same TS as the source Cover Sheet file (.docx). Before writing, it checks the space: a section too tall for a whole page or a line too long stops it, naming the fault, with no file written.
3.4kit_check_setters.py — setter discipline linter
Static linter of the generator, in upstream Layer 2 alongside kit_check_registry.py — §3.13. Checks that a generator script calls every mandatory setter, according to the Registry.requires flags. Primary target: the HTML generators gen-[prefix]-site.js — omitting setGlossaryTerms silently produces a site without glossary hotlinks. A call written in a comment does not count; the execution order, for its part, cannot be read from the text.
–Rule: each flag set to true in Registry.requires requires a call to the matching setter (glossary calls setGlossaryTerms, documentTitles setDocumentTitles, brands setBrands, variableNames setVariableNames, hassEntities setHassEntities, textHighlights setTextHighlights, colors setColors, plus glossStyle.setColors or yamlStyle.setColors when the generator uses the Glossary or YAML stylesheet). Added to these: setLanguage, always, then depending on the target: setDocumentAuthor and setDocumentSiteBase for a .docx generator; setWebAuthor, setFamilyDomains, setLanguageSelector, setSiteInfrastructure, and setGlossaryHref when the project publishes several glossaries, for an HTML generator. These setters are required on the receiver of the main stylesheet, recognised by its own setters whatever its name — setDocumentAuthor for the General stylesheet; setWebAuthor, setFamilyDomains, setLanguageSelector, setSiteInfrastructure or setGlossaryHref for the HTML stylesheet: a setColors set on yamlStyle alone does not cover the main stylesheet. It also refuses a generator that requires docx itself: docx comes from the stylesheet, style.docx — §3.14.2. A project under documentTitles also calls setKitDocumentTitles — General Reference §16; the Kit’s Registry is exempt.
–Usage: python kit_check_setters.py gen-document.js [--registry path] [--html] [--strict]. The --html flag applies the requirements of an HTML generator. The --strict flag is still accepted; setLanguage is always required.
–Exit codes: 0 = all required setters called; 1 = violations; 2 = Registry.js not found, or file outside the linter — nothing was checked.
–Paired with: HTML Pipeline §7.9, which gives the call pattern and the effect of each missing setter; the required list is that of the rule above, which the linter applies. With --html, it also requires the generator to require kit_publication.js and call verifierDepart(), controlerDocuments(), demarrer(), copierIcones(), copierPieces(), controlerAncres(), controlerCiblesDeLiens(), controlerLiensDuSite(), preparerConversion(), imageDeMarqueur(), copierImagesLiees(), etatDuSite() and terminer(), and renderAboutPage() of the HTML stylesheet, and, under several glossaries, setGlossaryHref() and buildSearchTerms() — §3.19.
–Retained artifact: lives in the kit/ folder; a project that produces an HTML site uses it from ../kit/, without a copy. Not regenerated at every session.
–Outside the linter: kit_gen_glossaire_html.js — a helper called within the site generator’s process, which sets the setters before calling it. Run on it, the linter exits with 2.
3.5kit_gen_glossaire_html.js — HTML glossary generator helper
A stable Kit helper that generates the site's glossary page — glossaire.html, or glossaire-{language}.html per published language — from [Prefix] - Glossary - Terms.js. It bypasses the pandoc AST pipeline entirely — the proprietary structure of the glossary file (.docx) (sectionBanner, letterHeader, inline aliases) cannot be read by the AST converter. Full normative contract in HTML Reference §14.8 and §15.
–Absolute rule: the HTML glossary is ALWAYS generated by this helper, NEVER reimplemented in gen-kit-site.js or in the gen-[prefix]-site.js of consumer projects. Strict centralisation to avoid silent divergence.
–Usage: const { generateGlossaireHtml } = require('../kit/kit_gen_glossaire_html.js'); generateGlossaireHtml({ termsPath, outputPath, htmlStyle, config }).
–Retained artifact: lives in the kit/ folder; a consumer project that publishes a glossary uses it from ../kit/, without a copy.
–Dependencies: no external npm. Reads Terms.js via require, uses the .gloss-* classes of the HTML stylesheet, and the title and breadcrumb localised through htmlStyle.getStrings().glossaryTitle.
3.6kit_patch_helpers.py — Python helpers for surgical patches to .docx
A Python helper that builds the XML fragment of a note or a tip box during a surgical change to an existing file (.docx). The fragment is rendered by the active General stylesheet, never copied from constants: the tool has it compose a minimal document — a heading of the requested level, a marker, the block, a second marker — and extracts the XML between the two markers. It is therefore exactly what a regeneration would produce.
–Absolute rule: to insert a note or a tip box into an existing file (.docx) by surgical patch (Dialogue Commands §2.4), the helpers of this module must be used — never clone a fragment of the target document by hand. A table is regenerated with its document: no helper covers it.
–Current API: build_note_block(content, level=1, lang='FR', rid_prefixe=None) returns the XML fragment <w:tbl>...</w:tbl> of a Kit note at level 1, 2 or 3, in the requested language. A note carrying a link — reference or address — requires rid_prefixe: the tool then returns the fragment and the list of relationships (rid, target), which the caller declares in external mode in word/_rels/document.xml.rels. build_tip_block(content, level=1, lang='FR', rid='rIdKitAmpoule', docpr_id=9001) returns the fragment of a tip box and the PNG bytes of the bulb. The fragment designates the image through the relationship rid; the caller adds, in the same move, the image under word/media/, the relationship rid in word/_rels/document.xml.rels and the png extension in [Content_Types].xml if it is missing. rid and docpr_id must be free in the target document.
–Rendered by the stylesheet: no copied constant: a copy of the stylesheet's values would drift from them, and its notes would no longer look like those of a regeneration. The fragment goes through the setters of a regeneration, under the flags of the project's Registry — REGISTRY_MODULE, or the only Registry of the current folder: glossary of the language, highlights, brands, document titles, author and reference root.
–Dependencies: Node, and the docx module taken from the stylesheet, style.docx — §3.14. The General stylesheet sits next to the tool or is named by the GENERAL_MODULE variable. No regex when writing a structured file.
–Retained artifact: lives in the kit/ folder; a project that needs it uses it from ../kit/, without a copy.
3.7kit_check_markup.py — markup and constants agreement check
Checks that no other Kit tool performs. A text diff does not see a loss of colour: a regenerated document can carry exactly the same words, in the same order, and have lost the markup of several terms or several brands.
–Markup check: counts the runs carrying each kind of markup — glossary, brands, variable names, entities, bold, hyperlinks, images — in the source file and in the document produced, then compares. Any loss is reported. The --strict mode also reports gains, for a regeneration that must not change the content; --added N declares the number of expected bold labels. The colours counted are read from the active General stylesheet, with the project colours when its Registry sets requires.colors: hard-coded, they counted zero on both sides for a project that replaces them, and the check stayed silent.
–Note label width check: the value lives in two copies — the localizedStrings table of General, NOTE_LABEL_COL_WIDTHS of the validator. The duplication is deliberate, as the validator cannot import the stylesheet. The check reads both sources at run time and verifies that they agree. kit_patch_helpers.py carries no copy: it has its fragments rendered by the stylesheet.
–Typography check: verifies that no stylesheet, nor the HTML glossary generator, keeps its own copy of the typographic correction, and that all of them require kit_typographie.js — the single source, General Reference §10.6. It also checks that the General and Glossary stylesheets build their runs with classeTextRunProtegee, without a copy of the non-breaking block protection.
–Change of the rule: a rendering change in kit_typographie.js counts as a change of each stylesheet that requires it — General, HTML, Glossary —, and each goes up one minor version. A document's fingerprint thus says which rule produced it.
–Usage: python kit_check_markup.py SOURCE.docx PRODUIT.docx [--strict] [--added N], python kit_check_markup.py --widths [--dir DOSSIER], or python kit_check_markup.py --typo [--dir DOSSIER]. Exit 0 if they agree, 1 on a discrepancy, 2 on a usage error.
–Retained artifact: lives in the kit/ folder; any project that regenerates existing documents uses it from ../kit/, without a copy.
3.8kit_check_ossature.py — skeleton check between language variants
Compares the skeleton of a translation with that of its source. §17 of the Prompt asks for a translation faithful to the meaning, in a text that reads as if it had been written in its own language: counting words or comparing sentence by sentence would penalise exactly what the rule asks for.
–What is measured: the sequence of blocks, their type and level, the section numbering, the dimensions of each table, the number of items in each list.
–What is not: the number of words, the length of sentences, sentence-by-sentence correspondence. German compounds, English shortens, and a translation that copied the length of the French would be a bad one.
–What is reported: a section, an item, a table row or a box present on one side and missing on the other. That is information lost or added, which Kit Prompt §17 forbids.
–Tolerance: the translation note in §1, which the reference variant does not carry, is recognised and accepted. The --sans-tolerance option refuses it.
–Usage: python kit_check_ossature.py REFERENCE.docx VARIANTE.docx [AUTRES...]. Exit 0 if the skeletons match, 1 otherwise, 2 if nothing was compared — a glossary is outside the skeleton check, and an exit 0 would make it pass for conformant.
3.9kit_extract_map.py — structure map of an existing document
Every regeneration starts from a map extracted from the source file. The tool reads the document’s XML and returns its structure: block order, type, level, content, markup. It is read-only and uses no regular expressions.
–Why it is stable while generators are not: Prompt §4.1 requires every document generator to be written from scratch, because it belongs to one document. Extraction does not share that property: it always does the same thing, and rewriting it at every working stretch only produces variants of the same code, each with its own blind spots.
–What it recognises: headings, tight ones included, paragraphs and their variants by indentation, list items and continuations, note, tip and prompt boxes, raw and coloured code blocks, ordinary tables, metaTable of the YAML stylesheet and the tight paragraph before it, termName, definition, letterHeader and sectionBanner of the Glossary stylesheet, images, hyperlinks, bridge and release paragraphs. An image, standing alone or in a cell, is stored as a file in the <map>-images folder and put back at regeneration; a linked image is recorded by its path and its alternative text, the photo staying under the project’s assets/png/, and regeneration links it again; the bulb of a tip box is not captured, the stylesheet redraws it. A table records whether its first row is a header, and is rebuilt without one otherwise; a single-column table is an ordinary table. The link of a cell is captured with its anchor and its target, resolved through the document relationships, and put back by hyperlinkCell. A cell is recorded as italic when all its runs are, spaces included: two glossary terms separated by an upright space do not make it an italic cell.
–What it cannot promise: its repertoire is finite. A construction that is not in it is degraded without anything in the produced file saying so. That is the reason for §3.10.
–Usage: python kit_extract_map.py SOURCE.docx CIBLE.json.
3.10kit_check_fidelite.py — extraction fidelity check
Extracts, regenerates, and compares the body XML byte for byte. A document that does not come back identical signals a construction that extraction cannot render. Such defects are silent and invisible to a text diff.
–The neutralisations without which the test measures something else: the timestamp and the hyperlink relationship identifiers change at every generation without the rendering moving. The language comes from the file name suffix — regenerating a German document with the French glossary surfaces produces a discrepancy that says nothing about extraction. And the replayed chain must be the production one, neutralisation of the pipeline’s marks included. The product is named CONTROLE FIDELITE: the tool passes the source document’s name with --nom, and the regeneration reads Document Titles under that name — §3.16.
–What it does not promise: on the document set, it only sees the constructions present. A helper never used is not tested there: the round trip of the document that uses it, at its delivery, reveals it. The check reduces the error surface without closing it: what is held to be safe is so in the light of what is known today, and that is the ordinary condition of any quality control. The day an unforeseen case arises, extraction is completed and the document set is checked again.
–Scope: a document produced by a General version earlier than the one requested differs legitimately: the tool reports it separately, as out of version, rather than counting it as a failure. A document whose GlossaryVersion or YamlVersion is below its stylesheet's floor counts, on the other hand, as a failure, as the publication gate would refuse it.
–When it is called: after generating a .docx to be delivered, on that document: the fingerprint attests the declared stylesheet, not the chain that built the document — a document assembled elsewhere carries it just as well —, and only what the chain knows how to build comes back identical. After a change to extraction and before a regeneration campaign, on the whole document set — §3.13.
–Usage: python kit_check_fidelite.py SOURCE.docx [...] --version {version active}. Exit 0 if everything comes back identical, 1 otherwise, 2 if no document was checked. It is run from the project folder: its Registry gives the prefix and the data modules of the regeneration; the floors are read from the Kit’s Registry. A document that links its photos is regenerated with them: the temporary folder carries a link to the assets/ of the .docx project.
–An unchanged document keeps its timestamp. A fresh timestamp is required at every DELIVERY — Kit Prompt §4.1 — not at every generator run. A regeneration campaign compares the body produced with that of the source, using the same neutralisation as here; if identical, it discards the product and keeps the source. Without this comparison, the publication delta treats the whole document set as modified, the local inventory is rewritten in full, and the site’s history loses its meaning: the whole document set there carries the same minute.
–The glossary is outside the check. It is not regenerated by extraction — §3.11 — and the round trip tested here therefore makes no sense for it. It is counted separately in the summary, never as a discrepancy. Its names are those of nomBase in Terms.js — Glossaire - Termes, Glossar - Begriffe, Glossary - Terms —, the same in every Kit tool. The Reference of the glossary stylesheet returns to the check: extraction recognises the letter and the banner, and gen-glossary-reference.js rebuilds it.
–Templates outside the Kit are outside the round trip. The Kit does not answer for their rendering, and extraction does not rebuild them — Extending the Kit §9. A document produced by a project stylesheet, on the other hand, stays under the check: as long as the Kit’s extraction does not recognise its blocks, it comes back with a discrepancy and is not delivered — Extending the Kit §7.
3.11kit_gen_glossaire_docx.js — .docx glossary generator helper
Produces the glossary file (.docx) from [Prefix] - Glossary - Terms.js. The counterpart of kit_gen_glossaire_html.js — §3.5: one source, two renderings.
–The .docx glossary is never regenerated by extraction. It is the only Kit document whose content lives in a module. Regenerated from its map read in the source file, it freezes: a term added to Terms.js stays absent from it.
–It calls the pipeline setters. Without them, glossary terms, brands and references stay plain text in the framing texts — opening, introduction, section notes. The definitions, rendered by definition() of the Glossary stylesheet, do not go through the pipeline: they stay verbatim, apart from the typographic correction.
–One folder, one project. The single Registry of the working folder gives the prefix under which the terms module and the pipeline modules are looked for; the stylesheets are looked for in that folder, then next to the tool, at the version the Registry declares. The project colours apply under requires.colors, to the entries as to the rest: the Glossary stylesheet receives style.getColors(). KIT_TS sets the output timestamp: a delivery that regenerates several documents gives them all the same one.
–Outside the skeleton check. Terms are sorted in the rendered language, so the groupings by letter differ from one variant to another. kit_check_ossature.py excludes it explicitly — §3.8.
–The two renderings do not have the same structure. Paper follows the sections declared in glossaryRubriques; the web is a single alphabetical index — §3.5. A binder is leafed through and gains entry points; a web page is searched by keyword and needs none. The content is the same: a single source, Terms.js.
3.12kit_check_couplets.py — shared timestamp of file sets
Checks that every present member of a file set carries the same timestamp — Kit Prompt §6.3. A missing member is reported without failing: a project does not necessarily have every stylesheet. The cover rendering and the glossary are also checked language by language: a PNG or a variant missing for a published language — project.siteLanguages in the Registry — makes the check fail. A folder in which no file set is found stops the tool with code 2: the check saw nothing there, and a success would hide it. The Cover Sheet category is read in each language of the Kit — Documentation, Dokumentation, Dokumentatioun —, Naming Convention §5.
It also reads the version exported by each Code.js and compares it with the Registry's: a file set agreeing on its timestamp may still carry two different versions. A stylesheet that does not export STYLESHEET_VERSION is reported as unchecked rather than taken as agreeing.
–The only check of this rule. The validator reads a document in isolation, the fidelity check compares a round trip, the fingerprint gate looks at versions. None of them sees two files side by side. Without it, a broken file set only shows when reading a list of files.
–What it does not check. That the content of the members agrees. A .js and its Reference can carry the same minute and contradict each other — that is the job of reading.
–Grouping is by prefix AND by role. A directory where several projects coexist holds two distinct Glossary file sets, which have no reason to share a minute. Grouping by role alone would declare them broken by each other.
–A file set does not always have two members. The Cover Sheet’s linked files bring together a specification file (.docx) and, per language, a rendering (.png) over one or more pages, numbered without a gap — Cover Sheet §4. The glossary’s file set, the module and one variant per language.
3.13Absolute calling rule
No file is delivered without validation. A non-negotiable rule. The links are run from the project folder, the tools taken from ../kit/; for the Kit itself, from its own folder, with no path. The complete chain has the following links, in this order:
–Environment prerequisites: the check of Execution environment §5, each capability before the step that uses it, from the Kit folder; the module test is in §3.14. Without it, the generator fails or produces an empty document.
–Before any generation: python ../kit/kit_check_registry.py. A Registry outside the perimeter produces correct documents, but no migration of the Update Guide knows its unspecified keys: their place is Settings.js — Common Structure §5.4.
–Before .js generation: python ../kit/kit_check_setters.py gen-document.js; for the site generator, python ../kit/kit_check_setters.py gen-[prefix]-site.js --html.
–After docx generation: node ../kit/kit_validate_docx.js document.docx --version {version active}. The Glossary and YAML floors are read from the Kit Registry — §3.1.
–After docx generation, the round trip: python ../kit/kit_check_fidelite.py document.docx --version {version active}. The validator reads the fingerprint, which does not say which chain built the document; the round trip does — §3.10. The glossary is excluded from it, as is a document made on a template outside the Kit — §3.10. The tool is run from the project folder.
–After xlsx generation: python ../kit/kit_validate_xlsx.py document.xlsx.
–After regenerating an existing document: python ../kit/kit_check_markup.py source.docx produit.docx. A text diff does not see a loss of markup; this check is the only net for it.
–After regenerating a language variant: python ../kit/kit_check_ossature.py reference.docx variante.docx. Checks that no section or item has been lost or added.
–After a change to extraction: python kit_check_fidelite.py on the document set, with the active version. On the document set, it is not run at every delivery but every time the extraction tool changes, and before any regeneration campaign.
–kit_check_couplets.py. Before any delivery touching a member of a file set. A broken file set leaves the reader not knowing which member is authoritative.
No final output file is produced until the whole chain has passed. A non-zero exit at any link interrupts delivery — full stop, no workaround.
3.14Environment prerequisites — session sanity checks
The session environment starts from scratch at every opening. The docx npm module, the engine that builds the document, conditions the whole chain. adm-zip serves the site publication alone, through kit_publication.js, which assembles and compares the archives. Neither ships in the archive: the Kit's package.json declares them under the caret rule, package-lock.json pins the exact versions, and they are always installed fresh in kit/ with npm install — Common Structure §11.
The environment check has its home in Execution environment §5, which says which capability is checked before which step. The tests below detail the criterion for the npm modules.
3.14.1Sanity test
On a healthy environment, the docx module typically exposes between 270 and 310 keys depending on the minor version. A zero value indicates a known degraded state. adm-zip either resolves or it does not — there is no intermediate state.
# Depuis le dossier du Kit — Environnement d’exécution §5
node -e "console.log(Object.keys(require('docx')).length)"
# Sortie attendue sur environnement sain : nombre > 200
# Sortie pathologique : 0 (require résolu sur un module sans exports CJS)
node -e "require('adm-zip'); console.log('adm-zip OK')"
# Sortie attendue : adm-zip OK
# Sortie pathologique : MODULE_NOT_FOUNDDecision criterion. If the docx key count exceeds 200, no action; adm-zip must also load before a site publication. A zero count signals a missing module or a broken installation: reinstall, never patch. A normal count guarantees nothing about the consistency of resolution — §3.14.2.
3.14.2Inconsistent resolution — the cause of the empty body
The docx package exposes two builds of the same code: dist/index.cjs and dist/index.umd.cjs. Node’s ordinary resolution picks the first; a require with a directory path picks the second. Both load without error, expose the same number of keys, and produce distinct classes: instanceof is false from one to the other.
A document whose paragraphs come from one instance and whose serialiser comes from the other comes out with a body full of rootKey tags. No error is thrown. The file opens; it is empty.
The remedy is therefore to align resolutions, never to modify the installed module. Patching the docx package.json would treat a symptom, touch a file belonging to a third party, and not survive a reinstallation.
3.14.3Persistence and blind spot
Reinstalling docx during a session changes nothing in the resolution rule, which lives in the Kit’s files and not in the module. The diagnosis in §3.14.1 remains useful after the fact: it detects the plain absence of a module.
Blind spot. The key count does not see an inconsistent resolution: both instances expose as many. Only check 13, downstream, and the fidelity round trip, ahead of a campaign, catch it. It was the latter that established the cause.
3.15kit_check_registry.py — Registry perimeter
–What it checks. The top-level keys of the project Registry. A key missing from the Kit’s list is an error: the Kit neither specifies nor reads it, and no migration of the Update Guide knows it. Its place is Settings.js — Common Structure §5.4.
–Engine document slugs: a document belonging to an engine carries that engine’s prefix — Naming Convention §3.4 —, and a slug prefixed with an engine belongs to that engine. The check reads the pattern and slug pairs of the Kit site generator, the gen-*-site.js that requires kit_publication.js — Naming Convention §3.5 —; a generator outside the Kit is ignored and named. It compares each slug with the Registry's documents block, and fails if it reads none, since nothing was then compared, or if several generators require kit_publication.js; a folder where none requires it says so, slugs not compared. A generator without pairs leaves the slugs to Document Titles, their home — Common Structure §6.8: each published page of the Registry, an entry carrying contentHash, must match an entry there, bare slug or followed by a site language when the entry is multilingual, under the right engine prefix. The opposite is an error. A variant derived from Document Titles without a page in the Registry is only information: the translation scope is decided document by document — Naming Convention §2.4.
–Agreement of the archive: the projectZip block carries the version in version and filename, and, in the Kit Registry alone, in downloadUrl. The check requires these values to agree, and projectZip.include, when declared, to be a list of paths relative to the project — their existence and refusals are checked at the pass. Without it, a delivery that raises only the version publishes an archive named after the previous one, and the announced address leads to a version behind, with nothing to say so.
–Kit dependency and last archive: a project's Registry declares under kit the required Kit version and kit.downloadUrl, shared or not, and carries the deploy.lastArchive key — Common Structure §5.1. The add flags are booleans, siteLanguages a list of Kit languages. rendering.translationNote, if declared, is true or false — Kit Prompt §17 —, and rendering.coverDate one of the formats of Common Structure §5.1.
–Historical path: deploy.historicalPath, when declared, is a relative string under the site root, neither html/ nor assets/ — HTML Pipeline §4.
–Data modules: under each requires flag set to true, the data module carries its timestamp next to the Registry — [Prefix] - Colors (TS).js, Naming Convention §2.1. A module without a timestamp, or missing, is an error: the tools look for it under that pattern, and generation stops as soon as a document loads it.
–Usage. python kit_check_registry.py, or --registry to name a file. Exit 1 if a check fails, 2 if the Registry cannot be found or read.
3.16kit_gen_document.js — rebuilding from a map
–What it does. Rebuilds a document from the map extracted from its source file by kit_extract_map.py. It serves any document: it is a stable artifact. It is part of the Kit's download archive, so that a project has everything it needs to work from the start. Like every stable artifact, it changes only when its logic changes — the rule of the generator written from scratch, Kit Prompt §4.1, targets ad hoc document generators.
–Translation note. On a variant — a document language other than project.docLanguage —, it sets the translation note in its fixed wording at the top of §1 when rendering.translationNote is true, and removes it otherwise, as on an online help. A note in the former wording is replaced — Kit Prompt §17.
–Subtitle and cover date. The subtitle is composed by documentSubtitle from the document name, without language tag, when Document Titles carries it; otherwise the caller’s one loses its final tag. The date in the cover page footer follows coverDate and coverDateValue of Document Titles, then rendering.coverDate — General Reference §10.5.
–Usage. node kit_gen_document.js carte.json “Nom sans TS” LANG titre sous-titre tagline --ts TS [--nom “Nom du document”]. --nom gives the document’s name, without timestamp, when the produced file carries another: Document Titles is read under it, and a translated online help stays without a note. The General stylesheet, the YAML stylesheet and the Registry are designated by the GENERAL_MODULE, YAML_MODULE and REGISTRY_MODULE environment variables.
3.17Checking the targets of labelled links
–What it does. It compares the targets gathered at render time against what the publication pass has written, and stops the generation naming every target that cannot be found. The stylesheets judge the form of a target and stop on it; only the end of the pass knows the inventory of pages, and can therefore judge existence. The target is decoded before the file is looked up: a space written %20 designates the name with spaces.
–Where it lives. controlerCiblesDeLiens(cibles, produits, siteDir), in kit_publication.js — §3.19. Every site generator calls it after the last write, and clears the record with resetCiblesDeLiens() before the first — Extending the Kit §10; kit_check_setters.py --html requires the call. controlerLiensDuSite(siteDir, registry) follows: every relative address of every page, PDF and anchors included, leads to a present file. Under deploy.historicalPath, a missing target goes to the record — the number of links, one line per first missing folder — instead of stopping the pass; what is present there is checked normally — HTML Pipeline §4.
3.18Checking anchors set outside the stylesheet
–What it does. The pass refuses a page carrying an anchor whose class is none of those the stylesheet sets. A project composing its own HTML escapes everything the stylesheet guarantees: escaping, typographic correction, colouring, bounding of the address. The rendering may look right while the text has been through no pass at all.
–Where it lives. controlerAncres(slug, corps), in kit_publication.js — §3.19 —, which every site generator calls on the converted body of each document, before renderDocument: around the body, the stylesheet itself sets anchors without a class, table of contents and home page illustration; kit_check_setters.py --html requires the call — §3.4. gen-kit-site.js calls it as a project's generator does, next to the text-conservation guard.
3.19kit_publication.js — site publication and project archive
What every publication pass must get right, and what each site generator would otherwise rewrite. gen-kit-site.js calls it as a project's generator does: a single source.
–Start. verifierDepart(registry) returns what is missing to publish — in the Registry, the projectZip block with filename and the deploy.lastArchive key; in the environment, zip, unzip and pandoc 3 or later —, to be added to the capability check. It also names what the Kit folder holds outside its archive — etrangersDuKit(dossier): a file outside the allow-list, at the root or under docx/, an unknown folder; an archive unzipped over an existing folder leaves behind what it does not contain. controlerDocuments(entrees) checks, before any write, the documents it is given — each published document, whether the pass regenerates it or not: fingerprint, floors read from the Kit's Registry, validator — HTML Pipeline §7.4. controlerAncres(slug, corps) refuses, on the converted body before renderDocument, an anchor the stylesheet did not set — §3.18. demarrer() refuses an output folder that is not a subfolder of the project, distinct from docx/, or that exists without carrying a site — HTML Pipeline §4 —, clears the site ZIP and the project archive left under their provisional name, takes back a site set aside by an interrupted pass, stops the pass if the archive of a number already produced is missing or, when present, no longer matches the project — compared before any production, the Registry on disk included without its deploy block —, and sets the current site aside for a full pass, keeping at the root what the project has placed there. copierIcones() and copierPieces() then copy the project's icons and pieces under assets/, and stop on a missing one.
–Linked images. preparerConversion(docx, dossier, registry) checks the linked photos of a document and returns the .docx to give pandoc: the original, or a copy in which each linked image becomes a marker. imageDeMarqueur(texte, images) designates during the walk the photo for picture() to place. copierImagesLiees(docxPublies, siteDir, registry), after the last page, checks and copies under the site’s assets/png/ the photos of every published document, delta included. A fault — target, name, missing file, format, caps of rendering.images — stops the pass and names the file — HTML Reference §14.7.
–About page. etatDuSite({ entrees, langue, passe }) gathers the data of the About this site page: the Kit that built it, read from the Kit’s Registry — version, archive, stylesheets and General floor, address —, and the state of each published document, read from its fingerprint, up to date or compliant; the documents are grouped by family and sorted by name in the page language. style.renderAboutPage() renders it, one per language — HTML Reference §24.
–Content fingerprint. empreinteDeContenu(blocs) returns the fingerprint of the bare text of a document body, on its pandoc AST: what follows the first heading, with the non-breaking space, the zero-width space and the non-breaking hyphen neutralised — HTML Pipeline §3.3. The generator carries it in the record of each page, together with empreinteDeContenuAnterieure(blocs), the former formula, title page included: a Registry fingerprint equal to it is replaced without redating the document. kit_check_setters.py --html requires both calls.
–Root loader. pageChargeur(registry, cible, langue) returns the page placed at the root — index.html and index-{langue}.html —, which forwards to the index with location.replace, carrying over the parameters and anchor of the address: embed=1 survives — HTML Reference §27. Every site generator uses it instead of writing its own.
–Site title. titreDuSite(registry, coverHeader, langue) returns the bar title of the landing page and of the history page: the first line of coverHeader in the page language, otherwise deploy.siteName; without either, the pass stops and says so. Every site generator uses it.
–End of pass. terminer() repeats the verifierDepart() check, updates the Registry on a provisional copy, which it reads back through require and compares with the expected state — Prompt §4.1, produces the project archive from the allow-list, completed by the paths of projectZip.include — Common Structure §11 — the same file under two timestamps stops it, Prompt §4.1 — under a provisional name — under assets/downloads/ if the project is shared, at the root otherwise —, writes the site ZIP under a provisional name, then removes the site set aside, names the archive, writes the Registry by renaming and finally names the site ZIP. A failure to write the Registry removes the named archive: nothing is published under a number the Registry does not know. The provisional folder is created and removed by terminer() itself, outside the project; a call still passing tmpBase is refused. An archive that deploy.lastArchive names is taken over if its content equals the project, the Registry compared without its deploy block; otherwise the pass stops and asks for projectZip to be raised. An archive of the same name that deploy.lastArchive does not name is the remnant of a failed pass: it is redone. This comparison repeats the one made at the start as a final check. A failure before that leaves the Registry intact and the old site restored; a deploy.lastDeploy or deploy.lastArchive key that is missing, duplicated — comments included — or of an unexpected form is one, before the archive is produced. A declared piece missing from the root, or that the allow-list does not admit, stops the pass and is named — Naming Convention §8.
–Where it lives. A project requires it from ../kit/; its npm modules are resolved like those of the stylesheets — Execution environment §4. It reads the Registry, Kit - Registry.js, each published .docx and the files the archive carries, and runs kit_validate_docx.js — controlerDocuments(). It writes the site, the archive, the Registry and a provisional folder in the system's temporary directory, removed at the end of the pass; node ../kit/kit_publication.js --archive, run from the project folder, produces the archive outside the pass — Common Structure §11; comparerArchiveReprise() rereads the Registry of an archive in a folder of the system's temporary directory, removed at once. A failure of the out-of-pass archive restores the original Registry: the number only goes up if the archive exists.
3.20gen-kit-site.js — publication pass of the Kit site
–What it does. Publishes the Kit site — document pages, landing page, history page, glossaries, stylesheet and PDFs —, then produces the Kit archive and the site ZIP through kit_publication.js — §3.19. A stable artifact despite its prefix — Naming Convention §3.5.
–Reserved to the Kit. It reads Kit - Registry.js in the current folder and stops if it finds a project's Registry there. A project writes its own site generator, gen-[prefix]-site.js, which requires kit_publication.js — HTML Pipeline §7.9.
–Usage. node gen-kit-site.js [--full | --delta]. --full redoes every page; --delta, the default when deploy.lastDeploy is set, redoes the pages whose document has changed, and all of them when the HTML stylesheet has changed — HTML Pipeline §4 and §4.2.
3.21gen-glossary-reference.js — rebuilding the Glossary Reference
–What it does. Rebuilds the Reference of the Glossary stylesheet from its map. It takes over the dispatch of kit_gen_document.js — §3.16 — and adds the Glossary stylesheet's helpers, which the generic tool cannot set back: term name, definition, letter header, banner. A stable artifact despite its prefix — Naming Convention §3.5.
–Usage. node gen-glossary-reference.js carte.json “Nom sans TS” titre sous-titre tagline --ts TS. The General, YAML and Glossary stylesheets and the Registry are designated by GENERAL_MODULE, YAML_MODULE, GLOSSARY_MODULE and REGISTRY_MODULE.
3.22kit_typographie.js — typographic correction
–What it does. The single source of the Kit's typographic correction: it removes the space set before a punctuation mark, and never sets one. It also carries the non-breaking block protection — dates, timestamps and amounts: protegerBlocs marks the string and classeTextRunProtegee builds the run, which General and Glossary use. The General, HTML and Glossary stylesheets and the HTML glossary generator require it; kit_check_markup.py --typo checks that none carries a copy — §3.7. Rendering rule: General Reference §10.6.
–Usage. const { corrigerPonctuation } = require('./kit_typographie.js'); texte = corrigerPonctuation(texte). const TextRun = classeTextRunProtegee(docx, opts => opts.font === FONT_CODE);
3.23kit_images.js — image rules
–What it does. The single source of the Kit’s image rules: the proportion of a photo — a share of the text width of its level, fitted inside a 3:2 landscape frame —, the level widths and their value in body-text size, reading the format and dimensions of a JPEG or a PNG, the naming of targets and the default caps, 1600 pixels on the long side and 400 KB. General, the HTML stylesheet, kit_publication.js and kit_validate_docx.js require it; General checks on loading that the level widths are its own. Rendering rule: General Reference §13.5.
–Change of the rule. A rendering change in kit_images.js counts as a change of General and of the HTML stylesheet, which each change version.
–Usage. const images = require('./kit_images.js'); images.proportion(largeur, hauteur); images.dimensions(buffer); images.lireCible(cible); images.plafonds(registry).
4Layer 3 — Periodic cross-cutting audits
Reviews done in a dedicated session. They deal with drift that cannot (yet) be detected at runtime or in session. The aim is often to identify a rule that deserves to move up into Layer 1 or 2.
4.1JSDoc and Reference audit
Confronts every exported function of every stylesheet with its line in the matching Reference. Detects divergences in return type, signatures, behaviour. Agreement between JSDoc and Reference is prescribed in Kit Prompt §6.2 — the audit checks continued compliance, not an unknown drift.
–Scope: General, Glossary, YAML, HTML — all stylesheets together.
–Deliverable: a bump of each stylesheet file set with JSDoc corrections and an aligned Reference.
4.2Version alignment audit
Checks the consistency of version numbers across the following locations. Any inconsistency indicates a document not regenerated after a bump, or a partially updated file.
–Registry: source of truth for the active versions.
–.js header: the version comment in the first lines, // Version followed by the number. It is the location the AI reads for the check in Update Guide §4.2.
–Exported constant: STYLESHEET_VERSION, the value actually stamped into documents. A gap with the header is invisible at runtime but distorts any check.
–.docx fingerprint: the StylesheetVersion custom property of each document produced.
This audit comes naturally at the end of a session of stylesheet changes.
4.3Multilingual coverage audit
Scans the stylesheets for strings hard-coded in French that should go through the L10N pattern. Findings by stylesheet:
–Glossary stylesheet: L10N complete, alsoLabel the only key.
–HTML stylesheet: L10N complete. The compilation notice goes through config.compiledWith; the language selector has its keys.
–General stylesheet: L10N complete (noteLabel, noteLabelCol, sessionTitles, undeclaredAuthor). The width of the label column of note boxes follows the label there: a single value would not describe languages whose labels do not have the same set width. No file (.docx) carries a compilation notice.
–YAML stylesheet: nothing notable.
4.4Maintenance audit
Review of the content of a project’s whole documentation, run by the maintenance rebuild — Kit Prompt §4.1. The audits before it look at the stylesheets; this one looks at what the documents say. Findings:
–Missing documents: every document declared in the Registry exists in the working tree, carries its label in Document Titles and its page on the site; every document in the tree is declared. A translation missing in a served language counts as a missing document — Kit Prompt §17.
–Duplications: a rule stated in two places. One becomes a reference to the rule’s home — Kit Prompt §1.
–Stale content: keys the code no longer reads, removed functions, outdated versions or file names, references to a section that has disappeared or been renumbered.
–Orphan files: a file in the tree that neither the Registry, nor a generator, nor a document designates; in the Kit folder, anything its archive does not carry — verifierDepart stops it, §3.19.
–Deliverable: the findings, by name, before any generation. Nothing is removed without the user’s go; the corrections retained go into the regeneration of the set that follows.
5Fingerprints and traceability
Every file of the Kit carries a fingerprint that makes it possible to identify it and verify its origin.
5.1Custom properties in the docx
Set by style.documentProps(TS, feuilles), passed to the Document constructor; style.injectCustomProps(buf, TS) checks after Packer that they are present, and stops generation otherwise. Fields:
–StylesheetVersion: version of the stylesheet used — read from style.STYLESHEET_VERSION.
–GeneratedAt: the document’s TS timestamp (format YYYY-MM-DD - HHhMM). Must be identical to the TS of the file name — a gap signals a generator that names the file with one timestamp and passes another to documentProps or makeCoverFooter.
–GlossaryVersion, YamlVersion: version of the Glossary or YAML stylesheet whose renderings the document uses, set only when it uses them. Publication compares it with the floor of its stylesheet — HTML Pipeline §7.4.
5.2File set timestamp convention
The members of a file set share exactly the same TS: a stylesheet .js and its Reference .docx, like the file sets below. A bump of one entails assessing and updating the others at an identical TS, save the cover image rendered alone — Kit Prompt §6.2. Without this constraint, nothing tells which one is authoritative. Complete inventory of file sets: Kit Prompt §6.
–Kit glossary file set: Kit - Glossary - Terms.js and the documents Kit - Glossaire - Termes, one per language.
–Kit Cover Sheet linked files: Kit - Documentation - Cover Sheet - FR (TS).docx and its PNGs, one rendering per language.
–Project Cover Sheet linked files: [Prefix] - Documentation - Cover Sheet - [Document language] (TS).docx and its PNGs, one rendering per published language — present if Registry.requires.coverSheet is true.
5.3Registry as the single source
Kit - Registry.js holds the versions, TS and flags of all the Kit’s files. Every version reference in another document must be traceable to the Registry. In case of divergence, the Registry prevails. The detailed structure of the Kit Registry is documented in HTML Pipeline §3.1; that of project Registries in Common Structure §5.
6Catalogued anti-patterns
Frequent errors, identified through experience, to be prevented by Layer 1 or Layer 2 as early as possible.
| Anti-pattern | Consequence | Defence |
|---|---|---|
| Paragraph level inconsistent with its parent heading | Badly indented rendering, visual inconsistency | Inexpressible — the level comes from the heading, not from the function name. Checked downstream by kit_validate_docx.js check 11 (§3.1) |
| Faulty cascading list — one-item sub-list, skipped level | Misread enumeration: an item alone under its parent, an item that seems to belong to another | kit_validate_docx.js check 22 (§3.1) |
| Note directly after a heading | Patronising effect — “too instructive” | Layer 2 — kit_validate_docx.js check 17 (§3.1) |
| §0 as the starting number | Non-standard numbering, a LaTeX legacy | Explicit rule General §1.2 — kit_validate_docx.js check 15 (§3.1) |
| Two adjacent Table functions without releaseParagraph | The two tables merge visually in Word | Documented in General §13.4 — generator discipline |
| ImageRun without the type parameter | File word/media/.undefined, hence a corrupt .docx | Fixed by the mandatory style.makeImageRun |
| Diverging resolutions of docx in one chain | Two instances of the module in the same chain: distinct classes, a document with an empty body. | Rule: requireExterne — ordinary resolution, then KIT_NODE_MODULES, then npm root -g; no path written in advance. A generator takes docx from the stylesheet, style.docx, and kit_check_setters.py refuses one that requires it itself. §3.14.2 and General Reference §1.3. |
| prompt for non-dialogue code | Semantic confusion — prompt is reserved for the chat | Rule: yamlStyle.rawBlock for all code (JS, bash, SVG, HTML, JSON) |
| disclaimer() as a final style | Patronising tone, ethically deprecated | Removed — style.tip() instead |
| Direct editing of the docx XML (ElementTree) | Namespace corruption, unreadable docx | Rule: regeneration from the map, §3.9 and §3.16. Only the regulated surgical patch — Dialogue Commands §2.4 — inserts a fragment, rendered by kit_patch_helpers.py, §3.6. |
| Missing custom properties | Publication refuses the document — HTML Pipeline §7.4 | Runtime — documentProps in the Document constructor; injectCustomProps checks it |
| Generic JSON extractor without semantic classification | Every 1×1 table rendered as prompt, code blocks miscategorised | Rule: each 1×1 block classified by hand — rawBlock (code), codeBlock (YAML) or prompt (dialogue only) |
| Equal widths kept on very unequal columns | Wasted space for numeric or short-symbol columns, main text squeezed | Rule: equal distribution by default suits comparable columns, and the # column is narrow automatically — General §9. Otherwise pass colWidths by content — symbols ≈ 5-10 %, long text ≈ 30-40 %. |
| Regex when writing a structured file | A regex does not know the grammar of the format — it can hit a protected case and corrupt the file | Rule Kit Prompt §4.1: every change to a structured file goes through the native parser. Regex allowed for pure reading only. |
| Inline changelog in Kit-published documents | Stray logs that clutter the reading of a reference document | Editorial rule: no “Document history” section / no inline changelog. Sole exception: Kit - Projet - Todos. |
| ASCII separators of variable length | Inconsistent rendering, poorer readability | Rule Kit Prompt §12: separators unified at 30 characters, = major, - minor. |
| Footer wrapped in new Footer({ children: [...] }) | docx-js serialises the child Footer as “<options/>” under <w:ftr>. Word refuses to open the file (Text Recovery Converter). | Layer 1 — explicit JSDoc on makeFooter / makeCoverFooter. Layer 2 — kit_validate_docx.js check 7. |
| Silent synchronisation between Cover Sheet and HTML landing page on the assumption of drift | Silent loss or addition: the two indexes are independent — a binder may be lighter, the landing page leaves out what is not read online. | The two indexes are declared separately (HTML Pipeline §2.5). No script reads one to drive the other. |
| Hard-coded Kit-specific values in a stable artifact | Prevents use by consumer projects | Read specific data from the canonical source: .docx via the pandoc AST, project Registry, .js data files. |
| require('docx') returns an empty object (corrupt npm cache) | Immediate TypeError on every new Document(), Packer.toBuffer() | Environment prerequisites — §3.14 |
| Stray <0/> injected by a forgotten spread on makeTable | Invalid XML tag. Word may tolerate it, but pandoc HTML fails silently on the broken table. | Layer 2 — kit_validate_docx.js check 14 (strict global XML). Blocks delivery. |
| Numbering broken by h2(level, text) instead of h2(number, text) | Every §2.X displays as “2”. Valid document but inconsistent numbering. | Layer 2 — kit_validate_docx.js check 15 (heading monotony). Blocks delivery. |
| X.1 without X.2 — orphaned subsection | Anti-pattern documented in General §1.2. A lone subsection whose content belongs under the parent. | Layer 2 — kit_validate_docx.js check 16 (orphaned X.1). Blocks delivery. |
| Isolated note or tip immediately after a heading | Anti-pattern documented in General §1.2. Tip or note used as the main content instead of underlining a preceding paragraph. | Layer 2 — kit_validate_docx.js check 17 (isolated note or tip). Blocks delivery. |
| Pipeline setter omitted at the top of gen-[prefix]-site.js | Silent regression — HTML site without glossary hotlinks, without small-caps brands, without family and external routing. The generator runs without error. | Layer 2 — kit_check_setters.py (§3.4). HTML Pipeline §7.9 documents the rule. Linter exit 1 if a required setter is missing. |
| First references without <w:titlePg/> in the sectPr | Word ignores headers.first and footers.first: the title page receives the navy header and the default footer. Silent defect, invisible at generation. | Layer 2 — kit_validate_docx.js check 18. Correct pattern: properties: { ...style.pageProps, titlePage: true } — General Reference §10.4. |
| Reusing the helpers of gen-kit-site.js in a consumer project | gen-kit-site.js is Kit-only under Naming Convention §3.5; its helpers are coupled to the Kit SECTIONS constant. Reuse = implicit duplication. | Layer 1 — gen-kit-site.js exports only main; what serves every site generator lives in kit_publication.js — §3.19. Consumer projects write their own gen-[prefix]-site.js, a durable file that is maintained — Naming Convention §3.5. |
| Comparing XML tags by prefix | “w:pPr” answers to “w:p” and inflates the depth, which “/w:pPr” does not decrement. The element swallows the rest of the body and the check goes inert without reporting anything. | Rule: require the tag name to end with an angle bracket, a space or a slash. Helpers isTagStart and findTagStart of kit_validate_docx.js. |
| Exit zero from a check that verified nothing | A linter that finds nothing to work on returns zero, which reads as a passed check. | Rule: distinguish “nothing to check” from “check passed”. A tool that found nothing to work on must say so and exit with an error, never return zero |
| Brand taken for a bold lead | The pipeline renders brands in bold small caps. A paragraph opening on a brand name therefore has a bold first run: extracted as boldText, it loses its small caps, boldText being excluded from the pipeline. | Rule: a run that is bold AND in small caps is a brand, never a lead. Detected by kit_check_markup.py (§3.7). |
| Glossary non-breaking spaces neutralised from the wrong language | Text extracted from a source file carries the non-breaking spaces set by the glossary pass. Neutralising them from another language’s surfaces leaves the term unmatched: it loses its colour without a single word changing. | Rule: read the surfaces through buildSearchTerms(document language). Detected by kit_check_markup.py (§3.7). |
7Feedback loop from project to Kit
The §1.1 layers are the Kit’s internal defences — runtime prevention, session validators, cross-cutting audits. Another source of signal exists: feedback from consumer projects in real use. It catches what Layers 1-3 do not see: defects that emerge from concrete use outside the Kit’s perimeter.
This feedback goes through a dedicated project file, the bug report, named per Common Structure §13.2. The consumer project produces the bug report from scratch with gen-kit-bug-report.js, puts it through the validation chain of §3.13 and delivers it by depositing the source file in the Kit project’s chat along with the necessary artifacts: the offending gen-*.js, the faulty .docx, screenshots if any.
The complete specification — triggers, naming, document structure, reporting workflow, non-permanence of the file — is in Common Structure §13. This §7 does not duplicate the contract: it points to the project’s source of truth. The corrections that came through this channel are recorded in Todos §4.