feat(domain): R5.6 prepared, fingerprint convention and registry inert, switch patch

canonical_json (RFC 8785), sheet_fingerprint behind feature fingerprint,
TRUSTED_ALIASES (one equine pair), equivalence and check_declared; tests against
the RFC vectors, the V8 numbers, an independent Node reference and the archives.
No consumer wired: the switch is a rehearsed patch under .claude/tasks/plans.
This commit is contained in:
bchanot committed 2026-10-24 14:36:01 +02:00
1 parent 1f8873dbce
commit 3b9a395d43
12 files changed
+1004 -1

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env node
/**
* R5.6 preparation: the independent Node reference of RFC 8785 for the Rust canonicaliser
* (`crates/core/src/domain/sheet/fingerprint.rs`). Its own `canonicalize` (JSON.parse,
* JSON.stringify, `<` on strings: UTF-16 order), written apart from the Rust and from the R5.1
* study script. Writes `crates/core/tests/oracles/r5/fingerprint-differential.json` once, only
* with MAKE_R5_ORACLES=1 and only when the file is absent (an oracle is added, never rewritten).
*
* MAKE_R5_ORACLES=1 node scripts/r5-fingerprint-differential.mjs
*/
import { createHash } from 'node:crypto'
import { existsSync, writeFileSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const OUT = resolve(
dirname(fileURLToPath(import.meta.url)),
'../crates/core/tests/oracles/r5/fingerprint-differential.json',
)
function canonicalize(value) {
if (value === null || typeof value !== 'object') return JSON.stringify(value)
if (Array.isArray(value)) return `[${value.map(canonicalize).join(',')}]`
const keys = Object.keys(value).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalize(value[k])}`).join(',')}}`
}
const INPUTS = [
'[1e21, 1e-7, 1E+2, 0.1, -0, 5e-324, 1.7976931348623157e308, 123456789012345678901, 9007199254740993, 100, 1.5e-6, 0.000001, 1e20, 999999999999999999999]',
'{"\\ud83d\\ude00": 1, "\\ufb33": 2, "\\u00e9": 3, "e\\u0301": 4, "Z": 5, "a": 6, "": 7, "aa": 8, "\\u0080": 9}',
'{"s": "\\u0000\\u0001\\u001f\\b\\f\\n\\r\\t\\"\\\\/\\u007f\\u2028\\u2029\\u00e9e\\u0301\\ud83d\\ude00"}',
'{"b": {"z": [true, false, null, {"y": 1, "x": [ ]}], "a": {}}, "a": [[[]]]}',
'{"geometry": {"cx": 743.0451049804688, "cy": 469.1115417480469, "r": 12}, "name": {"fr": "Atlas (C1)", "en": "Atlas"}}',
'{"k": 1, "k": 2}',
'[-1.0, 2.50, 1e0, -1e-0, 0.1e1, 12345678.9, 4.35, 0.3, 1e-6, 1e-5]',
]
const cases = INPUTS.map((input) => {
const canonical = canonicalize(JSON.parse(input))
return {
input,
canonical,
sha256: createHash('sha256').update(canonical, 'utf8').digest('hex'),
}
})
if (process.env.MAKE_R5_ORACLES !== '1') {
console.log(JSON.stringify(cases, null, 2))
} else if (existsSync(OUT)) {
console.error(`${OUT} exists: an oracle is never rewritten`)
process.exit(1)
} else {
const frozen = { frozen_from: `Node ${process.version}`, cases }
writeFileSync(OUT, `${JSON.stringify(frozen, null, 2)}\n`)
console.log(`wrote ${cases.length} cases`)
}
+4
View File
@@ -33,6 +33,10 @@ cargo test -p faunosteo-core --features curation --locked
# against a loopback stub of the local stack (`upload_tool`); never built into the module.
cargo clippy -p faunosteo-core --all-targets --features upload --locked -- -D warnings
cargo test -p faunosteo-core --features upload --locked
# The sheet fingerprint (R5.6, prepared, not active): RFC 8785, the V8 and Node oracles, the
# registry, and the census of the fixture archives (their attachments need the PDF reader).
cargo clippy -p faunosteo-core --all-targets --features fingerprint,pdf-read --locked -- -D warnings
cargo test -p faunosteo-core --features fingerprint,pdf-read --locked --test sheet_fingerprint
# Exports the TypeScript types of the contracts (ts-rs) into packages/core-wasm/types.
# `git status --porcelain --untracked-files=all -- packages/core-wasm/types` must stay
# empty afterwards (scripts/check-all.sh, .gitea/workflows/ci.yml): the committed types