
Refine a collection plan from stable file-group identifiers
Source:R/collection-refine.R
glc_collection_refine.RdRecompute final collection units for an in-memory subset of one structural
compatibility set. Refinement validates and reuses the compact facts stored
in a glc_collection_plan() result. It does not reopen the package, load
metadata, access a network, or inspect measurement contents.
Arguments
- plan
A validated
glc_collection_planobject with supported plan and refinement-input schema versions. Keep this parent plan after refinement; the lightweight result refers to it by schema, version, and fingerprint and does not copy its normalized metadata tables.- file_group
A character vector of unique, non-missing stable
file_group_idvalues. Every value must be an included member ofplanand all values must belong to one structural compatibility set. Numeric declaration indices are not accepted.- compatibility_id
Optional single structural compatibility identifier. When
NULL, the identifier is inferred only if all selected groups share exactly one set. When supplied, it must equal that set's identifier.
Details
glc_collection_refine() is the final, fast step after interactive metadata
narrowing. Build glc_collection_plan() once, choose one row of
plan$compatibility_sets, and filter its member groups through the typed
tables in plan$groups and plan$metadata. Pass only the resulting stable
file-group ids to this function. Input order does not affect the result.
Refinement reapplies the stored structural and relationship rules, recomputes
the active deterministic factor union, and creates request-sensitive final
unit ids. Its units table is identical to
a fresh glc_collection_plan() call with the parent's original term,
variable, dataset, and standardization request and with file_group set to
the refined ids. The restriction-stable compatibility_id is retained. No
full variable or metadata tables are rebuilt.
Device identity remains linked by stable file-group id, so different devices
in one dataset do not split otherwise compatible groups. A safe active factor
union is reported through the unit's harmonization_required and
harmonized_variables fields. glc_read() and glc_collect() still validate
actual source values and apply the same union before binding.
Validation and conditions
Refinement supports plan schema "glc-collection-plan" version "1.2.0"
and refinement-input schema "glc-collection-refinement-input" version
"1.1.0". It verifies the compact input fingerprint and checks it against
the parent plan's provenance, request, and group membership. The fingerprint
covers the structural-family contract, each member's declared factor contract,
and relationship facts needed for refinement. It does not cover the larger
normalized metadata snapshot, so validation does not rehash the complete plan.
Earlier plan versions do not contain these facts and must be planned again.
All refinement errors inherit from glcdp_collection_refine_error.
More specific subclasses are:
glcdp_collection_refine_planfor a value that is not a collection plan;glcdp_collection_refine_versionfor an unsupported schema or version;glcdp_collection_refine_incompleteandglcdp_collection_refine_tamperedfor missing or changed parent facts;glcdp_collection_refine_file_group,glcdp_collection_refine_empty, andglcdp_collection_refine_duplicatefor invalid file-group selectors;glcdp_collection_refine_unknown_groupandglcdp_collection_refine_excluded_groupfor groups outside the eligible parent membership;glcdp_collection_refine_compatibility,glcdp_collection_refine_unknown_compatibility, andglcdp_collection_refine_compatibility_mismatchfor invalid structural identifiers;glcdp_collection_refine_cross_structurewhen selected groups span more than one structural set; andglcdp_collection_refine_unresolved_identitywhen required study, participant, or device identities cannot be resolved from the stored metadata facts.
Zero-access assurance
Refinement performs no file or network input/output. It does not call
glc_open(), glc_files(), glc_summary(), glc_read(), glc_collect(),
glc_download(), or metadata-loading and materialization functions. Its
assurance records that the package was not reopened, remote availability was
not probed, and measurement contents were neither transferred nor inspected.
glc_read() and glc_collect() remain authoritative after refinement.
Return structure
The result is a plain serializable list with class
glc_collection_refinement, schema "glc-collection-refinement", and
version "1.1.0". It contains:
parent:plan_schema,plan_version, and the validated refinement-inputfingerprintlinking this result to the retained parent plan;provenance:package_id,repository, exactsource_revision, andpackage_schema_version;request: the selectedcompatibility_id, sortedfile_groupids, and the parent's compactoriginalrequest;assurance: declaration basis plus package, network, availability-probe, measurement-transfer, measurement-inspection, and final-validation fields;compatibility_id,final_selection_required, andpreferred_unit_id;units: the same stable final-unit columns documented forglc_collection_plan(), including active factor harmonization fields;groups:status,unit_id,compatibility_id,dataset_id, integerfile_group, stablefile_group_id,study_id,participant_id,participant_associated,study_link_status,participant_link_status,device_id,device_link_status, and list-columnsreason_codesandmessages; andconstraints:compatibility_id,code,message, and logicalresolved. Its schema is stable even when it has no rows.
All tables and list-columns contain only plain serializable values. The
result contains no package handle, environment, token, cache path, or
temporary path. print() reports the structural id, final-unit and group
counts, final-selection status, and zero-access assurance, then returns the
result invisibly.
See also
glc_collection_plan() for the required parent plan,
glc_read() and glc_collect() for runtime validation and collection.
Examples
if (FALSE) { # \dontrun{
# Use an existing local, manifest-backed package directory.
# This pattern performs no network request and does not read measurements.
pkg <- glc_open("path/to/manifest-backed-package", quiet = TRUE)
plan <- glc_collection_plan(
pkg,
terms = "photopic illuminance",
variable_scope = "matched"
)
# In an application, filter these ids with plan$groups and plan$metadata.
set <- plan$compatibility_sets[1L, ]
selected_ids <- set$file_group_ids[[1L]]
refined <- glc_collection_refine(
plan,
selected_ids,
compatibility_id = set$compatibility_id[[1L]]
)
refined
} # }