Skip to content

CRAN release/v1.4.1 with coverage and snapshot stabilization#510

Open
kristinawlai wants to merge 53 commits into
mainfrom
CRANrelease/v1.4.1
Open

CRAN release/v1.4.1 with coverage and snapshot stabilization#510
kristinawlai wants to merge 53 commits into
mainfrom
CRANrelease/v1.4.1

Conversation

@kristinawlai

@kristinawlai kristinawlai commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

Thank you for taking the time to submit a pull request!

To maximize the chances of acceptance:

  • The title of your PR should briefly describe the change.
  • Commit/merge messages to be included in NEWS.md should begin with -.
  • Code should follow the tidyverse style guide.
  • Documentation should use roxygen2, with Markdown syntax.
  • Contributions should include unit tests (using testthat).

For more information see Contributing.

This update reflects the added sim_pop_data_multi core-limit test coverage and stabilized sim_pop_data snapshot RNG behavior.

Changes

  • Updated DESCRIPTION version from 1.4.0.9008 to 1.4.1 for the CRAN release.
  • Updated cran-comments.md to describe the prior archival reason and current R CMD check note(s), with wording corrected to reflect this is a patch (maintenance) release and to reference inst/WORDLIST accurately.
  • Fixed parallel processing behavior in sim_pop_data_multi() to comply with CRAN core-use policies; default num_cores changed from max(1, parallel::detectCores() - 1) to 2L.
  • Switched sapply to vapply with FUN.VALUE = integer(1) in R/sim_pop_data_multi.R for type-safe output.
  • Added tests in tests/testthat/test-sim_pop_data_multi.R to cover _R_CHECK_LIMIT_CORES_ branches and verify expected core cap values plus output structure.
  • Stabilized the sim_pop_data() snapshot by fixing RNG kind/seed in tests/testthat/test-sim_pop_data.R.

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI review requested due to automatic review settings March 24, 2026 03:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prepares the serocalculator package for a CRAN submission by switching from a development version to a release version and updating the CRAN submission notes to reflect the current check status and recent CRAN archival context.

Changes:

  • Updated DESCRIPTION version from 1.4.0.9008 to 1.4.1 for the CRAN release.
  • Updated cran-comments.md to describe the prior archival reason and current R CMD check note(s).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
cran-comments.md Updates CRAN resubmission narrative and summarizes current check results/notes.
DESCRIPTION Bumps package version to the CRAN release version 1.4.1.

Comment thread cran-comments.md Outdated
Comment thread cran-comments.md Outdated
Comment thread DESCRIPTION Outdated
Package: serocalculator
Title: Estimating Infection Rates from Serological Data
Version: 1.4.0.9008
Version: 1.4.1

Copilot AI Mar 24, 2026

Copy link

Choose a reason for hiding this comment

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

DESCRIPTION is being set to version 1.4.1, but NEWS.md currently starts with “serocalculator (development version)” and has no 1.4.1 section header. For a CRAN release, NEWS should typically include an explicit 1.4.1 section (and move the current top entries under it or under a new “development version” header below).

Suggested change
Version: 1.4.1
Version: 1.4.1.9000

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not making this change now for CRAN release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not making this change now for CRAN release.

you already created the 1.4.1 tag on GitHub; now we should increment the dev version before merging back to main, as Copilot suggests; see step 5 of https://r-pkgs.org/release.html#sec-release-post-acceptance

kristinawlai and others added 3 commits March 23, 2026 20:55
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Mar 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
R/check_parallel_cores.R 100.00% <100.00%> (ø)
R/plot_curve_params_one_ab.R 68.75% <ø> (ø)
R/sim_pop_data_multi.R 96.77% <100.00%> (+96.77%) ⬆️

... and 1 file with indirect coverage changes

github-actions Bot added a commit that referenced this pull request Mar 24, 2026
github-actions Bot added a commit that referenced this pull request Mar 24, 2026
github-actions Bot added a commit that referenced this pull request Mar 24, 2026
github-actions Bot added a commit that referenced this pull request Mar 24, 2026
…1 cores to only 2 (as recommended by CRAN). Also fix lints in affected files.
Comment thread R/sim_pop_data_multi.R
@kristinawlai

Copy link
Copy Markdown
Collaborator Author

@copilot write tests to cover the 13 lines of sim_pop_data_multi.R that are not currently covered by tests to meet the minimum coverage levels.

@kristinawlai

Copy link
Copy Markdown
Collaborator Author

@copilot write tests to cover the 13 lines of sim_pop_data_multi.R that are not currently covered by tests to meet the minimum coverage levels.

@UCD-SERG UCD-SERG deleted a comment from Copilot AI Mar 25, 2026
@UCD-SERG UCD-SERG deleted a comment from Copilot AI Mar 25, 2026
@UCD-SERG UCD-SERG deleted a comment from Copilot AI Mar 25, 2026
@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Claude finished @kristinawlai's task in 2m 32s —— View job


Code Review: CRAN release/v1.4.1

  • Gather context and read changed files
  • Review R package correctness (roxygen2, NAMESPACE, DESCRIPTION)
  • Review sim_pop_data_multi.R changes and d-morrison's CHANGES_REQUESTED items
  • Review test coverage and reproducibility
  • Review NEWS.md / changelog hygiene
  • Review CRAN submission materials
  • Post final review summary

Summary

Good progress overall. The snapr restoration, skip_on_os("mac") removal, vapply conversion, and 2L default are all in. The d-morrison CHANGES_REQUESTED review has two open structural items that need resolution before merge. Three smaller items from prior reviews also remain.


D-Morrison's CHANGES_REQUESTED — current status

# Item Status
1 DESCRIPTION: bump version to 1.4.1.9000 ✅ done
2 DESCRIPTION: add snapr back (CRAN version) ✅ done
3 DESCRIPTION: remove Remotes: ✅ done
4 NEWS.md: add dev-version placeholder heading ✅ done (cosmetic issue below)
5 test-sim_pop_data.R: remove skip_on_os("mac"), use snapr::expect_snapshot_data() ✅ done
6 sim_pop_data_multi.R:52 — move _R_CHECK_LIMIT_CORES_ block into check_parallel_cores() ❌ not done
7 sim_pop_data_multi.R:60 — move check_parallel_cores() call inside the env-var block ❌ not done

Must-fix before merging (unblocks d-morrison's CHANGES_REQUESTED)

1. R/sim_pop_data_multi.R:28–60_R_CHECK_LIMIT_CORES_ logic not moved into check_parallel_cores()

d-morrison's review asked for the 24-line env-var block (lines 30–52) and the check_parallel_cores() call (line 55) to be consolidated inside check_parallel_cores() itself, so sim_pop_data_multi() simply calls num_cores |> check_parallel_cores(). This also fixes the related bug in R/check_parallel_cores.R:14 where the message still reads:

"`est_seroincidence_by()` has reduced its `num_cores` argument..."

…which is wrong when the caller is sim_pop_data_multi(). Fix this →

2. R/sim_pop_data_multi.R:10 — stale @param ... alongside @inheritDotParams

Both tags are still present in the source (flagged in every prior review):

#' @param ... arguments passed to [sim.cs()]   # stale: old name, redundant
#' @inheritDotParams sim_pop_data               # wins in the generated .Rd

The .Rd is fine because @inheritDotParams wins, but having both tags means roxygen2 sees a duplicate and may warn. The @param ... line should be removed. Fix this →


Should-fix (cosmetic / avoids future reviewer confusion)

3. vignettes/articles/simulate_xsectionalData.qmd:296 — double assignment (third time flagged)

n_cores <- n_cores <- min(2, parallel::detectCores())

R evaluates right-to-left so the result is correct, but lintr's assignment_linter flags this and it looks like a copy-paste artifact. Fix this →

4. cran-comments.md — note count mismatch (third time flagged)

Header says 0 errors | 0 warnings | 1 note but two distinct bullets follow (WORDLIST spelling + archival notice). Update to 2 notes. Fix this →

5. R/sim_pop_data_multi.R:54 — informal comment (third time flagged)

# Apply your existing safety checker after any cap

"your" is second-person in source code. Change to: # apply safety bounds after env-var cap. Fix this →


Cosmetic

NEWS.md:1 — extra space: # serocalculator (development version)# serocalculator (development version) (d-morrison's suggestion was single-space). Fix this →


What looks good

  • DESCRIPTION version correctly set to 1.4.1.9000 for post-release development ✓
  • snapr restored as CRAN Suggests (no version constraint); Remotes: deleted ✓
  • skip_on_os("mac") removed from test-sim_pop_data.R
  • withr::local_seed() with explicit Mersenne-Twister / Inversion / Rejection RNG kind ✓
  • csdata |> expect_snapshot_data(name = "sim_pop_data") — pipe syntax consistent with snapr API ✓
  • num_cores default changed to 2L — CRAN-safe ✓
  • _R_CHECK_LIMIT_CORES_ handling now covers TRUE/T/YES/Y, FALSE/F/NO/N, numeric strings, and unrecognized values ✓
  • sapplyvapply(FUN.VALUE = integer(1))
  • message()cli::cli_inform() for verbose output ✓
  • New _R_CHECK_LIMIT_CORES_ tests use local_mocked_bindings with .package and capture registerDoParallel calls — correct mocking pattern ✓
  • @param ... on plot_curve_params_one_ab.R documents the fun/n/args restriction inline — correctly avoids the @inheritDotsParam error ✓
  • n_coresnum_cores applied consistently across examples, vignettes, fixtures ✓

@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Claude finished @kristinawlai's task in 2m 6s —— View job


Code Review: CRAN release/v1.4.1

  • Gather context and read changed files
  • Review R package correctness (roxygen2, NAMESPACE, DESCRIPTION)
  • Review sim_pop_data_multi.R and check_parallel_cores.R changes
  • Review test coverage and reproducibility
  • Review NEWS.md / changelog hygiene
  • Review CRAN submission materials
  • Post final review summary

Summary

The latest commit (97ed283 — "claude review suggested changes") addresses five items from prior reviews. Good progress. Two structural items from d-morrison's CHANGES_REQUESTED remain open, plus one cosmetic issue.


What the latest commit fixed ✅

Item Status
R/sim_pop_data_multi.R — stale @param ... arguments passed to [sim.cs()] removed ✅ fixed
R/check_parallel_cores.Rest_seroincidence_by() reference replaced with generic message ✅ fixed
cran-comments.md — note count corrected to 2 notes ✅ fixed
vignettes/articles/simulate_xsectionalData.qmd:296 — double assignment n_cores <- n_cores <- ... removed ✅ fixed
R/sim_pop_data_multi.R:54 — "your" removed from comment ✅ fixed

D-Morrison's CHANGES_REQUESTED — current status

# Item Status
1 DESCRIPTION: bump version to 1.4.1.9000 ✅ done
2 DESCRIPTION: add snapr back (CRAN version) ✅ done
3 DESCRIPTION: remove Remotes: ✅ done
4 NEWS.md: add dev-version placeholder heading ✅ done (cosmetic issue below)
5 test-sim_pop_data.R: remove skip_on_os("mac"), use snapr::expect_snapshot_data() ✅ done
6 Move _R_CHECK_LIMIT_CORES_ block into check_parallel_cores() ❌ still open
7 Move check_parallel_cores() call inside the env-var block ❌ still open

Items 6 and 7 are linked — the ask is to consolidate the 24-line env-var block (lines 29–51 in sim_pop_data_multi.R) and the check_parallel_cores() call into check_parallel_cores() itself, so that sim_pop_data_multi() just calls num_cores |> check_parallel_cores(). Given @kristinawlai's note about wanting to stay close to the CRAN 1.4.1 snapshot, this is a judgment call for @d-morrison on whether to require it now or defer. Fix this →


Remaining issues

tests/testthat/test-sim_pop_data_multi.R:3skip_on_os("linux") in consistency test

test_that("`sim_pop_data_multi()` works consistently", {
  skip_on_cran()
  skip_on_os("linux")   # <-- asymmetric platform skip

This is the same pattern removed from test-sim_pop_data.R. Silently skipping Linux in CI means the snapshot is never validated on the most common CI platform. If Linux non-determinism is unavoidable (e.g., glibc vs. libc differences in the underlying C RNG), document it with a comment explaining why. Otherwise consider using snapr's variant argument (e.g. variant = .Platform$OS.type) to maintain per-platform snapshots rather than silently skipping. Fix this →

NEWS.md:1 — extra space after #

#  serocalculator (development version)

Two spaces between # and serocalculator. Should be one space (# serocalculator (development version)), consistent with the 1.4.1 header and d-morrison's suggestion. Fix this →


What looks good

  • DESCRIPTION version correctly set to 1.4.1.9000
  • snapr restored to Suggests (CRAN version, no version constraint); Remotes: deleted ✓
  • skip_on_os("mac") removed from test-sim_pop_data.R; expect_snapshot_data() used ✓
  • withr::local_seed() with explicit Mersenne-Twister / Inversion / Rejection RNG kind ✓
  • num_cores default 2L — CRAN-safe ✓
  • _R_CHECK_LIMIT_CORES_ handling covers TRUE/T/YES/Y, FALSE/F/NO/N, numeric strings, and unrecognized values ✓
  • sapplyvapply(FUN.VALUE = integer(1))
  • message()cli::cli_inform() for verbose output ✓
  • New _R_CHECK_LIMIT_CORES_ tests use local_mocked_bindings with .package
  • @inheritDotParams error in plot_curve_params_one_ab.R fixed; generated .Rd clean ✓
  • n_coresnum_cores applied consistently across examples, vignettes, fixtures ✓
  • check_parallel_cores.R message no longer names est_seroincidence_by()
  • cran-comments.md note count matches the actual notes ✓

github-actions Bot added a commit that referenced this pull request Jun 12, 2026
@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Claude finished @kristinawlai's task in 2m 36s —— View job


Code Review: CRAN release/v1.4.1

  • Gather context and read changed files
  • Review R package correctness (roxygen2, NAMESPACE, DESCRIPTION)
  • Review sim_pop_data_multi.R and check_parallel_cores.R changes
  • Review test coverage and reproducibility
  • Review NEWS.md / changelog hygiene
  • Review CRAN submission materials
  • Post final review summary

Summary

The latest commit (5675cee — "move lengthy code from sim_pop_data_multi to check_parallel_cores") introduces a critical regression: the _R_CHECK_LIMIT_CORES_ handling block was placed after return(num_cores) in check_parallel_cores.R, making it unreachable dead code. This also means the _R_CHECK_LIMIT_CORES_ test assertions in test-sim_pop_data_multi.R should be failing.

Several items from prior reviews are now resolved (✅ below). Two structural issues remain.


Critical bug (introduced in 5675cee)

R/check_parallel_cores.R:22–47_R_CHECK_LIMIT_CORES_ block is dead code

The block was added after return(num_cores) on line 21 and will never execute:

  return(num_cores)       # ← exits here; everything below is unreachable

  if (nzchar(chk)) {      # ← dead code: never runs
    ...
  }
  if (verbose) {          # ← dead code: `verbose` also isn't a parameter
    ...
  }

Two additional problems in the dead block: chk is not defined in check_parallel_cores() (it lives in sim_pop_data_multi()), and verbose is not a parameter of check_parallel_cores(). Both would error if the code ever ran.

R/sim_pop_data_multi.R:29chk is now a zombie variable:

chk <- Sys.getenv("_R_CHECK_LIMIT_CORES_", "")   # read but never used
num_cores <- num_cores |> check_parallel_cores()   # env-var cap never applied

The env-var parsing was supposed to be moved into check_parallel_cores(), but it's unreachable there, and sim_pop_data_multi() still reads chk without acting on it.

tests/testthat/test-sim_pop_data_multi.R:114–131 — test assertions should be failing

The test mocks check_parallel_cores and asserts that sim_pop_data_multi passes env-var-capped values to it:

# expects 1L when _R_CHECK_LIMIT_CORES_="1"
expect_identical(calls[[3]], expected_calls$numeric_cap)  # min(2L, 1L) = 1L

Since neither sim_pop_data_multi (env var is read, never applied) nor check_parallel_cores (cap block is dead code) actually processes the env var, sim_pop_data_multi always passes the original 2L — so calls[[3]] would be 2L, not 1L. This assertion should fail. Fix this →

The fix is to either:

  • Move the _R_CHECK_LIMIT_CORES_ block to before the return(), and read chk inside check_parallel_cores() instead of expecting it from the caller's scope; OR
  • Revert 5675cee and go back to the working approach where sim_pop_data_multi() applies the env-var cap before calling check_parallel_cores().

D-Morrison's CHANGES_REQUESTED — current status

# Item Status
1 DESCRIPTION: bump version to 1.4.1.9000 ✅ done
2 DESCRIPTION: add snapr back (CRAN version) ✅ done
3 DESCRIPTION: remove Remotes: ✅ done
4 NEWS.md: add dev-version placeholder heading ✅ done (extra space, see below)
5 test-sim_pop_data.R: remove skip_on_os("mac"), use snapr::expect_snapshot_data() ✅ done
6 Move _R_CHECK_LIMIT_CORES_ block into check_parallel_cores() ⚠️ attempted but broken (dead code)
7 Move check_parallel_cores() call inside the env-var block ⚠️ attempted but broken (dead code)

Items fixed since prior review ✅

  • @param ... arguments passed to [sim.cs()] stale tag removed from sim_pop_data_multi.R
  • check_parallel_cores.R message no longer names est_seroincidence_by()
  • cran-comments.md note count corrected to 2 notes
  • Double assignment n_cores <- n_cores <- ... fixed in vignette ✅
  • Informal # Apply your existing safety checker after any cap comment fixed ✅

Remaining minor issues

tests/testthat/test-sim_pop_data_multi.R:3skip_on_os("linux") in snapshot test

The platform skip is still present. Linux is the CI platform — this silently skips the snapshot on the machine most likely to catch regressions. If the RNG seeding is deterministic, the skip should not be needed. If Linux non-determinism is unavoidable (e.g. glibc differences), a comment explaining why would help future reviewers.

NEWS.md:1 — extra space after #

#  serocalculator (development version)

Two spaces between # and serocalculator; should be one (consistent with the # serocalculator 1.4.1 header on line 5 and d-morrison's suggestion). Fix this →


What looks good

  • DESCRIPTION version correctly set to 1.4.1.9000
  • snapr restored to Suggests (CRAN version, no version constraint); Remotes: deleted ✓
  • skip_on_os("mac") removed from test-sim_pop_data.R
  • withr::local_seed() with explicit Mersenne-Twister / Inversion / Rejection RNG kind ✓
  • csdata |> expect_snapshot_data(name = "sim_pop_data") — snapr API used correctly ✓
  • num_cores default changed to 2L — CRAN-safe ✓
  • sapplyvapply(FUN.VALUE = integer(1))
  • message()cli::cli_inform() for verbose output ✓
  • @param ... / @inheritDotParams duplicate tag removed ✓
  • cran-comments.md note count matches ✓
  • n_coresnum_cores consistent across examples, vignettes, fixtures ✓

@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Claude finished @kristinawlai's task in 5m 47s —— View job


Code Review: CRAN release/v1.4.1

  • Gather context and read changed files
  • Review check_parallel_cores.R and sim_pop_data_multi.R (critical regression check)
  • Review test coverage and reproducibility
  • Review NEWS.md / changelog hygiene
  • Review CRAN submission materials
  • Post final review summary

Summary

The latest commit (b7eab0c — "move chk") attempted to fix the dead-code regression from 5675cee by moving chk into check_parallel_cores.R, but the block was placed after return(num_cores) and is still dead code. This is the same critical regression identified in the prior review. Three additional issues remain from prior reviews.


Critical bug — still present

R/check_parallel_cores.R:20–49_R_CHECK_LIMIT_CORES_ block and verbose check are unreachable dead code

  return(num_cores)         # ← function exits here on line 20

  chk <- Sys.getenv(...)    # ← dead code: never runs (line 22)
  if (nzchar(chk)) { ... }  # ← dead code (lines 24–44)
  if (verbose) { ... }      # ← dead code; `verbose` is also not a parameter (lines 46–48)

b7eab0c moved chk from sim_pop_data_multi.R into check_parallel_cores.R, but placed it after the return(). The _R_CHECK_LIMIT_CORES_ cap is therefore never applied.

There is also an additional bug in the dead block: verbose on line 46 is not a parameter of check_parallel_cores() — it would throw object 'verbose' not found if the code ever executed.

Fix: Move the entire chk/if (nzchar(chk)) block to before return(num_cores), and remove the if (verbose) lines entirely (they belong in sim_pop_data_multi(), not here).

Correct structure:

check_parallel_cores <- function(num_cores) {
  requireNamespace("parallel", quietly = FALSE)

  chk <- Sys.getenv("_R_CHECK_LIMIT_CORES_", "")
  if (nzchar(chk)) {
    chk_u <- toupper(chk)
    if (chk_u %in% c("TRUE", "T", "YES", "Y")) {
      num_cores <- min(num_cores, 2L)
    } else if (!chk_u %in% c("FALSE", "F", "NO", "N")) {
      chk_n <- suppressWarnings(as.integer(chk))
      num_cores <- if (!is.na(chk_n) && chk_n >= 1L) min(num_cores, chk_n) else min(num_cores, 2L)
    }
  }

  if (num_cores > (parallel::detectCores() - 1)) {
    num_cores <- min(num_cores, parallel::detectCores() - 1)
    cli::cli_inform(class = "reduced num_cores", c(...))
  }

  return(num_cores)
}

Fix this →


Cascading test failure

tests/testthat/test-sim_pop_data_multi.R:126,130 — assertions will fail because the env-var cap is never applied

The test mocks check_parallel_cores to capture what value sim_pop_data_multi() passes to it, then asserts the env-var-capped values:

# line 126 — expects min(2L, 1L) = 1L when _R_CHECK_LIMIT_CORES_="1"
expect_identical(calls[[3]], expected_calls$numeric_cap)  # 1L expected, 2L actual
# line 130
expect_identical(register_calls[[3]], expected_calls$numeric_cap)  # same failure

Since neither sim_pop_data_multi() (it used to compute the cap, but chk was removed in b7eab0c) nor check_parallel_cores() (dead code) applies the env-var cap, sim_pop_data_multi() always passes the original 2L to check_parallel_cores(). The assertion expecting 1L fails.

Once the dead code is fixed (block moved before return()), the test also needs to be updated: the check_parallel_cores mock bypasses the real function and will always see 2L passed in (before the env-var cap is applied internally). The test should instead:

  1. Remove the check_parallel_cores mock and its assertions (lines 79–85 and 124–127)
  2. Keep the registerDoParallel mock
  3. Add a parallel::detectCores mock (e.g., local_mocked_bindings(detectCores = function(...) 100L, .package = "parallel")) so the detectCores cap doesn't interfere
  4. Assert on register_calls only — these reflect the final capped value passed to registerDoParallel

Fix this →


D-Morrison's CHANGES_REQUESTED — current status

# Item Status
1 DESCRIPTION: bump version to 1.4.1.9000 ✅ done
2 DESCRIPTION: add snapr back (CRAN version) ✅ done
3 DESCRIPTION: remove Remotes: ✅ done
4 NEWS.md: add dev-version placeholder heading ✅ done (extra space, see below)
5 test-sim_pop_data.R: remove skip_on_os("mac"), use snapr::expect_snapshot_data() ✅ done
6 Move _R_CHECK_LIMIT_CORES_ block into check_parallel_cores() ⚠️ attempted but block is dead code after return()
7 Move check_parallel_cores() call inside env-var block / call unconditionally ⚠️ partially done — guard removed but env-var logic non-functional

Remaining issues

tests/testthat/test-sim_pop_data_multi.R:3skip_on_os("linux") skips snapshot on CI

test_that("`sim_pop_data_multi()` works consistently", {
  skip_on_cran()
  skip_on_os("linux")   # <-- CI platform silently skipped

Linux (GitHub Actions ubuntu-latest) is the primary CI platform. Skipping the snapshot there means the snapshot is never validated in CI, which defeats its purpose. If the explicit RNG seeding with withr::local_seed() is sufficient for cross-platform determinism, remove the skip. If Linux genuinely produces different output (e.g. due to glibc differences), document why with a comment. Fix this →

NEWS.md:1 — extra space after #

#  serocalculator (development version)

Two spaces between # and serocalculator. Should be one space (consistent with the # serocalculator 1.4.1 header on line 5). Fix this →


What looks good

  • DESCRIPTION version correctly set to 1.4.1.9000
  • snapr restored to Suggests (CRAN version, no version constraint); Remotes: deleted ✓
  • skip_on_os("mac") removed from test-sim_pop_data.R
  • withr::local_seed() with explicit Mersenne-Twister / Inversion / Rejection RNG kind ✓
  • csdata |> expect_snapshot_data(name = "sim_pop_data") — snapr API used correctly ✓
  • num_cores default changed to 2L — CRAN-safe ✓
  • sapplyvapply(FUN.VALUE = integer(1))
  • message()cli::cli_inform() for verbose output ✓
  • @param ... / @inheritDotParams duplicate tag removed ✓
  • cran-comments.md note count corrected to 2 notes
  • n_coresnum_cores consistent across examples, vignettes, fixtures ✓
  • check_parallel_cores.R message no longer names est_seroincidence_by()
  • @inheritDotParams error in plot_curve_params_one_ab.R fixed ✓
  • Double assignment n_cores <- n_cores <- ... fixed in vignette ✓

github-actions Bot added a commit that referenced this pull request Jun 12, 2026
@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Claude finished @kristinawlai's task in 4m 4s —— View job


Code Review: CRAN release/v1.4.1

  • Gather context and read changed files
  • Review check_parallel_cores.R — dead code issue
  • Review sim_pop_data_multi.R changes
  • Review test coverage and reproducibility
  • Review NEWS.md / changelog hygiene
  • Review CRAN submission materials
  • Post final review summary

Correction from the prior review

The 2026-06-12 19:00 review incorrectly stated that the _R_CHECK_LIMIT_CORES_ cap "is never applied" and that tests would fail. This was wrong. The env-var cap is correctly applied in sim_pop_data_multi.R lines 30–52 before calling check_parallel_cores(). The tests mock what value reaches check_parallel_cores() and those assertions are valid. The tests should pass.


Must fix

1. R/check_parallel_cores.R:23–50 — dead code after return()

The _R_CHECK_LIMIT_CORES_ block was placed after return(num_cores) on line 21 and is unreachable:

  return(num_cores)         # line 21 — exits here

  chk <- Sys.getenv(...)    # lines 23–50 — dead code, never runs
  if (nzchar(chk)) { ... }
  if (verbose) { ... }      # `verbose` also not a parameter of this function

The env-var cap works correctly because it's still in sim_pop_data_multi.R (lines 30–52). But the dead block in check_parallel_cores.R should be removed — it's misleading, the verbose reference would error if somehow reached, and it contradicts d-morrison's design intent (items 6 & 7 below). Fix this →

2. R/check_parallel_cores.R:14 — message still names est_seroincidence_by()

"`est_seroincidence_by()` has reduced its `num_cores` argument..."

This function is called from sim_pop_data_multi() too. The message is wrong in that context. Should be generic: e.g. "Reducing \num_cores` to {num_cores} to avoid destabilizing this computer ({parallel::detectCores()} cores detected)."` Fix this →


D-Morrison's CHANGES_REQUESTED — current status

# Item Status
1 DESCRIPTION: bump version to 1.4.1.9000 ✅ done
2 DESCRIPTION: add snapr back (CRAN version) ✅ done
3 DESCRIPTION: remove Remotes: ✅ done
4 NEWS.md: add dev-version placeholder heading ✅ done (cosmetic issue below)
5 test-sim_pop_data.R: remove skip_on_os("mac"), use snapr::expect_snapshot_data() ✅ done
6 Move _R_CHECK_LIMIT_CORES_ block into check_parallel_cores() ⚠️ attempted but resulted in dead code; env-var cap works via sim_pop_data_multi.R, but the structural change was not completed
7 Move check_parallel_cores() call inside env-var block / call unconditionally ⚠️ same — partially done, structure incomplete

For items 6 & 7: the path of least resistance now is to remove the dead block from check_parallel_cores.R (fix 1 above) and leave the env-var logic in sim_pop_data_multi.R where it works. That defers the refactor to a follow-up PR. Whether to require the full consolidation before merge is d-morrison's call.


Should fix (flagged across multiple prior reviews)

R/sim_pop_data_multi.R:10 — stale @param ... with [sim.cs()] reference alongside @inheritDotParams

#' @param ... arguments passed to [sim.cs()]   # stale, redundant
#' @inheritDotParams sim_pop_data               # wins in the .Rd

Both tags are still present. Remove line 10. Fix this →

vignettes/articles/simulate_xsectionalData.qmd:296 — double assignment (flagged four times)

n_cores <- n_cores <- min(2, parallel::detectCores())

Fix this →

cran-comments.md:13 — note count mismatch (flagged four times)

Header says 0 errors | 0 warnings | 1 note but two note bullets follow (WORDLIST + archival). Update to 2 notes. Fix this →

NEWS.md:1 — extra space after #

# serocalculator (development version)# serocalculator (development version) (one space, consistent with line 5). Fix this →


Test concern

tests/testthat/test-sim_pop_data_multi.R:3skip_on_os("linux") skips on CI

test_that("`sim_pop_data_multi()` works consistently", {
  skip_on_cran()
  skip_on_os("linux")   # <-- GitHub Actions ubuntu-latest silently skipped

Linux is the primary CI platform. The snapshot is never validated in CI. If the explicit withr::local_seed() seeding is sufficient for determinism, this skip should not be needed. If Linux non-determinism is unavoidable, a comment explaining why would help future reviewers.


What looks good

  • DESCRIPTION version correctly set to 1.4.1.9000 for post-release development ✓
  • snapr restored to Suggests (CRAN version, no version constraint); Remotes: deleted ✓
  • skip_on_os("mac") removed from test-sim_pop_data.R; expect_snapshot_data() used ✓
  • withr::local_seed() with explicit Mersenne-Twister / Inversion / Rejection RNG kind ✓
  • num_cores default changed to 2L — CRAN-safe ✓
  • sapplyvapply(FUN.VALUE = integer(1))
  • message()cli::cli_inform() for verbose output ✓
  • _R_CHECK_LIMIT_CORES_ env-var cap applied correctly in sim_pop_data_multi.R — covers TRUE/T/YES/Y, FALSE/F/NO/N, numeric strings, unrecognized values ✓
  • New _R_CHECK_LIMIT_CORES_ tests use local_mocked_bindings with .package; test assertions are valid ✓
  • @inheritDotParams error in plot_curve_params_one_ab.R fixed; generated .Rd clean ✓
  • n_coresnum_cores applied consistently across examples, vignettes, fixtures ✓

github-actions Bot added a commit that referenced this pull request Jun 12, 2026
@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Code Review: CRAN release/v1.4.1

  • Gather context and read changed files
  • Review check_parallel_cores.R — dead code reverted (✅ clean)
  • Fix remaining simple issues that have been flagged across multiple reviews
  • Review d-morrison's CHANGES_REQUESTED status
  • Post final review summary

Working...

View job run

kristinawlai and others added 2 commits June 12, 2026 16:07
- Remove stale @param ... [sim.cs()] tag that shadowed @inheritDotParams
- Generalize check_parallel_cores() message (was est_seroincidence_by()-specific)
- Fix double assignment n_cores <- n_cores <- in vignette
- Correct cran-comments.md note count from 1 to 2
- Fix extra space in NEWS.md development version header

Co-authored-by: Kristina W. Lai <undefined@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 12, 2026
@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Claude finished @kristinawlai's task in 2m 35s —— View job


Code Review: CRAN release/v1.4.1

  • Gather context and read changed files
  • Review check_parallel_cores.R and sim_pop_data_multi.R
  • Review test coverage and reproducibility
  • Review NEWS.md / changelog hygiene
  • Review CRAN submission materials
  • Post final review summary

Summary

The latest commit (712b5e4 — "Fix review findings flagged across multiple Claude reviews") resolves nearly all of the recurring items from prior reviews. The code is in good shape. Two items remain open.


What 712b5e4 fixed ✅

Item Fixed
check_parallel_cores.R — dead code after return() removed
check_parallel_cores.R — generic message (no longer names est_seroincidence_by())
sim_pop_data_multi.R:10 — stale @param ... arguments passed to [sim.cs()] removed
vignettes/articles/simulate_xsectionalData.qmd:296 — double assignment fixed
cran-comments.md — note count corrected to 2 notes
sim_pop_data_multi.R:53 — "your" removed from comment
NEWS.md:1 — extra space after # cleaned up

D-Morrison's CHANGES_REQUESTED — current status

# Item Status
1 DESCRIPTION: bump version to 1.4.1.9000 ✅ done
2 DESCRIPTION: add snapr back (CRAN version) ✅ done
3 DESCRIPTION: remove Remotes: ✅ done
4 NEWS.md: add dev-version placeholder heading ✅ done
5 test-sim_pop_data.R: remove skip_on_os("mac"), use snapr::expect_snapshot_data() ✅ done
6 Move _R_CHECK_LIMIT_CORES_ block into check_parallel_cores() ❌ still in sim_pop_data_multi.R
7 Move check_parallel_cores() call inside the env-var block / call unconditionally ❌ same

Items 6 & 7 are a judgment call for @d-morrison: the env-var cap works correctly in sim_pop_data_multi.R (lines 29–51) and check_parallel_cores.R is now clean (no dead code). Consolidating the logic into check_parallel_cores() is purely a structural preference. @kristinawlai has noted a preference to defer further refactors to a follow-up branch.


Remaining issue

tests/testthat/test-sim_pop_data_multi.R:3skip_on_os("linux") skips snapshot on CI

test_that("`sim_pop_data_multi()` works consistently", {
  skip_on_cran()
  skip_on_os("linux")   # ← GitHub Actions ubuntu-latest silently skipped

This skip has been flagged in every review. Linux (GitHub Actions ubuntu-latest) is the primary CI platform — the snapshot is never validated in CI, which defeats its purpose. If the explicit withr::local_seed() seeding is sufficient for cross-platform determinism, the skip should not be needed. If Linux still produces different output for an unavoidable reason (e.g. platform-specific C library differences), a comment explaining why would help future reviewers. Fix this →


Cosmetic (NEWS.md)

NEWS.md lines 27 and 60 have trailing whitespace (a blank line with spaces). Not a functional issue, but lintr's trailing_whitespace_linter may flag these. Worth a quick cleanup. Fix this →


What looks good

  • DESCRIPTION version set to 1.4.1.9000 for post-release development ✓
  • snapr in Suggests (CRAN version, no version constraint); Remotes: deleted ✓
  • check_parallel_cores.R is clean — no dead code, generic message ✓
  • skip_on_os("mac") removed from test-sim_pop_data.R; expect_snapshot_data() used ✓
  • withr::local_seed() with explicit Mersenne-Twister / Inversion / Rejection RNG kind ✓
  • num_cores default changed to 2L — CRAN-safe ✓
  • _R_CHECK_LIMIT_CORES_ handling covers TRUE/T/YES/Y, FALSE/F/NO/N, numeric strings, and unrecognised values ✓
  • sapplyvapply(FUN.VALUE = integer(1))
  • message()cli::cli_inform() for verbose output ✓
  • @param ... / @inheritDotParams duplicate tag removed from sim_pop_data_multi.R
  • cran-comments.md note count matches the actual two notes ✓
  • Double assignment n_cores <- n_cores <- ... fixed in vignette ✓
  • @inheritDotParams error in plot_curve_params_one_ab.R fixed; generated .Rd clean ✓
  • n_coresnum_cores applied consistently across examples, vignettes, fixtures ✓
  • man/sim_pop_data_multi.Rd regenerated correctly — ... documents the sim_pop_data args, no reference to sim.cs()

@claude

claude Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Claude finished @kristinawlai's task in 5m 21s —— View job


Code Review: CRAN release/v1.4.1

  • Gather context from PR history
  • Read current state of key changed files
  • Review check_parallel_cores.R and sim_pop_data_multi.R
  • Review test coverage and reproducibility
  • Review NEWS.md / changelog hygiene
  • Review CRAN submission materials
  • Post final review summary

Summary

Commit 021d871 ("fix minor issues") resolves most of the remaining items flagged in prior reviews. The structural refactor from d-morrison's CHANGES_REQUESTED is now done: check_parallel_cores() correctly receives chk as a parameter and applies the env-var cap. Two new issues were introduced in this round.


What 021d871 / aa66b25 fixed ✅

Item Fixed
check_parallel_cores.R — dead code after return() removed
check_parallel_cores.Rchk and verbose now proper parameters
sim_pop_data_multi.R — reads chk and passes it to check_parallel_cores()
DESCRIPTION version 1.4.1.9000, snapr in Suggests, no Remotes:
skip_on_os("mac") removed from test-sim_pop_data.R
withr::local_seed() with explicit RNG kind/normal/sample args
cran-comments.md note count corrected to 2 notes
vignettes/…/simulate_xsectionalData.qmd:296 double assignment fixed
NEWS.md:1 single space after #
Stale @param ... [sim.cs()] tag removed from sim_pop_data_multi.R
Generic message in check_parallel_cores.R (no est_seroincidence_by() reference)

D-Morrison's CHANGES_REQUESTED — current status

# Item Status
1 DESCRIPTION: bump to 1.4.1.9000 ✅ done
2 DESCRIPTION: add snapr back (CRAN version) ✅ done
3 DESCRIPTION: remove Remotes: ✅ done
4 NEWS.md: dev-version placeholder heading ✅ done
5 test-sim_pop_data.R: remove skip_on_os("mac"), use snapr ✅ done
6 Move _R_CHECK_LIMIT_CORES_ block into check_parallel_cores() ✅ done (via chk parameter)
7 Move check_parallel_cores() call inside the env-var block ✅ done (unconditionally called when num_cores > 1L)

Must-fix (new issues in this round)

1. R/check_parallel_cores.R:51–58 — duplicate verbose messages

The verbose block now emits two nearly identical messages:

if (verbose) {
    cli::cli_inform(
      "Setting up parallel processing with `num_cores` = {num_cores}."
    )
    cli::cli_inform(
      "Set up parallel processing with `num_cores`={num_cores}"   # ← duplicate
    )
}

The second message ("Set up parallel processing...") was moved from sim_pop_data_multi.R, but the first was already present in check_parallel_cores.R. Remove one. The first is more consistently formatted (spaces around =, trailing period, backtick-quoted arg name). Fix this →

2. tests/testthat/test-sim_pop_data_multi.R:80 — mock function signature mismatch

The check_parallel_cores mock is function(x), but the production call in sim_pop_data_multi() now uses three named arguments:

# production code (sim_pop_data_multi.R:30):
num_cores <- check_parallel_cores(num_cores = num_cores, chk = chk, verbose = verbose)

# mock (test-sim_pop_data_multi.R:80):
check_parallel_cores = function(x) {
    calls <<- c(calls, list(x))
    x
}

In R, a named actual argument (num_cores = 2L) cannot be matched to an unrelated formal (x) — R would raise an "unused argument" error at call time. The mock needs to accept the same named parameters:

check_parallel_cores = function(num_cores, chk, verbose) {
    calls <<- c(calls, list(num_cores))
    num_cores
}

Additionally, the expected_calls$numeric_cap = min(num_cores, 1L) = 1L is wrong: with the mock bypassing check_parallel_cores, the env-var cap ("1" → cap at 1) is never applied, so calls[[3]] would be 2L (the original num_cores), not 1L. The expected values for the calls list should be 2L across all scenarios. The register_calls assertions (lines 128–131) test the value passed to registerDoParallel, which would also be 2L since the mock returns num_cores unchanged. If the intent is to verify that the env-var cap is applied, the mock on check_parallel_cores should be removed and parallel::detectCores should be mocked instead to avoid the hardware-limit path. Fix this →


Remaining from prior reviews

3. tests/testthat/test-sim_pop_data_multi.R:3skip_on_os("linux") skips snapshot on CI

This skip is still present in the sim_pop_data_multi() consistency test. ubuntu-latest (Linux) is the primary CI platform — the snapshot is never validated there. If the explicit set.seed(54321) seeding is enough for cross-platform determinism, remove the skip. If Linux still produces different output, a comment explaining why is warranted. Fix this →

4. R/check_parallel_cores.R:50 — misleading # (Unchanged) comment

# 3. Report setup if verbose (Unchanged)

This block was moved from sim_pop_data_multi.R, so it's not "unchanged". Remove the parenthetical. Fix this →


What looks good

  • DESCRIPTION version 1.4.1.9000, snapr in Suggests, no Remotes:
  • check_parallel_cores() signature now takes num_cores, chk = "", verbose = FALSE — clean and testable ✓
  • _R_CHECK_LIMIT_CORES_ block is before return() — no dead code ✓
  • Env-var cap covers TRUE/T/YES/Y, FALSE/F/NO/N, numeric strings, and unrecognized values ✓
  • sim_pop_data_multi() reads chk from env and passes it explicitly — correct and mockable design ✓
  • num_cores default is 2L — CRAN-safe ✓
  • skip_on_os("mac") removed from test-sim_pop_data.R
  • withr::local_seed() with explicit Mersenne-Twister / Inversion / Rejection RNG kind ✓
  • csdata |> expect_snapshot_data(name = "sim_pop_data") — snapr API correct ✓
  • sapplyvapply(FUN.VALUE = integer(1))
  • message()cli::cli_inform() for verbose output ✓
  • cran-comments.md note count matches (2 notes) ✓
  • Double assignment fixed in vignette ✓
  • NEWS.md dev-version header correct ✓
  • @inheritDotParams error in plot_curve_params_one_ab.R fixed ✓
  • n_coresnum_cores consistent across examples, vignettes, fixtures ✓

Merge branch 'CRANrelease/v1.4.1' of https://github.com/UCD-SERG/serocalculator into CRANrelease/v1.4.1

# Conflicts:
#	R/check_parallel_cores.R
github-actions Bot added a commit that referenced this pull request Jun 13, 2026
@claude

claude Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Code Review: CRAN release/v1.4.1

  • Gather context and PR history
  • Read current state of key changed files
  • Review CI failures (docs check + lint)
  • Fix lint errors in sim_pop_data_multi.R (lines 28, 30 exceed 80 chars)
  • Fix test mock signature in test-sim_pop_data_multi.R
  • Fix duplicate verbose messages in check_parallel_cores.R
  • Regenerate man/check_parallel_cores.Rd
  • Post final review summary

Working...

View job run

- Fix line length lint errors in R/sim_pop_data_multi.R (lines 28, 30
  exceeded 80 chars; wrap check_parallel_cores() call across lines)
- Fix check_parallel_cores mock signature in test-sim_pop_data_multi.R:
  mock was function(x) but production code calls with named args
  (num_cores, chk, verbose); rewrite test to mock detectCores instead
  so the full cap path (including env-var cap inside check_parallel_cores)
  is exercised end-to-end via register_calls
- Remove duplicate cli::cli_inform in check_parallel_cores() verbose block
- Remove misleading '(Unchanged)' annotation from comment
- Update man/check_parallel_cores.Rd: \verb{} -> \code{} for
  _R_CHECK_LIMIT_CORES_ (roxygen2 8.0.0 uses \code{} for strings
  without Rd markup characters)

Co-authored-by: Kristina W. Lai <undefined@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📖 https://UCD-SERG.github.io/serocalculator/preview/pr510/
Preview documentation for this PR (at commit 45a60cf)

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.

4 participants