From d752eed88b2a4777856d0439839a749cd74d6806 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Sat, 4 Jul 2026 19:18:11 +0800 Subject: [PATCH] Cover the remaining gate guards with focused tests Codex review: the RFC claims the fixtures prove each guard fires, but the binding-pattern guards (events + services), the service no-prose branch, and the empty-@param/@returns-description branches had no focused tests. Add the five missing cases; every violation branch in the generator now has a matching fixture. --- .../agent/tests/gen-cordis-catalog.spec.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/core/agent/tests/gen-cordis-catalog.spec.ts b/packages/core/agent/tests/gen-cordis-catalog.spec.ts index 2d8cd7764f..9eac8587a4 100644 --- a/packages/core/agent/tests/gen-cordis-catalog.spec.ts +++ b/packages/core/agent/tests/gen-cordis-catalog.spec.ts @@ -134,6 +134,12 @@ describe('gen-cordis-catalog collectEvents', () => { expect(events).toHaveLength(1) }) + it('hard-errors on a binding-pattern parameter @param cannot name', () => { + expect(() => collectEvents(make( + ' /**\n * A thing happened.\n * @mode emit\n */\n \'fix/destructured\'({ id }: { id: string }): void', + ))).toThrow(/is a binding pattern/) + }) + it('aggregates every violation into one error instead of failing fast', () => { expect(() => collectEvents(make( ' /** First. */\n \'fix/one\'(): void\n /** Second. */\n \'fix/two\'(): void', @@ -201,6 +207,30 @@ export class FixService { ))).toThrow(/@param ghost does not match any parameter/) }) + it('hard-errors on a method whose JSDoc is tags with no description prose', () => { + expect(() => collectServices(makeService( + '/** Fixture service. */\nexport class FixService {\n /**\n * @param id - which thing.\n * @returns the outcome.\n */\n run(id: string): string { return id }\n}', + ))).toThrow(/no description prose above its block tags/) + }) + + it('hard-errors on a method @param with an empty description', () => { + expect(() => collectServices(makeService( + '/** Fixture service. */\nexport class FixService {\n /**\n * Fire and forget.\n * @param id\n */\n poke(id: string): void {}\n}', + ))).toThrow(/@param id has an empty description/) + }) + + it('hard-errors on an @returns with an empty description', () => { + expect(() => collectServices(makeService( + '/** Fixture service. */\nexport class FixService {\n /**\n * Do the thing.\n * @param id - which thing.\n * @returns\n */\n run(id: string): string { return id }\n}', + ))).toThrow(/@returns has an empty description/) + }) + + it('hard-errors on a binding-pattern method parameter @param cannot name', () => { + expect(() => collectServices(makeService( + '/** Fixture service. */\nexport class FixService {\n /**\n * Do the thing.\n */\n run({ id }: { id: string }): void {}\n}', + ))).toThrow(/is a binding pattern/) + }) + it('ignores private/protected/static members (not the ctx. surface)', () => { const services = collectServices(makeService( '/** Fixture service. */\nexport class FixService {\n private hidden(id: string): string { return id }\n protected hook(): void {}\n static helper(): void {}\n}',