Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Added

- [rd-rds] Add the package-level `package::InstalledCodeDb` API for explicit
installed-package `R/<pkg>.rdx`/`.rdb` access, index-order stored bindings,
bounded closure-prefix inspection, and best-effort database provenance.
- [rd-rds] Add the owned `package::NamespaceMetadata` view for static
`Meta/nsInfo.rds` declarations, including field-local diagnostics, import
aliases and exclusions, source/export name pairs, S3
Expand Down
23 changes: 23 additions & 0 deletions crates/rd-rds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ API returns both the exact addressed bytes and the decompressed payload, with
independent 256 MiB default bounds. Raw records are already XDR bytes and do
not carry a length prefix; zlib records carry a four-byte declared length.

With the same feature, [`package::InstalledCodeDb`] provides the package-level
API for that pair. The caller supplies the installed package directory; the
reader selects `R/<basename>.rdx` and `.rdb` and does not discover libraries or
scan runtime exports. [`InstalledCodeDb::stored_bindings`] is the complete
`variables` map in index order, including duplicate names. Consequently this
view's completeness domain is `CodeDatabaseVariables`, not exports or runtime
bindings. [`InstalledCodeDb::inspect_stored_binding`] returns structured
unknown/ambiguous errors instead of choosing among duplicate names, reads only
a unique direct record, and returns bounded closure prefix metadata. Closure
bodies are reported as `BodyValidation::NotValidated`.
The selected record is fully loaded, decompressed, and checked by the
`LazyLoadDb` container layer first; stored/decompressed size limits, framing,
compression, and trailing-stream corruption therefore fail before prefix
inspection. `InstalledCodeOptions::max_bytes_visited` applies only to the
semantic prefix walker, which stops before reading or validating a closure's
decompressed body payload.
The provenance includes both selected paths, compression, and an opaque
`CodeDbGeneration` derived from best-effort file metadata. It is an identity
hint rather than a content hash or a transaction guarantee.

The `lazyload` feature includes the `gzip` feature because installed package
`.rdx` indexes use the standalone gzip envelope in the normal package
profile. Callers that enable `lazyload` therefore also get gzip `.rds`
Expand All @@ -41,6 +61,9 @@ before and after each read. On Unix this includes device and inode, and on
other platforms it uses file length and modification time when available.
This is best-effort detection of replacement or concurrent modification and
cannot provide a transaction guarantee against races after the final check.
Neither the generation nor replacement detection is a content hash or a
portable guarantee: a replacement that preserves all observed metadata may
not be distinguishable on every platform.

The [`rd-helpdb`](../rd-helpdb/README.md) crate uses the file layer for
standalone help-database RDS files, and [`rd-ast`](../rd-ast/README.md) can
Expand Down
2 changes: 1 addition & 1 deletion crates/rd-rds/src/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! closure body tag, which makes it suitable for answering metadata queries
//! about large or partially damaged objects.

#![allow(dead_code)]
#![cfg_attr(not(feature = "lazyload"), allow(dead_code))]

use std::fmt;

Expand Down
8 changes: 3 additions & 5 deletions crates/rd-rds/src/lazyload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,9 @@ fn snapshot_metadata(metadata: &Metadata) -> FileSnapshot {
}
}
#[cfg(not(unix))]
{
FileSnapshot {
len: metadata.len(),
modified: metadata.modified().ok(),
}
FileSnapshot {
len: metadata.len(),
modified: metadata.modified().ok(),
}
}

Expand Down
11 changes: 11 additions & 0 deletions crates/rd-rds/src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ use crate::{RObject, RStr, RValue};

mod namespace;

#[cfg(feature = "lazyload")]
mod installed_code;

#[cfg(feature = "lazyload")]
pub use installed_code::{
BodyValidation, CodeDbGeneration, CodeDbProvenance, DefaultPresence, FailureCause,
FailurePhase, Formal, FormalsInspection, FormalsNotApplicable, FormalsUnavailable,
FunctionFormals, InspectionExtent, InstalledCodeDb, InstalledCodeError, InstalledCodeOptions,
PrefixFailure, StoredBinding, StoredKind, StoredObjectInspection,
};

pub use namespace::{
ImportedName, MetadataField, NamespaceExport, NamespaceImport, NamespaceMetadata, S3MethodName,
S3Registration,
Expand Down
Loading