Skip to content

feat: on_overwrite(policy, same) (#161) - #162

Merged
thorwhalen merged 2 commits into
masterfrom
feat/on-overwrite-policy
Oct 26, 2026
Merged

thorwhalen merged 2 commits into
masterfrom
feat/on-overwrite-policy

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

Closes #161

Adds dol.on_overwrite(store, *, policy="warn"|"raise"|"overwrite"|callable, same=..., stacklevel=3): an overwrite policy for stores (class, instance or decorator factory), built on a wrap_kvs preset. Writing a same value is silent (default same: identity, then ==, and an ambiguous or raising == counts as different). Additive API only.

Review (two rounds, fresh Opus agents). Round 1 verdict "merge after fixes": default == crashed on array-like values; hardcoded stacklevel; brand's Registry couldn't adopt it (no custom message/exception). Applied: safe default same, stacklevel kwarg, callable policy as strategy, shared _existing_if_different helper with mk_confirm_overwrite_preset (behaviour unchanged), policy="overwrite" returns the store unwrapped, OVERWRITE_POLICIES/preset factory made private, docstring notes (per-write read, not thread-atomic, delete-then-write bypasses "raise"). Round 2: OK to land, no blockers; two non-blocking nits left (redundant policy re-resolve, one duplicated test).

Tests: full pytest 832 passed, 2 skipped locally.

@thorwhalen
thorwhalen merged commit 17e2ec9 into master Oct 26, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the feat/on-overwrite-policy branch October 26, 2026 16:07
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.

Overwrite policy for stores: warn/raise/overwrite with a pluggable same-value check

1 participant