|
| 1 | +# The NDI Bridge Protocol: YAML Specification |
| 2 | + |
| 3 | +# ============================================================================= |
| 4 | +# 1. File Purpose & Placement |
| 5 | +# ============================================================================= |
| 6 | +# Name: ndi_matlab_python_bridge.yaml |
| 7 | +# Location: One file per sub-package directory |
| 8 | +# (e.g., src/ndi/session/ndi_matlab_python_bridge.yaml). |
| 9 | +# Role: This is the Primary Contract. It defines how MATLAB names and types |
| 10 | +# map to Python. If a function is not here, it does not officially |
| 11 | +# exist in the Python port. |
| 12 | + |
| 13 | +# ============================================================================= |
| 14 | +# 2. Standard Header |
| 15 | +# ============================================================================= |
| 16 | +# Every bridge file must begin with this metadata to orient the agent: |
| 17 | + |
| 18 | +project_metadata: |
| 19 | + bridge_version: "1.1" |
| 20 | + naming_policy: "Strict MATLAB Mirror" |
| 21 | + indexing_policy: "Semantic Parity (1-based for user concepts, 0-based for internal data)" |
| 22 | + |
| 23 | +# ============================================================================= |
| 24 | +# 3. The "Active Maintenance" Instruction |
| 25 | +# ============================================================================= |
| 26 | +# When an agent or developer works on a function: |
| 27 | +# |
| 28 | +# 1. Check: Does the function/class exist in the YAML? |
| 29 | +# 2. Add/Update: If it is missing or the MATLAB signature has changed, |
| 30 | +# update the YAML first. |
| 31 | +# 3. Notify: The agent MUST explicitly tell the user: |
| 32 | +# "I have updated the ndi_matlab_python_bridge.yaml to include |
| 33 | +# [Function Name]. Please review the interface contract." |
| 34 | + |
| 35 | +# ============================================================================= |
| 36 | +# 4. Structure for Classes and Functions |
| 37 | +# ============================================================================= |
| 38 | + |
| 39 | +# --- Example: Class --- |
| 40 | +# - name: NDI_Session # Exact MATLAB Name |
| 41 | +# type: class |
| 42 | +# matlab_path: "+ndi/Session.m" |
| 43 | +# python_path: "ndi/session.py" |
| 44 | +# |
| 45 | +# properties: |
| 46 | +# - name: reference |
| 47 | +# type_matlab: "char" |
| 48 | +# type_python: "str" |
| 49 | +# decision_log: "Mirroring property name exactly." |
| 50 | +# |
| 51 | +# methods: |
| 52 | +# - name: get_epoch_data |
| 53 | +# input_arguments: |
| 54 | +# - name: epoch_id |
| 55 | +# type_python: "int" |
| 56 | +# decision_log: "Semantic Parity: User provides 1-based ID." |
| 57 | + |
| 58 | +# --- Example: Standalone Function --- |
| 59 | +# - name: ListAllDocuments |
| 60 | +# type: function |
| 61 | +# matlab_path: "+ndi/+cloud/ListAllDocuments.m" |
| 62 | +# python_path: "ndi/cloud/ListAllDocuments.py" |
| 63 | +# input_arguments: |
| 64 | +# - name: DatasetID |
| 65 | +# type_matlab: "string | numeric" |
| 66 | +# type_python: "str | int" |
| 67 | +# output_arguments: |
| 68 | +# - name: docs |
| 69 | +# type_matlab: "struct array" |
| 70 | +# type_python: "list[dict]" |
| 71 | +# decision_log: "Python returns a list of dictionaries to mimic MATLAB struct arrays." |
| 72 | + |
| 73 | +# ============================================================================= |
| 74 | +# 5. Summary of Field Rules |
| 75 | +# ============================================================================= |
| 76 | +# Field | Rule |
| 77 | +# ------------------|---------------------------------------------------------- |
| 78 | +# name | Strict Match. Case-sensitive match to the MATLAB .m file. |
| 79 | +# input_arguments | Used to generate Pydantic @validate_call. |
| 80 | +# output_arguments | Defines the order of the Return Tuple. |
| 81 | +# type_python | Use Python 3.10+ syntax (e.g., str | int). |
| 82 | +# decision_log | Mandatory for any divergence (e.g., "Shifted to |
| 83 | +# | 0-indexing for internal array access"). |
0 commit comments