Skip to content

test(tools): type the path-safety harnesses instead of erasing with any - #7270

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/path-safety-harness-typing
Aug 29, 2026
Merged

test(tools): type the path-safety harnesses instead of erasing with any#7270
waleedlatif1 merged 1 commit into
stagingfrom
fix/path-safety-harness-typing

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

These two files are the template every service copied during the path-hardening sweep, and both open with:

type AnyTool = ToolConfig<any, any>
// ...
return new URL(url(buildParams(tool, value) as any)).pathname

CLAUDE.md forbids any outright ("No any — use proper types or unknown with type guards"). Because these are the template, the violation propagated into ten in-flight PRs before review caught it there. Fixing the source stops the next copy inheriting it.

Why the obvious repair doesn't compile

Swapping in ToolConfig<Record<string, unknown>, ToolResponse> on its own fails across the whole barrel union:

Type '(params: VercelAddProjectDomainParams) => string' is not assignable to
type '(params: Record<string, unknown>) => string'

ToolConfig takes its param type in the contravariant position of request.url, so no concrete member is assignable to the widened alias. And filter's type-predicate overload intersects rather than replaces, so filtering the union directly leaves the mismatch standing.

Seeding the enumeration as Object.values<unknown>(...) makes the existing isVercelTool / isDaytonaTool predicate the single narrowing point — the unknown-plus-type-guard form the guidelines actually prescribe — and removes the need for a cast at the call site entirely.

These files have no type coverage in CI

Worth recording, because it is why the pattern survived: apps/sim/tsconfig.json excludes **/*.test.ts, and vitest does not typecheck. So neither direction would have flagged this.

I verified with a temporary tsconfig lifting the exclusion, and confirmed via --listFiles that both files were genuinely in the program — an empty program also reports zero errors, which is an easy way to fool yourself here. Zero errors in both. That config was not committed.

Checks

  • vitest run tools/vercel tools/daytona1129 pass, identical to before (pure typing change, no behavioural effect)
  • bun run lint — clean
  • bun run check:audits — 39/39
  • check-block-registry.ts origin/staging — pass
  • Type-check with the test exclusion lifted — zero errors in both harnesses

These two harnesses are the template every service copied when the path
hardening sweep began, and both open with `type AnyTool = ToolConfig<any, any>`
plus an `as any` at the `url(...)` call. CLAUDE.md forbids `any` outright, and
because they are the template the violation propagated into ten in-flight PRs
before review flagged it. Fixing the source stops the next copy inheriting it.

The obvious repair does not compile. `ToolConfig` takes its param type in the
contravariant position of `request.url`, so no concrete member of the barrel's
union is assignable to a widened `ToolConfig<Record<string, unknown>, ...>`, and
`filter`'s type-predicate overload intersects rather than replaces -- filtering
the union directly leaves the mismatch standing. Seeding the enumeration as
`Object.values<unknown>(...)` makes the existing `isVercelTool` / `isDaytonaTool`
predicate the single narrowing point, which is the `unknown`-plus-type-guard form
the guidelines actually ask for, and removes the need for a cast at the call site.

Note these files have no type coverage in CI from either direction:
`apps/sim/tsconfig.json` excludes `**/*.test.ts`, and vitest does not typecheck.
Verified with a temporary tsconfig lifting the exclusion, confirming via
`--listFiles` that both files were genuinely in the program -- an empty program
also reports zero errors. That config was not committed.

Behaviour is unchanged: 1129 tests pass, identical to before.
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 29, 2026 4:33am

Request Review

@greptile-apps

greptile-apps Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes explicit any usage from the Daytona and Vercel path-safety harnesses without changing runtime behavior.

  • Types heterogeneous tool barrels as unknown before narrowing through service-specific predicates.
  • Uses ToolConfig<Record<string, unknown>, ToolResponse> for the harness-facing tool shape.
  • Removes the call-site casts when passing generated parameters to URL builders.

Confidence Score: 5/5

The PR appears safe to merge because it changes only erased TypeScript annotations in test harnesses and introduces no observable behavior change.

The barrel enumeration, filtering, parameter construction, URL invocation, and assertions emit the same runtime behavior as before, and no concrete build or test failure was established.

Important Files Changed

Filename Overview
apps/sim/tools/daytona/sandbox_path_safety.test.ts Replaces explicit any types and casts with an unknown-first narrowing pattern; no actionable regression was identified.
apps/sim/tools/vercel/edge_config_path_safety.test.ts Applies the same type-only cleanup to the Vercel path-safety harness without changing test execution behavior.

Reviews (1): Last reviewed commit: "test(tools): type the path-safety harnes..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 87497b3 into staging Aug 29, 2026
27 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/path-safety-harness-typing branch August 29, 2026 04:39
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.

1 participant