Skip to content

Add ROMAN relaxation rules 0-4 and validate ARABIC by round-trip#173

Merged
hackerwins merged 1 commit into
mainfrom
fix-ascii-func
May 1, 2026
Merged

Add ROMAN relaxation rules 0-4 and validate ARABIC by round-trip#173
hackerwins merged 1 commit into
mainfrom
fix-ascii-func

Conversation

@ggyuchive

@ggyuchive ggyuchive commented May 1, 2026

Copy link
Copy Markdown
Member

Summary

ROMAN now accepts an optional second parameter (0–4) enabling progressively relaxed subtractive pairs (rule 4 adds ID=499, IM=999).

ARABIC validation is rewritten as a round-trip check: the input must equal the canonical ROMAN(n, rule) output for some rule 0–4, which cleanly rejects non-canonical forms like ILL, ILXL, ILX without ad-hoc structural checks.

Why

Linked Issues

Fixes #

Verification

CI automatically posts a verification summary comment on this PR with
per-lane results for both verify:self and verify:integration.

  • verify:self — CI comment shows ✅
  • verify:integration — CI comment shows ✅ (or explicit skip reason below)

Skip reason (if applicable):

Risk Assessment

  • User-facing risk:
  • Data/security risk:
  • Rollback plan:

Notes for Reviewers

  • UI changes (screenshots/gifs if applicable):
  • Follow-up work (if any):

Summary by CodeRabbit

New Features

  • ROMAN function now accepts an optional rule parameter to select from different Roman numeral representation formats.

Bug Fixes

  • ARABIC function now validates input format and rejects malformed Roman numerals with improved error handling.
  • ARABIC function now correctly processes edge cases, including empty inputs and negative values.

ROMAN now accepts an optional second parameter (0–4) enabling
progressively relaxed subtractive pairs (rule 4 adds ID=499, IM=999).

ARABIC validation is rewritten as a round-trip check: the input must
equal the canonical ROMAN(n, rule) output for some rule 0–4, which
cleanly rejects non-canonical forms like ILL, ILXL, ILX without
ad-hoc structural checks.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 629b7b3e-4f79-4451-9611-3bdb89d1171c

📥 Commits

Reviewing files that changed from the base of the PR and between 888d1ad and 541464b.

📒 Files selected for processing (2)
  • packages/sheets/src/formula/functions-math.ts
  • packages/sheets/test/formula/formula.test.ts

📝 Walkthrough

Walkthrough

Changes enhance Roman numeral conversion functions: arabicFunc now validates input format, enforces magnitude limits (≤3999), supports optional negation, and verifies canonical forms via round-trip generation; romanFunc accepts an optional rule parameter (0–4) to select different Roman numeral variants; tests expand to cover edge cases and rule-specific behavior.

Changes

Cohort / File(s) Summary
Roman-to-Arabic and Arabic-to-Roman Conversion Functions
packages/sheets/src/formula/functions-math.ts
Enhanced arabicFunc with regex validation, negation support, magnitude enforcement (≤3999), and canonical form verification using round-trip generation. Added optional rule parameter to romanFunc to select from 5 rule variants (0–4) via ROMAN_TABLES.
Roman Numeral Function Tests
packages/sheets/test/formula/formula.test.ts
Expanded test coverage for arabicFunc to validate normalization, malformed input rejection, negation handling, and rule-specific parsing. Added romanFunc tests for optional rule parameter behavior and edge cases (empty input, maximum magnitude).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

Numerals dance from rule zero to four,
Validation and round-trips open the door,
ARABIC and ROMAN now stronger, more true,
Canonical forms sing—the old becomes new! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding ROMAN rules 0-4 and implementing round-trip validation for ARABIC, matching the core objectives of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-ascii-func

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Verification: verify:self

Result: ✅ PASS in 123.6s

Lane Status Duration
sheets:build ✅ pass 12.8s
docs:build ✅ pass 10.6s
verify:fast ✅ pass 61.0s
frontend:build ✅ pass 16.4s
verify:frontend:chunks ✅ pass 0.3s
backend:build ✅ pass 4.6s
cli:build ✅ pass 1.7s
verify:entropy ✅ pass 16.2s

Verification: verify:integration

Result: ✅ PASS

@codecov

codecov Bot commented May 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.05882% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/sheets/src/formula/functions-math.ts 97.05% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@hackerwins
hackerwins merged commit 9fdf6b4 into main May 1, 2026
4 checks passed
@hackerwins
hackerwins deleted the fix-ascii-func branch May 1, 2026 22:37
@hackerwins hackerwins mentioned this pull request May 1, 2026
3 tasks
hackerwins added a commit that referenced this pull request May 1, 2026
ROMAN/ARABIC formula improvement landed on main after the release
branch was cut. Update the release task file to reflect the additional
commit picked up via rebase.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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