feat(power): add site patterns, clean links, Markdown links, and group names

Merged
NO
1d ago
+3188-0

Problem

Plan 07 (power features) needs four small pieces of pure logic before its hooks can land, about day 16, after Core's action table:

  • a shared site matcher, for link routing and site styles;
  • a clean-link strip table, for Shift+Cmd+C;
  • Copy as Markdown;
  • tab-group naming.

They can be written and unit-tested now, with no browser hooks.

Change

Three rac patches in patches/rac/power/. Nothing calls this code yet.

  • site-pattern.patch: rac::SitePattern (chrome/browser/rac/site_pattern/).
    • "Domain is": the host plus its subdomains, matched on label boundaries and case-insensitively. It refuses ICANN suffixes like com or co.uk through the registrable-domain helper, and allows private suffixes like github.io on purpose. It accepts *.host.
    • "URL contains": a case-insensitive substring of the canonical address.
    • Only http(s) pages match. ForSiteOf() gives the "Always open / Boost this site" pattern.
    • Values loaded from prefs are re-checked, so a hand-edited pref can't bypass the input checks.
  • clean-links.patch:
    • rac::CleanLink(), based on Stedding's L2 table (BSD-3). It drops utm_*, ad-click ids, and share ids on known hosts. Every other parameter keeps its order and its byte-exact encoding, the fragment is untouched, and only http(s) addresses change.
    • rac::MarkdownLink() writes [title](clean url), escaped so it always renders as exactly one link.
    • The one upstream hunk is the dep line in chrome/browser/BUILD.gn that loads these targets.
  • group-names.patch: rac::AutoGroupName(), Ardia's deterministic rule ported to C++ (Apache-2.0). The host's name comes from the public suffix list, and IDN hosts are shown in Unicode.

Borrowed code sits in chrome/browser/rac/power/third_party/{stedding,ardia}/ with README.chromium, LICENSE, and NOTICE, so about:credits lists it. tools/licenses/licenses.py parses both.

Net-diff hunks (D17): +1 (chrome/browser/BUILD.gn). Everything else is new rac-owned files.

Verification

  • rac_power_unittests: 106 of 106 pass in a real Chromium 156 build (base-156-2, through build-queue.sh). They include the plan's acceptance cases:
    • https://x.com/a?utm_source=y&id=3#c copies as https://x.com/a?id=3#c;
    • three GitHub PR tabs give the group name "GitHub";
    • Ardia's four test cases, ported one for one;
    • a must-not-change case for every strip-table name, including working look-alikes such as Google Calendar eid and Yandex clid.
  • he validate series is clean.
  • Reviews:
    • a hill-climb council (Sonnet and Devin SWE-2 Max), with no blocking findings; six confirmed findings were fixed;
    • a fresh Opus final review, whose two should-fix items and three nits were fixed;
    • /code-review, whose seven confirmed items were fixed. Two cost items were left for the hooks: PageOf splitting a title again, and Matches() copying the URL.
  • Nothing is user-visible, so there are no screenshots.

This PR is stacked on sync/helium-0.20.1.1. Retarget it to main once the sync merges (D62); it doesn't merge before then.

Model and tool: Claude Opus 5.5 (lead, judge, final review) in Claude Code, with Claude Sonnet 5.5 and Devin SWE-2 for tests and fixes.

šŸ¤– Generated with Claude Code


Devin Review


[!NOTE]
Low Risk
New, test-only library code with no UI or clipboard hooks yet; URL/query handling is localized and heavily unit-tested, with no auth or storage changes.

Overview
Introduces pure logic for upcoming power features (clean copy, Markdown copy, tab-group naming, per-site rules) under chrome/browser/rac/power/ and chrome/browser/rac/site_pattern/, wired into the build via one new dep in chrome/browser/BUILD.gn. Nothing in the browser calls these APIs yet.

rac::CleanLink (Stedding-derived, BSD-3) strips tracking query params on http(s) URLs only, with site-specific rules and byte-exact preservation of kept params and fragments. rac::MarkdownLink builds [label](url) using the cleaned URL and CommonMark-safe escaping. rac::AutoGroupName / SiteName / SiteKey (Ardia rule, Apache-2.0, C++) infer group titles from tab URLs and real page titles, using the public suffix list for host labels and Unicode for IDNs.

rac::SitePattern supports domain is (host + subdomains, rejects bare ICANN suffixes, accepts *.host) and URL contains (case-insensitive substring of canonical spec), with ForSiteOf, dict serialization, and Create/FromValue re-validation so prefs cannot smuggle invalid rules.

Third-party bits live in third_party/stedding and third_party/ardia with README.chromium and licenses. rac_power_unittests aggregates markdown, clean-link, group-name, and site-pattern tests (106 cases per the PR). Three patches are added to patches/series: clean-links, group-names, site-pattern.

Reviewed by Cursor Bugbot for commit ee69dec3b35609d67e30630ee26f23c4407d47b7. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Adds the pure logic and unit tests for four upcoming power features — site pattern matching, clean-link copying, Copy as Markdown, and tab-group naming. Nothing calls this code yet, so there's no user-visible change.

New Features

  • rac::SitePattern matches "domain is" (host plus subdomains, rejecting ICANN suffixes like com, accepting *.host) or "URL contains" for http(s) pages only, and refuses typed sites with a broken scheme.
  • rac::CleanLink drops tracking, ad-click, and share parameters on known hosts, including _ga, _gl, and mibextid on facebook.com and si on youtube-nocookie.com, keeping every other parameter's order and byte-exact encoding and leaving fragments untouched.
  • rac::MarkdownLink writes [title](clean url), percent-encoding < and > in destinations and escaping entity-like & and spaces kept by data: and javascript: addresses, so it renders as exactly one link.
  • rac::AutoGroupName names a tab group from the host's registrable domain, showing IDN hosts in Unicode and keeping non-Latin page titles.
  • Borrowed code from Stedding (BSD-3) and Ardia (Apache-2.0) sits in third_party/ with license files, so about:credits lists it.
  • All 106 rac_power_unittests pass, including must-not-change cases for every strip-table name and the plan's acceptance cases.