- 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
Feature/arango http2 client #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            21 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      60ff21c
              
                fix: Critical Jina embedder performance and config issues (Issue #45)
              
              
                r3d91ll c28ea36
              
                fix: Exclude test files from CodeRabbit review path filters
              
              
                r3d91ll ba173e3
              
                refactor: Remove redundant SentenceTransformersEmbedder (Issue #46)
              
              
                r3d91ll 9a17dca
              
                fix: Critical workflow issues preventing data loss and crashes (Issue…
              
              
                r3d91ll dd42c43
              
                refactor: Update .gitignore to include additional environment and cre…
              
              
                r3d91ll 8645ccd
              
                Merge remote-tracking branch 'origin/main' into feature/issue-46-remo…
              
              
                r3d91ll 7227c48
              
                chore: Move tests and dev-utils to local-only, reorganize setup scripts
              
              
                r3d91ll 5a4dc62
              
                Remove deprecated setup scripts and test files
              
              
                r3d91ll 6042fd6
              
                Refactor type hints and improve code documentation across multiple mo…
              
              
                r3d91ll f077583
              
                Remove the ArXiv Size-Sorted Processing Workflow (Simplified) script,…
              
              
                r3d91ll 4c82dd6
              
                feat: Add ArXiv initial ingest workflow and PHP ArangoDB bridge
              
              
                r3d91ll afd4e64
              
                refactor: Improve connection handling and enhance bulk insert safety …
              
              
                r3d91ll a90a8c9
              
                feat: update dependencies and add grpcio packages
              
              
                r3d91ll f24a1ed
              
                chore: remove obsolete benchmark report files and update .gitignore t…
              
              
                r3d91ll 3f516e5
              
                Refactor storage backend imports and error handling
              
              
                r3d91ll 2284909
              
                fix: correct spelling in comments and update test file exclusion note
              
              
                r3d91ll ae03738
              
                Refactor ArXiv ingestion workflow and database schema
              
              
                r3d91ll ce4f964
              
                Refactor ArangoDB collections and workflows for arXiv ingestion
              
              
                r3d91ll 9b401fc
              
                chore: update .gitignore to exclude Go cache files and remove obsolet…
              
              
                r3d91ll ac06da3
              
                Merge pull request #53 from r3d91ll/pr52
              
              
                r3d91ll c318fac
              
                Implement Virtual Context Management via ArangoDB and vLLM Model Mana…
              
              
                r3d91ll File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Repository Guidelines | ||
| 
     | 
||
| ## Project Structure & Module Organization | ||
| 
     | 
||
| - `core/` holds Python source, including database clients (`core/database`), embedders (`core/embedders`), and workflows (`core/workflows`). | ||
| - `core/database/arango/proxies/` contains the Go RO/RW proxy sources (`cmd/roproxy`, `cmd/rwproxy`). | ||
| - `docs/` captures product requirements, benchmarks, and deployment runbooks; `setup/` contains automation scripts for local/bootstrap installs. | ||
| - Tests live under `tests/` and align with the package structure; use matching module paths when adding new suites. | ||
| 
     | 
||
| ## Build, Test, and Development Commands | ||
| 
     | 
||
| - `poetry install` – create/update the virtualenv with project dependencies. | ||
| - `poetry run python -m compileall core` – quick syntax/bytecode sweep; run after touching Python modules. | ||
| - `poetry run pytest` – execute the Python test suite; add `-k` to target specific modules. | ||
| - `go build ./core/database/arango/proxies/...` – verify the RO/RW proxy binaries build cleanly. | ||
| - `poetry run ruff check` / `poetry run ruff format` – lint and auto-format Python code before committing. | ||
| - `poetry run python tests/benchmarks/conveyance_logger.py …` – translate benchmark JSON into Conveyance log entries (see docs/benchmarks/arango_phase4_summary.md for examples). | ||
| 
     | 
||
| ## Coding Style & Naming Conventions | ||
| 
     | 
||
| - Python: 4-space indentation, type hints required for new public APIs, and docstrings for modules/classes/functions exposed outside a file. | ||
| - Follow PEP 8 naming (snake_case for functions/vars, PascalCase for classes). Keep module names lowercase. | ||
| - Go: leverage `gofmt` and conventional CamelCase identifiers; ensure proxy allowlists remain alphabetical. | ||
| - Avoid committing secrets; configuration belongs in `.env` or systemd drop-ins (e.g., `ARANGO_PASSWORD`, `ARANGO_RO_SOCKET`). | ||
| 
     | 
||
| ## Testing Guidelines | ||
| 
     | 
||
| - Prefer `pytest`-style tests named `test_<feature>.py` with functions `test_<behavior>`. | ||
| - Mock external systems (ArangoDB, gRPC) and exercise both RO and RW paths of the memory client. | ||
| - Aim for ≥80 % docstring/type coverage (mirrors CI expectations) and capture evidence for Conveyance calculations when adding benchmarks. | ||
| 
     | 
||
| ## Commit & Pull Request Guidelines | ||
| 
     | 
||
| - Commit messages follow the repository’s style: imperative mood with a concise summary (e.g., “Add HTTP/2 proxy rollback guard”), optionally referencing issues (`#51`). | ||
| - Each PR should include: linked issue, Conveyance Summary, W/R/H/T mapping, Performance Evidence, and Tests & Compatibility sections. | ||
| - Attach benchmark artefacts under `benchmarks/reports/` when changing performance-sensitive code, and note any required manual login steps (e.g., rebuilding systemd units). | ||
| 
     | 
||
| ## Conveyance Framework Expectations | ||
| 
     | 
||
| - Frame design and review decisions using the efficiency view: `C = (W·R·H / T) · Ctx^α`, where `Ctx = wL·L + wI·I + wA·A + wG·G` and α is typically 1.7. | ||
| - Always report which factors improved (W, R, H, T, or Ctx) and include a zero-propagation check (if any base factor is 0 or T → ∞, declare C = 0). | ||
| - Benchmark notes must map measurements to W/R/H/T and cite context scores (L/I/A/G) so reviewers can recompute Conveyance. | ||
| - Late chunking is mandatory: encode documents once, then derive context-aware chunks. Choose embedders per workload (SentenceTransformers for high throughput, JinaV4 for fidelity) and document the trade-off in PRs. | ||
| - Further details on the conveyance framework can be found in docs/CONVEYANCE_FRAMEWORK.md | ||
| 
     | 
||
| ## Security & Configuration Tips | ||
| 
     | 
||
| - Never hard-code credentials. Use environment variables (`ARANGO_RO_SOCKET`, `ARANGO_RW_SOCKET`, `ARANGO_HTTP_BASE_URL`) and keep `.env` out of version control. | ||
| - Run `setup/verify_storage.py` after deployments to confirm collection/index health before ingest workflows. | ||
| 
     | 
||
| ## CRITICAL: Late Chunking Principle | ||
| 
     | 
||
| **MANDATORY**: All text chunking MUST use late chunking. Never use naive chunking. | ||
| 
     | 
||
| ### Why Late Chunking is Required | ||
| 
     | 
||
| From the Conveyance Framework: **C = (W·R·H/T)·Ctx^α** | ||
| 
     | 
||
| - **Naive chunking** breaks context awareness → Ctx approaches 0 → **C = 0** (zero-propagation) | ||
| - **Late chunking** preserves full document context → Ctx remains high → **C is maximized** | 
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # ArangoDB Optimized HTTP/2 Client | ||
| 
     | 
||
| ## Benchmarks | ||
| 
     | 
||
| | Operation | PHP Subprocess | HTTP/2 (direct) | HTTP/2 via proxies | | ||
| |---------------------------------------------|----------------|-----------------|--------------------| | ||
| | GET single doc (hot cache, p50) | ~100 ms | ~0.4 ms | ~0.6 ms | | ||
| | GET single doc (hot cache, p95 target) | n/a | 1.0 ms | 1.0 ms | | ||
| | Insert 1000 docs (waitForSync=false, p50) | ~400–500 ms | ~6 ms | ~7 ms | | ||
| | Query (LIMIT 1000, batch size 1000, p50) | ~200 ms | ~0.7 ms | ~0.8 ms | | ||
| 
     | 
||
| ## Usage | ||
| 
     | 
||
| ### Client | ||
| ```python | ||
| from core.database.arango.optimized_client import ArangoHttp2Client, ArangoHttp2Config | ||
| 
     | 
||
| config = ArangoHttp2Config( | ||
| database="arxiv_repository", | ||
| socket_path="/run/hades/readonly/arangod.sock", | ||
| username="arxiv_reader", | ||
| password="...", | ||
| ) | ||
| with ArangoHttp2Client(config) as client: | ||
| doc = client.get_document("arxiv_metadata", "0704_0003") | ||
| print(doc) | ||
| ``` | ||
| 
     | 
||
| ### Workflow Integration | ||
| ```python | ||
| from core.database.database_factory import DatabaseFactory | ||
| 
     | 
||
| memory_client = DatabaseFactory.get_arango_memory_service() | ||
| try: | ||
| documents = memory_client.execute_query( | ||
| "FOR doc IN @@collection LIMIT 5 RETURN doc", | ||
| {"@collection": "arxiv_metadata"}, | ||
| ) | ||
| finally: | ||
| memory_client.close() | ||
| ``` | ||
| 
     | 
||
| ### Proxy Binaries | ||
| 1. Build: `cd core/database/arango/proxies && go build ./...` | ||
| 2. Run RO proxy: `go run ./cmd/roproxy` | ||
| 3. Run RW proxy: `go run ./cmd/rwproxy` | ||
| 
     | 
||
| Sockets default to `/run/hades/readonly/arangod.sock` and `/run/hades/readwrite/arangod.sock` (systemd-managed). Ensure permissions (0640/0600) and adjust via env vars `LISTEN_SOCKET`, `UPSTREAM_SOCKET`. | ||
| 
     | 
||
| ### Benchmark CLI (Phase 4) | ||
| 
     | 
||
| `tests/benchmarks/arango_connection_test.py` now supports: | ||
| 
     | 
||
| - TTFB and E2E timing (full body consumption). | ||
| - Cache-busting via multiple `--key` values or varying bind variables. | ||
| - Adjustable payload size (`--doc-bytes`), `waitForSync`, and concurrency (`--concurrency`). | ||
| - JSON report emission (`--report-json`) for regression tracking. | ||
| 
     | 
||
| Example: | ||
| 
     | 
||
| ``` | ||
| poetry run python tests/benchmarks/arango_connection_test.py \ | ||
| --socket /run/hades/readonly/arangod.sock \ | ||
| --database arxiv_repository \ | ||
| --collection arxiv_metadata \ | ||
| --key 0704_0001 --key 0704_0002 \ | ||
| --iterations 20 --concurrency 4 \ | ||
| --report-json reports/get_hot.json | ||
| ``` | ||
| 
     | 
||
| ### Testing Infrastructure | ||
| 
     | 
||
| - The HTTP/2 memory client is now the default access path for automated tests. | ||
| - Run `poetry run pytest tests/core/database/test_memory_client_config.py` for a quick sanity check. | ||
| - Future regression suites should share the proxy-aware fixtures so workflows exercise the same transport stack. | ||
| 
     | 
||
| ### Production Hardening Notes | ||
| 
     | 
||
| - Treat the RO (`/run/hades/readonly/arangod.sock`) and RW (`/run/hades/readwrite/arangod.sock`) proxies as the security boundary. Plan to ship them via systemd socket units with explicit `SocketUser`/`SocketGroup` assignments and 0640/0600 modes. | ||
| - Arango HTTP responses are enforced to negotiate HTTP/2; mismatches raise immediately. | ||
| - Reference benchmark summary: see `docs/benchmarks/arango_phase4_summary.md` for the latest latency table. | ||
| - Systemd templates for the proxies live in `docs/deploy/arango_proxy_systemd.md`. | 
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "require": { | ||
| "triagens/arangodb": "^3.8" | ||
| } | ||
| } | 
      
      Oops, something went wrong.
        
    
  
  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.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Embedding path instructions LGTM; ensure code conforms.
Guidance matches learnings (late chunking, JinaV4 vs ST trade-offs). Verify core/workflows actually document trade-offs and never drop tail tokens.
🏁 Script executed:
Length of output: 7257
🏁 Script executed:
Length of output: 75273
Embedding path instructions LGTM — critical fixes required
🤖 Prompt for AI Agents