From 1642f47908c6c36892f1322c357a53092e6db325 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Mon, 4 May 2026 21:36:17 -0400 Subject: [PATCH] test: align registry wiring assertions with declarative assembly --- tests/bug-2492-context-coverage-gate.test.cjs | 11 +++---- ...sd-sdk-query-registry-integration.test.cjs | 29 +++++++------------ 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/tests/bug-2492-context-coverage-gate.test.cjs b/tests/bug-2492-context-coverage-gate.test.cjs index cee82a61d..658702285 100644 --- a/tests/bug-2492-context-coverage-gate.test.cjs +++ b/tests/bug-2492-context-coverage-gate.test.cjs @@ -27,6 +27,7 @@ const CONFIG_MUTATION_TS = path.join(__dirname, '..', 'sdk', 'src', 'query', 'co const CONFIG_SCHEMA_TS = path.join(__dirname, '..', 'sdk', 'src', 'query', 'config-schema.ts'); const CONFIG_GATES_TS = path.join(__dirname, '..', 'sdk', 'src', 'query', 'config-gates.ts'); const QUERY_INDEX_TS = path.join(__dirname, '..', 'sdk', 'src', 'query', 'registry-assembly.ts'); +const QUERY_ASSEMBLY_DESCRIPTOR_TS = path.join(__dirname, '..', 'sdk', 'src', 'query', 'registry-assembly-descriptor.ts'); describe('plan-phase decision-coverage gate (#2492)', () => { const md = fs.readFileSync(PLAN_PHASE, 'utf-8'); @@ -170,10 +171,10 @@ describe('SDK wiring for #2492 gates', () => { test('query registry assembly registers the new handlers', () => { const c = fs.readFileSync(QUERY_INDEX_TS, 'utf-8'); - // Handlers are now registered through catalog-based registration. - assert.ok(c.includes('VERIFY_DECISION_STATIC_CATALOG'), 'decision-coverage-plan handler must be registered via the verify-decision catalog'); - assert.ok(c.includes('registerStaticCatalog(registry, VERIFY_DECISION_STATIC_CATALOG)'), 'check.decision-coverage-plan handler must be registered'); - assert.ok(c.includes('registerStaticCatalog(registry, VERIFY_DECISION_STATIC_CATALOG)'), 'check.decision-coverage-verify handler must be registered'); - assert.ok(c.includes('decisions.parse') || c.includes('VERIFY_DECISION_STATIC_CATALOG'), 'decisions.parse handler must be registered'); + const d = fs.readFileSync(QUERY_ASSEMBLY_DESCRIPTOR_TS, 'utf-8'); + assert.ok(c.includes('REGISTRY_ASSEMBLY_PLAN'), 'registry assembly must be driven by declarative plan'); + assert.ok(d.includes('VERIFY_DECISION_STATIC_CATALOG'), 'decision-coverage handlers must be sourced from verify-decision catalog'); + assert.ok(d.includes("{ kind: 'static', key: 'VERIFY_DECISION_STATIC_CATALOG' }"), 'verify-decision catalog must be present in assembly plan'); + assert.ok(d.includes('decisions.parse') || d.includes('VERIFY_DECISION_STATIC_CATALOG'), 'decisions.parse handler must be registered'); }); }); diff --git a/tests/gsd-sdk-query-registry-integration.test.cjs b/tests/gsd-sdk-query-registry-integration.test.cjs index cf146c29f..74be9f7fb 100644 --- a/tests/gsd-sdk-query-registry-integration.test.cjs +++ b/tests/gsd-sdk-query-registry-integration.test.cjs @@ -48,28 +48,21 @@ function collectRegisteredNames() { let m; while ((m = re.exec(src)) !== null) names.add(m[1]); - // Catalog-based registrations: extract handler names from registerStaticCatalog calls. - const catalogRe = /registerStaticCatalog\(registry, (\w+)\)/g; - let cm; - while ((cm = catalogRe.exec(src)) !== null) { - const catalogVarName = cm[1]; - // Map variable names to their source files. - const catalogFileByVar = { - FOUNDATION_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-foundation.ts'), - STATE_SUPPORT_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-foundation.ts'), - MUTATION_SURFACES_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-foundation.ts'), - VERIFY_DECISION_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-foundation.ts'), - DECISION_ROUTING_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-foundation.ts'), - DOMAIN_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-domain.ts'), - }; - const cf = catalogFileByVar[catalogVarName]; - if (!cf) continue; + // Catalog-based registrations: parse known static catalogs directly. + const catalogFileByVar = { + FOUNDATION_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-foundation.ts'), + STATE_SUPPORT_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-foundation.ts'), + MUTATION_SURFACES_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-foundation.ts'), + VERIFY_DECISION_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-foundation.ts'), + DECISION_ROUTING_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-foundation.ts'), + DOMAIN_STATIC_CATALOG: path.join(REPO_ROOT, 'sdk', 'src', 'query', 'command-static-catalog-domain.ts'), + }; + + for (const [catalogVarName, cf] of Object.entries(catalogFileByVar)) { try { const catSrc = fs.readFileSync(cf, 'utf8'); - // Only extract names from the catalog matching this variable. const exportRe = new RegExp(`export const ${catalogVarName}:`, 'm'); if (!exportRe.test(catSrc)) continue; - // Match: [[name, handler], ...] const entryRe = /\[\s*['"]([^'"]+)['"]/g; let em; while ((em = entryRe.exec(catSrc)) !== null) {