import type { MigrationTask } from "#lib/api/migrator.ts";
import type { GitHubRepo } from "#lib/github.ts";
export type GitHubImportDatasetName = "demo" | "worst" | "empty" | "one" | "huge";
export interface GitHubImportDataset {
repos: GitHubRepo[];
knots: string[];
tasks: MigrationTask[];
}
const owner = "aleksandra-wisniewska-kowalczyk";
const repo = (
id: number,
name: string,
fields: Partial<Omit<GitHubRepo, "id" | "name">> = {}
): GitHubRepo => ({
id,
name,
fullName: `${owner}/${name}`,
description: null,
cloneUrl: `https://github.com/${owner}/${name}.git`,
htmlUrl: `https://github.com/${owner}/${name}`,
defaultBranch: "main",
...fields
});
type Job = MigrationTask["jobs"][number];
type JobFields = Partial<Job>;
const job = (id: string, name: string, status: string, fields: JobFields = {}): Job => ({
id,
name,
knotDid: "did:web:knot.northwind-industries-holdings.example.com",
sourceUrl: `https://github.com/${owner}/${name}.git`,
private: false,
status,
attempts: 1,
...fields
});
const task = (id: string, jobs: MigrationTask["jobs"]): MigrationTask => ({
id,
ownerDid: "did:plc:alice",
createdAt: "2026-10-27T09:14:00Z",
jobs
});
const longestName =
"NorthwindIndustriesHoldings.Platform.Infrastructure.Terraform.Modules.AWS.eu-central-1.production.v2".slice(
0,
100
);
const proxyErrorPage = `knot createRepo returned HTTP 502: <!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<html class="no-js" lang="en-US"><head><title>knot.northwind-industries-holdings.example.com | 502: Bad gateway</title><meta charset="UTF-8" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=Edge" /><meta name="robots" content="noindex, nofollow" /><meta name="viewport" content="width=device-width,initial-scale=1" /><link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/main.css" /></head><body><div id="cf-wrapper"><div id="cf-error-details" class="p-0"><header class="mx-auto pt-10 lg:pt-6 lg:px-8 w-240 lg:w-full mb-8"><h1 class="inline-block sm:block sm:mb-2 font-light text-60 lg:text-4xl text-black-dark leading-tight mr-2"><span class="inline-block">Bad gateway</span><span class="code-label">Error code 502</span></h1><div>Visit <a href="https://www.example.com/5xx-error-landing?utm_source=errorcode_502&utm_campaign=knot.northwind-industries-holdings.example.com" target="_blank" rel="noopener noreferrer">example.com</a> for more information.</div><div class="mt-3">2026-10-27 09:14:07 UTC</div></header></div></div></body></html>`;
const worstRepos: GitHubRepo[] = [
repo(1, longestName, {
description:
"Shared Terraform modules for every production account in eu-central-1, including VPC peering, Transit Gateway attachments, IAM permission boundaries, KMS key policies, and the Datadog forwarder. Owned by Platform Infrastructure; ask in #platform-infra before changing anything under modules/networking/.",
language: "HCL",
stars: 1284,
private: true
}),
repo(2, "a", { description: null, language: null, stars: 0 }),
repo(3, "dotfiles", {
description: "🦊 My config — è¨å®šãƒ•ァイル & scripts for zsh, nvim, and <tmux>",
language: "Vim Script",
stars: 1,
private: true
}),
repo(4, "Q3-board-deck-FINAL-revised-v12-approved-by-legal", {
description: "Fix & escaping in **bold** headings",
language: "Common Workflow Language",
stars: 128_400
}),
repo(5, "benachrichtigungseinstellungen", {
description: "Paramètres de confidentialité et de sécurité pour les notifications",
language: "Jupyter Notebook",
stars: 999_999
}),
...Array.from({ length: 18 }, (_, i) =>
repo(6 + i, `service-${String(i + 1).padStart(2, "0")}`, {
description: i % 3 === 0 ? null : `Internal service ${i + 1}`,
language: i % 2 === 0 ? "Go" : "TypeScript",
stars: i * 7
})
)
];
const worstTasks: MigrationTask[] = [
task("task-worst", [
job("job-proxy", longestName, "failed", { error: proxyErrorPage, private: true }),
job("job-a", "a", "queued"),
job("job-dotfiles", "dotfiles", "completed", {
repoDid: "did:plc:7f3k2m9xq4w8z1v5n6b0c2d4"
}),
job("job-deck", "Q3-board-deck-FINAL-revised-v12-approved-by-legal", "failed", {
error: `a repository named "Q3-board-deck-FINAL-revised-v12-approved-by-legal" already exists on did:web:knot.northwind-industries-holdings.example.com and was not created from https://github.com/${owner}/Q3-board-deck-FINAL-revised-v12-approved-by-legal.git`
}),
job("job-benach", "benachrichtigungseinstellungen", "importing"),
job("job-404", "service-01", "failed", { error: "knot createRepo returned HTTP 404: " }),
job("job-grant", "service-02", "authorization_required", {
error: "ScopeMissingError: Missing required scope rpc:org.tangled.repo.createRepo?aud=*"
}),
job("job-cloning", "service-03", "cloning"),
job("job-unknown", "service-04", "paused"),
job("job-silent", "service-05", "failed")
])
];
const demo: GitHubImportDataset = {
repos: [
repo(1, "alpha", { description: "first" }),
repo(2, "beta", { description: "second" }),
repo(3, "gamma", { description: "third" })
],
knots: ["knot.example.test"],
tasks: [task("task-earlier", [job("job-earlier", "delta", "completed")])]
};
const statuses = ["completed", "failed", "queued", "cloning", "importing", "completed"];
export const githubImportDatasets: Record<GitHubImportDatasetName, GitHubImportDataset> = {
demo,
worst: {
repos: worstRepos,
knots: [
"knot.northwind-industries-holdings.example.com",
"k.example.test",
"eu-central-1.knots.sub.department.region.example.co.uk"
],
tasks: worstTasks
},
empty: { repos: [], knots: [], tasks: [] },
one: {
repos: [repo(1, "dotfiles", { description: "My config", language: "Shell", stars: 1 })],
knots: ["knot.example.test"],
tasks: [task("task-one", [job("job-one", "dotfiles", "completed")])]
},
huge: {
repos: Array.from({ length: 1284 }, (_, i) =>
repo(i + 1, `repository-${String(i + 1).padStart(4, "0")}`, {
description: `Repository number ${i + 1}`,
language: i % 2 === 0 ? "Rust" : "Python",
stars: i * 13
})
),
knots: ["knot.example.test"],
tasks: Array.from({ length: 20 }, (_, t) =>
task(
`task-${t}`,
Array.from({ length: 50 }, (_, j) => {
const n = t * 50 + j + 1;
const status = statuses[n % statuses.length];
return job(
`job-${n}`,
`repository-${String(n).padStart(4, "0")}`,
status,
status === "failed" ? { error: "knot createRepo returned HTTP 404: " } : {}
);
})
)
)
}
};