feat(domain): V1-2.2 document measure, review groups, verdict, preview, edits
The core's authoring surface of contract §16.3: the server's document measure, review groups with digests and removal groups, the change list, the pure server verdict in the shape M5 reads, PreviewSheet with draft and published modes, and the editor's commands with the §6.6 markings.
This commit is contained in:
1 parent
ac71c5b662
commit
64a43840ce
21 files changed
+5204
-17
No files matched your search
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"generator": "crates/core/tests/oracles/v1-2-2/size.mjs",
|
||||
"postgres": "PostgreSQL 17.5 on aarch64-unknown-linux-gnu, compiled by emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.74 (1092ec30a3fb1d46b1782ff1b4db5094d3d06ae5), 32-bit",
|
||||
"vectors": [
|
||||
{
|
||||
"name": "zero",
|
||||
"text": "0",
|
||||
"bytes": 1
|
||||
},
|
||||
{
|
||||
"name": "negative_zero",
|
||||
"text": "0",
|
||||
"bytes": 1
|
||||
},
|
||||
{
|
||||
"name": "integers",
|
||||
"text": "[1,-12,100,9007199254740992,123456789012345680000]",
|
||||
"bytes": 54
|
||||
},
|
||||
{
|
||||
"name": "fractions",
|
||||
"text": "[0.5,0.1,0.001,123.456,0.3333333333333333,-0.3333333333333333,0.000001]",
|
||||
"bytes": 77
|
||||
},
|
||||
{
|
||||
"name": "exponents",
|
||||
"text": "[1e-7,1.5e-7,-1.5e-7,2.5e-10,1e+21,1.5e+21,1e+300,5e-324]",
|
||||
"bytes": 730
|
||||
},
|
||||
{
|
||||
"name": "extremes",
|
||||
"text": "[1.7976931348623157e+308,5e-324,-1.7976931348623157e+308]",
|
||||
"bytes": 951
|
||||
},
|
||||
{
|
||||
"name": "literals",
|
||||
"text": "[true,false,null]",
|
||||
"bytes": 19
|
||||
},
|
||||
{
|
||||
"name": "strings",
|
||||
"text": "[\"\",\"a\",\"é\",\"€\",\"𝄞\",\"\\\"\",\"\\\\\",\"/\",\"<script>\",\"Hanche « gauche »\"]",
|
||||
"bytes": 82
|
||||
},
|
||||
{
|
||||
"name": "escapes",
|
||||
"text": "[\"\\b\\f\\n\\r\\t\",\"\\u0001\\u001f\",\"\",\"
\",\"a\\\"b\\\\c\\nd\"]",
|
||||
"bytes": 59
|
||||
},
|
||||
{
|
||||
"name": "empty_containers",
|
||||
"text": "[[],{},[[]],[{}],{\"a\":{}}]",
|
||||
"bytes": 31
|
||||
},
|
||||
{
|
||||
"name": "keys",
|
||||
"text": "{\"é\":\"x\",\"𝄞\":1,\"a b\":[],\"\\\"\":\"\\\\\",\"\\n\":0}",
|
||||
"bytes": 54
|
||||
},
|
||||
{
|
||||
"name": "nested_arrays",
|
||||
"text": "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]",
|
||||
"bytes": 122
|
||||
},
|
||||
{
|
||||
"name": "dense",
|
||||
"text": "[{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"a\":1},{\"Line truncated
|
||||
"bytes": 10000
|
||||
},
|
||||
{
|
||||
"name": "pgtap_017_exponents",
|
||||
"text": "{\"pad\":[1e-7,1e+21]}",
|
||||
"bytes": 44
|
||||
},
|
||||
{
|
||||
"name": "mixed",
|
||||
"text": "{\"schema_version\":2,\"name\":{\"fr\":\"Cheval\",\"en\":\"Horse\"},\"views\":[{\"id\":\"main\",\"view_box\":{\"min_x\":-0.5,\"min_y\":1e-7,\"width\":1e+21,\"height\":2}}]}",
|
||||
"bytes": 184
|
||||
},
|
||||
{
|
||||
"name": "repeated_key",
|
||||
"text": "{\"a\":1,\"b\":2,\"a\":22}",
|
||||
"bytes": 17
|
||||
},
|
||||
{
|
||||
"name": "whitespace",
|
||||
"text": "{ \"a\" : [ 1 , 2 ] ,\n \"b\" : { } }",
|
||||
"bytes": 22
|
||||
}
|
||||
],
|
||||
"pgtap_017_base": {
|
||||
"text": "{\"pad\": \"\", \"name\": {\"en\": \"R horse\", \"fr\": \"Cheval R\"}, \"views\": [{\"id\": \"main\", \"kind\": \"main\", \"name\": {\"en\": \"V\", \"fr\": \"V\"}, \"view_box\": null, \"svg_asset_id\": \"00000000-0000-4000-8000-000000000001\"}], \"categories\": [{\"id\": \"c\", \"name\": {\"en\": \"C\", \"fr\": \"C\"}, \"color\": null}], \"references\": [], \"species_id\": \"equine\", \"annotations\": [{\"id\": \"a1\", \"kind\": \"point\", \"name\": {\"en\": \"P\", \"fr\": \"P\"}, \"view_id\": \"main\", \"geometry\": null, \"laterality\": \"unpaired\", \"category_id\": \"c\", \"review_status\": \"reviewed\", \"finding_zone_id\": \"z1\", \"vertebral_region_code\": null}], \"attribution\": {\"notes\": null, \"authors\": [\"F\"], \"license\": null}, \"description\": {\"en\": \"d\", \"fr\": \"d\"}, \"finding_zones\": [{\"id\": \"z1\", \"name\": {\"en\": \"Z\", \"fr\": \"Z\"}, \"categories\": [{\"id\": \"cat\", \"kind\": \"dysfunction\", \"name\": {\"en\": \"D\", \"fr\": \"D\"}, \"children\": [{\"id\": \"n1\", \"name\": {\"en\": \"N\", \"fr\": \"N\"}, \"review_status\": \"reviewed\"}], \"review_status\": \"reviewed\"}]}], \"schema_version\": 2, \"scope_disclaimer\": {\"en\": \"x\", \"fr\": \"x\"}, \"vertebral_config\": {\"regions\": []}}",
|
||||
"bytes": 1048
|
||||
},
|
||||
"seed": {
|
||||
"file": "supabase/seed/anatomical-sheets/equine/draft/document.json",
|
||||
"bytes": 184105
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// V1-2.2 size oracle: PostgreSQL measures each text the way the save RPCs and the table CHECK
|
||||
// do, `octet_length(text::jsonb::text)` (contract §12.2), and `size.json` freezes the answers
|
||||
// the core's `document_text_bytes` must reproduce (`crates/core/tests/sheet_size.rs`).
|
||||
//
|
||||
// PostgreSQL is PGlite (PostgreSQL 17 compiled to WebAssembly, the Dockerless pgTAP runner of
|
||||
// packages/supabase). Texts are written by JSON.stringify, as a page sends them, except the
|
||||
// repeated-key case and the seed file, which are read as they stand.
|
||||
//
|
||||
// Run from the repository root: node crates/core/tests/oracles/v1-2-2/size.mjs
|
||||
import { readFileSync, writeFileSync } from 'node:fs'
|
||||
import { createRequire } from 'node:module'
|
||||
|
||||
const root = new URL('../../../../../', import.meta.url)
|
||||
const require = createRequire(new URL('packages/supabase/package.json', root))
|
||||
const { PGlite } = await import(require.resolve('@electric-sql/pglite'))
|
||||
|
||||
const SEED = 'supabase/seed/anatomical-sheets/equine/draft/document.json'
|
||||
|
||||
const nested = (depth) => {
|
||||
let value = []
|
||||
for (let i = 0; i < depth; i += 1) value = [value]
|
||||
return value
|
||||
}
|
||||
|
||||
const values = {
|
||||
zero: 0,
|
||||
negative_zero: -0,
|
||||
integers: [1, -12, 100, 9007199254740993, 123456789012345680000],
|
||||
fractions: [0.5, 0.1, 0.001, 123.456, 1 / 3, -1 / 3, 1e-6],
|
||||
exponents: [1e-7, 1.5e-7, -1.5e-7, 2.5e-10, 1e21, 1.5e21, 1e300, 5e-324],
|
||||
extremes: [Number.MAX_VALUE, Number.MIN_VALUE, -Number.MAX_VALUE],
|
||||
literals: [true, false, null],
|
||||
strings: ['', 'a', 'é', '€', '𝄞', '"', '\\', '/', '<script>', 'Hanche « gauche »'],
|
||||
escapes: ['\b\f\n\r\t', '\u0001\u001f', '\u007f', '
', 'a"b\\c\nd'],
|
||||
empty_containers: [[], {}, [[]], [{}], { a: {} }],
|
||||
keys: { é: 'x', '𝄞': 1, 'a b': [], '"': '\\', '\n': 0 },
|
||||
nested_arrays: nested(60),
|
||||
dense: Array.from({ length: 1000 }, () => ({ a: 1 })),
|
||||
pgtap_017_exponents: { pad: [1e-7, 1e21] },
|
||||
mixed: { schema_version: 2, name: { fr: 'Cheval', en: 'Horse' }, views: [{ id: 'main', view_box: { min_x: -0.5, min_y: 1e-7, width: 1e21, height: 2 } }] },
|
||||
}
|
||||
|
||||
const texts = Object.entries(values).map(([name, value]) => ({ name, text: JSON.stringify(value) }))
|
||||
texts.push({ name: 'repeated_key', text: '{"a":1,"b":2,"a":22}' })
|
||||
texts.push({ name: 'whitespace', text: '{ "a" : [ 1 , 2 ] ,\n "b" : { } }' })
|
||||
|
||||
const db = new PGlite()
|
||||
const measure = async (text) =>
|
||||
(await db.query('select octet_length($1::jsonb::text) as n', [text])).rows[0].n
|
||||
|
||||
const vectors = []
|
||||
for (const { name, text } of texts) vectors.push({ name, text, bytes: await measure(text) })
|
||||
|
||||
// The pgTAP 017 base document (`pg_temp.doc(asset, 'reviewed')`) with an empty pad: the
|
||||
// `sized` fixtures pad it to cap − 1, cap and cap + 1 bytes.
|
||||
await db.exec(`create function doc(p_asset uuid, st text) returns jsonb language sql as $$
|
||||
select jsonb_build_object('schema_version', 2, 'species_id', 'equine',
|
||||
'name', jsonb_build_object('fr', 'Cheval R', 'en', 'R horse'),
|
||||
'description', jsonb_build_object('fr', 'd', 'en', 'd'),
|
||||
'scope_disclaimer', jsonb_build_object('fr', 'x', 'en', 'x'),
|
||||
'attribution', jsonb_build_object('authors', jsonb_build_array('F'), 'license', null, 'notes', null),
|
||||
'vertebral_config', jsonb_build_object('regions', '[]'::jsonb), 'references', '[]'::jsonb,
|
||||
'categories', jsonb_build_array(jsonb_build_object('id', 'c', 'name', jsonb_build_object('fr', 'C', 'en', 'C'), 'color', null)),
|
||||
'views', jsonb_build_array(jsonb_build_object('id', 'main', 'kind', 'main', 'name', jsonb_build_object('fr', 'V', 'en', 'V'),
|
||||
'svg_asset_id', p_asset, 'view_box', null)),
|
||||
'annotations', jsonb_build_array(jsonb_build_object('id', 'a1', 'kind', 'point', 'view_id', 'main', 'category_id', 'c',
|
||||
'laterality', 'unpaired', 'geometry', null, 'review_status', st, 'name', jsonb_build_object('fr', 'P', 'en', 'P'),
|
||||
'finding_zone_id', 'z1', 'vertebral_region_code', null)),
|
||||
'finding_zones', (select jsonb_agg(jsonb_build_object('id', 'z' || i, 'name', jsonb_build_object('fr', 'Z', 'en', 'Z'),
|
||||
'categories', jsonb_build_array(jsonb_build_object('id', 'cat', 'kind', 'dysfunction', 'name', jsonb_build_object('fr', 'D', 'en', 'D'),
|
||||
'review_status', st, 'children', jsonb_build_array(jsonb_build_object('id', 'n1', 'name', jsonb_build_object('fr', 'N', 'en', 'N'),
|
||||
'review_status', st)))))) from generate_series(1, 1) i));
|
||||
$$`)
|
||||
const base = (
|
||||
await db.query(
|
||||
`select (doc('00000000-0000-4000-8000-000000000001', 'reviewed') || '{"pad": ""}'::jsonb)::text as t`,
|
||||
)
|
||||
).rows[0].t
|
||||
const pgtap017 = { text: base, bytes: await measure(base) }
|
||||
|
||||
const seed = readFileSync(new URL(SEED, root), 'utf8')
|
||||
const version = (await db.query('select version() as v')).rows[0].v
|
||||
|
||||
const oracle = {
|
||||
generator: 'crates/core/tests/oracles/v1-2-2/size.mjs',
|
||||
postgres: version,
|
||||
vectors,
|
||||
pgtap_017_base: pgtap017,
|
||||
seed: { file: SEED, bytes: await measure(seed) },
|
||||
}
|
||||
writeFileSync(new URL('size.json', import.meta.url), `${JSON.stringify(oracle, null, 2)}\n`)
|
||||
console.log(`${vectors.length} vectors, base ${pgtap017.bytes} B, seed ${oracle.seed.bytes} B, ${version}`)
|
||||
Reference in new issue
Block a user