{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "github", "type": "registry:item", "title": "GitHub", "description": "Editable GitHub ingestion with independent issue, pull-request, discussion, review, commit, and stargazer streams and raw ClickHouse tables.", "dependencies": [ "@chkit/core@^0.2.0-beta.12", "@chkit/plugin-ingest@^0.2.0-beta.12", "zod@^4.3.6" ], "devDependencies": [ "@types/bun@^1.2.0" ], "files": [ { "path": "github/README.md", "type": "registry:file", "target": "src/integrations/github/README.md", "content": "# GitHub raw ingestion\n\nThis editable integration syncs eight GitHub resource collections into separate raw ClickHouse tables. One installation pipeline groups the streams; each resource owns its selection and journal progress.\n\n## First run\n\nSet `GITHUB_TOKEN`, or pass `token` in `config.ts`, and configure a direct ClickHouse connection. For private repositories, the supported setup grants repository access with **Issues: read**, **Pull requests: read**, and **Contents: read** permissions, including GraphQL commit reads. These permissions describe the supported setup; field-level minimum permissions depend on the selected endpoints and GraphQL fields. Each stream checks its configuration and token when it runs, before any request, so `generate`, `migrate`, and `chkit check` never depend on them; schema imports do not call GitHub. Native JSON requires ClickHouse 25.3 or later.\n\nEdit `githubConfig.repositories`, `sourceId`, timestamp settings, and `pageSize` in `config.ts`. Raw table names and database are declared in their `sources/` modules; edit those definitions before the first migration. `createGitHubPipeline(config)` snapshots the configuration, including `token`; pass another `token` for a second installation. Requests go through the ingestion runtime, which retries only network failures, timeouts, retryable HTTP statuses, and GitHub primary and secondary rate limits, including GraphQL `RATE_LIMITED` errors. Destination schemas remain setup-time module exports.\n\n```sh\nbunx chkit check\nbunx chkit generate --name add_github\n# Review the migration before applying it.\nbunx chkit migrate --apply\nbunx chkit ingest run --tag provider:github\n```\n\n## Pipeline and resources\n\nEach configured repository contributes eight independently selectable streams to `githubPipeline`:\n\n| Resource tag | Raw destination | Selection |\n| --- | --- | --- |\n| `resource:issues` | `github_issues_raw` | Updated-time window; excludes pull requests |\n| `resource:issue_comments` | `github_issue_comments_raw` | Comment updated-time window, with its own issue discovery |\n| `resource:pull_requests` | `github_pull_requests_raw` | Full pull-request collection |\n| `resource:pull_request_comments` | `github_pull_request_comments_raw` | Conversation-comment updated-time window, with its own PR discovery |\n| `resource:pull_request_review_comments` | `github_pull_request_review_comments_raw` | Repository-wide diff-comment updated-time window |\n| `resource:pull_request_reviews` | `github_pull_request_reviews_raw` | Full reviews collection, with its own PR discovery |\n| `resource:pull_request_commits` | `github_pull_request_commits_raw` | Full PR commit connections, with its own PR discovery |\n| `resource:stargazers` | `github_stargazers_raw` | Full stargazer collection |\n\nThe default repository is `obsessiondb/chkit`, so its stream IDs use `github..obsessiondb.chkit`. Existing issues and stargazers stream IDs remain unchanged. Another repository gets independent stream identities and checkpoints. Keep `sourceId` stable for one installation; changing it creates new stream identities.\n\nSelect a resource without running any other stream:\n\n```sh\nbunx chkit ingest run --tag provider:github --tag repository:obsessiondb/chkit --tag resource:pull_request_commits\nbunx chkit ingest run --tag provider:github --tag repository:obsessiondb/chkit --tag resource:pull_request_comments\n```\n\nRepeated tags use AND matching. The default `maxStreams: 1` executes selected streams sequentially; filtered runs give resources separate schedules and execution budgets. Stream order does not establish dependencies. A child reader discovers its own accessible parents through GitHub, even when the issues or pull-requests stream has never run. Individual issues and PRs are records inside their resource stream.\n\n## Stored data and joins\n\nEvery raw payload has the envelope `{ repository, data }`. Issue comments add `issue_number`; PR conversation comments, review comments, reviews, and commits add `pull_number`. Provider response fields remain under `data`. Issues and PRs contain their own metadata, while comments and reviews occupy individual rows in their respective tables.\n\nSee [destinations](https://chkit.obsessiondb.com/api-sync/destinations/).\n\nPR commits retain exactly `data.sha` and `data.message`, plus the repository and PR join keys. The reader requests the paginated [GraphQL PR commit connection](https://docs.github.com/en/graphql/reference/pulls#pullrequest) and maps the provider commit object ID to `sha`. Repeated SHAs, changes in `totalCount`, or a mismatched distinct terminal count fail the commit stream rather than completing a truncated collection. It does not request changed files or patches.\n\nJoin resources later in ClickHouse using `repository` plus `data.number` on issues/PRs and `issue_number` or `pull_number` on child rows. Review comments also retain their provider review ID for joining to reviews. A commit's SHA is scoped to its repository/PR membership, so a commit appearing in several PRs remains joinable to each one.\n\nRaw IDs retain provider identities and parent context. Existing issue and stargazer ID formats stay `[repository, issue.number]` and `[repository, user.id]`. The tables retain the latest observed payload per identity, with ingestion metadata added by chkit.\n\n## Sync and recovery\n\nIssues use `since`, update-time ordering, and a fixed local upper cutoff. Issue comments and PR conversation comments use their own `since` filters; their parent discovery reads the entire accessible issue or PR collection without restricting parent modification times. A recent comment on an old issue or PR stays eligible. Repository-wide review comments use their own update-time filter and recover the PR number from `pull_request_url`. See [issue comments](https://docs.github.com/en/rest/issues/comments#list-issue-comments) and [review comments](https://docs.github.com/en/rest/pulls/comments#list-review-comments-in-a-repository).\n\nThe initial timestamp window starts at `2008-01-01`; later windows replay five minutes before the committed watermark. GitHub has no server-side upper timestamp filter for these REST reads, so each timestamp reader discards observations newer than the fixed execution cutoff. A stream advances its watermark only after its complete window and destination writes succeed, including empty windows. Failed or interrupted windows replay from their lower bound.\n\nPull-request metadata, reviews, PR commits, and stargazers use the library's `fullSync()` strategy. Every run reads that selected resource again; the journal records successful completion, including empty reads. Interrupted reads start the selected collection from its beginning. There are no saved mutable page offsets or per-parent scan ledgers. REST `Link` URLs and GraphQL cursors are request continuations within the read; `paginate()` owns retryable requests and rejects cycles.\n\nDeleted records, removed stars, and commits no longer present after force-pushes remain stored. Pagination over live results is not a source snapshot; periodic historical replay refreshes older timestamp-selected observations and changes beyond overlap:\n\n```sh\nbunx chkit ingest run --tag provider:github --tag resource:issue_comments --backfill reconcile-2026-10-05 --from 2008-01-01\nbunx chkit ingest status --tag provider:github --json\n```\n\nUse a new backfill ID for each reconciliation. Historical replay reads current observations rather than reconstructing old versions. Full-sync resources ignore date bounds. A failed stream can have published some rows without completing its journal progress; it does not move another stream's checkpoint. Run one ingestion process per ClickHouse target at a time.\n\n## Upgrading existing data\n\nVersion `0.2.0` adds six raw destinations and separates issues from pull requests. The raw envelope changes to `{ repository, data }` while existing issue/stargazer row IDs stay stable. Previously stored flat payloads may coexist with new envelopes until their IDs are observed again or migrated explicitly.\n\nCombined-reader installations may also have PR rows in `github_issues_raw` and child arrays embedded in parent JSON. Those observations remain stored; running the new streams does not remove or move them. Keep the previous dataset as an archive, or deliberately migrate issue/PR classifications and child payloads into their separate destinations. In particular, old PR rows remain in the issues table until an explicit data migration or reconciliation removes them. Application queries need to account for both retained legacy shapes and the new envelope during that transition.\n\n## Fixture tests\n\n```sh\nbunx chkit add github --with-tests\nbun test src/integrations/github/tests/basic.test.ts\n```\n\nPortable fixtures pass provider responses through the ingestion runtime's `fetch` and verify resource selection and failure isolation, raw payloads and join keys, commit field selection, old-parent child updates, pagination continuations, source/sink failure recovery, configuration snapshots, and empty completion without live credentials.\n" }, { "path": "github/index.ts", "type": "registry:file", "target": "src/integrations/github/index.ts", "content": "export { githubPipeline, createGitHubPipeline } from './pipeline.js'\nexport { github_issuesRaw } from './sources/issues.js'\nexport { github_issueCommentsRaw } from './sources/issue-comments.js'\nexport { github_pullRequestsRaw } from './sources/pull-requests.js'\nexport { github_pullRequestCommentsRaw } from './sources/pull-request-comments.js'\nexport { github_pullRequestReviewCommentsRaw } from './sources/pull-request-review-comments.js'\nexport { github_pullRequestReviewsRaw } from './sources/pull-request-reviews.js'\nexport { github_pullRequestCommitsRaw } from './sources/pull-request-commits.js'\nexport { github_stargazersRaw } from './sources/stargazers.js'\n" }, { "path": "github/config.ts", "type": "registry:file", "target": "src/integrations/github/config.ts", "content": "import { z } from 'zod'\n\nconst repository = z.string().refine(\n (value) => /^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/.test(value) && value.split('/').every((part) => part !== '.' && part !== '..'),\n 'must use owner/repository names',\n)\nconst missingToken = 'Set GITHUB_TOKEN or pass token.'\nconst token = z.string().optional().pipe(z.string({ error: missingToken }).trim().min(1, missingToken))\n\nexport const githubConfigSchema = z.object({\n /** Stable, non-secret stream prefix for this installation. */\n sourceId: z.string(),\n /** Each repository creates eight independent resource streams with separate raw tables. */\n repositories: z.array(repository).readonly(),\n start: z.date(),\n overlapMs: z.number().nonnegative(),\n pageSize: z.int().min(1).max(100),\n /** GitHub token; read when a stream runs, never by schema commands. */\n token,\n})\n\nexport type GitHubConfig = z.input\n\n// Set source selection here; raw destinations are declared in sources/.\nexport const githubConfig: GitHubConfig = {\n sourceId: 'github',\n repositories: ['obsessiondb/chkit'],\n start: new Date('2008-01-01T00:00:00Z'),\n overlapMs: 5 * 60 * 1000,\n pageSize: 100,\n token: process.env.GITHUB_TOKEN,\n}\n" }, { "path": "github/client.ts", "type": "registry:file", "target": "src/integrations/github/client.ts", "content": "import { HttpError, paginate, rawRows, type Page, type RawRow, type SourceContext, type TimestampRange } from '@chkit/plugin-ingest'\nimport { z } from 'zod'\n\nimport { githubConfigSchema, type GitHubConfig } from './config.js'\n\nexport type GitHubObject = Record\nexport type GitHubParent = z.output\nexport type GitHubSettings = Omit, 'token'>\nexport interface PageOptions { accept?: string; params?: Record }\n\nexport interface GitHubClient {\n settings: GitHubSettings\n pages(path: string, item: z.ZodType, options?: PageOptions): AsyncGenerator>\n /** An omitted window means complete parent discovery, independent of another stream's progress. */\n issues(repo: string, window?: TimestampRange): AsyncGenerator>\n /** GitHub has no since filter for PR metadata: list the current collection in full. */\n pulls(repo: string): AsyncGenerator>\n graphql(query: string, variables: Record): Promise\n}\n\nexport const githubId = z.int().positive()\nconst githubParent = z.looseObject({ number: githubId })\nexport const githubRecord = z.looseObject({ id: githubId })\nconst apiUrl = 'https://api.github.com'\nconst updated = z.looseObject({ updated_at: z.string().refine((value) => Number.isFinite(Date.parse(value)), 'must be a timestamp') })\nconst graphqlResponse = z.looseObject({\n data: z.unknown(),\n errors: z.array(z.looseObject({ type: z.string().optional(), message: z.string().optional() })).optional(),\n})\n\nexport function createGitHubClient(context: SourceContext, config: GitHubConfig): GitHubClient {\n const { token, ...settings } = githubConfigSchema.parse(config)\n const request = (url: string, accept: string, init: { method?: string; body?: string; headers?: Record } = {}) =>\n context.fetch(url, { ...init, redirect: 'error', headers: { ...init.headers, Authorization: `Bearer ${token}`, Accept: accept } })\n .catch((error: unknown) => { throw error instanceof HttpError && isRateLimit(error) ? rateLimited(error.response, error.body) : error })\n const pages = (path: string, item: z.ZodType, options: PageOptions = {}) => {\n const first = new URL(`${apiUrl}${path}`)\n for (const [key, value] of Object.entries({ ...options.params, per_page: String(settings.pageSize) })) first.searchParams.set(key, value)\n const page = z.array(item)\n return paginate({\n context, initial: first.toString(), label: `GET ${path}`,\n fetchPage: async (cursor = first.toString()) => {\n const response = await request(cursor, options.accept ?? 'application/vnd.github+json', { headers: { 'X-GitHub-Api-Version': '2022-11-28' } })\n return { items: page.parse(await response.json()), next: nextLink(response.headers.get('link'), cursor) }\n },\n })\n }\n return {\n settings,\n pages,\n async *issues(repo, window) {\n for await (const page of pages(`/repos/${repo}/issues`, githubParent, { params: {\n state: 'all', sort: 'updated', direction: 'asc', ...(window ? { since: window.from.toISOString() } : {}),\n } })) {\n const issues = page.items.filter((item) => item.pull_request === undefined)\n yield { ...page, items: window ? updatedItems(issues, window) : issues }\n }\n },\n pulls: (repo) => pages(`/repos/${repo}/pulls`, githubParent, { params: { state: 'all', sort: 'updated', direction: 'asc' } }),\n graphql: async (query, variables) => {\n const response = await request(`${apiUrl}/graphql`, 'application/json', {\n method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query, variables }),\n })\n const body = graphqlResponse.parse(await response.clone().json())\n if (!body.errors?.length) return body.data\n const limited = response.headers.get('x-ratelimit-remaining') === '0' || response.headers.has('retry-after') ||\n body.errors.some((error) => error.type === 'RATE_LIMITED' || /secondary rate limit/i.test(error.message ?? ''))\n if (limited) throw rateLimited(response, await response.clone().text())\n throw new Error(`GitHub GraphQL returned errors: ${JSON.stringify(body.errors)}`)\n },\n }\n}\n\n/** GitHub signals rate exhaustion with 403 as well as 429. */\nfunction isRateLimit(error: HttpError): boolean {\n if (error.status !== 403 && error.status !== 429) return false\n const reported = /secondary rate limit/i.test(error.body) || /\"type\"\\s*:\\s*\"RATE_LIMITED\"/.test(error.body)\n return reported || error.response.headers.get('x-ratelimit-remaining') === '0' || error.response.headers.has('retry-after')\n}\n\n/** Without Retry-After, GitHub's reset header (epoch seconds) says when the budget refills. */\nfunction rateLimited(response: Response, body: string): HttpError {\n const resetSeconds = Number(response.headers.get('x-ratelimit-reset'))\n const untilReset = Number.isFinite(resetSeconds) && resetSeconds > 0 ? Math.max(0, resetSeconds * 1000 - Date.now()) : undefined\n return HttpError.withStatus(response, 429, { body, retryAfterMs: untilReset ?? 60_000 })\n}\n\n/** Provider data stays intact; repository and parent keys live outside it for warehouse joins. */\nexport function toGitHubRows(\n items: readonly T[], repo: string, identify: (item: T) => string | number,\n parent?: { issue_number: number } | { pull_number: number },\n): RawRow[] {\n const number = parent && ('pull_number' in parent ? parent.pull_number : parent.issue_number)\n return rawRows(items.map((data) => ({ repository: repo, ...parent, data })), ({ data }) =>\n JSON.stringify([repo, ...(number === undefined ? [] : [number]), identify(data)]))\n}\n\nexport function updatedItems(items: readonly T[], window: TimestampRange): T[] {\n return items.filter((item) => {\n const time = Date.parse(updated.parse(item).updated_at)\n return time >= window.from.getTime() && time <= window.to.getTime()\n })\n}\n\nexport function pullNumber(pullRequestUrl: string, repo: string): number {\n if (!URL.canParse(pullRequestUrl)) throw new Error('GitHub review comment has an invalid pull_request_url.')\n const url = new URL(pullRequestUrl)\n const prefix = `/repos/${repo}/pulls/`\n const value = url.pathname.slice(prefix.length)\n if (url.origin !== apiUrl || !url.pathname.toLowerCase().startsWith(prefix.toLowerCase()) || !/^[1-9]\\d*$/.test(value)) {\n throw new Error('GitHub review comment belongs to an unexpected repository or pull request.')\n }\n return githubId.parse(Number(value))\n}\n\nfunction nextLink(header: string | null, current: string): string | undefined {\n for (const link of header?.matchAll(/<([^>]*)>((?:[^\",]|\"(?:\\\\.|[^\"\\\\])*\")*)/g) ?? []) {\n const value = link[1]\n const parameters = link[2] ?? ''\n const relation = [...parameters.matchAll(/;\\s*([^=;\\s]+)\\s*(?:=\\s*(\"(?:\\\\.|[^\"\\\\])*\"|[^;\\s]+))?/g)]\n .find((parameter) => parameter[1]?.toLowerCase() === 'rel')?.[2]\n if (value === undefined || !relation) continue\n const relations = relation.startsWith('\"') ? relation.slice(1, -1).replace(/\\\\(.)/g, '$1') : relation\n if (!relations.toLowerCase().split(/\\s+/).includes('next')) continue\n if (!URL.canParse(value, current)) throw new Error('GitHub next page has an invalid URL.')\n const next = new URL(value, current)\n if (next.origin !== apiUrl) throw new Error('GitHub next page has an unexpected origin.')\n return next.toString()\n }\n return undefined\n}\n" }, { "path": "github/pipeline.ts", "type": "registry:file", "target": "src/integrations/github/pipeline.ts", "content": "import { definePipeline, defineStream, timestampWindow } from '@chkit/plugin-ingest'\n\nimport { githubConfig, type GitHubConfig } from './config.js'\nimport { github_issuesRaw, readIssues } from './sources/issues.js'\nimport { github_issueCommentsRaw, readIssueComments } from './sources/issue-comments.js'\nimport { github_pullRequestsRaw, readPullRequests } from './sources/pull-requests.js'\nimport { github_pullRequestCommentsRaw, readPullRequestComments } from './sources/pull-request-comments.js'\nimport { github_pullRequestReviewCommentsRaw, readPullRequestReviewComments } from './sources/pull-request-review-comments.js'\nimport { github_pullRequestReviewsRaw, readPullRequestReviews } from './sources/pull-request-reviews.js'\nimport { github_pullRequestCommitsRaw, readPullRequestCommits } from './sources/pull-request-commits.js'\nimport { github_stargazersRaw, readStargazers } from './sources/stargazers.js'\n\nexport function createGitHubPipeline(config: GitHubConfig = githubConfig) {\n const source = { ...config, repositories: [...config.repositories], start: new Date(config.start) }\n return definePipeline({\n id: source.sourceId, tags: ['provider:github'], maxStreams: 1, maxFetches: 1,\n streams: source.repositories.flatMap((repo) => {\n const suffix = repo.replace('/', '.')\n const repositoryTag = `repository:${repo}`\n return [\n defineStream({\n id: `${source.sourceId}.issues.${suffix}`, tags: [repositoryTag, 'resource:issues'], destination: github_issuesRaw,\n incremental: timestampWindow({ start: source.start, overlapMs: source.overlapMs }),\n read: (context) => readIssues(context, repo, source),\n }),\n defineStream({\n id: `${source.sourceId}.issue_comments.${suffix}`, tags: [repositoryTag, 'resource:issue_comments'], destination: github_issueCommentsRaw,\n incremental: timestampWindow({ start: source.start, overlapMs: source.overlapMs }),\n read: (context) => readIssueComments(context, repo, source),\n }),\n defineStream({\n id: `${source.sourceId}.pull_requests.${suffix}`, tags: [repositoryTag, 'resource:pull_requests'], destination: github_pullRequestsRaw,\n read: (context) => readPullRequests(context, repo, source),\n }),\n defineStream({\n id: `${source.sourceId}.pull_request_comments.${suffix}`, tags: [repositoryTag, 'resource:pull_request_comments'], destination: github_pullRequestCommentsRaw,\n incremental: timestampWindow({ start: source.start, overlapMs: source.overlapMs }),\n read: (context) => readPullRequestComments(context, repo, source),\n }),\n defineStream({\n id: `${source.sourceId}.pull_request_review_comments.${suffix}`, tags: [repositoryTag, 'resource:pull_request_review_comments'], destination: github_pullRequestReviewCommentsRaw,\n incremental: timestampWindow({ start: source.start, overlapMs: source.overlapMs }),\n read: (context) => readPullRequestReviewComments(context, repo, source),\n }),\n defineStream({\n id: `${source.sourceId}.pull_request_reviews.${suffix}`, tags: [repositoryTag, 'resource:pull_request_reviews'], destination: github_pullRequestReviewsRaw,\n read: (context) => readPullRequestReviews(context, repo, source),\n }),\n defineStream({\n id: `${source.sourceId}.pull_request_commits.${suffix}`, tags: [repositoryTag, 'resource:pull_request_commits'], destination: github_pullRequestCommitsRaw,\n read: (context) => readPullRequestCommits(context, repo, source),\n }),\n defineStream({\n id: `${source.sourceId}.stargazers.${suffix}`, tags: [repositoryTag, 'resource:stargazers'], destination: github_stargazersRaw,\n read: (context) => readStargazers(context, repo, source),\n }),\n ]\n }),\n })\n}\n\nexport const githubPipeline = createGitHubPipeline()\n" }, { "path": "github/sources/issues.ts", "type": "registry:file", "target": "src/integrations/github/sources/issues.ts", "content": "import { rawTable, type ReadContext, type TimestampRange, type TimestampWindowState } from '@chkit/plugin-ingest'\n\nimport { createGitHubClient, toGitHubRows } from '../client.js'\nimport type { GitHubConfig } from '../config.js'\n\nexport const github_issuesRaw = rawTable({ database: 'default', name: 'github_issues_raw' })\n\nexport async function* readIssues(context: ReadContext, repo: string, config: GitHubConfig) {\n const client = createGitHubClient(context, config)\n for await (const page of client.issues(repo, context.selection)) {\n yield { rows: toGitHubRows(page.items, repo, (issue) => issue.number) }\n }\n}\n" }, { "path": "github/sources/stargazers.ts", "type": "registry:file", "target": "src/integrations/github/sources/stargazers.ts", "content": "import { rawTable, type SourceContext } from '@chkit/plugin-ingest'\nimport { z } from 'zod'\n\nimport { createGitHubClient, githubRecord, toGitHubRows } from '../client.js'\nimport type { GitHubConfig } from '../config.js'\n\nconst stargazer = z.looseObject({ user: githubRecord })\n\nexport const github_stargazersRaw = rawTable({ database: 'default', name: 'github_stargazers_raw' })\n\nexport async function* readStargazers(context: SourceContext, repo: string, config: GitHubConfig) {\n const client = createGitHubClient(context, config)\n for await (const page of client.pages(`/repos/${repo}/stargazers`, stargazer, { accept: 'application/vnd.github.star+json' })) {\n yield { rows: toGitHubRows(page.items, repo, (star) => star.user.id) }\n }\n}\n" }, { "path": "github/sources/issue-comments.ts", "type": "registry:file", "target": "src/integrations/github/sources/issue-comments.ts", "content": "import { rawTable, type ReadContext, type TimestampRange, type TimestampWindowState } from '@chkit/plugin-ingest'\n\nimport { createGitHubClient, githubRecord, toGitHubRows, updatedItems } from '../client.js'\nimport type { GitHubConfig } from '../config.js'\n\nexport const github_issueCommentsRaw = rawTable({ database: 'default', name: 'github_issue_comments_raw' })\n\nexport async function* readIssueComments(context: ReadContext, repo: string, config: GitHubConfig) {\n const client = createGitHubClient(context, config)\n // Discover all issue parents: a recent comment need not imply a recent parent update.\n for await (const issues of client.issues(repo)) {\n for (const { number } of issues.items) {\n for await (const page of client.pages(`/repos/${repo}/issues/${number}/comments`, githubRecord, { params: { since: context.selection.from.toISOString() } })) {\n yield { rows: toGitHubRows(updatedItems(page.items, context.selection), repo, (comment) => comment.id, { issue_number: number }) }\n }\n }\n }\n}\n" }, { "path": "github/sources/pull-requests.ts", "type": "registry:file", "target": "src/integrations/github/sources/pull-requests.ts", "content": "import { rawTable, type SourceContext } from '@chkit/plugin-ingest'\n\nimport { createGitHubClient, toGitHubRows } from '../client.js'\nimport type { GitHubConfig } from '../config.js'\n\nexport const github_pullRequestsRaw = rawTable({ database: 'default', name: 'github_pull_requests_raw' })\n\nexport async function* readPullRequests(context: SourceContext, repo: string, config: GitHubConfig) {\n const client = createGitHubClient(context, config)\n for await (const page of client.pulls(repo)) {\n yield { rows: toGitHubRows(page.items, repo, (pull) => pull.number) }\n }\n}\n" }, { "path": "github/sources/pull-request-comments.ts", "type": "registry:file", "target": "src/integrations/github/sources/pull-request-comments.ts", "content": "import { rawTable, type ReadContext, type TimestampRange, type TimestampWindowState } from '@chkit/plugin-ingest'\n\nimport { createGitHubClient, githubRecord, toGitHubRows, updatedItems } from '../client.js'\nimport type { GitHubConfig } from '../config.js'\n\nexport const github_pullRequestCommentsRaw = rawTable({ database: 'default', name: 'github_pull_request_comments_raw' })\n\nexport async function* readPullRequestComments(context: ReadContext, repo: string, config: GitHubConfig) {\n const client = createGitHubClient(context, config)\n // This reader owns its discovery and window; the PR metadata stream need not have run.\n for await (const pulls of client.pulls(repo)) {\n for (const { number } of pulls.items) {\n for await (const page of client.pages(`/repos/${repo}/issues/${number}/comments`, githubRecord, { params: { since: context.selection.from.toISOString() } })) {\n yield { rows: toGitHubRows(updatedItems(page.items, context.selection), repo, (comment) => comment.id, { pull_number: number }) }\n }\n }\n }\n}\n" }, { "path": "github/sources/pull-request-review-comments.ts", "type": "registry:file", "target": "src/integrations/github/sources/pull-request-review-comments.ts", "content": "import { rawTable, type ReadContext, type TimestampRange, type TimestampWindowState } from '@chkit/plugin-ingest'\nimport { z } from 'zod'\n\nimport { createGitHubClient, githubId, pullNumber, toGitHubRows, updatedItems } from '../client.js'\nimport type { GitHubConfig } from '../config.js'\n\nconst reviewComment = z.looseObject({ id: githubId, pull_request_url: z.string() })\n\nexport const github_pullRequestReviewCommentsRaw = rawTable({ database: 'default', name: 'github_pull_request_review_comments_raw' })\n\nexport async function* readPullRequestReviewComments(context: ReadContext, repo: string, config: GitHubConfig) {\n const client = createGitHubClient(context, config)\n for await (const page of client.pages(`/repos/${repo}/pulls/comments`, reviewComment, { params: {\n since: context.selection.from.toISOString(), sort: 'updated', direction: 'asc',\n } })) {\n for (const comment of updatedItems(page.items, context.selection)) {\n yield { rows: toGitHubRows([comment], repo, (item) => item.id, { pull_number: pullNumber(comment.pull_request_url, repo) }) }\n }\n }\n}\n" }, { "path": "github/sources/pull-request-reviews.ts", "type": "registry:file", "target": "src/integrations/github/sources/pull-request-reviews.ts", "content": "import { rawTable, type SourceContext } from '@chkit/plugin-ingest'\n\nimport { createGitHubClient, githubRecord, toGitHubRows } from '../client.js'\nimport type { GitHubConfig } from '../config.js'\n\nexport const github_pullRequestReviewsRaw = rawTable({ database: 'default', name: 'github_pull_request_reviews_raw' })\n\nexport async function* readPullRequestReviews(context: SourceContext, repo: string, config: GitHubConfig) {\n const client = createGitHubClient(context, config)\n for await (const pulls of client.pulls(repo)) {\n for (const { number } of pulls.items) {\n for await (const page of client.pages(`/repos/${repo}/pulls/${number}/reviews`, githubRecord)) {\n yield { rows: toGitHubRows(page.items, repo, (review) => review.id, { pull_number: number }) }\n }\n }\n }\n}\n" }, { "path": "github/sources/pull-request-commits.ts", "type": "registry:file", "target": "src/integrations/github/sources/pull-request-commits.ts", "content": "import { paginate, rawTable, type SourceContext } from '@chkit/plugin-ingest'\nimport { z } from 'zod'\n\nimport { createGitHubClient, toGitHubRows } from '../client.js'\nimport type { GitHubConfig } from '../config.js'\n\nexport const github_pullRequestCommitsRaw = rawTable({ database: 'default', name: 'github_pull_request_commits_raw' })\n\n// The REST PR commits endpoint caps results at 250. Request only the two desired fields through GraphQL.\nconst commitsQuery = `query PullRequestCommits($owner: String!, $repo: String!, $number: Int!, $first: Int!, $after: String) {\n repository(owner: $owner, name: $repo) {\n pullRequest(number: $number) {\n commits(first: $first, after: $after) {\n totalCount\n nodes { commit { oid message } }\n pageInfo { hasNextPage endCursor }\n }\n }\n }\n}`\n\nconst commitsData = z.object({\n repository: z.object({\n pullRequest: z.object({\n commits: z.object({\n totalCount: z.int().nonnegative(),\n nodes: z.array(z.object({ commit: z.object({ oid: z.string().refine((value) => value.trim() !== '', 'must not be blank'), message: z.string() }) })),\n pageInfo: z.object({ hasNextPage: z.boolean(), endCursor: z.string().nullish() }),\n }),\n }),\n }),\n})\n\nexport async function* readPullRequestCommits(context: SourceContext, repo: string, config: GitHubConfig) {\n const client = createGitHubClient(context, config)\n const [owner, name] = repo.split('/')\n for await (const pulls of client.pulls(repo)) {\n for (const { number } of pulls.items) {\n let expectedCount: number | undefined\n const seenShas = new Set()\n const pages = paginate<{ sha: string; message: string }, string>({\n context, label: `POST /graphql PR ${repo}#${number} commits`,\n fetchPage: async (after) => {\n const data = await client.graphql(commitsQuery, { owner, repo: name, number, first: client.settings.pageSize, after: after ?? null })\n const { totalCount, nodes, pageInfo } = commitsData.parse(data).repository.pullRequest.commits\n if (expectedCount !== undefined && totalCount !== expectedCount) throw new Error('GitHub PR commit count changed during pagination; replay this stream.')\n if (pageInfo.hasNextPage && !pageInfo.endCursor?.trim()) throw new Error('GitHub commits have no continuation cursor.')\n const next = pageInfo.hasNextPage && pageInfo.endCursor ? pageInfo.endCursor : undefined\n const items = nodes.map(({ commit }) => ({ sha: commit.oid, message: commit.message }))\n const pageShas = new Set()\n for (const commit of items) {\n if (seenShas.has(commit.sha) || pageShas.has(commit.sha)) throw new Error('GitHub PR commits repeated a SHA; replay this stream.')\n pageShas.add(commit.sha)\n }\n const count = seenShas.size + pageShas.size\n if (count > totalCount || (next === undefined && count !== totalCount)) throw new Error('GitHub PR commits ended without the advertised complete collection.')\n expectedCount = totalCount\n for (const sha of pageShas) seenShas.add(sha)\n return { items, next }\n },\n })\n for await (const page of pages) {\n yield { rows: toGitHubRows(page.items, repo, (commit) => commit.sha, { pull_number: number }) }\n }\n }\n }\n}\n" }, { "path": "github/tests/basic.test.ts", "type": "registry:file", "target": "src/integrations/github/tests/basic.test.ts", "role": "test", "content": "import { expect, test } from 'bun:test'\nimport { HttpError, runIngestion, selectStreams, type Page, type SourceContext } from '@chkit/plugin-ingest'\nimport { createMemoryDestination, createMemoryJournal, createSourceContext } from '@chkit/plugin-ingest/testing'\n\nimport { createGitHubPipeline, githubPipeline } from '../index.js'\nimport { githubConfig, type GitHubConfig } from '../config.js'\nimport { createGitHubClient, type GitHubParent } from '../client.js'\n\nconst repository = 'obsessiondb/chkit'\nconst cutoff = new Date('2026-01-02T00:00:00Z')\nconst fixtureConfig = { ...githubConfig, token: 'fixture' }\nconst resources = ['issues', 'issue_comments', 'pull_requests', 'pull_request_comments', 'pull_request_review_comments', 'pull_request_reviews', 'pull_request_commits', 'stargazers']\nconst issue = { number: 1, id: 1001, title: 'Issue', updated_at: '2026-01-01T12:00:00Z', labels: [{ name: 'bug' }] }\nconst pull = { number: 2, id: 1002, title: 'Pull request', state: 'closed', updated_at: '2026-01-01T12:00:00Z', merged_at: '2026-01-01T00:00:00Z' }\nconst pullIssue = { ...pull, pull_request: { url: `https://api.github.com/repos/${repository}/pulls/2` } }\nconst issueComment = { id: 101, body: 'Issue discussion', updated_at: issue.updated_at, custom: ['retained'] }\nconst pullComment = { id: 201, body: 'Pull request discussion', updated_at: issue.updated_at }\nconst reviewComment = { id: 301, body: 'Review discussion', updated_at: issue.updated_at, pull_request_url: `https://api.github.com/repos/${repository}/pulls/2` }\nconst review = { id: 401, body: 'Review', state: 'APPROVED', submitted_at: '2020-01-01T00:00:00Z' }\nconst commit = { sha: '0123456789012345678901234567890123456789', message: 'Subject\\n\\nFull commit message\\nwith another line.' }\nconst stargazer = { starred_at: '2026-01-01T00:00:00Z', user: { id: 501, login: 'example' }, custom: true }\n\ntype Responder = (url: URL, init: RequestInit) => Response | Promise\ntype Pipeline = ReturnType\n\ntest.each(['owner/.', 'owner/..', './repo', '../repo'])('repositories with dot-only URL segments fail every stream before any request: %s', async (repo) => {\n let requests = 0\n const env = githubEnv(() => { requests++; return Response.json([]) })\n const result = await runIngestion(request(fixturePipeline({ ...fixtureConfig, repositories: [repo] })), { ...env, journal: createMemoryJournal(), destination: createMemoryDestination(), now: () => cutoff })\n expect(result.streams).toHaveLength(8)\n expect(result.streams.every((stream) => stream.outcome === 'failed' && /must use owner\\/repository names\\n\\s*→ at repositories\\[0\\]/.test(stream.error ?? ''))).toBe(true)\n expect(requests).toBe(0)\n})\n\ntest('GitHub resource streams retain flat provider payloads and parent join identities', async () => {\n const requests: URL[] = []\n const env = githubEnv((url, init) => { requests.push(url); return fixtureResponse(url, init) })\n const pipeline = fixturePipeline()\n expect(pipeline.streams.map((stream) => stream.id).sort()).toEqual(resources.map((resource) => `github.${resource}.obsessiondb.chkit`).sort())\n expect(githubPipeline.streams).toHaveLength(8)\n const destination = createMemoryDestination(), journal = createMemoryJournal()\n const result = await runIngestion(request(pipeline), { ...env, journal, destination, now: () => cutoff })\n expect(result.ok, JSON.stringify(result)).toBe(true)\n const expected: Record = {\n issues: { id: JSON.stringify([repository, 1]), raw: { repository, data: issue } },\n issue_comments: { id: JSON.stringify([repository, 1, 101]), raw: { repository, issue_number: 1, data: issueComment } },\n pull_requests: { id: JSON.stringify([repository, 2]), raw: { repository, data: pull } },\n pull_request_comments: { id: JSON.stringify([repository, 2, 201]), raw: { repository, pull_number: 2, data: pullComment } },\n pull_request_review_comments: { id: JSON.stringify([repository, 2, 301]), raw: { repository, pull_number: 2, data: reviewComment } },\n pull_request_reviews: { id: JSON.stringify([repository, 2, 401]), raw: { repository, pull_number: 2, data: review } },\n pull_request_commits: { id: JSON.stringify([repository, 2, commit.sha]), raw: { repository, pull_number: 2, data: commit } },\n stargazers: { id: JSON.stringify([repository, 501]), raw: { repository, data: stargazer } },\n }\n for (const [resource, expectedRow] of Object.entries(expected)) {\n expect(destination.tables.get(`default.github_${resource}_raw`)?.map(({ id, raw }) => ({ id, raw }))).toEqual([expectedRow])\n }\n expect(requests.some((url) => url.pathname.endsWith('/files') || /\\/pulls\\/\\d+\\/commits$/.test(url.pathname))).toBe(false)\n expect((await journal.readCheckpoint('github.issues.obsessiondb.chkit')).envelope?.state).toEqual({ watermark: cutoff.toISOString() })\n})\n\ntest('every resource runs alone and reversing stream order preserves the same observations', async () => {\n const env = githubEnv()\n const pipeline = fixturePipeline()\n const combined = createMemoryDestination()\n const reversed = { ...pipeline, streams: [...pipeline.streams].reverse() }\n expect((await runIngestion(request(reversed), { ...env, journal: createMemoryJournal(), destination: combined, now: () => cutoff })).ok).toBe(true)\n for (const resource of resources) {\n const destination = createMemoryDestination()\n const selected = request(pipeline, resource)\n expect(selected.selected.map((entry) => entry.stream.id)).toEqual([`github.${resource}.obsessiondb.chkit`])\n const result = await runIngestion(selected, { ...env, journal: createMemoryJournal(), destination, now: () => cutoff })\n expect(result.ok, `${resource}: ${JSON.stringify(result)}`).toBe(true)\n expect(destination.tables.size).toBe(1)\n expect(destination.tables.get(`default.github_${resource}_raw`)?.map(({ id, raw }) => ({ id, raw })))\n .toEqual(combined.tables.get(`default.github_${resource}_raw`)?.map(({ id, raw }) => ({ id, raw })))\n }\n})\n\ntest('selecting parents requests no children and separates issue and pull request responses', async () => {\n for (const resource of ['issues', 'pull_requests']) {\n const requests: URL[] = []\n const env = githubEnv((url, init) => { requests.push(url); return fixtureResponse(url, init) })\n const pipeline = fixturePipeline()\n const destination = createMemoryDestination()\n expect((await runIngestion(request(pipeline, resource), { ...env, journal: createMemoryJournal(), destination, now: () => cutoff })).ok).toBe(true)\n expect(requests.map((url) => url.pathname)).toEqual([`/repos/${repository}/${resource === 'issues' ? 'issues' : 'pulls'}`])\n expect(requests[0]?.searchParams.get('state')).toBe('all')\n expect(requests[0]?.searchParams.get('sort')).toBe('updated')\n expect(requests[0]?.searchParams.get('direction')).toBe('asc')\n expect(requests[0]?.searchParams.has('since')).toBe(resource === 'issues')\n expect(destination.tables.get(`default.github_${resource}_raw`)?.map((row) => row.raw)).toEqual([{ repository, data: resource === 'issues' ? issue : pull }])\n }\n})\n\ntest('short issue pages follow Link continuations while excluding PRs and updates beyond the cutoff', async () => {\n const requests: URL[] = []\n const nextIssue = { ...issue, number: 3, id: 1003 }\n const futureIssue = { ...issue, number: 4, updated_at: '2026-01-03T00:00:00Z' }\n const env = githubEnv((url) => {\n requests.push(url)\n if (url.searchParams.has('page')) return Response.json([pullIssue, nextIssue, futureIssue])\n return Response.json([issue], { headers: { Link: `<${url}&page=2>; rel=\"next\"` } })\n })\n const pipeline = fixturePipeline()\n const destination = createMemoryDestination(), journal = createMemoryJournal()\n const result = await runIngestion(request(pipeline, 'issues'), { ...env, journal, destination, now: () => cutoff })\n expect(result.ok).toBe(true)\n expect(requests).toHaveLength(2)\n expect(requests.every((url) => url.searchParams.get('since') === '2008-01-01T00:00:00.000Z')).toBe(true)\n expect(destination.tables.get('default.github_issues_raw')?.map((row) => row.raw)).toEqual([{ repository, data: issue }, { repository, data: nextIssue }])\n expect((await journal.readCheckpoint('github.issues.obsessiondb.chkit')).envelope?.state).toEqual({ watermark: cutoff.toISOString() })\n})\n\ntest.each([\n ['comma in target', '?labels=a,b&page=2', 'rel=\"next\"'],\n ['multiple relations', '?page=2', 'rel=\"alternate next\"'],\n ['quoted comma', '?page=2', 'title=\"page, two\"; rel=\"next\"'],\n ['quoted semicolon', '?page=2', 'title=\"; rel=prev\"; rel=next'],\n])('REST pagination follows next links with %s', async (_label, target, parameters) => {\n const requests: URL[] = []\n const env = githubEnv((url) => {\n requests.push(url)\n if (url.searchParams.has('page')) return Response.json([{ ...issue, number: 2 }])\n return Response.json([issue], { headers: { Link: `<${target}>; ${parameters}` } })\n })\n const pipeline = fixturePipeline()\n const destination = createMemoryDestination(), journal = createMemoryJournal()\n const result = await runIngestion(request(pipeline, 'issues'), { ...env, journal, destination, now: () => cutoff })\n expect(result.ok, JSON.stringify(result)).toBe(true)\n expect(requests).toHaveLength(2)\n expect(requests[1]?.search).toBe(target)\n expect(destination.tables.get('default.github_issues_raw')?.map((row) => row.raw)).toEqual([\n { repository, data: issue }, { repository, data: { ...issue, number: 2 } },\n ])\n expect((await journal.readCheckpoint('github.issues.obsessiondb.chkit')).envelope?.state).toEqual({ watermark: cutoff.toISOString() })\n})\n\ntest.each(['rel=\"next-archive\"', 'title=\"rel=next\"; rel=\"prev\"', 'rel=\"prev\"; rel=\"next\"', 'xrel=next; rel=prev'])('REST pagination ignores non-next relation parameters: %s', async (parameters) => {\n let requests = 0\n const env = githubEnv(() => {\n requests++\n return Response.json([issue], { headers: { Link: `; ${parameters}` } })\n })\n const pipeline = fixturePipeline()\n const result = await runIngestion(request(pipeline, 'issues'), { ...env, journal: createMemoryJournal(), destination: createMemoryDestination(), now: () => cutoff })\n expect(result.ok, JSON.stringify(result)).toBe(true)\n expect(requests).toBe(1)\n})\n\ntest.each(['', 'https://[invalid]'])('REST pagination rejects invalid or cyclic next targets without retrying: %s', async (target) => {\n let requests = 0\n const env = githubEnv(() => {\n requests++\n return Response.json([issue], { headers: { Link: `<${target}>; rel=\"next\"` } })\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal()\n const result = await runIngestion(request(pipeline, 'issues'), { ...env, retry: { retries: 2, minTimeout: 0, maxTimeout: 0 }, journal, destination: createMemoryDestination(), now: () => cutoff })\n expect(result.ok).toBe(false)\n expect(requests).toBe(1)\n expect(journal.events.filter((event) => event.eventKind === 'retry_scheduled')).toHaveLength(0)\n expect((await journal.readCheckpoint('github.issues.obsessiondb.chkit')).envelope).toBeUndefined()\n})\n\ntest('issue page filtering preserves continuations and empty terminal pages', async () => {\n const pages: Page[] = []\n const requests: URL[] = []\n const context = sourceContext((url) => {\n requests.push(url)\n const number = Number(url.searchParams.get('page') ?? '1')\n const next = new URL(url)\n next.searchParams.set('page', String(number + 1))\n return Response.json(number === 1 ? [pullIssue] : number === 2 ? [issue] : [],\n { headers: number < 3 ? { Link: `<${next}>; rel=\"next\"` } : {} })\n })\n for await (const page of createGitHubClient(context, fixtureConfig).issues(repository)) pages.push(page)\n expect(requests).toHaveLength(3)\n expect(pages.map((page) => page.items)).toEqual([[], [issue], []])\n expect(pages.map((page) => page.next)).toEqual([requests[1]?.toString(), requests[2]?.toString(), undefined])\n})\n\ntest('a failed child stream does not block its parents or the other resource checkpoints', async () => {\n const env = githubEnv((url, init) => url.pathname.endsWith('/issues/1/comments')\n ? new Response('denied', { status: 403 }) : fixtureResponse(url, init))\n const pipeline = fixturePipeline()\n const destination = createMemoryDestination(), journal = createMemoryJournal()\n const result = await runIngestion(request(pipeline), { ...env, journal, destination, now: () => cutoff })\n expect(result.ok).toBe(false)\n expect(result.streams.filter((stream) => stream.outcome === 'failed').map((stream) => stream.streamId)).toEqual(['github.issue_comments.obsessiondb.chkit'])\n expect(result.streams.filter((stream) => stream.outcome === 'succeeded')).toHaveLength(7)\n expect(destination.tables.has('default.github_issues_raw')).toBe(true)\n expect(destination.tables.has('default.github_pull_requests_raw')).toBe(true)\n expect((await journal.readCheckpoint('github.issue_comments.obsessiondb.chkit')).envelope).toBeUndefined()\n for (const resource of ['issues', 'pull_request_comments', 'pull_request_review_comments']) {\n expect((await journal.readCheckpoint(`github.${resource}.obsessiondb.chkit`)).envelope?.state).toEqual({ watermark: cutoff.toISOString() })\n }\n expect((await journal.readCheckpoint('github.pull_requests.obsessiondb.chkit')).lastSuccessSeq).toBeGreaterThan(0)\n})\n\ntest('comment streams capture edits on old parents using their own overlapping since windows', async () => {\n const oldIssue = { ...issue, number: 3, updated_at: '2020-01-01T00:00:00Z' }\n const oldPull = { ...pull, number: 4, updated_at: '2020-01-01T00:00:00Z' }\n for (const resource of ['issue_comments', 'pull_request_comments', 'pull_request_review_comments']) {\n let edited = false\n const requests: URL[] = []\n const env = githubEnv((url) => {\n requests.push(url)\n if (url.pathname.endsWith('/issues')) return Response.json([oldIssue, { ...oldPull, pull_request: pullIssue.pull_request }])\n if (url.pathname.endsWith('/pulls')) return Response.json([oldPull])\n const comment = resource === 'issue_comments' ? issueComment : resource === 'pull_request_comments' ? pullComment : reviewComment\n const data = { ...comment, body: edited ? 'Edited old discussion' : 'Original discussion', updated_at: edited ? '2026-01-02T12:00:00Z' : '2026-01-01T12:00:00Z',\n ...(resource === 'pull_request_review_comments' ? { pull_request_url: `https://api.github.com/repos/${repository}/pulls/4` } : {}) }\n return Response.json([data, { ...data, id: 999, updated_at: '2026-01-04T00:00:00Z' }])\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal(), destination = createMemoryDestination()\n expect((await runIngestion(request(pipeline, resource), { ...env, journal, destination, now: () => cutoff })).ok).toBe(true)\n edited = true\n expect((await runIngestion(request(pipeline, resource), { ...env, journal, destination, now: () => new Date('2026-01-03') })).ok).toBe(true)\n const children = requests.filter((url) => url.pathname.endsWith('/comments'))\n expect(children.map((url) => url.searchParams.get('since'))).toEqual(['2008-01-01T00:00:00.000Z', '2026-01-01T23:55:00.000Z'])\n expect(requests.filter((url) => url.pathname.endsWith('/issues') || url.pathname.endsWith('/pulls')).every((url) => !url.searchParams.has('since'))).toBe(true)\n const rows = destination.tables.get(`default.github_${resource}_raw`) ?? []\n expect(rows).toHaveLength(2)\n expect(new Set(rows.map((row) => row.id)).size).toBe(1)\n expect(rows.at(-1)?.raw).toMatchObject({ repository, data: { body: 'Edited old discussion' } })\n expect((await journal.readCheckpoint(`github.${resource}.obsessiondb.chkit`)).envelope?.state).toEqual({ watermark: '2026-01-03T00:00:00.000Z' })\n }\n})\n\ntest('a rejected child write cannot advance its timestamp watermark and the next run replays the window', async () => {\n const starts: string[] = []\n const env = githubEnv((url, init) => {\n if (url.pathname.endsWith('/comments')) starts.push(url.searchParams.get('since') ?? '')\n return fixtureResponse(url, init)\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal(), destination = createMemoryDestination()\n const selected = request(pipeline, 'issue_comments')\n const failed = await runIngestion(selected, { ...env, journal, destination: { insert: async () => { throw new Error('sink rejected') } }, now: () => cutoff })\n expect(failed.ok).toBe(false)\n expect((await journal.readCheckpoint('github.issue_comments.obsessiondb.chkit')).envelope).toBeUndefined()\n expect((await runIngestion(selected, { ...env, journal, destination, now: () => cutoff })).ok).toBe(true)\n expect(starts).toEqual(['2008-01-01T00:00:00.000Z', '2008-01-01T00:00:00.000Z'])\n expect(destination.tables.get('default.github_issue_comments_raw')).toHaveLength(1)\n})\n\ntest('empty resource runs complete independently and full readers scan again without provider state', async () => {\n const calls: string[] = []\n const env = githubEnv((url) => { calls.push(url.pathname); return Response.json([]) })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal(), destination = createMemoryDestination()\n for (const now of [cutoff, new Date('2026-01-03')]) expect((await runIngestion(request(pipeline), { ...env, journal, destination, now: () => now })).ok).toBe(true)\n expect(destination.tables.size).toBe(0)\n for (const resource of ['pull_requests', 'pull_request_reviews', 'pull_request_commits', 'stargazers']) {\n const checkpoint = await journal.readCheckpoint(`github.${resource}.obsessiondb.chkit`)\n expect(checkpoint.envelope).toBeUndefined()\n expect(checkpoint.lastSuccessSeq).toBeGreaterThan(0)\n expect(journal.events.filter((event) => event.namespaceId === `github.${resource}.obsessiondb.chkit` && event.eventKind === 'work_finished' && event.workState === 'succeeded')).toHaveLength(2)\n }\n expect(calls.filter((path) => path.endsWith('/stargazers'))).toHaveLength(2)\n expect((await journal.readCheckpoint('github.issue_comments.obsessiondb.chkit')).envelope?.state).toEqual({ watermark: '2026-01-03T00:00:00.000Z' })\n})\n\ntest('stargazer full sync replays from its first page after page or destination failures before completing', async () => {\n let failSecondPage = true\n const starts: string[] = []\n const second = { ...stargazer, user: { id: 502, login: 'another-example' } }\n const env = githubEnv((url) => {\n if (url.searchParams.get('page') === '2') return failSecondPage ? new Response('denied', { status: 403 }) : Response.json([second])\n starts.push(url.search)\n return Response.json([stargazer], { headers: { Link: `<${url}&page=2>; rel=\"next\"` } })\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal(), destination = createMemoryDestination()\n const selected = request(pipeline, 'stargazers')\n expect((await runIngestion(selected, { ...env, journal, destination, now: () => cutoff })).ok).toBe(false)\n expect((await journal.readCheckpoint('github.stargazers.obsessiondb.chkit')).lastSuccessSeq).toBe(0)\n expect((await journal.readCheckpoint('github.stargazers.obsessiondb.chkit')).envelope).toBeUndefined()\n failSecondPage = false\n const rejected = await runIngestion(selected, { ...env, journal, now: () => cutoff,\n destination: { insert: async () => { throw new Error('sink rejected') } } })\n expect(rejected.ok).toBe(false)\n expect((await journal.readCheckpoint('github.stargazers.obsessiondb.chkit')).lastSuccessSeq).toBe(0)\n expect((await journal.readCheckpoint('github.stargazers.obsessiondb.chkit')).envelope).toBeUndefined()\n expect((await runIngestion(selected, { ...env, journal, destination, now: () => cutoff })).ok).toBe(true)\n const completed = await journal.readCheckpoint('github.stargazers.obsessiondb.chkit')\n expect(completed.lastSuccessSeq).toBeGreaterThan(0)\n expect(completed.envelope).toBeUndefined()\n expect(starts).toEqual(Array(3).fill('?per_page=100'))\n expect(destination.tables.get('default.github_stargazers_raw')?.map(({ id, raw }) => ({ id, raw }))).toEqual([\n { id: JSON.stringify([repository, 501]), raw: { repository, data: stargazer } },\n { id: JSON.stringify([repository, 502]), raw: { repository, data: second } },\n ])\n})\n\ntest('GraphQL commits collect more than 250 entries and retain only SHA and the full multiline message', async () => {\n const commits = Array.from({ length: 275 }, (_, index) => ({ sha: (index + 1).toString(16).padStart(40, '0'), message: `Subject ${index}\\n\\nFull body ${index}\\nLast line.` }))\n const afters: unknown[] = [], requests: URL[] = []\n const env = githubEnv((url, init) => {\n requests.push(url)\n if (url.pathname !== '/graphql') return fixtureResponse(url, init)\n expect(init.method).toBe('POST')\n const body = JSON.parse(String(init.body))\n const after = body.variables.after ?? null\n afters.push(after)\n const offset = after === 'page-100' ? 100 : after === 'page-200' ? 200 : 0\n const items = commits.slice(offset, offset + 100)\n return commitPage(items, commits.length, offset + items.length < commits.length ? `page-${offset + items.length}` : null)\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal(), destination = createMemoryDestination()\n expect((await runIngestion(request(pipeline, 'pull_request_commits'), { ...env, journal, destination, now: () => cutoff })).ok).toBe(true)\n expect(afters).toEqual([null, 'page-100', 'page-200'])\n const rows = destination.tables.get('default.github_pull_request_commits_raw') ?? []\n expect(rows).toHaveLength(275)\n expect(rows.map((row) => row.raw)).toEqual(commits.map((data) => ({ repository, pull_number: 2, data })))\n expect(rows.at(-1)?.id).toBe(JSON.stringify([repository, 2, commits.at(-1)?.sha]))\n expect(requests.filter((url) => url.pathname !== '/graphql').map((url) => url.pathname)).toEqual([`/repos/${repository}/pulls`])\n expect((await journal.readCheckpoint('github.pull_request_commits.obsessiondb.chkit')).envelope).toBeUndefined()\n expect((await journal.readCheckpoint('github.pull_request_commits.obsessiondb.chkit')).lastSuccessSeq).toBeGreaterThan(0)\n})\n\ntest('GraphQL commit totals reject truncated collections and changes during pagination', async () => {\n for (const changed of [false, true]) {\n let calls = 0\n const env = githubEnv((url, init) => {\n if (url.pathname !== '/graphql') return fixtureResponse(url, init)\n calls++\n return commitPage([{ ...commit, sha: String(calls).padStart(40, '0') }], changed && calls === 2 ? 3 : 2, changed && calls === 1 ? 'next' : null)\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal()\n const result = await runIngestion(request(pipeline, 'pull_request_commits'), { ...env, journal, destination: createMemoryDestination(), now: () => cutoff })\n expect(result.ok).toBe(false)\n expect(calls).toBe(changed ? 2 : 1)\n expect((await journal.readCheckpoint('github.pull_request_commits.obsessiondb.chkit')).lastSuccessSeq).toBe(0)\n }\n})\n\ntest('GraphQL commits validate complete counts on empty terminal pages', async () => {\n for (const total of [0, 1, 2]) {\n let calls = 0\n const env = githubEnv((url, init) => {\n if (url.pathname !== '/graphql') return fixtureResponse(url, init)\n calls++\n return commitPage(total > 0 && calls === 1 ? [commit] : [], total, total > 0 && calls === 1 ? 'terminal' : null)\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal(), destination = createMemoryDestination()\n const result = await runIngestion(request(pipeline, 'pull_request_commits'), { ...env, journal, destination, now: () => cutoff })\n expect(result.ok).toBe(total < 2)\n expect(calls).toBe(total === 0 ? 1 : 2)\n expect((await journal.readCheckpoint('github.pull_request_commits.obsessiondb.chkit')).lastSuccessSeq > 0).toBe(total < 2)\n if (total < 2) expect(destination.tables.get('default.github_pull_request_commits_raw') ?? []).toHaveLength(total)\n }\n})\n\ntest('GraphQL commit pagination rejects duplicate SHAs within or across pages despite a matching total', async () => {\n for (const acrossPages of [true, false]) {\n let calls = 0\n const env = githubEnv((url, init) => {\n if (url.pathname !== '/graphql') return fixtureResponse(url, init)\n calls++\n return acrossPages ? commitPage([commit], 2, calls === 1 ? 'next' : null) : commitPage([commit, commit], 2, null)\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal()\n const result = await runIngestion(request(pipeline, 'pull_request_commits'), { ...env, journal, destination: createMemoryDestination(), now: () => cutoff })\n expect(result.ok).toBe(false)\n expect(calls).toBe(acrossPages ? 2 : 1)\n expect((await journal.readCheckpoint('github.pull_request_commits.obsessiondb.chkit')).lastSuccessSeq).toBe(0)\n }\n})\n\ntest('GitHub binds configuration and preserves independently selected installation and repository progress', async () => {\n const requests: URL[] = []\n const config = { ...fixtureConfig, sourceId: 'github.fixture', repositories: ['first/repo', 'second/repo'], pageSize: 25, start: new Date('2025-01-01'), overlapMs: 60_000, token: 'bound-token' }\n const env = githubEnv((url, init) => {\n requests.push(url)\n expect(new Headers(init.headers).get('authorization')).toBe('Bearer bound-token')\n expect(url.searchParams.get('per_page')).toBe('25')\n return Response.json([])\n })\n const pipeline = createGitHubPipeline(config)\n config.token = 'changed'\n config.pageSize = 100\n config.repositories.push('third/repo')\n config.start.setUTCFullYear(2000)\n config.overlapMs = 3_600_000\n expect(pipeline.streams.map((stream) => stream.id).sort()).toEqual(['first.repo', 'second.repo'].flatMap((repo) => resources.map((resource) => `github.fixture.${resource}.${repo}`)).sort())\n const journal = createMemoryJournal(), destination = createMemoryDestination()\n expect((await runIngestion(request(pipeline), { ...env, journal, destination, now: () => cutoff })).ok).toBe(true)\n expect(requests.filter((url) => url.searchParams.has('since')).every((url) => url.searchParams.get('since') === '2025-01-01T00:00:00.000Z')).toBe(true)\n requests.length = 0\n const selected = selectStreams([pipeline], ['repository:second/repo', 'resource:issues'])\n expect(selected.map((entry) => entry.stream.id)).toEqual(['github.fixture.issues.second.repo'])\n expect((await runIngestion({ selected, backfill: undefined }, { ...env, journal, destination, now: () => new Date('2026-01-03') })).ok).toBe(true)\n expect(requests.map((url) => url.pathname)).toEqual(['/repos/second/repo/issues'])\n expect(requests[0]?.searchParams.get('since')).toBe('2026-01-01T23:59:00.000Z')\n expect((await journal.readCheckpoint('github.issues.obsessiondb.chkit')).envelope).toBeUndefined()\n})\n\ntest('GitHub paginated HTTP rate limits consume exactly one request retry budget', async () => {\n let attempts = 0\n const env = githubEnv(() => ++attempts === 1\n ? new Response('rate limited', { status: 403, headers: { 'x-ratelimit-remaining': '0', 'retry-after': '0' } }) : Response.json([]))\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal()\n expect((await runIngestion(request(pipeline, 'stargazers'), { ...env, retry: { retries: 1, minTimeout: 0, maxTimeout: 0 }, journal, destination: createMemoryDestination(), now: () => cutoff })).ok).toBe(true)\n expect(attempts).toBe(2)\n expect(journal.events.filter((event) => event.eventKind === 'retry_scheduled' && event.errorClass === 'rate_limited')).toHaveLength(1)\n})\n\ntest('GraphQL HTTP200 rate errors honor Retry-After while partial data fails permanently', async () => {\n for (const retryable of [true, false]) {\n let attempts = 0\n const env = githubEnv((url, init) => {\n if (url.pathname !== '/graphql') return fixtureResponse(url, init)\n attempts++\n if (retryable && attempts > 1) return commitPage([commit], 1, null)\n return Response.json({ data: { repository: null }, errors: [{ type: retryable ? 'RATE_LIMITED' : 'NOT_FOUND', message: 'query rejected' }] },\n { headers: retryable ? { 'Retry-After': '0', 'x-ratelimit-remaining': '0' } : {} })\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal()\n const result = await runIngestion(request(pipeline, 'pull_request_commits'), { ...env, retry: { retries: 1, minTimeout: 0, maxTimeout: 0 }, journal, destination: createMemoryDestination(), now: () => cutoff })\n expect(result.ok).toBe(retryable)\n expect(attempts).toBe(retryable ? 2 : 1)\n expect(journal.events.filter((event) => event.eventKind === 'retry_scheduled')).toHaveLength(retryable ? 1 : 0)\n }\n})\n\ntest('secondary REST rate limits and headerless GraphQL rate errors retain provider diagnostics', async () => {\n const restClient = createGitHubClient(sourceContext(() => Response.json({ message: 'You have exceeded a secondary rate limit.' },\n { status: 403, headers: { 'x-ratelimit-remaining': '19' } })), fixtureConfig)\n const rest: unknown = await restClient.issues(repository).next().catch((cause: unknown) => cause)\n expect(rest).toBeInstanceOf(HttpError)\n expect(rest).toMatchObject({ status: 429, retryAfterMs: 60_000, body: expect.stringContaining('secondary rate limit'), response: { status: 403 } })\n const payload = { data: { repository: null }, errors: [{ type: 'RATE_LIMITED', message: 'API rate limit exceeded' }] }\n const client = createGitHubClient(sourceContext(() => Response.json(payload)), fixtureConfig)\n const failure: unknown = await client.graphql('query { viewer { login } }', {}).catch((cause: unknown) => cause)\n expect(failure).toBeInstanceOf(HttpError)\n expect(failure).toMatchObject({ status: 429, body: JSON.stringify(payload), retryAfterMs: 60_000 })\n})\n\ntest('invalid REST continuations and payloads fail without completing or replaying the resource', async () => {\n for (const mode of ['repeated', 'foreign', 'malformed']) {\n let calls = 0\n const env = githubEnv((url) => {\n calls++\n return mode === 'malformed' ? Response.json({ not: 'an array' })\n : Response.json([stargazer], { headers: { Link: `<${mode === 'foreign' ? 'https://example.com/steal' : url.toString()}>; rel=\"next\"` } })\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal(), destination = createMemoryDestination()\n const result = await runIngestion(request(pipeline, 'stargazers'), { ...env, journal, destination, now: () => cutoff })\n expect(result.ok).toBe(false)\n expect(calls).toBe(1)\n expect(destination.tables.size).toBe(0)\n expect((await journal.readCheckpoint('github.stargazers.obsessiondb.chkit')).lastSuccessSeq).toBe(0)\n }\n})\n\ntest('GraphQL malformed or cyclic cursors and invalid commit nodes never record successful completion', async () => {\n for (const mode of ['missing-cursor', 'repeated', 'missing-message']) {\n let calls = 0\n const env = githubEnv((url, init) => {\n if (url.pathname !== '/graphql') return fixtureResponse(url, init)\n calls++\n const page = { totalCount: mode === 'repeated' ? 3 : 1,\n nodes: [{ commit: mode === 'missing-message' ? { oid: commit.sha }\n : { oid: mode === 'repeated' ? String(calls).padStart(40, '0') : commit.sha, message: commit.message } }],\n pageInfo: { hasNextPage: mode !== 'missing-message', endCursor: mode === 'missing-cursor' ? null : 'same' } }\n return Response.json({ data: { repository: { pullRequest: { commits: page } } } })\n })\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal()\n const result = await runIngestion(request(pipeline, 'pull_request_commits'), { ...env, journal, destination: createMemoryDestination(), now: () => cutoff })\n expect(result.ok).toBe(false)\n expect(calls).toBe(mode === 'repeated' ? 2 : 1)\n if (mode === 'repeated') expect(result.streams[0]?.error).toContain('repeated continuation')\n expect((await journal.readCheckpoint('github.pull_request_commits.obsessiondb.chkit')).lastSuccessSeq).toBe(0)\n }\n})\n\ntest('review comments reject a parent URL from another repository before claiming a watermark', async () => {\n const env = githubEnv(() => Response.json([{ ...reviewComment, pull_request_url: 'https://api.github.com/repos/another/project/pulls/2' }]))\n const pipeline = fixturePipeline()\n const journal = createMemoryJournal()\n const result = await runIngestion(request(pipeline, 'pull_request_review_comments'), { ...env, journal, destination: createMemoryDestination(), now: () => cutoff })\n expect(result.ok).toBe(false)\n expect((await journal.readCheckpoint('github.pull_request_review_comments.obsessiondb.chkit')).envelope).toBeUndefined()\n})\n\ntest('GitHub checks its configuration when a stream runs, not when the module loads or a stream is selected', async () => {\n let requests = 0\n const pipeline = createGitHubPipeline({ ...fixtureConfig, repositories: ['not-a-repository'], pageSize: 500 })\n const selected = selectStreams([pipeline], [])\n expect(selected).toHaveLength(8)\n const env = githubEnv(() => { requests++; return Response.json([]) })\n const result = await runIngestion({ selected, backfill: undefined }, { ...env, journal: createMemoryJournal(), destination: createMemoryDestination(), now: () => cutoff })\n expect(result.streams.every((stream) => stream.outcome === 'failed' && /at pageSize[\\s\\S]*at repositories\\[0\\]/.test(stream.error ?? ''))).toBe(true)\n expect(requests).toBe(0)\n})\n\ntest('GitHub fails every stream before any request without a token', async () => {\n for (const token of [undefined, ' ']) {\n let requests = 0\n const env = githubEnv(() => { requests++; return Response.json([]) })\n const result = await runIngestion(request(fixturePipeline({ ...fixtureConfig, token })), { ...env, journal: createMemoryJournal(), destination: createMemoryDestination(), now: () => cutoff })\n expect(result.streams).toHaveLength(8)\n expect(result.streams.every((stream) => stream.outcome === 'failed' && stream.error?.includes('Set GITHUB_TOKEN or pass token.'))).toBe(true)\n expect(requests).toBe(0)\n }\n})\n\ntest('GitHub fails a malformed provider payload at once and retries only a transient response', async () => {\n const run = async (respond: Responder) => {\n const journal = createMemoryJournal()\n const result = await runIngestion(request(fixturePipeline(), 'stargazers'), { ...githubEnv(respond), retry: { retries: 2, minTimeout: 0 }, journal, destination: createMemoryDestination(), now: () => cutoff })\n return { result, retries: journal.events.filter((event) => event.eventKind === 'retry_scheduled').map((event) => event.errorClass) }\n }\n let calls = 0\n const malformed = await run(() => { calls += 1; return Response.json({ message: 'Not an array' }) })\n expect(malformed.result.streams[0]?.outcome).toBe('failed')\n expect(malformed.result.streams[0]?.error).toContain('Invalid input: expected array, received object')\n expect(calls).toBe(1)\n expect(malformed.retries).toEqual([])\n\n let unavailable = true\n const flaky = await run((url, init) => {\n if (unavailable) { unavailable = false; return new Response('busy', { status: 503 }) }\n return fixtureResponse(url, init)\n })\n expect(flaky.result.ok).toBe(true)\n expect(flaky.retries).toEqual(['transient'])\n})\n\nfunction fixturePipeline(config: GitHubConfig = fixtureConfig): Pipeline {\n return createGitHubPipeline(config)\n}\n\nfunction githubEnv(respond: Responder = fixtureResponse) {\n return { fetch: async (input: string | URL, init?: RequestInit) => respond(new URL(input), init ?? {}), retry: { retries: 0 } }\n}\n\nfunction sourceContext(respond: Responder): SourceContext {\n return createSourceContext({ fetch: async (input, init) => respond(new URL(input), init ?? {}) })\n}\n\nfunction request(pipeline: Pipeline, resource?: string) {\n return { selected: selectStreams([pipeline], resource ? [`resource:${resource}`] : []).map((entry) => ({\n ...entry, stream: { ...entry.stream, batchSize: 1 },\n })), backfill: undefined }\n}\n\nfunction fixtureResponse(url: URL, _init: RequestInit): Response {\n if (url.pathname === `/repos/${repository}/issues`) return Response.json([issue, pullIssue])\n if (url.pathname === `/repos/${repository}/pulls`) return Response.json([pull])\n if (url.pathname.endsWith('/issues/1/comments')) return Response.json([issueComment])\n if (url.pathname.endsWith('/issues/2/comments')) return Response.json([pullComment])\n if (url.pathname.endsWith('/pulls/comments')) return Response.json([reviewComment])\n if (url.pathname.endsWith('/pulls/2/reviews')) return Response.json([review])\n if (url.pathname.endsWith('/stargazers')) return Response.json([stargazer])\n if (url.pathname === '/graphql') return commitPage([commit], 1, null)\n throw new Error(`Unexpected GitHub fixture request: ${url}`)\n}\n\nfunction commitPage(items: readonly { sha: string; message: string }[], totalCount: number, next: string | null): Response {\n return Response.json({ data: { repository: { pullRequest: { commits: { totalCount,\n nodes: items.map((item) => ({ commit: { oid: item.sha, message: item.message, author: { name: 'Do not retain expanded commit fields' } } })),\n pageInfo: { hasNextPage: next !== null, endCursor: next },\n } } } } })\n}\n" } ], "meta": { "chkit": { "formatVersion": 1, "version": "0.3.1", "changelog": [ { "version": "0.3.1", "changes": [ "Trim raw-storage notes from the README." ] }, { "version": "0.3.0", "changes": [ "Read configuration and the token when a stream runs, so `generate`, `migrate`, and `chkit check` never depend on them; invalid settings, such as repositories or page sizes, or a missing token fail that run before any request. Requires zod 4 and chkit 0.2.0-beta.12.", "Send requests through the ingestion runtime, which retries only network failures, timeouts, retryable HTTP statuses, and GitHub primary and secondary rate limits, including GraphQL `RATE_LIMITED` errors; malformed payloads, invalid continuations, and other GraphQL errors fail at once.", "Set `token` in the configuration to use another token, for example for a second installation; it defaults to `GITHUB_TOKEN`." ] }, { "version": "0.2.1", "changes": [ "Follow REST next-page links containing commas or multiple relation types without truncating a read, and ignore non-next relation parameters.", "Reject dot-only repository path segments before URL normalization can change the requested resource.", "Clarify native JSON normalization of explicit null paths and empty objects." ] }, { "version": "0.2.0", "changes": [ "Sync issues and editable comments through overlapping updated-time windows; advance each stream watermark only after its destination acknowledgement.", "Separate issues, issue comments, pull requests, PR conversation comments, review comments, reviews, commits, and stargazers into independently selectable raw streams for every configured repository.", "Store repository and parent join keys beside provider data; retain only commit SHA and message through paginated GraphQL commit connections, and leave joins to ClickHouse.", "Use one installation pipeline with configuration snapshots, injectable requests, shared pagination, and fullSync where no reliable change filter exists; existing mixed or combined observations require deliberate data migration.", "Consume full pagination pages and use shared continuation-cycle detection while preserving raw resource checkpoints and PR commit completeness checks." ] }, { "version": "0.1.0", "changes": [ "Introduce raw repository issues and stargazers ingestion." ] } ], "language": "typescript", "license": "MIT", "documentation": "https://chkit.obsessiondb.com/integrations/github/", "logo": "https://chkit.obsessiondb.com/logos/github.svg", "authentication": { "method": "Bearer token", "env": [ "GITHUB_TOKEN" ], "setup": [ "For private repositories, the supported setup grants GITHUB_TOKEN repository access with Issues:read, Pull requests:read, and Contents:read, including GraphQL commit reads; this is not a verified field-level permission minimum.", "Supply a new access token when the existing token expires." ], "documentation": "https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens" }, "chkit": "^0.2.0-beta.12", "ingest": "^0.2.0-beta.12", "clickhouse": ">=25.3.0", "root": "src/integrations/github", "entry": "index.ts", "exports": [ "githubPipeline", "createGitHubPipeline", "github_issuesRaw", "github_issueCommentsRaw", "github_pullRequestsRaw", "github_pullRequestCommentsRaw", "github_pullRequestReviewCommentsRaw", "github_pullRequestReviewsRaw", "github_pullRequestCommitsRaw", "github_stargazersRaw" ], "resources": [ { "name": "issues", "title": "Issues", "table": "github_issues_raw", "description": "Only ordinary issues, with complete provider issue fields and repository context", "scopes": [ "Issues:read" ], "strategy": "timestamp", "endpoints": [ { "method": "GET", "path": "/repos/{owner}/{repo}/issues", "documentation": "https://docs.github.com/en/rest/issues/issues#list-repository-issues" } ] }, { "name": "issue_comments", "title": "Issue comments", "table": "github_issue_comments_raw", "description": "One raw comment per row for ordinary issues; independently discovers all issue parents and filters child updates", "scopes": [ "Issues:read" ], "strategy": "timestamp", "endpoints": [ { "method": "GET", "path": "/repos/{owner}/{repo}/issues", "documentation": "https://docs.github.com/en/rest/issues/issues#list-repository-issues" }, { "method": "GET", "path": "/repos/{owner}/{repo}/issues/{issue_number}/comments", "documentation": "https://docs.github.com/en/rest/issues/comments#list-issue-comments" } ] }, { "name": "pull_requests", "title": "Pull requests", "table": "github_pull_requests_raw", "description": "Pull-request metadata from its own collection, with repository context", "scopes": [ "Pull requests:read" ], "strategy": "full", "endpoints": [ { "method": "GET", "path": "/repos/{owner}/{repo}/pulls", "documentation": "https://docs.github.com/en/rest/pulls/pulls#list-pull-requests" } ] }, { "name": "pull_request_comments", "title": "Pull request conversation comments", "table": "github_pull_request_comments_raw", "description": "One raw conversation comment per row with its pull number; independently discovers all pull-request parents and filters child updates", "scopes": [ "Pull requests:read" ], "strategy": "timestamp", "endpoints": [ { "method": "GET", "path": "/repos/{owner}/{repo}/pulls", "documentation": "https://docs.github.com/en/rest/pulls/pulls#list-pull-requests" }, { "method": "GET", "path": "/repos/{owner}/{repo}/issues/{pull_number}/comments", "documentation": "https://docs.github.com/en/rest/issues/comments#list-issue-comments" } ] }, { "name": "pull_request_review_comments", "title": "Pull request review comments", "table": "github_pull_request_review_comments_raw", "description": "Raw diff-review comments with repository and pull-number context, selected by their own update times", "scopes": [ "Pull requests:read" ], "strategy": "timestamp", "endpoints": [ { "method": "GET", "path": "/repos/{owner}/{repo}/pulls/comments", "documentation": "https://docs.github.com/en/rest/pulls/comments#list-review-comments-in-a-repository" } ] }, { "name": "pull_request_reviews", "title": "Pull request reviews", "table": "github_pull_request_reviews_raw", "description": "One raw review per row with repository and pull number; discovers its own pull-request parents", "scopes": [ "Pull requests:read" ], "strategy": "full", "endpoints": [ { "method": "GET", "path": "/repos/{owner}/{repo}/pulls", "documentation": "https://docs.github.com/en/rest/pulls/pulls#list-pull-requests" }, { "method": "GET", "path": "/repos/{owner}/{repo}/pulls/{pull_number}/reviews", "documentation": "https://docs.github.com/en/rest/pulls/reviews#list-reviews-for-a-pull-request" } ] }, { "name": "pull_request_commits", "title": "Pull request commits", "table": "github_pull_request_commits_raw", "description": "Commit SHA and message only, with repository and pull number; paginates GraphQL commits after independent pull-request discovery", "scopes": [ "Pull requests:read", "Contents:read" ], "strategy": "full", "endpoints": [ { "method": "GET", "path": "/repos/{owner}/{repo}/pulls", "documentation": "https://docs.github.com/en/rest/pulls/pulls#list-pull-requests" }, { "method": "POST", "path": "/graphql", "documentation": "https://docs.github.com/en/graphql/reference/pulls#pullrequest" } ] }, { "name": "stargazers", "title": "Stargazers", "table": "github_stargazers_raw", "description": "Repository stargazers with starred_at and repository context", "scopes": [], "strategy": "full", "endpoints": [ { "method": "GET", "path": "/repos/{owner}/{repo}/stargazers", "documentation": "https://docs.github.com/en/rest/activity/starring#list-stargazers" } ] } ], "views": [], "sync": { "description": "One installation pipeline groups eight independent resource streams per configured repository. Issues and comments use completed updated-time windows; pull requests, reviews, commits, and stargazers use fullSync. Each child stream discovers its own parent collection, independently of parent-stream execution or parent update times.", "schedule": "Run bunx chkit ingest run --tag provider:github from a scheduler.", "deletions": "Deleted records, removed stars, and commits no longer present after a force-push remain stored. Missing observations do not generate tombstones; legacy mixed issue/PR rows and nested child payloads require deliberate migration." }, "env": { "GITHUB_TOKEN": "" }, "fileHashes": { "src/integrations/github/README.md": "56769dc999e1bd05b65d6899dfc22f0647126b33d4ca8d7a7ebac97487015279", "src/integrations/github/index.ts": "18cc6d48bcd79ca7855de185d15c3f245423571863e5f39deb031278640d7a9e", "src/integrations/github/config.ts": "100b4f884a67d940b74d5a1155530a240a0c1680e5749cac1e5964554be5bbd4", "src/integrations/github/client.ts": "b686a42be55be67142e08e98f91516ca97be4bb4cb602ae12eb246cd1f22fb5b", "src/integrations/github/pipeline.ts": "06be9f4bc93be4a5abf8fb1d1cf666185f57de7af5d39c96227e4e1e8dbc7df8", "src/integrations/github/sources/issues.ts": "ad858a92d5476e390350de4d0ed83db8651f4b4e79a3bc172711ed271884a899", "src/integrations/github/sources/stargazers.ts": "7bb347d31d394fece571d06dc6cbf6139a215019acd862facb10cd82ae0628ce", "src/integrations/github/sources/issue-comments.ts": "8afb3a5040bf2b06aa044639844ce8e88b0c86c481ed19a6d7fc9c8f83db989d", "src/integrations/github/sources/pull-requests.ts": "baab11f7ff1deb80e7a07df0a67d72e9cab764f8ab13bb16fb8bee6a6d97fe35", "src/integrations/github/sources/pull-request-comments.ts": "2515fc390a005e97db6762a289327111282b4a3c7a83f767d203fcc494673d03", "src/integrations/github/sources/pull-request-review-comments.ts": "99fbbe6bad027d5b786fee3b5b2b6563f99e8538a106cdcaf867a95b24b4b568", "src/integrations/github/sources/pull-request-reviews.ts": "a4b80106387887adbd75692f515639107da09a5d561a18e36a65897d11cc8ed9", "src/integrations/github/sources/pull-request-commits.ts": "8cc34c521885125b57a1394481312384a6acc55eadf78e0929b8825ed8d0b852", "src/integrations/github/tests/basic.test.ts": "e68940c3dea065cbb7c0f6fe18833a98e6915d56ac1ac803ee2fba3de7288153" } } } }