Apply changes to all pages referencing structure

Scenario:

I have a page whose blueprint includes a structure:

specification:
  type: structure
  fields:
    specification_name:
      type: text
    specification_icon:
      type: files

The above is a central/global index of specifications. In child pages, items from this structure can be added via select field with query within a structure, plus a corresponding value set on the child page:

specifications:
  type: structure
  fields:
    specification_type:
      type: select
      options: query
      query:
         fetch: page.parent.specification.toStructure
         value: "{{ structureItem.specification_name }}"
    specification_value:
      type: text

The above is the context. The question is as follows:

If a user updates the ‘specification_name’ in the parent page, what is the best way to update all child pages that reference ‘specification_name’ and therefore will contain the old value for ‘specification_name’ saved in their .txt files?

Is there something in the Kirby API already to help with this, or do I have to write my own function and hook onto the page update/save method, and if so how do I observe and record the ‘specificaion_name’ values that have been changed since last save in order to find and replace in the child pages? Maybe compare diffs with the .lock file or something?

Thanks in advance.

In a page.update:after hook you have access to both the old and new page object. So you can check if any values in the structure field have changed, and if so, update all children that reference the old value.

Since this procedure can become a pain in the neck, especially on large sites, it would make more sense to add unique ids to each item of the parent structure and reference these unique IDs instead of the name in the children. Thus, subsequent changes to field values of the structure wouldn’t have any effect.