# Trace schema (version 1) The family's schema (z80-python `docs/trace-schema.md`) with the SPC700's units. A trace is the observable behaviour of a core written down one processor boundary at a time; two cores that produce equal traces for the same program and host are, as far as software can tell, the same CPU. Everything here is implemented by `src/spc700_python/trace.py`; if the two disagree, the code is the specification. JSON Lines: UTF-8, one object per line, `\n` terminated, blank lines ignored. This package writes sorted keys and no whitespace; readers must not depend on either. Records are aligned by line position when compared; `sequence` is informational. | Key | Type | Meaning | | --- | --- | --- | | `version` | integer | `1`. A reader rejects any other value. | | `sequence` | integer >= 0 | Producer-local counter. | | `kind` | string | `instruction` or `stop_idle` (below). | | `cycles` | integer > 0 | SPC700 cycles the boundary consumed, exactly as `step()` returns them. | | `instruction` | object or `null` | The instruction fetched; `null` for `stop_idle`. | | `before`, `after` | state object | Complete processor state at the boundary's start and end. | | `accesses` | array, optional | Every cycle in order, as `[kind, address, value, dummy]`. Absent means *not recorded*. | No other keys are allowed. ## `accesses` One entry per cycle, so `len(accesses) == cycles`. `kind` is `"read"`, `"write"` or `"internal"`. `address` is what the CPU drove and `value` the byte moved, both `null` for an internal cycle, which has no address (C1). `dummy` is `true` for a read whose value the CPU discards: the second cycle of a one-byte opcode and the read half of a store (U1, C2), which are still real bus reads. ## `kind` Decided from `before`: `stopped` -> `stop_idle` (one idle cycle), else `instruction`. ## `instruction` and state `instruction`: `address`, `data` (lowercase hex of every byte), and optionally `mnemonic` and `operands` (present together or absent together). **A producer in another language should omit both**; the reader decodes the bytes with this package's disassembler. State fields are those of `CPUState`: `a x y sp pc psw stopped`.