Skip to content

feat(watcher): add addField() for dynamic field registration#101

Merged
zeevdr merged 1 commit into
mainfrom
feat/watcher-add-field
May 26, 2026
Merged

feat(watcher): add addField() for dynamic field registration#101
zeevdr merged 1 commit into
mainfrom
feat/watcher-add-field

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 26, 2026

Summary

  • ConfigWatcher.field() was one-shot: the field list was frozen at start() time, making it impossible to subscribe to new fields in a running watcher.
  • addField() lifts this constraint by loading the new field's initial value from a targeted GetConfig snapshot and re-opening the Subscribe stream with the updated field list.
  • loadSnapshot() is refactored into a private loadSnapshotForFields(paths) helper shared by both the full reconnect path and the new targeted addField path.

Test plan

  • addField() before start() — field is included and populated when start() runs.
  • addField() after start() — loads initial value, cancels current stream, re-subscribes with updated field list.
  • Re-subscribe call includes both old and new field paths.
  • Added field receives live changes from the new stream.
  • addField() after stop() throws DecreeError.
  • All 236 existing tests still pass.

Closes #70

ConfigWatcher.field() was one-shot: calling it after start() threw.
addField() fills that gap — it works both before and after start().
When called post-start it fetches a targeted GetConfig snapshot to
seed the new field's initial value, cancels the current Subscribe
stream, and re-opens it with the full updated field list.

Internally, loadSnapshot() is refactored into a private
loadSnapshotForFields(paths) helper so both the full reconnect
path and the targeted addField path share the same logic.

Closes #70

Co-Authored-By: Claude <noreply@anthropic.com>
@zeevdr zeevdr added this to the Beta Readiness milestone May 26, 2026
@zeevdr zeevdr added size: M Moderate — a day or two, clear scope priority: P2 Nice-to-have labels May 26, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/watcher.ts 90.90% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@zeevdr zeevdr merged commit ddcfa65 into main May 26, 2026
14 checks passed
@zeevdr zeevdr deleted the feat/watcher-add-field branch May 26, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P2 Nice-to-have size: M Moderate — a day or two, clear scope

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Watcher: dynamic field registration after start

1 participant