ReviewOS

stacks/ts-cloud

Stub commands in cost.ts return mock data — implement or guard with 'not implemented' warning

#107
Closed glennmichael123 opened this 24 days ago · 0 comments
24 days ago

Symptom

packages/ts-cloud/bin/commands/cost.ts registers five commands that return hardcoded mock data despite looking real at the CLI surface:

CommandBehavior today
costHardcoded "current month" total + projected, fake per-service breakdown, all marked // TODO: Fetch from AWS Cost Explorer API
cost:breakdownHardcoded service rankings + trends, // TODO
resourcesHardcoded resource counts + costs, // TODO: Fetch resources from AWS Resource Groups or CloudFormation
resources:unusedHardcoded "unused resources" list with fake savings numbers, // TODO: Analyze CloudWatch metrics, CloudFormation stacks, etc.
optimizeHardcoded recommendations with fake dollar savings, // TODO: Analyze resource usage, CloudWatch metrics, Cost Explorer data

Why this matters

A user runs cloud cost to check this month's bill. Output looks legit:

Current Month (Estimated):
  Total: $247.89
  Projected: $325.00

Service       Current   Projected   Change
EC2           $89.23    $120.00     +12%
S3            $12.45    $15.00      +8%
...

…but every number is fake. We saw real April spend was $352 on default and $307 on stacks (#103) — nothing close to $247. Someone will trust these numbers and act on them.

Two acceptable paths

Option A — Implement them properly

Use the real Cost Explorer client (now exists for cost:analyze). Each command becomes a thin shaping of real data:

  • cost — current MTD spend + naive linear projection
  • cost:breakdown — N-day window, by service, with previous-window trend comparison
  • resources — Resource Groups Tagging API or a per-service-type sweep
  • resources:unused — CloudWatch metrics-based heuristic per resource type
  • optimize — opinionated recommendations on top of cost + resource data

This is several issues' worth of work. Probably worth filing each as its own follow-up.

Option B — Guard them as not-yet-implemented (tactical fix)

Replace the body of each with:

cli.warn('Not yet implemented — see ts-cloud#NN for tracking')
return

This is honest, preserves the command surface so we don't break docs/help, and prevents acting on mock numbers. Real implementation lands as separate issues per command.

Recommendation

Do Option B now (one PR, prevents the active footgun) and file Option A as 5 separate follow-up issues that link back here. Don't leave mock data sitting in production-shaped commands.

Acceptance

  • No cloud cost* / cloud resources* / cloud optimize command returns mock numbers in its current form.
  • Either each is implemented with real data (Option A) or each prints a clear "not implemented" warning and a tracking-issue link (Option B).
  • cost:analyze (the one real command) is not affected.
  • #103 — bill investigation; surfaced the gap between mock and real data.
  • #104 — cost CLI scope; these stubs predate that ticket.

Sign in to comment on this issue.