@byok-sdk/cloud-dataplane 0.4.0 → 0.4.2

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.
@@ -0,0 +1,13 @@
1
+ -- Bounded, lossy approval lifecycle observations for host-side projection.
2
+ -- This is deliberately separate from activity_tail: approval envelopes have
3
+ -- no authoritative order key shared with task.progress batches.
4
+ CREATE TABLE approval_timeline_tail (
5
+ tenant_id text NOT NULL,
6
+ task_id text NOT NULL,
7
+ entries jsonb NOT NULL,
8
+ next_revision bigint NOT NULL,
9
+ dropped integer NOT NULL,
10
+ capacity integer NOT NULL,
11
+ expires_at text NOT NULL,
12
+ PRIMARY KEY (tenant_id, task_id)
13
+ );
@@ -0,0 +1,10 @@
1
+ import { type ActivityAppendInput, type ActivityStore, type ActivityTail } from '@byok-sdk/cloud';
2
+ import type { Clock, TenantId } from '@byok-sdk/core';
3
+ import type { Pool } from 'pg';
4
+ export declare class PostgresActivityStore implements ActivityStore {
5
+ private readonly pool;
6
+ private readonly clock;
7
+ constructor(pool: Pool, clock: Clock);
8
+ append(tenant: TenantId, input: ActivityAppendInput): Promise<ActivityTail>;
9
+ read(tenant: TenantId, taskId: string): Promise<ActivityTail | undefined>;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { type ApprovalTimelineAppendInput, type ApprovalTimelineStore, type ApprovalTimelineTail } from '@byok-sdk/cloud';
2
+ import type { Clock, TenantId } from '@byok-sdk/core';
3
+ import type { Pool } from 'pg';
4
+ export declare class PostgresApprovalTimelineStore implements ApprovalTimelineStore {
5
+ private readonly pool;
6
+ private readonly clock;
7
+ constructor(pool: Pool, clock: Clock);
8
+ append(tenant: TenantId, input: ApprovalTimelineAppendInput): Promise<ApprovalTimelineTail>;
9
+ read(tenant: TenantId, taskId: string): Promise<ApprovalTimelineTail | undefined>;
10
+ }
@@ -1,17 +1,17 @@
1
1
  /**
2
- * The Postgres composition of the eight `@byok-sdk/core` ports.
2
+ * The Postgres composition of the seven `@byok-sdk/core` ports.
3
3
  *
4
- * All eight, or none: `runCoreConformance`'s port-inventory dimension asserts a
4
+ * All seven, or none: `runCoreConformance`'s port-inventory dimension asserts a
5
5
  * composition supplies exactly `CORE_STORE_NAMES` and exactly the methods
6
6
  * `CORE_PORT_METHODS` declares, so there is no such thing as a partial core
7
7
  * composition to certify. The original seven landed in one slice (design §11);
8
- * `skillPacks` is the eighth, added in Phase 2 of `skill-pack-delivery-channel`
8
+ * `skillPacks` joined in Phase 2 of `skill-pack-delivery-channel`
9
9
  * when it graduated from a bridge port to a mandatory `CoreStores` member. This
10
10
  * function returns a full `CoreStores` where the cloud-local sibling returns a
11
11
  * named subset.
12
12
  *
13
13
  * Everything that reads time reads the injected clock. Nothing calls SQL
14
- * `now()` — presence expiry, activity expiry and reservation expiry are all
14
+ * `now()` — presence expiry and reservation expiry are both
15
15
  * contract behavior the suite asserts by moving a test clock, and a store that
16
16
  * asked the database for the time would make every one of those assertions
17
17
  * either a sleep or a flake.
@@ -21,7 +21,7 @@ import type { Pool } from 'pg';
21
21
  export { PostgresMailboxStore } from './mailbox';
22
22
  export { PostgresBoardStore } from './board';
23
23
  export { PostgresTruthStore } from './truth';
24
- export { PostgresPresenceStore, PostgresActivityStore } from './presence';
24
+ export { PostgresPresenceStore } from './presence';
25
25
  export { PostgresObjectStore } from './objects';
26
26
  export { PostgresQuotaStore } from './quota';
27
27
  export { PostgresSkillPackStore } from './skill-pack';
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Postgres {@link PresenceStore} and {@link ActivityStore} (§12.3).
2
+ * Postgres {@link PresenceStore} (§12.3).
3
3
  *
4
- * Both are lossy, TTL-bounded, unsigned, and never authoritative, and both are
5
- * bounded upserts: one row per device, one row per task. Nothing here may be
4
+ * Presence is lossy, TTL-bounded, unsigned, and never authoritative. It is a
5
+ * bounded upsert with one row per device. Nothing here may be
6
6
  * used to derive coordination state, execution state, authorization, billing or
7
7
  * recovery — which is why this file shares no vocabulary with `board.ts` and
8
8
  * none with the frozen wire states.
@@ -17,7 +17,7 @@
17
17
  * clock means sleeping or accepting flakes, which is why the port takes `ttlMs`
18
18
  * and the composition supplies the clock.
19
19
  */
20
- import { type ActivityAppendInput, type ActivityStore, type ActivityTail, type Clock, type PresenceHint, type PresenceHintInput, type PresenceStore, type TenantId } from '@byok-sdk/core';
20
+ import { type Clock, type PresenceHint, type PresenceHintInput, type PresenceStore, type TenantId } from '@byok-sdk/core';
21
21
  import type { Pool } from 'pg';
22
22
  export declare class PostgresPresenceStore implements PresenceStore {
23
23
  #private;
@@ -26,9 +26,3 @@ export declare class PostgresPresenceStore implements PresenceStore {
26
26
  read(tenant: TenantId, deviceId: string): Promise<PresenceHint | undefined>;
27
27
  list(tenant: TenantId): Promise<readonly PresenceHint[]>;
28
28
  }
29
- export declare class PostgresActivityStore implements ActivityStore {
30
- #private;
31
- constructor(pool: Pool, clock: Clock);
32
- append(tenant: TenantId, input: ActivityAppendInput): Promise<ActivityTail>;
33
- read(tenant: TenantId, taskId: string): Promise<ActivityTail | undefined>;
34
- }
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * The Postgres composition of the cloud-local ports.
3
3
  *
4
- * Seven durable stores, one object-storage blob store, one in-memory limiter:
4
+ * Nine durable stores, one object-storage blob store, one in-memory limiter:
5
5
  *
6
6
  * - Six durable ones have rows in `deploy/sql/0001_cloud_local.sql`; S6's
7
- * proof receipt authority is the seventh, in `0004_device_proof_truth.sql`.
7
+ * proof receipt authority is the seventh, in `0004_device_proof_truth.sql`;
8
+ * typed activity uses the JSONB tail row in `0002_core_domain.sql`; approval
9
+ * lifecycle observations use `0007_approval_timeline.sql`.
8
10
  * - `blobs` is the R2 adapter over the `object_manifest` row the core store
9
11
  * already owns: metadata in Postgres, bytes in the object store, one
10
12
  * reserve/verify protocol binding them (design §6). It supplies grants only,
@@ -29,10 +31,12 @@ export { PostgresPairingCodeStore } from './pairing-codes';
29
31
  export { PostgresRequestReceiptStore } from './receipts';
30
32
  export { PostgresProofRequestReceiptStore } from './proof-receipts';
31
33
  export { PostgresTaskAttemptStore } from './task-attempts';
34
+ export { PostgresActivityStore } from './activity';
35
+ export { PostgresApprovalTimelineStore } from './approval-timeline';
32
36
  export { DEFAULT_MAX_ATTEMPTS, DEFAULT_PRESIGN_TTL_SECONDS, DEFAULT_RETRY_DELAY_MS, MAX_PRESIGN_TTL_SECONDS, MIN_PRESIGN_TTL_SECONDS, ObjectStoreRequestError, R2_BLOB_ERROR_CODES, R2BlobStoreError, R2CloudBlobStore, R2ObjectMaintenanceStore, } from './r2-blobs';
33
37
  export type { ObjectStoreFetch, R2BlobErrorCode, R2BlobStoreOptions } from './r2-blobs';
34
38
  export type { R2DeleteResult, R2ListedObject, R2ObjectMaintenance, R2ObjectMaintenanceOptions, R2ObjectPage, } from './r2-blobs';
35
- /** Every cloud-local port. All nine, or it is not a composition. */
39
+ /** Every cloud-local port. All eleven, or it is not a composition. */
36
40
  export type PostgresCloudStores = CloudStores;
37
41
  /** Everything the blob store needs that is not already a composition-wide input. */
38
42
  export type PostgresObjectStorageOptions = Omit<R2BlobStoreOptions, 'objects'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byok-sdk/cloud-dataplane",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "BYOK SDK hosted data plane: canonical Postgres + R2 stores, migrations, truth transactions, and maintenance",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "homepage": "https://github.com/Ancienttwo/byok-sdk#readme",
16
16
  "engines": {
17
- "node": ">=22.19.0"
17
+ "node": ">=22.22.0"
18
18
  },
19
19
  "sideEffects": false,
20
20
  "main": "./dist/index.js",
@@ -25,6 +25,10 @@
25
25
  "types": "./dist/index.d.ts",
26
26
  "import": "./dist/index.js"
27
27
  },
28
+ "./runtime": {
29
+ "types": "./dist/runtime.d.ts",
30
+ "import": "./dist/runtime.js"
31
+ },
28
32
  "./package.json": "./package.json"
29
33
  },
30
34
  "files": [
@@ -35,25 +39,27 @@
35
39
  "publishConfig": {
36
40
  "access": "public"
37
41
  },
38
- "dependencies": {
39
- "aws4fetch": "1.0.20",
40
- "fast-xml-parser": "^5.10.1",
41
- "pg": "^8.22.0",
42
- "@byok-sdk/cloud": "0.4.0",
43
- "@byok-sdk/protocol": "0.4.0",
44
- "@byok-sdk/core": "0.4.0"
45
- },
46
- "devDependencies": {
47
- "@types/pg": "^8.20.4",
48
- "undici": "8.9.0",
49
- "@byok-sdk/conformance": "0.0.0"
50
- },
51
42
  "scripts": {
52
43
  "build": "tsup && tsc -p tsconfig.build.json && node scripts/copy-migrations.mjs",
53
44
  "dev": "tsup --watch",
54
45
  "test": "vitest run",
55
46
  "test:watch": "vitest",
47
+ "test:worker": "vitest run src/__tests__/runtime-entry.test.ts src/__tests__/worker-packaging.test.ts",
56
48
  "typecheck": "tsc --noEmit",
57
49
  "clean": "rm -rf dist"
50
+ },
51
+ "dependencies": {
52
+ "@byok-sdk/cloud": "0.4.2",
53
+ "@byok-sdk/core": "0.4.2",
54
+ "@byok-sdk/protocol": "0.4.2",
55
+ "aws4fetch": "1.0.20",
56
+ "fast-xml-parser": "^5.10.1",
57
+ "pg": "^8.22.0"
58
+ },
59
+ "devDependencies": {
60
+ "@byok-sdk/conformance": "0.0.0",
61
+ "@types/pg": "^8.20.4",
62
+ "undici": "8.9.0",
63
+ "wrangler": "4.123.0"
58
64
  }
59
- }
65
+ }