Skip to content

Add pup show index forensic command#49

Merged
typeless merged 1 commit into
mainfrom
feature/show-index
May 15, 2026
Merged

Add pup show index forensic command#49
typeless merged 1 commit into
mainfrom
feature/show-index

Conversation

@typeless

Copy link
Copy Markdown
Owner

Summary

Adds pup show index — a forensic command that dumps the on-disk .pup/index in a grep-friendly form. The intended use is to answer "did pup record this implicit-dep edge?" — the core diagnostic question for the transitive-dep tracking bug under investigation (see pup-header-detection-bug.md).

Usage

pup show index                  # full dump: per-command implicit/sticky edges
pup show index --summary        # counts only + "Commands with implicit/sticky deps: N/M"
pup show index PATTERN          # full dump filtered to commands whose command-string contains PATTERN

Example output:

[build] Index: /home/mural/src/pup/build/.pup/index
  Files:    832
  Commands: 101
  Edges:    39201 (Normal=352, Sticky=795, Implicit=38054)

Commands (with implicit/sticky edges):
  c2147483649  [test/unit]
       cmd: g++ -std=c++20 ... -MD -c .../catch_amalgamated.cpp -o ...
       implicit: third_party/catch_amalgamated.cpp
       implicit: /usr/include/stdc-predef.h
       ...
       sticky:   configs/Tupfile

Implementation

  • New cmd_export_index in src/cli/cmd_show.cpp dispatched from the existing show <format> mechanism. Joins script, compdb, graph, var, instructions as the sixth format.
  • Loads the index directly via discover_layout + read_index — does not parse Tupfiles. The forensic remains usable when the build graph is in a partially-broken state.
  • Extends options.cpp so show index PATTERN parses the positional argument into show_var_filter (same slot show var NAME uses).
  • Help text in print_usage() updated.

Test plan

  • New [e2e][show] SCENARIO (Show index dumps implicit-dep edges from the on-disk index) covers default output, --summary mode, and the positional filter
  • Manual smoke test against pup's own build/ directory: 832 files, 101 commands, 38054 implicit edges, all commands list their -MD-discovered headers
  • Full test suite: 462 cases, 23,644 assertions (one new SCENARIO, 22 new assertions)
  • make format clean

Once pup-header-detection-bug.md's reproducer is merged (PR #48), this command can be run on the broken state — e.g. pup show index PATTERN, look for newhdr.h in the implicit list — to confirm whether the dep was ever recorded.

🤖 Generated with Claude Code

Dumps the on-disk .pup/index in a grep-friendly form: file/command counts, per-edge-type totals, and a per-command listing of implicit and sticky deps. Used to diagnose whether a header's implicit-dep edge was ever recorded — the core forensic question for the transitive-dep tracking bug (see pup-header-detection-bug.md).

Usage:
  pup show index             - full dump (per-command implicit/sticky edges)
  pup show index --summary   - counts only, including how many commands have any implicit/sticky deps recorded
  pup show index PATTERN     - same as full dump but only commands whose command-string contains PATTERN

Loads the index directly via discover_layout + read_index, without parsing Tupfiles. Useful for forensics even when the build graph is in a partially-broken state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@typeless typeless merged commit 73684c5 into main May 15, 2026
9 checks passed
@typeless typeless deleted the feature/show-index branch May 15, 2026 06:25
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