commit
initial commit
diff --git a/.env.example b/.env.example
new file mode 100644
index 0000000..221dad9
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,33 @@
+# .env.example
+# MIT — (c) Doughmination System®
+# Copy to .env and fill in. In production it lives next to the build (see deploy/run).
+
+# GitHub token for your own account, with pull request read and write on the repository
+GITHUB_TOKEN=
+
+GITHUB_REPO_OWNER=is-a-dev
+GITHUB_REPO_NAME=register
+
+# Discord bot token, and your own Discord user id (the only id allowed to press buttons)
+DISCORD_BOT_TOKEN=
+DISCORD_USER_ID=
+
+# Optional: post in this channel instead of a direct message
+DISCORD_CHANNEL_ID=
+
+# Dry run is ON unless this is set to false. While ON, nothing is sent to GitHub.
+DRY_RUN=true
+
+# Required outside the dev server
+DASHBOARD_PASSWORD=
+
+# The public address of the dashboard, needed for form posts in production
+ORIGIN=http://localhost:3101
+
+# Optional tuning
+POLL_INTERVAL_SECONDS=120
+SCANNER_ENABLED=true
+DATABASE_PATH=data/tracker.sqlite
+MESSAGES_PATH=config/messages.json
+NS_MIN_MERGED_PRS=1
+MAX_FILES_PER_PR=25
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b553711
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,26 @@
+node_modules
+
+# Output
+.output
+.vercel
+.netlify
+.wrangler
+/.svelte-kit
+/build
+
+# OS
+.DS_Store
+Thumbs.db
+
+# Env
+.env
+.env.*
+!.env.example
+!.env.test
+
+# Vite
+vite.config.js.timestamp-*
+vite.config.ts.timestamp-*
+
+# Local database
+/data
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 0000000..b6f27f1
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+engine-strict=true
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..7d74fe2
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,9 @@
+# Package Managers
+package-lock.json
+pnpm-lock.yaml
+yarn.lock
+bun.lock
+bun.lockb
+
+# Miscellaneous
+/static/
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b220269
--- /dev/null
+++ b/README.md
@@ -0,0 +1,78 @@
+# is-a-tracker
+
+A personal moderation assistant for pull requests on `is-a-dev/register`.
+
+It detects two violations, pings you on Discord, and acts **only** when you press a button.
+
+| Violation | Button | What the button does |
+| ------------------------------------------ | --------------- | ---------------------------------------------------- |
+| NS records from a first-time contributor | Close PR | Posts the policy comment, then closes the PR |
+| `owner.email` is a GitHub no-reply address | Request Changes | Submits a review with an inline comment on that line |
+
+One Deno process runs the scanner, the Discord bot, and the SvelteKit dashboard. They share one SQLite file.
+
+## Setup
+
+1. Copy the example settings: `cp .env.example .env`
+2. Fill in `GITHUB_TOKEN`, `DISCORD_BOT_TOKEN`, `DISCORD_USER_ID` and `DASHBOARD_PASSWORD`
+3. Install: `deno install`
+4. Develop: `deno task dev`
+5. Or run for real: `deno task build`, then `deno task start`
+
+### GitHub token
+
+- Needs **Pull requests: Read and write** on `is-a-dev/register`.
+- A fine-grained token only works if the `is-a-dev` organisation lets you select the repository.
+ If it does not appear in the list, use a classic token with the `public_repo` scope instead.
+
+### Discord bot
+
+1. Create an application at <https://discord.com/developers/applications> and add a bot.
+2. Copy the bot token into `DISCORD_BOT_TOKEN`. No privileged intents are needed.
+3. Invite the bot to any server you are in. Direct messages need one shared server.
+4. Put your own user id in `DISCORD_USER_ID`. Only that id can press the buttons.
+
+The bot uses the Gateway, so nothing needs to be exposed to the internet.
+
+## Dry run
+
+`DRY_RUN` is **on by default**. While it is on, buttons revalidate the PR and report what they
+would have done, and nothing is sent to GitHub. Set `DRY_RUN=false` once you trust what you see.
+
+## Wording
+
+Edit `config/messages.json`. Changes apply on the next action, with no restart.
+
+## How it stays safe
+
+- Every action revalidates the PR at its latest commit first.
+- A finding can only be claimed once, so two clicks never post twice.
+- Writes to GitHub are never retried automatically.
+- Statistics count successful actions only. Every attempt lands in the audit log.
+- The scanner keeps a reserve of the GitHub rate limit free for your approved actions.
+
+## Adding a rule
+
+1. Add a module in `src/lib/server/rules/` that exports a `Rule`.
+2. Register it in `src/lib/server/rules/index.ts`.
+3. If it needs a new kind of action, add an executor in `src/lib/server/moderation/executors.ts`.
+
+## Checks
+
+```sh
+deno task test
+deno task check
+deno task lint
+```
+
+## Deploying
+
+The `deploy` folder is a runit service, laid out like the one in the `web` project.
+
+- `deploy/run` starts the built app as `clove` from `/srv/clove/is-a-tracker` on port 3101.
+- `deploy/log/run` sends its output to `/var/log/is-a-tracker` through `svlogd`.
+
+The server folder needs `build/`, `node_modules/`, `config/`, `package.json` and `.env`.
+It also needs a `data/` folder that `clove` can write to; the SQLite file lives there.
+
+Set `ORIGIN` in the server's `.env` to the dashboard's public address.
diff --git a/config/messages.json b/config/messages.json
new file mode 100644
index 0000000..976f5b2
--- /dev/null
+++ b/config/messages.json
@@ -0,0 +1,9 @@
+{
+ "nsRecords": {
+ "closeComment": "Thanks for your interest in is-a.dev!\n\nThis pull request requests `NS` records. We do not grant nameserver records to first-time contributors, so I am closing this pull request.\n\nYou are welcome to open a new pull request using other record types, such as `A`, `AAAA`, `CNAME`, `MX` or `TXT`. Once you have an accepted registration, you can request `NS` records with a clear justification for why they are needed."
+ },
+ "noReplyEmail": {
+ "reviewComment": "Your `owner.email` value is a GitHub no-reply email address. We do not allow these on our service. Please update it to a personal email address or remove the `owner.email` field entirely, as it is optional.",
+ "reviewSummary": "Please see the inline comment on `owner.email`."
+ }
+}
diff --git a/deno.lock b/deno.lock
new file mode 100644
index 0000000..b8358b4
--- /dev/null
+++ b/deno.lock
@@ -0,0 +1,1344 @@
+{
+ "version": "5",
+ "specifiers": {
+ "npm:@eslint/js@^10.0.1": "[email protected]",
+ "npm:@sveltejs/adapter-node@^6.0.2": "6.0.2_@[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]",
+ "npm:@sveltejs/kit@3": "3.2.0_@[email protected][email protected][email protected][email protected]_@[email protected]",
+ "npm:@sveltejs/vite-plugin-svelte@^7.2.0": "[email protected][email protected]_@[email protected]",
+ "npm:@types/node@26": "26.6.6",
+ "npm:discord.js@^14.28.1": "14.28.1",
+ "npm:eslint-config-prettier@^10.1.8": "[email protected]",
+ "npm:eslint-plugin-svelte@^3.19.0": "[email protected][email protected]",
+ "npm:eslint@^10.4.1": "10.14.0",
+ "npm:globals@^17.6.0": "17.14.0",
+ "npm:prettier-plugin-svelte@^4.1.0": "[email protected][email protected]",
+ "npm:prettier@^3.8.3": "3.10.0",
+ "npm:svelte-check@^4.6.0": "[email protected][email protected]",
+ "npm:svelte@^5.57.2": "5.57.3",
+ "npm:typescript-eslint@^8.60.1": "[email protected][email protected]",
+ "npm:typescript@^6.0.3": "6.0.3",
+ "npm:vite@^8.3.0": "8.3.8_@[email protected]"
+ },
+ "npm": {
+ "@cacheable/[email protected]": {
+ "integrity": "sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==",
+ "dependencies": [
+ "@cacheable/utils",
+ "@keyv/bigmap",
+ "[email protected]",
+ "keyv"
+ ]
+ },
+ "@cacheable/[email protected]": {
+ "integrity": "sha512-buipgOVDkkPXNR5+xBpDw7Zk2n1EvU7qBJCNUcL7rhQ//kfpOXPAvQ511Os0vpLYJ1pZnvudNytkQt2hst3wqA==",
+ "dependencies": [
+ "hashery",
+ "keyv"
+ ]
+ },
+ "@discordjs/[email protected]": {
+ "integrity": "sha512-AifaDWTw6WUDhKBn8E6mwwoyjDAcfsYq+ZE0nKSu1dMH1NLR22D3hGkNx+ctEv8NqHEHdAZnP5REteHDmn1lkA==",
+ "dependencies": [
+ "@discordjs/formatters",
+ "@discordjs/util",
+ "@sapphire/shapeshift",
+ "discord-api-types",
+ "fast-deep-equal",
+ "ts-mixer",
+ "tslib"
+ ]
+ },
+ "@discordjs/[email protected]": {
+ "integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ=="
+ },
+ "@discordjs/[email protected]": {
+ "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg=="
+ },
+ "@discordjs/[email protected]": {
+ "integrity": "sha512-y4UPwWhH6vChKRkGdMB4odasUbHOUwy7KL+OVwF86PvT6QVOwElx+TiI1/6kcmcEe+g5YRXJFiXSXUdabqZOvQ==",
+ "dependencies": [
+ "discord-api-types"
+ ]
+ },
+ "@discordjs/[email protected]": {
+ "integrity": "sha512-wvOylxNYJkwKjctS/Mn5GP1w9r3/rzyH+ThD1JlAca6zEdlHs8QWBBUQJpU5Q+W6DoIj/Ljh1IPlZs7hTU+UAg==",
+ "dependencies": [
+ "@discordjs/[email protected]",
+ "@discordjs/util",
+ "@sapphire/async-queue",
+ "@sapphire/snowflake",
+ "@vladfrangu/async_event_emitter",
+ "discord-api-types",
+ "magic-bytes.js",
+ "tslib",
+ "undici"
+ ]
+ },
+ "@discordjs/[email protected]": {
+ "integrity": "sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==",
+ "dependencies": [
+ "discord-api-types"
+ ]
+ },
+ "@discordjs/[email protected]": {
+ "integrity": "sha512-wPlQDxEmlDg5IxhJPuxXr3Vy9AjYq5xCvFWGJyD7w7Np8ZGu+Mc+97LCoEc/+AYCo2IDpKioiH0/c/mj5ZR9Uw==",
+ "dependencies": [
+ "@discordjs/[email protected]",
+ "@discordjs/rest",
+ "@discordjs/util",
+ "@sapphire/async-queue",
+ "@types/ws",
+ "@vladfrangu/async_event_emitter",
+ "discord-api-types",
+ "tslib",
+ "ws"
+ ]
+ },
+ "@emnapi/[email protected]": {
+ "integrity": "sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==",
+ "dependencies": [
+ "@emnapi/wasi-threads",
+ "tslib"
+ ]
+ },
+ "@emnapi/[email protected]": {
+ "integrity": "sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==",
+ "dependencies": [
+ "tslib"
+ ]
+ },
+ "@emnapi/[email protected]": {
+ "integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==",
+ "dependencies": [
+ "tslib"
+ ]
+ },
+ "@eslint-community/[email protected][email protected]": {
+ "integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==",
+ "dependencies": [
+ "eslint",
+ "[email protected]"
+ ]
+ },
+ "@eslint-community/[email protected]": {
+ "integrity": "sha512-R76UKbvsqI68DJJVTVyqFKqU98CN4+B+acxNfEA2IFarSzP0SjtKf/3+fFiXzTyv5Fj3PxLkGHe2wnVWWMxobQ=="
+ },
+ "@eslint/[email protected]": {
+ "integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==",
+ "dependencies": [
+ "@eslint/object-schema",
+ "debug",
+ "minimatch"
+ ]
+ },
+ "@eslint/[email protected]": {
+ "integrity": "sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==",
+ "dependencies": [
+ "@eslint/core"
+ ]
+ },
+ "@eslint/[email protected]": {
+ "integrity": "sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==",
+ "dependencies": [
+ "@types/json-schema"
+ ]
+ },
+ "@eslint/[email protected][email protected]": {
+ "integrity": "sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==",
+ "dependencies": [
+ "eslint"
+ ],
+ "optionalPeers": [
+ "eslint"
+ ]
+ },
+ "@eslint/[email protected]": {
+ "integrity": "sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw=="
+ },
+ "@eslint/[email protected]": {
+ "integrity": "sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==",
+ "dependencies": [
+ "@eslint/core",
+ "levn"
+ ]
+ },
+ "@humanfs/[email protected]": {
+ "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==",
+ "dependencies": [
+ "@humanfs/types"
+ ]
+ },
+ "@humanfs/[email protected]": {
+ "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==",
+ "dependencies": [
+ "@humanfs/core",
+ "@humanfs/types",
+ "@humanwhocodes/retry"
+ ]
+ },
+ "@humanfs/[email protected]": {
+ "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q=="
+ },
+ "@humanwhocodes/[email protected]": {
+ "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA=="
+ },
+ "@humanwhocodes/[email protected]": {
+ "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ=="
+ },
+ "@jridgewell/[email protected]": {
+ "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
+ "dependencies": [
+ "@jridgewell/sourcemap-codec",
+ "@jridgewell/trace-mapping"
+ ]
+ },
+ "@jridgewell/[email protected]": {
+ "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",
+ "dependencies": [
+ "@jridgewell/gen-mapping",
+ "@jridgewell/trace-mapping"
+ ]
+ },
+ "@jridgewell/[email protected]": {
+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="
+ },
+ "@jridgewell/[email protected]": {
+ "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw=="
+ },
+ "@jridgewell/[email protected]": {
+ "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
+ "dependencies": [
+ "@jridgewell/resolve-uri",
+ "@jridgewell/sourcemap-codec"
+ ]
+ },
+ "@keyv/[email protected][email protected]": {
+ "integrity": "sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==",
+ "dependencies": [
+ "hashery",
+ "[email protected]",
+ "keyv"
+ ]
+ },
+ "@keyv/[email protected]": {
+ "integrity": "sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA=="
+ },
+ "@napi-rs/[email protected]_@[email protected]_@[email protected]": {
+ "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==",
+ "dependencies": [
+ "@emnapi/core",
+ "@emnapi/runtime",
+ "@tybys/wasm-util"
+ ]
+ },
+ "@oxc-project/[email protected]": {
+ "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw=="
+ },
+ "@polka/[email protected]": {
+ "integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww=="
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==",
+ "os": ["android"],
+ "cpu": ["arm"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==",
+ "os": ["android"],
+ "cpu": ["arm64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==",
+ "os": ["darwin"],
+ "cpu": ["arm64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==",
+ "os": ["darwin"],
+ "cpu": ["x64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==",
+ "os": ["freebsd"],
+ "cpu": ["x64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==",
+ "os": ["linux"],
+ "cpu": ["arm"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==",
+ "os": ["linux"],
+ "cpu": ["arm64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==",
+ "os": ["linux"],
+ "cpu": ["arm64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==",
+ "os": ["linux"],
+ "cpu": ["ppc64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==",
+ "os": ["linux"],
+ "cpu": ["s390x"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==",
+ "os": ["linux"],
+ "cpu": ["x64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==",
+ "os": ["linux"],
+ "cpu": ["x64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==",
+ "os": ["openharmony"],
+ "cpu": ["arm64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==",
+ "dependencies": [
+ "@emnapi/core",
+ "@emnapi/runtime",
+ "@napi-rs/wasm-runtime"
+ ],
+ "cpu": ["wasm32"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==",
+ "os": ["win32"],
+ "cpu": ["arm64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==",
+ "os": ["win32"],
+ "cpu": ["x64"]
+ },
+ "@rolldown/[email protected]": {
+ "integrity": "sha512-K+NU2HDCEem4sClgHH4ZZXwdJeNFkJo+hRk479DIwdIviAPN2hFJH1KHHwg8CxHQXvi0M5XY4deTXINfIiSG6w=="
+ },
+ "@sapphire/[email protected]": {
+ "integrity": "sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg=="
+ },
+ "@sapphire/[email protected]": {
+ "integrity": "sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==",
+ "dependencies": [
+ "fast-deep-equal",
+ "lodash"
+ ]
+ },
+ "@sapphire/[email protected]": {
+ "integrity": "sha512-xzvBr1Q1c4lCe7i6sRnrofxeO1QTP/LKQ6A6qy0iB4x5yfiSfARMEQEghojzTNALDTcv8En04qYNIco9/K9eZQ=="
+ },
+ "@standard-schema/[email protected]": {
+ "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="
+ },
+ "@sveltejs/[email protected][email protected]": {
+ "integrity": "sha512-wgKggnhZVL9Bfx1OaKKTrYY9BFRk6C8UAkQNUcIv1+llzYrIqy+RZm5HPKzn0NpEBvTVhTqB4kQyllZywsRBRQ==",
+ "dependencies": [
+ "acorn"
+ ]
+ },
+ "@sveltejs/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]": {
+ "integrity": "sha512-LDCgko3cG727+fpiq0UzveID0MAG0DQ/+FOxpB9Ne0iCvUGslVtN+6irg+pXGDf+rZdW2k9UQB75tXmmDa0BfQ==",
+ "dependencies": [
+ "@sveltejs/kit"
+ ]
+ },
+ "@sveltejs/[email protected]_@[email protected][email protected][email protected][email protected]_@[email protected]": {
+ "integrity": "sha512-zhb8GTeFd/6BwfqaY4wKIF7eFACYOgn/KNppV6UHFBHk174B4d7xTtN7x0PxaPPlwnCTgbnpaYF6r9lirz0Biw==",
+ "dependencies": [
+ "@jridgewell/trace-mapping",
+ "@rolldown/pluginutils",
+ "@standard-schema/spec",
+ "@sveltejs/vite-plugin-svelte",
+ "cookie",
+ "devalue",
+ "esm-env",
+ "[email protected]",
+ "mrmime",
+ "sirv",
+ "svelte",
+ "typescript",
+ "vite"
+ ],
+ "optionalPeers": [
+ "typescript"
+ ],
+ "bin": true
+ },
+ "@sveltejs/[email protected]": {
+ "integrity": "sha512-VT3qmUb8pRV2QrZjd8iAmtg8lf4W0TIjZbvXtz5MKei/q96teWZgGJyyidJzOjzZzvdq616eSRVeMYIQChUTAQ=="
+ },
+ "@sveltejs/[email protected][email protected][email protected]_@[email protected]": {
+ "integrity": "sha512-ZPsLN8B1e/En+Ak5s4V7srFDT532oS0qieLsQwu63NGKsS+iAjoO2Js1BochlHlglcU+Pt7WAO3C5Ee+4f6gVA==",
+ "dependencies": [
+ "deepmerge",
+ "[email protected]",
+ "obug",
+ "svelte",
+ "vite",
+ "vitefu"
+ ]
+ },
+ "@tybys/[email protected]": {
+ "integrity": "sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==",
+ "dependencies": [
+ "tslib"
+ ]
+ },
+ "@types/[email protected]": {
+ "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw=="
+ },
+ "@types/[email protected]": {
+ "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g=="
+ },
+ "@types/[email protected]": {
+ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA=="
+ },
+ "@types/[email protected]": {
+ "integrity": "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==",
+ "dependencies": [
+ "undici-types"
+ ]
+ },
+ "@types/[email protected]": {
+ "integrity": "sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w==",
+ "dependencies": [
+ "@types/node"
+ ]
+ },
+ "@typescript-eslint/[email protected]_@[email protected][email protected][email protected]": {
+ "integrity": "sha512-222PKFXKihmFpi/pS5njoBgdAqsPhj2/GBmFbrNw8Tq8gEG9Sv+kSlKFy4u2q+mJv9ZzJgM2Gkv/bUzRZwZw5g==",
+ "dependencies": [
+ "@eslint-community/regexpp",
+ "@typescript-eslint/parser",
+ "@typescript-eslint/scope-manager",
+ "@typescript-eslint/type-utils",
+ "@typescript-eslint/utils",
+ "@typescript-eslint/visitor-keys",
+ "eslint",
+ "[email protected]",
+ "natural-compare",
+ "ts-api-utils",
+ "typescript"
+ ]
+ },
+ "@typescript-eslint/[email protected][email protected][email protected]": {
+ "integrity": "sha512-llP+T1YuJOLlxEciP6OyQGtz5SMxyn+9LA2BvZw5RmToGVa1y4beEDVQL6Gje7T5WFYh19WREjDCN9Ev4gm5AA==",
+ "dependencies": [
+ "@typescript-eslint/scope-manager",
+ "@typescript-eslint/types",
+ "@typescript-eslint/typescript-estree",
+ "@typescript-eslint/visitor-keys",
+ "debug",
+ "eslint",
+ "typescript"
+ ]
+ },
+ "@typescript-eslint/[email protected][email protected]": {
+ "integrity": "sha512-6y5dLTZdHhI8Eh3yIQ/bfQhRKwn5e+TpJj64o18Cngc0iW/BCrVvrr6zGYqXPnYH31u6YXAYiFh0+qxX5mybJw==",
+ "dependencies": [
+ "@typescript-eslint/tsconfig-utils",
+ "@typescript-eslint/types",
+ "debug",
+ "typescript"
+ ]
+ },
+ "@typescript-eslint/[email protected]": {
+ "integrity": "sha512-iIoMJ6/8c1/QpFNyFjU0d1YzPco4MsZjQw0k3V+vfzNWAFmUmvhlyMoYEoYYDQZXc+J6Gi1X5XcxlzW2taIIGQ==",
+ "dependencies": [
+ "@typescript-eslint/types",
+ "@typescript-eslint/visitor-keys"
+ ]
+ },
+ "@typescript-eslint/[email protected][email protected]": {
+ "integrity": "sha512-+h3iCgZXuTNtoLXcnnjP12ZUHLMqoUcIHPfQrFEXTUqvb9dF8QK9b5nv5VtSo5fLkdHuks8ehbTzZj3rImAm9w==",
+ "dependencies": [
+ "typescript"
+ ]
+ },
+ "@typescript-eslint/[email protected][email protected][email protected]": {
+ "integrity": "sha512-STfkR38qIdhfkLpgtXnUjAzsNy4xouqiBO0lrVc/Wpk9Kem5/aHXUx1J8dGC16zpdYN1+yc2ILQ28er1kXX7ag==",
+ "dependencies": [
+ "@typescript-eslint/types",
+ "@typescript-eslint/typescript-estree",
+ "@typescript-eslint/utils",
+ "debug",
+ "eslint",
+ "ts-api-utils",
+ "typescript"
+ ]
+ },
+ "@typescript-eslint/[email protected]": {
+ "integrity": "sha512-Xfn37OLZx03+PCU7qWx9DTv2FCRh1E6fk2+wONeNY15HXIwtcwuveaSwVpGAUptkNmPQegRxW5JyRel9T7wrog=="
+ },
+ "@typescript-eslint/[email protected][email protected]": {
+ "integrity": "sha512-pQEGqIK/cqEvKivVWaFLYpe7XYejFxfuAOi4mu1oAWFvIo36aRHI9esRFTUxcIy/z8N482RJyH+LpZB0ZIU7Ow==",
+ "dependencies": [
+ "@typescript-eslint/project-service",
+ "@typescript-eslint/tsconfig-utils",
+ "@typescript-eslint/types",
+ "@typescript-eslint/visitor-keys",
+ "debug",
+ "minimatch",
+ "semver",
+ "tinyglobby",
+ "ts-api-utils",
+ "typescript"
+ ]
+ },
+ "@typescript-eslint/[email protected][email protected][email protected]": {
+ "integrity": "sha512-hv3eRYbpPbbpezuax1EfGrzpa3C4ySgNZkPUkLOWOAjU8HsOKowEDAr8C7nsNl1C+SBSKDpvno6VKHnlhvp9iA==",
+ "dependencies": [
+ "@eslint-community/eslint-utils",
+ "@typescript-eslint/scope-manager",
+ "@typescript-eslint/types",
+ "@typescript-eslint/typescript-estree",
+ "eslint",
+ "typescript"
+ ]
+ },
+ "@typescript-eslint/[email protected]": {
+ "integrity": "sha512-NAGrjn0Pitjqzq/GkgMC4kBYm233PQ8GffyQ9+kTA3AlNQYEzOf25EIM02BAHZv5FRJSpHpJk+OGUxVkOB93GQ==",
+ "dependencies": [
+ "@typescript-eslint/types",
+ "[email protected]"
+ ]
+ },
+ "@vladfrangu/[email protected]": {
+ "integrity": "sha512-Xfe6rpCTxSxfbswi/W/Pz7zp1WWSNn4A0eW4mLkQUewCrXXtMj31lCg+iQyTkh/CkusZSq9eDflu7tjEDXUY6g=="
+ },
+ "[email protected][email protected]": {
+ "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
+ "dependencies": [
+ "acorn"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==",
+ "bin": true
+ },
+ "[email protected]": {
+ "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==",
+ "dependencies": [
+ "fast-deep-equal",
+ "fast-json-stable-stringify",
+ "json-schema-traverse",
+ "uri-js"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==",
+ "dependencies": [
+ "balanced-match"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-60cyAOytib/OzBw1JNSoSV/boK1AtHryDIjvVBk7XbN4ugfkM3+Sry7fEjNgPMGgOjuaZPAp8ruZ0Cxafwyq9g==",
+ "dependencies": [
+ "@cacheable/memory",
+ "@cacheable/utils",
+ "[email protected]",
+ "keyv",
+ "qified"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
+ "dependencies": [
+ "readdirp"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-SL0cVuEdETEp7pN0FuZb01toc3vnODEfVUCooxG1SJN0yIirh7JMb9X9bvfCFf0vzzbT68RdbKDHYTiWy7a7iw=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
+ "dependencies": [
+ "path-key",
+ "shebang-command",
+ "which"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
+ "dependencies": [
+ "ms"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-sPAT4pztbu6586/hrhOnMKS17IJrvg12mXiSPSS3W5qDeN2RGgvZ0diZCm31dBbnevfVmujNO3IM2wrS4Y2Rhg=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-6utghVho47hBzmx8nIp+pKEDDNIlVk6On/J5Y1Q529payNLZjBsrw+mt+G5Y3NYRE3kgta6eBx5hRYVyfHGdOA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-Je5OcqgurnIUQK4vR+gQnmzOf/lNQsD6d/UkV8ZOj+bFa5zJXPyiGXlbywp2EagwshVT18y7YNQNSRd3FjYkDw==",
+ "dependencies": [
+ "@discordjs/builders",
+ "@discordjs/[email protected]",
+ "@discordjs/formatters",
+ "@discordjs/rest",
+ "@discordjs/util",
+ "@discordjs/ws",
+ "@sapphire/snowflake",
+ "discord-api-types",
+ "fast-deep-equal",
+ "lodash.snakecase",
+ "magic-bytes.js",
+ "tslib",
+ "undici"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="
+ },
+ "[email protected][email protected]": {
+ "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==",
+ "dependencies": [
+ "eslint"
+ ],
+ "bin": true
+ },
+ "[email protected][email protected][email protected]": {
+ "integrity": "sha512-XYzp318u8UkDH4ZdRkdSomOYnwMTeJP2Zw9u6DuBj3mViFZD8zS+mhfTYq34plm3SH9eF7ZaiYJfQYq2xMhPHg==",
+ "dependencies": [
+ "@eslint-community/eslint-utils",
+ "@jridgewell/sourcemap-codec",
+ "eslint",
+ "esutils",
+ "[email protected]",
+ "known-css-properties",
+ "postcss",
+ "postcss-load-config",
+ "postcss-safe-parser",
+ "semver",
+ "svelte",
+ "svelte-eslint-parser"
+ ],
+ "optionalPeers": [
+ "svelte"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==",
+ "dependencies": [
+ "esrecurse",
+ "estraverse"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==",
+ "dependencies": [
+ "@types/esrecurse",
+ "@types/estree",
+ "esrecurse",
+ "estraverse"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-T0pNsxkb9IKmtQjhpK3d7nWOpFv+YHuMbTJnSVMoQblF0onvXfErrtp4V1jHtsQPan7dKaGVD0q1WCXnzMF31A==",
+ "dependencies": [
+ "@eslint-community/eslint-utils",
+ "@eslint-community/regexpp",
+ "@eslint/config-array",
+ "@eslint/config-helpers",
+ "@eslint/core",
+ "@eslint/plugin-kit",
+ "@humanfs/node",
+ "@humanwhocodes/module-importer",
+ "@humanwhocodes/retry",
+ "@types/estree",
+ "ajv",
+ "cross-spawn",
+ "debug",
+ "escape-string-regexp",
+ "[email protected]",
+ "[email protected]",
+ "[email protected]",
+ "esquery",
+ "esutils",
+ "fast-deep-equal",
+ "file-entry-cache",
+ "find-up",
+ "glob-parent",
+ "[email protected]",
+ "imurmurhash",
+ "is-glob",
+ "json-stable-stringify-without-jsonify",
+ "minimatch",
+ "natural-compare",
+ "optionator"
+ ],
+ "bin": true
+ },
+ "[email protected]": {
+ "integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==",
+ "dependencies": [
+ "acorn",
+ "acorn-jsx",
+ "[email protected]"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==",
+ "dependencies": [
+ "acorn",
+ "acorn-jsx",
+ "[email protected]"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==",
+ "dependencies": [
+ "estraverse"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-CQPcneEHw/czj32uwQC52nYnax8H4SXt25FCM+LIwGZ49cMIxpOj3bP8wmzcI+Z0HIy5KkClaPhRLfCySzwHPA==",
+ "dependencies": [
+ "@jridgewell/sourcemap-codec"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
+ "dependencies": [
+ "estraverse"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw=="
+ },
+ "[email protected][email protected]": {
+ "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
+ "dependencies": [
+ "picomatch"
+ ],
+ "optionalPeers": [
+ "picomatch"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==",
+ "dependencies": [
+ "flat-cache"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
+ "dependencies": [
+ "locate-path",
+ "path-exists"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-f++BY9pTk+983xK1FLzlLpmM0i0z+jHmx3QESGkURMXujQZz1k5wzwX6hjnQ8goaD0B+sYnDK1yZ6MTyZfUaqA==",
+ "dependencies": [
+ "cacheable",
+ "flatted",
+ "[email protected]"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+ "os": ["darwin"],
+ "scripts": true
+ },
+ "[email protected]": {
+ "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==",
+ "dependencies": [
+ "is-glob"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-c/c15i26VrJ4IRt5Z89DnIzCGDn9EcebibhAOjw5ibqEHsE1wLUgkPn9RDmNcUKyU87GeaL633nyJ+pplFR2ZQ=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-UtdkTVyAJePQv0J2M9Xe4L0ruNSDV314XiIJsADI2Zf40bcdAonE/D/OhAU8AT99oij9mhLByb+NvA3QWZYgCg=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==",
+ "dependencies": [
+ "[email protected]"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
+ "dependencies": [
+ "is-extglob"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==",
+ "dependencies": [
+ "@types/estree"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==",
+ "dependencies": [
+ "@keyv/serialize"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-JCDrsP4Z1Sb9JwG0aJ8Eo2r7k4Ou5MwmThS/6lcIe1ICyb7UBJKGRIUUdqc2ASdE/42lgz6zFUnzAIhtXnBVrQ=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",
+ "dependencies": [
+ "prelude-ls",
+ "type-check"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==",
+ "os": ["android"],
+ "cpu": ["arm64"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==",
+ "os": ["darwin"],
+ "cpu": ["arm64"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==",
+ "os": ["darwin"],
+ "cpu": ["x64"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==",
+ "os": ["freebsd"],
+ "cpu": ["x64"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==",
+ "os": ["linux"],
+ "cpu": ["arm"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==",
+ "os": ["linux"],
+ "cpu": ["arm64"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==",
+ "os": ["linux"],
+ "cpu": ["arm64"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==",
+ "os": ["linux"],
+ "cpu": ["x64"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==",
+ "os": ["linux"],
+ "cpu": ["x64"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==",
+ "os": ["win32"],
+ "cpu": ["arm64"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==",
+ "os": ["win32"],
+ "cpu": ["x64"]
+ },
+ "[email protected]": {
+ "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",
+ "dependencies": [
+ "detect-libc"
+ ],
+ "optionalDependencies": [
+ "lightningcss-android-arm64",
+ "lightningcss-darwin-arm64",
+ "lightningcss-darwin-x64",
+ "lightningcss-freebsd-x64",
+ "lightningcss-linux-arm-gnueabihf",
+ "lightningcss-linux-arm64-gnu",
+ "lightningcss-linux-arm64-musl",
+ "lightningcss-linux-x64-gnu",
+ "lightningcss-linux-x64-musl",
+ "lightningcss-win32-arm64-msvc",
+ "lightningcss-win32-x64-msvc"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
+ "dependencies": [
+ "p-locate"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-x5sn4UX2k5gCWlcfmoFwG4TPie8+dctESyqOBdhB5p6MsgWXdBKGmt9nXPObj/JI50TTL928lc5Yt1WntMn1bw=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
+ "dependencies": [
+ "@jridgewell/sourcemap-codec"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==",
+ "dependencies": [
+ "@jridgewell/sourcemap-codec"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
+ "dependencies": [
+ "brace-expansion"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==",
+ "bin": true
+ },
+ "[email protected]": {
+ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==",
+ "dependencies": [
+ "deep-is",
+ "fast-levenshtein",
+ "levn",
+ "prelude-ls",
+ "type-check",
+ "word-wrap"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
+ "dependencies": [
+ "yocto-queue"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
+ "dependencies": [
+ "p-limit"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="
+ },
+ "[email protected][email protected]": {
+ "integrity": "sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==",
+ "dependencies": [
+ "lilconfig",
+ "postcss",
+ "yaml"
+ ],
+ "optionalPeers": [
+ "postcss"
+ ]
+ },
+ "[email protected][email protected]": {
+ "integrity": "sha512-1WzZxRLaAFwEh6Do+zyGpjWV3nGJNxxhuh7Ubu/q1ICImMgZJnLwhoaEpRbG4pJppp2Y1ncL9ffA2f+LhrefQg==",
+ "dependencies": [
+ "postcss"
+ ]
+ },
+ "[email protected][email protected]": {
+ "integrity": "sha512-AjKOeiwAitL/MXxQW2DliT28EKukvvbEWx3LBmJIRN8KfBGZbRTxNYW0kSqi1COiTZ57nZ9NW06S6ux//N1c9A==",
+ "dependencies": [
+ "postcss"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-Khh/tERVBn0I1499dvBSHY0pWJloMJWUxDsOBM0CCDPAcVZ10Jl2L1qy1f19uEX22spa8Mv7DCdEQJc0cGwBhQ==",
+ "dependencies": [
+ "util-deprecate"
+ ],
+ "deprecated": true
+ },
+ "[email protected]": {
+ "integrity": "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==",
+ "dependencies": [
+ "nanoid",
+ "picocolors",
+ "source-map-js"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g=="
+ },
+ "[email protected][email protected][email protected]": {
+ "integrity": "sha512-wXvbXMjSvb4C9ENWTHXyd+ihakKCsJ6rJhLP6/8HFNj4GkZr48jqL9PoKsl2sk7SyCZRTnJ7O2TTowUpOxP/KA==",
+ "dependencies": [
+ "prettier",
+ "svelte"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-mBi4765LgjO1PFjlEs7pUeK0nb1bw71c+N4/ItfeUWNdY5cV2pRKaFpbbFRYmDJMO+5ZwzGxHRqHxFZna7iv5w==",
+ "bin": true
+ },
+ "[email protected]": {
+ "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==",
+ "dependencies": [
+ "[email protected]"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==",
+ "dependencies": [
+ "@oxc-project/types",
+ "@rolldown/pluginutils"
+ ],
+ "optionalDependencies": [
+ "@rolldown/binding-android-arm-eabi",
+ "@rolldown/binding-android-arm64",
+ "@rolldown/binding-darwin-arm64",
+ "@rolldown/binding-darwin-x64",
+ "@rolldown/binding-freebsd-x64",
+ "@rolldown/binding-linux-arm-gnueabihf",
+ "@rolldown/binding-linux-arm64-gnu",
+ "@rolldown/binding-linux-arm64-musl",
+ "@rolldown/binding-linux-ppc64-gnu",
+ "@rolldown/binding-linux-s390x-gnu",
+ "@rolldown/binding-linux-x64-gnu",
+ "@rolldown/binding-linux-x64-musl",
+ "@rolldown/binding-openharmony-arm64",
+ "@rolldown/binding-wasm32-wasi",
+ "@rolldown/binding-win32-arm64-msvc",
+ "@rolldown/binding-win32-x64-msvc"
+ ],
+ "bin": true
+ },
+ "[email protected]": {
+ "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
+ "dependencies": [
+ "mri"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==",
+ "bin": true
+ },
+ "[email protected]": {
+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
+ "dependencies": [
+ "shebang-regex"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g==",
+ "dependencies": [
+ "@polka/url",
+ "mrmime",
+ "totalist"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw=="
+ },
+ "[email protected][email protected][email protected]": {
+ "integrity": "sha512-laZ49GFHZ3b0z2PWinJWL0syehc/PTR8aHaUaTiBkWJ+4Y38nhxjmXsSz7CbGa3VdKopViVbrBH3bGNqIAI0bQ==",
+ "dependencies": [
+ "@jridgewell/trace-mapping",
+ "@sveltejs/load-config",
+ "chokidar",
+ "fdir",
+ "picocolors",
+ "sade",
+ "svelte",
+ "typescript"
+ ],
+ "bin": true
+ },
+ "[email protected][email protected]": {
+ "integrity": "sha512-owYBhrNRp/m+hDaQCH0S683kc0TMFy2bB+qvsMQQZRsjSFD9xp/3FYgI8FZoOKA3xk62gwkUj1HpVek0p6WgNw==",
+ "dependencies": [
+ "[email protected]",
+ "[email protected]",
+ "[email protected]",
+ "postcss",
+ "postcss-scss",
+ "postcss-selector-parser",
+ "semver",
+ "svelte"
+ ],
+ "optionalPeers": [
+ "svelte"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-5mAftM3SoDV9X0zdF386F9p2pv8iKOwi/KfBS1XnBAkVCKFzVOLHUoa8iGWAt4buoicLmyWVRpuuD5wplXOQsg==",
+ "dependencies": [
+ "@jridgewell/remapping",
+ "@jridgewell/sourcemap-codec",
+ "@sveltejs/acorn-typescript",
+ "@types/estree",
+ "acorn",
+ "aria-query",
+ "axobject-query",
+ "clsx",
+ "devalue",
+ "esm-env",
+ "esrap",
+ "is-reference",
+ "locate-character",
+ "[email protected]",
+ "zimmerframe"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
+ "dependencies": [
+ "fdir",
+ "picomatch"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ=="
+ },
+ "[email protected][email protected]": {
+ "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==",
+ "dependencies": [
+ "typescript"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
+ "dependencies": [
+ "prelude-ls"
+ ]
+ },
+ "[email protected][email protected][email protected]": {
+ "integrity": "sha512-c/+AKMW1KB81r28Sp0AAdcyXj5dzNmAsZFcsrxKbZTKmcBK2xIwBR31dcSYSDu3bKmzXe8GKrSxO+eDQ401Uzg==",
+ "dependencies": [
+ "@typescript-eslint/eslint-plugin",
+ "@typescript-eslint/parser",
+ "@typescript-eslint/typescript-estree",
+ "@typescript-eslint/utils",
+ "eslint",
+ "typescript"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
+ "bin": true
+ },
+ "[email protected]": {
+ "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
+ "dependencies": [
+ "punycode"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
+ },
+ "[email protected]_@[email protected]": {
+ "integrity": "sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==",
+ "dependencies": [
+ "@types/node",
+ "lightningcss",
+ "picomatch",
+ "postcss",
+ "rolldown",
+ "tinyglobby"
+ ],
+ "optionalDependencies": [
+ "fsevents"
+ ],
+ "optionalPeers": [
+ "@types/node"
+ ],
+ "bin": true
+ },
+ "[email protected][email protected]_@[email protected]": {
+ "integrity": "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg==",
+ "dependencies": [
+ "vite"
+ ],
+ "optionalPeers": [
+ "vite"
+ ]
+ },
+ "[email protected]": {
+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
+ "dependencies": [
+ "isexe"
+ ],
+ "bin": true
+ },
+ "[email protected]": {
+ "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-/rEZ2ejown2N5gxVTHUu9bVVC7ttu0/Tgzf5hbTOixR3Fs7mbbXgn2DbdbcKgJOmpQMtrIUWivtYuVMnp/W/yA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-vIYeF1u3CjlhAFekPPAk2h/Kv4T3mAkMox5OymRiJQB0spDP10LHvt+K7G9Ny6NuuMAb25/6n1qyUjAcGNf/AA=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="
+ },
+ "[email protected]": {
+ "integrity": "sha512-msJxIvYDYcoNL+PJsu+7qmpDWsYmAxTY+2TNYXXF0hzBzBk0BMecOqDOG/EckUoKCuKwObfbugIl8QpqHDXeFA=="
+ }
+ },
+ "workspace": {
+ "packageJson": {
+ "dependencies": [
+ "npm:@eslint/js@^10.0.1",
+ "npm:@sveltejs/adapter-node@^6.0.2",
+ "npm:@sveltejs/kit@3",
+ "npm:@sveltejs/vite-plugin-svelte@^7.2.0",
+ "npm:@types/node@26",
+ "npm:discord.js@^14.28.1",
+ "npm:eslint-config-prettier@^10.1.8",
+ "npm:eslint-plugin-svelte@^3.19.0",
+ "npm:eslint@^10.4.1",
+ "npm:globals@^17.6.0",
+ "npm:prettier-plugin-svelte@^4.1.0",
+ "npm:prettier@^3.8.3",
+ "npm:svelte-check@^4.6.0",
+ "npm:svelte@^5.57.2",
+ "npm:typescript-eslint@^8.60.1",
+ "npm:typescript@^6.0.3",
+ "npm:vite@^8.3.0"
+ ]
+ }
+ }
+}
diff --git a/deploy/log/run b/deploy/log/run
new file mode 100755
index 0000000..f50e383
--- /dev/null
+++ b/deploy/log/run
@@ -0,0 +1,9 @@
+#!/bin/sh
+# deploy/log/run
+# MIT — (c) Doughmination System®
+# runit log service for is-a-tracker: everything the app prints ends up here,
+# timestamped and rotated by svlogd
+LOG_DIR=/var/log/is-a-tracker
+
+mkdir -p "$LOG_DIR"
+exec svlogd -tt "$LOG_DIR"
diff --git a/deploy/run b/deploy/run
new file mode 100755
index 0000000..e8676ee
--- /dev/null
+++ b/deploy/run
@@ -0,0 +1,26 @@
+#!/bin/sh
+# deploy/run
+# MIT — (c) Doughmination System®
+exec 2>&1
+
+cd /srv/clove/is-a-tracker || exit 1
+
+export HOST=127.0.0.1
+export PORT=3101
+export NODE_ENV=production
+
+# Run as clove rather than root. chpst doesn't change HOME, so set it for Deno's cache
+export HOME=/home/clove
+
+# Secrets (GitHub token, Discord bot token, dashboard password) and ORIGIN live in
+# /srv/clove/is-a-tracker/.env, which Deno skips if it's missing.
+# ORIGIN must be the dashboard's public URL: SvelteKit needs it for form actions (CSRF check)
+
+# Reads are limited to this folder; writes are limited to data/, where the SQLite file lives
+exec chpst -u clove /usr/bin/deno run \
+ --allow-net \
+ --allow-env \
+ --allow-read=. \
+ --allow-write=data \
+ --env-file=.env \
+ build/index.js
diff --git a/eslint.config.js b/eslint.config.js
new file mode 100644
index 0000000..e7f978c
--- /dev/null
+++ b/eslint.config.js
@@ -0,0 +1,42 @@
+import prettier from 'eslint-config-prettier';
+import path from 'node:path';
+import js from '@eslint/js';
+import svelte from 'eslint-plugin-svelte';
+import { defineConfig, includeIgnoreFile } from 'eslint/config';
+import globals from 'globals';
+import ts from 'typescript-eslint';
+
+const gitignorePath = path.resolve(import.meta.dirname, '.gitignore');
+
+export default defineConfig(
+ includeIgnoreFile(gitignorePath),
+ js.configs.recommended,
+ ts.configs.recommended,
+ svelte.configs.recommended,
+ prettier,
+ svelte.configs.prettier,
+ {
+ languageOptions: { globals: { ...globals.browser, ...globals.node } },
+ rules: {
+ // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
+ // see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
+ 'no-undef': 'off'
+ }
+ },
+ {
+ files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
+ languageOptions: {
+ parserOptions: {
+ projectService: true,
+ extraFileExtensions: ['.svelte'],
+ parser: ts.parser
+ }
+ }
+ },
+ {
+ // The dashboard is served from the root and most links point at GitHub
+ rules: {
+ 'svelte/no-navigation-without-resolve': 'off'
+ }
+ }
+);
diff --git a/licence b/licence
new file mode 100644
index 0000000..a79aaa9
--- /dev/null
+++ b/licence
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025-2035 Doughmination System®
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..e5afab3
--- /dev/null
+++ b/package.json
@@ -0,0 +1,44 @@
+{
+ "name": "is-a-tracker",
+ "version": "0.0.1",
+ "private": true,
+ "license": "MIT",
+ "type": "module",
+ "imports": {
+ "#lib": "./src/lib/index.js",
+ "#lib/*": "./src/lib/*"
+ },
+ "scripts": {
+ "dev": "deno run -A --env-file=.env npm:vite dev",
+ "build": "vite build",
+ "start": "deno run -A --env-file=.env build/index.js",
+ "test": "deno test -A src",
+ "preview": "vite preview",
+ "prepare": "svelte-kit sync || echo ''",
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
+ "lint": "prettier --check . && eslint .",
+ "format": "prettier --write ."
+ },
+ "dependencies": {
+ "discord.js": "^14.28.1"
+ },
+ "devDependencies": {
+ "@eslint/js": "^10.0.1",
+ "@sveltejs/adapter-node": "^6.0.2",
+ "@sveltejs/kit": "^3.0.0",
+ "@sveltejs/vite-plugin-svelte": "^7.2.0",
+ "@types/node": "^26",
+ "eslint": "^10.4.1",
+ "eslint-config-prettier": "^10.1.8",
+ "eslint-plugin-svelte": "^3.19.0",
+ "globals": "^17.6.0",
+ "prettier": "^3.8.3",
+ "prettier-plugin-svelte": "^4.1.0",
+ "svelte": "^5.57.2",
+ "svelte-check": "^4.6.0",
+ "typescript": "^6.0.3",
+ "typescript-eslint": "^8.60.1",
+ "vite": "^8.3.0"
+ }
+}
diff --git a/prettier.config.js b/prettier.config.js
new file mode 100644
index 0000000..718ddb8
--- /dev/null
+++ b/prettier.config.js
@@ -0,0 +1,11 @@
+/** @type {import("prettier").Config} */
+const config = {
+ useTabs: true,
+ singleQuote: true,
+ trailingComma: 'none',
+ printWidth: 100,
+ plugins: ['prettier-plugin-svelte'],
+ overrides: [{ files: '*.svelte', options: { parser: 'svelte' } }]
+};
+
+export default config;
diff --git a/src/app.css b/src/app.css
new file mode 100644
index 0000000..0101c07
--- /dev/null
+++ b/src/app.css
@@ -0,0 +1,202 @@
+/* src/app.css
+ * MIT — (c) Doughmination System®
+ */
+
+:root {
+ color-scheme: light;
+
+ --surface-page: #f4f3f0;
+ --surface-card: #fcfcfb;
+ --border: #dcdbd5;
+ --text-primary: #0b0b0b;
+ --text-secondary: #52514e;
+ --accent: #2a78d6;
+ --accent-text: #ffffff;
+ --danger: #c8322f;
+ --series-closures: #2a78d6;
+ --series-reviews: #eb6834;
+ --status-good: #0d7a52;
+ --status-bad: #c8322f;
+ --status-neutral: #52514e;
+}
+
+@media (prefers-color-scheme: dark) {
+ :root {
+ color-scheme: dark;
+
+ --surface-page: #111110;
+ --surface-card: #1a1a19;
+ --border: #34342f;
+ --text-primary: #f0efec;
+ --text-secondary: #c3c2b7;
+ --accent: #3987e5;
+ --accent-text: #ffffff;
+ --danger: #e66767;
+ --series-closures: #3987e5;
+ --series-reviews: #d95926;
+ --status-good: #4cc79a;
+ --status-bad: #e66767;
+ --status-neutral: #c3c2b7;
+ }
+}
+
+* {
+ box-sizing: border-box;
+}
+
+body {
+ margin: 0;
+ background: var(--surface-page);
+ color: var(--text-primary);
+ font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
+ font-size: 1rem;
+ line-height: 1.6;
+ letter-spacing: 0.01em;
+}
+
+a {
+ color: var(--accent);
+}
+
+h1 {
+ margin: 0 0 1rem;
+ font-size: 1.5rem;
+}
+
+h2 {
+ margin: 0 0 0.75rem;
+ font-size: 1.1rem;
+}
+
+code {
+ font-family: ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
+ font-size: 0.9em;
+}
+
+.page {
+ max-width: 68rem;
+ margin: 0 auto;
+ padding: 1.5rem 1rem 3rem;
+}
+
+.card {
+ background: var(--surface-card);
+ border: 1px solid var(--border);
+ border-radius: 0.6rem;
+ padding: 1rem 1.25rem;
+ margin-bottom: 1rem;
+}
+
+.muted {
+ color: var(--text-secondary);
+}
+
+.tableScroll {
+ overflow-x: auto;
+}
+
+table {
+ width: 100%;
+ border-collapse: collapse;
+}
+
+th,
+td {
+ padding: 0.55rem 0.75rem;
+ text-align: left;
+ vertical-align: top;
+ border-bottom: 1px solid var(--border);
+}
+
+th {
+ color: var(--text-secondary);
+ font-size: 0.85rem;
+ font-weight: 600;
+}
+
+td.numeric,
+th.numeric {
+ text-align: right;
+ font-variant-numeric: tabular-nums;
+}
+
+button,
+.button {
+ font: inherit;
+ padding: 0.45rem 0.9rem;
+ border: 1px solid var(--border);
+ border-radius: 0.45rem;
+ background: var(--surface-card);
+ color: var(--text-primary);
+ cursor: pointer;
+}
+
+button.primary {
+ background: var(--accent);
+ border-color: var(--accent);
+ color: var(--accent-text);
+}
+
+button.danger {
+ background: var(--danger);
+ border-color: var(--danger);
+ color: #ffffff;
+}
+
+button:disabled {
+ opacity: 0.55;
+ cursor: wait;
+}
+
+input[type='text'],
+input[type='search'],
+input[type='password'] {
+ font: inherit;
+ width: 100%;
+ max-width: 28rem;
+ padding: 0.45rem 0.7rem;
+ border: 1px solid var(--border);
+ border-radius: 0.45rem;
+ background: var(--surface-card);
+ color: var(--text-primary);
+}
+
+.formRow {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.6rem;
+ align-items: center;
+}
+
+.notice {
+ border-left: 4px solid var(--status-neutral);
+ padding: 0.6rem 0.9rem;
+ margin-bottom: 1rem;
+ background: var(--surface-card);
+}
+
+.notice.success {
+ border-left-color: var(--status-good);
+}
+
+.notice.failure {
+ border-left-color: var(--status-bad);
+}
+
+.pill {
+ display: inline-block;
+ padding: 0.05rem 0.55rem;
+ border: 1px solid currentColor;
+ border-radius: 999px;
+ font-size: 0.82rem;
+ white-space: nowrap;
+ color: var(--status-neutral);
+}
+
+.pill.success {
+ color: var(--status-good);
+}
+
+.pill.failure {
+ color: var(--status-bad);
+}
diff --git a/src/app.d.ts b/src/app.d.ts
new file mode 100644
index 0000000..da08e6d
--- /dev/null
+++ b/src/app.d.ts
@@ -0,0 +1,13 @@
+// See https://svelte.dev/docs/kit/types#app.d.ts
+// for information about these interfaces
+declare global {
+ namespace App {
+ // interface Error {}
+ // interface Locals {}
+ // interface PageData {}
+ // interface PageState {}
+ // interface Platform {}
+ }
+}
+
+export {};
diff --git a/src/app.html b/src/app.html
new file mode 100644
index 0000000..6a2bb58
--- /dev/null
+++ b/src/app.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="text-scale" content="scale" />
+ %sveltekit.head%
+ </head>
+ <body data-sveltekit-preload-data="hover">
+ <div style="display: contents">%sveltekit.body%</div>
+ </body>
+</html>
diff --git a/src/hooks.server.ts b/src/hooks.server.ts
new file mode 100644
index 0000000..bde195f
--- /dev/null
+++ b/src/hooks.server.ts
@@ -0,0 +1,38 @@
+/* src/hooks.server.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { building, dev } from '$app/env';
+import { redirect } from '@sveltejs/kit';
+import type { Handle, ServerInit } from '@sveltejs/kit/hooks';
+
+import { isPasswordConfigured, isSessionValid, sessionCookieName } from '#lib/server/auth.ts';
+import { startServices } from '#lib/server/runtime.ts';
+
+// Starts the scanner and the Discord bot inside the same process as the dashboard
+export const init: ServerInit = async () => {
+ if (!building) {
+ await startServices();
+ }
+};
+
+export const handle: Handle = async ({ event, resolve }) => {
+ if (event.url.pathname === '/login') {
+ return resolve(event);
+ }
+
+ if (!isPasswordConfigured()) {
+ // Without a password the dashboard only opens on the local dev server
+ if (dev) {
+ return resolve(event);
+ }
+
+ return new Response('Set DASHBOARD_PASSWORD to use the dashboard.', { status: 503 });
+ }
+
+ if (!isSessionValid(event.cookies.get(sessionCookieName))) {
+ redirect(303, '/login');
+ }
+
+ return resolve(event);
+};
diff --git a/src/lib/assets/favicon.svg b/src/lib/assets/favicon.svg
new file mode 100644
index 0000000..cc5dc66
--- /dev/null
+++ b/src/lib/assets/favicon.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="107" height="128" viewBox="0 0 107 128"><title>svelte-logo</title><path d="M94.157 22.819c-10.4-14.885-30.94-19.297-45.792-9.835L22.282 29.608A29.92 29.92 0 0 0 8.764 49.65a31.5 31.5 0 0 0 3.108 20.231 30 30 0 0 0-4.477 11.183 31.9 31.9 0 0 0 5.448 24.116c10.402 14.887 30.942 19.297 45.791 9.835l26.083-16.624A29.92 29.92 0 0 0 98.235 78.35a31.53 31.53 0 0 0-3.105-20.232 30 30 0 0 0 4.474-11.182 31.88 31.88 0 0 0-5.447-24.116" style="fill:#ff3e00"/><path d="M45.817 106.582a20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.503 18 18 0 0 1 .624-2.435l.49-1.498 1.337.981a33.6 33.6 0 0 0 10.203 5.098l.97.294-.09.968a5.85 5.85 0 0 0 1.052 3.878 6.24 6.24 0 0 0 6.695 2.485 5.8 5.8 0 0 0 1.603-.704L69.27 76.28a5.43 5.43 0 0 0 2.45-3.631 5.8 5.8 0 0 0-.987-4.371 6.24 6.24 0 0 0-6.698-2.487 5.7 5.7 0 0 0-1.6.704l-9.953 6.345a19 19 0 0 1-5.296 2.326 20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.502 17.99 17.99 0 0 1 8.13-12.052l26.081-16.623a19 19 0 0 1 5.3-2.329 20.72 20.72 0 0 1 22.237 8.243 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-.624 2.435l-.49 1.498-1.337-.98a33.6 33.6 0 0 0-10.203-5.1l-.97-.294.09-.968a5.86 5.86 0 0 0-1.052-3.878 6.24 6.24 0 0 0-6.696-2.485 5.8 5.8 0 0 0-1.602.704L37.73 51.72a5.42 5.42 0 0 0-2.449 3.63 5.79 5.79 0 0 0 .986 4.372 6.24 6.24 0 0 0 6.698 2.486 5.8 5.8 0 0 0 1.602-.704l9.952-6.342a19 19 0 0 1 5.295-2.328 20.72 20.72 0 0 1 22.237 8.242 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-8.13 12.053l-26.081 16.622a19 19 0 0 1-5.3 2.328" style="fill:#fff"/></svg>
\ No newline at end of file
diff --git a/src/lib/components/ActionsChart.svelte b/src/lib/components/ActionsChart.svelte
new file mode 100644
index 0000000..d956c7d
--- /dev/null
+++ b/src/lib/components/ActionsChart.svelte
@@ -0,0 +1,316 @@
+<!-- src/lib/components/ActionsChart.svelte
+ MIT — (c) Doughmination System®
+-->
+
+<script lang="ts">
+ interface DailyCount {
+ day: string;
+ closures: number;
+ reviews: number;
+ }
+
+ let { daily }: { daily: DailyCount[] } = $props();
+
+ const width = 720;
+ const height = 220;
+
+ const margin = {
+ top: 10,
+ right: 8,
+ bottom: 26,
+ left: 32
+ };
+
+ const plotWidth = width - margin.left - margin.right;
+ const plotHeight = height - margin.top - margin.bottom;
+ const baseline = margin.top + plotHeight;
+ const barWidth = 14;
+ const segmentGap = 2;
+ const cornerRadius = 4;
+
+ let hoveredIndex = $state<number | null>(null);
+
+ const slotWidth = $derived(plotWidth / Math.max(daily.length, 1));
+
+ const busiestDay = $derived(Math.max(0, ...daily.map((entry) => entry.closures + entry.reviews)));
+
+ // An even ceiling of at least 4 keeps every tick a whole number
+ const scaleMax = $derived(Math.max(4, Math.ceil(busiestDay / 2) * 2));
+
+ const ticks = $derived([0, scaleMax / 2, scaleMax]);
+
+ const hasActions = $derived(busiestDay > 0);
+
+ const hovered = $derived(hoveredIndex === null ? null : daily[hoveredIndex]);
+
+ function slotCentre(index: number): number {
+ return margin.left + slotWidth * (index + 0.5);
+ }
+
+ function scaleHeight(value: number): number {
+ return (value / scaleMax) * plotHeight;
+ }
+
+ function tickY(value: number): number {
+ return baseline - scaleHeight(value);
+ }
+
+ // A bar segment; only the top of a stack gets rounded corners
+ function segmentPath(index: number, bottom: number, barHeight: number, rounded: boolean): string {
+ const left = slotCentre(index) - barWidth / 2;
+ const right = left + barWidth;
+ const top = bottom - barHeight;
+ const radius = rounded ? Math.min(cornerRadius, barHeight) : 0;
+
+ return [
+ `M ${left} ${bottom}`,
+ `V ${top + radius}`,
+ `Q ${left} ${top} ${left + radius} ${top}`,
+ `H ${right - radius}`,
+ `Q ${right} ${top} ${right} ${top + radius}`,
+ `V ${bottom}`,
+ 'Z'
+ ].join(' ');
+ }
+
+ function shortDay(day: string): string {
+ return day.slice(5);
+ }
+</script>
+
+<div class="chart">
+ <ul class="legend">
+ <li><span class="swatch closures"></span>PRs closed</li>
+ <li><span class="swatch reviews"></span>Changes requested</li>
+ </ul>
+
+ <div class="plot">
+ <svg
+ viewBox="0 0 {width} {height}"
+ role="img"
+ aria-label="Stacked bars of moderation actions per day for the last 30 days"
+ >
+ {#each ticks as tick (tick)}
+ <line
+ class="grid"
+ x1={margin.left}
+ x2={width - margin.right}
+ y1={tickY(tick)}
+ y2={tickY(tick)}
+ />
+ <text class="axisLabel" x={margin.left - 8} y={tickY(tick) + 4} text-anchor="end">
+ {tick}
+ </text>
+ {/each}
+
+ {#each daily as entry, index (entry.day)}
+ {@const closuresHeight = scaleHeight(entry.closures)}
+ {@const reviewsHeight = scaleHeight(entry.reviews)}
+ {@const reviewsBottom = baseline - closuresHeight - (entry.closures > 0 ? segmentGap : 0)}
+
+ {#if hoveredIndex === index}
+ <rect
+ class="hoverBand"
+ x={slotCentre(index) - slotWidth / 2}
+ y={margin.top}
+ width={slotWidth}
+ height={plotHeight}
+ />
+ {/if}
+
+ {#if entry.closures > 0}
+ <path
+ class="closures"
+ d={segmentPath(index, baseline, closuresHeight, entry.reviews === 0)}
+ />
+ {/if}
+
+ {#if entry.reviews > 0}
+ <path
+ class="reviews"
+ d={segmentPath(index, reviewsBottom, Math.max(reviewsHeight - segmentGap, 1), true)}
+ />
+ {/if}
+
+ {#if index % 7 === 0 || index === daily.length - 1}
+ <text class="axisLabel" x={slotCentre(index)} y={height - 8} text-anchor="middle">
+ {shortDay(entry.day)}
+ </text>
+ {/if}
+
+ <!-- Full-height hit target, wider than the bar itself -->
+ <rect
+ class="hitTarget"
+ role="button"
+ tabindex="0"
+ aria-label="{entry.day}: {entry.closures} closed, {entry.reviews} changes requested"
+ x={slotCentre(index) - slotWidth / 2}
+ y={margin.top}
+ width={slotWidth}
+ height={plotHeight}
+ onpointerenter={() => (hoveredIndex = index)}
+ onpointerleave={() => (hoveredIndex = null)}
+ onfocus={() => (hoveredIndex = index)}
+ onblur={() => (hoveredIndex = null)}
+ />
+ {/each}
+
+ <line
+ class="baseline"
+ x1={margin.left}
+ x2={width - margin.right}
+ y1={baseline}
+ y2={baseline}
+ />
+ </svg>
+
+ {#if hovered && hoveredIndex !== null}
+ <div
+ class="tooltip"
+ class:alignRight={hoveredIndex > daily.length / 2}
+ style="left: {(slotCentre(hoveredIndex) / width) * 100}%"
+ >
+ <strong>{hovered.day}</strong>
+ <span><span class="swatch closures"></span>{hovered.closures} closed</span>
+ <span><span class="swatch reviews"></span>{hovered.reviews} changes requested</span>
+ </div>
+ {/if}
+
+ {#if !hasActions}
+ <p class="empty muted">No completed actions in this period yet.</p>
+ {/if}
+ </div>
+
+ <details>
+ <summary>View as table</summary>
+
+ <div class="tableScroll">
+ <table>
+ <thead>
+ <tr>
+ <th>Day</th>
+ <th class="numeric">PRs closed</th>
+ <th class="numeric">Changes requested</th>
+ </tr>
+ </thead>
+ <tbody>
+ {#each daily.toReversed() as entry (entry.day)}
+ <tr>
+ <td>{entry.day}</td>
+ <td class="numeric">{entry.closures}</td>
+ <td class="numeric">{entry.reviews}</td>
+ </tr>
+ {/each}
+ </tbody>
+ </table>
+ </div>
+ </details>
+</div>
+
+<style>
+ .legend {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 1.2rem;
+ margin: 0 0 0.5rem;
+ padding: 0;
+ list-style: none;
+ color: var(--text-secondary);
+ font-size: 0.9rem;
+ }
+
+ .swatch {
+ display: inline-block;
+ width: 0.7rem;
+ height: 0.7rem;
+ margin-right: 0.4rem;
+ border-radius: 2px;
+ }
+
+ .swatch.closures {
+ background: var(--series-closures);
+ }
+
+ .swatch.reviews {
+ background: var(--series-reviews);
+ }
+
+ .plot {
+ position: relative;
+ }
+
+ svg {
+ display: block;
+ width: 100%;
+ height: auto;
+ }
+
+ path.closures {
+ fill: var(--series-closures);
+ }
+
+ path.reviews {
+ fill: var(--series-reviews);
+ }
+
+ .grid {
+ stroke: var(--border);
+ stroke-width: 1;
+ }
+
+ .baseline {
+ stroke: var(--text-secondary);
+ stroke-width: 1;
+ }
+
+ .axisLabel {
+ fill: var(--text-secondary);
+ font-size: 11px;
+ }
+
+ .hoverBand {
+ fill: var(--text-secondary);
+ opacity: 0.12;
+ }
+
+ .hitTarget {
+ fill: transparent;
+ outline: none;
+ }
+
+ .tooltip {
+ position: absolute;
+ top: 0;
+ display: flex;
+ flex-direction: column;
+ padding: 0.4rem 0.65rem;
+ border: 1px solid var(--border);
+ border-radius: 0.4rem;
+ background: var(--surface-card);
+ color: var(--text-primary);
+ font-size: 0.85rem;
+ white-space: nowrap;
+ pointer-events: none;
+ transform: translateX(0.75rem);
+ }
+
+ .tooltip.alignRight {
+ transform: translateX(calc(-100% - 0.75rem));
+ }
+
+ .empty {
+ position: absolute;
+ inset: 35% 0 auto;
+ margin: 0;
+ text-align: center;
+ }
+
+ details {
+ margin-top: 0.5rem;
+ }
+
+ summary {
+ cursor: pointer;
+ color: var(--text-secondary);
+ }
+</style>
diff --git a/src/lib/index.ts b/src/lib/index.ts
new file mode 100644
index 0000000..aa147cd
--- /dev/null
+++ b/src/lib/index.ts
@@ -0,0 +1,5 @@
+/* src/lib/index.ts
+ * MIT — (c) Doughmination System®
+ */
+
+// place files you want to import through the `#lib` alias in this folder.
diff --git a/src/lib/labels.ts b/src/lib/labels.ts
new file mode 100644
index 0000000..fa625fb
--- /dev/null
+++ b/src/lib/labels.ts
@@ -0,0 +1,36 @@
+/* src/lib/labels.ts
+ * MIT — (c) Doughmination System®
+ */
+
+// Display wording shared by the dashboard pages; safe to load in the browser
+
+export const ruleLabels: Record<string, string> = {
+ nsRecords: 'NS records (first-time contributor)',
+ noReplyEmail: 'No-reply owner.email'
+};
+
+export const actionLabels: Record<string, string> = {
+ closePr: 'Close PR',
+ requestChanges: 'Request Changes',
+ ignore: 'Ignore'
+};
+
+export const statusLabels: Record<string, string> = {
+ success: 'Success',
+ failure: 'Failed',
+ skipped: 'Skipped',
+ dryRun: 'Dry run'
+};
+
+export function labelFor(labels: Record<string, string>, key: string): string {
+ return labels[key] ?? key;
+}
+
+// 2026-11-12T15:49:33.000Z -> 2026-11-12 15:49 UTC
+export function formatTimestamp(isoText: string | null): string {
+ if (!isoText) {
+ return 'never';
+ }
+
+ return `${isoText.slice(0, 10)} ${isoText.slice(11, 16)} UTC`;
+}
diff --git a/src/lib/server/auth.ts b/src/lib/server/auth.ts
new file mode 100644
index 0000000..00f6a21
--- /dev/null
+++ b/src/lib/server/auth.ts
@@ -0,0 +1,53 @@
+/* src/lib/server/auth.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { Buffer } from 'node:buffer';
+import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
+
+import { getConfig } from './config.ts';
+import { getValue, setValue } from './db/keyValue.ts';
+
+export const sessionCookieName = 'trackerSession';
+
+const sessionSecretKey = 'auth.sessionSecret';
+
+function getSessionSecret(): string {
+ const existing = getValue(sessionSecretKey);
+
+ if (existing) {
+ return existing;
+ }
+
+ const secret = randomBytes(32).toString('hex');
+
+ setValue(sessionSecretKey, secret);
+
+ return secret;
+}
+
+function safeEqual(first: string, second: string): boolean {
+ const firstBuffer = Buffer.from(first);
+ const secondBuffer = Buffer.from(second);
+
+ return firstBuffer.length === secondBuffer.length && timingSafeEqual(firstBuffer, secondBuffer);
+}
+
+export function isPasswordConfigured(): boolean {
+ return getConfig().dashboardPassword !== '';
+}
+
+export function isPasswordCorrect(candidate: string): boolean {
+ return isPasswordConfigured() && safeEqual(candidate, getConfig().dashboardPassword);
+}
+
+// Tied to the password, so changing the password signs every browser out
+export function createSessionToken(): string {
+ return createHmac('sha256', getSessionSecret())
+ .update(getConfig().dashboardPassword)
+ .digest('hex');
+}
+
+export function isSessionValid(token: string | undefined): boolean {
+ return token !== undefined && isPasswordConfigured() && safeEqual(token, createSessionToken());
+}
diff --git a/src/lib/server/config.ts b/src/lib/server/config.ts
new file mode 100644
index 0000000..3cd1aa8
--- /dev/null
+++ b/src/lib/server/config.ts
@@ -0,0 +1,74 @@
+/* src/lib/server/config.ts
+ * MIT — (c) Doughmination System®
+ */
+
+export interface AppConfig {
+ githubToken: string;
+ repoOwner: string;
+ repoName: string;
+ discordToken: string;
+ discordUserId: string;
+ discordChannelId: string;
+ databasePath: string;
+ messagesPath: string;
+ pollIntervalSeconds: number;
+ scannerEnabled: boolean;
+ dryRun: boolean;
+ dashboardPassword: string;
+ maxFilesPerPullRequest: number;
+ nsMinMergedPullRequests: number;
+ rateLimitReserve: number;
+}
+
+function readText(name: string, fallback = ''): string {
+ const value = process.env[name];
+
+ return value === undefined || value.trim() === '' ? fallback : value.trim();
+}
+
+function readNumber(name: string, fallback: number): number {
+ const parsed = Number(readText(name));
+
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
+}
+
+function readFlag(name: string, fallback: boolean): boolean {
+ const value = readText(name).toLowerCase();
+
+ if (value === '') {
+ return fallback;
+ }
+
+ return ['1', 'true', 'yes', 'on'].includes(value);
+}
+
+let cachedConfig: AppConfig | undefined;
+
+export function getConfig(): AppConfig {
+ cachedConfig ??= {
+ githubToken: readText('GITHUB_TOKEN'),
+ repoOwner: readText('GITHUB_REPO_OWNER', 'is-a-dev'),
+ repoName: readText('GITHUB_REPO_NAME', 'register'),
+ discordToken: readText('DISCORD_BOT_TOKEN'),
+ discordUserId: readText('DISCORD_USER_ID'),
+ discordChannelId: readText('DISCORD_CHANNEL_ID'),
+ databasePath: readText('DATABASE_PATH', 'data/tracker.sqlite'),
+ messagesPath: readText('MESSAGES_PATH', 'config/messages.json'),
+ pollIntervalSeconds: Math.max(30, readNumber('POLL_INTERVAL_SECONDS', 120)),
+ scannerEnabled: readFlag('SCANNER_ENABLED', true),
+ // Dry run is the default: nothing is sent to GitHub until it is switched off
+ dryRun: readFlag('DRY_RUN', true),
+ dashboardPassword: readText('DASHBOARD_PASSWORD'),
+ maxFilesPerPullRequest: readNumber('MAX_FILES_PER_PR', 25),
+ nsMinMergedPullRequests: readNumber('NS_MIN_MERGED_PRS', 1),
+ rateLimitReserve: readNumber('GITHUB_RATE_LIMIT_RESERVE', 200)
+ };
+
+ return cachedConfig;
+}
+
+export function getRepoPath(): string {
+ const { repoOwner, repoName } = getConfig();
+
+ return `/repos/${repoOwner}/${repoName}`;
+}
diff --git a/src/lib/server/db/auditLog.ts b/src/lib/server/db/auditLog.ts
new file mode 100644
index 0000000..14cfaac
--- /dev/null
+++ b/src/lib/server/db/auditLog.ts
@@ -0,0 +1,120 @@
+/* src/lib/server/db/auditLog.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import type { ActionRow } from '../types.ts';
+import { getDatabase, nowIso } from './database.ts';
+
+export type NewAction = Omit<ActionRow, 'id' | 'createdAt'>;
+
+export function recordAction(action: NewAction): void {
+ getDatabase()
+ .query(
+ `INSERT INTO actions (
+ findingId,
+ prNumber,
+ contributor,
+ ruleId,
+ actionType,
+ source,
+ status,
+ detail,
+ githubUrl,
+ createdAt
+ )
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
+ )
+ .run(
+ action.findingId,
+ action.prNumber,
+ action.contributor,
+ action.ruleId,
+ action.actionType,
+ action.source,
+ action.status,
+ action.detail,
+ action.githubUrl,
+ nowIso()
+ );
+}
+
+export function searchActions(searchText: string, limit = 200): ActionRow[] {
+ const pattern = `%${searchText.trim().replace(/^#/, '')}%`;
+
+ return getDatabase()
+ .query<ActionRow, [string, string, string, string, string, number]>(
+ `SELECT * FROM actions
+ WHERE CAST(prNumber AS TEXT) LIKE ?
+ OR contributor LIKE ?
+ OR ruleId LIKE ?
+ OR actionType LIKE ?
+ OR status LIKE ?
+ ORDER BY id DESC
+ LIMIT ?`
+ )
+ .all(pattern, pattern, pattern, pattern, pattern, limit);
+}
+
+export interface DailyActionCount {
+ day: string;
+ closures: number;
+ reviews: number;
+}
+
+export interface ModerationStats {
+ closedTotal: number;
+ nsClosures: number;
+ reviewsTotal: number;
+ pendingTotal: number;
+ daily: DailyActionCount[];
+}
+
+function countWhere(table: 'actions' | 'findings', condition: string): number {
+ const row = getDatabase()
+ .query<{ total: number }, []>(`SELECT COUNT(*) AS total FROM ${table} WHERE ${condition}`)
+ .get();
+
+ return row?.total ?? 0;
+}
+
+// Only successful actions count towards statistics
+export function getModerationStats(dayCount = 30): ModerationStats {
+ const rows = getDatabase()
+ .query<DailyActionCount, [string]>(
+ `SELECT
+ substr(createdAt, 1, 10) AS day,
+ SUM(actionType = 'closePr') AS closures,
+ SUM(actionType = 'requestChanges') AS reviews
+ FROM actions
+ WHERE status = 'success'
+ AND actionType IN ('closePr', 'requestChanges')
+ AND createdAt >= ?
+ GROUP BY day`
+ )
+ .all(new Date(Date.now() - dayCount * 86_400_000).toISOString());
+
+ const countsByDay = new Map(rows.map((row) => [row.day, row]));
+ const daily: DailyActionCount[] = [];
+
+ for (let offset = dayCount - 1; offset >= 0; offset -= 1) {
+ const day = new Date(Date.now() - offset * 86_400_000).toISOString().slice(0, 10);
+ const counts = countsByDay.get(day);
+
+ daily.push({
+ day,
+ closures: counts?.closures ?? 0,
+ reviews: counts?.reviews ?? 0
+ });
+ }
+
+ return {
+ closedTotal: countWhere('actions', `status = 'success' AND actionType = 'closePr'`),
+ nsClosures: countWhere(
+ 'actions',
+ `status = 'success' AND actionType = 'closePr' AND ruleId = 'nsRecords'`
+ ),
+ reviewsTotal: countWhere('actions', `status = 'success' AND actionType = 'requestChanges'`),
+ pendingTotal: countWhere('findings', `status IN ('pending', 'acting')`),
+ daily
+ };
+}
diff --git a/src/lib/server/db/contributors.ts b/src/lib/server/db/contributors.ts
new file mode 100644
index 0000000..6496bb8
--- /dev/null
+++ b/src/lib/server/db/contributors.ts
@@ -0,0 +1,28 @@
+/* src/lib/server/db/contributors.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getDatabase, nowIso } from './database.ts';
+
+export interface ContributorRow {
+ login: string;
+ mergedPrCount: number;
+ checkedAt: string;
+}
+
+export function getContributor(login: string): ContributorRow | null {
+ return getDatabase()
+ .query<ContributorRow, [string]>('SELECT * FROM contributors WHERE login = ?')
+ .get(login.toLowerCase());
+}
+
+export function saveContributor(login: string, mergedPrCount: number): void {
+ getDatabase()
+ .query(
+ `INSERT INTO contributors (login, mergedPrCount, checkedAt) VALUES (?, ?, ?)
+ ON CONFLICT (login) DO UPDATE SET
+ mergedPrCount = excluded.mergedPrCount,
+ checkedAt = excluded.checkedAt`
+ )
+ .run(login.toLowerCase(), mergedPrCount, nowIso());
+}
diff --git a/src/lib/server/db/database.ts b/src/lib/server/db/database.ts
new file mode 100644
index 0000000..38e37f9
--- /dev/null
+++ b/src/lib/server/db/database.ts
@@ -0,0 +1,147 @@
+/* src/lib/server/db/database.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { mkdirSync } from 'node:fs';
+import { dirname } from 'node:path';
+import { DatabaseSync, type SQLInputValue } from 'node:sqlite';
+
+import { getConfig } from '../config.ts';
+
+const schema = `
+CREATE TABLE IF NOT EXISTS pullRequests (
+ number INTEGER PRIMARY KEY,
+ title TEXT NOT NULL,
+ author TEXT NOT NULL,
+ authorAssociation TEXT NOT NULL,
+ url TEXT NOT NULL,
+ state TEXT NOT NULL,
+ headSha TEXT NOT NULL,
+ updatedAt TEXT NOT NULL,
+ scannedSha TEXT,
+ scannedAt TEXT
+);
+
+CREATE TABLE IF NOT EXISTS findings (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ prNumber INTEGER NOT NULL REFERENCES pullRequests(number),
+ ruleId TEXT NOT NULL,
+ filePath TEXT NOT NULL,
+ headSha TEXT NOT NULL,
+ reason TEXT NOT NULL,
+ status TEXT NOT NULL,
+ lastOutcome TEXT,
+ commentId INTEGER,
+ discordChannelId TEXT,
+ discordMessageId TEXT,
+ createdAt TEXT NOT NULL,
+ updatedAt TEXT NOT NULL,
+ UNIQUE (prNumber, ruleId, filePath)
+);
+
+CREATE INDEX IF NOT EXISTS findingsByStatus ON findings (status);
+
+CREATE TABLE IF NOT EXISTS actions (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ findingId INTEGER REFERENCES findings(id),
+ prNumber INTEGER NOT NULL,
+ contributor TEXT NOT NULL,
+ ruleId TEXT NOT NULL,
+ actionType TEXT NOT NULL,
+ source TEXT NOT NULL,
+ status TEXT NOT NULL,
+ detail TEXT NOT NULL,
+ githubUrl TEXT,
+ createdAt TEXT NOT NULL
+);
+
+CREATE INDEX IF NOT EXISTS actionsByCreatedAt ON actions (createdAt);
+
+CREATE TABLE IF NOT EXISTS contributors (
+ login TEXT PRIMARY KEY,
+ mergedPrCount INTEGER NOT NULL,
+ checkedAt TEXT NOT NULL
+);
+
+CREATE TABLE IF NOT EXISTS keyValue (
+ key TEXT PRIMARY KEY,
+ value TEXT NOT NULL
+);
+`;
+
+type NamedParameters = Record<string, SQLInputValue>;
+
+type QueryParameters = SQLInputValue[] | [NamedParameters];
+
+export interface WriteResult {
+ changes: number;
+ lastInsertRowid: number;
+}
+
+// A typed statement: Row is what comes back, Parameters is what goes in
+export interface Query<Row, Parameters extends QueryParameters> {
+ get: (...parameters: Parameters) => Row | null;
+ all: (...parameters: Parameters) => Row[];
+ run: (...parameters: Parameters) => WriteResult;
+}
+
+export interface TrackerDatabase {
+ exec: (sql: string) => void;
+ query: <Row = unknown, Parameters extends QueryParameters = SQLInputValue[]>(
+ sql: string
+ ) => Query<Row, Parameters>;
+}
+
+function wrapDatabase(connection: DatabaseSync): TrackerDatabase {
+ return {
+ exec: (sql) => connection.exec(sql),
+
+ query<Row, Parameters extends QueryParameters>(sql: string): Query<Row, Parameters> {
+ const statement = connection.prepare(sql);
+
+ // node:sqlite takes named values first or positional values spread; both fit this call
+ const spread = (parameters: QueryParameters) => parameters as SQLInputValue[];
+
+ return {
+ get: (...parameters) => (statement.get(...spread(parameters)) as Row | undefined) ?? null,
+ all: (...parameters) => statement.all(...spread(parameters)) as Row[],
+ run: (...parameters) => {
+ const result = statement.run(...spread(parameters));
+
+ return {
+ changes: Number(result.changes),
+ lastInsertRowid: Number(result.lastInsertRowid)
+ };
+ }
+ };
+ }
+ };
+}
+
+let database: TrackerDatabase | undefined;
+
+export function getDatabase(): TrackerDatabase {
+ if (database) {
+ return database;
+ }
+
+ const { databasePath } = getConfig();
+
+ if (databasePath !== ':memory:') {
+ mkdirSync(dirname(databasePath), { recursive: true });
+ }
+
+ database = wrapDatabase(new DatabaseSync(databasePath));
+ database.exec('PRAGMA journal_mode = WAL;');
+ database.exec('PRAGMA foreign_keys = ON;');
+ database.exec(schema);
+
+ // A crash mid-action leaves rows claimed; release them for a fresh, revalidated attempt
+ database.exec(`UPDATE findings SET status = 'pending' WHERE status = 'acting';`);
+
+ return database;
+}
+
+export function nowIso(): string {
+ return new Date().toISOString();
+}
diff --git a/src/lib/server/db/findings.ts b/src/lib/server/db/findings.ts
new file mode 100644
index 0000000..e1cb2e2
--- /dev/null
+++ b/src/lib/server/db/findings.ts
@@ -0,0 +1,142 @@
+/* src/lib/server/db/findings.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import type { FindingRow, FindingStatus, FindingWithPullRequest, RuleId } from '../types.ts';
+import { getDatabase, nowIso } from './database.ts';
+
+const joinedSelect = `
+ SELECT
+ findings.*,
+ pullRequests.title,
+ pullRequests.author,
+ pullRequests.url
+ FROM findings
+ JOIN pullRequests ON pullRequests.number = findings.prNumber
+`;
+
+export function getFinding(id: number): FindingWithPullRequest | null {
+ return getDatabase()
+ .query<FindingWithPullRequest, [number]>(`${joinedSelect} WHERE findings.id = ?`)
+ .get(id);
+}
+
+export function listFindingsForPullRequest(prNumber: number): FindingRow[] {
+ return getDatabase()
+ .query<FindingRow, [number]>('SELECT * FROM findings WHERE prNumber = ?')
+ .all(prNumber);
+}
+
+export function listOpenFindings(): FindingWithPullRequest[] {
+ return getDatabase()
+ .query<FindingWithPullRequest, []>(
+ `${joinedSelect}
+ WHERE findings.status IN ('pending', 'acting')
+ ORDER BY findings.createdAt DESC`
+ )
+ .all();
+}
+
+// Pending findings that never reached Discord, oldest first
+export function listUnnotifiedFindings(): FindingWithPullRequest[] {
+ return getDatabase()
+ .query<FindingWithPullRequest, []>(
+ `${joinedSelect}
+ WHERE findings.status = 'pending' AND findings.discordMessageId IS NULL
+ ORDER BY findings.createdAt ASC`
+ )
+ .all();
+}
+
+export interface NewFinding {
+ prNumber: number;
+ ruleId: RuleId;
+ filePath: string;
+ headSha: string;
+ reason: string;
+}
+
+export function insertFinding(finding: NewFinding): number {
+ const timestamp = nowIso();
+
+ const result = getDatabase()
+ .query(
+ `INSERT INTO findings (
+ prNumber,
+ ruleId,
+ filePath,
+ headSha,
+ reason,
+ status,
+ createdAt,
+ updatedAt
+ )
+ VALUES (?, ?, ?, ?, ?, 'pending', ?, ?)`
+ )
+ .run(
+ finding.prNumber,
+ finding.ruleId,
+ finding.filePath,
+ finding.headSha,
+ finding.reason,
+ timestamp,
+ timestamp
+ );
+
+ return Number(result.lastInsertRowid);
+}
+
+export function updateFindingEvidence(id: number, headSha: string, reason: string): void {
+ getDatabase()
+ .query('UPDATE findings SET headSha = ?, reason = ?, updatedAt = ? WHERE id = ?')
+ .run(headSha, reason, nowIso(), id);
+}
+
+export function setFindingStatus(id: number, status: FindingStatus, lastOutcome?: string): void {
+ getDatabase()
+ .query(
+ `UPDATE findings
+ SET status = ?, lastOutcome = COALESCE(?, lastOutcome), updatedAt = ?
+ WHERE id = ?`
+ )
+ .run(status, lastOutcome ?? null, nowIso(), id);
+}
+
+// Reopens a finding and forgets its old Discord message, so a fresh notification goes out
+export function reopenFinding(id: number, headSha: string, reason: string): void {
+ getDatabase()
+ .query(
+ `UPDATE findings
+ SET status = 'pending',
+ headSha = ?,
+ reason = ?,
+ lastOutcome = NULL,
+ commentId = NULL,
+ discordChannelId = NULL,
+ discordMessageId = NULL,
+ updatedAt = ?
+ WHERE id = ?`
+ )
+ .run(headSha, reason, nowIso(), id);
+}
+
+// Atomic claim: only one caller can move a finding from pending to acting
+export function claimFinding(id: number): boolean {
+ const result = getDatabase()
+ .query(
+ `UPDATE findings SET status = 'acting', updatedAt = ? WHERE id = ? AND status = 'pending'`
+ )
+ .run(nowIso(), id);
+
+ return result.changes === 1;
+}
+
+export function setFindingComment(id: number, commentId: number): void {
+ getDatabase().query('UPDATE findings SET commentId = ? WHERE id = ?').run(commentId, id);
+}
+
+export function setFindingDiscordMessage(id: number, channelId: string, messageId: string): void {
+ getDatabase()
+ .query('UPDATE findings SET discordChannelId = ?, discordMessageId = ? WHERE id = ?')
+ .run(channelId, messageId, id);
+}
diff --git a/src/lib/server/db/keyValue.ts b/src/lib/server/db/keyValue.ts
new file mode 100644
index 0000000..a3432d3
--- /dev/null
+++ b/src/lib/server/db/keyValue.ts
@@ -0,0 +1,26 @@
+/* src/lib/server/db/keyValue.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getDatabase } from './database.ts';
+
+export function getValue(key: string): string | null {
+ const row = getDatabase()
+ .query<{ value: string }, [string]>('SELECT value FROM keyValue WHERE key = ?')
+ .get(key);
+
+ return row?.value ?? null;
+}
+
+export function setValue(key: string, value: string): void {
+ getDatabase()
+ .query(
+ `INSERT INTO keyValue (key, value) VALUES (?, ?)
+ ON CONFLICT (key) DO UPDATE SET value = excluded.value`
+ )
+ .run(key, value);
+}
+
+export function deleteValue(key: string): void {
+ getDatabase().query('DELETE FROM keyValue WHERE key = ?').run(key);
+}
diff --git a/src/lib/server/db/pullRequests.ts b/src/lib/server/db/pullRequests.ts
new file mode 100644
index 0000000..2f752a7
--- /dev/null
+++ b/src/lib/server/db/pullRequests.ts
@@ -0,0 +1,67 @@
+/* src/lib/server/db/pullRequests.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import type { PullRequestRow, PullRequestSummary } from '../types.ts';
+import { getDatabase, nowIso } from './database.ts';
+
+export function getPullRequestRow(number: number): PullRequestRow | null {
+ return getDatabase()
+ .query<PullRequestRow, [number]>('SELECT * FROM pullRequests WHERE number = ?')
+ .get(number);
+}
+
+// Saves the latest PR details and leaves the scan markers untouched
+export function upsertPullRequest(pullRequest: PullRequestSummary): void {
+ getDatabase()
+ .query<unknown, [Record<string, string | number>]>(
+ `INSERT INTO pullRequests (
+ number,
+ title,
+ author,
+ authorAssociation,
+ url,
+ state,
+ headSha,
+ updatedAt
+ )
+ VALUES (
+ $number,
+ $title,
+ $author,
+ $authorAssociation,
+ $url,
+ $state,
+ $headSha,
+ $updatedAt
+ )
+ ON CONFLICT (number) DO UPDATE SET
+ title = excluded.title,
+ author = excluded.author,
+ authorAssociation = excluded.authorAssociation,
+ url = excluded.url,
+ state = excluded.state,
+ headSha = excluded.headSha,
+ updatedAt = excluded.updatedAt`
+ )
+ .run({
+ $number: pullRequest.number,
+ $title: pullRequest.title,
+ $author: pullRequest.author,
+ $authorAssociation: pullRequest.authorAssociation,
+ $url: pullRequest.url,
+ $state: pullRequest.state,
+ $headSha: pullRequest.headSha,
+ $updatedAt: pullRequest.updatedAt
+ });
+}
+
+export function markPullRequestScanned(number: number, scannedSha: string): void {
+ getDatabase()
+ .query('UPDATE pullRequests SET scannedSha = ?, scannedAt = ? WHERE number = ?')
+ .run(scannedSha, nowIso(), number);
+}
+
+export function markPullRequestClosed(number: number): void {
+ getDatabase().query(`UPDATE pullRequests SET state = 'closed' WHERE number = ?`).run(number);
+}
diff --git a/src/lib/server/discord/bot.ts b/src/lib/server/discord/bot.ts
new file mode 100644
index 0000000..4b6236a
--- /dev/null
+++ b/src/lib/server/discord/bot.ts
@@ -0,0 +1,184 @@
+/* src/lib/server/discord/bot.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { Client, Events, MessageFlags, type Interaction } from 'discord.js';
+
+import { getConfig } from '../config.ts';
+import { getFinding, listUnnotifiedFindings, setFindingDiscordMessage } from '../db/findings.ts';
+import { onFindingEvent } from '../events.ts';
+import { createLogger } from '../logger.ts';
+import { performModerationAction, type ModerationDecision } from '../moderation/actions.ts';
+import { buttonPrefix, renderFinding } from './render.ts';
+
+const logger = createLogger('discord');
+
+let client: Client | undefined;
+
+function isReady(): boolean {
+ return client?.isReady() ?? false;
+}
+
+// Findings with a send in flight, so the event path and the catch-up path never double-post
+const sendsInFlight = new Set<number>();
+
+async function sendNotification(findingId: number): Promise<void> {
+ if (sendsInFlight.has(findingId)) {
+ return;
+ }
+
+ sendsInFlight.add(findingId);
+
+ try {
+ await deliverNotification(findingId);
+ } finally {
+ sendsInFlight.delete(findingId);
+ }
+}
+
+// Sends to the configured channel when set, otherwise as a direct message
+async function deliverNotification(findingId: number): Promise<void> {
+ const finding = getFinding(findingId);
+
+ if (!client || !isReady() || !finding) {
+ return;
+ }
+
+ if (finding.status !== 'pending' || finding.discordMessageId !== null) {
+ return;
+ }
+
+ const { discordChannelId, discordUserId } = getConfig();
+ const payload = renderFinding(finding);
+
+ if (discordChannelId) {
+ const channel = await client.channels.fetch(discordChannelId);
+
+ if (!channel?.isSendable()) {
+ throw new Error(`Channel ${discordChannelId} cannot receive messages`);
+ }
+
+ const message = await channel.send(payload);
+
+ setFindingDiscordMessage(finding.id, message.channelId, message.id);
+ return;
+ }
+
+ const user = await client.users.fetch(discordUserId);
+ const message = await user.send(payload);
+
+ setFindingDiscordMessage(finding.id, message.channelId, message.id);
+}
+
+async function refreshNotification(findingId: number): Promise<void> {
+ const finding = getFinding(findingId);
+
+ if (!client || !isReady() || !finding) {
+ return;
+ }
+
+ if (finding.discordChannelId === null || finding.discordMessageId === null) {
+ return;
+ }
+
+ const channel = await client.channels.fetch(finding.discordChannelId);
+
+ if (!channel?.isTextBased()) {
+ return;
+ }
+
+ await channel.messages.edit(finding.discordMessageId, renderFinding(finding));
+}
+
+// Catches up on findings that could not be delivered earlier
+export async function flushNotifications(): Promise<void> {
+ if (!isReady()) {
+ return;
+ }
+
+ for (const finding of listUnnotifiedFindings()) {
+ await sendNotification(finding.id);
+ }
+}
+
+async function handleInteraction(interaction: Interaction): Promise<void> {
+ if (!interaction.isButton()) {
+ return;
+ }
+
+ const [prefix, decision, findingIdText] = interaction.customId.split(':');
+ const findingId = Number(findingIdText);
+
+ if (prefix !== buttonPrefix || !Number.isInteger(findingId)) {
+ return;
+ }
+
+ if (decision !== 'approve' && decision !== 'ignore') {
+ return;
+ }
+
+ if (interaction.user.id !== getConfig().discordUserId) {
+ await interaction.reply({
+ content: 'Only the configured moderator can use these buttons.',
+ flags: MessageFlags.Ephemeral
+ });
+ return;
+ }
+
+ // Acknowledge within Discord's 3 second window, then do the slow GitHub work
+ await interaction.deferUpdate();
+
+ const outcome = await performModerationAction({
+ findingId,
+ decision: decision satisfies ModerationDecision,
+ source: 'discord'
+ });
+
+ logger.info(`Finding ${findingId} ${decision}: ${outcome.status}`);
+
+ // The findingChanged event redraws the message; this covers a finding that was already handled
+ await refreshNotification(findingId);
+}
+
+export async function startDiscordBot(): Promise<void> {
+ const { discordToken, discordUserId } = getConfig();
+
+ if (!discordToken || !discordUserId) {
+ logger.warn('DISCORD_BOT_TOKEN or DISCORD_USER_ID missing; Discord is disabled');
+ return;
+ }
+
+ // Buttons and direct messages need no privileged gateway intents
+ client = new Client({ intents: [] });
+
+ client.once(Events.ClientReady, (readyClient) => {
+ logger.info(`Connected as ${readyClient.user.tag}`);
+
+ void flushNotifications().catch((error) => logger.warn('Catch-up failed', error));
+ });
+
+ client.on(Events.InteractionCreate, (interaction) => {
+ void handleInteraction(interaction).catch((error) => logger.error('Interaction failed', error));
+ });
+
+ client.on(Events.Error, (error) => logger.error('Gateway error', error));
+
+ onFindingEvent('findingCreated', (findingId) => {
+ void sendNotification(findingId).catch((error) =>
+ logger.warn(`Could not notify finding ${findingId}; will retry after the next scan`, error)
+ );
+ });
+
+ onFindingEvent('findingChanged', (findingId) => {
+ void refreshNotification(findingId).catch((error) =>
+ logger.warn(`Could not update the message for finding ${findingId}`, error)
+ );
+ });
+
+ await client.login(discordToken);
+}
+
+export async function stopDiscordBot(): Promise<void> {
+ await client?.destroy();
+ client = undefined;
+}
diff --git a/src/lib/server/discord/render.ts b/src/lib/server/discord/render.ts
new file mode 100644
index 0000000..f2f6552
--- /dev/null
+++ b/src/lib/server/discord/render.ts
@@ -0,0 +1,109 @@
+/* src/lib/server/discord/render.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ EmbedBuilder,
+ type BaseMessageOptions
+} from 'discord.js';
+
+import { getConfig } from '../config.ts';
+import { getRule } from '../rules/index.ts';
+import type { FindingStatus, FindingWithPullRequest } from '../types.ts';
+
+export const buttonPrefix = 'tracker';
+
+const statusLabels: Record<FindingStatus, string> = {
+ pending: 'Awaiting your decision',
+ acting: 'Working…',
+ actioned: 'Done',
+ ignored: 'Ignored',
+ resolved: 'Resolved by the contributor',
+ prClosed: 'Pull request closed'
+};
+
+const statusColours: Record<FindingStatus, number> = {
+ pending: 0xeda100,
+ acting: 0x2a78d6,
+ actioned: 0x1baf7a,
+ ignored: 0x8a8a86,
+ resolved: 0x8a8a86,
+ prClosed: 0x8a8a86
+};
+
+function truncate(text: string, maxLength: number): string {
+ return text.length <= maxLength ? text : `${text.slice(0, maxLength - 1)}…`;
+}
+
+export function buildButtonId(decision: 'approve' | 'ignore', findingId: number): string {
+ return `${buttonPrefix}:${decision}:${findingId}`;
+}
+
+export function renderFinding(finding: FindingWithPullRequest): BaseMessageOptions {
+ const rule = getRule(finding.ruleId);
+
+ const embed = new EmbedBuilder()
+ .setTitle(truncate(`#${finding.prNumber} · ${finding.title}`, 250))
+ .setURL(finding.url)
+ .setColor(statusColours[finding.status])
+ .addFields(
+ {
+ name: 'Violation',
+ value: rule.title
+ },
+ {
+ name: 'Author',
+ value: `[${finding.author}](https://github.com/${finding.author})`,
+ inline: true
+ },
+ {
+ name: 'File',
+ value: `\`${finding.filePath}\``,
+ inline: true
+ },
+ {
+ name: 'Reason',
+ value: truncate(finding.reason, 1000)
+ },
+ {
+ name: 'Status',
+ value: statusLabels[finding.status]
+ }
+ );
+
+ if (finding.lastOutcome) {
+ embed.addFields({
+ name: 'Last result',
+ value: truncate(finding.lastOutcome, 1000)
+ });
+ }
+
+ if (getConfig().dryRun) {
+ embed.setFooter({ text: 'Dry run is ON: buttons will not change anything on GitHub' });
+ }
+
+ if (finding.status !== 'pending') {
+ return {
+ embeds: [embed],
+ components: []
+ };
+ }
+
+ const approveButton = new ButtonBuilder()
+ .setCustomId(buildButtonId('approve', finding.id))
+ .setLabel(rule.actionLabel)
+ .setStyle(rule.actionType === 'closePr' ? ButtonStyle.Danger : ButtonStyle.Primary);
+
+ const ignoreButton = new ButtonBuilder()
+ .setCustomId(buildButtonId('ignore', finding.id))
+ .setLabel('Ignore')
+ .setStyle(ButtonStyle.Secondary);
+
+ return {
+ embeds: [embed],
+ components: [new ActionRowBuilder<ButtonBuilder>().addComponents(approveButton, ignoreButton)]
+ };
+}
diff --git a/src/lib/server/events.ts b/src/lib/server/events.ts
new file mode 100644
index 0000000..f3ee5bc
--- /dev/null
+++ b/src/lib/server/events.ts
@@ -0,0 +1,23 @@
+/* src/lib/server/events.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { EventEmitter } from 'node:events';
+
+// findingCreated: a new pending finding needs a notification
+// findingChanged: an existing finding changed and its notification needs a refresh
+export type FindingEvent = 'findingCreated' | 'findingChanged';
+
+const emitter = new EventEmitter();
+
+export function emitFindingEvent(event: FindingEvent, findingId: number): void {
+ emitter.emit(event, findingId);
+}
+
+export function onFindingEvent(event: FindingEvent, listener: (findingId: number) => void): void {
+ emitter.on(event, listener);
+}
+
+export function removeFindingListeners(): void {
+ emitter.removeAllListeners();
+}
diff --git a/src/lib/server/github/client.ts b/src/lib/server/github/client.ts
new file mode 100644
index 0000000..99ad06b
--- /dev/null
+++ b/src/lib/server/github/client.ts
@@ -0,0 +1,229 @@
+/* src/lib/server/github/client.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getConfig } from '../config.ts';
+import { createLogger, sleep } from '../logger.ts';
+
+const logger = createLogger('github');
+
+const apiBase = 'https://api.github.com';
+const requestTimeoutMs = 20_000;
+const retryDelaysMs = [1_000, 3_000];
+
+export class GitHubError extends Error {
+ constructor(
+ readonly status: number,
+ message: string
+ ) {
+ super(message);
+ this.name = 'GitHubError';
+ }
+}
+
+export class RateLimitError extends Error {
+ constructor(readonly resumeAt: number) {
+ super(`GitHub rate limit reached; resumes at ${new Date(resumeAt).toISOString()}`);
+ this.name = 'RateLimitError';
+ }
+}
+
+interface RateBucket {
+ limit: number;
+ remaining: number;
+ resetAt: number;
+}
+
+const rateBuckets = new Map<string, RateBucket>();
+
+let blockedUntil = 0;
+
+export interface GitHubRequest {
+ method?: 'GET' | 'POST' | 'PATCH';
+ path: string;
+ query?: Record<string, string | number>;
+ body?: unknown;
+ accept?: string;
+ etag?: string | null;
+ // Moderator-approved actions may spend the reserve kept back from the scanner
+ priority?: boolean;
+}
+
+export interface GitHubResponse<Data> {
+ status: number;
+ data: Data;
+ etag: string | null;
+ notModified: boolean;
+}
+
+function assertWithinRateLimit(resource: string, priority: boolean): void {
+ const now = Date.now();
+
+ if (now < blockedUntil) {
+ throw new RateLimitError(blockedUntil);
+ }
+
+ const bucket = rateBuckets.get(resource);
+
+ if (!bucket || now >= bucket.resetAt) {
+ return;
+ }
+
+ const scannerReserve = Math.min(getConfig().rateLimitReserve, Math.floor(bucket.limit * 0.1));
+ const floor = priority ? 0 : scannerReserve;
+
+ if (bucket.remaining <= floor) {
+ throw new RateLimitError(bucket.resetAt);
+ }
+}
+
+function recordRateLimit(headers: Headers, fallbackResource: string): void {
+ const remaining = headers.get('x-ratelimit-remaining');
+ const reset = headers.get('x-ratelimit-reset');
+
+ if (remaining === null || reset === null) {
+ return;
+ }
+
+ rateBuckets.set(headers.get('x-ratelimit-resource') ?? fallbackResource, {
+ limit: Number(headers.get('x-ratelimit-limit') ?? 0),
+ remaining: Number(remaining),
+ resetAt: Number(reset) * 1000
+ });
+}
+
+function buildUrl(request: GitHubRequest): string {
+ const url = new URL(apiBase + request.path);
+
+ for (const [name, value] of Object.entries(request.query ?? {})) {
+ url.searchParams.set(name, String(value));
+ }
+
+ return url.toString();
+}
+
+function buildHeaders(request: GitHubRequest): Headers {
+ const headers = new Headers({
+ Accept: request.accept ?? 'application/vnd.github+json',
+ 'User-Agent': 'is-a-tracker',
+ 'X-GitHub-Api-Version': '2022-11-28'
+ });
+
+ const { githubToken } = getConfig();
+
+ if (githubToken) {
+ headers.set('Authorization', `Bearer ${githubToken}`);
+ }
+
+ if (request.etag) {
+ headers.set('If-None-Match', request.etag);
+ }
+
+ if (request.body !== undefined) {
+ headers.set('Content-Type', 'application/json');
+ }
+
+ return headers;
+}
+
+async function readErrorMessage(response: Response): Promise<string> {
+ const text = await response.text().catch(() => '');
+
+ try {
+ const parsed = JSON.parse(text) as { message?: string };
+
+ return parsed.message ?? text;
+ } catch {
+ return text;
+ }
+}
+
+async function sendOnce<Data>(request: GitHubRequest): Promise<GitHubResponse<Data>> {
+ const resource = request.path.startsWith('/search') ? 'search' : 'core';
+
+ assertWithinRateLimit(resource, request.priority ?? false);
+
+ const response = await fetch(buildUrl(request), {
+ method: request.method ?? 'GET',
+ headers: buildHeaders(request),
+ body: request.body === undefined ? undefined : JSON.stringify(request.body),
+ signal: AbortSignal.timeout(requestTimeoutMs)
+ });
+
+ recordRateLimit(response.headers, resource);
+
+ const etag = response.headers.get('etag');
+
+ if (response.status === 304) {
+ return {
+ status: 304,
+ data: undefined as Data,
+ etag,
+ notModified: true
+ };
+ }
+
+ const retryAfter = Number(response.headers.get('retry-after') ?? 0);
+ const exhausted = response.headers.get('x-ratelimit-remaining') === '0';
+
+ if ((response.status === 403 || response.status === 429) && (retryAfter > 0 || exhausted)) {
+ const resetAt = Number(response.headers.get('x-ratelimit-reset') ?? 0) * 1000;
+ const resumeAt = retryAfter > 0 ? Date.now() + retryAfter * 1000 : resetAt;
+
+ blockedUntil = Math.max(blockedUntil, resumeAt);
+
+ throw new RateLimitError(resumeAt);
+ }
+
+ if (!response.ok) {
+ throw new GitHubError(response.status, await readErrorMessage(response));
+ }
+
+ const isJson = (response.headers.get('content-type') ?? '').includes('json');
+ const wantsRaw = (request.accept ?? '').includes('raw');
+ const data = isJson && !wantsRaw ? await response.json() : await response.text();
+
+ return {
+ status: response.status,
+ data: data as Data,
+ etag,
+ notModified: false
+ };
+}
+
+function isRetryable(error: unknown): boolean {
+ if (error instanceof RateLimitError) {
+ return false;
+ }
+
+ if (error instanceof GitHubError) {
+ return error.status >= 500;
+ }
+
+ // Network failures and timeouts
+ return true;
+}
+
+export async function githubRequest<Data>(request: GitHubRequest): Promise<GitHubResponse<Data>> {
+ // Writes are never retried automatically, so nothing is ever posted twice
+ const isRead = (request.method ?? 'GET') === 'GET';
+ const attempts = isRead ? retryDelaysMs.length + 1 : 1;
+
+ for (let attempt = 1; ; attempt += 1) {
+ try {
+ return await sendOnce<Data>(request);
+ } catch (error) {
+ if (attempt >= attempts || !isRetryable(error)) {
+ throw error;
+ }
+
+ logger.warn(`${request.path} failed, retrying`, error);
+
+ await sleep(retryDelaysMs[attempt - 1]);
+ }
+ }
+}
+
+export function getRateLimitSnapshot(): Record<string, RateBucket> {
+ return Object.fromEntries(rateBuckets);
+}
diff --git a/src/lib/server/github/diff.ts b/src/lib/server/github/diff.ts
new file mode 100644
index 0000000..b0c8aa9
--- /dev/null
+++ b/src/lib/server/github/diff.ts
@@ -0,0 +1,35 @@
+/* src/lib/server/github/diff.ts
+ * MIT — (c) Doughmination System®
+ */
+
+const hunkHeader = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
+
+// Line numbers on the new side of a patch that GitHub accepts review comments on
+export function getCommentableLines(patch: string | undefined): Set<number> {
+ const commentableLines = new Set<number>();
+
+ if (!patch) {
+ return commentableLines;
+ }
+
+ let newLineNumber = 0;
+
+ for (const patchLine of patch.split('\n')) {
+ const header = hunkHeader.exec(patchLine);
+
+ if (header) {
+ newLineNumber = Number(header[1]);
+ continue;
+ }
+
+ if (newLineNumber === 0 || patchLine.startsWith('-') || patchLine.startsWith('\\')) {
+ continue;
+ }
+
+ // Added lines and unchanged context lines both exist on the new side
+ commentableLines.add(newLineNumber);
+ newLineNumber += 1;
+ }
+
+ return commentableLines;
+}
diff --git a/src/lib/server/github/pullRequests.ts b/src/lib/server/github/pullRequests.ts
new file mode 100644
index 0000000..ed7e5af
--- /dev/null
+++ b/src/lib/server/github/pullRequests.ts
@@ -0,0 +1,235 @@
+/* src/lib/server/github/pullRequests.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getConfig, getRepoPath } from '../config.ts';
+import type { PullRequestSummary } from '../types.ts';
+import { GitHubError, githubRequest } from './client.ts';
+
+// Shapes below mirror GitHub's REST payloads, so they keep GitHub's field names
+interface ApiPullRequest {
+ number: number;
+ title: string;
+ html_url: string;
+ state: 'open' | 'closed';
+ updated_at: string;
+ author_association: string;
+ user: { login: string } | null;
+ head: { sha: string };
+}
+
+export interface PullRequestFile {
+ filename: string;
+ status: string;
+ patch?: string;
+}
+
+export interface ApiReview {
+ id: number;
+ state: string;
+ body: string | null;
+ commit_id: string;
+ html_url: string;
+ user: { login: string } | null;
+}
+
+export interface ReviewComment {
+ path: string;
+ line: number;
+ side: 'RIGHT';
+ body: string;
+}
+
+function toSummary(pullRequest: ApiPullRequest): PullRequestSummary {
+ return {
+ number: pullRequest.number,
+ title: pullRequest.title,
+ author: pullRequest.user?.login ?? 'ghost',
+ authorAssociation: pullRequest.author_association,
+ url: pullRequest.html_url,
+ state: pullRequest.state,
+ headSha: pullRequest.head.sha,
+ updatedAt: pullRequest.updated_at
+ };
+}
+
+export interface PullRequestPage {
+ pullRequests: PullRequestSummary[];
+ etag: string | null;
+ notModified: boolean;
+}
+
+export async function listPullRequests(options: {
+ state: 'open' | 'all';
+ page: number;
+ etag?: string | null;
+}): Promise<PullRequestPage> {
+ const response = await githubRequest<ApiPullRequest[]>({
+ path: `${getRepoPath()}/pulls`,
+ query: {
+ state: options.state,
+ sort: 'updated',
+ direction: 'desc',
+ per_page: 100,
+ page: options.page
+ },
+ etag: options.etag
+ });
+
+ return {
+ pullRequests: response.notModified ? [] : response.data.map(toSummary),
+ etag: response.etag,
+ notModified: response.notModified
+ };
+}
+
+export async function getPullRequest(
+ number: number,
+ priority = false
+): Promise<PullRequestSummary> {
+ const response = await githubRequest<ApiPullRequest>({
+ path: `${getRepoPath()}/pulls/${number}`,
+ priority
+ });
+
+ return toSummary(response.data);
+}
+
+export async function listPullRequestFiles(
+ number: number,
+ priority = false
+): Promise<PullRequestFile[]> {
+ const files: PullRequestFile[] = [];
+
+ // Three pages cover 300 files; a registration PR beyond that is not ours to judge
+ for (let page = 1; page <= 3; page += 1) {
+ const response = await githubRequest<PullRequestFile[]>({
+ path: `${getRepoPath()}/pulls/${number}/files`,
+ query: {
+ per_page: 100,
+ page
+ },
+ priority
+ });
+
+ files.push(...response.data);
+
+ if (response.data.length < 100) {
+ break;
+ }
+ }
+
+ return files;
+}
+
+// Fork commits are readable through the base repository by their SHA
+export async function getFileContent(
+ path: string,
+ ref: string,
+ priority = false
+): Promise<string | null> {
+ const encodedPath = path.split('/').map(encodeURIComponent).join('/');
+
+ try {
+ const response = await githubRequest<string>({
+ path: `${getRepoPath()}/contents/${encodedPath}`,
+ query: { ref },
+ accept: 'application/vnd.github.raw+json',
+ priority
+ });
+
+ return response.data;
+ } catch (error) {
+ if (error instanceof GitHubError && error.status === 404) {
+ return null;
+ }
+
+ throw error;
+ }
+}
+
+export async function countMergedPullRequests(login: string, priority = false): Promise<number> {
+ const { repoOwner, repoName } = getConfig();
+
+ const response = await githubRequest<{ total_count: number }>({
+ path: '/search/issues',
+ query: {
+ q: `repo:${repoOwner}/${repoName} is:pr is:merged author:${login}`,
+ per_page: 1
+ },
+ priority
+ });
+
+ return response.data.total_count;
+}
+
+let authenticatedLogin: string | undefined;
+
+export async function getAuthenticatedLogin(): Promise<string> {
+ if (!authenticatedLogin) {
+ const response = await githubRequest<{ login: string }>({
+ path: '/user',
+ priority: true
+ });
+
+ authenticatedLogin = response.data.login;
+ }
+
+ return authenticatedLogin;
+}
+
+export interface CreatedComment {
+ id: number;
+ html_url: string;
+}
+
+export async function createIssueComment(number: number, body: string): Promise<CreatedComment> {
+ const response = await githubRequest<CreatedComment>({
+ method: 'POST',
+ path: `${getRepoPath()}/issues/${number}/comments`,
+ body: { body },
+ priority: true
+ });
+
+ return response.data;
+}
+
+export async function closePullRequest(number: number): Promise<void> {
+ await githubRequest({
+ method: 'PATCH',
+ path: `${getRepoPath()}/pulls/${number}`,
+ body: { state: 'closed' },
+ priority: true
+ });
+}
+
+export async function listReviews(number: number): Promise<ApiReview[]> {
+ const response = await githubRequest<ApiReview[]>({
+ path: `${getRepoPath()}/pulls/${number}/reviews`,
+ query: { per_page: 100 },
+ priority: true
+ });
+
+ return response.data;
+}
+
+export async function createChangesRequestedReview(options: {
+ number: number;
+ commitId: string;
+ body: string;
+ comments: ReviewComment[];
+}): Promise<ApiReview> {
+ const response = await githubRequest<ApiReview>({
+ method: 'POST',
+ path: `${getRepoPath()}/pulls/${options.number}/reviews`,
+ body: {
+ commit_id: options.commitId,
+ event: 'REQUEST_CHANGES',
+ body: options.body,
+ comments: options.comments
+ },
+ priority: true
+ });
+
+ return response.data;
+}
diff --git a/src/lib/server/logger.ts b/src/lib/server/logger.ts
new file mode 100644
index 0000000..ab4190c
--- /dev/null
+++ b/src/lib/server/logger.ts
@@ -0,0 +1,28 @@
+/* src/lib/server/logger.ts
+ * MIT — (c) Doughmination System®
+ */
+
+type LogLevel = 'info' | 'warn' | 'error';
+
+function write(level: LogLevel, scope: string, message: string, error?: unknown): void {
+ const line = `${new Date().toISOString()} [${level}] [${scope}] ${message}`;
+ const detail = error instanceof Error ? ` (${error.message})` : '';
+
+ console[level](line + detail);
+}
+
+export function createLogger(scope: string) {
+ return {
+ info: (message: string) => write('info', scope, message),
+ warn: (message: string, error?: unknown) => write('warn', scope, message, error),
+ error: (message: string, error?: unknown) => write('error', scope, message, error)
+ };
+}
+
+export function describeError(error: unknown): string {
+ return error instanceof Error ? error.message : String(error);
+}
+
+export function sleep(milliseconds: number): Promise<void> {
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
+}
diff --git a/src/lib/server/messages.ts b/src/lib/server/messages.ts
new file mode 100644
index 0000000..859128f
--- /dev/null
+++ b/src/lib/server/messages.ts
@@ -0,0 +1,37 @@
+/* src/lib/server/messages.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { readFileSync } from 'node:fs';
+
+import defaultMessages from '../../../config/messages.json' with { type: 'json' };
+import { getConfig } from './config.ts';
+import { createLogger } from './logger.ts';
+
+const logger = createLogger('messages');
+
+export type ModerationMessages = typeof defaultMessages;
+
+// Read on every use, so wording edits apply without a restart
+export function getMessages(): ModerationMessages {
+ try {
+ const overrides = JSON.parse(
+ readFileSync(getConfig().messagesPath, 'utf8')
+ ) as Partial<ModerationMessages>;
+
+ return {
+ nsRecords: {
+ ...defaultMessages.nsRecords,
+ ...overrides.nsRecords
+ },
+ noReplyEmail: {
+ ...defaultMessages.noReplyEmail,
+ ...overrides.noReplyEmail
+ }
+ };
+ } catch (error) {
+ logger.warn('Could not read the messages file; using built-in wording', error);
+
+ return defaultMessages;
+ }
+}
diff --git a/src/lib/server/moderation/actions.ts b/src/lib/server/moderation/actions.ts
new file mode 100644
index 0000000..6694eb5
--- /dev/null
+++ b/src/lib/server/moderation/actions.ts
@@ -0,0 +1,173 @@
+/* src/lib/server/moderation/actions.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getConfig } from '../config.ts';
+import { recordAction } from '../db/auditLog.ts';
+import {
+ claimFinding,
+ getFinding,
+ setFindingStatus,
+ updateFindingEvidence
+} from '../db/findings.ts';
+import { upsertPullRequest } from '../db/pullRequests.ts';
+import { emitFindingEvent } from '../events.ts';
+import { getPullRequest } from '../github/pullRequests.ts';
+import { createLogger, describeError } from '../logger.ts';
+import { getRule } from '../rules/index.ts';
+import type {
+ ActionOutcome,
+ ActionSource,
+ ActionType,
+ FindingStatus,
+ FindingWithPullRequest
+} from '../types.ts';
+import { evaluatePullRequest } from './evaluate.ts';
+import { executors } from './executors.ts';
+
+const logger = createLogger('actions');
+
+export type ModerationDecision = 'approve' | 'ignore';
+
+interface Resolution {
+ outcome: ActionOutcome;
+ findingStatus: FindingStatus;
+}
+
+// Runs with the finding already claimed; decides what happens and where the finding ends up
+async function resolveDecision(
+ finding: FindingWithPullRequest,
+ decision: ModerationDecision
+): Promise<Resolution> {
+ if (decision === 'ignore') {
+ return {
+ findingStatus: 'ignored',
+ outcome: {
+ status: 'success',
+ summary: 'Ignored. No action was taken on GitHub.'
+ }
+ };
+ }
+
+ // Revalidate against the latest commit before touching anything
+ const pullRequest = await getPullRequest(finding.prNumber, true);
+
+ upsertPullRequest(pullRequest);
+
+ if (pullRequest.state !== 'open') {
+ return {
+ findingStatus: 'prClosed',
+ outcome: {
+ status: 'skipped',
+ summary: 'The pull request is no longer open. Nothing was done.'
+ }
+ };
+ }
+
+ const evaluation = await evaluatePullRequest(pullRequest, {
+ fresh: true,
+ priority: true
+ });
+
+ const violation = evaluation.violations.find(
+ (candidate) => candidate.ruleId === finding.ruleId && candidate.filePath === finding.filePath
+ );
+
+ if (!violation) {
+ return {
+ findingStatus: 'resolved',
+ outcome: {
+ status: 'skipped',
+ summary: 'The latest commit no longer has this violation. Nothing was done.'
+ }
+ };
+ }
+
+ updateFindingEvidence(finding.id, pullRequest.headSha, violation.reason);
+
+ const rule = getRule(finding.ruleId);
+
+ if (getConfig().dryRun) {
+ return {
+ findingStatus: 'pending',
+ outcome: {
+ status: 'dryRun',
+ summary: `Dry run: would have run "${rule.actionLabel}" on #${pullRequest.number}.`
+ }
+ };
+ }
+
+ const outcome = await executors[rule.actionType]({
+ pullRequest,
+ finding,
+ evaluation
+ });
+
+ return {
+ findingStatus: 'actioned',
+ outcome
+ };
+}
+
+// The single entry point for Discord buttons and dashboard buttons alike
+export async function performModerationAction(options: {
+ findingId: number;
+ decision: ModerationDecision;
+ source: ActionSource;
+}): Promise<ActionOutcome> {
+ const finding = getFinding(options.findingId);
+
+ if (!finding) {
+ return {
+ status: 'failure',
+ summary: 'That finding no longer exists.'
+ };
+ }
+
+ if (!claimFinding(finding.id)) {
+ return {
+ status: 'skipped',
+ summary: `Already handled (status: ${finding.status}).`
+ };
+ }
+
+ const rule = getRule(finding.ruleId);
+ const actionType: ActionType = options.decision === 'ignore' ? 'ignore' : rule.actionType;
+
+ let resolution: Resolution;
+
+ try {
+ resolution = await resolveDecision(finding, options.decision);
+ } catch (error) {
+ logger.error(`Action on finding ${finding.id} failed`, error);
+
+ // Back to pending so it can be retried; the retry revalidates from scratch
+ resolution = {
+ findingStatus: 'pending',
+ outcome: {
+ status: 'failure',
+ summary: `Failed: ${describeError(error)}`
+ }
+ };
+ }
+
+ const { outcome, findingStatus } = resolution;
+
+ setFindingStatus(finding.id, findingStatus, outcome.summary);
+
+ recordAction({
+ findingId: finding.id,
+ prNumber: finding.prNumber,
+ contributor: finding.author,
+ ruleId: finding.ruleId,
+ actionType,
+ source: options.source,
+ status: outcome.status,
+ detail: outcome.summary,
+ githubUrl: outcome.githubUrl ?? null
+ });
+
+ emitFindingEvent('findingChanged', finding.id);
+
+ return outcome;
+}
diff --git a/src/lib/server/moderation/eligibility.ts b/src/lib/server/moderation/eligibility.ts
new file mode 100644
index 0000000..28a393d
--- /dev/null
+++ b/src/lib/server/moderation/eligibility.ts
@@ -0,0 +1,72 @@
+/* src/lib/server/moderation/eligibility.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getConfig } from '../config.ts';
+import { getContributor, saveContributor } from '../db/contributors.ts';
+import { countMergedPullRequests } from '../github/pullRequests.ts';
+import type { ContributorEligibility } from '../rules/types.ts';
+import type { PullRequestSummary } from '../types.ts';
+
+const maintainerAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR'];
+
+// GitHub's own marker for an author who already has a commit merged into the repository
+const returningAssociation = 'CONTRIBUTOR';
+const ineligibleCacheMs = 30 * 60 * 1000;
+
+function describe(login: string, mergedPrCount: number, required: number): ContributorEligibility {
+ const eligible = mergedPrCount >= required;
+
+ return {
+ eligible,
+ explanation: eligible
+ ? `@${login} has ${mergedPrCount} merged pull request(s) in this repository.`
+ : `@${login} has ${mergedPrCount} merged pull request(s) in this repository; ` +
+ `${required} needed before NS records are allowed.`
+ };
+}
+
+// Eligible = a maintainer, or enough previously merged PRs in the repository
+export async function getContributorEligibility(
+ pullRequest: PullRequestSummary,
+ options: {
+ fresh: boolean;
+ priority: boolean;
+ }
+): Promise<ContributorEligibility> {
+ const { author, authorAssociation } = pullRequest;
+ const required = getConfig().nsMinMergedPullRequests;
+
+ if (maintainerAssociations.includes(authorAssociation)) {
+ return {
+ eligible: true,
+ explanation: `@${author} is a repository ${authorAssociation.toLowerCase()}.`
+ };
+ }
+
+ if (authorAssociation === returningAssociation) {
+ return {
+ eligible: true,
+ explanation: `@${author} already has commits merged into this repository.`
+ };
+ }
+
+ const cached = getContributor(author);
+
+ if (cached && cached.mergedPrCount >= required) {
+ // Merged PRs never un-merge, so an eligible result is safe to keep
+ return describe(author, cached.mergedPrCount, required);
+ }
+
+ const cacheAgeMs = cached ? Date.now() - Date.parse(cached.checkedAt) : Infinity;
+
+ if (cached && !options.fresh && cacheAgeMs < ineligibleCacheMs) {
+ return describe(author, cached.mergedPrCount, required);
+ }
+
+ const mergedPrCount = await countMergedPullRequests(author, options.priority);
+
+ saveContributor(author, mergedPrCount);
+
+ return describe(author, mergedPrCount, required);
+}
diff --git a/src/lib/server/moderation/evaluate.ts b/src/lib/server/moderation/evaluate.ts
new file mode 100644
index 0000000..e2b87c2
--- /dev/null
+++ b/src/lib/server/moderation/evaluate.ts
@@ -0,0 +1,88 @@
+/* src/lib/server/moderation/evaluate.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getConfig } from '../config.ts';
+import { getFileContent, listPullRequestFiles } from '../github/pullRequests.ts';
+import { rules } from '../rules/index.ts';
+import type { ContributorEligibility, DomainFile, Violation } from '../rules/types.ts';
+import type { PullRequestSummary } from '../types.ts';
+import { getContributorEligibility } from './eligibility.ts';
+
+const registrationFile = /^domains\/[^/]+\.json$/;
+
+export interface Evaluation {
+ pullRequest: PullRequestSummary;
+ files: DomainFile[];
+ violations: Violation[];
+ skippedFileCount: number;
+}
+
+function parseJson(content: string): unknown {
+ try {
+ return JSON.parse(content);
+ } catch {
+ return null;
+ }
+}
+
+// Fetches the PR's registration files at its head commit and runs every rule over them
+export async function evaluatePullRequest(
+ pullRequest: PullRequestSummary,
+ options: {
+ fresh: boolean;
+ priority: boolean;
+ }
+): Promise<Evaluation> {
+ const changedFiles = await listPullRequestFiles(pullRequest.number, options.priority);
+
+ const candidates = changedFiles.filter(
+ (file) => registrationFile.test(file.filename) && file.status !== 'removed'
+ );
+
+ const inspected = candidates.slice(0, getConfig().maxFilesPerPullRequest);
+ const files: DomainFile[] = [];
+
+ for (const file of inspected) {
+ const content = await getFileContent(file.filename, pullRequest.headSha, options.priority);
+
+ if (content === null) {
+ continue;
+ }
+
+ files.push({
+ path: file.filename,
+ status: file.status,
+ patch: file.patch,
+ content,
+ json: parseJson(content)
+ });
+ }
+
+ let eligibility: Promise<ContributorEligibility> | undefined;
+
+ const getEligibility = () => {
+ eligibility ??= getContributorEligibility(pullRequest, options);
+
+ return eligibility;
+ };
+
+ const violations: Violation[] = [];
+
+ for (const rule of rules) {
+ violations.push(
+ ...(await rule.evaluate({
+ pullRequest,
+ files,
+ getEligibility
+ }))
+ );
+ }
+
+ return {
+ pullRequest,
+ files,
+ violations,
+ skippedFileCount: candidates.length - inspected.length
+ };
+}
diff --git a/src/lib/server/moderation/executors.ts b/src/lib/server/moderation/executors.ts
new file mode 100644
index 0000000..97c9833
--- /dev/null
+++ b/src/lib/server/moderation/executors.ts
@@ -0,0 +1,136 @@
+/* src/lib/server/moderation/executors.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { setFindingComment } from '../db/findings.ts';
+import { markPullRequestClosed } from '../db/pullRequests.ts';
+import { getCommentableLines } from '../github/diff.ts';
+import { GitHubError } from '../github/client.ts';
+import {
+ closePullRequest,
+ createChangesRequestedReview,
+ createIssueComment,
+ getAuthenticatedLogin,
+ listReviews
+} from '../github/pullRequests.ts';
+import { getMessages } from '../messages.ts';
+import { findNoReplyEmail, findOwnerEmailLine } from '../rules/noReplyEmail.ts';
+import type { ActionOutcome, ActionType, FindingRow, PullRequestSummary } from '../types.ts';
+import type { Evaluation } from './evaluate.ts';
+import { retireFindings } from './reconcile.ts';
+
+export interface ExecutorInput {
+ pullRequest: PullRequestSummary;
+ finding: FindingRow;
+ evaluation: Evaluation;
+}
+
+type Executor = (input: ExecutorInput) => Promise<ActionOutcome>;
+
+async function closeWithPolicyComment(input: ExecutorInput): Promise<ActionOutcome> {
+ const { pullRequest, finding } = input;
+
+ // A stored comment id means an earlier attempt already explained; never explain twice
+ if (finding.commentId === null) {
+ const comment = await createIssueComment(
+ pullRequest.number,
+ getMessages().nsRecords.closeComment
+ );
+
+ setFindingComment(finding.id, comment.id);
+ }
+
+ await closePullRequest(pullRequest.number);
+
+ markPullRequestClosed(pullRequest.number);
+ retireFindings(pullRequest.number, 'The pull request was closed through the tool.');
+
+ return {
+ status: 'success',
+ summary: `Closed #${pullRequest.number} with the NS policy explanation.`,
+ githubUrl: pullRequest.url
+ };
+}
+
+function reviewMarker(finding: FindingRow): string {
+ return `<!-- is-a-tracker:${finding.ruleId}:${finding.filePath} -->`;
+}
+
+async function requestEmailChanges(input: ExecutorInput): Promise<ActionOutcome> {
+ const { pullRequest, finding, evaluation } = input;
+ const messages = getMessages().noReplyEmail;
+ const marker = reviewMarker(finding);
+
+ const login = await getAuthenticatedLogin();
+ const reviews = await listReviews(pullRequest.number);
+
+ const duplicate = reviews.find(
+ (review) =>
+ review.user?.login === login &&
+ review.state === 'CHANGES_REQUESTED' &&
+ review.commit_id === pullRequest.headSha &&
+ (review.body ?? '').includes(marker)
+ );
+
+ if (duplicate) {
+ return {
+ status: 'skipped',
+ summary: 'Changes were already requested for this file on this commit.',
+ githubUrl: duplicate.html_url
+ };
+ }
+
+ const file = evaluation.files.find((candidate) => candidate.path === finding.filePath);
+ const email = file ? findNoReplyEmail(file.json) : null;
+ const line = file && email ? findOwnerEmailLine(file.content, email) : null;
+ const canCommentInline = line !== null && getCommentableLines(file?.patch).has(line);
+
+ const fallbackBody = `${messages.reviewComment}\n\nFile: \`${finding.filePath}\`\n\n${marker}`;
+
+ if (canCommentInline) {
+ try {
+ const review = await createChangesRequestedReview({
+ number: pullRequest.number,
+ commitId: pullRequest.headSha,
+ body: `${messages.reviewSummary}\n\n${marker}`,
+ comments: [
+ {
+ path: finding.filePath,
+ line,
+ side: 'RIGHT',
+ body: messages.reviewComment
+ }
+ ]
+ });
+
+ return {
+ status: 'success',
+ summary: `Requested changes on #${pullRequest.number} with an inline comment on line ${line}.`,
+ githubUrl: review.html_url
+ };
+ } catch (error) {
+ // 422 means GitHub refused the line position; fall through to a body-only review
+ if (!(error instanceof GitHubError) || error.status !== 422) {
+ throw error;
+ }
+ }
+ }
+
+ const review = await createChangesRequestedReview({
+ number: pullRequest.number,
+ commitId: pullRequest.headSha,
+ body: fallbackBody,
+ comments: []
+ });
+
+ return {
+ status: 'success',
+ summary: `Requested changes on #${pullRequest.number} in the review body (line not commentable).`,
+ githubUrl: review.html_url
+ };
+}
+
+export const executors: Record<Exclude<ActionType, 'ignore'>, Executor> = {
+ closePr: closeWithPolicyComment,
+ requestChanges: requestEmailChanges
+};
diff --git a/src/lib/server/moderation/pipeline.test.ts b/src/lib/server/moderation/pipeline.test.ts
new file mode 100644
index 0000000..14cd488
--- /dev/null
+++ b/src/lib/server/moderation/pipeline.test.ts
@@ -0,0 +1,368 @@
+/* src/lib/server/moderation/pipeline.test.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import assert from 'node:assert/strict';
+import { before, describe, test } from 'node:test';
+
+process.env.DATABASE_PATH = ':memory:';
+process.env.GITHUB_TOKEN = 'test-token';
+process.env.DRY_RUN = 'true';
+
+import { getConfig } from '../config.ts';
+import { getModerationStats, searchActions } from '../db/auditLog.ts';
+import { listFindingsForPullRequest } from '../db/findings.ts';
+import { performModerationAction } from './actions.ts';
+import { scanOnce } from './scanner.ts';
+
+interface FakePullRequest {
+ number: number;
+ author: string;
+ association: string;
+ sha: string;
+ state: 'open' | 'closed';
+ updatedAt: string;
+ fileName: string;
+ json: unknown;
+}
+
+interface RecordedWrite {
+ method: string;
+ path: string;
+ body: {
+ state?: string;
+ event?: string;
+ commit_id?: string;
+ comments?: {
+ path: string;
+ line: number;
+ body: string;
+ }[];
+ };
+}
+
+const nsJson = {
+ owner: {
+ username: 'newcomer',
+ email: '[email protected]'
+ },
+ records: {
+ NS: ['ns1.example.com', 'ns2.example.com']
+ }
+};
+
+const noReplyJson = {
+ owner: {
+ username: 'hidden',
+ email: '[email protected]'
+ },
+ records: {
+ CNAME: 'hidden.github.io'
+ }
+};
+
+const fakePullRequests = new Map<number, FakePullRequest>();
+const writes: RecordedWrite[] = [];
+
+function addPullRequest(pullRequest: FakePullRequest): void {
+ fakePullRequests.set(pullRequest.number, pullRequest);
+}
+
+function toApi(pullRequest: FakePullRequest) {
+ return {
+ number: pullRequest.number,
+ title: `Add ${pullRequest.fileName}`,
+ html_url: `https://github.com/is-a-dev/register/pull/${pullRequest.number}`,
+ state: pullRequest.state,
+ updated_at: pullRequest.updatedAt,
+ author_association: pullRequest.association,
+ user: { login: pullRequest.author },
+ head: { sha: pullRequest.sha }
+ };
+}
+
+function fileText(pullRequest: FakePullRequest): string {
+ return JSON.stringify(pullRequest.json, null, 2);
+}
+
+function jsonResponse(data: unknown): Response {
+ return new Response(JSON.stringify(data), {
+ headers: { 'content-type': 'application/json' }
+ });
+}
+
+async function fakeGitHub(input: string | URL | Request, init?: RequestInit): Promise<Response> {
+ const url = new URL(String(input));
+ const method = init?.method ?? 'GET';
+ const path = url.pathname.replace('/repos/is-a-dev/register', '');
+ const numberMatch = /^\/(?:pulls|issues)\/(\d+)/.exec(path);
+ const pullRequest = numberMatch ? fakePullRequests.get(Number(numberMatch[1])) : undefined;
+
+ if (method !== 'GET') {
+ writes.push({
+ method,
+ path,
+ body: JSON.parse(String(init?.body))
+ });
+
+ if (method === 'PATCH' && pullRequest) {
+ pullRequest.state = 'closed';
+ }
+
+ return jsonResponse({
+ id: writes.length,
+ html_url: `https://github.com/fake/${writes.length}`
+ });
+ }
+
+ if (path === '/pulls') {
+ const wanted = url.searchParams.get('state');
+
+ const listed = [...fakePullRequests.values()]
+ .filter((candidate) => wanted === 'all' || candidate.state === 'open')
+ .sort((first, second) => second.updatedAt.localeCompare(first.updatedAt));
+
+ return jsonResponse(listed.map(toApi));
+ }
+
+ if (path === '/search/issues' || url.pathname === '/search/issues') {
+ return jsonResponse({ total_count: 0 });
+ }
+
+ if (url.pathname === '/user') {
+ return jsonResponse({ login: 'moderator' });
+ }
+
+ if (path.startsWith('/contents/')) {
+ const owner = [...fakePullRequests.values()].find(
+ (candidate) => candidate.sha === url.searchParams.get('ref')
+ );
+
+ return new Response(owner ? fileText(owner) : 'missing', { status: owner ? 200 : 404 });
+ }
+
+ if (pullRequest && path.endsWith('/files')) {
+ const addedLines = fileText(pullRequest)
+ .split('\n')
+ .map((line) => `+${line}`);
+
+ return jsonResponse([
+ {
+ filename: pullRequest.fileName,
+ status: 'added',
+ patch: [`@@ -0,0 +1,${addedLines.length} @@`, ...addedLines].join('\n')
+ }
+ ]);
+ }
+
+ if (pullRequest && path.endsWith('/reviews')) {
+ return jsonResponse([]);
+ }
+
+ if (pullRequest) {
+ return jsonResponse(toApi(pullRequest));
+ }
+
+ return new Response('{"message":"Not Found"}', { status: 404 });
+}
+
+function findingFor(prNumber: number) {
+ return listFindingsForPullRequest(prNumber)[0];
+}
+
+before(() => {
+ globalThis.fetch = fakeGitHub as typeof fetch;
+
+ addPullRequest({
+ number: 1,
+ author: 'newcomer',
+ association: 'NONE',
+ sha: 'sha-one',
+ state: 'open',
+ updatedAt: '2026-11-01T00:00:01Z',
+ fileName: 'domains/newcomer.json',
+ json: nsJson
+ });
+
+ addPullRequest({
+ number: 2,
+ author: 'hidden',
+ association: 'NONE',
+ sha: 'sha-two',
+ state: 'open',
+ updatedAt: '2026-11-01T00:00:02Z',
+ fileName: 'domains/hidden.json',
+ json: noReplyJson
+ });
+
+ // A returning contributor may request NS records
+ addPullRequest({
+ number: 3,
+ author: 'regular',
+ association: 'CONTRIBUTOR',
+ sha: 'sha-three',
+ state: 'open',
+ updatedAt: '2026-11-01T00:00:03Z',
+ fileName: 'domains/regular.json',
+ json: nsJson
+ });
+
+ addPullRequest({
+ number: 4,
+ author: 'fixer',
+ association: 'NONE',
+ sha: 'sha-four',
+ state: 'open',
+ updatedAt: '2026-11-01T00:00:04Z',
+ fileName: 'domains/fixer.json',
+ json: noReplyJson
+ });
+});
+
+describe('moderation pipeline', () => {
+ test('a scan creates one finding per real violation', async () => {
+ await scanOnce();
+
+ assert.equal(findingFor(1).ruleId, 'nsRecords');
+ assert.equal(findingFor(2).ruleId, 'noReplyEmail');
+ assert.equal(listFindingsForPullRequest(3).length, 0);
+ assert.equal(findingFor(4).status, 'pending');
+ });
+
+ test('a repeat scan creates no duplicates', async () => {
+ await scanOnce();
+
+ assert.equal(listFindingsForPullRequest(1).length, 1);
+ assert.equal(listFindingsForPullRequest(2).length, 1);
+ });
+
+ test('dry run writes nothing and leaves the finding pending', async () => {
+ const outcome = await performModerationAction({
+ findingId: findingFor(1).id,
+ decision: 'approve',
+ source: 'discord'
+ });
+
+ assert.equal(outcome.status, 'dryRun');
+ assert.equal(writes.length, 0);
+ assert.equal(findingFor(1).status, 'pending');
+ assert.equal(getModerationStats().closedTotal, 0);
+ });
+
+ test('approving an NS finding comments once and closes once', async () => {
+ getConfig().dryRun = false;
+
+ const outcome = await performModerationAction({
+ findingId: findingFor(1).id,
+ decision: 'approve',
+ source: 'discord'
+ });
+
+ assert.equal(outcome.status, 'success');
+ assert.deepEqual(
+ writes.map((write) => `${write.method} ${write.path}`),
+ ['POST /issues/1/comments', 'PATCH /pulls/1']
+ );
+ assert.deepEqual(writes[1].body, { state: 'closed' });
+ assert.equal(findingFor(1).status, 'actioned');
+ });
+
+ test('a second approval of the same finding does nothing', async () => {
+ const outcome = await performModerationAction({
+ findingId: findingFor(1).id,
+ decision: 'approve',
+ source: 'dashboard'
+ });
+
+ assert.equal(outcome.status, 'skipped');
+ assert.equal(writes.length, 2);
+ });
+
+ test('approving a no-reply finding requests changes inline on the email line', async () => {
+ const outcome = await performModerationAction({
+ findingId: findingFor(2).id,
+ decision: 'approve',
+ source: 'dashboard'
+ });
+
+ const review = writes[2];
+
+ assert.equal(outcome.status, 'success');
+ assert.equal(review.path, '/pulls/2/reviews');
+ assert.equal(review.body.event, 'REQUEST_CHANGES');
+ assert.equal(review.body.commit_id, 'sha-two');
+ assert.equal(review.body.comments?.length, 1);
+
+ const comment = review.body.comments![0];
+
+ assert.equal(comment.path, 'domains/hidden.json');
+ assert.equal(comment.line, 4);
+ assert.ok(comment.body.includes('GitHub no-reply email address'));
+ assert.equal(fakePullRequests.get(2)?.state, 'open');
+ });
+
+ test('a fix pushed by the contributor resolves the finding', async () => {
+ const pullRequest = fakePullRequests.get(4)!;
+
+ pullRequest.sha = 'sha-four-fixed';
+ pullRequest.updatedAt = '2026-11-02T00:00:00Z';
+ pullRequest.json = {
+ owner: { username: 'fixer' },
+ records: { CNAME: 'fixer.github.io' }
+ };
+
+ await scanOnce();
+
+ assert.equal(findingFor(4).status, 'resolved');
+ });
+
+ test('a violation fixed after detection is caught by revalidation', async () => {
+ addPullRequest({
+ number: 5,
+ author: 'racer',
+ association: 'NONE',
+ sha: 'sha-five',
+ state: 'open',
+ updatedAt: '2026-11-03T00:00:00Z',
+ fileName: 'domains/racer.json',
+ json: nsJson
+ });
+
+ await scanOnce();
+
+ // The contributor removes the NS records before the button is pressed
+ const pullRequest = fakePullRequests.get(5)!;
+
+ pullRequest.sha = 'sha-five-fixed';
+ pullRequest.json = {
+ owner: { username: 'racer' },
+ records: { A: ['1.2.3.4'] }
+ };
+
+ const writesBefore = writes.length;
+
+ const outcome = await performModerationAction({
+ findingId: findingFor(5).id,
+ decision: 'approve',
+ source: 'discord'
+ });
+
+ assert.equal(outcome.status, 'skipped');
+ assert.equal(writes.length, writesBefore);
+ assert.equal(findingFor(5).status, 'resolved');
+ });
+
+ test('statistics count successful actions only', () => {
+ const stats = getModerationStats();
+
+ assert.equal(stats.closedTotal, 1);
+ assert.equal(stats.nsClosures, 1);
+ assert.equal(stats.reviewsTotal, 1);
+ // Dry run, closure, review and the revalidation skip; the claimed-twice attempt logs nothing
+ assert.equal(searchActions('').length, 4);
+ assert.equal(
+ searchActions('newcomer').every((action) => action.prNumber === 1),
+ true
+ );
+ });
+});
diff --git a/src/lib/server/moderation/reconcile.ts b/src/lib/server/moderation/reconcile.ts
new file mode 100644
index 0000000..9e0a044
--- /dev/null
+++ b/src/lib/server/moderation/reconcile.ts
@@ -0,0 +1,86 @@
+/* src/lib/server/moderation/reconcile.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import {
+ insertFinding,
+ listFindingsForPullRequest,
+ reopenFinding,
+ setFindingStatus,
+ updateFindingEvidence
+} from '../db/findings.ts';
+import { emitFindingEvent } from '../events.ts';
+import { getRule } from '../rules/index.ts';
+import type { Violation } from '../rules/types.ts';
+import type { FindingRow, PullRequestSummary } from '../types.ts';
+
+function findingKey(item: { ruleId: string; filePath: string }): string {
+ return `${item.ruleId}:${item.filePath}`;
+}
+
+function shouldReopen(finding: FindingRow): boolean {
+ if (finding.status === 'resolved' || finding.status === 'prClosed') {
+ return true;
+ }
+
+ // A PR that was closed through the tool and is open again needs a fresh decision
+ return finding.status === 'actioned' && getRule(finding.ruleId).actionType === 'closePr';
+}
+
+// Brings stored findings in line with what the latest commit actually violates
+export function reconcileFindings(pullRequest: PullRequestSummary, violations: Violation[]): void {
+ const existing = new Map(
+ listFindingsForPullRequest(pullRequest.number).map((finding) => [findingKey(finding), finding])
+ );
+
+ const violatedKeys = new Set<string>();
+
+ for (const violation of violations) {
+ const key = findingKey(violation);
+ const finding = existing.get(key);
+
+ violatedKeys.add(key);
+
+ if (!finding) {
+ const findingId = insertFinding({
+ prNumber: pullRequest.number,
+ ruleId: violation.ruleId,
+ filePath: violation.filePath,
+ headSha: pullRequest.headSha,
+ reason: violation.reason
+ });
+
+ emitFindingEvent('findingCreated', findingId);
+ continue;
+ }
+
+ if (finding.status === 'pending') {
+ // Same unresolved violation on a newer commit: refresh quietly, no new ping
+ updateFindingEvidence(finding.id, pullRequest.headSha, violation.reason);
+ emitFindingEvent('findingChanged', finding.id);
+ continue;
+ }
+
+ if (shouldReopen(finding)) {
+ reopenFinding(finding.id, pullRequest.headSha, violation.reason);
+ emitFindingEvent('findingCreated', finding.id);
+ }
+ }
+
+ for (const finding of existing.values()) {
+ if (finding.status === 'pending' && !violatedKeys.has(findingKey(finding))) {
+ setFindingStatus(finding.id, 'resolved', 'The contributor fixed this in a later commit.');
+ emitFindingEvent('findingChanged', finding.id);
+ }
+ }
+}
+
+// Retires every open finding of a PR that is no longer open
+export function retireFindings(prNumber: number, explanation: string): void {
+ for (const finding of listFindingsForPullRequest(prNumber)) {
+ if (finding.status === 'pending') {
+ setFindingStatus(finding.id, 'prClosed', explanation);
+ emitFindingEvent('findingChanged', finding.id);
+ }
+ }
+}
diff --git a/src/lib/server/moderation/scanner.ts b/src/lib/server/moderation/scanner.ts
new file mode 100644
index 0000000..ddffcf9
--- /dev/null
+++ b/src/lib/server/moderation/scanner.ts
@@ -0,0 +1,198 @@
+/* src/lib/server/moderation/scanner.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getConfig } from '../config.ts';
+import { deleteValue, getValue, setValue } from '../db/keyValue.ts';
+import {
+ getPullRequestRow,
+ markPullRequestScanned,
+ upsertPullRequest
+} from '../db/pullRequests.ts';
+import { RateLimitError } from '../github/client.ts';
+import { listPullRequests } from '../github/pullRequests.ts';
+import { createLogger, describeError } from '../logger.ts';
+import type { PullRequestSummary } from '../types.ts';
+import { evaluatePullRequest } from './evaluate.ts';
+import { reconcileFindings, retireFindings } from './reconcile.ts';
+
+const logger = createLogger('scanner');
+
+const watermarkKey = 'scanner.watermark';
+const etagKey = 'scanner.etag';
+const lastScanKey = 'scanner.lastScanAt';
+const lastErrorKey = 'scanner.lastError';
+const maxPages = 15;
+
+export interface ScannerStatus {
+ lastScanAt: string | null;
+ lastError: string | null;
+}
+
+export function getScannerStatus(): ScannerStatus {
+ return {
+ lastScanAt: getValue(lastScanKey),
+ lastError: getValue(lastErrorKey)
+ };
+}
+
+// First run: every open PR. Later runs: anything updated since the watermark, closed PRs included
+async function collectUpdatedPullRequests(watermark: string | null): Promise<{
+ pullRequests: PullRequestSummary[];
+ etag: string | null;
+} | null> {
+ const collected: PullRequestSummary[] = [];
+ let firstPageEtag: string | null = null;
+
+ for (let page = 1; page <= maxPages; page += 1) {
+ const result = await listPullRequests({
+ state: watermark === null ? 'open' : 'all',
+ page,
+ etag: page === 1 && watermark !== null ? getValue(etagKey) : null
+ });
+
+ if (result.notModified) {
+ return null;
+ }
+
+ if (page === 1) {
+ firstPageEtag = result.etag;
+ }
+
+ const fresh = result.pullRequests.filter(
+ (pullRequest) => watermark === null || pullRequest.updatedAt >= watermark
+ );
+
+ collected.push(...fresh);
+
+ const reachedOldPullRequests = fresh.length < result.pullRequests.length;
+
+ if (reachedOldPullRequests || result.pullRequests.length < 100) {
+ break;
+ }
+ }
+
+ return {
+ pullRequests: collected,
+ etag: firstPageEtag
+ };
+}
+
+async function processPullRequest(pullRequest: PullRequestSummary): Promise<void> {
+ const previous = getPullRequestRow(pullRequest.number);
+
+ upsertPullRequest(pullRequest);
+
+ if (pullRequest.state !== 'open') {
+ retireFindings(pullRequest.number, 'The pull request was closed or merged.');
+ return;
+ }
+
+ const alreadyScanned =
+ previous !== null && previous.state === 'open' && previous.scannedSha === pullRequest.headSha;
+
+ if (alreadyScanned) {
+ return;
+ }
+
+ const evaluation = await evaluatePullRequest(pullRequest, {
+ fresh: false,
+ priority: false
+ });
+
+ reconcileFindings(pullRequest, evaluation.violations);
+ markPullRequestScanned(pullRequest.number, pullRequest.headSha);
+
+ if (evaluation.violations.length > 0) {
+ logger.info(`#${pullRequest.number}: ${evaluation.violations.length} violation(s)`);
+ }
+}
+
+export async function scanOnce(): Promise<void> {
+ const watermark = getValue(watermarkKey);
+ const updated = await collectUpdatedPullRequests(watermark);
+
+ if (updated === null) {
+ return;
+ }
+
+ // Oldest first, so the watermark can stop just before the first failure
+ const ordered = updated.pullRequests.sort((first, second) =>
+ first.updatedAt.localeCompare(second.updatedAt)
+ );
+
+ let newWatermark = watermark;
+
+ for (const pullRequest of ordered) {
+ try {
+ await processPullRequest(pullRequest);
+ newWatermark = pullRequest.updatedAt;
+ } catch (error) {
+ if (!(error instanceof RateLimitError)) {
+ // One broken PR must not stall the queue; it is rechecked when it next changes
+ logger.error(`#${pullRequest.number} could not be evaluated; skipping`, error);
+ newWatermark = pullRequest.updatedAt;
+ continue;
+ }
+
+ if (newWatermark !== null) {
+ setValue(watermarkKey, newWatermark);
+ }
+
+ // The list changed but was not fully handled, so the next poll must refetch it
+ deleteValue(etagKey);
+
+ throw error;
+ }
+ }
+
+ if (newWatermark !== null) {
+ setValue(watermarkKey, newWatermark);
+ } else {
+ setValue(watermarkKey, new Date().toISOString());
+ }
+
+ if (updated.etag) {
+ setValue(etagKey, updated.etag);
+ }
+}
+
+let timer: ReturnType<typeof setTimeout> | undefined;
+let stopped = false;
+
+async function runCycle(afterScan: () => Promise<void>): Promise<void> {
+ let delayMs = getConfig().pollIntervalSeconds * 1000;
+
+ try {
+ await scanOnce();
+ setValue(lastScanKey, new Date().toISOString());
+ deleteValue(lastErrorKey);
+ } catch (error) {
+ setValue(lastErrorKey, describeError(error));
+
+ if (error instanceof RateLimitError) {
+ delayMs = Math.max(delayMs, error.resumeAt - Date.now() + 5_000);
+ logger.warn(`Paused for ${Math.round(delayMs / 1000)}s`, error);
+ } else {
+ logger.error('Scan failed; will retry next cycle', error);
+ }
+ }
+
+ await afterScan().catch((error) => logger.warn('Post-scan step failed', error));
+
+ if (!stopped) {
+ timer = setTimeout(() => void runCycle(afterScan), delayMs);
+ }
+}
+
+export function startScanner(afterScan: () => Promise<void>): void {
+ stopped = false;
+ logger.info(`Polling every ${getConfig().pollIntervalSeconds}s`);
+
+ void runCycle(afterScan);
+}
+
+export function stopScanner(): void {
+ stopped = true;
+ clearTimeout(timer);
+}
diff --git a/src/lib/server/rules/index.ts b/src/lib/server/rules/index.ts
new file mode 100644
index 0000000..ba0e321
--- /dev/null
+++ b/src/lib/server/rules/index.ts
@@ -0,0 +1,21 @@
+/* src/lib/server/rules/index.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import type { RuleId } from '../types.ts';
+import { noReplyEmailRule } from './noReplyEmail.ts';
+import { nsRecordsRule } from './nsRecords.ts';
+import type { Rule } from './types.ts';
+
+// Add a new rule module here and the scanner, Discord and dashboard all pick it up
+export const rules: Rule[] = [nsRecordsRule, noReplyEmailRule];
+
+export function getRule(ruleId: RuleId): Rule {
+ const rule = rules.find((candidate) => candidate.id === ruleId);
+
+ if (!rule) {
+ throw new Error(`Unknown rule: ${ruleId}`);
+ }
+
+ return rule;
+}
diff --git a/src/lib/server/rules/noReplyEmail.ts b/src/lib/server/rules/noReplyEmail.ts
new file mode 100644
index 0000000..ea4636a
--- /dev/null
+++ b/src/lib/server/rules/noReplyEmail.ts
@@ -0,0 +1,59 @@
+/* src/lib/server/rules/noReplyEmail.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import type { Rule, Violation } from './types.ts';
+import { isPlainObject } from './types.ts';
+
+const noReplyAddress = /^[^@\s]+@users\.noreply\.github\.com$/i;
+
+// Only the owner.email value in the JSON is inspected, never commit or profile emails
+export function findNoReplyEmail(json: unknown): string | null {
+ if (!isPlainObject(json) || !isPlainObject(json.owner)) {
+ return null;
+ }
+
+ const email = json.owner.email;
+
+ if (typeof email !== 'string') {
+ return null;
+ }
+
+ return noReplyAddress.test(email.trim()) ? email.trim() : null;
+}
+
+// 1-based line of the owner.email entry, or null when it cannot be pinned down
+export function findOwnerEmailLine(content: string, email: string): number | null {
+ const lines = content.split('\n');
+
+ const lineIndex = lines.findIndex((line) => /"email"\s*:/.test(line) && line.includes(email));
+
+ return lineIndex === -1 ? null : lineIndex + 1;
+}
+
+export const noReplyEmailRule: Rule = {
+ id: 'noReplyEmail',
+ title: 'GitHub no-reply owner.email',
+ actionType: 'requestChanges',
+ actionLabel: 'Request Changes',
+
+ async evaluate(context) {
+ const violations: Violation[] = [];
+
+ for (const file of context.files) {
+ const email = findNoReplyEmail(file.json);
+
+ if (email === null) {
+ continue;
+ }
+
+ violations.push({
+ ruleId: 'noReplyEmail',
+ filePath: file.path,
+ reason: `owner.email is a GitHub no-reply address (${email}).`
+ });
+ }
+
+ return violations;
+ }
+};
diff --git a/src/lib/server/rules/nsRecords.ts b/src/lib/server/rules/nsRecords.ts
new file mode 100644
index 0000000..537e478
--- /dev/null
+++ b/src/lib/server/rules/nsRecords.ts
@@ -0,0 +1,66 @@
+/* src/lib/server/rules/nsRecords.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import type { Rule, Violation } from './types.ts';
+import { isPlainObject } from './types.ts';
+
+// Returns the nameservers a registration file actually requests
+export function findNsRecords(json: unknown): string[] {
+ if (!isPlainObject(json)) {
+ return [];
+ }
+
+ // Older registrations use "record"; current ones use "records"
+ const records = json.records ?? json.record;
+
+ if (!isPlainObject(records)) {
+ return [];
+ }
+
+ const nsKey = Object.keys(records).find((key) => key.trim().toUpperCase() === 'NS');
+
+ if (nsKey === undefined) {
+ return [];
+ }
+
+ const value = records[nsKey];
+ const entries = Array.isArray(value) ? value : [value];
+
+ return entries
+ .filter((entry) => typeof entry === 'string' && entry.trim() !== '')
+ .map((entry) => String(entry).trim());
+}
+
+export const nsRecordsRule: Rule = {
+ id: 'nsRecords',
+ title: 'NS records from a first-time contributor',
+ actionType: 'closePr',
+ actionLabel: 'Close PR',
+
+ async evaluate(context) {
+ const violations: Violation[] = [];
+
+ for (const file of context.files) {
+ const nameservers = findNsRecords(file.json);
+
+ if (nameservers.length === 0) {
+ continue;
+ }
+
+ const eligibility = await context.getEligibility();
+
+ if (eligibility.eligible) {
+ return [];
+ }
+
+ violations.push({
+ ruleId: 'nsRecords',
+ filePath: file.path,
+ reason: `Requests NS records (${nameservers.join(', ')}). ${eligibility.explanation}`
+ });
+ }
+
+ return violations;
+ }
+};
diff --git a/src/lib/server/rules/rules.test.ts b/src/lib/server/rules/rules.test.ts
new file mode 100644
index 0000000..4e79738
--- /dev/null
+++ b/src/lib/server/rules/rules.test.ts
@@ -0,0 +1,107 @@
+/* src/lib/server/rules/rules.test.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import assert from 'node:assert/strict';
+import { describe, test } from 'node:test';
+
+import { getCommentableLines } from '../github/diff.ts';
+import { findNoReplyEmail, findOwnerEmailLine } from './noReplyEmail.ts';
+import { findNsRecords } from './nsRecords.ts';
+
+describe('findNsRecords', () => {
+ test('finds NS records under "records"', () => {
+ const json = {
+ records: {
+ NS: ['ns1.example.com', 'ns2.example.com']
+ }
+ };
+
+ assert.deepEqual(findNsRecords(json), ['ns1.example.com', 'ns2.example.com']);
+ });
+
+ test('finds NS records under the older "record" key', () => {
+ const json = {
+ record: {
+ ns: ['ns1.example.com']
+ }
+ };
+
+ assert.deepEqual(findNsRecords(json), ['ns1.example.com']);
+ });
+
+ test('ignores ordinary record types', () => {
+ const json = {
+ records: {
+ A: ['1.2.3.4'],
+ CNAME: 'example.com',
+ TXT: 'ns1.example.com'
+ }
+ };
+
+ assert.deepEqual(findNsRecords(json), []);
+ });
+
+ test('ignores an empty NS list and broken JSON', () => {
+ assert.deepEqual(findNsRecords({ records: { NS: [] } }), []);
+ assert.deepEqual(findNsRecords(null), []);
+ assert.deepEqual(findNsRecords('NS'), []);
+ });
+});
+
+describe('findNoReplyEmail', () => {
+ test('matches both no-reply forms', () => {
+ const plain = { owner: { email: '[email protected]' } };
+ const numbered = { owner: { email: '[email protected]' } };
+
+ assert.equal(findNoReplyEmail(plain), '[email protected]');
+ assert.equal(findNoReplyEmail(numbered), '[email protected]');
+ });
+
+ test('ignores personal addresses, missing emails and look-alike domains', () => {
+ assert.equal(findNoReplyEmail({ owner: { email: '[email protected]' } }), null);
+ assert.equal(findNoReplyEmail({ owner: { username: 'clove' } }), null);
+ assert.equal(
+ findNoReplyEmail({ owner: { email: '[email protected]' } }),
+ null
+ );
+ });
+
+ test('only reads owner.email, not other fields', () => {
+ const json = {
+ owner: { username: 'clove' },
+ description: 'mail me at [email protected]'
+ };
+
+ assert.equal(findNoReplyEmail(json), null);
+ });
+});
+
+describe('review line placement', () => {
+ const content = [
+ '{',
+ ' "owner": {',
+ ' "username": "clove",',
+ ' "email": "[email protected]"',
+ ' },',
+ ' "records": {}',
+ '}'
+ ].join('\n');
+
+ test('finds the owner.email line', () => {
+ assert.equal(findOwnerEmailLine(content, '[email protected]'), 4);
+ });
+
+ test('a new file makes every line commentable', () => {
+ const patch = '@@ -0,0 +1,3 @@\n+{\n+ "a": 1\n+}\n\\ No newline at end of file';
+
+ assert.deepEqual([...getCommentableLines(patch)], [1, 2, 3]);
+ });
+
+ test('a modified file exposes context and added lines only', () => {
+ const patch = '@@ -10,3 +10,3 @@\n context\n-removed\n+added\n context';
+
+ assert.deepEqual([...getCommentableLines(patch)], [10, 11, 12]);
+ assert.equal(getCommentableLines(undefined).size, 0);
+ });
+});
diff --git a/src/lib/server/rules/types.ts b/src/lib/server/rules/types.ts
new file mode 100644
index 0000000..1fcd3bd
--- /dev/null
+++ b/src/lib/server/rules/types.ts
@@ -0,0 +1,44 @@
+/* src/lib/server/rules/types.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import type { ActionType, PullRequestSummary, RuleId } from '../types.ts';
+
+export interface DomainFile {
+ path: string;
+ status: string;
+ patch: string | undefined;
+ content: string;
+ // null when the file is not valid JSON
+ json: unknown;
+}
+
+export interface ContributorEligibility {
+ eligible: boolean;
+ explanation: string;
+}
+
+export interface RuleContext {
+ pullRequest: PullRequestSummary;
+ files: DomainFile[];
+ // Lazy, so the contributor lookup only runs when a rule needs it
+ getEligibility: () => Promise<ContributorEligibility>;
+}
+
+export interface Violation {
+ ruleId: RuleId;
+ filePath: string;
+ reason: string;
+}
+
+export interface Rule {
+ id: RuleId;
+ title: string;
+ actionType: Exclude<ActionType, 'ignore'>;
+ actionLabel: string;
+ evaluate: (context: RuleContext) => Promise<Violation[]>;
+}
+
+export function isPlainObject(value: unknown): value is Record<string, unknown> {
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
+}
diff --git a/src/lib/server/runtime.ts b/src/lib/server/runtime.ts
new file mode 100644
index 0000000..9e0e79a
--- /dev/null
+++ b/src/lib/server/runtime.ts
@@ -0,0 +1,51 @@
+/* src/lib/server/runtime.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getConfig } from './config.ts';
+import { getDatabase } from './db/database.ts';
+import { flushNotifications, startDiscordBot, stopDiscordBot } from './discord/bot.ts';
+import { removeFindingListeners } from './events.ts';
+import { createLogger } from './logger.ts';
+import { startScanner, stopScanner } from './moderation/scanner.ts';
+
+const logger = createLogger('runtime');
+
+interface RuntimeHandle {
+ stop: () => Promise<void>;
+}
+
+// Kept on globalThis so a dev-server reload replaces the services instead of doubling them
+const globalStore = globalThis as typeof globalThis & {
+ trackerRuntime?: RuntimeHandle;
+};
+
+async function stop(): Promise<void> {
+ stopScanner();
+ removeFindingListeners();
+ await stopDiscordBot();
+}
+
+export async function startServices(): Promise<void> {
+ await globalStore.trackerRuntime?.stop();
+
+ globalStore.trackerRuntime = { stop };
+
+ const config = getConfig();
+
+ getDatabase();
+
+ logger.info(config.dryRun ? 'Dry run is ON: GitHub will not be changed' : 'Dry run is OFF');
+
+ if (!config.githubToken) {
+ logger.warn('GITHUB_TOKEN missing; reads are limited to 60 an hour and actions will fail');
+ }
+
+ await startDiscordBot().catch((error) => logger.error('Discord failed to start', error));
+
+ if (config.scannerEnabled) {
+ startScanner(flushNotifications);
+ } else {
+ logger.info('Scanner disabled (SCANNER_ENABLED=false)');
+ }
+}
diff --git a/src/lib/server/types.ts b/src/lib/server/types.ts
new file mode 100644
index 0000000..12d5ebb
--- /dev/null
+++ b/src/lib/server/types.ts
@@ -0,0 +1,71 @@
+/* src/lib/server/types.ts
+ * MIT — (c) Doughmination System®
+ */
+
+export type RuleId = 'nsRecords' | 'noReplyEmail';
+
+export type ActionType = 'closePr' | 'requestChanges' | 'ignore';
+
+export type ActionSource = 'discord' | 'dashboard';
+
+export type ActionStatus = 'success' | 'failure' | 'skipped' | 'dryRun';
+
+export type FindingStatus = 'pending' | 'acting' | 'actioned' | 'ignored' | 'resolved' | 'prClosed';
+
+export interface PullRequestSummary {
+ number: number;
+ title: string;
+ author: string;
+ authorAssociation: string;
+ url: string;
+ state: 'open' | 'closed';
+ headSha: string;
+ updatedAt: string;
+}
+
+export interface PullRequestRow extends PullRequestSummary {
+ scannedSha: string | null;
+ scannedAt: string | null;
+}
+
+export interface FindingRow {
+ id: number;
+ prNumber: number;
+ ruleId: RuleId;
+ filePath: string;
+ headSha: string;
+ reason: string;
+ status: FindingStatus;
+ lastOutcome: string | null;
+ commentId: number | null;
+ discordChannelId: string | null;
+ discordMessageId: string | null;
+ createdAt: string;
+ updatedAt: string;
+}
+
+export interface FindingWithPullRequest extends FindingRow {
+ title: string;
+ author: string;
+ url: string;
+}
+
+export interface ActionRow {
+ id: number;
+ findingId: number | null;
+ prNumber: number;
+ contributor: string;
+ ruleId: RuleId;
+ actionType: ActionType;
+ source: ActionSource;
+ status: ActionStatus;
+ detail: string;
+ githubUrl: string | null;
+ createdAt: string;
+}
+
+export interface ActionOutcome {
+ status: ActionStatus;
+ summary: string;
+ githubUrl?: string;
+}
diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts
new file mode 100644
index 0000000..2a5e365
--- /dev/null
+++ b/src/routes/+layout.server.ts
@@ -0,0 +1,20 @@
+/* src/routes/+layout.server.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getConfig } from '#lib/server/config.ts';
+import { listOpenFindings } from '#lib/server/db/findings.ts';
+import { isPasswordConfigured } from '#lib/server/auth.ts';
+
+import type { LayoutServerLoad } from './$types';
+
+export const load: LayoutServerLoad = ({ url }) => {
+ const onLoginPage = url.pathname === '/login';
+
+ return {
+ dryRun: getConfig().dryRun,
+ pendingTotal: onLoginPage ? 0 : listOpenFindings().length,
+ showNavigation: !onLoginPage,
+ canSignOut: isPasswordConfigured()
+ };
+};
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
new file mode 100644
index 0000000..195a3f2
--- /dev/null
+++ b/src/routes/+layout.svelte
@@ -0,0 +1,111 @@
+<!-- src/routes/+layout.svelte
+ MIT — (c) Doughmination System®
+-->
+
+<script lang="ts">
+ import '../app.css';
+
+ import { page } from '$app/state';
+ import favicon from '#lib/assets/favicon.svg';
+
+ import type { LayoutProps } from './$types';
+
+ let { data, children }: LayoutProps = $props();
+
+ const links = [
+ {
+ href: '/',
+ label: 'Overview'
+ },
+ {
+ href: '/pending',
+ label: 'Pending'
+ },
+ {
+ href: '/history',
+ label: 'History'
+ },
+ {
+ href: '/lookup',
+ label: 'Lookup'
+ }
+ ];
+</script>
+
+<svelte:head>
+ <link rel="icon" href={favicon} />
+</svelte:head>
+
+{#if data.showNavigation}
+ <header>
+ <nav class="page">
+ <strong>is-a-tracker</strong>
+
+ {#each links as link (link.href)}
+ <a href={link.href} aria-current={page.url.pathname === link.href ? 'page' : undefined}>
+ {link.label}
+ {#if link.href === '/pending' && data.pendingTotal > 0}
+ <span class="count">{data.pendingTotal}</span>
+ {/if}
+ </a>
+ {/each}
+
+ <span class="spacer"></span>
+
+ {#if data.dryRun}
+ <span class="pill" title="Buttons will not change anything on GitHub">Dry run ON</span>
+ {/if}
+
+ {#if data.canSignOut}
+ <form method="POST" action="/logout">
+ <button>Sign out</button>
+ </form>
+ {/if}
+ </nav>
+ </header>
+{/if}
+
+<main class="page">
+ {@render children()}
+</main>
+
+<style>
+ header {
+ background: var(--surface-card);
+ border-bottom: 1px solid var(--border);
+ }
+
+ nav {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 1.1rem;
+ padding-top: 0.7rem;
+ padding-bottom: 0.7rem;
+ }
+
+ nav a {
+ color: var(--text-secondary);
+ text-decoration: none;
+ padding: 0.15rem 0;
+ border-bottom: 2px solid transparent;
+ }
+
+ nav a[aria-current='page'] {
+ color: var(--text-primary);
+ border-bottom-color: var(--accent);
+ }
+
+ .count {
+ margin-left: 0.2rem;
+ padding: 0 0.45rem;
+ border-radius: 999px;
+ background: var(--accent);
+ color: var(--accent-text);
+ font-size: 0.8rem;
+ }
+
+ .spacer {
+ flex: 1;
+ }
+</style>
diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts
new file mode 100644
index 0000000..a783b15
--- /dev/null
+++ b/src/routes/+page.server.ts
@@ -0,0 +1,15 @@
+/* src/routes/+page.server.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getModerationStats } from '#lib/server/db/auditLog.ts';
+import { getScannerStatus } from '#lib/server/moderation/scanner.ts';
+
+import type { PageServerLoad } from './$types';
+
+export const load: PageServerLoad = () => {
+ return {
+ stats: getModerationStats(30),
+ scanner: getScannerStatus()
+ };
+};
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
new file mode 100644
index 0000000..a7495eb
--- /dev/null
+++ b/src/routes/+page.svelte
@@ -0,0 +1,82 @@
+<!-- src/routes/+page.svelte
+ MIT — (c) Doughmination System®
+-->
+
+<script lang="ts">
+ import ActionsChart from '#lib/components/ActionsChart.svelte';
+ import { formatTimestamp } from '#lib/labels.ts';
+
+ import type { PageProps } from './$types';
+
+ let { data }: PageProps = $props();
+
+ const tiles = $derived([
+ {
+ label: 'PRs closed',
+ value: data.stats.closedTotal
+ },
+ {
+ label: 'NS closures',
+ value: data.stats.nsClosures
+ },
+ {
+ label: 'Changes requested',
+ value: data.stats.reviewsTotal
+ },
+ {
+ label: 'Pending items',
+ value: data.stats.pendingTotal
+ }
+ ]);
+</script>
+
+<svelte:head>
+ <title>Overview · is-a-tracker</title>
+</svelte:head>
+
+<h1>Overview</h1>
+
+<section class="tiles">
+ {#each tiles as tile (tile.label)}
+ <div class="card tile">
+ <span class="muted">{tile.label}</span>
+ <strong>{tile.value}</strong>
+ </div>
+ {/each}
+</section>
+
+<section class="card">
+ <h2>Moderation actions, last 30 days</h2>
+ <ActionsChart daily={data.stats.daily} />
+</section>
+
+<p class="muted">
+ Last scan: {formatTimestamp(data.scanner.lastScanAt)}.
+ {#if data.scanner.lastError}
+ Last scan problem: {data.scanner.lastError}
+ {/if}
+</p>
+
+<style>
+ .tiles {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
+ gap: 1rem;
+ }
+
+ .tile {
+ display: flex;
+ flex-direction: column;
+ margin-bottom: 0;
+ }
+
+ .tile strong {
+ font-size: 2.1rem;
+ line-height: 1.2;
+ font-variant-numeric: tabular-nums;
+ }
+
+ .tiles {
+ margin-bottom: 1rem;
+ }
+</style>
diff --git a/src/routes/history/+page.server.ts b/src/routes/history/+page.server.ts
new file mode 100644
index 0000000..d60dc22
--- /dev/null
+++ b/src/routes/history/+page.server.ts
@@ -0,0 +1,19 @@
+/* src/routes/history/+page.server.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getConfig } from '#lib/server/config.ts';
+import { searchActions } from '#lib/server/db/auditLog.ts';
+
+import type { PageServerLoad } from './$types';
+
+export const load: PageServerLoad = ({ url }) => {
+ const searchText = url.searchParams.get('q') ?? '';
+ const { repoOwner, repoName } = getConfig();
+
+ return {
+ searchText,
+ repoUrl: `https://github.com/${repoOwner}/${repoName}`,
+ actions: searchActions(searchText)
+ };
+};
diff --git a/src/routes/history/+page.svelte b/src/routes/history/+page.svelte
new file mode 100644
index 0000000..40d27d0
--- /dev/null
+++ b/src/routes/history/+page.svelte
@@ -0,0 +1,80 @@
+<!-- src/routes/history/+page.svelte
+ MIT — (c) Doughmination System®
+-->
+
+<script lang="ts">
+ import {
+ actionLabels,
+ formatTimestamp,
+ labelFor,
+ ruleLabels,
+ statusLabels
+ } from '#lib/labels.ts';
+
+ import type { PageProps } from './$types';
+
+ let { data }: PageProps = $props();
+</script>
+
+<svelte:head>
+ <title>History · is-a-tracker</title>
+</svelte:head>
+
+<h1>Moderation history</h1>
+
+<form method="GET" class="formRow card">
+ <input
+ type="search"
+ name="q"
+ value={data.searchText}
+ placeholder="PR number, contributor, rule, action or status"
+ aria-label="Search history"
+ />
+ <button class="primary">Search</button>
+</form>
+
+{#if data.actions.length === 0}
+ <p class="card muted">No matching actions.</p>
+{:else}
+ <div class="card tableScroll">
+ <table>
+ <thead>
+ <tr>
+ <th>PR</th>
+ <th>Contributor</th>
+ <th>Violation</th>
+ <th>Action</th>
+ <th>When</th>
+ <th>Result</th>
+ </tr>
+ </thead>
+ <tbody>
+ {#each data.actions as action (action.id)}
+ <tr>
+ <td>
+ <a
+ href={action.githubUrl ?? `${data.repoUrl}/pull/${action.prNumber}`}
+ target="_blank"
+ rel="noreferrer"
+ >
+ #{action.prNumber}
+ </a>
+ </td>
+ <td>{action.contributor}</td>
+ <td>{labelFor(ruleLabels, action.ruleId)}</td>
+ <td>
+ {labelFor(actionLabels, action.actionType)}
+ <span class="muted">via {action.source}</span>
+ </td>
+ <td>{formatTimestamp(action.createdAt)}</td>
+ <td>
+ <span class="pill {action.status}" title={action.detail}>
+ {labelFor(statusLabels, action.status)}
+ </span>
+ </td>
+ </tr>
+ {/each}
+ </tbody>
+ </table>
+ </div>
+{/if}
diff --git a/src/routes/login/+page.server.ts b/src/routes/login/+page.server.ts
new file mode 100644
index 0000000..1e1a156
--- /dev/null
+++ b/src/routes/login/+page.server.ts
@@ -0,0 +1,48 @@
+/* src/routes/login/+page.server.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { fail, redirect } from '@sveltejs/kit';
+
+import {
+ createSessionToken,
+ isPasswordConfigured,
+ isPasswordCorrect,
+ isSessionValid,
+ sessionCookieName
+} from '#lib/server/auth.ts';
+import { sleep } from '#lib/server/logger.ts';
+
+import type { Actions, PageServerLoad } from './$types';
+
+const sessionLengthSeconds = 60 * 60 * 24 * 30;
+
+export const load: PageServerLoad = ({ cookies }) => {
+ if (!isPasswordConfigured() || isSessionValid(cookies.get(sessionCookieName))) {
+ redirect(303, '/');
+ }
+};
+
+export const actions: Actions = {
+ default: async ({ request, cookies, url }) => {
+ const formData = await request.formData();
+ const password = String(formData.get('password') ?? '');
+
+ if (!isPasswordCorrect(password)) {
+ // Slows down guessing
+ await sleep(750);
+
+ return fail(401, { problem: 'Wrong password.' });
+ }
+
+ cookies.set(sessionCookieName, createSessionToken(), {
+ path: '/',
+ httpOnly: true,
+ sameSite: 'lax',
+ secure: url.protocol === 'https:',
+ maxAge: sessionLengthSeconds
+ });
+
+ redirect(303, '/');
+ }
+};
diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte
new file mode 100644
index 0000000..bdb5a58
--- /dev/null
+++ b/src/routes/login/+page.svelte
@@ -0,0 +1,31 @@
+<!-- src/routes/login/+page.svelte
+ MIT — (c) Doughmination System®
+-->
+
+<script lang="ts">
+ import type { PageProps } from './$types';
+
+ let { form }: PageProps = $props();
+</script>
+
+<svelte:head>
+ <title>Sign in · is-a-tracker</title>
+</svelte:head>
+
+<h1>is-a-tracker</h1>
+
+{#if form?.problem}
+ <p class="notice failure" role="alert">{form.problem}</p>
+{/if}
+
+<form method="POST" class="card formRow">
+ <input
+ type="password"
+ name="password"
+ placeholder="Dashboard password"
+ aria-label="Dashboard password"
+ autocomplete="current-password"
+ required
+ />
+ <button class="primary">Sign in</button>
+</form>
diff --git a/src/routes/logout/+server.ts b/src/routes/logout/+server.ts
new file mode 100644
index 0000000..8ff2abe
--- /dev/null
+++ b/src/routes/logout/+server.ts
@@ -0,0 +1,13 @@
+/* src/routes/logout/+server.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { redirect, type RequestHandler } from '@sveltejs/kit';
+
+import { sessionCookieName } from '#lib/server/auth.ts';
+
+export const POST: RequestHandler = ({ cookies }) => {
+ cookies.delete(sessionCookieName, { path: '/' });
+
+ redirect(303, '/login');
+};
diff --git a/src/routes/lookup/+page.server.ts b/src/routes/lookup/+page.server.ts
new file mode 100644
index 0000000..ab560e4
--- /dev/null
+++ b/src/routes/lookup/+page.server.ts
@@ -0,0 +1,68 @@
+/* src/routes/lookup/+page.server.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { getPullRequest } from '#lib/server/github/pullRequests.ts';
+import { describeError } from '#lib/server/logger.ts';
+import { evaluatePullRequest } from '#lib/server/moderation/evaluate.ts';
+
+import type { PageServerLoad } from './$types';
+
+// Accepts "123", "#123" or any GitHub pull request URL
+function parsePullRequestNumber(input: string): number | null {
+ const match = /\/pull\/(\d+)/.exec(input) ?? /^#?(\d+)$/.exec(input.trim());
+
+ return match ? Number(match[1]) : null;
+}
+
+// Read-only: fetches and validates live, and stores nothing
+export const load: PageServerLoad = async ({ url }) => {
+ const query = url.searchParams.get('pr') ?? '';
+
+ if (query.trim() === '') {
+ return {
+ query,
+ result: null,
+ problem: null
+ };
+ }
+
+ const number = parsePullRequestNumber(query);
+
+ if (number === null) {
+ return {
+ query,
+ result: null,
+ problem: 'Enter a PR number or a GitHub pull request URL.'
+ };
+ }
+
+ try {
+ const pullRequest = await getPullRequest(number, true);
+
+ const evaluation = await evaluatePullRequest(pullRequest, {
+ fresh: true,
+ priority: true
+ });
+
+ return {
+ query,
+ problem: null,
+ result: {
+ pullRequest,
+ violations: evaluation.violations,
+ inspectedFiles: evaluation.files.map((file) => ({
+ path: file.path,
+ validJson: file.json !== null
+ })),
+ skippedFileCount: evaluation.skippedFileCount
+ }
+ };
+ } catch (error) {
+ return {
+ query,
+ result: null,
+ problem: `Could not check #${number}: ${describeError(error)}`
+ };
+ }
+};
diff --git a/src/routes/lookup/+page.svelte b/src/routes/lookup/+page.svelte
new file mode 100644
index 0000000..73b0593
--- /dev/null
+++ b/src/routes/lookup/+page.svelte
@@ -0,0 +1,85 @@
+<!-- src/routes/lookup/+page.svelte
+ MIT — (c) Doughmination System®
+-->
+
+<script lang="ts">
+ import { labelFor, ruleLabels } from '#lib/labels.ts';
+
+ import type { PageProps } from './$types';
+
+ let { data }: PageProps = $props();
+</script>
+
+<svelte:head>
+ <title>Lookup · is-a-tracker</title>
+</svelte:head>
+
+<h1>Manual PR lookup</h1>
+
+<form method="GET" class="formRow card">
+ <input
+ type="text"
+ name="pr"
+ value={data.query}
+ placeholder="PR number or GitHub pull request URL"
+ aria-label="Pull request"
+ />
+ <button class="primary">Check</button>
+</form>
+
+{#if data.problem}
+ <p class="notice failure" role="alert">{data.problem}</p>
+{/if}
+
+{#if data.result}
+ {@const result = data.result}
+
+ <section class="card">
+ <h2>
+ <a href={result.pullRequest.url} target="_blank" rel="noreferrer">
+ #{result.pullRequest.number}
+ </a>
+ {result.pullRequest.title}
+ </h2>
+
+ <p class="muted">
+ By {result.pullRequest.author} ({result.pullRequest.authorAssociation}) ·
+ {result.pullRequest.state} · commit <code>{result.pullRequest.headSha.slice(0, 7)}</code>
+ </p>
+
+ {#if result.violations.length === 0}
+ <p class="notice success">No violations found.</p>
+ {:else}
+ {#each result.violations as violation (violation.ruleId + violation.filePath)}
+ <div class="notice failure">
+ <strong>{labelFor(ruleLabels, violation.ruleId)}</strong>
+ <br />
+ <code>{violation.filePath}</code>
+ <br />
+ {violation.reason}
+ </div>
+ {/each}
+ {/if}
+
+ <h2>Files inspected</h2>
+
+ {#if result.inspectedFiles.length === 0}
+ <p class="muted">This PR changes no registration files under <code>domains/</code>.</p>
+ {:else}
+ <ul>
+ {#each result.inspectedFiles as file (file.path)}
+ <li>
+ <code>{file.path}</code>
+ {#if !file.validJson}
+ <span class="pill failure">Invalid JSON</span>
+ {/if}
+ </li>
+ {/each}
+ </ul>
+ {/if}
+
+ {#if result.skippedFileCount > 0}
+ <p class="muted">{result.skippedFileCount} more file(s) were over the per-PR limit.</p>
+ {/if}
+ </section>
+{/if}
diff --git a/src/routes/pending/+page.server.ts b/src/routes/pending/+page.server.ts
new file mode 100644
index 0000000..7820c08
--- /dev/null
+++ b/src/routes/pending/+page.server.ts
@@ -0,0 +1,62 @@
+/* src/routes/pending/+page.server.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import { fail } from '@sveltejs/kit';
+
+import { listOpenFindings } from '#lib/server/db/findings.ts';
+import {
+ performModerationAction,
+ type ModerationDecision
+} from '#lib/server/moderation/actions.ts';
+import { getRule } from '#lib/server/rules/index.ts';
+
+import type { Actions, PageServerLoad } from './$types';
+
+export const load: PageServerLoad = () => {
+ const findings = listOpenFindings().map((finding) => ({
+ id: finding.id,
+ prNumber: finding.prNumber,
+ title: finding.title,
+ author: finding.author,
+ url: finding.url,
+ ruleId: finding.ruleId,
+ filePath: finding.filePath,
+ reason: finding.reason,
+ status: finding.status,
+ lastOutcome: finding.lastOutcome,
+ createdAt: finding.createdAt,
+ actionLabel: getRule(finding.ruleId).actionLabel,
+ actionType: getRule(finding.ruleId).actionType
+ }));
+
+ return { findings };
+};
+
+// Same pipeline as the Discord buttons: claim, revalidate, act, audit
+async function decide(request: Request, decision: ModerationDecision) {
+ const formData = await request.formData();
+ const findingId = Number(formData.get('findingId'));
+
+ if (!Number.isInteger(findingId) || findingId <= 0) {
+ return fail(400, {
+ outcome: {
+ status: 'failure',
+ summary: 'Missing finding id.'
+ }
+ });
+ }
+
+ const outcome = await performModerationAction({
+ findingId,
+ decision,
+ source: 'dashboard'
+ });
+
+ return { outcome };
+}
+
+export const actions: Actions = {
+ approve: ({ request }) => decide(request, 'approve'),
+ ignore: ({ request }) => decide(request, 'ignore')
+};
diff --git a/src/routes/pending/+page.svelte b/src/routes/pending/+page.svelte
new file mode 100644
index 0000000..eb42dd9
--- /dev/null
+++ b/src/routes/pending/+page.svelte
@@ -0,0 +1,110 @@
+<!-- src/routes/pending/+page.svelte
+ MIT — (c) Doughmination System®
+-->
+
+<script lang="ts">
+ import { enhance } from '$app/forms';
+ import { formatTimestamp, labelFor, ruleLabels } from '#lib/labels.ts';
+
+ import type { PageProps } from './$types';
+
+ let { data, form }: PageProps = $props();
+
+ let busyFindingId = $state<number | null>(null);
+
+ function trackBusy(findingId: number) {
+ return () => {
+ busyFindingId = findingId;
+
+ return async ({ update }: { update: () => Promise<void> }) => {
+ await update();
+ busyFindingId = null;
+ };
+ };
+ }
+</script>
+
+<svelte:head>
+ <title>Pending · is-a-tracker</title>
+</svelte:head>
+
+<h1>Pending reviews</h1>
+
+{#if form?.outcome}
+ <p class="notice {form.outcome.status}" role="status">
+ {form.outcome.summary}
+ {#if 'githubUrl' in form.outcome && form.outcome.githubUrl}
+ <a href={form.outcome.githubUrl} target="_blank" rel="noreferrer">Open on GitHub</a>
+ {/if}
+ </p>
+{/if}
+
+{#if data.findings.length === 0}
+ <p class="card muted">Nothing is waiting for a decision.</p>
+{/if}
+
+{#each data.findings as finding (finding.id)}
+ <article class="card">
+ <h2>
+ <a href={finding.url} target="_blank" rel="noreferrer">#{finding.prNumber}</a>
+ {finding.title}
+ </h2>
+
+ <dl>
+ <dt>Violation</dt>
+ <dd>{labelFor(ruleLabels, finding.ruleId)}</dd>
+
+ <dt>Author</dt>
+ <dd>{finding.author}</dd>
+
+ <dt>File</dt>
+ <dd><code>{finding.filePath}</code></dd>
+
+ <dt>Reason</dt>
+ <dd>{finding.reason}</dd>
+
+ <dt>Detected</dt>
+ <dd>{formatTimestamp(finding.createdAt)}</dd>
+
+ {#if finding.lastOutcome}
+ <dt>Last result</dt>
+ <dd>{finding.lastOutcome}</dd>
+ {/if}
+ </dl>
+
+ <div class="formRow">
+ <form method="POST" action="?/approve" use:enhance={trackBusy(finding.id)}>
+ <input type="hidden" name="findingId" value={finding.id} />
+ <button
+ class={finding.actionType === 'closePr' ? 'danger' : 'primary'}
+ disabled={busyFindingId !== null}
+ >
+ {busyFindingId === finding.id ? 'Working…' : finding.actionLabel}
+ </button>
+ </form>
+
+ <form method="POST" action="?/ignore" use:enhance={trackBusy(finding.id)}>
+ <input type="hidden" name="findingId" value={finding.id} />
+ <button disabled={busyFindingId !== null}>Ignore</button>
+ </form>
+ </div>
+ </article>
+{/each}
+
+<style>
+ dl {
+ display: grid;
+ grid-template-columns: 7rem 1fr;
+ gap: 0.25rem 1rem;
+ margin: 0 0 1rem;
+ }
+
+ dt {
+ color: var(--text-secondary);
+ }
+
+ dd {
+ margin: 0;
+ overflow-wrap: anywhere;
+ }
+</style>
diff --git a/static/robots.txt b/static/robots.txt
new file mode 100644
index 0000000..b6dd667
--- /dev/null
+++ b/static/robots.txt
@@ -0,0 +1,3 @@
+# allow crawling everything by default
+User-agent: *
+Disallow:
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..7c65d00
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,8 @@
+{
+ "extends": "$app/tsconfig",
+ "compilerOptions": {
+ "strict": true,
+ "types": ["$app/types", "node"]
+ },
+ "include": ["src", "vite.config.ts", "prettier.config.js", "eslint.config.js"]
+}
diff --git a/vite.config.ts b/vite.config.ts
new file mode 100644
index 0000000..9ea64f6
--- /dev/null
+++ b/vite.config.ts
@@ -0,0 +1,22 @@
+/* vite.config.ts
+ * MIT — (c) Doughmination System®
+ */
+
+import adapter from '@sveltejs/adapter-node';
+import { sveltekit } from '@sveltejs/kit/vite';
+import { defineConfig } from 'vite';
+
+export default defineConfig({
+ plugins: [
+ sveltekit({
+ compilerOptions: {
+ // Force runes mode for the project, except for libraries. Can be removed in svelte 6.
+ runes: ({ filename }) =>
+ filename.split(/[/\\]/).includes('node_modules') ? undefined : true
+ },
+
+ // The Node adapter's output runs under Deno: see deploy/run
+ adapter: adapter()
+ })
+ ]
+});