Skip to content

Add root-list and pipe-delimited row shapes to @TableSource - #293

Merged
em3s merged 1 commit into
mainfrom
feat/tablesource-pipe-rows-and-root-list
Apr 28, 2026
Merged

em3s merged 1 commit into
mainfrom
feat/tablesource-pipe-rows-and-root-list

Conversation

@em3s

@em3s em3s commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Simplifies @TableSource to a single canonical shape: the annotation value is a YAML list of rows; cells map to test method parameters by position via Kotlin reflection. The previous map-with-columns:-and-rows: wrapper is removed — columns: was always redundant with the method signature, and the rows: wrapper added a layer that didn't earn its keep.

This is a precondition for the Phase 1 migration in #271 / #292: state-machine tests like SingleTransitionTest (41 × 32) read poorly without column-by-column scannability.

Changes

Each row item is one of two shapes:

1. Flow list [a, b, c] — concise for short, simple tables.

@TableSource("""
    - [IDLE,    START, RUNNING]
    - [RUNNING, STOP,  IDLE]
""")
fun `transition`(from: State, event: Event, expected: State) { ... }

2. Pipe-delimited string a | b | c — recommended for wide matrices where column-by-column scannability matters. Each cell is parsed as a YAML scalar, so ~ is null, bare numbers are typed, and single-quoted strings keep their content. YAML strips # comments and blank lines naturally.

@TableSource("""
    # state machine transitions
    - IDLE    | START | RUNNING
    - RUNNING | STOP  | IDLE
""")
fun `transition`(from: State, event: Event, expected: State) { ... }

Implementation

  • core/src/testFixtures/.../params/ObjectSourceExtension.kt — parseTableSource now takes methodParameters: List<String> (supplied from reflection at call time). The annotation value parses as a YAML list directly; each row item is dispatched to parseRow which handles List (flow) or String (pipe).
  • core/src/testFixtures/.../params/TableSource.kt — KDoc updated.
  • core/src/test/.../test/TableSourceTest.kt — covers both shapes plus error paths.

Phase 0 callers updated

The two callers that already used @TableSource are converted to the new shape:

  • engine/.../experiments/hbase/PerCellTTLTest.kt (14 rows × 3 cols)
  • server/.../v3/metadata/MetadataStatusTest.kt (6 rows × 3 cols)

Both retain their original test counts.

Breaking change

The legacy map-with-columns:-and-rows: shape no longer parses. Any consumer outside this PR that uses @TableSource must adopt the new shape; #292 (Phase 1 migration) will rebase on this PR.

How to Test

./gradlew :core:test --tests '*TableSourceTest'                  # 12 cases
./gradlew :server:test --tests '*MetadataStatusTest'             # 6 cases
./gradlew :engine:test --tests '*PerCellTTLTest'                 # 14 cases (HBase)
./gradlew :core:test :server:test                                # full sweep, no regression
./gradlew spotlessKotlinCheck

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code with Claude Opus 4.7 (1M context)

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. enhancement New feature or request labels Apr 28, 2026
Replaces the previous map-with-`columns:`-and-`rows:` shape with a single
canonical form: the annotation value is a YAML list of rows. Cells map to
test method parameters by position via Kotlin reflection, so the redundant
`columns:` declaration is gone too.

Each row item is one of:

- **Flow list** `[a, b, c]` — concise for short tables (existing shape,
  minus the wrapper).
- **Pipe-delimited string** `a | b | c` — recovers the column-by-column
  scannability of the original @CsvSource for wide matrices. Each cell is
  parsed as a YAML scalar (so `~` is null, bare numbers are typed,
  single-quoted strings keep their content). YAML strips `#` comments and
  blank lines naturally.

Example (state-machine style):

    @TableSource("""
        # state machine transitions
        - IDLE    | START | RUNNING
        - RUNNING | STOP  | IDLE
    """)
    fun `transition`(from: State, event: Event, expected: State) { ... }

`parseTableSource` now requires the test method's parameter names; the
extension supplies them from reflection.

Phase 0 callers updated to the new shape:
- engine/.../experiments/hbase/PerCellTTLTest.kt
- server/.../v3/metadata/MetadataStatusTest.kt

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s
em3s force-pushed the feat/tablesource-pipe-rows-and-root-list branch from 7f15e72 to 5af1fa8 Compare April 28, 2026 07:18
em3s added a commit that referenced this pull request Apr 28, 2026
…rce (#271)

Replaces all remaining @CsvSource usages in Kotlin test files with the new
@TableSource shape introduced in #293 (root list, no `columns:` or `rows:`
wrapper, pipe-delimited rows for wide matrices).

- core/codec/EdgeIndexMapperTest.kt — leftover @CsvSource (2 rows)
- core/codec/EdgeCountMapperTest.kt — leftover @CsvSource (1 row)
- core/state/SingleTransitionTest.kt — 41 rows × 32 columns (pipe rows)
- core/state/ProcessingOrderTest.kt — 44 rows × 14 columns (pipe rows)
- test/state/CombinatoricsTest.kt — 8 @CsvSource blocks (flow rows; cells
  are quoted strings parsed by parseAsList)

ComplexTransitionTest.kt and server/filter/ReadOnlyRequestFilterTest.kt
remain on @MethodSource as escape hatches per the issue's guidance: cases
are computed at runtime (cartesian products, reflection-scanned endpoints).

Test bodies and helper calls (toBooleanFlexible, toEventType, toStateValue,
handleSpecialValue, toEventSequence, parseAsList) kept as-is — those
helpers do domain work beyond what Jackson can replace (runtime version
context, special-marker semantics, notation parsing).

Acceptance: `rg "@CsvSource|@valuesource" core engine server` Kotlin
matches drops to 0.

Test counts preserved per file:
- EdgeIndexMapperTest 4 → 4
- EdgeCountMapperTest 6 → 6
- SingleTransitionTest 41 → 41
- ProcessingOrderTest 44 → 44
- CombinatoricsTest 45 → 45

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s

em3s commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed. Merging

@em3s
em3s merged commit dccba6a into main Apr 28, 2026
6 checks passed
@em3s
em3s deleted the feat/tablesource-pipe-rows-and-root-list branch April 28, 2026 07:33
em3s added a commit that referenced this pull request Apr 28, 2026
…rce (#271)

Replaces all remaining @CsvSource usages in Kotlin test files with the new
@TableSource shape introduced in #293 (root list, no `columns:` or `rows:`
wrapper, pipe-delimited rows for wide matrices).

- core/codec/EdgeIndexMapperTest.kt — leftover @CsvSource (2 rows)
- core/codec/EdgeCountMapperTest.kt — leftover @CsvSource (1 row)
- core/state/SingleTransitionTest.kt — 41 rows × 32 columns (pipe rows)
- core/state/ProcessingOrderTest.kt — 44 rows × 14 columns (pipe rows)
- test/state/CombinatoricsTest.kt — 8 @CsvSource blocks (flow rows; cells
  are quoted strings parsed by parseAsList)

ComplexTransitionTest.kt and server/filter/ReadOnlyRequestFilterTest.kt
remain on @MethodSource as escape hatches per the issue's guidance: cases
are computed at runtime (cartesian products, reflection-scanned endpoints).

Test bodies and helper calls (toBooleanFlexible, toEventType, toStateValue,
handleSpecialValue, toEventSequence, parseAsList) kept as-is — those
helpers do domain work beyond what Jackson can replace (runtime version
context, special-marker semantics, notation parsing).

Acceptance: `rg "@CsvSource|@valuesource" core engine server` Kotlin
matches drops to 0.

Test counts preserved per file:
- EdgeIndexMapperTest 4 → 4
- EdgeCountMapperTest 6 → 6
- SingleTransitionTest 41 → 41
- ProcessingOrderTest 44 → 44
- CombinatoricsTest 45 → 45

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
em3s added a commit that referenced this pull request Apr 28, 2026
…rce (#271)

Replaces all remaining @CsvSource usages in Kotlin test files with the new
@TableSource shape introduced in #293 (root list, no `columns:` or `rows:`
wrapper, pipe-delimited rows for wide matrices).

- core/codec/EdgeIndexMapperTest.kt — leftover @CsvSource (2 rows)
- core/codec/EdgeCountMapperTest.kt — leftover @CsvSource (1 row)
- core/state/SingleTransitionTest.kt — 41 rows × 32 columns (pipe rows)
- core/state/ProcessingOrderTest.kt — 44 rows × 14 columns (pipe rows)
- test/state/CombinatoricsTest.kt — 8 @CsvSource blocks (flow rows; cells
  are quoted strings parsed by parseAsList)

ComplexTransitionTest.kt and server/filter/ReadOnlyRequestFilterTest.kt
remain on @MethodSource as escape hatches per the issue's guidance: cases
are computed at runtime (cartesian products, reflection-scanned endpoints).

Test bodies and helper calls (toBooleanFlexible, toEventType, toStateValue,
handleSpecialValue, toEventSequence, parseAsList) kept as-is — those
helpers do domain work beyond what Jackson can replace (runtime version
context, special-marker semantics, notation parsing).

Acceptance: `rg "@CsvSource|@valuesource" core engine server` Kotlin
matches drops to 0.

Test counts preserved per file:
- EdgeIndexMapperTest 4 → 4
- EdgeCountMapperTest 6 → 6
- SingleTransitionTest 41 → 41
- ProcessingOrderTest 44 → 44
- CombinatoricsTest 45 → 45

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
em3s added a commit that referenced this pull request Apr 28, 2026
…rce (#271)

Replaces all remaining @CsvSource usages in Kotlin test files with the new
@TableSource shape introduced in #293 (root list, no `columns:` or `rows:`
wrapper, pipe-delimited rows for wide matrices).

- core/codec/EdgeIndexMapperTest.kt — leftover @CsvSource (2 rows)
- core/codec/EdgeCountMapperTest.kt — leftover @CsvSource (1 row)
- core/state/SingleTransitionTest.kt — 41 rows × 32 columns (pipe rows)
- core/state/ProcessingOrderTest.kt — 44 rows × 14 columns (pipe rows)
- test/state/CombinatoricsTest.kt — 8 @CsvSource blocks (flow rows; cells
  are quoted strings parsed by parseAsList)

ComplexTransitionTest.kt and server/filter/ReadOnlyRequestFilterTest.kt
remain on @MethodSource as escape hatches per the issue's guidance: cases
are computed at runtime (cartesian products, reflection-scanned endpoints).

Test bodies and helper calls (toBooleanFlexible, toEventType, toStateValue,
handleSpecialValue, toEventSequence, parseAsList) kept as-is — those
helpers do domain work beyond what Jackson can replace (runtime version
context, special-marker semantics, notation parsing).

Acceptance: `rg "@CsvSource|@valuesource" core engine server` Kotlin
matches drops to 0.

Test counts preserved per file:
- EdgeIndexMapperTest 4 → 4
- EdgeCountMapperTest 6 → 6
- SingleTransitionTest 41 → 41
- ProcessingOrderTest 44 → 44
- CombinatoricsTest 45 → 45

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
em3s added a commit that referenced this pull request Apr 28, 2026
…rce (#271)

Replaces all remaining @CsvSource usages in Kotlin test files with the new
@TableSource shape introduced in #293 (root list, no `columns:` or `rows:`
wrapper, pipe-delimited rows for wide matrices).

- core/codec/EdgeIndexMapperTest.kt — leftover @CsvSource (2 rows)
- core/codec/EdgeCountMapperTest.kt — leftover @CsvSource (1 row)
- core/state/SingleTransitionTest.kt — 41 rows × 32 columns (pipe rows)
- core/state/ProcessingOrderTest.kt — 44 rows × 14 columns (pipe rows)
- test/state/CombinatoricsTest.kt — 8 @CsvSource blocks (flow rows; cells
  are quoted strings parsed by parseAsList)

ComplexTransitionTest.kt and server/filter/ReadOnlyRequestFilterTest.kt
remain on @MethodSource as escape hatches per the issue's guidance: cases
are computed at runtime (cartesian products, reflection-scanned endpoints).

Test bodies and helper calls (toBooleanFlexible, toEventType, toStateValue,
handleSpecialValue, toEventSequence, parseAsList) kept as-is — those
helpers do domain work beyond what Jackson can replace (runtime version
context, special-marker semantics, notation parsing).

Acceptance: `rg "@CsvSource|@valuesource" core engine server` Kotlin
matches drops to 0.

Test counts preserved per file:
- EdgeIndexMapperTest 4 → 4
- EdgeCountMapperTest 6 → 6
- SingleTransitionTest 41 → 41
- ProcessingOrderTest 44 → 44
- CombinatoricsTest 45 → 45

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s em3s self-assigned this May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant