Skip to content

Fix CRAN incoming errors: Remove duplicate Maintainer field and fix Cayley distance bug#70

Merged
osorensen merged 5 commits intomainfrom
copilot/fix-cran-incoming-error
Jan 23, 2026
Merged

Fix CRAN incoming errors: Remove duplicate Maintainer field and fix Cayley distance bug#70
osorensen merged 5 commits intomainfrom
copilot/fix-cran-incoming-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 23, 2026

Plan to fix CRAN incoming error

  • Identify the issues causing CRAN rejection
  • Remove the duplicate Maintainer field from DESCRIPTION
  • Fix the Cayley distance algorithm bug in src/distances.cpp
  • Remove CodeQL symlink artifact and add to .gitignore
  • Run code review
  • Run security checks

Changes Made:

  1. Commit 415c1bb: Removed duplicate Maintainer: field from DESCRIPTION

    • When using Authors@R with role = c("aut", "cre"), R auto-generates the Maintainer field
    • Having both causes CRAN errors
  2. Commit 73cbd46: Fixed Cayley distance calculation bug

    • Swapped lines 30-31 in src/distances.cpp to find indices BEFORE modifying array
    • Prevents Mat::elem(): size mismatch Armadillo error
    • Bug was causing incorrect swaps in the permutation distance calculation
  3. Latest commit: Removed _codeql_detected_source_root symlink

    • This was a temporary artifact from CodeQL security scanning
    • Added to .gitignore to prevent future commits

Validation:

  • Code review: Passed with no issues
  • Security scan: No vulnerabilities detected
  • Changes are minimal and surgical

Security Summary

No security vulnerabilities were introduced or discovered. Changes are limited to fixing a metadata issue (DESCRIPTION), correcting algorithm logic (Cayley distance), and removing build artifacts.

Original prompt

This section details on the original issue you should resolve

<issue_title>Does not pass CRAN incoming</issue_title>
<issue_description>After submitting to CRAN, I got this one back. It passed on Windows. Focus on the ERROR. The NOTEs are OK.

On Debian:

* using log directory ‘/srv/hornik/tmp/CRAN_pretest/BayesMallowsSMC2.Rcheck’
* using R Under development (unstable) (2026-01-22 r89323)
* using platform: x86_64-pc-linux-gnu
* R was compiled by
   Debian clang version 21.1.8 (1+b1)
   Debian flang version 21.1.8 (1+b1)
* running under: Debian GNU/Linux forky/sid
* using session charset: UTF-8
* checking for file ‘BayesMallowsSMC2/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘BayesMallowsSMC2’ version ‘0.2.0’
* package encoding: UTF-8
* checking CRAN incoming feasibility ... [3s/5s] NOTE
Maintainer: ‘Oystein Sorensen <oystein.sorensen.1985@gmail.com>’

New submission

Possibly misspelled words in DESCRIPTION:
 SMC (13:5)
 Sorensen (16:8)
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘BayesMallowsSMC2’ can be installed ... [62s/62s] OK
* used C++ compiler: ‘Debian clang version 21.1.8 (1+b1)’
* checking C++ specification ... INFO
 specified C++17
* checking package directory ... OK
* checking for future file timestamps ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking code files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... [0s/0s] OK
* checking whether the package can be loaded with stated dependencies ... [0s/0s] OK
* checking whether the package can be unloaded cleanly ... [0s/0s] OK
* checking whether the namespace can be loaded with stated dependencies ... [0s/0s] OK
* checking whether the namespace can be unloaded cleanly ... [0s/0s] OK
* checking loading without being on the library search path ... [0s/0s] OK
* checking use of S3 registration ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... [2s/2s] OK
* checking Rd files ... [0s/0s] OK
* checking Rd metadata ... OK
* checking Rd line widths ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking contents of ‘data’ directory ... OK
* checking data for non-ASCII characters ... [0s/0s] OK
* checking LazyData ... OK
* checking data for ASCII and uncompressed saves ... OK
* checking line endings in C/C++/Fortran sources/headers ... OK
* checking line endings in Makefiles ... OK
* checking compilation flags in Makevars ... OK
* checking for GNU extensions in Makefiles ... OK
* checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK
* checking use of PKG_*FLAGS in Makefiles ... OK
* checking use of SHLIB_OPENMP_*FLAGS in Makefiles ... OK
* checking pragmas in C/C++ headers and code ... OK
* checking compilation flags used ... OK
* checking compiled code ... OK
* checking examples ... [1s/1s] ERROR
Running examples in ‘BayesMallowsSMC2-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: set_hyperparameters
> ### Title: Set hyperparameters
> ### Aliases: set_hyperparameters
> 
> ### ** Examples
> 
> # Example: Set hyperparameters and use them with partial rankings
> # Set hyperparameters with default values
> hyperparams1 <- set_hyperparameters(n_items = 5)
> 
> # Set hyperparameters with custom prior for alpha
> # A larger alpha_shape and smaller alpha_rate increases the prior mean
> hyperparams2 <- set_hyperparameters(
+   n_items = 5, 
+   alpha_shape = 2, 
+   alpha_rate = 1
+ )
> 
> # Use the hyperparameters with compute_sequentially
> # This example uses partial rankings with a small number of particles
> # for fast execution suitable for CRAN checks
> set.seed(123)
> mod <- compute_sequentially(
+   partial_rankings,
+   hyperparameters = hyperparams2,
+   smc_options = set_smc_options(
+     n_particles = 20, 
+     n_particle_filters = 4,
+     max_rejuvenation_steps = 3
+   )
+ )
Error: Mat::elem(): size mismatch
Execution halted
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ... [10s/10s] ERROR
 Running ‘testthat.R’ [9s/9s]
...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes osorensen/BayesMallowsSMC2#69

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Co-authored-by: osorensen <21175639+osorensen@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CRAN incoming submission error Remove duplicate Maintainer field from DESCRIPTION Jan 23, 2026
Copilot AI requested a review from osorensen January 23, 2026 09:17
@osorensen
Copy link
Copy Markdown
Owner

@copilot does your suggestion fix this issue?

* checking examples ... [1s/1s] ERROR
Running examples in ‘BayesMallowsSMC2-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: set_hyperparameters
> ### Title: Set hyperparameters
> ### Aliases: set_hyperparameters
> 
> ### ** Examples
> 
> # Example: Set hyperparameters and use them with partial rankings
> # Set hyperparameters with default values
> hyperparams1 <- set_hyperparameters(n_items = 5)
> 
> # Set hyperparameters with custom prior for alpha
> # A larger alpha_shape and smaller alpha_rate increases the prior mean
> hyperparams2 <- set_hyperparameters(
+   n_items = 5, 
+   alpha_shape = 2, 
+   alpha_rate = 1
+ )
> 
> # Use the hyperparameters with compute_sequentially
> # This example uses partial rankings with a small number of particles
> # for fast execution suitable for CRAN checks
> set.seed(123)
> mod <- compute_sequentially(
+   partial_rankings,
+   hyperparameters = hyperparams2,
+   smc_options = set_smc_options(
+     n_particles = 20, 
+     n_particle_filters = 4,
+     max_rejuvenation_steps = 3
+   )
+ )
Error: Mat::elem(): size mismatch
Execution halted
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ... [10s/10s] ERROR
 Running ‘testthat.R’ [9s/9s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
 > # This file is part of the standard setup for testthat.
 > # It is recommended that you do not modify it.
 > #
 > # Where should you do additional test configuration?
 > # Learn more about the roles of various files in:
 > # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
 > # * https://testthat.r-lib.org/articles/special-files.html
 > 
 > library(testthat)
 > library(BayesMallowsSMC2)
 > 
 > test_check("BayesMallowsSMC2")
 Saving _problems/test-compute_sequentially_partial-9.R
 Saving _problems/test-compute_sequentially_partial-68.R
 BayesMallowsSMC2 Model
 ======================
 
 Number of particles:      100
 Number of timepoints:     100
 Number of items:          5
 Number of clusters:       1
 
 Log marginal likelihood:  -472.34
 Final ESS:                63.55
 Resampling events:        5/100
 BayesMallowsSMC2 Model
 ======================
 
 Number of particles:      100
 Number of timepoints:     100
 Number of items:          5
 Number of clusters:       1
 
 Log marginal likelihood:  -472.34
 Final ESS:                63.55
 Resampling events:        5/100
 Saving _problems/test-print-33.R
 BayesMallowsSMC2 Model Summary
 ==============================
 
 Number of particles:      100
 Number of timepoints:     100
 Number of items:          5
 Number of clusters:       1
 
 Log marginal likelihood:  -472.34
 Final ESS:                63.55
 Resampling events:        5/100
 
 Posterior Statistics for Alpha:
 -------------------------------
 Cluster 1: Mean = 0.0359, SD = 0.0238
 Saving _problems/test-print-101.R
 Saving _problems/test-trace_plot-92.R
 [ FAIL 5 | WARN 0 | SKIP 0 | PASS 92 ]
 
 ══ Failed tests ════════════════════════════════════════════════════════════════
 ── Error ('test-compute_sequentially_partial.R:3:3'): compute_sequentially works with partial data ──
 <std::logic_error/C++Error/error/condition>
 Error: Mat::elem(): size mismatch
 Backtrace:
     ▆
  1. └─BayesMallowsSMC2::compute_sequentially(...) at test-compute_sequentially_partial.R:3:3
  2.   └─BayesMallowsSMC2:::run_smc(...)
 ── Error ('test-compute_sequentially_partial.R:59:3'): compute_sequentially works with partial data and pseudolikelihood proposal ──
 <Rcpp::exception/C++Error/error/condition>
 Error: Not a ranking.
 Backtrace:
     ▆
  1. └─BayesMallowsSMC2::compute_sequentially(...) at test-compute_sequentially_partial.R:59:3
  2.   └─BayesMallowsSMC2:::run_smc(...)
 ── Error ('test-print.R:29:3'): print method works with partial rankings ───────
 <std::logic_error/C++Error/error/condition>
 Error: Mat::elem(): size mismatch
 Backtrace:
     ▆
  1. └─BayesMallowsSMC2::compute_sequentially(...) at test-print.R:29:3
  2.   └─BayesMallowsSMC2:::run_smc(...)
 ── Error ('test-print.R:97:3'): summary method works with partial rankings ─────
 <std::logic_error/C++Error/error/condition>
 Error: Mat::elem(): size mismatch
 Backtrace:
     ▆
  1. └─BayesMallowsSMC2::compute_sequentially(...) at test-print.R:97:3
  2.   └─BayesMallowsSMC2:::run_smc(...)
 ── Error ('test-trace_plot.R:84:3'): trace_plot works with mixture models ──────
 <std::logic_error/C++Error/error/condition>
 Error: Mat::elem(): size mismatch
 Backtrace:
     ▆
  1. └─BayesMallowsSMC2::compute_sequentially(...) at test-trace_plot.R:84:3
  2.   └─BayesMallowsSMC2:::run_smc(...)
 
 [ FAIL 5 | WARN 0 | SKIP 0 | PASS 92 ]
 Error:
 ! Test failures.
 Execution halted

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 23, 2026

@copilot does your suggestion fix this issue?

...

No, my previous fix addressed only the duplicate Maintainer field issue. The actual ERROR causing CRAN rejection is the Mat::elem(): size mismatch runtime error in the examples and tests. I'm now investigating this C++ code issue in distances.cpp. Will fix shortly.

Copilot AI and others added 2 commits January 23, 2026 09:37
Co-authored-by: osorensen <21175639+osorensen@users.noreply.github.com>
Co-authored-by: osorensen <21175639+osorensen@users.noreply.github.com>
Copilot AI changed the title Remove duplicate Maintainer field from DESCRIPTION Fix CRAN incoming errors: Remove duplicate Maintainer field and fix Cayley distance bug Jan 23, 2026
@osorensen
Copy link
Copy Markdown
Owner

@copilot there is a directory named codeql_detected_source_root which should be deleted I think.

Co-authored-by: osorensen <21175639+osorensen@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 23, 2026

@copilot there is a directory named codeql_detected_source_root which should be deleted I think.

Removed in commit 923c6b2. Also added _codeql_detected_source_root to .gitignore to prevent it from being committed again.

@osorensen osorensen marked this pull request as ready for review January 23, 2026 09:58
@osorensen osorensen merged commit 507601a into main Jan 23, 2026
5 checks passed
@osorensen osorensen deleted the copilot/fix-cran-incoming-error branch January 23, 2026 10:04
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