Shared network knowledge (Marty 2026-11-15): the chatbot publishes its KB to the network hub and reads the other network sites' entries (netkb.js, the same file in every network site), home entries boosted, a named site's entries first and labelled with its LinkSpin tracked link, a question naming another site skips the instant answers (a hand-off still wins). Wallet answers follow Marty's rule (SafePal or any other crypto wallet, never recommend MetaMask), since they are now shared network-wide. KNOWLEDGE_DATE 2026-11-15. qa kb: netkb-merge 67 pass, kb-chat pass, kb-retrieval 2 misses that also fail on a clean tree

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-15 13:31:35 -06:00
parent f4789156b8
commit fbf7d87030
6 changed files with 221 additions and 20 deletions
+26 -7
View File
@@ -20,15 +20,28 @@ const https = require('https');
const http = require('http');
const kb = require('./kb');
const kbSeed = require('./kb-seed');
const netkb = require('./netkb'); // the shared network knowledge base on the hub (2026-11-15): publishes this site's entries, reads the other sites'
let DATA_DIR = null;
let chain = null;
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
const CONTRACT = '0x26Bdc556b94399bEdd69ae3ACA5aA6c54D946e8b';
const KNOWLEDGE_DATE = '2026-11-13'; // the day the CANNED answers and FACTS below were last checked against the site
const KNOWLEDGE_DATE = '2026-11-15'; // the day the CANNED answers and FACTS below were last checked against the site
function init(opts) {
if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; DATA_DIR = opts.dataDir; chain = opts.chain; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); }
if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; DATA_DIR = opts.dataDir; chain = opts.chain; const ready = kb.init({ dataDir: DATA_DIR, seeds: seeds() });
netkb.init({ dataDir: DATA_DIR, site: process.env.HUB_SITE || 'linkspin', name: 'LinkSpin', url: SITE_URL, entries: () => kb.own(), linkFor: netLink });
return ready; }
// the link to another network site: its LinkSpin tracked link with ?src=linkspin (netsites.js), else its plain address
function netLink(url) {
try { const ns = require('./netsites'); const h = u => { try { return new URL(u).hostname.toLowerCase().replace(/^www\./, ''); } catch (e) { return ''; } };
const m = ns.list().concat(ns.FALLBACK || []).find(x => h(x.url) === h(url)); return (m && m.id !== 'linkspin' && ns.tracked(m.id, 'linkspin')) || url; } catch (e) { return url; }
}
// the other network sites for the system prompt (from the hub's merged set)
function networkBlock() {
const l = netkb.sites(); if (!l.length) return '';
return '\n- OTHER NETWORK SITES (one network account works across them): ' + l.map(x => x.name + ' ' + x.go).join('; ') + '. A question about one of them: answer from its KNOWLEDGE BASE entries below, say which site it is about, give its link exactly as shown, and never mix two sites\' prices, splits or rules. Wallets: say "SafePal or any other crypto wallet". Ad credits buy advertising, not income. Never mention RM Circle.';
}
function key() {
if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim();
try { return fs.readFileSync(path.join(DATA_DIR, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; }
@@ -124,10 +137,10 @@ const CANNED = [
a: 'One credit is one cent of ad delivery: banner, text and login ads shown across the LinkSpin ad viewer, every member zone and the partner network, managed from the Ads screen. Credits come two ways, bought in a package or earned free (zones, the daily ad set, videos, verified visits, daily sign-in). Earned credits spend on banner and text campaigns; a login-ad slot (1,000 purchased credits for 30 days) takes purchased credits only. Credits are advertising, not money: they never cash out and are never converted to crypto.' },
{ id: 'trust-drain', title: 'Trust Wallet "drain your wallet" warning', q: ['Trust Wallet says this will drain my wallet', 'My wallet blocked the purchase'], tags: ['trust wallet', 'drain', 'wallet warning'],
re: /(drain (my|your) wallet|stop and go back|trust wallet.*(warn|block|red)|wallet (warning|blocked))/i,
a: 'That red "this transaction will drain your wallet" screen is Trust Wallet\'s own safety rule, not a problem with the purchase: it blocks any transaction that spends most of the POL in the wallet. Ways through: buy a smaller package first, add some POL so the purchase is well under half the balance, or connect a different wallet. SafePal, MetaMask and Phantom have no such block. Extra POL always stays yours. If the next try says WalletConnect disconnected, open the Wallet screen, disconnect, then connect again.' },
a: 'That red "this transaction will drain your wallet" screen is Trust Wallet\'s own safety rule, not a problem with the purchase: it blocks any transaction that spends most of the POL in the wallet. Ways through: buy a smaller package first, add some POL so the purchase is well under half the balance, or connect a different wallet. SafePal and most other wallets have no such block. Extra POL always stays yours. If the next try says WalletConnect disconnected, open the Wallet screen, disconnect, then connect again.' },
{ id: 'wallets', title: 'Which wallet, and buying POL with a card', q: ['Which wallet should I use?', 'How do I buy POL with a card?', 'I have never owned crypto'], tags: ['wallet', 'safepal', 'metamask', 'buy pol', 'card'],
re: /(which wallet|what wallet|best wallet|recommended wallet|set ?up (a )?wallet|buy (pol|crypto|polygon)|get (pol|crypto)|card to crypto|no crypto|never (had|held|owned) crypto|metamask|safepal|phantom|coinbase wallet)/i,
a: 'SafePal is the recommended wallet; MetaMask, Phantom (turn Polygon on first under Settings, Active Networks) and any WalletConnect wallet work too. Trust Wallet works but blocks a purchase that spends most of its POL, so keep about double the package cost there. Never held crypto? Buy POL with a card on any major exchange or on-ramp (or the Buy button inside your wallet app), choose POL on the Polygon network, send it to your own wallet address, then buy the package on the Credits screen. The provider handles its own ID checks, fees and limits. Keep a little extra POL for network fees. The step-by-step guide is at ' + SITE_URL + '/wallets.' },
a: 'Use SafePal or any other crypto wallet on Polygon (in Phantom, turn Polygon on first under Settings, Active Networks). Trust Wallet works but blocks a purchase that spends most of its POL, so keep about double the package cost there. Never held crypto? Buy POL with a card on any major exchange or on-ramp (or the Buy button inside your wallet app), choose POL on the Polygon network, send it to your own wallet address, then buy the package on the Credits screen. The provider handles its own ID checks, fees and limits. Keep a little extra POL for network fees. The step-by-step guide is at ' + SITE_URL + '/wallets.' },
{ id: 'join', title: 'How to join and sign in', q: ['How do I join?', 'Do I need a wallet?', 'Is there a password?'], tags: ['join', 'sign up', 'sign in', 'code'],
re: /(need (a )?wallet|crypto experience|how (do i|to) (join|sign ?up|register|sign in)|sign ?up|register|password|sign.?in code|six.?digit)/i,
a: 'Join free with just your email at ' + SITE_URL + '/join. A six-digit code signs you in, there is no password, and no wallet is needed to use the links, pages and zones. The wallet step comes later, inside your Control Room, when you want to be paid or to buy a package.' },
@@ -211,7 +224,7 @@ ${refuelFact()}${synFact()}- PRODUCT, all free with an email account: SPIN LINKS
- THE SPLIT, same transaction on Polygon, fixed in the contract: 50 percent direct sponsor, 20 percent level 2, 10 percent level 3, 10 percent + 10 percent to the two admin wallets. Level 1 pays from a referral's first qualifying purchase once the sponsor's payouts are on. Level 2 opens after two of the member's people buy a qualifying ($25 or larger) package, level 3 after five. An unfilled tier passes up the line to the next qualified member, then to the platform. Nothing is held, there are no withdrawals, no pending balances. Contract ${CONTRACT} on Polygon, verified on Polygonscan; plain-language review at ${SITE_URL}/contract; live ledger at ${SITE_URL}/ledger with a verify link on every row.
- CREDITS VS POL: every member, free ones included, earns CREDITS (zones, the daily ad set with a claim streak, watch-to-earn videos, verified visits, a daily sign-in bonus). Credits buy the member's own banner and text ads (a login-ad slot takes purchased credits only) and NEVER cash out or convert to crypto. POL only reaches a wallet through the contract split when a package sells in the member's line. Never promise or estimate income.
- AD FORMATS members buy with credits: banner ads (standard sizes), text ads, full-screen login ads (a flat slot: 1,000 PURCHASED credits for 30 days of unlimited sign-in impressions, never charged per day; at most 6 member slots live at once (raised from 3 on 2026-10-23); PAID QUEUE (2026-10-23): when all 6 are taken a member can reserve the next slot by paying the full 1,000 purchased credits now, first paid first served, the 30 days start only when a slot frees (a slot ends or is paused) and the member gets an on-site notice and an email, the Ads screen shows the place in line and an ESTIMATED start date in Central time, edits are free while waiting, cancelling before the start refunds the full amount as purchased credits (a running slot is not refundable), and a paused slot can resume only when live plus waiting slots are under 6; house login ads only show when no member slot is running; earned credits never fund login ads); EDITING AN AD (2026-10-18): the Edit button on each ad on the Ads screen changes the click link, the banner image (upload or https link), a text ad's headline and line, and the ad name; type, size, budget, countries, schedule and audience cannot change (start a new ad); the first edit of every ad is free, each later edit costs the campaignEditFee, 100 credits by default, earned credits first, then purchased; a new link and a new banner image get the same checks as a new ad, plus solo ads to member inboxes, watch-to-earn video, verified visits. Banner and text ads also run on member zones and the partner network.
- ACCOUNT: join at ${SITE_URL}/join with email only, a six-digit code, no password. Wallet linking happens inside the Control Room (Credits screen): one signature to link, then payouts switch on by activating (one transaction, gas only) or by buying any package. SafePal is the recommended wallet; MetaMask, Phantom (turn Polygon on first) and any WalletConnect wallet work; Trust Wallet blocks a buy that spends most of its POL. No card button on the site: members buy POL with a card on any major exchange or on-ramp, then send it to their own wallet on the Polygon network (guide at ${SITE_URL}/wallets); never name a specific exchange or on-ramp brand.
- ACCOUNT: join at ${SITE_URL}/join with email only, a six-digit code, no password. Wallet linking happens inside the Control Room (Credits screen): one signature to link, then payouts switch on by activating (one transaction, gas only) or by buying any package. wallets: say "SafePal or any other crypto wallet", never recommend MetaMask by name (Marty 2026-11-13); in Phantom turn Polygon on first; Trust Wallet blocks a buy that spends most of its POL. No card button on the site: members buy POL with a card on any major exchange or on-ramp, then send it to their own wallet on the Polygon network (guide at ${SITE_URL}/wallets); never name a specific exchange or on-ramp brand.
- SPONSOR: the invite link opened most recently sets the sponsor (30-day cookie), shown on the join page, locked when the account is created; the contract binds the buyer to that sponsor at the first purchase. CARRY-OVER: Crypto Team Build Network members who sign in with the email they use on InstantAdPay get their InstantAdPay sponsor from the network registry automatically when no invite link was used. Wrong sponsor before the first purchase: the admin can move the account. Members should switch on payouts before their people buy.
- CONTROL ROOM screens: Links, Pages, Zones (with Audiences), Ads, Credits, Reports, Team (three levels, who has payouts on, who bought, qualifying-buyer counts), Wallet (what was paid to this wallet, payout history). More at ${SITE_URL}/tools: Promo tools, Training, Pipeline (a follow-up board for prospects and directs), My line (including the holding tank: members who joined with no sponsor wait there and can be adopted by a member with payouts on and their own qualifying package), Profile.
- BTC4HITS (2026-11-11): the closed BTC4Hits rotator site moved here. Its members with a deliverable email were imported as waiting accounts (InstantAdPay first, carried here by the registry sync), with their BTC4Hits sponsor when that sponsor was also imported or already a member, otherwise into the holding tank. Sign-in page: /from/btc4hits (same email, code sign-in, no welcome-back credits). Rotators with visits in the last month became spin links named 'BTC4Hits rotator #<old id>' on the owner's account with every working destination (dead, parked or erroring URLs left out), on a 'BTC4Hits' traffic source; btc4hits.com/ro.php?id=<id> forwards to the spin link, other btc4hits.com pages go to /from/btc4hits. Pro status and old BTC4Hits commissions do not carry over. HOLDING TANK CAP: an adopter may hold up to 10 people from the tank at one time (open adoptions whose person has not switched on payouts yet; was 2). The cap is the site setting tankAdoptCap (default 10). HOLDING TANK MENU ITEM: members who can adopt (payouts on, own $25 package) see Holding tank in the Control Room menu (rail), with a badge of how many can be adopted right now; it opens More > My line, where the Holding tank card lists them and says how many you can adopt at a time. Members who cannot adopt do not see the item.
@@ -230,7 +243,7 @@ RULES:
- 1 to 4 sentences, plain text, no markdown, include full URLs when pointing at a page.
- NEVER promise or estimate income. This is an advertising service with a referral program, never an investment. Be honest about risk: crypto transactions are irreversible, nobody earns unless real ad purchases happen in their line.
- No em dashes. If you do not know, say so and point to ${SITE_URL}/contract or the ledger.
- Anything about one person's own account (a missing payout, a sign-in that will not work, a charge, a bug) you cannot look up: say so and point them to Help at ${SITE_URL}/help, or ${SITE_URL}/support when signed out.` + (kbBlock ? '\n\n' + kbBlock : '');
- Anything about one person's own account (a missing payout, a sign-in that will not work, a charge, a bug) you cannot look up: say so and point them to Help at ${SITE_URL}/help, or ${SITE_URL}/support when signed out.${networkBlock()}` + (kbBlock ? '\n\n' + kbBlock : '');
}
// OPENROUTER_URL overrides the endpoint (local tests point it at a mock); production uses openrouter.ai
@@ -280,7 +293,13 @@ async function answerRaw(message, historyText) {
if (!msg) return { error: 'Say something first.' };
// fast path: the knowledge base's instant answers (seeded from CANNED); the in-code list only if the KB store is down
let hit = null, kbOk = true;
try { hit = await kb.fastPath(msg); } catch (e) { kbOk = false; console.error('kb fast path', e.message); }
try {
await kb.load();
// another network site named (and this one not): this site's instant answers stand aside, except a hand-off (2026-11-15)
const other = /link ?spin/i.test(msg) ? [] : kb.namesOther(msg, process.env.HUB_SITE || 'linkspin');
hit = await kb.fastPath(msg);
if (hit && other.length && !hit.handoff) hit = null;
} catch (e) { kbOk = false; console.error('kb fast path', e.message); }
if (hit && hit.id === 'refuel' && !REFUEL_ON()) return { reply: REFUEL_OFF_ANSWER, canned: true, kb: hit.id };
if (hit && (hit.id === 'network-rate' || hit.id === 'c-network-rate') && (SYN_N() !== 4 || SYN_T() !== 10)) return { reply: netRateAnswer(SYN_N()), canned: true, kb: hit.id };
if (hit) return Object.assign({ reply: hit.answer, canned: true, kb: hit.id }, hit.handoff ? { handoff: true } : {});