@ak--47/dungeon-master 1.4.5 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/.claude/skills/analyze-soup/SKILL.md +158 -0
  2. package/.claude/skills/create-dungeon/SKILL.md +464 -0
  3. package/.claude/skills/verify-dungeon/SKILL.md +157 -0
  4. package/.claude/skills/verify-dungeon/references/counting-semantics.md +161 -0
  5. package/.claude/skills/verify-dungeon/references/report-format.md +216 -0
  6. package/.claude/skills/verify-dungeon/references/sql-recipes.md +857 -0
  7. package/.claude/skills/write-hooks/SKILL.md +468 -0
  8. package/CHANGELOG.md +182 -0
  9. package/HOOKS.md +1256 -597
  10. package/README.md +140 -5
  11. package/dungeons/technical/ad-spend.js +41 -49
  12. package/dungeons/technical/anonymous-users.js +38 -36
  13. package/dungeons/technical/array-of-object-lookup.js +136 -153
  14. package/dungeons/technical/datagen-v15-verify.js +87 -0
  15. package/dungeons/technical/experiments.js +42 -40
  16. package/dungeons/technical/foobar.js +114 -118
  17. package/dungeons/technical/group-analytics.js +42 -40
  18. package/dungeons/technical/hook-helpers-verify.js +69 -50
  19. package/dungeons/technical/identity-model-verify.js +22 -12
  20. package/dungeons/technical/mirror-strategies.js +37 -39
  21. package/dungeons/technical/nested-objects.js +119 -118
  22. package/dungeons/technical/pattern-aggregate-by-bin.js +21 -8
  23. package/dungeons/technical/pattern-attributed-by-source.js +23 -9
  24. package/dungeons/technical/pattern-frequency-by-frequency.js +21 -8
  25. package/dungeons/technical/pattern-funnel-frequency.js +30 -15
  26. package/dungeons/technical/pattern-ttc-by-segment.js +21 -8
  27. package/dungeons/technical/retention-cadence.js +115 -112
  28. package/dungeons/technical/sanity.js +86 -80
  29. package/dungeons/technical/scale-test.js +34 -38
  30. package/dungeons/technical/scd.js +111 -128
  31. package/dungeons/technical/simple.js +134 -141
  32. package/dungeons/technical/simplest.js +111 -65
  33. package/dungeons/technical/text-generation.js +110 -146
  34. package/dungeons/vertical/ai-platform.js +300 -333
  35. package/dungeons/vertical/community.js +290 -255
  36. package/dungeons/vertical/crypto.js +400 -391
  37. package/dungeons/vertical/dating.js +421 -375
  38. package/dungeons/vertical/devtools.js +346 -298
  39. package/dungeons/vertical/ecommerce.js +322 -394
  40. package/dungeons/vertical/education.js +380 -325
  41. package/dungeons/vertical/fintech.js +371 -325
  42. package/dungeons/vertical/fitness.js +345 -291
  43. package/dungeons/vertical/food-delivery.js +352 -307
  44. package/dungeons/vertical/gaming.js +490 -444
  45. package/dungeons/vertical/healthcare.js +311 -262
  46. package/dungeons/vertical/insurance-application.js +437 -409
  47. package/dungeons/vertical/logistics.js +278 -252
  48. package/dungeons/vertical/marketplace.js +340 -323
  49. package/dungeons/vertical/media.js +390 -335
  50. package/dungeons/vertical/real-estate.js +402 -347
  51. package/dungeons/vertical/sass.js +331 -333
  52. package/dungeons/vertical/social.js +377 -316
  53. package/dungeons/vertical/travel.js +302 -295
  54. package/index.js +64 -7
  55. package/lib/core/config-validator.js +378 -17
  56. package/lib/core/dungeon-loader.js +2 -5
  57. package/lib/generators/events.js +12 -13
  58. package/lib/generators/funnels.js +76 -2
  59. package/lib/hook-helpers/index.js +1 -0
  60. package/lib/hook-helpers/inject.js +95 -0
  61. package/lib/orchestrators/mixpanel-sender.js +7 -0
  62. package/lib/orchestrators/user-loop.js +598 -48
  63. package/lib/templates/defaults.js +59 -59
  64. package/lib/templates/macro-presets.js +53 -11
  65. package/lib/utils/dataset-context.js +103 -0
  66. package/lib/utils/retention-curve.js +140 -0
  67. package/lib/utils/utils.js +157 -109
  68. package/lib/verify/counting.js +360 -0
  69. package/lib/verify/emulate-breakdown.js +531 -108
  70. package/lib/verify/funnel-engine.js +539 -0
  71. package/lib/verify/identity.js +78 -0
  72. package/lib/verify/index.js +20 -0
  73. package/lib/verify/schema-validator.js +3 -1
  74. package/lib/verify/verify-dungeon.js +58 -0
  75. package/package.json +14 -3
  76. package/scripts/run-dungeon.mjs +12 -1
  77. package/types.d.ts +353 -4
  78. package/scripts/smoke-test-all.mjs +0 -162
@@ -1,70 +1,46 @@
1
- // ── TWEAK THESE ──
2
- const SEED = "dm4-community";
3
- const num_days = 120;
4
- const num_users = 10_000;
5
- const avg_events_per_user_per_day = 1.2;
6
- let token = "your-mixpanel-token";
7
-
8
- // ── env overrides ──
9
- if (process.env.MP_TOKEN) token = process.env.MP_TOKEN;
10
-
1
+ // ── IMPORTS ──
11
2
  import dayjs from "dayjs";
12
3
  import utc from "dayjs/plugin/utc.js";
4
+ dayjs.extend(utc);
13
5
  import "dotenv/config";
14
6
  import * as u from "../../lib/utils/utils.js";
15
7
  import * as v from "ak-tools";
16
-
17
- dayjs.extend(utc);
18
- const chance = u.initChance(SEED);
19
8
  /** @typedef {import("../../types").Dungeon} Config */
20
9
 
21
- // Generate consistent wiki/article IDs at module level
22
- const wikiIds = v.range(1, 500).map(() => `WIKI_${v.uid(6)}`);
23
- const communityIds = v.range(1, 30).map(() => `COMM_${v.uid(4)}`);
24
-
25
- /**
26
- * ===================================================================
27
- * DATASET OVERVIEW
28
- * ===================================================================
29
- *
30
- * FanVerse -- a fan wiki and community discussion platform where
31
- * users create articles, discuss topics, moderate content, and
32
- * build collaborative knowledge bases across fandoms.
33
- *
34
- * - 10,000 users over 120 days
35
- * - Multi-role system: power creators (5%), moderators (8%),
36
- * active contributors (25%), readers (45%), lurkers (17%)
37
- * - Core loop: sign up -> search -> read articles -> contribute -> discuss
38
- * - Revenue: free / supporter ($4.99, ad-free) / pro ($12.99, analytics+badges)
39
- *
40
- * Advanced Features:
41
- * - Personas: 5 archetypes (power_creator, moderator, active_contributor, reader, lurker)
42
- * - Engagement Decay: linear decline with floor
43
- * - Subscription: 3-tier with supporter and pro plans
44
- * - Attribution: google_search, reddit_referral, youtube_link, organic
45
- * - Features: live_discussions (day 25), interactive_polls (day 55)
46
- *
47
- * Key entities:
48
- * - wiki_id: unique wiki article identifier
49
- * - community_id: community/fandom grouping
50
- * - content_hub: topical category (gaming, anime, movies, tv, comics, music)
51
- * - discussion_mode: classic vs live (driven by Feature rollout)
10
+ // ── OVERVIEW ──
11
+ /*
12
+ * NAME: FanVerse
13
+ * APP: Fan wiki and community discussion platform where users create
14
+ * articles, discuss topics, moderate content, and build collaborative
15
+ * knowledge bases across fandoms. Core loop: sign up → search → read
16
+ * articles contribute → discuss. Revenue: free / supporter ($4.99,
17
+ * ad-free) / pro ($12.99, analytics + badges).
18
+ * SCALE: 10,000 users, ~1.4M events, 121 days (2026-01-01 → 2026-05-01)
19
+ * CORE LOOP: account created search performed article viewed → article published → comment posted
20
+ *
21
+ * EVENTS (18):
22
+ * article viewed (9) > app session (8) > upvote given (7) > comment posted (6)
23
+ * > search performed (6) > notification received (6) > discussion posted (5)
24
+ * > article edited (4) > article published (3) > user followed (3)
25
+ * > wiki page created (2) > media uploaded (2) > moderation action (2)
26
+ * > profile updated (2) > account created (1) > support ticket created (1)
27
+ * > report submitted (1) > account deactivated (1)
28
+ *
29
+ * FUNNELS (5):
30
+ * - Onboarding Flow: account created search performed article viewed → discussion posted (40%)
31
+ * - Content Creation: article viewed article published → comment posted (35%)
32
+ * - Engagement Loop: article viewed upvote given comment posted → discussion posted (30%)
33
+ * - Creator to Supporter: article published profile updated → notification received (45%)
34
+ * - Moderation Pipeline: report submitted moderation action (60%)
35
+ *
36
+ * USER PROPS: role, contributor_level, articles_created, reputation_score, preferred_hub, subscription_tier, Platform, content_hub
37
+ * SUPER PROPS: subscription_tier, Platform, content_hub
38
+ * SCD PROPS: contributor_level (newcomer/regular/trusted/admin, monthly fuzzy, max 8)
39
+ * GROUPS: none
52
40
  */
53
41
 
54
- /**
55
- * ===================================================================
56
- * ANALYTICS HOOKS (10 hooks)
57
- *
58
- * NOTE: All cohort effects are HIDDEN — no flag stamping. Discoverable via
59
- * raw-prop breakdowns (day, content_hub, subscription_tier) or behavioral cohorts.
60
- *
61
- * Adds 9. CONTENT CREATION TIME-TO-CONVERT (Pro 1.3x faster, Free 1.25x slower)
62
- * [funnel-post: visible only in Mixpanel funnel median TTC; cross-event
63
- * MIN→MIN SQL queries do NOT show this]
64
- * and 10. ARTICLE-PUBLISHED MAGIC NUMBER (sweet 2-5 → +35% upvote_count;
65
- * over 6+ → drop 25% upvote events).
66
- * ===================================================================
67
- *
42
+ // ── HOOK STORIES ──
43
+ /*
68
44
  * -------------------------------------------------------------------
69
45
  * 1. WEEKEND CONTENT SURGE (event hook)
70
46
  * -------------------------------------------------------------------
@@ -329,31 +305,258 @@ const communityIds = v.range(1, 30).map(() => `COMM_${v.uid(4)}`);
329
305
  * Article-Published Magic Num | over upvote events | 1x | 0.75x | -25%
330
306
  */
331
307
 
308
+ // ── SCALE ──
309
+ const SEED = "dm4-community";
310
+ const NUM_USERS = 10_000;
311
+ const DATASET_START = "2026-01-01T00:00:00Z";
312
+ const DATASET_END = "2026-05-01T23:59:59Z";
313
+ const EVENTS_PER_DAY = 1.2;
314
+ const token = process.env.MP_TOKEN || "your-mixpanel-token";
315
+
316
+ const chance = u.initChance(SEED);
317
+
318
+ // ── KNOBS (tweak these to reshape stories) ──
319
+ const WEEKEND_WORD_COUNT_MULT = 1.5;
320
+
321
+ const TREND_START_DAY = 35;
322
+ const TREND_END_DAY = 50;
323
+ const TREND_VIEW_MULT = 2;
324
+
325
+ const POWER_CREATOR_PUBLISH_THRESHOLD = 20;
326
+ const POWER_CREATOR_UPVOTE_MULT = 3;
327
+
328
+ const DISCUSSION_CLONE_LIKELIHOOD = 50;
329
+
330
+ const EDIT_WAR_THRESHOLD = 5;
331
+ const EDIT_WAR_QUALITY_MIN = 1.0;
332
+ const EDIT_WAR_QUALITY_MAX = 2.0;
333
+
334
+ const LURKER_EVENT_THRESHOLD = 5;
335
+ const LURKER_CHURN_CUTOFF_DAYS = 10;
336
+ const LURKER_DROP_LIKELIHOOD = 60;
337
+
338
+ const PRO_LIFT_FREE_DROP_LIKELIHOOD = 65;
339
+
340
+ const TTC_PRO_FACTOR = 0.77;
341
+ const TTC_FREE_FACTOR = 1.25;
342
+
343
+ const ARTICLE_SWEET_MIN = 2;
344
+ const ARTICLE_SWEET_MAX = 5;
345
+ const ARTICLE_OVER_THRESHOLD = 6;
346
+ const ARTICLE_UPVOTE_BOOST = 1.35;
347
+ const ARTICLE_UPVOTE_DROP_LIKELIHOOD = 25;
348
+
349
+ // ── DATA ARRAYS ──
350
+ // Generate consistent wiki/article IDs at module level
351
+ const wikiIds = v.range(1, 500).map(() => `WIKI_${v.uid(6)}`);
352
+ const communityIds = v.range(1, 30).map(() => `COMM_${v.uid(4)}`);
353
+
354
+ // ── HELPER FUNCTIONS ──
355
+ function handleUserHooks(record) {
356
+ // H7: CREATOR PROFILES — creators get high articles_created and reputation.
357
+ // Moderators get mid-range reputation. Readers/lurkers stay at defaults.
358
+ if (record.role === "creator") {
359
+ record.articles_created = chance.integer({ min: 50, max: 200 });
360
+ record.reputation_score = chance.integer({ min: 80, max: 100 });
361
+ record.contributor_level = "admin";
362
+ } else if (record.role === "moderator") {
363
+ record.articles_created = chance.integer({ min: 10, max: 50 });
364
+ record.reputation_score = chance.integer({ min: 40, max: 70 });
365
+ record.contributor_level = "trusted";
366
+ } else if (record.role === "contributor") {
367
+ record.articles_created = chance.integer({ min: 1, max: 15 });
368
+ record.reputation_score = chance.integer({ min: 15, max: 50 });
369
+ record.contributor_level = "regular";
370
+ } else {
371
+ record.articles_created = 0;
372
+ record.reputation_score = chance.integer({ min: 0, max: 20 });
373
+ record.contributor_level = "newcomer";
374
+ }
375
+ return record;
376
+ }
377
+
378
+ function handleFunnelPostHooks(record, meta) {
379
+ // H9: CONTENT CREATION TIME-TO-CONVERT — Pro/supporter complete 1.3x
380
+ // faster (factor 0.77); Free 1.25x slower (factor 1.25).
381
+ const segment = meta?.profile?.subscription_tier;
382
+ if (Array.isArray(record) && record.length > 1) {
383
+ const factor = (
384
+ segment === "pro" || segment === "supporter" ? TTC_PRO_FACTOR :
385
+ segment === "free" ? TTC_FREE_FACTOR :
386
+ 1.0
387
+ );
388
+ if (factor !== 1.0) {
389
+ for (let i = 1; i < record.length; i++) {
390
+ const prev = dayjs(record[i - 1].time);
391
+ const newGap = Math.round(dayjs(record[i].time).diff(prev) * factor);
392
+ record[i].time = prev.add(newGap, "milliseconds").toISOString();
393
+ }
394
+ }
395
+ }
396
+ return record;
397
+ }
398
+
399
+ function handleEverythingHooks(record, meta) {
400
+ const datasetStart = dayjs.unix(meta.datasetStart);
401
+ let events = record;
402
+ if (!events.length) return record;
403
+ const profile = meta && meta.profile ? meta.profile : {};
404
+
405
+ // -- SUPERPROP STAMPING -----------------------------------
406
+ // Stamp superProp values from profile onto every event so
407
+ // they stay consistent per-user instead of randomizing per-event.
408
+ events.forEach(e => {
409
+ if (profile.subscription_tier) e.subscription_tier = profile.subscription_tier;
410
+ if (profile.Platform) e.Platform = profile.Platform;
411
+ if (profile.content_hub) e.content_hub = profile.content_hub;
412
+ });
413
+
414
+ // HOOK 1: WEEKEND CONTENT SURGE — articles on Sat/Sun get
415
+ // word_count 1.5x. Mutates raw prop. No flag.
416
+ for (const e of events) {
417
+ if (e.event === 'article published' || e.event === 'article viewed') {
418
+ const dow = new Date(e.time).getUTCDay();
419
+ if ((dow === 0 || dow === 6) && e.word_count) {
420
+ e.word_count = Math.floor(e.word_count * WEEKEND_WORD_COUNT_MULT);
421
+ }
422
+ }
423
+ }
424
+
425
+ // -- HOOK 2: TRENDING TOPIC WINDOW -------------------------
426
+ // Days 35-50: gaming hub articles get 2x view_count.
427
+ // Runs after superProp stamping so content_hub is the
428
+ // profile's consistent value, not the random event-level one.
429
+ const TREND_START = datasetStart.add(TREND_START_DAY, "days");
430
+ const TREND_END = datasetStart.add(TREND_END_DAY, "days");
431
+ if (profile.content_hub === "gaming") {
432
+ events.forEach(e => {
433
+ if (e.event === "article viewed") {
434
+ const eventTime = dayjs(e.time);
435
+ if (eventTime.isAfter(TREND_START) && eventTime.isBefore(TREND_END)) {
436
+ e.view_count = Math.floor((e.view_count || 50) * TREND_VIEW_MULT);
437
+ }
438
+ }
439
+ });
440
+ }
441
+
442
+ // -- HOOK 8: PRO SUBSCRIBER CONTENT CREATION LIFT ---------
443
+ // Free-tier users drop 65% of comment events to widen the funnel
444
+ // conversion gap to ~2x vs paid subscribers.
445
+ if (profile.subscription_tier !== "pro" && profile.subscription_tier !== "supporter") {
446
+ events = events.filter(e => {
447
+ if (e.event === "comment posted" && chance.bool({ likelihood: PRO_LIFT_FREE_DROP_LIKELIHOOD })) return false;
448
+ return true;
449
+ });
450
+ }
451
+
452
+ // -- HOOK 3: POWER CREATOR ENGAGEMENT LIFT ----------------
453
+ // Users with >20 article_published events get 3x upvote_count.
454
+ let publishCount = 0;
455
+ events.forEach(e => {
456
+ if (e.event === "article published") publishCount++;
457
+ });
458
+
459
+ if (publishCount > POWER_CREATOR_PUBLISH_THRESHOLD) {
460
+ events.forEach(e => {
461
+ if (e.event === "upvote given" && e.upvote_count) {
462
+ e.upvote_count = Math.floor(e.upvote_count * POWER_CREATOR_UPVOTE_MULT);
463
+ }
464
+ });
465
+ }
466
+
467
+ // -- HOOK 4: DISCUSSION DEPTH BY CONTRIBUTOR TYPE ---------
468
+ // Active contributors get cloned comment_posted events.
469
+ if (profile.segment === "active_contributor") {
470
+ const templateComment = events.find(e => e.event === "comment posted");
471
+ if (templateComment) {
472
+ const existingComments = events.filter(e => e.event === "comment posted");
473
+ existingComments.forEach(c => {
474
+ if (chance.bool({ likelihood: DISCUSSION_CLONE_LIKELIHOOD })) {
475
+ events.push({
476
+ ...templateComment,
477
+ time: dayjs(c.time).add(chance.integer({ min: 1, max: 120 }), "minutes").toISOString(),
478
+ user_id: c.user_id,
479
+ is_reply: true,
480
+ comment_length: chance.integer({ min: 20, max: 300 }),
481
+ });
482
+ }
483
+ });
484
+ }
485
+ }
486
+
487
+ // -- HOOK 5: EDIT WAR DETECTION ---------------------------
488
+ // Users with >5 article_edited events get reduced edit_quality.
489
+ const editEvents = events.filter(e => e.event === "article edited");
490
+ if (editEvents.length > EDIT_WAR_THRESHOLD) {
491
+ editEvents.forEach(e => {
492
+ e.edit_quality = chance.floating({ min: EDIT_WAR_QUALITY_MIN, max: EDIT_WAR_QUALITY_MAX, fixed: 1 });
493
+ });
494
+ }
495
+
496
+ // HOOK 6: LURKER CHURN — users with <5 events lose 60% after
497
+ // day 10. No flag.
498
+ if (events.length < LURKER_EVENT_THRESHOLD && events.length > 0) {
499
+ const firstEventTime = dayjs(events[0].time);
500
+ const cutoff = firstEventTime.add(LURKER_CHURN_CUTOFF_DAYS, "days");
501
+ for (let i = events.length - 1; i >= 0; i--) {
502
+ if (dayjs(events[i].time).isAfter(cutoff) && chance.bool({ likelihood: LURKER_DROP_LIKELIHOOD })) {
503
+ events.splice(i, 1);
504
+ }
505
+ }
506
+ }
507
+
508
+ // HOOK 10: ARTICLE-PUBLISHED MAGIC NUMBER (no flags)
509
+ // Sweet 2-5 articles published → +35% on upvote_count for
510
+ // upvote-given events. Over 6+ → drop 25% of upvote-given events
511
+ // (over-publishing dilutes signal). No flag.
512
+ const articleCount = events.filter(e => e.event === "article published").length;
513
+ if (articleCount >= ARTICLE_SWEET_MIN && articleCount <= ARTICLE_SWEET_MAX) {
514
+ events.forEach(e => {
515
+ if (e.event === "upvote given" && typeof e.upvote_count === "number") {
516
+ e.upvote_count = Math.round(e.upvote_count * ARTICLE_UPVOTE_BOOST);
517
+ }
518
+ });
519
+ } else if (articleCount >= ARTICLE_OVER_THRESHOLD) {
520
+ for (let i = events.length - 1; i >= 0; i--) {
521
+ if (events[i].event === "upvote given" && chance.bool({ likelihood: ARTICLE_UPVOTE_DROP_LIKELIHOOD })) {
522
+ events.splice(i, 1);
523
+ }
524
+ }
525
+ }
526
+
527
+ return events;
528
+ }
529
+
530
+ // ── CONFIG ──
332
531
  /** @type {Config} */
333
532
  const config = {
334
533
  version: 2,
335
- token,
336
534
  seed: SEED,
337
- datasetStart: "2026-01-01T00:00:00Z",
338
- datasetEnd: "2026-05-01T23:59:59Z",
339
- // numDays: num_days,
340
- avgEventsPerUserPerDay: avg_events_per_user_per_day,
341
- numUsers: num_users,
342
- hasAnonIds: true,
343
- avgDevicePerUser: 2,
344
- hasSessionIds: true,
535
+ datasetStart: DATASET_START,
536
+ datasetEnd: DATASET_END,
537
+ avgEventsPerUserPerDay: EVENTS_PER_DAY,
538
+ numUsers: NUM_USERS,
345
539
  format: "json",
346
540
  gzip: true,
347
- alsoInferFunnels: false,
348
- hasLocation: true,
349
- hasAndroidDevices: true,
350
- hasIOSDevices: true,
351
- hasDesktopDevices: true,
352
- hasBrowser: false,
353
- hasCampaigns: false,
354
- isAnonymous: false,
355
- hasAdSpend: false,
356
- hasAvatar: true,
541
+ credentials: {
542
+ token,
543
+ },
544
+ switches: {
545
+ hasSessionIds: true,
546
+ alsoInferFunnels: false,
547
+ hasLocation: true,
548
+ hasAndroidDevices: true,
549
+ hasIOSDevices: true,
550
+ hasDesktopDevices: true,
551
+ hasBrowser: false,
552
+ hasCampaigns: false,
553
+ isAnonymous: false,
554
+ hasAdSpend: false,
555
+ hasAvatar: true,
556
+ },
557
+ identity: {
558
+ avgDevicePerUser: 2,
559
+ },
357
560
  concurrency: 1,
358
561
  writeToDisk: false,
359
562
  scdProps: {
@@ -381,6 +584,7 @@ const config = {
381
584
  {
382
585
  event: "article viewed",
383
586
  weight: 9,
587
+ isStrictEvent: false,
384
588
  properties: {
385
589
  wiki_id: chance.pickone.bind(chance, wikiIds),
386
590
  content_hub: ["gaming", "anime", "movies", "tv", "comics", "music"],
@@ -391,6 +595,7 @@ const config = {
391
595
  {
392
596
  event: "article published",
393
597
  weight: 3,
598
+ isStrictEvent: false,
394
599
  properties: {
395
600
  wiki_id: chance.pickone.bind(chance, wikiIds),
396
601
  content_hub: ["gaming", "anime", "movies", "tv", "comics", "music"],
@@ -413,6 +618,7 @@ const config = {
413
618
  {
414
619
  event: "discussion posted",
415
620
  weight: 5,
621
+ isStrictEvent: false,
416
622
  properties: {
417
623
  community_id: chance.pickone.bind(chance, communityIds),
418
624
  content_hub: ["gaming", "anime", "movies", "tv", "comics", "music"],
@@ -424,6 +630,7 @@ const config = {
424
630
  {
425
631
  event: "comment posted",
426
632
  weight: 6,
633
+ isStrictEvent: false,
427
634
  properties: {
428
635
  community_id: chance.pickone.bind(chance, communityIds),
429
636
  content_hub: ["gaming", "anime", "movies", "tv", "comics", "music"],
@@ -435,6 +642,7 @@ const config = {
435
642
  {
436
643
  event: "upvote given",
437
644
  weight: 7,
645
+ isStrictEvent: false,
438
646
  properties: {
439
647
  content_type: ["article", "article", "discussion", "comment"],
440
648
  content_hub: ["gaming", "anime", "movies", "tv", "comics", "music"],
@@ -565,6 +773,7 @@ const config = {
565
773
  order: "sequential",
566
774
  timeToConvert: 96,
567
775
  weight: 4,
776
+ reentry: true,
568
777
  },
569
778
  {
570
779
  name: "Creator to Supporter",
@@ -746,184 +955,10 @@ const config = {
746
955
  },
747
956
  ],
748
957
 
749
- // -- Hook Function ------------------------------------------------
750
- hook: function (record, type, meta) {
751
- // -- HOOK 7: CREATOR PROFILES (user) --------------------------
752
- // Creators get high articles_created and reputation. Moderators
753
- // get mid-range reputation. Readers/lurkers stay at defaults.
754
- if (type === "user") {
755
- if (record.role === "creator") {
756
- record.articles_created = chance.integer({ min: 50, max: 200 });
757
- record.reputation_score = chance.integer({ min: 80, max: 100 });
758
- record.contributor_level = "admin";
759
- } else if (record.role === "moderator") {
760
- record.articles_created = chance.integer({ min: 10, max: 50 });
761
- record.reputation_score = chance.integer({ min: 40, max: 70 });
762
- record.contributor_level = "trusted";
763
- } else if (record.role === "contributor") {
764
- record.articles_created = chance.integer({ min: 1, max: 15 });
765
- record.reputation_score = chance.integer({ min: 15, max: 50 });
766
- record.contributor_level = "regular";
767
- } else {
768
- record.articles_created = 0;
769
- record.reputation_score = chance.integer({ min: 0, max: 20 });
770
- record.contributor_level = "newcomer";
771
- }
772
- }
773
-
774
- // HOOK 9 (T2C): CONTENT CREATION TIME-TO-CONVERT (funnel-post)
775
- // Pro/supporter subscribers complete the Content Creation funnel
776
- // 1.3x faster (factor 0.77); Free 1.25x slower (factor 1.25).
777
- if (type === "funnel-post") {
778
- const segment = meta?.profile?.subscription_tier;
779
- if (Array.isArray(record) && record.length > 1) {
780
- const factor = (
781
- segment === "pro" || segment === "supporter" ? 0.77 :
782
- segment === "free" ? 1.25 :
783
- 1.0
784
- );
785
- if (factor !== 1.0) {
786
- for (let i = 1; i < record.length; i++) {
787
- const prev = dayjs(record[i - 1].time);
788
- const newGap = Math.round(dayjs(record[i].time).diff(prev) * factor);
789
- record[i].time = prev.add(newGap, "milliseconds").toISOString();
790
- }
791
- }
792
- }
793
- }
794
-
795
- // -- EVERYTHING HOOKS -----------------------------------------
796
- if (type === "everything") {
797
- const datasetStart = dayjs.unix(meta.datasetStart);
798
- let events = record;
799
- if (!events.length) return record;
800
- const profile = meta && meta.profile ? meta.profile : {};
801
-
802
- // -- SUPERPROP STAMPING -----------------------------------
803
- // Stamp superProp values from profile onto every event so
804
- // they stay consistent per-user instead of randomizing per-event.
805
- events.forEach(e => {
806
- if (profile.subscription_tier) e.subscription_tier = profile.subscription_tier;
807
- if (profile.Platform) e.Platform = profile.Platform;
808
- if (profile.content_hub) e.content_hub = profile.content_hub;
809
- });
810
-
811
- // HOOK 1: WEEKEND CONTENT SURGE — articles on Sat/Sun get
812
- // word_count 1.5x. Mutates raw prop. No flag.
813
- for (const e of events) {
814
- if (e.event === 'article published' || e.event === 'article viewed') {
815
- const dow = new Date(e.time).getUTCDay();
816
- if ((dow === 0 || dow === 6) && e.word_count) {
817
- e.word_count = Math.floor(e.word_count * 1.5);
818
- }
819
- }
820
- }
821
-
822
- // -- HOOK 2: TRENDING TOPIC WINDOW -------------------------
823
- // Days 35-50: gaming hub articles get 2x view_count.
824
- // Runs after superProp stamping so content_hub is the
825
- // profile's consistent value, not the random event-level one.
826
- const TREND_START = datasetStart.add(35, "days");
827
- const TREND_END = datasetStart.add(50, "days");
828
- if (profile.content_hub === "gaming") {
829
- events.forEach(e => {
830
- if (e.event === "article viewed") {
831
- const eventTime = dayjs(e.time);
832
- if (eventTime.isAfter(TREND_START) && eventTime.isBefore(TREND_END)) {
833
- e.view_count = Math.floor((e.view_count || 50) * 2);
834
- }
835
- }
836
- });
837
- }
838
-
839
- // -- HOOK 8: PRO SUBSCRIBER CONTENT CREATION LIFT ---------
840
- // Free-tier users drop 50% of comment events to widen
841
- // the gap to ~2.0x vs paid subscribers.
842
- if (profile.subscription_tier !== "pro" && profile.subscription_tier !== "supporter") {
843
- events = events.filter(e => {
844
- if (e.event === "comment posted" && chance.bool({ likelihood: 50 })) return false;
845
- return true;
846
- });
847
- }
848
-
849
- // -- HOOK 3: POWER CREATOR ENGAGEMENT LIFT ----------------
850
- // Users with >20 article_published events get 3x upvote_count.
851
- let publishCount = 0;
852
- events.forEach(e => {
853
- if (e.event === "article published") publishCount++;
854
- });
855
-
856
- if (publishCount > 20) {
857
- events.forEach(e => {
858
- if (e.event === "upvote given" && e.upvote_count) {
859
- e.upvote_count = Math.floor(e.upvote_count * 3);
860
- }
861
- });
862
- }
863
-
864
- // -- HOOK 4: DISCUSSION DEPTH BY CONTRIBUTOR TYPE ---------
865
- // Active contributors get cloned comment_posted events.
866
- if (profile.segment === "active_contributor") {
867
- const templateComment = events.find(e => e.event === "comment posted");
868
- if (templateComment) {
869
- const existingComments = events.filter(e => e.event === "comment posted");
870
- existingComments.forEach(c => {
871
- if (chance.bool({ likelihood: 50 })) {
872
- events.push({
873
- ...templateComment,
874
- time: dayjs(c.time).add(chance.integer({ min: 1, max: 120 }), "minutes").toISOString(),
875
- user_id: c.user_id,
876
- is_reply: true,
877
- comment_length: chance.integer({ min: 20, max: 300 }),
878
- });
879
- }
880
- });
881
- }
882
- }
883
-
884
- // -- HOOK 5: EDIT WAR DETECTION ---------------------------
885
- // Users with >5 article_edited events get reduced edit_quality.
886
- const editEvents = events.filter(e => e.event === "article edited");
887
- if (editEvents.length > 5) {
888
- editEvents.forEach(e => {
889
- e.edit_quality = chance.floating({ min: 1.0, max: 2.0, fixed: 1 });
890
- });
891
- }
892
-
893
- // HOOK 6: LURKER CHURN — users with <5 events lose 60% after
894
- // day 10. No flag.
895
- if (events.length < 5 && events.length > 0) {
896
- const firstEventTime = dayjs(events[0].time);
897
- const cutoff = firstEventTime.add(10, "days");
898
- for (let i = events.length - 1; i >= 0; i--) {
899
- if (dayjs(events[i].time).isAfter(cutoff) && chance.bool({ likelihood: 60 })) {
900
- events.splice(i, 1);
901
- }
902
- }
903
- }
904
-
905
- // HOOK 10: ARTICLE-PUBLISHED MAGIC NUMBER (no flags)
906
- // Sweet 2-5 articles published → +35% on upvote_count for
907
- // upvote-given events. Over 6+ → drop 25% of upvote-given events
908
- // (over-publishing dilutes signal). No flag.
909
- const articleCount = events.filter(e => e.event === "article published").length;
910
- if (articleCount >= 2 && articleCount <= 5) {
911
- events.forEach(e => {
912
- if (e.event === "upvote given" && typeof e.upvote_count === "number") {
913
- e.upvote_count = Math.round(e.upvote_count * 1.35);
914
- }
915
- });
916
- } else if (articleCount >= 6) {
917
- for (let i = events.length - 1; i >= 0; i--) {
918
- if (events[i].event === "upvote given" && chance.bool({ likelihood: 25 })) {
919
- events.splice(i, 1);
920
- }
921
- }
922
- }
923
-
924
- return events;
925
- }
926
-
958
+ hook(record, type, meta) {
959
+ if (type === "user") return handleUserHooks(record);
960
+ if (type === "funnel-post") return handleFunnelPostHooks(record, meta);
961
+ if (type === "everything") return handleEverythingHooks(record, meta);
927
962
  return record;
928
963
  },
929
964
  };