Well, I can simply prevent the crashing if I leave the job hanging outside of joblist (it'd function exactly as it did before for whoever managed to get to it, just the jobs around it wouldn't have way back to it, but the designation is gone from the tile), but I imagine that would cause memory creep. Not much, but bad practice, that. However, no way to see which potential future third-party screens may want to access it.
However, seems like vanilla has some behaviour that resembles that, as I can still access the job struct after it is erased with d-x. With some interesting changes:
value before after
id 11544 -511203432
posting_index -1 -239520752
job_type 2 0
job_subtype -1 4
completion_timer 26 37
unk4 1076101120 3705166224
mat_type -1 0
mat_index -1 4
item_type -1 0
item_subtype -1 -19396
hist_figure_id -1 37
job.flags consistent differences, across 5 different jobs (to cull garbage data)
17 TRUE FALSE
Most of this comes across as garbage data, though - ex, the historical figure of the worker was 40959, and there's infinite specific refs. Though matching the garbage data shouldn't hurt and matching the cleanup ones should be helpful. Anyway, job.flags[17] might be something like "active"?
Are there actually any general refs that are not workers or buildings? I notice logic for cancelling for those, but no handling of anything else, which implies there could be but presently aren't any known.
However, it seems the the safest option would be to save the designations I don't want to erase, let vanilla d-x do its thing, then replace them. Makes those with jobs on 'unerased' designations lose their job (e: but not engraving images?!) but
should be safe otherwise.
Edit:
Noticed that dfhack has unnamed flags for carve track jobs (that should be named):
job.item_category: 18/19/20/21 true/false values correspond to carve_track_north/south/east/west. Tested and successfully altered track carving jobs with this.