Skip to content

fix: table row validation improvements and defensive coding#163

Merged
jlevy merged 5 commits intomainfrom
claude/table-row-validation-fixes
Feb 22, 2026
Merged

fix: table row validation improvements and defensive coding#163
jlevy merged 5 commits intomainfrom
claude/table-row-validation-fixes

Conversation

@jlevy
Copy link
Owner

@jlevy jlevy commented Feb 22, 2026

Summary

Addresses code review findings from PR #161 with defensive coding improvements, refactoring, and documentation clarifications.

Changes

Defensive Coding (P1 Bug Fix):

  • Add explicit state check in isRowFullyEmpty() to handle unknown/malformed cell states conservatively
  • Unknown states now treated as NOT empty to avoid accidentally dropping meaningful data
  • Added tests for malformed cells with unknown states

Code Quality (P2 Refactoring):

  • Extract shared isCellEmpty() helper function to eliminate duplication between isRowFullyEmpty() and validateTableRow()
  • Ensures consistent definition of "empty" across normalization and validation
  • Added comprehensive unit tests for isCellEmpty()

Documentation (P3 Improvements):

  • Clarify "more than half" threshold with concrete examples (e.g., 1 of 3, 1 of 4 trigger warnings; 2 of 4 doesn't)
  • Replace "strictly more than half" phrasing in both markform-spec.md and markform-reference.md

Test Organization (P3):

  • Group mostly-empty row warning tests under describe('mostly-empty row warnings') block

Test Results

  • ✅ All 2266 tests pass (6 new tests for isCellEmpty())
  • ✅ Typecheck passes
  • ✅ Lint passes
  • ✅ No regressions

Closed Beads

  • mf-ccnu: Fix isRowFullyEmpty logic inconsistency (P1 bug)
  • mf-33pt: Extract shared 'is cell empty' logic (P2 refactoring)
  • mf-21q7: Improve documentation phrasing (P3 docs)
  • mf-rk6m: Add describe block for tests (P3 organization)
  • mf-uysu: Boolean false values (closed as not applicable - CellValue doesn't support boolean)
  • mf-kr4o: Integration test (closed as already covered by existing tests)

Related

Follows up on PR #161 code review

🤖 Generated with Claude Code

jlevy and others added 5 commits February 21, 2026 18:23
Make isRowFullyEmpty more defensive by explicitly checking for 'answered'
state before checking cell values. Unknown/unexpected states are now
conservatively treated as NOT empty to avoid accidentally dropping rows
with meaningful data.

Added tests for malformed cells with unknown states to ensure defensive
behavior.

Closes mf-ccnu

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace 'strictly more than half' with concrete examples showing that
even splits (like 2 of 4) don't trigger warnings, while 1 of 3 or 1 of 4
do trigger warnings. Makes the threshold more immediately clear.

Closes mf-21q7

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Group the 4 mostly-empty row warning tests together under a
describe('mostly-empty row warnings') block for better test
organization and readability.

Closes mf-rk6m

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extract cell emptiness logic into a shared isCellEmpty() helper used by
both isRowFullyEmpty() (for row normalization) and validateTableRow()
(for sparseness warnings). This ensures consistent definition of 'empty'
across the codebase and eliminates logic duplication.

Added comprehensive tests for isCellEmpty covering all cell states.

Closes mf-33pt

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove resolved issue files from .tbd/workspaces/outbox after tbd sync.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

Coverage Report for packages/markform

Status Category Percentage Covered / Total
🔵 Lines 66.2% (🎯 64%) 6116 / 9238
🔵 Statements 65.99% (🎯 64%) 6335 / 9599
🔵 Functions 65.58% (🎯 64%) 747 / 1139
🔵 Branches 62.62% (🎯 60%) 4417 / 7053
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/markform/src/engine/validate.ts 91.89% 89.34% 100% 91.73% 128-133, 249, 254-259, 264-269, 318-323, 380-385, 610, 627, 759-764, 771-777, 782, 789-794, 806-811, 826-831, 843-848, 871-876, 881-888, 892-899, 937-942, 1079-1080, 1099-1100, 1154-1160
packages/markform/src/engine/table/parseTable.ts 87.14% 82.4% 93.54% 86.45% 180-224, 263, 278, 325, 508
Generated in workflow #1004 for commit 0d07ef4 by the Vitest Coverage Report Action

@jlevy jlevy merged commit d97beb9 into main Feb 22, 2026
1 check passed
@jlevy jlevy deleted the claude/table-row-validation-fixes branch February 22, 2026 02:58
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