Skip to content

Resync Rust port to graphify-py v0.8.22 (43bf3c2)#14

Merged
rblaine95 merged 7 commits into
masterfrom
resync/graphify-py/43bf3c2
May 29, 2026
Merged

Resync Rust port to graphify-py v0.8.22 (43bf3c2)#14
rblaine95 merged 7 commits into
masterfrom
resync/graphify-py/43bf3c2

Conversation

@rblaine95

@rblaine95 rblaine95 commented May 29, 2026

Copy link
Copy Markdown
Member

Ports the applicable graphify-py v0.8.21..v0.8.22 (43bf3c2) changes into the Rust workspace. Submodule pointer and workspace version both advance to 0.8.22.

Ported

  • BYOND DreamMaker support — new extract_dm / extract_dmi / extract_dmm / extract_dmf extractors (graphify-extract/src/extractors/dm.rs) covering tree-sitter .dm/.dme source, .dmi icon sheets, .dmm maps, and .dmf interface forms; wired into the extension dispatch. Adds the tree-sitter-dm and flate2 deps. .dmi zTXt decompression is capped at 1 MiB (the upstream decompression-bomb guard).
  • graphify-detect — register .dm/.dme/.dmi/.dmm/.dmf as code extensions, and stop applying ignore patterns to files under graphify-out/memory so a broad .gitignore rule can't erase generated memory notes (#1047).
  • graphify-extract — treat Python decorated_definition as a transparent wrapper so @property/@staticmethod/@classmethod methods keep their class-qualified node id and their docstring rationale edge resolves (#1050). Edge gains an external flag for unresolved includes.
  • graphify-dedup — mirror Pass 1's source_file partition for identical labels in Pass 2 fuzzy matching (#1046).
  • graphify-export — remap hyperedges from semantic node ids to community ids when rendering the aggregated community meta-graph (#1006).
  • graphify-llm + extract CLI — add --mode deep, which appends a deep-extraction instruction to the LLM system prompt for richer INFERRED architectural edges. Threaded through every backend and the corpus fan-out.

Also updates README.md / USAGE.md (supported formats, the --mode flag, edge vocabulary).

Notes / divergences

  • The #1046 Pass-2 guard is ported verbatim per maintainer direction, but is unreachable given the unique-by-norm candidate set, so its continue branch reads as uncovered in llvm-cov. An observable-contract test asserts identical-label/different-file nodes stay unmerged.
  • .dmi zTXt decompression degrades gracefully on a corrupt stream (keeps what decompressed cleanly) rather than aborting the extraction, an intentional improvement over the Python reference.
  • Pre-existing gap (not in this delta): graphify-py/tests/test_rationale.py has 13 tests; only the new v0.8.22 decorated-method case is ported (tests/parity_rationale.rs).

Verification

  • cargo fmt, cargo clippy --all-targets --all-features --workspace, hk check — clean.
  • cargo nextest run --workspace — 1501 passed, 2 skipped (network).
  • New dm.rs coverage: 94.85% region / 93.40% line (cargo llvm-cov nextest -p graphify-extract).
  • CodeRabbit final review: findings: 0.

Summary by CodeRabbit

  • New Features

    • Added BYOND DreamMaker file support (.dm/.dme/.dmi/.dmm/.dmf)
    • Added --mode deep for more aggressive semantic extraction
  • Bug Fixes

    • Prevented merging of identically‑labeled items from different files
    • Always include generated notes under graphify-out/memory (ignore filters bypassed)
    • Aggregated HTML views now preserve and show hyperedges
  • Documentation

    • Updated README and USAGE with BYOND and deep‑mode details
  • Tests

    • Added BYOND and deep‑mode parity/regression tests
  • Chore

    • Workspace version bumped to 0.8.22

Review Change Stack

rblaine95 added 4 commits May 29, 2026 08:28
Routine `cargo update` refresh of transitively pinned crates ahead of
the graphify-py v0.8.22 resync. Picks up patch and minor bumps for
`jiff`, the `aws-sdk-*` family, `mio`, `socket2`, `zerocopy`, and
`cmov`, and pulls in `arc-swap` as a new transitive dependency. No
direct dependency declarations changed.

Glory to the Omnissiah
Port the applicable v0.8.21..v0.8.22 changes from the `graphify-py`
submodule into the Rust workspace.

Ports:

- BYOND DreamMaker support: new `extract_dm`/`extract_dmi`/`extract_dmm`/
  `extract_dmf` extractors in `graphify-extract` (tree-sitter `.dm`/`.dme`
  source plus `.dmi` icon sheets, `.dmm` maps, `.dmf` interface forms),
  wired through the extension dispatch. Adds the `tree-sitter-dm` and
  `flate2` dependencies. `.dmi` zTXt decompression is capped at 1 MiB
  (the upstream decompression-bomb guard).
- `graphify-detect`: register `.dm`/`.dme`/`.dmi`/`.dmm`/`.dmf` as code
  extensions, and stop applying ignore patterns to files under
  `graphify-out/memory` so a broad `.gitignore` rule cannot erase
  generated memory notes (#1047).
- `graphify-extract`: treat Python `decorated_definition` as a transparent
  wrapper so `@property`/`@staticmethod`/`@classmethod` methods keep their
  class-qualified node id and their docstring rationale edge resolves
  (#1050). `Edge` gains an `external` flag for unresolved includes.
- `graphify-dedup`: mirror Pass 1's `source_file` partition for identical
  labels in Pass 2 fuzzy matching (#1046).
- `graphify-export`: remap hyperedges from semantic node ids to community
  ids when rendering the aggregated community meta-graph (#1006).
- `graphify-llm` and the `extract` CLI: add `--mode deep`, which appends a
  deep-extraction instruction to the LLM system prompt for richer INFERRED
  architectural edges. Threaded through every backend and the corpus
  fan-out.

Also bumps the workspace version to 0.8.22 and updates `README.md` and
`USAGE.md` (supported formats, the `--mode` flag, edge vocabulary).

Glory to the Omnissiah
- Use `.expect()` with descriptive messages on the four `.dm`/`.dmm`/`.dmf`
  static `LazyLock<Regex>` initializers instead of `.unwrap()`, matching the
  established `ids.rs` convention so a malformed literal surfaces a clear
  message. Swap the `#[allow]` to `clippy::expect_used` accordingly.
- De-duplicate remapped hyperedge community IDs with an `IndexSet` (O(1),
  insertion-ordered) instead of a `Vec` + linear `contains` in the export
  aggregated-view path.

By the will of the Machine God
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 24b13fcd-7e38-4bbf-899a-c7d402c822a1

📥 Commits

Reviewing files that changed from the base of the PR and between 9620ebb and f1a4de4.

📒 Files selected for processing (5)
  • crates/graphify-detect/tests/parity_detect.rs
  • crates/graphify-extract/src/extractors/dm.rs
  • crates/graphify-extract/tests/parity_languages.rs
  • src/cli/extract.rs
  • tests/cli_commands.rs

📝 Walkthrough

Walkthrough

Adds BYOND DreamMaker extractors and tests, introduces a per-edge external flag and propagates it across extractors/handlers/tests, adds a CLI --mode deep LLM path threaded through backends and retry logic, remaps hyperedges for aggregated HTML, fixes dedup merging, and bumps workspace version to 0.8.22.

Changes

All changes

Layer / File(s) Summary
Edge schema and propagation
crates/graphify-extract/src/types.rs, crates/graphify-extract/src/extractors/*, crates/graphify-extract/src/generic/*, crates/graphify-extract/src/import_handlers.rs, tests
Adds external: bool to Edge (omitted when false) and sets external: false across extractor/emission sites and test helpers so resolved/local edges are explicit.
BYOND DreamMaker extractors and tests
crates/graphify-extract/src/extractors/dm.rs, crates/graphify-extract/tests/parity_languages.rs, tests/fixtures/sample.*
Adds .dm/.dme tree-sitter extractor (procs, types, includes, call-resolution), .dmi PNG Description state extraction, .dmm map dictionary parsing with uses edges, .dmf interface form parsing; extensive parity/regression tests and fixtures added.
Detection, dispatch, and re-exports
crates/graphify-detect/src/extensions.rs, crates/graphify-detect/src/walk.rs, crates/graphify-extract/src/extractors/mod.rs, crates/graphify-extract/src/multi.rs, crates/graphify-extract/src/lib.rs
Recognize BYOND extensions as code, bypass .graphifyignore for graphify-out/memory/, dispatch new extractors in multi-file orchestration, and re-export new extractor entrypoints.
LLM deep-mode plumbing and retry/parallel changes
crates/graphify-llm/src/constants.rs, bedrock.rs, claude.rs, claude_cli.rs, openai_compat.rs, extract.rs, retry.rs, parallel.rs, tests, CLI wiring src/cli/*
Adds DEEP_EXTRACTION_SUFFIX and extraction_system(deep), exposes backend-with-system variants, threads deep-mode through extractors/messaging and AdaptiveRetryCtx, adds extract_files_direct_mode, and wires CLI --mode deep into semantic phase and tests.
Graph export and dedup fixes
crates/graphify-export/src/html.rs, crates/graphify-export/tests/parity.rs, crates/graphify-dedup/src/merge.rs, parity tests
Remaps hyperedges to community IDs for aggregated visualizations, keeps only cross-community hyperedges, and prevents merging nodes with identical normalized labels from different source files; tests added.
Docs, CLI, version bump
README.md, USAGE.md, src/cli/*, Cargo.toml, tests/cli_commands.rs
Documents BYOND support and --mode deep, clarifies edge/context semantics and memory sidecar behavior, adds CLI --mode option and tests, bumps version 0.8.21 → 0.8.22.

Estimated code review effort:
🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly Related PRs

Poem

🐰 I hop through trees of code and light,

I find DM dreams in day and night,
Deep mode hums a richer song,
Edges mark where things belong,
Hyperedges cluster—what a sight!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch resync/graphify-py/43bf3c2

coderabbitai[bot]

This comment was marked as resolved.

rblaine95 added 3 commits May 29, 2026 10:49
Second review round on the graphify-py v0.8.22 resync branch.

Fixed:

- DM `#include` normalisation collapsed `../` to nothing, mis-resolving
  parent-relative includes. graphify-py's `raw.lstrip("./")` has the same
  bug because Python's `str.lstrip` treats its argument as a character
  set; the Rust port now strips only a single leading `/` plus leading
  `./` segments and preserves `../`. Added a parity test that resolves a
  `../helpers.dm` include to a non-external `imports_from` edge.
- `--mode deep` printed "deep mode enabled: richer semantic extraction"
  unconditionally. graphify-py prints it then hard-exits when no backend
  is configured, but the Rust pipeline degrades to an AST-only run, so
  the banner now reports the path that will actually execute.
- The semantic cache is keyed by file content only (mode-agnostic), so a
  prior shallow extraction would mask the richer deep-mode prompt. Deep
  mode now bypasses the cache read so it always re-extracts; fresh
  results still populate the cache. graphify-py reads the cache
  regardless, making `--mode deep` a silent no-op on cached files.
- `byond_extractors_error_on_missing_file` used a hard-coded absolute
  path; it now derives the missing path from a `tempfile::tempdir`.
- `extract_mode_deep_prints_banner_and_succeeds` scrubbed only a partial
  set of backend env vars. Added a `cli_no_backend` helper covering every
  variable `detect_backend` inspects so the AST-only smoke test cannot
  accidentally select a real LLM backend.
- `detect_memory_dir_bypasses_gitignore` now returns `Result` and uses
  `?` instead of `.expect`, matching the project's preferred test style.

Documented (not changed): the DM call-resolution index intentionally
includes type nodes alongside procs, matching graphify-py; a name that
uniquely identifies a single node resolves, and any collision falls
through to `raw_calls`. CodeRabbit's suggested predicate misreads the
already-paren-stripped labels.

Glory to the Omnissiah
Route extract_mode_invalid_value_exits_2 through the backend-less helper
for consistency with the sibling deep-mode test. clap rejects the bad
value before backend detection runs, so behaviour is unchanged.

By the will of the Machine God
CodeRabbit re-raised the DM call-resolution index. On reconsideration it
is a legitimate latent bug rather than an intentional heuristic: there is
no DreamMaker construct that calls a type-named identifier, yet the index
mapped every node label (types included) by last path segment, so a bare
call like `widget()` could resolve to the `/datum/widget` type node and
emit a spurious `calls` edge.

`label_to_nids` now indexes only callable proc nodes (their labels end in
`()`); `path_to_nids` is unchanged so `new /type` instantiation still
resolves. graphify-py indexes every label here, so this is a deliberate
divergence (feature parity, not bug parity). No existing DM parity test
regresses — the sample.dm fixture has no call/type name collision, so its
output is unchanged. Added a focused test proving a colliding call lands
in raw_calls instead of resolving to the type node.

By the will of the Machine God
@rblaine95 rblaine95 merged commit fa57aa4 into master May 29, 2026
12 checks passed
@rblaine95 rblaine95 deleted the resync/graphify-py/43bf3c2 branch May 29, 2026 10:20
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