(322150c) Make mv crash-safe by writing before renaming, and bump to 0.3.3
cmd_mv renamed the ticket into its new directory and only then wrote the updated content, so a write that failed left the ticket in the target directory still claiming the old status. Reproduced with a read-only ticket file: the move reported a bare "Permission denied" and left the file in committed/ carrying "Status: backlog". move_ticket_file now stages the content in a temp file, renames it over the source, and only then renames the file into the target directory. Two atomic steps, so a partial write is discarded and the original is untouched. The other obvious order, writing to the target and deleting the source afterwards, was rejected because it has the ticket in two directories at once. The worst case left is a ticket still in its old directory with a Status one move ahead, which the next mv corrects since the directory is what decides the current status. Tested, including the retry. The temp file is staged under .worklane/ rather than beside the ticket, so a leftover from a hard kill is invisible to ticket lookup and to the listing instead of appearing as a stray untitled ticket. IO errors now name the ticket and the path rather than propagating bare. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
f5204f6d8b
commit
e20396ce6b
@@ -62,6 +62,7 @@
|
||||
- Rules under headings are measured on the displayed name in characters, never on the raw line or in bytes
|
||||
- `resolve_ticket()` scans all status directories — it's the single source for ticket lookup by UUID prefix, title, or filename
|
||||
- `parse_ticket_field()` handles extracting metadata values from markdown format
|
||||
- `move_ticket_file()` stages the updated content in a temp file under `.worklane/`, renames it over the source, and only then renames the file into the target directory. Do not reorder these: renaming first and writing second leaves a ticket in its new directory claiming the old status, and writing to the target then deleting the source puts it in two directories at once. The temp lives outside the status directories so a leftover is never read as a ticket. A failure at the last step leaves the ticket in its old directory with a Status one move ahead, which the next `mv` corrects
|
||||
- Field lookup, read and write, is scoped to the lines under the `## Metadata` heading and anchored to the start of the line. Prose above it is free text: tickets in this repo quote field markers in their descriptions, and an unscoped search reads or rewrites those instead. `set_status_field()` carries the same scoping
|
||||
|
||||
### Ticket Resolution
|
||||
|
||||
Reference in New Issue
Block a user