From b3971aefa5cff300513ca74241e872dfa7a44f9b Mon Sep 17 00:00:00 2001 From: FilipBl4gojevic <84703395+FilipBl4gojevic@users.noreply.github.com> Date: Mon, 27 Jul 2026 17:08:11 +0200 Subject: [PATCH] test: use strict equality for schema snapshot comparisons A test whose job is catching subtle JSON-serializer drift should not use loose comparison - deepEqual would pass a string 1 against a numeric 1. Also documents the zod/v4 isSchemaOptional() quirk on bare .default() at the call site rather than only in a planning doc. --- src/vector/self-improvement.ts | 4 ++++ test/smoke/tool-inventory.test.ts | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vector/self-improvement.ts b/src/vector/self-improvement.ts index ea03207..bc5fc66 100644 --- a/src/vector/self-improvement.ts +++ b/src/vector/self-improvement.ts @@ -713,6 +713,10 @@ activity tracking token (\`pact_\`) minted. Visible on the Foundation dashboard. mnemonic: z.string().describe("15 or 24-word BIP39 mnemonic for the wallet"), agentDid: z.string().describe("Agent DID (hex)"), proposalTxHash: z.string().describe("TX hash of the proposal UTxO to critique"), + // Note: a bare .default() without .optional() is reported as *required* by the + // SDK's isSchemaOptional() under zod/v4 (it returned optional under v3). That + // helper is only used for server.prompt() argument listing, which this codebase + // does not use — harmless for server.tool(), but relevant if prompts are added. proposalOutputIndex: z.number().default(0).describe("Output index of the proposal UTxO"), critiqueDocument: z.string().optional().describe("Full critique document as JSON string. Uploaded to IPFS via Filebase; hash and CID computed automatically."), critiqueHash: z.string().optional().describe("blake2b_256 hash of critique document (64 hex chars). Required if critiqueDocument is not provided."), diff --git a/test/smoke/tool-inventory.test.ts b/test/smoke/tool-inventory.test.ts index 4f045cf..3d67c60 100644 --- a/test/smoke/tool-inventory.test.ts +++ b/test/smoke/tool-inventory.test.ts @@ -92,7 +92,7 @@ describe('tool inventory smoke test', () => { const added = actualNames.filter((name) => !EXPECTED_TOOLS.includes(name)); const removed = EXPECTED_TOOLS.filter((name) => !actualNames.includes(name)); - assert.deepEqual( + assert.deepStrictEqual( actualNames, EXPECTED_TOOLS, 'Tool inventory drifted from the checked-in snapshot in test/smoke/tool-inventory.test.ts.\n' + @@ -109,7 +109,7 @@ describe('tool schema snapshot', () => { const missingFromSnapshot = actualNames.filter((name) => !snapshotNames.includes(name)); const staleInSnapshot = snapshotNames.filter((name) => !actualNames.includes(name)); - assert.deepEqual( + assert.deepStrictEqual( snapshotNames, actualNames, 'test/smoke/tool-schemas.snapshot.json keys do not match the live tool set.\n' + @@ -119,7 +119,7 @@ describe('tool schema snapshot', () => { ); }); - // One assertion per tool (rather than a single deepEqual over the whole + // One assertion per tool (rather than a single deepStrictEqual over the whole // 23-tool map) so a failure names the specific tool and shows a readable // diff of just that tool's schema, instead of "objects differ" over an // unreadable combined structure. @@ -130,7 +130,7 @@ describe('tool schema snapshot', () => { live, `Tool "${toolName}" is in the snapshot but was not returned by the live server's listTools().` ); - assert.deepEqual( + assert.deepStrictEqual( live.inputSchema, schemaSnapshot[toolName], `inputSchema for "${toolName}" differs from the checked-in snapshot in test/smoke/tool-schemas.snapshot.json.\n` +