From ea18422a3f94b6bf970cedace4f87d3f8f51eb0a Mon Sep 17 00:00:00 2001 From: cesnimda Date: Tue, 17 Nov 2026 21:01:39 +0100 Subject: [PATCH] docs(i18n): make catalogue and census integrity checks reproducible --- docs/i18n/00/AUDIT.md | 2 + docs/i18n/00/BASELINE_TESTS.md | 2 + docs/i18n/00/CATALOGUE_QA_Q01.md | 33 +++++ docs/i18n/00/HANDOFF.md | 2 + docs/i18n/00/Q01_VALIDATION.json | 67 ++++++++++ docs/i18n/00/validate-research.cjs | 160 ++++++++++++++++++++++++ docs/i18n/00/validate-research.test.cjs | 67 ++++++++++ 7 files changed, 333 insertions(+) create mode 100644 docs/i18n/00/CATALOGUE_QA_Q01.md create mode 100644 docs/i18n/00/Q01_VALIDATION.json create mode 100644 docs/i18n/00/validate-research.cjs create mode 100644 docs/i18n/00/validate-research.test.cjs diff --git a/docs/i18n/00/AUDIT.md b/docs/i18n/00/AUDIT.md index 85113e96..eb9fa874 100644 --- a/docs/i18n/00/AUDIT.md +++ b/docs/i18n/00/AUDIT.md @@ -1,5 +1,7 @@ # I18N-00 baseline audit +17 November Q01: [documentation-scoped integrity validator](CATALOGUE_QA_Q01.md) checks the existing 60-candidate draft catalogue, EU24 language groups, historical English AST/caller/placeholder inventory and B01/B02 immutable blob/line/trace/segment evidence. It preserves catalogue/schema/statuses and all stage/publication gates. Integrity is not full-census, translation, runtime or native acceptance. + 17 November R01 addendum: [runtime compatibility research](RUNTIME_CAPABILITIES_R01.md) supplies60 Node and60 .NET candidate observations plus four negative controls across all24 EU language groups and the wider60-tag planned scope. No product test/translation/locale publication is claimed. Per-API gaps, Montenegrin identity, explicit scripts, nonbinary plurals and CultureInfo-construction limits inform the gated stage01 proposal. Exact framework/source/native bindings are retained; catalogue/schema and application tree remain unchanged. Full00 and native/market/surface acceptance remain open. 17 November 2026 B02 addendum: [upstream producer census](BACKEND_MESSAGE_CENSUS_B02.md) adds 23 source loci, five source findings and ten producer/consumer traces bound to the same immutable A3 `07fbd5f72c3605d6b2b5b31332ba5786f9446309`. Rules reasons, usage limits and three actual notification-construction owners now have bounded contextual evidence. Fifteen blob, 23 record and 64 trace-line bindings passed (102 total), with 23 segment partitions and 32/26/6/0 raw/candidate/invariant/unresolved segment counts reconciled. B01 remains independently accepted at `5d8d5d6ff7467de11ba2ca9526f87bca196a1b4b`; its artifacts were not modified. Runtime/native/full-surface and all stage/publication gates remain open. diff --git a/docs/i18n/00/BASELINE_TESTS.md b/docs/i18n/00/BASELINE_TESTS.md index 7d005b08..187feb42 100644 --- a/docs/i18n/00/BASELINE_TESTS.md +++ b/docs/i18n/00/BASELINE_TESTS.md @@ -1,5 +1,7 @@ # Planning evidence and baseline checks +17 November Q01: [reproducible research validator](CATALOGUE_QA_Q01.md) rechecks the existing 60-candidate draft schema/status envelope, all 24 EU language groups, immutable historical frontend AST/caller/placeholder bindings and B01/B02 source/trace/segment accounting. Commands, negative controls, input hashes and limits are retained there. This is documentation evidence only; existing catalogue/schema, runtime behaviour and stage/publication gates are unchanged. + 2026-11-02. Baseline `5cb903b989742b7a96cb22ddf4c0e24993b18980`, branch `feature/i18n-00-audit`. Documentation only. No runtime code, test code, lockfiles or settings changed. | Check | Result | Scope | diff --git a/docs/i18n/00/CATALOGUE_QA_Q01.md b/docs/i18n/00/CATALOGUE_QA_Q01.md new file mode 100644 index 00000000..4e3343fc --- /dev/null +++ b/docs/i18n/00/CATALOGUE_QA_Q01.md @@ -0,0 +1,33 @@ +# Q01 reproducible research integrity checks + +17 November 2026. Scope: I18N-00 documentation evidence only. This packages the draft-catalogue/schema and source-inventory assertions already required by I18N-00 into a repeatable local command. It does not implement the stage 01 locale registry or stage 06 translation pipeline. Formal I18N-00 remains partial; stages 01–08 retain Phase 10, Product Review, accepted predecessor and owner-authorisation gates. Production NO-GO. + +Authority: the full frozen `E:/Storage/Projects/Active/temp docs/final/I18N/00_MASTER_ORCHESTRATOR.md` requires machine-readable draft catalogues with independently validated schema; `01_I18N_00_AUDIT_COVERAGE.md` permits research/documentation, requires draft catalogue and validated schema, and prohibits feature code changes. The existing [baseline checks](BASELINE_TESTS.md) already exercised Ajv and TypeScript assertions. Q01 stays under this documentation directory, with no application/package/lockfile/schema/catalogue changes and no runtime import or CI wiring. + +## Reproduce + +From repository root, using existing frontend dependencies (TypeScript 5.9.3 and Ajv; no installation needed for this checkpoint): + +```powershell +rtk proxy node docs/i18n/00/validate-research.cjs +rtk proxy node --test docs/i18n/00/validate-research.test.cjs +``` + +For a worktree without its own installed dependencies, set `NODE_PATH` to an existing qualified frontend `node_modules` directory before running these commands. This checkpoint used `E:/Storage/Projects/Active/Job tracker/job-tracker-ui/node_modules`. Dependencies resolve through the frontend package; TypeScript version drift fails explicitly. Historical Git objects must exist locally: missing source objects fail, without network fetch. Run on a trusted checkout with Git and Node available. The CLI writes JSON only to stdout and exits nonzero on failed assertions; it never rewrites evidence, catalogues, approval state or source. [Q01_VALIDATION.json](Q01_VALIDATION.json) retains this checkpoint's run and input hashes. + +## What is checked + +- Draft-07 schema, exact frozen 60-candidate envelope, unique parseable BCP-47 tags, owner/reviewer constraints, planned candidate and six per-surface statuses. The 24 distinct EU language groups from the existing [matrix](EUROPE_COUNTRY_LANGUAGE_MATRIX.md) must be present. Equal-count substitution cannot conceal a missing candidate. These are 60 candidate tags, including language/script/territory variants, not 60 distinct languages or supported locales. +- Montenegrin `cnr-ME` remains present under its original identity. Intl's canonicalisation is reported, without changing catalogue identity or granting aliases. The validator uses the recorded EU24 baseline; it does not refresh legal/territory authority. +- All 3,119 historical English catalogue entries: exact AST order, unique IDs, English text, source line, source hash, placeholder list and caller associations. All 134 non-test/non-declaration frontend source files are re-read from immutable baseline `5cb903b989742b7a96cb22ddf4c0e24993b18980`; the same bounded syntactic `t`/`.t` method recomputes 3,164 known-key static sites, 188 dynamic/unknown calls and 853 keys without a static caller. Original frontend hashes used CRLF checkout bytes; validation reconstructs that documented historical representation and normalises only CRLF/LF in multiline caller comparisons. It does not hash the changed current application tree as historical evidence. +- B01/B02 immutable source `07fbd5f72c3605d6b2b5b31332ba5786f9446309`: raw Git blob hashes, line counts, exact trimmed source expressions, full untrimmed line hashes, unique record IDs/loci, raw-to-candidate/invariant/unresolved lexical-segment multiset partitions, category/count reconciliation, and unchanged native/runtime/translator statuses. B02 trace references and all 64 trace-line occurrences are checked. B01's 117 and B02's 102 file/record/trace bindings are separate batches; shared source files are not claimed as distinct files. + +Tests mutate in-memory copies only: all 60 candidate statuses and all 360 surface statuses reject forged `released`, alongside schema/identity/scope, omitted/duplicate/altered English messages, source hashes/placeholders/callers, backend source/segment/accounting and trace controls. A positive end-to-end test prevents negative controls from passing solely because the baseline is broken. + +Checkpoint results: validator CLI exit 0; Node test runner **22/22 passed, 0 failed, 0 skipped** (420 release-status mutations occur inside one test and are not added to the 22 test total). Node 24.19.0, ICU 78.3, TypeScript 5.9.3, Ajv 6.15.0. `git diff --check` passed. Earlier validator-development failures were corrected before this receipt; none is counted as passing evidence. + +## Limits and next work + +This proves recorded research integrity, not full census completeness, translation quality, locale readiness or human approval. Static syntactic association is not TypeScript symbol resolution; dynamic-key/domain triage, direct catalogue accesses, hardcoded JSX inventory and other census packages retain their separate evidence. Uncalled keys are not deletion candidates. Historical counts do not describe the newer A3 frontend. Source/context classification still requires review; source hashes cannot establish its semantic correctness. + +No app/unit/browser/backend/MariaDB/model/PDF/native/legal/provider/hosted/production tests ran. No translation, locale publication, country/legal cross-check, source refresh, approval or stage progression occurred. Graph artifacts are absent in this worktree; Q01 adds documentation evidence scripts only and does not claim a graph rebuild. Continue the authorised complete-surface census and official-record/reviewer work; review entry prerequisites separately before stages 01–08. diff --git a/docs/i18n/00/HANDOFF.md b/docs/i18n/00/HANDOFF.md index 11d73dea..e47688b8 100644 --- a/docs/i18n/00/HANDOFF.md +++ b/docs/i18n/00/HANDOFF.md @@ -1,5 +1,7 @@ # Partial I18N-00 research handoff +17 November Q01: [catalogue and inventory integrity checks](CATALOGUE_QA_Q01.md) make the draft 60-candidate/EU24 and historical source-binding assertions reproducible without application integration. Catalogue/schema/statuses remain unchanged. Full I18N-00 and stages 01–08/publication acceptance remain gated; Q01 is not a translation pipeline or locale rollout. + 17 November R01: [European runtime capability observations](RUNTIME_CAPABILITIES_R01.md) cover all60 planned candidates and all24 EU language groups in Node24.19/ICU78.3 and .NET9.0.19, with four negative-control observations. Canonicalisation, six per-API data-gap candidates, plural categories and permissive culture-construction limits are recorded. Catalogue/schema and application source remain unchanged; no translation/locale/stage release is implied. Runtime observations do not replace native/browser/PDF/legal review. Source/native receipts are in `evidence/runtime-capabilities-r01/`. Formal00 remains partial;01–08 entry remains gated. Current research branch is `codex/i18n-message-census`; the older branch identity below is historical. 17 November 2026 B02 continuation: [upstream producer batch](BACKEND_MESSAGE_CENSUS_B02.md) on `codex/i18n-message-census` follows published B01 `5d8d5d6ff7467de11ba2ca9526f87bca196a1b4b`. Exact application source remains `07fbd5f72c3605d6b2b5b31332ba5786f9446309`. B02 records 23 source loci, five findings and ten source-level traces for rules reasons, usage/admission and operation/send/search notification prose. 102 source bindings and 23 partitions/count checks passed; product/native tests not run. Existing B01/catalogue/schema/European requirements and all gate decisions are unchanged. No commit/push by the B02 worker. diff --git a/docs/i18n/00/Q01_VALIDATION.json b/docs/i18n/00/Q01_VALIDATION.json new file mode 100644 index 00000000..cfc5e977 --- /dev/null +++ b/docs/i18n/00/Q01_VALIDATION.json @@ -0,0 +1,67 @@ +{ + "status": "research-integrity-only", + "node": "v24.19.0", + "icu": "78.3", + "typescript": "5.9.3", + "ajv": "6.15.0", + "inputSha256": { + "LOCALE_CATALOG.json": "e3c4071134b5aa890183d7c11fea793c25e13f19264012faaaa5131061e3a83b", + "LOCALE_SCHEMA.json": "df189c9b83e52d9244839e80672fcc2e99bb66ee9f35d8afc457f27f676eb0c3", + "MESSAGE_INVENTORY.json": "ff6e4d755bf30920a8a4f288d208ec966b13927f3e73602a77bdda1bb459c6e7", + "BACKEND_MESSAGE_CENSUS_B01.json": "71c04592aec07469cb7fc5b58d7145b18cfaaaba1af86758cf7ee4ab9fb07e74", + "BACKEND_MESSAGE_CENSUS_B02.json": "5f8cf2c85a365243615c154b01a1bf175df8ac563cacf1e67d1d7d7ad4f15681", + "validate-research.cjs": "14cf2a196559fb9100b2a1281197b18fd046aef510cf3b5b7fd92eb1d5e02769" + }, + "catalogue": { + "candidates": 60, + "euLanguageGroups": 24, + "canonicalisationDifferences": [ + { + "tag": "cnr-ME", + "canonical": "sr-ME" + } + ], + "surfaceStatuses": "planned", + "publicationAuthority": "none" + }, + "frontend": { + "baseline": "5cb903b989742b7a96cb22ddf4c0e24993b18980", + "messages": 3119, + "scannedFiles": 134, + "staticCallSites": 3164, + "dynamicOrUnknownCalls": 188, + "withoutStaticCaller": 853 + }, + "backend": [ + { + "batch": "B01", + "sourceCommit": "07fbd5f72c3605d6b2b5b31332ba5786f9446309", + "records": 110, + "traces": 0, + "fileRecordTraceBindings": 117, + "segmentPartitions": 110, + "segments": { + "sourceLiteralSegments": 155, + "translationCandidateSegments": 102, + "nonTranslatableSegments": 47, + "unresolvedSegments": 6 + } + }, + { + "batch": "B02", + "sourceCommit": "07fbd5f72c3605d6b2b5b31332ba5786f9446309", + "records": 23, + "traces": 10, + "fileRecordTraceBindings": 102, + "segmentPartitions": 23, + "segments": { + "sourceLiteralSegments": 32, + "translationCandidateSegments": 26, + "nonTranslatableSegments": 6, + "unresolvedSegments": 0 + } + } + ], + "acceptance": "NOT GRANTED", + "runtimeNativeProductTests": "NOT RUN" +} diff --git a/docs/i18n/00/validate-research.cjs b/docs/i18n/00/validate-research.cjs new file mode 100644 index 00000000..2ee00688 --- /dev/null +++ b/docs/i18n/00/validate-research.cjs @@ -0,0 +1,160 @@ +// Research evidence checks only; no runtime locale or release authority. +const assert = require('node:assert/strict'); +const { createHash } = require('node:crypto'); +const { execFileSync } = require('node:child_process'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); +const { createRequire } = require('node:module'); +const requireUi = createRequire(path.resolve(__dirname, '../../..', 'job-tracker-ui/package.json')); +const Ajv = requireUi('ajv'); +const ts = requireUi('typescript'); +const root = path.resolve(__dirname, '../../..'); +const sha = value => createHash('sha256').update(value).digest('hex'); +const load = name => JSON.parse(readFileSync(path.join(__dirname, name), 'utf8')); +const git = (...args) => execFileSync('git', args, { cwd: root, maxBuffer: 32 * 1024 * 1024 }); +const cache = new Map(); +function source(commit, file) { + assert.match(commit, /^[0-9a-f]{40}$/); + assert.match(file, /^(job-tracker-ui\/src\/|JobTrackerApi\/|tools\/summarizer\/)/); + assert(!file.split('/').includes('..')); + const key = `${commit}:${file}`; + if (!cache.has(key)) cache.set(key, git('show', key)); + return cache.get(key); +} +const sorted = values => [...values].sort(); +function unique(values, label) { assert.equal(new Set(values).size, values.length, `${label}: duplicate`); } + +// Frozen candidate envelope from LOCALE_CATALOG.json, not a public support list. +const candidates = 'en en-GB nb-NO nn-NO sv-SE da-DK fi-FI is-IS bg-BG hr-HR cs-CZ nl-NL et-EE fr-FR de-DE el-GR hu-HU ga-IE it-IT lv-LV lt-LT mt-MT pl-PL pt-PT ro-RO sk-SK sl-SI es-ES uk-UA sq-AL sr-Latn-RS sr-Cyrl-RS bs-BA cnr-ME mk-MK tr-TR lb-LU cy-GB rm-CH fo-FO be-BY ka-GE hy-AM az-Latn-AZ ru-RU fr-CH de-CH it-CH nl-BE fr-BE de-BE en-IE ca-ES eu-ES gl-ES gd-GB se-NO smj-NO sma-NO fkv-NO'.split(' '); +// EU official language baseline already recorded in EUROPE_COUNTRY_LANGUAGE_MATRIX.md. +const eu24 = 'bg hr cs da nl en et fi fr de el hu ga it lv lt mt pl pt ro sk sl es sv'.split(' '); +function validateCatalogue(catalogue = load('LOCALE_CATALOG.json')) { + const validate = new Ajv({ allErrors: true }).compile(load('LOCALE_SCHEMA.json')); + assert(validate(catalogue), JSON.stringify(validate.errors)); + const tags = catalogue.locales.map(locale => locale.tag); + unique(tags, 'locale tags'); + assert.deepEqual(sorted(tags), sorted(candidates), 'candidate envelope changed'); + const languages = new Set(tags.map(tag => new Intl.Locale(tag).language)); + assert.deepEqual(eu24.filter(language => !languages.has(language)), [], 'missing EU language groups'); + // Preserve raw cnr-ME identity; Intl canonicalisation is observation, never an alias decision. + return { candidates: tags.length, euLanguageGroups: eu24.length, + canonicalisationDifferences: tags.flatMap(tag => { + const canonical = Intl.getCanonicalLocales(tag)[0]; + return canonical === tag ? [] : [{ tag, canonical }]; + }), surfaceStatuses: 'planned', publicationAuthority: 'none' }; +} + +function parse(file, text) { return ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true); } +function nodes(tree, predicate) { + const found = []; + function visit(node) { if (predicate(node)) found.push(node); ts.forEachChild(node, visit); } + visit(tree); + return found; +} +const lineAt = (tree, node) => tree.getLineAndCharacterOfPosition(node.getStart(tree)).line + 1; +function validateFrontend(inventory = load('MESSAGE_INVENTORY.json')) { + const file = 'job-tracker-ui/src/i18n/translations.ts'; + const bytes = source(inventory.baseline, file); + const tree = parse(file, bytes.toString('utf8')); + assert.equal(ts.version, inventory.typescriptVersion, 'parser version changed; requalify extraction'); + const declarations = nodes(tree, node => ts.isVariableDeclaration(node) && node.name.getText(tree) === 'translations'); + assert.equal(declarations.length, 1); + let object = declarations[0].initializer; + while (ts.isAsExpression(object) || ts.isSatisfiesExpression(object)) object = object.expression; + const en = object.properties.find(property => property.name.getText(tree) === 'en').initializer; + const extracted = en.properties.map(property => { + assert(ts.isPropertyAssignment(property) && ts.isStringLiteral(property.initializer)); + return { id: property.name.text, english: property.initializer.text, line: lineAt(tree, property) }; + }); + unique(extracted.map(message => message.id), 'English source keys'); + unique(inventory.messages.map(message => message.id), 'inventory keys'); + assert.deepEqual(inventory.messages.map(({ id, english, line }) => ({ id, english, line })), extracted); + const actualCalls = new Map(extracted.map(message => [message.id, []])); + const files = git('ls-tree', '-r', '--name-only', inventory.baseline, '--', 'job-tracker-ui/src').toString('utf8') + .trim().split('\n').filter(name => /\.tsx?$/.test(name) && !/\.(test|d)\./.test(name)); + assert.equal(files.length, inventory.scannedFrontendFiles); + let dynamic = 0; + for (const name of files) { + const ast = parse(name, source(inventory.baseline, name).toString('utf8')); + for (const call of nodes(ast, node => ts.isCallExpression(node) && /(^|\.)t$/.test(node.expression.getText(ast)))) { + const argument = call.arguments[0]; + if (!argument || !ts.isStringLiteral(argument)) { dynamic++; continue; } + if (actualCalls.has(argument.text)) actualCalls.get(argument.text).push({ file: name, line: lineAt(ast, call), expression: call.getText(ast) }); + } + } + assert.equal(dynamic, inventory.dynamicOrUnknownCalls); + for (const message of inventory.messages) { + assert.equal(message.source, file); + // Original frontend inventory hashed the Windows CRLF checkout; backend batches hash raw Git blobs. + assert.equal(message.sourceSha256, sha(bytes.toString('utf8').replace(/\r?\n/g, '\r\n'))); + const placeholders = [...new Set([...message.english.matchAll(/\{(\w+)\}/g)].map(match => match[1]))]; + assert.deepEqual(message.placeholders, placeholders, `${message.id}: placeholders`); + const normaliseCalls = calls => calls.map(call => ({ ...call, expression: call.expression.replace(/\r\n/g, '\n') })); + assert.deepEqual(normaliseCalls(message.callers), normaliseCalls(actualCalls.get(message.id)), `${message.id}: callers`); + } + return { baseline: inventory.baseline, messages: extracted.length, scannedFiles: files.length, + staticCallSites: inventory.messages.reduce((sum, message) => sum + message.callers.length, 0), + dynamicOrUnknownCalls: dynamic, withoutStaticCaller: inventory.messages.filter(message => !message.callers.length).length }; +} + +function validateCensus(census) { + assert.equal(census.status, 'partial-research-only'); + unique(census.sourceBindings.map(binding => binding.path), 'source bindings'); + const bindings = new Map(census.sourceBindings.map(binding => [binding.path, binding])); + let checks = 0; + for (const binding of census.sourceBindings) { + const bytes = source(census.sourceCommit, binding.path); + assert.equal(sha(bytes), binding.sha256, binding.path); + assert.equal(bytes.toString('utf8').replace(/\r?\n$/, '').split(/\r?\n/).length, binding.lineCount, binding.path); + checks++; + } + function checkLine(record) { + assert.equal(record.sourceSha256, bindings.get(record.source)?.sha256); + const lines = source(census.sourceCommit, record.source).toString('utf8').split(/\r?\n/); + assert(Number.isInteger(record.line) && record.line > 0 && record.line <= lines.length); + const expression = lines[record.line - 1].trim(); + assert.equal(expression, record.sourceExpression, `${record.source}:${record.line}`); + assert.equal(sha(lines[record.line - 1]), record.sourceLineSha256); + checks++; + } + unique(census.records.map(record => record.id), 'record IDs'); + unique(census.records.map(record => `${record.source}:${record.line}`), 'record loci'); + const segmentKeys = ['sourceLiteralSegments', 'translationCandidateSegments', 'nonTranslatableSegments', 'unresolvedSegments']; + const segments = Object.fromEntries(segmentKeys.map(key => [key, 0])); + const categories = {}; + for (const record of census.records) { + checkLine(record); + assert.equal(record.translator, null); + assert.equal(record.nativeReview, 'not-run'); + assert.equal(record.runtimeReview, 'not-run'); + for (const key of segmentKeys) segments[key] += record[key].length; + assert.deepEqual(sorted(record.sourceLiteralSegments), sorted([ + ...record.translationCandidateSegments, ...record.nonTranslatableSegments, ...record.unresolvedSegments + ]), `${record.id}: segment partition`); + categories[record.category] = (categories[record.category] || 0) + 1; + } + assert.equal(census.counts.records, census.records.length); + assert.equal(census.counts.sources, census.sourceBindings.length); + assert.deepEqual(census.counts.byCategory, categories); + assert.deepEqual(Object.fromEntries(segmentKeys.map(key => [key, census.segmentAccounting[key]])), segments); + const traces = census.traces || []; + unique(traces.map(trace => trace.id), 'trace IDs'); + for (const trace of traces) for (const record of trace.evidence) checkLine(record); + for (const record of census.records) for (const id of record.traceIds || []) assert(traces.some(trace => trace.id === id)); + if (census.counts.traceEdges !== undefined) assert.equal(census.counts.traceEdges, traces.length); + return { sourceCommit: census.sourceCommit, records: census.records.length, traces: traces.length, + fileRecordTraceBindings: checks, segmentPartitions: census.records.length, segments }; +} + +function validateResearch() { + return { status: 'research-integrity-only', node: process.version, icu: process.versions.icu, + typescript: ts.version, ajv: requireUi('ajv/package.json').version, + inputSha256: Object.fromEntries(['LOCALE_CATALOG.json', 'LOCALE_SCHEMA.json', 'MESSAGE_INVENTORY.json', + 'BACKEND_MESSAGE_CENSUS_B01.json', 'BACKEND_MESSAGE_CENSUS_B02.json', 'validate-research.cjs'] + .map(name => [name, sha(readFileSync(path.join(__dirname, name)))])), + catalogue: validateCatalogue(), frontend: validateFrontend(), + backend: ['B01', 'B02'].map(batch => ({ batch, ...validateCensus(load(`BACKEND_MESSAGE_CENSUS_${batch}.json`)) })), + acceptance: 'NOT GRANTED', runtimeNativeProductTests: 'NOT RUN' }; +} +module.exports = { load, validateCatalogue, validateFrontend, validateCensus, validateResearch }; +if (require.main === module) console.log(JSON.stringify(validateResearch(), null, 2)); diff --git a/docs/i18n/00/validate-research.test.cjs b/docs/i18n/00/validate-research.test.cjs new file mode 100644 index 00000000..845b87ca --- /dev/null +++ b/docs/i18n/00/validate-research.test.cjs @@ -0,0 +1,67 @@ +const { test } = require('node:test'); +const assert = require('node:assert/strict'); +const { load, validateCatalogue, validateFrontend, validateCensus, validateResearch } = require('./validate-research.cjs'); + +test('existing catalogue and immutable frontend/backend inventories reconcile', () => { + const report = validateResearch(); + assert.equal(report.catalogue.candidates, 60); + assert.equal(report.catalogue.euLanguageGroups, 24); + assert.equal(report.frontend.messages, 3119); + assert.equal(report.frontend.staticCallSites, 3164); + assert.deepEqual(report.backend.map(batch => batch.fileRecordTraceBindings), [117, 102]); +}); + +test('all 60 candidate and 360 surface status promotions are rejected', () => { + const catalogue = load('LOCALE_CATALOG.json'); + for (const locale of catalogue.locales) { + locale.status = 'released'; + assert.throws(() => validateCatalogue(catalogue)); + locale.status = 'planned'; + for (const surface of Object.keys(locale.surfaces)) { + locale.surfaces[surface] = 'released'; + assert.throws(() => validateCatalogue(catalogue)); + locale.surfaces[surface] = 'planned'; + } + } +}); + +for (const [name, mutate] of [ + ['missing EU language', catalogue => { catalogue.locales = catalogue.locales.filter(locale => locale.tag !== 'mt-MT'); }], + ['same-count substituted candidate', catalogue => { catalogue.locales[8].tag = 'zz-ZZ'; }], + ['duplicate candidate', catalogue => { catalogue.locales[8].tag = catalogue.locales[9].tag; }], + ['canonicalisation replacing Montenegrin identity', catalogue => { catalogue.locales.find(locale => locale.tag === 'cnr-ME').tag = 'sr-ME'; }], + ['forged reviewer', catalogue => { catalogue.locales[0].reviewer = 'approved'; }], + ['unknown surface', catalogue => { catalogue.locales[0].surfaces.extra = 'planned'; }], +]) test(`rejects ${name}`, () => { + const catalogue = load('LOCALE_CATALOG.json'); + mutate(catalogue); + assert.throws(() => validateCatalogue(catalogue)); +}); + +for (const [name, mutate] of [ + ['omitted English source entry', inventory => { inventory.messages.pop(); }], + ['changed English text', inventory => { inventory.messages[0].english = 'forged'; }], + ['duplicate English key', inventory => { inventory.messages[1].id = inventory.messages[0].id; }], + ['changed frontend source hash', inventory => { inventory.messages[0].sourceSha256 = '0'.repeat(64); }], + ['changed placeholder inventory', inventory => { inventory.messages[0].placeholders = ['forged']; }], + ['missing static caller', inventory => { inventory.messages[0].callers.pop(); }], +]) test(`rejects ${name}`, () => { + const inventory = load('MESSAGE_INVENTORY.json'); + mutate(inventory); + assert.throws(() => validateFrontend(inventory)); +}); + +for (const [name, mutate] of [ + ['changed source hash', census => { census.sourceBindings[0].sha256 = '0'.repeat(64); }], + ['changed source expression', census => { census.records[0].sourceExpression = 'forged'; }], + ['duplicate source locus', census => { census.records.push(census.records[0]); }], + ['lost segment', census => { census.records[0].translationCandidateSegments = []; }], + ['forged native approval', census => { census.records[0].nativeReview = 'approved'; }], + ['wrong category accounting', census => { census.counts.byCategory['controlled-message']++; }], + ['broken trace reference', census => { census.records[0].traceIds = ['missing']; }], + ['changed trace evidence', census => { census.traces[0].evidence[0].sourceExpression = 'forged'; }], +]) test(`rejects ${name}`, () => { + const census = load('BACKEND_MESSAGE_CENSUS_B02.json'); + mutate(census); + assert.throws(() => validateCensus(census)); +});