Skip to content

feat(ztd-cli): add test-kind support for feature tests scaffold#772

Merged
mk3008 merged 2 commits intomainfrom
767-ztd-cli-traditional-test-kind-と-ztdtraditional-併存-scaffold-を後続拡張として設計する
Apr 15, 2026

Hidden character warning

The head ref may contain hidden characters: "767-ztd-cli-traditional-test-kind-\u3068-ztdtraditional-\u4f75\u5b58-scaffold-\u3092\u5f8c\u7d9a\u62e1\u5f35\u3068\u3057\u3066\u8a2d\u8a08\u3059\u308b"
Merged

feat(ztd-cli): add test-kind support for feature tests scaffold#772
mk3008 merged 2 commits intomainfrom
767-ztd-cli-traditional-test-kind-と-ztdtraditional-併存-scaffold-を後続拡張として設計する

Conversation

@mk3008
Copy link
Copy Markdown
Owner

@mk3008 mk3008 commented Apr 15, 2026

Summary

  • Add --test-kind <kind> to ztd feature tests scaffold with ztd as the default.
  • Implement lane-aware scaffold outputs for ztd and traditional so both can coexist under the same query tests directory.
  • Keep backward compatibility for existing ZTD-only workflows and add tests for traditional lane generation and invalid --test-kind fail-fast behavior.
  • Add a follow-up design guide and include release notes via changeset.

Verification

  • pnpm --filter @rawsql-ts/ztd-cli build
  • pnpm --filter @rawsql-ts/ztd-cli test -- featureTestsScaffold.unit.test.ts cliCommands.test.ts
  • pre-commit gate suite passed during commit (includes test:essential, build, lint)

Merge Readiness

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

Tracking issue:
Scoped checks run:
Why full baseline is not required:

CLI Surface Migration

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

No-migration rationale:
Upgrade note: ztd feature tests scaffold now accepts --test-kind ztd|traditional. Default remains ztd.
Deprecation/removal plan or issue: None. No existing flag or behavior was removed.
Docs/help/examples updated: Yes. CLI help coverage updated in packages/ztd-cli/tests/cliCommands.test.ts; follow-up plan linked from packages/ztd-cli/README.md.
Release/changeset wording: Added .changeset/fair-apes-tie.md as @rawsql-ts/ztd-cli minor.

Scaffold Contract Proof

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

No-proof rationale:
Non-edit assertion: Existing ZTD scaffold assets are preserved (<query>.boundary.ztd.test.ts, generated/TEST_PLAN.md, generated/analysis.json) and traditional lane files are generated as additional, lane-qualified artifacts.
Fail-fast input-contract proof: Unsupported --test-kind values fail fast with an explicit error (Feature test kind supports only ztd, traditional.), covered by unit test.
Generated-output viability proof: Traditional lane now generates *.boundary.traditional.test.ts, boundary-traditional-types.ts, cases/basic.traditional.case.ts, generated/TEST_PLAN.traditional.md, and generated/analysis.traditional.json, covered by unit test.

Closes #767

Summary by CodeRabbit

  • New Features

    • Added --test-kind CLI option for ztd feature tests scaffold, allowing users to select between ztd and traditional test scaffolding approaches. Defaults to ZTD for backward compatibility, with each mode generating appropriate scaffold outputs.
  • Documentation

    • Added guide describing the traditional lane follow-up expansion plan.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 47 minutes and 55 seconds.

⌛ 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: 8ab3f938-301d-4547-a167-c69554c54b31

📥 Commits

Reviewing files that changed from the base of the PR and between 595f86c and cadfdea.

📒 Files selected for processing (3)
  • docs/guide/ztd-cli-traditional-lane-followup-plan.md
  • packages/ztd-cli/src/commands/featureTests.ts
  • packages/ztd-cli/tests/featureTestsScaffold.unit.test.ts
📝 Walkthrough

Walkthrough

This PR implements design and support for a feature test "lane" selection mechanism in ztd-cli. It adds a new --test-kind CLI option to feature tests scaffold accepting ztd or traditional, with ztd as the default. The implementation includes updated types, lane-specific file generation (boundary entrypoints, types modules, generated artifacts, and case files), conditional CLI behavior, and comprehensive unit tests and documentation of the design plan.

Changes

Cohort / File(s) Summary
Documentation & Design
.changeset/fair-apes-tie.md, docs/guide/ztd-cli-traditional-lane-followup-plan.md, packages/ztd-cli/README.md
Added changeset for minor version bump; new comprehensive design plan for traditional lane expansion with CLI surface, scaffold layout, and responsibility boundaries; updated README to reference new guide.
Core Feature Implementation
packages/ztd-cli/src/commands/featureTests.ts
Added --test-kind <kind> CLI option with validation via new normalizeFeatureTestKind(). Updated types (FeatureTestsCommandOptions, FeatureTestsScaffoldResult, FeatureTestAnalysis) to carry testKind. Implemented lane-dependent file generation: boundary entrypoint (${queryName}.boundary.${testKind}.test.ts), types module (boundary-${testKind}-types.ts), generated artifacts (TEST_PLAN.${testKind}.md, analysis.${testKind}.json), and case files. Added conditional logic: ZTD support check only for ztd kind; vitest entrypoint generates harness-based test for ztd or placeholder test.skip() for traditional.
Tests
packages/ztd-cli/tests/cliCommands.test.ts, packages/ztd-cli/tests/featureTestsScaffold.unit.test.ts
Extended CLI help test to assert --test-kind <kind> option presence. Added unit tests for traditional lane scaffold generation (verifying output files, placeholder test markers, and analysis artifacts), lane coexistence (confirming both ZTD and traditional artifacts persist), and invalid kind rejection.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A CLI with lanes both swift and wide,
ZTD blazing fast, traditional with pride,
Choose your path, let the tests decide,
Each query's journey—scaffold side by side! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 accurately summarizes the main change: adding --test-kind support to enable feature test scaffold lane selection between ztd and traditional modes.
Description check ✅ Passed The PR description comprehensively covers all required template sections with specific details: summary of changes, verification steps, merge readiness, CLI migration packet information, and scaffold contract proof with evidence.
Linked Issues check ✅ Passed The PR fully implements the core coding requirements from issue #767: adds --test-kind ztd|traditional CLI option with ztd default [#767], implements coexisting lane scaffolds with file-suffix approach [#767], maintains CLI/library responsibility boundary [#767], generates thin adapters delegating to library [#767], and includes fail-fast validation and unit tests covering both lanes and edge cases [#767].
Out of Scope Changes check ✅ Passed All code changes are within scope of issue #767 objectives: CLI surface implementation, scaffold layout design, lane selection, responsibility boundary clarification, and supporting tests. No unrelated modifications detected.

✏️ 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 767-ztd-cli-traditional-test-kind-と-ztdtraditional-併存-scaffold-を後続拡張として設計する

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

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: 2

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)

459-463: ⚠️ Potential issue | 🟡 Minor

Generate lane-specific DB hints for the traditional artifacts.

buildDbScenarioHints() always emits ZTD guidance (“fixed app-level harness”, “keep the ZTD path thin”), so analysis.traditional.json and TEST_PLAN.traditional.md currently tell users to implement the traditional lane with ZTD-specific instructions. Please thread testKind into this hint builder and swap those messages for traditional-specific guidance.

Also applies to: 497-513

🤖 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` around lines 459 - 463, The DB
scenario hint generator is currently ZTD-biased because buildDbScenarioHints is
called without the test kind; thread params.testKind into buildDbScenarioHints
calls (e.g., replace buildDbScenarioHints(writesTables,
params.queryLayout.queryName, fixtureCandidateTables) with
buildDbScenarioHints(params.testKind, writesTables,
params.queryLayout.queryName, fixtureCandidateTables) at both the shown call and
the other occurrence around 497-513) and update the buildDbScenarioHints
implementation to branch on the incoming testKind (e.g., if testKind ===
'traditional' emit traditional-specific guidance like implementing the
traditional lane and non-ZTD harness notes; if testKind indicates ZTD keep the
existing ZTD-specific hints), ensuring the function signature and any callers
are adjusted accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/guide/ztd-cli-traditional-lane-followup-plan.md`:
- Around line 8-10: Update the guide header to reflect the shipped scaffold:
change "Implementation status: `not done`" to `done` (so both "Current status"
and "Implementation status" indicate completion) and replace all occurrences of
the old filenames `TEST_PLAN.ztd.md` and `analysis.ztd.json` with the scaffold's
actual paths `generated/TEST_PLAN.md` and `generated/analysis.json` in
docs/guide/ztd-cli-traditional-lane-followup-plan.md (also apply the same
replacements where referenced in lines ~72-75).

In `@packages/ztd-cli/src/commands/featureTests.ts`:
- Around line 345-375: The generated vitest entrypoint currently emits a
non-runnable test.skip scaffold for the "traditional" kind (see
vitestEntrypointFile and the test.skip line) and also leaves fixedVerifierPath
as a TODO; either wire this scaffold to the real library traditional-mode
adapter or block/flag the kind: add a guard where the CLI/templating chooses
test kind (check the code that sets params.testKind / fixedVerifierPath) to
either (A) replace the test.skip scaffold with an actual call to the library
traditional adapter (use the real adapter import instead of the TODO
fixedVerifierPath and remove test.skip), or (B) fail-fast / mark as experimental
by throwing a clear error or returning a template that logs "traditional mode
not supported yet" when params.testKind === 'traditional' so we never generate a
permanent skipped test; update any references to fixedVerifierPath and the
vitestEntrypointFile generation to reflect the chosen behavior.

---

Outside diff comments:
In `@packages/ztd-cli/src/commands/featureTests.ts`:
- Around line 459-463: The DB scenario hint generator is currently ZTD-biased
because buildDbScenarioHints is called without the test kind; thread
params.testKind into buildDbScenarioHints calls (e.g., replace
buildDbScenarioHints(writesTables, params.queryLayout.queryName,
fixtureCandidateTables) with buildDbScenarioHints(params.testKind, writesTables,
params.queryLayout.queryName, fixtureCandidateTables) at both the shown call and
the other occurrence around 497-513) and update the buildDbScenarioHints
implementation to branch on the incoming testKind (e.g., if testKind ===
'traditional' emit traditional-specific guidance like implementing the
traditional lane and non-ZTD harness notes; if testKind indicates ZTD keep the
existing ZTD-specific hints), ensuring the function signature and any callers
are adjusted accordingly.
🪄 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: 46894cb3-3efa-42ca-a130-dc88379409f5

📥 Commits

Reviewing files that changed from the base of the PR and between e531ef2 and 595f86c.

📒 Files selected for processing (6)
  • .changeset/fair-apes-tie.md
  • docs/guide/ztd-cli-traditional-lane-followup-plan.md
  • packages/ztd-cli/README.md
  • packages/ztd-cli/src/commands/featureTests.ts
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/tests/featureTestsScaffold.unit.test.ts

Comment on lines +8 to +10
- Current status: `done` (planning artifact for Issue #767)
- Implementation status: `not done` (separate issues/PRs are expected)

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 | 🟡 Minor

Align this guide with the shipped scaffold layout.

This doc is linked from README as a user guide, but it still says the implementation is “not done” and shows TEST_PLAN.ztd.md / analysis.ztd.json. The current scaffold code already ships --test-kind and keeps the ZTD lane on generated/TEST_PLAN.md and generated/analysis.json, so readers will follow the wrong filenames and infer the feature is unavailable.

Also applies to: 72-75

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

In `@docs/guide/ztd-cli-traditional-lane-followup-plan.md` around lines 8 - 10,
Update the guide header to reflect the shipped scaffold: change "Implementation
status: `not done`" to `done` (so both "Current status" and "Implementation
status" indicate completion) and replace all occurrences of the old filenames
`TEST_PLAN.ztd.md` and `analysis.ztd.json` with the scaffold's actual paths
`generated/TEST_PLAN.md` and `generated/analysis.json` in
docs/guide/ztd-cli-traditional-lane-followup-plan.md (also apply the same
replacements where referenced in lines ~72-75).

Comment on lines +345 to +375
const vitestEntrypointFile = isZtdLane
? [
`import { expect, test } from 'vitest';`,
'',
`import { runQuerySpecZtdCases } from '${harnessImportPath}';`,
`import { ${executorName} } from '${querySpecImportPath}';`,
`import cases from '${casesImportPath}';`,
`import type { ${queryCaseTypeName} } from '${queryTypesImportPath}';`,
'',
`test('${params.featureName}/${params.queryName} boundary ZTD cases run through the fixed app-level harness', async () => {`,
' expect(cases.length).toBeGreaterThan(0);',
` const evidence = await runQuerySpecZtdCases(cases, ${executorName});`,
" expect(evidence.every((entry) => entry.mode === 'ztd')).toBe(true);",
' expect(evidence.every((entry) => entry.physicalSetupUsed === false)).toBe(true);',
'});',
''
].join('\n')
: [
`import { expect, test } from 'vitest';`,
'',
`import { ${executorName} } from '${querySpecImportPath}';`,
`import cases from '${casesImportPath}';`,
`import type { ${queryCaseTypeName} } from '${queryTypesImportPath}';`,
'',
`test.skip('${params.featureName}/${params.queryName} boundary traditional lane scaffold placeholder', async () => {`,
' expect(cases.length).toBeGreaterThan(0);',
' // TODO(issue-767 follow-up): wire this lane to the library traditional mode API.',
` void ${executorName};`,
'});',
''
].join('\n');
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

Don't ship traditional as a supported kind until the scaffold is executable.

Right now --test-kind traditional generates a permanent test.skip(...) placeholder and a fixedVerifierPath of TODO: library traditional mode API adapter. That means the new public CLI option produces a non-runnable lane even though the help text, README link, and changeset present it as supported. Either wire this scaffold to the library adapter now or fail fast / mark the kind as experimental until that adapter exists.

Also applies to: 476-478

🤖 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` around lines 345 - 375, The
generated vitest entrypoint currently emits a non-runnable test.skip scaffold
for the "traditional" kind (see vitestEntrypointFile and the test.skip line) and
also leaves fixedVerifierPath as a TODO; either wire this scaffold to the real
library traditional-mode adapter or block/flag the kind: add a guard where the
CLI/templating chooses test kind (check the code that sets params.testKind /
fixedVerifierPath) to either (A) replace the test.skip scaffold with an actual
call to the library traditional adapter (use the real adapter import instead of
the TODO fixedVerifierPath and remove test.skip), or (B) fail-fast / mark as
experimental by throwing a clear error or returning a template that logs
"traditional mode not supported yet" when params.testKind === 'traditional' so
we never generate a permanent skipped test; update any references to
fixedVerifierPath and the vitestEntrypointFile generation to reflect the chosen
behavior.

@mk3008 mk3008 merged commit ac00253 into main Apr 15, 2026
10 checks passed
@mk3008 mk3008 deleted the 767-ztd-cli-traditional-test-kind-と-ztdtraditional-併存-scaffold-を後続拡張として設計する branch April 15, 2026 11:09
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.

ztd-cli: traditional test kind と ztd/traditional 併存 scaffold を後続拡張として設計する

1 participant