Skip to content

Offer free Luna with a configurable weekly allowance and upgrades - #4620

Closed
reachjalil wants to merge 2 commits into
feature/new-install-signinfrom
feature/luna-weekly-allowance
Closed

reachjalil wants to merge 2 commits into
feature/new-install-signinfrom
feature/luna-weekly-allowance

Conversation

@reachjalil

Copy link
Copy Markdown
Member

Stack

Parent: #4619 (feature/new-install-signin), above #4608. This PR adds the free managed-model offer; it does not repeat the installation gate or change legacy sign-in policy.

Experience

  • Offer standard openai/gpt-5.6-luna through OpenWork inference without a paid subscription.
  • Default allowance: USD 1 of actual inference usage per person per week, configurable server-side. Monday 00:00 UTC reset, no rollover, one allowance across devices, keys and organizations.
  • Initialize Luna once for the new-install cohort after verified sign-in and provider readiness. Preserve explicit selections, existing conversations and legacy defaults; paid/BYOK repair stays available.
  • Selecting another OpenWork-managed model offers the existing Models upgrade path and retains the current model/draft. Exhaustion shows the reset and upgrade guidance. Non-admins get administrator guidance. Local/OpenCode and organization BYOK are not paywalled by these prompts.
  • Account/org-scoped status is exposed through member-readable GET /v1/inference/access; the SDK and both clients use the shared reason contract. In-flight usage remains free access, not lost entitlement.

Metered allowance, not a strict pre-reserved dollar ceiling

Admission checks actual weekly usage before generation and permits one unsettled request per person. Requests are limited to 32 KiB supplied input, 128 KiB wire size and 4,096 output tokens, including reasoning. The final admitted reply may exceed the weekly dollar amount. Future calls are then blocked. This is the intended usage-metered policy, not a guarantee of zero overage.

Actual provider cost settles transactionally from the terminal response or authenticated webhook. Missing receipts retain the hold and request manual retry rather than granting fresh capacity. Late/repeated receipts charge only the original person/week once. reservedUsd is an estimate, not billed cost. Another managed model and exhausted usage return explicit 402 upgrade errors; a request already running returns a non-upsell 423.

Paid policies, paid upstream keys and BYOK remain separate. Admin disablement cannot be silently overridden. Free keys are not distributed to organization-wide shared workers.

Configuration and migration

  • Apply additive migration 0093_free_inference_allowance before enabling. The large generated snapshot is schema metadata.
  • Mirror non-secret INFERENCE_FREE_ENABLED, INFERENCE_FREE_WEEKLY_BUDGET_USD and INFERENCE_FREE_MODEL_ID in Den and inference. Defaults are disabled, USD 1, standard Luna.
  • Configure INFERENCE_FREE_UPSTREAM_API_KEY only in inference and retain authenticated usage export. No shared upstream key is delivered to clients.
  • Production flags, credentials, billing and subscriptions were not changed. No paid upstream calls were made.
  • Details: ee/apps/inference/FREE_ALLOWANCE.md and ee/apps/den-api/FREE_ALLOWANCE.md.

Verification — Incomplete

Exact head: 00b1b9b77bd750ce5996712ba21666dc0319d873.

Passed

  • pnpm evals:pr specs/free-inference-allowance.test.ts — exit 0, 1 passed, 0 failed, 0 skipped, on this exact head. The PR lane used the existing local MySQL prerequisite with an isolated disposable database; it does not print the E2E placement banner. Real inference HTTP service and SQL accounting; only upstream generation is synthetic.
  • Journey assertions cover successful JSON/fragmented-SSE responses, request caps, paid-model denial before upstream, final overage followed by denial, person-wide accounting across memberships/keys, independent-person concurrency, single-person serialization, rollover with held usage, revoked keys, invalid/late/replayed receipts, response/webhook races and database cleanup. Paid ledger and other people are checked unchanged.
  • App and Den Web typechecks after inheriting the sign-in parent; inference/Den source types; pnpm sdk:check; catalog validation.
  • Focused implementation checks: 94 inference tests, 71 UI/access tests, 38 Stripe tests; real-DB provider/access coverage and member-credential regression. These supplement the journey, not replace UI evidence.

Deferred / Incomplete

  • Full end-to-end new installation → sign-in → free Luna response → paid-model selection/exhaustion upsell is not yet proven. The picker/error journeys were extended, but their positive free-access runtime path has not been executed.
  • No real Luna generation, live upstream usage export, live checkout, production migration or rollout. Missing provider receipts intentionally block more free requests until reconciled; no timeout refunds.
  • Non-text/unsupported free-input formats and organization-wide worker credentials remain outside the initial free offer.
  • Parent Require sign-in only for new desktop installations #4619 has its own exact-head four-test desktop proof; it is not substituted for this child's missing integrated UI proof.

Overlap and deployment boundary

#4471 changes overlapping paid managed-inference accounting and capability surfaces. This free ledger/entitlement is isolated, paid behavior is retained, and #4471 is untouched; reconcile both diffs before integration.

Both stack branch names are disabled in all four Vercel Git deployment configs before publication. GitHub reports no deployment records for either branch. No Vercel deployment command, merge or release is included. Merge bottom-up only after separate approval and fresh exact-head checks.

@reachjalil

Copy link
Copy Markdown
Member Author

Test evidence — free-luna-meters-a-person-s-actual-weekly-usage-across-keys-organizations-and-la — ✅ passed

SHA 00b1b9b · engine v1

✅ passed · 4 expectations passed · 0 failed · 0 pending

screenshots not attached (gh < 2.99; run brew upgrade gh)

verdict passed · 0 user observations · 0 probes · steps 0/0

ℹ️ ASSERTION — 1. Actual usage, not estimates, consumes one USD per person per Monday UTC week

HTTP 200 replies reached the fixture; SQL settled 0.25 + 0.50 + 0.50 USD. All three keys then received 402 without upstream; the second person and paid ledger stayed unchanged.

  • ✅ PASS Actual usage, not estimates, consumes one USD per person per Monday UTC week — HTTP 200 replies reached the fixture; SQL settled 0.25 + 0.50 + 0.50 USD. All three keys then received 402 without upstream; the second person and paid ledger stayed unchanged.

ℹ️ ASSERTION — 2. Person locking neither deadlocks independent first use nor admits two requests for one person

Two independent first admissions completed concurrently; two cross-organization keys for a fresh person produced exactly one upstream call and HTTP 200/423, with a retained SQL hold when usage.cost was missing.

  • ✅ PASS Person locking neither deadlocks independent first use nor admits two requests for one person — Two independent first admissions completed concurrently; two cross-organization keys for a fresh person produced exactly one upstream call and HTTP 200/423, with a retained SQL hold when usage.cost was missing.

ℹ️ ASSERTION — 3. Old-week missing usage blocks new admission until an authenticated original-week receipt settles once

423 survived explicit rollover seeding; invalid signature and wrong identity did not release the hold. Late and replayed receipts charged only the old week. An active key then used the fresh one-USD week; the revoked key remained denied.

  • ✅ PASS Old-week missing usage blocks new admission until an authenticated original-week receipt settles once — 423 survived explicit rollover seeding; invalid signature and wrong identity did not release the hold. Late and replayed receipts charged only the old week. An active key then used the fresh one-USD week; the revoked key remained denied.

ℹ️ ASSERTION — 4. Response usage and signed webhook fallback cannot double-charge

Racing the final SSE usage against the authenticated webhook settled exactly 0.25 USD once; replay left SQL unchanged, the independent person unchanged, and paid accounting empty.

  • ✅ PASS Response usage and signed webhook fallback cannot double-charge — Racing the final SSE usage against the authenticated webhook settled exactly 0.25 USD once; replay left SQL unchanged, the independent person unchanged, and paid accounting empty.

Test run created 2026-09-08T12:18:36.003Z · Source: evals/results/test-runs/2026-09-08T12-18-36-003Z-free-luna-meters-a-person-s-actual-weekly-usage-across-keys-organizations-and-la/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4620 --test-run 2026-09-08T12-18-36-003Z-free-luna-meters-a-person-s-actual-weekly-usage-across-keys-organizations-and-la

@benjaminshafii

Copy link
Copy Markdown
Member

@reachjalil I think we should just go full free I have a branch ready PR is coming up soon

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.

2 participants