@catalyst-cloud/schema 0.1.26 → 0.1.27
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/package.json +2 -2
- package/src/migrations.generated.ts +18 -0
- package/src/mirror.ts +13 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catalyst-cloud/schema",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Typed Drizzle schema = single source of truth for the per-tenant Mirror DO SQLite store (CTC-13 / ADR-0002). Shared by the mirror Worker, the host-sync replica, and the browser OPFS replica.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@catalyst-cloud/typescript-config": "workspace:*",
|
|
34
|
-
"@types/node": "^
|
|
34
|
+
"@types/node": "^26.3.0",
|
|
35
35
|
"drizzle-kit": "^0.31.0",
|
|
36
36
|
"prettier": "^3.9.6",
|
|
37
37
|
"typescript": "^7.0.2",
|
|
@@ -221,6 +221,20 @@ export const MIRROR_MIGRATIONS = {
|
|
|
221
221
|
tag: "0029_square_silhouette",
|
|
222
222
|
breakpoints: true,
|
|
223
223
|
},
|
|
224
|
+
{
|
|
225
|
+
idx: 30,
|
|
226
|
+
version: "6",
|
|
227
|
+
when: 1787972489820,
|
|
228
|
+
tag: "0030_wandering_bastion",
|
|
229
|
+
breakpoints: true,
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
idx: 31,
|
|
233
|
+
version: "6",
|
|
234
|
+
when: 1787972497785,
|
|
235
|
+
tag: "0031_ctc851_comment_parent_backfill",
|
|
236
|
+
breakpoints: true,
|
|
237
|
+
},
|
|
224
238
|
],
|
|
225
239
|
},
|
|
226
240
|
migrations: {
|
|
@@ -281,5 +295,9 @@ export const MIRROR_MIGRATIONS = {
|
|
|
281
295
|
"0028_burly_nemesis": "ALTER TABLE `check_suites` ADD `pull_request_numbers` text;",
|
|
282
296
|
"0029_square_silhouette":
|
|
283
297
|
"CREATE INDEX `idx_relations_type_related` ON `relations` (`type`,`related_identifier`);",
|
|
298
|
+
"0030_wandering_bastion":
|
|
299
|
+
"ALTER TABLE `comments` ADD `parent_type` text;--> statement-breakpoint\nALTER TABLE `comments` ADD `parent_entity_id` text;--> statement-breakpoint\nCREATE INDEX `idx_comments_parent` ON `comments` (`parent_type`,`parent_entity_id`,`removed_at`);",
|
|
300
|
+
"0031_ctc851_comment_parent_backfill":
|
|
301
|
+
"-- CTC-851 — backfill comment parents + quarantine the pre-fix empty-issue_id orphans.\n--\n-- 0030 adds the parent_type/parent_entity_id columns and fixes both WRITE legs (webhook normalizer +\n-- reconcile) so new/re-swept comments carry a real parent, but that alone converges only rows the\n-- reconcile re-sweeps — and it walks OPEN issues, so a non-issue comment (or a comment on a closed\n-- issue) keeps its corrupt shape forever. This backfill is what makes the CORPUS canonical rather\n-- than just the new writes.\n--\n-- ⭐ Deliberately a DATA migration in the SHARED bundle (the 0014 pattern): the DO and every host /\n-- OPFS replica apply the same MIRROR_MIGRATIONS through the same runner, so each side repairs its OWN\n-- rows locally. That converges every replica WITHOUT emitting a change_log delta per row (migrations\n-- bypass appendChange), so no ring-buffer flood (the CTC-279 concern).\n--\n-- (a) Healthy rows (a real issue_id) → parent_type='issue', parent_entity_id=issue_id.\n-- (b) Orphans (issue_id empty-string — the measured shape — or NULL, defensively) cannot be repaired\n-- from row data: the replica comments table has no `raw` column and no parent signal beyond the\n-- comment-reply parent_id. A pure in-bundle DML migration cannot call Linear, so it QUARANTINES\n-- them: parent_type='unresolved', issue_id nulled — MARKED with a stated reason, never deleted\n-- (the AC explicitly permits quarantine-with-reason). CTC-851 measured 54 such rows live.\n--\n-- Idempotent by the `parent_type IS NULL` guard: once a row is stamped it is skipped on replay, so a\n-- crash between a statement succeeding and its tag being recorded (execReplaySafe) is safe.\nUPDATE `comments`\n SET `parent_type` = 'issue', `parent_entity_id` = `issue_id`\n WHERE `parent_type` IS NULL AND `issue_id` IS NOT NULL AND `issue_id` <> '';\n--> statement-breakpoint\nUPDATE `comments`\n SET `parent_type` = 'unresolved', `issue_id` = NULL\n WHERE `parent_type` IS NULL AND (`issue_id` = '' OR `issue_id` IS NULL);\n",
|
|
284
302
|
},
|
|
285
303
|
} as const;
|
package/src/mirror.ts
CHANGED
|
@@ -422,6 +422,13 @@ export const comments = sqliteTable(
|
|
|
422
422
|
{
|
|
423
423
|
id: text("id").primaryKey(),
|
|
424
424
|
issue_id: text("issue_id"),
|
|
425
|
+
// CTC-851: the real parent of a non-issue comment (project/initiative update, document, …).
|
|
426
|
+
// `parent_type` ∈ 'issue'|'projectUpdate'|'initiativeUpdate'|'documentContent'|'project'|
|
|
427
|
+
// 'initiative'|'unresolved'; `parent_entity_id` is the id of that parent. For an issue comment
|
|
428
|
+
// both `issue_id` and `parent_entity_id` hold the issue id (parent_type 'issue'), so every
|
|
429
|
+
// existing `WHERE issue_id = ?` read is untouched. Nullable: a quarantined orphan has neither.
|
|
430
|
+
parent_type: text("parent_type"),
|
|
431
|
+
parent_entity_id: text("parent_entity_id"),
|
|
425
432
|
body: text("body"),
|
|
426
433
|
author_id: text("author_id"),
|
|
427
434
|
author_name: text("author_name"),
|
|
@@ -435,7 +442,12 @@ export const comments = sqliteTable(
|
|
|
435
442
|
},
|
|
436
443
|
// CTC-59: the detail comments fetch — `WHERE issue_id = ? AND removed_at IS NULL ORDER BY updated_at`.
|
|
437
444
|
// Composite covers the filter AND the sort, so SQLite seeks instead of building a temp b-tree.
|
|
438
|
-
(t) => [
|
|
445
|
+
(t) => [
|
|
446
|
+
index("idx_comments_issue").on(t.issue_id, t.removed_at, t.updated_at),
|
|
447
|
+
// CTC-851: retrievability by parent — `WHERE parent_type = ? AND parent_entity_id = ? AND
|
|
448
|
+
// removed_at IS NULL`. Makes the non-issue-comment corpus queryable without a table scan.
|
|
449
|
+
index("idx_comments_parent").on(t.parent_type, t.parent_entity_id, t.removed_at),
|
|
450
|
+
],
|
|
439
451
|
);
|
|
440
452
|
|
|
441
453
|
// ── GitHub ───────────────────────────────────────────────────────────────────────────────────────
|