Scalars and lists of scalars of record are top-level keys and come first; each mapping becomes a [table]; each non-empty list of mappings becomes an array of tables [[name]]. Every key of record is written or the call raises: nothing is dropped. Keys that are not bare-key safe are quoted. The text is parsed again with tomllib and must give back record, and the file is replaced atomically, so a failure leaves neither a run.toml nor a temporary file behind (an existing one stays as it was). The file has mode 0644.