Skip to content

feat(directory): per-host dedup + featured-pinning (re-land #53 onto main)#65

Merged
New1Direction merged 1 commit into
mainfrom
feat/directory-dedup-reland
Jun 5, 2026
Merged

feat(directory): per-host dedup + featured-pinning (re-land #53 onto main)#65
New1Direction merged 1 commit into
mainfrom
feat/directory-dedup-reland

Conversation

@New1Direction

Copy link
Copy Markdown
Owner

Re-lands the directory per-host dedup from #53, which had been opened against a stale branch (fix/proxy-test-real-auth, 41 commits behind main) instead of main.

What it does: adds worker/src/directory_rank.ts — pure, unit-tested per-host dedup + featured-first ordering, so one prolific Shopify-cron host (the "aloyoga flood") can't dominate /directory.

Conflict resolved in index.ts: kept main's deep seen: pagination (reads the full set, not just 1000 keys) AND fed it into rankDirectory (per-host cap + featured bypass + distinct_hosts), preserving main's cache-control headers.

Verified: 237/237 worker tests pass (incl. new directory_rank.test.ts), tsc --noEmit clean.

#54 (governance) and #55 (leads) were already in main via other commits — those PRs were stale duplicates, nothing to re-land.

…oga flood) (#53)

* feat: per-host dedup + featured-pinning for /directory (stop the aloyoga flood)

The directory read as spam: the 2h Shopify cron seeds hundreds of products from
a few stores, KV.list returns ~insertion order, so one host (aloyoga) flooded
the page before diverse hosts appeared. directory_rank.ts (pure + unit-tested)
caps each host (default 3, featured bypasses) and pins featured; /api/v1/directory
reads a wide 1000-key window then diversifies, returns distinct_hosts. +6 tests.
Stacked on fix/proxy-test-real-auth; base auto-retargets to main on merge.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(directory): count distinct_hosts after truncation; clarify per_host=0 + subdomain limits

Adversarial review of the ranking found 3 minor defects (all display/clarity, no
functional/security impact):

1. distinct_hosts was counted over the pre-truncation deduped list, so the
   'N stores' badge could overcount when deduped.length > limit (e.g. 20 hosts,
   limit 10 → badge said 20, showed 10). Now counted on the returned entries.
2. per_host=0 was labelled 'full list' but limit still truncates. Corrected the
   doc comment, handler comment, and test name; added an assertion that limit
   still applies when perHost=0.
3. hostOf keys on the full host, so shop.x.com vs x.com get separate quotas.
   Left as-is (eTLD+1 collapsing needs a public-suffix list; sub-stores can be
   distinct) but documented the limitation + locked in behavior with a test.

+2 tests (161 total). Verify green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: New1Direction <285551516+New1Direction@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@New1Direction New1Direction merged commit 11bed05 into main Jun 5, 2026
1 check passed
@New1Direction New1Direction deleted the feat/directory-dedup-reland branch June 5, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant