.mini FORMAT — family 'a' v1 (Assessment items (multiple choice, Bloom + IRT 3PL + CAT metadata))
One multiple-choice assessment item per line, as generated by SIMA from a lecture transcript. The selected option is the correct answer; IRT parameters feed a computerized adaptive test.
Rules:
- Plain UTF-8 text. The FIRST line is the header: 'a|n=<int>, m=<str>?, d=<str>?, l=<str>?, t=<str>?, bd=<list>?, cat=<tuple>?, k=<int>?'. n is mandatory and must equal the exact number of record lines.
- After the header, ONE line per record and nothing else (no comments, no code fences, no blank lines in between).
- Each record has these fields in THIS order, separated by '|' (position is the semantics; field names are never written):
  1. id: str — item identifier
  2. bloom: one of {L1|L2|L3|L4|L5|L6}
  3. topic: str
  4. statement: str — question stem
  5. options: ','-separated list of str, 2 to 6 elements; exactly one element carries the suffix * (selected)
  6. irt: fixed tuple 'a:float,b:float,c:float' separated by ','
  7. difficulty: int [1..5]
  8. cat: fixed tuple 'area:str,exposure_cap:float,demand:enum' separated by ','
- If a list element contains the separator ',', enclose the element in double quotes CSV-style ("impact, justice and evidence"; the * marker goes after the closing quote) or escape the separator as '\,'. A literal trailing asterisk is written '\*'.
- Escapes valid in any value: '\|' for a literal vertical bar, '\\' for a backslash, '\n' for a line break.
- Numbers unquoted; booleans true/false. Scalar fields are never quoted.
- An empty field means null (allowed only for optional fields).
- Record: 8 core fields.

TASK: write a deterministic Python parser for family 'a'. It must: validate the header and n; validate the arity of every record; process lists, tuples and the * marker; apply the escapes; and return the canonical JSON object shaped {'prefix', 'header', 'items': [records]} where each record is an object keyed by the field names above; a marked list is returned as two sibling keys of the record: the element list and the selected index (or indices), named as the contract states (e.g. 'options' and 'correct'). When the marker rule is exactly_one/at_most_one the selected value is a single 0-based index (or null); when it is at_least_one/any it is always a list of ascending 0-based indices, even when only one element is marked.
Reject any invalid document with an exception that reports the line. No external libraries.

--- fixture: valid.mini ---
a|n=12|m=IRT3PL|d=20260603|l=es|t=evaluación transversal|bd=1,1,1,1,1,1|cat=0,-3,3,0.3,12,SH|k=4
i1|L1|Biología|¿Dónde ocurre principalmente la fotosíntesis?|cloroplastos*,núcleo,mitocondria,ribosoma|0.9,-1,0.25|1|biología,0.2,low
i2|L2|Química|¿Qué representa el pH de una solución?|acidez o basicidad*,masa molecular,temperatura,presión osmótica|1.1,-0.3,0.25|2|química,0.2,medium
i3|L3|Matemática|Si 3x+6=18, ¿cuál es el valor de x?|4*,6,8,12|1.4,0.2,0.2|3|matemática,0.25,medium
i4|L4|Historia|¿Qué factor explica mejor la caída del Imperio romano de Occidente?|presiones militares y crisis internas*,un solo terremoto,la invención de la imprenta,la conquista española|1.7,0.8,0.2|4|historia,0.18,high
i5|L5|Literatura|Evalúa cuál opción interpreta mejor un narrador no confiable.|su relato debe contrastarse con evidencias*,siempre dice la verdad,solo narra en tercera persona,no participa en la trama|2,1.2,0.15|5|literatura,0.15,high
i6|L6|Computación|¿Qué solución diseñarías para reducir errores en una API?|validación de esquema y pruebas automatizadas*,eliminar logs,usar variables globales,evitar documentación|2.3,1.7,0.15|5|computación,0.15,high
i7|L1|Física|¿Cuál es la unidad de fuerza en el SI?|newton*,joule,watt,pascal|0.9,-1.2,0.25|1|física,0.2,low
i8|L2|Geografía|¿Qué describe una cuenca hidrográfica?|territorio drenado por un río*,altura de una montaña,tipo de clima,frontera política|1.1,-0.2,0.25|2|geografía,0.22,medium
i9|L3|Comunicación|Elige el conector que completa una relación de causa.|porque*,sin embargo,además,por ejemplo|1.4,0.1,0.2|3|comunicación,0.25,medium
i10|L4|Economía|Analiza qué sucede si sube el precio y baja la demanda.|disminuye la cantidad demandada*,sube la oferta siempre,desaparece el mercado,no cambia el equilibrio|1.7,0.7,0.2|4|economía,0.18,high
i11|L5|Ética|¿Qué criterio permite evaluar mejor una decisión pública?|impacto\, justicia y evidencia*,popularidad inmediata,costo únicamente,autoridad del emisor|2,1.3,0.15|5|ética,0.15,high
i12|L6|Arte|Propón el principio clave para crear una campaña visual coherente.|unidad entre mensaje\, color y audiencia*,usar todos los colores,copiar una plantilla,evitar bocetos|2.3,1.8,0.15|5|arte,0.15,high


--- fixture: escaping.mini ---
a|n=1|m=IRT3PL|d=20260603|l=es|t=evaluación transversal|bd=1,1,1,1,1,1|cat=0,-3,3,0.3,12,SH|k=4
i1|L1|pipe \| and back\\slash, comma, "quotes", star* and newline\nend|¿Dónde ocurre principalmente la fotosíntesis?|a\, b \| c \\ d\**,núcleo,mitocondria,ribosoma|0.9,-1,0.25|1|biología,0.2,low


Deliver a single Python 3 file defining `def parse(text: str) -> dict` (raise ValueError on invalid input, mentioning the line number). No third-party imports. Do not include tests or a main block. OUTPUT: only the Python code, no markdown fences, no explanations.