docs(docs): RUST.md §10.5 completed (application build results, residual risks); R4 J1 procedure and kit

docs/development/R4_J1.md: the two LAN surfaces (dev server, production build behind the
DEPLOY CSP through serve.mjs --host on the DEV origin), the kit folder generated by
scripts/r4-j1-kit.mjs (reference PDFs, the O8 hostile corpus with expected messages,
rescue copies), twelve checks per device, what to report.
This commit is contained in:
bchanot committed 2026-10-18 19:52:25 +02:00
1 parent 08f01ef363
commit b08373a89b
4 files changed
+292 -13

No files matched your search

+7 -2
View File
@@ -187,6 +187,7 @@ export function startServer({
csp = 'with',
mounts = {},
reportViolations = false,
host = HOST,
} = {}) {
const enforced = cspVariant(productionCsp(), csp)
const policy = reportViolations
@@ -198,8 +199,8 @@ export function startServer({
)
return new Promise((done, fail) => {
server.once('error', fail)
server.listen(port, HOST, () => {
const url = `http://${HOST}:${server.address().port}`
server.listen(port, host, () => {
const url = `http://${host}:${server.address().port}`
done({ url, csp: policy, reports, close: () => server.close() })
})
})
@@ -211,6 +212,9 @@ async function main() {
port: { type: 'string', default: '4173' },
csp: { type: 'string', default: 'with' },
r4: { type: 'boolean', default: false },
// The owner's device acceptance (J1): the production build behind the DEPLOY CSP on
// the DEV origin (scripts/dev-env.sh), never on every interface.
host: { type: 'string', default: HOST },
},
})
if (!['with', 'without'].includes(values.csp)) {
@@ -220,6 +224,7 @@ async function main() {
port: Number(values.port),
csp: values.csp,
mounts: values.r4 ? R4_MOUNTS : {},
host: values.host,
})
console.log(`serving apps/app/dist on ${server.url}`)
if (values.r4) console.log(`R4 import page on ${server.url}/r4/`)
+132
View File
@@ -0,0 +1,132 @@
// R4 J1 device acceptance kit (plan 2026-10-17 §A.4, BDR-058): gathers in one
// folder the files the owner picks from a phone or a computer, each with the
// message expected (docs/development/R4_J1.md). Reference PDFs (Step 5 v2 and
// v3, Step 6 envelopes, R3 exports), a hostile folder with the expected
// message per file (from the frozen O8 oracle, the declared R4 differences
// applied), rescue copies (valid, BOM, invalid UTF-8, oversized, refused) and
// the large synthetic L export built like the application exports it is NOT
// here (it needs the browser: export the L report from the editor, see the
// doc). Synthetic data only. Usage: node scripts/r4-j1-kit.mjs [out-dir]
// (default: a `faunosteo-j1-kit` folder next to the repository).
import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
import { join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const ROOT = resolve(fileURLToPath(new URL('..', import.meta.url)))
const FIXTURES = join(ROOT, 'apps/app/tests/fixtures')
const OUT = resolve(process.argv[2] ?? join(ROOT, '..', 'faunosteo-j1-kit'))
// The FR messages of apps/app/src/i18n/fr.ts, by kind (kept in step by hand).
const MESSAGES = {
editor: 'ouvre le bilan dans l’éditeur',
invalid_pdf: "Ce fichier n'est pas un PDF lisible.",
no_attachment:
"Ce PDF n'a pas été généré par Faunosteo (pas de données détectées).",
attachment_stripped:
'Ce PDF Faunosteo a perdu ses données embarquées (pièce jointe supprimée…). Utilisez le fichier d’origine.',
incompatible_version:
'Ce PDF est au format v{version}, que cette version de l’application ne sait pas lire…',
lone_surrogate:
'Ce PDF Faunosteo contient un texte mal encodé que cette version ne peut pas relire sans l’altérer. Import refusé…',
invalid_copy:
'Ce fichier n’est pas une copie de secours Faunosteo lisible par cette version. Import refusé…',
}
/** The R4 outcome of an O8 case (RUST.md §10.3 declared differences applied). */
const DECLARED = {
'values-1m': 'attachment_stripped',
'surrogate-content-overwritten': 'lone_surrogate',
'surrogate-version-overwritten': 'lone_surrogate',
'two-files-decoy-first': 'lone_surrogate',
}
function copy(from, toDir, name = from.split('/').pop()) {
mkdirSync(toDir, { recursive: true })
writeFileSync(join(toDir, name), readFileSync(from))
return name
}
const lines = ['# Kit J1 (R4) — fichiers et message attendu', '']
// 1. Reference PDFs: every one opens the editor.
lines.push('## 1-reference : chaque fichier ouvre l’éditeur', '')
const reference = join(OUT, '1-reference')
for (const f of [
'report-v2.full.pdf',
'report-v2.minimal.pdf',
'report-v3.bare.pdf',
]) {
lines.push(`- ${copy(join(FIXTURES, f), reference)} (Step 5)`)
}
for (const f of readdirSync(join(FIXTURES, 'pdf/r3')).filter((n) =>
n.endsWith('.pdf'),
)) {
lines.push(
`- ${copy(join(FIXTURES, 'pdf/r3', f), reference, `r3-${f}`)} (R3)`,
)
}
lines.push(
`- ${copy(join(FIXTURES, 'pdf/r3/real/v2full-obs1.fr.logos.pdf'), reference, 'r3-real-raster.pdf')} (R3, rasters réels)`,
)
for (const f of readdirSync(join(FIXTURES, 'pdf/step6')).filter((n) =>
n.endsWith('.pdf'),
)) {
lines.push(
`- ${copy(join(FIXTURES, 'pdf/step6', f), reference, `step6-${f}`)} (Step 6)`,
)
}
// 2. Hostile folder from the O8 oracle.
lines.push('', '## 2-hostile : message attendu par fichier (corpus O8)', '')
const oracle = JSON.parse(
readFileSync(
join(ROOT, 'crates/core/tests/oracles/r4/tolerance.json'),
'utf8',
),
)
const hostile = join(OUT, '2-hostile')
for (const c of oracle.cases) {
const kind = DECLARED[c.id] ?? (c.outcome.ok ? 'editor' : c.outcome.kind)
const name = copy(join(ROOT, c.pdf), hostile)
const expected = MESSAGES[kind].replace(
'{version}',
String(c.outcome.foundVersion ?? ''),
)
lines.push(`- ${name} : ${expected}`)
}
// 3. Rescue copies.
lines.push('', '## 3-copies : copies de secours', '')
const copies = join(OUT, '3-copies')
mkdirSync(copies, { recursive: true })
const demo = readFileSync(join(FIXTURES, 'report-v3.demo.json'), 'utf8')
const write = (name, data, note) => {
writeFileSync(join(copies, name), data)
lines.push(`- ${name} : ${note}`)
}
write('copie-valide.json', demo, MESSAGES.editor)
write('copie-bom.json', `${demo}`, `${MESSAGES.editor} (BOM accepté)`)
write(
'copie-sans-extension',
demo,
`${MESSAGES.editor} (routée par le contenu)`,
)
write(
'copie-utf8-invalide.json',
Buffer.concat([
Buffer.from('{"version": 3, "x": "'),
Buffer.from([0xff]),
Buffer.from('"}'),
]),
MESSAGES.invalid_copy,
)
write('copie-json-invalide.json', '{"version": 3,', MESSAGES.invalid_copy)
write('copie-version-1.json', '{"version": 1}', MESSAGES.invalid_copy)
write(
'copie-trop-grande.json',
`{"version":3,"a":[${'1,'.repeat((9 * 1024 * 1024) / 2)}1]}`,
`${MESSAGES.invalid_copy} (18 Mo, au-dessus de 16 Mio)`,
)
writeFileSync(join(OUT, 'ATTENDU.md'), `${lines.join('\n')}\n`)
console.log(`kit written to ${OUT} (${lines.length} lines in ATTENDU.md)`)