import { DurableObject } from "cloudflare:workers";
import { userInbox } from "../user-inbox";
import { activityTouches, indexActivity } from "../activity-index";
import { configurePerf } from "../perf";
import {
armsPreciseRepoTask,
armsRepoHousekeeping,
markRepo,
nextRepoDue,
repoMarksOf,
runRepoHousekeeping,
type LastRuns,
} from "./housekeeping";
import type { InvolvementEntry, InvolvementRole } from "../involvement";
import { ScopedStore } from "../scoped-db/store";
import { REPO_SCHEMA } from "../scoped-db/schema.gen";
import { REPO_SCHEMA_EXTRA } from "../scoped-db/schema-extra";
import type {
ScopedQueryResult,
ScopedRunResult,
ScopedSqlHost,
ScopedStatement,
ScopedValue,
} from "../scoped-db/types";
const SYNC_CHUNK = 50;
const SCOPE_KEY = "scope-id";
const INDEX_TIMEOUT_MS = 2000;
const RUNS_KEY = "housekeeping-runs";
const INVOLVEMENT_DDL = `CREATE TABLE IF NOT EXISTS involvement_published (
issue_id TEXT PRIMARY KEY,
users TEXT NOT NULL
)`;
type IssueRow = {
id: string;
number: number;
is_pull: number;
state: string;
title: string;