Michael Camire fixes + hub shells in the tank (Marty 2026-11-14, LinkSpin Support)

1. Top-up across positions: an ad burns from ONE position, and topUpCampaign only looked at the ad's
   own position (or the main one when the list row had no memberId), so credits bought on a linked
   position could never top up the ad. Ported from InstantAdPay 2026-09-27 (Jim Watts): the ad's real
   member id is read from the campaign row; when it cannot cover, the refusal names where the free
   credits are and offers switchOptions; with the member's yes (switchTo, only a position on the
   account) moveFunding settles what the ad already ran up on the OLD position, moves the ad, then
   tops up. Ads screen asks in-page (own dialog) and retries. Create already had the largest-position guard.
2. Toasts: errors stay until closed (close button, role=alert), other notes 3.5 to 9 s by length.
3. Banner Spin per-banner clicks: his 3 clicks were all unmatched (no view on record for that browser),
   so they landed on the fallback row and every banner said 0. Click matching now also tries the same
   connection (daily-salted IP-only hash) when the browser key finds nothing (mail/exchange app view,
   click opened in the phone browser), view notes last 60 min instead of 15, and the stats split
   'Fallback shown' from 'Clicks not tied to a banner' so the rows add up to the total. History is not
   backfilled: views were never stored per visitor, so old clicks cannot be tied reliably.
4. Holding tank: hub-made waiting accounts with no sponsor are in the tank (waiting, rescue, readyTick
   read listAll with { shells: true }; 'hub-shell' no longer holds anyone back). Locked / sponsored /
   unknown, grace, 2-adoption cap unchanged; readyTick still never switches a shell on;
   accounts.listAll default unchanged (mailings skip shells).

Assets: cr.css, cr-shell.js, ads-screen.js ?v=20261114tu, banner-spin.js ?v=20261114bc.
QA: walk member 0 bugs (36 ok), netconv 57/57, networksso ALL PASSED, tank-hold all passed (new hub
shell part), profile policy 16/16, new topup-positions 8/8, new bannerspin-attrib 7/7, bannerspin e2e
75/75, hubsync 15 checks, tank-cap 15/15, sponsorfollow 30/30.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-14 11:59:38 -06:00
parent a630979a3a
commit e545343fe0
27 changed files with 282 additions and 47 deletions
+12 -6
View File
@@ -91,9 +91,15 @@ const inTank = a => !a.sponsorRef && !a.memberId; // arrived with no sponsor (or
// hooks.networkHeld = hubsync.heldAmong, wired only with HUB_ENABLED. A hook that throws holds everyone it was asked about:
// the conservative side. No hook (flag off, tests) = nothing held, the tank as before.
const lc = v => String(v || '').trim().toLowerCase();
async function heldSet(accts) {
// Hub-made waiting accounts with no sponsor ARE in the tank (Marty 2026-11-14: "Yes to the unsponsored old members going in the
// holding tank"): 'hub-shell' no longer holds anyone back from waiting / adoption / expiry; locked, sponsored and unknown still do.
// readyTick passes keepShells: a shell is still never aligned or switched on there (quiet: no wallet, never signed in here).
async function heldSet(accts, keepShells) {
if (!hooks.networkHeld || !accts.length) return new Map();
try { return (await hooks.networkHeld(accts)) || new Map(); } catch (e) { console.error('tank networkHeld', e.message); return new Map(accts.map(a => [lc(a.email), 'unknown'])); }
let m;
try { m = (await hooks.networkHeld(accts)) || new Map(); } catch (e) { console.error('tank networkHeld', e.message); return new Map(accts.map(a => [lc(a.email), 'unknown'])); }
if (!keepShells) for (const [k, w] of [...m]) if (w === 'hub-shell') m.delete(k);
return m;
}
const HELD_WHY = { locked: 'they are locked on a network contract', sponsored: 'it already knows a sponsor for them', unknown: 'nothing (it is not answering)', 'hub-shell': 'they are a waiting copy from another door and never signed in here' };
// release / rescue / expiry: 'locked' | 'unknown' | null (hooks.networkLocked = hubsync.lockedAnywhere)
@@ -104,7 +110,7 @@ async function lockedWhy(email) {
// waiting list: newest sign-in first so a live one is easy to spot
async function waiting() {
const all = await accounts.listAll(1e6); // was 2000: newest-first, so once the site passed 2000 accounts (BTC4Hits import 2026-11-11) older tank members fell off the list
const all = await accounts.listAll(1e6, { shells: true }); // hub-made waiting accounts included (Marty 2026-11-14); was 2000: newest-first, so once the site passed 2000 accounts (BTC4Hits import 2026-11-11) older tank members fell off the list
const cand = all.filter(a => inTank(a) && !remoteOpen(a.email));
const held = await heldSet(cand); // rule 3: locked or sponsored elsewhere
return cand.filter(a => !held.has(lc(a.email))).map(a => ({ email: a.email, name: nameOf(a), username: a.username || null, joined: a.created, lastSeen: a.lastSeen || 0, wallet: !!a.address,
@@ -303,7 +309,7 @@ async function rescueSweep() {
if (String(process.env.TANK_RESCUE || '').trim() !== 'on') return { warned: 0, rescued: 0, dead: 0, off: true };
const now = Date.now();
let warned = 0, rescued = 0, dead = 0;
const all = await accounts.listAll(5000);
const all = await accounts.listAll(5000, { shells: true });
await heldSet(all.filter(a => !a.memberId && !a.address && a.sponsorRef)); // one batched hub call warms the cache for lockedWhy below
for (const a of all) {
if (a.memberId || a.address || !a.sponsorRef) continue; // bound, wallet, or already in the tank
@@ -551,9 +557,9 @@ async function autoAssignRun() {
// InstantAdPay owns are announced there, not twice in the shared topic).
async function readyTick() {
const st = RS.load(); const fresh = []; let aligned = 0;
const tankers = (await accounts.listAll(5000)).filter(inTank);
const tankers = (await accounts.listAll(5000, { shells: true })).filter(inTank);
if (hooks.prefetch) { try { await hooks.prefetch(tankers.map(a => a.email)); } catch (e) {} } // one signed batch call to InstantAdPay, not one per member
const netHeld = await heldSet(tankers); // one batched hub call; alignToNetwork below reads the same cache
const netHeld = await heldSet(tankers, true); // one batched hub call; alignToNetwork below reads the same cache
for (const a of tankers) {
if (netHeld.get(lc(a.email)) === 'hub-shell') continue; // a waiting copy from another door: no alignment, no payouts switch-on here (quiet)
if (await alignToNetwork(a).catch(() => null)) { aligned++; continue; }