Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
2d49997
feat!: establish phase 1-2 fit API migration foundation (#33)
psychelzh Mar 13, 2026
e1cb3c9
refactor: complete phase-3 polish for cpm_spec + fit API (#35)
psychelzh Mar 13, 2026
5667f48
feat: roll out native-first fit API and result objects (#49)
psychelzh Mar 16, 2026
a80c8f2
docs: restore pkgdown news navigation
psychelzh Mar 16, 2026
d1b32fe
refactor: align utility file names
psychelzh Mar 16, 2026
767632d
refactor: group source files by responsibility
psychelzh Mar 16, 2026
dbf9224
Update documentation
psychelzh Mar 16, 2026
475e01f
refactor: lead files with primary entry points
psychelzh Mar 16, 2026
e004041
refactor: colocate native fit helpers with cpm_spec
psychelzh Mar 16, 2026
ae59b92
refactor: extract shared prediction and resample helpers
psychelzh Mar 16, 2026
58b3282
refactor: drop direct native fit wrappers
psychelzh Mar 16, 2026
7f3454d
refactor: unify resample helper utilities
psychelzh Mar 16, 2026
b007369
docs: refresh vignette workflow guidance
psychelzh Mar 16, 2026
c310f71
feat: redesign resample summary metrics
psychelzh Mar 16, 2026
20c4777
docs: refresh resample summary guidance
psychelzh Mar 16, 2026
5e08bb4
fix: refine resample summary printing
psychelzh Mar 16, 2026
891976f
feat: add resample_metrics helper
psychelzh Mar 16, 2026
3cbf975
docs: document resample_metrics access
psychelzh Mar 16, 2026
53b49a5
refactor: clarify resample correlation parameter
psychelzh Mar 16, 2026
393a214
refactor: scope correlation method handling
psychelzh Mar 16, 2026
15e71db
docs: refine summary and workflow wording
psychelzh Mar 17, 2026
0efbb33
style: align user-facing messages
psychelzh Mar 17, 2026
0da80a2
docs: improve help text and examples
psychelzh Mar 17, 2026
928b2cb
test: restore fit-model coverage
psychelzh Mar 17, 2026
f50d0c6
test: reduce repeated resample fixtures
psychelzh Mar 17, 2026
673b212
style: refine printed model output
psychelzh Mar 17, 2026
fcb8eb7
refactor: unify summary metric tables
psychelzh Mar 17, 2026
64f9b9d
docs: clarify summary metric access in vignettes
psychelzh Mar 17, 2026
a0b6dd1
Merge pull request #53 from psychelzh/codex/issue-16-metric-policy
psychelzh Mar 17, 2026
7fff8ba
Add touchstone benchmark CI
psychelzh Mar 21, 2026
74f257d
Warm fit benchmark before timing
psychelzh Mar 22, 2026
61d9803
Add edge standardization benchmark
psychelzh Mar 22, 2026
5bf2afe
Add standardized resample benchmark
psychelzh Mar 22, 2026
afc04e2
Increase touchstone benchmark iterations
psychelzh Mar 22, 2026
4c1e0b3
Order touchstone benchmarks more clearly
psychelzh Mar 22, 2026
1923df0
Add weighted CPM network summaries
psychelzh Mar 17, 2026
9de9fbc
Simplify cpm_spec helper API
psychelzh Mar 17, 2026
f6e88be
Tighten validation and coverage for spec helpers
psychelzh Mar 17, 2026
2f37554
Apply air formatting across R and tests
psychelzh Mar 17, 2026
caead3e
Improve vignette readability
psychelzh Mar 17, 2026
55b08c3
Prototype model helper stage in cpm_spec
psychelzh Mar 17, 2026
50c1bed
Clarify CPM feature-space naming
psychelzh Mar 17, 2026
89e0ea7
Clarify prediction stream semantics
psychelzh Mar 17, 2026
2da2114
Fix aliased joint stream regression
psychelzh Mar 18, 2026
546722b
Clarify CPM feature-space terminology
psychelzh Mar 18, 2026
82b185f
Polish network strength wording
psychelzh Mar 18, 2026
071c7ad
Fix per-sign sparsity thresholding
psychelzh Mar 19, 2026
d68dc87
Clarify bias_correct documentation
psychelzh Mar 19, 2026
37e585d
Rename bias_correct to standardize_edges
psychelzh Mar 19, 2026
bc73d7b
Default to classic CPM edge handling
psychelzh Mar 19, 2026
b30168e
Summarize CPM API refresh in NEWS
psychelzh Mar 19, 2026
c2ba525
Refine cpm_screen rule and control API
psychelzh Mar 19, 2026
e1e4bca
Refactor cpm_spec into staged helper API
psychelzh Mar 20, 2026
fb6c0f8
Refresh docs for staged CPM helpers
psychelzh Mar 20, 2026
3658336
Tidy internal selection and stream helpers
psychelzh Mar 20, 2026
2b603e0
Separate staged selection and construction internals
psychelzh Mar 20, 2026
61b458e
Refine staged CPM helper API
psychelzh Mar 21, 2026
37c6c2a
Polish prediction naming and stream docs
psychelzh Mar 21, 2026
bab26e3
Drop helper-specific print methods
psychelzh Mar 21, 2026
4dc690c
Tighten staged spec validation and reporting
psychelzh Mar 21, 2026
f01179c
Simplify fit_resamples resampling API
psychelzh Mar 21, 2026
8e6855a
Tighten staged CPM internals
psychelzh Mar 22, 2026
b1dba0f
Refine CPM tidy and construction internals
psychelzh Mar 22, 2026
5ff11c1
Clarify summary construction dispatch
psychelzh Mar 22, 2026
7336850
Split fit internals by stage
psychelzh Mar 22, 2026
b866705
Improve fit module organization
psychelzh Mar 22, 2026
4ae2f35
Clarify construction dispatch boundaries
psychelzh Mar 22, 2026
8f1e3bf
Extract shared split fit pipeline
psychelzh Mar 22, 2026
573e9aa
Remove fit module header comments
psychelzh Mar 22, 2026
0a8df87
Simplify fit runner setup and split results
psychelzh Mar 22, 2026
fa66a66
Simplify resample runner setup
psychelzh Mar 22, 2026
bc8ef16
Clarify shared fit state helper
psychelzh Mar 22, 2026
b2989da
Simplify fit runner state setup
psychelzh Mar 22, 2026
20be120
Reduce runner state reassignment
psychelzh Mar 22, 2026
989c9ac
Shorten runner context naming
psychelzh Mar 22, 2026
b3d7072
Separate data context from runner rules
psychelzh Mar 22, 2026
d9ca735
Flatten cpm_spec stage storage
psychelzh Mar 22, 2026
df01c90
Trim redundant field rebinding
psychelzh Mar 22, 2026
a203015
Separate fitted spec from runtime settings
psychelzh Mar 22, 2026
dda124d
Simplify summary construction internals
psychelzh Mar 22, 2026
66f2c5d
Hoist construction prediction streams into spec
psychelzh Mar 22, 2026
dfecc3a
Store stream identity on fitted models
psychelzh Mar 22, 2026
c66bd2d
Refactor fit pipeline for readability
psychelzh Mar 22, 2026
6a8f6d4
Update documentation
psychelzh Mar 22, 2026
e701d52
Reorganize fit internals into fewer files
psychelzh Mar 22, 2026
182a966
Avoid repeated summary recomputation
psychelzh Mar 22, 2026
4267790
Rename construction model state
psychelzh Mar 22, 2026
961fa67
Speed up binary summary features
psychelzh Mar 22, 2026
c848222
Reduce split validation overhead
psychelzh Mar 22, 2026
863c8b5
Split spec assertions from normalization
psychelzh Mar 22, 2026
c875d1b
Rename spec helper module
psychelzh Mar 22, 2026
0d78d02
Update documentation
psychelzh Mar 22, 2026
d7dd97f
Refresh print and summary output
psychelzh Mar 22, 2026
c591a89
Simplify summary construction flow
psychelzh Mar 23, 2026
4e60224
Simplify split fit preprocessing and construction
psychelzh Mar 23, 2026
69f2023
Collapse edge selection helper layers
psychelzh Mar 23, 2026
d5252c6
Add repo-managed cpmr development skill
psychelzh Mar 23, 2026
6d0f32c
Simplify split prediction feature reuse
psychelzh Mar 23, 2026
08d660a
Tighten cpmr development skill quality gates
psychelzh Mar 24, 2026
260fd68
Simplify staged spec validation boundaries
psychelzh Mar 24, 2026
5c6404c
Inline single-use CPM object constructors
psychelzh Mar 24, 2026
c1dfea4
Refine cpmr skill file-order guidance
psychelzh Mar 24, 2026
30b1513
Clarify internal pipeline and utility names
psychelzh Mar 25, 2026
97592e3
Add tidyverse-inspired R API design skill
psychelzh Mar 25, 2026
8871079
Simplify fit input prep and resample fold handling
psychelzh Mar 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
^CODE_OF_CONDUCT\.md$
^[.]?air[.]toml$
^\.vscode$
^\.agents($|/)
^doc$
^Meta$
^touchstone$
99 changes: 99 additions & 0 deletions .agents/skills/cpmr-r-development/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
name: cpmr-r-development
description: Work on the cpmr R package in this repository. Use when editing package code, tests, documentation, or repo-managed package workflow guidance, especially for the staged selection/construction/model architecture, AIR formatting, devtools::document()/devtools::test(), restoring package coverage to 100%, and finishing with devtools::check().
---

# CPMR R Development

Use this skill for changes inside the `cpmr` package repo.
Read the package surface before editing: start with `README.Rmd`, then open the
relevant files in `R/` and matching tests in `tests/testthat/`.

## Project Workflow

1. Understand the affected stage before changing code.
In this repo, keep the public CPM stages visible as `selection`,
`construction`, and `model`.
2. Preserve the staged API.
`cpm_spec()` should stay readable at the top level, while stage-specific
helpers carry their own arguments.
3. Keep runtime paths straight.
Avoid helper layers that only forward arguments, avoid repeated
validation/normalization in internal spec-based paths, and prefer computing a
value once over recomputing it through wrappers.
4. Keep the `model` layer extensible.
Even if `lm` is the only current model, preserve a clear model boundary so
future model types have an obvious integration point.
5. Match tests to the layer you changed.
Update the closest `testthat` file first, then run broader tests when the
change crosses multiple stages.

## Repo-Specific Guidance

- `R/cpm-spec*.R`: public staged spec helpers and validation
- `R/fit-selection.R`: edge-selection runtime
- `R/fit-construction.R`: feature construction and cached summaries
- `R/fit-pipeline.R`: train/test flow, construction, model fit, prediction
- `R/fit-runner.R`: top-level fit orchestration
- `tests/testthat/`: stage-aligned tests

When simplifying code in this repo:

- Prefer one real runtime function over `foo()` plus `foo_impl()` when there is
only one meaningful path.
- Put validation and normalization at public constructors or convenience
wrappers, not deep in internal runtime helpers that already receive parsed
specs.
- When a private helper is still worth keeping, place it after the main
function(s) it supports so the file reads top-down from public flow to
implementation detail.
- Preserve training-time caches when prediction reuses training data.
- Keep names literal and stage-based instead of introducing abstract temporary
state.

## Quality Checks

Use AIR for formatting.
This repo already points VS Code at `Posit.air-vscode` and CI uses
`posit-dev/setup-air`.

```bash
air format .
air format R/file.R
```

After R code changes, run:

```r
devtools::document()
devtools::test()
cov <- covr::package_coverage()
print(cov)
if (covr::percent_coverage(cov) < 100) {
stop(
sprintf(
"Coverage must remain at 100%% (current: %.3f%%).",
covr::percent_coverage(cov)
)
)
}
devtools::check()
```

Do not stop at green tests alone. This repo expects package coverage to remain
at `100%`; if coverage drops below `100%`, add or adjust tests before
finishing, or report the blocker explicitly. Once coverage is back to `100%`,
run `devtools::check()` as the final package gate, because it catches build,
install, documentation, and example issues that unit tests alone can miss.
When coverage is below `100%`, inspect `covr::zero_coverage(cov)` to locate the
uncovered lines before adding tests.

For narrower iteration loops, use:

```r
devtools::test(filter = "fit-model")
testthat::test_file("tests/testthat/test-fit-model.R")
```

If roxygen examples, README examples, or pkgdown-facing docs changed, update the
generated outputs that belong with those sources before finishing.
4 changes: 4 additions & 0 deletions .agents/skills/cpmr-r-development/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface:
display_name: "CPMR Package Development"
short_description: "cpmr workflow with staged specs and quality gates"
default_prompt: "Use $cpmr-r-development to work on the cpmr package with staged CPM specs, AIR formatting, 100% coverage, and a final devtools::check()."
103 changes: 103 additions & 0 deletions .agents/skills/r-api-design/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
name: r-api-design
description: Design or refactor R function APIs with tidyverse-inspired principles. Use when choosing function names, argument order, defaults, enums vs booleans, options/helper objects, output contracts, side effects, or error structure in R packages.
---

# R API Design

Use this skill when shaping an R API, not just when polishing style.
Optimize for humans reading code, consistency across related functions, and
small composable pieces.

Before editing, read the public function signature, its closest tests, and the
callers directly above and below it in the stack.

## Design Priorities

1. Keep layers distinct.
Do not force one naming pattern across different abstraction levels. Public
entry points, orchestration helpers, and low-level transforms can use
different name families if the boundary becomes clearer.
2. Prefer interfaces that are obvious at a glance.
The function signature should reveal what is required, what is optional, and
which arguments matter most.
3. Optimize for consistency and composition.
Reuse the same API pattern across related functions, and make outputs easy to
feed into the next step.
4. Prefer explicit behavior.
Avoid hidden dependence on options, locale, or internal state when it affects
computation.

## Naming

- Use `snake_case`.
- Prefer verbs for actions and nouns for object builders.
- Err toward names that are a bit long but obvious.
- Reserve very short names for very frequent calls.
- Use prefixes for families and suffixes for variations.
- Keep related names parallel within a layer, but do not flatten different
layers into one naming scheme just for symmetry.

## Function Signatures

- Put the most important arguments first.
- Give defaults only to optional arguments.
- Put `...` after required arguments.
- Keep defaults short and simple.
If the real default is non-trivial, prefer `NULL` plus in-body resolution, or
a documented helper object.
- Make inputs explicit.
If an option, locale, or external setting changes results, surface it as an
argument.
- Keep argument meanings independent whenever possible.
Avoid signatures where one argument silently changes the meaning of another.

## Options And Strategies

- Use small string enums for a finite set of choices.
Prefer `c("a", "b")` with `rlang::arg_match()` or `match.arg()` over ad hoc
checking.
- Prefer enums over booleans when `TRUE`/`FALSE` would be ambiguous, or when
the choice may grow beyond two strategies.
- If different strategies need different arguments, extract them into helper
objects instead of piling mutually dependent arguments into one function.
- If low-importance tuning arguments clutter a signature, group them in an
options object created by a helper.

## Helpers

- Delete helpers that only forward arguments or rename values without adding a
clear boundary.
- Keep a private helper when it collapses truly identical repetition or enforces
one stable invariant.
- Extract an error helper only after the same error pattern appears in three or
more places.
- Place private helpers after the main function(s) they support so the file
reads top-down from public flow to implementation detail.

## Outputs, Side Effects, And Errors

- Keep outputs type-stable whenever possible.
- If a function returns multiple values, give them stable names and a stable
container shape.
- Partition side effects away from computation where possible.
- If a function exists mainly for side effects, return invisibly.
- Suppress noisy raw calls in user-facing errors with `call. = FALSE` or
`rlang::abort()`.
- Use custom error constructors only for repeated, structured failure modes.

## Review Loop

When reviewing or refactoring an R API:

1. Identify the abstraction layer of the function before judging its name.
2. Check whether the signature is scannable without reading documentation.
3. Replace boolean switches or tangled arguments with clearer strategy choices
only when that actually reduces complexity.
4. Remove helpers that exist only because of prior refactors, not because they
carry meaning now.
5. Re-check callers and tests after renaming so the new boundary is still
obvious in use.

For deeper source-backed notes, read
[references/tidyverse-design-map.md](references/tidyverse-design-map.md).
4 changes: 4 additions & 0 deletions .agents/skills/r-api-design/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface:
display_name: "R API Design"
short_description: "Tidyverse-inspired R API and function design guidance"
default_prompt: "Use $r-api-design to refine R function names, arguments, defaults, helper layers, outputs, side effects, and errors with tidyverse-inspired design principles."
64 changes: 64 additions & 0 deletions .agents/skills/r-api-design/references/tidyverse-design-map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Tidyverse Design Source Map

This note distills the parts of [Tidy design principles](https://design.tidyverse.org/)
that are most useful when designing or refactoring R package APIs.
Use it as a map back to the official source, not as a substitute for the book.

## Core frame

- [Unifying principles](https://design.tidyverse.org/unifying.html)
Optimize for humans, consistency, composition, and inclusive interfaces.
- [Function names](https://design.tidyverse.org/function-names.html)
Prefer clear `snake_case` names, usually verbs, with prefixes for families and
suffixes for variations.

## Signatures

- [Put the most important arguments first](https://design.tidyverse.org/important-args-first.html)
Order arguments by importance and typical use, not by implementation details.
- [Required args shouldn’t have defaults](https://design.tidyverse.org/required-no-defaults.html)
Make requiredness visible from the signature.
- [Put ... after required arguments](https://design.tidyverse.org/dots-after-required.html)
Keep the structure of the call readable.
- [Keep defaults short and sweet](https://design.tidyverse.org/defaults-short-and-sweet.html)
Prefer simple defaults; move complex resolution into the body or a helper.
- [Avoid magical defaults](https://design.tidyverse.org/def-magical.html)
Do not make an explicitly supplied default behave differently from an omitted
argument.
- [Make inputs explicit](https://design.tidyverse.org/inputs-explicit.html)
Avoid hidden dependence on global options, locale, or other ambient state.

## Choices and helper objects

- [Enumerate possible options](https://design.tidyverse.org/enumerate-options.html)
Use small string enums for finite choices and validate them centrally.
- [Prefer a enum, even if only two choices](https://design.tidyverse.org/boolean-strategies.html)
Avoid booleans when `TRUE`/`FALSE` would not be self-explanatory or the design
may grow.
- [Reduce argument clutter with an options object](https://design.tidyverse.org/argument-clutter.html)
Move low-importance tuning knobs into a helper-built object when the main
signature gets noisy.
- [Extract strategies into objects](https://design.tidyverse.org/strategy-objects.html)
When different strategies need different arguments, use helper objects rather
than one oversized signature.

## Outputs and side effects

- [Type-stability](https://design.tidyverse.org/out-type-stability.html)
Make output type predictable from input types, not surprising value-dependent
branches.
- [Side-effect functions should return invisibly](https://design.tidyverse.org/out-invisible.html)
Let side-effect helpers stay pipe-friendly without pretending they compute a
primary value.
- [Side-effect soup](https://design.tidyverse.org/side-effects.html)
Partition side effects deliberately; mixing them with transformation logic
raises cognitive load fast.

## Errors

- [Error call](https://design.tidyverse.org/err-call.html)
Hide noisy raw calls from user-facing errors unless the call is genuinely
helpful.
- [Error constructors](https://design.tidyverse.org/err-constructor.html)
Extract structured error helpers only when the same failure pattern repeats
enough to justify the machinery.
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Keep repository text files on LF across platforms.
* text=auto eol=lf

# Treat common package artifacts as binary.
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.pdf binary
*.rds binary
*.RData binary
46 changes: 46 additions & 0 deletions .github/workflows/document.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
paths: ["R/**"]

name: document.yaml

permissions: read-all

jobs:
document:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::roxygen2
needs: roxygen2

- name: Document
run: roxygen2::roxygenise()
shell: Rscript {0}

- name: Commit and push changes
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add man/\* NAMESPACE DESCRIPTION
git commit -m "Update documentation" || echo "No changes to commit"
git pull --ff-only
git push origin
1 change: 0 additions & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,5 @@ jobs:
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
folder: docs
26 changes: 26 additions & 0 deletions .github/workflows/touchstone-comment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Continuous Benchmarks (Comment)

concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.id }}
cancel-in-progress: true

on:
workflow_run:
workflows: ["Continuous Benchmarks (Receive)"]
types:
- completed

permissions:
contents: read
statuses: write
pull-requests: write

jobs:
upload:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: lorenzwalthert/touchstone/actions/comment@7e6072a25d1f8d72649188bc711113039ef94b75
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading
Loading