Skip to content

Make library sourcing passive and initialization explicit #222

Description

@codeforester

Parent: #214

Train position: 8 of 26
Phase: P1 — Passive, stable runtime and API

Problem

Sourcing lib_std.sh currently filters caller arguments, resets positional parameters, exports logging controls, and creates or unsets generic state. That makes a reusable library behave like an application bootstrap and creates surprising integration failures.

Acceptance criteria

  • Make sourcing define public symbols, immutable package metadata, and collision-safe load guards without consuming or rewriting $@.
  • Do not install traps, export runtime controls, change shell state, or create, unset, or overwrite caller-owned generic variables at source time.
  • Introduce an explicit, idempotent initialization API that accepts argv and configuration as inputs and returns filtered application arguments without hidden positional mutation.
  • Move wrapper flags, logging and color initialization, and application lifecycle setup into the launcher or explicit initialization.
  • Make repeated sourcing, repeated initialization, and loading compatible or incompatible versions deterministic and diagnosable.
  • Provide a tested one-time v1.4.0-to-v2 migration path and prove the legacy source-time mutations are absent; do not retain them behind a compatibility mode.

Dependencies

Completion

Implemented by PR #250 (merged 2026-08-04). Local validation passed all 475 BATS tests, Bash 4.2 compatibility smoke checks, all eight Bash option-contract modes, examples, and ShellCheck error-profile validation. Hosted Ubuntu and macOS checks also passed.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or product improvement

Type

No type

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions