Commit Graph
246 Commits
Author SHA1 Message Date
inference-bot d10b36ed34 credits: an adjustment below the drawn amount must not eat the next pack
ci/woodpecker/push/woodpecker Pipeline was canceled
credits_drawn could exceed credit_balance after an admin set/correction (or a
negative adjustment), so a later pack was only partly usable: available =
max(0, purchased - drawn) swallowed the difference. Cap credits_drawn at the
row's balance on every add_credits movement; ledger history is unchanged.
Tests cover reduction-then-repurchase.
2026-11-27 22:05:19 +00:00
inference-bot a70dd6ab4c guests: only UNSPENT credit carries into membership
ci/woodpecker/push/woodpecker Pipeline was canceled
A guest has no monthly cycle, so nothing ever drew their spend against the $2
pack. Conversion kept the full credit_balance, handing back credits already
used — guest-access.md promises only the unspent credit carries over.

record_guest_conversion_draw() writes the consumed part as a negative ledger
row (reference guest-convert-draw:<email>) and bumps credits_drawn, capped by
the row's credit and idempotent on replay. Tests cover draw, replay, cap, and
the resulting remaining figure.
2026-11-27 22:03:43 +00:00
inference-bot 18a4447aa2 usage: handle an uncapped team in /broker/usage
ci/woodpecker/push/woodpecker Pipeline was canceled
An operator account has team max_budget NULL (no cap). broker_get_usage only
assigned balance when max_budget was not None, so the DB path left 'balance'
unbound and the HTTP fallback read the same name before assignment — a 500 for
exactly the accounts the uncapped policy created. Initialise balance from the
member's allowance + credits still available, mark the response uncapped when
the team row has no cap, and keep the dashboard arithmetic defined.
2026-11-27 21:58:34 +00:00
inference-bot 3e01f727c2 credits: defer a clawback cap that would fall under recorded spend
ci/woodpecker/push/woodpecker Pipeline was canceled
Applying the draw mid-cycle used to push max_budget below the member's
already-recorded spend, so LiteLLM refused every call until their next reset
(weeks for some anchors). The draw is still recorded immediately — books are
correct — but the cap is only pushed once the member's spend has room for it,
which happens right after LiteLLM's reset. The tick retries every 10 minutes,
so the cap lands at the first tick after the boundary; deferred members are
reported in close_credit_cycles().deferred.

tests/test_credit_cycle_close.py covers draw-recorded/cap-deferred and the
cap landing after spend resets, with no second draw.
2026-11-27 21:35:02 +00:00
inference-bot 0296f8d066 credits: infer anchor days for org-backed members
ci/woodpecker/push/woodpecker Pipeline was canceled
The allowance reconcile skips rows with org_slug (dues are paid by an OC
Organization, not an individual order), so org members never got an anchor_day
and close_credit_cycles skipped them forever — their packs regenerated monthly,
the same defect as #12.

- fetch_org_join_days(): paginated OC members walk, ORGANIZATION accounts only,
  slug -> membership createdAt.
- reconcile_org_anchors(): for every active org-backed row with anchor_day NULL,
  set anchor = org join day clamped to 1..28 and pin the team reset to its next
  occurrence. Only NULL rows are touched (idempotent); an org with no OC record is
  reported, never guessed, and keeps being reported until resolved.
- Runs in /admin/sweep and immediately in the org-member webhook path.

tests/test_org_anchors.py: anchor math incl. clamp, reset pin, idempotence,
unresolved reporting.
2026-11-27 21:23:24 +00:00
inference-bot 97f0d6c3f1 credits: uncapped operator accounts; no cap for info@
ci/woodpecker/push/woodpecker Pipeline was canceled
Operator/infrastructure accounts are a collective expense, not members: applying
the $15 + credits cap to them cuts the co-op's own tooling off mid-task.

- UNCAPPED_EMAILS (defaults to OPERATOR_EMAILS) is cleared in
  sync_team_budget_from_balance via litellm_clear_team_budget: max_budget = NULL
  on the team row (unlimited), written directly because /team/update drops
  budget_reset_at.
- sync_team_budget_from_balance returns None for an uncapped account; admin
  responses report team_budget: null rather than a computed figure.
2026-11-27 21:19:52 +00:00
inference-bot fe898905b4 credits: close each cycle so a pack cannot be spent twice (#12)
ci/woodpecker/push/woodpecker Pipeline failed
LiteLLM zeroes a team's `spend` at budget_reset_at but leaves max_budget
alone, and nothing in the portal ever reduced credit_balance. So every
monthly reset restored every credit pack already spent: a $15 member who
bought $50 and used all $65 got $65 again the next month.

Fix — record the draw when a cycle closes:
- new `members.credits_drawn` (credits consumed in CLOSED cycles);
  credit_balance stays the lifetime purchased total so the "bought all-time"
  display never changes meaning.
- `compute_max_budget` caps at allowance + credits STILL AVAILABLE
  (purchased − drawn). Spend inside the current cycle still does not shrink
  the cap, so a credit add keeps raising it 1:1.
- `apply_cycle_draw` writes a NEGATIVE credit_ledger row per closed cycle,
  deduped on reference `cycle-close:<email>:<cycle>`; the cycle's spend is
  summed from LiteLLM_SpendLogs over the exact anchor-day window.
- `close_credit_cycles` runs every 10 min via the new Cloudron scheduler task
  (credit_cycle_close.sh) and again as a catch-up inside /admin/sweep.
- CREDIT_CLOSE_FROM (default 2026-11-28) stops it charging cycles that
  started before the fix: credits already regranted are forgiven rather than
  clawed back mid-cycle.
- /admin/credits/{email} now reports credits_drawn.

Tests: tests/test_credit_cycle_close.py covers the cap arithmetic, the
issue's worked example, draw idempotence and the available-credit cap.
2026-11-27 20:29:12 +00:00
inference-bot 9ab8156da2 fx: baseline the spot check at the written fallback pin, not a stale 1.16
ci/woodpecker/push/woodpecker Pipeline failed
The sweep compared the ECB rate to a hardcoded 1.16 and emailed info@ with
"-5.39%" plus advice to "re-convert" — obsolete since fx_sync.py converts at
boot. The steady breach also froze the alert marker, so a later, real move
could never mail.

- Default baseline 1.0975 (the gateway's FX_FALLBACK_USD pin, ECB 2026-11-26);
  runtime value set via FX_POLICY_EUR_USD.
- Email now says live billing is unaffected by conversion and points at the
  stale artifacts (config fallback, ops pricing tables, fx_state.json).
2026-11-27 17:58:01 +00:00
inference-bot b3de608170 membership events: durable lapse/reactivation log
ci/woodpecker/push/woodpecker Pipeline failed
2026-11-24 19:41:00 +00:00
inference-admin 419b1f4322 matrix sync: skip a member's remaining rooms after a transport error
ci/woodpecker/push/woodpecker Pipeline was canceled
An unreachable remote homeserver hangs every invite POST to that member until
the client timeout (8 rooms x 30s), which outlived the 5-minute service-sync
tick and starved every member queued behind it. Raise a member-scoped
_TransportError instead of returning False, skip that member's remaining rooms
for this pass, and report transport_skipped in the result. Invites stay
idempotent, so the next pass retries.

Test: a timed-out member is attempted once, not once per room.
2026-11-23 14:26:03 +00:00
inference-bot db0c09e85d orders: docstring matches the paginated read (no fixed window) 2026-11-23 03:36:33 +00:00
inference-bot c60dc2c482 orders: read every page, never a fixed 200-order window
The collective crossed 200 orders on 2026-11-23 (203). fetch_member_orders()
asked for orders(limit: 200) in one request, so the orders beyond the window —
the OLDEST ones, where long-standing members' recurring contributions live —
were absent from the sweep's read. Three paying members (ntnsndr,
elizabeth-barry1, guest-0f6d98ac) therefore read as "no recurring (monthly)
contribution on Open Collective" and were sent a payment reminder at 03:02 UTC
for contributions that were live and charged on 2 Nov.

fetch_oc_monthly_order_charges() had the same fixed window, hiding the oldest
orders' charge ladders from the shortfall credit pass.

Both now page by offset until OC's totalCount is covered, and a read that falls
short of totalCount RAISES instead of returning a short list: a short list is
the exact shape that reads as "nobody is paying".
2026-11-23 03:34:49 +00:00
inference-bot ffed06d492 loomio sync: a stamp must not outlive the membership
ci/woodpecker/push/woodpecker Pipeline failed
The invite stamp meant 'handed to Loomio once, EVER', so a member whose
membership was later revoked (a lapse that was reversed) or who deleted
their Loomio account was recorded as invited and never invited again.

- Stamp only the addresses Loomio actually returns in added_emails; an
  address accepted in the payload but not added stays eligible.
- Clear the stamp for an ACTIVE member stamped-but-absent from the live
  roster; the invite itself waits one pass so a single stale page cannot
  become an invite.
- Cap stamp clearing per pass (LOOMIO_RECONCILE_MAX, default 10): more
  stamped-but-absent members means a short roster read, not a mass
  re-invite.
- loomio_opt_out exempts members who deliberately left.
- Username fix falls back to the portal slug when a handle is already
  taken (Loomio handles are instance-global; every OC alias resolves to
  opencollective).
2026-11-22 19:45:20 +00:00
inference-bot b761136dd9 unmapped backers: a plain donation is not a member finding
ci/woodpecker/push/woodpecker Pipeline was canceled
A no-tier BACKER is only a member when it predates the tier system
(LEGACY_NO_TIER_BEFORE). Treating every no-tier BACKER as memberish made
the $75 Workers.VC donation mail info@ as a paid contributor with no
account. Mirror fetch_members() exactly; donations stay silent, and only
unattached credit packs keep the hold-and-notify path.
2026-11-21 19:42:36 +00:00
inference-bot a4b6aa5357 matrix sync: a transport error on one invite must not abort the pass
An httpx.ReadTimeout during an invite POST raised out of sync_matrix_space,
so every member after the timed-out one got nothing and the service-sync log
said only 'Matrix sync failed:' (httpx transport exceptions stringify to '').
One new member sat uninvited for a day that way.

- invite(): catch httpx.HTTPError per member/room, log the type, return False
- pass counts only members whose invite actually returned True
- room-membership snapshot, the retire half and the Cloudron users walk no
  longer abort on a transport error; the unreadable room/member is skipped
- service-sync now logs the exception TYPE (empty str(e) hid the cause)

Regression in tests/test_service_invites.py section 7: a timed-out member does
not stop the member after them, and the next pass retries them.
2026-11-21 18:20:00 +00:00
inference-admin 34f2eeddd7 security: reject hostile tokens cleanly and record webhook sources
secrets.compare_digest raises TypeError on str containing non-ASCII, so a
webhook path token or header token with one answered 503/500 instead of
401/403 — a scanner manufactured a false money-critical alert on 2026-11-20.
Compare UTF-8 bytes through _secret_eq and fail closed on empty.

webhook_failures now stores ip and user_agent; the sweep email names each
source and distinguishes a probe from an Open Collective delivery.
2026-11-20 20:08:12 +00:00
inference-admin 3c36bdf2a9 security: cap MXID verification DMs per member per day
ci/woodpecker/push/woodpecker Pipeline was canceled
2026-11-20 10:01:47 +00:00
inference-admin 637a8aed13 security: require timestamped HMAC on the key feed when configured
ci/woodpecker/push/woodpecker Pipeline was canceled
2026-11-20 00:18:43 +00:00
inference-admin 504200e011 security: queue Matrix invites after MXID verification instead of blocking the request
ci/woodpecker/push/woodpecker Pipeline failed
2026-11-20 00:06:37 +00:00
inference-admin dc7c381bd8 security: verify control of external MXIDs before inviting (one-time Matrix DM code)
ci/woodpecker/push/woodpecker Pipeline failed
2026-11-20 00:01:23 +00:00
inference-admin 3a2d6088f2 security: expose MXID change date to the admin panel
ci/woodpecker/push/woodpecker Pipeline failed
2026-11-19 23:44:10 +00:00
inference-admin a215b5f9c9 security: bound MXID changes, preserve Cloudron groups, refuse guest invites onto existing accounts, legacy no-tier cutoff, internal-only key feed
ci/woodpecker/push/woodpecker Pipeline failed
2026-11-19 23:33:24 +00:00
inference-admin 89e5ae6273 webhook: refuse an unresolvable order.processed instead of answering provisioned
ci/woodpecker/push/woodpecker Pipeline was canceled
2026-11-19 23:25:39 +00:00
inference-admin c9726f4029 security: verify OC orders, fail-closed revoke, per-IP rate buckets, escaped guest email
ci/woodpecker/push/woodpecker Pipeline failed
2026-11-19 23:22:51 +00:00
inference-admin 59d228b8d3 retire Open WebUI: drop rag_refresh job and its credentials; keep LibreChat path
ci/woodpecker/push/woodpecker Pipeline was canceled
2026-11-19 22:44:49 +00:00
inference-admin 5f3519d0af security: retire the legacy /v1/* key-injection proxy and PORTAL_SECRET
ci/woodpecker/push/woodpecker Pipeline failed
2026-11-19 22:39:14 +00:00
inference-admin 649392d2e8 security: constant-time admin-token compare on four routes; legacy token off by default
ci/woodpecker/push/woodpecker Pipeline failed
2026-11-19 22:09:38 +00:00
inference-admin 4af22ca4c4 portal: daily EUR/USD spot check against the pricing FX, alert only (no reprice)
ci/woodpecker/push/woodpecker Pipeline was canceled
Reads the ECB reference rate in the sweep, compares to FX_POLICY_EUR_USD (1.16),
and emails info@ only when the drift first crosses FX_ALERT_PCT (2%). Marker in
portal_state keeps a steady breach from mailing daily and resets when inside the band.
2026-11-18 17:44:00 +00:00
inference-admin e4d9d7bf49 portal: stale-invite sweep skips addresses emailed in the last hour
ci/woodpecker/push/woodpecker Pipeline was canceled
An explicit resend followed by the sweep sent the same guest two identical invites.
2026-11-17 16:13:49 +00:00
inference-admin 0ae9634f70 portal: setup links expire after seven days — say so, and offer a resend
ci/woodpecker/push/woodpecker Pipeline was canceled
Cloudron's account-setup links lapse after a week, so an unaccepted invitation goes
stale through no fault of the member. Both setup emails now state the lifetime and
where to ask for a new link. New admin routes: resend one invite (fresh link, never
to an activated account) and resend every unaccepted guest invite older than N days.
2026-11-17 16:12:40 +00:00
inference-admin 9023496e94 portal: dues sum stacked subscriptions and record for manual members
ci/woodpecker/push/woodpecker Pipeline was canceled
_current_dues took only the newest live order, so evan-prodromou's $5 + $10 monthly
subscriptions displayed as $5. Sum per unit (monthly separate from yearly), never
mixing them. Also snapshot dues BEFORE the manual skip: manual members take no
membership decision, but the panel's Dues column is a read-model of OC truth and
was unreachable for them.
2026-11-17 09:17:37 +00:00
inference-admin f7f6946207 portal: dues = the co-op's share, not the donor's OC total
ci/woodpecker/push/woodpecker Pipeline was canceled
totalAmount includes the buyer's optional Open Collective tip, so a member who tips
showed a higher dues level than they pay us. Use amount.value — the base
contribution that reaches the co-op — and fetch it alongside totalAmount. The
webhook credit-pack path made this same mistake and already resolves it via the
public order API.
2026-11-17 09:08:58 +00:00
inference-bot a135560899 portal: persist each member's current OC dues level
reconcile_allowances already matches every member's Open Collective orders;
it now records what those orders say the member currently pays:
dues_amount / dues_frequency / dues_updated_at (added via the lazy ALTER
pattern). Only a LIVE recurring order (MONTHLY/YEARLY, ACTIVE/PROCESSING)
counts — one-time orders are credit purchases, cancelled/errored ones are not
a current level, and anything unreadable is NULL rather than a guessed tier.

/admin/overview carries the three fields so the admin panel can show a real
Dues column instead of a credit figure. The write happens in report mode too:
it records OC's own truth and makes no membership decision.

tests/test_dues_level.py pins the extraction rules.
2026-11-17 09:02:22 +00:00
inference-admin 9b90f89135 portal: stray-credit email states the real floor — from $5/month, no suggested level
ci/woodpecker/push/woodpecker Pipeline was canceled
2026-11-17 08:14:05 +00:00
inference-admin d941961549 portal: stop telling stray-credit buyers the floor is $10
ci/woodpecker/push/woodpecker Pipeline was canceled
mmoya traced the false '$10 floor' to the stray-credit email: it said '($10-20/month,
sliding scale)' when Open Collective's flexible tier starts at $5 (suggested $10).
Copy now says 'from $5/month, suggested $10 — sliding scale'.
2026-11-17 08:07:01 +00:00
inference-admin ea0f728af2 portal: member_aliases — credit a purchase made from a member's second OC profile
ci/woodpecker/push/woodpecker Pipeline was canceled
A person can hold two Open Collective profiles, one hiding its email. Purchases from
the hidden one have no email to match and no primary slug, so they land in held
credits. member_aliases maps extra slugs to a member email; the sweep's held-credit
pass resolves email -> slug -> alias before holding anything. Admin GET/POST
/admin/aliases manages rows; test covers grant and idempotency.
2026-11-17 05:11:16 +00:00
inference-admin ffe62d3c78 portal: derive source from OC email visibility instead of trusting a stale flag
ci/woodpecker/push/woodpecker Pipeline was canceled
oc-incognito disables email matching by design, so a profile that later shows an
email leaves the member silently unmatched. The sweep now flips those to oc and
records oc_email; profiles still hiding an email are untouched. Test covers both.
2026-11-17 05:04:50 +00:00
inference-admin 85e8e62e5b portal: membership-status reports the computed allowance, not members.balance (often NULL)
ci/woodpecker/push/woodpecker Pipeline was canceled
2026-11-17 04:56:58 +00:00
inference-admin 27b0ea564a portal: answer for a lapsed membership instead of leaving the dashboard blank
ci/woodpecker/push/woodpecker Pipeline was canceled
New read-only /broker/membership-status, authenticated by the broker secret with a
verifier that admits a member row in ANY state (usage and keys still require active).
Returns active/state, the latest allowance_log decision with its evidence, the OC
minimum contribution (MIN_CONTRIBUTION, copy-only — OC stays the authority), credits,
allowance and the contribute URL.

MIN_CONTRIBUTION is deliberately NOT wired into deactivation: a number we half-know
should not cost anyone access.
2026-11-17 04:55:34 +00:00
inference-admin e9d0fd259a portal: settle held credits in the sweep, and report the ones nobody can be credited for
ci/woodpecker/push/woodpecker Pipeline was canceled
A credit pack bought while the buyer's membership was inactive is held — correctly,
we must never mint credits for a non-member. The gap was what happened next: the hold
sat until a human noticed (mmoya's $10 waited from 01:45 until they wrote in).

Every sweep now grants any hold that resolves to an ACTIVE member (by email first, then
slug), reusing grant_held_credits() so held:<id> keeps it idempotent; holds with no
active member older than HELD_ALERT_HOURS are emailed to info@. Tests cover grant/hold/
no-double-apply.
2026-11-17 04:51:40 +00:00
inference-admin bed7f03063 rate limits: one bucket per ROUTE, not one per proxy address
ci/woodpecker/push/woodpecker Pipeline was canceled
Every request arrives through Cloudrons
2026-11-13 22:45:48 +00:00
inference-admin 0a6939fe07 retire the Open WebUI integration
ci/woodpecker/push/woodpecker Pipeline was canceled
The app is stopped (`com.openwebui.cloudronapp`, installed|stopped), so every call
to it failed with "Temporary failure in name resolution" — a stopped container has
no DNS entry. Four of the last four provisions logged exactly that; no new member
ever reached the group.

Its "members group" was never a Cloudron group: the id pointed at a group inside
Open WebUI's own database, which is why it appears nowhere in Cloudron's UI.

Removed: owui_add_to_members_group, both call sites (provision_member and guest
convert), the OWUI_* constants, and the signed-JWT identity path in inject_key.
That last one is the part that matters beyond tidiness: it accepted a
shared-secret-signed token as proof of identity for an integration nobody runs.
inject_key keeps its one live path (LibreChat: X-User-Email + X-Portal-Secret,
still verified).

First attempt at this cut too much — a greedy splice off the guest-convert call
took listmonk_sync and the held-credit grant with it, and test_guest_lifecycle.py
caught it before anything shipped. Redone with exact anchors.
2026-11-13 22:33:10 +00:00
inference-admin b1022eb02a oc-incognito: take the slug from the member's own row
ci/woodpecker/push/woodpecker Pipeline was canceled
Setting the source was not enough, and verification is what caught it: mmoya still
produced no allowance decision at all.

The reconciler gets a member's OC slug from the member INDEX — which is keyed by
email, and DROPS anyone whose profile hides its email. So `oc_slug` came back
empty, the member fell into "not in the live Open Collective member list — cannot
verify payment", and was counted as skipped. An oc-incognito member would have
been "not manual" and still not reconciled: a nicer label over the same hole.

For source oc-incognito the slug now comes from the member's own row, which is
the same key fetch_member_orders() groups orders by — the whole reason matching
can work for these people. The test pins the fallback, not just the source.
2026-11-13 22:27:55 +00:00
inference-admin 64d1ea5093 members: an explicit SOURCE, so 'oc-incognito' stops being 'manual'
ci/woodpecker/push/woodpecker Pipeline was canceled
mmoya@mmoya.org sat in MANUAL_MEMBERS because OC hides the address on their
profile (incognito-5ad60182, email null since 2023), so email matching can never
find them. But "manual" means hand-provisioned, and the sweep SKIPS manual
members entirely: a paying subscriber had no lapse logic, no dues tracking and no
order attribution. Two different facts were sharing one word.

members.source now carries which one it is:
  oc            — OC-backed, matched by email (the default; NULL means this)
  oc-incognito  — OC-backed, profile hides the email, matched by the stored OC
                  SLUG — which the reconciliation already uses, since
                  fetch_member_orders() groups orders by the payer's slug and
                  members.slug holds exactly that for these people
  manual        — hand-provisioned; no contribution expected, nothing reconciles,
                  nobody lapses

So an oc-incognito member needs no exemption from reconciliation — they need to
stop being skipped, and the existing slug path does the rest.

Every decision that keyed on the raw MANUAL_MEMBERS list now keys on the source:
the reconciliation skip, the sweep's deactivation guard, and the shortfall-credit
exemption. An explicit source beats the list, so a member can be moved without
editing the env — and the env list can shrink toward deprecation. An
unrecognised or unreadable source falls back to 'oc', the direction that keeps
reconciling someone rather than quietly exempting them.

anchor_day_for_member also resolves by slug now: an incognito member is absent
from the member index (it drops anyone without an email), and falling back to
"today" would silently move their renewal day.

tests/test_oc_incognito.py pins all of it, including that the column is optional
(NULL = not stated) so this ships without a data migration.
2026-11-13 22:24:46 +00:00
inference-admin 2cde368c1e resolve payer: authenticate the lookup — without the token OC hides the email
ci/woodpecker/push/woodpecker Pipeline was canceled
Second live-only bug in the same helper. Sent unauthenticated, OC answers the
public view of an account: name comes back, email does not. A hand query with the
Personal-Token header returned conor.canaday@gmail.com for the very slug the
helper reported as email=None — so the fix would have resolved nobody, silently,
while looking like it worked.

The test now pins the header (the stub records what it was called with), because
the failure mode here is an absence, and an absence is exactly what a stub
forgets to check.
2026-11-13 22:14:36 +00:00
inference-admin 9c10e627fc resolve payer: read the response's JSON (the stub hid this)
ci/woodpecker/push/woodpecker Pipeline was canceled
_oc_graphql_post returns the RESPONSE — it is a retrying wrapper around
client.post — so fetch_account_by_slug has to call .json() on it. My unit test
stubbed it as a dict, so the test passed and the first live call in the container
died with "Response object has no attribute get".

The test now stubs the real shape (a response wrapper with .json()). Folding it
in here rather than hiding it: a stub that does not match the real return shape
certifies nothing.
2026-11-13 22:13:22 +00:00
inference-admin 5a7380686c webhook: a first-time contributor's order must not vanish in silence
ci/woodpecker/push/woodpecker Pipeline was canceled
On 2026-11-13 21:59:43 Open Collective delivered order.processed for a live
$5/month membership (Conor W, conor.canaday@gmail.com, order
or_eU8gRkrPCvFsaYHrgiCfz). The portal answered 200 and did nothing.

The membership branch resolves the payer by SLUG against the collective's
members list:

    members = await fetch_members()
    member = next((m for m in members if m["slug"] == slug), None)

and a first-time contributor's account is not in that list yet — OC reports the
payer as guest-…/incognito-…. So `member` was None, the branch fell through, and
because the delivery had SUCCEEDED there was no error to record either: no
account, no welcome email, no credit, no log line. The sweep's unmapped-backers
check found it hours later, which is the wrong place to find it.

Now an unknown payer is resolved from the order's account slug
(`Individual.email`, which OC exposes for an ordinary guest checkout) and handed
to the same provisioning path a known member gets. When even that yields no
email — an incognito profile, hidden on purpose — the webhook logs at ERROR that
nobody was provisioned or credited, instead of shrugging.

The defect worth naming is the SHAPE: an `if` with no `else` on a money path,
where doing nothing leaves no trace. tests/test_resolve_payer.py pins the
resolution cases (guest with email, incognito, unknown account, read failure, no
token) and the fact that the branch can no longer fall through quietly.
2026-11-13 22:12:02 +00:00
inference-admin 241ac800c6 panel state: a reminder is history, not a state — renewals clear grace, grace expires
ci/woodpecker/push/woodpecker Pipeline was canceled
mark@ofosos.org showed as in grace while his contribution was live. The sweep's
own trail says it plainly: reminded 2026-11-04 for the cycle that looked unpaid,
grace elapsed 2026-11-11, and `renewed` logged at 19:02 on 2026-11-13 (last
charge 2026-11-11, next reset 2026-11-26). The panel said grace anyway, because
member_membership_state() asked only "is there a row in payment_reminders?".

That table is a HISTORY — kept so the sweep does not re-remind inside a cycle. It
is not a state, and treating it as one broke two things: a reminder never
expired (grace is PAYMENT_GRACE_DAYS long), and a renewal never cleared it.

Now the LATEST reconciliation decision decides:
  renewed / would_renew            -> active (they are paying)
  reminder inside the window       -> in_grace
  reminder past the window         -> awaiting_contribution, saying grace elapsed
  would_deactivate / deactivated   -> awaiting_contribution
Ordered by decided_at, not id: the same member had id 2296 dated 2026-11-11 next
to id 2286 dated 2026-11-13, so "latest by id" reads the wrong decision.

Reads still fail safe: an unreadable DB reports active, never a payment problem.

tests/test_membership_state.py pins all of it, including the ordering trap.
2026-11-13 21:53:27 +00:00
inference-admin 2a77b0c988 spend: ONE all-time figure, computed once, for every surface that shows it
ci/woodpecker/push/woodpecker Pipeline was canceled
The panel's card said $941.37 and the member dashboard's said $900.51 for the
same claim. The panel used its own per-team query; the dashboard summed the
chart series IN THE BROWSER, which disagrees with the server whenever a row is
null, capped or stale.

coop_spend_totals() is now the definition: one GROUP BY over SpendLogs joined to
the team table, so
  spend_all_time      = every row (members, operators, agent teams, sandboxes) —
                        the same universe litellm_spend_by_day() sums, so the
                        cards and the money chart agree by construction
  own_all_time_spend  = the part that is the co-op's own (non-member teams, plus
                        rows with no team)
and member_all_time_spend = the rest. Exposed through /admin/overview (the
panel's boot payload), the money payload, and /broker/metrics (the dashboard's).
_coop_spend_totals_safe() returns {} rather than a zero: a failed computation
must never read as "the co-op has spent nothing".

tests/test_coop_spend_totals.py pins the arithmetic (total == member + own ==
every row) and the no-fake-zero rule.
2026-11-13 21:44:13 +00:00
inference-admin 9af0604f47 portal: /broker/money-series, so members chart the co-op's money beside its other charts
ci/woodpecker/push/woodpecker Pipeline was successful
The member dashboard could not show the money chart because the broker exposed no
money series — the same payload /admin/money-series serves the panel is aggregate
and carries no member identities (cumulative revenue, cumulative token spend, the
OC balance), so it goes through the broker for the same reason /broker/metrics
does. One chart definition, drawn identically for members and stewards.
2026-11-13 21:01:38 +00:00