Skip to content

v1.0.0-pre.3

Pre-release
Pre-release

Choose a tag to compare

@anth64 anth64 released this 07 Mar 11:27
· 18 commits to main since this release

This release introduces a major overhaul of dependency resolution, including transitive "cascade" unloads, a generic topological sort implementation, and granular failure logging.

Core Architecture Changes

Dependency Graph & Topological Sorting

  • Generic Kahn's Sort: Refactored the topological sort into stk_kahn_sort(). It now accepts has_dep and on_cycle callbacks, decoupling the core algorithm from the stk_modules structure.
  • Batch Load Ordering: stk_sort_load_order() now uses stk_batch_has_dep to inspect temporary files. This allows simultaneous load events to be processed in dependency-first order without requiring a retry cycle.
  • Transitive Unloads (Cascade): On UNLOAD events, stk_poll() now expands the target set via stk_collect_dependents() to include all transitively dependent modules.
  • Unload Ordering: Added stk_sort_unload_order() to ensure that dependents are always shut down before their dependencies (reverse topological order).

Module Lifecycle Refactor

  • Phased Loading: stk_module_load() has been decomposed into stk_module_preload(), stk_module_activate(), stk_module_discard(), and stk_validate_dependencies_single().
  • Activation Guard: Module init is no longer called if dependencies are unmet during the validation phase.
  • Pending Queue Persistence: Modules with unmet dependencies are now added to the pending queue instead of being dropped. stk_pending_retry() now prunes entries for files that no longer exist and skips already-loaded entries.

Logging & Diagnostics

  • Granular Failure Reporting: Replaced vague "unmet dependencies" logs with stk_log_dependency_failures().
  • Error Context: Logs now specify the exact reason for a dependency failure:
    • not found: Missing dependency ID.
    • requires <constraint>, have <version>: Version mismatch.
  • Buffer Configuration: Added STK_MOD_DEP_LOG_BUFFER (2048) to stk.h to define the failure message buffer size.

Technical Changelog

Added

  • STK_MOD_DEP_LOG_BUFFER constant in stk.h.
  • stk_kahn_sort generic callback-based implementation.
  • stk_log_dependency_failures for detailed mismatch reporting.
  • stk_collect_dependents for transitive dependency tracking.

Changed

  • stk_module_load logic split into discrete preload, validate, activate, and discard steps.
  • stk_poll event loop updated to support cascade unloads and improved retry paths.
  • Kahn sort refactored to eliminate direct coupling to stk_modules.

Fixed

  • Fixed silent deferrals during stk_init.
  • Fixed logic error where stk_pending_retry could be bypassed in certain stk_poll exit paths.

Full Changelog: v1.0.0-pre.2...v1.0.0-pre.3