Reorganize: Python Package Structure + Comprehensive Docs with Mermaid Diagrams#1
Open
itsXactlY wants to merge 9 commits into
Open
Reorganize: Python Package Structure + Comprehensive Docs with Mermaid Diagrams#1itsXactlY wants to merge 9 commits into
itsXactlY wants to merge 9 commits into
Conversation
Structure: - jackrabbitdlm/ package with server/, client/, common/, tools/, benchmarks/ - scripts/ for shell helpers (install, launch, stress test) - tests/ with encoding roundtrip tests - config/ for defaults README features: - TL;DR section with quick start - 5 Mermaid diagrams (architecture, sequence, state machine, data flow, class) - Complete protocol reference - Security model explanation - All deeper concepts linked to Wikipedia - Comparison table with Redis/ZK/Etcd Original files preserved alongside new structure.
… threshold - Sequence diagram: separate file names for lock (my_job) vs data (my_job:state), separate IDs (lock-abc vs data-xyz), independent cleanup - State machine: removed Put/Erase transitions (those are data operations, not lock ops), added note about Lock/DataStore separation - Data flow: dynamic threshold 16KB→8KB under memory pressure (>24.75% RAM), three-condition ForceDisk logic, threshold summary table
- Diagram now shows operation type fork (Lock/Put vs Get/Unlock/Erase) - Memory check gates both Lock and Put at ≥33% RAM - Memory Pressure Zones table: all four zones with Lock/Put/Erase behavior - Critical note at top of section
## Summary
Major reorganization of JackrabbitDLM into a standard Python package with
comprehensive documentation, Mermaid diagrams, and corrected technical details.
## Structural Changes
### New Package Layout
jackrabbitdlm/
├── __init__.py # Package root (version, exports)
├── common/
│ └── encoding.py # dlmEncode, dlmDecode, ShuffleJSON (shared)
├── client/
│ └── locker.py # Locker class (refactored, docstrings)
├── server/
│ └── daemon.py # Main server daemon (cleaned, documented)
├── tools/
│ ├── identity/ # Auth config generator
│ └── chart/ # Log visualizer
└── benchmarks/
└── lock_fighter.py # Stress tester
### New Directories
scripts/ # Shell helpers (install, launch, lock_wars)
config/ # Configuration templates
tests/ # Test suite (encoding roundtrip)
docs/ # Extended documentation
## Code Changes
### Encoding Module (jackrabbitdlm/common/encoding.py)
- Extracted shared encoding functions from inline code
- dlmEncode/dlmDecode/ShuffleJSON as importable functions
- Pre-computed ENCODE_TABLE/DECODE_TABLE for O(1) lookups
- Full docstrings with Wikipedia references
### Client Library (jackrabbitdlm/client/locker.py)
- Refactored Locker class with cleaner API
- Renamed internal methods (_retry, _retry_data, talk)
- Added docstrings for all public methods
- Import encoding from common module instead of inline
- Maintains full backward compatibility with original DLMLocker.py
### Server Daemon (jackrabbitdlm/server/daemon.py)
- Extracted action handlers (_handle_lock, _handle_unlock, _handle_get,
_handle_put, _handle_erase) for readability
- Environment variable JACKRABBIT_BASE for configurable paths
- Full docstrings with Wikipedia references
- Maintains identical protocol behavior
### Shell Scripts
- scripts/install.sh: Proper setup with venv creation
- scripts/launch_dlm.sh: Auto-restart with configurable base dir
- scripts/lock_wars.sh: Parallel stress test launcher
## Documentation (README.md)
### Content
- ASCII art header (slant font via pyfiglet)
- TL;DR section with quick start
- 5 Mermaid diagrams:
1. Architecture Overview (graph TB)
2. Request Flow (sequenceDiagram) - shows Lock vs DataStore as
SEPARATE entities with separate IDs
3. Lock State Machine (stateDiagram-v2)
4. Data Flow with Disk Spillover (flowchart TD) - correct dynamic
thresholds (16KB → 8KB under memory pressure)
5. Class Diagram (classDiagram)
- Complete protocol reference with field descriptions
- Security model documentation
- Performance & monitoring guide
- Comparison table with Redis/ZooKeeper/Etcd/PostgreSQL
### Critical Technical Corrections
- Locks and DataStores are SEPARATE entities with separate IDs
(use different FileName: "my_job" for lock, "my_job:state" for data)
- At 33% RAM saturation, BOTH Lock AND Put are disabled (not just Put)
- Disk spillover threshold is dynamic: 16KB normal, drops to ~8KB
when RAM > 24.75% (memory pressure)
- Unlock does NOT erase data; Erase does NOT unlock
## Preserved
- All original files kept alongside new structure for reference
- LGPL-2.1 license unchanged
- Full backward compatibility with existing JSON-over-TCP protocol
- Zero additional dependencies beyond psutil
## Testing
- tests/test_encoding.py: encode/decode roundtrip + ShuffleJSON verification
- All imports verified working
Co-authored-by: Hermes Agent <hermes@nousresearch.com>
…ith auth If a resource was PUT or LOCKED with Name+Identity, subsequent Get and Erase operations also require matching Name+Identity. _check_identity() is called on every access to authenticated resources. Updated Authentication Rules table: - Split Get/Erase into anonymous vs authenticated cases - Added explanation of how _check_identity() works - Mismatch → NotOwner response
JackrabbitDLM now supports swappable storage backends: - Memory (default, original behavior) - Redis (host/port/db config) - SQLite (persistent, file-based) - Filesystem (JSON-on-disk) Backend selected via config/backend option. Factory registry pattern for runtime swapping.
backend.py now supports Memory, Redis, SQLite, Filesystem. Merged with upstream origin/main.
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.
What This PR Does
Major reorganization of JackrabbitDLM into a standard Python package layout with comprehensive documentation, Mermaid diagrams, and technical corrections discovered during code analysis.
Structural Changes
New Python Package:
jackrabbitdlm/New Directories
scripts/— Shell helpers (install.sh, launch_dlm.sh, lock_wars.sh)config/— Configuration templates (defaults.yaml)tests/— Test suite (encoding roundtrip + ShuffleJSON)docs/— Extended documentationCode Improvements
Encoding Module (
jackrabbitdlm/common/encoding.py)dlmEncode/dlmDecode/ShuffleJSONfrom inline duplicationENCODE_TABLE,DECODE_TABLE) for O(1) performanceClient Library (
jackrabbitdlm/client/locker.py)talk(),_retry(),_retry_data()as internal methodsLock,Unlock,Put,Get,Erase,Version,IsDLM)commoninstead of duplicating codeDLMLocker.pyServer Daemon (
jackrabbitdlm/server/daemon.py)_handle_lock(),_handle_unlock(),_handle_get(),_handle_put(),_handle_erase()JACKRABBIT_BASEenvironment variableShell Scripts
scripts/install.sh— Proper setup with venv creation and dependency installscripts/launch_dlm.sh— Auto-restart wrapper with configurable pathsscripts/lock_wars.sh— Parallel stress test launcher with argument passthroughREADME.md Overhaul
ASCII Art
slantfont header (via pyfiglet) — clean, terminal-friendly5 Mermaid Diagrams
graph TB) — Clients → TCP → Server internalssequenceDiagram) — Lock/Put/Get/Unlock lifecycle with correct Lock vs DataStore separationstateDiagram-v2) — Lock states with note on entity separationflowchart TD) — Put with dynamic disk spillover thresholdsclassDiagram) — All classes and their relationshipsSections
Critical Technical Corrections
During code analysis, we discovered and documented several important details that were previously unclear:
1. Locks and DataStores Are Separate Entities
Locks and DataStores use separate IDs and should use different FileName values. A lock on
"my_job"and data on"my_job:state"have independent lifecycles, ownership, and expiration.Unlock does NOT erase data. Erase does NOT unlock.
2. At 33% RAM, Both Lock AND Put Are Disabled
The
MemoryOverloadCheck()is called in both_handle_lockand_handle_put. When process RSS exceeds 33% of total system RAM, both operations return{"Status": "NO"}. OnlyGet,Unlock, andErasecontinue working.3. Disk Spillover Threshold Is Dynamic
The
ForceDisklogic has three conditions:Preserved
psutil(andplotlyfor charts)Testing
Reorganized by itsXactlY with Hermes Agent. All technical details verified against source code.