Holding tank: 24-hour sign-up grace plus a Who invited you card (Marty 2026-11-07: "24-hour grace plus the prompt"). On Nov 2 a sponsorless sign-up was adopted five hours after joining, before he could say who invited him.

Grace: for 24 hours from an account's created time nobody can adopt the person by hand. They stay on the waiting list after the open ones with an Opens in badge and no Adopt button, and adopt() refuses in plain words. Only sign-up counts, so someone back in the tank later has no grace. Auto-assign does not wait for it: the 24-hour hold still runs from the wallet link and is not stretched. No notice tells people to adopt someone they cannot adopt yet: the wallet-ready post waits for the grace and says the time really left, is skipped when the rotation takes them in that tick, the arrivals post moves to when the grace ends (marks.claim per member), and the Overview note and weekly email count only people who are open.

Prompt: a member with no sponsor and no member number sees the card at the top of Overview, types a username, confirms in an in-page box, and that person becomes their sponsor through setSponsor as a deliberate change with by 'invited', so it follows to LinkSpin and clears the hold. Refused: self, unknown username, already sponsored, member number or wallet already on the contract, a chain loop, a suspended sponsor, a no-payout chain, and a line with nobody on the contract (they would walk up to the company). The network sponsor is tried first. Nobody invited me hides it and a small link brings it back. Not an adoption: status 'invited', no 7-day window, not counted toward the two. The named sponsor gets the referral email and an on-site notice. Switch-on-payouts reminders track the named sponsor.

Chatbot canned + systemPrompt, KNOWLEDGE_DATE 2026-11-07. my.js, admin.js, admin-sponsorcheck.js ?v=20261107tg. qa/tank-hold.mjs, qa/sponsorfollow.test.cjs and qa/sponsorfollow-e2e.mjs extended (SF_E2E_PORT overrides the ports).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-07 07:04:18 -06:00
parent 973fc80570
commit bfbea142b6
13 changed files with 405 additions and 33 deletions
+13 -2
View File
@@ -17,7 +17,7 @@ const LS_SITE = process.env.LS_SITE || path.join(IAP_SITE, '..', '..', 'linkspin
const SECRET = 'qa-sponsorfollow-' + 'x'.repeat(40);
process.env.LS_SYNC_SECRET = SECRET;
const SF = require(path.join(IAP_SITE, 'sponsorfollow.js'));
const IAP_PORT = 8811, LS_PORT = 8812, IAP = 'http://127.0.0.1:' + IAP_PORT, LS = 'http://127.0.0.1:' + LS_PORT;
const IAP_PORT = Number(process.env.SF_E2E_PORT || 8811), LS_PORT = IAP_PORT + 1, IAP = 'http://127.0.0.1:' + IAP_PORT, LS = 'http://127.0.0.1:' + LS_PORT;
const sleep = ms => new Promise(r => setTimeout(r, ms));
let pass = 0, fail = 0; const lines = [];
const ok = (cond, name, extra) => { if (cond) { pass++; lines.push('ok ' + name); } else { fail++; lines.push('FAIL ' + name + (extra ? '\n ' + extra : '')); } };
@@ -30,7 +30,7 @@ function seed(dir, list) {
for (const a of list) { db.byEmail[a.email] = a; db.byCode[a.code] = a.email; }
fs.writeFileSync(path.join(dir, 'accounts.json'), JSON.stringify(db));
}
const base = () => [acct('adopter@qa.test', 'adopter', { memberId: 0 }), acct('old@qa.test', 'oldsponsor'), acct('lead1@qa.test', 'leadone'), acct('lead2@qa.test', 'leadtwo', { sponsorRef: 'oldsponsor' }), acct('lead4@qa.test', 'leadfour', { sponsorRef: 'oldsponsor' })];
const base = () => [acct('boss@qa.test', 'qaboss', { memberId: 77 }), acct('lead5@qa.test', 'leadfive'), acct('adopter@qa.test', 'adopter', { memberId: 0 }), acct('old@qa.test', 'oldsponsor'), acct('lead1@qa.test', 'leadone'), acct('lead2@qa.test', 'leadtwo', { sponsorRef: 'oldsponsor' }), acct('lead4@qa.test', 'leadfour', { sponsorRef: 'oldsponsor' })];
const iapDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sf-e2e-iap-')), lsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sf-e2e-ls-'));
// lead3 is bound on InstantAdPay (memberId), lead4 joined LinkSpin under someone else (ordinary, already different)
seed(iapDir, base().concat([acct('lead3@qa.test', 'leadthree', { memberId: 42, sponsorRef: 'oldsponsor' })]));
@@ -70,6 +70,17 @@ try {
await sleep(6000);
ok((await facts(IAP, 'lead3@qa.test')).sponsorEmail === 'old@qa.test', 'bound on InstantAdPay: sponsor there unchanged');
// 3b. Who invited you (2026-11-07): the member, signed in on InstantAdPay, names their sponsor; LinkSpin follows through the real sync
{ const st = await fetch(IAP + '/api/auth/email/start', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: 'lead5@qa.test', fts: Date.now() - 8000 }) }).then(x => x.json());
const v = await fetch(IAP + '/api/auth/email/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: 'lead5@qa.test', code: st.devCode }) });
const cookie = (v.headers.getSetCookie ? v.headers.getSetCookie() : []).map(c => c.split(';')[0]).join('; ');
const inv = await fetch(IAP + '/api/my/tank/invited', { method: 'POST', headers: { 'Content-Type': 'application/json', Cookie: cookie }, body: JSON.stringify({ who: '@qaboss' }) }).then(x => x.json());
ok(inv.ok && inv.name === '@qaboss', 'lead5 names @qaboss on InstantAdPay', JSON.stringify({ inv, dev: !!st.devCode }));
ok(await waitFor(async () => (await facts(LS, 'lead5@qa.test')).sponsorEmail === 'boss@qa.test'), 'LinkSpin follows: lead5 under boss');
const f5 = await facts(LS, 'lead5@qa.test'); ok(f5 && f5.prov && f5.prov.by === 'invited' && f5.prov.origin === 'instantadpay', 'LinkSpin keeps the record (by invited, origin instantadpay)', JSON.stringify(f5 && f5.prov));
const a5 = await admin(IAP, '/api/admin/tank'); ok((a5.adoptions || []).some(x => x.adoptee === 'lead5@qa.test' && x.status === 'invited'), 'InstantAdPay admin tank shows the record');
}
// 4. ping-pong: let both ticks run; nothing keeps bouncing
const s1 = await admin(IAP, '/api/admin/lssync'), t1 = await admin(LS, '/api/admin/iapsync');
await admin(IAP, '/api/admin/lssync/run', {}); await admin(LS, '/api/admin/iapsync/run', {}); await sleep(1500);