I added the plugin tweak to use your new MOBI writer code and trying to use debug on the resulting file gets me this
Code:
C:\Users\Nick\Calibre-Kindle\News-Files>calibre-debug --inspect-mobi nytcalibre2.mobi
Python function terminated unexpectedly
'MOBIFile' object has no attribute 'secondary_index_header' (Error Code: 1)
Traceback (most recent call last):
File "site.py", line 132, in main
File "site.py", line 109, in run_entry_point
File "C:\Users\Nick\calibre\src\calibre\debug.py", line 236, in main
inspect_mobi(opts.inspect_mobi)
File "C:\Users\Nick\calibre\src\calibre\ebooks\mobi\debug.py", line 1456, in inspect_mobi
if f.secondary_index_header is not None:
AttributeError: 'MOBIFile' object has no attribute 'secondary_index_header'