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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Drop 2 tables scaffolded in 0004_scoring_intelligence.sql that never gained a real reader or writer
-- (#4619, review-stack architecture audit). Their sibling tables from the same migration
-- (scoring_model_snapshots, score_previews, contributor_evidence, contributor_scoring_profiles,
-- burden_forecasts, bounty_lifecycle_events) all got wired with real read+write paths; these two alone
-- never did -- the "issue quality report" concept now lives entirely in the generic signal_snapshots
-- cache via src/services/issue-quality.ts instead. Confirmed zero rows on the live production database
-- before writing this migration (both tables empty).
DROP TABLE IF EXISTS issue_quality_reports;
DROP TABLE IF EXISTS registry_drift_events;
37 changes: 0 additions & 37 deletions src/db/repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
githubAgentCommandFeedback,
installationHealth,
installations,
issueQualityReports,
issues,
githubRateLimitObservations,
notificationDeliveries,
Expand All @@ -43,7 +42,6 @@ import {
repositories,
repoGithubTotalsSnapshots,
repoQueueTrendSnapshots,
registryDriftEvents,
repoLabels,
repoSnapshots,
repoSyncSegments,
Expand Down Expand Up @@ -113,7 +111,6 @@ import type {
InstallationHealthRecord,
InstallationRecord,
IssueRecord,
IssueQualityReportRecord,
JsonValue,
McpCompatibilityAdoptionSummary,
NotificationChannel,
Expand Down Expand Up @@ -144,7 +141,6 @@ import type {
PullRequestReviewRecord,
RecentMergedPullRequestRecord,
RegistryRepoConfig,
RegistryDriftEventRecord,
RepoLabelRecord,
RepoGithubTotalsSnapshotRecord,
RepoQueueTrendSnapshotRecord,
Expand Down Expand Up @@ -3573,23 +3569,6 @@ export async function getContributorScoringProfile(env: Env, login: string): Pro
: null;
}

export async function upsertIssueQualityReport(env: Env, report: IssueQualityReportRecord): Promise<void> {
const db = getDb(env.DB);
await db
.insert(issueQualityReports)
.values({
id: report.id,
repoFullName: report.repoFullName,
issueNumber: report.issueNumber,
payloadJson: jsonString(report.payload),
generatedAt: report.generatedAt,
})
.onConflictDoUpdate({
target: [issueQualityReports.repoFullName, issueQualityReports.issueNumber],
set: { payloadJson: jsonString(report.payload), generatedAt: report.generatedAt },
});
}

export async function upsertBurdenForecast(env: Env, forecast: BurdenForecastRecord): Promise<void> {
const db = getDb(env.DB);
await db
Expand All @@ -3613,22 +3592,6 @@ export async function getBurdenForecast(env: Env, repoFullName: string): Promise
};
}

export async function persistRegistryDriftEvents(env: Env, events: RegistryDriftEventRecord[]): Promise<void> {
const db = getDb(env.DB);
for (const event of events) {
await db.insert(registryDriftEvents).values({
id: event.id,
repoFullName: event.repoFullName,
driftType: event.driftType,
detail: event.detail,
previousSnapshotId: event.previousSnapshotId,
currentSnapshotId: event.currentSnapshotId,
payloadJson: jsonString(event.payload),
generatedAt: event.generatedAt,
});
}
}

export async function persistBountyLifecycleEvent(env: Env, event: BountyLifecycleEventRecord): Promise<void> {
const db = getDb(env.DB);
await db.insert(bountyLifecycleEvents).values({
Expand Down
25 changes: 0 additions & 25 deletions src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1014,20 +1014,6 @@ export const officialMinerDetections = sqliteTable("official_miner_detections",
updatedAt: text("updated_at").notNull().$defaultFn(() => nowIso()),
});

export const issueQualityReports = sqliteTable(
"issue_quality_reports",
{
id: text("id").primaryKey(),
repoFullName: text("repo_full_name").notNull(),
issueNumber: integer("issue_number").notNull(),
payloadJson: text("payload_json").notNull().default("{}"),
generatedAt: text("generated_at").notNull().$defaultFn(() => nowIso()),
},
(table) => ({
repoIssue: uniqueIndex("issue_quality_reports_repo_issue_unique").on(table.repoFullName, table.issueNumber),
}),
);

export const burdenForecasts = sqliteTable("burden_forecasts", {
repoFullName: text("repo_full_name").primaryKey(),
payloadJson: text("payload_json").notNull().default("{}"),
Expand All @@ -1040,17 +1026,6 @@ export const repoQueueTrendSnapshots = sqliteTable("repo_queue_trend_snapshots",
generatedAt: text("generated_at").notNull().$defaultFn(() => nowIso()),
});

export const registryDriftEvents = sqliteTable("registry_drift_events", {
id: text("id").primaryKey(),
repoFullName: text("repo_full_name").notNull(),
driftType: text("drift_type").notNull(),
detail: text("detail").notNull(),
previousSnapshotId: text("previous_snapshot_id"),
currentSnapshotId: text("current_snapshot_id"),
payloadJson: text("payload_json").notNull().default("{}"),
generatedAt: text("generated_at").notNull().$defaultFn(() => nowIso()),
});

export const upstreamSourceSnapshots = sqliteTable(
"upstream_source_snapshots",
{
Expand Down
19 changes: 0 additions & 19 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2044,31 +2044,12 @@ export type ContributorScoringProfileRecord = {
generatedAt: string;
};

export type IssueQualityReportRecord = {
id: string;
repoFullName: string;
issueNumber: number;
payload: Record<string, JsonValue>;
generatedAt: string;
};

export type BurdenForecastRecord = {
repoFullName: string;
payload: Record<string, JsonValue>;
generatedAt: string;
};

export type RegistryDriftEventRecord = {
id: string;
repoFullName: string;
driftType: string;
detail: string;
previousSnapshotId?: string | null | undefined;
currentSnapshotId?: string | null | undefined;
payload: Record<string, JsonValue>;
generatedAt: string;
};

export type BountyLifecycleEventRecord = {
id: string;
bountyId: string;
Expand Down
29 changes: 1 addition & 28 deletions test/unit/db-persistence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import {
listRepoPullRequestFilePaths,
listSignalSnapshots,
persistBountyLifecycleEvent,
persistRegistryDriftEvents,
persistRepoGithubTotalsSnapshot,
persistSignalSnapshot,
startActiveReviewTracking,
terminalizeActiveReviewTracking,
updateUpstreamDriftReportIssue,
upsertContributorRepoStat,
upsertContributorScoringProfile,
upsertIssueQualityReport,
upsertPullRequestFile,
upsertUpstreamDriftReport,
} from "../../src/db/repositories";
Expand All @@ -27,7 +25,7 @@ import type { PullRequestFileRecord, PullRequestRecord, RepositoryRecord } from
import { createTestEnv } from "../helpers/d1";

describe("database persistence helpers", () => {
it("round-trips drift, quality, lifecycle, and scoring persistence helpers", async () => {
it("round-trips drift, lifecycle, and scoring persistence helpers", async () => {
const env = createTestEnv();
await upsertUpstreamDriftReport(env, {
id: "drift-1",
Expand Down Expand Up @@ -66,25 +64,6 @@ describe("database persistence helpers", () => {
payload: { scoreability: "ready" },
});

await upsertIssueQualityReport(env, {
id: "quality-1",
repoFullName: "JSONbored/gittensory",
issueNumber: 7,
payload: { score: 92 },
generatedAt: "2026-05-30T00:03:00.000Z",
});
await persistRegistryDriftEvents(env, [
{
id: "registry-event-1",
repoFullName: "JSONbored/gittensory",
driftType: "changed",
detail: "Emission changed",
previousSnapshotId: "old",
currentSnapshotId: "new",
payload: { emissionShare: 0.01 },
generatedAt: "2026-05-30T00:04:00.000Z",
},
]);
await persistBountyLifecycleEvent(env, {
id: "bounty-event-1",
bountyId: "bounty-1",
Expand All @@ -95,12 +74,6 @@ describe("database persistence helpers", () => {
generatedAt: "2026-05-30T00:05:00.000Z",
});

await expect(
env.DB.prepare("select payload_json from issue_quality_reports where repo_full_name = ? and issue_number = ?")
.bind("JSONbored/gittensory", 7)
.first<{ payload_json: string }>(),
).resolves.toMatchObject({ payload_json: JSON.stringify({ score: 92 }) });
await expect(env.DB.prepare("select count(*) as count from registry_drift_events").first<{ count: number }>()).resolves.toMatchObject({ count: 1 });
await expect(env.DB.prepare("select count(*) as count from bounty_lifecycle_events").first<{ count: number }>()).resolves.toMatchObject({ count: 1 });
});

Expand Down
Loading