Skip to content

Copies a parent's named metadata to a durable child - #306

Merged
johnnyt merged 1 commit into
mainfrom
sp-3iui-inherited-metadata-copy
Nov 23, 2026
Merged

johnnyt merged 1 commit into
mainfrom
sp-3iui-inherited-metadata-copy

Conversation

@johnnyt

@johnnyt johnnyt commented Nov 23, 2026

Copy link
Copy Markdown
Member

Implements the ADR-0008 Amendment of 2026-11-23 (on main, at proposed), points 1, 2, 4 and 5 and its "What a host sees". Point 6, the reader, is a later change and is not here.

What changes

  • Driver.new/3 takes inherited_metadata_keys:, a list of host metadata keys, default [] (new/3's docstring). new/3 raises ArgumentError on a value that is not a list of strings, or that names Linkage.reserved_key/0 (inherited_metadata_keys!/1).
  • A per-call inherited_metadata_keys: raises ArgumentError on create/3, send_event/4, done_invocation/5 and failed_invocation/5, before any read or write (refuse_per_call_inheritance!/1).
  • At a durable child's create, and nowhere else, the child is given as its metadata: each named key its parent's host metadata holds, with the parent's value; a named key the parent does not hold is not written (create_linked/5, take_inherited/2). The parent's map is the metadata: its own create was given for a child started during that create, its stored record on a step (one :fetch_execution of the parent), and the record start_child_at/6 already reads for a fan-out (start_context/3) (inherited_metadata/3).
  • With [], no read is made and no metadata: is passed to the child's create, so a child is created as on 0.27.0 (inherited_metadata/3's first clause, inherited_opt/2).
  • An adopted child is not written to; a grandchild copies the same keys from its parent, the child, because the child is driven by the same driver.
  • The Ecto adapter's moduledoc says what an opted-in host's metadata-held linkage gets: write_tree_migration/2 re-pins it in metadata, while the two listings, the children pin count and the retirement guard read the V09 columns alone, so such a child is not listed, not counted and does not block a retirement.
  • An Added fragment, changelog.d/sp-3iui.md. docs/telemetry.md names the private emitter at its new arity.

No migration version, no adapter callback, no schema and no stored value changes; no dependency is added.

Where it is proved

  • test/statifier_persistence/driver_inherited_metadata_test.exs: every child case runs on the in-memory adapter and on the Ecto adapter on Postgres (named in each test). A parent holding a named and an unnamed key gives the child the named key only; a missing key is not written; without the option the child's metadata is its linkage alone; a loop's later pass copies from the stored parent and its re-drive adopts the child with the keys kept; a grandchild copies; each fan-out child copies; a step's child reads the parent once more only when keys are named; and the option's refusals.
  • test/statifier_persistence/ecto/sqlite_migrations_test.exs: a linkage written with the linkage-columns option off and read with it on is re-pinned but not listed or counted.

Each new test carries its sabotage note. The required one: copying every host key in take_inherited/2 turns the named-key test red on both stores.

Held from this pull request

The fan-out re-entered by a loop (sp-1my6) is not in this pull request. A fan-out child's start is at-least-once, and on 0.27.0 a start delivered again after its child ended adopts that child. Naming a later pass's fan-out children the way single children are named (an ended child at the first id is an earlier pass's) would instead start a second child for that delivery, which changes what an existing call does for a host that never loops. The token of the pass that created a first-pass child is not stored, so no rule tells the two apart from what is stored today. That choice is held for a ruling and is not decided here.

Provenance

  • The metadata-held linkage answer is the documentation answer rather than making the listings read metadata as the re-pin does: the cheaper true answer, and it changes no existing answer. Decided by the conductor under a standing consent, 2026-11-23.
  • Where the child's create reads the parent's map (a map in hand, or the stored record) is threaded through the driver's executor as a private value; no public type changes.

Gate

Full mix quality green on this branch's head: format, compile with warnings as errors, credo, docs, dialyzer and the whole suite, Postgres and SQLite included.

Implements the ADR-0008 Amendment of 2026-11-23, points 1, 2, 4 and 5.
Driver.new/3 takes inherited_metadata_keys:, a list of host metadata
keys, default []. At every durable child's create (a single child on
any pass, each fan-out child) the child is given each named key its
parent's host metadata holds, beside its linkage. The parent's map is
the create's metadata: for a child started during the parent's own
create, the stored record on a step, and the record start_child_at/6
already read for a fan-out. An adopted child is not written to. With
[] no copy and no read is made, and no metadata: is passed, so a
child is created as on 0.27.0. new/3 raises on a list that is not
strings or names the reserved key; create/3, send_event/4,
done_invocation/5 and failed_invocation/5 raise on a per-call list.

The Ecto adapter's moduledoc now says what an opted-in host's
metadata-held linkage gets: the re-pin reads it, the listings, the
pin count and the retirement guard do not; a SQLite test pins it.

Tests run on the in-memory adapter and on Postgres. Full mix quality
green.

Refs: sp-3iui, sp-rokq
@johnnyt
johnnyt merged commit 14f7ea1 into main Nov 23, 2026
1 check passed
@johnnyt
johnnyt deleted the sp-3iui-inherited-metadata-copy branch November 23, 2026 21:08
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