Skip to content

Tier settings - #183

Open
agualdron wants to merge 24 commits into
stagingfrom
feat/tier-settings
Open

Tier settings #183
agualdron wants to merge 24 commits into
stagingfrom
feat/tier-settings

Conversation

@agualdron

Copy link
Copy Markdown
Collaborator

Summary

Adds billing-tier workflow execution time limits and private subscription tiers.

This PR:

  • Captures the applied billing tier, tier name, execution limit, and absolute deadline when a workflow begins.
  • Enforces deadlines across synchronous, queued, nested, retried, and background executions.
  • Adds durable lifecycle state, projections, fencing, reconciliation, cancellation, and outbox processing.
  • Cancels active Trigger.dev runs and supported durable provider operations during termination.
  • Displays the applied tier name and limit when an execution ends with WORKFLOW_EXECUTION_TIME_LIMIT_EXCEEDED.
  • Adds private-tier access codes, user access grants, subscription selection, and administration controls.
  • Updates the TypeScript and Python SDKs with workflow deadline metadata.
  • Includes associated billing, subscription, workflow editor, dropdown, log details, and widget fixes.

Why

Workflow execution limits need to reflect the subscriber's billing tier and remain consistent across retries, queues, nested executions, and external operations.

Private tiers also need a controlled discovery mechanism so authorized users can access non-public subscription options without exposing them in the public catalog.

Type of Changes

  • New feature
  • Bug fix
  • Breaking change
  • Documentation
  • Other: Database migration and durable workflow execution infrastructure

The SDK changes are additive. The database and runtime changes require a coordinated rollout.

Affected Areas

  • apps/tradinggoose
  • apps/docs
  • packages/*
  • Workflows / execution
  • Realtime / sockets
  • Market data / charting
  • Dev tooling / CI / infra
  • Documentation only
  • Other: Billing tiers, subscriptions, administration, database schema, and SDKs

Validation

  • bun run test:billing:suite

    • Passed: 28 files and 124 tests.
  • Focused workflow and execution Vitest suite.

    • Passed: 20 files and 204 tests.
  • TypeScript SDK tests.

    • Passed: 21 tests.
  • TypeScript SDK build.

    • Passed.
  • python -m compileall packages/python-sdk/tradinggoose

    • Passed.
    • Python SDK tests were added, but pytest was unavailable in the validation environment.
  • git diff --check origin/staging...HEAD

    • Passed.
  • Localization validation.

    • Checked 1,900 catalog files and 11,718 used keys.
    • Passed with zero missing keys and zero target-locale gaps.
  • Application-wide typecheck.

    • Blocked by two pre-existing errors in unchanged staging files:
      • apps/tradinggoose/app/api/routes.test.ts
      • apps/tradinggoose/app/api/webhooks/route.ts
  • Root lint.

    • Blocked by the repository's existing lint backlog.
    • Focused formatting and style validation for changed files passed.

Tests were added or updated for workflow policies, lifecycle persistence, projections, termination reconciliation, queued execution, provider operations, billing tiers, private-tier access, subscriptions, UI components, and both SDKs.

Reviewer Focus

Please focus on:

  • Deadline capture and preservation across retries and nested executions.
  • Arbitration between completion, failure, cancellation, infrastructure failure, and deadline expiry.
  • Reconciliation, claims, and fencing under concurrent workers.
  • Cancellation of Trigger.dev runs and durable provider operations.
  • Private-tier authorization, access-code handling, and subscription eligibility.
  • Migration constraints and deployment compatibility.
  • Admin tier creation and editing.
  • Subscription selection and private-tier redemption.
  • Workflow timeout details showing the tier name rather than its identifier.
  • SDK deadline field naming and serialization.

Risk / Rollout Notes

  • Apply 0040_gigantic_morlun.sql before deploying application and worker code that depends on the new schema.
  • Deploy the web application and workflow workers together to avoid mixed lifecycle behavior.
  • Monitor termination reconciliation retries, unresolved provider operations, outbox backlog, and deadline enforcement latency.
  • External cancellation is eventually consistent and depends on provider availability.
  • Private-tier access codes should be created with sufficient entropy and handled as credentials.
  • Application rollback can use the previous application and worker versions while leaving the additive schema in place.

Config / Data Changes

  • Env vars added or changed: None.
  • Database schema or migration impact: Adds private-tier access, workflow execution limits, lifecycle events, attempts, operations, projections, terminal state, and outbox persistence through 0040_gigantic_morlun.sql.
  • External services or provider behavior changed: Trigger.dev runs and supported Apify, Exa, Firecrawl, and Browser Use operations can be cancelled or reconciled when workflow termination begins.

Screenshots / Video

image

Recommended visual verification:

  • Create and edit public and private billing tiers.
  • Confirm the capacity fields use the intended two-column layout.
  • Redeem a private-tier access code and select the unlocked subscription.
  • Confirm timeout log details show the applied tier name.
  • Confirm dropdowns render without Base UI portal errors.
  • Confirm widget close controls work correctly.

Checklist

  • I kept the change focused and reviewed my own diff
  • I validated the change locally and documented the results above
  • I updated docs, examples, or copy if behavior/user-facing flows changed
  • I called out any env, schema, provider, or rollout impact
  • I did not include secrets, tokens, or private credentials in this PR

Record the branch changes against origin/staging, including workflow
execution deadlines, durable lifecycle ownership, and private tiers.

Document canonical helpers, replaced cancellation paths, deployment
considerations, validation results, and guardrails for future branches.
@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds tier-based workflow execution deadlines and private subscription tiers, together with durable execution lifecycle handling and SDK metadata.

  • Captures and propagates billing-tier execution limits across workflow entry points, queues, retries, nested runs, and provider operations.
  • Adds lifecycle events, projections, fencing, reconciliation, termination, cancellation, and outbox processing.
  • Adds private-tier access-code redemption, eligibility policies, administration, subscription selection, and localized UI.
  • Extends the TypeScript and Python SDK contracts with workflow deadline metadata.

Confidence Score: 5/5

The PR appears safe to merge because no eligible blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/tradinggoose/lib/execution/workflow-execution-runtime.ts Coordinates captured execution deadlines with runtime lifecycle and terminal-state handling.
apps/tradinggoose/lib/execution/workflow-execution-lifecycle-repository.ts Adds durable lifecycle persistence and concurrency-aware state transitions.
apps/tradinggoose/background/workflow-execution-termination-reconcile.ts Reconciles deadline-driven termination and unresolved external cancellation work.
apps/tradinggoose/lib/billing/tiers.ts Extends tier resolution with workflow limits and private-tier access grants.
apps/tradinggoose/lib/billing/core/subscription.ts Updates effective subscription and tier entitlement behavior for the expanded tier model.
apps/tradinggoose/app/api/billing/private-tier-access/route.ts Adds authenticated private-tier access-code redemption.
packages/ts-sdk/src/index.ts Adds workflow deadline metadata to the TypeScript SDK contract.
packages/python-sdk/tradinggoose/init.py Adds corresponding workflow deadline metadata to the Python SDK.

Sequence Diagram

sequenceDiagram
  participant Entry as Workflow entry point
  participant Policy as Billing tier policy
  participant Queue as Pending execution queue
  participant Worker as Execution worker
  participant Lifecycle as Lifecycle repository
  participant Provider as Durable provider
  participant Reconciler as Termination reconciler

  Entry->>Policy: Capture applied tier and time limit
  Policy-->>Entry: Absolute deadline and tier metadata
  Entry->>Queue: Enqueue execution with captured deadline
  Queue->>Worker: Claim execution attempt
  Worker->>Lifecycle: Record attempt and lifecycle events
  Worker->>Provider: Start supported operation
  alt Execution completes before deadline
    Worker->>Lifecycle: Arbitrate terminal completion
  else Deadline expires
    Worker->>Lifecycle: Begin fenced termination
    Worker->>Provider: Request cancellation
    Reconciler->>Lifecycle: Reconcile unresolved termination
    Reconciler->>Provider: Retry cancellation or status check
    Reconciler->>Lifecycle: Finalize terminal projection
  end
Loading

Reviews (2): Last reviewed commit: "docs(changelog): document workflow lifec..." | Re-trigger Greptile

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