Skip to content

watch: --semantic runs LLM extraction automatically when doc/paper/image files change - #3

Merged
Azeem1985 merged 2 commits into
v8from
feat/watch-semantic
Aug 24, 2026
Merged

Azeem1985 merged 2 commits into
v8from
feat/watch-semantic

Conversation

@Azeem1985

Copy link
Copy Markdown

What: graphify watch --semantic runs a real LLM-backed graphify extract (as a subprocess) when non-code files change, instead of only writing the needs_update flag and waiting for someone to notice. --backend and --fallback-backend are forwarded to that extract; using them without --semantic is 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-backend flag 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 existing tests/test_watch.py (126 tests) stay green. All offline; the extract subprocess is mocked.

🤖 Generated with Claude Code

…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]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread graphify/watch.py
except OSError as exc:
print(f"[graphify watch] Semantic extraction failed to start: {exc}")
return False
if rc != 0:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread graphify/watch.py
Comment on lines +1942 to +1943
if fallback_backend:
cmd += ["--fallback-backend", fallback_backend]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@Azeem1985
Azeem1985 merged commit 7f13af8 into v8 Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant