From a5e7ec45497932c8165f3ace48428bbde35400da Mon Sep 17 00:00:00 2001 From: DarkSky Date: Fri, 4 Dec 2026 17:13:18 +0900 Subject: [PATCH] ci(frontend): check 215 snapshot prefixes in production Wasm Add 38 snapshot prefixes for the collection editor, properties, header dialogs, overlays, and block controls to ZERO_IN_PRODUCTION after the existing 177 prefixes. Check that production playground and desktop Wasm files have zero matches, and add Section 11 unit tests. --- .../scripts/check-snapshot-prefixes.mjs | 38 ++++++ .../scripts/check-snapshot-prefixes.test.mjs | 119 ++++++++++++++++-- 2 files changed, 147 insertions(+), 10 deletions(-) diff --git a/packages/frontend/scripts/check-snapshot-prefixes.mjs b/packages/frontend/scripts/check-snapshot-prefixes.mjs index 80f10b5ab2..3621ef4b8e 100644 --- a/packages/frontend/scripts/check-snapshot-prefixes.mjs +++ b/packages/frontend/scripts/check-snapshot-prefixes.mjs @@ -197,6 +197,44 @@ export const ZERO_IN_PRODUCTION = Object.freeze([ 'page.status', 'page.table_area_selection', 'page.table_cell_caret', + '.attachment_card', + '.bookmark_card', + '.builtin.', + '.custom.menu.', + '.embed_activate', + '.embed_card', + '.embed_shield', + '.highlight_menu.background.', + '.hscrollbar', + '.image_card', + '.journal_next', + '.journal_previous', + '.journal_week', + '.links.', + '.tag.attached.', + '.tag.create', + '.tag.option.', + '.toolbar.copy', + '.toolbar.language', + 'desktop.collection_editor.count', + 'desktop.collection_editor.doc.', + 'desktop.collection_editor.filter.remove.', + 'desktop.collection_editor.include.remove.', + 'desktop.collection_editor.menu.item.', + 'desktop.collection_editor.rules.tips', + 'desktop.collection_editor.selected', + 'desktop.header.dialog.close.icon', + 'desktop.header.info.backlink.', + 'desktop.header.info.outgoing.', + 'desktop.header.trash.description', + 'desktop.header.trash.title', + 'desktop.inspector.outgoing.', + 'desktop.settings.appearance.language', + 'desktop.settings.storage.panel', + 'overlay.pdf_viewer.titlebar', + 'overlay.slash_menu.submenu', + 'page.database_cell_caret', + 'root.canvas', ]); const WASM_MAGIC = new Uint8Array([0x00, 0x61, 0x73, 0x6d]); diff --git a/packages/frontend/scripts/check-snapshot-prefixes.test.mjs b/packages/frontend/scripts/check-snapshot-prefixes.test.mjs index 4a67e8d606..2ab0a19d7f 100644 --- a/packages/frontend/scripts/check-snapshot-prefixes.test.mjs +++ b/packages/frontend/scripts/check-snapshot-prefixes.test.mjs @@ -158,6 +158,47 @@ const SNAPSHOT_RATCHET_ADDITIONS = [ 'page.table_cell_caret', ]; +const EXTENDED_SNAPSHOT_PREFIXES = [ + '.attachment_card', + '.bookmark_card', + '.builtin.', + '.custom.menu.', + '.embed_activate', + '.embed_card', + '.embed_shield', + '.highlight_menu.background.', + '.hscrollbar', + '.image_card', + '.journal_next', + '.journal_previous', + '.journal_week', + '.links.', + '.tag.attached.', + '.tag.create', + '.tag.option.', + '.toolbar.copy', + '.toolbar.language', + 'desktop.collection_editor.count', + 'desktop.collection_editor.doc.', + 'desktop.collection_editor.filter.remove.', + 'desktop.collection_editor.include.remove.', + 'desktop.collection_editor.menu.item.', + 'desktop.collection_editor.rules.tips', + 'desktop.collection_editor.selected', + 'desktop.header.dialog.close.icon', + 'desktop.header.info.backlink.', + 'desktop.header.info.outgoing.', + 'desktop.header.trash.description', + 'desktop.header.trash.title', + 'desktop.inspector.outgoing.', + 'desktop.settings.appearance.language', + 'desktop.settings.storage.panel', + 'overlay.pdf_viewer.titlebar', + 'overlay.slash_menu.submenu', + 'page.database_cell_caret', + 'root.canvas', +]; + /** * Encodes an unsigned integer as LEB128. * @@ -256,13 +297,29 @@ test('rejects bare snapshot container IDs in Wasm Data segments', () => { } }); -test('verifies all 177 live prefixes including desktop production sources', () => { - assert.equal(ZERO_IN_PRODUCTION.length, 177); - const addedPrefixes = ZERO_IN_PRODUCTION.slice(83); +test('verifies all 215 live prefixes including desktop production sources', () => { + assert.equal(ZERO_IN_PRODUCTION.length, 215); + const firstBatchAdditions = ZERO_IN_PRODUCTION.slice(83, 177); assert.deepEqual( - addedPrefixes, - [...addedPrefixes].sort(), - 'New snapshot prefixes must stay sorted lexicographically' + firstBatchAdditions, + SNAPSHOT_RATCHET_ADDITIONS, + 'Existing 177 prefixes must keep exact order' + ); + assert.deepEqual( + firstBatchAdditions, + [...firstBatchAdditions].sort(), + 'First ratchet batch must stay sorted lexicographically' + ); + const extendedAdditions = ZERO_IN_PRODUCTION.slice(177); + assert.deepEqual( + extendedAdditions, + EXTENDED_SNAPSHOT_PREFIXES, + 'Extended snapshot prefixes must match appended order' + ); + assert.deepEqual( + extendedAdditions, + [...extendedAdditions].sort(), + 'Extended snapshot prefixes must stay sorted lexicographically' ); assert.equal( new Set(ZERO_IN_PRODUCTION).size, @@ -281,7 +338,7 @@ test('verifies all 177 live prefixes including desktop production sources', () = } const additionSet = new Set(SNAPSHOT_RATCHET_ADDITIONS); for (const prefix of SNAPSHOT_RATCHET_ADDITIONS) { - for (const existing of ZERO_IN_PRODUCTION) { + for (const existing of ZERO_IN_PRODUCTION.slice(0, 177)) { if (existing === prefix) continue; assert.equal( prefix.startsWith(existing), @@ -297,18 +354,34 @@ test('verifies all 177 live prefixes including desktop production sources', () = } } } + for (const prefix of EXTENDED_SNAPSHOT_PREFIXES) { + for (const existing of ZERO_IN_PRODUCTION) { + if (existing === prefix) continue; + assert.equal( + prefix.startsWith(existing), + false, + `Redundant addition ${prefix} is already covered by ${existing}` + ); + assert.equal( + existing.startsWith(prefix), + false, + `Addition ${prefix} shadows existing prefix ${existing}` + ); + } + } const result = verifySourcePrefixes(); assert.equal( result.ok, true, `Missing prefixes in repo: ${result.missing.join(', ')}` ); - assert.equal(Object.keys(result.counts).length, 177); + assert.equal(Object.keys(result.counts).length, 215); for (const prefix of [ ...DESKTOP_PREFIXES, ...NEW_DESKTOP_PREFIXES, ...SIDEBAR_AND_PANEL_PREFIXES, ...SNAPSHOT_RATCHET_ADDITIONS, + ...EXTENDED_SNAPSHOT_PREFIXES, ]) { assert.ok( result.counts[prefix] >= 1, @@ -383,6 +456,7 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s ...NEW_DESKTOP_PREFIXES, ...SIDEBAR_AND_PANEL_PREFIXES, ...SNAPSHOT_RATCHET_ADDITIONS, + ...EXTENDED_SNAPSHOT_PREFIXES, ]) { const payload = `${prefix}item-1`; const wasm = buildWasm([buildPassiveDataSection([payload])]); @@ -399,12 +473,28 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s assert.deepEqual(result.hits, expectedHits); } + for (const prefix of EXTENDED_SNAPSHOT_PREFIXES) { + const splitAt = Math.floor(prefix.length / 2); + const splitWasm = buildWasm([ + buildPassiveDataSection([prefix.slice(0, splitAt), prefix.slice(splitAt)]), + ]); + const splitResult = scanWasmDataPrefixes(splitWasm); + assert.equal(splitResult.ok, true, `split segment: ${prefix}`); + assert.deepEqual(splitResult.hits, []); + } + const dir = mkdtempSync(join(tmpdir(), 'snapshot-prefix-desktop-wasm-')); try { for (const [sample, pattern] of [ ['desktop.qs.doc.doc-1', /desktop\.qs\.doc\./], ['desktop.inspector.frame.item.frame-1', /desktop\.inspector\.frame\.item\./], ['overlay.equation_editor.input', /overlay\.equation_editor\.input/], + ['desktop.collection_editor.doc.doc-1', /desktop\.collection_editor\.doc\./], + ['desktop.header.info.outgoing.doc-2', /desktop\.header\.info\.outgoing\./], + ['desktop.inspector.custom.menu.edit', /\.custom\.menu\./], + ['overlay.pdf_viewer.titlebar', /overlay\.pdf_viewer\.titlebar/], + ['page.database_cell_caret', /page\.database_cell_caret/], + ['root.canvas', /root\.canvas/], ]) { const badWasm = join(dir, 'bad.wasm'); writeFileSync(badWasm, buildWasm([buildPassiveDataSection([sample])])); @@ -416,7 +506,10 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s } const nonDataPayload = Buffer.from( - 'desktop.qs.doc.doc-1 desktop.qs.cmd.0 desktop.list.doc.a', + [ + 'desktop.qs.doc.doc-1 desktop.qs.cmd.0 desktop.list.doc.a', + ...EXTENDED_SNAPSHOT_PREFIXES, + ].join(' '), 'utf8' ); const cleanWasm = join(dir, 'clean.wasm'); @@ -437,6 +530,7 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s 'desktop.inspector.frame.present', 'desktop.inspector.frame.empty', 'desktop.inspector.frame.list', + 'desktop.inspector.tag.list', 'desktop.explorer.menu', 'desktop.sidebar', 'desktop.sidebar.settings', @@ -446,6 +540,11 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s 'desktop.settings.appearance.title', 'desktop.settings.appearance', 'desktop.collections.add', + 'desktop.collection_editor.filter.method', + 'desktop.collection_editor.include.toggle', + 'desktop.collection_editor.menu.rows', + 'desktop.workbench.topbar', + 'desktop.journals.create', ]), ]) ); @@ -453,7 +552,7 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s encoding: 'utf8', }); assert.equal(passRun.status, 0, passRun.stderr); - assert.match(passRun.stdout, /177\/177 prefixes at 0/); + assert.match(passRun.stdout, /215\/215 prefixes at 0/); } finally { rmSync(dir, { recursive: true, force: true }); }