Production-harden loader, multi-package dependency tracking, exhaustive tests#15
Open
felix-andreas-finccam wants to merge 3 commits into
Open
Production-harden loader, multi-package dependency tracking, exhaustive tests#15felix-andreas-finccam wants to merge 3 commits into
felix-andreas-finccam wants to merge 3 commits into
Conversation
…ve tests
Loader (R/loadfast.R):
- Track cross-package dependencies: reloading a package flags every cached
package that (transitively) imports it; the flagged package's next
load_fast() auto-upgrades to a full reload, and full loads recursively
reload flagged dependencies first, so a chain C -> B -> A converges with a
single load_fast(C) after A is reloaded. No-change loads do not invalidate.
- Attach DESCRIPTION Depends packages during full loads (with a clear error
when one is missing), matching library()/load_all() semantics.
- Run .onUnload best-effort when unloadNamespace() refuses (dependency
imported by other loaded packages) before force-replacing the registry
entry.
- Clean up half-built namespaces when a full load fails partway (unregister
and detach), while keeping failed-load recovery on the next call.
- Detach/unload the old identity when the Package field changes in place for
a cached path.
- Re-source incremental changes in Collate-aware full-load order instead of
alphabetical basename order.
- Seed the namespace spec version from DESCRIPTION so
getNamespaceVersion() reports correctly.
- Replace the boolean re-entrance flag with a path stack (public load_fast()
stays strict; internal recursion is allowed).
- Replace library("testthat") with a guarded attachNamespace(), inline the
tiny methods::: metadata helpers (.hasS4MetaData/.getGenerics/
.TableMetaPrefix equivalents), move the top-level message to .onAttach,
and make the sources ASCII-only -- R CMD check --as-cran is now clean
(0 errors, 0 warnings; only the inherent attach() NOTE remains).
Packaging:
- DESCRIPTION: version 1.0.0, declare methods/tools in Imports, move dev
dependencies from the non-standard DevDeps field to Suggests.
- roxygen2-generated NAMESPACE and man/ pages for both exports.
- New tests/testthat suite that runs against the installed package during
R CMD check (smoke, incremental, dependency invalidation, error paths).
- .Rbuildignore covers all non-package files; renv settings track Suggests.
Tests (test_loadfast.R, 299 checks total):
- Stage 6: multi-package dependency invalidation -- direct importer
invalidation, transitive chain convergence, no-change loads, whole-
namespace import(), S4 class redefinition across packages, forced
unregister path incl. .onUnload.
- Stage 7: production hardening -- Depends attachment and failure, rename-
in-place cleanup, failed-full-load cleanup and recovery, namespace version,
Collate order on incremental reload, re-entrance guard, verbose logs.
CI: harness now also runs on macOS; new R CMD check --as-cran job on
Linux/Windows/macOS (R release) plus oldrel-1 on Linux.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S8v6K52c7AJwuDkyyETMU7
…ix CI installs rlang::ns_registry_env() is defunct as of rlang 1.2.0 and hard-errors, which broke every R CMD check CI job on fresh installs (the renv.lock pinned an old rlang, masking it locally). Replace it with .loadfast.ns_register() / .loadfast.ns_unregister(), which construct .Internal(registerNamespace(...)) / .Internal(unregisterNamespace(...)) calls at runtime -- the same approach current pkgload uses. loadfast now has no third-party runtime dependencies; rlang moves to Suggests (still imported by the devpackage test fixture, which now imports the stable rlang::abort instead of the defunct symbol). The harness CI jobs failed separately during renv::restore(): the lockfile drags in dev-machine packages (keyring needs libsecret on ubuntu; a package failed to resolve on macos). Switch those jobs to setup-r-dependencies, which installs exactly the DESCRIPTION Imports+Suggests the harness needs and handles system requirements; renv.lock remains for local development. Verified locally: harness 299/299, R CMD check --as-cran clean (2 expected NOTEs), testthat suite passes under check. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S8v6K52c7AJwuDkyyETMU7
normalizePath(mustWork = TRUE) wording differs by OS: "No such file or directory" on unix vs "The system cannot find the file specified" on Windows. Broaden the two expected-error patterns accordingly; this was the only remaining CI failure (Windows R CMD check). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S8v6K52c7AJwuDkyyETMU7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brings
loadfastinto production shape: fixes real multi-package and lifecycle bugs found by probing, makes the package a clean installable artifact (R CMD check --as-cran: 0 errors, 0 warnings), and extends testing from 259 to 299 harness checks plus a newtestthatsuite that runs against the installed package duringR CMD check.Loader changes (
R/loadfast.R)Multi-package dependency tracking (the main gap): previously, after reloading a dependency, importer packages kept running against a stale snapshot and a plain
load_fast()on them short-circuited with "No changes". Now:load_fast()auto-upgrades to a full reload, with a message explaining why.C -> B -> Aconverges with a singleload_fast(C)afterAis reloaded.Lifecycle fixes:
Depends:packages are attached during full loads (clear error when missing) — previously ignored, so package code relying on them crashed..onUnloadruns best-effort whenunloadNamespace()refuses (namespace imported by other loaded packages) before the registry entry is force-replaced.DESCRIPTIONin place now detaches/unloads the old identity instead of leaving it on the search path forever.DESCRIPTION, sogetNamespaceVersion()reports correctly.load_fast()stays strict, internal dependency-reload recursion is allowed.Packaging
DESCRIPTION: version 1.0.0;methods/toolsdeclared in Imports; dev deps moved from the non-standardDevDepsfield toSuggests.NAMESPACEandman/pages for both exports.message()moved to a suppressible.onAttach; sources are ASCII-only.library("testthat")replaced with a guardedattachNamespace(); tinymethods:::internals (.hasS4MetaData/.getGenerics/.TableMetaPrefix) inlined as equivalents so--as-cranis warning-free..Rbuildignore; renv settings trackSuggests.R CMD check --as-cran: 0 errors, 0 warnings; the only inherent NOTE is theattach()call (same NOTE pkgload carries).Testing
import(), S4 class redefinition across packages, forced-unregister path incl..onUnload.tests/testthat/(new) — self-contained smoke/error-path tests that run against the installed package duringR CMD check, so the check proves the built artifact works.CI
R CMD check --as-cranjob on Linux/Windows/macOS at R release, plus oldrel-1 on Linux.🤖 Generated with Claude Code
https://claude.ai/code/session_01S8v6K52c7AJwuDkyyETMU7
Generated by Claude Code