@aeolus-fleet/core 0.35.0 → 0.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/prisma/generated/internal/class.js +1 -1
- package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
- package/dist/adapters/prisma/messaging.js +39 -0
- package/dist/adapters/prisma/messaging.js.map +1 -1
- package/dist/adapters/trpc/context.d.ts +2 -0
- package/dist/adapters/trpc/router.d.ts +37 -0
- package/dist/adapters/trpc/ship-protocol.js +3 -1
- package/dist/adapters/trpc/ship-protocol.js.map +1 -1
- package/dist/adapters/trpc/ship.d.ts +43 -0
- package/dist/adapters/trpc/ship.js +33 -2
- package/dist/adapters/trpc/ship.js.map +1 -1
- package/dist/domain/messaging/delivery.d.ts +8 -3
- package/dist/domain/messaging/delivery.js +15 -2
- package/dist/domain/messaging/delivery.js.map +1 -1
- package/dist/domain/messaging/ports.d.ts +15 -0
- package/dist/domain/messaging/push-receive-deliveries.d.ts +4 -1
- package/dist/domain/messaging/push-receive-deliveries.js +4 -2
- package/dist/domain/messaging/push-receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/read-record.d.ts +38 -0
- package/dist/domain/messaging/read-record.js +59 -0
- package/dist/domain/messaging/read-record.js.map +1 -0
- package/dist/wiring.d.ts +2 -0
- package/dist/wiring.js +2 -0
- package/dist/wiring.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/prisma/migrations/20261108100000_delivery_record_index/migration.sql +4 -0
- package/src/adapters/prisma/schema.prisma +2 -0
|
@@ -17,7 +17,7 @@ const config = {
|
|
|
17
17
|
"clientVersion": "7.10.0",
|
|
18
18
|
"engineVersion": "0edf323efd1d98336f3f0a68684b56f689b900d3",
|
|
19
19
|
"activeProvider": "postgresql",
|
|
20
|
-
"inlineSchema": "// Aeolus core tables (docs/architecture.md, \"Core tables\").\n//\n// Prefixed ids, fleet_id on every table except fleets, and the columns and key\n// constraints named in the architecture. Columns a later slice owns (a message's\n// sender and selector, for one) arrive with that slice.\n//\n// References to rows of the same fleet carry fleet_id in the foreign key, so a\n// row can never point at another fleet's ship, lease, message or delivery.\n//\n// Timestamps have no database default: the application's Clock port sets every\n// one of them, so tests control time.\n//\n// Check constraints and the append-only rule for events live in the migration\n// SQL, because Prisma does not model them.\n\ngenerator client {\n provider = \"prisma-client\"\n output = \"./generated\"\n moduleFormat = \"esm\"\n importFileExtension = \"js\"\n runtime = \"nodejs\"\n previewFeatures = [\"partialIndexes\"]\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n\n/// The tenant: one operator's ships, messages and history. Ids start with flt_.\nmodel Fleet {\n id String @id\n name String\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n /// The sequence number of the fleet's last committed event. A unit of work\n /// takes its numbers from it as its last statements, so the row lock orders\n /// the numbers as the transactions commit.\n lastEventSeq BigInt @default(0) @map(\"last_event_seq\")\n /// Whether the fleet sets its own ship limit (else it follows the installation\n /// default), and that limit: null for no limit.\n shipLimitSet Boolean @default(false) @map(\"ship_limit_set\")\n shipLimit Int? @map(\"ship_limit\")\n /// The same for its daily message limit.\n dailyMessageLimitSet Boolean @default(false) @map(\"daily_message_limit_set\")\n dailyMessageLimit Int? @map(\"daily_message_limit\")\n /// The same for the schedules each of its ships may hold, and for the\n /// minimum interval of a repeating schedule, in seconds (decision 0062).\n schedulesPerShipLimitSet Boolean @default(false) @map(\"schedules_per_ship_limit_set\")\n schedulesPerShipLimit Int? @map(\"schedules_per_ship_limit\")\n minimumScheduleIntervalSet Boolean @default(false) @map(\"minimum_schedule_interval_set\")\n minimumScheduleInterval Int? @map(\"minimum_schedule_interval\")\n /// The same for its retention in days (decision 0066): null for kept for good.\n retentionSet Boolean @default(false) @map(\"retention_set\")\n retentionDays Int? @map(\"retention_days\")\n /// When its last pruning pass ran, and from when it keeps its finished\n /// history, as its last finished pass left it (decision 0066); null before any.\n prunedAt DateTime? @map(\"pruned_at\") @db.Timestamptz(3)\n keptFrom DateTime? @map(\"kept_from\") @db.Timestamptz(3)\n /// Its sealing (decision 0068): null while it is not sealed; then sealing until no payload is stored plain, and sealed. The company key that wraps its data keys, by its reference.\n sealingState SealingState? @map(\"sealing_state\")\n /// Since when it reads its sealing state: turned on, or the sealing pass left no payload plain.\n sealingStateSince DateTime? @map(\"sealing_state_since\") @db.Timestamptz(3)\n /// The sealing pass's progress (decision 0068, B5): the payloads stored plain when it turned sealing on, and how many the pass sealed since.\n payloadsToSeal Int @default(0) @map(\"payloads_to_seal\")\n payloadsSealed Int @default(0) @map(\"payloads_sealed\")\n companyKey String? @map(\"company_key\")\n /// Its recovery key (decision 0068, B6), when the company set one: the public half, an age X25519 recipient, and\n /// its fingerprint (SHA256: and the unpadded base64 SHA-256 of the recipient). Each data key is wrapped to it too.\n recoveryKey String? @map(\"recovery_key\")\n recoveryKeyFingerprint String? @map(\"recovery_key_fingerprint\")\n /// Whether its company key answered its last unwrap, and since when (decision 0068, B11): the key vault's reason\n /// while it refuses (accessDenied, disabled, notFound, unreachable), null while it answers. Since when set with the sealing.\n keyUnavailableReason String? @map(\"key_unavailable_reason\")\n keyAvailabilitySince DateTime? @map(\"key_availability_since\") @db.Timestamptz(3)\n\n ships Ship[]\n leases Lease[]\n crewRequests CrewRequest[]\n crewRequestGiveBacks CrewRequestGiveBack[]\n clearRequests WorktreeClearRequest[]\n labels Label[]\n labelValues LabelValue[]\n shipLabels ShipLabel[]\n networkSettings NetworkSettings?\n networkRulesDraft NetworkRulesDraft?\n declaredNetworkRules DeclaredNetworkRules[]\n installationDeclaredNetworkRules InstallationDeclaredNetworkRules?\n scopeNamespaces ScopeNamespace[]\n definedScopes DefinedScope[]\n verifiedFacts VerifiedFacts[]\n alerts Alert[]\n shipExpectations ShipExpectations[]\n reachRefusals ReachRefusal[]\n credentials Credential[]\n messages Message[]\n messageDays MessageDay[]\n deliveries Delivery[]\n overdueDeliveries OverdueDelivery[]\n events Event[]\n consoleSessions ConsoleSession[]\n signInTickets SignInTicket[]\n noticeDismissals NoticeDismissal[]\n guideProgress GuideProgress[]\n accountNoticeDismissals AccountNoticeDismissal[]\n accountGuideProgress AccountGuideProgress[]\n operator Operator?\n healthSnapshots HealthSnapshot[]\n healthSnapshotDeliveries HealthSnapshotDelivery[]\n meetings Meeting[]\n dataKeys DataKey[]\n meetingParticipants MeetingParticipant[]\n meetingMicRequests MeetingMicRequest[]\n schedules Schedule[]\n featureFlags FleetFeatureFlag[]\n\n @@map(\"fleets\")\n}\n\n/// A sealed fleet's sealing (decision 0068): payloads stored plain before still wait for the sealing pass, or none do.\nenum SealingState {\n sealing\n sealed\n}\n\n/// What a ship is (decision 0044): argo the one operator, the viewer, an agent session, a person's ship or an app's.\nenum ShipKind {\n operator\n agent\n viewer\n person\n app\n plugin\n\n @@map(\"ship_kind\")\n}\n\n/// A durable, addressable identity with an inbox. Ids start with shp_.\n/// Scopes are set when the ship is created and checked before every call.\nmodel Ship {\n id String @id\n fleetId String @map(\"fleet_id\")\n name String\n type String\n kind ShipKind\n scopes String[]\n note String?\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n retiredAt DateTime? @map(\"retired_at\") @db.Timestamptz(3)\n /// When the pruning pass removed it, past the fleet's retention (decision 0070): the row stays a remnant its kept history names.\n removedAt DateTime? @map(\"removed_at\") @db.Timestamptz(3)\n /// The actor that commissioned it, its idempotency key and the request's hash; null for argo.\n /// commissioned_by names the actor: a ship's id, an account's id, or `installation`.\n commissionedByKind CommissionerKind? @map(\"commissioned_by_kind\")\n commissionedBy String? @map(\"commissioned_by\")\n commissionKey String? @map(\"commission_key\")\n commissionRequestHash String? @map(\"commission_request_hash\")\n /// The ship that answers for it, a person's ship or argo (decision 0045); null for argo and the viewer.\n ownerShipId String? @map(\"owner_ship_id\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n owner Ship? @relation(\"ShipOwner\", fields: [fleetId, ownerShipId], references: [fleetId, id], onDelete: Restrict)\n ownedShips Ship[] @relation(\"ShipOwner\")\n leases Lease[]\n credentials Credential[]\n sentMessages Message[] @relation(\"MessageSender\")\n addressedMessages Message[] @relation(\"MessageSelectorShip\")\n deliveries Delivery[] @relation(\"DeliveryRecipientShip\")\n claimedDeliveries Delivery[] @relation(\"DeliveryClaimedByShip\")\n overdueDeliveries OverdueDelivery[]\n consoleSessions ConsoleSession[]\n actorOfEvents Event[] @relation(\"EventActorShip\")\n actorThroughOfEvents Event[] @relation(\"EventActorThroughShip\")\n events Event[] @relation(\"EventShip\")\n crewRequest CrewRequest? @relation(\"CrewRequestShip\")\n assignedCrews CrewRequest[] @relation(\"CrewRequestAssignee\")\n givenBackCrews CrewRequestGiveBack[] @relation(\"CrewRequestGiveBackTrierarch\")\n clearRequests WorktreeClearRequest[] @relation(\"WorktreeClearRequestTrierarch\")\n clearedWorktrees WorktreeClearRequest[] @relation(\"WorktreeClearRequestShip\")\n requestedClears WorktreeClearRequest[] @relation(\"WorktreeClearRequestRequester\")\n ownedLabels Label[] @relation(\"LabelOwner\")\n labels ShipLabel[] @relation(\"ShipLabelShip\")\n declaredNetworkRules DeclaredNetworkRules[]\n declaredNamespace ScopeNamespace?\n verifiedFacts VerifiedFacts[]\n alerts Alert[]\n shipExpectations ShipExpectations[]\n ownedMeetings Meeting[] @relation(\"MeetingOwner\")\n moderatedMeetings Meeting[] @relation(\"MeetingModerator\")\n openedMeetings Meeting[] @relation(\"MeetingOpener\")\n micHeldMeetings Meeting[] @relation(\"MeetingMicHolder\")\n meetings MeetingParticipant[]\n schedules Schedule[] @relation(\"ScheduleShip\")\n scheduledTo Schedule[] @relation(\"ScheduleSelectorShip\")\n\n @@unique([fleetId, id])\n /// An idempotency key is used once per commissioning actor.\n @@unique([fleetId, commissionedByKind, commissionedBy, commissionKey], map: \"ships_commission_key_key\")\n /// A name is unique among ships that are not retired, and reusable after retirement.\n @@unique([fleetId, name], map: \"ships_fleet_id_name_active_key\", where: { retiredAt: null })\n /// Exactly one operator ship per fleet.\n @@unique([fleetId], map: \"ships_fleet_id_operator_key\", where: raw(\"kind = 'operator'::ship_kind\"))\n /// At most one viewer ship per fleet (decision 0022).\n @@unique([fleetId], map: \"ships_fleet_id_viewer_key\", where: raw(\"kind = 'viewer'::ship_kind\"))\n @@index([fleetId, ownerShipId])\n @@index([fleetId, type], map: \"ships_type_listing_idx\", where: { retiredAt: null })\n @@index([fleetId, kind], map: \"ships_kind_listing_idx\", where: { retiredAt: null })\n /// The pruning pass picks the oldest retired ships not removed yet (decision 0070).\n @@index([fleetId, retiredAt, id], map: \"ships_removal_idx\", where: raw(\"((retired_at IS NOT NULL) AND (removed_at IS NULL))\"))\n @@map(\"ships\")\n}\n\n/// Where the session crewing a ship runs. OTHER carries a description; the other kinds none.\nenum ReportState {\n working\n blocked\n idle\n\n @@map(\"report_state\")\n}\n\n/// A pushed session's turn, as its hooks report it (decision 0040).\nenum LeaseWaker {\n trierarch\n pluginWatcher\n personApp\n gateway\n adapter\n\n @@map(\"lease_waker\")\n}\n\nenum TurnState {\n idle\n busy\n\n @@map(\"turn_state\")\n}\n\n/// The kind of a session's latest event as its trierarch observes it (headless design, H14).\nenum ActivityKind {\n text\n tool\n result\n error\n\n @@map(\"activity_kind\")\n}\n\nenum LocationKind {\n DEVICE\n CLOUD\n SERVER\n OTHER\n\n @@map(\"location_kind\")\n}\n\n/// The exclusive right of one session to crew a ship, and where that session runs.\n/// Ids start with lse_.\n/// The hash of the crew token register gave the session, unique across all fleets:\n/// finding a ship by its crew token is a lookup not scoped by fleet (ADR 0007). A\n/// console session's lease on argo has none; the console session holds its token.\nmodel Lease {\n id String @id\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n location LocationKind\n locationDescription String? @map(\"location_description\")\n /// The harness the session stated when it claimed the ship; none for argo's console lease and for leases from before harnesses were stated.\n harness String?\n crewTokenHash String? @unique @map(\"crew_token_hash\")\n startedAt DateTime @map(\"started_at\") @db.Timestamptz(3)\n /// The last call by its crew: observation only, nothing acts on it (ADR 0016).\n lastSeenAt DateTime? @map(\"last_seen_at\") @db.Timestamptz(3)\n /// The crew's last report: plain data, nothing acts on it. Null until it reports.\n reportState ReportState? @map(\"report_state\")\n reportNote String? @map(\"report_note\")\n reportedAt DateTime? @map(\"reported_at\") @db.Timestamptz(3)\n /// When the state, note, task or step last changed; details alone do not move it (decision 0028). Null until it reports.\n reportChangedAt DateTime? @map(\"report_changed_at\") @db.Timestamptz(3)\n /// What the crew works on: a typed reference, a kind and its fields (decision 0028). Null when it names none.\n reportTask Json? @map(\"report_task\")\n /// Where the crew is in its task, step at of of; both null when it gives none.\n reportStepAt Int? @map(\"report_step_at\")\n reportStepOf Int? @map(\"report_step_of\")\n /// The report's details: one JSON object stored without meaning, at most 16 KB (decision 0028). Null when there are none.\n reportDetails Json? @map(\"report_details\")\n /// Moves by one each time the details change; 0 before any.\n reportDetailsVersion Int @default(0) @map(\"report_details_version\")\n /// The crew's statement: what its ship is and offers, at most 256 KB, its shape common's; null until it states one (decision 0047).\n statement Json?\n /// Moves by one each time the statement changes; 0 before any.\n statementVersion Int @default(0) @map(\"statement_version\")\n /// From the lease's first push receive: the computer side takes its deliveries, and the agent's plain receive answers nothing (decision 0040).\n pushedAt DateTime? @map(\"pushed_at\") @db.Timestamptz(3)\n /// What wakes the ship, as its first push receive stated it; null when it stated none (interop 5.1).\n waker LeaseWaker?\n /// The session's turn as its hooks last reported it, and when they saw it change; null until they report (decision 0040).\n turn TurnState?\n turnAt DateTime? @map(\"turn_at\") @db.Timestamptz(3)\n /// What its assigned trierarch last observed of the session: the latest event's time, kind and tool, never content; null until it writes (docs/design/monitoring, 4.3).\n activityAt DateTime? @map(\"activity_at\") @db.Timestamptz(3)\n activityKind ActivityKind? @map(\"activity_kind\")\n activityTool String? @map(\"activity_tool\")\n /// When the trierarch wrote it, and the report interval it stated: past twice that interval it reads unknown.\n activityReportedAt DateTime? @map(\"activity_reported_at\") @db.Timestamptz(3)\n activityIntervalSeconds Int? @map(\"activity_interval_seconds\")\n endedAt DateTime? @map(\"ended_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n consoleSessions ConsoleSession[]\n claimedDeliveries Delivery[]\n overdueDeliveries OverdueDelivery[]\n\n @@unique([fleetId, id])\n /// At most one open lease per ship.\n @@unique([shipId], map: \"leases_ship_id_open_key\", where: { endedAt: null })\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, shipId])\n @@map(\"leases\")\n}\n\n/// How the assigned trierarch says its crew of a ship stands (decision 0029).\nenum CrewStatus {\n crewing\n running\n restarting\n crashed\n releasing\n\n @@map(\"crew_status\")\n}\n\n/// A standing request that a ship be kept crewed (decision 0029): at most one per\n/// ship, so the ship's id is its key. Its settings are crew settings of at most\n/// 16 KB, checked but never acted on; each request replaces them and moves their\n/// version by one.\nmodel CrewRequest {\n shipId String @id @map(\"ship_id\")\n fleetId String @map(\"fleet_id\")\n settings Json\n settingsVersion Int @map(\"settings_version\")\n requestedAt DateTime @map(\"requested_at\") @db.Timestamptz(3)\n /// The trierarch ship it is assigned to; null while unassigned.\n assignedTo String? @map(\"assigned_to_ship_id\")\n /// How its trierarch says the crew stands; null until it says.\n status CrewStatus?\n /// Why no trierarch can take it, written by the assigner while unassigned; null when none.\n reason String?\n /// How many times its trierarch restarted the session within its restart window, with the status: 0 on its first start.\n attempt Int @default(0)\n /// When the session its trierarch runs now started, with the status; null while none runs.\n sessionStartedAt DateTime? @map(\"session_started_at\") @db.Timestamptz(3)\n /// Whether its crew is final: set by its trierarch's first running, restarting or crashed, kept whatever status follows, cleared on every new settings version.\n isFinal Boolean @default(false) @map(\"is_final\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(\"CrewRequestShip\", fields: [fleetId, shipId], references: [fleetId, id])\n assignee Ship? @relation(\"CrewRequestAssignee\", fields: [fleetId, assignedTo], references: [fleetId, id])\n givenBack CrewRequestGiveBack[]\n\n @@unique([fleetId, shipId])\n /// A trierarch reads the requests assigned to it.\n @@index([fleetId, assignedTo])\n @@map(\"crew_requests\")\n}\n\n/// A trierarch that gave a crew request back before its crew was final (#382): one per trierarch, until the next settings version.\nmodel CrewRequestGiveBack {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n trierarchShipId String @map(\"trierarch_ship_id\")\n settingsVersion Int @map(\"settings_version\")\n reason String\n givenBackAt DateTime @map(\"given_back_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n crewRequest CrewRequest @relation(fields: [fleetId, shipId], references: [fleetId, shipId])\n trierarch Ship @relation(\"CrewRequestGiveBackTrierarch\", fields: [fleetId, trierarchShipId], references: [fleetId, id])\n\n @@id([fleetId, shipId, trierarchShipId])\n @@index([fleetId, trierarchShipId])\n @@map(\"crew_request_give_backs\")\n}\n\n/// A pending request that a trierarch clear a worktree it kept (decision 0032),\n/// named by the ship it belonged to and its repository: never a path.\nmodel WorktreeClearRequest {\n fleetId String @map(\"fleet_id\")\n trierarchShipId String @map(\"trierarch_ship_id\")\n shipId String @map(\"ship_id\")\n repository String\n requestedBy String @map(\"requested_by_ship_id\")\n requestedAt DateTime @map(\"requested_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n trierarch Ship @relation(\"WorktreeClearRequestTrierarch\", fields: [fleetId, trierarchShipId], references: [fleetId, id])\n ship Ship @relation(\"WorktreeClearRequestShip\", fields: [fleetId, shipId], references: [fleetId, id])\n requester Ship @relation(\"WorktreeClearRequestRequester\", fields: [fleetId, requestedBy], references: [fleetId, id])\n\n @@id([fleetId, trierarchShipId, shipId, repository])\n @@index([fleetId, shipId])\n @@index([fleetId, requestedBy])\n @@map(\"worktree_clear_requests\")\n}\n\n/// A label (decision 0031): a key unique in its fleet with its defined values,\n/// owned by the ship that defined it. Ids start with lbl_. A retired or deleted\n/// label is deleted with its values; its events stay.\nmodel Label {\n id String @id\n fleetId String @map(\"fleet_id\")\n key String\n /// A ship or the installation (decision 0031); the installation's label names no owner ship.\n ownerKind LabelOwnerKind @default(ship) @map(\"owner_kind\")\n ownerShipId String? @map(\"owner_ship_id\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n owner Ship? @relation(\"LabelOwner\", fields: [fleetId, ownerShipId], references: [fleetId, id])\n values LabelValue[]\n carriers ShipLabel[]\n\n @@unique([fleetId, id])\n @@unique([fleetId, key])\n /// A retire finds the labels its ship owns.\n @@index([fleetId, ownerShipId])\n @@map(\"labels\")\n}\n\n/// One value of a label, each once, at most 50 a label. Ids start with lbv_; a\n/// value keeps its id while its label has it.\nmodel LabelValue {\n id String @id\n fleetId String @map(\"fleet_id\")\n labelId String @map(\"label_id\")\n value String\n /// Its place in the order the owner gave the values.\n position Int\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n label Label @relation(fields: [fleetId, labelId], references: [fleetId, id])\n carriers ShipLabel[]\n\n @@unique([fleetId, id])\n @@unique([fleetId, labelId, value])\n @@map(\"label_values\")\n}\n\n/// A label value a ship carries: a ship holds a set of values, so the ship and\n/// the value are its key.\nmodel ShipLabel {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n labelId String @map(\"label_id\")\n valueId String @map(\"value_id\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(\"ShipLabelShip\", fields: [fleetId, shipId], references: [fleetId, id])\n label Label @relation(fields: [fleetId, labelId], references: [fleetId, id])\n value LabelValue @relation(fields: [fleetId, valueId], references: [fleetId, id])\n\n @@id([fleetId, shipId, valueId])\n /// A change of values, a delete and a retire find every ship that carries a label.\n @@index([fleetId, labelId])\n /// Removing a value checks that no ship carries it.\n @@index([fleetId, valueId])\n @@map(\"ship_labels\")\n}\n\n/// A fleet's network settings (decision 0034), once it first set rules: its\n/// rules as JSON, none (null) for all-to-all, and their version. A send and a\n/// set take turns on an advisory lock on them (network.ts).\nmodel NetworkSettings {\n fleetId String @id @map(\"fleet_id\")\n /// The fleet's own rules as last applied (decision 0034); NULL while none\n /// are, all-to-all with open on.\n rules Json?\n /// The viewer reading every ship, the built-in rule an actor turns (decision 0034). On at fleet create.\n builtInViewerRead Boolean @default(true) @map(\"built_in_viewer_read\")\n version Int\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@map(\"network_settings\")\n}\n\n/// The draft of a fleet's own rules (decision 0034): one a fleet at most, the\n/// rules as JSON or NULL for all-to-all. Nothing in force reads it; an apply\n/// moves it into network_settings and removes it.\nmodel NetworkRulesDraft {\n fleetId String @id @map(\"fleet_id\")\n rules Json?\n savedAt DateTime @map(\"saved_at\") @db.Timestamptz(3)\n savedAgainstVersion Int @map(\"saved_against_version\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@map(\"network_rules_drafts\")\n}\n\n/// The network rules a ship declared on the labels it owns (decision 0037),\n/// its whole list as JSON, at most 20. No row while it declares none; a retire\n/// removes its row.\nmodel DeclaredNetworkRules {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n rules Json\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n\n @@id([fleetId, shipId])\n @@map(\"declared_network_rules\")\n}\n\n/// The network rules the installation declares on the labels it owns in one\n/// fleet (decisions 0037, 0052), its whole list as JSON; no row while it\n/// declares none.\nmodel InstallationDeclaredNetworkRules {\n fleetId String @id @map(\"fleet_id\")\n rules Json\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@map(\"installation_declared_network_rules\")\n}\n\n/// A plugin's namespace (decision 0046): taken up for good by the ship that\n/// declared it, one per ship and unique in the fleet, with its whole list of\n/// scopes and their descriptions as JSON, in order. It goes when its declarer\n/// retires.\nmodel ScopeNamespace {\n fleetId String @map(\"fleet_id\")\n namespace String\n declaredBy String @map(\"declared_by\")\n scopes Json\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n declarer Ship @relation(fields: [fleetId, declaredBy], references: [fleetId, id])\n\n @@id([fleetId, namespace])\n @@unique([fleetId, declaredBy])\n @@map(\"scope_namespaces\")\n}\n\n/// One of the fleet's own scopes (design gateway-scopes, 4.1), with its one-line description.\nmodel DefinedScope {\n fleetId String @map(\"fleet_id\")\n scope String\n description String\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, scope])\n @@map(\"defined_scopes\")\n}\n\n/// One writer's verified facts about a ship (decision 0059): what it checked,\n/// as JSON in the shape common gives, set whole and kept with the ship. The\n/// writer is an actor: a ship or an account by its id, or the installation\n/// by its name, as a commissioning actor is.\nmodel VerifiedFacts {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n writerKind FactWriterKind @map(\"writer_kind\")\n writer String\n facts Json\n writtenAt DateTime @map(\"written_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n\n @@id([fleetId, shipId, writerKind, writer])\n /// A retiring writer finds its facts about every ship.\n @@index([fleetId, writerKind, writer])\n @@map(\"verified_facts\")\n}\n\n/// An alert on a ship (decision 0071): what the watch raised when a fact and\n/// its signal parted, open until the watch clears it or the ship retires.\n/// Ids start with alt_. One per ship, signal and occurrence, open or cleared,\n/// so an occurrence is raised once. facts holds the signal's facts at raise,\n/// as common's schema gives them.\nmodel Alert {\n id String @id\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n signal String\n occurrenceKey String @map(\"occurrence_key\")\n facts Json\n ownerShipId String? @map(\"owner_ship_id\")\n since DateTime @db.Timestamptz(3)\n raisedAt DateTime @map(\"raised_at\") @db.Timestamptz(3)\n clearedAt DateTime? @map(\"cleared_at\") @db.Timestamptz(3)\n clearedWhy String? @map(\"cleared_why\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n\n @@unique([fleetId, shipId, signal, occurrenceKey])\n /// The fleet's open alerts, newest first, a page at a time.\n @@index([fleetId, id(sort: Desc)], map: \"alerts_open_idx\", where: { clearedAt: null })\n /// A ship's open alerts, and how many it has.\n @@index([fleetId, shipId], map: \"alerts_open_on_ship_idx\", where: { clearedAt: null })\n @@map(\"alerts\")\n}\n\n/// The expectations on a ship (decision 0071): what its owner, or a ship\n/// that manages it, expects of it, standing, at most one of each. Each keeps\n/// who set it (JSON, as common's expectation setter) and when; its columns\n/// are null while it is not set. No row while none holds; a retire removes it.\nmodel ShipExpectations {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n reportChangesWithinMinutes Int? @map(\"report_changes_within_minutes\")\n reportChangesWithinSetBy Json? @map(\"report_changes_within_set_by\")\n reportChangesWithinSetAt DateTime? @map(\"report_changes_within_set_at\") @db.Timestamptz(3)\n taskDoneByTask Json? @map(\"task_done_by_task\")\n taskDoneBy DateTime? @map(\"task_done_by\") @db.Timestamptz(3)\n taskDoneBySetBy Json? @map(\"task_done_by_set_by\")\n taskDoneBySetAt DateTime? @map(\"task_done_by_set_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n\n @@id([fleetId, shipId])\n @@map(\"ship_expectations\")\n}\n\n/// A send the network rules refused (decision 0034), recorded in the\n/// transaction that refused it. Ids start with rfs_. Sender and recipient are\n/// as they were then: ids, names and the label values they carried, as JSON,\n/// so a later rename or relabelling keeps the record true. Only argo reads it.\nmodel ReachRefusal {\n id String @id\n fleetId String @map(\"fleet_id\")\n at DateTime @db.Timestamptz(3)\n sender Json\n /// The plugin ship that read on behalf of the sender (decision 0034); null for the sender's own call.\n askedBy Json? @map(\"asked_by\")\n recipient Json\n /// What the sender tried to do: send, read or manage (decision 0034).\n verb String\n settingsVersion Int @map(\"settings_version\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n /// They page newest first by id.\n @@index([fleetId, id])\n @@map(\"reach_refusals\")\n}\n\n/// A ship secret, stored only as its hash. Ids start with crd_.\n/// The hash is unique across all fleets: finding a ship by its secret is one of the\n/// lookups not scoped by fleet (ADR 0007).\nmodel Credential {\n id String @id\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n secretHash String @unique @map(\"secret_hash\")\n issuedAt DateTime @map(\"issued_at\") @db.Timestamptz(3)\n claimedAt DateTime? @map(\"claimed_at\") @db.Timestamptz(3)\n invalidatedAt DateTime? @map(\"invalidated_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n\n /// At most one valid secret per ship.\n @@unique([shipId], map: \"credentials_ship_id_valid_key\", where: { invalidatedAt: null })\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, shipId])\n @@map(\"credentials\")\n}\n\n/// Who a message is for: one ship or any ship of a type. Group and fleet come later.\nenum SelectorKind {\n ship\n type\n meeting\n label\n\n @@map(\"selector_kind\")\n}\n\n/// The messages a fleet stored on one UTC day and their payloads' UTF-8 bytes\n/// (performance design, decision 1). A unit of work adds to it as its last\n/// statements, after the fleet's event numbers, so the row lock is held only\n/// until commit. Storage is the sum of the days; the daily message limit\n/// counts today's row.\n/// A feature flag that is on for a fleet (decision 0069): a row per flag that\n/// is on, none being off. The flag by its key in common's list, as text, so a\n/// new flag needs no migration.\nmodel FleetFeatureFlag {\n fleetId String @map(\"fleet_id\")\n flag String\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, flag])\n @@map(\"fleet_feature_flags\")\n}\n\nmodel MessageDay {\n fleetId String @map(\"fleet_id\")\n day DateTime @db.Date\n messages Int\n payloadBytes BigInt @map(\"payload_bytes\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, day])\n @@map(\"message_days\")\n}\n\n/// An immutable envelope plus an opaque payload of at most 256 KB, sent by one ship.\n/// Ids start with msg_. The selector is stored as resolved at send time: a ship's\n/// id, never its name, or a type. It can name the message it replies to, and a\n/// resend names the message it resends (nothing sets that yet).\nmodel Message {\n id String @id\n fleetId String @map(\"fleet_id\")\n senderShipId String @map(\"sender_ship_id\")\n selectorKind SelectorKind @map(\"selector_kind\")\n selectorShipId String? @map(\"selector_ship_id\")\n selectorType String? @map(\"selector_type\")\n /// The label selection a send to a label was sent to, its value ids as sent (decision 0065); none for any other selector.\n selectorValueIds String[] @default([]) @map(\"selector_value_ids\")\n /// Null in a sealed fleet (decision 0068): the sealed payload is the data key, nonce and ciphertext with its tag,\n /// beside the plain payload's UTF-8 byte count.\n payload String?\n sealedDataKeyId String? @map(\"sealed_data_key_id\")\n sealedNonce Bytes? @map(\"sealed_nonce\")\n sealedCiphertext Bytes? @map(\"sealed_ciphertext\")\n sealedPayloadBytes Int? @map(\"sealed_payload_bytes\")\n /// The question uuid a withdrawal or a replacement names, read at send (decision 0068, B18).\n questionId String? @map(\"question_id\")\n contentType String @map(\"content_type\")\n /// The model the sender's session stated; none from argo and on messages from before models were stated.\n model String?\n idempotencyKey String @map(\"idempotency_key\")\n requestHash String @map(\"request_hash\")\n /// The message it replies to and the one it resends, as written: no foreign\n /// key, so a kept message may name one that is no longer kept (decision 0066).\n inReplyToMessageId String? @map(\"in_reply_to_message_id\")\n resendOfMessageId String? @map(\"resend_of_message_id\")\n /// The meeting it was sent to, or the meeting whose added notice it is (decision 0061).\n meetingId String? @map(\"meeting_id\")\n /// The schedule it was sent for, and that send time; none on a live send (decision 0062).\n scheduleId String? @map(\"schedule_id\")\n sendTime DateTime? @map(\"send_time\") @db.Timestamptz(3)\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n senderShip Ship @relation(\"MessageSender\", fields: [fleetId, senderShipId], references: [fleetId, id], onDelete: Restrict)\n selectorShip Ship? @relation(\"MessageSelectorShip\", fields: [fleetId, selectorShipId], references: [fleetId, id], onDelete: Restrict)\n meeting Meeting? @relation(fields: [fleetId, meetingId], references: [fleetId, id], onDelete: Restrict)\n schedule Schedule? @relation(\"MessageSchedule\", fields: [fleetId, scheduleId], references: [fleetId, id], onDelete: Restrict)\n sealedDataKey DataKey? @relation(fields: [fleetId, sealedDataKeyId], references: [fleetId, id], onDelete: Restrict)\n repliedToBySchedules Schedule[] @relation(\"ScheduleInReplyTo\")\n lastSentBySchedules Schedule[] @relation(\"ScheduleLastMessage\")\n deliveries Delivery[]\n events Event[]\n\n @@unique([fleetId, id])\n /// A sender uses an idempotency key once: a repeat of the same request, told by its\n /// request hash, returns the original message; another request with the key is refused.\n @@unique([fleetId, senderShipId, idempotencyKey])\n /// A ship's current model is its newest message with a model.\n @@index([fleetId, senderShipId, createdAt])\n /// A ship's messages page newest first by id: those it sent and those sent to it.\n @@index([fleetId, senderShipId, id])\n /// The installation counts a fleet's messages of the last 7 days (#1126).\n @@index([fleetId, createdAt])\n /// A question's withdrawals and replacements, found by the question uuid they name (decisions 0038, 0068).\n @@index([fleetId, questionId], map: \"messages_fleet_id_question_id_idx\", where: { questionId: { not: null } })\n /// A data key's sealed messages, for its foreign key.\n @@index([fleetId, sealedDataKeyId])\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, selectorShipId, id])\n @@index([fleetId, inReplyToMessageId])\n @@index([fleetId, resendOfMessageId])\n /// The messages a schedule sent (decision 0062): the foreign key's index (#331).\n @@index([fleetId, scheduleId])\n /// A meeting's contributions page newest first by id (decision 0061).\n @@index([fleetId, meetingId, id])\n @@index([fleetId, selectorShipId, createdAt, id], map: \"messages_pings_idx\", where: raw(\"(content_type = 'application/vnd.aeolus.ping'::text)\"))\n @@map(\"messages\")\n}\n\nenum DeliveryState {\n pending\n received\n handed\n acknowledged\n handled\n notHandled\n undeliverable\n dismissed\n abandoned\n\n @@map(\"delivery_state\")\n}\n\n/// One message to one resolved recipient: a ship or a type. Ids start with dlv_.\n/// A receive hands it to the ship and the lease of the crew receiving, or a push\n/// receive takes it for them: set while it is received or handed, kept once\n/// acknowledged, none while it is pending. Attempts count the hand-overs; the fifth\n/// makes it undeliverable. The hand-over number is the last one the crew reported\n/// with handed (decision 0040), none while pending.\n/// The read date is set when the operator opens a message to argo.\n/// For a type under network rules, the ships of the type its sender may reach,\n/// fixed at send time: only they claim it (decision 0034). Empty: any ship of\n/// the type, as a send no ship of the type may take is refused.\n/// A meeting of ships (decision 0061), id mtg_: one owner and one moderator,\n/// both participants, the opener at first.\nmodel Meeting {\n id String @id\n fleetId String @map(\"fleet_id\")\n title String?\n ownerShipId String @map(\"owner_ship_id\")\n moderatorShipId String @map(\"moderator_ship_id\")\n openedByShipId String @map(\"opened_by_ship_id\")\n idempotencyKey String @map(\"idempotency_key\")\n requestHash String @map(\"request_hash\")\n openedAt DateTime @map(\"opened_at\") @db.Timestamptz(3)\n endedAt DateTime? @map(\"ended_at\") @db.Timestamptz(3)\n /// The participant that holds the mic; none while it is free.\n micHolderShipId String? @map(\"mic_holder_ship_id\")\n micPattern MicPattern @default(moderator) @map(\"mic_pattern\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n micHolder Ship? @relation(\"MeetingMicHolder\", fields: [fleetId, micHolderShipId], references: [fleetId, id], onDelete: Restrict)\n micRequests MeetingMicRequest[]\n owner Ship @relation(\"MeetingOwner\", fields: [fleetId, ownerShipId], references: [fleetId, id], onDelete: Restrict)\n moderator Ship @relation(\"MeetingModerator\", fields: [fleetId, moderatorShipId], references: [fleetId, id], onDelete: Restrict)\n openedBy Ship @relation(\"MeetingOpener\", fields: [fleetId, openedByShipId], references: [fleetId, id], onDelete: Restrict)\n participants MeetingParticipant[]\n messages Message[]\n\n @@unique([fleetId, id])\n /// An opener uses an idempotency key once.\n @@unique([fleetId, openedByShipId, idempotencyKey])\n /// Every foreign key has an index leading with its columns (#331).\n @@index([fleetId, ownerShipId])\n @@index([fleetId, moderatorShipId])\n @@index([fleetId, micHolderShipId])\n @@map(\"meetings\")\n}\n\n/// How a meeting's free mic passes (decision 0061, M9): the moderator's pick, or the oldest request.\n/// A ship's scheduled message (decision 0062): its send input as given, its timing and\n/// refusal strategy, its state, next send time and attempt, and its last outcome.\nmodel Schedule {\n id String @id\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n /// The selector as the creator gave it: a ship by id or by name, a type, or a label selection by value ids; never a meeting.\n selectorKind SelectorKind @map(\"selector_kind\")\n selectorShipId String? @map(\"selector_ship_id\")\n selectorShipName String? @map(\"selector_ship_name\")\n selectorType String? @map(\"selector_type\")\n selectorValueIds String[] @default([]) @map(\"selector_value_ids\")\n /// Null in a sealed fleet (decision 0068): the sealed payload is the data key, nonce and ciphertext with its tag,\n /// beside the plain payload's UTF-8 byte count, as a message's.\n payload String?\n sealedDataKeyId String? @map(\"sealed_data_key_id\")\n sealedNonce Bytes? @map(\"sealed_nonce\")\n sealedCiphertext Bytes? @map(\"sealed_ciphertext\")\n sealedPayloadBytes Int? @map(\"sealed_payload_bytes\")\n contentType String @map(\"content_type\")\n model String?\n inReplyToMessageId String? @map(\"in_reply_to_message_id\")\n isForced Boolean @map(\"is_forced\")\n timingKind ScheduleTimingKind @map(\"timing_kind\")\n /// The timing: once an instant; every a duration, or a cron and its zone, each from a start to an end or a count of sends.\n onceAt DateTime? @map(\"once_at\") @db.Timestamptz(3)\n every String?\n cron String?\n timeZone String? @map(\"time_zone\")\n start DateTime? @db.Timestamptz(3)\n end DateTime? @db.Timestamptz(3)\n count Int?\n onRefused RefusalStrategy @map(\"on_refused\")\n retryWindow String @map(\"retry_window\")\n onMissed MissedStrategy @map(\"on_missed\")\n grace String\n idempotencyKey String @map(\"idempotency_key\")\n requestHash String @map(\"request_hash\")\n state ScheduleState\n nextSendTime DateTime? @map(\"next_send_time\") @db.Timestamptz(3)\n nextAttemptAt DateTime? @map(\"next_attempt_at\") @db.Timestamptz(3)\n lastOutcomeKind ScheduleOutcomeKind? @map(\"last_outcome_kind\")\n lastMessageId String? @map(\"last_message_id\")\n lastRefusalCode String? @map(\"last_refusal_code\")\n lastSendTime DateTime? @map(\"last_send_time\") @db.Timestamptz(3)\n lastOutcomeAt DateTime? @map(\"last_outcome_at\") @db.Timestamptz(3)\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n endedAt DateTime? @map(\"ended_at\") @db.Timestamptz(3)\n cancelledAt DateTime? @map(\"cancelled_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(\"ScheduleShip\", fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n selectorShip Ship? @relation(\"ScheduleSelectorShip\", fields: [fleetId, selectorShipId], references: [fleetId, id], onDelete: Restrict)\n inReplyTo Message? @relation(\"ScheduleInReplyTo\", fields: [fleetId, inReplyToMessageId], references: [fleetId, id], onDelete: Restrict)\n sealedDataKey DataKey? @relation(fields: [fleetId, sealedDataKeyId], references: [fleetId, id], onDelete: Restrict)\n lastMessage Message? @relation(\"ScheduleLastMessage\", fields: [fleetId, lastMessageId], references: [fleetId, id], onDelete: Restrict)\n messages Message[] @relation(\"MessageSchedule\")\n\n @@unique([fleetId, id])\n /// A ship uses an idempotency key once for its schedules.\n @@unique([fleetId, shipId, idempotencyKey])\n /// A ship's schedules page newest first by id.\n @@index([fleetId, shipId, id])\n /// The claim of the active schedules that are due, earliest attempt first.\n @@index([fleetId, nextAttemptAt, id], map: \"schedules_due_idx\", where: raw(\"(state = 'active'::schedule_state)\"))\n /// Every foreign key has an index leading with its columns (#331).\n @@index([fleetId, selectorShipId])\n @@index([fleetId, inReplyToMessageId])\n @@index([fleetId, lastMessageId])\n @@index([fleetId, sealedDataKeyId])\n @@map(\"schedules\")\n}\n\nenum ScheduleState {\n active\n paused\n ended\n cancelled\n\n @@map(\"schedule_state\")\n}\n\nenum ScheduleTimingKind {\n once\n every\n cron\n\n @@map(\"schedule_timing_kind\")\n}\n\nenum RefusalStrategy {\n skip\n retry\n pause\n\n @@map(\"refusal_strategy\")\n}\n\nenum MissedStrategy {\n each\n once\n skip\n\n @@map(\"missed_strategy\")\n}\n\nenum ScheduleOutcomeKind {\n sent\n refused\n missed\n\n @@map(\"schedule_outcome_kind\")\n}\n\nenum MicPattern {\n moderator\n fifo\n\n @@map(\"mic_pattern\")\n}\n\n/// A participant waiting for the mic of its meeting, since its time (decision 0061, M8): once per meeting.\nmodel MeetingMicRequest {\n fleetId String @map(\"fleet_id\")\n meetingId String @map(\"meeting_id\")\n shipId String @map(\"ship_id\")\n requestedAt DateTime @map(\"requested_at\") @db.Timestamptz(3)\n /// Its place on the list, the oldest request's 0.\n place Int\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n meeting Meeting @relation(fields: [fleetId, meetingId], references: [fleetId, id], onDelete: Restrict)\n participant MeetingParticipant @relation(fields: [fleetId, meetingId, shipId], references: [fleetId, meetingId, shipId], onDelete: Restrict)\n\n @@id([fleetId, meetingId, shipId])\n @@map(\"meeting_mic_requests\")\n}\n\n/// A ship in a meeting and when it joined (decision 0061): once per meeting.\nmodel MeetingParticipant {\n fleetId String @map(\"fleet_id\")\n meetingId String @map(\"meeting_id\")\n shipId String @map(\"ship_id\")\n joinedAt DateTime @map(\"joined_at\") @db.Timestamptz(3)\n /// Its place in the order the meeting's ships joined, the opener's 0.\n place Int\n /// When it left or was revoked; none while it is present (decision 0061, M13).\n leftAt DateTime? @map(\"left_at\") @db.Timestamptz(3)\n /// Whether the owner revoked its right to rejoin.\n isRevoked Boolean @default(false) @map(\"is_revoked\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n meeting Meeting @relation(fields: [fleetId, meetingId], references: [fleetId, id], onDelete: Restrict)\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n micRequest MeetingMicRequest?\n\n @@id([fleetId, meetingId, shipId])\n /// A ship's meetings, and a retire checking them.\n @@index([fleetId, shipId])\n @@map(\"meeting_participants\")\n}\n\nmodel Delivery {\n id String @id\n fleetId String @map(\"fleet_id\")\n messageId String @map(\"message_id\")\n recipientShipId String? @map(\"recipient_ship_id\")\n recipientType String? @map(\"recipient_type\")\n state DeliveryState @default(pending)\n claimedByShipId String? @map(\"claimed_by_ship_id\")\n claimedByLeaseId String? @map(\"claimed_by_lease_id\")\n attempts Int @default(0)\n handOverNumber Int? @map(\"hand_over_number\")\n /// When its crew handed it once more after the turn that took it died; only once (decision 0040).\n handedOnceMoreAt DateTime? @map(\"handed_once_more_at\") @db.Timestamptz(3)\n /// Whether its message was forced: it comes first in receive and push receive (decision 0040).\n isForced Boolean @default(false) @map(\"is_forced\")\n reachableShipIds String[] @default([]) @map(\"reachable_ship_ids\")\n readAt DateTime? @map(\"read_at\") @db.Timestamptz(3)\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n message Message @relation(fields: [fleetId, messageId], references: [fleetId, id])\n recipientShip Ship? @relation(\"DeliveryRecipientShip\", fields: [fleetId, recipientShipId], references: [fleetId, id], onDelete: Restrict)\n claimedByShip Ship? @relation(\"DeliveryClaimedByShip\", fields: [fleetId, claimedByShipId], references: [fleetId, id], onDelete: Restrict)\n claimedByLease Lease? @relation(fields: [fleetId, claimedByLeaseId], references: [fleetId, id], onDelete: Restrict)\n events Event[]\n overdue OverdueDelivery[]\n\n @@unique([fleetId, id])\n /// One row per recipient.\n @@unique([messageId, recipientShipId])\n @@unique([messageId, recipientType])\n @@index([fleetId, recipientShipId, state])\n /// A ship's inbox pages newest first by id.\n @@index([fleetId, recipientShipId, id])\n @@index([fleetId, recipientType, state])\n /// The installation's health figures scan a fleet's open deliveries by state (decision 0041). Partial, so a foreign key check never picks it.\n @@index([fleetId, state, createdAt], map: \"deliveries_open_fleet_id_state_created_at_idx\", where: raw(\"(state = ANY (ARRAY['pending'::delivery_state, 'received'::delivery_state, 'handed'::delivery_state, 'undeliverable'::delivery_state, 'notHandled'::delivery_state]))\"))\n /// A crew's own deliveries in flight, which its next receive returns first.\n @@index([fleetId, claimedByLeaseId, state])\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, messageId, id])\n @@index([fleetId, claimedByShipId])\n @@map(\"deliveries\")\n}\n\n/// Which of the 10 and 60 minute clocks ran out (decision 0040).\nenum OverdueClock {\n notConfirmed\n idle\n busy\n\n @@map(\"overdue_clock\")\n}\n\n/// A delivery argo was told is overdue on a pushed lease: its clock ran out\n/// while it waited in the state kept here. Once per lease and delivery, so a\n/// pass after a restart, or a second pass at once, tells nothing again.\nmodel OverdueDelivery {\n fleetId String @map(\"fleet_id\")\n leaseId String @map(\"lease_id\")\n deliveryId String @map(\"delivery_id\")\n shipId String @map(\"ship_id\")\n state DeliveryState\n clock OverdueClock\n minutes Int\n toldAt DateTime @map(\"told_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n lease Lease @relation(fields: [fleetId, leaseId], references: [fleetId, id], onDelete: Restrict)\n delivery Delivery @relation(fields: [fleetId, deliveryId], references: [fleetId, id], onDelete: Restrict)\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n\n @@id([fleetId, leaseId, deliveryId])\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, deliveryId])\n @@index([fleetId, shipId])\n @@map(\"overdue_deliveries\")\n}\n\n/// The stuck snapshot (docs/design/performance/performance.md, section 5):\n/// one row per fleet and closed hour, written once by the 30 second pass and\n/// kept for 168 hours. Its counts are by message parties, so a read counts\n/// only what its caller reads (decision 0034).\nmodel HealthSnapshot {\n fleetId String @map(\"fleet_id\")\n hour DateTime @db.Timestamptz(3)\n /// The last event folded into it, by its seq.\n seq BigInt\n /// Stuck at the hour mark: cause, place, message parties, count and oldest since, each.\n stuck Json\n /// The waits from send to acknowledgement in the hour, by message parties, as counts per duration bucket.\n acknowledged Json\n /// The same waits summed over every message, as a reader of every ship reads them.\n acknowledgedWaits Json @map(\"acknowledged_waits\")\n /// Each lease's latest turn as of seq; the latest row's is the fold's.\n turns Json\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, hour])\n @@map(\"health_snapshots\")\n}\n\n/// The fleet's open deliveries as of its latest snapshot, each at its latest\n/// step: replaced whole by each close. A copy for the fold, so no foreign key\n/// but the fleet's.\nmodel HealthSnapshotDelivery {\n fleetId String @map(\"fleet_id\")\n deliveryId String @map(\"delivery_id\")\n messageId String @map(\"message_id\")\n senderShipId String @map(\"sender_ship_id\")\n recipientShipId String? @map(\"recipient_ship_id\")\n recipientType String? @map(\"recipient_type\")\n claimedByShipId String? @map(\"claimed_by_ship_id\")\n reachableShipIds String[] @map(\"reachable_ship_ids\")\n sentAt DateTime @map(\"sent_at\") @db.Timestamptz(3)\n /// Its latest step: the state, since when, and the ship and lease that took it; none while pending since its send.\n state DeliveryState?\n since DateTime? @db.Timestamptz(3)\n stepShipId String? @map(\"step_ship_id\")\n leaseId String? @map(\"lease_id\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, deliveryId])\n @@map(\"health_snapshot_deliveries\")\n}\n\n/// Append-only log of every state change: never updated or deleted. Ids start with evt_.\n/// Records its type and time, who caused it (a ship, or the system when\n/// actor_ship_id is null), the ship, message and delivery it concerns, and a few\n/// details as a flat JSON object.\nmodel Event {\n id String @id\n fleetId String @map(\"fleet_id\")\n type String\n occurredAt DateTime @map(\"occurred_at\") @db.Timestamptz(3)\n /// Who caused it (decision 0057): a ship, an account, the installation or the system.\n actorKind EventActorKind @default(system) @map(\"actor_kind\")\n actorShipId String? @map(\"actor_ship_id\")\n /// The account that caused it, by pagasae's id only: never an email.\n actorAccountId String? @map(\"actor_account_id\")\n /// The ship that presented the account's token, a plugin's page or the gateway, if one did.\n actorThroughShipId String? @map(\"actor_through_ship_id\")\n /// The account signed in to the console as argo when argo caused it, by its id only (decision 0054).\n actorSignedInAccountId String? @map(\"actor_signed_in_account_id\")\n shipId String? @map(\"ship_id\")\n messageId String? @map(\"message_id\")\n deliveryId String? @map(\"delivery_id\")\n details Json\n /// The event's place in its fleet's stream, in commit order and without\n /// gaps: where a live subscription resumes. The id is not, since ids are\n /// taken before their transaction commits.\n seq BigInt\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n actorShip Ship? @relation(\"EventActorShip\", fields: [fleetId, actorShipId], references: [fleetId, id], onDelete: Restrict)\n actorThroughShip Ship? @relation(\"EventActorThroughShip\", fields: [fleetId, actorThroughShipId], references: [fleetId, id], onDelete: Restrict)\n ship Ship? @relation(\"EventShip\", fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n message Message? @relation(fields: [fleetId, messageId], references: [fleetId, id], onDelete: Restrict)\n delivery Delivery? @relation(fields: [fleetId, deliveryId], references: [fleetId, id], onDelete: Restrict)\n\n @@unique([fleetId, seq])\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n /// A ship's timeline pages through the events it caused and those naming\n /// it by their place in the stream, each through its own index.\n @@index([fleetId, actorShipId, seq])\n @@index([actorThroughShipId, fleetId])\n @@index([fleetId, shipId, seq])\n @@index([fleetId, messageId])\n @@index([fleetId, deliveryId])\n /// The health reads take a fleet's events since a time (decision 0042).\n @@index([fleetId, occurredAt])\n @@index([fleetId, shipId, seq], map: \"events_starting_prompt_issued_idx\", where: raw(\"(type = 'StartingPromptIssued'::text)\"))\n /// A ship's messages page through those it claimed as a ship of their type by id.\n @@index([fleetId, shipId, messageId], map: \"events_delivery_handed_idx\", where: raw(\"(type = 'DeliveryHanded'::text)\"))\n /// A first stuck snapshot reads each lease's turn at its oldest hour from the turn reports alone.\n @@index([fleetId, occurredAt], map: \"events_turn_reported_idx\", where: raw(\"(type = 'TurnReported'::text)\"))\n /// The pruning pass finds the mic and participant events of ended meetings (decision 0066).\n @@index([fleetId, seq], map: \"events_meeting_parts_idx\", where: raw(\"(type = ANY (ARRAY['ParticipantAdded'::text, 'ParticipantLeft'::text, 'ParticipantRejoined'::text, 'ParticipantRevoked'::text, 'MicRequested'::text, 'MicRequestWithdrawn'::text, 'MicGiven'::text, 'MicReleased'::text, 'MicTaken'::text, 'MicPatternSet'::text]))\"))\n /// The pruning pass finds a crew's session and secret events past the cutoff (decision 0066).\n @@index([fleetId, occurredAt], map: \"events_crew_idx\", where: raw(\"(type = ANY (ARRAY['ShipClaimed'::text, 'LeaseRevoked'::text, 'LeasePushed'::text, 'ShipReported'::text, 'TurnReported'::text, 'StatementSet'::text, 'CrewStatusChanged'::text, 'SignInTicketIssued'::text, 'ViewerSessionStarted'::text, 'StartingPromptIssued'::text, 'CredentialRevoked'::text]))\"))\n @@map(\"events\")\n}\n\n/// Why a console session ended: a sign-in elsewhere took argo over, the\n/// operator signed out, or the password was reset.\nenum ConsoleSessionEndReason {\n takenOver\n signedOut\n passwordReset\n accountCutOff\n\n @@map(\"console_session_end_reason\")\n}\n\n/// argo's own sign-in: email and Argon2id password hash. fleet:init creates it\n/// with neither, until argo sets both in Settings; a hosting installation\n/// creates it with an email and no password. Ids start with opr_.\n/// The email is unique across all fleets: finding the account by email is the one\n/// lookup not scoped by fleet (ADR 0007). One account per fleet in v1.\nmodel Operator {\n id String @id\n fleetId String @unique @map(\"fleet_id\")\n email String? @unique\n passwordHash String? @map(\"password_hash\")\n /// How the console looks for this operator; system until they choose.\n theme Theme @default(system)\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@map(\"operators\")\n}\n\nenum Theme {\n light\n dark\n system\n\n @@map(\"theme\")\n}\n\n/// The operator crewing argo through the web console. Ids start with ses_.\n/// Only the hash of the session token is stored, unique across all fleets: finding\n/// a session by its token is the one lookup not scoped by fleet (ADR 0007).\n/// Valid until expires_at, which moves to idle_limit_seconds after each use\n/// (30 days for the operator, 2 hours for a viewer), never past ends_by.\nmodel ConsoleSession {\n id String @id\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n /// The lease on argo it holds; null for a viewer session (decision 0022).\n leaseId String? @map(\"lease_id\")\n idleLimitSeconds Int @map(\"idle_limit_seconds\")\n /// No use renews it past this; null when only idleness ends it.\n endsBy DateTime? @map(\"ends_by\") @db.Timestamptz(3)\n /// The device it signed in from, as the browser told: \"Mac · Chrome\".\n device String @default(\"Unknown device\")\n /// The account that signed in as argo, by its id only; null for argo's own sign-in and a viewer (decision 0054).\n accountId String? @map(\"account_id\")\n tokenHash String @unique @map(\"token_hash\")\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n lastUsedAt DateTime @map(\"last_used_at\") @db.Timestamptz(3)\n expiresAt DateTime @map(\"expires_at\") @db.Timestamptz(3)\n endedAt DateTime? @map(\"ended_at\") @db.Timestamptz(3)\n /// Why the session ended; null while it has not.\n endReason ConsoleSessionEndReason? @map(\"end_reason\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n lease Lease? @relation(fields: [fleetId, leaseId], references: [fleetId, id])\n\n noticeDismissals NoticeDismissal[]\n guideProgress GuideProgress[]\n\n /// At most one live session holding argo's lease per fleet: signing in ends the previous one. Viewer sessions run beside it.\n @@unique([fleetId], map: \"console_sessions_fleet_id_open_key\", where: raw(\"ended_at IS NULL AND lease_id IS NOT NULL\"))\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, shipId])\n @@index([fleetId, leaseId])\n @@map(\"console_sessions\")\n}\n\n/// A one-time sign-in ticket for the fleet's operator, issued by a hosting\n/// installation and redeemed in the console (decision 0020). Only its hash is\n/// stored, unique across all fleets: redeeming finds it before the fleet is known.\nmodel SignInTicket {\n tokenHash String @id @map(\"token_hash\")\n fleetId String @map(\"fleet_id\")\n /// Whom it signs in as: the operator or a viewer (decision 0022).\n signInAs SignInAs @map(\"sign_in_as\")\n /// The account it signs in as argo, by its id only; null for argo's own or a viewer's ticket (decision 0054).\n accountId String? @map(\"account_id\")\n issuedAt DateTime @map(\"issued_at\") @db.Timestamptz(3)\n expiresAt DateTime @map(\"expires_at\") @db.Timestamptz(3)\n /// When it signed in; null while unused.\n usedAt DateTime? @map(\"used_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@index([fleetId])\n @@map(\"sign_in_tickets\")\n}\n\nenum SignInAs {\n operator\n viewer\n\n @@map(\"sign_in_as\")\n}\n\n/// The installation's settings (decision 0020): the default ship, daily message,\n/// schedules per ship and minimum schedule interval (seconds) limits and the\n/// default retention in days (decision 0066) for fleets, and the cap on fleets,\n/// each null for none. One row at most, and none until the installation sets\n/// them. Belongs to no fleet.\nmodel InstallationSettings {\n id Int @id @default(1)\n defaultShipLimit Int? @map(\"default_ship_limit\")\n defaultDailyMessageLimit Int? @map(\"default_daily_message_limit\")\n defaultSchedulesPerShipLimit Int? @map(\"default_schedules_per_ship_limit\")\n defaultMinimumScheduleInterval Int? @map(\"default_minimum_schedule_interval\")\n defaultRetentionDays Int? @map(\"default_retention_days\")\n fleetCap Int? @map(\"fleet_cap\")\n\n @@map(\"installation_settings\")\n}\n\nenum InstallationRequestKind {\n createFleet @map(\"create_fleet\")\n deleteFleet @map(\"delete_fleet\")\n\n @@map(\"installation_request_kind\")\n}\n\n/// A create or delete of a fleet the installation carried out, under its caller's\n/// request id, so a replay answers the same (decision 0020). It belongs to the\n/// installation, not to a fleet, and keeps the request as a hash only. A create's\n/// row names the fleet and argo it answers with and is deleted with that fleet; a\n/// delete's row names nothing of the fleet.\nmodel InstallationRequest {\n requestId String @id @map(\"request_id\")\n kind InstallationRequestKind\n requestHash String @map(\"request_hash\")\n /// The created fleet and its argo; null for a delete.\n fleetId String? @map(\"fleet_id\")\n operatorShipId String? @map(\"operator_ship_id\")\n at DateTime @db.Timestamptz(3)\n\n @@index([fleetId])\n @@map(\"installation_requests\")\n}\n\n/// A console notice the installation sets (decision 0023), shown above every\n/// page to the sessions of its audience. It belongs to no fleet.\nmodel Notice {\n id String @id\n /// Its place in the installation's order.\n position Int\n audience NoticeAudience\n text String\n /// Its links: label, and url, isSignOut or both.\n links Json @default(\"[]\")\n isDismissible Boolean @default(false) @map(\"is_dismissible\")\n\n @@map(\"notices\")\n}\n\nenum NoticeAudience {\n everyone\n operators\n viewers\n accounts\n\n @@map(\"notice_audience\")\n}\n\n/// A notice a console session dismissed, for itself (decision 0023). It goes\n/// with its session and its fleet.\nmodel NoticeDismissal {\n fleetId String @map(\"fleet_id\")\n consoleSessionId String @map(\"console_session_id\")\n noticeId String @map(\"notice_id\")\n dismissedAt DateTime @map(\"dismissed_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n consoleSession ConsoleSession @relation(fields: [consoleSessionId], references: [id])\n\n @@id([consoleSessionId, noticeId])\n @@index([fleetId])\n @@map(\"notice_dismissals\")\n}\n\n/// A notice an account signed in to the console as itself dismissed, for\n/// itself, kept by its account id in each fleet (accounts design, A9). Core\n/// stores no account: the id is pagasae's. It goes with its fleet.\nmodel AccountNoticeDismissal {\n fleetId String @map(\"fleet_id\")\n accountId String @map(\"account_id\")\n noticeId String @map(\"notice_id\")\n dismissedAt DateTime @map(\"dismissed_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, accountId, noticeId])\n @@map(\"account_notice_dismissals\")\n}\n\n/// The installation's guide (decision 0024): steps for the console sessions of\n/// one audience. At most one row; it belongs to no fleet.\nmodel Guide {\n /// Always \"guide\": the installation has one guide or none.\n id String @id\n audience NoticeAudience\n /// Its steps, in order: path, anchor (optional), title and text.\n steps Json\n\n @@map(\"guides\")\n}\n\nenum GuideProgressState {\n open\n skipped\n finished\n\n @@map(\"guide_progress_state\")\n}\n\n/// Where a console session is in the guide, for itself (decision 0024). It\n/// goes with its session and its fleet.\nmodel GuideProgress {\n fleetId String @map(\"fleet_id\")\n consoleSessionId String @id @map(\"console_session_id\")\n step Int\n state GuideProgressState\n recordedAt DateTime @map(\"recorded_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n consoleSession ConsoleSession @relation(fields: [consoleSessionId], references: [id])\n\n @@index([fleetId])\n @@map(\"guide_progress\")\n}\n\n/// Where an account signed in to the console as itself is in the guide, kept\n/// by its account id in each fleet (accounts design, A9). It goes with its fleet.\nmodel AccountGuideProgress {\n fleetId String @map(\"fleet_id\")\n accountId String @map(\"account_id\")\n step Int\n state GuideProgressState\n recordedAt DateTime @map(\"recorded_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, accountId])\n @@map(\"account_guide_progress\")\n}\n\n/// An account pagasae cut off (decision 0058): its tokens issued before\n/// cut_off_at are refused in every fleet until forget_at, when the longest of\n/// them has ended. The installation's, not a fleet's: no fleet_id (ADR 0007).\n/// Never an email: the account by pagasae's id only.\nmodel AccountCutOff {\n accountId String @id @map(\"account_id\")\n cutOffAt DateTime @map(\"cut_off_at\") @db.Timestamptz(3)\n forgetAt DateTime @map(\"forget_at\") @db.Timestamptz(3)\n\n /// Forgetting finds the cut-offs that ended.\n @@index([forgetAt])\n @@map(\"account_cut_offs\")\n}\n\n/// Who caused an event (decision 0057).\nenum EventActorKind {\n ship\n account\n installation\n system\n\n @@map(\"event_actor_kind\")\n}\n\n/// Who commissioned a ship (decision 0057).\n/// Who wrote a verified fact (decision 0059).\nenum FactWriterKind {\n ship\n account\n installation\n\n @@map(\"fact_writer_kind\")\n}\n\nenum CommissionerKind {\n ship\n account\n installation\n\n @@map(\"commissioner_kind\")\n}\n\nenum LabelOwnerKind {\n ship\n installation\n\n @@map(\"label_owner_kind\")\n}\n\n/// A sealed fleet's data key (decision 0068): kept only wrapped, by the company key and by the recovery key\n/// when set, with a check value (HMAC-SHA-256 of a fixed text under the key) that proves an unwrap gave\n/// the right key. Never unwrapped in the database. Old keys stay to unseal old payloads.\nmodel DataKey {\n id String @id\n fleetId String @map(\"fleet_id\")\n wrappedByCompanyKey Bytes @map(\"wrapped_by_company_key\")\n wrappedByRecoveryKey Bytes? @map(\"wrapped_by_recovery_key\")\n checkValue Bytes @map(\"check_value\")\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n isCurrent Boolean @map(\"is_current\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n messages Message[]\n schedules Schedule[]\n\n @@unique([fleetId, id])\n /// One current data key per fleet.\n @@unique([fleetId], map: \"data_keys_fleet_id_current_key\", where: { isCurrent: true })\n @@map(\"data_keys\")\n}\n",
|
|
20
|
+
"inlineSchema": "// Aeolus core tables (docs/architecture.md, \"Core tables\").\n//\n// Prefixed ids, fleet_id on every table except fleets, and the columns and key\n// constraints named in the architecture. Columns a later slice owns (a message's\n// sender and selector, for one) arrive with that slice.\n//\n// References to rows of the same fleet carry fleet_id in the foreign key, so a\n// row can never point at another fleet's ship, lease, message or delivery.\n//\n// Timestamps have no database default: the application's Clock port sets every\n// one of them, so tests control time.\n//\n// Check constraints and the append-only rule for events live in the migration\n// SQL, because Prisma does not model them.\n\ngenerator client {\n provider = \"prisma-client\"\n output = \"./generated\"\n moduleFormat = \"esm\"\n importFileExtension = \"js\"\n runtime = \"nodejs\"\n previewFeatures = [\"partialIndexes\"]\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n\n/// The tenant: one operator's ships, messages and history. Ids start with flt_.\nmodel Fleet {\n id String @id\n name String\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n /// The sequence number of the fleet's last committed event. A unit of work\n /// takes its numbers from it as its last statements, so the row lock orders\n /// the numbers as the transactions commit.\n lastEventSeq BigInt @default(0) @map(\"last_event_seq\")\n /// Whether the fleet sets its own ship limit (else it follows the installation\n /// default), and that limit: null for no limit.\n shipLimitSet Boolean @default(false) @map(\"ship_limit_set\")\n shipLimit Int? @map(\"ship_limit\")\n /// The same for its daily message limit.\n dailyMessageLimitSet Boolean @default(false) @map(\"daily_message_limit_set\")\n dailyMessageLimit Int? @map(\"daily_message_limit\")\n /// The same for the schedules each of its ships may hold, and for the\n /// minimum interval of a repeating schedule, in seconds (decision 0062).\n schedulesPerShipLimitSet Boolean @default(false) @map(\"schedules_per_ship_limit_set\")\n schedulesPerShipLimit Int? @map(\"schedules_per_ship_limit\")\n minimumScheduleIntervalSet Boolean @default(false) @map(\"minimum_schedule_interval_set\")\n minimumScheduleInterval Int? @map(\"minimum_schedule_interval\")\n /// The same for its retention in days (decision 0066): null for kept for good.\n retentionSet Boolean @default(false) @map(\"retention_set\")\n retentionDays Int? @map(\"retention_days\")\n /// When its last pruning pass ran, and from when it keeps its finished\n /// history, as its last finished pass left it (decision 0066); null before any.\n prunedAt DateTime? @map(\"pruned_at\") @db.Timestamptz(3)\n keptFrom DateTime? @map(\"kept_from\") @db.Timestamptz(3)\n /// Its sealing (decision 0068): null while it is not sealed; then sealing until no payload is stored plain, and sealed. The company key that wraps its data keys, by its reference.\n sealingState SealingState? @map(\"sealing_state\")\n /// Since when it reads its sealing state: turned on, or the sealing pass left no payload plain.\n sealingStateSince DateTime? @map(\"sealing_state_since\") @db.Timestamptz(3)\n /// The sealing pass's progress (decision 0068, B5): the payloads stored plain when it turned sealing on, and how many the pass sealed since.\n payloadsToSeal Int @default(0) @map(\"payloads_to_seal\")\n payloadsSealed Int @default(0) @map(\"payloads_sealed\")\n companyKey String? @map(\"company_key\")\n /// Its recovery key (decision 0068, B6), when the company set one: the public half, an age X25519 recipient, and\n /// its fingerprint (SHA256: and the unpadded base64 SHA-256 of the recipient). Each data key is wrapped to it too.\n recoveryKey String? @map(\"recovery_key\")\n recoveryKeyFingerprint String? @map(\"recovery_key_fingerprint\")\n /// Whether its company key answered its last unwrap, and since when (decision 0068, B11): the key vault's reason\n /// while it refuses (accessDenied, disabled, notFound, unreachable), null while it answers. Since when set with the sealing.\n keyUnavailableReason String? @map(\"key_unavailable_reason\")\n keyAvailabilitySince DateTime? @map(\"key_availability_since\") @db.Timestamptz(3)\n\n ships Ship[]\n leases Lease[]\n crewRequests CrewRequest[]\n crewRequestGiveBacks CrewRequestGiveBack[]\n clearRequests WorktreeClearRequest[]\n labels Label[]\n labelValues LabelValue[]\n shipLabels ShipLabel[]\n networkSettings NetworkSettings?\n networkRulesDraft NetworkRulesDraft?\n declaredNetworkRules DeclaredNetworkRules[]\n installationDeclaredNetworkRules InstallationDeclaredNetworkRules?\n scopeNamespaces ScopeNamespace[]\n definedScopes DefinedScope[]\n verifiedFacts VerifiedFacts[]\n alerts Alert[]\n shipExpectations ShipExpectations[]\n reachRefusals ReachRefusal[]\n credentials Credential[]\n messages Message[]\n messageDays MessageDay[]\n deliveries Delivery[]\n overdueDeliveries OverdueDelivery[]\n events Event[]\n consoleSessions ConsoleSession[]\n signInTickets SignInTicket[]\n noticeDismissals NoticeDismissal[]\n guideProgress GuideProgress[]\n accountNoticeDismissals AccountNoticeDismissal[]\n accountGuideProgress AccountGuideProgress[]\n operator Operator?\n healthSnapshots HealthSnapshot[]\n healthSnapshotDeliveries HealthSnapshotDelivery[]\n meetings Meeting[]\n dataKeys DataKey[]\n meetingParticipants MeetingParticipant[]\n meetingMicRequests MeetingMicRequest[]\n schedules Schedule[]\n featureFlags FleetFeatureFlag[]\n\n @@map(\"fleets\")\n}\n\n/// A sealed fleet's sealing (decision 0068): payloads stored plain before still wait for the sealing pass, or none do.\nenum SealingState {\n sealing\n sealed\n}\n\n/// What a ship is (decision 0044): argo the one operator, the viewer, an agent session, a person's ship or an app's.\nenum ShipKind {\n operator\n agent\n viewer\n person\n app\n plugin\n\n @@map(\"ship_kind\")\n}\n\n/// A durable, addressable identity with an inbox. Ids start with shp_.\n/// Scopes are set when the ship is created and checked before every call.\nmodel Ship {\n id String @id\n fleetId String @map(\"fleet_id\")\n name String\n type String\n kind ShipKind\n scopes String[]\n note String?\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n retiredAt DateTime? @map(\"retired_at\") @db.Timestamptz(3)\n /// When the pruning pass removed it, past the fleet's retention (decision 0070): the row stays a remnant its kept history names.\n removedAt DateTime? @map(\"removed_at\") @db.Timestamptz(3)\n /// The actor that commissioned it, its idempotency key and the request's hash; null for argo.\n /// commissioned_by names the actor: a ship's id, an account's id, or `installation`.\n commissionedByKind CommissionerKind? @map(\"commissioned_by_kind\")\n commissionedBy String? @map(\"commissioned_by\")\n commissionKey String? @map(\"commission_key\")\n commissionRequestHash String? @map(\"commission_request_hash\")\n /// The ship that answers for it, a person's ship or argo (decision 0045); null for argo and the viewer.\n ownerShipId String? @map(\"owner_ship_id\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n owner Ship? @relation(\"ShipOwner\", fields: [fleetId, ownerShipId], references: [fleetId, id], onDelete: Restrict)\n ownedShips Ship[] @relation(\"ShipOwner\")\n leases Lease[]\n credentials Credential[]\n sentMessages Message[] @relation(\"MessageSender\")\n addressedMessages Message[] @relation(\"MessageSelectorShip\")\n deliveries Delivery[] @relation(\"DeliveryRecipientShip\")\n claimedDeliveries Delivery[] @relation(\"DeliveryClaimedByShip\")\n overdueDeliveries OverdueDelivery[]\n consoleSessions ConsoleSession[]\n actorOfEvents Event[] @relation(\"EventActorShip\")\n actorThroughOfEvents Event[] @relation(\"EventActorThroughShip\")\n events Event[] @relation(\"EventShip\")\n crewRequest CrewRequest? @relation(\"CrewRequestShip\")\n assignedCrews CrewRequest[] @relation(\"CrewRequestAssignee\")\n givenBackCrews CrewRequestGiveBack[] @relation(\"CrewRequestGiveBackTrierarch\")\n clearRequests WorktreeClearRequest[] @relation(\"WorktreeClearRequestTrierarch\")\n clearedWorktrees WorktreeClearRequest[] @relation(\"WorktreeClearRequestShip\")\n requestedClears WorktreeClearRequest[] @relation(\"WorktreeClearRequestRequester\")\n ownedLabels Label[] @relation(\"LabelOwner\")\n labels ShipLabel[] @relation(\"ShipLabelShip\")\n declaredNetworkRules DeclaredNetworkRules[]\n declaredNamespace ScopeNamespace?\n verifiedFacts VerifiedFacts[]\n alerts Alert[]\n shipExpectations ShipExpectations[]\n ownedMeetings Meeting[] @relation(\"MeetingOwner\")\n moderatedMeetings Meeting[] @relation(\"MeetingModerator\")\n openedMeetings Meeting[] @relation(\"MeetingOpener\")\n micHeldMeetings Meeting[] @relation(\"MeetingMicHolder\")\n meetings MeetingParticipant[]\n schedules Schedule[] @relation(\"ScheduleShip\")\n scheduledTo Schedule[] @relation(\"ScheduleSelectorShip\")\n\n @@unique([fleetId, id])\n /// An idempotency key is used once per commissioning actor.\n @@unique([fleetId, commissionedByKind, commissionedBy, commissionKey], map: \"ships_commission_key_key\")\n /// A name is unique among ships that are not retired, and reusable after retirement.\n @@unique([fleetId, name], map: \"ships_fleet_id_name_active_key\", where: { retiredAt: null })\n /// Exactly one operator ship per fleet.\n @@unique([fleetId], map: \"ships_fleet_id_operator_key\", where: raw(\"kind = 'operator'::ship_kind\"))\n /// At most one viewer ship per fleet (decision 0022).\n @@unique([fleetId], map: \"ships_fleet_id_viewer_key\", where: raw(\"kind = 'viewer'::ship_kind\"))\n @@index([fleetId, ownerShipId])\n @@index([fleetId, type], map: \"ships_type_listing_idx\", where: { retiredAt: null })\n @@index([fleetId, kind], map: \"ships_kind_listing_idx\", where: { retiredAt: null })\n /// The pruning pass picks the oldest retired ships not removed yet (decision 0070).\n @@index([fleetId, retiredAt, id], map: \"ships_removal_idx\", where: raw(\"((retired_at IS NOT NULL) AND (removed_at IS NULL))\"))\n @@map(\"ships\")\n}\n\n/// Where the session crewing a ship runs. OTHER carries a description; the other kinds none.\nenum ReportState {\n working\n blocked\n idle\n\n @@map(\"report_state\")\n}\n\n/// A pushed session's turn, as its hooks report it (decision 0040).\nenum LeaseWaker {\n trierarch\n pluginWatcher\n personApp\n gateway\n adapter\n\n @@map(\"lease_waker\")\n}\n\nenum TurnState {\n idle\n busy\n\n @@map(\"turn_state\")\n}\n\n/// The kind of a session's latest event as its trierarch observes it (headless design, H14).\nenum ActivityKind {\n text\n tool\n result\n error\n\n @@map(\"activity_kind\")\n}\n\nenum LocationKind {\n DEVICE\n CLOUD\n SERVER\n OTHER\n\n @@map(\"location_kind\")\n}\n\n/// The exclusive right of one session to crew a ship, and where that session runs.\n/// Ids start with lse_.\n/// The hash of the crew token register gave the session, unique across all fleets:\n/// finding a ship by its crew token is a lookup not scoped by fleet (ADR 0007). A\n/// console session's lease on argo has none; the console session holds its token.\nmodel Lease {\n id String @id\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n location LocationKind\n locationDescription String? @map(\"location_description\")\n /// The harness the session stated when it claimed the ship; none for argo's console lease and for leases from before harnesses were stated.\n harness String?\n crewTokenHash String? @unique @map(\"crew_token_hash\")\n startedAt DateTime @map(\"started_at\") @db.Timestamptz(3)\n /// The last call by its crew: observation only, nothing acts on it (ADR 0016).\n lastSeenAt DateTime? @map(\"last_seen_at\") @db.Timestamptz(3)\n /// The crew's last report: plain data, nothing acts on it. Null until it reports.\n reportState ReportState? @map(\"report_state\")\n reportNote String? @map(\"report_note\")\n reportedAt DateTime? @map(\"reported_at\") @db.Timestamptz(3)\n /// When the state, note, task or step last changed; details alone do not move it (decision 0028). Null until it reports.\n reportChangedAt DateTime? @map(\"report_changed_at\") @db.Timestamptz(3)\n /// What the crew works on: a typed reference, a kind and its fields (decision 0028). Null when it names none.\n reportTask Json? @map(\"report_task\")\n /// Where the crew is in its task, step at of of; both null when it gives none.\n reportStepAt Int? @map(\"report_step_at\")\n reportStepOf Int? @map(\"report_step_of\")\n /// The report's details: one JSON object stored without meaning, at most 16 KB (decision 0028). Null when there are none.\n reportDetails Json? @map(\"report_details\")\n /// Moves by one each time the details change; 0 before any.\n reportDetailsVersion Int @default(0) @map(\"report_details_version\")\n /// The crew's statement: what its ship is and offers, at most 256 KB, its shape common's; null until it states one (decision 0047).\n statement Json?\n /// Moves by one each time the statement changes; 0 before any.\n statementVersion Int @default(0) @map(\"statement_version\")\n /// From the lease's first push receive: the computer side takes its deliveries, and the agent's plain receive answers nothing (decision 0040).\n pushedAt DateTime? @map(\"pushed_at\") @db.Timestamptz(3)\n /// What wakes the ship, as its first push receive stated it; null when it stated none (interop 5.1).\n waker LeaseWaker?\n /// The session's turn as its hooks last reported it, and when they saw it change; null until they report (decision 0040).\n turn TurnState?\n turnAt DateTime? @map(\"turn_at\") @db.Timestamptz(3)\n /// What its assigned trierarch last observed of the session: the latest event's time, kind and tool, never content; null until it writes (docs/design/monitoring, 4.3).\n activityAt DateTime? @map(\"activity_at\") @db.Timestamptz(3)\n activityKind ActivityKind? @map(\"activity_kind\")\n activityTool String? @map(\"activity_tool\")\n /// When the trierarch wrote it, and the report interval it stated: past twice that interval it reads unknown.\n activityReportedAt DateTime? @map(\"activity_reported_at\") @db.Timestamptz(3)\n activityIntervalSeconds Int? @map(\"activity_interval_seconds\")\n endedAt DateTime? @map(\"ended_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n consoleSessions ConsoleSession[]\n claimedDeliveries Delivery[]\n overdueDeliveries OverdueDelivery[]\n\n @@unique([fleetId, id])\n /// At most one open lease per ship.\n @@unique([shipId], map: \"leases_ship_id_open_key\", where: { endedAt: null })\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, shipId])\n @@map(\"leases\")\n}\n\n/// How the assigned trierarch says its crew of a ship stands (decision 0029).\nenum CrewStatus {\n crewing\n running\n restarting\n crashed\n releasing\n\n @@map(\"crew_status\")\n}\n\n/// A standing request that a ship be kept crewed (decision 0029): at most one per\n/// ship, so the ship's id is its key. Its settings are crew settings of at most\n/// 16 KB, checked but never acted on; each request replaces them and moves their\n/// version by one.\nmodel CrewRequest {\n shipId String @id @map(\"ship_id\")\n fleetId String @map(\"fleet_id\")\n settings Json\n settingsVersion Int @map(\"settings_version\")\n requestedAt DateTime @map(\"requested_at\") @db.Timestamptz(3)\n /// The trierarch ship it is assigned to; null while unassigned.\n assignedTo String? @map(\"assigned_to_ship_id\")\n /// How its trierarch says the crew stands; null until it says.\n status CrewStatus?\n /// Why no trierarch can take it, written by the assigner while unassigned; null when none.\n reason String?\n /// How many times its trierarch restarted the session within its restart window, with the status: 0 on its first start.\n attempt Int @default(0)\n /// When the session its trierarch runs now started, with the status; null while none runs.\n sessionStartedAt DateTime? @map(\"session_started_at\") @db.Timestamptz(3)\n /// Whether its crew is final: set by its trierarch's first running, restarting or crashed, kept whatever status follows, cleared on every new settings version.\n isFinal Boolean @default(false) @map(\"is_final\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(\"CrewRequestShip\", fields: [fleetId, shipId], references: [fleetId, id])\n assignee Ship? @relation(\"CrewRequestAssignee\", fields: [fleetId, assignedTo], references: [fleetId, id])\n givenBack CrewRequestGiveBack[]\n\n @@unique([fleetId, shipId])\n /// A trierarch reads the requests assigned to it.\n @@index([fleetId, assignedTo])\n @@map(\"crew_requests\")\n}\n\n/// A trierarch that gave a crew request back before its crew was final (#382): one per trierarch, until the next settings version.\nmodel CrewRequestGiveBack {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n trierarchShipId String @map(\"trierarch_ship_id\")\n settingsVersion Int @map(\"settings_version\")\n reason String\n givenBackAt DateTime @map(\"given_back_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n crewRequest CrewRequest @relation(fields: [fleetId, shipId], references: [fleetId, shipId])\n trierarch Ship @relation(\"CrewRequestGiveBackTrierarch\", fields: [fleetId, trierarchShipId], references: [fleetId, id])\n\n @@id([fleetId, shipId, trierarchShipId])\n @@index([fleetId, trierarchShipId])\n @@map(\"crew_request_give_backs\")\n}\n\n/// A pending request that a trierarch clear a worktree it kept (decision 0032),\n/// named by the ship it belonged to and its repository: never a path.\nmodel WorktreeClearRequest {\n fleetId String @map(\"fleet_id\")\n trierarchShipId String @map(\"trierarch_ship_id\")\n shipId String @map(\"ship_id\")\n repository String\n requestedBy String @map(\"requested_by_ship_id\")\n requestedAt DateTime @map(\"requested_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n trierarch Ship @relation(\"WorktreeClearRequestTrierarch\", fields: [fleetId, trierarchShipId], references: [fleetId, id])\n ship Ship @relation(\"WorktreeClearRequestShip\", fields: [fleetId, shipId], references: [fleetId, id])\n requester Ship @relation(\"WorktreeClearRequestRequester\", fields: [fleetId, requestedBy], references: [fleetId, id])\n\n @@id([fleetId, trierarchShipId, shipId, repository])\n @@index([fleetId, shipId])\n @@index([fleetId, requestedBy])\n @@map(\"worktree_clear_requests\")\n}\n\n/// A label (decision 0031): a key unique in its fleet with its defined values,\n/// owned by the ship that defined it. Ids start with lbl_. A retired or deleted\n/// label is deleted with its values; its events stay.\nmodel Label {\n id String @id\n fleetId String @map(\"fleet_id\")\n key String\n /// A ship or the installation (decision 0031); the installation's label names no owner ship.\n ownerKind LabelOwnerKind @default(ship) @map(\"owner_kind\")\n ownerShipId String? @map(\"owner_ship_id\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n owner Ship? @relation(\"LabelOwner\", fields: [fleetId, ownerShipId], references: [fleetId, id])\n values LabelValue[]\n carriers ShipLabel[]\n\n @@unique([fleetId, id])\n @@unique([fleetId, key])\n /// A retire finds the labels its ship owns.\n @@index([fleetId, ownerShipId])\n @@map(\"labels\")\n}\n\n/// One value of a label, each once, at most 50 a label. Ids start with lbv_; a\n/// value keeps its id while its label has it.\nmodel LabelValue {\n id String @id\n fleetId String @map(\"fleet_id\")\n labelId String @map(\"label_id\")\n value String\n /// Its place in the order the owner gave the values.\n position Int\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n label Label @relation(fields: [fleetId, labelId], references: [fleetId, id])\n carriers ShipLabel[]\n\n @@unique([fleetId, id])\n @@unique([fleetId, labelId, value])\n @@map(\"label_values\")\n}\n\n/// A label value a ship carries: a ship holds a set of values, so the ship and\n/// the value are its key.\nmodel ShipLabel {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n labelId String @map(\"label_id\")\n valueId String @map(\"value_id\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(\"ShipLabelShip\", fields: [fleetId, shipId], references: [fleetId, id])\n label Label @relation(fields: [fleetId, labelId], references: [fleetId, id])\n value LabelValue @relation(fields: [fleetId, valueId], references: [fleetId, id])\n\n @@id([fleetId, shipId, valueId])\n /// A change of values, a delete and a retire find every ship that carries a label.\n @@index([fleetId, labelId])\n /// Removing a value checks that no ship carries it.\n @@index([fleetId, valueId])\n @@map(\"ship_labels\")\n}\n\n/// A fleet's network settings (decision 0034), once it first set rules: its\n/// rules as JSON, none (null) for all-to-all, and their version. A send and a\n/// set take turns on an advisory lock on them (network.ts).\nmodel NetworkSettings {\n fleetId String @id @map(\"fleet_id\")\n /// The fleet's own rules as last applied (decision 0034); NULL while none\n /// are, all-to-all with open on.\n rules Json?\n /// The viewer reading every ship, the built-in rule an actor turns (decision 0034). On at fleet create.\n builtInViewerRead Boolean @default(true) @map(\"built_in_viewer_read\")\n version Int\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@map(\"network_settings\")\n}\n\n/// The draft of a fleet's own rules (decision 0034): one a fleet at most, the\n/// rules as JSON or NULL for all-to-all. Nothing in force reads it; an apply\n/// moves it into network_settings and removes it.\nmodel NetworkRulesDraft {\n fleetId String @id @map(\"fleet_id\")\n rules Json?\n savedAt DateTime @map(\"saved_at\") @db.Timestamptz(3)\n savedAgainstVersion Int @map(\"saved_against_version\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@map(\"network_rules_drafts\")\n}\n\n/// The network rules a ship declared on the labels it owns (decision 0037),\n/// its whole list as JSON, at most 20. No row while it declares none; a retire\n/// removes its row.\nmodel DeclaredNetworkRules {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n rules Json\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n\n @@id([fleetId, shipId])\n @@map(\"declared_network_rules\")\n}\n\n/// The network rules the installation declares on the labels it owns in one\n/// fleet (decisions 0037, 0052), its whole list as JSON; no row while it\n/// declares none.\nmodel InstallationDeclaredNetworkRules {\n fleetId String @id @map(\"fleet_id\")\n rules Json\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@map(\"installation_declared_network_rules\")\n}\n\n/// A plugin's namespace (decision 0046): taken up for good by the ship that\n/// declared it, one per ship and unique in the fleet, with its whole list of\n/// scopes and their descriptions as JSON, in order. It goes when its declarer\n/// retires.\nmodel ScopeNamespace {\n fleetId String @map(\"fleet_id\")\n namespace String\n declaredBy String @map(\"declared_by\")\n scopes Json\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n declarer Ship @relation(fields: [fleetId, declaredBy], references: [fleetId, id])\n\n @@id([fleetId, namespace])\n @@unique([fleetId, declaredBy])\n @@map(\"scope_namespaces\")\n}\n\n/// One of the fleet's own scopes (design gateway-scopes, 4.1), with its one-line description.\nmodel DefinedScope {\n fleetId String @map(\"fleet_id\")\n scope String\n description String\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, scope])\n @@map(\"defined_scopes\")\n}\n\n/// One writer's verified facts about a ship (decision 0059): what it checked,\n/// as JSON in the shape common gives, set whole and kept with the ship. The\n/// writer is an actor: a ship or an account by its id, or the installation\n/// by its name, as a commissioning actor is.\nmodel VerifiedFacts {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n writerKind FactWriterKind @map(\"writer_kind\")\n writer String\n facts Json\n writtenAt DateTime @map(\"written_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n\n @@id([fleetId, shipId, writerKind, writer])\n /// A retiring writer finds its facts about every ship.\n @@index([fleetId, writerKind, writer])\n @@map(\"verified_facts\")\n}\n\n/// An alert on a ship (decision 0071): what the watch raised when a fact and\n/// its signal parted, open until the watch clears it or the ship retires.\n/// Ids start with alt_. One per ship, signal and occurrence, open or cleared,\n/// so an occurrence is raised once. facts holds the signal's facts at raise,\n/// as common's schema gives them.\nmodel Alert {\n id String @id\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n signal String\n occurrenceKey String @map(\"occurrence_key\")\n facts Json\n ownerShipId String? @map(\"owner_ship_id\")\n since DateTime @db.Timestamptz(3)\n raisedAt DateTime @map(\"raised_at\") @db.Timestamptz(3)\n clearedAt DateTime? @map(\"cleared_at\") @db.Timestamptz(3)\n clearedWhy String? @map(\"cleared_why\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n\n @@unique([fleetId, shipId, signal, occurrenceKey])\n /// The fleet's open alerts, newest first, a page at a time.\n @@index([fleetId, id(sort: Desc)], map: \"alerts_open_idx\", where: { clearedAt: null })\n /// A ship's open alerts, and how many it has.\n @@index([fleetId, shipId], map: \"alerts_open_on_ship_idx\", where: { clearedAt: null })\n @@map(\"alerts\")\n}\n\n/// The expectations on a ship (decision 0071): what its owner, or a ship\n/// that manages it, expects of it, standing, at most one of each. Each keeps\n/// who set it (JSON, as common's expectation setter) and when; its columns\n/// are null while it is not set. No row while none holds; a retire removes it.\nmodel ShipExpectations {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n reportChangesWithinMinutes Int? @map(\"report_changes_within_minutes\")\n reportChangesWithinSetBy Json? @map(\"report_changes_within_set_by\")\n reportChangesWithinSetAt DateTime? @map(\"report_changes_within_set_at\") @db.Timestamptz(3)\n taskDoneByTask Json? @map(\"task_done_by_task\")\n taskDoneBy DateTime? @map(\"task_done_by\") @db.Timestamptz(3)\n taskDoneBySetBy Json? @map(\"task_done_by_set_by\")\n taskDoneBySetAt DateTime? @map(\"task_done_by_set_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n\n @@id([fleetId, shipId])\n @@map(\"ship_expectations\")\n}\n\n/// A send the network rules refused (decision 0034), recorded in the\n/// transaction that refused it. Ids start with rfs_. Sender and recipient are\n/// as they were then: ids, names and the label values they carried, as JSON,\n/// so a later rename or relabelling keeps the record true. Only argo reads it.\nmodel ReachRefusal {\n id String @id\n fleetId String @map(\"fleet_id\")\n at DateTime @db.Timestamptz(3)\n sender Json\n /// The plugin ship that read on behalf of the sender (decision 0034); null for the sender's own call.\n askedBy Json? @map(\"asked_by\")\n recipient Json\n /// What the sender tried to do: send, read or manage (decision 0034).\n verb String\n settingsVersion Int @map(\"settings_version\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n /// They page newest first by id.\n @@index([fleetId, id])\n @@map(\"reach_refusals\")\n}\n\n/// A ship secret, stored only as its hash. Ids start with crd_.\n/// The hash is unique across all fleets: finding a ship by its secret is one of the\n/// lookups not scoped by fleet (ADR 0007).\nmodel Credential {\n id String @id\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n secretHash String @unique @map(\"secret_hash\")\n issuedAt DateTime @map(\"issued_at\") @db.Timestamptz(3)\n claimedAt DateTime? @map(\"claimed_at\") @db.Timestamptz(3)\n invalidatedAt DateTime? @map(\"invalidated_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n\n /// At most one valid secret per ship.\n @@unique([shipId], map: \"credentials_ship_id_valid_key\", where: { invalidatedAt: null })\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, shipId])\n @@map(\"credentials\")\n}\n\n/// Who a message is for: one ship or any ship of a type. Group and fleet come later.\nenum SelectorKind {\n ship\n type\n meeting\n label\n\n @@map(\"selector_kind\")\n}\n\n/// The messages a fleet stored on one UTC day and their payloads' UTF-8 bytes\n/// (performance design, decision 1). A unit of work adds to it as its last\n/// statements, after the fleet's event numbers, so the row lock is held only\n/// until commit. Storage is the sum of the days; the daily message limit\n/// counts today's row.\n/// A feature flag that is on for a fleet (decision 0069): a row per flag that\n/// is on, none being off. The flag by its key in common's list, as text, so a\n/// new flag needs no migration.\nmodel FleetFeatureFlag {\n fleetId String @map(\"fleet_id\")\n flag String\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, flag])\n @@map(\"fleet_feature_flags\")\n}\n\nmodel MessageDay {\n fleetId String @map(\"fleet_id\")\n day DateTime @db.Date\n messages Int\n payloadBytes BigInt @map(\"payload_bytes\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, day])\n @@map(\"message_days\")\n}\n\n/// An immutable envelope plus an opaque payload of at most 256 KB, sent by one ship.\n/// Ids start with msg_. The selector is stored as resolved at send time: a ship's\n/// id, never its name, or a type. It can name the message it replies to, and a\n/// resend names the message it resends (nothing sets that yet).\nmodel Message {\n id String @id\n fleetId String @map(\"fleet_id\")\n senderShipId String @map(\"sender_ship_id\")\n selectorKind SelectorKind @map(\"selector_kind\")\n selectorShipId String? @map(\"selector_ship_id\")\n selectorType String? @map(\"selector_type\")\n /// The label selection a send to a label was sent to, its value ids as sent (decision 0065); none for any other selector.\n selectorValueIds String[] @default([]) @map(\"selector_value_ids\")\n /// Null in a sealed fleet (decision 0068): the sealed payload is the data key, nonce and ciphertext with its tag,\n /// beside the plain payload's UTF-8 byte count.\n payload String?\n sealedDataKeyId String? @map(\"sealed_data_key_id\")\n sealedNonce Bytes? @map(\"sealed_nonce\")\n sealedCiphertext Bytes? @map(\"sealed_ciphertext\")\n sealedPayloadBytes Int? @map(\"sealed_payload_bytes\")\n /// The question uuid a withdrawal or a replacement names, read at send (decision 0068, B18).\n questionId String? @map(\"question_id\")\n contentType String @map(\"content_type\")\n /// The model the sender's session stated; none from argo and on messages from before models were stated.\n model String?\n idempotencyKey String @map(\"idempotency_key\")\n requestHash String @map(\"request_hash\")\n /// The message it replies to and the one it resends, as written: no foreign\n /// key, so a kept message may name one that is no longer kept (decision 0066).\n inReplyToMessageId String? @map(\"in_reply_to_message_id\")\n resendOfMessageId String? @map(\"resend_of_message_id\")\n /// The meeting it was sent to, or the meeting whose added notice it is (decision 0061).\n meetingId String? @map(\"meeting_id\")\n /// The schedule it was sent for, and that send time; none on a live send (decision 0062).\n scheduleId String? @map(\"schedule_id\")\n sendTime DateTime? @map(\"send_time\") @db.Timestamptz(3)\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n senderShip Ship @relation(\"MessageSender\", fields: [fleetId, senderShipId], references: [fleetId, id], onDelete: Restrict)\n selectorShip Ship? @relation(\"MessageSelectorShip\", fields: [fleetId, selectorShipId], references: [fleetId, id], onDelete: Restrict)\n meeting Meeting? @relation(fields: [fleetId, meetingId], references: [fleetId, id], onDelete: Restrict)\n schedule Schedule? @relation(\"MessageSchedule\", fields: [fleetId, scheduleId], references: [fleetId, id], onDelete: Restrict)\n sealedDataKey DataKey? @relation(fields: [fleetId, sealedDataKeyId], references: [fleetId, id], onDelete: Restrict)\n repliedToBySchedules Schedule[] @relation(\"ScheduleInReplyTo\")\n lastSentBySchedules Schedule[] @relation(\"ScheduleLastMessage\")\n deliveries Delivery[]\n events Event[]\n\n @@unique([fleetId, id])\n /// A sender uses an idempotency key once: a repeat of the same request, told by its\n /// request hash, returns the original message; another request with the key is refused.\n @@unique([fleetId, senderShipId, idempotencyKey])\n /// A ship's current model is its newest message with a model.\n @@index([fleetId, senderShipId, createdAt])\n /// A ship's messages page newest first by id: those it sent and those sent to it.\n @@index([fleetId, senderShipId, id])\n /// The installation counts a fleet's messages of the last 7 days (#1126).\n @@index([fleetId, createdAt])\n /// A question's withdrawals and replacements, found by the question uuid they name (decisions 0038, 0068).\n @@index([fleetId, questionId], map: \"messages_fleet_id_question_id_idx\", where: { questionId: { not: null } })\n /// A data key's sealed messages, for its foreign key.\n @@index([fleetId, sealedDataKeyId])\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, selectorShipId, id])\n @@index([fleetId, inReplyToMessageId])\n @@index([fleetId, resendOfMessageId])\n /// The messages a schedule sent (decision 0062): the foreign key's index (#331).\n @@index([fleetId, scheduleId])\n /// A meeting's contributions page newest first by id (decision 0061).\n @@index([fleetId, meetingId, id])\n @@index([fleetId, selectorShipId, createdAt, id], map: \"messages_pings_idx\", where: raw(\"(content_type = 'application/vnd.aeolus.ping'::text)\"))\n @@map(\"messages\")\n}\n\nenum DeliveryState {\n pending\n received\n handed\n acknowledged\n handled\n notHandled\n undeliverable\n dismissed\n abandoned\n\n @@map(\"delivery_state\")\n}\n\n/// One message to one resolved recipient: a ship or a type. Ids start with dlv_.\n/// A receive hands it to the ship and the lease of the crew receiving, or a push\n/// receive takes it for them: set while it is received or handed, kept once\n/// acknowledged, none while it is pending. Attempts count the hand-overs; the fifth\n/// makes it undeliverable. The hand-over number is the last one the crew reported\n/// with handed (decision 0040), none while pending.\n/// The read date is set when the operator opens a message to argo.\n/// For a type under network rules, the ships of the type its sender may reach,\n/// fixed at send time: only they claim it (decision 0034). Empty: any ship of\n/// the type, as a send no ship of the type may take is refused.\n/// A meeting of ships (decision 0061), id mtg_: one owner and one moderator,\n/// both participants, the opener at first.\nmodel Meeting {\n id String @id\n fleetId String @map(\"fleet_id\")\n title String?\n ownerShipId String @map(\"owner_ship_id\")\n moderatorShipId String @map(\"moderator_ship_id\")\n openedByShipId String @map(\"opened_by_ship_id\")\n idempotencyKey String @map(\"idempotency_key\")\n requestHash String @map(\"request_hash\")\n openedAt DateTime @map(\"opened_at\") @db.Timestamptz(3)\n endedAt DateTime? @map(\"ended_at\") @db.Timestamptz(3)\n /// The participant that holds the mic; none while it is free.\n micHolderShipId String? @map(\"mic_holder_ship_id\")\n micPattern MicPattern @default(moderator) @map(\"mic_pattern\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n micHolder Ship? @relation(\"MeetingMicHolder\", fields: [fleetId, micHolderShipId], references: [fleetId, id], onDelete: Restrict)\n micRequests MeetingMicRequest[]\n owner Ship @relation(\"MeetingOwner\", fields: [fleetId, ownerShipId], references: [fleetId, id], onDelete: Restrict)\n moderator Ship @relation(\"MeetingModerator\", fields: [fleetId, moderatorShipId], references: [fleetId, id], onDelete: Restrict)\n openedBy Ship @relation(\"MeetingOpener\", fields: [fleetId, openedByShipId], references: [fleetId, id], onDelete: Restrict)\n participants MeetingParticipant[]\n messages Message[]\n\n @@unique([fleetId, id])\n /// An opener uses an idempotency key once.\n @@unique([fleetId, openedByShipId, idempotencyKey])\n /// Every foreign key has an index leading with its columns (#331).\n @@index([fleetId, ownerShipId])\n @@index([fleetId, moderatorShipId])\n @@index([fleetId, micHolderShipId])\n @@map(\"meetings\")\n}\n\n/// How a meeting's free mic passes (decision 0061, M9): the moderator's pick, or the oldest request.\n/// A ship's scheduled message (decision 0062): its send input as given, its timing and\n/// refusal strategy, its state, next send time and attempt, and its last outcome.\nmodel Schedule {\n id String @id\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n /// The selector as the creator gave it: a ship by id or by name, a type, or a label selection by value ids; never a meeting.\n selectorKind SelectorKind @map(\"selector_kind\")\n selectorShipId String? @map(\"selector_ship_id\")\n selectorShipName String? @map(\"selector_ship_name\")\n selectorType String? @map(\"selector_type\")\n selectorValueIds String[] @default([]) @map(\"selector_value_ids\")\n /// Null in a sealed fleet (decision 0068): the sealed payload is the data key, nonce and ciphertext with its tag,\n /// beside the plain payload's UTF-8 byte count, as a message's.\n payload String?\n sealedDataKeyId String? @map(\"sealed_data_key_id\")\n sealedNonce Bytes? @map(\"sealed_nonce\")\n sealedCiphertext Bytes? @map(\"sealed_ciphertext\")\n sealedPayloadBytes Int? @map(\"sealed_payload_bytes\")\n contentType String @map(\"content_type\")\n model String?\n inReplyToMessageId String? @map(\"in_reply_to_message_id\")\n isForced Boolean @map(\"is_forced\")\n timingKind ScheduleTimingKind @map(\"timing_kind\")\n /// The timing: once an instant; every a duration, or a cron and its zone, each from a start to an end or a count of sends.\n onceAt DateTime? @map(\"once_at\") @db.Timestamptz(3)\n every String?\n cron String?\n timeZone String? @map(\"time_zone\")\n start DateTime? @db.Timestamptz(3)\n end DateTime? @db.Timestamptz(3)\n count Int?\n onRefused RefusalStrategy @map(\"on_refused\")\n retryWindow String @map(\"retry_window\")\n onMissed MissedStrategy @map(\"on_missed\")\n grace String\n idempotencyKey String @map(\"idempotency_key\")\n requestHash String @map(\"request_hash\")\n state ScheduleState\n nextSendTime DateTime? @map(\"next_send_time\") @db.Timestamptz(3)\n nextAttemptAt DateTime? @map(\"next_attempt_at\") @db.Timestamptz(3)\n lastOutcomeKind ScheduleOutcomeKind? @map(\"last_outcome_kind\")\n lastMessageId String? @map(\"last_message_id\")\n lastRefusalCode String? @map(\"last_refusal_code\")\n lastSendTime DateTime? @map(\"last_send_time\") @db.Timestamptz(3)\n lastOutcomeAt DateTime? @map(\"last_outcome_at\") @db.Timestamptz(3)\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n endedAt DateTime? @map(\"ended_at\") @db.Timestamptz(3)\n cancelledAt DateTime? @map(\"cancelled_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(\"ScheduleShip\", fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n selectorShip Ship? @relation(\"ScheduleSelectorShip\", fields: [fleetId, selectorShipId], references: [fleetId, id], onDelete: Restrict)\n inReplyTo Message? @relation(\"ScheduleInReplyTo\", fields: [fleetId, inReplyToMessageId], references: [fleetId, id], onDelete: Restrict)\n sealedDataKey DataKey? @relation(fields: [fleetId, sealedDataKeyId], references: [fleetId, id], onDelete: Restrict)\n lastMessage Message? @relation(\"ScheduleLastMessage\", fields: [fleetId, lastMessageId], references: [fleetId, id], onDelete: Restrict)\n messages Message[] @relation(\"MessageSchedule\")\n\n @@unique([fleetId, id])\n /// A ship uses an idempotency key once for its schedules.\n @@unique([fleetId, shipId, idempotencyKey])\n /// A ship's schedules page newest first by id.\n @@index([fleetId, shipId, id])\n /// The claim of the active schedules that are due, earliest attempt first.\n @@index([fleetId, nextAttemptAt, id], map: \"schedules_due_idx\", where: raw(\"(state = 'active'::schedule_state)\"))\n /// Every foreign key has an index leading with its columns (#331).\n @@index([fleetId, selectorShipId])\n @@index([fleetId, inReplyToMessageId])\n @@index([fleetId, lastMessageId])\n @@index([fleetId, sealedDataKeyId])\n @@map(\"schedules\")\n}\n\nenum ScheduleState {\n active\n paused\n ended\n cancelled\n\n @@map(\"schedule_state\")\n}\n\nenum ScheduleTimingKind {\n once\n every\n cron\n\n @@map(\"schedule_timing_kind\")\n}\n\nenum RefusalStrategy {\n skip\n retry\n pause\n\n @@map(\"refusal_strategy\")\n}\n\nenum MissedStrategy {\n each\n once\n skip\n\n @@map(\"missed_strategy\")\n}\n\nenum ScheduleOutcomeKind {\n sent\n refused\n missed\n\n @@map(\"schedule_outcome_kind\")\n}\n\nenum MicPattern {\n moderator\n fifo\n\n @@map(\"mic_pattern\")\n}\n\n/// A participant waiting for the mic of its meeting, since its time (decision 0061, M8): once per meeting.\nmodel MeetingMicRequest {\n fleetId String @map(\"fleet_id\")\n meetingId String @map(\"meeting_id\")\n shipId String @map(\"ship_id\")\n requestedAt DateTime @map(\"requested_at\") @db.Timestamptz(3)\n /// Its place on the list, the oldest request's 0.\n place Int\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n meeting Meeting @relation(fields: [fleetId, meetingId], references: [fleetId, id], onDelete: Restrict)\n participant MeetingParticipant @relation(fields: [fleetId, meetingId, shipId], references: [fleetId, meetingId, shipId], onDelete: Restrict)\n\n @@id([fleetId, meetingId, shipId])\n @@map(\"meeting_mic_requests\")\n}\n\n/// A ship in a meeting and when it joined (decision 0061): once per meeting.\nmodel MeetingParticipant {\n fleetId String @map(\"fleet_id\")\n meetingId String @map(\"meeting_id\")\n shipId String @map(\"ship_id\")\n joinedAt DateTime @map(\"joined_at\") @db.Timestamptz(3)\n /// Its place in the order the meeting's ships joined, the opener's 0.\n place Int\n /// When it left or was revoked; none while it is present (decision 0061, M13).\n leftAt DateTime? @map(\"left_at\") @db.Timestamptz(3)\n /// Whether the owner revoked its right to rejoin.\n isRevoked Boolean @default(false) @map(\"is_revoked\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n meeting Meeting @relation(fields: [fleetId, meetingId], references: [fleetId, id], onDelete: Restrict)\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n micRequest MeetingMicRequest?\n\n @@id([fleetId, meetingId, shipId])\n /// A ship's meetings, and a retire checking them.\n @@index([fleetId, shipId])\n @@map(\"meeting_participants\")\n}\n\nmodel Delivery {\n id String @id\n fleetId String @map(\"fleet_id\")\n messageId String @map(\"message_id\")\n recipientShipId String? @map(\"recipient_ship_id\")\n recipientType String? @map(\"recipient_type\")\n state DeliveryState @default(pending)\n claimedByShipId String? @map(\"claimed_by_ship_id\")\n claimedByLeaseId String? @map(\"claimed_by_lease_id\")\n attempts Int @default(0)\n handOverNumber Int? @map(\"hand_over_number\")\n /// When its crew handed it once more after the turn that took it died; only once (decision 0040).\n handedOnceMoreAt DateTime? @map(\"handed_once_more_at\") @db.Timestamptz(3)\n /// Whether its message was forced: it comes first in receive and push receive (decision 0040).\n isForced Boolean @default(false) @map(\"is_forced\")\n reachableShipIds String[] @default([]) @map(\"reachable_ship_ids\")\n readAt DateTime? @map(\"read_at\") @db.Timestamptz(3)\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n message Message @relation(fields: [fleetId, messageId], references: [fleetId, id])\n recipientShip Ship? @relation(\"DeliveryRecipientShip\", fields: [fleetId, recipientShipId], references: [fleetId, id], onDelete: Restrict)\n claimedByShip Ship? @relation(\"DeliveryClaimedByShip\", fields: [fleetId, claimedByShipId], references: [fleetId, id], onDelete: Restrict)\n claimedByLease Lease? @relation(fields: [fleetId, claimedByLeaseId], references: [fleetId, id], onDelete: Restrict)\n events Event[]\n overdue OverdueDelivery[]\n\n @@unique([fleetId, id])\n /// One row per recipient.\n @@unique([messageId, recipientShipId])\n @@unique([messageId, recipientType])\n @@index([fleetId, recipientShipId, state])\n /// A ship's inbox pages newest first by id.\n @@index([fleetId, recipientShipId, id])\n @@index([fleetId, recipientType, state])\n /// The installation's health figures scan a fleet's open deliveries by state (decision 0041). Partial, so a foreign key check never picks it.\n @@index([fleetId, state, createdAt], map: \"deliveries_open_fleet_id_state_created_at_idx\", where: raw(\"(state = ANY (ARRAY['pending'::delivery_state, 'received'::delivery_state, 'handed'::delivery_state, 'undeliverable'::delivery_state, 'notHandled'::delivery_state]))\"))\n /// A crew's own deliveries in flight, which its next receive returns first.\n @@index([fleetId, claimedByLeaseId, state])\n /// A ship's record pages the deliveries of its type it claimed newest first by id (Bridge, CC12). Partial, so a foreign key check never picks it.\n @@index([fleetId, claimedByShipId, id], map: \"deliveries_record_fleet_id_claimed_by_ship_id_id_idx\", where: raw(\"(recipient_type IS NOT NULL)\"))\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, messageId, id])\n @@index([fleetId, claimedByShipId])\n @@map(\"deliveries\")\n}\n\n/// Which of the 10 and 60 minute clocks ran out (decision 0040).\nenum OverdueClock {\n notConfirmed\n idle\n busy\n\n @@map(\"overdue_clock\")\n}\n\n/// A delivery argo was told is overdue on a pushed lease: its clock ran out\n/// while it waited in the state kept here. Once per lease and delivery, so a\n/// pass after a restart, or a second pass at once, tells nothing again.\nmodel OverdueDelivery {\n fleetId String @map(\"fleet_id\")\n leaseId String @map(\"lease_id\")\n deliveryId String @map(\"delivery_id\")\n shipId String @map(\"ship_id\")\n state DeliveryState\n clock OverdueClock\n minutes Int\n toldAt DateTime @map(\"told_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n lease Lease @relation(fields: [fleetId, leaseId], references: [fleetId, id], onDelete: Restrict)\n delivery Delivery @relation(fields: [fleetId, deliveryId], references: [fleetId, id], onDelete: Restrict)\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n\n @@id([fleetId, leaseId, deliveryId])\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, deliveryId])\n @@index([fleetId, shipId])\n @@map(\"overdue_deliveries\")\n}\n\n/// The stuck snapshot (docs/design/performance/performance.md, section 5):\n/// one row per fleet and closed hour, written once by the 30 second pass and\n/// kept for 168 hours. Its counts are by message parties, so a read counts\n/// only what its caller reads (decision 0034).\nmodel HealthSnapshot {\n fleetId String @map(\"fleet_id\")\n hour DateTime @db.Timestamptz(3)\n /// The last event folded into it, by its seq.\n seq BigInt\n /// Stuck at the hour mark: cause, place, message parties, count and oldest since, each.\n stuck Json\n /// The waits from send to acknowledgement in the hour, by message parties, as counts per duration bucket.\n acknowledged Json\n /// The same waits summed over every message, as a reader of every ship reads them.\n acknowledgedWaits Json @map(\"acknowledged_waits\")\n /// Each lease's latest turn as of seq; the latest row's is the fold's.\n turns Json\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, hour])\n @@map(\"health_snapshots\")\n}\n\n/// The fleet's open deliveries as of its latest snapshot, each at its latest\n/// step: replaced whole by each close. A copy for the fold, so no foreign key\n/// but the fleet's.\nmodel HealthSnapshotDelivery {\n fleetId String @map(\"fleet_id\")\n deliveryId String @map(\"delivery_id\")\n messageId String @map(\"message_id\")\n senderShipId String @map(\"sender_ship_id\")\n recipientShipId String? @map(\"recipient_ship_id\")\n recipientType String? @map(\"recipient_type\")\n claimedByShipId String? @map(\"claimed_by_ship_id\")\n reachableShipIds String[] @map(\"reachable_ship_ids\")\n sentAt DateTime @map(\"sent_at\") @db.Timestamptz(3)\n /// Its latest step: the state, since when, and the ship and lease that took it; none while pending since its send.\n state DeliveryState?\n since DateTime? @db.Timestamptz(3)\n stepShipId String? @map(\"step_ship_id\")\n leaseId String? @map(\"lease_id\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, deliveryId])\n @@map(\"health_snapshot_deliveries\")\n}\n\n/// Append-only log of every state change: never updated or deleted. Ids start with evt_.\n/// Records its type and time, who caused it (a ship, or the system when\n/// actor_ship_id is null), the ship, message and delivery it concerns, and a few\n/// details as a flat JSON object.\nmodel Event {\n id String @id\n fleetId String @map(\"fleet_id\")\n type String\n occurredAt DateTime @map(\"occurred_at\") @db.Timestamptz(3)\n /// Who caused it (decision 0057): a ship, an account, the installation or the system.\n actorKind EventActorKind @default(system) @map(\"actor_kind\")\n actorShipId String? @map(\"actor_ship_id\")\n /// The account that caused it, by pagasae's id only: never an email.\n actorAccountId String? @map(\"actor_account_id\")\n /// The ship that presented the account's token, a plugin's page or the gateway, if one did.\n actorThroughShipId String? @map(\"actor_through_ship_id\")\n /// The account signed in to the console as argo when argo caused it, by its id only (decision 0054).\n actorSignedInAccountId String? @map(\"actor_signed_in_account_id\")\n shipId String? @map(\"ship_id\")\n messageId String? @map(\"message_id\")\n deliveryId String? @map(\"delivery_id\")\n details Json\n /// The event's place in its fleet's stream, in commit order and without\n /// gaps: where a live subscription resumes. The id is not, since ids are\n /// taken before their transaction commits.\n seq BigInt\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n actorShip Ship? @relation(\"EventActorShip\", fields: [fleetId, actorShipId], references: [fleetId, id], onDelete: Restrict)\n actorThroughShip Ship? @relation(\"EventActorThroughShip\", fields: [fleetId, actorThroughShipId], references: [fleetId, id], onDelete: Restrict)\n ship Ship? @relation(\"EventShip\", fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n message Message? @relation(fields: [fleetId, messageId], references: [fleetId, id], onDelete: Restrict)\n delivery Delivery? @relation(fields: [fleetId, deliveryId], references: [fleetId, id], onDelete: Restrict)\n\n @@unique([fleetId, seq])\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n /// A ship's timeline pages through the events it caused and those naming\n /// it by their place in the stream, each through its own index.\n @@index([fleetId, actorShipId, seq])\n @@index([actorThroughShipId, fleetId])\n @@index([fleetId, shipId, seq])\n @@index([fleetId, messageId])\n @@index([fleetId, deliveryId])\n /// The health reads take a fleet's events since a time (decision 0042).\n @@index([fleetId, occurredAt])\n @@index([fleetId, shipId, seq], map: \"events_starting_prompt_issued_idx\", where: raw(\"(type = 'StartingPromptIssued'::text)\"))\n /// A ship's messages page through those it claimed as a ship of their type by id.\n @@index([fleetId, shipId, messageId], map: \"events_delivery_handed_idx\", where: raw(\"(type = 'DeliveryHanded'::text)\"))\n /// A first stuck snapshot reads each lease's turn at its oldest hour from the turn reports alone.\n @@index([fleetId, occurredAt], map: \"events_turn_reported_idx\", where: raw(\"(type = 'TurnReported'::text)\"))\n /// The pruning pass finds the mic and participant events of ended meetings (decision 0066).\n @@index([fleetId, seq], map: \"events_meeting_parts_idx\", where: raw(\"(type = ANY (ARRAY['ParticipantAdded'::text, 'ParticipantLeft'::text, 'ParticipantRejoined'::text, 'ParticipantRevoked'::text, 'MicRequested'::text, 'MicRequestWithdrawn'::text, 'MicGiven'::text, 'MicReleased'::text, 'MicTaken'::text, 'MicPatternSet'::text]))\"))\n /// The pruning pass finds a crew's session and secret events past the cutoff (decision 0066).\n @@index([fleetId, occurredAt], map: \"events_crew_idx\", where: raw(\"(type = ANY (ARRAY['ShipClaimed'::text, 'LeaseRevoked'::text, 'LeasePushed'::text, 'ShipReported'::text, 'TurnReported'::text, 'StatementSet'::text, 'CrewStatusChanged'::text, 'SignInTicketIssued'::text, 'ViewerSessionStarted'::text, 'StartingPromptIssued'::text, 'CredentialRevoked'::text]))\"))\n @@map(\"events\")\n}\n\n/// Why a console session ended: a sign-in elsewhere took argo over, the\n/// operator signed out, or the password was reset.\nenum ConsoleSessionEndReason {\n takenOver\n signedOut\n passwordReset\n accountCutOff\n\n @@map(\"console_session_end_reason\")\n}\n\n/// argo's own sign-in: email and Argon2id password hash. fleet:init creates it\n/// with neither, until argo sets both in Settings; a hosting installation\n/// creates it with an email and no password. Ids start with opr_.\n/// The email is unique across all fleets: finding the account by email is the one\n/// lookup not scoped by fleet (ADR 0007). One account per fleet in v1.\nmodel Operator {\n id String @id\n fleetId String @unique @map(\"fleet_id\")\n email String? @unique\n passwordHash String? @map(\"password_hash\")\n /// How the console looks for this operator; system until they choose.\n theme Theme @default(system)\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@map(\"operators\")\n}\n\nenum Theme {\n light\n dark\n system\n\n @@map(\"theme\")\n}\n\n/// The operator crewing argo through the web console. Ids start with ses_.\n/// Only the hash of the session token is stored, unique across all fleets: finding\n/// a session by its token is the one lookup not scoped by fleet (ADR 0007).\n/// Valid until expires_at, which moves to idle_limit_seconds after each use\n/// (30 days for the operator, 2 hours for a viewer), never past ends_by.\nmodel ConsoleSession {\n id String @id\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n /// The lease on argo it holds; null for a viewer session (decision 0022).\n leaseId String? @map(\"lease_id\")\n idleLimitSeconds Int @map(\"idle_limit_seconds\")\n /// No use renews it past this; null when only idleness ends it.\n endsBy DateTime? @map(\"ends_by\") @db.Timestamptz(3)\n /// The device it signed in from, as the browser told: \"Mac · Chrome\".\n device String @default(\"Unknown device\")\n /// The account that signed in as argo, by its id only; null for argo's own sign-in and a viewer (decision 0054).\n accountId String? @map(\"account_id\")\n tokenHash String @unique @map(\"token_hash\")\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n lastUsedAt DateTime @map(\"last_used_at\") @db.Timestamptz(3)\n expiresAt DateTime @map(\"expires_at\") @db.Timestamptz(3)\n endedAt DateTime? @map(\"ended_at\") @db.Timestamptz(3)\n /// Why the session ended; null while it has not.\n endReason ConsoleSessionEndReason? @map(\"end_reason\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(fields: [fleetId, shipId], references: [fleetId, id])\n lease Lease? @relation(fields: [fleetId, leaseId], references: [fleetId, id])\n\n noticeDismissals NoticeDismissal[]\n guideProgress GuideProgress[]\n\n /// At most one live session holding argo's lease per fleet: signing in ends the previous one. Viewer sessions run beside it.\n @@unique([fleetId], map: \"console_sessions_fleet_id_open_key\", where: raw(\"ended_at IS NULL AND lease_id IS NOT NULL\"))\n /// Every foreign key has an index leading with its columns, so deleting a\n /// referenced row checks it with an index, not a scan (#331).\n @@index([fleetId, shipId])\n @@index([fleetId, leaseId])\n @@map(\"console_sessions\")\n}\n\n/// A one-time sign-in ticket for the fleet's operator, issued by a hosting\n/// installation and redeemed in the console (decision 0020). Only its hash is\n/// stored, unique across all fleets: redeeming finds it before the fleet is known.\nmodel SignInTicket {\n tokenHash String @id @map(\"token_hash\")\n fleetId String @map(\"fleet_id\")\n /// Whom it signs in as: the operator or a viewer (decision 0022).\n signInAs SignInAs @map(\"sign_in_as\")\n /// The account it signs in as argo, by its id only; null for argo's own or a viewer's ticket (decision 0054).\n accountId String? @map(\"account_id\")\n issuedAt DateTime @map(\"issued_at\") @db.Timestamptz(3)\n expiresAt DateTime @map(\"expires_at\") @db.Timestamptz(3)\n /// When it signed in; null while unused.\n usedAt DateTime? @map(\"used_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@index([fleetId])\n @@map(\"sign_in_tickets\")\n}\n\nenum SignInAs {\n operator\n viewer\n\n @@map(\"sign_in_as\")\n}\n\n/// The installation's settings (decision 0020): the default ship, daily message,\n/// schedules per ship and minimum schedule interval (seconds) limits and the\n/// default retention in days (decision 0066) for fleets, and the cap on fleets,\n/// each null for none. One row at most, and none until the installation sets\n/// them. Belongs to no fleet.\nmodel InstallationSettings {\n id Int @id @default(1)\n defaultShipLimit Int? @map(\"default_ship_limit\")\n defaultDailyMessageLimit Int? @map(\"default_daily_message_limit\")\n defaultSchedulesPerShipLimit Int? @map(\"default_schedules_per_ship_limit\")\n defaultMinimumScheduleInterval Int? @map(\"default_minimum_schedule_interval\")\n defaultRetentionDays Int? @map(\"default_retention_days\")\n fleetCap Int? @map(\"fleet_cap\")\n\n @@map(\"installation_settings\")\n}\n\nenum InstallationRequestKind {\n createFleet @map(\"create_fleet\")\n deleteFleet @map(\"delete_fleet\")\n\n @@map(\"installation_request_kind\")\n}\n\n/// A create or delete of a fleet the installation carried out, under its caller's\n/// request id, so a replay answers the same (decision 0020). It belongs to the\n/// installation, not to a fleet, and keeps the request as a hash only. A create's\n/// row names the fleet and argo it answers with and is deleted with that fleet; a\n/// delete's row names nothing of the fleet.\nmodel InstallationRequest {\n requestId String @id @map(\"request_id\")\n kind InstallationRequestKind\n requestHash String @map(\"request_hash\")\n /// The created fleet and its argo; null for a delete.\n fleetId String? @map(\"fleet_id\")\n operatorShipId String? @map(\"operator_ship_id\")\n at DateTime @db.Timestamptz(3)\n\n @@index([fleetId])\n @@map(\"installation_requests\")\n}\n\n/// A console notice the installation sets (decision 0023), shown above every\n/// page to the sessions of its audience. It belongs to no fleet.\nmodel Notice {\n id String @id\n /// Its place in the installation's order.\n position Int\n audience NoticeAudience\n text String\n /// Its links: label, and url, isSignOut or both.\n links Json @default(\"[]\")\n isDismissible Boolean @default(false) @map(\"is_dismissible\")\n\n @@map(\"notices\")\n}\n\nenum NoticeAudience {\n everyone\n operators\n viewers\n accounts\n\n @@map(\"notice_audience\")\n}\n\n/// A notice a console session dismissed, for itself (decision 0023). It goes\n/// with its session and its fleet.\nmodel NoticeDismissal {\n fleetId String @map(\"fleet_id\")\n consoleSessionId String @map(\"console_session_id\")\n noticeId String @map(\"notice_id\")\n dismissedAt DateTime @map(\"dismissed_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n consoleSession ConsoleSession @relation(fields: [consoleSessionId], references: [id])\n\n @@id([consoleSessionId, noticeId])\n @@index([fleetId])\n @@map(\"notice_dismissals\")\n}\n\n/// A notice an account signed in to the console as itself dismissed, for\n/// itself, kept by its account id in each fleet (accounts design, A9). Core\n/// stores no account: the id is pagasae's. It goes with its fleet.\nmodel AccountNoticeDismissal {\n fleetId String @map(\"fleet_id\")\n accountId String @map(\"account_id\")\n noticeId String @map(\"notice_id\")\n dismissedAt DateTime @map(\"dismissed_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, accountId, noticeId])\n @@map(\"account_notice_dismissals\")\n}\n\n/// The installation's guide (decision 0024): steps for the console sessions of\n/// one audience. At most one row; it belongs to no fleet.\nmodel Guide {\n /// Always \"guide\": the installation has one guide or none.\n id String @id\n audience NoticeAudience\n /// Its steps, in order: path, anchor (optional), title and text.\n steps Json\n\n @@map(\"guides\")\n}\n\nenum GuideProgressState {\n open\n skipped\n finished\n\n @@map(\"guide_progress_state\")\n}\n\n/// Where a console session is in the guide, for itself (decision 0024). It\n/// goes with its session and its fleet.\nmodel GuideProgress {\n fleetId String @map(\"fleet_id\")\n consoleSessionId String @id @map(\"console_session_id\")\n step Int\n state GuideProgressState\n recordedAt DateTime @map(\"recorded_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n consoleSession ConsoleSession @relation(fields: [consoleSessionId], references: [id])\n\n @@index([fleetId])\n @@map(\"guide_progress\")\n}\n\n/// Where an account signed in to the console as itself is in the guide, kept\n/// by its account id in each fleet (accounts design, A9). It goes with its fleet.\nmodel AccountGuideProgress {\n fleetId String @map(\"fleet_id\")\n accountId String @map(\"account_id\")\n step Int\n state GuideProgressState\n recordedAt DateTime @map(\"recorded_at\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n\n @@id([fleetId, accountId])\n @@map(\"account_guide_progress\")\n}\n\n/// An account pagasae cut off (decision 0058): its tokens issued before\n/// cut_off_at are refused in every fleet until forget_at, when the longest of\n/// them has ended. The installation's, not a fleet's: no fleet_id (ADR 0007).\n/// Never an email: the account by pagasae's id only.\nmodel AccountCutOff {\n accountId String @id @map(\"account_id\")\n cutOffAt DateTime @map(\"cut_off_at\") @db.Timestamptz(3)\n forgetAt DateTime @map(\"forget_at\") @db.Timestamptz(3)\n\n /// Forgetting finds the cut-offs that ended.\n @@index([forgetAt])\n @@map(\"account_cut_offs\")\n}\n\n/// Who caused an event (decision 0057).\nenum EventActorKind {\n ship\n account\n installation\n system\n\n @@map(\"event_actor_kind\")\n}\n\n/// Who commissioned a ship (decision 0057).\n/// Who wrote a verified fact (decision 0059).\nenum FactWriterKind {\n ship\n account\n installation\n\n @@map(\"fact_writer_kind\")\n}\n\nenum CommissionerKind {\n ship\n account\n installation\n\n @@map(\"commissioner_kind\")\n}\n\nenum LabelOwnerKind {\n ship\n installation\n\n @@map(\"label_owner_kind\")\n}\n\n/// A sealed fleet's data key (decision 0068): kept only wrapped, by the company key and by the recovery key\n/// when set, with a check value (HMAC-SHA-256 of a fixed text under the key) that proves an unwrap gave\n/// the right key. Never unwrapped in the database. Old keys stay to unseal old payloads.\nmodel DataKey {\n id String @id\n fleetId String @map(\"fleet_id\")\n wrappedByCompanyKey Bytes @map(\"wrapped_by_company_key\")\n wrappedByRecoveryKey Bytes? @map(\"wrapped_by_recovery_key\")\n checkValue Bytes @map(\"check_value\")\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n isCurrent Boolean @map(\"is_current\")\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n messages Message[]\n schedules Schedule[]\n\n @@unique([fleetId, id])\n /// One current data key per fleet.\n @@unique([fleetId], map: \"data_keys_fleet_id_current_key\", where: { isCurrent: true })\n @@map(\"data_keys\")\n}\n",
|
|
21
21
|
"runtimeDataModel": {
|
|
22
22
|
"models": {},
|
|
23
23
|
"enums": {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../../src/adapters/prisma/generated/internal/class.ts"],"names":[],"mappings":"AACA,qEAAqE;AACrE,oBAAoB;AACpB,wCAAwC;AACxC,eAAe;AACf;;;;;;GAMG;AAEH,OAAO,KAAK,OAAO,MAAM,+BAA+B,CAAA;AAIxD,MAAM,MAAM,GAAkC;IAC5C,iBAAiB,EAAE;QACjB,gBAAgB;KACjB;IACD,eAAe,EAAE,QAAQ;IACzB,eAAe,EAAE,0CAA0C;IAC3D,gBAAgB,EAAE,YAAY;IAC9B,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../../src/adapters/prisma/generated/internal/class.ts"],"names":[],"mappings":"AACA,qEAAqE;AACrE,oBAAoB;AACpB,wCAAwC;AACxC,eAAe;AACf;;;;;;GAMG;AAEH,OAAO,KAAK,OAAO,MAAM,+BAA+B,CAAA;AAIxD,MAAM,MAAM,GAAkC;IAC5C,iBAAiB,EAAE;QACjB,gBAAgB;KACjB;IACD,eAAe,EAAE,QAAQ;IACzB,eAAe,EAAE,0CAA0C;IAC3D,gBAAgB,EAAE,YAAY;IAC9B,cAAc,EAAE,kxwEAAkxwE;IAClywE,kBAAkB,EAAE;QAClB,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;KACZ;IACD,wBAAwB,EAAE;QACxB,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,EAAE;KACZ;CACF,CAAA;AAED,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,y4yDAAy4yD,CAAC,CAAA;AAC/6yD,MAAM,CAAC,sBAAsB,GAAG;IAC9B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,u14BAAu14B,CAAC;IAC524B,KAAK,EAAE,09xVAA09xV;CACl+xV,CAAA;AAED,KAAK,UAAU,kBAAkB,CAAC,UAAkB;IAClD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAC9C,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACnD,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AAC1C,CAAC;AAED,MAAM,CAAC,YAAY,GAAG;IACpB,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,MAAM,CAAC,8DAA8D,CAAC;IAEpG,0BAA0B,EAAE,KAAK,IAAI,EAAE;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,0EAA0E,CAAC,CAAA;QACzG,OAAO,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC;IAED,UAAU,EAAE,6BAA6B;CAC1C,CAAA;AA0kBD,MAAM,UAAU,oBAAoB;IAClC,OAAO,OAAO,CAAC,eAAe,CAAC,MAAM,CAAuC,CAAA;AAC9E,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PING_CONTENT_TYPE } from '@aeolus-fleet/common';
|
|
2
|
+
import { Prisma } from './generated/client.js';
|
|
2
3
|
import { payloadColumnsOf, toDeliveryFromSql, toMessage } from './rows.js';
|
|
3
4
|
import { plainBytesOf } from '../../domain/messaging/sealed-payload.js';
|
|
5
|
+
import { pageOf } from '../../domain/shared/page.js';
|
|
4
6
|
/**
|
|
5
7
|
* Messages on Postgres. Each message stored is counted on its fleet's row for
|
|
6
8
|
* the UTC day it was stored (performance design, decision 1), in the same
|
|
@@ -156,6 +158,43 @@ export function createPrismaDeliveryRepository(db) {
|
|
|
156
158
|
return { delivery, message };
|
|
157
159
|
});
|
|
158
160
|
},
|
|
161
|
+
findRecordPage: async ({ fleetId, shipId, cursor, limit }) => {
|
|
162
|
+
// Two halves, each read newest first along its own index and cut at one
|
|
163
|
+
// past the page: the deliveries to the ship (fleet_id, recipient_ship_id,
|
|
164
|
+
// id), and those of its type it claimed (the partial record index). A
|
|
165
|
+
// delivery is in one half only, so the merged page holds no repeat.
|
|
166
|
+
const after = cursor === undefined ? Prisma.empty : Prisma.sql `AND id < ${cursor}`;
|
|
167
|
+
const rows = await db.$queryRaw `
|
|
168
|
+
SELECT * FROM (
|
|
169
|
+
(SELECT id, fleet_id, message_id, recipient_ship_id, recipient_type, state::text AS state,
|
|
170
|
+
claimed_by_ship_id, claimed_by_lease_id, attempts, hand_over_number, handed_once_more_at, is_forced, created_at
|
|
171
|
+
FROM deliveries
|
|
172
|
+
WHERE fleet_id = ${fleetId} AND recipient_ship_id = ${shipId} ${after}
|
|
173
|
+
ORDER BY id DESC
|
|
174
|
+
LIMIT ${limit + 1})
|
|
175
|
+
UNION ALL
|
|
176
|
+
(SELECT id, fleet_id, message_id, recipient_ship_id, recipient_type, state::text AS state,
|
|
177
|
+
claimed_by_ship_id, claimed_by_lease_id, attempts, hand_over_number, handed_once_more_at, is_forced, created_at
|
|
178
|
+
FROM deliveries
|
|
179
|
+
WHERE fleet_id = ${fleetId} AND claimed_by_ship_id = ${shipId} AND recipient_type IS NOT NULL ${after}
|
|
180
|
+
ORDER BY id DESC
|
|
181
|
+
LIMIT ${limit + 1})
|
|
182
|
+
) AS record
|
|
183
|
+
ORDER BY id DESC
|
|
184
|
+
LIMIT ${limit + 1}`;
|
|
185
|
+
const deliveries = rows.map(toDeliveryFromSql);
|
|
186
|
+
const messages = await db.message.findMany({ where: { fleetId, id: { in: deliveries.map((delivery) => delivery.messageId) } } });
|
|
187
|
+
const byId = new Map(messages.map((row) => [row.id, toMessage(row)]));
|
|
188
|
+
const recorded = deliveries.map((delivery) => {
|
|
189
|
+
const message = byId.get(delivery.messageId);
|
|
190
|
+
if (!message) {
|
|
191
|
+
// The foreign key keeps every delivery's message in its fleet.
|
|
192
|
+
throw new Error(`Delivery ${delivery.id} has no message ${delivery.messageId}`);
|
|
193
|
+
}
|
|
194
|
+
return { delivery, message };
|
|
195
|
+
});
|
|
196
|
+
return pageOf(recorded, { limit, cursorOf: (row) => row.delivery.id });
|
|
197
|
+
},
|
|
159
198
|
findForUpdate: async (fleetId, deliveryId) => {
|
|
160
199
|
const [row] = await db.$queryRaw `
|
|
161
200
|
SELECT id, fleet_id, message_id, recipient_ship_id, recipient_type, state::text AS state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messaging.js","sourceRoot":"","sources":["../../../src/adapters/prisma/messaging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAgB,MAAM,sBAAsB,CAAC;AAIvE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAexE;;;;;;GAMG;AACH,MAAM,UAAU,6BAA6B,CAAC,EAAM;IAClD,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,OAAO;QACL,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAChC,wGAAwG;YACxG,MAAM,EAAE,CAAC,WAAW,CAAA,qEAAqE,OAAO,IAAI,CAAC;QACvG,CAAC;QACD,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;YACpC,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YACrH,OAAO,GAAG,EAAE,QAAQ,IAAI,CAAC,CAAC;QAC5B,CAAC;QACD,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,KAAK,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC5E,MAAM,EAAE,CAAC,WAAW,CAAA;;oBAER,OAAO,KAAK,GAAG,WAAW,QAAQ,KAAK,YAAY;;wIAEiE,CAAC;YACnI,CAAC;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,CAAC;QAC3G,CAAC;QACD,UAAU,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE;YAC5C,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/F,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -18,6 +18,7 @@ import type { MarkDone } from '../../domain/messaging/mark-done.js';
|
|
|
18
18
|
import type { MarkRead } from '../../domain/messaging/mark-read.js';
|
|
19
19
|
import type { HandOverDelivery } from '../../domain/messaging/hand-over-delivery.js';
|
|
20
20
|
import type { ReadDelivery } from '../../domain/messaging/read-delivery.js';
|
|
21
|
+
import type { ReadRecord } from '../../domain/messaging/read-record.js';
|
|
21
22
|
import type { ReportHandled } from '../../domain/messaging/report-handled.js';
|
|
22
23
|
import type { ReportNotHandled } from '../../domain/messaging/report-not-handled.js';
|
|
23
24
|
import type { PushReceiveDeliveries } from '../../domain/messaging/push-receive-deliveries.js';
|
|
@@ -263,6 +264,7 @@ export interface UseCases {
|
|
|
263
264
|
handOverDelivery: HandOverDelivery;
|
|
264
265
|
reportHandled: ReportHandled;
|
|
265
266
|
readDelivery: ReadDelivery;
|
|
267
|
+
readRecord: ReadRecord;
|
|
266
268
|
reportNotHandled: ReportNotHandled;
|
|
267
269
|
acknowledgeDelivery: AcknowledgeDelivery;
|
|
268
270
|
answerPing: AnswerPing;
|
|
@@ -4190,6 +4190,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4190
4190
|
max?: number | undefined;
|
|
4191
4191
|
waker?: "trierarch" | "gateway" | "pluginWatcher" | "personApp" | "adapter" | undefined;
|
|
4192
4192
|
shouldSkipHanded?: boolean | undefined;
|
|
4193
|
+
excluding?: unknown[] | undefined;
|
|
4193
4194
|
} | undefined;
|
|
4194
4195
|
output: {
|
|
4195
4196
|
deliveries: {
|
|
@@ -4504,6 +4505,42 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4504
4505
|
};
|
|
4505
4506
|
meta: import("./trpc.js").ProcedureMeta;
|
|
4506
4507
|
}>;
|
|
4508
|
+
record: import("@trpc/server").TRPCMutationProcedure<{
|
|
4509
|
+
input: {
|
|
4510
|
+
cursor?: unknown;
|
|
4511
|
+
limit?: number | undefined;
|
|
4512
|
+
} | undefined;
|
|
4513
|
+
output: {
|
|
4514
|
+
items: {
|
|
4515
|
+
deliveryId: `dlv_${string}`;
|
|
4516
|
+
messageId: `msg_${string}`;
|
|
4517
|
+
senderShipId: `shp_${string}`;
|
|
4518
|
+
senderName: string;
|
|
4519
|
+
senderType: string;
|
|
4520
|
+
recipient: {
|
|
4521
|
+
kind: "ship";
|
|
4522
|
+
shipId: `shp_${string}`;
|
|
4523
|
+
} | {
|
|
4524
|
+
kind: "type";
|
|
4525
|
+
type: string;
|
|
4526
|
+
};
|
|
4527
|
+
payload: string;
|
|
4528
|
+
contentType: string;
|
|
4529
|
+
model: string | null;
|
|
4530
|
+
inReplyTo: `msg_${string}` | null;
|
|
4531
|
+
sentAt: string;
|
|
4532
|
+
isForced: boolean;
|
|
4533
|
+
meetingId: `mtg_${string}` | null;
|
|
4534
|
+
scheduleId: `sch_${string}` | null;
|
|
4535
|
+
sendTime: string | null;
|
|
4536
|
+
attempts: number;
|
|
4537
|
+
state: "acknowledged" | "undeliverable" | "pending" | "received" | "handed" | "handled" | "notHandled" | "dismissed" | "abandoned";
|
|
4538
|
+
isPayloadUnreadable: boolean;
|
|
4539
|
+
}[];
|
|
4540
|
+
nextCursor: `dlv_${string}` | null;
|
|
4541
|
+
};
|
|
4542
|
+
meta: import("./trpc.js").ProcedureMeta;
|
|
4543
|
+
}>;
|
|
4507
4544
|
inbox: import("@trpc/server").TRPCMutationProcedure<{
|
|
4508
4545
|
input: {
|
|
4509
4546
|
waitSeconds?: number | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ANSWER_CONTENT_TYPE, ARGO_HEADLINE_MAX_LENGTH, MARKDOWN_CONTENT_TYPE, MEETING_ADDED_CONTENT_TYPE, MEETING_ENDED_CONTENT_TYPE, MEETING_MIC_CONTENT_TYPE, NO_TERMINAL_QUESTIONS, PING_CONTENT_TYPE, QUESTION_CONTENT_TYPE, REPLACEMENT_CONTENT_TYPE, WITHDRAWAL_CONTENT_TYPE, } from '@aeolus-fleet/common';
|
|
1
|
+
import { ANSWER_CONTENT_TYPE, ARGO_HEADLINE_MAX_LENGTH, MARKDOWN_CONTENT_TYPE, MEETING_ADDED_CONTENT_TYPE, MEETING_ENDED_CONTENT_TYPE, MEETING_MIC_CONTENT_TYPE, NO_TERMINAL_QUESTIONS, NOTICE_CONTENT_TYPE, PING_CONTENT_TYPE, QUESTION_CONTENT_TYPE, REPLACEMENT_CONTENT_TYPE, STEP_CONTENT_TYPE, STEP_OUTCOME_CONTENT_TYPE, STEP_REPLACEMENT_CONTENT_TYPE, STEP_WITHDRAWAL_CONTENT_TYPE, WITHDRAWAL_CONTENT_TYPE, } from '@aeolus-fleet/common';
|
|
2
2
|
/**
|
|
3
3
|
* The ship protocol: how a session crewing a ship uses the ship calls, and
|
|
4
4
|
* when. The MCP server sends it as its instructions when a client connects,
|
|
@@ -28,5 +28,7 @@ export const SHIP_PROTOCOL = [
|
|
|
28
28
|
'16. LEASE_ENDED while passing your crew token: your ship was released. Stop calling the fleet and say so.',
|
|
29
29
|
'17. To read a delivery you acknowledged again, whole, until it is handled, call delivery with its deliveryId. It changes nothing.',
|
|
30
30
|
`18. A delivery naming a meetingId comes from a meeting you take part in; ${MEETING_ADDED_CONTENT_TYPE} tells you that you were added. Contribute by send to {"kind":"meeting","meetingId":"<its id>"}, never with inReplyTo, and only while you hold the mic: call requestMic, contribute once ${MEETING_MIC_CONTENT_TYPE} arrives, then releaseMic, and request again to speak again. The moderator needs no mic. Call meeting to read what was said and who takes part. ${MEETING_ENDED_CONTENT_TYPE} means the meeting ended: contribute no more.`,
|
|
31
|
+
`19. For what only a human can do (create a repository, sign in to an outside server), send your owner's ship, as whoami names it, a step: a message of content type ${STEP_CONTENT_TYPE}. Its payload is JSON: {"id":"<a new uuid>","title":"...","why":"...","link":"<the http(s) URL where it is done, optional>"}. Your owner answers with a reply to it (inReplyTo) of content type ${STEP_OUTCOME_CONTENT_TYPE}, payload {"stepId":"<its uuid>","outcome":"done"|"cannot","note":"..."}, the note optional for either. Until then you can withdraw it: send the ship you asked ${STEP_WITHDRAWAL_CONTENT_TYPE}, payload {"stepId":"<its uuid>"}. Or replace it: send the ship you asked ${STEP_REPLACEMENT_CONTENT_TYPE}, payload {"stepId":"<its uuid>","step":<the new step, with a new uuid>}.`,
|
|
32
|
+
`20. To tell a person something without asking (a PR opened, a release out), send your owner's ship, as whoami names it, a notice: a message of content type ${NOTICE_CONTENT_TYPE}. Its payload is JSON: {"headline":"<one line of at most ${String(ARGO_HEADLINE_MAX_LENGTH)} characters>","body":"<Markdown>","link":{"label":"...","url":"<http(s) URL>"}}, the link optional. A notice is not answered.`,
|
|
31
33
|
].join('\n');
|
|
32
34
|
//# sourceMappingURL=ship-protocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ship-protocol.js","sourceRoot":"","sources":["../../../src/adapters/trpc/ship-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,8DAA8D;IAC9D,EAAE;IACF,sVAAsV;IACtV,oNAAoN;IACpN,2EAA2E;IAC3E,MAAM,qBA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