Skip to content

feat(ztd-cli): add telemetry seam and observed SQL matcher - #682

Merged
mk3008 merged 8 commits into
mainfrom
codex/675-telemetry-observed-sql-clean
Mar 27, 2026
Merged

feat(ztd-cli): add telemetry seam and observed SQL matcher#682
mk3008 merged 8 commits into
mainfrom
codex/675-telemetry-observed-sql-clean

Conversation

@mk3008

@mk3008 mk3008 commented Mar 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a no-op repository telemetry seam for safe runtime metadata (queryId, repositoryName, methodName, paramsShape, transformations).
  • Add ztd query match-observed and an AST-based observed SQL matcher for SELECT-oriented candidate ranking.
  • Add starter and docs coverage for telemetry guidance and observed SQL matching.

Customer Value

  • Helps teams trace repository activity by queryId without exposing SQL text or bind values.
  • Helps engineers recover the most likely SQL asset from observed SQL in logs or monitoring tools.
  • Keeps observability safe by default, so teams can adopt telemetry without leaking sensitive data.

Verification

  • pnpm --filter @rawsql-ts/sql-grep-core test
  • pnpm --filter @rawsql-ts/ztd-cli test -- cliCommands.test.ts init.command.test.ts ⚠️ In the isolated worktree, the broader CLI suite hit pre-existing workspace dependency/build issues, but the new observed SQL matcher path and starter telemetry coverage were exercised.
  • The branch was rebased onto current main to clear the GitHub merge conflict on this PR.

Related Issue

Summary by CodeRabbit

  • New Features

    • Added a CLI command to rank likely source SQL from an observed statement when telemetry queryId is missing (supports inline/file input, text or JSON output).
  • Documentation

    • Added guides: Observed SQL Matching, Observed SQL Investigation, and Repository Telemetry Setup; updated CLI/package/starter READMEs to reference them.
  • Improvements

    • Init starter now includes repository telemetry scaffolding and defaults the starter telemetry seam to a no-op.
  • Tests

    • Added CLI tests validating observed-SQL ranking and updated init dry-run assertions.

@coderabbitai

coderabbitai Bot commented Mar 27, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a no-op repository telemetry scaffold and telemetry types to the init starter, wires telemetry template files into ztd init --starter, introduces a new CLI command ztd query match-observed (implementation docs, README updates, tests), and adjusts observed-SQL normalization and telemetry template serialization behavior.

Changes

Cohort / File(s) Summary
Guides & READMEs
docs/guide/feature-index.md, docs/guide/observed-sql-matching.md, docs/guide/observed-sql-investigation.md, docs/guide/repository-telemetry-setup.md, docs/guide/ztd-cli-telemetry-philosophy.md, packages/sql-grep-core/README.md, packages/ztd-cli/templates/README.md
Added feature index entry and three new guides; updated advanced README and telemetry cross-references; documented ztd query match-observed usage and investigation flow.
CLI Descriptor
packages/ztd-cli/src/commands/describe.ts
Added query match-observed command descriptor with flags (--sql, --sql-file, --format json, --out), output contract, and exit codes.
Init scaffolding & exports
packages/ztd-cli/src/commands/init.ts
Emits new starter telemetry template files (src/infrastructure/README.md, src/infrastructure/telemetry/types.ts, .../repositoryTelemetry.ts, .../consoleRepositoryTelemetry.ts), wires template writes into scaffold sequence, extends dry-run plan output, and exports InitDryRunPlan and buildInitDryRunPlan.
Telemetry templates & types
packages/ztd-cli/templates/src/infrastructure/telemetry/types.ts, .../repositoryTelemetry.ts, .../consoleRepositoryTelemetry.ts
Added exported telemetry primitive types and RepositoryTelemetryParameterShape/transformations; changed RepositoryTelemetryContext to require queryId, paramsShape, transformations; added createNoopRepositoryTelemetry() and made it the default; console serializer no longer emits sqlText and now emits fixed structured fields.
SQL matching core
packages/sql-grep-core/src/observed/match.ts
Normalization change: ParameterExpression and non-null literals now normalize to 'value:bound'; null literals normalize to 'value:null'.
Tests
packages/ztd-cli/tests/cliCommands.test.ts, packages/ztd-cli/tests/init.command.test.ts
Removed an old init dry-run test; added CLI test for query match-observed validating JSON ranking and per-section scores; extended init tests to assert telemetry scaffold file presence and content markers.
Packaging / Changeset / Scripts
.changeset/clean-singers-explain.md, scripts/verify-published-package-mode.mjs, packages/ztd-cli/README.md
Added a changeset for a patch release; updated package verification expectations and README references to new telemetry/investigation guides.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer / CLI User
  participant CLI as ztd CLI (match-observed)
  participant Repo as Repository (disk: .sql assets)
  participant Matcher as sql-grep-core matcher
  participant Out as Stdout / File

  Dev->>CLI: run `ztd query match-observed --sql-file` / `--sql`
  CLI->>Repo: read project .sql assets (AST)
  CLI->>Matcher: provide observed SQL AST + candidate ASTs
  Matcher->>Matcher: normalize predicates and operands, compute section scores
  Matcher-->>CLI: return ranked matches with scores and reasons
  CLI->>Out: print text report or `--format json` output (optionally write `--out`)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 In my burrow I parse and softly sniff,
When queryId's gone I follow the drift,
I rank the paths, give reasons why they fit,
A hop, a score, and a tidy little writ,
Hooray — the matcher found the likely bit!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.77% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(ztd-cli): add telemetry seam and observed SQL matcher' accurately summarizes the two primary features introduced: repository telemetry scaffolding and the observed SQL matching CLI command.
Linked Issues check ✅ Passed The PR successfully implements both objectives from Issue #675: (A) repository telemetry hook scaffold with no-op default, proper event shape, and documentation; (B) observed SQL matcher CLI command with AST-based scoring for SSSQL candidate ranking.
Out of Scope Changes check ✅ Passed All changes are within scope of Issue #675 objectives: telemetry seam infrastructure, observed SQL matching implementation, starter scaffold updates, documentation guides, and supporting test/verification additions.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/675-telemetry-observed-sql-clean

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.

@mk3008 mk3008 closed this Mar 27, 2026
@mk3008
mk3008 force-pushed the codex/675-telemetry-observed-sql-clean branch from b6f8f43 to 6a1b5ef Compare March 27, 2026 11:36
@mk3008 mk3008 reopened this Mar 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

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

⚠️ Outside diff range comments (2)
packages/ztd-cli/templates/src/infrastructure/telemetry/consoleRepositoryTelemetry.ts (1)

34-52: ⚠️ Potential issue | 🟠 Major

Do not log raw errorMessage in the default console sink.

Even with SQL text removed, event.errorMessage can still carry SQL fragments or parameter values from upstream driver/app errors. Keep the default payload to structured fields such as errorName, and let applications opt into richer error logging in their own sink.

🛠️ Suggested fix
   if (event.kind === 'query.execute.error') {
     payload.errorName = event.errorName;
-    payload.errorMessage = event.errorMessage;
   }
Based on learnings, "Default telemetry behavior MUST stay conservative about query text emission."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/ztd-cli/templates/src/infrastructure/telemetry/consoleRepositoryTelemetry.ts`
around lines 34 - 52, The default console sink is including event.errorMessage
which can leak SQL fragments/params; update the payload construction in
consoleRepositoryTelemetry.ts (the code that builds the payload object using
payload and event) to stop assigning payload.errorMessage for event.kind ===
'query.execute.error' — keep only payload.errorName (and any structured fields
like durationMs/rowCount), and ensure no other code in the same sink logs
event.errorMessage; if downstream apps need richer error text, they should opt
into that in a custom sink.
packages/ztd-cli/templates/src/infrastructure/telemetry/repositoryTelemetry.ts (1)

36-43: ⚠️ Potential issue | 🟡 Minor

Update stale JSDoc to match no-op default behavior.

The comment still says “default console hook works,” but the default is now no-op.

📝 Suggested comment fix
 /**
  * Resolve the repository telemetry hook that application code wants to use.
  *
  * Repository constructors can accept an optional telemetry dependency and call
- * this helper so the default console hook works without extra setup.
+ * this helper so the default no-op hook works without extra setup.
  */
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/ztd-cli/templates/src/infrastructure/telemetry/repositoryTelemetry.ts`
around lines 36 - 43, Update the stale JSDoc above defaultRepositoryTelemetry to
reflect that the default behavior is a no-op (created by
createNoopRepositoryTelemetry) rather than a console hook; update the
description for the repository telemetry hook and the note about repository
constructors accepting an optional telemetry dependency so it states the default
is a no-op telemetry implementation that requires no extra setup.
🧹 Nitpick comments (2)
packages/ztd-cli/templates/README.md (1)

70-89: Make adapter snippets directly runnable.

The examples use logger and trace without showing their declarations/imports, which can cause copy/paste friction.

♻️ Suggested doc patch
 ```ts
+import { trace } from '@opentelemetry/api';
+const logger = console;
+
 const repositoryTelemetry = {
   emit(event) {
     logger.info({ repositoryTelemetry: event }, 'repository telemetry');
   }
 };
+import { trace } from '@opentelemetry/api';
+
const repositoryTelemetry = {
  emit(event) {
    const span = trace.getActiveSpan();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ztd-cli/templates/README.md` around lines 70 - 89, The README
snippets use undeclared symbols; make each adapter snippet directly runnable by
adding the missing declarations/imports: import trace from '@opentelemetry/api'
(or import { trace } ...) and declare a logger (e.g., const logger = console)
before the repositoryTelemetry object so repositoryTelemetry.emit, logger.info,
and trace.getActiveSpan() resolve when copy/pasted; ensure both code blocks
include these lines above their respective repositoryTelemetry definitions.
packages/ztd-cli/templates/src/infrastructure/telemetry/types.ts (1)

6-15: Tighten RepositoryTelemetryParameterShape as a discriminated union.

Current shape permits contradictory states (e.g., kind: 'scalar' with arrayLength: 'many', or kind: 'null' + nullability: 'non-null'). Encoding valid combinations in the type will keep emitted telemetry structurally consistent.

♻️ Suggested type refactor
-export interface RepositoryTelemetryParameterShape {
-  name: string;
-  kind: RepositoryTelemetryParameterKind;
-  nullability: RepositoryTelemetryNullability;
-  arrayLength?: RepositoryTelemetryArrayLength;
-}
+type RepositoryTelemetryScalarOrUnknownShape = {
+  name: string;
+  kind: 'scalar' | 'unknown';
+  nullability: 'non-null' | 'mixed';
+  arrayLength?: never;
+};
+
+type RepositoryTelemetryArrayShape = {
+  name: string;
+  kind: 'array';
+  nullability: 'non-null' | 'mixed';
+  arrayLength: RepositoryTelemetryArrayLength;
+};
+
+type RepositoryTelemetryNullShape = {
+  name: string;
+  kind: 'null';
+  nullability: 'null';
+  arrayLength?: never;
+};
+
+export type RepositoryTelemetryParameterShape =
+  | RepositoryTelemetryScalarOrUnknownShape
+  | RepositoryTelemetryArrayShape
+  | RepositoryTelemetryNullShape;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ztd-cli/templates/src/infrastructure/telemetry/types.ts` around
lines 6 - 15, Replace the loose RepositoryTelemetryParameterShape interface with
a discriminated union keyed on RepositoryTelemetryParameterKind so invalid
combos are impossible: define separate variants for kind='scalar' (no
arrayLength, nullability limited appropriately), kind='array' (requires
arrayLength and appropriate nullability), kind='null' (nullability fixed to
'null' and no arrayLength), and kind='unknown' (permissive). Update usages to
accept the new union and keep the exported type names
RepositoryTelemetryParameterKind, RepositoryTelemetryNullability,
RepositoryTelemetryArrayLength unchanged.
🤖 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/src/commands/init.ts`:
- Around line 2567-2572: The dry-run plan lists multiple AGENTS.md target paths
that runInitCommand() does not actually create in normal starter mode, causing
over-promising; update the dry-run generation logic to only include files that
runInitCommand() will create (e.g., keep the top-level 'AGENTS.md' entry or the
single path produced by runInitCommand()) and remove the extra paths
(path.join('ztd','AGENTS.md'), path.join('ztd','ddl','AGENTS.md'),
path.join('src','AGENTS.md'), path.join('src','features','AGENTS.md'),
path.join('tests','AGENTS.md')) so the plan matches actual outputs, ensuring the
code paths that assemble the dry-run list (where those AGENTS.md entries are
declared) reference the same creation logic used by runInitCommand().

In `@packages/ztd-cli/src/commands/query.ts`:
- Around line 439-451: Remove the duplicate function definition
resolveObservedSqlInput (the one that simply reads --sql or --sql-file) that
appears earlier in the file and causes TS2393; keep the existing, correct
implementation of resolveObservedSqlInput (the version at lines ~669–686) which
performs mutual-exclusion validation between --sql and --sql-file and proper
error handling. Ensure only the single, validated resolveObservedSqlInput
remains in the file so the mutual-exclusion logic is preserved and the duplicate
declaration is eliminated.

In `@packages/ztd-cli/tests/cliCommands.test.ts`:
- Around line 2378-2460: The PR added a duplicate test with the same title
("query match-observed ranks the likely source asset for observed SELECT SQL")
and unnecessarily mutates process.env.ZTD_PROJECT_ROOT even though runCli is
already passed an env override; remove the duplicate test block so only one
variant remains, and delete the manual process.env.ZTD_PROJECT_ROOT save/restore
logic inside that test (leave runCli(..., { ZTD_PROJECT_ROOT: workspace.rootDir
}, workspace.rootDir) as the sole env scoping mechanism) — look for the test
function by its title and references to process.env.ZTD_PROJECT_ROOT and runCli
to make the changes.

---

Outside diff comments:
In
`@packages/ztd-cli/templates/src/infrastructure/telemetry/consoleRepositoryTelemetry.ts`:
- Around line 34-52: The default console sink is including event.errorMessage
which can leak SQL fragments/params; update the payload construction in
consoleRepositoryTelemetry.ts (the code that builds the payload object using
payload and event) to stop assigning payload.errorMessage for event.kind ===
'query.execute.error' — keep only payload.errorName (and any structured fields
like durationMs/rowCount), and ensure no other code in the same sink logs
event.errorMessage; if downstream apps need richer error text, they should opt
into that in a custom sink.

In
`@packages/ztd-cli/templates/src/infrastructure/telemetry/repositoryTelemetry.ts`:
- Around line 36-43: Update the stale JSDoc above defaultRepositoryTelemetry to
reflect that the default behavior is a no-op (created by
createNoopRepositoryTelemetry) rather than a console hook; update the
description for the repository telemetry hook and the note about repository
constructors accepting an optional telemetry dependency so it states the default
is a no-op telemetry implementation that requires no extra setup.

---

Nitpick comments:
In `@packages/ztd-cli/templates/README.md`:
- Around line 70-89: The README snippets use undeclared symbols; make each
adapter snippet directly runnable by adding the missing declarations/imports:
import trace from '@opentelemetry/api' (or import { trace } ...) and declare a
logger (e.g., const logger = console) before the repositoryTelemetry object so
repositoryTelemetry.emit, logger.info, and trace.getActiveSpan() resolve when
copy/pasted; ensure both code blocks include these lines above their respective
repositoryTelemetry definitions.

In `@packages/ztd-cli/templates/src/infrastructure/telemetry/types.ts`:
- Around line 6-15: Replace the loose RepositoryTelemetryParameterShape
interface with a discriminated union keyed on RepositoryTelemetryParameterKind
so invalid combos are impossible: define separate variants for kind='scalar' (no
arrayLength, nullability limited appropriately), kind='array' (requires
arrayLength and appropriate nullability), kind='null' (nullability fixed to
'null' and no arrayLength), and kind='unknown' (permissive). Update usages to
accept the new union and keep the exported type names
RepositoryTelemetryParameterKind, RepositoryTelemetryNullability,
RepositoryTelemetryArrayLength unchanged.
🪄 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: 485200a2-2723-4a7f-8e05-b374e28509d8

📥 Commits

Reviewing files that changed from the base of the PR and between 6a1b5ef and 1b46b39.

⛔ Files ignored due to path filters (1)
  • packages/ztd-cli/tests/__snapshots__/describe.cli.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (14)
  • docs/guide/feature-index.md
  • docs/guide/observed-sql-matching.md
  • packages/sql-grep-core/README.md
  • packages/sql-grep-core/src/observed/match.ts
  • packages/ztd-cli/src/commands/describe.ts
  • packages/ztd-cli/src/commands/init.ts
  • packages/ztd-cli/src/commands/query.ts
  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/templates/src/infrastructure/README.md
  • packages/ztd-cli/templates/src/infrastructure/telemetry/consoleRepositoryTelemetry.ts
  • packages/ztd-cli/templates/src/infrastructure/telemetry/repositoryTelemetry.ts
  • packages/ztd-cli/templates/src/infrastructure/telemetry/types.ts
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/tests/init.command.test.ts

Comment thread packages/ztd-cli/src/commands/init.ts Outdated
Comment thread packages/ztd-cli/src/commands/query.ts Outdated
Comment thread packages/ztd-cli/tests/cliCommands.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/ztd-cli/tests/init.command.test.ts (1)

217-221: Also assert the fields the scaffold must not emit.

These lines only check for the new positive markers. A regression that reintroduces sqlText or raw parameter-value fields into the generated telemetry files would still pass. Please add a couple of explicit not.toContain(...) assertions alongside these checks.

As per coding guidelines, "Default telemetry behavior MUST stay conservative about query text emission."

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

In `@packages/ztd-cli/tests/init.command.test.ts` around lines 217 - 221, Add
explicit negative assertions to the test: alongside the existing positive checks
for repositoryTelemetry.ts, types.ts and consoleRepositoryTelemetry.ts, assert
that generated files do NOT contain the raw query text or raw parameter-value
fields by adding expect(readNormalizedFile(...
'src/infrastructure/telemetry/repositoryTelemetry.ts')).not.toContain('sqlText'),
expect(readNormalizedFile(...
'src/infrastructure/telemetry/consoleRepositoryTelemetry.ts')).not.toContain('sqlText'),
and expect(readNormalizedFile(...
'src/infrastructure/telemetry/types.ts')).not.toContain('parameterValues') (or
another concrete raw-parameter identifier your generator might produce, e.g.,
'paramValues'/'parameterValues'), so the test fails if sqlText or raw
parameter-value fields reappear in repositoryTelemetry.ts,
consoleRepositoryTelemetry.ts or types.ts.
🤖 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/templates/src/infrastructure/telemetry/types.ts`:
- Around line 6-42: The current telemetry parameter types
(RepositoryTelemetryParameterKind, RepositoryTelemetryNullability,
RepositoryTelemetryArrayLength and the union of
RepositoryTelemetryScalarParameterShape, RepositoryTelemetryArrayParameterShape,
RepositoryTelemetryNullParameterShape, RepositoryTelemetryUnknownParameterShape)
do not match the scaffolded contract: update the shapes so the union includes
fields required by the contract (presence, isNull, kind should allow 'scalar' |
'array' | 'object', explicit empty-string/empty-array flags, booleanValue, and
an optional operator) and remove impossible combinations (e.g., forbid
nullability: 'mixed' for kind: 'scalar'); specifically revise
RepositoryTelemetryScalarParameterShape, RepositoryTelemetryArrayParameterShape,
RepositoryTelemetryNullParameterShape and
RepositoryTelemetryUnknownParameterShape (and adjust
RepositoryTelemetryParameterKind/RepositoryTelemetryNullability types) so each
variant enforces correct presence/isNull semantics and array/empty flags,
ensuring the union statically prevents invalid states and matches the documented
telemetry contract.

---

Nitpick comments:
In `@packages/ztd-cli/tests/init.command.test.ts`:
- Around line 217-221: Add explicit negative assertions to the test: alongside
the existing positive checks for repositoryTelemetry.ts, types.ts and
consoleRepositoryTelemetry.ts, assert that generated files do NOT contain the
raw query text or raw parameter-value fields by adding
expect(readNormalizedFile(...
'src/infrastructure/telemetry/repositoryTelemetry.ts')).not.toContain('sqlText'),
expect(readNormalizedFile(...
'src/infrastructure/telemetry/consoleRepositoryTelemetry.ts')).not.toContain('sqlText'),
and expect(readNormalizedFile(...
'src/infrastructure/telemetry/types.ts')).not.toContain('parameterValues') (or
another concrete raw-parameter identifier your generator might produce, e.g.,
'paramValues'/'parameterValues'), so the test fails if sqlText or raw
parameter-value fields reappear in repositoryTelemetry.ts,
consoleRepositoryTelemetry.ts or types.ts.
🪄 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: 790dd607-c0e1-4597-a5e2-661ac478c05c

📥 Commits

Reviewing files that changed from the base of the PR and between 25a71be and 07eb7fd.

📒 Files selected for processing (12)
  • .changeset/clean-singers-explain.md
  • docs/guide/feature-index.md
  • docs/guide/observed-sql-investigation.md
  • docs/guide/observed-sql-matching.md
  • docs/guide/repository-telemetry-setup.md
  • docs/guide/ztd-cli-telemetry-philosophy.md
  • packages/ztd-cli/README.md
  • packages/ztd-cli/src/commands/init.ts
  • packages/ztd-cli/templates/README.md
  • packages/ztd-cli/templates/src/infrastructure/telemetry/types.ts
  • packages/ztd-cli/tests/cliCommands.test.ts
  • packages/ztd-cli/tests/init.command.test.ts
✅ Files skipped from review due to trivial changes (8)
  • docs/guide/ztd-cli-telemetry-philosophy.md
  • .changeset/clean-singers-explain.md
  • packages/ztd-cli/README.md
  • packages/ztd-cli/templates/README.md
  • docs/guide/feature-index.md
  • docs/guide/repository-telemetry-setup.md
  • docs/guide/observed-sql-investigation.md
  • docs/guide/observed-sql-matching.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/ztd-cli/src/commands/init.ts
  • packages/ztd-cli/tests/cliCommands.test.ts

Comment thread packages/ztd-cli/templates/src/infrastructure/telemetry/types.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/ztd-cli/tests/init.command.test.ts (1)

246-275: localSourceRoot: null may violate strict type checking.

The parameter type is localSourceRoot?: string, but null is passed. While both null and undefined are falsy at runtime, TypeScript with strictNullChecks treats them differently. Consider using undefined or omitting the property entirely to maintain type correctness.

♻️ Suggested fix
   const plan = buildInitDryRunPlan(workspace, {
     appShape: 'default',
     starter: true,
     postgresImage: 'postgres:17',
     withAiGuidance: false,
     withDogfooding: false,
     withAppInterface: false,
     workflow: 'demo',
-    validator: 'zod',
-    localSourceRoot: null
+    validator: 'zod'
   });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ztd-cli/tests/init.command.test.ts` around lines 246 - 275, The test
passes null for localSourceRoot which violates the function parameter type
localSourceRoot?: string under strictNullChecks; update the test invocation of
buildInitDryRunPlan in this test to either omit localSourceRoot or set it to
undefined (e.g., remove the localSourceRoot entry or replace null with
undefined) so the call matches the expected optional string signature used by
buildInitDryRunPlan.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/ztd-cli/tests/init.command.test.ts`:
- Around line 246-275: The test passes null for localSourceRoot which violates
the function parameter type localSourceRoot?: string under strictNullChecks;
update the test invocation of buildInitDryRunPlan in this test to either omit
localSourceRoot or set it to undefined (e.g., remove the localSourceRoot entry
or replace null with undefined) so the call matches the expected optional string
signature used by buildInitDryRunPlan.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 540c5e63-c31d-40f3-b232-cd110c3491a0

📥 Commits

Reviewing files that changed from the base of the PR and between 07eb7fd and f9f9e14.

📒 Files selected for processing (5)
  • docs/guide/repository-telemetry-setup.md
  • packages/ztd-cli/templates/src/infrastructure/telemetry/repositoryTelemetry.ts
  • packages/ztd-cli/templates/src/infrastructure/telemetry/types.ts
  • packages/ztd-cli/tests/init.command.test.ts
  • scripts/verify-published-package-mode.mjs
✅ Files skipped from review due to trivial changes (1)
  • docs/guide/repository-telemetry-setup.md

@mk3008
mk3008 merged commit 915d54f into main Mar 27, 2026
9 checks passed
@mk3008
mk3008 deleted the codex/675-telemetry-observed-sql-clean branch March 27, 2026 22:13
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.

実務向け repository telemetry hook の scaffold と、観測SQLから原型SSSQLを探索する仕組みの整備

1 participant