@di-framework/pglite-component 6.0.15 → 6.0.16
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/README.md +71 -5
- package/dist/BUILD-INFO.txt +7 -5
- package/dist/SHA256SUMS +3 -3
- package/dist/THIRD-PARTY-NOTICES.txt +29 -13
- package/dist/di-framework-pglite.wasm +0 -0
- package/package.json +1 -1
- package/wit/world.wit +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# di-framework:pglite — embedded PostgreSQL over WIT
|
|
2
2
|
|
|
3
|
-
The provider bundles
|
|
3
|
+
The provider bundles a PostgreSQL 17.11 engine, built for WASI, into a WebAssembly
|
|
4
4
|
component. SQL calls cross WIT and WebAssembly memory. There is no TCP listener,
|
|
5
5
|
network client, native sidecar, or separate database service.
|
|
6
6
|
|
|
@@ -59,6 +59,24 @@ is cached under `target/engine`. Containers are build tools only; deployment
|
|
|
59
59
|
runs the resulting `.wasm` directly. For a remote Podman daemon, set the task's
|
|
60
60
|
`DOCKER_CONTEXT=podman`.
|
|
61
61
|
|
|
62
|
+
### Engine source
|
|
63
|
+
|
|
64
|
+
The engine is upstream PostgreSQL `REL_17_11` with ElectricSQL's PGlite WASI
|
|
65
|
+
changes replayed onto it. Electric maintains no WASI branch past 17.5 (its newer
|
|
66
|
+
branches are Emscripten-only), so the 17.5 WASI changes are carried as
|
|
67
|
+
[`engine/patches/postgresql-17.11-wasi.patch`](engine/patches/README.md)
|
|
68
|
+
(PostgreSQL License). `scripts/build-engine.ts` fetches the tag pinned in
|
|
69
|
+
`scripts/tool-versions.env` (`POSTGRES_SOURCE_TAG`), refuses it unless it
|
|
70
|
+
resolves to `POSTGRES_SOURCE_COMMIT`, and applies that patch and then the
|
|
71
|
+
[wasipg](https://github.com/moznion/wasipg) recipe's sjlj patches, checking each
|
|
72
|
+
before applying it. `scripts/patch-engine-source.ts` adds the di-framework
|
|
73
|
+
changes described in `engine/NOTICE`.
|
|
74
|
+
|
|
75
|
+
`make check-engine-patch` runs all of those steps without the container build,
|
|
76
|
+
in about 30 seconds. Run it first after bumping the PostgreSQL release: a patch
|
|
77
|
+
that no longer applies fails with its name, the base, and git's output. Then
|
|
78
|
+
follow [engine/patches/README.md](engine/patches/README.md).
|
|
79
|
+
|
|
62
80
|
The build embeds the support filesystem, adapts the engine's WASI Preview 1
|
|
63
81
|
imports to Preview 2, and composes the engine with the Rust database provider.
|
|
64
82
|
It fails if the final artifact imports sockets or leaves the engine unresolved.
|
|
@@ -98,6 +116,14 @@ and persistence across separate runtime processes. It also exits a runtime
|
|
|
98
116
|
with an open transaction and verifies that committed rows survive and the
|
|
99
117
|
uncommitted row is absent after restart. No scripted database server is used.
|
|
100
118
|
|
|
119
|
+
`make smoke` also checks upgrades from the previous release. It downloads the
|
|
120
|
+
published `@di-framework/pglite-component` tarball pinned as
|
|
121
|
+
`PGLITE_UPGRADE_FROM_*` in `scripts/tool-versions.env` (6.0.15, PostgreSQL
|
|
122
|
+
17.5) and checks its sha256. Its provider writes a data directory with a table,
|
|
123
|
+
pgcrypto and PGP ciphertext. The new build must then open that directory,
|
|
124
|
+
report 17.11, read the rows, decrypt the old ciphertext, run pgcrypto on new
|
|
125
|
+
values, and write to it.
|
|
126
|
+
|
|
101
127
|
## Publishing to GHCR
|
|
102
128
|
|
|
103
129
|
The pglite component is published to GitHub Container Registry (GHCR) as an OCI wasm component. [The workflow](https://github.com/di-framework/platform/actions/workflows/pglite-component-publish.yml) runs by itself on each push to `main` that changes one of its input paths (`on.push.paths`). `workflow_dispatch` stays available for reruns and always builds.
|
|
@@ -113,7 +139,7 @@ Tags are movable. `0.2.0` always points to the latest `main` publish for WIT pac
|
|
|
113
139
|
### Artifact location
|
|
114
140
|
|
|
115
141
|
The digest is in **Details** > **Record component digest** > **Step summary**, and in the `pglite-publish-report` artifact (`publish-report.json`).
|
|
116
|
-
Published digest: `ghcr.io/di-framework/pglite-component@sha256:
|
|
142
|
+
Published digest: `ghcr.io/di-framework/pglite-component@sha256:9be0cc2f59efea9ade293173ca28bd289a5505eb31b08fb954e718c03316355e`
|
|
117
143
|
|
|
118
144
|
**Note:** The GHCR package must be made public by an org admin after the first publish. Until then, only members with access to di-framework/platform can pull it.
|
|
119
145
|
|
|
@@ -151,7 +177,7 @@ wasmtime run --dir ./data::/data path/to/app.composed.wasm
|
|
|
151
177
|
To use the published OCI component from GHCR instead (pin by digest for reproducibility):
|
|
152
178
|
|
|
153
179
|
```sh
|
|
154
|
-
export PGLITE_REF='ghcr.io/di-framework/pglite-component@sha256:
|
|
180
|
+
export PGLITE_REF='ghcr.io/di-framework/pglite-component@sha256:9be0cc2f59efea9ade293173ca28bd289a5505eb31b08fb954e718c03316355e'
|
|
155
181
|
wash oci pull "${PGLITE_REF}" pglite.wasm
|
|
156
182
|
wac plug --plug pglite.wasm path/to/app.wasm -o path/to/app.composed.wasm
|
|
157
183
|
mkdir -p ./data
|
|
@@ -319,7 +345,12 @@ Blowfish (`bf`), CAST5 (`cast5`) and single DES (`des`) are unavailable in
|
|
|
319
345
|
this build, because the OpenSSL legacy provider is not built or loaded.
|
|
320
346
|
pgcrypto refuses them with `Cipher cannot be initialized`: in `encrypt()` and
|
|
321
347
|
`decrypt()`, in the PGP functions, and when decrypting PGP messages that use
|
|
322
|
-
them.
|
|
348
|
+
them. For PGP this is upstream PostgreSQL's own check (17.11, CVE-2026-14663);
|
|
349
|
+
pgcrypto is otherwise unmodified. Provider releases before the #355 fix wrote
|
|
350
|
+
Blowfish and CAST5 PGP messages that are not actually encrypted. To recover such
|
|
351
|
+
a message, decrypt it once with upstream's `ignore-cipher-failure=1` option
|
|
352
|
+
(`pgp_sym_decrypt`, `pgp_pub_decrypt`; decryption only), then re-encrypt it with
|
|
353
|
+
AES. Plaintext recovered that way is not authenticated by the key. `3des` (DES-EDE3) is in OpenSSL's default provider and still works, for
|
|
323
354
|
legacy data only. Use `aes` (`aes128`, `aes192`, `aes256` for PGP). Password hashing with
|
|
324
355
|
`crypt()` and `gen_salt('bf')`, `'md5'`, `'xdes'` or `'des'` is unaffected,
|
|
325
356
|
because pgcrypto implements those itself.
|
|
@@ -339,7 +370,8 @@ For an `open("/data/orders", ...)` call:
|
|
|
339
370
|
|
|
340
371
|
Mount the entire root on persistent storage and reuse it after restarts.
|
|
341
372
|
Initialization creates the cluster once; later starts reuse it. Incomplete
|
|
342
|
-
clusters
|
|
373
|
+
clusters are rejected, and so is a data directory from another PostgreSQL major
|
|
374
|
+
version (see [below](#upgrading-across-postgresql-major-versions)).
|
|
343
375
|
`fsync`, `synchronous_commit`, and `full_page_writes` are enabled before the
|
|
344
376
|
backend starts. The host filesystem must honor WASI sync operations; a local
|
|
345
377
|
restart test is not a power-loss durability certification.
|
|
@@ -370,6 +402,38 @@ its components the matching WASI preopen. Use a stable workload identity on
|
|
|
370
402
|
redeploy and configure exclusive execution for this database. These
|
|
371
403
|
annotations provide storage; they do not enforce database ownership.
|
|
372
404
|
|
|
405
|
+
## Upgrading across PostgreSQL major versions
|
|
406
|
+
|
|
407
|
+
A data directory belongs to one PostgreSQL major version, recorded in
|
|
408
|
+
`<root>/data/PG_VERSION`. Minor releases share the on-disk format: a directory
|
|
409
|
+
written by the 17.5 engine (provider 6.0.15 and earlier) opens in place under
|
|
410
|
+
17.11, and `make smoke` checks this.
|
|
411
|
+
|
|
412
|
+
The engine opens only major version 17. For any other `PG_VERSION`, `open`
|
|
413
|
+
fails with `open-failed` and a message such as:
|
|
414
|
+
|
|
415
|
+
```text
|
|
416
|
+
incompatible PostgreSQL data directory: PG_VERSION is 16, but this provider bundles
|
|
417
|
+
PostgreSQL 17.11 and opens only major version 17 data directories; see
|
|
418
|
+
platform/pglite-component/README.md#upgrading-across-postgresql-major-versions
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
The provider does not convert directories between major versions; it bundles
|
|
422
|
+
neither a second engine nor `pg_upgrade`. To move a database across a major
|
|
423
|
+
version:
|
|
424
|
+
|
|
425
|
+
1. Stop every writer. Keep the provider version that wrote the directory,
|
|
426
|
+
pinned by its digest or npm version, and back up the whole root.
|
|
427
|
+
2. With that provider, export the data through the application, for example
|
|
428
|
+
with a migration step that reads each table through the `database`
|
|
429
|
+
interface into a portable format.
|
|
430
|
+
3. Deploy the new provider on a new, empty root, and recreate the schema with
|
|
431
|
+
the application's migrations.
|
|
432
|
+
4. Import the exported data, check it, then retire the old root.
|
|
433
|
+
|
|
434
|
+
If the root is encrypted with `pglite-encfs`, compose encfs with the same key
|
|
435
|
+
for both the export and the import. PostgreSQL 18 is tracked in #401.
|
|
436
|
+
|
|
373
437
|
## Implementation
|
|
374
438
|
|
|
375
439
|
- `js/adapter.ts`: the `SqlDatabase` adapter published on npm (`bun run build:adapter`).
|
|
@@ -380,6 +444,8 @@ annotations provide storage; they do not enforce database ownership.
|
|
|
380
444
|
- `engine/bridge.wat`: private canonical ABI bridge to the core engine.
|
|
381
445
|
- `engine/build-pgcrypto.sh`: builds OpenSSL libcrypto and pgcrypto in the engine container and generates pgcrypto's static `dlsym` table; `scripts/patch-engine-source.ts` links both into the engine. The libcrypto build is cached under a key of the OpenSSL source tarball's sha256, the Configure options and `SOURCE_DATE_EPOCH`, so an OpenSSL version bump always rebuilds it.
|
|
382
446
|
- `scripts/patch-engine-source.ts`: also replaces the upstream `dlopen` emulation's unbounded table (`dltab`) with the bounded one described under [Extensions](#extensions), and keeps pgcrypto's hook ahead of it.
|
|
447
|
+
- `engine/patches/postgresql-17.11-wasi.patch`: Electric's 17.5 WASI changes replayed onto upstream `REL_17_11`; see [engine/patches/README.md](engine/patches/README.md).
|
|
448
|
+
- `scripts/build-engine.ts`: builds the engine source tree (pinned tag, checked commit, checked patches) and runs the wasipg container build; `scripts/check-engine-patch.ts` (`make check-engine-patch`) runs the same source steps without the build.
|
|
383
449
|
- `scripts/prepare-engine.ts`: pinned engine preparation and componentization (all build scripts are Bun TypeScript; see `scripts/`).
|
|
384
450
|
- `wit/deps/pglite-engine/engine.wit`: internal interface, composed away at build.
|
|
385
451
|
|
package/dist/BUILD-INFO.txt
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
component: di-framework:pglite@0.2.0
|
|
2
2
|
profile: release
|
|
3
|
-
built: 2026-10-
|
|
3
|
+
built: 2026-10-16T17:04:13Z
|
|
4
4
|
rustc: rustc 1.97.1 (8bab26f4f 2026-07-14)
|
|
5
5
|
target: wasm32-wasip2
|
|
6
6
|
wasm-tools: wasm-tools 1.258.0 (5c6d31c78 2026-08-24)
|
|
7
7
|
wit-bindgen: 0.61.1
|
|
8
8
|
md5: 0.7.0
|
|
9
|
-
engine: PostgreSQL 17.
|
|
9
|
+
engine: PostgreSQL 17.11, persistent WASI filesystem
|
|
10
10
|
extensions: plpgsql, pgcrypto (OpenSSL 3.5.9 libcrypto)
|
|
11
|
-
engine-source: https://github.com/
|
|
11
|
+
engine-source: https://github.com/postgres/postgres/tree/083ac033419f690758508e08c1736089384bbee8 (REL_17_11)
|
|
12
|
+
engine-patch: engine/patches/postgresql-17.11-wasi.patch (sha256 6beb64a561caa80e3669733f9e24e344edb0445d2623c17eee79d48ec28fac65)
|
|
13
|
+
engine-recipe: https://github.com/moznion/wasipg/tree/fa290be67946c0d3c4540bd1400b11e193d874e1
|
|
12
14
|
adapter-sha256: e51dd61669a20daca34befe7fdadf1ac84e4795a2c84a8400818ee1de5373ccc
|
|
13
|
-
engine-sha256:
|
|
14
|
-
size:
|
|
15
|
+
engine-sha256: eb374344cff24c4cedacdad05a636a3b75b5eb1c4e55aa1a3ff9930be2ebc328
|
|
16
|
+
size: 20168533 bytes
|
package/dist/SHA256SUMS
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
a98a0476f61d539c72458be572d5705c8a237a49d51329784b65d564fab1b657 di-framework-pglite.wasm
|
|
2
2
|
6053154ec1bc94de63ce4f4f4cce5922ef57dce794c2dde326f5845b8982d35f di-framework-pglite.wit
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
f76f82266b1f741e10c5c89e6c30f620571adba6bb228a33324681d2dc1822b3 BUILD-INFO.txt
|
|
4
|
+
443fd294671eb64972556656d3ee871e48448ad1169c012d18aa868568f628c1 THIRD-PARTY-NOTICES.txt
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
di-framework embedded PGlite component
|
|
2
2
|
|
|
3
|
-
The provider bundles PostgreSQL 17.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
The provider bundles PostgreSQL 17.11 built for WASI. The engine source is
|
|
4
|
+
upstream PostgreSQL REL_17_11 (commit 083ac033419f690758508e08c1736089384bbee8)
|
|
5
|
+
with ElectricSQL's PGlite WASI changes from postgres-pglite branch
|
|
6
|
+
REL_17_5_WASM-pglite (commit 2194acf356e9b7bf7cff29c4ed4bd6b82b93895d) replayed
|
|
7
|
+
onto it; that replay is engine/patches/postgresql-17.11-wasi.patch in the
|
|
8
|
+
di-framework source. PostgreSQL, postgres-pglite and the replay patch are
|
|
9
|
+
distributed under the PostgreSQL License, reproduced in POSTGRESQL-COPYRIGHT.
|
|
10
|
+
The engine is built with the wasipg recipe and its sjlj patches (Apache-2.0;
|
|
11
|
+
notice below). The upstream bindings license and WASI adapter license are
|
|
12
|
+
reproduced in PGLITE-BINDINGS-LICENSE and WASMTIME-LICENSE. The engine
|
|
13
|
+
statically links the pgcrypto extension and OpenSSL libcrypto; their notices
|
|
14
|
+
are in PGCRYPTO-NOTICES and the OpenSSL license (Apache-2.0) in
|
|
15
|
+
OPENSSL-LICENSE.
|
|
9
16
|
|
|
10
17
|
Sources:
|
|
11
|
-
https://github.com/
|
|
18
|
+
https://github.com/postgres/postgres/tree/REL_17_11
|
|
19
|
+
https://github.com/electric-sql/postgres-pglite/tree/REL_17_5_WASM-pglite
|
|
12
20
|
https://github.com/electric-sql/pglite-bindings
|
|
13
21
|
https://github.com/moznion/wasipg
|
|
14
22
|
https://github.com/bytecodealliance/wasmtime/tree/v29.0.1
|
|
@@ -21,9 +29,17 @@ bootstrap files within the database's persistent filesystem mount. A growable,
|
|
|
21
29
|
bounded memory buffer replaces socket-file spillover for query replies. Backend
|
|
22
30
|
startup restores application session defaults after bootstrap and enables
|
|
23
31
|
durable writes. The emulated dlopen keeps loaded libraries in a bounded table
|
|
24
|
-
instead of writing past the end of an unsized array.
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
instead of writing past the end of an unsized array. Two small changes to the
|
|
33
|
+
WASI glue let it compile against 17.11: initdb's frontend SplitGUCList
|
|
34
|
+
declaration is renamed where initdb is compiled into the backend, and the
|
|
35
|
+
frontend allocator stubs gain the overflow-checked pg_malloc_mul and
|
|
36
|
+
pg_realloc_mul. pgcrypto is unmodified: PostgreSQL 17.11 itself refuses
|
|
37
|
+
ciphers OpenSSL cannot run (CVE-2026-14663), which in this build includes
|
|
38
|
+
Blowfish and CAST5.
|
|
39
|
+
|
|
40
|
+
The wasipg notice below describes wasipg's own release artifacts, which were
|
|
41
|
+
built from REL_17_5_WASM-pglite; this provider uses wasipg's build recipe and
|
|
42
|
+
patches with the 17.11 source tree above.
|
|
27
43
|
|
|
28
44
|
The engine's core module, support files, adapter, and the provider are
|
|
29
45
|
composed into one deployable artifact. Engine code executes in the Wasm
|
|
@@ -86,9 +102,9 @@ wasi-libc from wasi-sdk 33, distributed under
|
|
|
86
102
|
"Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT". The shadow headers
|
|
87
103
|
under build/hotfix/ are derived from wasi-libc headers.
|
|
88
104
|
PostgreSQL Database Management System
|
|
89
|
-
(
|
|
105
|
+
(also known as Postgres, formerly known as Postgres95)
|
|
90
106
|
|
|
91
|
-
Portions Copyright (c) 1996-
|
|
107
|
+
Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
|
|
92
108
|
|
|
93
109
|
Portions Copyright (c) 1994, The Regents of the University of California
|
|
94
110
|
|
|
@@ -110,7 +126,7 @@ ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
|
|
|
110
126
|
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
111
127
|
|
|
112
128
|
--------------------------------------------------------------------------
|
|
113
|
-
pgcrypto (PostgreSQL 17.
|
|
129
|
+
pgcrypto (PostgreSQL 17.11 contrib/pgcrypto)
|
|
114
130
|
--------------------------------------------------------------------------
|
|
115
131
|
|
|
116
132
|
pgcrypto is part of PostgreSQL and is distributed under the PostgreSQL
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@di-framework/pglite-component",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Embedded PostgreSQL component with persistent WASI storage and no TCP, plus its SqlDatabase adapter for @di-framework/repo.",
|
|
6
6
|
"license": "(MIT OR Apache-2.0)",
|
package/wit/world.wit
CHANGED
|
@@ -114,7 +114,7 @@ interface database {
|
|
|
114
114
|
/// are supported. Close/drop releases the connection for reuse at that root.
|
|
115
115
|
open: func(path: string, options: option<open-options>) -> result<connection, error>;
|
|
116
116
|
|
|
117
|
-
/// The bundled engine version string, `17.
|
|
117
|
+
/// The bundled engine version string, `17.11`; does not open a database.
|
|
118
118
|
server-version: func() -> result<string, error>;
|
|
119
119
|
|
|
120
120
|
/// An exclusive handle to the embedded session. Closing or dropping it
|