Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Sources: [go-live menu](resources/js/components/profile-actions-menu.tsx), [live

### Achievement badges and XP

Profiles have **15 achievement badges**. Earned badges appear in a single row, with **+N more** when more have been earned than fit. Hover over the row on desktop or tap it on mobile to toggle a popover with every badge, including locked badges and their progress. Profiles with no earned badges show **View achievements** instead. Select a badge in the popover, or the profile's rank or unlocked count, to open the detailed achievements dialog.
Profiles have **16 achievement badges**. Earned badges appear in a single row, with **+N more** when more have been earned than fit. Hover over the row on desktop or tap it on mobile to toggle a popover with every badge, including locked badges and their progress. Profiles with no earned badges show **View achievements** instead. Select a badge in the popover, or the profile's rank or unlocked count, to open the detailed achievements dialog.

| Badge | When it unlocks |
| --- | --- |
Expand All @@ -131,17 +131,20 @@ Profiles have **15 achievement badges**. Earned badges appear in a single row, w
| **pipe** | Write **5 replies to other developers' commits**, excluding self-replies. Replies still count when their parent commit is soft-deleted. |
| **authorized_keys** | Have at least one public SSH key linked from GitHub. |
| **sweet tooth** | Receive **100 pastéis across your account**, not on a single commit. Pastéis mode does not need to be enabled, and the total survives deletion of the awarded commits. |
| **contributor** | Get a contribution merged into the /dev/null source code, whether a feature, bug fix, documentation, or another change. |
| **luddite** | Stop following Tom while he still follows you. This deducts **100 XP**; following him again removes the badge and penalty. Accounts Tom has never befriended do not qualify. |
| **shell shocked** | “Survived the php2shell downtime of Oct '26. Earns 100 XP.” — accounts created before **October 21, 2026 at 14:00 UTC** receive this badge and **100 bonus XP**. Accounts created at or after that moment do not qualify. |
| **super-saiyan** | Have **9,000 followers or more** on /dev/null. “Y—your follower count. It... it’s over 9000!!!1!” |

Commit counts include replies and quotes. Commit-based badges and XP use non-deleted commits visible to the person viewing the profile, so an author may see progress from pending or rejected commits that other viewers cannot see. Streak badges use the **longest** streak, not the current streak: missing a day does not by itself remove them. Days follow the activity graph's app-timezone grouping, not the user's selected display timezone.

Badges are calculated from current account data, not permanently recorded awards. Removing qualifying activity can reduce progress or lock a badge again; for example, unstarring a commit can remove **stargazer**. **Shell shocked** depends only on when the account was created, so deleting activity does not remove it. When a commit posted on the web unlocks a badge, a toast names it and confetti drops; clicking an unlocked badge drops confetti again. Unlocking a badge does not normally give bonus XP; **shell shocked** contributes **100 XP** once. XP otherwise comes from **10 per commit**, **15 per day in the longest streak**, **5 per star received**, **5 per reply to another developer**, and **2 per star given to another developer**. The **luddite** penalty applies once while the badge is unlocked, not once per unfollow, and total XP cannot fall below zero. A qualifying reply contributes both commit XP and reply XP; pastéis do not add XP.
The **contributor** badge unlocks when GitHub credits at least one contribution to your account on the **production** branch of **dev-null-sh/dev-null.sh**, the repository /dev/null is built from: one per Git commit on that branch, so a squash-merged pull request counts once. Accounts are matched by numeric GitHub ID, not username, so renaming your account keeps your progress. The contributor list is read hourly, so a merge can take up to an hour to show; until the first read, every account shows zero. If GitHub keeps failing, the last list is kept for up to a day, and only the top 1,000 contributors GitHub lists are read. This badge adds no XP, and since no post unlocks it, unlocking it shows no toast or confetti. Tom's top-ten contributor tool is a separate GitHub read.

Badges are calculated from current account data, not permanently recorded awards; the contributor badge uses the last contributor list read from GitHub. Removing qualifying activity can reduce progress or lock a badge again; for example, unstarring a commit can remove **stargazer**. **Shell shocked** depends only on when the account was created, so deleting activity does not remove it. When a commit posted on the web unlocks a badge, a toast names it and confetti drops; clicking an unlocked badge drops confetti again. Unlocking a badge does not normally give bonus XP; **shell shocked** contributes **100 XP** once. XP otherwise comes from **10 per commit**, **15 per day in the longest streak**, **5 per star received**, **5 per reply to another developer**, and **2 per star given to another developer**. The **luddite** penalty applies once while the badge is unlocked, not once per unfollow, and total XP cannot fall below zero. A qualifying reply contributes both commit XP and reply XP; pastéis do not add XP.

XP also determines your Unix rank: **user** at 0 XP, **daemon** at 50, **operator** at 150, **maintainer** at 400, **wheel** at 1,000, and **root** at 2,500. The achievements dialog's **Ranks** tab shows the levels and progress. Level-up notifications use your public progress, so pending or rejected commits do not trigger them. Each level above the starting rank can notify you only once, even if you lose and regain the XP; jumping ahead does not send a notification for every skipped level.

Sources: [badge definitions](app/Enums/Achievement.php), [unlock conditions and XP calculation](app/Queries/UserAchievementsQuery.php), [streak calculation](app/Queries/UserStreakQuery.php), [Unix ranks](app/Enums/UnixRank.php), [level-up notifications](app/Actions/CreateLevelNotification.php), [achievements dialog](resources/js/components/achievements-dialog.tsx).
Sources: [badge definitions](app/Enums/Achievement.php), [unlock conditions and XP calculation](app/Queries/UserAchievementsQuery.php), [streak calculation](app/Queries/UserStreakQuery.php), [contributor counts](app/Queries/UpstreamContributionsQuery.php), [contributor sync](app/Jobs/SyncUpstreamContributions.php), [Unix ranks](app/Enums/UnixRank.php), [level-up notifications](app/Actions/CreateLevelNotification.php), [achievements dialog](resources/js/components/achievements-dialog.tsx).

### Following developers and suggestions

Expand Down
5 changes: 5 additions & 0 deletions app/Enums/Achievement.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum Achievement: string
case Pipe = 'pipe';
case AuthorizedKeys = 'authorized_keys';
case SweetTooth = 'sweet_tooth';
case Contributor = 'contributor';
case Luddite = 'luddite';
case ShellShocked = 'shell_shocked';
case SuperSaiyan = 'super_saiyan';
Expand All @@ -37,6 +38,7 @@ public function label(): string
self::Pipe => 'pipe',
self::AuthorizedKeys => 'authorized_keys',
self::SweetTooth => 'sweet tooth',
self::Contributor => 'contributor',
self::Luddite => 'luddite',
self::ShellShocked => 'shell shocked',
self::SuperSaiyan => 'super-saiyan',
Expand All @@ -58,6 +60,7 @@ public function description(): string
self::Pipe => 'Joined conversations with 5 replies to other developers.',
self::AuthorizedKeys => 'Provisioned a public SSH key from GitHub.',
self::SweetTooth => 'Received 100 pastéis across your account.',
self::Contributor => 'Contributed to the /dev/null source code.',
self::Luddite => 'Unfollowed Tom. Costs 100 XP until you follow him again.',
self::ShellShocked => "Survived the php2shell downtime of Oct '26. Earns 100 XP.",
self::SuperSaiyan => 'Y—your follower count. It... it’s over 9000!!!1!',
Expand All @@ -79,6 +82,7 @@ public function icon(): string
self::Pipe => 'git-merge',
self::AuthorizedKeys => 'key',
self::SweetTooth => 'cookie',
self::Contributor => 'git-pull-request',
self::Luddite => 'bot-off',
self::ShellShocked => 'bomb',
self::SuperSaiyan => 'dragon-ball',
Expand All @@ -100,6 +104,7 @@ public function target(): int
self::Pipe => 5,
self::AuthorizedKeys => 1,
self::SweetTooth => 100,
self::Contributor => 1,
self::Luddite => 1,
self::ShellShocked => 1,
self::SuperSaiyan => 9000,
Expand Down
69 changes: 69 additions & 0 deletions app/Jobs/SyncUpstreamContributions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

declare(strict_types=1);

namespace App\Jobs;

use App\Queries\UpstreamContributionsQuery;
use App\Services\GitHub;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Queue\Attributes\Backoff;
use Illuminate\Queue\Attributes\Timeout;
use Illuminate\Queue\Attributes\Tries;
use Illuminate\Queue\Attributes\UniqueFor;
use Illuminate\Support\Facades\Cache;
use RuntimeException;

#[Backoff([60, 600])]
#[Timeout(120)]
#[Tries(3)]
#[UniqueFor(3600)]
final class SyncUpstreamContributions implements ShouldBeUnique, ShouldQueue
{
use Queueable;

private const int PerPage = 100;

private const int MaxPages = 10;

/**
* Reads the contributor list page by page. A failed read throws before the map is stored, so an outage never
* hides the badges and the retry fills the map again.
*/
public function handle(GitHub $github): void
{
/** @var array<int|string, int> $contributions */
$contributions = [];
$repository = config()->string('services.github.repository');

for ($page = 1; $page <= self::MaxPages; $page++) {
$body = $github->request()
->get("repos/{$repository}/contributors", ['per_page' => self::PerPage, 'page' => $page])
->throw()
->json();

throw_if(! is_array($body) || ! array_is_list($body), RuntimeException::class, 'GitHub returned an unexpected contributor list.');

throw_if($page === 1 && $body === [], RuntimeException::class, 'GitHub returned an empty contributor list.');

/** @var list<array{id?: int, type?: string, contributions?: int}> $contributors */
$contributors = $body;

foreach ($contributors as $contributor) {
if (($contributor['type'] ?? null) !== 'User' || ! isset($contributor['id'], $contributor['contributions'])) {
continue;
}

$contributions[$contributor['id']] = $contributor['contributions'];
}

if (count($contributors) < self::PerPage) {
break;
}
}

Cache::put(UpstreamContributionsQuery::CacheKey, $contributions, now()->addDay());
}
}
25 changes: 25 additions & 0 deletions app/Queries/UpstreamContributionsQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace App\Queries;

use App\Models\User;
use Illuminate\Support\Facades\Cache;

final readonly class UpstreamContributionsQuery
{
public const string CacheKey = 'upstream:contributions';

/**
* The changes GitHub counts for the developer on the source repository's production branch, matched by the
* immutable account ID so a rename keeps the progress. Nothing cached yet means none.
*/
public function countFor(User $user): int
{
/** @var array<int|string, int> $contributions */
$contributions = Cache::memo()->get(self::CacheKey, []);

return $contributions[$user->github_id] ?? 0;
}
}
7 changes: 6 additions & 1 deletion app/Queries/UserAchievementsQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
final readonly class UserAchievementsQuery
{
public function __construct(private UserStreakQuery $streaks)
public function __construct(private UserStreakQuery $streaks, private UpstreamContributionsQuery $contributions)
{
//
}
Expand Down Expand Up @@ -87,6 +87,7 @@ public function get(User $user, ?User $viewer, ?array $streaks = null): array

$longestStreak = ($streaks ?? $this->streaks->get($user, $viewer))['longest'];
$hasSshKey = $user->sshKeys()->exists();
$upstreamContributions = $this->contributions->countFor($user);
$hasUnfollowedTom = $user->followers()->where('github_id', CreateTomFriendship::GITHUB_ID)->exists()
&& ! $user->following()->where('github_id', CreateTomFriendship::GITHUB_ID)->exists();
$isShellShocked = $user->created_at->lt('2026-10-21 14:00:00 UTC');
Expand Down Expand Up @@ -176,6 +177,10 @@ public function get(User $user, ?User $viewer, ?array $streaks = null): array
'progress' => min($user->pasteis_received, Achievement::SweetTooth->target()),
'target' => Achievement::SweetTooth->target(),
],
Achievement::Contributor->value => [
'progress' => min($upstreamContributions, Achievement::Contributor->target()),
'target' => Achievement::Contributor->target(),
],
Achievement::Luddite->value => [
'progress' => $hasUnfollowedTom ? 1 : 0,
'target' => Achievement::Luddite->target(),
Expand Down
2 changes: 2 additions & 0 deletions resources/js/components/achievements-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
FileCode,
Flame,
GitMerge,
GitPullRequest,
Key,
Server,
Shield,
Expand Down Expand Up @@ -41,6 +42,7 @@ const iconMap: Record<string, React.ComponentType<{ className?: string }>> = {
star: Star,
sparkles: Sparkles,
'git-merge': GitMerge,
'git-pull-request': GitPullRequest,
key: Key,
cookie: Cookie,
'bot-off': BotOff,
Expand Down
2 changes: 2 additions & 0 deletions resources/js/components/achievements-shelf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
FileCode,
Flame,
GitMerge,
GitPullRequest,
Key,
Server,
Shield,
Expand Down Expand Up @@ -46,6 +47,7 @@ const iconMap: Record<string, React.ComponentType<{ className?: string }>> = {
star: Star,
sparkles: Sparkles,
'git-merge': GitMerge,
'git-pull-request': GitPullRequest,
key: Key,
cookie: Cookie,
'bot-off': BotOff,
Expand Down
2 changes: 2 additions & 0 deletions routes/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

use App\Jobs\EmbedKnowledgeBase;
use App\Jobs\EndLiveStreams;
use App\Jobs\SyncUpstreamContributions;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schedule;

Schedule::command('commits:submit-scheduled')->everyMinute()->withoutOverlapping(5);
Schedule::job(new EmbedKnowledgeBase())->hourly();
Schedule::job(new SyncUpstreamContributions())->hourly();
Schedule::job(new EndLiveStreams())->everyFiveMinutes();

Schedule::call(function (): void {
Expand Down
Loading