Linked feedback: ADX-007
Problem
patcher.ts relies on a large operation switch with repeated content-type checks and
index bounds logic in multiple branches, increasing maintenance overhead and error risk.
Evidence:
- Main switch:
packages/adf/src/patcher.ts:22
- Repeated guards in add/replace/remove bullet paths:
packages/adf/src/patcher.ts:49
Scope
- Introduce handler map keyed by operation (
PatchOperation['op']).
- Extract shared helpers for:
- section lookup
- index bounds validation
- list/map entry parsing/coercion
- Keep immutable semantics and current error behavior.
Acceptance Criteria
- Behavior parity across all patch operations and failure paths.
- Duplicated guard logic is reduced materially in patcher implementation.
- Existing patcher tests pass; new helper-focused edge-case tests added.
Test Plan
pnpm run test --filter @stackbilt/adf
- Add tests for:
- invalid index errors (list/map)
- unsupported content-type errors
- metric update on missing metric key
Linked feedback: ADX-007
Problem
patcher.tsrelies on a large operation switch with repeated content-type checks andindex bounds logic in multiple branches, increasing maintenance overhead and error risk.
Evidence:
packages/adf/src/patcher.ts:22packages/adf/src/patcher.ts:49Scope
PatchOperation['op']).Acceptance Criteria
Test Plan
pnpm run test --filter @stackbilt/adf