Skip to content

Add check-elemco-sync: guard the method registry against catalog drift - #53

Merged
dnkats merged 3 commits into
mainfrom
check-elemco-sync
Sep 3, 2026
Merged

Add check-elemco-sync: guard the method registry against catalog drift#53
dnkats merged 3 commits into
mainfrom
check-elemco-sync

Conversation

@dnkats

@dnkats dnkats commented Sep 1, 2026

Copy link
Copy Markdown
Member

What

js/elemco-methods.js is deliberately hand-maintained, so it can silently drift from the generated ElemCo.jl catalogs: a registry entry can point at a macro or option group that no longer exists in the pinned version, and new backend macros can stay unreachable from the UI without anyone noticing (e.g. the pending scf.stability/:search + UNO-CAS work will land as new scf options and macros).

scripts/check-elemco-sync.js makes the drift loud:

  • errors (exit 1): registry macro missing from elemco-macros.js; referenced option group/field missing from elemco-options.js; the two generated catalogs pinned to different ElemCo versions
  • warnings: catalog macros not surfaced by the registry (curation candidates; documented "Alias for @x" macros count as covered by the original)

Wired as npm run check-elemco-sync and chained onto both update-elemco-* scripts, so every catalog regeneration is checked automatically.

Testing

  • Passes clean on the current tree: 26 registry entries against 43 macros / 16 option groups @ v0.16.0 (the @ciϕ/@sci aliases of @ciphi are recognized as covered).
  • Negative test: injecting a dangling macro (@dfhf_gone) and a dangling group (nope) into a copy of the registry produces the two expected errors and exit 1.

🤖 Generated with Claude Code

… catalog drift

js/elemco-methods.js is deliberately hand-maintained, so it can silently drift
from the generated ElemCo.jl catalogs: a registry entry can point at a macro or
option group that no longer exists in the pinned version, and new backend
macros can stay unreachable from the UI unnoticed (e.g. the pending
scf.stability/:search + UNO-CAS work will land as new scf options and macros).

scripts/check-elemco-sync.js makes the drift loud:
- errors (exit 1): registry macro missing from elemco-macros.js; referenced
  option group/field missing from elemco-options.js; the two generated
  catalogs pinned to different ElemCo versions
- warnings: catalog macros not surfaced by the registry (curation candidates;
  documented "Alias for @x" macros count as covered by the original)

Wired as `npm run check-elemco-sync` and chained onto both update-elemco-*
scripts so every catalog regeneration is checked automatically. Currently
passes clean: 26 registry entries against 43 macros / 16 option groups
@ v0.16.0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 1, 2026 12:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Node-based consistency check to ensure the hand-maintained ElemCo method registry (js/elemco-methods.js) stays in sync with the generated ElemCo catalogs (js/elemco-macros.js, js/elemco-options.js), and wires it into the catalog update workflows.

Changes:

  • Introduces scripts/check-elemco-sync.js to validate macro and option-group references and report drift as errors/warnings.
  • Adds an npm run check-elemco-sync script and chains it after both update-elemco-* regeneration scripts.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/check-elemco-sync.js Adds the sync-checker CLI that loads the catalogs/registry and validates macros, option groups, and version pins.
package.json Registers check-elemco-sync and runs it automatically after ElemCo catalog regeneration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +81 to +89
for (const [gid, fields] of Object.entries(w.ELEMCO_GLOBAL_EXCLUDE || {})) {
checkGroup('ELEMCO_GLOBAL_EXCLUDE', gid);
const known = catalogGroups[gid] ? catalogGroups[gid].options : null;
for (const f of fields) {
if (known && !known[f]) {
errors.push(`ELEMCO_GLOBAL_EXCLUDE: field '${gid}.${f}' not in elemco-options.js (${w.ELEMCO_OPTIONS.sourceRef})`);
}
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 8e9e616: groups carry fields, so known was always null. Verified by injecting a bogus excluded field: passed before the fix, exits 1 with ELEMCO_GLOBAL_EXCLUDE: field 'wf.bogus_field' not in elemco-options.js after.

Comment thread scripts/check-elemco-sync.js Outdated
Comment on lines +30 to +43
const fs = require('fs');
const path = require('path');

const JS_DIR = path.join(__dirname, '..', 'js');

// The catalog files assign to `window.*`; elemco-methods.js declares consts and
// copies them onto `window` when present. Evaluate all three against one shared
// fake window and read everything back from it.
global.window = {};
for (const f of ['elemco-macros.js', 'elemco-options.js', 'elemco-methods.js']) {
// eslint-disable-next-line no-eval
eval(fs.readFileSync(path.join(JS_DIR, f), 'utf8'));
}
const w = global.window;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8e9e616: the three catalog files now run via vm.runInContext in a context whose only global is the fake window; nothing from this process's globals is visible to them.

dnkats and others added 2 commits September 3, 2026 07:39
Both from Copilot's review of #53:

- The ELEMCO_GLOBAL_EXCLUDE field check was dead: catalog groups keep
  their options under `fields`, so `known` was always null and a bogus
  excluded field passed silently. Verified by injecting `wf.bogus_field`
  before (OK) and after (ERROR, exit 1).
- The three catalog files ran under eval() in this process's global
  scope. They now run in a vm context whose only global is the fake
  `window`; the script reads everything back from that.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Dependabot alert #15, high: host confusion via skipped IDN canonicalization
on scheme-relative references. Transitive dev dependency only
(electron-builder -> app-builder-lib -> ajv -> fast-uri), so build-time,
not shipped. npm audit clean afterwards; no other package moved.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dnkats
dnkats merged commit 6b5259e into main Sep 3, 2026
1 check passed
@dnkats
dnkats deleted the check-elemco-sync branch September 3, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants