Skip to content

feat(rpkg): return event state as data.frame or list-of-data.frames#193

Open
CGMossa wants to merge 1 commit into
fix/resolve-paths-pass-throughfrom
error-state-as-dataframe
Open

feat(rpkg): return event state as data.frame or list-of-data.frames#193
CGMossa wants to merge 1 commit into
fix/resolve-paths-pass-throughfrom
error-state-as-dataframe

Conversation

@CGMossa
Copy link
Copy Markdown
Contributor

@CGMossa CGMossa commented May 11, 2026

Stacked on #192. The R bindings flattened Success / Error rows into a single data.frame with NA-padded columns between variants — useful for nothing. With miniextendr's new vec_to_dataframe_split, callers now get a bare data.frame when only one variant occurred, or a named list(Success = <df>, Error = <df>) when both occurred, each carrying only its own columns. For dvs_add / dvs_get, when there's no glob, the rpkg now bypasses resolve_paths_for_* and lets validate_for_* (with #192's cwd-relative support) classify each path per-row, so missing / untracked paths surface as Error rows instead of bailing the whole call. ui/main_events.sh walks the 12 cases ({all-success, all-failure, mixed-success, mixed-failure} × {add, get, status}) so reviewers can eyeball the shape switch.

AI-written details

Summary

  • Bumps the miniextendr pin so vec_to_dataframe_split is available.
  • Adds per-command Serialize view enums (AddResultView, GetResultView, FileStatusSuccessView / ErrorView), externally tagged so the splitter sees Success / Error as proper variants.
  • dvs_status partitions manually so the Success data.frame carries add_time as a POSIXct column (jiff timestamps go directly to OffsetDateTime, not through serde's RFC 3339 string form).
  • R-side .dvs_finalize helper recursively applies new_dvs_bytes to byte columns and tibble::as_tibble, preserving whichever shape Rust returned.
  • For dvs_add / dvs_get: when no glob is supplied, bypasses resolve_paths_for_* and feeds user paths straight to add_files / get_files. validate_for_add / validate_for_get already classify each path per-row (Valid / NotFound / OutsideProject / IsDirectory for add; Tracked / NotTracked / NotFound for get) and the per-row machinery surfaces non-Valid statuses as Error rows. resolve_paths_for_* stays for the directory-walk + glob case.

Test plan

  • cargo check -p dvs-rpkg clean
  • devtools::test('dvs-rpkg') passes (test-add.R / test-get.R updated to assert per-row Error rows for missing / untracked paths instead of expect_error)
  • bash ui/main_events.sh exercises 12 cases ({all-success, all-failure, mixed-success, mixed-failure} × {add, get, status}) and prints class and shape per case. Verify bare tibble for all-success/all-failure, named list(Error, Success) for mixed cases.

Notes


Drafted by Claude (claude-opus-4-7). Reviewed by the author.

dvs_add / dvs_get / dvs_status used to flatten Success and Error rows
into a single data.frame with NA columns padded between variants.
With miniextendr's new vec_to_dataframe_split helper, R callers now
get:

  - a single bare data.frame when only one variant occurred (all
    rows are Success, or all rows are Error)
  - a named list(Success = <df>, Error = <df>) when both variants
    occurred, where each per-variant data.frame contains only its
    own columns

Implementation:
- Bump miniextendr pin so vec_to_dataframe_split is available.
- Per-command Serialize view enums (AddResultView, GetResultView,
  FileStatusSuccessView / ErrorView) — externally tagged so the
  splitter sees Success / Error as proper variants.
- dvs_status partitions manually so the Success data.frame can
  carry add_time as a POSIXct column (jiff timestamps go directly
  to OffsetDateTime, not through serde's RFC 3339 string form).
- R-side .dvs_finalize helper recursively applies new_dvs_bytes
  to byte columns and tibble::as_tibble, preserving whichever
  shape Rust returned.
- For dvs_add and dvs_get: when no glob is supplied, bypass
  resolve_paths_for_* and feed user paths straight to add_files /
  get_files. validate_for_add / validate_for_get already classify
  each path per-row (Valid / NotFound / OutsideProject / IsDirectory
  for add; Tracked / NotTracked / NotFound for get) and the
  per-row machinery surfaces non-Valid statuses as Error rows.
  resolve_paths_for_* stays for the directory-walk + glob case.
  Depends on the companion paths.rs change so validate_for_* can
  consume cwd-relative input directly.

Tests:
- test-add.R / test-get.R now assert per-row Error rows for
  missing / untracked paths instead of expect_error.

UI walk-through:
- ui/main_events.sh exercises 12 cases — {all-success, all-failure,
  mixed-success, mixed-failure} x {add, get, status} — and prints
  class + shape for each so reviewers can eyeball the data.frame-vs-
  named-list switch per scenario.
@CGMossa CGMossa force-pushed the fix/resolve-paths-pass-through branch from 79e65df to 2270fcf Compare May 17, 2026 09:17
@CGMossa CGMossa force-pushed the error-state-as-dataframe branch from eb69167 to 4863e80 Compare May 17, 2026 09:17
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