Pcornel
Automation · Scripting

Modules

Cheat sheet · https://pcornel.dk/topic.php?topic=5218

Back to the Topic

Answer

Modules package reusable script code and dependencies. Operational reliability depends on version, provenance, load path, compatibility and the difference between successful import and correct runtime behavior.

Remember

  • Module import ≠ compatible dependency; loading can succeed while an invoked function or API later fails.
  • Module name ≠ trusted source; path precedence or package repositories can resolve an unintended implementation.
  • Latest version ≠ safest version automatically; breaking changes and removed defaults can alter behavior.
  • Dependency installed ≠ dependency active in this runtime; virtual environments, module paths and interpreter versions matter.

First checks

  • python3 -c 'import <module>' — import works
  • Get-Module -ListAvailable <name> — PowerShell modules
  • source lib.sh — Bash library

Verify in this order

shared module → imported by scripts

Where it usually breaks

Successful module loading proves only that a runtime resolved and initialized some dependency; it does not prove provenance, supported version or correct behavior for the intended target.

Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload. Preserve at least three independent checks: prerequisite/interface or identity/transport state; the owning control/service/policy state; then effective data-plane, backend or workload state. A healthy upstream boundary does not prove the downstream consumer or return path.

Modules scripting boundary map

BoundaryHealthy evidenceSuspicious evidence
Input / runtimeEffective inputs, runtime, working context and dependency versions are explicitHidden defaults, stale environment, wrong interpreter/path or unvalidated input
Logic / executionBranch/function/module decisions and external actions expose per-operation resultsSwallowed failures, shell reinterpretation, blind retries or last-result-wins behavior
Result / proofExit/exception/log evidence is correlated with independent target read-backProcess success or printed output treated as target success
Recovery / troubleshootingFirst failed boundary is preserved, changed minimally and retestedRandom edits, catch-all suppression or evidence destroyed before diagnosis

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5218

Confirmation

Confirm action

Continue?