Id Regulation Legacy Metadata
Backward-compatible reads for renamed Indonesian regulation metadata keys.
Stages downstream of the parser (chunker, data generators) are routinely fed metadata that was produced and persisted by an earlier version -- a cache, a reprocessing queue, a stored intermediate artifact. A renamed key therefore cannot be switched over in one release: the new reader would find nothing where the old writer put a value and would degrade silently, emitting a document with no amendment relations rather than failing.
Each shim here reads the current key, falls back to the superseded one, and warns when it had to. The whole module is meant to be deleted once the deprecation window closes; keeping the shims together makes the removal a single greppable unit rather than a hunt through call sites.
read_amends_regulations(metadata, current_key, legacy_key)
Read the amended-regulation list, falling back to the single-valued key it replaced.
amends_regulation (one str | None) became amends_regulations (a list) so an omnibus
law can record every regulation it amends. Both names are parameters because the pair is read
under different prefixes per stage: regulation_amends_regulations on parser-stamped element
metadata, amends_regulations on chunk metadata.
The current key wins whenever it is present, even holding an empty list -- that is a current document amending nothing, and a stale sibling value would resurrect it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
dict[str, Any]
|
Element or chunk metadata dict. |
required |
current_key
|
str
|
Key holding the list. |
required |
legacy_key
|
str
|
Superseded key holding a single regulation ID. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Fully-qualified amended regulation IDs. Empty when neither key carries a value. |