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
5 changes: 3 additions & 2 deletions KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,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 @@ -144,10 +144,11 @@ Profiles have **15 achievement badges**. Earned badges appear in a single row, w
| **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!” |
| **git blame** | Have **at least one commit** in the [/dev/null repository](https://github.com/dev-null-sh/dev-null.sh) on GitHub, matched by your GitHub account rather than your handle. “Landed a commit in the /dev/null repo itself. git blame now points at you.” It uses the same contributor list as the About page, cached for an hour, so it can take that hour (and however long GitHub takes to update its counts) to appear after a merge. An earned badge stays while that list is cached; it only locks when the list runs out while GitHub can't be reached, until GitHub answers again. |

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.
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. **Git blame** depends only on GitHub's contributor list, not on anything posted on /dev/null. 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.

Expand Down
5 changes: 5 additions & 0 deletions app/Enums/Achievement.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum Achievement: string
case Luddite = 'luddite';
case ShellShocked = 'shell_shocked';
case SuperSaiyan = 'super_saiyan';
case GitBlame = 'git_blame';

public function label(): string
{
Expand All @@ -40,6 +41,7 @@ public function label(): string
self::Luddite => 'luddite',
self::ShellShocked => 'shell shocked',
self::SuperSaiyan => 'super-saiyan',
self::GitBlame => 'git blame',
};
}

Expand All @@ -61,6 +63,7 @@ public function description(): string
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!',
self::GitBlame => 'Landed a commit in the /dev/null repo itself. git blame now points at you.',
};
}

Expand All @@ -82,6 +85,7 @@ public function icon(): string
self::Luddite => 'bot-off',
self::ShellShocked => 'bomb',
self::SuperSaiyan => 'dragon-ball',
self::GitBlame => 'git-commit-horizontal',
};
}

Expand All @@ -103,6 +107,7 @@ public function target(): int
self::Luddite => 1,
self::ShellShocked => 1,
self::SuperSaiyan => 9000,
self::GitBlame => 1,
};
}
}
9 changes: 9 additions & 0 deletions app/Queries/ContributorsQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public function get(): ?array
], $accounts);
}

/**
* How many commits the user's GitHub account has in the repository, as GitHub counts them, from the same list the
* About page shows. Zero when it has none, or GitHub didn't answer.
*/
public function commits(User $user): int
{
return array_column($this->accounts() ?? [], 'commits', 'github_id')[$user->github_id] ?? 0;
}

/**
* The GitHub accounts behind the contributors. A failed read is kept for a minute, so an outage doesn't send every
* visitor to GitHub.
Expand Down
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 ContributorsQuery $contributors)
{
//
}
Expand Down Expand Up @@ -90,6 +90,7 @@ public function get(User $user, ?User $viewer, ?array $streaks = null): array
$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');
$repositoryCommits = $this->contributors->commits($user);

// XP breakdown: 10 per commit, 15 per streak day, 5 per star received, 5 per reply, 2 per star given
$commitsXp = $commitsCount * 10;
Expand Down Expand Up @@ -188,6 +189,10 @@ public function get(User $user, ?User $viewer, ?array $streaks = null): array
'progress' => min($user->followers()->count(), Achievement::SuperSaiyan->target()),
'target' => Achievement::SuperSaiyan->target(),
],
Achievement::GitBlame->value => [
'progress' => min($repositoryCommits, Achievement::GitBlame->target()),
'target' => Achievement::GitBlame->target(),
],
];

$badges = array_map(function (Achievement $achievement) use ($metrics): array {
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 @@ -5,6 +5,7 @@ import {
Cookie,
FileCode,
Flame,
GitCommitHorizontal,
GitMerge,
Key,
Server,
Expand Down Expand Up @@ -46,6 +47,7 @@ const iconMap: Record<string, React.ComponentType<{ className?: string }>> = {
'bot-off': BotOff,
bomb: Bomb,
'dragon-ball': DragonBallIcon,
'git-commit-horizontal': GitCommitHorizontal,
};

export function AchievementsDialog({
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 @@ -7,6 +7,7 @@ import {
Cookie,
FileCode,
Flame,
GitCommitHorizontal,
GitMerge,
Key,
Server,
Expand Down Expand Up @@ -51,6 +52,7 @@ const iconMap: Record<string, React.ComponentType<{ className?: string }>> = {
'bot-off': BotOff,
bomb: Bomb,
'dragon-ball': DragonBallIcon,
'git-commit-horizontal': GitCommitHorizontal,
};

export function AchievementsShelf({
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Controllers/AboutControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\User;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;

it('renders the about page for guests', function (): void {
Expand Down Expand Up @@ -55,6 +56,7 @@
});

it('leaves the contributors out while GitHub is unreachable', function (): void {
Cache::forget(gitHubContributorsCacheKey());
Http::fake(fn () => throw new ConnectionException('timeout'));

$this->get(route('about.show'))
Expand Down
11 changes: 11 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Client\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Process;
Expand All @@ -30,6 +31,9 @@
Str::createRandomStringsNormally();
Str::createUuidsNormally();
Http::preventStrayRequests();
// Achievements read the repository contributors, so every page that shows them would ask GitHub;
// fakeGitHubContributors() clears this to serve a list instead
Cache::put(gitHubContributorsCacheKey(), []);
Process::preventStrayProcesses();
Sleep::fake();

Expand Down Expand Up @@ -155,13 +159,20 @@ function gitHubContributor(string $login, int $commits, string $type = 'User', ?
return ['login' => $login, 'id' => $id ?? crc32($login), 'contributions' => $commits, 'type' => $type];
}

function gitHubContributorsCacheKey(): string
{
return 'about:contributor-accounts:'.config()->string('services.github.repository');
}

/**
* Serves the contributors of the repository like GitHub does: most commits first, a page at a time.
*
* @param list<array<string, mixed>> $contributors
*/
function fakeGitHubContributors(array $contributors): void
{
Cache::forget(gitHubContributorsCacheKey());

Http::fake(['api.github.com/repos/'.config()->string('services.github.repository').'/contributors*' => function (Request $request) use ($contributors): PromiseInterface {
$perPage = (int) $request['per_page'];

Expand Down
21 changes: 21 additions & 0 deletions tests/Unit/Queries/ContributorsQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

declare(strict_types=1);

use App\Models\User;
use App\Queries\ContributorsQuery;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;

beforeEach(function (): void {
Cache::forget(gitHubContributorsCacheKey());
});

it('lists everyone with a commit, as GitHub counts them', function (): void {
fakeGitHubContributors([gitHubContributor('xHeaven', 187), gitHubContributor('jubianchi', 1)]);

Expand Down Expand Up @@ -131,3 +136,19 @@
expect(resolve(ContributorsQuery::class)->get())->toBe([['login' => 'recovered', 'commits' => 12, 'handle' => null]]);
Http::assertSentCount(3);
});

it('counts the commits of a user by their GitHub account, and none for anyone else', function (): void {
fakeGitHubContributors([gitHubContributor('xHeaven', 187), gitHubContributor('jubianchi', 1)]);
$query = resolve(ContributorsQuery::class);

expect($query->commits(User::factory()->make(['github_id' => (string) crc32('jubianchi')])))->toBe(1)
->and($query->commits(User::factory()->make(['handle' => 'xHeaven'])))->toBe(0);

Http::assertSentCount(1);
});

it('counts no commits while GitHub does not answer', function (): void {
Http::fake(['api.github.com/*' => Http::response(status: 500)]);

expect(resolve(ContributorsQuery::class)->commits(User::factory()->make(['github_id' => (string) crc32('xHeaven')])))->toBe(0);
});
35 changes: 34 additions & 1 deletion tests/Unit/Queries/UserAchievementsQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use App\Models\SshKey;
use App\Models\User;
use App\Queries\UserAchievementsQuery;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;

beforeEach(function (): void {
$this->travelTo(now()->setDate(2026, 10, 22)->setTime(12, 0));
Expand All @@ -28,7 +30,7 @@
->and($result['ranks'])->toHaveCount(6)
->and($result['xp_breakdown']['commits']['xp'])->toBe(0)
->and($result['xp_breakdown']['shell_shocked']['xp'])->toBe(0)
->and($result['badges'])->toHaveCount(15);
->and($result['badges'])->toHaveCount(16);

foreach ($result['badges'] as $badge) {
expect($badge['unlocked'])->toBeFalse()
Expand Down Expand Up @@ -360,3 +362,34 @@
'exactly at cutoff' => ['2026-10-21 14:00:00', false, 0, 1],
'just after cutoff' => ['2026-10-21 14:00:01', false, 0, 1],
]);

it('unlocks git blame with a commit in the /dev/null repository, matching the GitHub account', function (): void {
$contributor = User::factory()->create(['github_id' => (string) crc32('xHeaven'), 'handle' => 'renamed']);
$other = User::factory()->create(['handle' => 'xHeaven']);
fakeGitHubContributors([gitHubContributor('xHeaven', 187)]);

$query = resolve(UserAchievementsQuery::class);
$result = $query->get($contributor, null);

expect(collect($result['badges'])->firstWhere('id', 'git_blame'))->toBe([
'id' => 'git_blame',
'name' => 'git blame',
'description' => 'Landed a commit in the /dev/null repo itself. git blame now points at you.',
'icon' => 'git-commit-horizontal',
'unlocked' => true,
'progress' => 1,
'target' => 1,
])->and($result['xp'])->toBe(0)
->and(collect($query->get($other, null)['badges'])->firstWhere('id', 'git_blame')['unlocked'])->toBeFalse();
});

it('keeps git blame locked while GitHub does not answer', function (): void {
$user = User::factory()->create(['github_id' => (string) crc32('xHeaven')]);
Cache::forget(gitHubContributorsCacheKey());
Http::fake(['api.github.com/*' => Http::response(status: 500)]);

$badge = collect(resolve(UserAchievementsQuery::class)->get($user, null)['badges'])->firstWhere('id', 'git_blame');

expect($badge['unlocked'])->toBeFalse()
->and($badge['progress'])->toBe(0);
});
Loading