Skip to content

refactor(adf): split bundler orchestration from pure merge logic #8

Closed

Description

@SmartBrandStrategies

Linked feedback: ADX-007

Problem

packages/adf/src/bundler.ts currently combines manifest parsing, trigger resolution,
AST merge/transformation, token estimation, and orchestration/file loading concerns.
This raises cognitive load and couples pure transformation behavior to orchestration paths.

Evidence:

  • Manifest parsing in bundler: packages/adf/src/bundler.ts:29
  • Trigger resolution in bundler: packages/adf/src/bundler.ts:160
  • Merge and token estimation in bundler: packages/adf/src/bundler.ts:331

Scope

  • Extract manifest parsing/trigger resolution to packages/adf/src/manifest.ts.
  • Extract pure merge/token-estimation functions to packages/adf/src/merger.ts.
  • Keep bundler.ts as orchestration shell only:
    • load manifest
    • resolve module paths
    • read content
    • parse docs
    • call pure merger/evaluator

Acceptance Criteria

  • Merge utilities are pure and independently unit-tested without filesystem mocks.
  • bundler.ts no longer defines merge/token estimation internals.
  • CLI behavior for adf bundle is unchanged for existing fixtures/tests.
  • Existing bundle tests pass; add focused tests for extracted merger.ts.

Test Plan

  • pnpm run test --filter @stackbilt/adf
  • Add unit tests for:
    • duplicate-section merge behavior across content types
    • weight promotion rules
    • token estimate parity against current behavior

Activity

  1. added this to the v0.6.0 milestone on Mar 2, 2026
  2. added
    area:adf
    type:refactor
    priority:p0
    on Mar 2, 2026
  3. SmartBrandStrategies commented on Mar 2, 2026

    @SmartBrandStrategies
    ContributorAuthor

    Blocks #9 — the unified evidence pipeline depends on the clean merge/manifest boundaries this refactor introduces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:adfpriority:p0type:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions