Skip to content

Conversation

@paul-hammant
Copy link
Contributor

No description provided.

claude and others added 6 commits November 18, 2025 15:46
A natural persistence format for ChrysaLisp, built on tree-load/tree-save.

Features:
- Human-readable S-expression storage format
- Full CRUD operations (Create, Read, Update, Delete)
- Indexing for O(1) field lookups
- Query support with predicate functions
- Message-passing for multi-client access
- Collections for organizing data
- Auto-generated unique IDs

Implementation:
- apps/sxdb/app.lisp - Service entry point
- apps/sxdb/app_impl.lisp - Core database engine
- apps/sxdb/client.inc - Client library API
- apps/sxdb/example.lisp - Comprehensive example
- apps/sxdb/README.md - Full documentation

The database leverages ChrysaLisp's existing tree-save/tree-load
primitives for fast serialization, uses Emap for in-memory storage,
and provides a service-based architecture for concurrent access.
Tests cover all database functionality:
- Database lifecycle (open/close)
- Index creation, usage, and deletion
- CRUD operations (insert, find, update, delete)
- Indexed field lookups
- Predicate-based queries
- Collection management
- Statistics and metadata
- Data persistence and reload
- Multiple concurrent databases
- Error handling and edge cases

Test features:
- 75+ individual test assertions
- Clear pass/fail indicators (✓/✗)
- Automatic cleanup of test files
- Exit code 0 on success, 1 on failure
- Comprehensive coverage of all API functions

Updated README.md with Testing section explaining:
- How to run the tests
- What's covered
- Expected output format
Applied fixes based on comprehensive code review:

Error Handling:
- Add try/catch for tree-load to handle corrupted files
- Add try/catch for tree-save to detect write failures
- Validate loaded database structure is a valid Emap
- Check file-stream success before operations
- Add path validation (must be string)

Input Validation:
- Validate records are Emap before insert
- Validate updates are Emap before update operations
- Prevents crashes from invalid data types

Message Validation:
- Check message structure before processing
- Prevent crashes from malformed messages
- Safely handle invalid message formats

Code Cleanup:
- Remove redundant mbox variable (task-mbox always returns same mailbox)
- Match pattern used in other ChrysaLisp services

Security Documentation:
- Add Security Considerations section to README
- Document eval security issue in queries
- Provide recommendations for production use
- Warn about trusted-clients-only requirement

All critical and major issues from code review addressed.
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