chord-postgres 0.0.0-stage → 0.1.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/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +271 -3
- package/dist/catalog.d.ts +25 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +71 -0
- package/dist/catalog.js.map +1 -0
- package/dist/database.d.ts +76 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +468 -0
- package/dist/database.js.map +1 -0
- package/dist/dialect.d.ts +73 -0
- package/dist/dialect.d.ts.map +1 -0
- package/dist/dialect.js +671 -0
- package/dist/dialect.js.map +1 -0
- package/dist/errors.d.ts +31 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +45 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/pi-durable.d.ts +47 -0
- package/dist/pi-durable.d.ts.map +1 -0
- package/dist/pi-durable.js +97 -0
- package/dist/pi-durable.js.map +1 -0
- package/dist/queue.d.ts +17 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +37 -0
- package/dist/queue.js.map +1 -0
- package/docs/dialect.md +103 -0
- package/docs/port-chord-1.7.md +83 -0
- package/docs/port-chord-template.md +64 -0
- package/package.json +95 -4
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Port to chord 1.7.0
|
|
2
|
+
|
|
3
|
+
A port note per chord release, as `docs/port-chord-<version>.md`. It records what moved, what it cost, and what would
|
|
4
|
+
have been missed — so the next port starts from evidence instead of a fresh diff. (The idea comes from
|
|
5
|
+
[gscode1/pi-durable-postgres](https://github.com/gscode1/pi-durable-postgres)'s `docs/port-1.5.md`, which is the most
|
|
6
|
+
useful artefact in this ecosystem.)
|
|
7
|
+
|
|
8
|
+
## What this package is verified against
|
|
9
|
+
|
|
10
|
+
| | Version |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `@earendil-works/chord` | 1.7.0 |
|
|
13
|
+
| `@earendil-works/pi-durable` | 1.7.0 |
|
|
14
|
+
| Postgres | 16 (local development) and 18 (the CI service) |
|
|
15
|
+
| Node | 26.13.1 |
|
|
16
|
+
|
|
17
|
+
This is the *first* port: the package was written against 1.7.0, so there is no previous release of it to move from.
|
|
18
|
+
What follows is the inventory a port starts from.
|
|
19
|
+
|
|
20
|
+
## The SQL surface, as of 1.7.0
|
|
21
|
+
|
|
22
|
+
Files that emit SQL, and whether they changed the dialect layer's work:
|
|
23
|
+
|
|
24
|
+
| File | SQL sites | Constructs it needed |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| `store/sql.js` | 15 | `INSERT OR REPLACE`, `?`, `TEXT`/`INTEGER`/`REAL`, `STRICT`/`WITHOUT ROWID`, `json_each`, scalar `max`/`min`, `substr`/`\|\|` |
|
|
27
|
+
| `store/schema.js` | 13 | `PRAGMA encoding`, `pragma_encoding`, `STRICT`/`WITHOUT ROWID`, partial indexes |
|
|
28
|
+
| `store/read-plan.js` | 4 | `EXISTS`, `count(*)`, the probe, `CROSS JOIN … ON`, row-value comparison |
|
|
29
|
+
| `store/engine.js` | 24 | placeholders, `count(*)`-free plain DML over `chord_documents`/`chord_revisions` |
|
|
30
|
+
| `store/table-writes.js` | 8 | `ALTER TABLE … RENAME/ADD/DROP COLUMN` |
|
|
31
|
+
| `store/catalog.js` | 1 | `INSERT OR REPLACE` |
|
|
32
|
+
| `store/import.js` | 2 | `sqlite_master` (the "holds a store already" check) |
|
|
33
|
+
| `store/{store,outbox,apply-batch,export,host-data}.js` | 12 | plain DML, `SELECT DISTINCT` |
|
|
34
|
+
| `sqlite/migrations.js` | 2 | `INSERT OR IGNORE`, `CREATE TABLE IF NOT EXISTS … STRICT` |
|
|
35
|
+
| `store/adapter.js` (pi-durable's door) | — | re-uses the above through `TableSql` |
|
|
36
|
+
| `store/text.js` | — | not SQL: `compareText`/`prefixUpperBound` are what `COLLATE "C"` has to reproduce |
|
|
37
|
+
|
|
38
|
+
## What pi-durable 1.7.0 needed
|
|
39
|
+
|
|
40
|
+
Nothing. `StoreStorage` is a `Storage` over a chord store, so the only requirement was that the chord store work; the
|
|
41
|
+
five `storage/store/*.js` modules are byte-identical between 1.6.0 and 1.7.0.
|
|
42
|
+
|
|
43
|
+
Verified rather than assumed: pi-durable's own conformance suite, run through `postgresStorage` —
|
|
44
|
+
`createStorageConformance` from `@earendil-works/pi-durable/testing`, **33 cases, all passing** (`test/conformance.test.ts`).
|
|
45
|
+
|
|
46
|
+
## Deltas 1.6.0 → 1.7.0 that mattered
|
|
47
|
+
|
|
48
|
+
Measured by unpacking both tarballs and diffing `dist/`:
|
|
49
|
+
|
|
50
|
+
| File | Result | Consequence here |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `store/sql.js` | **byte-identical** | the dialect table was unchanged |
|
|
53
|
+
| `store/schema.js`, `engine.js`, `rows.js`, `text.js`, `table-writes.js`, `catalog.js`, `outbox.js`, `import.js`, `export.js`, `apply-batch.js`, `host-data.js` | byte-identical | — |
|
|
54
|
+
| `dist/sqlite/*` (`database.d.ts`, `node.js`, `cloudflare.js`, `migrations.js`) | byte-identical | the `SqliteDatabase` seam did not move |
|
|
55
|
+
| `store/backend.js`/`backend.d.ts` | doc comment only | `sqliteBackend(db)` is still the passthrough this package needs |
|
|
56
|
+
| `store/store.js` | 9 removed / 43 added | `openStore` resolves with `ChordStore`; nothing the adapter sees |
|
|
57
|
+
| `store/read-plan.js` | 72 removed / 235 added (slice 15, the read index) | **the file to watch**: it grew most, and it emits SQL (`EXISTS`, `count`, the probe, `CROSS JOIN … ON`) |
|
|
58
|
+
| `store/{read,live-query}.js`, `decoded-rows.js`, `read-index.js`, `shared-read.js` | changed / new | the query layer churns; the SQL generator does not |
|
|
59
|
+
|
|
60
|
+
The reading that matters for maintenance: **the seam (`SqliteDatabase`, and the SQL generator behind it) is currently the
|
|
61
|
+
most stable part of chord, and the read/query layer on top of it is where the churn is.** A dialect layer sits on the
|
|
62
|
+
stable part. Anything that hooked the query planner instead would be rebuilding itself every release.
|
|
63
|
+
|
|
64
|
+
## What to check on the next port
|
|
65
|
+
|
|
66
|
+
1. `diff -u` the two `dist/store/sql.js` and `dist/store/schema.js`: a change there is a change to this package.
|
|
67
|
+
2. Grep the new `dist/store/*.js` for the construct list in `docs/dialect.md`; anything new must be added or refused.
|
|
68
|
+
3. `diff` the new `dist/sqlite/database.d.ts`. If the seam gains a method or a class of value, `src/database.ts` changes
|
|
69
|
+
— and `SqliteValue` gaining a type means `bind()` needs a case for it.
|
|
70
|
+
4. `diff` pi-durable's `dist/storage/store/*.js` and `dist/types.d.ts` (its `Storage` interface, and `CommitResult` in
|
|
71
|
+
particular: it was tagged as a breaking change in a *patch* release, 1.6.1). A break there shows up as a type error in
|
|
72
|
+
`src/pi-durable.ts`, which is why its `Storage` wrapper is written out method by method instead of proxied.
|
|
73
|
+
5. Run the gates: `pnpm typecheck && pnpm lint && pnpm test && pnpm build`, then the smoke test
|
|
74
|
+
(`DATABASE_URL=… pnpm smoke`), then bump the peer range and record the result here.
|
|
75
|
+
|
|
76
|
+
## Record for 1.7.0
|
|
77
|
+
|
|
78
|
+
- Constructs added to the dialect layer for this release: all 18 in `docs/dialect.md` (the package did not exist before).
|
|
79
|
+
- Constructs removed: none.
|
|
80
|
+
- Constructs added to chord that this package does not handle: none found.
|
|
81
|
+
- Oddities worth remembering: `store/import.js` queries `sqlite_master` (answered with a compatibility view);
|
|
82
|
+
`store/schema.js`'s metadata probe is the one statement whose *failure* is expected (answered from the catalogue, see
|
|
83
|
+
`docs/dialect.md`); the `CROSS JOIN … ON` in `store/read-plan.js` is legal SQLite and illegal Postgres.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Port to chord `<version>`
|
|
2
|
+
|
|
3
|
+
Copy this file to `docs/port-chord-<version>.md` and fill it in. One per chord release — the point is that the next
|
|
4
|
+
port starts from evidence (what moved, what it cost, what would have been missed) instead of a fresh diff. The idea is
|
|
5
|
+
[gscode1/pi-durable-postgres](https://github.com/gscode1/pi-durable-postgres)'s `docs/port-1.5.md`.
|
|
6
|
+
|
|
7
|
+
The work itself:
|
|
8
|
+
|
|
9
|
+
1. **Diff the SQL emitters.** A change in these files is a change to this package:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm pack @earendil-works/chord@<old> --pack-destination /tmp/old
|
|
13
|
+
npm pack @earendil-works/chord@<new> --pack-destination /tmp/new
|
|
14
|
+
for file in store/sql.js store/schema.js store/engine.js store/read-plan.js store/table-writes.js \
|
|
15
|
+
store/catalog.js store/outbox.js store/import.js store/export.js store/apply-batch.js \
|
|
16
|
+
store/host-data.js store/store.js sqlite/migrations.js; do
|
|
17
|
+
diff -u /tmp/old/package/dist/$file /tmp/new/package/dist/$file
|
|
18
|
+
done
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
2. **Re-check the construct table.** Grep the new `dist/store/*.js` for every construct in
|
|
22
|
+
[`dialect.md`](dialect.md). A new one is either translated (`src/dialect.ts` + `CONSTRUCTS` + a test) or refused; it
|
|
23
|
+
is never left to chance.
|
|
24
|
+
|
|
25
|
+
3. **Diff the seam.** `dist/sqlite/database.d.ts` — a new method, or a new class of `SqliteValue`, means `src/database.ts`
|
|
26
|
+
changes (`bind()` needs a case for a new value type).
|
|
27
|
+
|
|
28
|
+
4. **Diff pi-durable.** `dist/storage/store/*.js` and `dist/types.d.ts`, `Storage` above all. A break shows up as a type
|
|
29
|
+
error in `src/pi-durable.ts`, which is written out method by method for exactly that reason. pi-durable broke
|
|
30
|
+
`CommitResult` in a *patch* release (1.6.1) once already.
|
|
31
|
+
|
|
32
|
+
5. **Run the gates, then the artefact:**
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm install && pnpm typecheck && pnpm lint && pnpm test && pnpm build
|
|
36
|
+
DATABASE_URL=… pnpm smoke
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
6. **Bump the peer range** in `package.json` to the tested range, update the compatibility table in the README, and
|
|
40
|
+
record the result below.
|
|
41
|
+
|
|
42
|
+
## Record
|
|
43
|
+
|
|
44
|
+
| | |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| chord-postgres version released for this port | |
|
|
47
|
+
| `@earendil-works/chord` before → after | |
|
|
48
|
+
| `@earendil-works/pi-durable` before → after | |
|
|
49
|
+
| Postgres versions tested | |
|
|
50
|
+
| construct table entries added / removed | |
|
|
51
|
+
| conformance suite result (`test/conformance.test.ts`) | |
|
|
52
|
+
| statement budget (`test/statement-budget.test.ts`) | |
|
|
53
|
+
|
|
54
|
+
### What moved
|
|
55
|
+
|
|
56
|
+
<!-- Per file: byte-identical, or what changed and what it forced here. -->
|
|
57
|
+
|
|
58
|
+
### What it cost
|
|
59
|
+
|
|
60
|
+
<!-- Files touched, cases added, surprises. -->
|
|
61
|
+
|
|
62
|
+
### What would have been missed
|
|
63
|
+
|
|
64
|
+
<!-- The construct or seam that no test would have caught. This section is the one that pays off next time. -->
|
package/package.json
CHANGED
|
@@ -1,6 +1,97 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chord-postgres",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "PostgreSQL backend for chord's store: run chord apps and pi-durable on Postgres.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"chord",
|
|
7
|
+
"pi-durable",
|
|
8
|
+
"postgres",
|
|
9
|
+
"postgresql",
|
|
10
|
+
"durable",
|
|
11
|
+
"store"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Luke Hohlin (tctcl)",
|
|
15
|
+
"homepage": "https://github.com/Tctcl/chord-postgres#readme",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/Tctcl/chord-postgres.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Tctcl/chord-postgres/issues"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.19.0"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"docs",
|
|
30
|
+
"README.md",
|
|
31
|
+
"CHANGELOG.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./pi-durable": {
|
|
40
|
+
"types": "./dist/pi-durable.d.ts",
|
|
41
|
+
"import": "./dist/pi-durable.js"
|
|
42
|
+
},
|
|
43
|
+
"./package.json": "./package.json"
|
|
44
|
+
},
|
|
45
|
+
"main": "./dist/index.js",
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc -p tsconfig.json",
|
|
49
|
+
"typecheck": "tsc -p tsconfig.test.json",
|
|
50
|
+
"lint": "oxlint",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:watch": "vitest",
|
|
53
|
+
"prepare": "husky",
|
|
54
|
+
"smoke": "node scripts/package-smoke.mjs"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"pg": "^8.23.1"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@earendil-works/chord": "~1.7.0",
|
|
61
|
+
"@earendil-works/pi-durable": "~1.7.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@earendil-works/pi-durable": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@commitlint/cli": "^21.2.4",
|
|
70
|
+
"@commitlint/config-conventional": "^21.2.4",
|
|
71
|
+
"@earendil-works/chord": "1.7.0",
|
|
72
|
+
"@earendil-works/pi-durable": "1.7.0",
|
|
73
|
+
"@types/node": "^26.6.6",
|
|
74
|
+
"@types/pg": "^8.23.1",
|
|
75
|
+
"husky": "^9.1.7",
|
|
76
|
+
"oxlint": "^1.90.0",
|
|
77
|
+
"typescript": "^7.0.2",
|
|
78
|
+
"vitest": "^5.1.1"
|
|
79
|
+
},
|
|
80
|
+
"packageManager": "pnpm@12.16.1",
|
|
81
|
+
"pnpm": {
|
|
82
|
+
"ignoredBuiltDependencies": [
|
|
83
|
+
"protobufjs"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
"publishConfig": {
|
|
87
|
+
"access": "public",
|
|
88
|
+
"provenance": true
|
|
89
|
+
},
|
|
90
|
+
"devEngines": {
|
|
91
|
+
"runtime": {
|
|
92
|
+
"name": "node",
|
|
93
|
+
"version": "26.13.1",
|
|
94
|
+
"onFail": "error"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|