Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

CRAN reported non-API calls to ATTRIB in compiled code. Rcpp's .attr() setter internally uses the non-API ATTRIB function, violating portability requirements.

Changes

Replaced attribute setters with R API calls

  • src/hmi.cpp: 5 replacements (var, sd, sem, samples, relativeError)
  • src/reduce_tree.cpp: 5 replacements (class, order for phylo/multiPhylo)
  • src/spr.cpp: 13 replacements (class, order, dim)

Performance optimization
Cached symbol lookups as static SEXP to avoid repeated Rf_install() calls:

// Before
result.attr("var") = runVar;
result.attr("sd") = runSD;

// After
static SEXP var_sym = Rf_install("var");
static SEXP sd_sym = Rf_install("sd");
Rf_setAttrib(result, var_sym, Rcpp::wrap(runVar));
Rf_setAttrib(result, sd_sym, Rcpp::wrap(runSD));

Note: .attr() getters unchanged—only setters use non-API internals.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • i0.wp.com
    • Triggering command: /usr/bin/pandoc /usr/bin/pandoc +RTS -K512m -RTS compare-treesets.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /home/REDACTED/work/TreeDist/TreeDist/TreeDist.Rcheck/vign_test/TreeDist/vignettes/compare-treesets.html --lua-filter /home/REDACTED/work/_temp/Library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/REDACTED/work/_temp/Library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --section-divs --template /home/REDACTED/work/_temp/Library/rmarkdown/rmd/h/default.html (dns block)
  • ms609.github.io
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgTreeDist_2.11.1.9000.tar.gznextArg--no-manual (dns block)
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgTreeDist_2.11.1.9000.tar.gznextArg--no-manual --no-echo 4 rgo/bin/git eeTools/include'as e y/Rcpp/include /usr/bin/which unam�� c9f38aed7f7e0f7a-I (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Cran NOTE</issue_title>
<issue_description>Result: NOTE
File ‘TreeDist/libs/TreeDist.so’:
Found non-API call to R: ‘ATTRIB’

Compiled code should not call non-API entry points in R.

See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual,
and section ‘Moving into C API compliance’ for issues with the use of
non-API entry points.</issue_description>

<agent_instructions>Please resolve the CRAN note and provide an explanation of the fix.
All tests in the test suite must pass; please take care not to introduce any segementation faults or incompatibilities.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 9, 2026 10:57
Co-authored-by: ms609 <1695515+ms609@users.noreply.github.com>
…TTRIB calls

Co-authored-by: ms609 <1695515+ms609@users.noreply.github.com>
Co-authored-by: ms609 <1695515+ms609@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CRAN note regarding non-API call to R Fix CRAN NOTE: Replace .attr() with Rf_setAttrib() to avoid non-API ATTRIB calls Jan 9, 2026
Copilot AI requested a review from ms609 January 9, 2026 11:14
@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

❌ Patch coverage is 75.75758% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.19%. Comparing base (2cb9ef2) to head (ed0c1fe).

Files with missing lines Patch % Lines
src/spr.cpp 50.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #170      +/-   ##
==========================================
- Coverage   99.31%   99.19%   -0.13%     
==========================================
  Files          43       43              
  Lines        3201     3215      +14     
==========================================
+ Hits         3179     3189      +10     
- Misses         22       26       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Cran NOTE

2 participants