AI-2146: fix stale notes.md and silent permission errors in init_task_record.py#7
Draft
RachelXiaolan wants to merge 1 commit into
Draft
AI-2146: fix stale notes.md and silent permission errors in init_task_record.py#7RachelXiaolan wants to merge 1 commit into
RachelXiaolan wants to merge 1 commit into
Conversation
…task_record.py The old init_task_record.py would silently partial-overwrite a task folder: - task.json was always rewritten with the new title/repo/branch - notes.md was preserved if it existed, leaving '## Scope' referencing the previous issue's context while the new run's metadata sat next to it. It also crashed with a raw PermissionError traceback when --root pointed at a read-only directory. Changes: - Refuse to create a task artifact in an existing folder unless --force is passed (with a clear error message and exit code 2). - --force rewrites both task.json and notes.md atomically (folder reused). - PermissionError and other OSErrors during mkdir are caught and turned into a clean non-zero exit with an actionable message. - Add tests/test_init_task_record.py covering: first-run creation, repeat-run refusal, --force refresh, and permission-error handling.
Owner
Author
|
🔗 Synced from Linear
🤖 Codex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
scripts/init_task_record.pyhad two related footguns when run twice on the same issue id (or when--rootpointed at a read-only directory):--title/--repo/--branchwould rewritetask.jsonwhile preservingnotes.mdfrom the previous issue. The result was a folder whosetask.json(title, repo, branch) andnotes.md(Scope, Progress, Links) disagreed about which Linear issue they belonged to.Path.mkdir(parents=True, exist_ok=True)swallowsFileExistsErrorbut letsPermissionErrorpropagate as a raw traceback, with no actionable hint and a partial folder left behind.Changes
--forceis passed (exit code 2, clear stderr message).--forcereuses the folder and rewrites bothtask.jsonandnotes.mdatomically so they always describe the same issue.PermissionError/ genericOSErrorfrommkdirare caught and turned into a clean non-zero exit with an actionable message; no partial folders are left behind.Tests
tests/test_init_task_record.pycovers:task.jsonandnotes.md.--forcerefresh: both files rewritten atomically.Linear
Tracked under AI-2146 (parent AI-2145). No code behavior change for the existing happy path — only the failure / repeat-run cases are tightened.