Skip to content

Rust engine: live feeds and repository discovery, parity-checked against Python, with prebuilt releases - #41

Merged
New1Direction merged 4 commits into
mainfrom
claude/stoic-lamport-3t9dyl
Oct 28, 2026
Merged

New1Direction merged 4 commits into
mainfrom
claude/stoic-lamport-3t9dyl

Conversation

@New1Direction

Copy link
Copy Markdown
Owner

What this adds

Two new Rust binaries that do the same jobs as the Python tools, faster and with the same answers, plus a way to install them without a Rust toolchain.

Binary Replaces Measured (4-core container, release build)
ontologyex-feeds feeds.py OTLP receiver: 1.74M spans/s vs 98k (17.8×), 8.3 MiB vs 41.5 MiB resident. Probes and Prometheus polled in parallel.
ontologyex-discover discover_repo.py 5,900-file repo, 125 manifests: 0.088 s vs 1.30 s (14.8×). Byte-identical JSON.

Python stays the default and the reference. control_room.py --view-engine rust now also uses Rust discovery. Benchmark: tests/bench_rust_engines.py.

How we know they give the same answers

  • Discovery parity (tests/rust_discover_parity.py): 49 edge-case repos plus seeded mutations of compose files, workflows, package.json, Cargo.toml and pyproject.toml. Locally, 0 mismatches over 24,000+ mutated manifests. The YAML loader is a port of PyYAML's reader, scanner and parser. A YAML 1.2 crate first disagreed on tabs, U+0085 line breaks and indentation, which is why the port exists.
  • Feeds parity (tests/rust_feeds_parity.py): config validation (60 URL shapes plus seeded mutations), OTLP protobuf/JSON/gzip decoding with byte-flipped bodies, Prometheus responses, span-window replays, byte-for-byte store merges, once end to end, and the live receiver's status codes and rows. 2,223 cases, 0 mismatches. A planted bug is caught.
  • Kernels (tests/feeds_conformance.py): classification (31,250 cases), retention (4,095) and the p95 rank for every count up to 100,000. Compared across Python, Rust and Lean.
  • Lean (OntologyEX.Feeds): down_is_error, threshold_inclusive, classify_monotone, keep_at_most, keep_from_input, dropped_are_older, p95_index_in_range.

CI runs all of this in rust-proof-foundation.yml, with cargo --locked. Cargo.lock is now committed.

Python changes (needed for exact parity)

Each change refuses input that was malformed anyway, rather than copying a quirk into Rust:

  • Feeds:
    • URLs must be printable RFC 3986 text with a plain host and port.
    • OTLP/JSON and Prometheus bodies must be strict UTF-8 JSON with typed fields.
    • Truncated gzip bodies are refused.
    • The bearer token is compared as bytes; a non-ASCII header used to raise.
    • A non-object Prometheus response no longer crashes the runner.
  • Discovery:
    • Explicit YAML tags are refused.
    • Nesting is bounded explicitly: YAML 64 levels, JSON 512.
    • A TOML float overflow is an error instead of infinity.
    • Gap error_type is now a stable parse category.

Releases

  • release-engine.yml builds Linux (static musl, x86_64 and arm64) and macOS (arm64, plus x86_64 cross-built), and runs the parity suites on each native build. On an engine-v* tag it publishes the archives, SHA256SUMS, and a build provenance attestation. This PR only builds.
  • fetch_engine.py downloads from github.com only, verifies the checksum, and installs just the four binaries into the skill's bin/. It never runs them and prints the gh attestation verify command.

Docs: docs/rust-engine.md, which includes the known differences (IPv6 bind, timestamp forms, Windows via WSL).

Verification run locally

  • 560 Python tests OK.
  • cargo test --all-targets with -D warnings: 39 tests.
  • Existing Rust parity scripts pass (view, incident, HTTP, business 1,111/64/259 rows).
  • Static musl build: parity re-run, 549 and 556 cases, 0 mismatches. A self-signed certificate is refused by both implementations.
  • Lean is not built locally; CI checks it.

Generated by Claude Code

Port discover_repo.py to Rust with output that matches byte for byte:
the same walk order and budgets, ID quoting, gap ordering, and Python's
json.dumps formatting. The YAML loader is a port of PyYAML's reader,
scanner, and parser plus the SafeLoader resolver, so it accepts and
rejects exactly what PyYAML does (tabs, NEL line breaks, YAML 1.1
scalars such as 1:30).

- discover_repo.py: refuse explicit YAML tags; bound YAML nesting (64)
  and JSON nesting (512) explicitly instead of at Python's recursion
  limit; a TOML float that overflows is an error, not infinity; parse
  failures report a stable category (YAMLError, JSONDecodeError,
  TOMLDecodeError, UnicodeError, DiscoveryError)
- control_room --view-engine rust also discovers with the binary
  (native_view_bridge.native_discover, clean environment, trust checks)
- engine_binary(): $ONTOLOGYEX_ENGINE_DIR, skill bin/, then the
  checkout's release and debug builds
- tests/rust_discover_parity.py: 49 edge-case repositories plus seeded
  manifest mutations; 0 mismatches over 24,000 mutated manifests
- Cargo.lock is now committed for reproducible release builds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SoxWvtYbajXo6hFeADTXYF
…oofs

A Rust drop-in for feeds.py: the same ONTOLOGYEX_FEEDS config, the same
observations and status files. HTTP probes and Prometheus targets are
polled in parallel; the OTLP/HTTP receiver (protobuf and JSON, gzip,
bearer token) runs on a small worker pool. No proxy, no redirects,
system trust store.

On a 4-core container: ~1.74M spans/s vs ~98k for feeds.py (17.8x),
8.3 MiB vs 41.5 MiB resident.

feeds.py is tightened where Rust could not match its quirks, refusing
input that was malformed anyway: URLs must be printable RFC 3986 with a
plain host and port; OTLP/JSON and Prometheus bodies are strict UTF-8
JSON with typed fields; truncated gzip is refused; the bearer token is
compared as bytes (a non-ASCII header no longer raises); a non-object
Prometheus response no longer crashes the runner; the status file's
folder is created when no rows were written.

Verification:
- tests/rust_feeds_parity.py: config validation, OTLP decoding (seeded
  byte mutations), Prometheus parsing, span-window replays, store merges
  byte for byte, `once` end to end, and the live receiver
- tests/feeds_conformance.py: classification, retention, and p95 rank
  tables compared across Python, Rust, and Lean
- Lean (OntologyEX.Feeds): down_is_error, threshold_inclusive,
  classify_monotone, keep_at_most, keep_from_input, dropped_are_older,
  p95_index_in_range
- CI runs both parity suites, the feeds conformance table for Rust and
  Lean, and cargo with --locked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SoxWvtYbajXo6hFeADTXYF
- release-engine.yml: build the four binaries for Linux (static musl,
  x86_64 and arm64) and macOS (arm64, and x86_64 cross-built); run the
  discovery and feeds parity suites on each native build; on an
  engine-v* tag, publish the archives, SHA256SUMS, and a GitHub build
  provenance attestation. Pull requests build without publishing.
- fetch_engine.py: download a release over HTTPS from github.com only,
  check the archive against SHA256SUMS, and install only the expected
  binaries into the skill's bin/ (no traversal, symlinks, or extra
  files; no silent overwrite). Prints the gh attestation verify
  command. Shipped with the installed skill.
- docs/rust-engine.md: install, run, measured speedups, how parity is
  checked, what is proven, known differences, and how to release.
- README, live feeds, operating-picture reference: point to the engine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SoxWvtYbajXo6hFeADTXYF
Python 3.11.9's urlsplit accepts http://x[::1]/ and http://[::1]x/,
newer versions refuse them; check the shape explicitly so feeds.py and
ontologyex-feeds agree everywhere. The parity harness now prints only
the rows that differ in the end-to-end case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SoxWvtYbajXo6hFeADTXYF
@New1Direction
New1Direction merged commit cc86272 into main Oct 28, 2026
13 checks passed
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