Context
PR #64 renames the cipher_meta field to encrypted_meta in OpaquePointer (SPEC §7). The SPEC includes a compatibility note stating implementations SHOULD accept both names but MUST emit encrypted_meta going forward.
Request
Add a migration script to help users update existing JSON files containing OpaquePointer objects.
Suggested Implementation
# scripts/migrate_opaque_pointers.py
"""
Migrate OpaquePointer.cipher_meta → encrypted_meta in JSON files.
Usage: python scripts/migrate_opaque_pointers.py <path>
"""
import json, sys
from pathlib import Path
def migrate_pointer(obj):
if isinstance(obj, dict):
if obj.get('kind') == 'opaque' and 'cipher_meta' in obj:
obj['encrypted_meta'] = obj.pop('cipher_meta')
for v in obj.values():
migrate_pointer(v)
elif isinstance(obj, list):
for item in obj:
migrate_pointer(item)
if __name__ == '__main__':
path = Path(sys.argv[1])
data = json.loads(path.read_text())
migrate_pointer(data)
path.write_text(json.dumps(data, indent=2))
print(f"Migrated {path}")
References
Context
PR #64 renames the
cipher_metafield toencrypted_metainOpaquePointer(SPEC §7). The SPEC includes a compatibility note stating implementations SHOULD accept both names but MUST emitencrypted_metagoing forward.Request
Add a migration script to help users update existing JSON files containing
OpaquePointerobjects.Suggested Implementation
References