Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
v0.60.22.0 fix(links): deterministic ORDER BY l.id in getLinks/getBacklinks (#5789)
Garry Tan6fb479c7229c
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex 2f270a191f..62441af678 100644--- a/.claude-plugin/plugin.json+++ b/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain",- "version": "0.60.21.0",+ "version": "0.60.22.0","description": "Personal knowledge brain for your coding agent — hybrid search, synthesis, graph traversal, and durable cross-session memory over Postgres/PGLite with pgvector, plus a curated brain-first skill set.","author": {"name": "Garry Tan",diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.jsonindex 52a5f7779d..149952810e 100644--- a/.codex-plugin/plugin.json+++ b/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain",- "version": "0.60.21.0",+ "version": "0.60.22.0","description": "Personal knowledge brain for your coding agent — hybrid search, synthesis, graph traversal, and durable cross-session memory over Postgres/PGLite with pgvector, plus a curated brain-first skill set.","author": {"name": "Garry Tan",diff --git a/BOOTSTRAP_FOR_AGENTS.md b/BOOTSTRAP_FOR_AGENTS.mdindex db34dc8cbf..1778928d70 100644--- a/BOOTSTRAP_FOR_AGENTS.md+++ b/BOOTSTRAP_FOR_AGENTS.md@@ -1,4 +1,4 @@-<!-- gbrain-runbook-stamp: 0.60.21.0 -->+<!-- gbrain-runbook-stamp: 0.60.22.0 --><!-- This stamp must equal the VERSION file at every release; CI enforces it(scripts/check-bootstrap-tag.sh). `gbrain bootstrap status` compares it tothe installed binary and warns on skew. -->diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4432ae9acd..0d45fd5d42 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,29 @@ credits are retained; no result has been reassigned to another provider. Originaidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [0.60.22.0] - 2026-09-30++**Links now come back in the same order every time. `get_links`, backlinks and every caller that reads them return edges in the order the links were created, instead of whatever order the database happened to store them in.**++`getLinks` and `getBacklinks` had no `ORDER BY`, so Postgres and PGLite returned rows in storage order. When an edge was rewritten, for example by an auto-link re-run updating its context, Postgres stored the new row version after its siblings, and the edge moved to the end of the list. An index scan could also return endpoint page order instead. That was the recurring `attendance-retrieval` failure on Postgres CI, where the same two attendance edges came back swapped. Both reads now order by link id, which is creation order and never changes when an edge is updated.++| Reading a page's links after one edge is rewritten | Before | After |+| --- | --- | --- |+| Order | storage order: the rewritten edge moves last, or index order | link-id (creation) order, stable |+| `attendance-retrieval-postgres` | intermittent swapped-order failure | deterministic |++No caller changes meaning. The callers look up edges with `find` or `some`, or return the list as is, and the first match by link type is now the oldest such edge, which is what storage order returned before any rewrite.++### To take advantage of v0.60.22.0++`gbrain upgrade`. There is no migration.++### Itemized changes++- `src/core/engine-sql/links.ts`: `getLinks` and `getBacklinks` end every scope branch (federated grant, single source, unscoped) with `ORDER BY l.id`. Both engines share this SQL.+- New `test/e2e/links-read-order.test.ts` (PGLite, and Postgres when `DATABASE_URL` is set) creates the endpoint pages in reverse and rewrites the oldest edge, then expects link-id order from every branch. It fails without the `ORDER BY`.+- `test/fixtures/goldens/sql-text/links.json` is regenerated for the 8 `getLinks` / `getBacklinks` variants. The only change is the added `ORDER BY l.id`.+## [0.60.21.0] - 2026-09-30**A `git` command GBrain stops early no longer leaves your brain repo locked.**diff --git a/VERSION b/VERSIONindex 1b2b4f8237..f325e224b8 100644--- a/VERSION+++ b/VERSION@@ -1 +1 @@-0.60.21.0+0.60.22.0diff --git a/openclaw.plugin.json b/openclaw.plugin.jsonindex 70b1743cd0..086db67640 100644--- a/openclaw.plugin.json+++ b/openclaw.plugin.json@@ -1,7 +1,7 @@{"id": "gbrain-context-engine","name": "gbrain",- "version": "0.60.21.0",+ "version": "0.60.22.0","description": "Personal knowledge brain with Postgres + pgvector hybrid search","family": "bundle-plugin","kind": "context-engine",diff --git a/package.json b/package.jsonindex 6f73b6cf80..86bd2ff0d1 100644--- a/package.json+++ b/package.json@@ -204,7 +204,7 @@"bun": ">=1.3.11"},"license": "MIT",- "version": "0.60.21.0",+ "version": "0.60.22.0","overrides": {"@ai-sdk/provider-utils": "4.0.33","@hono/node-server": "^2.0.5",diff --git a/plugin-variants/gbrain-coding/.claude-plugin/plugin.json b/plugin-variants/gbrain-coding/.claude-plugin/plugin.jsonindex 8b6933ffa6..2fcf10d47e 100644--- a/plugin-variants/gbrain-coding/.claude-plugin/plugin.json+++ b/plugin-variants/gbrain-coding/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-coding",- "version": "0.60.21.0",+ "version": "0.60.22.0","description": "Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant. (persona variant of the gbrain plugin — 21 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-coding/.codex-plugin/plugin.json b/plugin-variants/gbrain-coding/.codex-plugin/plugin.jsonindex 8facdfc423..e2c90ac3d4 100644--- a/plugin-variants/gbrain-coding/.codex-plugin/plugin.json+++ b/plugin-variants/gbrain-coding/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-coding",- "version": "0.60.21.0",+ "version": "0.60.22.0","description": "Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant. (persona variant of the gbrain plugin — 21 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-coding/README.md b/plugin-variants/gbrain-coding/README.mdindex dccc0fb6ca..d641f6673e 100644--- a/plugin-variants/gbrain-coding/README.md+++ b/plugin-variants/gbrain-coding/README.md@@ -1,4 +1,4 @@-<!-- gbrain-plugin-tree-stamp: 0.60.21.0 -->+<!-- gbrain-plugin-tree-stamp: 0.60.22.0 --># gbrain-coding (generated persona variant — do not hand-edit)Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant.diff --git a/plugin-variants/gbrain-daily/.claude-plugin/plugin.json b/plugin-variants/gbrain-daily/.claude-plugin/plugin.jsonindex 0e6aed5283..3c9cc0a6bd 100644--- a/plugin-variants/gbrain-daily/.claude-plugin/plugin.json+++ b/plugin-variants/gbrain-daily/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-daily",- "version": "0.60.21.0",+ "version": "0.60.22.0","description": "Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant. (persona variant of the gbrain plugin — 20 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-daily/.codex-plugin/plugin.json b/plugin-variants/gbrain-daily/.codex-plugin/plugin.jsonindex ac019488f3..82d2cac050 100644--- a/plugin-variants/gbrain-daily/.codex-plugin/plugin.json+++ b/plugin-variants/gbrain-daily/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-daily",- "version": "0.60.21.0",+ "version": "0.60.22.0","description": "Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant. (persona variant of the gbrain plugin — 20 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-daily/README.md b/plugin-variants/gbrain-daily/README.mdindex d1dce7de56..6e1599047f 100644--- a/plugin-variants/gbrain-daily/README.md+++ b/plugin-variants/gbrain-daily/README.md@@ -1,4 +1,4 @@-<!-- gbrain-plugin-tree-stamp: 0.60.21.0 -->+<!-- gbrain-plugin-tree-stamp: 0.60.22.0 --># gbrain-daily (generated persona variant — do not hand-edit)Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant.diff --git a/plugin/README.md b/plugin/README.mdindex d0a9446ae2..31365dfeb2 100644--- a/plugin/README.md+++ b/plugin/README.md@@ -1,4 +1,4 @@-<!-- gbrain-plugin-tree-stamp: 0.60.21.0 -->+<!-- gbrain-plugin-tree-stamp: 0.60.22.0 --># gbrain plugin skill tree (generated — do not hand-edit)This tree is the curated skill set for the gbrain Codex and Claude Codediff --git a/scripts/e2e-test-map.ts b/scripts/e2e-test-map.tsindex b4527205da..04630d869a 100644--- a/scripts/e2e-test-map.ts+++ b/scripts/e2e-test-map.ts@@ -577,3 +577,4 @@ E2E_TEST_MAP["src/core/engine-sql/dialect-*.ts"] = ENGINE_SQL_EXECUTOR_E2E;E2E_TEST_MAP["src/core/engine-sql/normalize.ts"] = ["test/e2e/engine-sql-normalize-parity.test.ts"];E2E_TEST_MAP["src/core/engine-sql/brands.ts"] = ["test/e2e/engine-sql-rls-scope.test.ts"];E2E_TEST_MAP["src/core/engine-sql/chunks.ts"] = ["test/e2e/evidence-delivery-leak.test.ts", "test/e2e/evidence-delivery-parity.test.ts"];+E2E_TEST_MAP["src/core/engine-sql/links.ts"] = ["test/e2e/links-read-order.test.ts", "test/e2e/attendance-retrieval-postgres.test.ts"];diff --git a/src/core/engine-sql/links.ts b/src/core/engine-sql/links.tsindex 1c64dec5c7..ee51bbfb9b 100644--- a/src/core/engine-sql/links.ts+++ b/src/core/engine-sql/links.ts@@ -235,6 +235,7 @@ export async function getLinks(exec: ScopedRead, slug: string, opts?: { sourceIdLEFT JOIN pages o ON o.id = l.origin_page_id AND o.source_id = ANY(${ids}::text[])WHERE f.slug = ${slug} AND f.source_id = ANY(${ids}::text[]) AND t.source_id = ANY(${ids}::text[])AND f.deleted_at IS NULL AND t.deleted_at IS NULL ${trustedSql(privacy)}+ ORDER BY l.id`)).rows;return rows as unknown as Link[];}@@ -258,6 +259,7 @@ export async function getLinks(exec: ScopedRead, slug: string, opts?: { sourceIdLEFT JOIN pages o ON o.id = l.origin_page_idWHERE f.slug = ${slug} AND f.source_id = ${opts.sourceId}AND f.deleted_at IS NULL AND t.deleted_at IS NULL ${trustedSql(privacy)}+ ORDER BY l.id`)).rows;return rows as unknown as Link[];}@@ -273,6 +275,7 @@ export async function getLinks(exec: ScopedRead, slug: string, opts?: { sourceIdLEFT JOIN pages o ON o.id = l.origin_page_idWHERE f.slug = ${slug}AND f.deleted_at IS NULL AND t.deleted_at IS NULL ${trustedSql(privacy)}+ ORDER BY l.id`)).rows;return rows as unknown as Link[];}@@ -297,6 +300,7 @@ export async function getBacklinks(exec: ScopedRead, slug: string, opts?: { sourLEFT JOIN pages o ON o.id = l.origin_page_id AND o.source_id = ANY(${ids}::text[])WHERE t.slug = ${slug} AND t.source_id = ANY(${ids}::text[]) AND f.source_id = ANY(${ids}::text[])AND f.deleted_at IS NULL AND t.deleted_at IS NULL ${trustedSql(privacy)}+ ORDER BY l.id`)).rows;return rows as unknown as Link[];}@@ -315,6 +319,7 @@ export async function getBacklinks(exec: ScopedRead, slug: string, opts?: { sourLEFT JOIN pages o ON o.id = l.origin_page_idWHERE t.slug = ${slug} AND t.source_id = ${opts.sourceId}AND f.deleted_at IS NULL AND t.deleted_at IS NULL ${trustedSql(privacy)}+ ORDER BY l.id`)).rows;return rows as unknown as Link[];}@@ -330,6 +335,7 @@ export async function getBacklinks(exec: ScopedRead, slug: string, opts?: { sourLEFT JOIN pages o ON o.id = l.origin_page_idWHERE t.slug = ${slug}AND f.deleted_at IS NULL AND t.deleted_at IS NULL ${trustedSql(privacy)}+ ORDER BY l.id`)).rows;return rows as unknown as Link[];}diff --git a/templates/bootstrap/template-repo/README.md b/templates/bootstrap/template-repo/README.mdindex ebe1f968ef..68dd48f33a 100644--- a/templates/bootstrap/template-repo/README.md+++ b/templates/bootstrap/template-repo/README.md@@ -1,6 +1,6 @@# gbrain agent workspace — template-<!-- gbrain-template-stamp: 0.60.21.0 -->+<!-- gbrain-template-stamp: 0.60.22.0 -->This repository is the **"Use this template"** distribution artifact for a[gbrain](https://github.com/garrytan/gbrain) personal-agent workspace — the samediff --git a/test/e2e/links-read-order.test.ts b/test/e2e/links-read-order.test.tsnew file mode 100644index 0000000000..9b35ce6419--- /dev/null+++ b/test/e2e/links-read-order.test.ts@@ -0,0 +1,72 @@+/**+ * getLinks / getBacklinks return rows in a stable order (link id) on both+ * engines.+ *+ * Authoring gate: the link reads had no ORDER BY, so rows came back in heap+ * order. Postgres MVCC writes an updated row as a new tuple at the end of+ * the heap, so re-upserting one edge (auto-link re-runs do) moved it behind+ * its siblings, and order-sensitive callers and tests flaked+ * (attendance-retrieval-postgres), and an index scan returns endpoint+ * page-id order instead. This test creates the endpoint pages in reverse,+ * rewrites the oldest edge and expects link-id order; without the ORDER BY+ * neither plan returns it.+ *+ * Postgres arm runs when DATABASE_URL is set.+ */+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';+import { PGLiteEngine } from '../../src/core/pglite-engine.ts';+import type { BrainEngine } from '../../src/core/engine.ts';+import { isolatedPersistencePostgres } from '../helpers/persistence-postgres.ts';++const backends = process.env.DATABASE_URL ? ['pglite', 'postgres'] as const : ['pglite'] as const;+const TARGETS = ['people/bea-example', 'people/cal-example', 'people/dee-example'];+const SOURCES = ['notes/one-example', 'notes/two-example', 'notes/three-example'];++for (const backend of backends) describe(`link reads keep link-id order (${backend})`, () => {+ let engine: BrainEngine;+ let close: () => Promise<void>;++ beforeAll(async () => {+ if (backend === 'postgres') {+ const isolated = await isolatedPersistencePostgres(process.env.DATABASE_URL!);+ engine = isolated.engine;+ close = isolated.close;+ } else {+ const pglite = new PGLiteEngine();+ await pglite.connect({});+ await pglite.initSchema();+ engine = pglite;+ close = () => pglite.disconnect();+ }+ // Pages are created in reverse, so page-id order (what an index scan on the+ // endpoint columns yields) disagrees with link-id order.+ for (const slug of ['notes/hub-example', 'people/hub-example', ...[...TARGETS].reverse(), ...[...SOURCES].reverse()]) {+ await engine.putPage(slug, { type: 'note', title: slug, compiled_truth: `${slug} body.`, timeline: '', frontmatter: {} });+ }+ for (const to of TARGETS) await engine.addLink('notes/hub-example', to, `mentions ${to}`, 'mentions', 'manual');+ for (const from of SOURCES) await engine.addLink(from, 'people/hub-example', `mentions hub from ${from}`, 'mentions', 'manual');+ // Rewrite the oldest edge of each set: MVCC moves its tuple to the end of the heap.+ await engine.executeRaw(`UPDATE links SET context = context || ' (edited)' WHERE id IN (+ SELECT MIN(l.id) FROM links l JOIN pages f ON f.id = l.from_page_id WHERE f.slug = 'notes/hub-example'+ UNION ALL+ SELECT MIN(l.id) FROM links l JOIN pages t ON t.id = l.to_page_id WHERE t.slug = 'people/hub-example')`);+ }, 120_000);++ afterAll(async () => { await close?.(); }, 60_000);++ test('getLinks returns outbound edges in link-id order after an edge is rewritten, in every scope arm', async () => {+ for (const opts of [undefined, { sourceId: 'default' }, { sourceIds: ['default'] }]) {+ const links = await engine.getLinks('notes/hub-example', opts);+ expect(links.map(l => l.to_slug), JSON.stringify(opts)).toEqual(TARGETS);+ expect(links[0].context).toEndWith('(edited)');+ }+ });++ test('getBacklinks returns inbound edges in link-id order after an edge is rewritten, in every scope arm', async () => {+ for (const opts of [undefined, { sourceId: 'default' }, { sourceIds: ['default'] }]) {+ const links = await engine.getBacklinks('people/hub-example', opts);+ expect(links.map(l => l.from_slug), JSON.stringify(opts)).toEqual(SOURCES);+ expect(links[0].context).toEndWith('(edited)');+ }+ });+});diff --git a/test/fixtures/goldens/sql-text/links.json b/test/fixtures/goldens/sql-text/links.jsonindex 6231631ba0..d7152f75c1 100644--- a/test/fixtures/goldens/sql-text/links.json+++ b/test/fixtures/goldens/sql-text/links.json@@ -80,8 +80,8 @@"params": ["string"],- "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE t.slug = $1 AND f.deleted_at IS NULL AND t.deleted_at IS NULL",- "textSha256": "7d3b83f8d08012a264432a507f636bc9e84cb3dc459f53fa5532f7b5fea3cf78"+ "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE t.slug = $1 AND f.deleted_at IS NULL AND t.deleted_at IS NULL ORDER BY l.id",+ "textSha256": "bbb2209d09e9db7b7bfa4d3a99b2e6aef24b44fb9c8545f0f58aa07b320dd2f1"}],"excludePrivate": [@@ -90,8 +90,8 @@"params": ["string"],- "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE t.slug = $1 AND f.deleted_at IS NULL AND t.deleted_at IS NULL AND (COALESCE(f.frontmatter->>'visibility', CASE WHEN (f.type = 'atom' OR (f.type = 'concept' AND f.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN f.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = f.source_id AND derived_origin.slug = f.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (f.type = 'atom' OR (f.type = 'concept' AND f.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = f.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) AND (COALESCE(t.frontmatter->>'visibility', CASE WHEN (t.type = 'atom' OR (t.type = 'concept' AND t.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN t.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = t.source_id AND derived_origin.slug = t.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (t.type = 'atom' OR (t.type = 'concept' AND t.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = t.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) AND (l.origin_page_id IS NULL OR EXISTS ( SELECT 1 FROM pages origin_private WHERE origin_private.id = l.origin_page_id AND (COALESCE(origin_private.frontmatter->>'visibility', CASE WHEN (origin_private.type = 'atom' OR (origin_private.type = 'concept' AND origin_private.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN origin_private.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = origin_private.source_id AND derived_origin.slug = origin_private.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (origin_private.type = 'atom' OR (origin_private.type = 'concept' AND origin_private.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = origin_private.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) ))",- "textSha256": "695e199ca070e35fe302338cd5988edb2393864e9eb147f50b42368651b117f1"+ "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE t.slug = $1 AND f.deleted_at IS NULL AND t.deleted_at IS NULL AND (COALESCE(f.frontmatter->>'visibility', CASE WHEN (f.type = 'atom' OR (f.type = 'concept' AND f.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN f.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = f.source_id AND derived_origin.slug = f.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (f.type = 'atom' OR (f.type = 'concept' AND f.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = f.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) AND (COALESCE(t.frontmatter->>'visibility', CASE WHEN (t.type = 'atom' OR (t.type = 'concept' AND t.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN t.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = t.source_id AND derived_origin.slug = t.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (t.type = 'atom' OR (t.type = 'concept' AND t.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = t.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) AND (l.origin_page_id IS NULL OR EXISTS ( SELECT 1 FROM pages origin_private WHERE origin_private.id = l.origin_page_id AND (COALESCE(origin_private.frontmatter->>'visibility', CASE WHEN (origin_private.type = 'atom' OR (origin_private.type = 'concept' AND origin_private.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN origin_private.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = origin_private.source_id AND derived_origin.slug = origin_private.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (origin_private.type = 'atom' OR (origin_private.type = 'concept' AND origin_private.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = origin_private.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) )) ORDER BY l.id",+ "textSha256": "76d5701cad7c4c256d3f0f2d2929340313d821412d95f03dabcd920a70de3ee1"}],"sourceId": [@@ -101,8 +101,8 @@"string","string"],- "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE t.slug = $1 AND t.source_id = $2 AND f.deleted_at IS NULL AND t.deleted_at IS NULL",- "textSha256": "d40000067d7b970f2adc3d1aceeaae3a9dba58afd87b0436c4fe76ea8b7d4132"+ "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE t.slug = $1 AND t.source_id = $2 AND f.deleted_at IS NULL AND t.deleted_at IS NULL ORDER BY l.id",+ "textSha256": "66b9e4e2d79b3236efe05c234089d86f91c4286d9e1f7afbd35d626a18aae16c"}],"sourceIds": [@@ -114,8 +114,8 @@"array<string>","array<string>"],- "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id AND o.source_id = ANY($1::text[]) WHERE t.slug = $2 AND t.source_id = ANY($3::text[]) AND f.source_id = ANY($4::text[]) AND f.deleted_at IS NULL AND t.deleted_at IS NULL",- "textSha256": "f84cef0e4257fa530728f1b560521ed95049d867f3a8726f04e2b4151d142433"+ "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id AND o.source_id = ANY($1::text[]) WHERE t.slug = $2 AND t.source_id = ANY($3::text[]) AND f.source_id = ANY($4::text[]) AND f.deleted_at IS NULL AND t.deleted_at IS NULL ORDER BY l.id",+ "textSha256": "e77d0bcedf2207f2702287d9f43d909f29ffd9fdb959ea0ae96127417196ce27"}]},@@ -126,8 +126,8 @@"params": ["string"],- "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE f.slug = $1 AND f.deleted_at IS NULL AND t.deleted_at IS NULL",- "textSha256": "c326f3772480fd102e584acd07c02fe649dae800d26a059aebb69670d8fa1b5a"+ "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE f.slug = $1 AND f.deleted_at IS NULL AND t.deleted_at IS NULL ORDER BY l.id",+ "textSha256": "e47cd60fa4248491a041a1539bb444bb874f353c5c17a8706d4670e0ebf3b869"}],"excludePrivate": [@@ -136,8 +136,8 @@"params": ["string"],- "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE f.slug = $1 AND f.deleted_at IS NULL AND t.deleted_at IS NULL AND (COALESCE(f.frontmatter->>'visibility', CASE WHEN (f.type = 'atom' OR (f.type = 'concept' AND f.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN f.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = f.source_id AND derived_origin.slug = f.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (f.type = 'atom' OR (f.type = 'concept' AND f.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = f.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) AND (COALESCE(t.frontmatter->>'visibility', CASE WHEN (t.type = 'atom' OR (t.type = 'concept' AND t.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN t.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = t.source_id AND derived_origin.slug = t.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (t.type = 'atom' OR (t.type = 'concept' AND t.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = t.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) AND (l.origin_page_id IS NULL OR EXISTS ( SELECT 1 FROM pages origin_private WHERE origin_private.id = l.origin_page_id AND (COALESCE(origin_private.frontmatter->>'visibility', CASE WHEN (origin_private.type = 'atom' OR (origin_private.type = 'concept' AND origin_private.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN origin_private.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = origin_private.source_id AND derived_origin.slug = origin_private.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (origin_private.type = 'atom' OR (origin_private.type = 'concept' AND origin_private.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = origin_private.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) ))",- "textSha256": "6a9d06556058ab9b2a10727eb3ceacebec03e00f69fb76a77a6e1cfcbc276ff7"+ "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE f.slug = $1 AND f.deleted_at IS NULL AND t.deleted_at IS NULL AND (COALESCE(f.frontmatter->>'visibility', CASE WHEN (f.type = 'atom' OR (f.type = 'concept' AND f.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN f.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = f.source_id AND derived_origin.slug = f.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (f.type = 'atom' OR (f.type = 'concept' AND f.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = f.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) AND (COALESCE(t.frontmatter->>'visibility', CASE WHEN (t.type = 'atom' OR (t.type = 'concept' AND t.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN t.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = t.source_id AND derived_origin.slug = t.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (t.type = 'atom' OR (t.type = 'concept' AND t.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = t.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) AND (l.origin_page_id IS NULL OR EXISTS ( SELECT 1 FROM pages origin_private WHERE origin_private.id = l.origin_page_id AND (COALESCE(origin_private.frontmatter->>'visibility', CASE WHEN (origin_private.type = 'atom' OR (origin_private.type = 'concept' AND origin_private.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN origin_private.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = origin_private.source_id AND derived_origin.slug = origin_private.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (origin_private.type = 'atom' OR (origin_private.type = 'concept' AND origin_private.frontmatter->>'synthesized_by' IS NOT NULL)) THEN EXISTS (SELECT 1 FROM links derived_input_link JOIN pages derived_input ON derived_input.id = derived_input_link.to_page_id WHERE derived_input_link.from_page_id = origin_private.id AND derived_input_link.link_source = 'concept-provenance' AND derived_input_link.link_type = 'synthesized_from' AND (COALESCE(derived_input.frontmatter->>'visibility', CASE WHEN derived_input.type = 'atom' THEN 'private' ELSE 'world' END) = 'private' OR EXISTS (SELECT 1 FROM pages derived_input_origin WHERE derived_input_origin.source_id = derived_input.source_id AND derived_input_origin.slug = derived_input.frontmatter->>'source_slug' AND derived_input_origin.frontmatter->>'visibility' = 'private'))) ELSE false END)) )) ORDER BY l.id",+ "textSha256": "c84f67b6123840b2eba4ba645f4a462e088f5421b512c0121ba7e888f0aa2685"}],"sourceId": [@@ -147,8 +147,8 @@"string","string"],- "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE f.slug = $1 AND f.source_id = $2 AND f.deleted_at IS NULL AND t.deleted_at IS NULL",- "textSha256": "6d42832aea826bcff6ed51b166facbb6df6bc33acdf985614a2c40decb436353"+ "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id WHERE f.slug = $1 AND f.source_id = $2 AND f.deleted_at IS NULL AND t.deleted_at IS NULL ORDER BY l.id",+ "textSha256": "047a5dbd950079e6eabb438e6bacdb6e7083d107cbb4c455d4262a94e862cc8e"}],"sourceIds": [@@ -160,8 +160,8 @@"array<string>","array<string>"],- "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id AND o.source_id = ANY($1::text[]) WHERE f.slug = $2 AND f.source_id = ANY($3::text[]) AND t.source_id = ANY($4::text[]) AND f.deleted_at IS NULL AND t.deleted_at IS NULL",- "textSha256": "0a0323d66573dbd2ea49978f4ed78e217cf7668056abdb38017c3a39b1c0ed78"+ "sql": "SELECT f.slug as from_slug, f.source_id as from_source_id, t.slug as to_slug, t.source_id as to_source_id, l.link_type, l.context, l.link_source, o.slug as origin_slug, o.source_id as origin_source_id, l.origin_field FROM links l JOIN pages f ON f.id = l.from_page_id JOIN pages t ON t.id = l.to_page_id LEFT JOIN pages o ON o.id = l.origin_page_id AND o.source_id = ANY($1::text[]) WHERE f.slug = $2 AND f.source_id = ANY($3::text[]) AND t.source_id = ANY($4::text[]) AND f.deleted_at IS NULL AND t.deleted_at IS NULL ORDER BY l.id",+ "textSha256": "f506c27e60abdc7fd8a0a42fe2452ad356672d9ab3704e9695222a8ff25485fe"}]},