Skip to content

create-issue: write run artifacts into per-run sub-directories under .prflow/tmp/ and clean up at end of run #1811

Description

@The01Geek

Problem Statement

The create-issue command writes every run artifact as a flat file directly under .prflow/tmp/ and never removes any of them. One run's working set is scattered across a directory shared with every other producer (suite shards, telemetry staging, workpad buffers, verification flights), and the directory only grows — measured at 137 MB / 1,840 entries in one checkout, 1,323 of them create-issue issue-* files dating back six weeks.

Current Behavior

Artifacts are separated only by a <slug> embedded in each filename (issue-draft-<slug>.*.staged.md, issue-audit-<slug>.md, issue-audit-state-<slug>.json, issue-body-<slug>.md, issue-fetched-<slug>.md, …), all flat under .prflow/tmp/. No step of the run deletes anything, so completed runs leave their whole working set behind indefinitely. This happens regardless of environment.

Desired Behavior

Each create-issue run writes its artifacts into its own sub-directory .prflow/tmp/create-issue/<slug>/. A run that completes successfully (issue created and reported) removes its own run directory as its final step; a run that ends any other way leaves the directory in place as its diagnostic record. Cleanup targets only the run's own recorded directory handle, never a pattern or age sweep, so concurrent runs in sibling worktrees are untouched.

User Impact

Whoever runs create-issue in this repository stops accumulating unbounded scratch files, and a failed run's evidence remains findable in one directory instead of interleaved with a thousand strangers.

Technical Context

Scope note: The files and details below are the known starting points, not the full list. Before implementing, trace the change through the codebase to find every affected call site, consumer, and layer — this issue maps the work, it does not bound it.

  • Relevant Classes/Files — skills/create-issue/SKILL.md and skills/create-issue/references/*.md compose the artifact paths; scripts/issue-audit-state.py owns the audit-state file path; skills/create-issue/references/audit-prompt-template.md enumerates exact out-of-bounds paths under .prflow/tmp/ that must move with the artifacts.
  • Architecture Alignment — .prflow/tmp/ stays the scratch root; this adds one namespaced level under it. The scaffolded .prflow/.gitignore already ignores tmp/ wholesale, so sub-directories need no gitignore change.
  • Dependencies — none beyond the guaranteed toolset.
  • Data/Schema Considerations — the audit-state JSON and staged-draft history keep their formats; only their directory changes.
  • Cross-layer Impact — create-issue skill prose, its references, and scripts/issue-audit-state.py. Other commands' .prflow/tmp/ usage is untouched.

The durable record of a successful run is the created issue plus its investigation-record comment, so deleting the run directory on success destroys no citable evidence; the retained-on-failure arm preserves the audit lifecycle and staged canonical-draft history exactly when they are still needed.

Acceptance Criteria

  • A create-issue run writes every artifact it produces (drafts, staged history, audit files, audit state, emitted body, fetched copies, derivation artifact) under .prflow/tmp/create-issue/<slug>/ and none as a flat file directly under .prflow/tmp/.
  • A run that completes successfully leaves no files of its own under .prflow/tmp/ after it reports the created issue URL.
  • A run that ends without creating the issue leaves its run directory and contents in place.
  • Cleanup removes only the directory the run itself recorded creating; artifacts belonging to any other slug or producer are untouched.
  • Every path literal in skills/create-issue/references/audit-prompt-template.md's out-of-bounds enumerations names the new per-run location, and lib/test/modules/create-issue-contract.sh passes.
  • Pre-existing flat issue-* files under .prflow/tmp/ are left in place by this change.

Implementation Notes

  • Approach — introduce the per-run directory at the point the slug is first derived, thread it through every path composition, and add a final delete-on-success step keyed to that recorded handle. Backfill of the ~1,300 existing flat artifacts is out of scope; a human sweeps them once by hand.
  • Relevant files — this likely touches skills/create-issue/SKILL.md, the references/*.md files that compose artifact paths (step-4-present-create.md, audit-prompt-template.md, issue-template.md's posting block), and scripts/issue-audit-state.py; plausibly lib/test/modules/create-issue-contract.sh fixtures.
  • Code Patterns — mirror the parallel coordinator's run-root convention (.prflow/tmp/parallel-suite/run-<pid>-<n>), which already namespaces per-run scratch under .prflow/tmp/ and reaps by its own recorded handle.
  • Testing Strategy — lib/test/modules/create-issue-contract.sh covers the coupled path enumerations; a focused case drives scripts/issue-audit-state.py with the new state-file location and asserts it reads and writes there. One residual-risk case: a cleanup invoked with an empty or unset directory handle deletes nothing and exits non-destructively.
  • Documentation Needed — none. The artifact layout is internal scratch; the coupled prose that names paths is updated as part of the change itself.
  • Potential Gotchas — the audit prompt template enumerates exact .prflow/tmp/ paths in two places and skills/create-issue/** plus scripts/issue-audit-state.py compose them independently: this is a coupled edit across all of them, not a one-line change. Editing skills/** bodies goes through the writing-skills discipline with a Writing-skills evidence: marker. The Write tool refuses main-root paths from a worktree, so path composition must keep resolving through resolve-main-root.sh as today.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions