Skip to content

feat: add podcast episode unit economics - #276

Open
i-xtsu-sixyou-ken-mei wants to merge 13 commits into
mainfrom
feat/podcast-unit-economics-dashboard
Open

feat: add podcast episode unit economics#276
i-xtsu-sixyou-ken-mei wants to merge 13 commits into
mainfrom
feat/podcast-unit-economics-dashboard

Conversation

@i-xtsu-sixyou-ken-mei

Copy link
Copy Markdown
Collaborator

Summary

  • expose per-episode podcast/video unit economics from the existing ops.pipeline_* ledger
  • show podcast, video, total cost, retry waste, stage/language breakdown, and unpriced operations in Control Center Costs
  • attribute the shared visual/storyboard job's Fly compute to the episode using the existing render-machine rate card
  • keep shared Fly infrastructure/monthly invoice accounting in the provider ledger; Sentry remains error observability only

Cost semantics

  • ingest provider-reported costs remain the podcast variable cost
  • localization render costs remain Fly rate-card estimates
  • shared visual work is priced as visual processor wall time × the same Fly render-machine rate card
  • retry waste is a subset of total cost: spend attached to failed pipeline runs
  • always-on/shared Fly costs are intentionally not allocated to episodes

Tests

  • adds aggregation coverage for ingest vs video vs retry waste and unpriced stages
  • adds shared visual Fly rate-card attribution coverage

No new infrastructure or Sentry heartbeat/uptime accounting is introduced.

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
zap-engine-frontend Canceled Canceled Aug 28, 2026 1:36pm
zap-engine-landing-page Canceled Canceled Aug 28, 2026 1:36pm

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20221dcb3e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.select('id,pipeline,episode_id,status,started_at')
.not('episode_id', 'is', null)
.order('started_at', { ascending: false })
.limit(RUN_LIMIT);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Aggregate all runs for each displayed episode

When an older episode receives a recent render or retry, it enters this result set even though its ingest and earlier render runs may fall outside the global newest-200 cutoff. The response then presents the resulting subtotal as that episode's total unit cost, silently understating podcast cost, retry waste, and run counts; select the displayed episode IDs first and retrieve their complete run histories, or otherwise indicate that the values are partial.

Useful? React with 👍 / 👎.

'run_id,episode_id,language_code,stage,status,estimated_cost_usd,pricing_basis',
)
.in('run_id', runIds)
.limit(2_000),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Paginate all stage rows before summing costs

When the selected 200 runs contain more than 2,000 stage rows, this query returns only a subset, without an ordering or truncation signal. summarizePodcastCosts consequently reports incomplete totals, breakdowns, and unpriced-operation counts as authoritative values; paginate the stage query or aggregate the complete set in the database.

Useful? React with 👍 / 👎.

episodeId: job.episode_id,
runRef: context.runId,
attempt: job.attempt_count,
status: 'completed',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Mark the visual run complete only after persistence

When visual processing returns but visualRepository.complete(...) later fails, loses the lease, or is skipped because shutdown aborts the context, this wrapper has already recorded the attempt as completed. The worker then treats the same attempt as failed and retries it, but the dashboard excludes its spent compute from retry waste and reports a completed run; record the outcome at the claimed-job lifecycle boundary after the repository completion succeeds.

Useful? React with 👍 / 👎.

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