mirror of
https://github.com/myronblair/jarvis
synced 2026-07-28 08:43:00 -05:00
feat(kb-intent): 122-topic rotation engine, every-6h cron
- Expanded $BATCHES from 25 to 122 topics across: life skills, personal finance, Texas/local, US national, world geopolitics, human sexuality (educational), deep astronomy (15 topics), and space exploration (15 topics) - Rotation engine: 25 topics per run cycling through all 122 in order; wraps to topic 1 on cycle complete (~30h full cycle at 6h interval) - batch_offset tracked in kb_facts for cross-run persistence - Cron changed from 0 3 * * * to 0 */6 * * * (every 6 hours) - 20h skip guard reduced to 4h so 6h cron isn't blocked - max_tokens bumped 3500 → 5000 to prevent JSON truncation errors - JSON extraction: partial recovery + raw snippet logged on failure Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014p87VFec84hNaf2WpvmLrW
This commit is contained in:
@@ -75,7 +75,7 @@ $lastRun = JarvisDB::single(
|
|||||||
"SELECT updated_at FROM kb_facts WHERE category='kb_generator' AND fact_key='last_run'"
|
"SELECT updated_at FROM kb_facts WHERE category='kb_generator' AND fact_key='last_run'"
|
||||||
);
|
);
|
||||||
$forceRun = !empty(getenv('JARVIS_FORCE_RUN')) || (isset($argv[1]) && $argv[1] === '--force');
|
$forceRun = !empty(getenv('JARVIS_FORCE_RUN')) || (isset($argv[1]) && $argv[1] === '--force');
|
||||||
if (!$forceRun && $lastRun && (time() - strtotime($lastRun['updated_at'])) < 72000) {
|
if (!$forceRun && $lastRun && (time() - strtotime($lastRun['updated_at'])) < 14400) {
|
||||||
log_line('Skipping – ran within last 20 hours (next run tomorrow 3am). Use --force to override.');
|
log_line('Skipping – ran within last 20 hours (next run tomorrow 3am). Use --force to override.');
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -85,6 +85,7 @@ log_line('Starting daily KB intent generation run.');
|
|||||||
|
|
||||||
/* ── topic batches (25 topics × ~40 intents = 1,000+) ── */
|
/* ── topic batches (25 topics × ~40 intents = 1,000+) ── */
|
||||||
$BATCHES = [
|
$BATCHES = [
|
||||||
|
// ── EXISTING: EDUCATION CORE (25 topics) ──
|
||||||
['id' => 'math_elem', 'category' => 'math_elementary', 'topic' => 'Elementary school mathematics',
|
['id' => 'math_elem', 'category' => 'math_elementary', 'topic' => 'Elementary school mathematics',
|
||||||
'desc' => 'counting, basic arithmetic, place value, simple fractions, 2D/3D shapes, measurement, telling time, money, patterns'],
|
'desc' => 'counting, basic arithmetic, place value, simple fractions, 2D/3D shapes, measurement, telling time, money, patterns'],
|
||||||
['id' => 'math_mid', 'category' => 'math_middle', 'topic' => 'Middle school mathematics',
|
['id' => 'math_mid', 'category' => 'math_middle', 'topic' => 'Middle school mathematics',
|
||||||
@@ -135,8 +136,240 @@ $BATCHES = [
|
|||||||
'desc' => 'nutrition (macronutrients, vitamins, minerals), exercise physiology, mental health (anxiety, depression, stress response), reproductive health, substance abuse, first aid, disease prevention, sleep hygiene'],
|
'desc' => 'nutrition (macronutrients, vitamins, minerals), exercise physiology, mental health (anxiety, depression, stress response), reproductive health, substance abuse, first aid, disease prevention, sleep hygiene'],
|
||||||
['id' => 'arts_music', 'category' => 'arts', 'topic' => 'Arts and music',
|
['id' => 'arts_music', 'category' => 'arts', 'topic' => 'Arts and music',
|
||||||
'desc' => 'elements of art (line, shape, color, texture), colour theory, major art movements, famous artists and their works, music notes and scales, rhythm and meter, instrument families, major composers and genres'],
|
'desc' => 'elements of art (line, shape, color, texture), colour theory, major art movements, famous artists and their works, music notes and scales, rhythm and meter, instrument families, major composers and genres'],
|
||||||
|
|
||||||
|
// ── LIFE SKILLS & PERSONAL ──
|
||||||
|
['id' => 'personal_finance', 'category' => 'personal_finance', 'topic' => 'Personal finance and budgeting',
|
||||||
|
'desc' => 'budgeting methods (50/30/20 rule), emergency funds, compound interest, credit scores, debt payoff strategies (avalanche vs snowball), Roth IRA vs 401k, index funds, tax basics, net worth'],
|
||||||
|
['id' => 'investing', 'category' => 'personal_finance', 'topic' => 'Investing and wealth building',
|
||||||
|
'desc' => 'stocks vs bonds, ETFs, mutual funds, dividends, risk vs return, diversification, dollar-cost averaging, market cycles, real estate investing, passive income strategies'],
|
||||||
|
['id' => 'cooking_basics', 'category' => 'cooking', 'topic' => 'Cooking fundamentals',
|
||||||
|
'desc' => 'knife skills, cooking methods (sauté, braise, roast, steam), temperature and food safety, seasoning and flavor building, baking ratios, measuring techniques, kitchen equipment'],
|
||||||
|
['id' => 'nutrition_diet', 'category' => 'health', 'topic' => 'Nutrition and diet science',
|
||||||
|
'desc' => 'macronutrients (protein/carb/fat), micronutrients, glycemic index, intermittent fasting, keto vs paleo, caloric deficit, gut health, hydration, meal planning, food labels'],
|
||||||
|
['id' => 'fitness', 'category' => 'health', 'topic' => 'Fitness and exercise science',
|
||||||
|
'desc' => 'strength training principles (progressive overload, compound vs isolation), cardio types (HIIT, LISS), flexibility and mobility, recovery and sleep, body composition, VO2 max, common injuries'],
|
||||||
|
['id' => 'mental_health', 'category' => 'mental_health', 'topic' => 'Mental health and wellbeing',
|
||||||
|
'desc' => 'anxiety disorders, depression, PTSD, OCD, bipolar disorder, therapy types (CBT, DBT), mindfulness, stress management, burnout, emotional regulation, medication basics, when to seek help'],
|
||||||
|
['id' => 'relationships', 'category' => 'relationships', 'topic' => 'Relationships and communication',
|
||||||
|
'desc' => 'attachment styles, love languages, conflict resolution, active listening, setting boundaries, codependency, gaslighting, toxic vs healthy relationship signs, long-distance relationships, breakups'],
|
||||||
|
['id' => 'parenting', 'category' => 'parenting', 'topic' => 'Parenting and child development',
|
||||||
|
'desc' => 'infant milestones, attachment theory, authoritative vs authoritarian parenting, screen time guidelines, discipline strategies, learning disabilities, puberty, teen communication, co-parenting'],
|
||||||
|
['id' => 'career', 'category' => 'career', 'topic' => 'Career development and job skills',
|
||||||
|
'desc' => 'resume writing, cover letters, interview techniques (STAR method), salary negotiation, LinkedIn optimization, networking, career pivots, remote work, professional etiquette, workplace conflict'],
|
||||||
|
['id' => 'home_repair', 'category' => 'home', 'topic' => 'Home maintenance and repair',
|
||||||
|
'desc' => 'unclogging drains, fixing leaky faucets, patching drywall, painting techniques, electrical basics (outlets, breakers), HVAC filters, lawn care, weatherstripping, tools every homeowner needs'],
|
||||||
|
['id' => 'first_aid', 'category' => 'health', 'topic' => 'First aid and emergency response',
|
||||||
|
'desc' => 'CPR steps, AED use, Heimlich maneuver, treating burns and cuts, recognizing stroke/heart attack signs, anaphylaxis and EpiPen, hypothermia, heat stroke, emergency kit essentials, calling 911'],
|
||||||
|
['id' => 'driving_safety', 'category' => 'transportation', 'topic' => 'Driving and road safety',
|
||||||
|
'desc' => 'defensive driving techniques, traffic laws, DUI consequences, distracted driving, highway merging, parallel parking, car maintenance basics (oil, tires, brakes), winter driving, road rage'],
|
||||||
|
['id' => 'time_mgmt', 'category' => 'productivity', 'topic' => 'Productivity and time management',
|
||||||
|
'desc' => 'Pomodoro technique, time blocking, Eisenhower matrix, GTD (Getting Things Done), procrastination psychology, deep work vs shallow work, digital minimalism, habit stacking, morning routines'],
|
||||||
|
['id' => 'social_skills', 'category' => 'social', 'topic' => 'Social skills and networking',
|
||||||
|
'desc' => 'small talk strategies, reading body language, building rapport, public speaking, networking at events, giving and receiving feedback, conflict avoidance vs resolution, empathy development'],
|
||||||
|
['id' => 'legal_basics', 'category' => 'legal', 'topic' => 'Legal basics for everyday life',
|
||||||
|
'desc' => 'tenant rights, landlord obligations, contract basics, small claims court, Miranda rights, traffic tickets, wills and estate planning, power of attorney, employment law, consumer protection'],
|
||||||
|
|
||||||
|
// ── LOCAL / TEXAS ──
|
||||||
|
['id' => 'texas_history', 'category' => 'texas', 'topic' => 'Texas history',
|
||||||
|
'desc' => 'Alamo and Texas Revolution (1836), Republic of Texas, annexation (1845), Civil War and Reconstruction, oil boom (Spindletop 1901), WW2 contributions, Civil Rights in Texas, modern growth'],
|
||||||
|
['id' => 'texas_geography','category' => 'texas', 'topic' => 'Texas geography and regions',
|
||||||
|
'desc' => 'Piney Woods, Gulf Coastal Plains, Hill Country, Edwards Plateau, Trans-Pecos (Big Bend), Panhandle, Rio Grande, major rivers, highest point (Guadalupe Peak), largest cities'],
|
||||||
|
['id' => 'texas_govt', 'category' => 'texas', 'topic' => 'Texas government and politics',
|
||||||
|
'desc' => 'Texas Constitution, bicameral legislature (House/Senate), governor powers, Lt. Governor role, Texas Supreme Court, judicial elections, redistricting, ballot propositions, two-party system in Texas'],
|
||||||
|
['id' => 'texas_culture', 'category' => 'texas', 'topic' => 'Texas culture and identity',
|
||||||
|
'desc' => 'rodeo and cowboy culture, BBQ styles (brisket, ribs), Tex-Mex cuisine, Austin music scene, state symbols (bluebonnets, mockingbird), Friday Night Lights football, Southern hospitality, Texas pride'],
|
||||||
|
['id' => 'dfw_area', 'category' => 'texas', 'topic' => 'DFW Metroplex and North Texas',
|
||||||
|
'desc' => 'Fort Worth stockyards, Sundance Square, Dallas skyline, Fair Park, AT&T Stadium, DFW Airport, White Rock Lake, Stockyards National Historic District, Kimbell Art Museum, economic hubs'],
|
||||||
|
['id' => 'texas_economy', 'category' => 'texas', 'topic' => 'Texas economy and industry',
|
||||||
|
'desc' => 'oil and gas (Permian Basin), technology sector (Austin Silicon Hills), agriculture (cattle, cotton, corn), aerospace and defense, healthcare, financial services, no state income tax, business climate'],
|
||||||
|
['id' => 'texas_wildlife', 'category' => 'texas', 'topic' => 'Texas wildlife and nature',
|
||||||
|
'desc' => 'white-tailed deer, Texas Horned Lizard, nine-banded armadillo, whooping cranes, monarch butterfly migration, state parks (Palo Duro Canyon, Enchanted Rock), wildflowers, hunting season regulations'],
|
||||||
|
['id' => 'texas_weather', 'category' => 'texas', 'topic' => 'Texas weather and natural hazards',
|
||||||
|
'desc' => 'tornado alley and Dixie Alley, hurricane season (Gulf Coast), Flash flood risk, extreme heat (110F+), Winter Storm Uri (2021), ERCOT grid, drought cycles, hail, dust storms in West Texas'],
|
||||||
|
['id' => 'texas_sports', 'category' => 'texas', 'topic' => 'Texas sports teams and traditions',
|
||||||
|
'desc' => 'Dallas Cowboys, Texas Rangers, Dallas Mavericks, FC Dallas, Houston Texans/Astros/Rockets, San Antonio Spurs, UT Longhorns, Texas A&M Aggies, TCU Horned Frogs, high school football culture'],
|
||||||
|
|
||||||
|
// ── NATIONAL (US) ──
|
||||||
|
['id' => 'us_economy', 'category' => 'national', 'topic' => 'US economy and financial system',
|
||||||
|
'desc' => 'Federal Reserve and monetary policy, inflation and CPI, unemployment rate, GDP components, national debt and deficit, trade balance, housing market, stock market indices, recession indicators'],
|
||||||
|
['id' => 'us_politics', 'category' => 'national', 'topic' => 'US politics and current events',
|
||||||
|
'desc' => 'congressional gridlock, bipartisan vs partisan legislation, presidential executive orders, Supreme Court appointments, gerrymandering, campaign finance, voter ID laws, electoral system reform'],
|
||||||
|
['id' => 'us_healthcare', 'category' => 'national', 'topic' => 'US healthcare system',
|
||||||
|
'desc' => 'Affordable Care Act, Medicare and Medicaid eligibility, employer-sponsored insurance, deductibles and copays, prescription drug pricing, mental health parity, hospital billing, single-payer debate'],
|
||||||
|
['id' => 'us_immigration', 'category' => 'national', 'topic' => 'US immigration and border policy',
|
||||||
|
'desc' => 'legal immigration pathways (green card, visa categories), naturalization process, asylum vs refugee status, DACA and Dreamers, southern border crossings, ICE enforcement, immigration courts'],
|
||||||
|
['id' => 'us_education', 'category' => 'national', 'topic' => 'US education system and policy',
|
||||||
|
'desc' => 'K-12 public school funding (property taxes), Common Core, charter schools, standardized testing (SAT/ACT), student loan crisis, college admissions, community college, vocational training, homeschooling'],
|
||||||
|
['id' => 'us_military', 'category' => 'national', 'topic' => 'US military and national defense',
|
||||||
|
'desc' => 'Army, Navy, Air Force, Marines, Coast Guard, Space Force, Selective Service, military pay and benefits, veterans services (VA), defense budget, NATO obligations, recent conflicts, PTSD in veterans'],
|
||||||
|
['id' => 'us_environment', 'category' => 'national', 'topic' => 'US environmental policy',
|
||||||
|
'desc' => 'Paris Climate Agreement, EPA regulations, Clean Air and Water Acts, national park system, pipeline controversies (Keystone), renewable energy subsidies, carbon tax debate, wildfire management'],
|
||||||
|
['id' => 'us_crime', 'category' => 'national', 'topic' => 'US criminal justice system',
|
||||||
|
'desc' => 'mass incarceration, mandatory minimum sentencing, bail reform, police use of force, Second Amendment and gun control, death penalty by state, recidivism, drug policy reform, prison conditions'],
|
||||||
|
['id' => 'us_media', 'category' => 'national', 'topic' => 'US media and information literacy',
|
||||||
|
'desc' => 'news media bias (left vs right), social media algorithms, misinformation and fact-checking, First Amendment press freedoms, journalism ethics, podcasts vs TV news, echo chambers, deepfakes'],
|
||||||
|
['id' => 'us_culture', 'category' => 'national', 'topic' => 'US culture and society',
|
||||||
|
'desc' => 'demographic shifts, racial wealth gap, gender pay gap, LGBTQ+ rights timeline, religious landscape, gun culture, opioid epidemic, homelessness crisis, urban vs rural divide, American dream'],
|
||||||
|
|
||||||
|
// ── WORLD ──
|
||||||
|
['id' => 'geopolitics', 'category' => 'world', 'topic' => 'Geopolitics and international relations',
|
||||||
|
'desc' => 'NATO expansion, UN Security Council vetoes, nuclear deterrence (MAD), great power competition (US-China-Russia), sanctions and trade wars, proxy wars, balance of power, soft power vs hard power'],
|
||||||
|
['id' => 'russia_ukraine', 'category' => 'world', 'topic' => 'Russia-Ukraine conflict',
|
||||||
|
'desc' => 'history of Soviet collapse and Ukrainian independence, Crimea annexation (2014), 2022 full-scale invasion, NATO response, sanctions on Russia, humanitarian impact, refugee crisis, nuclear threats'],
|
||||||
|
['id' => 'middle_east', 'category' => 'world', 'topic' => 'Middle East politics and culture',
|
||||||
|
'desc' => 'Israel-Palestine conflict history, Abraham Accords, Iran nuclear program, Saudi Arabia Vision 2030, OPEC oil production, Lebanon and Syria instability, Yemen civil war, religious diversity (Sunni/Shia)'],
|
||||||
|
['id' => 'china_relations','category' => 'world', 'topic' => 'China and global influence',
|
||||||
|
'desc' => 'Belt and Road Initiative, Taiwan Strait tensions, South China Sea territorial disputes, trade relationship with US, Huawei and tech rivalry, Hong Kong, Xinjiang (Uyghur issue), Xi Jinping consolidation of power'],
|
||||||
|
['id' => 'europe', 'category' => 'world', 'topic' => 'Europe and the European Union',
|
||||||
|
'desc' => 'EU structure and Eurozone, Brexit aftermath, NATO defense spending debate, far-right political movements, migration crisis, energy dependence on Russia, ECB monetary policy, Balkan EU aspirations'],
|
||||||
|
['id' => 'africa', 'category' => 'world', 'topic' => 'Africa — politics, economy, and culture',
|
||||||
|
'desc' => 'colonial legacy and borders, Sub-Saharan economic growth, coup belt (Sahel region), South Africa post-apartheid, Ethiopia civil war, AU peacekeeping, African Continental Free Trade Area, population growth'],
|
||||||
|
['id' => 'latin_america', 'category' => 'world', 'topic' => 'Latin America and the Caribbean',
|
||||||
|
'desc' => 'left-wing political wave, Venezuela collapse, Colombia peace process, cartels and narco-states (Mexico, Central America), Brazil Amazon deforestation, immigration drivers, Cuba embargo, Haiti instability'],
|
||||||
|
['id' => 'asia_pacific', 'category' => 'world', 'topic' => 'Asia-Pacific — Japan, Korea, SE Asia',
|
||||||
|
'desc' => 'North Korea nuclear program and Kims, South Korea tech/culture rise (K-pop, Samsung), Japan pacifist constitution debate, ASEAN economic bloc, Vietnam and Philippines territorial disputes, Australian foreign policy'],
|
||||||
|
['id' => 'world_religions','category' => 'world', 'topic' => 'World religions and belief systems',
|
||||||
|
'desc' => 'Christianity denominations and spread, Islam (Sunni/Shia/Sufi), Hinduism castes and gods, Buddhism branches, Judaism and Israel, Sikhism, atheism/agnosticism trends, religious extremism, interfaith dialogue'],
|
||||||
|
['id' => 'global_economy', 'category' => 'world', 'topic' => 'Global economy and trade',
|
||||||
|
'desc' => 'WTO and trade agreements (USMCA, TPP), supply chain disruptions, global inflation post-COVID, BRICS economic bloc, currency exchange and forex, sovereign debt crises, IMF/World Bank role, de-dollarization debate'],
|
||||||
|
|
||||||
|
// ── HUMAN SEXUALITY (EDUCATIONAL) ──
|
||||||
|
['id' => 'sex_anatomy', 'category' => 'sexuality', 'topic' => 'Human sexual anatomy and physiology',
|
||||||
|
'desc' => 'male and female reproductive anatomy, sexual response cycle (Masters and Johnson), arousal physiology, erogenous zones, orgasm types, hormones (testosterone, estrogen, oxytocin), aging and sexuality'],
|
||||||
|
['id' => 'sexual_health', 'category' => 'sexuality', 'topic' => 'Sexual health and STI prevention',
|
||||||
|
'desc' => 'common STIs (chlamydia, gonorrhea, syphilis, herpes, HIV/AIDS), transmission routes, prevention (condoms, PrEP, dental dams), testing frequency, treatment options, stigma reduction, disclosing status'],
|
||||||
|
['id' => 'contraception', 'category' => 'sexuality', 'topic' => 'Contraception and family planning',
|
||||||
|
'desc' => 'barrier methods (condoms, diaphragm), hormonal methods (pill, patch, ring, shot, implant), IUDs (hormonal vs copper), emergency contraception (Plan B, Ella), vasectomy, tubal ligation, fertility awareness'],
|
||||||
|
['id' => 'lgbtq', 'category' => 'sexuality', 'topic' => 'LGBTQ+ identities and issues',
|
||||||
|
'desc' => 'sexual orientation spectrum (gay, lesbian, bisexual, pansexual, asexual), gender identity vs biological sex, transgender healthcare, non-binary identities, coming out process, LGBTQ+ history (Stonewall), legal rights'],
|
||||||
|
['id' => 'consent_safety', 'category' => 'sexuality', 'topic' => 'Consent, boundaries, and healthy intimacy',
|
||||||
|
'desc' => 'affirmative consent, reading verbal and non-verbal cues, coercion and manipulation, intoxication and consent, communicating desires and limits, sexual violence statistics, recovery resources, bystander intervention'],
|
||||||
|
['id' => 'reproductive_health', 'category' => 'sexuality', 'topic' => 'Reproductive health and fertility',
|
||||||
|
'desc' => 'menstrual cycle phases (follicular, ovulation, luteal), PMS vs PMDD, endometriosis, PCOS, male fertility factors, infertility treatments (IVF, IUI), miscarriage facts, menopause symptoms, perimenopause'],
|
||||||
|
['id' => 'pregnancy', 'category' => 'sexuality', 'topic' => 'Pregnancy and prenatal care',
|
||||||
|
'desc' => 'conception and implantation, trimester-by-trimester development, prenatal vitamins, genetic testing, common complications (preeclampsia, gestational diabetes), labor stages, C-section, postpartum depression'],
|
||||||
|
['id' => 'sex_dysfunction','category' => 'sexuality', 'topic' => 'Sexual dysfunction and therapy',
|
||||||
|
'desc' => 'erectile dysfunction causes and treatments (PDE5 inhibitors), premature ejaculation, low libido in men and women, vaginismus, anorgasmia, sexual side effects of medications, sex therapy approaches'],
|
||||||
|
['id' => 'relationship_intimacy','category' => 'sexuality', 'topic' => 'Intimacy, desire, and long-term relationships',
|
||||||
|
'desc' => 'desire discrepancy in couples, rekindling intimacy, emotional vs physical intimacy, open relationships and polyamory basics, kink and BDSM fundamentals (SSC, RACK), sexual communication, aging and desire'],
|
||||||
|
['id' => 'sex_education', 'category' => 'sexuality', 'topic' => 'Sex education — history, myths, and facts',
|
||||||
|
'desc' => 'abstinence-only vs comprehensive sex ed outcomes, common sex myths debunked, pornography vs reality, "blue balls" myth, virginity social constructs, sex-positive education, talking to kids about sex at different ages'],
|
||||||
|
|
||||||
|
// ── ASTRONOMY DEEP DIVES ──
|
||||||
|
['id' => 'solar_system', 'category' => 'astronomy', 'topic' => 'Solar system in depth',
|
||||||
|
'desc' => 'planetary formation (nebular hypothesis), terrestrial vs gas vs ice giants, asteroid belt composition, Kuiper Belt and Oort Cloud, dwarf planets (Pluto, Eris, Ceres), solar wind, heliosphere, Lagrange points'],
|
||||||
|
['id' => 'stars_deep', 'category' => 'astronomy', 'topic' => 'Stars — formation, lifecycle, and types',
|
||||||
|
'desc' => 'nebulae as stellar nurseries, main sequence stars, red giants, white dwarfs, neutron stars, pulsars, magnetars, supernovae types (Ia vs II), nucleosynthesis, Hertzsprung-Russell diagram, stellar populations'],
|
||||||
|
['id' => 'black_holes', 'category' => 'astronomy', 'topic' => 'Black holes — types and physics',
|
||||||
|
'desc' => 'stellar vs supermassive vs primordial black holes, event horizon and Schwarzschild radius, singularity, spaghettification, Hawking radiation, accretion disks, relativistic jets, first image (M87, Sgr A*)'],
|
||||||
|
['id' => 'galaxies', 'category' => 'astronomy', 'topic' => 'Galaxies — structure and evolution',
|
||||||
|
'desc' => 'Milky Way structure (spiral arms, galactic center, halo), galaxy types (elliptical, spiral, irregular), Andromeda collision forecast, galaxy clusters, the Local Group, active galactic nuclei, quasars'],
|
||||||
|
['id' => 'cosmology', 'category' => 'astronomy', 'topic' => 'Cosmology and the early universe',
|
||||||
|
'desc' => 'Big Bang timeline (Planck era, inflation, nucleosynthesis, recombination), cosmic microwave background, observable universe size, Hubble constant tension, fate of universe (Big Freeze, Rip, Crunch), multiverse theories'],
|
||||||
|
['id' => 'exoplanets', 'category' => 'astronomy', 'topic' => 'Exoplanets and planet detection',
|
||||||
|
'desc' => 'transit photometry (Kepler/TESS), radial velocity method, direct imaging, habitable zone definition, super-Earths, hot Jupiters, TRAPPIST-1 system, biosignatures (oxygen, methane), atmospheric spectroscopy'],
|
||||||
|
['id' => 'dark_universe', 'category' => 'astronomy', 'topic' => 'Dark matter and dark energy',
|
||||||
|
'desc' => 'dark matter evidence (galaxy rotation curves, gravitational lensing), dark matter candidates (WIMPs, axions), dark energy and accelerating expansion, cosmological constant, Lambda-CDM model, detection experiments'],
|
||||||
|
['id' => 'telescopes', 'category' => 'astronomy', 'topic' => 'Telescopes and observatories',
|
||||||
|
'desc' => 'refracting vs reflecting telescopes, radio telescopes (VLA, ALMA), Hubble Space Telescope legacy, James Webb Space Telescope (infrared, L2 orbit), Chandra X-ray, Event Horizon Telescope, future projects (Vera Rubin, ELT)'],
|
||||||
|
['id' => 'astrobiology', 'category' => 'astronomy', 'topic' => 'Astrobiology and the search for life',
|
||||||
|
'desc' => 'conditions for life (liquid water, energy, organic molecules), extremophiles on Earth, promising targets (Europa, Enceladus, Mars, Titan), SETI and Breakthrough Listen, Fermi paradox explanations, panspermia hypothesis'],
|
||||||
|
['id' => 'space_time', 'category' => 'astronomy', 'topic' => 'Spacetime, relativity, and gravitational waves',
|
||||||
|
'desc' => 'special relativity (time dilation, length contraction, E=mc2), general relativity (spacetime curvature, equivalence principle), gravitational waves (LIGO/Virgo discoveries), frame dragging, black hole mergers'],
|
||||||
|
['id' => 'nebulae', 'category' => 'astronomy', 'topic' => 'Nebulae, star clusters, and deep sky objects',
|
||||||
|
'desc' => 'emission vs reflection vs planetary nebulae, open vs globular clusters, famous nebulae (Orion, Crab, Eagle/Pillars of Creation, Helix), Messier catalog, stellar nurseries, supernova remnants'],
|
||||||
|
['id' => 'moons_planets', 'category' => 'astronomy', 'topic' => 'Moons of the solar system',
|
||||||
|
'desc' => 'our Moon (formation, tides, phases, far side), Galilean moons (Io volcanoes, Europa ocean, Ganymede, Callisto), Titan atmosphere and methane lakes, Enceladus geysers, Triton retrograde orbit, Charon'],
|
||||||
|
['id' => 'comets_meteors', 'category' => 'astronomy', 'topic' => 'Comets, meteors, and asteroids',
|
||||||
|
'desc' => 'comet composition and tails, short vs long period comets (Halley, Hale-Bopp), meteor showers (Perseids, Leonids, Geminids), meteorite types, Chicxulub extinction event, Tunguska 1908, Chelyabinsk 2013, Apophis'],
|
||||||
|
['id' => 'space_weather', 'category' => 'astronomy', 'topic' => 'Space weather and solar activity',
|
||||||
|
'desc' => 'solar cycle (11-year sunspot cycle), solar flares and CMEs (coronal mass ejections), geomagnetic storms, auroras (borealis and australis), Carrington Event 1859, effects on power grids and satellites, space weather forecasting'],
|
||||||
|
['id' => 'astrochemistry', 'category' => 'astronomy', 'topic' => 'Astrochemistry and molecules in space',
|
||||||
|
'desc' => 'interstellar medium composition, molecular clouds, amino acids in meteorites (Murchison), organic molecules in space (formaldehyde, glycine), primordial soup theories, Miller-Urey experiment, phosphine on Venus controversy'],
|
||||||
|
|
||||||
|
// ── SPACE EXPLORATION ──
|
||||||
|
['id' => 'nasa_history', 'category' => 'space', 'topic' => 'NASA history and programs',
|
||||||
|
'desc' => 'Mercury program (first Americans in space), Gemini (spacewalks, rendezvous), Apollo (Moon landings 1969-1972), Skylab, Space Shuttle program (135 missions, Challenger, Columbia), ISS partnership, Commercial Crew'],
|
||||||
|
['id' => 'moon_missions', 'category' => 'space', 'topic' => 'Moon missions — past and future',
|
||||||
|
'desc' => 'Apollo 11 (Neil Armstrong), all 6 successful landings, lunar samples, retroreflectors, Soviet Luna program, Artemis program goals (2020s lunar base), Lunar Gateway, commercial lunar payloads (CLPS)'],
|
||||||
|
['id' => 'mars_missions', 'category' => 'space', 'topic' => 'Mars exploration',
|
||||||
|
'desc' => 'Viking landers, Mars Pathfinder/Sojourner, Spirit and Opportunity rovers, Curiosity (nuclear-powered), Perseverance and Ingenuity helicopter, InSight seismometer, MAVEN atmosphere study, future crewed missions'],
|
||||||
|
['id' => 'space_stations', 'category' => 'space', 'topic' => 'Space stations and living in orbit',
|
||||||
|
'desc' => 'ISS construction and modules, daily life (eating, sleeping, hygiene, exercise), microgravity health effects, EVA spacewalks, Mir history, China Tiangong, commercial stations (Axiom, Starlab), ISS deorbit plan 2030'],
|
||||||
|
['id' => 'commercial_space','category' => 'space', 'topic' => 'Commercial spaceflight industry',
|
||||||
|
'desc' => 'SpaceX (Falcon 9 reusability, Dragon, Starship), Blue Origin (New Shepard, New Glenn), Virgin Galactic, Rocket Lab, ULA, space tourism milestones, Starlink constellation, satellite internet competition'],
|
||||||
|
['id' => 'rocket_science', 'category' => 'space', 'topic' => 'Rocket propulsion and orbital mechanics',
|
||||||
|
'desc' => 'Tsiolkovsky rocket equation, specific impulse, staging (why multi-stage), propellant types (solid, liquid, ion), Hohmann transfer orbits, escape velocity, Lagrange points, orbital insertion, re-entry physics'],
|
||||||
|
['id' => 'satellites', 'category' => 'space', 'topic' => 'Satellites and their applications',
|
||||||
|
'desc' => 'LEO vs MEO vs GEO orbits, GPS constellation and GNSS accuracy, weather satellites (GOES), spy satellites (reconnaissance), communication satellites, remote sensing, space debris (Kessler syndrome), anti-satellite weapons'],
|
||||||
|
['id' => 'deep_space', 'category' => 'space', 'topic' => 'Deep space probes and missions',
|
||||||
|
'desc' => 'Pioneer 10/11 (first outer solar system), Voyager 1 (interstellar space), New Horizons (Pluto flyby), Cassini-Huygens (Saturn rings and Titan), Juno (Jupiter), DART (asteroid deflection), Europa Clipper'],
|
||||||
|
['id' => 'space_medicine', 'category' => 'space', 'topic' => 'Space medicine and human factors',
|
||||||
|
'desc' => 'muscle and bone loss in microgravity, cardiovascular changes, fluid shift to head, vision impairment (VIIP), radiation exposure, psychological isolation, sleep disruption, countermeasures, Mars mission health risks'],
|
||||||
|
['id' => 'launch_vehicles','category' => 'space', 'topic' => 'Launch vehicles — past and present',
|
||||||
|
'desc' => 'Saturn V (still most powerful flown), Space Shuttle SRBs, Soyuz reliability record, Atlas V, Delta IV Heavy, Falcon 9 and Heavy, Electron (small sat), Vulcan, SLS, Starship/Super Heavy, Ariane 6'],
|
||||||
|
['id' => 'future_space', 'category' => 'space', 'topic' => 'Future of space exploration and colonization',
|
||||||
|
'desc' => 'Mars colony challenges (radiation, ISRU, psychology), lunar ice mining, asteroid mining economics, space elevator concept, nuclear propulsion (NTP, NEP), generation ships, terraforming Mars, Drake equation implications'],
|
||||||
|
['id' => 'space_law', 'category' => 'space', 'topic' => 'Space law and policy',
|
||||||
|
'desc' => 'Outer Space Treaty (1967) — no national sovereignty, no weapons of mass destruction, Moon Agreement, Artemis Accords, commercial property rights debate, debris liability, orbital slot allocation (ITU), militarization concerns'],
|
||||||
|
['id' => 'planetary_defense','category' => 'space', 'topic' => 'Planetary defense — asteroid threats',
|
||||||
|
'desc' => 'NEO (Near Earth Object) tracking programs (Spaceguard, ATLAS, WISE), Torino Scale for threat rating, DART mission results (Dimorphos deflection), gravity tractor concept, nuclear option debate, Apophis 2029 flyby'],
|
||||||
|
['id' => 'women_space', 'category' => 'space', 'topic' => 'Women and minorities in space history',
|
||||||
|
'desc' => 'Valentina Tereshkova (first woman in space), Sally Ride (first American woman), Mae Jemison (first Black woman), Katherine Johnson and Hidden Figures, Peggy Whitson (record ISS time), Jasmin Moghbeli, diverse astronaut classes'],
|
||||||
|
|
||||||
|
// ── GENERAL CULTURE & LIFESTYLE ──
|
||||||
|
['id' => 'pop_culture', 'category' => 'culture', 'topic' => 'Pop culture and entertainment',
|
||||||
|
'desc' => 'blockbuster movie franchises (Marvel, Star Wars, Fast and Furious), streaming wars (Netflix, Disney+, Max), reality TV evolution, viral memes and internet culture, celebrity influence, award shows, K-pop global reach'],
|
||||||
|
['id' => 'true_crime', 'category' => 'culture', 'topic' => 'True crime — famous cases and forensics',
|
||||||
|
'desc' => 'DNA evidence and cold cases, criminal profiling, BTK, Ted Bundy, Casey Anthony, OJ Simpson, Serial podcast effect, wrongful convictions (Innocence Project), forensic science (ballistics, toxicology), crime scene investigation'],
|
||||||
|
['id' => 'gaming', 'category' => 'culture', 'topic' => 'Video games and gaming culture',
|
||||||
|
'desc' => 'gaming history (Pong to PS5), genres (FPS, RPG, RTS, battle royale), esports and streaming (Twitch, YouTube), game design principles, gaming addiction debate, VR gaming, mobile gaming dominance, indie game movement'],
|
||||||
|
['id' => 'sports_sci', 'category' => 'sports', 'topic' => 'Sports science and performance',
|
||||||
|
'desc' => 'biomechanics of athletic movement, VO2 max and lactate threshold, altitude training, sports nutrition (carb loading, creatine, caffeine), doping and anti-doping (WADA), concussion and CTE, sports psychology, recovery tech'],
|
||||||
|
['id' => 'mythology', 'category' => 'culture', 'topic' => 'World mythology and folklore',
|
||||||
|
'desc' => 'Greek pantheon (Zeus, Athena, Poseidon), Roman equivalents, Norse mythology (Odin, Thor, Ragnarok), Egyptian gods (Ra, Osiris, Anubis), Aztec and Mayan cosmology, Japanese mythology (Amaterasu), Celtic legends, hero archetype'],
|
||||||
|
['id' => 'travel', 'category' => 'culture', 'topic' => 'Travel and world destinations',
|
||||||
|
'desc' => 'travel hacking (points and miles), visa requirements overview, budget travel strategies, solo travel safety, top destinations (Southeast Asia, Europe backpacking, South America), travel insurance, packing light, cultural etiquette'],
|
||||||
|
['id' => 'animals_pets', 'category' => 'nature', 'topic' => 'Animals and pet care',
|
||||||
|
'desc' => 'dog breeds and temperament, cat behavior and communication, exotic pets legality, veterinary basics (vaccines, spay/neuter), animal cognition research, endangered species, wildlife rehabilitation, insects role in ecosystems'],
|
||||||
|
['id' => 'gardening', 'category' => 'nature', 'topic' => 'Gardening and urban farming',
|
||||||
|
'desc' => 'soil types and amendments, composting methods, companion planting, organic pest control, seed starting vs transplants, hydroponics and aquaponics, raised bed gardening, Texas growing zones, edible landscaping'],
|
||||||
|
['id' => 'weather', 'category' => 'nature', 'topic' => 'Weather, meteorology, and climate',
|
||||||
|
'desc' => 'how weather systems form (fronts, pressure systems), thunderstorm anatomy, tornado formation and EF scale, hurricane categories and storm surge, jet stream, La Nina vs El Nino, climate change vs weather, forecasting tools'],
|
||||||
|
['id' => 'language', 'category' => 'culture', 'topic' => 'Language, linguistics, and communication',
|
||||||
|
'desc' => 'how languages evolve and die, language families (Indo-European, Sino-Tibetan), second language acquisition, bilingualism and brain effects, dialects and accents, sign languages, language and culture connection, most spoken languages'],
|
||||||
|
['id' => 'architecture', 'category' => 'culture', 'topic' => 'Architecture and design',
|
||||||
|
'desc' => 'architectural styles (Gothic, Baroque, Art Deco, Modernism, Brutalism), famous structures (Parthenon, Sagrada Familia, Fallingwater, Burj Khalifa), green building (LEED), urban planning, tiny house movement, biophilic design'],
|
||||||
|
['id' => 'food_culture', 'category' => 'culture', 'topic' => 'Food culture and culinary traditions',
|
||||||
|
'desc' => 'world cuisines overview (French, Italian, Japanese, Indian, Mexican, Ethiopian), fermentation (kimchi, sourdough, wine), food history and spice trade, street food culture, farm-to-table movement, food deserts, food waste'],
|
||||||
|
['id' => 'disasters', 'category' => 'safety', 'topic' => 'Natural disasters and emergency preparedness',
|
||||||
|
'desc' => 'earthquake preparedness (drop-cover-hold), wildfire evacuation, flood safety, hurricane prep checklist, emergency food and water storage, bug-out bag essentials, FEMA resources, community resilience, disaster psychology'],
|
||||||
|
['id' => 'wine_spirits', 'category' => 'culture', 'topic' => 'Wine, beer, and spirits',
|
||||||
|
'desc' => 'wine varietals (Cabernet, Pinot Noir, Chardonnay, Riesling), wine regions (Bordeaux, Napa, Tuscany), craft beer styles (IPA, stout, lager, sour), brewing process, whiskey types (Scotch, bourbon, Irish), cocktail classics'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/* ── ROTATION ENGINE: process BATCH_SIZE topics per run, cycling through all ── */
|
||||||
|
define('BATCH_SIZE', 25);
|
||||||
|
$totalTopics = count($BATCHES);
|
||||||
|
$offsetRow = JarvisDB::single(
|
||||||
|
"SELECT CAST(fact_value AS SIGNED) AS v FROM kb_facts WHERE category='kb_generator' AND fact_key='batch_offset'"
|
||||||
|
);
|
||||||
|
$batchOffset = max(0, (int)($offsetRow['v'] ?? 0));
|
||||||
|
if ($batchOffset >= $totalTopics) $batchOffset = 0;
|
||||||
|
$nextOffset = ($batchOffset + BATCH_SIZE) % $totalTopics;
|
||||||
|
$cycleComplete = ($batchOffset + BATCH_SIZE) >= $totalTopics;
|
||||||
|
|
||||||
|
// Slice BATCH_SIZE topics starting at offset, wrapping if needed
|
||||||
|
$runBatches = [];
|
||||||
|
for ($i = 0; $i < BATCH_SIZE; $i++) {
|
||||||
|
$runBatches[] = $BATCHES[($batchOffset + $i) % $totalTopics];
|
||||||
|
}
|
||||||
|
$endIdx = ($batchOffset + BATCH_SIZE - 1) % $totalTopics;
|
||||||
|
$cycleLen = (int)ceil($totalTopics / BATCH_SIZE);
|
||||||
|
log_line("Rotation: topics " . ($batchOffset + 1) . "–" . ($endIdx + 1) . " of {$totalTopics} total | cycle {$cycleLen} runs × every 6h = " . ($cycleLen * 6) . "h full cycle.");
|
||||||
|
if ($cycleComplete) log_line(" ↻ Full cycle complete — restarting from topic 1 next run.");
|
||||||
|
|
||||||
|
|
||||||
/* ── system prompt ── */
|
/* ── system prompt ── */
|
||||||
$SYSTEM = <<<'SYS'
|
$SYSTEM = <<<'SYS'
|
||||||
You are an expert educator generating KB (knowledge-base) intents for an AI assistant called JARVIS.
|
You are an expert educator generating KB (knowledge-base) intents for an AI assistant called JARVIS.
|
||||||
@@ -155,7 +388,7 @@ Rules:
|
|||||||
- Patterns should NOT start with ^ or end with $
|
- Patterns should NOT start with ^ or end with $
|
||||||
- Responses must be factually accurate
|
- Responses must be factually accurate
|
||||||
- Do not duplicate intent names; every "n" must be unique within this batch
|
- Do not duplicate intent names; every "n" must be unique within this batch
|
||||||
- Return exactly 40 intents
|
- Return exactly 20 intents
|
||||||
SYS;
|
SYS;
|
||||||
|
|
||||||
/* ── insert helper ── */
|
/* ── insert helper ── */
|
||||||
@@ -199,8 +432,8 @@ function safe_insert(array $intent, string $batchCategory): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ── main generation loop ── */
|
/* ── main generation loop ── */
|
||||||
$totalBatches = count($BATCHES);
|
$totalBatches = count($runBatches);
|
||||||
foreach ($BATCHES as $idx => $batch) {
|
foreach ($runBatches as $idx => $batch) {
|
||||||
$num = $idx + 1;
|
$num = $idx + 1;
|
||||||
log_line("Batch {$num}/{$totalBatches}: {$batch['topic']}");
|
log_line("Batch {$num}/{$totalBatches}: {$batch['topic']}");
|
||||||
|
|
||||||
@@ -209,10 +442,10 @@ foreach ($BATCHES as $idx => $batch) {
|
|||||||
. "Prefix every intent_name with \"{$batch['id']}_\".\n"
|
. "Prefix every intent_name with \"{$batch['id']}_\".\n"
|
||||||
. "Category string to use: \"{$batch['category']}\".";
|
. "Category string to use: \"{$batch['category']}\".";
|
||||||
|
|
||||||
$raw = groq($SYSTEM, $user, 3500);
|
$raw = groq($SYSTEM, $user, 5000);
|
||||||
if ($raw === null) {
|
if ($raw === null) {
|
||||||
log_line(" ✗ API call failed after retries – skipping batch.");
|
log_line(" ✗ API call failed after retries – skipping batch.");
|
||||||
$errors += 40;
|
$errors += 20;
|
||||||
sleep(8);
|
sleep(8);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -222,19 +455,29 @@ foreach ($BATCHES as $idx => $batch) {
|
|||||||
$raw = preg_replace('/^```\s*/m', '', $raw);
|
$raw = preg_replace('/^```\s*/m', '', $raw);
|
||||||
$raw = trim($raw);
|
$raw = trim($raw);
|
||||||
|
|
||||||
// Extract JSON array (even if the model added preamble text)
|
// Extract JSON array; fall back to partial recovery for truncated responses
|
||||||
if (!preg_match('/\[\s*\{.*\}\s*\]/s', $raw, $m)) {
|
$items = null;
|
||||||
log_line(" ✗ No JSON array found in response – skipping batch.");
|
if (preg_match('/\[\s*\{.*\}\s*\]/s', $raw, $m)) {
|
||||||
$errors += 40;
|
|
||||||
sleep(8);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$items = json_decode($m[0], true);
|
$items = json_decode($m[0], true);
|
||||||
if (!is_array($items)) {
|
if (!is_array($items)) {
|
||||||
log_line(" ✗ JSON parse failed – skipping batch.");
|
log_line(" ✗ JSON parse failed – skipping batch.");
|
||||||
$errors += 40;
|
$errors += 20; sleep(8); continue;
|
||||||
sleep(8);
|
}
|
||||||
continue;
|
} else {
|
||||||
|
$start = strpos($raw, '[');
|
||||||
|
if ($start !== false) {
|
||||||
|
$partial = substr($raw, $start);
|
||||||
|
if (preg_match_all('/\{[^{}]*(?:\{[^{}]*\}[^{}]*)*\}/s', $partial, $objs) && !empty($objs[0])) {
|
||||||
|
$recovered = '[' . implode(',', $objs[0]) . ']';
|
||||||
|
$items = json_decode($recovered, true);
|
||||||
|
if (is_array($items) && count($items) > 0)
|
||||||
|
log_line(" ⚠ Truncated — recovered " . count($items) . " items.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!is_array($items) || count($items) === 0) {
|
||||||
|
log_line(" ✗ No JSON array found — raw[0:120]: " . substr(str_replace("\n", ' ', $raw), 0, 120));
|
||||||
|
$errors += 20; sleep(8); continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$batchInserted = 0;
|
$batchInserted = 0;
|
||||||
@@ -324,6 +567,13 @@ JarvisDB::execute(
|
|||||||
ON DUPLICATE KEY UPDATE fact_value=NOW(), updated_at=NOW()",
|
ON DUPLICATE KEY UPDATE fact_value=NOW(), updated_at=NOW()",
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
JarvisDB::execute(
|
||||||
|
"INSERT INTO kb_facts (category, fact_key, fact_value, host)
|
||||||
|
VALUES ('kb_generator', 'batch_offset', ?, 'local')
|
||||||
|
ON DUPLICATE KEY UPDATE fact_value=VALUES(fact_value), updated_at=NOW()",
|
||||||
|
[$nextOffset]
|
||||||
|
);
|
||||||
|
log_line("Next run will start at topic offset {$nextOffset}/{$totalTopics}.");
|
||||||
JarvisDB::execute(
|
JarvisDB::execute(
|
||||||
"INSERT INTO kb_facts (category, fact_key, fact_value, host)
|
"INSERT INTO kb_facts (category, fact_key, fact_value, host)
|
||||||
VALUES ('kb_generator', 'last_inserted', ?, 'local')
|
VALUES ('kb_generator', 'last_inserted', ?, 'local')
|
||||||
|
|||||||
Reference in New Issue
Block a user