fix: remove unused SurrealDB scripting feature (~10-20MB savings)#3
Closed
HexaField wants to merge 2 commits into
Closed
fix: remove unused SurrealDB scripting feature (~10-20MB savings)#3HexaField wants to merge 2 commits into
HexaField wants to merge 2 commits into
Conversation
Remove the SurrealDB `scripting` feature which embeds a QuickJS JavaScript engine. This saves ~10-20MB RSS and ~2-5MB binary size. Changes: - Remove `scripting` from surrealdb features in Cargo.toml - Remove `.with_scripting(true)` capability configuration - Rewrite fn::contains and fn::regex_match as thin wrappers around native SurrealQL functions (string::contains, string::matches) - Rewrite fn::parse_literal in pure SurrealQL with a fn::url_decode helper for percent-decoding (supports string:, number:, boolean: prefixes) - Remove fn::strip_html (requires regex replace, unavailable in pure SurrealQL) - Remove fn::json_path (requires dynamic object traversal, unavailable in SurrealQL) - Add fn::url_decode helper for common percent-encoded characters Zero production queries call any of these functions — all 29 fn:: references are inside #[cfg(test)] blocks. The literal://json: case (which required JSON.parse via QuickJS) is dropped; json: literals pass through as raw URLs. Tests updated accordingly.
HexaField
pushed a commit
that referenced
this pull request
Feb 23, 2026
…#652) * Surreal files per perspective wip 1 * Avoid duplicate links w/ unique index and handle lock and write errors * Fix new remove_link on surreal service * Rename update_surreal_cache() to persist_link_diff() * Temporary perspective data migration from rusqlite to surreal * fmt * fix: address CodeRabbit issues #2, #3, coasys#7 - MIGRATION_REMOVAL_GUIDE.md: Complete sentence in heading - migration.rs: Only mark as migrated when error_count == 0 (prevents data loss) - surreal_service/mod.rs: Remove overly broad 'index' error check (more precise error handling) Addresses CodeRabbit actionable comments on PR coasys#652 * fix: preserve original link status instead of hardcoding Local (issue #4) Instead of hardcoding LinkStatus::Local, now reads link.status and uses it (falls back to Local if None). This preserves the original link status during import operations. Addresses CodeRabbit actionable comment on PR coasys#652 * fix: propagate SurrealDB write failures to prevent desync (issue #1) - retry_surreal_op now returns Result and propagates errors - persist_link_diff now returns Result instead of silently swallowing errors - Updated all callsites: - Functions returning Result: use .await? to propagate - Functions returning (): use .await.expect() to fail-fast - Critical synchronization operations now fail loudly instead of silently Addresses CodeRabbit actionable comment #1 on PR coasys#652 * fix: honor full unique constraint in SurrealDB lookups (issue coasys#6) Updated get_link to accept and use author and timestamp parameters: - get_link now takes optional author and timestamp - When provided, queries using all 5 unique fields (source, target, predicate, author, timestamp) - When not provided, falls back to 3-field lookup for backward compatibility - Updated all callsites to pass author and timestamp from LinkExpression This prevents returning arbitrary links when multiple authors/timestamps exist for the same source/predicate/target combination. Addresses CodeRabbit actionable comment coasys#6 on PR coasys#652 * fix: prevent TOCTOU race in initialize_from_db (issue #5) Added atomic check-and-insert before storing perspective: - Initial read-lock check remains for quick filtering - After async initialization completes, do final write-lock check - Only insert if another task hasn't already initialized this perspective - Discard duplicate work and don't start background tasks if race lost This prevents multiple tasks from creating duplicate SurrealDB services for the same perspective UUID. Addresses CodeRabbit actionable comment #5 on PR coasys#652 * fix: clone link.status to avoid partial move Compilation error: link.status.unwrap_or() moves the value, preventing use of 'link' afterwards. Use clone() to avoid the partial move. * fix: borrow links in migration loop to avoid partial move Changed 'for (link_expr, status) in links' to '&links' and cloned status to avoid moving values out of the vector. * chore: run cargo fmt and add PR fixes summary * refactor: remove redundant variable reassignments in get_link Addresses CodeRabbit feedback: simplified variable flow by directly assigning query result to response instead of going through intermediate query and results variables. Co-authored-by: CodeRabbit AI <coderabbit@example.com> * fix: address CodeRabbit feedback on PR coasys#652 1. Remove 'WHERE perspective = $perspective' from test queries - Each perspective has isolated database, no filtering needed - Fixed 11 test queries in surreal_service/mod.rs 2. Make status parsing case-insensitive in SurrealLink conversion - Now handles 'Shared'/'shared' and 'Local'/'local' correctly - Preserves migrated data regardless of case 3. Require author/timestamp in get_link() signature - Changed from Option<&str> to &str for both params - Removed fallback branch (always use full unique constraint) - Updated 4 callsites in perspective_instance.rs - Enforces UNIQUE index (in, out, predicate, author, timestamp) Co-authored-by: CodeRabbit AI <coderabbit@example.com> * reset bootstrapSeed.json * Handle fallback sync read failure gracefully. * Don’t proceed when migration fails. * Fix inconsistent error handling: .expect() vs. map_err()? * fix: handle SurrealDB service creation failure in initialize_from_db Complements commit e57b8f8 which fixed the same issue in add_perspective(). This fix addresses the spawned task in initialize_from_db() which also had a panicking .expect() call. Changes: - Replace .expect() with match expression - Log error and return early on failure - Prevents panic if SurrealDB creation fails (RocksDB lock, disk, permissions) Addresses CodeRabbit feedback on PR coasys#652 (line 90 issue) * don't fail silently if links from DB can't be parsed * don't panic on DB write failures but log error --------- Co-authored-by: Data <data.coasys@gmail.com> Co-authored-by: CodeRabbit AI <coderabbit@example.com>
lucksus
pushed a commit
that referenced
this pull request
Feb 26, 2026
- Use SHACLShape.toJSON() in ensureSDNASubjectClass instead of manual JSON (coasys#15) - Refactor getSubjectClassMetadataFromSDNA to use getShacl()/SHACLShape.fromLinks() (coasys#14) - Update addSdna docs to clarify SHACL is primary, Prolog kept for compat (#1) - Mark Phase 3 as completed in architecture doc (#3) - Add .worktrees/ to .gitignore
HexaField
pushed a commit
that referenced
this pull request
Mar 6, 2026
…rdcoding Address review comments #3 and #4 from Nico: - subscriptions.rs: When no explicit predicate is provided, load the SHACL class definition and derive the SurrealQL query from its property predicates (IN clause). No more hardcoded flux:// types. - shacl.rs: Enrich ShaclClass with shape_uri and all_predicates fields, providing enough metadata to construct targeted queries without type-specific knowledge. - Add load_class_properties_with_uri() to return shape URI alongside properties for richer metadata.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the SurrealDB
scriptingfeature, which embeds a full QuickJS JavaScript engine inside SurrealDB. This engine is defined in the schema but never called by production code — allfn::references exist only in#[cfg(test)]blocks.Expected savings
What changed
fn::contains— inline JSstr.includes()string::contains()native wrapperfn::regex_match— inline JSRegExp.test()string::matches()native wrapperfn::parse_literal— JS withdecodeURIComponent+JSON.parsefn::url_decodehelper. Supportsstring:,number:,boolean:prefixes.json:case removed (requires JS engine).fn::strip_html— JS regex replacefn::json_path— JS dynamic object traversalNew:
fn::url_decodehelperA pure SurrealQL function that decodes common percent-encoded characters (
%20→ space,%22→ double-quote,%3A→ colon, etc.) using a chain ofstring::replacecalls. Handles the 22 most common URL-encoded characters. Used byfn::parse_literalfor thestring:prefix.Risk: Low
literal://json:test updated to expect passthrough behavior (raw URL returned)Note
cargo checkcannot be verified locally due to a pre-existing xcodebuild/v8 toolchain issue (Xcode not installed, only Command Line Tools). CI will validate.