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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/gittensory-miner/lib/ams-policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function fetchRepoAmsPolicyContent(target, resolved) {
for (const path of AMS_POLICY_SPEC_FILENAMES) {
const url = `${resolved.rawContentBaseUrl}/${encodeURIComponent(target.owner)}/${encodeURIComponent(target.repo)}/HEAD/${path}`;
try {
const response = await resolved.fetchImpl(url, { method: "GET", headers: { accept: "application/json", "user-agent": "gittensory-miner" } });
const response = await resolved.fetchImpl(url, { method: "GET", headers: { accept: "application/json", "user-agent": "loopover-miner" } });
if (response.ok) {
const text = await response.text();
if (typeof text === "string") return text;
Expand Down
2 changes: 1 addition & 1 deletion packages/gittensory-miner/lib/ci-poller.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function normalizePullNumber(value) {
function githubHeaders(githubToken) {
const headers = {
accept: "application/vnd.github+json",
"user-agent": "gittensory-miner",
"user-agent": "loopover-miner",
"x-github-api-version": githubApiVersion,
};
if (githubToken) headers.authorization = `Bearer ${githubToken}`;
Expand Down
2 changes: 1 addition & 1 deletion packages/gittensory-miner/lib/laptop-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function resolveCodexAuthPath(env = process.env) {
function githubHeaders(githubToken) {
const headers = {
accept: "application/vnd.github+json",
"user-agent": "gittensory-miner",
"user-agent": "loopover-miner",
"x-github-api-version": githubApiVersion,
};
const token = typeof githubToken === "string" ? githubToken.trim() : "";
Expand Down
2 changes: 1 addition & 1 deletion packages/gittensory-miner/lib/live-issue-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function githubGraphqlHeaders(githubToken) {
const headers = {
accept: "application/vnd.github+json",
"content-type": "application/json",
"user-agent": "gittensory-miner",
"user-agent": "loopover-miner",
"x-github-api-version": GITHUB_API_VERSION,
};
const token = typeof githubToken === "string" ? githubToken.trim() : "";
Expand Down
2 changes: 1 addition & 1 deletion packages/gittensory-miner/lib/opportunity-fanout.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function targetFromSearchIssue(issue) {
function githubHeaders(githubToken) {
const headers = {
accept: "application/vnd.github+json",
"user-agent": "gittensory-miner",
"user-agent": "loopover-miner",
"x-github-api-version": githubApiVersion,
};
const token = typeof githubToken === "string" ? githubToken.trim() : "";
Expand Down
2 changes: 1 addition & 1 deletion packages/gittensory-miner/lib/pr-disposition-poller.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function normalizePullNumber(value) {
function githubHeaders(githubToken) {
const headers = {
accept: "application/vnd.github+json",
"user-agent": "gittensory-miner",
"user-agent": "loopover-miner",
"x-github-api-version": githubApiVersion,
};
if (githubToken) headers.authorization = `Bearer ${githubToken}`;
Expand Down
2 changes: 1 addition & 1 deletion packages/gittensory-miner/lib/rejection-signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function normalizeOptions(options = {}) {
async function fetchPolicyDoc(target, path, resolved) {
const url = `${resolved.rawContentBaseUrl}/${encodeURIComponent(target.owner)}/${encodeURIComponent(target.repo)}/HEAD/${path}`;
try {
const response = await resolved.fetchImpl(url, { method: "GET", headers: { accept: "application/json", "user-agent": "gittensory-miner" } });
const response = await resolved.fetchImpl(url, { method: "GET", headers: { accept: "application/json", "user-agent": "loopover-miner" } });
if (!response.ok) return null;
const text = await response.text();
return typeof text === "string" ? text : null;
Expand Down
4 changes: 2 additions & 2 deletions packages/gittensory-miner/lib/self-review-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function parseRepoFullName(repoFullName) {
function githubHeaders(githubToken) {
const headers = {
accept: "application/vnd.github+json",
"user-agent": "gittensory-miner",
"user-agent": "loopover-miner",
"x-github-api-version": GITHUB_API_VERSION,
};
const token = typeof githubToken === "string" ? githubToken.trim() : "";
Expand Down Expand Up @@ -216,7 +216,7 @@ async function fetchManifestContent(target, resolved) {
for (const path of MANIFEST_FILE_CANDIDATES) {
const url = `${resolved.rawContentBaseUrl}/${encodeURIComponent(target.owner)}/${encodeURIComponent(target.repo)}/HEAD/${path}`;
try {
const response = await resolved.fetchImpl(url, { method: "GET", headers: { accept: "application/json", "user-agent": "gittensory-miner" } });
const response = await resolved.fetchImpl(url, { method: "GET", headers: { accept: "application/json", "user-agent": "loopover-miner" } });
if (response.ok) {
const text = await response.text();
if (typeof text === "string") return text;
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-mcp-release-due.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async function githubRequest({ token, method, path, body }) {
accept: "application/vnd.github+json",
authorization: `Bearer ${token}`,
"content-type": "application/json",
"user-agent": "gittensory-mcp-release-watch",
"user-agent": "loopover-mcp-release-watch",
"x-github-api-version": "2022-11-28",
},
body: body ? JSON.stringify(body) : undefined,
Expand Down
2 changes: 1 addition & 1 deletion scripts/smoke-production.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async function fetchWithTimeout(url, init = {}) {
return await fetch(url, {
...init,
headers: {
"user-agent": "gittensory-production-smoke",
"user-agent": "loopover-production-smoke",
...(init.headers ?? {}),
},
signal: controller.signal,
Expand Down
10 changes: 5 additions & 5 deletions src/auth/github-oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function startGitHubDeviceFlow(env: Env): Promise<GitHubDeviceCodeR
headers: {
accept: "application/json",
"content-type": "application/json",
"user-agent": "gittensory-api",
"user-agent": "loopover-api",
},
body: JSON.stringify({
client_id: env.GITHUB_OAUTH_CLIENT_ID,
Expand All @@ -69,7 +69,7 @@ export async function pollGitHubDeviceFlow(env: Env, deviceCode: string) {
headers: {
accept: "application/json",
"content-type": "application/json",
"user-agent": "gittensory-api",
"user-agent": "loopover-api",
},
body: JSON.stringify({
client_id: env.GITHUB_OAUTH_CLIENT_ID,
Expand Down Expand Up @@ -130,7 +130,7 @@ export async function completeGitHubWebOAuth(
headers: {
accept: "application/json",
"content-type": "application/json",
"user-agent": "gittensory-api",
"user-agent": "loopover-api",
},
body: JSON.stringify({
client_id: env.GITHUB_OAUTH_CLIENT_ID,
Expand Down Expand Up @@ -183,7 +183,7 @@ export async function createSessionFromGitHubToken(
headers: {
accept: "application/vnd.github+json",
authorization: `Bearer ${githubToken}`,
"user-agent": "gittensory-api",
"user-agent": "loopover-api",
"x-github-api-version": "2022-11-28",
},
});
Expand Down Expand Up @@ -213,7 +213,7 @@ async function verifyTokenBelongsToApp(env: Env, githubToken: string): Promise<b
accept: "application/vnd.github+json",
authorization: `Basic ${btoa(`${env.GITHUB_OAUTH_CLIENT_ID}:${env.GITHUB_OAUTH_CLIENT_SECRET}`)}`,
"content-type": "application/json",
"user-agent": "gittensory-api",
"user-agent": "loopover-api",
"x-github-api-version": "2022-11-28",
},
body: JSON.stringify({ access_token: githubToken }),
Expand Down
3 changes: 2 additions & 1 deletion src/github/backfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import {
githubRateLimitAdmissionKeyForPublicToken,
githubRateLimitAdmissionKeyForToken,
isGitHubResponseCacheReplay,
PRODUCT_USER_AGENT,
timeoutFetch,
type GitHubRateLimitAdmissionKey,
} from "./client";
Expand Down Expand Up @@ -4412,7 +4413,7 @@ function notModifiedResponse(response: Response): GitHubJsonNotModifiedResponse
function githubRestHeaders(token?: string, validators?: GitHubConditionalValidators): HeadersInit {
return {
accept: "application/vnd.github+json",
"user-agent": "gittensory/0.1",
"user-agent": PRODUCT_USER_AGENT,
"x-github-api-version": "2022-11-28",
...(validators?.etag ? { "if-none-match": validators.etag } : {}),
...(validators?.lastModified ? { "if-modified-since": validators.lastModified } : {}),
Expand Down
8 changes: 7 additions & 1 deletion src/github/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ const DEFAULT_METADATA_TTL_SECONDS = 10 * 60;
const DEFAULT_COMMIT_TTL_SECONDS = 15 * 60;
export const GITHUB_RESPONSE_CACHE_REPLAY_HEADER = "x-gittensory-cache";

/** The single source of truth for the product's outbound User-Agent, used by every raw-`fetch`/`timeoutFetch`
* call across `src/` that identifies itself generically (as opposed to a service-specific variant like the
* self-host or content-lane User-Agent). Consolidates what had drifted into ~16 independently hardcoded
* copies of the same literal. */
export const PRODUCT_USER_AGENT = "loopover/0.1";

/** The single shared GitHub REST header-builder for every raw-`fetch`/`timeoutFetch` call in `src/` (Octokit
* calls set their own headers internally and don't need this). Consolidates four independent, drifted
* `githubHeaders` copies that had each grown a different signature (#4610). `token` is optional — a public,
Expand All @@ -48,7 +54,7 @@ export function githubHeaders(options: GitHubHeadersOptions = {}): Record<string
const { token, accept = "application/vnd.github+json", json = false, apiVersion = true } = options;
return {
accept,
"user-agent": "gittensory/0.1",
"user-agent": PRODUCT_USER_AGENT,
...(apiVersion ? { "x-github-api-version": "2022-11-28" } : {}),
...(json ? { "content-type": "application/json" } : {}),
...(token ? { authorization: `Bearer ${token}` } : {}),
Expand Down
3 changes: 2 additions & 1 deletion src/github/graphql-cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
GITHUB_RESPONSE_CACHE_REPLAY_HEADER,
PRODUCT_USER_AGENT,
getGitHubResponseCache,
timeoutFetch,
type CachedGitHubResponse,
Expand Down Expand Up @@ -85,7 +86,7 @@ function graphQlFetchInit(query: string, token: string, admissionKey?: GitHubRat
headers: {
accept: "application/vnd.github+json",
"content-type": "application/json",
"user-agent": "gittensory/0.1",
"user-agent": PRODUCT_USER_AGENT,
authorization: `Bearer ${token}`,
},
body: JSON.stringify({ query }),
Expand Down
4 changes: 2 additions & 2 deletions src/github/migration-tree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { timeoutFetch, type GitHubRateLimitAdmissionKey } from "./client";
import { PRODUCT_USER_AGENT, timeoutFetch, type GitHubRateLimitAdmissionKey } from "./client";
import { repoParts } from "../utils/json";

const GITHUB_FETCH_TIMEOUT_MS = 10_000;
Expand All @@ -8,7 +8,7 @@ const MIGRATIONS_PREFIX = "migrations/";
function ghHeaders(token: string | undefined): Record<string, string> {
return {
accept: "application/vnd.github+json",
"user-agent": "gittensory/0.1",
"user-agent": PRODUCT_USER_AGENT,
"x-github-api-version": "2022-11-28",
...(token ? { authorization: `Bearer ${token}` } : {}),
};
Expand Down
6 changes: 3 additions & 3 deletions src/github/public.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { githubRateLimitAdmissionKeyForPublicToken, timeoutFetch, type GitHubRateLimitAdmissionKey } from "./client";
import { githubRateLimitAdmissionKeyForPublicToken, PRODUCT_USER_AGENT, timeoutFetch, type GitHubRateLimitAdmissionKey } from "./client";

export type PublicContributorProfile = {
login: string;
Expand Down Expand Up @@ -66,7 +66,7 @@ export async function fetchPublicContributorProfile(login: string, env?: Pick<En
const safeLogin = encodeURIComponent(login);
const headers = {
accept: "application/vnd.github+json",
"user-agent": "gittensory/0.1",
"user-agent": PRODUCT_USER_AGENT,
"x-github-api-version": "2022-11-28",
// Authenticated requests lift the 60/hr unauthenticated ceiling to 5000/hr so the 500-login evidence
// loop doesn't exhaust it and silently degrade (mirrors fetchPublicRepoStats) (#790).
Expand Down Expand Up @@ -192,7 +192,7 @@ async function fetchRepoStatsFromGitHub(env: Pick<Env, "GITHUB_PUBLIC_TOKEN">, r
const response = await timeoutFetch(`https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`, {
headers: {
accept: "application/vnd.github+json",
"user-agent": "gittensory/0.1",
"user-agent": PRODUCT_USER_AGENT,
"x-github-api-version": "2022-11-28",
...(env.GITHUB_PUBLIC_TOKEN ? { authorization: `Bearer ${env.GITHUB_PUBLIC_TOKEN}` } : {}),
},
Expand Down
3 changes: 2 additions & 1 deletion src/gittensor/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ContributorRepoStatRecord } from "../types";
import { PRODUCT_USER_AGENT } from "../github/client";
import { errorMessage } from "../utils/json";

const GITTENSOR_API_BASE = "https://api.gittensor.io";
Expand Down Expand Up @@ -282,7 +283,7 @@ async function fetchJson<T>(url: string): Promise<T> {
const response = await fetch(url, {
headers: {
accept: "application/json",
"user-agent": "gittensory/0.1",
"user-agent": PRODUCT_USER_AGENT,
},
signal: AbortSignal.timeout(GITTENSOR_FETCH_TIMEOUT_MS),
});
Expand Down
2 changes: 1 addition & 1 deletion src/orb/app-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function orbHeaders(jwt: string): HeadersInit {
accept: "application/vnd.github+json",
authorization: `Bearer ${jwt}`,
"content-type": "application/json",
"user-agent": "gittensory-orb/0.1",
"user-agent": "loopover-orb/0.1",
"x-github-api-version": "2022-11-28",
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/orb/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// (read back at token-exchange, never from a request). No request input is echoed into the markup (no injection
// surface).
import type { Context } from "hono";
import { timeoutFetch } from "../github/client";
import { PRODUCT_USER_AGENT, timeoutFetch } from "../github/client";
import { GITTENSORY_SITE_URL } from "../github/footer";
import { isOrbBrokerEnabled, issueOrbEnrollment } from "./broker";

Expand All @@ -36,7 +36,7 @@ export async function exchangeOrbOAuthCode(env: Env, code: string, fetchImpl: ty
/** Identify the authenticated maintainer (GET /user with their token). Null on any non-OK / loginless response. */
export async function fetchOrbOAuthUser(token: string, fetchImpl: typeof fetch = timeoutFetch): Promise<GitHubUser | null> {
const res = await fetchImpl("https://api.github.com/user", {
headers: { authorization: `Bearer ${token}`, accept: "application/vnd.github+json", "user-agent": "gittensory/0.1" },
headers: { authorization: `Bearer ${token}`, accept: "application/vnd.github+json", "user-agent": PRODUCT_USER_AGENT },
});
const user = (await res.json().catch(() => ({}))) as GitHubUser;
return res.ok && user.login ? user : null;
Expand All @@ -60,7 +60,7 @@ export async function verifyInstallationAdmin(
return userId === accountId && userLogin.toLowerCase() === accountLogin.toLowerCase();
}
const res = await fetchImpl(`https://api.github.com/user/memberships/orgs/${encodeURIComponent(accountLogin)}`, {
headers: { authorization: `Bearer ${token}`, accept: "application/vnd.github+json", "user-agent": "gittensory/0.1" },
headers: { authorization: `Bearer ${token}`, accept: "application/vnd.github+json", "user-agent": PRODUCT_USER_AGENT },
});
if (!res.ok) return false;
const body = (await res.json().catch(() => ({}))) as GitHubOrgMembership;
Expand Down
2 changes: 1 addition & 1 deletion src/orb/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export async function forwardOrbEvent(
"x-github-event": args.eventName,
"x-github-delivery": args.deliveryId,
"x-orb-signature-256": `sha256=${signature}`,
"user-agent": "gittensory-orb/0.1",
"user-agent": "loopover-orb/0.1",
},
body: args.rawBody,
signal: AbortSignal.timeout(10_000),
Expand Down
3 changes: 2 additions & 1 deletion src/registry/sync.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { and, desc, eq, inArray } from "drizzle-orm";
import { getDb } from "../db/client";
import { registrySnapshots, repositories, syncRuns } from "../db/schema";
import { PRODUCT_USER_AGENT } from "../github/client";
import type { RegistrySnapshot } from "../types";
import { errorMessage, jsonString, nowIso, repoParts } from "../utils/json";
import { normalizeRegistryPayload } from "./normalize";
Expand Down Expand Up @@ -35,7 +36,7 @@ export async function refreshRegistry(env: Env): Promise<RegistrySnapshot> {
const response = await fetch(url, {
headers: {
accept: "application/json",
"user-agent": "gittensory/0.1",
"user-agent": PRODUCT_USER_AGENT,
},
});
if (!response.ok) {
Expand Down
2 changes: 1 addition & 1 deletion src/review/content-lane/netuid-verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export async function fetchSubnetRecord(
try {
const res = await fetchWithRetry(
`${base}/subnets/${netuid}`,
{ headers: { accept: "application/json", "user-agent": "gittensory-content-lane" } },
{ headers: { accept: "application/json", "user-agent": "loopover-content-lane" } },
fetchImpl,
);
if (res.status === 404) return { status: "missing", record: null };
Expand Down
4 changes: 2 additions & 2 deletions src/review/enrichment-wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async function fetchReesPingWithRetry(url: string, secret: string): Promise<Resp
fetch(url, {
method: "POST",
headers: {
"user-agent": "gittensory-selfhost/1.0",
"user-agent": "loopover-selfhost/1.0",
authorization: `Bearer ${secret}`,
},
signal: AbortSignal.timeout(5000),
Expand Down Expand Up @@ -447,7 +447,7 @@ export async function buildReviewEnrichment(
const response = await fetch(`${base.replace(/\/+$/, "")}/v1/enrich`, {
method: "POST",
headers: {
"user-agent": "gittensory-selfhost/1.0",
"user-agent": "loopover-selfhost/1.0",
accept: "application/json",
"content-type": "application/json",
"x-gittensory-request-id": requestId,
Expand Down
4 changes: 2 additions & 2 deletions src/review/grounding-wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// fail-safe: any missing CI data / fetch error degrades to "no grounding" and the review proceeds on the diff.

import { createInstallationToken } from "../github/app";
import { githubRateLimitAdmissionKeyForToken, timeoutFetch, type GitHubRateLimitAdmissionKey } from "../github/client";
import { githubRateLimitAdmissionKeyForToken, PRODUCT_USER_AGENT, timeoutFetch, type GitHubRateLimitAdmissionKey } from "../github/client";
import { getCachedGroundingFileContent, putCachedGroundingFileContent, recordAuditEvent } from "../db/repositories";
import type { CheckSummaryRecord, PullRequestFileRecord } from "../types";
import { repoParts } from "../utils/json";
Expand Down Expand Up @@ -185,7 +185,7 @@ export async function makeGithubFileFetcher(env: Env, repoFullName: string, inst
headers: {
// raw media type returns the file body directly (no base64 envelope to decode).
accept: "application/vnd.github.raw+json",
"user-agent": "gittensory/0.1",
"user-agent": PRODUCT_USER_AGENT,
"x-github-api-version": "2022-11-28",
...(token ? { authorization: `Bearer ${token}` } : {}),
},
Expand Down
4 changes: 2 additions & 2 deletions src/review/rag-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// GitHub call, and does no adapter use — the deploy is byte-identical to today.

import { createInstallationToken } from "../github/app";
import { githubRateLimitAdmissionKeyForToken, timeoutFetch, type GitHubRateLimitAdmissionKey } from "../github/client";
import { githubRateLimitAdmissionKeyForToken, PRODUCT_USER_AGENT, timeoutFetch, type GitHubRateLimitAdmissionKey } from "../github/client";
import { incr } from "../selfhost/metrics";
import { isConfigFile, isDependencyManifestFile } from "../signals/path-matchers";
import { repoParts } from "../utils/json";
Expand Down Expand Up @@ -93,7 +93,7 @@ async function resolveReadToken(env: Env, installationId: number | null | undefi
function ghHeaders(token: string | undefined, accept: string): Record<string, string> {
return {
accept,
"user-agent": "gittensory/0.1",
"user-agent": PRODUCT_USER_AGENT,
"x-github-api-version": "2022-11-28",
...(token ? { authorization: `Bearer ${token}` } : {}),
};
Expand Down
Loading
Loading