ruff_cpp_spo: harvest_network example — sink Tesseract LSTM network C++ to SPO - #41
Conversation
…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
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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}"), | ||
| } |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit a3cc828. Configure here.
There was a problem hiding this comment.
💡 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}"), |
There was a problem hiding this comment.
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 👍 / 👎.
…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


Summary
The
ruff→OGARsink-in for the Tesseract recognizer transcode. A newruff_cpp_spoexample,harvest_network, walks Tesseract's 11 LSTM network-layer headers (network.h+ theFullyConnected/LSTM/Series/Parallel/Plumbing/Convolve/Maxpool/Reversed/Reconfig/Inputsubclasses) via libclang and emits thehas_function/inherits_from/virtually_overridesSPO manifest — theclassid → ClassViewmethod-resolution table that the downstream network→V3-SoA sink (lance-graph-contract::network) and theinvoke_networkdispatch resolve against. It mirrors the provenharvest_unicharsetexample (samewalk_tu→model_from_class→expand→to_ndjsonpipeline; corpus stays UPSTREAM, never vendored).The manifest is the "vtable the hand-rolled enum would have faked": the
Forwardoverride set (FullyConnected/LSTM/Series/Parallel/Convolve/Maxpool/Reversed/Reconfig/Input) is the recognizer's compute-leaf list; theDeSerializeoverride set (FullyConnected/LSTM/Plumbing/Convolve/Maxpool/Reconfig/Input) is the binary-leaf list.Additive: one new
[[example]](gatedrequired-features = ["libclang"], so a default--all-targetsbuild never compiles it) + the example file. No library change.Test Plan
Ran against real Tesseract 5.5.0 source:
cargo clippy -p ruff_cpp_spo --features libclang --all-targets -- -D warningsclean.🤖 Generated with Claude Code
https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1
Generated by Claude Code