Skip to content

feat(core): DAG-based lifecycle ordering for @OnStart and @OnTerminate#83

Merged
isatiso merged 3 commits intomainfrom
feat/lifecycle-dag-ordering
Apr 13, 2026
Merged

feat(core): DAG-based lifecycle ordering for @OnStart and @OnTerminate#83
isatiso merged 3 commits intomainfrom
feat/lifecycle-dag-ordering

Conversation

@isatiso
Copy link
Copy Markdown
Owner

@isatiso isatiso commented Apr 13, 2026

Summary

Replace flat parallel execution of @OnStart / @OnTerminate hooks with dependency-aware DAG scheduling based on constructor injection graph.

Core changes

  • TpLoader now maintains a DAG of lifecycle nodes with deps and dependents relationships
  • New TpLoader.record(token, deps) method registers component dependency relationships for all components
  • TpLoader.register() accepts optional deps parameter for module-level dependencies
  • @OnStart hooks execute eagerly as soon as their direct dependencies complete (no layer-based waiting)
  • @OnTerminate hooks execute in reverse dependency order
  • Intermediate nodes without hooks still propagate dependency relationships

Changeset & versioning

  • Align all package versions to 2.1.1 baseline
  • Configure linked versioning group for all @tarpit/* packages (major/minor aligned, patch independent)
  • Change peerDependencies from workspace:* to workspace:^ to prevent minor bumps cascading into major
  • Add onlyUpdatePeerDependentsWhenOutOfRange to changeset config
  • Release @tarpit/core@2.2.0

Test plan

  • 15 new/updated tests for TpLoader covering dependency ordering, reverse termination, diamond deps, eager execution, intermediate node propagation, null/self-ref dep handling
  • 100% coverage on tp-loader.ts
  • All 141 core module tests pass
  • Full test suite passes (pre-existing failures only)

isatiso and others added 3 commits April 13, 2026 09:43
Replace flat parallel execution with dependency-aware DAG scheduling.
Lifecycle hooks now respect constructor injection dependencies - a
component's @onstart runs only after its dependencies are ready,
and @OnTerminate runs in reverse order.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Releases:
  @tarpit/core@2.2.0
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@isatiso isatiso merged commit f1fdc52 into main Apr 13, 2026
15 checks passed
@isatiso isatiso deleted the feat/lifecycle-dag-ordering branch April 13, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant