Repository navigation
watch: --semantic runs LLM extraction automatically when doc/paper/image files change - #3
Conversation
…doc changes Instead of only writing the needs_update flag, `graphify watch --semantic` runs `graphify extract` on the watched root when a debounced batch contains surviving non-code files. The extract runs as a subprocess on purpose: fcntl.flock is held per open file description, so in-process re-entry of _rebuild_lock would self-deadlock, while a child process serializes cleanly on graphify-out/.rebuild.lock against hook-driven rebuilds. A failed extract falls back to _notify_only so the user never loses the flag + /graphify --update instruction; a successful run clears the flag (extract itself never touches it — only _rebuild_code does). --backend and --fallback-backend are forwarded to the extract subprocess and rejected without --semantic rather than being a silent no-op. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83e12ef1be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| except OSError as exc: | ||
| print(f"[graphify watch] Semantic extraction failed to start: {exc}") | ||
| return False | ||
| if rc != 0: |
There was a problem hiding this comment.
Preserve the update flag after partial semantic extraction
When a multi-chunk extraction has at least one successful chunk and another failed or partial chunk, graphify extract can mark the extraction incomplete yet still exit 0 if its shrink guard accepts the resulting graph; the affected files are merely left unstamped for a future run. This return-code-only check consequently reports success and removes needs_update, leaving a partial graph with neither an automatic retry nor a manual-update prompt until another filesystem event occurs. Require strict extraction success or verify that all changed semantic files were stamped before clearing the flag.
Useful? React with 👍 / 👎.
| if fallback_backend: | ||
| cmd += ["--fallback-backend", fallback_backend] |
There was a problem hiding this comment.
Implement the fallback instead of forwarding an ignored option
For graphify watch --semantic --backend gemini --fallback-backend ollama, this appends --fallback-backend to the child command, but the extract argument parser has no branch for that option and silently skips unknown arguments at graphify/cli.py:3089-3090. The fallback is therefore never selected when the primary backend fails, so the advertised option has no effect and the watcher falls back directly to the manual-update flag.
Useful? React with 👍 / 👎.
# Conflicts: # CHANGELOG.md
What:
graphify watch --semanticruns a real LLM-backedgraphify extract(as a subprocess) when non-code files change, instead of only writing theneeds_updateflag and waiting for someone to notice.--backendand--fallback-backendare forwarded to that extract; using them without--semanticis rejected instead of silently ignored. A successful run clears the stale flag; a failed run falls back to the old flag + instruction behavior.Why: doc/paper/image changes were second-class in watch — the graph went stale until a manual update.
Merge-order dependency — this PR requires #1 and #2 merged first, in that order: the subprocess design assumes extract takes the rebuild lock itself (from #1 — in-process re-entry would self-deadlock on
flock), and the forwarded--fallback-backendflag only exists on extract's parser once #2 is in. Merged alone, watch would forward a flag extract rejects.Tests:
tests/test_watch_semantic.py(13 tests) plus the existingtests/test_watch.py(126 tests) stay green. All offline; the extract subprocess is mocked.🤖 Generated with Claude Code