Q132: remove PR bot gates that no task completion or goal close consulted
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fe45cd4d46
commit
e562444487
19 files changed
+35
-151
No files matched your search
@@ -57,7 +57,6 @@ export const platformContracts = {
|
||||
resolveMigrationReconciliation: z.strictObject({ orgId: id, reconciliationItemId: id, employeeId: id }) satisfies z.ZodType<C.ResolveMigrationReconciliationInput>,
|
||||
setFeatureFlag: z.strictObject({ orgId: id, flagId: id, enabled: z.boolean() }) satisfies z.ZodType<C.SetFeatureFlagInput>,
|
||||
runChaosDrill: z.strictObject({ orgId: id, drillId: id }) satisfies z.ZodType<C.RunChaosDrillInput>,
|
||||
setPrBotGate: z.strictObject({ orgId: id, gateId: id, enabled: z.boolean() }) satisfies z.ZodType<C.SetPrBotGateInput>,
|
||||
createComplianceExport: z.strictObject({
|
||||
orgId: id, subjectType: z.enum(["employee", "agent"]), subjectId: id, exportType: z.enum(COMPLIANCE_EXPORT_TYPE), requestedByEmployeeId: id,
|
||||
}) satisfies z.ZodType<C.CreateComplianceExportInput>,
|
||||
|
||||
@@ -19,7 +19,6 @@ import { ComplianceService } from "../services/compliance-service";
|
||||
import { SearchService } from "../services/search-service";
|
||||
import { IdentityAccessService } from "../services/identity-access-service";
|
||||
import { OperationsService } from "../services/operations-service";
|
||||
import { SdlcService } from "../services/sdlc-service";
|
||||
import { AuditService } from "../services/audit-service";
|
||||
import { RollbackService } from "../services/rollback-service";
|
||||
import { TaskExecutionService } from "../services/task-execution-service";
|
||||
@@ -78,7 +77,6 @@ export function registerIpcHandlers(deps: IpcDeps): void {
|
||||
const search = new SearchService(deps.connection.db);
|
||||
const identityAccess = new IdentityAccessService(deps.connection.db);
|
||||
const operations = new OperationsService(deps.connection.db);
|
||||
const sdlc = new SdlcService(deps.connection.db);
|
||||
const audit = new AuditService(deps.connection.db);
|
||||
const rollback = new RollbackService(deps.connection.db);
|
||||
const documents = new DocumentService(deps.connection.db);
|
||||
@@ -379,7 +377,6 @@ export function registerIpcHandlers(deps: IpcDeps): void {
|
||||
handle("resolveMigrationReconciliation", (input) => mutate(() => rollback.resolveReconciliationItem(input)));
|
||||
handle("setFeatureFlag", (input) => mutate(() => operations.setFeatureFlag(input)));
|
||||
handle("runChaosDrill", (input) => mutate(() => operations.runChaosDrill(input)));
|
||||
handle("setPrBotGate", (input) => mutate(() => sdlc.setPrBotGate(input)));
|
||||
handle("createComplianceExport", (input) => mutate(() => compliance.createExport(input)));
|
||||
handle("createAuditReplay", (input) => mutate(() => audit.createThreadReplay(input)));
|
||||
handle("createLegalHold", (input) => mutate(() => compliance.createLegalHold(input)));
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// PR bot gates were switches that no task completion or goal close ever consulted, so turning one on blocked nothing.
|
||||
export const dropPrBotGatesSchema = `
|
||||
drop table if exists pr_bot_gates;
|
||||
|
||||
insert into schema_migrations(version, name, applied_at)
|
||||
values (95, 'drop_pr_bot_gates', datetime('now'));
|
||||
`;
|
||||
@@ -93,6 +93,7 @@ import { requestPurposeSchema } from "./migrations/091-request-purpose";
|
||||
import { runActionTargetsSchema } from "./migrations/092-run-action-targets";
|
||||
import { taskEnqueueErrorSchema } from "./migrations/093-task-enqueue-error";
|
||||
import { dropConfigCountEvalsSchema } from "./migrations/094-drop-config-count-evals";
|
||||
import { dropPrBotGatesSchema } from "./migrations/095-drop-pr-bot-gates";
|
||||
|
||||
interface Migration {
|
||||
version: number;
|
||||
@@ -195,6 +196,7 @@ const MIGRATIONS: Migration[] = [
|
||||
{ version: 92, name: "run_action_targets", sql: runActionTargetsSchema },
|
||||
{ version: 93, name: "task_enqueue_error", sql: taskEnqueueErrorSchema },
|
||||
{ version: 94, name: "drop_config_count_evals", sql: dropConfigCountEvalsSchema },
|
||||
{ version: 95, name: "drop_pr_bot_gates", sql: dropPrBotGatesSchema },
|
||||
];
|
||||
|
||||
const SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1].version;
|
||||
|
||||
@@ -32,7 +32,6 @@ const LEGACY_TABLES = [
|
||||
"operational_events",
|
||||
"chaos_drills",
|
||||
"chaos_drill_runs",
|
||||
"pr_bot_gates",
|
||||
"chat_spaces",
|
||||
"chat_messages",
|
||||
"chat_threads",
|
||||
@@ -159,7 +158,6 @@ const RELATION_CHECKS: RelationCheck[] = [
|
||||
{ table: "chaos_drills", column: "org_id", referencedTable: "organizations", referencedColumn: "id", reason: "dangling_org_id" },
|
||||
{ table: "chaos_drill_runs", column: "org_id", referencedTable: "organizations", referencedColumn: "id", reason: "dangling_org_id" },
|
||||
{ table: "chaos_drill_runs", column: "drill_id", referencedTable: "chaos_drills", referencedColumn: "id", reason: "dangling_drill_id" },
|
||||
{ table: "pr_bot_gates", column: "org_id", referencedTable: "organizations", referencedColumn: "id", reason: "dangling_org_id" },
|
||||
{ table: "chat_spaces", column: "org_id", referencedTable: "organizations", referencedColumn: "id", reason: "dangling_org_id" },
|
||||
{ table: "chat_messages", column: "org_id", referencedTable: "organizations", referencedColumn: "id", reason: "dangling_org_id" },
|
||||
{ table: "chat_messages", column: "space_id", referencedTable: "chat_spaces", referencedColumn: "id", reason: "dangling_space_id" },
|
||||
|
||||
@@ -7,7 +7,6 @@ import { PolicyService } from "./policy-service";
|
||||
import { IdentityAccessService } from "./identity-access-service";
|
||||
import { OrgGovernanceService } from "./org-governance-service";
|
||||
import { OperationsService } from "./operations-service";
|
||||
import { SdlcService } from "./sdlc-service";
|
||||
import { assertUsableMentionName } from "../../shared/mention-handles";
|
||||
|
||||
/**
|
||||
@@ -22,7 +21,6 @@ export function seedOrganization(db: DatabaseSync, input: CreateOrganizationInpu
|
||||
const identityAccess = new IdentityAccessService(db);
|
||||
const governance = new OrgGovernanceService(db);
|
||||
const operations = new OperationsService(db);
|
||||
const sdlc = new SdlcService(db);
|
||||
|
||||
assertUsableMentionName(input.employeeName);
|
||||
const orgId = createId("org");
|
||||
@@ -50,7 +48,6 @@ export function seedOrganization(db: DatabaseSync, input: CreateOrganizationInpu
|
||||
identityAccess.seedEmployeeAccess(orgId, employeeId, now);
|
||||
governance.seedOrganizationGovernance(orgId, employeeId, now);
|
||||
operations.seedOrganizationOperations(orgId, now);
|
||||
sdlc.seedOrganizationSdlc(orgId, now);
|
||||
|
||||
for (const space of [
|
||||
["company", "general", "Company coordination", "workspace"],
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import type { DatabaseSync } from "node:sqlite";
|
||||
import type { SetPrBotGateInput } from "../../shared/commands";
|
||||
import { PR_BOT_GATE_KEY } from "../../shared/domain";
|
||||
import { createId } from "../../shared/ids";
|
||||
import { AuditService } from "./audit-service";
|
||||
|
||||
const PR_BOT_GATES = [
|
||||
{ key: PR_BOT_GATE_KEY.STATIC_CHECKS, label: "Static checks", gateType: "typecheck_lint_test" },
|
||||
{ key: PR_BOT_GATE_KEY.MIGRATION_DIFF, label: "Migration diff", gateType: "schema_review" },
|
||||
{ key: PR_BOT_GATE_KEY.POLICY_DIFF, label: "Policy diff", gateType: "policy_review" },
|
||||
{ key: PR_BOT_GATE_KEY.HUMAN_APPROVAL, label: "Human approval", gateType: "approval_required" },
|
||||
] as const;
|
||||
|
||||
export class SdlcService {
|
||||
private readonly audit: AuditService;
|
||||
|
||||
constructor(private readonly db: DatabaseSync) {
|
||||
this.audit = new AuditService(db);
|
||||
}
|
||||
|
||||
seedOrganizationSdlc(orgId: string, now: string): void {
|
||||
for (const gate of PR_BOT_GATES) {
|
||||
this.db.prepare(`
|
||||
insert into pr_bot_gates(id, org_id, key, label, gate_type, enabled, created_at, updated_at)
|
||||
values (?, ?, ?, ?, ?, 1, ?, ?)
|
||||
on conflict(org_id, key) do nothing
|
||||
`).run(createId("pbg"), orgId, gate.key, gate.label, gate.gateType, now, now);
|
||||
}
|
||||
}
|
||||
|
||||
setPrBotGate(input: SetPrBotGateInput): void {
|
||||
const gate = this.db.prepare("select key from pr_bot_gates where id = ? and org_id = ?")
|
||||
.get(input.gateId, input.orgId) as { key: string } | undefined;
|
||||
if (!gate) throw new Error("PR bot gate was not found.");
|
||||
const now = new Date().toISOString();
|
||||
const result = this.db.prepare("update pr_bot_gates set enabled = ?, updated_at = ? where id = ? and org_id = ?")
|
||||
.run(input.enabled ? 1 : 0, now, input.gateId, input.orgId);
|
||||
if (result.changes === 0) throw new Error("PR bot gate was not found.");
|
||||
this.audit.record({
|
||||
orgId: input.orgId,
|
||||
entityType: "pr_bot_gate",
|
||||
entityId: input.gateId,
|
||||
actorType: "system",
|
||||
actorId: null,
|
||||
action: "updated",
|
||||
payload: { key: gate.key, enabled: input.enabled },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -81,8 +81,6 @@ export class SnapshotService {
|
||||
.map((event) => ({ ...event, success: toBool(event.success) }));
|
||||
const chaosDrills = list<AppSnapshot["chaosDrills"][number]>(this.db, "chaos_drills", "key asc")
|
||||
.map((drill) => ({ ...drill, enabled: toBool(drill.enabled) }));
|
||||
const prBotGates = list<AppSnapshot["prBotGates"][number]>(this.db, "pr_bot_gates", "key asc")
|
||||
.map((gate) => ({ ...gate, enabled: toBool(gate.enabled) }));
|
||||
const rollbackSnapshots = list<AppSnapshot["rollbackSnapshots"][number]>(this.db, "rollback_snapshots", "created_at desc")
|
||||
.map((snapshot) => ({ ...snapshot, active: toBool(snapshot.active) }));
|
||||
|
||||
@@ -162,7 +160,6 @@ export class SnapshotService {
|
||||
operationalEvents,
|
||||
chaosDrills,
|
||||
chaosDrillRuns: list(this.db, "chaos_drill_runs", "started_at desc"),
|
||||
prBotGates,
|
||||
auditReplayRuns: list(this.db, "audit_replay_runs", "created_at desc"),
|
||||
auditEvents: recentList<AppSnapshot["auditEvents"][number]>(this.db, "audit_events", "created_at desc", 200),
|
||||
documents: list(this.db, "documents", "updated_at desc"),
|
||||
|
||||
Reference in new issue
Block a user