Argument Digestion Architecture#
MolSysMT uses ArgDigest (@digest and @arg_digest) to enforce input contracts, argument normalization, and error reporting across the public API without compromising execution speed.
1. Validated Boundary Philosophy#
MolSysMT strictly distinguishes between public API boundaries and internal execution paths:
Public Functions: Every function exposed to users (e.g. in
molsysmt.*) is decorated with@digest. The decorator intercepts arguments, validates types and shapes, resolves selection strings, casts identifiers, and ensures physical units meet library standards before the function body executes.Private and Internal Functions: Functions in
_private/or internal helpers must never be decorated with@digest.Trusted Delegation: When a public function delegates work to another function whose contract is already satisfied, it explicitly passes
skip_digestion=Trueto bypass redundant validation:
# Boundary call (digestion active)
def public_algorithm(molecular_system, selection='all', skip_digestion=False):
# Internal delegation (digestion bypassed)
return internal_worker(molecular_system, selection=selection, skip_digestion=True)
2. Standard Digestion Arguments#
Public functions consistently accept and process standardized argument conventions:
Argument |
Purpose |
Digestion Rule |
|---|---|---|
|
Input system |
Validates recognized form item, file path, or string representation |
|
Atom or element filter |
Resolves string syntax, list of integers, or array; converts to 0-based indices |
|
Coordinate frame filter |
Resolves integer list, slice, or |
|
Grammar for |
Validates selection engine ( |
|
Conversion target |
Validates supported destination form name |
|
Validation bypass |
Boolean flag; defaults to |
3. Fast-Track and Performance Safety#
Argument digestion validates inputs in microseconds. Because validation occurs once at the public entry point, compute-intensive loops and internal algorithms execute at native C/Numba/Rust speed with pure arrays and trusted parameters.