Holding-tank readiness on the tank cards (Marty 2026-11-18, warm-up stage 1, no email)

Each waiting lead on My line > Holding tank and Admin > Members tank card now shows how they got into the tank, a stage chip (New / Warming / Engaged / Activated / Ready, real actions only), the network heat score 0-100 with its band, and their last real action. Computed on the network hub (POST /v1/tank/readiness); tankready.js sends this site's facts (own last sign-in, wallet, entry reason from the adoption records and join data; sponsor usernames, never emails) and caches the answer. Tank list sorts hottest first by default (grace and ready-to-activate grouping unchanged), new Heat sort and "Warm or hot" filter on the tank only. Hub down = the card exactly as before. No mail, no Telegram, no sponsor moves; adoption rules, caps and the v2 batch untouched. qa/tank-readiness.test.mjs (against a local hub) added to member + tankhold. tankready.js?v=20261118rd, my.js / admin.js / site.css ?v=20261118rd. iap-qa member ALL PASSED.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-18 19:01:46 -06:00
parent e57efd9e7c
commit 52f0a5496b
10 changed files with 304 additions and 12 deletions
+2 -2
View File
@@ -7,7 +7,7 @@
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
<link rel="icon" type="image/png" href="/logo-icon.png">
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
<link rel="stylesheet" href="/assets/site.css?v=20261118rd">
<style>
.adm-table{width:100%;table-layout:auto}
.adm-table th{cursor:pointer;user-select:none;white-space:nowrap}
@@ -654,6 +654,6 @@
<script src="/assets/common.js?v=20261117nw"></script><script src="/assets/welcome.js?v=20261117nw"></script>
<script src="/assets/admin-kb.js?v=20261020kb"></script>
<script src="/assets/admin.js?v=20261115la"></script><script src="/assets/admin-sponsorcheck.js?v=20261107tg"></script><script src="/assets/admin-kits.js?v=20261101th"></script>
<script src="/assets/tankready.js?v=20261118rd"></script><script src="/assets/admin.js?v=20261118rd"></script><script src="/assets/admin-sponsorcheck.js?v=20261107tg"></script><script src="/assets/admin-kits.js?v=20261101th"></script>
</body>
</html>
+7 -1
View File
@@ -300,7 +300,13 @@
// ready = wallet linked: activation is held (never the company) until someone adopts them or the 24-hour safety net assigns them (2026-10-27)
const left = w => { const ms = (w.holdUntil || 0) - Date.now(); if (ms <= 0) return 'assigning now'; const m = Math.round(ms / 60000); return (m >= 60 ? Math.floor(m / 60) + ' h ' + (m % 60) + ' min' : m + ' min') + ' left'; };
const rb = w => (w.opensAt > Date.now() ? ' <span class="badge amber" title="New sign-up: hand adoption opens 24 hours after they joined">Opens ' + when(w.opensAt) + '</span>' : '') + (w.ready ? ' <span class="badge" style="background:var(--ok-soft);border-color:var(--ok);color:var(--ok)">Ready to activate · ' + left(w) + '</span>' : '');
$('tankWait').innerHTML = '<tr><th>Waiting</th><th>Email</th><th>Joined</th><th>Last sign-in</th></tr>' + (r.waiting.length ? r.waiting.map(w => '<tr><td>' + esc(w.name) + rb(w) + '</td><td>' + esc(w.email) + '</td><td class="when">' + when(w.joined) + '</td><td class="when">' + (w.lastSeen ? when(w.lastSeen) : '<span class="muted">never</span>') + '</td></tr>').join('') : '<tr><td colspan="4" class="muted">empty</td></tr>')
// readiness (2026-11-18, network hub): hottest first, stage + heat + last action + how they got here; the hub down = the old table
const RD = window.TankReady; const rdOn = RD && r.waiting.some(w => w.rd);
const wl = rdOn ? r.waiting.slice().sort((a, b) => RD.score(b) - RD.score(a)) : r.waiting;
const rs = r.readiness || {}; const rc = rs.counts || {}; const cnt = o => Object.entries(o || {}).sort((a, b) => b[1] - a[1]).map(([k, v]) => k + ' ' + v).join(', ');
$('tankAdmSub').textContent += rs.on ? (rs.ok === false ? ' · readiness: hub not answering (' + (rs.error || '') + ')' : rc.n ? ' · readiness: how they got here ' + cnt(rc.reasons) + ' · stages ' + cnt(rc.stages) + ' · heat ' + cnt(rc.bands) : ' · readiness: loading') : ' · readiness off';
const cols = rdOn ? 5 : 4;
$('tankWait').innerHTML = '<tr><th>Waiting</th><th>Email</th><th>Joined</th><th>Last sign-in</th>' + (rdOn ? '<th>Readiness (hottest first)</th>' : '') + '</tr>' + (wl.length ? wl.map(w => '<tr><td>' + esc(w.name) + rb(w) + '</td><td>' + esc(w.email) + '</td><td class="when">' + when(w.joined) + '</td><td class="when">' + (w.lastSeen ? when(w.lastSeen) : '<span class="muted">never</span>') + '</td>' + (rdOn ? '<td>' + (w.rd ? RD.html(w.rd) : '<span class="muted small">no answer</span>') + '</td>' : '') + '</tr>').join('') : '<tr><td colspan="' + cols + '" class="muted">empty</td></tr>')
+ ((r.aligned || []).length ? '<tr><th colspan="4">Aligned to their network sponsor (LinkSpin) instead of the tank</th></tr>' + r.aligned.slice(0, 15).map(x => '<tr><td>' + esc(x.email) + '</td><td>' + esc(x.toName || x.to) + '</td><td class="when">' + when(x.at) + '</td><td class="muted">' + esc(x.via || '') + '</td></tr>').join('') : '');
$('tankAdopt').innerHTML = '<tr><th>Member</th><th>Adopted by</th><th>When</th><th>Window ends</th><th>Status</th></tr>' + (r.adoptions.length ? r.adoptions.map(a => '<tr><td>' + esc(a.adopteeName) + '</td><td>' + esc(a.adopterName) + '</td><td class="when">' + when(a.ts) + '</td><td class="when">' + (a.status === 'released' || a.status === 'invited' ? '' : when(a.expires)) + '</td><td>' + esc(a.status) + '</td></tr>').join('') : '<tr><td colspan="5" class="muted">none yet</td></tr>');
} catch (e) {}
+10 -5
View File
@@ -336,6 +336,8 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
{ k: 'earned', label: 'Surf earnings', v: m => m.earned || 0 },
{ k: 'balance', label: 'Earned balance', v: m => m.balance || 0 },
{ k: 'name', label: 'Name', v: m => String(m.name || '').toLowerCase(), str: true },
// holding tank only (2026-11-18): the network heat score, hottest first by default (a lead the hub has no answer for sorts last)
{ k: 'heat', label: 'Heat', v: m => (window.TankReady ? TankReady.score(m) : -1), only: 'tank' },
];
const LIST_FILTERS = [
{ k: 'today', label: 'Active today', t: m => activeToday(m) },
@@ -344,8 +346,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
{ k: 'nopay', label: 'Wallet, payouts off', t: m => !!m.wallet && !m.activated },
{ k: 'payouts', label: 'Payouts on', t: m => !!m.activated },
{ k: 'nowallet', label: 'No wallet', t: m => !m.wallet },
{ k: 'pulse', label: 'Warm or hot', t: m => !!(m.rd && m.rd.heat && m.rd.heat.score >= 40), only: 'tank' },
];
const listState = key => LIST_UI[key] || (LIST_UI[key] = { sort: 'seen', dir: -1, on: new Set(), q: '' });
const listState = key => LIST_UI[key] || (LIST_UI[key] = { sort: key === 'tank' ? 'heat' : 'seen', dir: -1, on: new Set(), q: '' });
// search box (Marty, 2026-11-12: "a user can find their member in the list"): name, username, email or member number
const listHay = m => [m.name, m.username, m.email, m.ref, m.src, m.memberId ? '#' + m.memberId : ''].filter(Boolean).join(' ').toLowerCase();
function listApply(key, rows) {
@@ -360,9 +363,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
const st = listState(key); const hide = (opts && opts.hide) || [];
const bar = document.createElement('div'); bar.className = 'lst-bar';
bar.innerHTML = '<input type="search" class="lst-q" placeholder="Find a member: name, username or email" aria-label="Find a member in this list" autocomplete="off" spellcheck="false">'
+ '<label class="lst-sort">Sort <select aria-label="Sort by">' + LIST_SORTS.map(s => '<option value="' + s.k + '"' + (s.k === st.sort ? ' selected' : '') + '>' + s.label + '</option>').join('') + '</select></label>'
+ '<label class="lst-sort">Sort <select aria-label="Sort by">' + LIST_SORTS.filter(s => !s.only || s.only === key).map(s => '<option value="' + s.k + '"' + (s.k === st.sort ? ' selected' : '') + '>' + s.label + '</option>').join('') + '</select></label>'
+ '<button type="button" class="lst-dir" title="Flip the order">' + (st.dir < 0 ? '&#8595; high to low' : '&#8593; low to high') + '</button>'
+ '<span class="lst-chips">' + LIST_FILTERS.filter(f => !hide.includes(f.k)).map(f => '<button type="button" class="lst-chip' + (st.on.has(f.k) ? ' on' : '') + '" data-f="' + f.k + '" aria-pressed="' + (st.on.has(f.k) ? 'true' : 'false') + '">' + f.label + '</button>').join('') + '</span>'
+ '<span class="lst-chips">' + LIST_FILTERS.filter(f => !hide.includes(f.k) && (!f.only || f.only === key)).map(f => '<button type="button" class="lst-chip' + (st.on.has(f.k) ? ' on' : '') + '" data-f="' + f.k + '" aria-pressed="' + (st.on.has(f.k) ? 'true' : 'false') + '">' + f.label + '</button>').join('') + '</span>'
+ '<span class="lst-n">' + (shown === total ? total + (total === 1 ? ' person' : ' people') : shown + ' of ' + total) + '</span>';
// the list (and this bar with it) is rebuilt on every keystroke, so the new box takes the focus and caret back
const qi = bar.querySelector('.lst-q'); qi.value = st.q || '';
@@ -1996,8 +1999,10 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
el.innerHTML = '';
el.appendChild(listBar('tank', r.waiting.length, rows.length, () => renderTank(el, r), { hide: ['payouts'] })); // nobody in the tank has payouts on
const readyBadge = w => w.ready ? ' <span class="badge" style="background:var(--ok-soft);border-color:var(--ok);color:var(--ok)" title="Wallet linked. If nobody adopts them, the site assigns them to the next eligible adopter when the time runs out.">Ready to activate \u00b7 ' + (w.holdUntil > Date.now() ? holdLeft(w.holdUntil - Date.now()) + ' left' : 'assigning now') + '</span>' : '';
el.insertAdjacentHTML('beforeend', rows.length ? rows.map(w => '<div class="lin-row"><span class="nm">' + esc(w.name) + (opens(w) ? opensBadge(w) : readyBadge(w)) + '</span>'
+ '<span class="em">joined ' + ago(w.joined) + '<span class="sp wrap">' + memberChips(w) + '</span></span>'
// readiness (2026-11-18, network hub): stage, heat, last action and how they got here under each lead; none when the hub is down
const rdHtml = w => (w.rd && window.TankReady ? TankReady.html(w.rd) : '');
el.insertAdjacentHTML('beforeend', rows.length ? rows.map(w => '<div class="lin-row' + (w.rd ? ' rd-row' : '') + '"><span class="nm">' + esc(w.name) + (opens(w) ? opensBadge(w) : readyBadge(w)) + '</span>'
+ '<span class="em">joined ' + ago(w.joined) + '<span class="sp wrap">' + memberChips(w) + '</span>' + rdHtml(w) + '</span>'
+ '<span class="dt">last sign-in: <b>' + ago(w.lastSeen) + '</b></span>'
+ (r.eligible && !opens(w) ? '<button class="btn small" type="button" data-adopt="' + esc(w.username || w.email) + '" data-aname="' + esc(w.name) + '">Adopt</button>' : '') + '</div>').join('')
: '<p class="muted small">Nobody in the tank matches your search or filters.</p>');
+15
View File
@@ -864,3 +864,18 @@ body.hasback #status{bottom:92px}
:root[data-theme="light"] .mockup,:root[data-theme="light"] .modal-card,:root[data-theme="light"] #status,:root[data-theme="light"] #iapChatPanel,:root[data-theme="light"] .chat-drawer{box-shadow:0 18px 50px -20px rgba(11,26,20,.35)}
:root[data-theme="light"] .bo.side-open .bo-side{box-shadow:0 0 60px rgba(11,26,20,.25)}
:root[data-theme="light"] .plate{box-shadow:0 0 24px rgba(10,107,86,.12),inset 0 1px 0 rgba(255,255,255,.8)}
/* ── holding-tank readiness (2026-11-18): stage chip, heat with its band, last action, how they got here. Theme tokens only. ── */
.rd-line{display:flex;flex-wrap:wrap;gap:4px 6px;align-items:center;margin-top:4px;font-weight:400;white-space:normal}
.rd-stage,.rd-heat{display:inline-block;font-size:11px;line-height:1.5;padding:0 7px;border-radius:999px;border:1px solid var(--line-strong);color:var(--muted);font-weight:600;font-variant-numeric:tabular-nums}
.rd-s-warming{color:var(--cyan);border-color:var(--cyan-line);background:var(--cyan-soft)}
.rd-s-engaged{color:var(--violet);border-color:var(--violet-line);background:var(--violet-soft)}
.rd-s-activated{color:var(--mint);border-color:var(--mint-line);background:var(--mint-soft)}
.rd-s-ready{color:var(--ok);border-color:var(--ok);background:var(--ok-soft)}
.rd-hot{color:var(--bad);border-color:var(--bad);background:var(--bad-soft)}
.rd-warm{color:var(--amber);border-color:var(--amber-line);background:var(--amber-soft)}
.rd-cooling{color:var(--cyan);border-color:var(--cyan-line);background:var(--cyan-soft)}
.rd-cold{color:var(--muted);border-color:var(--muted-line);background:var(--muted-soft)}
.rd-last{font-size:11.5px;color:var(--muted)}
.rd-entry{display:block;font-size:11.5px;color:var(--muted);font-weight:400;white-space:normal;margin-top:2px}
.lin-row .em .rd-line,.lin-row .em .rd-entry{white-space:normal}
.lin-row.rd-row .em{white-space:normal}
+51
View File
@@ -0,0 +1,51 @@
// Holding-tank readiness on the tank cards (Marty 2026-11-18, stage 1 of the tank warm-up). The server attaches `rd` to each waiting
// lead from the network hub: { entry: {reason, site, at, detail}, stage, heat: {score, band, label, trend}, last: {kind, site, at} }.
// A lead without `rd` (the hub is down) renders exactly as before. Shared by InstantAdPay and LinkSpin (same file in both).
(function () {
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
const SITES = { iap: 'InstantAdPay', instantadpay: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', dlb: 'Downline Banners',
vbb: 'ViralBannerBlitz', vab: 'ViralAdBlitz', viraladblitz: 'ViralAdBlitz', fivex: '5xYourTeam', dh: 'DownlineHydra', downlinehydra: 'DownlineHydra', hydra: 'DownlineHydra',
ypb: 'YourProgramBuilder', yourprogrambuilder: 'YourProgramBuilder', vas: 'ViralAdSource', viraladsource: 'ViralAdSource', ctb: 'CryptoTeamBuild',
stackpol: 'Stack POL', earnerscorner: 'Earners Corner', polhunter: 'PolHunter', btc4hits: 'BTC4Hits' };
const site = s => (s ? SITES[String(s).toLowerCase()] || String(s) : '');
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
const day = t => { if (!t) return ''; const d = new Date(t); return MON[d.getMonth()] + ' ' + d.getDate() + (d.getFullYear() !== new Date().getFullYear() ? ', ' + d.getFullYear() : ''); };
const month = t => { if (!t) return ''; const d = new Date(t); return MON[d.getMonth()] + ' ' + d.getFullYear(); };
const ago = t => { if (!t) return ''; const ms = Date.now() - t; if (ms < 3600e3) return Math.max(1, Math.round(ms / 60e3)) + ' min ago'; if (ms < 86400e3) return Math.round(ms / 3600e3) + 'h ago'; const d = Math.floor(ms / 86400e3); return d === 1 ? 'yesterday' : d + ' days ago'; };
const who = d => (d && d.from ? ' @' + d.from : '');
function entryText(e) {
if (!e || !e.reason || e.reason === 'unknown') return 'How they got here: unknown';
const d = e.detail || {};
switch (e.reason) {
case 'joined': {
const src = [d.via ? 'via ' + d.via : '', d.ref && d.ref !== 'direct' ? 'from ' + d.ref : d.ref === 'direct' ? 'typed in directly' : ''].filter(Boolean).join(', ');
return 'Joined ' + (site(e.site) || 'the network') + ' ' + day(e.at) + ' with no sponsor' + (src ? ' (' + src + ')' : '');
}
case 'imported': return 'Imported old member of ' + (site(d.oldSite) || 'an older network site') + (d.memberSince ? ', member since ' + month(d.memberSince) : '') + (d.lastSeenOld ? ', last seen there ' + month(d.lastSeenOld) : '') + (e.at ? ' (in the tank since ' + day(e.at) + ')' : '');
case 'rescued': return 'Moved here ' + day(e.at) + ': their sponsor' + who(d) + ' did not reach them in 14 days';
case 'released': return d.note ? 'Released ' + day(e.at) + ' by' + (who(d) || ' the member') + ' who had adopted them' : 'Released by their sponsor' + who(d) + ' ' + day(e.at);
case 'sponsor_gone': return 'Their sponsor left or was blocked (in the tank since ' + day(e.at) + ')';
case 'returned': return 'Back in the tank ' + day(e.at) + ': an adoption' + (d.from ? ' by @' + d.from : '') + ' ended before they got started';
default: return 'How they got here: unknown';
}
}
const STAGE = { new: ['New', 'Nothing yet beyond joining'], warming: ['Warming', 'Visited or clicked a tracked link'], engaged: ['Engaged', 'Signed in or replied'], activated: ['Activated', 'Wallet linked'], ready: ['Ready', 'Bought something'] };
const VERB = { signin: 'signed in', visit: 'visited', click: 'clicked a tracked link', wallet: 'linked a wallet', purchase: 'bought a package', upgrade: 'upgraded', message: 'replied to a message', share: 'shared a link' };
function lastText(l) {
if (!l) return 'no activity yet';
return (VERB[l.kind] || l.kind) + (l.site ? ' on ' + site(l.site) : '') + ', ' + ago(l.at);
}
// the block that goes under the lead's name: stage chip, heat, last action, entry reason
function html(rd) {
if (!rd) return '';
const st = STAGE[rd.stage] || STAGE.new; const h = rd.heat || { score: 0, band: 'cold', label: 'Cold' };
const tr = h.trend === 'up' ? ' &#8599;' : h.trend === 'down' ? ' &#8600;' : '';
return '<span class="rd-line"><span class="rd-stage rd-s-' + esc(rd.stage) + '" title="' + esc(st[1]) + '">' + esc(st[0]) + '</span>'
+ '<span class="rd-heat rd-' + esc(h.band) + '" title="Heat 0-100 from real actions across the network, recent ones count most. Hot 70+, Warm 40-69, Cooling 15-39, Cold under 15.">' + Number(h.score || 0) + ' &middot; ' + esc(h.label || '') + tr + '</span>'
+ '<span class="rd-last" title="Their newest real action on the network">' + esc(lastText(rd.last)) + '</span></span>'
+ '<span class="rd-entry">' + esc(entryText(rd.entry)) + '</span>';
}
const score = m => (m && m.rd && m.rd.heat ? Number(m.rd.heat.score) || 0 : -1);
window.TankReady = { html, entryText, lastText, score, stageLabel: s => (STAGE[s] || STAGE.new)[0] };
})();
+3 -2
View File
@@ -6,7 +6,7 @@
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
<link rel="icon" type="image/png" href="/logo-icon.png">
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
<link rel="stylesheet" href="/assets/site.css?v=20261118rd">
</head>
<body class="bo-body">
@@ -1313,7 +1313,8 @@
<script src="/assets/promo.js?v=20261103gp"></script>
<script src="/assets/support.js?v=20261116sg"></script>
<script src="/assets/netkits.js?v=20261117ypb"></script>
<script src="/assets/my.js?v=20261118team"></script>
<script src="/assets/tankready.js?v=20261118rd"></script>
<script src="/assets/my.js?v=20261118rd"></script>
<script src="/assets/fuel.js?v=20261113sso"></script><script src="/assets/tankfeed.js?v=20261115tb"></script>
<script src="/assets/engine-room.js?v=20261113sso"></script>
<script src="/assets/netsso.js?v=20261113sso"></script>
+2
View File
@@ -77,6 +77,7 @@ elif [ "$MODE" = "member" ]; then
node qa/networksso-hub.e2e.mjs || status=1 # the network hub as the sign-in provider: push, hub sign-in on another site, wallet partner, sign out everywhere, blocked, replay (skips without ../../network-hub)
node qa/tank-hold.mjs || status=1
node qa/tank-batch.test.mjs || status=1 # holding tank batches: ladder, switch off = no writes, rotation, grace, cadence, follow-up, separate 5x cap
node qa/tank-readiness.test.mjs || status=1 # holding tank readiness (2026-11-18): entry reasons, stage, heat against a LOCAL network hub; hub down = card as before
node qa/draft-partner.test.mjs || status=1 # 5xYourTeam draft partner routes (DRAFT_E2E_PORT, default 8825)
node qa/walletnudge.test.cjs || status=1
node qa/bixpay.test.cjs || status=1
@@ -102,6 +103,7 @@ elif [ "$MODE" = "walletnudge" ]; then
elif [ "$MODE" = "tankhold" ]; then
node qa/tank-hold.mjs || status=1
node qa/tank-batch.test.mjs || status=1 # holding tank batches: ladder, switch off = no writes, rotation, grace, cadence, follow-up, separate 5x cap
node qa/tank-readiness.test.mjs || status=1 # holding tank readiness (2026-11-18): entry reasons, stage, heat against a LOCAL network hub; hub down = card as before
elif [ "$MODE" = "sponsorfollow" ]; then
node qa/sponsorfollow.test.cjs || status=1
node qa/sponsorfollow-e2e.mjs || status=1
+82
View File
@@ -0,0 +1,82 @@
// Holding-tank readiness (2026-11-18): the site module against a REAL local network hub (its own temp data dir, throwaway people),
// never production. Checks the entry reasons this site derives from its own records, the signed call, the cache, and that the
// hub being down leaves the tank list exactly as it was. No mail module is even loaded.
// node qa/tank-readiness.test.mjs (HUB_DIR = the network-hub checkout, default ../../network-hub)
import { createRequire } from 'module';
import fs from 'fs'; import os from 'os'; import path from 'path'; import assert from 'assert';
const require = createRequire(import.meta.url);
const HUB_DIR = process.env.HUB_DIR || path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '../../../network-hub');
const SECRET = 'q'.repeat(40);
process.env.DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-rdy-'));
process.env.HUB_SITES = JSON.stringify({ iap: { secret: SECRET, seeEmails: true } });
process.env.HUB_ADMIN_SECRET = 'z'.repeat(40);
delete process.env.DATABASE_URL;
const hubStore = require(path.join(HUB_DIR, 'lib/store'));
const hubPeople = require(path.join(HUB_DIR, 'lib/people'));
const hubAct = require(path.join(HUB_DIR, 'lib/activity'));
const { start } = require(path.join(HUB_DIR, 'server'));
const TR = require('../tankready.js');
let pass = 0; const ok = (c, m) => { assert.ok(c, m); pass++; console.log(' ok', m); };
const DAY = 86400000; const now = Date.now();
// the hub knows two of the leads: one imported from an old site, one who signed in on LinkSpin yesterday
hubPeople.importRows([{ email: 'old@t.test', username: 'oldtimer', joinedAt: now - 500 * DAY }], 'vbb');
const live = hubPeople.join({ site: 'iap', email: 'live@t.test', username: 'livewire' }).person;
hubAct.record(live.id, 'linkspin', 'signin', now - DAY, now);
hubPeople.join({ site: 'iap', email: 'spons@t.test', username: 'sponsorx' });
const server = await start(0); const port = server.address().port;
process.env.HUB_URL = 'http://127.0.0.1:' + port; process.env.HUB_SECRET = SECRET; process.env.HUB_SITE = 'iap'; process.env.HUB_ENABLED = '1';
// a fake site: accounts, tank waiting list, adoption history, follow records
const accts = {
'old@t.test': { email: 'old@t.test', username: 'oldtimer', created: now - 3 * DAY, joinedVia: 'hub', joinedRef: 'hub:vbb' },
'live@t.test': { email: 'live@t.test', username: 'livewire', created: now - 10 * DAY, joinedVia: 'page', joinedRef: 'viefaucet.com', lastSeen: now - 2 * 3600e3 },
'resc@t.test': { email: 'resc@t.test', username: 'rescued1', created: now - 30 * DAY },
'dead@t.test': { email: 'dead@t.test', username: 'deadlink', created: now - 30 * DAY },
'b4h@t.test': { email: 'b4h@t.test', created: now - 7 * DAY, joinedVia: 'btc4hits', joinedRef: 'btc4hits' },
'back@t.test': { email: 'back@t.test', username: 'backagain', created: now - 40 * DAY },
'spons@t.test': { email: 'spons@t.test', username: 'sponsorx' }
};
const waiting = ['old@t.test', 'live@t.test', 'resc@t.test', 'dead@t.test', 'b4h@t.test', 'back@t.test'].map(e => ({ email: e, name: '@' + (accts[e].username || 'x'), joined: accts[e].created, lastSeen: accts[e].lastSeen || 0, wallet: e === 'live@t.test' }));
const hist = new Map([
['resc@t.test', [{ adopter: 'spons@t.test', ts: now - 4 * DAY, status: 'rescued', closed: null }]],
['dead@t.test', [{ adopter: 'dead:gone99', ts: now - 5 * DAY, status: 'rescued', closed: null }]],
['back@t.test', [{ adopter: 'spons@t.test', ts: now - 20 * DAY, status: 'rescued' }, { adopter: 'spons@t.test', ts: now - 15 * DAY, status: 'expired', closed: now - 8 * DAY }]]
]);
let calls = 0;
TR.init({ site: 'iap', accounts: { byEmail: async e => accts[e] || null }, tank: { waiting: async () => { calls++; return waiting; }, historyMap: async () => hist }, followGet: () => null });
console.log('tank readiness: local hub on :' + port);
const c = await TR.refresh();
ok(c && c.by.size === 6, 'one call returned readiness for all six leads');
const get = e => c.by.get(e);
ok(get('old@t.test').entry.reason === 'imported' && get('old@t.test').entry.detail.oldSite === 'vbb', 'hub-made account: the hub says imported from ViralBannerBlitz with the old join date');
ok(get('live@t.test').entry.reason === 'joined' && get('live@t.test').entry.detail.ref === 'viefaucet.com', 'joined with no sponsor, with the source');
ok(get('live@t.test').stage === 'activated' && get('live@t.test').heat.score >= 40, 'wallet linked = Activated, signed in recently = warm or hot (' + get('live@t.test').heat.score + ')');
ok(get('live@t.test').last.kind === 'signin' && get('live@t.test').last.site === 'iap', 'last action: the site sign-in 2 hours ago beats the LinkSpin one yesterday');
ok(get('resc@t.test').entry.reason === 'rescued' && get('resc@t.test').entry.detail.from === 'sponsorx', 'rescued, naming the sponsor by username');
ok(get('dead@t.test').entry.reason === 'sponsor_gone' && !get('dead@t.test').entry.detail.from, 'dead sponsor link: sponsor gone, no name');
ok(get('b4h@t.test').entry.reason === 'imported' && get('b4h@t.test').entry.detail.oldSite === 'BTC4Hits', 'BTC4Hits import (not on the hub: the site report alone)');
ok(get('back@t.test').entry.reason === 'returned', 'back after an adoption window ended (newest record wins)');
ok(get('b4h@t.test').stage === 'new' && get('b4h@t.test').heat.band === 'cold' && get('b4h@t.test').last === null, 'never seen: New, Cold, no activity');
const txt = JSON.stringify([...c.by.values()]);
ok(!/@t\.test/.test(txt), 'no email in anything the hub sent back');
ok(!JSON.stringify(hubStore.all().map(p => p.tankEntry || null)).includes('@'), 'no email stored in the entry facts on the hub');
ok(hubPeople.byEmail('live@t.test').tankEntry && hubPeople.byEmail('live@t.test').tankEntry.reason === 'joined', 'the entry fact is recorded on the hub');
const att = await TR.attach(waiting);
ok(att.every(w => w.rd) && calls === 1, 'attach uses the fresh cache, no second call');
ok(waiting.every(w => !w.rd), 'the original rows are not changed');
// the hub goes away: the card shows the rows as before (after the cache is gone)
server.close(); TR._reset();
const down = await TR.attach(waiting, 1500);
ok(down.length === 6 && down.every(w => !w.rd), 'hub down: the same rows, no extras, no error');
ok(TR.status().ok === false, 'status says the hub is not answering');
process.env.HUB_ENABLED = '0'; TR._reset();
ok((await TR.attach(waiting)) === waiting, 'switched off: untouched');
console.log('tank readiness: ALL PASSED (' + pass + ')');
process.exit(0);
+7 -2
View File
@@ -36,6 +36,7 @@ const kb = require('./kb'); // the assistant's knowledge base:
const fraud = require('./fraud');
const coach = require('./coach'); // coaching view, nudges, digest, prospects, link stats
const tank = require('./tank');
const tankready = require('./tankready'); // holding-tank readiness from the network hub (2026-11-18): entry reason, stage, heat, last action on the tank cards. No mail.
const walletnudge = require('./walletnudge');
const milestone = require('./milestone'); // players with POL waiting in the games and no wallet (2026-10-07) // holding tank: unsponsored free members, adoptions, pay-it-forward
const legacy = require('./legacy'); // Faucet Wave / Tier One Ads bridge: welcome-back credits for listed emails
@@ -743,6 +744,7 @@ async function boot() {
sponsorAccount: em => accounts.byEmail(em),
wouldCycle: async (email, sp) => { let cur = sp; const seen = new Set(); for (let i = 0; cur && i < 60; i++) { if (cur.email === email || seen.has(cur.email)) return true; seen.add(cur.email); cur = await accounts.sponsorOf(cur.email); } return false; },
activationOf: a => a.address ? activationByAddress().get(String(a.address).toLowerCase()) || null : null });
tankready.init({ site: 'iap', accounts, tank, followGet: e => followStore.get(e) }); // read-only: sends this site's facts, keeps the hub's answer for the tank cards
tank.init({ capOpen: () => siteConfig().tankAdoptCap, dataDir: DATA_DIR, chain, accounts, messages, mailer, ads, site: 'https://instantadpay.com', follow, store: followStore,
// activation hold + 24-hour safety net (2026-10-27): a tank member is never bound under the fallback position
// network hub rule 3 (2026-11-14, only with HUB_ENABLED): the hub's sponsor comes first for alignment, and nobody it reports
@@ -1696,6 +1698,7 @@ async function tankAdminAlert(text) {
// who linked a wallet, run the safety net, and tell the shared payments topic once per member who became ready
async function tankReadyTick() {
const r = await tank.readyTick();
tankready.refresh().catch(() => {}); // readiness: send the hub this site's entry facts and refresh the card cache (no mail, no sponsor change)
if (r.aligned || r.assigned.length || r.held || r.fresh.length || (r.reminders || []).length) console.log('tank ready tick', JSON.stringify({ fresh: r.fresh.length, aligned: r.aligned, assigned: r.assigned.length, held: r.held, payReminders: (r.reminders || []).map(x => x.stage) }));
const sc = siteConfig();
if (!r.fresh.length || !sc.telegramBotToken || !sc.telegramEchoChatId) return r;
@@ -3627,7 +3630,8 @@ const server = http.createServer(async (req, res) => {
if (p === '/api/my/tank' && req.method === 'GET') {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
return json(res, 200, await tank.view(s.email));
const v = await tank.view(s.email); v.waiting = await tankready.attach(v.waiting); // readiness (hub): entry, stage, heat, last action
return json(res, 200, v);
}
// -- achievement badge -> Telegram (payments topic + the main group), once per badge per member.
// The browser composes the personalised image (canvas, same as Share) and posts it here.
@@ -3927,7 +3931,8 @@ const server = http.createServer(async (req, res) => {
if (p === '/api/admin/tank/batches' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, await tankbatch.adminView()); }
if (p === '/api/admin/tank' && req.method === 'GET') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
return json(res, 200, await tank.adminView());
const v = await tank.adminView(); v.waiting = await tankready.attach(v.waiting); v.readiness = Object.assign(tankready.status(), { counts: tankready.counts() });
return json(res, 200, v);
}
// an adoption made for a member (Marty 2026-11-14: sponsors who lost people when the contract sponsor won get a few from the
// tank). The same tank.adopt as the member's own button: their eligibility and cap, the adoptee's email and chat. No payments-topic
+125
View File
@@ -0,0 +1,125 @@
'use strict';
// Holding-tank readiness (Marty 2026-11-18, stage 1 of the tank warm-up; review page claude.ai/artifact/76vTtcB67KJNopG3KZu5ca).
// What an adopting sponsor sees on each waiting lead: how they got into the tank, how far along they are (New, Warming, Engaged,
// Activated, Ready), a 0-100 heat score with its band, and their last real action. The network hub computes it
// (POST <hub>/v1/tank/readiness, the one heat formula in network-hub lib/heat.js); this module sends the hub what only this
// site knows (its own last sign-in, a linked wallet, and the entry reason from its adoption records and join data) and keeps
// the answer in memory for the tank card.
//
// NO EMAIL, NO MESSAGE, NO SPONSOR CHANGE: read-only here; the hub stores only the entry fact. The hub down = no extras, the tank
// card works exactly as before. The same file runs on InstantAdPay and LinkSpin (deps.site names the site; copy changes to both).
const crypto = require('crypto');
const FRESH_MS = 5 * 60 * 1000; // a cached answer this young is used as is
const STALE_MS = 6 * 3600 * 1000; // an older one is still shown while a refresh runs, never past this
const DOWN_MS = 2 * 60 * 1000; // the hub failed: no new try for this long
let R = null; // deps: { site, accounts, tank, followGet(email) }
let cache = { at: 0, by: new Map() }; let busy = null; let downUntil = 0; let last = { at: 0, ok: null, n: 0, ms: 0, error: null, recorded: 0 };
const on = () => /^(1|true|on|yes)$/i.test(String(process.env.HUB_ENABLED || '')) && String(process.env.HUB_READINESS || '1') !== '0'
&& !!process.env.HUB_URL && String(process.env.HUB_SECRET || '').length >= 32 && typeof fetch === 'function';
const lc = v => String(v || '').trim().toLowerCase();
function init(deps) { R = deps; }
async function hubPost(p, body, timeout) {
const raw = JSON.stringify(body); const ts = String(Date.now());
const sig = crypto.createHmac('sha256', process.env.HUB_SECRET).update(ts + '\n' + raw).digest('hex');
const r = await fetch(String(process.env.HUB_URL).replace(/\/+$/, '') + p, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Hub-Site': process.env.HUB_SITE || R.site, 'X-Hub-Ts': ts, 'X-Hub-Sig': sig }, body: raw, signal: AbortSignal.timeout(timeout || 20000) });
let j = null; try { j = await r.json(); } catch (e) {}
if (r.status !== 200) throw new Error('hub ' + p + ' ' + r.status + (j && j.error ? ' ' + j.error : ''));
return j;
}
// ── how they got into the tank, from this site's own records ──
// adoption history (tank.historyMap: newest 6 per person: adopter, ts, status, closed, note), the sponsor-follow record (a move
// made on the other platform), and the join data. Sponsor emails never leave the site: a username, or nothing.
const ENTRY_STATUS = { rescued: 'rescued', released: 'released', dropped: 'released', expired: 'returned', unreached: 'returned' };
const LATER = new Set(['open', 'done', 'invited', 'gift', 'moved', 'conflict']); // a sponsor came after: that entry is over
const FOLLOW_BY = { rescue: 'rescued', release: 'released', expire: 'returned', expiry: 'returned' };
const IMPORTS = { btc4hits: 'BTC4Hits', faucetwave: 'FaucetWave', socialpix: 'SocialPix' };
async function nameOfEmail(email) {
if (!email || String(email).startsWith('dead:')) return null;
try { const a = await R.accounts.byEmail(lc(email)); return a && a.username ? a.username : null; } catch (e) { return null; }
}
async function localEntry(a, hist, pv) {
const rows = (hist || []).slice().sort((x, y) => (x.closed || x.ts || 0) - (y.closed || y.ts || 0));
let best = null;
for (const h of rows) {
if (ENTRY_STATUS[h.status]) {
const dead = h.status === 'rescued' && String(h.adopter || '').startsWith('dead:');
best = { reason: dead ? 'sponsor_gone' : ENTRY_STATUS[h.status], at: Number(h.status === 'rescued' || h.status === 'released' ? h.ts : (h.closed || h.ts)) || 0, adopter: h.adopter, status: h.status };
} else if (LATER.has(h.status) && best && (h.ts || 0) >= best.at) best = null;
}
// a move made on the other platform that left them with no sponsor here (sponsorfollow), when newer
if (pv && !pv.sponsorEmail && FOLLOW_BY[pv.by] && Number(pv.at) > (best ? best.at : 0)) best = { reason: FOLLOW_BY[pv.by], at: Number(pv.at), adopter: pv.prevEmail || null, site: ({ instantadpay: 'iap', linkspin: 'linkspin' })[lc(pv.origin)] || null };
if (best) {
const from = best.reason === 'sponsor_gone' ? null : await nameOfEmail(best.adopter);
const detail = {}; if (from) detail.from = from;
if (best.reason === 'sponsor_gone') detail.note = 'their sponsor link no longer leads to a member';
if (best.status === 'dropped') detail.note = 'released by the member who adopted them';
return { reason: best.reason, at: best.at, site: best.site || undefined, detail };
}
const via = lc(a.joinedVia); const ref = lc(a.joinedRef);
if (via === 'hub') return null; // made here for someone who joined elsewhere on the network: the hub knows their first door
if ((via === 'linkspin' || via === 'instantadpay' || via === 'carried') && ref !== 'btc4hits') return null; // a copy of an account from the other platform (LinkSpin: 'carried'): same, the hub knows
const leg = /^legacy:([a-z0-9]+)/.exec(ref);
if (via === 'btc4hits' || ref === 'btc4hits') return { reason: 'imported', at: Number(a.created) || 0, detail: { oldSite: 'BTC4Hits' } };
if (leg) return { reason: 'imported', at: Number(a.created) || 0, detail: { oldSite: IMPORTS[leg[1]] || leg[1] } };
const detail = {}; if (via) detail.via = via; if (ref && !/^hub:/.test(ref)) detail.ref = ref.slice(0, 80);
return { reason: 'joined', at: Number(a.created) || 0, detail };
}
// one call for the whole waiting list (a few thousand rows at most)
async function refresh() {
if (!R || !on()) return null;
if (busy) return busy;
busy = (async () => {
const t0 = Date.now();
try {
const list = await R.tank.waiting();
const hist = R.tank.historyMap ? await R.tank.historyMap() : new Map();
const accts = new Map();
const rows = [];
for (const w of list) {
const a = (await R.accounts.byEmail(w.email)) || { email: w.email, created: w.joined };
accts.set(w.email, a);
let pv = null; try { pv = R.followGet ? R.followGet(w.email) : null; } catch (e) {}
rows.push({ email: w.email, seenAt: w.lastSeen || 0, wallet: !!w.wallet, entry: await localEntry(a, hist.get(w.email), pv) || undefined });
}
const r = rows.length ? await hubPost('/v1/tank/readiness', { rows }, 30000) : { rows: [] };
const by = new Map();
for (const x of (r.rows || [])) { const src = rows[x.i]; if (src) by.set(src.email, { entry: x.entry, stage: x.stage, heat: x.heat, last: x.last, onHub: !!x.onHub }); }
cache = { at: Date.now(), by };
last = { at: Date.now(), ok: true, n: by.size, ms: Date.now() - t0, error: null, recorded: r.recorded || 0 };
return cache;
} catch (e) {
downUntil = Date.now() + DOWN_MS; last = { at: Date.now(), ok: false, n: 0, ms: Date.now() - t0, error: e.message, recorded: 0 };
console.error('tankready', e.message);
return null;
} finally { busy = null; }
})();
return busy;
}
// the readiness for these waiting rows, as rows with `rd` added. Waits for the hub only when nothing usable is cached, and then
// at most `waitMs`; otherwise answers from the cache and refreshes in the background.
async function attach(list, waitMs) {
if (!R || !on() || !Array.isArray(list)) return list;
const age = Date.now() - cache.at;
if (age > FRESH_MS && Date.now() > downUntil) {
const p = refresh();
if (age > STALE_MS && p) await Promise.race([p, new Promise(res => setTimeout(res, waitMs || 4000))]);
}
if (Date.now() - cache.at > STALE_MS) return list;
return list.map(w => { const x = cache.by.get(w.email); return x ? Object.assign({}, w, { rd: x }) : w; });
}
const status = () => Object.assign({ on: on(), cached: cache.by.size, cachedAt: cache.at || null }, last);
// counts for the report: entry reasons and stages across the cached tank
function counts() {
const reasons = {}; const stages = {}; const bands = {};
for (const x of cache.by.values()) { reasons[x.entry.reason] = (reasons[x.entry.reason] || 0) + 1; stages[x.stage] = (stages[x.stage] || 0) + 1; bands[x.heat.band] = (bands[x.heat.band] || 0) + 1; }
return { at: cache.at, n: cache.by.size, reasons, stages, bands };
}
module.exports = { init, refresh, attach, status, counts, localEntry, _reset: () => { cache = { at: 0, by: new Map() }; downUntil = 0; busy = null; } };