Skip to content

fix(ztd-cli): wire traditional QuerySpec runner#793

Merged
mk3008 merged 3 commits into
mainfrom
789-wire-ztd-cli-traditional-test-lane-to-a-supported-mode-switching-runner
Apr 29, 2026
Merged

fix(ztd-cli): wire traditional QuerySpec runner#793
mk3008 merged 3 commits into
mainfrom
789-wire-ztd-cli-traditional-test-lane-to-a-supported-mode-switching-runner

Conversation

@mk3008
Copy link
Copy Markdown
Owner

@mk3008 mk3008 commented Apr 28, 2026

Summary

Customer Value

Users can generate and run traditional QuerySpec tests as a real supported mode-switching lane, alongside the existing ZTD rewritten lane. The scaffold now makes the traditional path reviewable and executable instead of requiring users to invent local harness glue.

Acceptance Criteria

  • done: ztd feature tests scaffold --test-kind traditional generates an active traditional entrypoint.
  • done: the shared template harness supports explicit mode: "ztd" and mode: "traditional" execution.
  • done: traditional cases execute against physical DB setup without ZTD SQL rewriting and expose evidence that confirms the selected mode.
  • done: generated docs and template docs describe the traditional runner contract and afterDb support.
  • done: the prior package test failure from missing dotenv is fixed by adding the dependency where ztd-cli tests import starter template support.
  • done: recurrence prevention is strengthened so failed required verification commands stay in scope until proven otherwise.

Additional Hardening

  • Added guardrails to AGENTS.md and the local review, verification, and reporting agents so required-check failures cannot be dismissed as unrelated solely because the stack trace points outside touched files.
  • Fixed root pnpm test failures discovered by the pre-commit hook:
    • testkit-core now imports afterEach explicitly instead of relying on Vitest globals.
    • perf DDL inventory skips comment-only DDL placeholders.
    • test-evidence Git subprocesses strip Git local environment variables before materializing worktrees.

Verification

  • passed: pnpm --filter @rawsql-ts/ztd-cli test -- featureTestsScaffold.unit.test.ts ztdVerifier.unit.test.ts init.command.test.ts directoryFinding.docs.test.ts
  • passed: pnpm --filter @rawsql-ts/ztd-cli build
  • passed: pnpm --filter @rawsql-ts/ztd-cli test -- repoGuidance.unit.test.ts
  • passed: pnpm --filter @rawsql-ts/ztd-cli test
  • passed: pnpm test -- packages/testkit-core/tests/SelectFixtureRewriter.test.ts packages/ztd-cli/tests/commandTelemetry.unit.test.ts packages/ztd-cli/tests/testEvidence.unit.test.ts packages/ztd-cli/tests/perfSandbox.unit.test.ts
  • passed: pnpm --filter @rawsql-ts/ztd-cli test -- commandTelemetry.unit.test.ts perfSandbox.unit.test.ts
  • passed: pnpm test -- packages/ztd-cli/tests/testEvidence.unit.test.ts
  • passed: pnpm --filter @rawsql-ts/ztd-cli test -- testEvidence.unit.test.ts
  • passed: pre-commit hook on commit eb89983c
    • pnpm typecheck
    • pnpm test (350 passed, 3116 passed | 8 skipped)
    • pnpm build
    • pnpm lint

Note: package-level ztd-cli full test output still reports DB-dependent CLI tests skipped when pg_dump is not on PATH; the command exits successfully under the repository's existing skip behavior.

Merge Readiness

  • No baseline exception requested.
  • Baseline exception requested and linked below.

Tracking issue: not needed; no baseline exception requested.
Scoped checks run: not needed; no baseline exception requested.
Why full baseline is not required: full baseline exception path not used for this PR.

Self Review

Self-review workflow: repo-local self-review skill and global self-review skill two-cycle passes completed before updating this PR.
Self-review result: no unresolved blockers; review nits addressed or intentionally scoped with CI-backed guardrails.

CLI Surface Migration

  • No migration packet required for this CLI change.
  • CLI/user-facing surface change and migration packet completed.

No-migration rationale: not selected for this PR.
Upgrade note: ztd feature tests scaffold --test-kind traditional now emits an active traditional QuerySpec test entrypoint backed by isolated physical database setup.
Deprecation/removal plan or issue: no deprecation or removal; this completes the existing traditional mode path requested in #789.
Docs/help/examples updated: ztd-cli README and template README files now describe traditional mode, physical setup, evidence, and optional afterDb assertions.
Release/changeset wording: .changeset/traditional-runner-mode.md records a patch release for the traditional QuerySpec runner wiring.

Scaffold Contract Proof

  • No scaffold contract proof required for this PR.
  • Scaffold contract proof completed.

No-proof rationale: not selected for this PR.
Non-edit assertion: featureTestsScaffold.unit.test.ts keeps the scaffold assertions focused on generated query-local files and does not require parent boundary edits for the traditional lane.
Fail-fast input-contract proof: existing scaffold input-contract coverage remains in featureTestsScaffold.unit.test.ts, including invalid feature/query layout cases; this PR extends the generated mode contract without weakening those checks.
Generated-output viability proof: featureTestsScaffold.unit.test.ts asserts active traditional entrypoint imports, generated traditional case types, mode evidence, and physicalSetupUsed evidence; ztdVerifier.unit.test.ts exercises the physical traditional runner and optional afterDb.

Open Questions

None.

Merge Blockers

None known.

@mk3008 mk3008 linked an issue Apr 28, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Warning

Rate limit exceeded

@mk3008 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 16 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 63433778-7e6b-45c7-b3d2-a238220017b0

📥 Commits

Reviewing files that changed from the base of the PR and between eb89983 and b314211.

📒 Files selected for processing (14)
  • .agents/skills/pr-readiness/SKILL.md
  • .github/pull_request_template.md
  • .husky/pre-commit
  • AGENTS.md
  • docs/guide/release-readiness.md
  • packages/ztd-cli/src/commands/featureTests.ts
  • packages/ztd-cli/src/perf/sandbox.ts
  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/templates/tests/support/ztd/verifier.ts
  • packages/ztd-cli/tests/featureTestsScaffold.unit.test.ts
  • packages/ztd-cli/tests/perfSandbox.unit.test.ts
  • packages/ztd-cli/tests/prReadiness.unit.test.ts
  • scripts/check-pr-readiness.js
  • scripts/prepare-pr-readiness.js
📝 Walkthrough

Walkthrough

This PR implements the "traditional" test execution mode for ztd-cli's query boundary tests, enabling physical database schema setup and fixture seeding as an alternative to CTE-based fixture rewriting. The traditional runner accepts case inputs matching ZTD shape, optionally supports post-state assertions via afterDb, and records execution evidence marked with mode: 'traditional' and physicalSetupUsed: true. Scaffolding now generates active test entrypoints instead of placeholders, and verification rules for failure classification are tightened across agent documentation.

Changes

Cohort / File(s) Summary
Agent & Policy Documentation
AGENTS.md, .codex/agents/reporting.md, .codex/agents/review.md, .codex/agents/verification.md
Tightened verification failure classification rules: required command failures now assumed branch-isolated unless explicit evidence (base-branch reproduction, repo guidance, or unavailable external prerequisite) contradicts this; failures cannot be deprioritized solely by stack trace location or file scope.
Type System & Case Definitions
packages/ztd-cli/templates/tests/support/ztd/case-types.ts
Refactored QuerySpecZtdCase to a base QuerySpecCase with optional afterDb field; introduced QuerySpecTraditionalCase alias for full shape; preserved backward compatibility for existing ZtdCase references.
Harness & Test Runner
packages/ztd-cli/templates/tests/support/ztd/harness.ts
Added mode-switching dispatcher: runQuerySpecCases with optional mode parameter, new runQuerySpecTraditionalCases function, and QuerySpecRunnerOptions interface; expanded re-exports to include traditional case types.
Traditional Verification Implementation
packages/ztd-cli/templates/tests/support/ztd/verifier.ts
Introduced verifyQuerySpecTraditionalCase function that physically creates temporary Postgres schemas from starter DDL, seeds fixtures, rewrites schema-qualified SQL, supports afterDb assertions, and returns evidence marked mode: 'traditional' and physicalSetupUsed: true; added PhysicalQuerySpecExecutorClient for schema-rewriting SQL execution.
CLI Scaffolding Generation
packages/ztd-cli/src/commands/featureTests.ts
Updated traditional lane scaffolding to emit active Vitest entrypoints calling runQuerySpecTraditionalCases(cases, executor) with evidence assertions; changed generated diagnostic text from "lane skipped" to active execution guidance; updated case typing to use shared QuerySpecTraditionalCase; changed verifier target to tests/support/ztd/harness.ts#runQuerySpecTraditionalCases.
Git Environment Sanitization
packages/ztd-cli/src/commands/testEvidence.ts
Modified runGitCommand to clone process.env and remove Git-local override variables (worktree, config, object directory) via new withoutGitLocalEnv helper, preventing Git subprocess interference from injected parent environment.
SQL Parsing Resilience
packages/ztd-cli/src/perf/sandbox.ts
Added parseOptionalDdlStatement helper that tolerates empty/invalid SQL inputs by catching "No SQL statements found" errors specifically; inspectPerfDdlInventory and loadTableDefinitions now continue iteration instead of throwing on empty chunks.
Documentation & Guidance
packages/ztd-cli/README.md, packages/ztd-cli/templates/README.md, packages/ztd-cli/templates/tests/support/ztd/README.md
Added traditional mode guidance: explain --test-kind traditional scaffold behavior, physical DDL/fixture setup, optional afterDb assertions, evidence expectations (mode=traditional, physicalSetupUsed=true); generalized Vitest entrypoint references from fixed .boundary.ztd.test.ts to parameterized .boundary.<kind>.test.ts.
Unit Test Coverage
packages/ztd-cli/tests/featureTestsScaffold.unit.test.ts, packages/ztd-cli/tests/ztdVerifier.unit.test.ts
Extended traditional lane tests to validate active entrypoint generation with runQuerySpecTraditionalCases invocation, evidence metadata assertions (mode: 'traditional', physicalSetupUsed: true), schema/fixture/cleanup mock interactions, and TEST_PLAN correctness.
Additional Test Coverage
packages/ztd-cli/tests/perfSandbox.unit.test.ts, packages/ztd-cli/tests/testEvidence.unit.test.ts
Added tests for comment-only DDL files and Git environment sanitization; wrapped runTestEvidencePr invocations with temporary GIT_INDEX_FILE manipulation to isolate environment state.
Misc Configuration & Baseline
.changeset/traditional-runner-mode.md, packages/testkit-core/tests/SelectFixtureRewriter.test.ts, packages/ztd-cli/package.json
Changeset entry for traditional runner patch release; added missing afterEach import in Vitest; added dotenv dev dependency.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Vitest Test
    participant Harness as runQuerySpecTraditionalCases
    participant Verifier as verifyQuerySpecTraditionalCase
    participant Executor as PhysicalQuerySpecExecutorClient
    participant DB as Postgres DB

    Test->>Harness: call(cases, executor)
    Harness->>Verifier: for each case
    Verifier->>DB: CREATE TEMP SCHEMA
    Verifier->>DB: LOAD starter DDL
    Verifier->>DB: INSERT fixture rows
    Verifier->>Executor: initialize with temp schema
    Executor->>DB: EXECUTE query (rewritten to temp schema)
    Executor->>DB: RECORD trace entries
    alt case.afterDb provided
        Executor->>DB: assertAfterDb (table/row matching)
    end
    Verifier->>DB: DROP TEMP SCHEMA
    Verifier->>Harness: return Evidence (mode: 'traditional', physicalSetupUsed: true)
    Harness->>Test: []QuerySpecExecutionEvidence
    Test->>Test: assert mode === 'traditional' && physicalSetupUsed === true
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • #720: Introduced initial ZTD harness and verifier pattern that this PR extends with traditional mode support via the same template structure and architectural approach.
  • #772: Previously introduced the --test-kind traditional scaffold flag and placeholder generation that this PR now wires to an active, functional runner.
  • #738: Parallels this PR's agent policy tightening by refining failure-reporting and verification rules across AGENTS.md and related codex guidance documents.

Poem

🐰 The tests hop forth with dual-mode cheer—
Traditional schemas now crystal clear!
No CTE shadows, just fixtures laid true,
Physical tables in isolation grew.
afterDb whispers what changed in the state,
A harness that switches makes both modes first-rate! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: wiring the traditional QuerySpec runner, which is the primary objective of this PR.
Linked Issues check ✅ Passed The PR addresses all acceptance criteria from #789: provides a supported mode-switching runner, generates active traditional entrypoints, supports optional afterDb assertions, physically prepares DB state, records mode-specific evidence, maintains ZTD backward compatibility, and updates generated docs.
Out of Scope Changes check ✅ Passed All changes directly support the PR objectives: traditional runner implementation, template updates, test scaffolding, hardening of verification/reporting agents, fixes for testkit-core imports and perf DDL handling, and Git environment variable cleanup for test-evidence.
Description check ✅ Passed The pull request description is comprehensive and well-structured, covering all required template sections with detailed information about changes, verification, merge readiness, CLI surface migration, and scaffold contract proof.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 789-wire-ztd-cli-traditional-test-lane-to-a-supported-mode-switching-runner

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 27 minutes and 16 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/ztd-cli/src/commands/featureTests.ts (1)

1-1: ⚠️ Potential issue | 🟠 Major

Pipeline failure: Missing "## CLI Surface Migration" section.

The PR check failed with: Missing "## CLI Surface Migration" section for a CLI-facing change. This is a required merge gate per the pipeline output. The PR modifies --test-kind traditional behavior from placeholder to active execution, which qualifies as a CLI surface change requiring documentation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ztd-cli/src/commands/featureTests.ts` at line 1, The PR is missing
the required "## CLI Surface Migration" section for a CLI-facing change; add
that section to the PR description (or changelog) documenting the behavioral
change to --test-kind traditional introduced by edits in
packages/ztd-cli/src/commands/featureTests.ts, explain the new active execution
behavior (previously a placeholder), list migration steps or opt-in/opt-out
flags, show example CLI invocations that demonstrate the new default and any
flags affected (e.g., --test-kind traditional), and call out any
backward-compatibility considerations so the pipeline gate recognizes the change
as documented.
🧹 Nitpick comments (4)
packages/ztd-cli/templates/tests/support/ztd/verifier.ts (1)

269-334: Verify resource cleanup on partial setup failure.

In createPhysicalQuerySpecExecutor, if an error occurs during DDL application or fixture seeding (lines 280-283), the catch block drops the schema, releases client, and ends pool. However, if dropPhysicalSchema itself fails, client.release() may not execute.

Consider wrapping cleanup in try-finally:

🔒 Proposed hardening for cleanup
   } catch (error) {
-    await dropPhysicalSchema(client, schemaName);
-    client.release();
-    await pool.end();
+    try {
+      await dropPhysicalSchema(client, schemaName);
+    } finally {
+      client.release();
+      await pool.end();
+    }
     throw error;
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ztd-cli/templates/tests/support/ztd/verifier.ts` around lines 269 -
334, The catch block in createPhysicalQuerySpecExecutor can fail to release
resources if dropPhysicalSchema throws; update the catch to ensure
client.release() and pool.end() always run by wrapping the dropPhysicalSchema
call in its own try/catch or using try { await dropPhysicalSchema(...); }
finally { client.release(); await pool.end(); } then rethrow the original error;
reference the catch inside createPhysicalQuerySpecExecutor and the cleanup
helpers dropPhysicalSchema, client.release, and pool.end to locate where to
apply this change.
packages/ztd-cli/templates/README.md (1)

67-67: Consider breaking the AI prompt paragraph for readability.

Line 67 packs substantial information (scaffold command, test-kind options, evidence expectations, entrypoint naming) into a single dense paragraph. While AI prompts benefit from completeness, this could be restructured with line breaks or bullet points to improve human scannability when reviewing or modifying the prompt.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ztd-cli/templates/README.md` at line 67, The README paragraph around
the "ztd feature tests scaffold" command is overly dense; split it into clearer
lines or bullets so each concept is scannable — separate the scaffold command
invocation (`ztd feature tests scaffold --feature <feature-name>`), what files
are generated or kept (`src/features/.../tests/generated/TEST_PLAN.md`,
`analysis.json`, `generated/*`, thin entrypoint `*.boundary.ztd.test.ts`,
persistent `cases/`), the `--test-kind traditional` guidance and when to use it,
where to get fixture metadata
(`.ztd/generated/ztd-fixture-manifest.generated.ts`) and what `beforeDb`
returns, the evidence fields (`mode`, `rewriteApplied`, `physicalSetupUsed`) and
expected values for ZTD vs traditional runs, and the optional SQL trace env vars
(`ZTD_SQL_TRACE`, `ZTD_SQL_TRACE_DIR`) plus how to run the final entrypoint
(`npx vitest run`); reorganize into short bullets or separate sentences so each
symbol/path/option from the paragraph is its own readable item.
packages/ztd-cli/tests/featureTestsScaffold.unit.test.ts (1)

432-454: afterDb の生成ケース実体にも直接アサートを追加するとさらに堅くなります。

型・TEST_PLAN 文言は検証されていますが、cases/basic.traditional.case.ts 側の実体に afterDb が入ることを直接固定しておくと、テンプレート退行をより早く検知できます。

Diff suggestion
   const traditionalTypes = readFileSync(
     path.join(featureDir, 'queries', 'insert-users', 'tests', 'boundary-traditional-types.ts'),
     'utf8'
   );
   expect(traditionalTypes).toContain("import type { QuerySpecTraditionalCase } from '../../../../../../tests/support/ztd/case-types.js';");
   expect(traditionalTypes).toContain('export type InsertUsersQueryBoundaryTraditionalCase = QuerySpecTraditionalCase<');
+
+  const traditionalCaseFile = readFileSync(
+    path.join(featureDir, 'queries', 'insert-users', 'tests', 'cases', 'basic.traditional.case.ts'),
+    'utf8'
+  );
+  expect(traditionalCaseFile).toContain('afterDb');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ztd-cli/tests/featureTestsScaffold.unit.test.ts` around lines 432 -
454, Add an assertion that the generated case file
(cases/basic.traditional.case.ts) actually contains the afterDb callback to
catch template regressions: read the file at path.join(featureDir, 'queries',
'insert-users', 'tests', 'cases', 'basic.traditional.case.ts') and expect its
contents toContain a clear afterDb marker (e.g. "afterDb" or the exact snippet
used by the template), similar to the existing checks for
boundary-traditional-types.ts, analysis.traditional.json and
TEST_PLAN.traditional.md, so the test fails if the template stops emitting
afterDb.
packages/ztd-cli/src/perf/sandbox.ts (1)

204-210: String matching on SqlParser error messages is fragile, but requires upstream changes to improve.

Line 209 uses message.includes('[SqlParser] No SQL statements found in input.') to distinguish this specific error from other parse failures. While the concern about message-based matching is valid, SqlParser.parse() currently exposes only plain Error objects without stable error codes or custom error classes. No error type or code property is available for type-safe discrimination.

To address this properly would require either:

  1. Contributing to SqlParser to expose error codes or custom error classes (e.g., class NoStatementsError extends Error { code = 'NO_SQL_STATEMENTS' })
  2. Adding a validation method to SqlParser like hasStatements(sql: string): boolean

For now, consider adding a comment above the string check explaining why it's necessary as a workaround, and document the fragility. If this pattern becomes common across the codebase, it would be worth advocating for stable error handling in SqlParser.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ztd-cli/src/perf/sandbox.ts` around lines 204 - 210, The current
string-match on SqlParser.parse error messages in parseOptionalDdlStatement is
fragile; add a short explanatory comment immediately above the check that
documents why message.includes('[SqlParser] No SQL statements found in input.')
is required as a temporary workaround (SqlParser only throws plain Error and has
no error codes/classes or a hasStatements helper), note the fragility and
recommend upstream fixes (error codes or custom error classes/have a
hasStatements method) for future refactors, and leave the existing conditional
behavior unchanged until SqlParser is improved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/ztd-cli/README.md`:
- Around line 192-194: The PR is blocked by the check-pr-readiness required
check because CLI-facing changes (e.g., the new behavior described for `ztd
feature tests scaffold --test-kind traditional` in README.md) lack the mandated
PR checklist items; update the PR description to add the missing "## CLI Surface
Migration" and "## Scaffold Contract Proof" sections and mark the required
checkboxes (or otherwise satisfy the `check-pr-readiness` criteria) so the
pipeline passes and the PR can be merged.

---

Outside diff comments:
In `@packages/ztd-cli/src/commands/featureTests.ts`:
- Line 1: The PR is missing the required "## CLI Surface Migration" section for
a CLI-facing change; add that section to the PR description (or changelog)
documenting the behavioral change to --test-kind traditional introduced by edits
in packages/ztd-cli/src/commands/featureTests.ts, explain the new active
execution behavior (previously a placeholder), list migration steps or
opt-in/opt-out flags, show example CLI invocations that demonstrate the new
default and any flags affected (e.g., --test-kind traditional), and call out any
backward-compatibility considerations so the pipeline gate recognizes the change
as documented.

---

Nitpick comments:
In `@packages/ztd-cli/src/perf/sandbox.ts`:
- Around line 204-210: The current string-match on SqlParser.parse error
messages in parseOptionalDdlStatement is fragile; add a short explanatory
comment immediately above the check that documents why
message.includes('[SqlParser] No SQL statements found in input.') is required as
a temporary workaround (SqlParser only throws plain Error and has no error
codes/classes or a hasStatements helper), note the fragility and recommend
upstream fixes (error codes or custom error classes/have a hasStatements method)
for future refactors, and leave the existing conditional behavior unchanged
until SqlParser is improved.

In `@packages/ztd-cli/templates/README.md`:
- Line 67: The README paragraph around the "ztd feature tests scaffold" command
is overly dense; split it into clearer lines or bullets so each concept is
scannable — separate the scaffold command invocation (`ztd feature tests
scaffold --feature <feature-name>`), what files are generated or kept
(`src/features/.../tests/generated/TEST_PLAN.md`, `analysis.json`,
`generated/*`, thin entrypoint `*.boundary.ztd.test.ts`, persistent `cases/`),
the `--test-kind traditional` guidance and when to use it, where to get fixture
metadata (`.ztd/generated/ztd-fixture-manifest.generated.ts`) and what
`beforeDb` returns, the evidence fields (`mode`, `rewriteApplied`,
`physicalSetupUsed`) and expected values for ZTD vs traditional runs, and the
optional SQL trace env vars (`ZTD_SQL_TRACE`, `ZTD_SQL_TRACE_DIR`) plus how to
run the final entrypoint (`npx vitest run`); reorganize into short bullets or
separate sentences so each symbol/path/option from the paragraph is its own
readable item.

In `@packages/ztd-cli/templates/tests/support/ztd/verifier.ts`:
- Around line 269-334: The catch block in createPhysicalQuerySpecExecutor can
fail to release resources if dropPhysicalSchema throws; update the catch to
ensure client.release() and pool.end() always run by wrapping the
dropPhysicalSchema call in its own try/catch or using try { await
dropPhysicalSchema(...); } finally { client.release(); await pool.end(); } then
rethrow the original error; reference the catch inside
createPhysicalQuerySpecExecutor and the cleanup helpers dropPhysicalSchema,
client.release, and pool.end to locate where to apply this change.

In `@packages/ztd-cli/tests/featureTestsScaffold.unit.test.ts`:
- Around line 432-454: Add an assertion that the generated case file
(cases/basic.traditional.case.ts) actually contains the afterDb callback to
catch template regressions: read the file at path.join(featureDir, 'queries',
'insert-users', 'tests', 'cases', 'basic.traditional.case.ts') and expect its
contents toContain a clear afterDb marker (e.g. "afterDb" or the exact snippet
used by the template), similar to the existing checks for
boundary-traditional-types.ts, analysis.traditional.json and
TEST_PLAN.traditional.md, so the test fails if the template stops emitting
afterDb.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bceed848-5752-45c8-a471-1f0cb1a83665

📥 Commits

Reviewing files that changed from the base of the PR and between 0f52781 and eb89983.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (20)
  • .changeset/traditional-runner-mode.md
  • .codex/agents/reporting.md
  • .codex/agents/review.md
  • .codex/agents/verification.md
  • AGENTS.md
  • packages/testkit-core/tests/SelectFixtureRewriter.test.ts
  • packages/ztd-cli/README.md
  • packages/ztd-cli/package.json
  • packages/ztd-cli/src/commands/featureTests.ts
  • packages/ztd-cli/src/commands/testEvidence.ts
  • packages/ztd-cli/src/perf/sandbox.ts
  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/templates/tests/support/ztd/README.md
  • packages/ztd-cli/templates/tests/support/ztd/case-types.ts
  • packages/ztd-cli/templates/tests/support/ztd/harness.ts
  • packages/ztd-cli/templates/tests/support/ztd/verifier.ts
  • packages/ztd-cli/tests/featureTestsScaffold.unit.test.ts
  • packages/ztd-cli/tests/perfSandbox.unit.test.ts
  • packages/ztd-cli/tests/testEvidence.unit.test.ts
  • packages/ztd-cli/tests/ztdVerifier.unit.test.ts

Comment on lines +192 to +194
`ztd feature tests scaffold --test-kind traditional` creates an active `.boundary.traditional.test.ts` entrypoint that calls the shared mode runner.
Traditional cases keep the same `beforeDb`, `input`, and `output` shape and can add optional `afterDb` assertions.
The traditional runner physically prepares DDL and fixture rows, then reports `mode=traditional` and `physicalSetupUsed=true`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

PR merge gate が未解消です(check-pr-readiness の required failure)。

Line 192 以降の CLI-facing 変更に対して、パイプライン上で ## CLI Surface Migration / ## Scaffold Contract Proof の欠落とチェックボックス未選択が報告されています。コード変更とは別に、PR本文の必須項目を満たさない限りマージ準備完了にはできません。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ztd-cli/README.md` around lines 192 - 194, The PR is blocked by the
check-pr-readiness required check because CLI-facing changes (e.g., the new
behavior described for `ztd feature tests scaffold --test-kind traditional` in
README.md) lack the mandated PR checklist items; update the PR description to
add the missing "## CLI Surface Migration" and "## Scaffold Contract Proof"
sections and mark the required checkboxes (or otherwise satisfy the
`check-pr-readiness` criteria) so the pipeline passes and the PR can be merged.

@mk3008 mk3008 merged commit 6597a53 into main Apr 29, 2026
10 checks passed
@mk3008 mk3008 deleted the 789-wire-ztd-cli-traditional-test-lane-to-a-supported-mode-switching-runner branch April 29, 2026 01:37
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.

Wire ztd-cli traditional test lane to a supported mode-switching runner

1 participant