On this page

Spell metadata kwargs๏ƒ

๐ŸŸก Intermediate ยท Lesson 06

Spell metadata via bind kwargs (landed 2026-07-19): any extra keyword on bind() threads into the Spell's own kwargs channel and lands on spell.metadata - tag your registrations with ownership, tiers, or agent breadcrumbs. Native bind values are unstealable: declared parameters capture their names before **kwargs collects.

Before you run๏ƒ

Use the Intermediate guide for prerequisite concepts. Run from a checkout with Melder installed and Python 3.14 free-threading selected. The collection download includes the level's local helper modules.

Run the saved script๏ƒ

python UX_and_AIX_experiences/02_intermediate/06_spell_metadata_kwargs.py
py -3.14t UX_and_AIX_experiences/02_intermediate/06_spell_metadata_kwargs.py

Download this collection ยท Source on GitHub

Public surface๏ƒ

bind(**extras) -> Spell.metadata, find_spell_by_spell_id

Code๏ƒ

 1"""
 2TIER: intermediate (06)
 3GOAL: Spell metadata via bind kwargs (landed 2026-07-19): any extra
 4      keyword on bind() threads into the Spell's own kwargs channel and
 5      lands on spell.metadata - tag your registrations with ownership,
 6      tiers, or agent breadcrumbs. Native bind values are unstealable:
 7      declared parameters capture their names before **kwargs collects.
 8SURFACE EXERCISED: bind(**extras) -> Spell.metadata, find_spell_by_spell_id
 9"""
10import melder as md
11
12
13class PaymentsApi:
14    pass
15
16
17def main() -> None:
18    book = md.Spellbook()
19    spell_id = book.bind(
20        spell=PaymentsApi, existence="unique",
21        owner_team="payments", tier="gold", reviewed="2026-07-19",
22    )
23    spell = book.find_spell_by_spell_id(spell_id)
24    assert spell.metadata == {
25        "owner_team": "payments", "tier": "gold", "reviewed": "2026-07-19",
26    }
27    print("spell born with metadata:", spell.metadata)
28
29    try:
30        book.bind(spell=PaymentsApi, existence="unique", spell_id="jacked")
31        print("collision unexpectedly accepted")
32    except TypeError as err:
33        print("native Spell params stay sovereign:", type(err).__name__)
34
35
36if __name__ == "__main__":
37    main()

Check the outcome๏ƒ

The script contains its own assertions or demonstrated refusal paths. Run it to evaluate those checks against your installed version. The code above is taken directly from the saved file; no run output is invented here.

More intermediate examples ยท Level guide

API contracts๏ƒ