Skip to content

Commit a49b46d

Browse files
Sync public snapshot from freebuff-private
Source: CodebuffAI/freebuff-private@f7245a9477879db1065330cd04d013dc40170ae0
1 parent 835ae0f commit a49b46d

10 files changed

Lines changed: 372 additions & 51 deletions

bun.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/src/components/__tests__/freebuff-model-selector.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ describe('FreebuffModelSelector plan line', () => {
796796
const frame = (await renderSelector()).captureCharFrame()
797797
expect(frame).toContain('STARTER PLAN')
798798
expect(frame).toContain('today 1.3 of 2')
799-
expect(frame).toContain('5-day 3 of 6')
799+
expect(frame).toContain('week 3 of 6')
800800
expect(frame).toContain('month 11 of 50')
801801
})
802802

cli/src/components/freebuff-landing-screen.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,14 @@ export const FreebuffLandingScreen: React.FC<FreebuffLandingScreenProps> = ({
813813
</span>
814814
. Press Ctrl+C to exit.
815815
</text>
816+
{/* The paywall half (2026-09-01): the server's structured hint
817+
when it sent one, the plans page otherwise — a quota wall is
818+
never a dead end. */}
819+
<text style={{ fg: theme.muted, wrapMode: 'word', marginTop: 1 }}>
820+
{'upgrade' in session && session.upgrade
821+
? `${session.upgrade.message} ${session.upgrade.url}`
822+
: 'Get more sessions with a plan: https://freebuff.com/plans'}
823+
</text>
816824
</>
817825
)}
818826

@@ -832,6 +840,11 @@ export const FreebuffLandingScreen: React.FC<FreebuffLandingScreenProps> = ({
832840
{' — '}your free usage resets automatically at midnight Pacific.
833841
Press Ctrl+C to exit.
834842
</text>
843+
<text style={{ fg: theme.muted, wrapMode: 'word', marginTop: 1 }}>
844+
{'upgrade' in session && session.upgrade
845+
? `${session.upgrade.message} ${session.upgrade.url}`
846+
: 'Get more sessions with a plan: https://freebuff.com/plans'}
847+
</text>
835848
</>
836849
)}
837850

common/src/__tests__/freebuff-spend-ceilings.test.ts

Lines changed: 93 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,18 @@ describe('elevated countries', () => {
182182
expect(result.usd).toBeLessThan(FREEBUFF_REGION_DAILY_SPEND_USD.full)
183183
})
184184

185-
it('does not cut a LIVE session — no hard cap, like the region ceilings', () => {
186-
// The whole point of $5 rather than $0.50 is that it is a budget, not a
187-
// suspicion. Applying the 2x hard cut here would interrupt an ordinary
188-
// Singaporean developer mid-thought, which is the error this tier exists
189-
// to stop making.
185+
it('cuts a LIVE session only past the leeway multiplier', () => {
186+
// Reversed 2026-08-31 when the elevated ceiling dropped $5 → $1: at one
187+
// dollar, overshoot is no longer proportionally small, and the multiplier
188+
// is what grants an open session leeway to finish before the hard cut.
190189
const ceiling = resolveFreebuffSpendCeiling({
191190
accessTier: 'full',
192191
countryCode: 'SG',
193192
})
194-
expect(resolveFreebuffHardSpendCeiling(ceiling)).toBeNull()
193+
expect(ceiling.usd).toBe(FREEBUFF_ELEVATED_DAILY_SPEND_USD)
194+
expect(resolveFreebuffHardSpendCeiling(ceiling, 1.25)).toBeCloseTo(
195+
FREEBUFF_ELEVATED_DAILY_SPEND_USD * 1.25,
196+
)
195197
})
196198

197199
it('still loses to a restricted cohort the account is also in', () => {
@@ -207,11 +209,13 @@ describe('elevated countries', () => {
207209
})
208210

209211
it('resolves a tie with the region ceiling to `region`', () => {
210-
// A limited-tier account in an elevated country sees $5 from both rules.
211-
// The tie must land on the reason that implies nothing about the account.
212+
// The defaults no longer tie ($1 elevated vs $5 limited region), so the
213+
// tie is constructed with overrides — the RULE still has to hold: a tie
214+
// lands on the reason that implies nothing about the account.
212215
const result = resolveFreebuffSpendCeiling({
213216
accessTier: 'limited',
214217
countryCode: 'SG',
218+
overrides: { elevatedUsd: 5 },
215219
})
216220
expect(result.usd).toBe(5)
217221
expect(result.reason).toBe('region')
@@ -286,3 +290,84 @@ describe('refusal copy', () => {
286290
}
287291
})
288292
})
293+
294+
describe('paid-plan daily floors (2026-08-31)', () => {
295+
// The cohort ceilings were sized for free usage; 11 live subscribers were
296+
// spend-refused in the 48h before this shipped, three of them at thirty
297+
// cents a day against an $8/month plan. A floor, not an exemption: the
298+
// plan's monthly spend cap remains the money bound.
299+
it('floors a limited-region subscriber at $3 when the region ceiling dips below', () => {
300+
// The code-default limited region ($5) already exceeds the $3 floor; the
301+
// floor binds when env tuning takes the region lower — as prod does.
302+
const result = resolveFreebuffSpendCeiling({
303+
accessTier: 'limited',
304+
hasPaidSubscription: true,
305+
overrides: { regionUsd: { limited: 1 } },
306+
})
307+
expect(result.usd).toBe(3)
308+
expect(result.reason).toBe('region')
309+
})
310+
311+
it('floors a full-region subscriber at $7', () => {
312+
const result = resolveFreebuffSpendCeiling({
313+
accessTier: 'full',
314+
hasPaidSubscription: true,
315+
overrides: { regionUsd: { full: 5 } },
316+
})
317+
expect(result.usd).toBe(7)
318+
})
319+
320+
it('floors the restricted cohorts too — a card is the realness signal', () => {
321+
for (const input of [
322+
{ privacyEgress: true },
323+
{ countryCode: 'CN' },
324+
{ flaggedEmailDomain: true },
325+
{ unverifiedEgress: true },
326+
]) {
327+
const result = resolveFreebuffSpendCeiling({
328+
accessTier: 'limited',
329+
hasPaidSubscription: true,
330+
...input,
331+
})
332+
expect(result.usd).toBe(3)
333+
}
334+
})
335+
336+
it('never LOWERS a ceiling that already exceeds the floor', () => {
337+
const result = resolveFreebuffSpendCeiling({
338+
accessTier: 'full',
339+
hasPaidSubscription: true,
340+
})
341+
// Region default $15 > the $7 floor: the higher number survives.
342+
expect(result.usd).toBe(FREEBUFF_REGION_DAILY_SPEND_USD.full)
343+
expect(result.reason).toBe('region')
344+
})
345+
346+
it('does NOT floor third_party_client — the reseller cohort', () => {
347+
const result = resolveFreebuffSpendCeiling({
348+
accessTier: 'full',
349+
thirdPartyClient: true,
350+
hasPaidSubscription: true,
351+
})
352+
expect(result.usd).toBe(FREEBUFF_RESTRICTED_DAILY_SPEND_USD)
353+
expect(result.reason).toBe('third_party_client')
354+
})
355+
356+
it('keeps naming the floored cohort as the reason', () => {
357+
const result = resolveFreebuffSpendCeiling({
358+
accessTier: 'limited',
359+
countryCode: 'CN',
360+
hasPaidSubscription: true,
361+
})
362+
expect(result.usd).toBe(3)
363+
expect(result.reason).toBe('restricted_country')
364+
})
365+
366+
it('a free account is untouched by the floor machinery', () => {
367+
const result = resolveFreebuffSpendCeiling({
368+
accessTier: 'limited',
369+
countryCode: 'CN',
370+
})
371+
expect(result.usd).toBe(FREEBUFF_RESTRICTED_DAILY_SPEND_USD)
372+
})
373+
})

common/src/constants/freebuff-spend-ceilings.ts

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ export const FREEBUFF_RESTRICTED_COUNTRIES: readonly string[] = ['CN']
119119
* `flaggedEmailDomain` instead. Catching it there is what makes this tier
120120
* affordable.
121121
*
122-
* $5 and not $15: SG remains a top VPN and datacenter exit, so the tail this
123-
* bounds is real even with the farm named. Five dollars is the same figure a
124-
* limited-region account gets — enough for a full day's ordinary work, still a
125-
* bound — and deliberately not a number that has to be defended per-country.
122+
* $1 as of 2026-08-31 (operator decision; was $5 from 2026-08-15): the tail
123+
* kept growing and the farm-domain pricing did not shrink it enough. One
124+
* dollar still buys a normal day of ordinary sessions, and unlike the
125+
* restricted tier it now carries the live-session leeway multiplier below —
126+
* at this size, letting an open session run to 1.25x and then cutting is the
127+
* bound that matters, exactly the reasoning the restricted ceilings use.
126128
*/
127-
export const FREEBUFF_ELEVATED_DAILY_SPEND_USD = 5
129+
export const FREEBUFF_ELEVATED_DAILY_SPEND_USD = 1
128130

129131
/**
130132
* Countries held at the elevated ceiling.
@@ -308,18 +310,63 @@ export function freebuffSessionSpendNotice(verdict: {
308310
*/
309311
export const FREEBUFF_SPEND_CEILING_HARD_MULTIPLIER = 2
310312

313+
/**
314+
* Daily-spend FLOORS for accounts holding a live paid plan (2026-08-31).
315+
*
316+
* The cohort ceilings above were sized for free usage, and until this floor a
317+
* paying customer inherited them unchanged: measured over the 48h before it
318+
* shipped, 11 live subscribers were spend-refused — six limited-region
319+
* Starters at the $3 region ceiling they had paid to escape, three in a
320+
* restricted country at thirty cents a day against an $8/month plan.
321+
*
322+
* A floor, not an exemption: the plan's own monthly spend cap remains the
323+
* money bound, and a stolen card should still not buy unbounded daily burn.
324+
* Composed as max() AFTER the cohort minimum, so it can only ever RAISE a
325+
* paying account's ceiling, never lower one — a full-region paid account whose
326+
* cohort maths already exceeds the floor keeps the higher number.
327+
*
328+
* Full access floors higher than everyone else ($7 vs $3) on the operator's
329+
* explicit split: paid limited-region and paid suspicious-cohort accounts go
330+
* to $3. `third_party_client` is deliberately NOT floored — an account
331+
* observed sending a foreign toolset while paying is the reseller pattern
332+
* (see freebuff2api), and the one cohort where a card is evidence of a
333+
* business model rather than a person.
334+
*/
335+
export const FREEBUFF_PAID_DAILY_SPEND_FLOOR_USD: Record<
336+
FreebuffAccessTier,
337+
number
338+
> = {
339+
full: 7,
340+
limited: 3,
341+
}
342+
343+
/** The reasons a paid floor may override. Everything except the reseller
344+
* cohort — see FREEBUFF_PAID_DAILY_SPEND_FLOOR_USD. */
345+
const PAID_FLOOR_REASONS: ReadonlySet<string> = new Set([
346+
'region',
347+
'elevated_country',
348+
'restricted_country',
349+
'privacy_egress',
350+
'flagged_email_domain',
351+
'unverified_egress',
352+
'trust_level',
353+
])
354+
311355
/**
312356
* Reasons whose ceiling is small enough that the hard multiplier applies.
313357
*
314-
* `region`, `elevated_country` and `trust_level` are excluded: all three are
315-
* whole-population limits where the fresh-admission gate is proportionate, and
316-
* applying a hard cut there would interrupt ordinary paying-in-attention users
317-
* mid-thought. `elevated_country` sits at the same $5 as a limited-region
318-
* account precisely so it can be reasoned about as a region ceiling rather
319-
* than as a suspicion, and cutting it live would undo that.
358+
* `region` and `trust_level` are excluded: whole-population limits where the
359+
* fresh-admission gate is proportionate, and applying a hard cut there would
360+
* interrupt ordinary paying-in-attention users mid-thought.
361+
*
362+
* `elevated_country` JOINED this set on 2026-08-31 when its ceiling dropped
363+
* $5 → $1: at one dollar, overshoot is no longer proportionally small, and
364+
* the multiplier is what grants an open session leeway to finish before the
365+
* hard cut — the same trade the restricted ceilings make.
320366
*/
321367
const HARD_CAPPED_REASONS: ReadonlySet<string> = new Set([
322368
'restricted_country',
369+
'elevated_country',
323370
'privacy_egress',
324371
'flagged_email_domain',
325372
'third_party_client',
@@ -391,12 +438,20 @@ export interface FreebuffSpendCeilingInput {
391438
/** The trust matrix's ceiling, when that rollout is enforcing. */
392439
trustLevelCeilingUsd?: number | null
393440
/** Overrides, all optional so a missing env var changes nothing. */
441+
/**
442+
* True when the account holds a live paid plan (Postgres-entitling row —
443+
* never a mirror; see the coercion rule in triggerGates). Resolved LAZILY
444+
* by the caller, only when the cohort ceiling would refuse: the ordinary
445+
* request must not pay a subscription read to learn a ceiling it is under.
446+
*/
447+
hasPaidSubscription?: boolean
394448
overrides?: {
395449
regionUsd?: Partial<Record<FreebuffAccessTier, number>>
396450
restrictedUsd?: number
397451
restrictedCountries?: readonly string[]
398452
elevatedUsd?: number
399453
elevatedCountries?: readonly string[]
454+
paidFloorUsd?: Partial<Record<FreebuffAccessTier, number>>
400455
}
401456
}
402457

@@ -462,6 +517,18 @@ export function resolveFreebuffSpendCeiling(
462517
if (candidate.usd < winner.usd) winner = candidate
463518
}
464519

520+
// The paid floor, AFTER the minimum: it may only raise. The reason keeps
521+
// naming the cohort that was floored — a support question about a paid
522+
// account still deserves the one-word answer for why it isn't higher.
523+
if (input.hasPaidSubscription && PAID_FLOOR_REASONS.has(winner.reason)) {
524+
const floor =
525+
input.overrides?.paidFloorUsd?.[input.accessTier] ??
526+
FREEBUFF_PAID_DAILY_SPEND_FLOOR_USD[input.accessTier]
527+
if (typeof floor === 'number' && floor > winner.usd) {
528+
return { usd: floor, reason: winner.reason, applied }
529+
}
530+
}
531+
465532
return { usd: winner.usd, reason: winner.reason, applied }
466533
}
467534

0 commit comments

Comments
 (0)