feat: viewer_anchor_facts edge read model for broken/external links (#114)#159
Merged
Merged
Conversation
Records the read/write/storage-optimized design for broken/external link listing, superseding the destination-summary-only approach from PR #157.
…#114) Add viewer_anchor_facts, an edge-deduped (source_page_id, dest_page_id) table backing a new cursor-paginated listViewerBrokenLinks fast path, and derive viewer_external_links from the same single anchors scan instead of a separate GROUP BY + COUNT(DISTINCT) query. Bumps VIEWER_READ_MODEL_SCHEMA_VERSION to 6.
… path /api/links?type=broken now dispatches to the cursor-paginated listViewerBrokenLinks when the read model is current, falling back to the legacy offset-based listLinks otherwise. useLinksInfinite switches its virtual-scroll pageParam from offset to the server-issued nextCursor to match.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
viewer_anchor_facts, an edge-deduped(source_page_id, dest_page_id)read-model table with a new cursor-paginatedlistViewerBrokenLinksfast path for/api/links?type=broken.viewer_external_links(added in feat(query,viewer): add viewer_external_links read model for /api/links?type=external #157) from the same singleanchorsscan instead of its ownGROUP BY+COUNT(DISTINCT)query — no extra JOIN cost.url_refs/content_items, issue Design shared text/URL dedup ref tables for viewer read models #139) design, which was reconsidered against a stricter "optimize read/write/storage, don't just follow the doc literally" bar. Full rationale in ARCHITECTURE.md's new「設計注意(viewer_anchor_facts read model、issue Move broken and external links to viewer_anchor_facts #114)」note, and posted to issue #114./api/links?type=brokenmoves from an offset-only response tonextCursor/prevCursor(matching/api/pages's prior migration), with the legacy anchor-scan fallback exposing an equivalent pseudo-cursor. No visible UI change.Benchmark (synthetic archive, no real customer data)
50k pages / 400k anchors: read-model build +5.9s, +152 MiB on disk.
/api/links?type=brokenfast path: warm p50 1.2ms, p95 1.2-1.8ms across all 5 sort/direction combinations (previously 13-16s via the legacy anchor scan).Test plan
yarn build(+ directtsc --noEmitonquery/viewer)yarn test— 303 files / 2431 passed, 5 skippedyarn lint— cleanyarn workspace @nitpicker/viewer test:e2e— 46/46 passed (Broken Links view unchanged visually)/code-review xhigh,/qa-engineer,/product-manager,/doc— findings applied🤖 Generated with Claude Code