Skip to content

feat!: require ordered axis in custom categoryNames#21

Merged
antonstefer merged 2 commits into
mainfrom
feat/require-ordered-axis-in-custom-categories
Apr 28, 2026
Merged

feat!: require ordered axis in custom categoryNames#21
antonstefer merged 2 commits into
mainfrom
feat/require-ordered-axis-in-custom-categories

Conversation

@antonstefer
Copy link
Copy Markdown
Owner

@antonstefer antonstefer commented Apr 28, 2026

Summary

Replace the silent House auto-prepend at generator.ts:177-179 with an explicit error when a user-supplied categoryNames list contains no category with ordered: true.

Before: generate({ categoryNames: [4 unordered] }) → silently mutates input to 5 categories (House + your 4) and proceeds.
After: same call → throws with a message that explains the requirement and points to defaultHouseCategory(size) as the escape hatch.

The default path (no categoryNames supplied) is unchanged — it still prepends House to DEFAULT_CATEGORIES because that contract is internal.

Why

Migration

// Before — relied on silent prepend
generate({ size: 4, categoryNames: [name, color, drink, pet] });

// After — pick one of:
generate({ size: 4, categoryNames: [defaultHouseCategory(4), name, color, drink, pet] });
// or mark a domain-relevant category as ordered with orderingPhrases

The error message itself includes this hint.

Implementation notes

  • The throw fires after validateCategories(categories) so existing structural errors (duplicate values, duplicate names, missing verbs) still surface first when present.
  • logic-grid-ai is unaffected: validateThemeResult already requires an ordered axis on AI output, so generateTheme results always satisfy the new contract.
  • Demo presets (hedge-fund, morning-schedule) both already mark a category ordered, so no demo changes needed.
  • README updated with the new requirement and an example using defaultHouseCategory(size).

Release impact

feat!: triggers a major bump → release-please will propose logic-grid 3.0.0. After it lands, logic-grid-ai's peerDep should bump to ^3.0.0 in a follow-up commit so a corresponding logic-grid-ai major is cut.

Replace the silent House-prepend fallback in generate() with an
explicit error when a user-supplied categoryNames list contains no
category with ordered: true. The default-categories path (when
categoryNames is omitted) is unchanged.

The previous behavior silently changed the puzzle shape — pass 4
themed categories, get a puzzle with 5 columns including an
unrelated 'House 1/2/3/4'. That violates the project's
no-silent-fallbacks rule and surprises callers who expected their
category list to be respected.

BREAKING CHANGE: generate({ categoryNames: [...] }) now throws when
no category has ordered: true. Migration: prepend
defaultHouseCategory(size) to categoryNames, or mark a
domain-relevant category as ordered: true with orderingPhrases.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 28, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
logic-grid e55319c Commit Preview URL

Branch Preview URL
Apr 28 2026, 11:59 AM

Adds a positive test for the new validation in generator.ts so that a
future refactor that drops the throw fails CI.
@antonstefer antonstefer merged commit 07b59ef into main Apr 28, 2026
4 checks passed
@antonstefer antonstefer deleted the feat/require-ordered-axis-in-custom-categories branch April 28, 2026 12:02
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