Skip to content

(janitor/test-prune): remove tautological constant and type-only test assertions - #8997

Closed
kilo-code-bot[bot] wants to merge 1 commit into
mainfrom
janitor/test-prune-constant-and-type-only-tests
Closed

kilo-code-bot[bot] wants to merge 1 commit into
mainfrom
janitor/test-prune-constant-and-type-only-tests

Conversation

@kilo-code-bot

@kilo-code-bot kilo-code-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes test assertions that re-state literal constants or exist only to typecheck, without exercising runtime behavior. Both deletions target the same failure mode: an assertion whose expected value is either the source literal itself or a compile-time-only fact already enforced at the authoritative runtime boundary.

Changes

packages/auto-routing-contracts/src/taxonomy.test.ts

Deleted the never-run compile-only helper:

// Never called: this only has to typecheck. A subtask may only pair with the
// task type that owns it in SUBTYPES_BY_TASK_TYPE.
function compileOnlyRejectsCrossPairs() {
  // @ts-expect-error code_generation belongs to implementation, not debugging
  taxonomyRouteKey({ taskType: 'debugging', subtaskType: 'code_generation' });
}
void compileOnlyRejectsCrossPairs;
  • Classification: type-system noise (never invoked at runtime).
  • Surviving coverage: the runtime test rejects a subtask from another task type already asserts TaxonomyRouteKeySchema.safeParse('debugging/code_generation').success === false, pinning the same cross-pair rejection at the authoritative runtime schema, not just in the type layer.
  • Why it can't detect an additional regression: the function body never executes, so the only thing it verifies is a TypeScript signature. A loosened taxonomyRouteKey signature would not change any runtime behavior (the schema is the authority), and the runtime schema test already catches an actual cross-pair acceptance.

apps/web/src/lib/code-reviews/analytics/contracts.test.ts

Replaced the exports stable labels, versions, and impact points test, dropping four literal re-statements and keeping the two real-logic assertions:

  • Removed: SCHEMA_VERSION === 1, TAXONOMY_VERSION === 1, CHANGE_TYPE_LABELS.bug_fix === 'Bug fix', IMPACT_POINTS === { low: 1, medium: 2, high: 3 }.

  • Kept (renamed to derives impact points from impact and confidence): getCodeReviewAnalyticsImpactPoints('high', 'high') === 3 and ('high', 'low') === 0.

  • Classification: constant/literal re-statement.

  • Surviving coverage:

    • Version constants are enforced by CodeReviewAnalyticsManifestSchema's z.literal(CODE_REVIEW_ANALYTICS_SCHEMA_VERSION / TAXONOMY_VERSION) plus the existing rejects unsupported taxonomy values and versions test (rejects schemaVersion: 2 and taxonomyVersion: 2).
    • Label/impact-point maps are as const satisfies Record<…> at compile time and are pure data with no behavior.
  • Why they can't detect an additional regression: each assertion's expected value is the source literal itself, so they can only fail when the source is intentionally edited (mechanical churn), never when a bug is introduced. The version values are the same reference consumed by z.literal, so the schema/reject tests already pin them behaviorally.

Verification

  • pnpm --filter auto-routing-contracts run test — 226 passed (incl. the 4 taxonomy tests).
  • pnpm --filter auto-routing-contracts run typecheck — clean.
  • pnpm --filter auto-routing-contracts run lint — clean.
  • oxlint apps/web/src/lib/code-reviews/analytics/contracts.test.ts — clean.
  • apps/web Jest suite could not be run in this environment (requires Postgres/Redis); the change only removes assertions and two now-unused imports, and the file lints clean.

Remove test assertions that re-state literal constants or exist only to
typecheck, without exercising runtime behavior:

- auto-routing-contracts: drop the never-run compile-only cross-pair helper;
  the runtime TaxonomyRouteKeySchema test already rejects the cross-pair.
- code-reviews analytics: drop literal re-statements of schema/taxonomy
  version constants (already enforced by the schema's z.literal + reject
  tests) and label/impact-point maps, keeping the impact-points derivation
  assertions that exercise real logic.
@kilo-code-bot kilo-code-bot Bot added the janitor Automated dead-code/duplication cleanup label Oct 28, 2026
@kilo-code-bot
kilo-code-bot Bot enabled auto-merge October 28, 2026 07:35
expect(CODE_REVIEW_ANALYTICS_CHANGE_TYPE_LABELS.bug_fix).toBe('Bug fix');
expect(CODE_REVIEW_ANALYTICS_IMPACT_POINTS).toEqual({ low: 1, medium: 2, high: 3 });
it('derives impact points from impact and confidence', () => {
expect(getCodeReviewAnalyticsImpactPoints('high', 'high')).toBe(3);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

SUGGESTION: The retained test now only pins the high impact score

Dropping the CODE_REVIEW_ANALYTICS_IMPACT_POINTS assertion leaves the low: 1 and medium: 2 entries untested. The map is declared as const satisfies Record<CodeReviewAnalyticsImpactLevel, number>, so the compiler only enforces that those keys exist and hold numbers, not their values. A wrong score for low or medium would now pass the suite while silently changing analytics impact scoring. Consider adding assertions for getCodeReviewAnalyticsImpactPoints('medium', 'high') and getCodeReviewAnalyticsImpactPoints('low', 'high') next to the two kept cases.

@kilo-code-bot

kilo-code-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

Test-only cleanup is sound overall; the only regressions are reduced pinning of the analytics impact-point scores and loss of the sole type-level guard on taxonomyRouteKey.

Assumptions: [INFERENCE] Repo-wide grep for getCodeReviewAnalyticsImpactPoints and CODE_REVIEW_ANALYTICS_IMPACT_POINTS shows no other test covers the low/medium scores. No tests were executed (read-only review).

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 2
Issue Details (click to expand)

SUGGESTION

File Line Issue
apps/web/src/lib/code-reviews/analytics/contracts.test.ts 265 Removing the CODE_REVIEW_ANALYTICS_IMPACT_POINTS assertion leaves low: 1 and medium: 2 untested; the satisfies Record<…, number> type only checks keys/types, so wrong values would pass silently.
packages/auto-routing-contracts/src/taxonomy.test.ts deleted 40-47 Removing compileOnlyRejectsCrossPairs drops the only @ts-expect-error guard on the exported taxonomyRouteKey generic (subtaskType: SubtypesOfTaskType<T> at taxonomy.ts:52). The surviving runtime test validates a literal enum key, not the helper signature, so a widened parameter would pass typecheck and all tests. Summary-only because the finding is on deleted lines.
Files Reviewed (2 files)
  • apps/web/src/lib/code-reviews/analytics/contracts.test.ts - 1 issue
  • packages/auto-routing-contracts/src/taxonomy.test.ts - 1 issue

Fix these issues in Kilo Cloud


Reviewed by deepseek-flash-latest · Input: 40.4K · Output: 10K · Cached: 584.6K

Review guidance: REVIEW.md from base branch main

@kilo-code-bot

kilo-code-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Meta Janitor: Closing because Kilo bot review contains actionable feedback. A future janitor run can recreate this cleanup against current main. Feedback: #8997 (comment) #8997 (comment)

@kilo-code-bot kilo-code-bot Bot closed this Oct 28, 2026
auto-merge was automatically disabled October 28, 2026 11:07

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

janitor Automated dead-code/duplication cleanup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants