diff --git a/README.md b/README.md index 295f67f..d1e0f18 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ LibreChat ──→ Member Portal ──→ LiteLLM ──→ backend | `ALLOWANCE_POLICY` | `report` (default) \| `on`. `report` computes every allowance decision and changes nothing; `on` performs renewals and sends the one reminder. Deactivation is gated separately by `ALLOWANCE_DEACTIVATE`. | | `ALLOWANCE_DEACTIVATE` | `off` (default) \| `on`. When `on`, a member who was reminded and is still unpaid after the grace window is moved to the inactive group. **Defaults off so renewals/reminders can run before anyone loses access.** | | `PAYMENT_GRACE_DAYS` | Days after the single reminder before an unpaid member is deactivated (default `7`). | -| `GUEST_BUDGET` | Guest-account credit in USD (default `5.0`). | +| `GUEST_BUDGET` | Guest-account credit in USD (default `2.0`). | | `GUEST_DAYS` | Guest-account time box in days from provisioning (default `60`). The sweep deactivates an expired guest even with credits left. | | `GUEST_PER_INVITER_DAYS` | Rolling window for the one-guest-per-inviter limit (default `30`). | | `GUESTS_GROUP_ID` | Cloudron group ID for guest accounts. The chat and dashboard apps' access restrictions list BOTH the members and guests groups, so a guest reaches exactly those two apps. | @@ -58,12 +58,12 @@ LibreChat ──→ Member Portal ──→ LiteLLM ──→ backend ## Guest accounts -A member can give a friend access to the co-op with $5 of credits — no Open +A member can give a friend access to the co-op with $2 of credits — no Open Collective membership required. `POST /admin/provision-guest` (X-Admin-Token) with `{"email", "name", "inviter": ""}` runs the guest pipeline: Cloudron user in the **guests** group, a LiteLLM team capped at `GUEST_BUDGET` with **no monthly reset** (the cap is the guest's whole life), the -portal row marked `account_type='guest'` with the $5 held as non-expiring +portal row marked `account_type='guest'` with the $2 held as non-expiring credit, `guest_expires_at` set to now + `GUEST_DAYS`, the guest welcome email (setup link, what they can use, Become-a-member, newsletter note), and a **guests ledger** row (`guests` table: inviter → recipient, expiry, status) for diff --git a/app/main.py b/app/main.py index e0e3816..09946d6 100644 --- a/app/main.py +++ b/app/main.py @@ -336,18 +336,18 @@ OC_PERSONAL_TOKEN = os.environ.get("OC_PERSONAL_TOKEN", "") MEMBER_BUDGET = float(os.environ.get("MEMBER_BUDGET", "15.0")) # --- Guest accounts (operator decisions, 2026-11-08) -------------------------- # -# A member can give a friend access to the co-op with $5 of credits, no Open +# A member can give a friend access to the co-op with $2 of credits, no Open # Collective membership required. The guest is a ONE-TIME non-expiring credit # balance held in the credits model (credit_balance), hard-capped by the # LiteLLM team budget. Two lapse triggers, both handled by the sweep: -# * the $5 is spent (the cap enforces the limit; the sweep deactivates the +# * the $2 is spent (the cap enforces the limit; the sweep deactivates the # row once spend reaches the credit balance), and # * GUEST_DAYS elapse from provisioning — a time box, even with credits left. # Deactivation is the same semantics as a member's: guests group → inactive, # team budget zeroed, row active=0, newsletter unsubscribed. The account is # KEPT so a returning payer resumes cleanly (and the guest→member conversion # still fires if their OC membership appears later). -GUEST_BUDGET = float(os.environ.get("GUEST_BUDGET", "5.0")) +GUEST_BUDGET = float(os.environ.get("GUEST_BUDGET", "2.0")) GUEST_DAYS = float(os.environ.get("GUEST_DAYS", "60")) # One guest per inviting member per rolling 30 days (abuse protection). GUEST_PER_INVITER_DAYS = float(os.environ.get("GUEST_PER_INVITER_DAYS", "30")) @@ -923,7 +923,7 @@ def get_db() -> sqlite3.Connection: if "loomio_invited_at" not in cols: conn.execute("ALTER TABLE members ADD COLUMN loomio_invited_at TEXT") # Migration: account_type — 'member' (default) or 'guest'. Guest accounts are - # provisioned by /admin/provision-guest with $5 of non-expiring credit, live + # provisioned by /admin/provision-guest with $2 of non-expiring credit, live # in the Cloudron "guests" group, and sit outside every membership # obligation: the sweep never deactivates one for lacking an OC # contribution, they are invited to no Loomio/Matrix rooms, and they lapse @@ -1579,7 +1579,7 @@ async def get_active_member_emails() -> list[str]: The local `members` table is the authoritative source of member emails (populated during provisioning). Used for the Loomio sync and the Matrix invite pass. GUEST accounts are excluded: they are not members — they hold - $5 credits, live in the Cloudron guests group, and must never be invited + $2 credits, live in the Cloudron guests group, and must never be invited to Loomio, Matrix or (via these lists) any member service. """ conn = get_db() @@ -2529,7 +2529,7 @@ async def provision_member(email: str, name: str, slug: str = "") -> str: # --- Guest accounts (operator feature, 2026-11-08) --------------------------- # -# A member gives a friend access with $5 of credits: Cloudron user in the +# A member gives a friend access with $2 of credits: Cloudron user in the # guests group (chat + dashboard only), a one-time LiteLLM budget with NO # monthly reset, the portal row marked account_type='guest', the guest welcome # email, and the newsletter subscription. NO Loomio/Matrix invites. See the @@ -2539,7 +2539,7 @@ def guest_invitation_email(name: str, setup_url: str, inviter_name: str = "") -> """Build the guest INVITATION email — the one email a guest sends. This is the guest-time email AND the guest welcome in one: the recipient is - invited in (the inviter named), told what the guest gives ($5 of credits, + invited in (the inviter named), told what the guest gives ($2 of credits, how long access runs), and given the account-setup link. The guest welcome content lives here rather than in a second email — one coherent invitation, not two mails at once. Same branded shell as welcome_email(): cream @@ -2565,7 +2565,7 @@ def guest_invitation_email(name: str, setup_url: str, inviter_name: str = "") -> f"{greet}\n\n" f"{invited_line}.\n\n" "It's a member-governed AI cooperative that runs open models.\n\n" - "Your invitation comes with $5 of credits for the co-op's chat and\n" + "Your invitation comes with $2 of credits for the co-op's chat and\n" f"API. Access runs for {int(GUEST_DAYS)} days from today; the credits\n" "themselves don't expire early.\n\n" "To accept, create your account — it takes about a minute:\n\n" @@ -2596,7 +2596,7 @@ def guest_invitation_email(name: str, setup_url: str, inviter_name: str = "") ->

{h1}

{html_invited} — a member-governed AI cooperative running open models.

-

Your invitation comes with $5 of credits for the co-op's chat and API. Access runs for {int(GUEST_DAYS)} days from today; the credits themselves don't expire early.

+

Your invitation comes with $2 of credits for the co-op's chat and API. Access runs for {int(GUEST_DAYS)} days from today; the credits themselves don't expire early.

Create your account

This takes about a minute.

If you like it, become a member.

@@ -2675,7 +2675,7 @@ def guest_member_congrats_email(name: str, setup_url: str | None) -> tuple[str, def guest_limits_email(name: str, reason: str) -> tuple[str, str, str]: """Build the reaching-limits email for a guest account hitting its limit. - Sent ONCE per guest when the sweep deactivates the guest — either the $5 + Sent ONCE per guest when the sweep deactivates the guest — either the $2 of credits are spent or the GUEST_DAYS time box has run out. Says plainly: the guest access has ended, the account and data are kept, and becoming a member ($15/month via Open Collective) restores access with a full @@ -2734,14 +2734,14 @@ async def provision_guest_member( ) -> str: """Provision a GUEST account end-to-end (operator guest access feature). - A guest gives a friend $5 of credits with no Open Collective membership: + A guest gives a friend $2 of credits with no Open Collective membership: * Cloudron user in the GUESTS group (chat + dashboard only — the two apps' access restrictions list both groups); * a LiteLLM team hard-capped at GUEST_BUDGET with NO monthly reset (budget_duration None — the cap is the guest's whole life); - * the portal row marked account_type='guest' with the $5 held as + * the portal row marked account_type='guest' with the $2 held as non-expiring credit (the credits model) and guest_expires_at set; - * the guest INVITATION email (inviter named, the $5 credits, the + * the guest INVITATION email (inviter named, the $2 credits, the setup link — the invitation and the guest welcome in one) and the newsletter subscription; * a guests-ledger row recording inviter → recipient; @@ -2768,7 +2768,7 @@ async def provision_guest_member( await cloudron_set_group(user_id, GUESTS_GROUP_ID) await cloudron_set_active(user_id, True) - # One-time $5 team: budget_duration None means LiteLLM never resets it. + # One-time $2 team: budget_duration None means LiteLLM never resets it. team_id = await litellm_get_or_create_team(email, GUEST_BUDGET, budget_duration=None) key_token = get_stored_key(email) if not key_token: @@ -2781,9 +2781,9 @@ async def provision_guest_member( guest_ref = f"guest:{email}" if not credit_reference_exists(guest_ref): add_credits(email, GUEST_BUDGET, - reason="guest account — $5 credit from a member", + reason="guest account — $2 credit from a member", reference=guest_ref) - # Guest rows hold NO allowance (balance 0 — the $5 is all credit) and + # Guest rows hold NO allowance (balance 0 — the $2 is all credit) and # anchor their join day at the guest date (kept if they later convert). conn = get_db() conn.execute( @@ -2849,7 +2849,7 @@ async def convert_guest_to_member(email: str, name: str, slug: str = "") -> str: What converts: * the Cloudron user moves guests → members (regaining Loomio/Matrix eligibility through the normal syncs); - * the LiteLLM cap lifts from the $5 guest to the member allowance + + * the LiteLLM cap lifts from the $2 guest to the member allowance + credits — any UNSPENT guest credit stays (it already lives in the non-expiring credit_balance bucket); * the portal row becomes account_type='member' with the standard @@ -3279,7 +3279,7 @@ async def litellm_get_or_create_team(email: str, budget: float, spend draws from the one pool. `budget_duration` is the reset cadence: members renew every 30 days; GUEST - accounts pass None — a one-time budget that NEVER resets, so the $5 cap is + accounts pass None — a one-time budget that NEVER resets, so the $2 cap is the guest's whole life (spend it and it is gone). Idempotent: looks up the existing team by alias before creating. Note that @@ -4221,7 +4221,7 @@ async def admin_provision_guest(request: Request): (ADMIN_INVITER_EMAIL, default info@inference.coop) — the panel has no inviter input, and the ledger records the admin account. - Runs the guest pipeline: Cloudron user in the guests group, a $5 LiteLLM + Runs the guest pipeline: Cloudron user in the guests group, a $2 LiteLLM team with NO monthly reset, the portal row marked as a guest with a GUEST_DAYS expiry, the guest welcome email, the newsletter subscription, and a guests-ledger row recording inviter → recipient. Admin invites @@ -4375,7 +4375,7 @@ async def admin_guest_request_approve(request_id: int, request: Request): """Approve a pending guest request — the trial gate's approval action. Approval fires the FULL guest pipeline (provision_guest_member: Cloudron - user, $5 credit, GUEST_DAYS box, invitation email naming the inviter, + user, $2 credit, GUEST_DAYS box, invitation email naming the inviter, newsletter subscribe, ledger row) — the same path the operator's /admin/provision-guest runs, so every guard re-runs. If state moved since the request (the recipient signed up; another invitation landed), the @@ -6250,7 +6250,7 @@ async def broker_guest_invite(request: Request): pending request, or a MANUAL_MEMBERS address. The guest itself is provisioned ONLY through provision_guest_member — the same pipeline the operator's /admin/provision-guest runs (Cloudron user in the guests - group, $5 non-expiring credit, GUEST_DAYS time box, invitation email + group, $2 non-expiring credit, GUEST_DAYS time box, invitation email naming the inviter, newsletter subscribe, ledger row). Trial gate: with GUEST_AUTO_APPROVE off (the default) the request waits @@ -7047,7 +7047,7 @@ async def reconcile_allowances(send: bool = False) -> dict: welcome_sent = row[6] if len(row) > 6 else None if acct_type == "guest": - # Guest accounts have no OC membership by design — the $5 credit + # Guest accounts have no OC membership by design — the $2 credit # balance and the GUEST_DAYS time box govern them instead. No # renewal decision, no reminder, ever. counts["skipped"] += 1 diff --git a/metrics_snapshot.py b/metrics_snapshot.py index 0907284..9a77030 100644 --- a/metrics_snapshot.py +++ b/metrics_snapshot.py @@ -207,7 +207,7 @@ def from_sqlite() -> dict: """Members, plus the provisioning dates that give the growth curve. Operator/utility accounts are excluded, matching the panel's member count. - GUEST accounts are excluded too: they are $5 guest passes, not members — + GUEST accounts are excluded too: they are $2 guest passes, not members — counting them would move the growth curve the co-op publishes. """ conn = connect() diff --git a/tests/test_guest_cancel.py b/tests/test_guest_cancel.py index abb8e15..208d168 100644 --- a/tests/test_guest_cancel.py +++ b/tests/test_guest_cancel.py @@ -112,7 +112,7 @@ m.listmonk_sync = rec_listmonk m.send_email = rec_email -def seed_gift(conn, email, active=1, credits=5.0, balance=0.0): +def seed_gift(conn, email, active=1, credits=2.0, balance=0.0): conn.execute( "INSERT INTO members (email, key_token, cloudron_user_id, slug, active, " "balance, credit_balance, account_type, guest_expires_at) " @@ -160,11 +160,11 @@ def main(): # --- 3-8. the full cancel flow ------------------------------------------ conn = m.get_db() - seed_gift(conn, "invited@x.org", active=1, credits=5.0) + seed_gift(conn, "invited@x.org", active=1, credits=2.0) # the grant row production writes at provisioning (add_credits on the # guest reference) — the return is audited against it conn.execute("INSERT INTO credit_ledger (email, delta, reason, reference) " - "VALUES ('invited@x.org', 5.0, 'guest account — $5 credit from a member', " + "VALUES ('invited@x.org', 2.0, 'guest account — $2 credit from a member', " "'guest:invited@x.org')") conn.commit() conn.close() @@ -186,9 +186,9 @@ def main(): led = ledger_rows(conn, "invited@x.org") grants = [r for r in led if r[2] == "guest:invited@x.org"] returns = [r for r in led if r[2] == "guest-return:invited@x.org"] - check("cancel: ledger holds the $5 grant and ONE negative return row", - len(grants) == 1 and grants[0][0] == 5.0 and len(returns) == 1 - and returns[0][0] == -5.0, str(led)) + check("cancel: ledger holds the $2 grant and ONE negative return row", + len(grants) == 1 and grants[0][0] == 2.0 and len(returns) == 1 + and returns[0][0] == -2.0, str(led)) check("cancel: return reason names the cancellation and the guest reference", len(returns) == 1 and "cancelled by recipient" in returns[0][1] and "guest:invited@x.org" in returns[0][1], str(returns)) @@ -198,7 +198,7 @@ def main(): g and g[0] == "member-one@x.org" and g[1] == "invited@x.org" and g[2] == "cancelled by recipient", str(g)) check("cancel: result reports the returned amount", - out.get("status") == "cancelled" and out.get("credits_returned") == 5.0, str(out)) + out.get("status") == "cancelled" and out.get("credits_returned") == 2.0, str(out)) conn.close() # --- 9. idempotence: the second cancel is a no-op ----------------------- @@ -260,11 +260,11 @@ def main(): } check("status: cancelled guest reads ended + cancelled + amount returned", st_cancelled["ended"] and st_cancelled["cancelled"] - and st_cancelled["credits_returned"] == 5.0, str(st_cancelled)) + and st_cancelled["credits_returned"] == 2.0, str(st_cancelled)) # live guest: active with remaining credits conn = m.get_db() - seed_gift(conn, "live@x.org", active=1, credits=5.0) + seed_gift(conn, "live@x.org", active=1, credits=2.0) conn.commit() conn.close() st_live = { diff --git a/tests/test_guest_lifecycle.py b/tests/test_guest_lifecycle.py index eddf37c..b514916 100644 --- a/tests/test_guest_lifecycle.py +++ b/tests/test_guest_lifecycle.py @@ -2,7 +2,7 @@ """Guest-account lifecycle tests — structurally isolated from live services. WHY THIS EXISTS - Guest accounts (operator feature, 2026-11-08) touch money ($5 of credits), + Guest accounts (operator feature, 2026-11-08) touch money ($2 of credits), Cloudron groups and email. Every path proven here runs against a FIXTURE database with the network layer REPLACED BY A RAISING GUARD: any code path that tries to reach Cloudron, LiteLLM, OC, Listmonk, Loomio, Matrix or SMTP @@ -237,12 +237,12 @@ def main(): conn = m.get_db() check("provision: row marked guest", row_of(conn, "invited@x.org", "account_type") == "guest") check("provision: allowance balance 0", row_of(conn, "invited@x.org", "balance") == 0.0) - check("provision: $5 credit", row_of(conn, "invited@x.org", "credit_balance") == 5.0) + check("provision: $2 credit", row_of(conn, "invited@x.org", "credit_balance") == 2.0) check("provision: guest_expires_at set", bool(row_of(conn, "invited@x.org", "guest_expires_at"))) check("provision: group = guests group", calls["group"] and calls["group"][0][1] == m.GUESTS_GROUP_ID, str(calls["group"])) - check("provision: cap set to 5.00 (one-time)", - (calls["budget"] and calls["budget"][0][1] == 5.0), str(calls["budget"])) + check("provision: cap set to 2.00 (one-time)", + (calls["budget"] and calls["budget"][0][1] == 2.0), str(calls["budget"])) check("provision: invitation email sent (merged invite + welcome)", any("invited to the Inference Cooperative" in s for _, s in calls["email"]), str(calls["email"])) check("provision: newsletter subscribed", @@ -264,11 +264,11 @@ def main(): check("convert: allowance lifted to MEMBER_BUDGET", row_of(conn, "invited@x.org", "balance") == m.MEMBER_BUDGET) check("convert: unspent guest credit carried", - row_of(conn, "invited@x.org", "credit_balance") == 5.0) + row_of(conn, "invited@x.org", "credit_balance") == 2.0) check("convert: group moved to members", calls["group"] and calls["group"][0][1] == m.MEMBERS_GROUP_ID, str(calls["group"])) - check("convert: cap lifted to 20.00 (15 + 5 credits)", - (calls["budget"] and calls["budget"][0][1] == m.MEMBER_BUDGET + 5.0), str(calls["budget"])) + check("convert: cap lifted to 17.00 (15 + 2 credits)", + (calls["budget"] and calls["budget"][0][1] == m.MEMBER_BUDGET + 2.0), str(calls["budget"])) check("convert: anchor day kept", row_of(conn, "invited@x.org", "anchor_day") == anchor_before) check("convert: congrats email sent", any("member now" in s for _, s in calls["email"]), str(calls["email"])) diff --git a/tests/test_guest_requests.py b/tests/test_guest_requests.py index 7049c11..5189ffa 100644 --- a/tests/test_guest_requests.py +++ b/tests/test_guest_requests.py @@ -2,7 +2,7 @@ """Member self-serve guest requests — structurally isolated from live services. WHY THIS EXISTS - The member path creates REAL guest accounts ($5 of credits, Cloudron users, + The member path creates REAL guest accounts ($2 of credits, Cloudron users, invitation email) once approved, and the trial gate decides when. Every path proven here runs against a FIXTURE database with the network layer REPLACED BY A RAISING GUARD: any code path that tries to reach Cloudron, LiteLLM, OC, @@ -25,7 +25,7 @@ WHY THIS EXISTS members invite guests. APPROVAL (the panel action) 9. Approve fires the FULL guest pipeline: row marked account_type='guest', - $5 credit, ledger row inviter → recipient, the invitation email (the + $2 credit, ledger row inviter → recipient, the invitation email (the INVITING member named in it), newsletter subscribe — and the request row becomes 'approved'. 10. Approving a request whose guard now refuses (state moved) records the @@ -306,7 +306,7 @@ def main(): "SELECT account_type, balance, credit_balance FROM members WHERE email = ?", ("friend@x.org",)).fetchone() check("approve: recipient row marked guest", acct and acct[0] == "guest", str(acct)) - check("approve: $5 non-expiring credit", acct and acct[2] == 5.0, str(acct)) + check("approve: $2 non-expiring credit", acct and acct[2] == 2.0, str(acct)) ledger = conn.execute( "SELECT inviter_email, recipient_email, status FROM guests WHERE recipient_email = 'friend@x.org'" ).fetchall()