Skip to content

ruff_cpp_spo: harvest_network example — sink Tesseract LSTM network C++ to SPO - #41

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/happy-hamilton-0azlw4
Jul 4, 2026
Merged

ruff_cpp_spo: harvest_network example — sink Tesseract LSTM network C++ to SPO#41
AdaWorldAPI merged 1 commit into
mainfrom
claude/happy-hamilton-0azlw4

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

The ruff→OGAR sink-in for the Tesseract recognizer transcode. A new ruff_cpp_spo example, harvest_network, walks Tesseract's 11 LSTM network-layer headers (network.h + the FullyConnected/LSTM/Series/Parallel/Plumbing/Convolve/Maxpool/Reversed/Reconfig/Input subclasses) via libclang and emits the has_function / inherits_from / virtually_overrides SPO manifest — the classid → ClassView method-resolution table that the downstream network→V3-SoA sink (lance-graph-contract::network) and the invoke_network dispatch resolve against. It mirrors the proven harvest_unicharset example (same walk_tumodel_from_classexpandto_ndjson pipeline; corpus stays UPSTREAM, never vendored).

The manifest is the "vtable the hand-rolled enum would have faked": the Forward override set (FullyConnected/LSTM/Series/Parallel/Convolve/Maxpool/Reversed/Reconfig/Input) is the recognizer's compute-leaf list; the DeSerialize override set (FullyConnected/LSTM/Plumbing/Convolve/Maxpool/Reconfig/Input) is the binary-leaf list.

Additive: one new [[example]] (gated required-features = ["libclang"], so a default --all-targets build never compiles it) + the example file. No library change.

Test Plan

Ran against real Tesseract 5.5.0 source:

TESSERACT_SRC=/tmp/tesseract LIBCLANG_PATH=/usr/lib/llvm-18/lib \
  cargo run -p ruff_cpp_spo --features libclang --example harvest_network
# → 62 unique classes across 11 headers; 5060 triples → /tmp/network_manifest.ndjson
# → per-class Forward/DeSerialize override manifest printed for all 11 layer types

cargo clippy -p ruff_cpp_spo --features libclang --all-targets -- -D warnings clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1


Generated by Claude Code

…o SPO

The ruff>OGAR sink-in for the recognizer transcode. Walks the 11 network
layer headers (network.h + FullyConnected/LSTM/Series/Parallel/Plumbing/
Convolve/Maxpool/Reversed/Reconfig/Input) via libclang and emits the
has_function / inherits_from / virtually_overrides SPO manifest — the
classid -> ClassView method-resolution table the invoke_network keystone
resolves against (the invoke_unicharset analog). Mirrors harvest_unicharset.

Harvest on real Tesseract 5.5.0 src: 62 classes, 5060 triples. The Forward
override set (FullyConnected/LSTM/Series/Parallel/Convolve/Maxpool/Reversed/
Reconfig/Input) is the compute-leaf list; the DeSerialize override set
(FullyConnected/LSTM/Plumbing/Convolve/Maxpool/Reconfig/Input) is the
binary-leaf list. Corpus stays UPSTREAM (never vendored).

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a3cc828. Configure here.

}
}
Err(e) => eprintln!("[harvest] walk {h} failed: {e}"),
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Libclang failures exit successfully

Medium Severity

When walk_tu returns WalkError::Libclang (missing LIBCLANG_PATH, libclang unavailable), the example logs to stderr and continues instead of failing. It can still write an empty or partial manifest and return Ok(()), unlike harvest_unicharset and the crate’s walk_files helper, which propagate that error.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a3cc828. Configure here.

@AdaWorldAPI
AdaWorldAPI merged commit c0b24ee into main Jul 4, 2026
1 check passed

@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: a3cc82880b

ℹ️ 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".

}
}
}
Err(e) => eprintln!("[harvest] walk {h} failed: {e}"),

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 Fail when libclang harvesting fails

When LIBCLANG_PATH is wrong or libclang cannot be loaded, every walk_tu call returns WalkError::Libclang; this arm only logs the error and continues, so the command exits successfully and writes an empty or partial manifest for downstream consumers. Treat non-recoverable walker errors as fatal (as the library extraction path does) so a bad environment cannot silently produce a bogus network manifest.

Useful? React with 👍 / 👎.

AdaWorldAPI pushed a commit that referenced this pull request Aug 18, 2026
…ippy-clean

CI has been red on the base branch independently of this arc. Each failure was
verified against the parent commit before being touched:

- cargo clippy: clippy 1.97's `manual_option_zip` fired on
  `ruff_annotate_snippets::zip_opt`, which carried a literal `// TODO: option_zip`
  — the lint's suggestion IS the resolution the author left pending, so
  `a.and_then(|a| b.map(|b| (a, b)))` becomes `a.zip(b)`. The four reported
  `ruff_python_ast` errors were downstream of that crate failing to compile;
  `cargo clippy --workspace --all-targets --all-features` is now green.
- cargo shear: `ruff_ruby_spo` sat in `[workspace.dependencies]` with no
  consuming crate (only doc-comment mentions elsewhere). Removed; the crate
  itself is untouched and the workspace still builds.
- shellcheck: SC2086 on unquoted `$LEVEL` in the vendored
  `vendor/lsp-types/release.sh` (lines 10, 15). Note this file is vendored, so
  a future re-vendor will clobber the fix — it is tracked and CI lints it, so
  the quoting has to live here for now.
- mkdocs: `docs/OGAR-POLYGLOT-AST-INTEGRATION.md` (added by PR #41) was absent
  from `nav`, and strict mode aborts on the warning. Added to `not_in_nav` —
  it is an internal architecture note, not user documentation.

ruff_r2il, `--features lift` (the libsla-backed examples) now clippy-clean:
type aliases for the two residual buckets, a `LiftCtx` grouping the three
invariant lifting handles (readable shape, and settles too_many_arguments),
`checked_div`, doc-list indentation, and a narrow visible
`#![expect(clippy::disallowed_methods)]` on each example. That last one is
deliberate: the workspace policy reads "Use System::… instead **in ty crates**",
and this workspace-EXCLUDED crate cannot reach ty's `System` abstraction — so it
is suppressed with a stated reason rather than evaded by switching to a
non-disallowed API, which would hide that the crate sits outside the policy.

Gates: fmt, clippy (default AND lift), 43 tests, plus the three isolation
proofs — all green.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
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.

2 participants