Skip to content

Hook rebuild ignores --code-only scope: code-only graph becomes full graph #4923

Closed

Description

@stoneskin

Summary

When a graph is built with --code-only, the git hooks installed by
graphify hook install rebuild it as a full graph (code + docs)
on the next commit / branch switch. The rebuild does not preserve the
scope the graph was originally built with.

Repro

  1. graphify extract . --code-only — code-only graph (in my repo: 675
    nodes, 1356 edges, 20 communities; 70 code files, 335 docs skipped).
  2. graphify hook install (installs post-commit / post-checkout /
    post-merge / post-rewrite).
  3. Make a commit (or switch branches).
  4. The hook rebuilds the graph — it now includes docs: 2325 nodes,
    2701 edges, 364 communities (403 files extracted, including 333 docs).

Expected

A rebuild should preserve the scope the graph was built with. A
code-only graph should stay code-only across hook-triggered rebuilds
(unless the user explicitly changes the scope).

Actual

_rebuild_code has no code-only parameter. When called without
changed_paths (post-checkout / post-merge / post-rewrite do a full
rebuild), it extracts every file it can parse — code and docs alike.
The original --code-only flag is silently dropped. There is also no
record of the extraction scope in the graph metadata (e.g.
graphify-out/.graphify_analysis.json / manifest.json), so the
rebuild has no way to know the graph was code-only.

Suggested fix

Record the extraction scope (e.g. code_only: true) in the graph
metadata at extract time, and have _rebuild_code respect it (or
accept a code_only parameter that the hooks pass through).
Alternatively, add a --code-only flag to the hook install / a
code_only key in .graphifyrc.

Environment

  • graphify 0.9.99 (via uv tool install graphifyy)
  • Python 3.12, Linux
  • No LLM API key configured (AST-only extraction)

Related observations

  • The CLI and the hook disagree about docs without an API key:
    graphify extract . (no --code-only, no key) refuses with "no LLM
    API key found (335 doc/paper/image file(s) need semantic extraction)",
    while the hook's _rebuild_code extracts docs via AST with no key. A
    --ast-only CLI mode (full extraction, no LLM) would match the hook's
    behavior.
  • graphify-out/manifest.json changes on every rebuild (mtime/seen
    timestamps) even when the graph topology is unchanged, which dirties
    the working tree for repos that commit the graph. It would help if the
    manifest were stable when nothing meaningful changed.

Activity

  1. github-actions commented on Nov 1, 2026

    @github-actions

    Thanks for opening this issue, @stoneskin. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. safishamsi commented on Nov 2, 2026

    @safishamsi
    Member

    Fixed in 0.9.101 (published to PyPI) via #4939. A --code-only graph now stays code-only across hook, update and watch rebuilds; the scope is recorded in .graphify_build.json.

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