Skip to content

Add Effect.FlushlessCreateNextChild for appending numbered child effects#186

Merged
stidsborg merged 1 commit into
mainfrom
add-flushless-create-next-child
Jul 5, 2026
Merged

Add Effect.FlushlessCreateNextChild for appending numbered child effects#186
stidsborg merged 1 commit into
mainfrom
add-flushless-create-next-child

Conversation

@stidsborg

Copy link
Copy Markdown
Owner

Summary

Adds a flushless Effect.FlushlessCreateNextChild<T> primitive that, for a given parent EffectId, finds the next free direct-child slot and records the provided content there as a completed effect.

  • Next-free rule: highest existing direct-child index + 1 (append; gaps are kept).
  • Returns the created child's EffectId.
  • Flushless / in-memory only: the write is visible immediately (readable via Get/TryGet) and the next call already sees the reserved slot, so flushing is not needed for index correctness — durability is the caller's concern (call Effect.Flush()), matching the existing Flushless* family.
  • Thread-safe: index-selection and reservation happen under a single _sync acquisition (via an extracted lock-free AddToPendingCore) so concurrent callers cannot collide on the same index.

This generalizes the hand-rolled next-child bookkeeping currently in Queuing/IdempotencyKeys.cs. Migrating IdempotencyKeys onto this primitive is intentionally left as a follow-up.

Caveat

This is a raw append: each call adds a new child, so it is not replay-idempotent on its own. It is intended for callers driven by genuinely-new external events (as IdempotencyKeys is, guarded by its own content dedup).

Tests

CreateNextChildTests (4 tests, in-memory):

  • appends sequentially from 0
  • continues from pre-existing children
  • keeps gaps and uses highest+1 (across a persisted Clear)
  • indexing is scoped per-parent

Introduces a flushless primitive that finds the next free direct-child slot
under a given parent EffectId (highest existing child index + 1) and records
the provided content there as a completed effect, returning the new child's
EffectId. Index-selection and reservation happen under a single lock so
concurrent callers cannot collide on the same index.

Generalizes the hand-rolled next-child bookkeeping in IdempotencyKeys.
@stidsborg stidsborg merged commit 9ff8cb3 into main Jul 5, 2026
7 of 8 checks passed
@stidsborg stidsborg deleted the add-flushless-create-next-child branch July 5, 2026 07:06
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