@aeolus-fleet/core 0.38.4 → 0.38.6
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/browser.d.ts +8 -0
- package/dist/adapters/prisma/generated/client.d.ts +8 -0
- package/dist/adapters/prisma/generated/internal/class.d.ts +11 -0
- package/dist/adapters/prisma/generated/internal/class.js +4 -4
- package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +84 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +7 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +8 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +7 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
- package/dist/adapters/prisma/generated/models/Fleet.d.ts +495 -0
- package/dist/adapters/prisma/generated/models/PrunedExchange.d.ts +1339 -0
- package/dist/adapters/prisma/generated/models/PrunedExchange.js +2 -0
- package/dist/adapters/prisma/generated/models/PrunedExchange.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Ship.d.ts +854 -0
- package/dist/adapters/prisma/generated/models.d.ts +1 -0
- package/dist/adapters/prisma/history-pruner.js +14 -1
- package/dist/adapters/prisma/history-pruner.js.map +1 -1
- package/dist/adapters/prisma/pruned-exchanges.d.ts +16 -0
- package/dist/adapters/prisma/pruned-exchanges.js +18 -0
- package/dist/adapters/prisma/pruned-exchanges.js.map +1 -0
- package/dist/adapters/prisma/registry.js +1 -0
- package/dist/adapters/prisma/registry.js.map +1 -1
- package/dist/adapters/prisma/unit-of-work.d.ts +2 -1
- package/dist/adapters/prisma/unit-of-work.js +2 -0
- package/dist/adapters/prisma/unit-of-work.js.map +1 -1
- package/dist/adapters/trpc/router.d.ts +1 -0
- package/dist/adapters/trpc/ship-protocol.js +2 -2
- package/dist/adapters/trpc/ship-protocol.js.map +1 -1
- package/dist/adapters/trpc/ship.d.ts +1 -0
- package/dist/adapters/trpc/ship.js +7 -1
- package/dist/adapters/trpc/ship.js.map +1 -1
- package/dist/domain/messaging/ports.d.ts +12 -0
- package/dist/domain/messaging/read-exchange.d.ts +12 -3
- package/dist/domain/messaging/read-exchange.js +6 -2
- package/dist/domain/messaging/read-exchange.js.map +1 -1
- package/dist/domain/shared/history-pruning.d.ts +3 -1
- package/package.json +2 -2
- package/src/adapters/prisma/migrations/20261110100000_pruned_exchanges/migration.sql +18 -0
- package/src/adapters/prisma/schema.prisma +23 -0
|
@@ -223,6 +223,18 @@ export interface ExchangeList {
|
|
|
223
223
|
shipId: ShipId;
|
|
224
224
|
} & PageQuery<MessageId>): Promise<Page<ListedExchange, MessageId>>;
|
|
225
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Outbound port: how far pruning went in each exchange
|
|
228
|
+
* (docs/design/exchange-history), one mark per pair of ships, written only by
|
|
229
|
+
* the pruning batch. Read without a lock.
|
|
230
|
+
*/
|
|
231
|
+
export interface PrunedExchanges {
|
|
232
|
+
/** The send time of the newest message of the two ships' exchange that pruning removed, whichever of them is named first; null when it removed none. */
|
|
233
|
+
prunedUpTo(fleetId: FleetId, exchange: {
|
|
234
|
+
shipId: ShipId;
|
|
235
|
+
otherShipId: ShipId;
|
|
236
|
+
}): Promise<Date | null>;
|
|
237
|
+
}
|
|
226
238
|
/** Outbound port: deliveries, always within one fleet. */
|
|
227
239
|
export interface DeliveryRepository {
|
|
228
240
|
/** Stores the delivery of the message, with its sender and whether it is in an exchange (E3). */
|
|
@@ -5,11 +5,12 @@ import { type DomainError } from '../shared/errors.js';
|
|
|
5
5
|
import { type Result } from '../shared/result.js';
|
|
6
6
|
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
7
7
|
import { type ListedPayload, type PayloadSealing } from './data-keys.js';
|
|
8
|
-
import type { DeliveryRepository, MessageRepository } from './ports.js';
|
|
8
|
+
import type { DeliveryRepository, MessageRepository, PrunedExchanges } from './ports.js';
|
|
9
9
|
export interface ReadExchangeTx extends HoldLeaseTx {
|
|
10
10
|
ships: Pick<ShipRepository, 'find'>;
|
|
11
11
|
messages: Pick<MessageRepository, 'find'>;
|
|
12
12
|
deliveries: Pick<DeliveryRepository, 'findExchangePage' | 'findOfMessageReaching'>;
|
|
13
|
+
prunedExchanges: PrunedExchanges;
|
|
13
14
|
}
|
|
14
15
|
/** The caller's own delivery of a message it received: its id and where it stands (docs/design/exchange-read, section 7). */
|
|
15
16
|
export interface ReceivedDelivery {
|
|
@@ -30,11 +31,16 @@ export interface ExchangeEntry {
|
|
|
30
31
|
deliveryState: DeliveryState | null;
|
|
31
32
|
receivedDelivery: ReceivedDelivery | null;
|
|
32
33
|
}
|
|
33
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* A page of an exchange, newest first, with the cursor each way while more lie
|
|
36
|
+
* that way, and the send time of the newest message of the exchange pruning
|
|
37
|
+
* removed, null when it removed none (docs/design/exchange-history).
|
|
38
|
+
*/
|
|
34
39
|
export interface ExchangePage {
|
|
35
40
|
items: ExchangeEntry[];
|
|
36
41
|
olderCursor: DeliveryId | null;
|
|
37
42
|
newerCursor: DeliveryId | null;
|
|
43
|
+
prunedUpTo: Date | null;
|
|
38
44
|
}
|
|
39
45
|
export type ReadExchangeRefusal = DomainError<'SHIP_NOT_FOUND' | 'MESSAGE_NOT_FOUND' | 'KEY_UNAVAILABLE'> | LeaseEnded;
|
|
40
46
|
export interface ExchangeToRead {
|
|
@@ -54,7 +60,10 @@ export type ReadExchange = (crew: Crew, input: ExchangeToRead) => Promise<Result
|
|
|
54
60
|
* (messages:receive) is checked before this runs. It holds the crew's lease
|
|
55
61
|
* and reads without a lock: it hands, counts and records nothing. In a sealed
|
|
56
62
|
* fleet each payload is unsealed, or marked unreadable when its key cannot be
|
|
57
|
-
* had (decision 0068, B9).
|
|
63
|
+
* had (decision 0068, B9). Every page answers how far pruning went in the
|
|
64
|
+
* exchange, read after the page's rows: a batch that commits between the two
|
|
65
|
+
* reads answers its messages with its mark, never the messages gone without
|
|
66
|
+
* it (docs/design/exchange-history, section 5).
|
|
58
67
|
*/
|
|
59
68
|
export declare function createReadExchange(deps: {
|
|
60
69
|
uow: UnitOfWork<ReadExchangeTx>;
|
|
@@ -13,7 +13,10 @@ import { isInExchange } from './exchange.js';
|
|
|
13
13
|
* (messages:receive) is checked before this runs. It holds the crew's lease
|
|
14
14
|
* and reads without a lock: it hands, counts and records nothing. In a sealed
|
|
15
15
|
* fleet each payload is unsealed, or marked unreadable when its key cannot be
|
|
16
|
-
* had (decision 0068, B9).
|
|
16
|
+
* had (decision 0068, B9). Every page answers how far pruning went in the
|
|
17
|
+
* exchange, read after the page's rows: a batch that commits between the two
|
|
18
|
+
* reads answers its messages with its mark, never the messages gone without
|
|
19
|
+
* it (docs/design/exchange-history, section 5).
|
|
17
20
|
*/
|
|
18
21
|
export function createReadExchange(deps) {
|
|
19
22
|
return (crew, input) => withDataKeysForList({ sealing: deps.sealing, fleetId: crew.fleetId }, (keys) => deps.uow.run(async (tx) => {
|
|
@@ -48,7 +51,8 @@ export function createReadExchange(deps) {
|
|
|
48
51
|
: { deliveryState: null, receivedDelivery: { deliveryId: delivery.id, state: delivery.state } }),
|
|
49
52
|
});
|
|
50
53
|
}
|
|
51
|
-
|
|
54
|
+
const prunedUpTo = await tx.prunedExchanges.prunedUpTo(crew.fleetId, { shipId: crew.shipId, otherShipId: input.otherShipId });
|
|
55
|
+
return ok({ items, olderCursor: page.value.olderCursor, newerCursor: page.value.newerCursor, prunedUpTo });
|
|
52
56
|
}));
|
|
53
57
|
}
|
|
54
58
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-exchange.js","sourceRoot":"","sources":["../../../src/domain/messaging/read-exchange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAoE,MAAM,sBAAsB,CAAC;AAElI,OAAO,EAA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@ export interface HistoryPruner {
|
|
|
146
146
|
* name, type, kind and dates kept, `removedAt` set, its scopes emptied,
|
|
147
147
|
* its note, owner and commission cleared, and its schedules gone, a kept
|
|
148
148
|
* message one of them sent naming no schedule; every other row naming it
|
|
149
|
-
* stays (decision 0070, D2 and D3).
|
|
149
|
+
* stays (decision 0070, D2 and D3). Before its messages go, it marks each
|
|
150
|
+
* exchange they reached with the newest send time among them, never moving
|
|
151
|
+
* a mark back (docs/design/exchange-history).
|
|
150
152
|
*/
|
|
151
153
|
go(fleetId: FleetId, set: PruneSet): Promise<PrunedCounts>;
|
|
152
154
|
/** Records where the fleet's finished history begins (R9). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeolus-fleet/core",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.6",
|
|
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.38.
|
|
62
|
+
"@aeolus-fleet/common": "0.38.6",
|
|
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,18 @@
|
|
|
1
|
+
-- How far pruning went in each exchange (docs/design/exchange-history): per pair of ships, the lower id
|
|
2
|
+
-- first, the send time of the newest message of their exchange that pruning removed. Written only by the
|
|
3
|
+
-- pruning batch. Nothing is marked here: what was pruned before it is not known per exchange (H4).
|
|
4
|
+
CREATE TABLE "pruned_exchanges" (
|
|
5
|
+
"fleet_id" TEXT NOT NULL,
|
|
6
|
+
"ship_id" TEXT NOT NULL,
|
|
7
|
+
"other_ship_id" TEXT NOT NULL,
|
|
8
|
+
"pruned_up_to" TIMESTAMPTZ(3) NOT NULL,
|
|
9
|
+
|
|
10
|
+
CONSTRAINT "pruned_exchanges_pkey" PRIMARY KEY ("fleet_id", "ship_id", "other_ship_id")
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
-- Backs the foreign key to the other ship, as every foreign key is backed; the read uses the primary key alone.
|
|
14
|
+
CREATE INDEX "pruned_exchanges_fleet_id_other_ship_id_idx" ON "pruned_exchanges"("fleet_id", "other_ship_id");
|
|
15
|
+
|
|
16
|
+
ALTER TABLE "pruned_exchanges" ADD CONSTRAINT "pruned_exchanges_fleet_id_fkey" FOREIGN KEY ("fleet_id") REFERENCES "fleets"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
17
|
+
ALTER TABLE "pruned_exchanges" ADD CONSTRAINT "pruned_exchanges_fleet_id_ship_id_fkey" FOREIGN KEY ("fleet_id", "ship_id") REFERENCES "ships"("fleet_id", "id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
18
|
+
ALTER TABLE "pruned_exchanges" ADD CONSTRAINT "pruned_exchanges_fleet_id_other_ship_id_fkey" FOREIGN KEY ("fleet_id", "other_ship_id") REFERENCES "ships"("fleet_id", "id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -94,6 +94,7 @@ model Fleet {
|
|
|
94
94
|
messages Message[]
|
|
95
95
|
messageDays MessageDay[]
|
|
96
96
|
exchanges Exchange[]
|
|
97
|
+
prunedExchanges PrunedExchange[]
|
|
97
98
|
deliveries Delivery[]
|
|
98
99
|
overdueDeliveries OverdueDelivery[]
|
|
99
100
|
events Event[]
|
|
@@ -194,6 +195,8 @@ model Ship {
|
|
|
194
195
|
scheduledTo Schedule[] @relation("ScheduleSelectorShip")
|
|
195
196
|
exchanges Exchange[] @relation("ExchangeShip")
|
|
196
197
|
exchangedWith Exchange[] @relation("ExchangeOtherShip")
|
|
198
|
+
prunedExchanges PrunedExchange[] @relation("PrunedExchangeShip")
|
|
199
|
+
prunedExchangesWith PrunedExchange[] @relation("PrunedExchangeOtherShip")
|
|
197
200
|
|
|
198
201
|
@@unique([fleetId, id])
|
|
199
202
|
/// An idempotency key is used once per commissioning actor.
|
|
@@ -747,6 +750,26 @@ model Exchange {
|
|
|
747
750
|
@@map("exchanges")
|
|
748
751
|
}
|
|
749
752
|
|
|
753
|
+
/// How far pruning went in one exchange (docs/design/exchange-history): the send time of the newest
|
|
754
|
+
/// message of the two ships' exchange that pruning removed, only ever moved forward. One row per pair,
|
|
755
|
+
/// the lower ship id first; a ship's exchange with itself names it twice. Written only by the pruning
|
|
756
|
+
/// batch, in its transaction. No foreign key to a message: what it points at is gone.
|
|
757
|
+
model PrunedExchange {
|
|
758
|
+
fleetId String @map("fleet_id")
|
|
759
|
+
shipId String @map("ship_id")
|
|
760
|
+
otherShipId String @map("other_ship_id")
|
|
761
|
+
prunedUpTo DateTime @map("pruned_up_to") @db.Timestamptz(3)
|
|
762
|
+
|
|
763
|
+
fleet Fleet @relation(fields: [fleetId], references: [id], onDelete: Restrict)
|
|
764
|
+
ship Ship @relation("PrunedExchangeShip", fields: [fleetId, shipId], references: [fleetId, id], onDelete: Restrict)
|
|
765
|
+
otherShip Ship @relation("PrunedExchangeOtherShip", fields: [fleetId, otherShipId], references: [fleetId, id], onDelete: Restrict)
|
|
766
|
+
|
|
767
|
+
@@id([fleetId, shipId, otherShipId])
|
|
768
|
+
/// Backs the foreign key to the other ship; the read uses the primary key alone.
|
|
769
|
+
@@index([fleetId, otherShipId])
|
|
770
|
+
@@map("pruned_exchanges")
|
|
771
|
+
}
|
|
772
|
+
|
|
750
773
|
/// An immutable envelope plus an opaque payload of at most 256 KB, sent by one ship.
|
|
751
774
|
/// Ids start with msg_. The selector is stored as resolved at send time: a ship's
|
|
752
775
|
/// id, never its name, or a type. It can name the message it replies to, and a
|