Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat(links): source ids on graph nodes and edges, page-id edge dedup (#5827)

garrytan2b09413dd5fb
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index 2ea539adb5..de16ac1769 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -23,7 +23,7 @@ src/core/operations.ts 329 ratchet peel target: containment sprint C4-C7; grown
src/core/pglite-engine.ts 3379 ratchet +1 System One v1 evals: search arms clamp to searchLimitCap() (import of search/eval-pool-depth.ts; eval-only --eval-pool-depth, production cap unchanged); refactor wave 1 split target (W1 engine-sql); E1 bootstrap moved to engine-sql/bootstrap.ts; ceiling rationale: docs/architecture/key-files/engines-1.md entry for src/core/pglite-engine.ts; evidence delivery: getChunkWindows delegate + type import (+3; SQL in engine-sql/chunks.ts); #5761: +4 markPagesAttendanceBlocked delegate (SQL in engine-sql/pages.ts)
src/core/postgres-engine.ts 3398 ratchet +1 System One v1 evals: search arms clamp to searchLimitCap() (import of search/eval-pool-depth.ts; eval-only --eval-pool-depth, production cap unchanged); refactor wave 1 split target (W1 engine-sql); ceiling rationale: docs/architecture/key-files/engines-2.md entry for src/core/postgres-engine.ts; evidence delivery: getChunkWindows scoped-read delegate + type import (+5; SQL in engine-sql/chunks.ts); #5761: +4 markPagesAttendanceBlocked delegate (SQL in engine-sql/pages.ts)
src/core/search/hybrid.ts 1584 ratchet +2 System One v1: HybridSearchOpts.decide (search/decide-stage.ts); refactor wave 1 split target (W4 hybrid, cut line); ceiling rationale: docs/architecture/key-files/core-search-1.md entry for src/core/search/hybrid.ts; +10 #5691: per-request embedding_query_prefix read once and threaded to the embeds and cache key
-src/core/types.ts 2097 ratchet +5 System One v1 retrieval lane: SearchResult injection_p/injection_suspected, HybridSearchMeta answerability, egress_denied degraded reason; +4 System One v1: SearchResult rerank_score_kind/decide_evidence, HybridSearchMeta decide/rerank; +3 wave review: PAGE_SORT_SQL.updated_asc source_id + id tiebreakers (total order under federated scopes); +5 #4881: OntologyReadOpts extends PageReadScope doc; +3 #4857: PAGE_SORT_SQL.slug total-order tiebreaker comment; grown v0.46.26.0 megawave: EvidenceOpts, pacing/usage result fields, PageFilters growth (#4352 #4218); wave-k: +9 SalienceOpts/AnomaliesOpts source scope (#3867); +20 2026-09 adversarial batch 2: keyword_relaxed_carried stage + relaxed_dropped meta field docs; +16 2026-09 fix wave: SearchResult.keyword_relaxed field + full fusion-demotion doc; (#3867); +9: #4648 rerank_passthrough degraded stage + empty_result_set/malformed_shape reasons | merged v0.48.1.0 true-up; +master v0.48 merge true-up (reranker succession: no_key preflight, reranker_skipped stage, readiness); corrective release: shared internal PageReadScope and PageReadPolicy; ranker wave v0.48.4.0: HybridSearchMeta relational_rerank_pin / keyword_arm_confidence / metadata_boost_gate + SearchResult.relational_pinned (+48 over master's peel); +12: #4681 Page.updated_at_iso + keyset cursor precision docs; #5105: canonical page state shared module and transaction/snapshot delegates; #5105: public page revision fields; upstream integration: preserve independently reviewed master additions with branch facade extraction; #5252 wave: typed vector pool and readiness metadata; merged company ingestion/schema routing changes; retired provider integration removed; +1 write-path wave: 'created' effective-date source; +3 read-path wave: rerank_failed degraded stage + budget reason (closed vocabularies) and its recall classification note; +8 fw3-search: SearchOpts.source_boosts + keyword_arm_failed/title_arm_failed stages; +2 wave-2 W4: ChunkInput.embedding_input_hash (#5553); fix wave 3 x fix wave 2 (v0.60.5.0) composition: +2 at the merge; evidence delivery: optional SearchResult.delivered (+2; shape in search/evidence-delivery.ts)
+src/core/types.ts 2101 ratchet +5 System One v1 retrieval lane: SearchResult injection_p/injection_suspected, HybridSearchMeta answerability, egress_denied degraded reason; +4 System One v1: SearchResult rerank_score_kind/decide_evidence, HybridSearchMeta decide/rerank; +3 wave review: PAGE_SORT_SQL.updated_asc source_id + id tiebreakers (total order under federated scopes); +5 #4881: OntologyReadOpts extends PageReadScope doc; +3 #4857: PAGE_SORT_SQL.slug total-order tiebreaker comment; grown v0.46.26.0 megawave: EvidenceOpts, pacing/usage result fields, PageFilters growth (#4352 #4218); wave-k: +9 SalienceOpts/AnomaliesOpts source scope (#3867); +20 2026-09 adversarial batch 2: keyword_relaxed_carried stage + relaxed_dropped meta field docs; +16 2026-09 fix wave: SearchResult.keyword_relaxed field + full fusion-demotion doc; (#3867); +9: #4648 rerank_passthrough degraded stage + empty_result_set/malformed_shape reasons | merged v0.48.1.0 true-up; +master v0.48 merge true-up (reranker succession: no_key preflight, reranker_skipped stage, readiness); corrective release: shared internal PageReadScope and PageReadPolicy; ranker wave v0.48.4.0: HybridSearchMeta relational_rerank_pin / keyword_arm_confidence / metadata_boost_gate + SearchResult.relational_pinned (+48 over master's peel); +12: #4681 Page.updated_at_iso + keyset cursor precision docs; #5105: canonical page state shared module and transaction/snapshot delegates; #5105: public page revision fields; upstream integration: preserve independently reviewed master additions with branch facade extraction; #5252 wave: typed vector pool and readiness metadata; merged company ingestion/schema routing changes; retired provider integration removed; +1 write-path wave: 'created' effective-date source; +3 read-path wave: rerank_failed degraded stage + budget reason (closed vocabularies) and its recall classification note; +8 fw3-search: SearchOpts.source_boosts + keyword_arm_failed/title_arm_failed stages; +2 wave-2 W4: ChunkInput.embedding_input_hash (#5553); fix wave 3 x fix wave 2 (v0.60.5.0) composition: +2 at the merge; evidence delivery: optional SearchResult.delivered (+2; shape in search/evidence-delivery.ts); +4 #5827: GraphNode.source_id and GraphPath from_source_id/to_source_id
src/core/minions/queue.ts 2522 ratchet grown #4078 + megawave probe-liveness unlatch (#4310) + master private-queue lifecycle: recovery classifier + monotonic lease; security: durable queued authority and confined filesystem dispatch; master integration: grown #4078 + megawave probe-liveness unlatch (#4310) + master private-queue lifecycle: recovery classifier + monotonic lease; harness support: boundary wiring to shared grants, isolated setup, withdrawal and delegated guards; merged v0.49: durable authority and delegated admission both enforced; typed readiness, configuration-blocked lifecycle and bounded release; +9: prune archives completed dream synthesis keys
src/commands/init.ts 1932 ratchet grown v0.46.x keyless capability notices; grown db-availability loop: initPostgresCore typed-failure extraction + --prefer-postgres ladder hook + pgvector rethrow fix; +1 at megawave/wave-k merge; +master-merge true-up; wave-k: merge; #3753 --force re-init engine-preservation guard; +1 wave-k merge-union brace (--prefer-postgres close); +10 ambient-writeback WP8: runWritebackNudge consent ask in both engine epilogues (logic lives in core/onboard/writeback-nudge.ts); +4: v0.48.2 reranker readiness at init + test seam; +1: v0.48.2 provider normalization; +3: v0.48.2 review fixes; master integration: +2: preserve typed PGLite busy errors in schema-only init; shared-skills integration on company-ingestion base; retired provider integration removed; retain stored-vector identity on re-init
src/commands/integrations.ts 1739 ratchet grown v0.46.26.0 megawave (#4039 connector compat) + 1 nosemgrep dataflow annotation (path-traversal audit); wave-k: exported heartbeatPath seam (#3900)
diff --git a/src/core/engine-sql/links.ts b/src/core/engine-sql/links.ts
index ee51bbfb9b..7750af9b0a 100644
--- a/src/core/engine-sql/links.ts
+++ b/src/core/engine-sql/links.ts
@@ -467,7 +467,7 @@ export async function traverseGraph(
// the truncation callback.
const cap = opts?.frontierCap;
const recursiveStep = cap !== undefined && cap > 0
- ? sqlFragment`(SELECT p2.id, p2.slug, p2.title, p2.type, g.depth + 1, g.visited || p2.id
+ ? sqlFragment`(SELECT p2.id, p2.slug, p2.source_id, p2.title, p2.type, g.depth + 1, g.visited || p2.id
FROM graph g
JOIN links l ON l.from_page_id = g.id
JOIN pages p2 ON p2.id = l.to_page_id
@@ -477,7 +477,7 @@ export async function traverseGraph(
${stepScope}
ORDER BY p2.slug ASC, p2.id ASC
LIMIT ${cap})`
- : sqlFragment`SELECT p2.id, p2.slug, p2.title, p2.type, g.depth + 1, g.visited || p2.id
+ : sqlFragment`SELECT p2.id, p2.slug, p2.source_id, p2.title, p2.type, g.depth + 1, g.visited || p2.id
FROM graph g
JOIN links l ON l.from_page_id = g.id
JOIN pages p2 ON p2.id = l.to_page_id
@@ -488,14 +488,14 @@ export async function traverseGraph(
// Cycle prevention: visited array tracks page IDs already in the path.
const rows = (await exec.run(sqlFragment`
WITH RECURSIVE graph AS (
- SELECT p.id, p.slug, p.title, p.type, 0 as depth, ARRAY[p.id] as visited
+ SELECT p.id, p.slug, p.source_id, p.title, p.type, 0 as depth, ARRAY[p.id] as visited
FROM pages p WHERE p.slug = ${slug} AND p.deleted_at IS NULL ${privacy('p')} ${seedScope}
UNION ALL
${recursiveStep}
)
- SELECT DISTINCT g.slug, g.title, g.type, g.depth,
+ SELECT DISTINCT g.slug, g.source_id, g.title, g.type, g.depth,
coalesce(
-- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type)
-- edges that originate from different provenance (markdown body
@@ -510,9 +510,9 @@ export async function traverseGraph(
WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL ${privacy('p3', 'l2')} ${aggScope}),
'[]'::jsonb
) as links
- FROM (SELECT DISTINCT id, slug, title, type, depth
- FROM (SELECT id, slug, title, type, depth FROM graph LIMIT ${TRAVERSE_WALK_ROW_CAP}) capped) g
- ORDER BY g.depth, g.slug
+ FROM (SELECT DISTINCT id, slug, source_id, title, type, depth
+ FROM (SELECT id, slug, source_id, title, type, depth FROM graph LIMIT ${TRAVERSE_WALK_ROW_CAP}) capped) g
+ ORDER BY g.depth, g.slug, g.source_id
`)).rows;
// T8 truncation-detection callback was designed here but the v1 algorithm
@@ -523,6 +523,7 @@ export async function traverseGraph(
return rows.map((r: Record<string, unknown>) => ({
slug: r.slug as string,
+ source_id: r.source_id as string,
title: r.title as string,
type: r.type as string,
depth: r.depth as number,
@@ -577,10 +578,10 @@ export async function traversePathsDetailed(
if (direction === 'out') {
rows = (await exec.run(sqlFragment`
WITH RECURSIVE walk AS (
- SELECT p.id, p.slug, 0::int as depth, ARRAY[p.id] as visited
+ SELECT p.id, p.slug, p.source_id, 0::int as depth, ARRAY[p.id] as visited
FROM pages p WHERE p.slug = ${slug} AND p.deleted_at IS NULL ${privacy('p')} ${seedScope}
UNION ALL
- SELECT p2.id, p2.slug, w.depth + 1, w.visited || p2.id
+ SELECT p2.id, p2.slug, p2.source_id, w.depth + 1, w.visited || p2.id
FROM walk w
JOIN links l ON l.from_page_id = w.id
JOIN pages p2 ON p2.id = l.to_page_id
@@ -590,10 +591,11 @@ export async function traversePathsDetailed(
AND (${!linkTypeMatches} OR l.link_type = ${linkType ?? ''})
${stepScope}
),
- capped AS (SELECT id, slug, depth FROM walk LIMIT ${TRAVERSE_WALK_ROW_CAP + 1}),
- nodes AS (SELECT DISTINCT id, slug, depth FROM capped)
+ capped AS (SELECT id, slug, source_id, depth FROM walk LIMIT ${TRAVERSE_WALK_ROW_CAP + 1}),
+ nodes AS (SELECT DISTINCT id, slug, source_id, depth FROM capped)
SELECT (SELECT count(*) FROM capped) > ${TRAVERSE_WALK_ROW_CAP} AS walk_truncated,
- w.slug as from_slug, p2.slug as to_slug,
+ w.id as from_id, w.slug as from_slug, w.source_id as from_source_id,
+ p2.id as to_id, p2.slug as to_slug, p2.source_id as to_source_id,
l.link_type, l.context, w.depth + 1 as depth
FROM nodes w
JOIN links l ON l.from_page_id = w.id
@@ -602,16 +604,16 @@ export async function traversePathsDetailed(
AND p2.deleted_at IS NULL ${privacy('p2', 'l')}
AND (${!linkTypeMatches} OR l.link_type = ${linkType ?? ''})
${stepScope}
- ORDER BY depth, from_slug, to_slug
+ ORDER BY depth, from_slug, to_slug, from_source_id, to_source_id
LIMIT ${TRAVERSE_PATH_ROW_CAP + 1}
`)).rows;
} else if (direction === 'in') {
rows = (await exec.run(sqlFragment`
WITH RECURSIVE walk AS (
- SELECT p.id, p.slug, 0::int as depth, ARRAY[p.id] as visited
+ SELECT p.id, p.slug, p.source_id, 0::int as depth, ARRAY[p.id] as visited
FROM pages p WHERE p.slug = ${slug} AND p.deleted_at IS NULL ${privacy('p')} ${seedScope}
UNION ALL
- SELECT p2.id, p2.slug, w.depth + 1, w.visited || p2.id
+ SELECT p2.id, p2.slug, p2.source_id, w.depth + 1, w.visited || p2.id
FROM walk w
JOIN links l ON l.to_page_id = w.id
JOIN pages p2 ON p2.id = l.from_page_id
@@ -621,10 +623,11 @@ export async function traversePathsDetailed(
AND (${!linkTypeMatches} OR l.link_type = ${linkType ?? ''})
${stepScope}
),
- capped AS (SELECT id, slug, depth FROM walk LIMIT ${TRAVERSE_WALK_ROW_CAP + 1}),
- nodes AS (SELECT DISTINCT id, slug, depth FROM capped)
+ capped AS (SELECT id, slug, source_id, depth FROM walk LIMIT ${TRAVERSE_WALK_ROW_CAP + 1}),
+ nodes AS (SELECT DISTINCT id, slug, source_id, depth FROM capped)
SELECT (SELECT count(*) FROM capped) > ${TRAVERSE_WALK_ROW_CAP} AS walk_truncated,
- p2.slug as from_slug, w.slug as to_slug,
+ p2.id as from_id, p2.slug as from_slug, p2.source_id as from_source_id,
+ w.id as to_id, w.slug as to_slug, w.source_id as to_source_id,
l.link_type, l.context, w.depth + 1 as depth
FROM nodes w
JOIN links l ON l.to_page_id = w.id
@@ -633,7 +636,7 @@ export async function traversePathsDetailed(
AND p2.deleted_at IS NULL ${privacy('p2', 'l')}
AND (${!linkTypeMatches} OR l.link_type = ${linkType ?? ''})
${stepScope}
- ORDER BY depth, from_slug, to_slug
+ ORDER BY depth, from_slug, to_slug, from_source_id, to_source_id
LIMIT ${TRAVERSE_PATH_ROW_CAP + 1}
`)).rows;
} else {
@@ -655,7 +658,8 @@ export async function traversePathsDetailed(
capped AS (SELECT id, depth FROM walk LIMIT ${TRAVERSE_WALK_ROW_CAP + 1}),
nodes AS (SELECT DISTINCT id, depth FROM capped)
SELECT (SELECT count(*) FROM capped) > ${TRAVERSE_WALK_ROW_CAP} AS walk_truncated,
- pf.slug as from_slug, pt.slug as to_slug,
+ pf.id as from_id, pf.slug as from_slug, pf.source_id as from_source_id,
+ pt.id as to_id, pt.slug as to_slug, pt.source_id as to_source_id,
l.link_type, l.context, w.depth + 1 as depth
FROM nodes w
JOIN links l ON (l.from_page_id = w.id OR l.to_page_id = w.id)
@@ -667,7 +671,7 @@ export async function traversePathsDetailed(
AND (${!linkTypeMatches} OR l.link_type = ${linkType ?? ''})
${pfScope}
${ptScope}
- ORDER BY depth, from_slug, to_slug
+ ORDER BY depth, from_slug, to_slug, from_source_id, to_source_id
LIMIT ${TRAVERSE_PATH_ROW_CAP + 1}
`)).rows;
}
@@ -676,16 +680,19 @@ export async function traversePathsDetailed(
// us the walk overflowed and is dropped with everything past the cap.
const truncated = rows.length > TRAVERSE_PATH_ROW_CAP || (rows as Array<{ walk_truncated?: boolean }>).some((r) => r.walk_truncated === true);
const bounded = (truncated ? rows.slice(0, TRAVERSE_PATH_ROW_CAP) : rows) as Record<string, unknown>[];
- // Dedup edges (same edge can appear via multiple visited paths).
+ // Dedup edges (same edge can appear via multiple visited paths). Keyed on
+ // page ids, so the same slug in two sources stays two distinct edges.
const seen = new Set<string>();
const result: GraphPath[] = [];
for (const r of bounded) {
- const key = `${r.from_slug}|${r.to_slug}|${r.link_type}|${r.depth}`;
+ const key = `${r.from_id}|${r.to_id}|${r.link_type}|${r.depth}`;
if (seen.has(key)) continue;
seen.add(key);
result.push({
from_slug: r.from_slug as string,
+ from_source_id: r.from_source_id as string,
to_slug: r.to_slug as string,
+ to_source_id: r.to_source_id as string,
link_type: r.link_type as string,
context: (r.context as string) || '',
depth: Number(r.depth),
diff --git a/src/core/types.ts b/src/core/types.ts
index e0470d5050..6eab049202 100644
--- a/src/core/types.ts
+++ b/src/core/types.ts
@@ -1463,6 +1463,8 @@ export interface Link {
export interface GraphNode {
slug: string;
+ /** Source holding this page; the same slug in two sources is two nodes. */
+ source_id: string;
title: string;
type: PageType;
depth: number;
@@ -1476,7 +1478,9 @@ export interface GraphNode {
*/
export interface GraphPath {
from_slug: string;
+ from_source_id: string;
to_slug: string;
+ to_source_id: string;
link_type: string;
context: string;
/** Depth of `to_slug` from the root (1 for direct neighbors). */
diff --git a/test/fixtures/goldens/sql-text/links.json b/test/fixtures/goldens/sql-text/links.json
index d7152f75c1..45d6f90911 100644
--- a/test/fixtures/goldens/sql-text/links.json
+++ b/test/fixtures/goldens/sql-text/links.json
@@ -396,8 +396,8 @@
"number",
"number"
],
- "sql": "WITH RECURSIVE graph AS ( SELECT p.id, p.slug, p.title, p.type, 0 as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL SELECT p2.id, p2.slug, p2.title, p2.type, g.depth + 1, g.visited || p2.id FROM graph g JOIN links l ON l.from_page_id = g.id JOIN pages p2 ON p2.id = l.to_page_id WHERE g.depth < $2 AND NOT (p2.id = ANY(g.visited)) AND p2.deleted_at IS NULL ) SELECT DISTINCT g.slug, g.title, g.type, g.depth, coalesce( -- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type) -- edges that originate from different provenance (markdown body -- vs frontmatter vs auto-extracted). The underlying links table -- preserves every row with its origin_page_id / link_source — -- the dedup is presentation-only for the legacy traverseGraph -- aggregation. traversePaths has its own in-memory dedup at a -- different layer. See plan Bug 6/10. (SELECT jsonb_agg(DISTINCT jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type)) FROM links l2 JOIN pages p3 ON p3.id = l2.to_page_id WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL ), '[]'::jsonb ) as links FROM (SELECT DISTINCT id, slug, title, type, depth FROM (SELECT id, slug, title, type, depth FROM graph LIMIT $3) capped) g ORDER BY g.depth, g.slug",
- "textSha256": "f1dd83368f4490f9153b52f5364c0c35f9367505d0f4633ed6db222aa01a737b"
+ "sql": "WITH RECURSIVE graph AS ( SELECT p.id, p.slug, p.source_id, p.title, p.type, 0 as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL SELECT p2.id, p2.slug, p2.source_id, p2.title, p2.type, g.depth + 1, g.visited || p2.id FROM graph g JOIN links l ON l.from_page_id = g.id JOIN pages p2 ON p2.id = l.to_page_id WHERE g.depth < $2 AND NOT (p2.id = ANY(g.visited)) AND p2.deleted_at IS NULL ) SELECT DISTINCT g.slug, g.source_id, g.title, g.type, g.depth, coalesce( -- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type) -- edges that originate from different provenance (markdown body -- vs frontmatter vs auto-extracted). The underlying links table -- preserves every row with its origin_page_id / link_source — -- the dedup is presentation-only for the legacy traverseGraph -- aggregation. traversePaths has its own in-memory dedup at a -- different layer. See plan Bug 6/10. (SELECT jsonb_agg(DISTINCT jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type)) FROM links l2 JOIN pages p3 ON p3.id = l2.to_page_id WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL ), '[]'::jsonb ) as links FROM (SELECT DISTINCT id, slug, source_id, title, type, depth FROM (SELECT id, slug, source_id, title, type, depth FROM graph LIMIT $3) capped) g ORDER BY g.depth, g.slug, g.source_id",
+ "textSha256": "668c5de92d0904e614566a97f482304b5fc3a6fcb27c5f6eed10993b13ee7e55"
}
],
"excludePrivate": [
@@ -408,8 +408,8 @@
"number",
"number"
],
- "sql": "WITH RECURSIVE graph AS ( SELECT p.id, p.slug, p.title, p.type, 0 as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL AND (COALESCE(p.frontmatter->>'visibility', CASE WHEN (p.type = 'atom' OR (p.type = 'concept' AND p.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN p.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = p.source_id AND derived_origin.slug = p.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (p.type = 'atom' OR (p.type = 'concept' AND p.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 = p.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)) UNION ALL SELECT p2.id, p2.slug, p2.title, p2.type, g.depth + 1, g.visited || p2.id FROM graph g JOIN links l ON l.from_page_id = g.id JOIN pages p2 ON p2.id = l.to_page_id WHERE g.depth < $2 AND NOT (p2.id = ANY(g.visited)) AND p2.deleted_at IS NULL AND (COALESCE(p2.frontmatter->>'visibility', CASE WHEN (p2.type = 'atom' OR (p2.type = 'concept' AND p2.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN p2.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = p2.source_id AND derived_origin.slug = p2.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (p2.type = 'atom' OR (p2.type = 'concept' AND p2.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 = p2.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)) )) ) SELECT DISTINCT g.slug, g.title, g.type, g.depth, coalesce( -- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type) -- edges that originate from different provenance (markdown body -- vs frontmatter vs auto-extracted). The underlying links table -- preserves every row with its origin_page_id / link_source — -- the dedup is presentation-only for the legacy traverseGraph -- aggregation. traversePaths has its own in-memory dedup at a -- different layer. See plan Bug 6/10. (SELECT jsonb_agg(DISTINCT jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type)) FROM links l2 JOIN pages p3 ON p3.id = l2.to_page_id WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL AND (COALESCE(p3.frontmatter->>'visibility', CASE WHEN (p3.type = 'atom' OR (p3.type = 'concept' AND p3.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN p3.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = p3.source_id AND derived_origin.slug = p3.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (p3.type = 'atom' OR (p3.type = 'concept' AND p3.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 = p3.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 (l2.origin_page_id IS NULL OR EXISTS ( SELECT 1 FROM pages origin_private WHERE origin_private.id = l2.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)) )) ), '[]'::jsonb ) as links FROM (SELECT DISTINCT id, slug, title, type, depth FROM (SELECT id, slug, title, type, depth FROM graph LIMIT $3) capped) g ORDER BY g.depth, g.slug",
- "textSha256": "92cb87da1b2f09b5b4a5c209e8388ca8cc8e802062b6b220f962b11272541434"
+ "sql": "WITH RECURSIVE graph AS ( SELECT p.id, p.slug, p.source_id, p.title, p.type, 0 as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL AND (COALESCE(p.frontmatter->>'visibility', CASE WHEN (p.type = 'atom' OR (p.type = 'concept' AND p.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN p.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = p.source_id AND derived_origin.slug = p.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (p.type = 'atom' OR (p.type = 'concept' AND p.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 = p.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)) UNION ALL SELECT p2.id, p2.slug, p2.source_id, p2.title, p2.type, g.depth + 1, g.visited || p2.id FROM graph g JOIN links l ON l.from_page_id = g.id JOIN pages p2 ON p2.id = l.to_page_id WHERE g.depth < $2 AND NOT (p2.id = ANY(g.visited)) AND p2.deleted_at IS NULL AND (COALESCE(p2.frontmatter->>'visibility', CASE WHEN (p2.type = 'atom' OR (p2.type = 'concept' AND p2.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN p2.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = p2.source_id AND derived_origin.slug = p2.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (p2.type = 'atom' OR (p2.type = 'concept' AND p2.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 = p2.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)) )) ) SELECT DISTINCT g.slug, g.source_id, g.title, g.type, g.depth, coalesce( -- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type) -- edges that originate from different provenance (markdown body -- vs frontmatter vs auto-extracted). The underlying links table -- preserves every row with its origin_page_id / link_source — -- the dedup is presentation-only for the legacy traverseGraph -- aggregation. traversePaths has its own in-memory dedup at a -- different layer. See plan Bug 6/10. (SELECT jsonb_agg(DISTINCT jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type)) FROM links l2 JOIN pages p3 ON p3.id = l2.to_page_id WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL AND (COALESCE(p3.frontmatter->>'visibility', CASE WHEN (p3.type = 'atom' OR (p3.type = 'concept' AND p3.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN p3.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = p3.source_id AND derived_origin.slug = p3.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (p3.type = 'atom' OR (p3.type = 'concept' AND p3.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 = p3.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 (l2.origin_page_id IS NULL OR EXISTS ( SELECT 1 FROM pages origin_private WHERE origin_private.id = l2.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)) )) ), '[]'::jsonb ) as links FROM (SELECT DISTINCT id, slug, source_id, title, type, depth FROM (SELECT id, slug, source_id, title, type, depth FROM graph LIMIT $3) capped) g ORDER BY g.depth, g.slug, g.source_id",
+ "textSha256": "74a3c3762962e044355b66afccbe66e3091276b075daf4f955eaea4df2cefb7e"
}
],
"frontierCap": [
@@ -421,8 +421,8 @@
"number",
"number"
],
- "sql": "WITH RECURSIVE graph AS ( SELECT p.id, p.slug, p.title, p.type, 0 as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL (SELECT p2.id, p2.slug, p2.title, p2.type, g.depth + 1, g.visited || p2.id FROM graph g JOIN links l ON l.from_page_id = g.id JOIN pages p2 ON p2.id = l.to_page_id WHERE g.depth < $2 AND NOT (p2.id = ANY(g.visited)) AND p2.deleted_at IS NULL ORDER BY p2.slug ASC, p2.id ASC LIMIT $3) ) SELECT DISTINCT g.slug, g.title, g.type, g.depth, coalesce( -- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type) -- edges that originate from different provenance (markdown body -- vs frontmatter vs auto-extracted). The underlying links table -- preserves every row with its origin_page_id / link_source — -- the dedup is presentation-only for the legacy traverseGraph -- aggregation. traversePaths has its own in-memory dedup at a -- different layer. See plan Bug 6/10. (SELECT jsonb_agg(DISTINCT jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type)) FROM links l2 JOIN pages p3 ON p3.id = l2.to_page_id WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL ), '[]'::jsonb ) as links FROM (SELECT DISTINCT id, slug, title, type, depth FROM (SELECT id, slug, title, type, depth FROM graph LIMIT $4) capped) g ORDER BY g.depth, g.slug",
- "textSha256": "ccdff59c0b210028ea95d7d10b571b270736cd7f1bf5a5f31f0f91b91cd02141"
+ "sql": "WITH RECURSIVE graph AS ( SELECT p.id, p.slug, p.source_id, p.title, p.type, 0 as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL (SELECT p2.id, p2.slug, p2.source_id, p2.title, p2.type, g.depth + 1, g.visited || p2.id FROM graph g JOIN links l ON l.from_page_id = g.id JOIN pages p2 ON p2.id = l.to_page_id WHERE g.depth < $2 AND NOT (p2.id = ANY(g.visited)) AND p2.deleted_at IS NULL ORDER BY p2.slug ASC, p2.id ASC LIMIT $3) ) SELECT DISTINCT g.slug, g.source_id, g.title, g.type, g.depth, coalesce( -- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type) -- edges that originate from different provenance (markdown body -- vs frontmatter vs auto-extracted). The underlying links table -- preserves every row with its origin_page_id / link_source — -- the dedup is presentation-only for the legacy traverseGraph -- aggregation. traversePaths has its own in-memory dedup at a -- different layer. See plan Bug 6/10. (SELECT jsonb_agg(DISTINCT jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type)) FROM links l2 JOIN pages p3 ON p3.id = l2.to_page_id WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL ), '[]'::jsonb ) as links FROM (SELECT DISTINCT id, slug, source_id, title, type, depth FROM (SELECT id, slug, source_id, title, type, depth FROM graph LIMIT $4) capped) g ORDER BY g.depth, g.slug, g.source_id",
+ "textSha256": "4a15dff50622e72c2c64563c116f1b59b02c0b64eee8d10022ae6febbc1288a1"
}
],
"sourceId": [
@@ -436,8 +436,8 @@
"string",
"number"
],
- "sql": "WITH RECURSIVE graph AS ( SELECT p.id, p.slug, p.title, p.type, 0 as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL AND p.source_id = $2 UNION ALL SELECT p2.id, p2.slug, p2.title, p2.type, g.depth + 1, g.visited || p2.id FROM graph g JOIN links l ON l.from_page_id = g.id JOIN pages p2 ON p2.id = l.to_page_id WHERE g.depth < $3 AND NOT (p2.id = ANY(g.visited)) AND p2.deleted_at IS NULL AND p2.source_id = $4 ) SELECT DISTINCT g.slug, g.title, g.type, g.depth, coalesce( -- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type) -- edges that originate from different provenance (markdown body -- vs frontmatter vs auto-extracted). The underlying links table -- preserves every row with its origin_page_id / link_source — -- the dedup is presentation-only for the legacy traverseGraph -- aggregation. traversePaths has its own in-memory dedup at a -- different layer. See plan Bug 6/10. (SELECT jsonb_agg(DISTINCT jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type)) FROM links l2 JOIN pages p3 ON p3.id = l2.to_page_id WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL AND p3.source_id = $5), '[]'::jsonb ) as links FROM (SELECT DISTINCT id, slug, title, type, depth FROM (SELECT id, slug, title, type, depth FROM graph LIMIT $6) capped) g ORDER BY g.depth, g.slug",
- "textSha256": "a94d59c8f8e3a10c55b47709c7b1ce97727b6ce4018e362f8c5993c1f6921e6c"
+ "sql": "WITH RECURSIVE graph AS ( SELECT p.id, p.slug, p.source_id, p.title, p.type, 0 as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL AND p.source_id = $2 UNION ALL SELECT p2.id, p2.slug, p2.source_id, p2.title, p2.type, g.depth + 1, g.visited || p2.id FROM graph g JOIN links l ON l.from_page_id = g.id JOIN pages p2 ON p2.id = l.to_page_id WHERE g.depth < $3 AND NOT (p2.id = ANY(g.visited)) AND p2.deleted_at IS NULL AND p2.source_id = $4 ) SELECT DISTINCT g.slug, g.source_id, g.title, g.type, g.depth, coalesce( -- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type) -- edges that originate from different provenance (markdown body -- vs frontmatter vs auto-extracted). The underlying links table -- preserves every row with its origin_page_id / link_source — -- the dedup is presentation-only for the legacy traverseGraph -- aggregation. traversePaths has its own in-memory dedup at a -- different layer. See plan Bug 6/10. (SELECT jsonb_agg(DISTINCT jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type)) FROM links l2 JOIN pages p3 ON p3.id = l2.to_page_id WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL AND p3.source_id = $5), '[]'::jsonb ) as links FROM (SELECT DISTINCT id, slug, source_id, title, type, depth FROM (SELECT id, slug, source_id, title, type, depth FROM graph LIMIT $6) capped) g ORDER BY g.depth, g.slug, g.source_id",
+ "textSha256": "f527f0c25594e2baf9d848c3e4d5a5819f8490a6b03208086aa4c88343981a2a"
}
],
"sourceIds": [
@@ -451,8 +451,8 @@
"array<string>",
"number"
],
- "sql": "WITH RECURSIVE graph AS ( SELECT p.id, p.slug, p.title, p.type, 0 as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL AND p.source_id = ANY($2::text[]) UNION ALL SELECT p2.id, p2.slug, p2.title, p2.type, g.depth + 1, g.visited || p2.id FROM graph g JOIN links l ON l.from_page_id = g.id JOIN pages p2 ON p2.id = l.to_page_id WHERE g.depth < $3 AND NOT (p2.id = ANY(g.visited)) AND p2.deleted_at IS NULL AND p2.source_id = ANY($4::text[]) ) SELECT DISTINCT g.slug, g.title, g.type, g.depth, coalesce( -- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type) -- edges that originate from different provenance (markdown body -- vs frontmatter vs auto-extracted). The underlying links table -- preserves every row with its origin_page_id / link_source — -- the dedup is presentation-only for the legacy traverseGraph -- aggregation. traversePaths has its own in-memory dedup at a -- different layer. See plan Bug 6/10. (SELECT jsonb_agg(DISTINCT jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type)) FROM links l2 JOIN pages p3 ON p3.id = l2.to_page_id WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL AND p3.source_id = ANY($5::text[])), '[]'::jsonb ) as links FROM (SELECT DISTINCT id, slug, title, type, depth FROM (SELECT id, slug, title, type, depth FROM graph LIMIT $6) capped) g ORDER BY g.depth, g.slug",
- "textSha256": "e652f1a45bbd561e3c65fa8fec192cde258b763c62bcdbf6539c73199884d1d1"
+ "sql": "WITH RECURSIVE graph AS ( SELECT p.id, p.slug, p.source_id, p.title, p.type, 0 as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL AND p.source_id = ANY($2::text[]) UNION ALL SELECT p2.id, p2.slug, p2.source_id, p2.title, p2.type, g.depth + 1, g.visited || p2.id FROM graph g JOIN links l ON l.from_page_id = g.id JOIN pages p2 ON p2.id = l.to_page_id WHERE g.depth < $3 AND NOT (p2.id = ANY(g.visited)) AND p2.deleted_at IS NULL AND p2.source_id = ANY($4::text[]) ) SELECT DISTINCT g.slug, g.source_id, g.title, g.type, g.depth, coalesce( -- jsonb_agg(DISTINCT ...) collapses duplicate (to_slug, link_type) -- edges that originate from different provenance (markdown body -- vs frontmatter vs auto-extracted). The underlying links table -- preserves every row with its origin_page_id / link_source — -- the dedup is presentation-only for the legacy traverseGraph -- aggregation. traversePaths has its own in-memory dedup at a -- different layer. See plan Bug 6/10. (SELECT jsonb_agg(DISTINCT jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type)) FROM links l2 JOIN pages p3 ON p3.id = l2.to_page_id WHERE l2.from_page_id = g.id AND p3.deleted_at IS NULL AND p3.source_id = ANY($5::text[])), '[]'::jsonb ) as links FROM (SELECT DISTINCT id, slug, source_id, title, type, depth FROM (SELECT id, slug, source_id, title, type, depth FROM graph LIMIT $6) capped) g ORDER BY g.depth, g.slug, g.source_id",
+ "textSha256": "0691360c6f5d9b85c81372113ee3120f69617e34b4a980b9bbd8b77ad91c3b84"
}
]
},
@@ -472,8 +472,8 @@
"string",
"number"
],
- "sql": "WITH RECURSIVE walk AS ( SELECT p.id, p.slug, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL SELECT p2.id, p2.slug, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth + 1 < $2 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND ($3 OR l.link_type = $4) ), capped AS (SELECT id, slug, depth FROM walk LIMIT $5), nodes AS (SELECT DISTINCT id, slug, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $6 AS walk_truncated, w.slug as from_slug, p2.slug as to_slug, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth < $7 AND p2.deleted_at IS NULL AND ($8 OR l.link_type = $9) ORDER BY depth, from_slug, to_slug LIMIT $10",
- "textSha256": "8431b064516c53834fd114df302b49f5acbe3a09fc5e80a95d6ee17b6ac8377c"
+ "sql": "WITH RECURSIVE walk AS ( SELECT p.id, p.slug, p.source_id, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL SELECT p2.id, p2.slug, p2.source_id, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth + 1 < $2 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND ($3 OR l.link_type = $4) ), capped AS (SELECT id, slug, source_id, depth FROM walk LIMIT $5), nodes AS (SELECT DISTINCT id, slug, source_id, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $6 AS walk_truncated, w.id as from_id, w.slug as from_slug, w.source_id as from_source_id, p2.id as to_id, p2.slug as to_slug, p2.source_id as to_source_id, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth < $7 AND p2.deleted_at IS NULL AND ($8 OR l.link_type = $9) ORDER BY depth, from_slug, to_slug, from_source_id, to_source_id LIMIT $10",
+ "textSha256": "e85a15fac4e1db7f3451b223ff4f2b68341957636a2c74f142600fd36771edd2"
}
]
},
@@ -493,8 +493,8 @@
"string",
"number"
],
- "sql": "WITH RECURSIVE walk AS ( SELECT p.id, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL SELECT p2.id, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON (l.from_page_id = w.id OR l.to_page_id = w.id) JOIN pages p2 ON p2.id = CASE WHEN l.from_page_id = w.id THEN l.to_page_id ELSE l.from_page_id END WHERE w.depth + 1 < $2 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND ($3 OR l.link_type = $4) ), capped AS (SELECT id, depth FROM walk LIMIT $5), nodes AS (SELECT DISTINCT id, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $6 AS walk_truncated, pf.slug as from_slug, pt.slug as to_slug, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON (l.from_page_id = w.id OR l.to_page_id = w.id) JOIN pages pf ON pf.id = l.from_page_id JOIN pages pt ON pt.id = l.to_page_id WHERE w.depth < $7 AND pf.deleted_at IS NULL AND pt.deleted_at IS NULL AND ($8 OR l.link_type = $9) ORDER BY depth, from_slug, to_slug LIMIT $10",
- "textSha256": "d0b5842b5dd640d8da08e98665d9afad106345275c39c24d28022a27d5ea61c5"
+ "sql": "WITH RECURSIVE walk AS ( SELECT p.id, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL SELECT p2.id, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON (l.from_page_id = w.id OR l.to_page_id = w.id) JOIN pages p2 ON p2.id = CASE WHEN l.from_page_id = w.id THEN l.to_page_id ELSE l.from_page_id END WHERE w.depth + 1 < $2 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND ($3 OR l.link_type = $4) ), capped AS (SELECT id, depth FROM walk LIMIT $5), nodes AS (SELECT DISTINCT id, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $6 AS walk_truncated, pf.id as from_id, pf.slug as from_slug, pf.source_id as from_source_id, pt.id as to_id, pt.slug as to_slug, pt.source_id as to_source_id, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON (l.from_page_id = w.id OR l.to_page_id = w.id) JOIN pages pf ON pf.id = l.from_page_id JOIN pages pt ON pt.id = l.to_page_id WHERE w.depth < $7 AND pf.deleted_at IS NULL AND pt.deleted_at IS NULL AND ($8 OR l.link_type = $9) ORDER BY depth, from_slug, to_slug, from_source_id, to_source_id LIMIT $10",
+ "textSha256": "6ebe2010f651c3a10e2c52680122ad0e38b9cdf69246cd8e1fd1b0e5e0f9ea85"
}
],
"both+sourceIds+excludePrivate": [
@@ -516,8 +516,8 @@
"array<string>",
"number"
],
- "sql": "WITH RECURSIVE walk AS ( SELECT p.id, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL AND (COALESCE(p.frontmatter->>'visibility', CASE WHEN (p.type = 'atom' OR (p.type = 'concept' AND p.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN p.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = p.source_id AND derived_origin.slug = p.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (p.type = 'atom' OR (p.type = 'concept' AND p.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 = p.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 p.source_id = ANY($2::text[]) UNION ALL SELECT p2.id, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON (l.from_page_id = w.id OR l.to_page_id = w.id) JOIN pages p2 ON p2.id = CASE WHEN l.from_page_id = w.id THEN l.to_page_id ELSE l.from_page_id END WHERE w.depth + 1 < $3 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND (COALESCE(p2.frontmatter->>'visibility', CASE WHEN (p2.type = 'atom' OR (p2.type = 'concept' AND p2.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN p2.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = p2.source_id AND derived_origin.slug = p2.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (p2.type = 'atom' OR (p2.type = 'concept' AND p2.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 = p2.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)) )) AND ($4 OR l.link_type = $5) AND p2.source_id = ANY($6::text[]) ), capped AS (SELECT id, depth FROM walk LIMIT $7), nodes AS (SELECT DISTINCT id, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $8 AS walk_truncated, pf.slug as from_slug, pt.slug as to_slug, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON (l.from_page_id = w.id OR l.to_page_id = w.id) JOIN pages pf ON pf.id = l.from_page_id JOIN pages pt ON pt.id = l.to_page_id WHERE w.depth < $9 AND pf.deleted_at IS NULL AND (COALESCE(pf.frontmatter->>'visibility', CASE WHEN (pf.type = 'atom' OR (pf.type = 'concept' AND pf.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN pf.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = pf.source_id AND derived_origin.slug = pf.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (pf.type = 'atom' OR (pf.type = 'concept' AND pf.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 = pf.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)) )) AND pt.deleted_at IS NULL AND (COALESCE(pt.frontmatter->>'visibility', CASE WHEN (pt.type = 'atom' OR (pt.type = 'concept' AND pt.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN pt.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = pt.source_id AND derived_origin.slug = pt.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (pt.type = 'atom' OR (pt.type = 'concept' AND pt.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 = pt.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 ($10 OR l.link_type = $11) AND pf.source_id = ANY($12::text[]) AND pt.source_id = ANY($13::text[]) ORDER BY depth, from_slug, to_slug LIMIT $14",
- "textSha256": "f7b67d9b99542223fe741b65e39c048efe9febbe73073a329e7988078e2559a0"
+ "sql": "WITH RECURSIVE walk AS ( SELECT p.id, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL AND (COALESCE(p.frontmatter->>'visibility', CASE WHEN (p.type = 'atom' OR (p.type = 'concept' AND p.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN p.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = p.source_id AND derived_origin.slug = p.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (p.type = 'atom' OR (p.type = 'concept' AND p.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 = p.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 p.source_id = ANY($2::text[]) UNION ALL SELECT p2.id, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON (l.from_page_id = w.id OR l.to_page_id = w.id) JOIN pages p2 ON p2.id = CASE WHEN l.from_page_id = w.id THEN l.to_page_id ELSE l.from_page_id END WHERE w.depth + 1 < $3 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND (COALESCE(p2.frontmatter->>'visibility', CASE WHEN (p2.type = 'atom' OR (p2.type = 'concept' AND p2.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN p2.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = p2.source_id AND derived_origin.slug = p2.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (p2.type = 'atom' OR (p2.type = 'concept' AND p2.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 = p2.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)) )) AND ($4 OR l.link_type = $5) AND p2.source_id = ANY($6::text[]) ), capped AS (SELECT id, depth FROM walk LIMIT $7), nodes AS (SELECT DISTINCT id, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $8 AS walk_truncated, pf.id as from_id, pf.slug as from_slug, pf.source_id as from_source_id, pt.id as to_id, pt.slug as to_slug, pt.source_id as to_source_id, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON (l.from_page_id = w.id OR l.to_page_id = w.id) JOIN pages pf ON pf.id = l.from_page_id JOIN pages pt ON pt.id = l.to_page_id WHERE w.depth < $9 AND pf.deleted_at IS NULL AND (COALESCE(pf.frontmatter->>'visibility', CASE WHEN (pf.type = 'atom' OR (pf.type = 'concept' AND pf.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN pf.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = pf.source_id AND derived_origin.slug = pf.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (pf.type = 'atom' OR (pf.type = 'concept' AND pf.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 = pf.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)) )) AND pt.deleted_at IS NULL AND (COALESCE(pt.frontmatter->>'visibility', CASE WHEN (pt.type = 'atom' OR (pt.type = 'concept' AND pt.frontmatter->>'synthesized_by' IS NOT NULL)) THEN 'private' ELSE 'world' END) <> 'private' AND NOT (CASE WHEN pt.type = 'atom' THEN EXISTS (SELECT 1 FROM pages derived_origin WHERE derived_origin.source_id = pt.source_id AND derived_origin.slug = pt.frontmatter->>'source_slug' AND derived_origin.frontmatter->>'visibility' = 'private') WHEN (pt.type = 'atom' OR (pt.type = 'concept' AND pt.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 = pt.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 ($10 OR l.link_type = $11) AND pf.source_id = ANY($12::text[]) AND pt.source_id = ANY($13::text[]) ORDER BY depth, from_slug, to_slug, from_source_id, to_source_id LIMIT $14",
+ "textSha256": "f0a2cdea00c215134219886ee221c9a571407d29f63f38f7340545ff790361d9"
}
],
"default": [
@@ -535,8 +535,8 @@
"string",
"number"
],
- "sql": "WITH RECURSIVE walk AS ( SELECT p.id, p.slug, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL SELECT p2.id, p2.slug, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth + 1 < $2 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND ($3 OR l.link_type = $4) ), capped AS (SELECT id, slug, depth FROM walk LIMIT $5), nodes AS (SELECT DISTINCT id, slug, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $6 AS walk_truncated, w.slug as from_slug, p2.slug as to_slug, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth < $7 AND p2.deleted_at IS NULL AND ($8 OR l.link_type = $9) ORDER BY depth, from_slug, to_slug LIMIT $10",
- "textSha256": "8431b064516c53834fd114df302b49f5acbe3a09fc5e80a95d6ee17b6ac8377c"
+ "sql": "WITH RECURSIVE walk AS ( SELECT p.id, p.slug, p.source_id, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL SELECT p2.id, p2.slug, p2.source_id, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth + 1 < $2 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND ($3 OR l.link_type = $4) ), capped AS (SELECT id, slug, source_id, depth FROM walk LIMIT $5), nodes AS (SELECT DISTINCT id, slug, source_id, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $6 AS walk_truncated, w.id as from_id, w.slug as from_slug, w.source_id as from_source_id, p2.id as to_id, p2.slug as to_slug, p2.source_id as to_source_id, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth < $7 AND p2.deleted_at IS NULL AND ($8 OR l.link_type = $9) ORDER BY depth, from_slug, to_slug, from_source_id, to_source_id LIMIT $10",
+ "textSha256": "e85a15fac4e1db7f3451b223ff4f2b68341957636a2c74f142600fd36771edd2"
}
],
"in": [
@@ -554,8 +554,8 @@
"string",
"number"
],
- "sql": "WITH RECURSIVE walk AS ( SELECT p.id, p.slug, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL SELECT p2.id, p2.slug, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON l.to_page_id = w.id JOIN pages p2 ON p2.id = l.from_page_id WHERE w.depth + 1 < $2 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND ($3 OR l.link_type = $4) ), capped AS (SELECT id, slug, depth FROM walk LIMIT $5), nodes AS (SELECT DISTINCT id, slug, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $6 AS walk_truncated, p2.slug as from_slug, w.slug as to_slug, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON l.to_page_id = w.id JOIN pages p2 ON p2.id = l.from_page_id WHERE w.depth < $7 AND p2.deleted_at IS NULL AND ($8 OR l.link_type = $9) ORDER BY depth, from_slug, to_slug LIMIT $10",
- "textSha256": "311669d8d3ae9b2353cba5d61f1930435807a062a6241d8e07bde66fb91806f2"
+ "sql": "WITH RECURSIVE walk AS ( SELECT p.id, p.slug, p.source_id, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL UNION ALL SELECT p2.id, p2.slug, p2.source_id, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON l.to_page_id = w.id JOIN pages p2 ON p2.id = l.from_page_id WHERE w.depth + 1 < $2 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND ($3 OR l.link_type = $4) ), capped AS (SELECT id, slug, source_id, depth FROM walk LIMIT $5), nodes AS (SELECT DISTINCT id, slug, source_id, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $6 AS walk_truncated, p2.id as from_id, p2.slug as from_slug, p2.source_id as from_source_id, w.id as to_id, w.slug as to_slug, w.source_id as to_source_id, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON l.to_page_id = w.id JOIN pages p2 ON p2.id = l.from_page_id WHERE w.depth < $7 AND p2.deleted_at IS NULL AND ($8 OR l.link_type = $9) ORDER BY depth, from_slug, to_slug, from_source_id, to_source_id LIMIT $10",
+ "textSha256": "42ebd2f252ca54faaa92aee69cb1695930b827a4517500528c616991e26c2705"
}
],
"out+sourceId+linkType": [
@@ -576,8 +576,8 @@
"string",
"number"
],
- "sql": "WITH RECURSIVE walk AS ( SELECT p.id, p.slug, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL AND p.source_id = $2 UNION ALL SELECT p2.id, p2.slug, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth + 1 < $3 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND ($4 OR l.link_type = $5) AND p2.source_id = $6 ), capped AS (SELECT id, slug, depth FROM walk LIMIT $7), nodes AS (SELECT DISTINCT id, slug, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $8 AS walk_truncated, w.slug as from_slug, p2.slug as to_slug, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth < $9 AND p2.deleted_at IS NULL AND ($10 OR l.link_type = $11) AND p2.source_id = $12 ORDER BY depth, from_slug, to_slug LIMIT $13",
- "textSha256": "4d1393bd3ef7fabe22133c82a8bd0779c32cb1825bf3d89dc5c53bf7a6a343e4"
+ "sql": "WITH RECURSIVE walk AS ( SELECT p.id, p.slug, p.source_id, 0::int as depth, ARRAY[p.id] as visited FROM pages p WHERE p.slug = $1 AND p.deleted_at IS NULL AND p.source_id = $2 UNION ALL SELECT p2.id, p2.slug, p2.source_id, w.depth + 1, w.visited || p2.id FROM walk w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth + 1 < $3 AND NOT (p2.id = ANY(w.visited)) AND p2.deleted_at IS NULL AND ($4 OR l.link_type = $5) AND p2.source_id = $6 ), capped AS (SELECT id, slug, source_id, depth FROM walk LIMIT $7), nodes AS (SELECT DISTINCT id, slug, source_id, depth FROM capped) SELECT (SELECT count(*) FROM capped) > $8 AS walk_truncated, w.id as from_id, w.slug as from_slug, w.source_id as from_source_id, p2.id as to_id, p2.slug as to_slug, p2.source_id as to_source_id, l.link_type, l.context, w.depth + 1 as depth FROM nodes w JOIN links l ON l.from_page_id = w.id JOIN pages p2 ON p2.id = l.to_page_id WHERE w.depth < $9 AND p2.deleted_at IS NULL AND ($10 OR l.link_type = $11) AND p2.source_id = $12 ORDER BY depth, from_slug, to_slug, from_source_id, to_source_id LIMIT $13",
+ "textSha256": "687df7c9ed8c269f0340ef55ef0b34a7306388ef4937c3933066e27572fce591"
}
]
}