Skip to content

Add initial native Rust runtime (packages/core-rust) for mounting and querying .knolo packs#31

Merged
HiveForensicsAI merged 2 commits intomainfrom
codex/plan-new-feature-for-rust-support
Apr 15, 2026
Merged

Add initial native Rust runtime (packages/core-rust) for mounting and querying .knolo packs#31
HiveForensicsAI merged 2 commits intomainfrom
codex/plan-new-feature-for-rust-support

Conversation

@HiveForensicsAI
Copy link
Copy Markdown
Contributor

Motivation

  • Provide a native Rust runtime to mount and query .knolo packs for improved portability and performance.
  • Expose core parsing and deterministic lexical retrieval functionality in Rust to match the existing JS runtime capabilities.

Description

  • Add a new package at packages/core-rust with Cargo.toml, src/lib.rs, README.md, and .gitignore implementing mount_pack_from_bytes and query along with pack parsing for meta, lexicon, postings, and blocks formats.
  • Implement a deterministic lexical retrieval engine including tokenization, BM25-like scoring, and top_k, min_score, namespace, and source filters.
  • Add unit tests in packages/core-rust/tests/core_rust_test.rs that build a synthetic pack and verify mounting, ranking, and namespace filtering.
  • Update repository README.md to advertise the new Rust runtime and add test:rust to package.json to run Rust tests via cargo test.

Testing

  • Ran the Rust unit tests with cargo test in packages/core-rust and the test suite passed.
  • Verified the new test:rust npm script (cargo test --manifest-path packages/core-rust/Cargo.toml) was added for CI integration.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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: 290ba30b9a

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

Comment on lines +443 to +445
fn compact(s: &str) -> String {
s.chars().filter(|c| !c.is_whitespace()).collect()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve whitespace when decoding block payloads

parse_blocks calls compact(json) before extracting text, heading, docId, and namespace, and compact removes every whitespace character globally. Because block text is serialized as JSON strings from buildPack, this collapses normal spaces/newlines inside document content (e.g., "alpha beta" becomes "alphabeta"), corrupting returned snippets and fallback token-length calculation for packs without len values.

Useful? React with 👍 / 👎.

Comment on lines +347 to +353
if *ch == '{' {
if depth == 0 {
start = Some(i);
}
depth += 1;
} else if *ch == '}' {
depth -= 1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle braces inside quoted JSON strings

split_top_level_objects increments/decrements depth on every {/} character without tracking whether the parser is currently inside a quoted string. If a block's text contains braces (common in code snippets like { "a": 1 }), object boundary detection becomes incorrect and can produce malformed object slices or mounting failures.

Useful? React with 👍 / 👎.

Comment on lines +379 to +380
let end = rest.find('"')?;
Some(unescape(&rest[..end]))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Respect escaped quotes in string field parsing

parse_string_or_null finds the first " after the opening quote and treats it as the end of the value. This breaks valid JSON strings containing escaped quotes (e.g., \"), truncating text/heading/docId/namespace at the first escaped quote and returning corrupted metadata and snippets.

Useful? React with 👍 / 👎.

@HiveForensicsAI HiveForensicsAI merged commit 7e9367a into main Apr 15, 2026
2 checks passed
@HiveForensicsAI HiveForensicsAI deleted the codex/plan-new-feature-for-rust-support branch April 15, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant