5xYourTeam The Draft on the network holding tank (Marty approved the rules 2026-11-15): signed partner routes draftpartner.js, LOCAL ONLY

POST /api/partner/draft/{pool,adopt,release,status}, HMAC DRAFT_PARTNER_SECRET over 'draft.v1.' + ts + newline + body (X-Draft-Ts /
X-Draft-Sig, 5 min), 503 until the secret is set; GET /api/admin/draft (picks + log). Every pick is tank.adopt() with opts.partner:
the signed 5x claim (positions >= 1) replaces the own-$20-buy rule for these calls only (the member's own tank button keeps it); the
coach needs an account here with a wallet linked and someone on this contract in their line (else a pick who starts here would walk
up to the company), not flagged, under the people-held cap; max 10 open picks; max 2 adoptions per person; the 24 h grace; rule 3
plus a fresh hub lock check at adopt (hub silent = refused); pool also drops spam/flagged (fraud + link-farm list), throwaway and
mistyped email domains, anyone adopted twice. Cards carry no contact data (hub ids or opaque i_ ids, door, joined, last seen,
wallet yes/no, surfing credits; games null, not tracked here). The adoption email is the only mail: no payTrack reminders, no
payments-topic post. Sponsor moves via setSponsor (sponsorfollow + hub sponsor-change, by 'adopt' / 'release').

Pick window: adoption row expires +3 days; tank.sweep skips picks (hooks.isDraftPick); draftpartner.sweep (hourly) closes them by the
pick rule: started (payouts on / purchase) = done, adopted twice or locked = kept with the coach, hub silent = wait, else back to the
tank with the original join time (no new grace). Coach release after 48 h. rid makes adopt/release idempotent. A pick closed some
other way reconciles as 'moved'. MySQL tables draft_picks + draft_log (JSON fallback locally); every call logged with a code/reason.

Tests: qa/draft-partner.test.mjs 66/66 (real tank.js, mocked clock, fake hub + a local copy's routes on 8825), in run.sh member and
run.sh draft; bash qa/run.sh member exit 0 (bugs 0); tank-cap 13/13, sponsorfollow 30/30.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-15 07:20:14 -06:00
parent 7f57aedcb6
commit e17d8c4fbb
5 changed files with 672 additions and 12 deletions
+21
View File
@@ -55,6 +55,7 @@ const lssync = require('./lssync');
const lsconv = require('./lsconv'); // conversion tracking: ad click ids pushed to LinkSpin + the member's goals (2026-10-23)
const lsreport = require('./lsreport'); // conversion linkage: the LinkSpin click on the account, sign-up / wallet / purchase reported, reporting only (2026-11-07)
const lsinbound = require('./lsinbound'); // reverse registry sync: LinkSpin-first members arrive as waiting accounts (2026-10-15)
const draftpartner = require('./draftpartner'); // 5xYourTeam The Draft: signed pool / adopt / release / status on the network tank (2026-11-15, needs DRAFT_PARTNER_SECRET)
const hubsync = require('./hubsync'); // network hub: members from other doors arrive as waiting accounts, ours are reported (2026-11-12, only with HUB_ENABLED)
const SF = require('./sponsorfollow'); // deliberate sponsor changes follow to LinkSpin until chain-bound + one network tank (2026-10-22)
const bixpay = require('./bixpay'); // BixPay Visa card: partner-link field, sponsor-follows resolver, tracked clicks (2026-10-29, gated by site config bixpayLive)
@@ -735,6 +736,7 @@ async function boot() {
hooks: { network: async (email, address) => (hubsync.enabled() ? await hubsync.hubSponsor(email).catch(() => null) : null) || lsinbound.networkSponsor(email, address),
networkHeld: hubsync.enabled() ? accts => hubsync.heldAmong(accts) : null, networkLocked: hubsync.enabled() ? email => hubsync.lockedAnywhere(email) : null,
isSuspended: em => fraud.isSuspended(em), excluded: em => fraud.excluded(em),
isDraftPick: id => draftpartner.isDraftPick(id), // a 5xYourTeam pick's adoption: draftpartner.js owns its 3-day window
payoutBlocked: id => payoutChainBlocked(id, 2), companyId: () => Number(siteConfig().defaultSponsorId) || 1,
assigned: r => { tankPickupPost(r.adopterName, r.adopteeName, true); }, adminAlert: text => tankAdminAlert(text),
// switch-on-payouts reminders after an assignment (2026-10-27): one send per key across both app copies (deploy overlap),
@@ -746,6 +748,11 @@ async function boot() {
lsinbound.init({ dataDir: DATA_DIR, accounts, lssync, follow, store: followStore });
// network hub (hubsync.js): nothing at all happens here unless HUB_ENABLED is on; the LinkSpin sync above runs either way
if (hubsync.enabled()) { hubsync.init({ dataDir: DATA_DIR, accounts, lsinbound, follow: followStore, chain }); accounts.onChange(email => { lssync.touch(email); hubsync.touch(email); }); hubsync.start(); }
// 5xYourTeam draft picks (draftpartner.js, 2026-11-15): the routes answer 503 until DRAFT_PARTNER_SECRET is set; the pool stays empty
// and nobody can be drafted while the hub is off (DRAFT_ALLOW_NO_HUB=1 is for local tests only, refused in production)
await draftpartner.init({ dataDir: DATA_DIR, accounts, chain, tank, ads, requireHub: !(process.env.DRAFT_ALLOW_NO_HUB === '1' && process.env.NODE_ENV !== 'production'),
hooks: { hubInfo: email => (hubsync.enabled() ? hubsync.hubInfo(email) : null), resolvePerson: q => (hubsync.enabled() ? hubsync.resolvePerson(q) : null), networkOn: () => hubsync.enabled(),
excluded: em => fraud.excluded(em), spamEmails: () => (((spamscan.view() || {}).last || {}).candidates || []).map(c => c.email), suggestDomain: d => require('./emailcheck').suggestDomain(d) } }).catch(e => console.error('draftpartner init', e.message));
setTimeout(() => lssync.tick().catch(e => console.error('lssync', e.message)), 2 * 60 * 1000);
setInterval(() => lssync.tick().catch(e => console.error('lssync', e.message)), 2 * 60 * 1000);
setInterval(() => follow.retryPending().catch(e => console.error('sponsorfollow retry', e.message)), 2 * 60 * 1000); // follows waiting on a chain read or a sponsor account
@@ -827,6 +834,7 @@ async function boot() {
geo.init({ dataDir: DATA_DIR }).catch(e => console.error('geo init', e.message));
setInterval(() => geo.refresh().catch(e => console.error('geo refresh', e.message)), 24 * 3600 * 1000); // monthly file, checked daily
setInterval(() => tank.sweep().catch(e => console.error('tank sweep', e.message)), 60 * 60 * 1000); // adoptions past their 7-day window
setInterval(() => draftpartner.sweep().then(r => { if (r.done || r.returned || r.kept || r.moved) console.log('draft sweep', JSON.stringify(r)); }).catch(e => console.error('draft sweep', e.message)), 60 * 60 * 1000); // 5xYourTeam picks: 3-day window
burner.init({ chain, ads, accounts });
setTimeout(() => coach.nudgeTick().catch(e => console.error('coach', e.message)), 90 * 1000);
setInterval(() => coach.nudgeTick().catch(e => console.error('coach', e.message)), 60 * 60 * 1000);
@@ -3825,6 +3833,19 @@ const server = http.createServer(async (req, res) => {
}
if (p === '/api/admin/lssync/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const b = await readBody(req); return json(res, 200, await lssync.tick(!!(b && b.force))); }
if (p === '/api/admin/walletnudge/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, await walletnudge.tick()); }
// -- 5xYourTeam The Draft (draftpartner.js, 2026-11-15): signed partner calls, DRAFT_PARTNER_SECRET as X-Draft-Ts + X-Draft-Sig
if (p.startsWith('/api/partner/draft/') && req.method === 'POST') {
const raw = await new Promise((ok, no) => { let d = ''; req.on('data', c => { d += c; if (d.length > 64000) { req.destroy(); no(new Error('too big')); } }); req.on('end', () => ok(d)); req.on('error', no); });
const sg = draftpartner.verify(req.headers, raw); if (!sg.body) return json(res, sg.status, { error: sg.error });
const op = p.slice('/api/partner/draft/'.length);
if (!['pool', 'adopt', 'release', 'status'].includes(op)) return json(res, 404, { error: 'unknown op' });
const r = await draftpartner.handle(op, sg.body);
return json(res, r.error ? 400 : 200, r);
}
if (p === '/api/admin/draft' && req.method === 'GET') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
return json(res, 200, await draftpartner.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());