From 3815965fc1a41cd74a30726ebc4d4264c4b97a81 Mon Sep 17 00:00:00 2001 From: martbost Date: Sun, 15 Nov 2026 08:42:22 -0600 Subject: [PATCH] Staging test mode (Marty's rule: test apps never touch real people): TANK_MODE=iap with DRAFT_LIVE not 1 reads the pool + statuses from InstantAdPay but every pick (5 instant picks on a purchase, the Monday draft) and release is a preview kept here: no tank.adopt(), no sponsor change, no email. Yellow 'TEST MODE, nobody is adopted' strip on every page (/api/config testMode). Admin view: testMode, previewPicks, adoptionMailsSkipped. iap-tank 35/35 (new section 6 against the real draftpartner.js), unit 62/62, smoke 156/156. common.js/fx.css ?v=3 Co-Authored-By: Claude Opus 5.5 --- .env.example | 1 + docker-compose.yml | 1 + public/admin.html | 6 +++--- public/assets/common.js | 3 +++ public/assets/fx.css | 4 ++++ public/builder.html | 8 ++++---- public/cards.html | 6 +++--- public/coach.html | 6 +++--- public/contract.html | 4 ++-- public/disclaimer.html | 6 +++--- public/draftday.html | 2 +- public/index.html | 6 +++--- public/join.html | 8 ++++---- public/ledger.html | 6 +++--- public/privacy.html | 6 +++--- public/promote.html | 8 ++++---- public/team.html | 8 ++++---- public/terms.html | 6 +++--- qa/iap-tank.test.cjs | 25 ++++++++++++++++++++++++- server.js | 2 +- tankpool.js | 27 +++++++++++++++++++++++---- tools/pages.mjs | 2 +- 22 files changed, 101 insertions(+), 50 deletions(-) diff --git a/.env.example b/.env.example index 85144b7..e04743b 100644 --- a/.env.example +++ b/.env.example @@ -20,6 +20,7 @@ KEEPER_KEY= # the voucher key; its a WALLETCONNECT_PROJECT_ID= # the holding tank: stub (phase 1 fixture) | hub (phase 2, not wired) TANK_MODE=stub +DRAFT_LIVE=0 # 1 only at go-live: picks become real IAP adoptions + sponsor emails # the draft (Central time); every value here is an open question for Marty DRAFT_DOW=1 DRAFT_HOUR_CT=19 diff --git a/docker-compose.yml b/docker-compose.yml index e3379e6..55b3bde 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,6 +21,7 @@ services: HUB_URL: ${HUB_URL:-} HUB_SECRET: ${HUB_SECRET:-} TANK_MODE: ${TANK_MODE:-} + DRAFT_LIVE: ${DRAFT_LIVE:-0} # 1 = picks are real InstantAdPay adoptions (go-live only); anything else = test mode, nobody adopted IAP_URL: ${IAP_URL:-} LS_URL: ${LS_URL:-} DRAFT_PARTNER_SECRET: ${DRAFT_PARTNER_SECRET:-} diff --git a/public/admin.html b/public/admin.html index d486975..5527301 100644 --- a/public/admin.html +++ b/public/admin.html @@ -19,7 +19,7 @@ - +
@@ -28,7 +28,7 @@

Best Coach pot (last week)

Old-link map (JSON {"oldrefs": {"old": "network username"}})

- - + + diff --git a/public/assets/common.js b/public/assets/common.js index cc9179f..c248b13 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -29,6 +29,9 @@ window.FX = (function () { + links.map(l => '' + l[1] + '').join('') + ''; document.body.prepend(nav); if (week) setWeek(week); + // staging test mode (DRAFT_LIVE not 1): say so on every page, plainly + getConfig().then(c => { if (!c || !c.testMode || $('testMode')) return; const b = document.createElement('div'); b.id = 'testMode'; b.className = 'testmode'; b.setAttribute('role', 'status'); + b.innerHTML = '
TEST MODE, nobody is adopted. Picks on this site are previews: no one gets a new sponsor and no email is sent.
'; nav.after(b); }).catch(() => {}); } // ISO-ish week number of a Monday date (the mockup's "DRAFT WEEK 46") function weekNo(monday) { const d = new Date(monday + 'T12:00:00Z'); const t = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate() + 3)); const y = new Date(Date.UTC(t.getUTCFullYear(), 0, 4)); return 1 + Math.round(((t - y) / 86400000 - 3 + ((y.getUTCDay() + 6) % 7)) / 7); } diff --git a/public/assets/fx.css b/public/assets/fx.css index 46fd005..b5fd614 100644 --- a/public/assets/fx.css +++ b/public/assets/fx.css @@ -217,3 +217,7 @@ footer.foot p{margin:4px 0}footer.foot a{color:var(--gold)}footer.foot .here{col .kit-pre{white-space:pre-wrap;font:inherit;font-size:14px;color:var(--muted);margin:0;background:var(--bar);padding:12px} .ccard .l .kvr{color:var(--muted)}.ccard .l .kvr span{color:var(--muted)}.ccard .l .kvr b{font-family:var(--text);font-size:15px;color:#fff;word-break:normal} .splitbar div{font-size:11px;padding:0 4px} + +/* staging test mode strip (DRAFT_LIVE not 1) */ +.testmode{background:#ffc93c;color:#0b1530;font-size:14px;padding:8px 0;border-bottom:2px solid #0b1530} +.testmode b{letter-spacing:.04em} diff --git a/public/builder.html b/public/builder.html index 013a92b..0c00f3c 100644 --- a/public/builder.html +++ b/public/builder.html @@ -19,7 +19,7 @@ - +
@@ -28,8 +28,8 @@
- - - + + + diff --git a/public/cards.html b/public/cards.html index 1aa525d..c44d143 100644 --- a/public/cards.html +++ b/public/cards.html @@ -19,7 +19,7 @@ - +
@@ -28,7 +28,7 @@

The five tiers

Rookie when drafted, Starter when they link a wallet, Pro when they switch on payouts, All-Star at their first purchase, Hall of Fame when they hold a position of their own and coach a team. Tap a card to flip it for the stats on the back.

- - + + diff --git a/public/coach.html b/public/coach.html index 3477671..499b778 100644 --- a/public/coach.html +++ b/public/coach.html @@ -19,7 +19,7 @@ - +
@@ -27,7 +27,7 @@

The team

Milestones only. Every Monday this coach drafts people who joined the network without a sponsor and helps them get started.

- - + + diff --git a/public/contract.html b/public/contract.html index 2ffd63c..487667c 100644 --- a/public/contract.html +++ b/public/contract.html @@ -19,14 +19,14 @@ - +

CONTRACT

Check the contract yourself

Read live from Polygon. No owner withdraw, no proxy, the split fixed in the code.

- + diff --git a/public/disclaimer.html b/public/disclaimer.html index 353e41e..82521dd 100644 --- a/public/disclaimer.html +++ b/public/disclaimer.html @@ -19,7 +19,7 @@ - +
@@ -30,7 +30,7 @@

Prices and taxes

Positions are priced in US dollars and paid in POL, whose price moves. You are responsible for any taxes on what you receive where you live.

Who to ask

TrustClickz, 615 Green Valley Drive, Moody, AL 35004. Network support.

- - + + diff --git a/public/draftday.html b/public/draftday.html index 146407d..850b5b3 100644 --- a/public/draftday.html +++ b/public/draftday.html @@ -15,4 +15,4 @@ h1{margin:0;font-family:Oswald,Impact,sans-serif;font-weight:700;font-size:108px
5XYOURTEAM

DRAFT DAY
RESULTS

5xyourteam.com
- + diff --git a/public/index.html b/public/index.html index c82355b..b1ed3c7 100644 --- a/public/index.html +++ b/public/index.html @@ -19,7 +19,7 @@ - +
@@ -53,7 +53,7 @@

A position buys a draft spot and coaching tools, not income. Nothing is promised.

- - + + diff --git a/public/join.html b/public/join.html index a11e9e0..0c65479 100644 --- a/public/join.html +++ b/public/join.html @@ -19,7 +19,7 @@ - +
@@ -34,8 +34,8 @@

Your sponsor gets 25% and levels 2 to 5 of your network sponsor line get 5% each. Only people who hold a position can receive a share: anyone in your line who does not is passed over and the share goes up to the next person who does. 10% goes to the weekly Best Coach pot and 45% to 5xYourTeam. The contract keeps nothing. Check it on the contract page and every payment on the ledger.

A position buys a draft spot and coaching tools, not income. Nothing is promised.

- - - + + + diff --git a/public/ledger.html b/public/ledger.html index 6b18e5c..e61f0d2 100644 --- a/public/ledger.html +++ b/public/ledger.html @@ -19,7 +19,7 @@ - +
@@ -28,7 +28,7 @@
WHENPOSITIONPAID IN THE SAME TRANSACTION

Best Coach payouts

WEEKCOACHPOL
- - + + diff --git a/public/privacy.html b/public/privacy.html index 6359752..0ddc3d1 100644 --- a/public/privacy.html +++ b/public/privacy.html @@ -19,7 +19,7 @@ - +
@@ -32,7 +32,7 @@

Your choices

You can ask us to remove your account and messages here. Records on the blockchain cannot be removed by anyone.

Contact

TrustClickz, 615 Green Valley Drive, Moody, AL 35004. Network support. Last updated November 15, 2026.

- - + + diff --git a/public/promote.html b/public/promote.html index 19c3a64..b210120 100644 --- a/public/promote.html +++ b/public/promote.html @@ -19,7 +19,7 @@ - +
@@ -28,8 +28,8 @@
- - - + + + diff --git a/public/team.html b/public/team.html index 6b4e97a..7006755 100644 --- a/public/team.html +++ b/public/team.html @@ -19,7 +19,7 @@ - +
@@ -52,8 +52,8 @@
- - - + + + diff --git a/public/terms.html b/public/terms.html index 80ff63c..3210784 100644 --- a/public/terms.html +++ b/public/terms.html @@ -19,7 +19,7 @@ - +
@@ -37,7 +37,7 @@

The service

The site is provided as it is. We work to keep it running but cannot promise it will always be available or free of errors. The smart contract runs on Polygon on its own; its rules are public on the contract page. We may change features, draft settings, the price of future positions or these terms; changes apply from the date they are posted here. As far as the law allows, our total responsibility to you is limited to what you paid for the purchase in question. These terms are governed by the laws of the State of Alabama, USA.

Contact

TrustClickz, 615 Green Valley Drive, Moody, AL 35004. Network support. Last updated November 15, 2026.

- - + + diff --git a/qa/iap-tank.test.cjs b/qa/iap-tank.test.cjs index 2a5f7ee..9025bf5 100644 --- a/qa/iap-tank.test.cjs +++ b/qa/iap-tank.test.cjs @@ -40,7 +40,7 @@ function fakeAccounts() { const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'fx-iaptank-')); const iapDir = path.join(dir, 'iap'); fs.mkdirSync(iapDir); delete process.env.DATABASE_URL; - Object.assign(process.env, { DATA_DIR: path.join(dir, 'fx'), DOCSTORE_URL: '', TANK_MODE: 'iap', IAP_URL: 'http://127.0.0.1:' + PORT, DRAFT_PARTNER_SECRET: SECRET, DRAFT_ROUNDS: '2', PICK_RETURN_DAYS: '3' }); + Object.assign(process.env, { DATA_DIR: path.join(dir, 'fx'), DOCSTORE_URL: '', TANK_MODE: 'iap', IAP_URL: 'http://127.0.0.1:' + PORT, DRAFT_PARTNER_SECRET: SECRET, DRAFT_ROUNDS: '2', PICK_RETURN_DAYS: '3', DRAFT_LIVE: '1' }); // sections 1-5 live; section 6 = staging test mode fs.mkdirSync(process.env.DATA_DIR); require(path.join(APP, 'config.js')).reset(); const C = require(path.join(APP, 'config.js')).get(); const store = require(path.join(APP, 'store.js')); const league = require(path.join(APP, 'league.js')); const tank = require(path.join(APP, 'tankpool.js')); @@ -137,6 +137,29 @@ function fakeAccounts() { ok(r.error && store.picks().length === n0, 'no answer: a pick is refused and nothing is recorded', r); const st = await tank.status([back[0].id], now()); ok(st[back[0].id] === null, 'no answer: status is null (nothing changes on the sweep)'); ok(tank.view().remote.failed >= 3 && tank.view().remote.secret === true, 'the admin view counts the failures', tank.view().remote); + + console.log('6. staging test mode (DRAFT_LIVE not 1): the pool is read, picks are previews, nobody is adopted, no mail'); + C.iapBase = 'http://127.0.0.1:' + PORT; delete process.env.DRAFT_LIVE; + const m0 = mails.length, c0 = chats.length; + ok(tank.preview() === true && tank.live() === false && tank.view().testMode === true, 'test mode is on without DRAFT_LIVE=1', tank.view()); + const tp = await league.pool(now()); ok(tp.length > 0, 'the pool is still read from InstantAdPay', tp.length); + const who = tp[0]; const whoEmail = emailOfId(who.id); const sp0 = await sponsorOf(whoEmail); + r = await league.instantPick(A, who.id); + ok(r.ok && /^preview:/.test(store.pick(r.pickId).ref), 'instant pick in test mode: recorded here as a preview (ref preview:...)', r); + ok(await sponsorOf(whoEmail) === sp0 && (await itank.openOf(whoEmail)).length === 0, 'InstantAdPay: no sponsor change, no open adoption'); + ok(mails.length === m0 && chats.length === c0, 'no adoption email, no chat', mails.slice(m0)); + ok(!(await league.pool(now())).some(x => x.id === who.id), 'a previewed person leaves the pool on this site only'); + const nextMon = store.ctToMs('2026-11-23', 19); league.clock.set(nextMon + 1000); await league.tick(); + const d2 = store.draft('2026-11-23'); const made2 = d2 ? d2.made.filter(x => x.person) : []; + ok(d2 && d2.status === 'done' && made2.length > 0, 'the Monday draft runs in test mode', d2 && d2.made.map(x => x.person ? 'pick' : x.skipped || 'x')); + const prev = store.picks().filter(p => p.status === 'open'); + ok(prev.length > 0 && prev.every(p => /^preview:/.test(p.ref || '')), 'every open pick is a preview', prev.map(p => p.ref)); + let clean = true; for (const p of prev) { const e = emailOfId(p.person); if ((await itank.openOf(e)).length || (await sponsorOf(e)) !== '') clean = false; } + ok(clean, 'InstantAdPay: no drafted person got a sponsor or an open adoption'); + ok(mails.length === m0 && chats.length === c0, 'still no email or chat after the draft', mails.length - m0); + league.clock.set(nextMon + 3 * D); const rp = prev.find(p => p.coach === A) || prev[0]; r = await league.release(rp.coach, rp.id); + ok(r.ok && store.pick(rp.id).status === 'returned' && mails.length === m0, 'releasing a preview pick touches nothing on InstantAdPay', r); + ok(tank.view().adoptionMailsSkipped >= 1 + made2.length, 'the admin view counts the adoptions (and emails) that test mode skipped', tank.view()); } finally { srv.close(); fs.rmSync(dir, { recursive: true, force: true }); } console.log('\n' + pass + ' passed, ' + fail + ' failed'); process.exit(fail ? 1 : 0); diff --git a/server.js b/server.js index 785767a..efb3280 100644 --- a/server.js +++ b/server.js @@ -248,7 +248,7 @@ const server = http.createServer(async (req, res) => { if (p === '/api/config' && req.method === 'GET') { return json(res, 200, { site: C.site, siteName: C.siteName, chainId: C.chainId, chainName: C.chainName, rpc: C.publicRpc, walletConnectProjectId: C.walletConnectProjectId, position: C.position, split: C.split, draft: { dow: C.draft.dow, hour: C.draft.hour, rounds: C.draft.rounds, pickSeconds: C.draft.pickSeconds }, picks: { returnDays: C.picks.returnDays, maxOpen: C.picks.maxOpen, holdHours: C.picks.holdHours }, - pot: C.pot, sso: networksso.enabled(), shop: { live: shop.watching(), contract: shop.watching() ? C.contractAddress : null }, explorer: C.explorer, tank: C.tankMode, joinUrl: joinUrl('') }); + pot: C.pot, sso: networksso.enabled(), shop: { live: shop.watching(), contract: shop.watching() ? C.contractAddress : null }, explorer: C.explorer, tank: C.tankMode, testMode: tank.preview(), joinUrl: joinUrl('') }); } if (p === '/api/board' && req.method === 'GET') { const s = session(req); return json(res, 200, await board(s ? s.address : null)); } if (p === '/api/draftday' && req.method === 'GET') { diff --git a/tankpool.js b/tankpool.js index c8f81d1..645590d 100644 --- a/tankpool.js +++ b/tankpool.js @@ -42,9 +42,17 @@ function init(cfg, opts) { try { fixture = JSON.parse(fs.readFileSync(f, 'utf8')); } catch (e) { fixture = { people: [] }; console.error('tankpool: no stub pool at', f); } fixture.base = nowFn(); // relative times are measured from boot console.log('tankpool: STUB mode (' + fixture.people.length + ' fixture people, nobody is adopted for real, no mail)'); - } else console.log('tankpool: InstantAdPay mode (' + C.iapBase + '/api/partner/draft/*' + (secret() ? '' : ', DRAFT_PARTNER_SECRET MISSING: every call refuses') + ')'); + } else console.log('tankpool: InstantAdPay mode (' + C.iapBase + '/api/partner/draft/*' + (secret() ? '' : ', DRAFT_PARTNER_SECRET MISSING: every call refuses') + ')' + (live() ? ' LIVE: picks are real adoptions' : ' TEST MODE (DRAFT_LIVE not 1): pool read-only, picks are previews, nobody is adopted, no mail')); } const isStub = () => mode === 'stub'; +// ---- staging test mode (Marty 2026-11-15, "test apps never touch real people"): with TANK_MODE=iap and DRAFT_LIVE not '1', the pool +// and pick status are READ from InstantAdPay, but every pick (instant picks on a purchase and the weekly draft) and every release is a +// PREVIEW kept here only: no tank.adopt() on InstantAdPay, no sponsor change, no "X is now your sponsor" email. DRAFT_LIVE=1 at go-live. +const live = () => !isStub() && String(process.env.DRAFT_LIVE || '').trim() === '1'; +const preview = () => !isStub() && !live(); +const PFILE = () => path.join(C.dataDir, 'preview-picks.json'); +function pst() { let s = {}; try { s = JSON.parse(fs.readFileSync(PFILE(), 'utf8')); } catch (e) {} s.picked = s.picked || {}; s.log = s.log || []; s.wouldMail = s.wouldMail || 0; return s; } +function pput(s) { s.log = s.log.slice(-300); fs.writeFileSync(PFILE() + '.tmp', JSON.stringify(s)); fs.renameSync(PFILE() + '.tmp', PFILE()); } // ---- the InstantAdPay client ---- const secret = () => { const s = String(process.env.DRAFT_PARTNER_SECRET || '').trim(); return s.length >= 32 ? s : ''; }; const remote = { calls: 0, failed: 0, lastError: null, lastPool: 0 }; @@ -82,7 +90,7 @@ function person(p, s, now) { } async function candidates(now) { - if (!isStub()) { const r = await call('pool', {}); if (!r.ok || !Array.isArray(r.pool)) return []; remote.lastPool = r.pool.length; return r.pool.filter(c => c && c.id).map(candOf); } + if (!isStub()) { const r = await call('pool', {}); if (!r.ok || !Array.isArray(r.pool)) return []; remote.lastPool = r.pool.length; const taken = preview() ? pst().picked : {}; return r.pool.filter(c => c && c.id && !taken[String(c.id)]).map(candOf); } const s = st(); now = now || nowFn(); return fixture.people.filter(p => !s.adopted[p.id]).map(p => { const x = person(p, s, now); return Object.assign(x, { wallet: !!x.wallet }); }) .filter(x => !x.payouts && !x.purchase); // payouts on = out of the tank (the IAP rule) @@ -104,6 +112,13 @@ async function status(ids, now) { return out; } async function adopt(o) { + if (preview()) { + const s = pst(); const id = String(o.person || ''); if (!id) return { error: 'Not in the holding tank.' }; + if (s.picked[id]) return { error: 'Already picked (test mode).' }; + const c = o.coach || {}; s.picked[id] = { coach: c.address || null, at: nowFn(), kind: o.kind || 'draft', week: o.week || null }; + s.wouldMail++; s.log.push({ at: nowFn(), preview: 'adopt', person: id, coach: c.address || null, kind: o.kind || 'draft' }); pput(s); + return { ok: true, ref: 'preview:' + id, preview: true }; + } if (!isStub()) { const c = o.coach || {}; const body = { rid: rid(), coach: { wallet: c.address, hubId: c.hubId || null, username: c.username || null, positions: Number(c.positions) || 0 }, person: o.person, kind: o.kind || 'draft', week: o.week || null, slot: o.slot || null, note: o.note || '' }; @@ -121,6 +136,10 @@ async function adopt(o) { return { ok: true, ref: 'stub:' + p.id }; } async function release(o) { + if (preview() || String(o.ref || '').startsWith('preview:')) { // a preview pick never touches InstantAdPay, even after DRAFT_LIVE flips to 1 + const s = pst(); const id = String(o.person || ''); delete s.picked[id]; + s.log.push({ at: nowFn(), preview: 'release', person: id, why: o.why || '' }); pput(s); return { ok: true, outcome: 'returned', preview: true }; + } if (!isStub()) { const body = { rid: rid(), coach: { wallet: o.coach }, ref: o.ref || null, person: o.person, why: o.kind === 'return' || /window/.test(o.why || '') ? 'return' : 'coach' }; let r = await call('release', body); if (r.transient) r = await call('release', body); @@ -136,5 +155,5 @@ function setStatus(id, patch) { for (const k of ['wallet', 'payouts', 'purchase', 'seen']) if (patch[k] !== undefined) o[k] = patch[k] ? (typeof patch[k] === 'number' ? patch[k] : t) : 0; put(s); return { ok: true, over: o }; } -function view() { if (!C) return {}; const s = isStub() ? st() : null; return { mode, remote: isStub() ? null : Object.assign({ url: C.iapBase, secret: !!secret() }, remote), fixture: fixture ? fixture.people.length : 0, adopted: s ? Object.keys(s.adopted).length : 0, adoptionMailsThatWouldSend: s ? s.mails : 0, log: s ? s.log.slice(-20) : [] }; } -module.exports = { init, candidates, status, adopt, release, setStatus, view, isStub, H, D }; +function view() { if (!C) return {}; const s = isStub() ? st() : null; const ps = preview() ? pst() : null; return { mode, live: live(), testMode: preview(), previewPicks: ps ? Object.keys(ps.picked).length : 0, adoptionMailsSkipped: ps ? ps.wouldMail : 0, remote: isStub() ? null : Object.assign({ url: C.iapBase, secret: !!secret() }, remote), fixture: fixture ? fixture.people.length : 0, adopted: s ? Object.keys(s.adopted).length : 0, adoptionMailsThatWouldSend: s ? s.mails : 0, log: s ? s.log.slice(-20) : [] }; } +module.exports = { init, candidates, status, adopt, release, setStatus, view, isStub, live, preview, H, D }; diff --git a/tools/pages.mjs b/tools/pages.mjs index ccc1991..4a1732b 100644 --- a/tools/pages.mjs +++ b/tools/pages.mjs @@ -8,7 +8,7 @@ import path from 'node:path'; import { fileURLToPath } from 'node:url'; const PUB = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'public'); const SITE = 'https://5xyourteam.com'; -const V = { css: 2, js: 2 }; +const V = { css: 3, js: 3 }; const F = { co: 'TrustClickz', addr: '615 Green Valley Drive, Moody, AL 35004', updated: 'November 15, 2026', usd: 10, picks: 5, rounds: 5, returnDays: 3, maxOpen: 10 }; const FONTS = 'https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap'; const NOTE = 'A position buys a draft spot and coaching tools, not income. Nothing is promised.';