trycomp/safety
@sarj-ai/workspace-sync/trycomp/safety ยท Source
import type { D1Database } from "@cloudflare/workers-types";import { z } from "zod";import type { ActiveResourceLease } from "../identity-sync/resource-lease.ts";import type { TrycompAction } from "./model.ts";export declare const TrycompDeploymentEvidenceSchema: z.ZodObject<{ id: z.ZodString; tag: z.ZodString; timestamp: z.ZodISODateTime;}, z.core.$strict>;export type TrycompDeploymentEvidence = z.output<typeof TrycompDeploymentEvidenceSchema>;declare const BreakerRowSchema: z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodObject<{ updated_at_ms: z.ZodNumber; state: z.ZodLiteral<"closed">; opened_action_index: z.ZodNull; opened_at_ms: z.ZodNull; opened_run_id: z.ZodNull; reason: z.ZodNull;}, z.core.$strict>, z.ZodObject<{ updated_at_ms: z.ZodNumber; state: z.ZodLiteral<"review_required">; opened_action_index: z.ZodNumber; opened_at_ms: z.ZodNumber; opened_run_id: z.ZodString; reason: z.ZodString;}, z.core.$strict>], "state">>;export type TrycompBreakerStatus = z.output<typeof BreakerRowSchema>;export declare const TrycompVerifiedIncidentResolutionSchema: z.ZodObject<{ tickId: z.ZodLiteral<"e42a58d91d7c68dc96602c470cb5a9de7ed91b78c3b621fdfe2b47cac6ed1275">; runId: z.ZodLiteral<"94d0feb3-92f2-4f10-83fd-dbcc00fdaf31">; actionIndex: z.ZodLiteral<0>; kind: z.ZodLiteral<"observed-after">; sourceHash: z.ZodString; observedAtMs: z.ZodNumber; recordedAtMs: z.ZodNumber;}, z.core.$strict>;export declare const TrycompVerifiedIncidentResolutionsSchema: z.ZodArray<z.ZodObject<{ tickId: z.ZodLiteral<"e42a58d91d7c68dc96602c470cb5a9de7ed91b78c3b621fdfe2b47cac6ed1275">; runId: z.ZodLiteral<"94d0feb3-92f2-4f10-83fd-dbcc00fdaf31">; actionIndex: z.ZodLiteral<0>; kind: z.ZodLiteral<"observed-after">; sourceHash: z.ZodString; observedAtMs: z.ZodNumber; recordedAtMs: z.ZodNumber;}, z.core.$strict>>;export declare const TrycompSafetyReadModelSchema: z.ZodObject<{ breaker: z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodObject<{ updated_at_ms: z.ZodNumber; state: z.ZodLiteral<"closed">; opened_action_index: z.ZodNull; opened_at_ms: z.ZodNull; opened_run_id: z.ZodNull; reason: z.ZodNull; }, z.core.$strict>, z.ZodObject<{ updated_at_ms: z.ZodNumber; state: z.ZodLiteral<"review_required">; opened_action_index: z.ZodNumber; opened_at_ms: z.ZodNumber; opened_run_id: z.ZodString; reason: z.ZodString; }, z.core.$strict>], "state">>; effectiveBreaker: z.ZodBoolean; verifiedIncidentResolutions: z.ZodOptional<z.ZodArray<z.ZodObject<{ tickId: z.ZodLiteral<"e42a58d91d7c68dc96602c470cb5a9de7ed91b78c3b621fdfe2b47cac6ed1275">; runId: z.ZodLiteral<"94d0feb3-92f2-4f10-83fd-dbcc00fdaf31">; actionIndex: z.ZodLiteral<0>; kind: z.ZodLiteral<"observed-after">; sourceHash: z.ZodString; observedAtMs: z.ZodNumber; recordedAtMs: z.ZodNumber; }, z.core.$strict>>>; latestActions: z.ZodArray<z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[z.ZodObject<{ actionIndex: z.ZodNumber; authorityGroupId: z.ZodNullable<z.ZodString>; deactivationAuthority: z.ZodNullable<z.ZodEnum<{ contractor_group: "contractor_group"; inactive_google: "inactive_google"; }>>; email: z.ZodEmail; googleUserId: z.ZodNullable<z.ZodString>; memberId: z.ZodNullable<z.ZodString>; runId: z.ZodUUID; actionType: z.ZodLiteral<"invite">; state: z.ZodLiteral<"planned">; errorCode: z.ZodNull; }, z.core.$strict>, z.ZodObject<{ actionIndex: z.ZodNumber; authorityGroupId: z.ZodNullable<z.ZodString>; deactivationAuthority: z.ZodNullable<z.ZodEnum<{ contractor_group: "contractor_group"; inactive_google: "inactive_google"; }>>; email: z.ZodEmail; googleUserId: z.ZodNullable<z.ZodString>; runId: z.ZodUUID; actionType: z.ZodEnum<{ deactivate: "deactivate"; reactivate: "reactivate"; }>; memberId: z.ZodString; state: z.ZodLiteral<"planned">; errorCode: z.ZodNull; }, z.core.$strict>], "actionType">, z.ZodDiscriminatedUnion<[z.ZodObject<{ actionIndex: z.ZodNumber; authorityGroupId: z.ZodNullable<z.ZodString>; deactivationAuthority: z.ZodNullable<z.ZodEnum<{ contractor_group: "contractor_group"; inactive_google: "inactive_google"; }>>; email: z.ZodEmail; googleUserId: z.ZodNullable<z.ZodString>; memberId: z.ZodNullable<z.ZodString>; runId: z.ZodUUID; actionType: z.ZodLiteral<"invite">; state: z.ZodLiteral<"attempted">; errorCode: z.ZodNull; }, z.core.$strict>, z.ZodObject<{ actionIndex: z.ZodNumber; authorityGroupId: z.ZodNullable<z.ZodString>; deactivationAuthority: z.ZodNullable<z.ZodEnum<{ contractor_group: "contractor_group"; inactive_google: "inactive_google"; }>>; email: z.ZodEmail; googleUserId: z.ZodNullable<z.ZodString>; runId: z.ZodUUID; actionType: z.ZodEnum<{ deactivate: "deactivate"; reactivate: "reactivate"; }>; memberId: z.ZodString; state: z.ZodLiteral<"attempted">; errorCode: z.ZodNull; }, z.core.$strict>], "actionType">, z.ZodDiscriminatedUnion<[z.ZodObject<{ actionIndex: z.ZodNumber; authorityGroupId: z.ZodNullable<z.ZodString>; deactivationAuthority: z.ZodNullable<z.ZodEnum<{ contractor_group: "contractor_group"; inactive_google: "inactive_google"; }>>; email: z.ZodEmail; googleUserId: z.ZodNullable<z.ZodString>; memberId: z.ZodNullable<z.ZodString>; runId: z.ZodUUID; actionType: z.ZodLiteral<"invite">; state: z.ZodLiteral<"provider_accepted">; errorCode: z.ZodNull; }, z.core.$strict>, z.ZodObject<{ actionIndex: z.ZodNumber; authorityGroupId: z.ZodNullable<z.ZodString>; deactivationAuthority: z.ZodNullable<z.ZodEnum<{ contractor_group: "contractor_group"; inactive_google: "inactive_google"; }>>; email: z.ZodEmail; googleUserId: z.ZodNullable<z.ZodString>; runId: z.ZodUUID; actionType: z.ZodEnum<{ deactivate: "deactivate"; reactivate: "reactivate"; }>; memberId: z.ZodString; state: z.ZodLiteral<"provider_accepted">; errorCode: z.ZodNull; }, z.core.$strict>], "actionType">, z.ZodObject<{ actionIndex: z.ZodNumber; actionType: z.ZodEnum<{ deactivate: "deactivate"; invite: "invite"; reactivate: "reactivate"; }>; authorityGroupId: z.ZodNullable<z.ZodString>; deactivationAuthority: z.ZodNullable<z.ZodEnum<{ contractor_group: "contractor_group"; inactive_google: "inactive_google"; }>>; email: z.ZodEmail; googleUserId: z.ZodNullable<z.ZodString>; runId: z.ZodUUID; state: z.ZodLiteral<"verified">; memberId: z.ZodString; errorCode: z.ZodNull; }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{ actionIndex: z.ZodNumber; authorityGroupId: z.ZodNullable<z.ZodString>; deactivationAuthority: z.ZodNullable<z.ZodEnum<{ contractor_group: "contractor_group"; inactive_google: "inactive_google"; }>>; email: z.ZodEmail; googleUserId: z.ZodNullable<z.ZodString>; memberId: z.ZodNullable<z.ZodString>; runId: z.ZodUUID; actionType: z.ZodLiteral<"invite">; state: z.ZodLiteral<"ambiguous">; errorCode: z.ZodString; }, z.core.$strict>, z.ZodObject<{ actionIndex: z.ZodNumber; authorityGroupId: z.ZodNullable<z.ZodString>; deactivationAuthority: z.ZodNullable<z.ZodEnum<{ contractor_group: "contractor_group"; inactive_google: "inactive_google"; }>>; email: z.ZodEmail; googleUserId: z.ZodNullable<z.ZodString>; runId: z.ZodUUID; actionType: z.ZodEnum<{ deactivate: "deactivate"; reactivate: "reactivate"; }>; memberId: z.ZodString; state: z.ZodLiteral<"ambiguous">; errorCode: z.ZodString; }, z.core.$strict>], "actionType">], "state">>>; latestNotification: z.ZodNullable<z.ZodObject<{ attemptCount: z.ZodNumber; acceptedSlackTimestamp: z.ZodNullable<z.ZodString>; attemptKey: z.ZodString; deliveredAtMs: z.ZodNullable<z.ZodNumber>; intentKey: z.ZodString; kind: z.ZodEnum<{ audit_drift: "audit_drift"; blocked: "blocked"; breaker_review_required: "breaker_review_required"; completed: "completed"; failed: "failed"; prechange: "prechange"; }>; lastError: z.ZodNullable<z.ZodString>; lastSeenAtMs: z.ZodNumber; occurrenceCount: z.ZodNumber; slackTimestamp: z.ZodNullable<z.ZodString>; state: z.ZodEnum<{ claimed: "claimed"; delivered: "delivered"; pending: "pending"; }>; updatedAtMs: z.ZodNumber; }, z.core.$strict>>; latestRuns: z.ZodArray<z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodObject<{ ambiguousCount: z.ZodNumber; attemptedCount: z.ZodNumber; createdAtMs: z.ZodNumber; mode: z.ZodEnum<{ audit: "audit"; live: "live"; }>; planHash: z.ZodString; plannedCount: z.ZodNumber; providerAcceptedCount: z.ZodNumber; runId: z.ZodUUID; trigger: z.ZodEnum<{ cron: "cron"; http: "http"; }>; verifiedCount: z.ZodNumber; workerVersionId: z.ZodString; workerVersionTag: z.ZodString; workerVersionTimestamp: z.ZodISODateTime; state: z.ZodLiteral<"planned">; completedAtMs: z.ZodNull; errorCode: z.ZodNull; }, z.core.$strict>, z.ZodObject<{ ambiguousCount: z.ZodNumber; attemptedCount: z.ZodNumber; createdAtMs: z.ZodNumber; mode: z.ZodEnum<{ audit: "audit"; live: "live"; }>; planHash: z.ZodString; plannedCount: z.ZodNumber; providerAcceptedCount: z.ZodNumber; runId: z.ZodUUID; trigger: z.ZodEnum<{ cron: "cron"; http: "http"; }>; verifiedCount: z.ZodNumber; workerVersionId: z.ZodString; workerVersionTag: z.ZodString; workerVersionTimestamp: z.ZodISODateTime; state: z.ZodLiteral<"applying">; completedAtMs: z.ZodNull; errorCode: z.ZodNull; }, z.core.$strict>, z.ZodObject<{ ambiguousCount: z.ZodNumber; attemptedCount: z.ZodNumber; createdAtMs: z.ZodNumber; mode: z.ZodEnum<{ audit: "audit"; live: "live"; }>; planHash: z.ZodString; plannedCount: z.ZodNumber; providerAcceptedCount: z.ZodNumber; runId: z.ZodUUID; trigger: z.ZodEnum<{ cron: "cron"; http: "http"; }>; verifiedCount: z.ZodNumber; workerVersionId: z.ZodString; workerVersionTag: z.ZodString; workerVersionTimestamp: z.ZodISODateTime; state: z.ZodLiteral<"completed">; completedAtMs: z.ZodNumber; errorCode: z.ZodNull; }, z.core.$strict>, z.ZodObject<{ ambiguousCount: z.ZodNumber; attemptedCount: z.ZodNumber; createdAtMs: z.ZodNumber; mode: z.ZodEnum<{ audit: "audit"; live: "live"; }>; planHash: z.ZodString; plannedCount: z.ZodNumber; providerAcceptedCount: z.ZodNumber; runId: z.ZodUUID; trigger: z.ZodEnum<{ cron: "cron"; http: "http"; }>; verifiedCount: z.ZodNumber; workerVersionId: z.ZodString; workerVersionTag: z.ZodString; workerVersionTimestamp: z.ZodISODateTime; state: z.ZodLiteral<"failed">; completedAtMs: z.ZodNumber; errorCode: z.ZodString; }, z.core.$strict>, z.ZodObject<{ ambiguousCount: z.ZodNumber; attemptedCount: z.ZodNumber; createdAtMs: z.ZodNumber; mode: z.ZodEnum<{ audit: "audit"; live: "live"; }>; planHash: z.ZodString; plannedCount: z.ZodNumber; providerAcceptedCount: z.ZodNumber; runId: z.ZodUUID; trigger: z.ZodEnum<{ cron: "cron"; http: "http"; }>; verifiedCount: z.ZodNumber; workerVersionId: z.ZodString; workerVersionTag: z.ZodString; workerVersionTimestamp: z.ZodISODateTime; state: z.ZodLiteral<"ambiguous">; completedAtMs: z.ZodNumber; errorCode: z.ZodString; }, z.core.$strict>], "state">>>; latestScheduledAttempt: z.ZodNullable<z.ZodObject<{ attemptKey: z.ZodString; completedAtMs: z.ZodNullable<z.ZodNumber>; errorCode: z.ZodNullable<z.ZodString>; notificationIntentKey: z.ZodNullable<z.ZodString>; notification: z.ZodNullable<z.ZodObject<{ attemptCount: z.ZodNumber; acceptedSlackTimestamp: z.ZodNullable<z.ZodString>; deliveredAtMs: z.ZodNullable<z.ZodNumber>; intentKey: z.ZodString; kind: z.ZodEnum<{ audit_drift: "audit_drift"; blocked: "blocked"; breaker_review_required: "breaker_review_required"; completed: "completed"; failed: "failed"; prechange: "prechange"; }>; rootIntentKey: z.ZodString; slackTimestamp: z.ZodNullable<z.ZodString>; state: z.ZodEnum<{ claimed: "claimed"; delivered: "delivered"; pending: "pending"; }>; }, z.core.$strict>>; planHash: z.ZodNullable<z.ZodString>; plannedCount: z.ZodNumber; reportStatus: z.ZodNullable<z.ZodEnum<{ audit: "audit"; blocked: "blocked"; converged: "converged"; failed: "failed"; }>>; runId: z.ZodNullable<z.ZodString>; scheduledAtMs: z.ZodNumber; startedAtMs: z.ZodNumber; state: z.ZodEnum<{ completed: "completed"; failed: "failed"; lease_busy: "lease_busy"; started: "started"; }>; workerVersionId: z.ZodString; workerVersionTag: z.ZodString; workerVersionTimestamp: z.ZodISODateTime; }, z.core.$strict>>; notificationHealth: z.ZodObject<{ acceptedCount: z.ZodNumber; claimedCount: z.ZodNumber; deliveredCount: z.ZodNumber; healthy: z.ZodBoolean; latestDeliveredAtMs: z.ZodNullable<z.ZodNumber>; maxAttemptCount: z.ZodNumber; missingEvidenceCount: z.ZodNumber; oldestUndeliveredAtMs: z.ZodNullable<z.ZodNumber>; pendingCount: z.ZodNumber; }, z.core.$strict>; scheduleHealth: z.ZodObject<{ healthy: z.ZodBoolean; missingNotificationEvidenceCount: z.ZodNumber; observed: z.ZodBoolean; staleAttemptCount: z.ZodNumber; }, z.core.$strict>; scheduleHealthy: z.ZodBoolean; unresolvedMutations: z.ZodNumber;}, z.core.$strict>;export type TrycompSafetyReadModel = z.output<typeof TrycompSafetyReadModelSchema>;export interface TrycompSafetyStore { assertClosed(): Promise<void>; readModel(): Promise<TrycompSafetyReadModel>; status(): Promise<TrycompBreakerStatus>;}export interface TrycompMutationStore { beginRun(input: { actionAuthority?: readonly TrycompActionAuthorityEvidence[]; actions: readonly TrycompAction[]; deployment: TrycompDeploymentEvidence; mode: "audit" | "live"; planHash: string; providerOperationKeys: readonly string[]; runId: string; trigger: "cron" | "http"; }): Promise<void>; completeRun(runId: string): Promise<void>; failRun(runId: string, errorCode: string): Promise<void>; markAttempted(input: { actionIndex: number; lease: ActiveResourceLease; runId: string; }): Promise<void>; markProviderAccepted(runId: string, actionIndex: number): Promise<void>; markVerified(correlationId: string, actionIndex: number, verifiedMemberId: string): Promise<void>; openForAmbiguous(runId: string, actionIndex: number, errorCode: string): Promise<void>; recordPreannouncement(input: { runId: string; lease: ActiveResourceLease; intentKey: string; slackTimestamp: string; }): Promise<void>;}export interface TrycompActionAuthorityEvidence { authorityGroupId: null | string; deactivationAuthority: "contractor_group" | "inactive_google" | null; googleUserId: null | string;}export declare abstract class D1TrycompMutationStore implements TrycompMutationStore { #private; constructor(db: D1Database, options?: { readonly clock?: () => number; }); beginRun(input: { actionAuthority?: readonly TrycompActionAuthorityEvidence[]; actions: readonly TrycompAction[]; deployment: TrycompDeploymentEvidence; mode: "audit" | "live"; planHash: string; providerOperationKeys: readonly string[]; runId: string; trigger: "cron" | "http"; }): Promise<void>; markAttempted(input: { actionIndex: number; lease: ActiveResourceLease; runId: string; }): Promise<void>; markProviderAccepted(runId: string, actionIndex: number): Promise<void>; markVerified(correlationId: string, actionIndex: number, verifiedMemberId: string): Promise<void>; abstract recordPreannouncement(input: { runId: string; lease: ActiveResourceLease; intentKey: string; slackTimestamp: string; }): Promise<void>; openForAmbiguous(runId: string, actionIndex: number, errorCode: string): Promise<void>; completeRun(runId: string): Promise<void>; failRun(runId: string, errorCode: string): Promise<void>;}export declare class D1TrycompSafetyStore implements TrycompSafetyStore { #private; constructor(db: D1Database, options?: { readonly clock?: () => number; }); assertClosed(): Promise<void>; status(): Promise<TrycompBreakerStatus>; readModel(): Promise<TrycompSafetyReadModel>;}export {};