Skip to content

Step 9 cleanup shells out to rm / find -delete, which permission-gated hosts deny — stale .graphify_chunk_*.json survives into the next --update #2790

Description

@cdtatarevich

Environment

  • graphifyy 0.9.39, macOS 15, Claude Code host with tool-permission gating

What happens

Step 9's cleanup is the only part of the pipeline that shells out instead of using Python:

rm -f graphify-out/.graphify_detect.json graphify-out/.graphify_extract.json ...
find graphify-out -maxdepth 1 -name '.graphify_chunk_*.json' -delete 2>/dev/null
rm -f graphify-out/.needs_update 2>/dev/null || true

In a host where the agent's shell commands are permission-gated, rm and find -delete are commonly not on the allowlist — destructive filesystem verbs are exactly what such policies withhold. Both calls were denied in my run, the pipeline had no fallback, and the intermediates stayed on disk:

1.5M  .graphify_extract.json
1.4M  .graphify_ast.json
 87K  .graphify_analysis.json
 74K  .graphify_semantic.json
 74K  .graphify_semantic_new.json
 63K  .graphify_chunk_01.json
 10K  .graphify_detect.json

~3 MB of intermediates per run, and .graphify_semantic_new.json / .graphify_chunk_*.json are exactly the files Step B3 and Part C read unconditionally — so a later --update can merge a stale chunk from a previous run rather than a fresh one.

Why this variant is new

Closed #1172 (fish/zsh glob on pure-code corpora) and closed #464 (Codex/Windows leftovers) are the same symptom from shell-dialect causes. This one is a permission policy, so it reproduces on any host that gates destructive shell verbs regardless of platform or shell — and unlike a glob mismatch, retrying or changing shell does not help.

Suggested fix

Do the cleanup in Python like every other step, e.g. Path.unlink(missing_ok=True) in a loop plus Path.glob('.graphify_chunk_*.json'). That removes the shell dependency entirely, works identically on Windows/POSIX, and sidesteps all three reported causes at once. If the shell form is kept for any reason, at minimum the pipeline should verify the files are gone and warn rather than assume success, since a surviving .graphify_chunk_*.json is a correctness risk, not just clutter.

Activity

  1. jvzelst-tech commented on Sep 23, 2026

    @jvzelst-tech

    A fourth cause of this exact symptom, which the suggested fix would not cover: the run never reaches Step 9 at all.

    The three causes on record so far — shell-dialect globbing (#1172), Codex/Windows leftovers (#464), and permission gating (this issue) — are all "cleanup ran and didn't delete the files". There is a fourth: cleanup never runs. A failed subagent, an interrupted session, or any error between extraction and report generation leaves the run dead upstream of Step 9, and its chunk files stay on disk exactly as described here.

    That matters for the fix proposed above. Moving the cleanup into Python (Path.unlink(missing_ok=True) + Path.glob) genuinely fixes the shell-dialect and permission-gating causes, and it is the right change on its own merits — but it cannot fix this one, because no implementation of Step 9 helps when Step 9 is never reached.

    Measured

    Found 2026-09-23 on a markdown-only corpus (~340 files, 245 documents in the graph). A --update dispatched 3 semantic subagents; the Step B3 merge reported 4 chunks, 384 nodes.

    The extra was .graphify_chunk_31.json, dated 13 days earlier — from a run that died before cleanup. It carried 81 nodes and 118 edges for a document that had been edited in the interim and that the current run had just re-extracted. Merging both would have put two generations of the same document into one graph, with the stale copy arbitrarily winning any id collision.

    Why it stays silent

    Step B3 merges whatever the glob returns:

    chunks = sorted(glob.glob('graphify-out/.graphify_chunk_*.json'))

    Nothing validates that set against what was actually dispatched, and the summary line prints the glob's own count — so Merged 4 chunks reads as success. It is caught only if someone remembers how many subagents they launched and checks the arithmetic, and both numbers are plausible either way. A stale chunk covering a file the current run did not touch produces no anomaly at all — it simply contributes silently to the graph.

    This is the same shape as #3093: a bookkeeping artifact is trusted as evidence of what the run did, and the indicator reads identically whether or not it did it.

    Suggested addition

    Clear the chunks at the start of the merge path as well as the end — i.e. in Step B0, before any subagent is dispatched:

    for p in Path('graphify-out').glob('.graphify_chunk_*.json'):
        p.unlink(missing_ok=True)

    This is strictly stronger than end-only cleanup, because it is the reader protecting itself rather than the writer promising to tidy up: it holds regardless of why the previous run's files are still there — dialect, permissions, crash, or a cause nobody has reported yet. Combined with doing it in Python as suggested above, all four known causes are covered.

    Optionally, passing the expected chunk count into the merge and failing loudly when the glob returns a different number would convert the remaining silent cases into a message naming the unexpected files.

    Still present at HEAD

    Checked graphify/skill.md at HEAD today (the observation above is from 0.7.15): Step B0 still has no clearing step, Step B3 still merges the unvalidated glob, and the chunk deletion at the end of Step 9 is still the only place the files are removed.

    Environment: graphifyy 0.7.15 · Python 3.13 · macOS · markdown-only corpus, no code files.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions