@aeolus-fleet/core 0.38.9 → 0.39.0
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/generated/models/Operator.d.ts +3 -0
- package/dist/adapters/prisma/identity.js +12 -9
- package/dist/adapters/prisma/identity.js.map +1 -1
- package/dist/domain/identity/operator-account.d.ts +11 -1
- package/dist/domain/identity/operator-account.js +8 -0
- package/dist/domain/identity/operator-account.js.map +1 -1
- package/dist/domain/identity/ports.d.ts +5 -5
- package/dist/domain/identity/public.d.ts +1 -1
- package/dist/domain/identity/public.js +1 -1
- package/dist/domain/identity/public.js.map +1 -1
- package/dist/domain/identity/set-operator-login.d.ts +1 -1
- package/dist/domain/identity/set-operator-login.js +3 -3
- package/dist/domain/identity/set-operator-login.js.map +1 -1
- package/dist/domain/identity/sign-in.js +3 -3
- package/dist/domain/identity/sign-in.js.map +1 -1
- package/dist/domain/registry/create-fleet.d.ts +4 -2
- package/dist/domain/registry/create-fleet.js +7 -5
- package/dist/domain/registry/create-fleet.js.map +1 -1
- package/dist/testing/container-sweeper.d.ts +18 -0
- package/dist/testing/container-sweeper.js +54 -0
- package/dist/testing/container-sweeper.js.map +1 -0
- package/dist/testing/postgres-container.d.ts +3 -2
- package/dist/testing/postgres-container.js +5 -2
- package/dist/testing/postgres-container.js.map +1 -1
- package/dist/testing/postgres-global-setup.d.ts +5 -1
- package/dist/testing/postgres-global-setup.js +9 -2
- package/dist/testing/postgres-global-setup.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/prisma/migrations/20261112100000_crew_request_repositories/migration.sql +11 -0
- package/src/adapters/prisma/migrations/20261112190000_shared_operator_email/migration.sql +4 -0
- package/src/adapters/prisma/schema.prisma +4 -1
|
@@ -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 commissionApprovals CommissionApproval[]\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 exchanges Exchange[]\n prunedExchanges PrunedExchange[]\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 requestedCrews CrewRequest[] @relation(\"CrewRequestRequester\")\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 commissionApprovals CommissionApproval[]\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 exchanges Exchange[] @relation(\"ExchangeShip\")\n exchangedWith Exchange[] @relation(\"ExchangeOtherShip\")\n prunedExchanges PrunedExchange[] @relation(\"PrunedExchangeShip\")\n prunedExchangesWith PrunedExchange[] @relation(\"PrunedExchangeOtherShip\")\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 ship that made it last; null for a request made before it was recorded.\n requestedBy String? @map(\"requested_by_ship_id\")\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 requester Ship? @relation(\"CrewRequestRequester\", fields: [fleetId, requestedBy], 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 /// A delete of a ship checks the requests it made with an index.\n @@index([fleetId, requestedBy])\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/// The rollup of a person ship's list of exchanges (docs/design/exchange-read, E4, E5): per other ship it\n/// exchanged with, the newest message between them and how many of the other ship's deliveries to it are\n/// not yet acknowledged. Written in the transactions that make and change deliveries, never counted from history.\nmodel Exchange {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n otherShipId String @map(\"other_ship_id\")\n newestMessageId String @map(\"newest_message_id\")\n unacknowledged Int @default(0)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(\"ExchangeShip\", fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n otherShip Ship @relation(\"ExchangeOtherShip\", fields: [fleetId, otherShipId], references: [fleetId, id], onDelete: Restrict)\n newestMessage Message @relation(fields: [fleetId, newestMessageId], references: [fleetId, id], onDelete: Restrict)\n\n @@id([fleetId, shipId, otherShipId])\n /// The list pages a ship's rows newest first.\n @@index([fleetId, shipId, newestMessageId])\n @@index([fleetId, otherShipId])\n @@index([fleetId, newestMessageId])\n @@map(\"exchanges\")\n}\n\n/// How far pruning went in one exchange (docs/design/exchange-history): the send time of the newest\n/// message of the two ships' exchange that pruning removed, only ever moved forward. One row per pair,\n/// the lower ship id first; a ship's exchange with itself names it twice. Written only by the pruning\n/// batch, in its transaction. No foreign key to a message: what it points at is gone.\nmodel PrunedExchange {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n otherShipId String @map(\"other_ship_id\")\n prunedUpTo DateTime @map(\"pruned_up_to\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id], onDelete: Restrict)\n ship Ship @relation(\"PrunedExchangeShip\", fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n otherShip Ship @relation(\"PrunedExchangeOtherShip\", fields: [fleetId, otherShipId], references: [fleetId, id], onDelete: Restrict)\n\n @@id([fleetId, shipId, otherShipId])\n /// Backs the foreign key to the other ship; the read uses the primary key alone.\n @@index([fleetId, otherShipId])\n @@map(\"pruned_exchanges\")\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 exchangesNewest Exchange[]\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 /// Its message's sender, and whether its message is in an exchange: no meeting, no ping (docs/design/exchange-read, E1, E3).\n senderShipId String @map(\"sender_ship_id\")\n isInExchange Boolean @default(false) @map(\"is_in_exchange\")\n /// The ship it reached: its recipient, or the ship of its type that claimed it. Generated by the database from the two, never written.\n reachedShipId String? @default(dbgenerated(\"COALESCE(recipient_ship_id, claimed_by_ship_id)\")) @map(\"reached_ship_id\")\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 /// Seen up to here finds the deliveries of its type a ship claimed that are still in flight (docs/design/exchange-read, E6). Partial, so a foreign key check never picks it.\n @@index([fleetId, claimedByShipId, id], map: \"deliveries_in_flight_claimed_idx\", where: raw(\"((recipient_type IS NOT NULL) AND (state = ANY (ARRAY['received'::delivery_state, 'handed'::delivery_state])))\"))\n /// One exchange page is two range scans, one per direction (docs/design/exchange-read, E3). Partial, so a foreign key check never picks it.\n @@index([fleetId, reachedShipId, senderShipId, id], map: \"deliveries_exchange_idx\", where: raw(\"is_in_exchange\"))\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\n/// Immutable bounded commission rights. Only withdrawnAt changes after recording.\nmodel CommissionApproval {\n id String @id\n fleetId String @map(\"fleet_id\")\n approver Json\n commissionerId String @map(\"commissioner_id\")\n scopes String[]\n subjectDigest String @map(\"subject_digest\")\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n withdrawnAt DateTime? @map(\"withdrawn_at\") @db.Timestamptz(3)\n fleet Fleet @relation(fields: [fleetId], references: [id], onDelete: Restrict)\n commissioner Ship @relation(fields: [fleetId, commissionerId], references: [fleetId, id], onDelete: Restrict)\n\n @@unique([fleetId, id])\n @@index([fleetId, commissionerId])\n @@map(\"commission_approvals\")\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 commissionApprovals CommissionApproval[]\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 exchanges Exchange[]\n prunedExchanges PrunedExchange[]\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 requestedCrews CrewRequest[] @relation(\"CrewRequestRequester\")\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 commissionApprovals CommissionApproval[]\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 exchanges Exchange[] @relation(\"ExchangeShip\")\n exchangedWith Exchange[] @relation(\"ExchangeOtherShip\")\n prunedExchanges PrunedExchange[] @relation(\"PrunedExchangeShip\")\n prunedExchangesWith PrunedExchange[] @relation(\"PrunedExchangeOtherShip\")\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 ship that made it last; null for a request made before it was recorded.\n requestedBy String? @map(\"requested_by_ship_id\")\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 requester Ship? @relation(\"CrewRequestRequester\", fields: [fleetId, requestedBy], 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 /// A delete of a ship checks the requests it made with an index.\n @@index([fleetId, requestedBy])\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/// The rollup of a person ship's list of exchanges (docs/design/exchange-read, E4, E5): per other ship it\n/// exchanged with, the newest message between them and how many of the other ship's deliveries to it are\n/// not yet acknowledged. Written in the transactions that make and change deliveries, never counted from history.\nmodel Exchange {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n otherShipId String @map(\"other_ship_id\")\n newestMessageId String @map(\"newest_message_id\")\n unacknowledged Int @default(0)\n\n fleet Fleet @relation(fields: [fleetId], references: [id])\n ship Ship @relation(\"ExchangeShip\", fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n otherShip Ship @relation(\"ExchangeOtherShip\", fields: [fleetId, otherShipId], references: [fleetId, id], onDelete: Restrict)\n newestMessage Message @relation(fields: [fleetId, newestMessageId], references: [fleetId, id], onDelete: Restrict)\n\n @@id([fleetId, shipId, otherShipId])\n /// The list pages a ship's rows newest first.\n @@index([fleetId, shipId, newestMessageId])\n @@index([fleetId, otherShipId])\n @@index([fleetId, newestMessageId])\n @@map(\"exchanges\")\n}\n\n/// How far pruning went in one exchange (docs/design/exchange-history): the send time of the newest\n/// message of the two ships' exchange that pruning removed, only ever moved forward. One row per pair,\n/// the lower ship id first; a ship's exchange with itself names it twice. Written only by the pruning\n/// batch, in its transaction. No foreign key to a message: what it points at is gone.\nmodel PrunedExchange {\n fleetId String @map(\"fleet_id\")\n shipId String @map(\"ship_id\")\n otherShipId String @map(\"other_ship_id\")\n prunedUpTo DateTime @map(\"pruned_up_to\") @db.Timestamptz(3)\n\n fleet Fleet @relation(fields: [fleetId], references: [id], onDelete: Restrict)\n ship Ship @relation(\"PrunedExchangeShip\", fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)\n otherShip Ship @relation(\"PrunedExchangeOtherShip\", fields: [fleetId, otherShipId], references: [fleetId, id], onDelete: Restrict)\n\n @@id([fleetId, shipId, otherShipId])\n /// Backs the foreign key to the other ship; the read uses the primary key alone.\n @@index([fleetId, otherShipId])\n @@map(\"pruned_exchanges\")\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 exchangesNewest Exchange[]\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 /// Its message's sender, and whether its message is in an exchange: no meeting, no ping (docs/design/exchange-read, E1, E3).\n senderShipId String @map(\"sender_ship_id\")\n isInExchange Boolean @default(false) @map(\"is_in_exchange\")\n /// The ship it reached: its recipient, or the ship of its type that claimed it. Generated by the database from the two, never written.\n reachedShipId String? @default(dbgenerated(\"COALESCE(recipient_ship_id, claimed_by_ship_id)\")) @map(\"reached_ship_id\")\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 /// Seen up to here finds the deliveries of its type a ship claimed that are still in flight (docs/design/exchange-read, E6). Partial, so a foreign key check never picks it.\n @@index([fleetId, claimedByShipId, id], map: \"deliveries_in_flight_claimed_idx\", where: raw(\"((recipient_type IS NOT NULL) AND (state = ANY (ARRAY['received'::delivery_state, 'handed'::delivery_state])))\"))\n /// One exchange page is two range scans, one per direction (docs/design/exchange-read, E3). Partial, so a foreign key check never picks it.\n @@index([fleetId, reachedShipId, senderShipId, id], map: \"deliveries_exchange_idx\", where: raw(\"is_in_exchange\"))\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 /// The fleets the installation creates may share one; the email of argo's own sign-in (with a password) is no other operator's.\n email String?\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 @@unique([email], map: \"operators_sign_in_email_key\", where: raw(\"(password_hash IS NOT NULL)\"))\n @@index([email])\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\n/// Immutable bounded commission rights. Only withdrawnAt changes after recording.\nmodel CommissionApproval {\n id String @id\n fleetId String @map(\"fleet_id\")\n approver Json\n commissionerId String @map(\"commissioner_id\")\n scopes String[]\n subjectDigest String @map(\"subject_digest\")\n createdAt DateTime @map(\"created_at\") @db.Timestamptz(3)\n withdrawnAt DateTime? @map(\"withdrawn_at\") @db.Timestamptz(3)\n fleet Fleet @relation(fields: [fleetId], references: [id], onDelete: Restrict)\n commissioner Ship @relation(fields: [fleetId, commissionerId], references: [fleetId, id], onDelete: Restrict)\n\n @@unique([fleetId, id])\n @@index([fleetId, commissionerId])\n @@map(\"commission_approvals\")\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,027EAA027E;IAC137E,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,qm7DAAqm7D,CAAC,CAAA;AAC3o7D,MAAM,CAAC,sBAAsB,GAAG;IAC9B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,yp8BAAyp8B,CAAC;IAC9q8B,KAAK,EAAE,g5jYAAg5jY;CACx5jY,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;AAwmBD,MAAM,UAAU,oBAAoB;IAClC,OAAO,OAAO,CAAC,eAAe,CAAC,MAAM,CAAuC,CAAA;AAC9E,CAAC"}
|
|
@@ -404,6 +404,9 @@ export type $OperatorPayload<ExtArgs extends runtime.Types.Extensions.InternalAr
|
|
|
404
404
|
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
|
405
405
|
id: string;
|
|
406
406
|
fleetId: string;
|
|
407
|
+
/**
|
|
408
|
+
* The fleets the installation creates may share one; the email of argo's own sign-in (with a password) is no other operator's.
|
|
409
|
+
*/
|
|
407
410
|
email: string | null;
|
|
408
411
|
passwordHash: string | null;
|
|
409
412
|
/**
|
|
@@ -45,16 +45,17 @@ export function createPrismaCredentialRepository(db) {
|
|
|
45
45
|
}
|
|
46
46
|
export function createPrismaOperatorAccountLookup(db) {
|
|
47
47
|
return {
|
|
48
|
-
|
|
48
|
+
allByEmail: async (email) => {
|
|
49
49
|
// Not scoped by fleet: signing in names no fleet (ADR 0007). No lock:
|
|
50
50
|
// a plain read never waits for a sign-in or a reset holding the row.
|
|
51
|
-
const
|
|
51
|
+
const rows = await db.$queryRaw `
|
|
52
52
|
SELECT id, fleet_id, email, password_hash, theme::text AS theme, created_at FROM operators
|
|
53
|
-
WHERE email = ${email}
|
|
54
|
-
|
|
53
|
+
WHERE email = ${email}
|
|
54
|
+
ORDER BY id`;
|
|
55
|
+
return rows.map(toOperatorAccount);
|
|
55
56
|
},
|
|
56
57
|
byFleet: async (fleetId) => {
|
|
57
|
-
// No lock, as
|
|
58
|
+
// No lock, as allByEmail: the caller checks the row again under its lock.
|
|
58
59
|
const [row] = await db.$queryRaw `
|
|
59
60
|
SELECT id, fleet_id, email, password_hash, theme::text AS theme, created_at FROM operators
|
|
60
61
|
WHERE fleet_id = ${fleetId}`;
|
|
@@ -72,13 +73,15 @@ export function createPrismaOperatorAccountRepository(db) {
|
|
|
72
73
|
// released at commit or rollback, as the ship-name lock is per fleet.
|
|
73
74
|
await db.$executeRaw `SELECT pg_advisory_xact_lock(hashtext('operator-email'), hashtext(${email}))`;
|
|
74
75
|
},
|
|
75
|
-
|
|
76
|
-
// Not scoped by fleet: signing in names no fleet (ADR 0007).
|
|
77
|
-
|
|
76
|
+
findAllByEmailForUpdate: async (email) => {
|
|
77
|
+
// Not scoped by fleet: signing in names no fleet (ADR 0007). Locked in
|
|
78
|
+
// id order, so two units of work never wait on each other's rows.
|
|
79
|
+
const rows = await db.$queryRaw `
|
|
78
80
|
SELECT id, fleet_id, email, password_hash, theme::text AS theme, created_at FROM operators
|
|
79
81
|
WHERE email = ${email}
|
|
82
|
+
ORDER BY id
|
|
80
83
|
FOR UPDATE`;
|
|
81
|
-
return
|
|
84
|
+
return rows.map(toOperatorAccount);
|
|
82
85
|
},
|
|
83
86
|
findForFleetForUpdate: async (fleetId) => {
|
|
84
87
|
const [row] = await db.$queryRaw `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/adapters/prisma/identity.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,GAClB,MAAM,WAAW,CAAC;AAEnB,gFAAgF;AAChF,8EAA8E;AAC9E,6EAA6E;AAC7E,oEAAoE;AAEpE,uDAAuD;AACvD,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,MAAM,UAAU,gCAAgC,CAAC,EAAM;IACrD,OAAO;QACL,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;YAC3B,MAAM,EAAE,CAAC,UAAU,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,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1E,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,EAAM;IAC7C,OAAO;QACL,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;KACpF,CAAC;AACJ,CAAC"}
|
|
@@ -11,7 +11,11 @@ import { type Result } from '../shared/result.js';
|
|
|
11
11
|
export interface OperatorAccount {
|
|
12
12
|
id: OperatorId;
|
|
13
13
|
fleetId: FleetId;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Normalised, found before the fleet is known (ADR 0007); null until argo
|
|
16
|
+
* sets one. The fleets a hosting installation creates may share one; the
|
|
17
|
+
* email of argo's own sign-in is unique across the installation.
|
|
18
|
+
*/
|
|
15
19
|
email: string | null;
|
|
16
20
|
/**
|
|
17
21
|
* The Argon2id hash of the password; null for an operator who has none,
|
|
@@ -22,6 +26,12 @@ export interface OperatorAccount {
|
|
|
22
26
|
theme: Theme;
|
|
23
27
|
createdAt: Date;
|
|
24
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The account among those holding one email that signs in with it on its
|
|
31
|
+
* own: the one with a password. Only argo's own sign-in has one, and its
|
|
32
|
+
* email is no other operator's, so there is at most one.
|
|
33
|
+
*/
|
|
34
|
+
export declare function ownSignInOf(accounts: readonly OperatorAccount[]): OperatorAccount | undefined;
|
|
25
35
|
/** The form an email is stored and found in: without the spaces around it, in lowercase. */
|
|
26
36
|
export declare function normaliseEmail(raw: string): string;
|
|
27
37
|
/** An operator email, normalised: one @ with something on each side, no whitespace, at most 254 characters. */
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { OPERATOR_EMAIL_MAX_LENGTH, OPERATOR_EMAIL_PATTERN, newOperatorPasswordProblem, } from '@aeolus-fleet/common';
|
|
2
2
|
import { refuse } from '../shared/errors.js';
|
|
3
3
|
import { ok } from '../shared/result.js';
|
|
4
|
+
/**
|
|
5
|
+
* The account among those holding one email that signs in with it on its
|
|
6
|
+
* own: the one with a password. Only argo's own sign-in has one, and its
|
|
7
|
+
* email is no other operator's, so there is at most one.
|
|
8
|
+
*/
|
|
9
|
+
export function ownSignInOf(accounts) {
|
|
10
|
+
return accounts.find((account) => account.passwordHash !== null);
|
|
11
|
+
}
|
|
4
12
|
/** The form an email is stored and found in: without the spaces around it, in lowercase. */
|
|
5
13
|
export function normaliseEmail(raw) {
|
|
6
14
|
return raw.trim().toLowerCase();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator-account.js","sourceRoot":"","sources":["../../../src/domain/identity/operator-account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,GAI3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"operator-account.js","sourceRoot":"","sources":["../../../src/domain/identity/operator-account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,GAI3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AA4BtD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,QAAoC;IAC9D,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,+GAA+G;AAC/G,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,MAAM,IAAI,yBAAyB,IAAI,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC;QACpF,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACX,CAAC,CAAC,MAAM,CACJ,eAAe,EACf,kEAAkE,MAAM,CAAC,yBAAyB,CAAC,aAAa,CACjH,CAAC;AACR,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,MAAM,OAAO,GAAG,0BAA0B,CAAC,GAAG,CAAC,CAAC;IAChD,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -53,7 +53,8 @@ export interface CredentialRepository {
|
|
|
53
53
|
* One query, not scoped by fleet: signing in names no fleet (ADR 0007).
|
|
54
54
|
*/
|
|
55
55
|
export interface OperatorAccountLookup {
|
|
56
|
-
|
|
56
|
+
/** Every account holding this normalised email: the fleets a hosting installation creates may share one. */
|
|
57
|
+
allByEmail(email: string): Promise<readonly OperatorAccount[]>;
|
|
57
58
|
byFleet(fleetId: FleetId): Promise<OperatorAccount | undefined>;
|
|
58
59
|
}
|
|
59
60
|
/** Outbound port: the operator account. */
|
|
@@ -65,11 +66,10 @@ export interface OperatorAccountRepository {
|
|
|
65
66
|
*/
|
|
66
67
|
lockEmail(email: string): Promise<void>;
|
|
67
68
|
/**
|
|
68
|
-
*
|
|
69
|
-
* ends. Not scoped by fleet: signing in names no fleet
|
|
70
|
-
* unique across all fleets (ADR 0007).
|
|
69
|
+
* Every account holding this normalised email, locked until the unit of
|
|
70
|
+
* work ends. Not scoped by fleet: signing in names no fleet (ADR 0007).
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
findAllByEmailForUpdate(email: string): Promise<readonly OperatorAccount[]>;
|
|
73
73
|
/** The fleet's operator account, locked until the unit of work ends. */
|
|
74
74
|
findForFleetForUpdate(fleetId: FleetId): Promise<OperatorAccount | undefined>;
|
|
75
75
|
changePassword(change: {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { findValidShipSecret, issueShipSecret, markShipSecretClaimed, revokeShipSecret, SHIP_SECRET_PREFIX, type Credential, type CredentialTx, type SecretTools, } from './credential.js';
|
|
2
|
-
export { operatorEmail, operatorPassword } from './operator-account.js';
|
|
2
|
+
export { operatorEmail, operatorPassword, ownSignInOf } from './operator-account.js';
|
|
3
3
|
export type { CredentialRepository, OperatorAccountRepository } from './ports.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Identity's published surface: what other contexts may use. Use cases are not
|
|
2
2
|
// part of it; adapters import them from their own modules.
|
|
3
3
|
export { findValidShipSecret, issueShipSecret, markShipSecretClaimed, revokeShipSecret, SHIP_SECRET_PREFIX, } from './credential.js';
|
|
4
|
-
export { operatorEmail, operatorPassword } from './operator-account.js';
|
|
4
|
+
export { operatorEmail, operatorPassword, ownSignInOf } from './operator-account.js';
|
|
5
5
|
//# sourceMappingURL=public.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/domain/identity/public.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2DAA2D;AAC3D,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,GAInB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/domain/identity/public.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2DAA2D;AAC3D,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,GAInB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -23,7 +23,7 @@ export type SetOperatorLogin = (caller: ShipCaller, input: {
|
|
|
23
23
|
* Use case: argo, signed in to the console, sets the email and password of
|
|
24
24
|
* its own sign-in (decision 0012, accounts design A1). Only where core trusts
|
|
25
25
|
* no pagasae: a hosted fleet has no own sign-in for argo (decision 0054). The
|
|
26
|
-
* email is the user name,
|
|
26
|
+
* email is the user name, held by no other operator of the installation.
|
|
27
27
|
* The old email and password stop working; the console session that set
|
|
28
28
|
* them stays, since it is the one argo sign-in.
|
|
29
29
|
*
|
|
@@ -8,7 +8,7 @@ const WRONG_PASSWORD = 'That is not your current password';
|
|
|
8
8
|
* Use case: argo, signed in to the console, sets the email and password of
|
|
9
9
|
* its own sign-in (decision 0012, accounts design A1). Only where core trusts
|
|
10
10
|
* no pagasae: a hosted fleet has no own sign-in for argo (decision 0054). The
|
|
11
|
-
* email is the user name,
|
|
11
|
+
* email is the user name, held by no other operator of the installation.
|
|
12
12
|
* The old email and password stop working; the console session that set
|
|
13
13
|
* them stays, since it is the one argo sign-in.
|
|
14
14
|
*
|
|
@@ -50,8 +50,8 @@ export function createSetOperatorLogin(deps) {
|
|
|
50
50
|
if (account.passwordHash !== (current?.passwordHash ?? null)) {
|
|
51
51
|
return refuse('WRONG_PASSWORD', WRONG_PASSWORD);
|
|
52
52
|
}
|
|
53
|
-
const
|
|
54
|
-
if (holder
|
|
53
|
+
const holders = await tx.operatorAccounts.findAllByEmailForUpdate(email.value);
|
|
54
|
+
if (holders.some((holder) => holder.id !== account.id)) {
|
|
55
55
|
return refuse('OPERATOR_EMAIL_TAKEN', `An operator already signs in with ${email.value}`);
|
|
56
56
|
}
|
|
57
57
|
await tx.operatorAccounts.changeLogin({ fleetId, operatorId: account.id, email: email.value, passwordHash });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-operator-login.js","sourceRoot":"","sources":["../../../src/domain/identity/set-operator-login.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAmB,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAiB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGxE,MAAM,cAAc,GAAG,mCAAmC,CAAC;AAc3D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAQtC;IACC,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;QAC7B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,gBAAgB,EAAE,uEAAuE,CAAC,CAAC;QAC3G,CAAC;QACD,IAAI,MAAM,CAAC,gBAAgB,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACxE,OAAO,MAAM,CAAC,uBAAuB,EAAE,kEAAkE,CAAC,CAAC;QAC7G,CAAC;QACD,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,OAAO,QAAQ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AM,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE;gBACtD,OAAO;gBACP,IAAI,EAAE,kBAAkB;gBACxB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;gBAC5B,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;gBACtB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,OAAO,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE;aACpC,CAAC,CAAC;YACH,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { refuse } from '../shared/errors.js';
|
|
2
2
|
import { UNKNOWN_DEVICE } from './console-session.js';
|
|
3
|
-
import { normaliseEmail } from './operator-account.js';
|
|
3
|
+
import { normaliseEmail, ownSignInOf } from './operator-account.js';
|
|
4
4
|
import { startConsoleSession } from './start-console-session.js';
|
|
5
5
|
const WRONG_EMAIL_OR_PASSWORD = 'Wrong email or password';
|
|
6
6
|
/**
|
|
@@ -21,14 +21,14 @@ const WRONG_EMAIL_OR_PASSWORD = 'Wrong email or password';
|
|
|
21
21
|
export function createSignIn(deps) {
|
|
22
22
|
return async (input) => {
|
|
23
23
|
const email = normaliseEmail(input.email);
|
|
24
|
-
const account = await deps.accounts.
|
|
24
|
+
const account = ownSignInOf(await deps.accounts.allByEmail(email));
|
|
25
25
|
// An account without a password checks against none, as a missing account does: no password signs it in.
|
|
26
26
|
const isPasswordRight = await deps.passwords.verify(input.password, account?.passwordHash ?? undefined);
|
|
27
27
|
if (!account || !isPasswordRight) {
|
|
28
28
|
return refuse('WRONG_EMAIL_OR_PASSWORD', WRONG_EMAIL_OR_PASSWORD);
|
|
29
29
|
}
|
|
30
30
|
return deps.uow.run(async (tx) => {
|
|
31
|
-
const locked = await tx.operatorAccounts.
|
|
31
|
+
const locked = ownSignInOf(await tx.operatorAccounts.findAllByEmailForUpdate(email));
|
|
32
32
|
if (locked?.id !== account.id || locked.passwordHash !== account.passwordHash) {
|
|
33
33
|
return refuse('WRONG_EMAIL_OR_PASSWORD', WRONG_EMAIL_OR_PASSWORD);
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-in.js","sourceRoot":"","sources":["../../../src/domain/identity/sign-in.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAI/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"sign-in.js","sourceRoot":"","sources":["../../../src/domain/identity/sign-in.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAI/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAA8B,MAAM,4BAA4B,CAAC;AAwB7F,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAAC,IAQ5B;IACC,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE;QACrB,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QACnE,yGAAyG;QACzG,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,IAAI,SAAS,CAAC,CAAC;QACxG,IAAI,CAAC,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;YACjC,OAAO,MAAM,CAAC,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAA4C,EAAE;YACzE,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC;YACrF,IAAI,MAAM,EAAE,EAAE,KAAK,OAAO,CAAC,EAAE,IAAI,MAAM,CAAC,YAAY,KAAK,OAAO,CAAC,YAAY,EAAE,CAAC;gBAC9E,OAAO,MAAM,CAAC,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;YACpE,CAAC;YACD,OAAO,mBAAmB,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE;gBAC1F,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,cAAc;gBACtC,6EAA6E;gBAC7E,SAAS,EAAE,IAAI;gBACf,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;aACrB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -29,8 +29,10 @@ export type CreateFleet = (input: {
|
|
|
29
29
|
* Use case: the installation creates a fleet (docs/blueprint.md,
|
|
30
30
|
* "Installation"), with its argo and its operator account, who has no
|
|
31
31
|
* password: a password sign-in for that operator fails like a wrong password.
|
|
32
|
-
* Unlike fleet:init it creates a fleet beside others. The
|
|
33
|
-
*
|
|
32
|
+
* Unlike fleet:init it creates a fleet beside others. The fleets it creates
|
|
33
|
+
* may share an operator email; the email argo of a fleet made before signs in
|
|
34
|
+
* with on its own is refused, so the installation still tells that fleet by
|
|
35
|
+
* it. Asked for, the viewer ship comes with it
|
|
34
36
|
* (decision 0022), and so do the feature flags asked for on, each with its
|
|
35
37
|
* FeatureFlagTurnedOn (decision 0069). Under its request id it runs once: a replay
|
|
36
38
|
* answers the same fleet, and a different create under that id is refused.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { operatorEmail } from '../identity/public.js';
|
|
1
|
+
import { operatorEmail, ownSignInOf } from '../identity/public.js';
|
|
2
2
|
import { refuse } from '../shared/errors.js';
|
|
3
3
|
import { recordEvent } from '../shared/events.js';
|
|
4
4
|
import { ok } from '../shared/result.js';
|
|
@@ -9,8 +9,10 @@ import { installationRequestText } from './installation-request.js';
|
|
|
9
9
|
* Use case: the installation creates a fleet (docs/blueprint.md,
|
|
10
10
|
* "Installation"), with its argo and its operator account, who has no
|
|
11
11
|
* password: a password sign-in for that operator fails like a wrong password.
|
|
12
|
-
* Unlike fleet:init it creates a fleet beside others. The
|
|
13
|
-
*
|
|
12
|
+
* Unlike fleet:init it creates a fleet beside others. The fleets it creates
|
|
13
|
+
* may share an operator email; the email argo of a fleet made before signs in
|
|
14
|
+
* with on its own is refused, so the installation still tells that fleet by
|
|
15
|
+
* it. Asked for, the viewer ship comes with it
|
|
14
16
|
* (decision 0022), and so do the feature flags asked for on, each with its
|
|
15
17
|
* FeatureFlagTurnedOn (decision 0069). Under its request id it runs once: a replay
|
|
16
18
|
* answers the same fleet, and a different create under that id is refused.
|
|
@@ -46,8 +48,8 @@ export function createCreateFleet(deps) {
|
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
await tx.operatorAccounts.lockEmail(email.value);
|
|
49
|
-
if (await tx.operatorAccounts.
|
|
50
|
-
return refuse('OPERATOR_EMAIL_TAKEN', `
|
|
51
|
+
if (ownSignInOf(await tx.operatorAccounts.findAllByEmailForUpdate(email.value))) {
|
|
52
|
+
return refuse('OPERATOR_EMAIL_TAKEN', `argo of another fleet signs in with ${email.value}`);
|
|
51
53
|
}
|
|
52
54
|
const at = deps.clock.now();
|
|
53
55
|
const { fleetId, operatorShipId } = await foundFleet({ tx, ids: deps.ids }, { name, email: email.value, passwordHash: null, at, hasViewer });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-fleet.js","sourceRoot":"","sources":["../../../src/domain/registry/create-fleet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-fleet.js","sourceRoot":"","sources":["../../../src/domain/registry/create-fleet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAqB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AA0BpE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAA8F;IAC9H,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE;QACrB,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,IAAI,GAAG,KAAK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AAK,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YACxK,CAAC;YACD,MAAM,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;YACpI,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The label every container a test run starts carries, its value the run. The
|
|
3
|
+
* sweeper removes a run's containers by it, and CI checks by it that a run left
|
|
4
|
+
* none behind.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TEST_RUN_LABEL = "aeolus-fleet.test-run";
|
|
7
|
+
/**
|
|
8
|
+
* Starts the sweeper of a test run: a process of its own that removes the
|
|
9
|
+
* run's containers with their volumes once the run's process ends, however it
|
|
10
|
+
* ends. A run's teardown removes them too, but an interrupted or killed run
|
|
11
|
+
* never reaches it, and rootless Podman often runs no Testcontainers reaper
|
|
12
|
+
* (#1581). The sweeper learns the run ended when the pipe from the run's
|
|
13
|
+
* process closes, which the operating system does for a killed process too. It
|
|
14
|
+
* runs in a process group of its own, so the Ctrl-C that interrupts the run
|
|
15
|
+
* does not stop it, and it keeps the run's process from exiting by nothing.
|
|
16
|
+
* The file is the sweeper: this function starts it again as a program.
|
|
17
|
+
*/
|
|
18
|
+
export declare function startContainerSweeper(run: string): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { Socket } from 'node:net';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { getContainerRuntimeClient } from 'testcontainers';
|
|
5
|
+
/**
|
|
6
|
+
* The label every container a test run starts carries, its value the run. The
|
|
7
|
+
* sweeper removes a run's containers by it, and CI checks by it that a run left
|
|
8
|
+
* none behind.
|
|
9
|
+
*/
|
|
10
|
+
export const TEST_RUN_LABEL = 'aeolus-fleet.test-run';
|
|
11
|
+
/**
|
|
12
|
+
* Starts the sweeper of a test run: a process of its own that removes the
|
|
13
|
+
* run's containers with their volumes once the run's process ends, however it
|
|
14
|
+
* ends. A run's teardown removes them too, but an interrupted or killed run
|
|
15
|
+
* never reaches it, and rootless Podman often runs no Testcontainers reaper
|
|
16
|
+
* (#1581). The sweeper learns the run ended when the pipe from the run's
|
|
17
|
+
* process closes, which the operating system does for a killed process too. It
|
|
18
|
+
* runs in a process group of its own, so the Ctrl-C that interrupts the run
|
|
19
|
+
* does not stop it, and it keeps the run's process from exiting by nothing.
|
|
20
|
+
* The file is the sweeper: this function starts it again as a program.
|
|
21
|
+
*/
|
|
22
|
+
export function startContainerSweeper(run) {
|
|
23
|
+
const sweeper = spawn(process.execPath, [fileURLToPath(import.meta.url), run], {
|
|
24
|
+
detached: true,
|
|
25
|
+
stdio: ['pipe', 'ignore', 'inherit'],
|
|
26
|
+
});
|
|
27
|
+
sweeper.unref();
|
|
28
|
+
// The pipe is a socket: unreferenced, it keeps the run's process from exiting by nothing either.
|
|
29
|
+
if (sweeper.stdin instanceof Socket) {
|
|
30
|
+
sweeper.stdin.unref();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Removes every container of the run, running or not, with its anonymous volumes. */
|
|
34
|
+
async function sweep(run) {
|
|
35
|
+
const { dockerode } = (await getContainerRuntimeClient()).container;
|
|
36
|
+
const containers = await dockerode.listContainers({ all: true, filters: { label: [`${TEST_RUN_LABEL}=${run}`] } });
|
|
37
|
+
// A container the run's teardown removes meanwhile answers not found: it is gone either way.
|
|
38
|
+
await Promise.allSettled(containers.map((container) => dockerode.getContainer(container.Id).remove({ force: true, v: true })));
|
|
39
|
+
}
|
|
40
|
+
if (import.meta.main) {
|
|
41
|
+
const run = process.argv[2];
|
|
42
|
+
if (!run) {
|
|
43
|
+
console.error('Usage: node container-sweeper.ts <test run>');
|
|
44
|
+
process.exit(2);
|
|
45
|
+
}
|
|
46
|
+
process.stdin.on('end', () => {
|
|
47
|
+
sweep(run).catch((error) => {
|
|
48
|
+
console.error(`The sweeper of test run ${run} could not remove its containers:`, error);
|
|
49
|
+
process.exitCode = 1;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
process.stdin.resume();
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=container-sweeper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-sweeper.js","sourceRoot":"","sources":["../../src/testing/container-sweeper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE;QAC7E,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;KACrC,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,EAAE,CAAC;IAChB,iGAAiG;IACjG,IAAI,OAAO,CAAC,KAAK,YAAY,MAAM,EAAE,CAAC;QACpC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;AACH,CAAC;AAED,s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import { PostgreSqlContainer } from '@testcontainers/postgresql';
|
|
|
7
7
|
* that waits for the disk waits behind every other test's writes, and under a
|
|
8
8
|
* loaded full run Prisma Migrate's commits alone outlasted a test's time
|
|
9
9
|
* (#499). Only a crash of the host loses a commit then, and no test survives
|
|
10
|
-
* that anyway.
|
|
10
|
+
* that anyway. It carries the label of the test run that starts it, so the
|
|
11
|
+
* run's sweeper removes it.
|
|
11
12
|
*/
|
|
12
13
|
export declare class TestPostgres extends PostgreSqlContainer {
|
|
13
|
-
constructor(image: string);
|
|
14
|
+
constructor(image: string, run: string);
|
|
14
15
|
/** Drops the check the module sets on start; the image defines none of its own. */
|
|
15
16
|
protected beforeContainerCreated(): Promise<void>;
|
|
16
17
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PostgreSqlContainer } from '@testcontainers/postgresql';
|
|
2
2
|
import { Wait } from 'testcontainers';
|
|
3
|
+
import { TEST_RUN_LABEL } from './container-sweeper.js';
|
|
3
4
|
/**
|
|
4
5
|
* Postgres says it is ready twice: once for the server the image's entrypoint
|
|
5
6
|
* starts to initialise the database, once for the server that stays.
|
|
@@ -13,11 +14,13 @@ const READY_LOG = /database system is ready to accept connections/;
|
|
|
13
14
|
* that waits for the disk waits behind every other test's writes, and under a
|
|
14
15
|
* loaded full run Prisma Migrate's commits alone outlasted a test's time
|
|
15
16
|
* (#499). Only a crash of the host loses a commit then, and no test survives
|
|
16
|
-
* that anyway.
|
|
17
|
+
* that anyway. It carries the label of the test run that starts it, so the
|
|
18
|
+
* run's sweeper removes it.
|
|
17
19
|
*/
|
|
18
20
|
export class TestPostgres extends PostgreSqlContainer {
|
|
19
|
-
constructor(image) {
|
|
21
|
+
constructor(image, run) {
|
|
20
22
|
super(image);
|
|
23
|
+
this.withLabels({ [TEST_RUN_LABEL]: run });
|
|
21
24
|
this.withCommand(['postgres', '-c', 'fsync=off']);
|
|
22
25
|
this.withWaitStrategy(Wait.forAll([Wait.forLogMessage(READY_LOG, 2), Wait.forListeningPorts()]));
|
|
23
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-container.js","sourceRoot":"","sources":["../../src/testing/postgres-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC;;;GAGG;AACH,MAAM,SAAS,GAAG,gDAAgD,CAAC;AAEnE
|
|
1
|
+
{"version":3,"file":"postgres-container.js","sourceRoot":"","sources":["../../src/testing/postgres-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;GAGG;AACH,MAAM,SAAS,GAAG,gDAAgD,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,YAAa,SAAQ,mBAAmB;IACnD,YAAY,KAAa,EAAE,GAAW;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,WAAW,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,CAAC;IACnG,CAAC;IAED,mFAAmF;IAChE,KAAK,CAAC,sBAAsB;QAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QACnC,MAAM,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -3,6 +3,8 @@ declare module 'vitest' {
|
|
|
3
3
|
interface ProvidedContext {
|
|
4
4
|
/** Admin URL of the Postgres container shared by the integration tests. */
|
|
5
5
|
postgresUrl: string;
|
|
6
|
+
/** The test run, the label value of every container it starts, for its sweeper to remove them. */
|
|
7
|
+
testRun: string;
|
|
6
8
|
}
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
@@ -10,6 +12,8 @@ declare module 'vitest' {
|
|
|
10
12
|
* own database in it (see database.ts), so files stay isolated; a
|
|
11
13
|
* migrated one is a copy of the template migrated here, before any test runs.
|
|
12
14
|
* Testcontainers reads the reaper image from the environment when it starts
|
|
13
|
-
* the first container; a reaper image set from outside wins.
|
|
15
|
+
* the first container; a reaper image set from outside wins. The run's sweeper
|
|
16
|
+
* starts before any container, so a run that never reaches its teardown still
|
|
17
|
+
* leaves none behind.
|
|
14
18
|
*/
|
|
15
19
|
export declare function setup(project: TestProject): Promise<() => Promise<void>>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
1
2
|
import { POSTGRES_IMAGE, REAPER_IMAGE } from './container-images.js';
|
|
3
|
+
import { startContainerSweeper } from './container-sweeper.js';
|
|
2
4
|
import { TestPostgres } from './postgres-container.js';
|
|
3
5
|
import { createMigratedTemplate } from './migrated-template.js';
|
|
4
6
|
/**
|
|
@@ -6,11 +8,16 @@ import { createMigratedTemplate } from './migrated-template.js';
|
|
|
6
8
|
* own database in it (see database.ts), so files stay isolated; a
|
|
7
9
|
* migrated one is a copy of the template migrated here, before any test runs.
|
|
8
10
|
* Testcontainers reads the reaper image from the environment when it starts
|
|
9
|
-
* the first container; a reaper image set from outside wins.
|
|
11
|
+
* the first container; a reaper image set from outside wins. The run's sweeper
|
|
12
|
+
* starts before any container, so a run that never reaches its teardown still
|
|
13
|
+
* leaves none behind.
|
|
10
14
|
*/
|
|
11
15
|
export async function setup(project) {
|
|
12
16
|
process.env.RYUK_CONTAINER_IMAGE ??= REAPER_IMAGE;
|
|
13
|
-
const
|
|
17
|
+
const run = randomUUID();
|
|
18
|
+
startContainerSweeper(run);
|
|
19
|
+
project.provide('testRun', run);
|
|
20
|
+
const container = await new TestPostgres(POSTGRES_IMAGE, run).start();
|
|
14
21
|
await createMigratedTemplate(container.getConnectionUri());
|
|
15
22
|
project.provide('postgresUrl', container.getConnectionUri());
|
|
16
23
|
return async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-global-setup.js","sourceRoot":"","sources":["../../src/testing/postgres-global-setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"postgres-global-setup.js","sourceRoot":"","sources":["../../src/testing/postgres-global-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAWhE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAoB;IAC9C,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,YAAY,CAAC;IAClD,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;IACzB,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAChC,MAAM,SAAS,GAAG,MAAM,IAAI,YAAY,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;IACtE,MAAM,sBAAsB,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC3D,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAE7D,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeolus-fleet/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "The Aeolus fleet server: ships, guaranteed delivery and the API for Claude Code, Codex and any agent.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-agents",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"postpack": "rm LICENSE"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@aeolus-fleet/common": "0.
|
|
62
|
+
"@aeolus-fleet/common": "0.39.0",
|
|
63
63
|
"@aws-sdk/client-kms": "^3.1159.0",
|
|
64
64
|
"@fastify/websocket": "^11.3.1",
|
|
65
65
|
"@modelcontextprotocol/server": "^2.3.0",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- A crew request's workspace names a main repository and its sub-repositories
|
|
2
|
+
-- (#1760): a stored worktree workspace becomes repositories, that repository
|
|
3
|
+
-- (and its ref) as main and no sub-repositories, so no standing request holds
|
|
4
|
+
-- settings no trierarch can read (decision 0013).
|
|
5
|
+
UPDATE "crew_requests"
|
|
6
|
+
SET "settings" = jsonb_set(
|
|
7
|
+
"settings",
|
|
8
|
+
'{workspace}',
|
|
9
|
+
jsonb_build_object('kind', 'repositories', 'main', ("settings"->'workspace') - 'kind', 'subRepositories', '[]'::jsonb)
|
|
10
|
+
)
|
|
11
|
+
WHERE "settings"->'workspace'->>'kind' = 'worktree';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- The fleets the installation creates may share an operator email (decision 0020); the email of argo's own sign-in, with a password, stays unique.
|
|
2
|
+
DROP INDEX "operators_email_key";
|
|
3
|
+
CREATE UNIQUE INDEX "operators_sign_in_email_key" ON "operators"("email") WHERE (password_hash IS NOT NULL);
|
|
4
|
+
CREATE INDEX "operators_email_idx" ON "operators"("email");
|
|
@@ -1290,7 +1290,8 @@ enum ConsoleSessionEndReason {
|
|
|
1290
1290
|
model Operator {
|
|
1291
1291
|
id String @id
|
|
1292
1292
|
fleetId String @unique @map("fleet_id")
|
|
1293
|
-
email
|
|
1293
|
+
/// The fleets the installation creates may share one; the email of argo's own sign-in (with a password) is no other operator's.
|
|
1294
|
+
email String?
|
|
1294
1295
|
passwordHash String? @map("password_hash")
|
|
1295
1296
|
/// How the console looks for this operator; system until they choose.
|
|
1296
1297
|
theme Theme @default(system)
|
|
@@ -1298,6 +1299,8 @@ model Operator {
|
|
|
1298
1299
|
|
|
1299
1300
|
fleet Fleet @relation(fields: [fleetId], references: [id])
|
|
1300
1301
|
|
|
1302
|
+
@@unique([email], map: "operators_sign_in_email_key", where: raw("(password_hash IS NOT NULL)"))
|
|
1303
|
+
@@index([email])
|
|
1301
1304
|
@@map("operators")
|
|
1302
1305
|
}
|
|
1303
1306
|
|