Skip to content

feat: filter the content list by taxonomy term - #3046

Open
eisenbruch wants to merge 13 commits into
emdash-cms:mainfrom
eisenbruch:feat/content-list-term-filters
Open

eisenbruch wants to merge 13 commits into
emdash-cms:mainfrom
eisenbruch:feat/content-list-term-filters

Conversation

@eisenbruch

@eisenbruch eisenbruch commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Implements the accepted feature plan proposals/content-list-term-filters.md (#4087): the content list can be filtered by taxonomy term, in the admin and over the API.

GET /_emdash/api/content/posts?termFilters={"topics":["rodeo","polo"],"places":["kentucky"]}

OR within a taxonomy, AND across taxonomies. total and cursor pages follow the filter.

Documented in the REST API reference ("Filter a content list by term") and the taxonomy guide.

Core

  • The handler rejects a taxonomy not applied to the collection with VALIDATION_ERROR, reading the applied collections from the taxonomy group structure.
  • The repository resolves every taxonomy's slugs to term translation groups in one statement, before the list query, without restricting taxonomies.locale. If a taxonomy matches no term, it returns an empty list without running the list or count query.
  • Slugs and groups are bound as JSON values with jsonTextValues, so there is no slug budget. The schema caps taxonomies at 10 and the raw parameter at 8,192 characters.
  • The page query starts from the matching entries' pivot rows, under a CROSS JOIN so SQLite keeps that order, and seeks each entry by translation_group. Filtered with IN alone, the planner walked the created_at index and tested every row. In the D1 test (400 entries, a term on 3), that page query read 405 rows. Now it reads 15. The count uses the same set in an IN.
  • One taxonomy is a SELECT DISTINCT entry_id over its terms' rows, so an entry carrying two picked terms appears once. Several taxonomies bind every picked term in one JSON value as [set, group] pairs and keep the entries whose rows cover every set (GROUP BY entry_id HAVING COUNT(DISTINCT set) = n). Either way the filter is one SELECT with two parameters, so it stays inside D1's five compound-SELECT terms and 100 bound parameters at any number of taxonomies. The grouped form reads about a fifth more rows on D1, which is why one taxonomy keeps DISTINCT.
  • SQLite preferred walking the pivot's primary key (collection, entry_id, taxonomy_id) over the collection's whole range, 413 rows, because that order makes DISTINCT free. A unary + on collection, SQLite only as in fix(core): seek an id-pinned collection read on the primary key #3916, keeps it on the taxonomy_id index.
  • The joined column is named _term_entry, which no field slug can match, so field filters and ordering on a field named entry_id stay unambiguous.

Admin

One picker per taxonomy applied to the collection, beside the byline filter. It is the entry editor's TaxonomyTermPicker with a new toolbar mode: a filter-bar button instead of the labeled field with chips. The search, option list and keyboard handling are unchanged. Creation is off. Several terms can be picked. The selection is cleared when the list switches to another collection. Terms load as the editor loads them (includeCounts=false, resolveFallback=true for the list's locale). "Clear filters" removes the term keys, and a taxonomy with nothing picked is never sent.

Cost to know about: a term carried by nearly every entry reads about four rows per entry for the page and again for the count (1,602 each for 400 entries on D1), because both start from the pivot. For an admin list I chose that over the plan's failure case, a narrow term reading the whole collection.

Type of change

  • Bug fix
  • Feature (requires an accepted feature plan or RFC)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Your connection to this change

  • I use EmDash and ran into the problem this PR addresses
  • I maintain a tool, dependency, or service that EmDash uses, and this change concerns that integration
  • A Maintainer approved this specific change before I opened the PR

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes: tsgo --noEmit clean for core and admin
  • pnpm lint passes: oxlint --type-aware --deny-warnings on every changed file
  • pnpm test passes (or targeted tests for my change): core repository, schema and integration tests 155 passed on SQLite and PostgreSQL 14; D1 tests 4 passed; admin TermFilters, TaxonomySidebar, ContentList and router tests 215 passed
  • pnpm format has been run: oxfmt --check repo-wide clean
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to their merged design PR: design: filter the content list by taxonomy term #4087
  • I have included screenshots below if this PR changes the UI

AI assistance disclosure

  • This PR includes AI-generated code or text — model/tool: Claude Opus 5.5 (Claude Code)

Screenshots / test output

Before (main): the posts list has no taxonomy filter.

term-filter-before.png

After: a picker per taxonomy beside the byline filter. Here the Categories picker is open with Tutorials and Opinion checked, and the list shows the 2 posts carrying either.

term-filter-open.png

Tests, as the plan's Verification section lists them:

  • Repository (tests/database/repositories/content.test.ts, seeding content_taxonomies by hand): OR within, an entry carrying two picked terms listed once (full page and one-per-page cursors), a field named entry_id combined with a term filter, AND across, unknown slug, empty slug list, total across cursor pages, with an indexed field filter, a de list matching through an en-only term, a parent not matching an entry that carries only its child, and one term lookup with no list query when a taxonomy matches no term.
  • Schema (tests/unit/api/schemas.test.ts): malformed JSON, empty array, name pattern and length, slug length, 10 taxonomies, 300 slugs accepted, raw length.
  • Handler (tests/integration/content/content-list-term-filters.test.ts), on SQLite and PostgreSQL 14: items and total, OR within plus AND across two taxonomies with an entry carrying two picked terms listed once, 152 slugs with 25 bylines, VALIDATION_ERROR for an unapplied and for an unknown taxonomy.
  • D1 (tests/workerd/content-list-term-filters-d1.test.ts): a narrow term's list plus count reads fewer rows than the collection's 400 entries; 151 slugs with 40 field-filter values and 25 bylines loads; six taxonomies (more than D1's five compound-SELECT terms) match only the entries carrying all six, across cursor pages; five taxonomies with 40 field-filter values and 25 inferred bylines stay under D1's 100 parameters.
  • Admin (tests/components/TermFilters.test.tsx): nothing for a collection without taxonomies, several terms sent as slugs and the key removed when cleared, child terms listed, no create control, terms requested with fallback and without counts. ContentList.test.tsx covers "Clear filters" for a term selection alone. router.test.tsx: a term picked on posts is not sent for pages, and is gone on returning to posts.

Manual, on pnpm ux:site:start (editorial-small), after assigning categories to the three posts:

(no filter)                                 total 3  draft-post, first-post, second-post
{"category":["news"]}                       total 2  first-post, second-post
{"category":["tutorials","opinion"]}        total 2  draft-post, second-post
{"category":["news"],"tag":["nosuch"]}      total 0
{"nosuchtaxonomy":["x"]}                    400 VALIDATION_ERROR  Taxonomy not applied to posts: nosuchtaxonomy
{"category":[]}                             400 VALIDATION_ERROR  Invalid request data

🤖 Generated with Claude Code

https://claude.ai/code/session_01RktNvhjty22ohh1GSHXGMq

@changeset-bot

changeset-bot Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 71c5231

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
emdash Minor
@emdash-cms/admin Minor
@emdash-cms/cloudflare Minor
@emdash-cms/plugin-test Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/auth Minor
@emdash-cms/blocks Minor
create-emdash Minor
@emdash-cms/gutenberg-to-portable-text Minor
@emdash-cms/x402 Minor
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 506 lines across 11 files. Large PRs are harder to review and more likely to be closed without review.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@github-actions

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@ascorbic ascorbic added the bot:review Trigger an emdashbot code review on this PR label Sep 11, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@3046

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@3046

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@3046

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@3046

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@3046

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@3046

emdash

npm i https://pkg.pr.new/emdash@3046

create-emdash

npm i https://pkg.pr.new/create-emdash@3046

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@3046

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@3046

@emdash-cms/plugin-test

npm i https://pkg.pr.new/@emdash-cms/plugin-test@3046

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@3046

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@3046

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@3046

@emdash-cms/registry-loader

npm i https://pkg.pr.new/@emdash-cms/registry-loader@3046

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/@emdash-cms/registry-moderation@3046

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@3046

upgrade-emdash

npm i https://pkg.pr.new/upgrade-emdash@3046

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@3046

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@3046

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@3046

@emdash-cms/plugin-ai-search

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-search@3046

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@3046

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@3046

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@3046

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@3046

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@3046

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@3046

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@3046

commit: 71c5231

@emdashbot emdashbot Bot removed the bot:review Trigger an emdashbot code review on this PR label Sep 11, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Visual regression: 10 screens changed

These admin screens render differently on this PR. Confirm every change below is intended before accepting.

Screen Image Compare
content-list-byline-filter-ltr expected · actual
content-list-byline-filter-rtl expected · actual
content-list-date-field-filter-ltr expected · actual
content-list-date-field-filter-rtl expected · actual
content-list-date-range-filter-ltr expected · actual
content-list-date-range-filter-rtl expected · actual
content-list-ltr expected · actual
content-list-rtl expected · actual
content-list-status-filter-ltr expected · actual
content-list-status-filter-rtl expected · actual

Maintainers: if every change above is intended, comment /accept-baselines
to commit the regenerated Linux baselines to this PR.

Measured head: 71c52317e7d30ce4562057fdc761d3c5bb161feb. /accept-baselines accepts the snapshots for this commit.

@eisenbruch

Copy link
Copy Markdown
Contributor Author

Two notes on the CI run, to save a reviewer the digging:

  • The 10 visual-regression diffs are all the new "All categories" control in the content-list filter bar; the fixture's posts collection has the category taxonomy applied, so it now renders there. Nothing else on those screens moved.
  • The D1 Tests failure is migrations-d1.test.ts > replays every migration written since the guarded-DDL pattern timing out at 30s. This PR adds no migrations, and the same job failed on main yesterday (22:52 UTC) and passed on later runs.

@eisenbruch
eisenbruch marked this pull request as draft September 15, 2026 17:14
@github-actions github-actions Bot added needs-rebase and removed review/needs-review No maintainer or bot review yet labels Sep 15, 2026
@swissky swissky added the bot:review Trigger an emdashbot code review on this PR label Sep 23, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds termFilters to the content list API and admin UI, aligned with the shape approved in Discussion #3055. The approach is sound: termFilters is a sibling to fieldFilters (avoiding name collisions), applies OR within a taxonomy and AND across taxonomies via correlated EXISTS subqueries, and is mirrored in countWithResolvedFilters so cursor totals stay stable. The handler correctly rejects taxonomies not attached to the collection instead of silently ignoring them, and the changeset documents the new parameter and failure behavior well.

I checked the diff, AGENTS.md, and related code. The core implementation is clean and the new tests cover the junction semantics. Two admin issues need fixing before merge: FilterBar does not treat term filters as active filters, so the clear button can be hidden and won't clear term filters; and TermFilters lowercases taxonomy labels before passing them to Lingui, which is English-specific and harms other locales. TermFilters also indents hierarchical terms with literal non-breaking spaces, which is not RTL-safe per AGENTS.md. The verbose justifying comment in the handler can be trimmed once the changeset/PR cover it.

Conclusion: approach LGTM, but fix the admin filter-state handling and i18n/RTL issues.


Findings

  • [needs fixing] packages/admin/src/components/ContentList.tsx:888-904

    hasActiveFilter ignores termFilter and handleClear never resets it. As a result, when only a term filter is selected the Clear filters button (rendered from hasActiveFilter at line 986) is hidden, and when other filters are present the button leaves the term filter applied after clearing everything else.

    Add a helper to check for active term selections and reset them in handleClear:

    	const isTermFilterActive = (filter: TermFilterState) =>
    		Object.values(filter).some((slugs) => slugs.length > 0);
    
    	const hasActiveFilter =
    		statusFilter !== "all" ||
    		authorFilter !== "" ||
    		!!dateFilter.from ||
    		!!dateFilter.to ||
    		isBylineFilterActive(bylineFilter) ||
    		isTermFilterActive(termFilter ?? {});
    
    	const handleClear = () => {
    		onStatusFilterChange("all");
    		onAuthorFilterChange?.("");
    		onDateFilterChange?.(EMPTY_DATE_FILTER);
    		// Clearing drops the selection but keeps the inferred-byline
    		// preference, which is a display choice rather than an active filter.
    		onBylineFilterChange?.({
    			...EMPTY_BYLINE_FILTER,
    			includeInferred: bylineFilter.includeInferred,
    		});
    		onTermFilterChange?.({});
    	};
    
  • [needs fixing] packages/admin/src/components/TermFilters.tsx:74-75

    Lowercasing taxonomy labels before passing them into Lingui placeholders is English-specific and makes the message wrong for locales where taxonomy names keep capitals (or follow other casing rules). The translators only see the already-lowercased placeholder value.

    Drop the .toLowerCase() calls and let the original label be the placeholder:

    					allLabel={t`All ${def.label}`}
    					ariaLabel={t`Filter by ${def.label}`}
    
  • [needs fixing] packages/admin/src/components/TermFilters.tsx:123

    Hierarchical indentation is done with literal non-breaking-space characters inside the option text. That is physical indentation and breaks RTL layout expectations: AGENTS.md requires RTL-safe logical Tailwind (ps-*, padding-inline-start, etc.) in admin UI.

    Use an element with logical start padding instead, for example:

    			{options.map(({ term, depth }) => (
    				<Select.Option key={term.id} value={term.slug}>
    					<span
    						className={depth > 0 ? `ps-${Math.min(depth * 4, 12)}` : undefined}
    						style={depth > 0 ? { paddingInlineStart: `${depth * 1}rem` } : undefined}
    					>
    						{term.label}
    					</span>
    				</Select.Option>
    			))}
    
  • [suggestion] packages/core/src/api/handlers/content.ts:553-556

    This comment is justification addressed to the reviewer rather than a future reader of the code. The same rationale and failure choice already appear in the PR description and the changeset, which are the right places for it. Once this block is merged, the behavior is clear from the validation code itself; trim the comment to the single line that states the invariant, or remove it.

@emdashbot emdashbot Bot removed the bot:review Trigger an emdashbot code review on this PR label Sep 23, 2026
@github-actions github-actions Bot mentioned this pull request Sep 24, 2026
11 of 18 tasks
@eisenbruch
eisenbruch force-pushed the feat/content-list-term-filters branch from e13a7f6 to dca23a1 Compare September 24, 2026 15:39
@eisenbruch

Copy link
Copy Markdown
Contributor Author

Rebased onto main after #3364 (bulk tagging), and the review findings addressed in dca23a12:

  • Clear filters and term filters. FilterBar now counts a term selection as an active filter (isTermFilterActive, exported from TermFilters.tsx) and handleClear resets it. New test: with only a term selected, Clear filters is offered and resets it to {}; with none selected, it is not offered. The first test fails on the previous commit and passes on this one.
  • Labels. The taxonomy label goes to Lingui as written (All ${label}, Filter by ${label}), no toLowerCase().
  • Indentation. Child terms are indented with paddingInlineStart in rem, the same pattern TaxonomySidebar uses, instead of literal non-breaking spaces.
  • The handler comment on the unattached-taxonomy rejection is cut to one line.

The rebase conflicted only on the imports in repositories/content.ts (the datetime normalization import added on main). Checked: ContentList.test.tsx and TaxonomySidebar.test.tsx (108 tests), core repositories/content.test.ts and api/schemas.test.ts (133), admin tsgo --noEmit, core tsc --noEmit, oxfmt --ignore-path .gitignore --check, oxlint --type-aware --deny-warnings.

github-actions Bot pushed a commit that referenced this pull request Sep 24, 2026
@emdashbot emdashbot Bot added review/needs-review No maintainer or bot review yet and removed review/needs-review No maintainer or bot review yet labels Nov 7, 2026
github-actions Bot pushed a commit that referenced this pull request Nov 7, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach remains appropriate and consistent with the accepted design. The follow-up addresses the earlier findings: term matches are deduplicated, collection navigation clears term selections before requests are formed, the joined column no longer collides with custom fields, canonical documentation covers the feature, and the picker shares the editor’s query key.

I reviewed the follow-up diff, surrounding query and state handling, the new regression tests, and the documentation against the implementation. I found no new issues requiring changes. Review was static; I did not run tests, builds, or lint checks.


Follow-up review by openai/gpt-6.1-sol, scoped to the changes since the last review.

eisenbruch and others added 2 commits November 12, 2026 11:35
…m-filters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RktNvhjty22ohh1GSHXGMq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RktNvhjty22ohh1GSHXGMq
github-actions Bot pushed a commit that referenced this pull request Nov 12, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach fits the accepted design (OR within a taxonomy, AND across taxonomies, with total and cursor pages following the filter). The earlier findings stay fixed: matches are deduplicated, term selections clear on collection navigation, the joined column avoids custom-field collisions, canonical docs cover the feature, and the picker shares the editor's cache key. The reviewers disagree on whether the change is ready. One (anthropic/claude-opus-5-5) found no new issues and approved. The other (openai/gpt-6.1-sol) found two D1 limits that remain unhandled. Six taxonomy filters exceed the compound-SELECT ceiling, and valid combinations of term, field and inferred-byline filters exceed the bind-parameter ceiling. The existing D1 tests cover only one taxonomy, so they miss both cases. Both reviews were static; neither ran tests, builds or lint.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol. The change since the last review (2109 lines) was too large for a scoped follow-up, so this is a full review.

WHERE ${collection} = ${type}
AND ${sql.ref("taxonomy_id")} IN (${jsonTextValues(this.db, groups)})`,
);
return sql<{ _term_entry: string }>`(${sql.join(sets, sql` INTERSECT `)})`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[needs fixing] This emits one flat compound SELECT containing every taxonomy's set. The schema permits 10 taxonomies, but production D1 permits only 5 compound-SELECT terms, as recorded by D1_COMPOUND_SELECT_LIMIT in packages/cloudflare/src/db/d1-dialect.ts. A valid filter on six applied taxonomies, each resolving to a term, therefore fails with too many terms in compound SELECT instead of returning the filtered page. Respect the adapter's compoundSelectLimit by nesting or otherwise restructuring the intersection while preserving the accepted 10-taxonomy contract. Add coverage for six or more taxonomies; the current D1 tests exercise only one. (Raised by openai/gpt-6.1-sol; anthropic/claude-opus-5-5 did not mention it.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed on D1: six taxonomies failed with too many terms in compound SELECT. Fixed in 71c52317e. With more than one taxonomy, every picked term is now bound in one JSON value as a [set, group] pair, and an entry matches when its pivot rows cover every set (GROUP BY entry_id HAVING COUNT(DISTINCT set) = n). That is one SELECT whatever the number of taxonomies. The page query and the count use it.

One taxonomy keeps the DISTINCT read. On the D1 test's 400 entries the grouped form read 2,001 rows per statement for a broad term against 1,602, and 17 against 15 for a narrow one.

New D1 test: six taxonomies applied, three entries carry all six picked terms and one carries five; total 3, and the second cursor page holds the third entry. It fails on the previous commit.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RktNvhjty22ohh1GSHXGMq

Comment on lines +2253 to +2254
WHERE ${collection} = ${type}
AND ${sql.ref("taxonomy_id")} IN (${jsonTextValues(this.db, groups)})`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[needs fixing] Binding each taxonomy as JSON bounds its slug cost, but these clauses still add two parameters per taxonomy to an already parameter-heavy list query. A schema-valid request with five taxonomy filters, 40 indexed-field operands, and 25 bylines with includeInferredBylines=true binds 102 parameters before pagination: 10 for terms, 40 for fields, and 52 for the byline predicates (the IDs occur in both explicit-credit and inferred-author branches). That exceeds D1's 100-parameter limit even though the same field/byline request without term filters fits. Both page and count fail. Preserve the existing filter budgets by reducing bindings in the combined query, and extend the D1 combination test to multiple taxonomies rather than only one. (Raised by openai/gpt-6.1-sol; anthropic/claude-opus-5-5 did not mention it.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed: five taxonomies with 40 indexed-field values and 25 bylines with includeInferredBylines failed on D1 with too many SQL variables. Fixed by the same change in 71c52317e: term filters now cost two parameters in the page query and two in the count, however many taxonomies are named, so a term filter adds the same as with one taxonomy, which the existing D1 test already covered at those field and byline maximums. New D1 test with that five-taxonomy combination; it fails on the previous commit. A PostgreSQL and SQLite integration test now covers OR within plus AND across taxonomies, with an entry carrying two picked terms listed once.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RktNvhjty22ohh1GSHXGMq

…r limits

An INTERSECT per taxonomy failed on D1 past five taxonomies (too many terms
in compound SELECT) and added two bound parameters per taxonomy, so five
taxonomies with the largest field and byline filters went over 100. Several
taxonomies now bind every picked term as one JSON list of [set, group] pairs
and match entries whose rows cover every set (GROUP BY ... HAVING). One
taxonomy keeps the DISTINCT read, which reads fewer rows on D1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RktNvhjty22ohh1GSHXGMq
@emdashbot emdashbot Bot added review/needs-review No maintainer or bot review yet and removed review/needs-review No maintainer or bot review yet labels Nov 12, 2026
github-actions Bot pushed a commit that referenced this pull request Nov 12, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The revised approach fits the accepted design: grouping matching pivot rows preserves OR within each taxonomy and AND across taxonomies while avoiding D1’s compound-SELECT and parameter limits.

I reviewed the follow-up diff, traced the shared page/count filtering and both SQL dialect branches, and checked the added integration and D1 regressions. The two outstanding findings are addressed: multiple taxonomies now use one SELECT with two bindings, with coverage for six taxonomies, cursor pagination, and the maximum field/byline combination. Earlier resolved findings remain settled.

No new issues found in the changed code. This was a static review; I did not run tests, builds, or lint.


Follow-up review by openai/gpt-6.1-sol, scoped to the changes since the last review.

@eisenbruch

Copy link
Copy Markdown
Contributor Author

CI on 71c52317e, three failures, none from this change:

  • Cloudflare E2E shard (3/8) (and the Tests summary that follows it): editor-image-panel.spec.ts "keeps image settings within the mobile sidebar". The same test fails on main's latest CI run (acb8a0fa5, the commit this branch merged), and this push touched only repositories/content.ts and two term-filter test files.
  • Visual Regression: the content-list screens, for the reason given earlier: the new term filter sits in the filter bar. A maintainer's /accept-baselines is what's needed there.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RktNvhjty22ohh1GSHXGMq

@github-actions

Copy link
Copy Markdown
Contributor

This PR is waiting on its author because it has merge conflicts with main, and it has had no activity for 14 days. It will be closed in 7 days unless there is activity: push an update or leave a comment to keep it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants