Skip to content

fix: length-aware pattern selection and syllable-boundary trimming#14

Open
bukinoshita wants to merge 11 commits into
mainfrom
fix/length-aware-pattern-selection-syllable-trim-2c81
Open

fix: length-aware pattern selection and syllable-boundary trimming#14
bukinoshita wants to merge 11 commits into
mainfrom
fix/length-aware-pattern-selection-syllable-trim-2c81

Conversation

@bukinoshita

@bukinoshita bukinoshita commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary by cubic

Respect name length ranges and trim at syllable-safe boundaries. This addresses BU-2308 by cutting truncation and eliminating illegal endings.

  • New Features
    • Added selectPattern with precomputed PATTERN_LENGTH_STATS to favor patterns whose expected length fits [minLength, maxLength], penalize overshoot, and preserve variety. Falls back to default weights when nothing fits.
  • Bug Fixes
    • Added trimToFit and FINAL_CLUSTERS to cut overlong words at legal boundaries (no split clusters, no naked q, no illegal final letters).
    • Updated padToLength to trim first, then pad using canJoin and a length budget to avoid illegal seams.
    • Results (defaults 6–10): truncation ~33% → ~5%, at-max share ~44% → ~25%, zero illegal endings in tests.

Written for commit a07dcbc. Summary will update on new commits.

Review in cubic

cursoragent and others added 2 commits July 6, 2026 21:33
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
@bukinoshita bukinoshita marked this pull request as ready for review July 6, 2026 22:34

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

5 issues found across 12 files

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread src/utils/pad.ts Outdated
Comment thread src/utils/clusters.ts
Comment thread src/utils/pad.ts Outdated
Comment thread src/utils/pattern-length-stats.ts
Comment thread src/utils/trim-to-fit.ts Outdated
cursoragent and others added 4 commits July 6, 2026 23:01
Addresses cubic review: pad.ts, join-segments.ts and can-join.ts each had their own isVowel; trim-to-fit.ts duplicated trailingConsonantRun. Also replaces the recursive appendPadding with a bounded reduce so padding no longer depends on call-stack depth.

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Recomputing fit weights for all 16 patterns on every call doubled generation cost; caching the candidate list per (min, max) brings 1M-word generation from ~4.2s to ~1.9s and keeps the 1M uniqueness test well under its timeout.

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 9 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/utils/select-pattern.ts
Comment thread src/utils/is-vowel.ts Outdated
cursoragent and others added 2 commits July 6, 2026 23:19
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 4 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 18 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/utils/trim-to-fit.ts Outdated
Comment thread src/utils/pad.ts Outdated
cursoragent and others added 2 commits July 8, 2026 01:01
… prefix fits

Addresses cubic review: with maxLength 2 a word like 'whanere' trimmed to 'wh' and skipped padding since minLength was already met, leaking an illegal ending. trimToFit now returns an empty string when no prefix ends legally, letting padToLength rebuild a legal word from padding syllables.

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Addresses cubic review: appendPadding allocated an array proportional to the initial length deficit. Padding now proceeds in chunks of at most 1024 steps, keeping allocation constant while preserving the exact RNG sequence.

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread src/utils/trim-to-fit.spec.ts
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Requires human review: The PR modifies core name generation logic with new pattern selection, trimming, and padding algorithms; risk of breakage in an important utility.

Re-trigger cubic

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.

2 participants