Repository navigation
feat(content): read what kind of source each link is, and underline the weak ones (CE-046, part a) - #1450
Merged
Conversation
…he weak ones (CE-046, part a) Quality phase 2 (NEXT_PUBLIC_CONTENT_QUALITY_PHASE=2), by rules only: - sourceClass(): primary (official, research, standards), secondary (news, reviews, Wikipedia), weak (forums, social posts, uploaded papers), a competitor's page (primary on a comparison) or the brand's own; an address the rules can't place is left out (an AI read comes in part b) - Trust's primarySources (15) and noWeakSources (10); two placed sources score Trust on their own - Quality suggests replacing weak sources (Show, Keep) and adding a primary one, once Trust is scored; the editor underlines weak sources in amber (a decoration: never exported) - 00263: content_drafts.kept_sources (≤ 50) and content_draft_keep_source() - byUrl keeps a link's first place, so Show goes there Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rebuild supabase/schema.sql with 00262 and 00263, and keep both RPCs in web/src/types/supabase.ts.
gkhngyk
approved these changes
Oct 24, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good. One small follow-up:
- A weak source is underlined before Quality offers Keep for it.
_draft-editor.tsx:557underlines every link intrust.weak, buttrustSuggestionsonly lists the weak sources once Trust is scored (_quality-tab.tsx:435). Take a page whose only source is one forum thread and that has no figures: the link gets the amber underline, and its hover says "See Quality to replace or keep it", but Quality has no row for it. Either underline only whiletrustScore.score !== null, or list the weak row with Keep and no gain before Trust is scored, the way broken links are listed.
Merge notes:
- With #1437 on main, the merge of main on this branch rebuilds
supabase/schema.sqlwithbuild-schema.shand keeps both RPCs inweb/src/types/supabase.ts. getContentDraftnow selectskept_sources, so 00263 has to be on prod before this merges. Otherwise the editor fails to load.- 00263 dry-runs cleanly on prod on top of 00262.
content_draft_keep_sourcekeeps the address for a member and returns nothing for a member of another workspace. The server-columns guard lets the member's write through.
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
This is Quality Phase 2, CE-046 "Source classification (primary / weak / competitor / own)", part a: rules only, no AI. Part b will add an AI read for addresses the rules can't place, cached per host. Everything here sits behind
NEXT_PUBLIC_CONTENT_QUALITY_PHASE=2; with the flag at 1, nothing changes.sourceClass()(web/src/lib/content/source-class.ts) reads a link's kind from its address. It uses the citations' categories (classifyDomain) and a short research/standards list:Trust gets two checks from spec §2.2:
Two placed sources score Trust on their own, even without a figure or a dated source. That is a judgement call: Phase 1 waits for a figure or a dated source because one link would set the whole score, so here it takes two. Say if you'd rather wait for a figure too.
Quality suggests replacing weak sources: "2 sources are weak: a forum, a social post or a competitor's page", with Show and Keep on the first one. It also suggests "No primary source yet". Both appear only once Trust is scored, so their gain is never made up. Before you publish's warning reads them as reasons, e.g. "Trust 40, below 60. No primary source yet. …".
In the draft, a weak source gets an amber wavy underline in place of its link's own, with why on hover. It is a ProseMirror decoration, so no save, export, copy or CMS push carries it. It is marked again on every change of the page while any is listed: a restore, an accepted suggestion, or a second link to the same address.
Keep saves the address on the draft: 00263 adds
content_drafts.kept_sources text[](≤ 50) and the security-invokercontent_draft_keep_source(uuid, text).updated_atbump goes through autosave's same-body retry, as the author pick does.Show on a link listed twice now goes to where the page has it first:
byUrlkeeps the first entry. Stale and broken links get the same fix, which matches what their comment always said."Own data as a primary source" comes with CE-048 (Your input), so the copy doesn't promise it yet.
Related issue
Quality spec (Drive), Phase 2, CE-046 (part a). Follows #1449 (CE-056).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
NEXT_PUBLIC_CONTENT_QUALITY_PHASE=2inweb/.env.local.https://www.reddit.com/r/coffeeand another linkinghttps://www.who.int/. The Reddit link gets an amber wavy underline; hover it to read why.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)00263 is applied on the dev DB and
schema.sqlis rebuilt. Web: all 3,365 tests and the build pass. I checked that the build's CSS has the rule removing the link's own underline under a weak source. I haven't checked it in the browser in both themes yet; it goes into the next local test session, with screenshots.🤖 Generated with Claude Code