Free allowance across the games (Marty 2026-11-02, "cap these so if they want to keep playing they spend a tiny amount"): an account with no Game Pass receives at most capFreeLifetime POL of game rewards ever, across every game (2 POL default, site setting). After that a free account's room for the day is zero: progress rewards defer until a pass is active, repeatable rewards drop, carry waits too. Grant answers and partner caps carry lifetimeHit / freeUsed / lifetime; chatbot facts; QA block for the allowance

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-02 17:01:27 -06:00
parent 7f3f057db0
commit c6b4a84abc
4 changed files with 34 additions and 6 deletions
+18 -1
View File
@@ -132,7 +132,8 @@ try {
ok(st && st.enabled === true && st.settings.enforced === false, 'admin stats: enabled, caps not enforced', JSON.stringify(st.settings));
// 6. enforced: daily within / over the cap, idempotent ref, progress deferral
await api('/api/admin/site', { method: 'PATCH', data: { capsStartDate: '2026-10-20' } }, adminH);
// capFreeLifetime is parked high here so the daily/total cap checks below read as they always did; it gets its own block at the end
await api('/api/admin/site', { method: 'PATCH', data: { capsStartDate: '2026-10-20', capFreeLifetime: 1000 } }, adminH);
const D1 = '2026-10-20', D2 = '2026-10-21', D3 = '2026-10-22';
gr = await grant({ memberId: 0, email: C, game: 'gemkingdom', kind: 'daily', pol: 0.2, ref: 'f1', devDay: D1 });
ok(gr.j.allowed === 0.2 && gr.j.deferred === 0 && gr.j.enforced === true && gr.j.capHit === null, 'D1 daily 0.2 -> allowed 0.2', JSON.stringify(gr.j));
@@ -216,6 +217,22 @@ try {
ok(tokenClaims && tokenClaims.gamePass && tokenClaims.gamePass.active === true && tokenClaims.gamePass.until === until1 + 7 * 86400000, 'in-game sign-in token carries gamePass { active, until }', JSON.stringify(tokenClaims && tokenClaims.gamePass));
// the ledger file on the volume (saves are debounced 500 ms)
// 9. the free allowance (2026-11-02): an account with no pass receives at most capFreeLifetime POL of game rewards, ever
await api('/api/admin/site', { method: 'PATCH', data: { capFreeLifetime: 2 } }, adminH);
const LF = 'qa-gp-lifetime@example.com'; await signIn(LF, 'qagplife');
gr = await grant({ memberId: 0, email: LF, game: 'gemkingdom', kind: 'progress', pol: 1.5, ref: 'lf:boss:1', devDay: D1 });
ok(gr.j.allowed === 1.5 && gr.j.deferred === 0 && gr.j.lifetimeHit === false && gr.j.freeUsed === 1.5, 'allowance: progress 1.5 -> allowed 1.5, 1.5 of 2 used', JSON.stringify(gr.j));
gr = await grant({ memberId: 0, email: LF, game: 'gemkingdom', kind: 'daily', pol: 0.3, ref: 'lf:d1', devDay: D1 });
ok(gr.j.allowed === 0.3 && gr.j.freeUsed === 1.8, 'allowance: daily 0.3 -> allowed 0.3, 1.8 used', JSON.stringify(gr.j));
gr = await grant({ memberId: 0, email: LF, game: 'gemkingdom', kind: 'progress', pol: 1, ref: 'lf:boss:2', devDay: D1 });
ok(gr.j.allowed === 0.2 && gr.j.deferred === 0.8 && gr.j.lifetimeHit === true && gr.j.freeUsed === 2, 'allowance: progress 1 -> 0.2 allowed, 0.8 deferred, the allowance is used up', JSON.stringify(gr.j));
pl = await gameGet('/api/partner/player', { game: 'gemkingdom', m: 0, e: LF, devDay: D1 }, LF, GK);
ok(pl.j.caps.lifetime && pl.j.caps.lifetime.cap === 2 && pl.j.caps.lifetime.used === 2 && pl.j.caps.pending === 0.8, 'player caps carry the allowance: 2 of 2 used, 0.8 pending', JSON.stringify(pl.j.caps));
gr = await grant({ memberId: 0, email: LF, game: 'gemkingdom', kind: 'daily', pol: 0.2, ref: 'lf:d2', devDay: D2 });
ok(gr.j.allowed === 0 && gr.j.deferred === 0 && gr.j.lifetimeHit === true, 'allowance used: next day daily 0.2 -> nothing, dropped', JSON.stringify(gr.j));
gr = await grant({ memberId: 0, email: LF, game: 'gemkingdom', kind: 'progress', pol: 0.1, ref: 'lf:stage:9', devDay: D2 });
ok(gr.j.allowed === 0 && gr.j.deferred === 0.1 && gr.j.carried === 0, 'allowance used: next day progress 0.1 -> deferred, no carry paid either', JSON.stringify(gr.j));
await api('/api/admin/site', { method: 'PATCH', data: { capFreeLifetime: 1000 } }, adminH);
await sleep(1200);
ok(fs.existsSync(path.join(DATA, 'gamepass-ledger.json')), 'cap ledger persisted to DATA_DIR/gamepass-ledger.json', fs.readdirSync(DATA).join(','));
const ot = JSON.parse(fs.readFileSync(path.join(DATA, 'open-tokens.json'), 'utf8'));