feat(skills): rename scribe-OKF>write-OKF, implement>weave, domain-modeling>model-domain, codebase-design>design-codebase, caveman>talk-caveman, background-work>harden-background-work, dev-python>develop-python, dev-r>develop-r, r-style>style-r, handoff>write-handoff, cavecrew-octobot>spawn-cavecrew, jj-atomic>commit-atomic-jj; bdd stays as the single grandfathered name docs(skills): sweep spec>blueprint across skill prose; spec-format.md becomes blueprint-format.md; internal Spec section becomes Contract; commit citations now read implements blueprint NNN docs(blueprint): numbering starts at 001 when OKF/blueprints/ is empty docs(conjure): 110-line cap applies to SKILL.md only; siblings uncapped fix(containerize): read an existing build-dev recipe and surface semantic mismatch instead of trusting the name
2.3 KiB
Deep modules in R
Vocabulary and principles in ../design-codebase/SKILL.md.
This file shows what deep / shallow look like with box::use — the R lever
for controlling the interface.
In R you control the interface with box::use (or NAMESPACE/@export in a
package). The interface is whatever a caller writes after box::use(...).
Shallow — bad
# R/modb/client.R — exports eight thin helpers
box::export(
build_url, build_headers, parse_token, refresh_token,
page_request, paged_collect, validate_dataset_id, query_dataset
)
A caller writes:
box::use(R/modb/client[
build_url, build_headers, parse_token, refresh_token,
page_request, paged_collect, validate_dataset_id, query_dataset
])
tok <- refresh_token(parse_token(Sys.getenv("MODB_TOKEN")))
url <- build_url("DS001")
hdr <- build_headers(tok)
rows <- paged_collect(page_request(url, hdr))
Every refactor that splits, renames, or merges a helper breaks every caller and every test. The tests reach into internals because the internals are the interface.
Deep — good
# R/modb/client.R — one exported entry point, everything else internal
box::export(query_dataset)
A caller writes:
box::use(R/modb/client[query_dataset])
rows <- query_dataset("DS001")
query_dataset() handles tokens, paging, retries, and validation
internally. Tests target the contract ("returns a tibble of expected rows
for DS001"; "raises modb_auth_error on bad token"). Internal helpers can
be renamed or replaced freely.
Design questions before exporting
For every name you are about to box::export() or @export:
- Does a caller need this? If only other internals call it, keep it unexported.
- Could two of these collapse?
build_url+build_headersmay want to become an internalprepare_request(). - Could a parameter swallow a helper? A
paginate = TRUEargument onquery_dataset()can removepage_request+paged_collectfrom the surface. - Is this a leaky abstraction? Returning a
httr2::requestobject forces every caller (and test) to knowhttr2. Return a tibble or a typed result instead.
Heuristic
If the count of exports from a module changes every PR, the module is shallow. Deep modules export one or two names and stay stable for months.