diff --git a/LICENSE b/LICENSE index faa1d3ce..9ae02a90 100644 --- a/LICENSE +++ b/LICENSE @@ -1,29 +1,69 @@ -Business Source License 1.1 +Context-Engine Source Available License 1.0 -License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. -"Business Source License" is a trademark of MariaDB Corporation Ab. +Licensor: John Donalson (john@context-engine.ai) ------------------------------------------------------------------------------ - -Parameters - -Licensor: John Donalson and Context-Engine Contributors - -Licensed Work: Context-Engine - The Licensed Work is (c) 2025 John Donalson and Context-Engine Contributors. +Copyright (c) 2025 John Donalson. +All rights reserved. -Additional Use Grant: This Additional Use Grant expands the rights above to allow - production use of the Licensed Work for any purpose except - providing a Code Search or Code Intelligence Service. - - A "Code Search or Code Intelligence Service" is a commercial offering - that allows third parties to access the functionality of the Licensed - Work by performing code search, code navigation, code intelligence, - or code analysis as a hosted or managed service. +----------------------------------------------------------------------------- -Change Date: January 10, 2030 +Grant of License + +Permission is hereby granted, free of charge, to any person or Entity +obtaining a copy of this software and associated documentation files (the +"Software"), to use, copy, and modify the Software, subject to the +following conditions: + +1. USE. You may use the Software for any purpose — personal, internal + business, commercial, academic, or governmental — provided that such + use does not violate the Competition Restriction below. + +2. LIMITED MODIFICATION. You may modify the Software, subject to the + following: + (a) You may not distribute, publish, or make publicly available any + modified version of the Software, except by contributing changes + back to the official project repository. + (b) All modifications, derivative works, improvements, additions, and + contributions based on or incorporating the Software (collectively, + "Modifications") are and shall remain the sole and exclusive + intellectual property of the Licensor, John Donalson. + (c) By creating any Modification, you hereby irrevocably assign to the + Licensor all right, title, and interest in and to such Modification, + including all intellectual property rights therein. + (d) You waive any moral rights in your Modifications to the fullest + extent permitted by applicable law. + +3. NO REDISTRIBUTION. You may not sublicense, sell, resell, lease, rent, + lend, distribute, or otherwise transfer the Software or any copy thereof + to any third party, except by directing them to the original source + repository. + +4. COMPETITION RESTRICTION. You may not use the Software, directly or + indirectly, to provide a Competing Service. A "Competing Service" means + any product or service that: + (a) provides code search, code intelligence, code navigation, code + indexing, or semantic code analysis functionality; AND + (b) is made available to third parties as a hosted, managed, cloud-based, + or on-premises service, whether paid or free. + For clarity, using the Software internally within your own organization + for your own code is permitted. Using it to build and sell a code search + or code intelligence product to others is not. + +5. NO REVERSE ENGINEERING. You may not decompile, disassemble, or reverse + engineer any compiled or obfuscated portions of the Software, except to + the extent expressly permitted by applicable law. + +6. ATTRIBUTION. You must retain all copyright notices, this license text, + and any other proprietary notices in all copies of the Software. + +Commercial Licensing + +Use that violates the Competition Restriction, or any use of Premium +Features (see Plugin Licensing below), requires a separate commercial +license from the Licensor. -Change License: GNU General Public License v2.0 or later (GPL-2.0-or-later) +To obtain a commercial license, contact: + Email: john@context-engine.ai ----------------------------------------------------------------------------- @@ -43,7 +83,7 @@ COMMERCIAL LICENSE REQUIRED FOR: - Use in hosted/managed services To obtain a commercial license, contact: - Email: mirlok89@gmail.com + Email: john@context-engine.ai THIRD-PARTY DEPENDENCY - NEO4J DATABASE: The plugin requires Neo4j database software, which is licensed separately @@ -64,65 +104,25 @@ in the base Licensed Work and requires no additional plugin license. ----------------------------------------------------------------------------- -Terms - -The Licensor hereby grants you the right to copy, modify, create derivative -works, redistribute, and make non-production use of the Licensed Work. The -Licensor may make an Additional Use Grant, above, permitting limited -production use. - -Effective on the Change Date, or the fourth anniversary of the first publicly -available distribution of a specific version of the Licensed Work under this -License, whichever comes first, the Licensor hereby grants you rights under -the terms of the Change License, and the rights granted in the paragraph -above terminate. - -If your use of the Licensed Work does not comply with the requirements -currently in effect as described in this License, you must purchase a -commercial license from the Licensor, its affiliated entities, or authorized -resellers, or you must refrain from using the Licensed Work. - -All copies of the original and modified Licensed Work, and derivative works -of the Licensed Work, are subject to this License. This License applies -separately for each version of the Licensed Work and the Change Date may vary -for each version of the Licensed Work released by Licensor. - -You must conspicuously display this License on each original or modified copy -of the Licensed Work. If you receive the Licensed Work in original or -modified form from a third party, the terms and conditions set forth in this -License apply to your use of that work. - -Any use of the Licensed Work in violation of this License will automatically -terminate your rights under this License for the current and all other -versions of the Licensed Work. - -This License does not grant you any right in any trademark or logo of -Licensor or its affiliates (provided that you may use a trademark or logo of -Licensor as expressly required by this License). - -TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. - -MariaDB hereby grants you permission to use this License's text to license -your works, and to refer to it using the trademark "Business Source License", -as long as you comply with the Covenants of Licensor below. - -Covenants of Licensor - -In consideration of the right to use this License's text and the "Business -Source License" name and trademark, Licensor covenants to MariaDB, and to -all other recipients of the licensed work to be provided by Licensor: - -1. To specify as the Change License the GPL Version 2.0 or any later version, - or a license that is compatible with GPL Version 2.0 or a later version, - where "compatible" means that software provided under the Change License - can be included in a program with software provided under GPL Version 2.0 - or a later version. Licensor may specify additional Change Licenses without - limitation. -2. To either: (a) specify an additional grant of rights to use that does not - impose any additional restriction on the right granted in this License, as - the Additional Use Grant; or (b) insert the text "None". -3. To specify a Change Date. -4. Not to modify this License in any other way. +Termination + +Any use of the Software in violation of this License will automatically and +immediately terminate your rights under this License. Upon termination, you +must cease all use of the Software and destroy all copies in your possession. + +----------------------------------------------------------------------------- + +Disclaimer of Warranty + +TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS IS", +WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, +NON-INFRINGEMENT, AND TITLE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE SOFTWARE IS WITH YOU. + +Limitation of Liability + +IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING +FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/package.json b/package.json index 6b97a078..9e5a9d58 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "context-engine", "private": true, "version": "0.0.1", - "license": "BUSL-1.1", + "license": "SEE LICENSE IN LICENSE", "type": "module", "scripts": { "dev": "vite dev", diff --git a/scripts/workspace_state.py b/scripts/workspace_state.py index 14fcf105..5e0bc293 100644 --- a/scripts/workspace_state.py +++ b/scripts/workspace_state.py @@ -41,6 +41,8 @@ _cache_memo_last_check: Dict[str, float] = {} _REDIS_CLIENT = None _REDIS_CLIENT_LOCK = threading.Lock() +_REDIS_BIN_CLIENT = None +_REDIS_BIN_CLIENT_LOCK = threading.Lock() # Global flag to enable skip-if-contended behavior for Redis locks. # When set, locks that are contended will raise LockContendedException @@ -126,6 +128,49 @@ def _get_redis_client(): return None +def _get_redis_bin_client(): + """Return a Redis client with decode_responses=False for binary data (LZ4).""" + if not _redis_state_enabled(): + return None + global _REDIS_BIN_CLIENT + with _REDIS_BIN_CLIENT_LOCK: + if _REDIS_BIN_CLIENT is not None: + return _REDIS_BIN_CLIENT + try: + import redis # type: ignore + except Exception as e: + logger.warning(f"Redis binary client: redis package not available: {e}") + return None + url = os.environ.get("CODEBASE_STATE_REDIS_URL") or os.environ.get("REDIS_URL") or "redis://redis:6379/0" + try: + socket_timeout = float(os.environ.get("CODEBASE_STATE_REDIS_SOCKET_TIMEOUT", "2") or 2) + connect_timeout = float(os.environ.get("CODEBASE_STATE_REDIS_CONNECT_TIMEOUT", "2") or 2) + max_connections = int(os.environ.get("CODEBASE_STATE_REDIS_MAX_CONNECTIONS", "10") or 10) + except Exception: + socket_timeout = 2.0 + connect_timeout = 2.0 + max_connections = 10 + try: + client = redis.Redis.from_url( + url, + decode_responses=False, + socket_timeout=socket_timeout, + socket_connect_timeout=connect_timeout, + max_connections=max_connections, + retry_on_timeout=True, + ) + try: + client.ping() + except Exception as e: + logger.warning(f"Redis binary client ping failed: {e}") + return None + _REDIS_BIN_CLIENT = client + return _REDIS_BIN_CLIENT + except Exception as e: + logger.warning(f"Redis binary client connection failed: {e}") + return None + + def _redis_retry(fn, retries: int = 2, delay: float = 0.1): """Retry a Redis operation on transient failures.""" last_err = None @@ -186,20 +231,18 @@ def _redis_decompress(data: bytes) -> bytes: def _redis_get_json(kind: str, path: Path) -> Optional[Dict[str, Any]]: - client = _get_redis_client() + client = _get_redis_bin_client() if client is None: return None key = _redis_key_for_path(kind, path) try: - # Get raw bytes for decompression - raw = _redis_retry(lambda: client.execute_command("GET", key)) + raw = _redis_retry(lambda: client.get(key)) except Exception as e: logger.debug(f"Redis get failed for {key}: {e}") return None if not raw: return None try: - # Handle both string and bytes responses if isinstance(raw, str): raw = raw.encode("utf-8") decompressed = _redis_decompress(raw) @@ -258,7 +301,7 @@ def _redis_scan_keys(kind: str) -> List[str]: def _redis_get_json_by_key(key: str) -> Optional[Dict[str, Any]]: - client = _get_redis_client() + client = _get_redis_bin_client() if client is None: return None try: @@ -269,7 +312,10 @@ def _redis_get_json_by_key(key: str) -> Optional[Dict[str, Any]]: if not raw: return None try: - obj = json.loads(raw) + if isinstance(raw, str): + raw = raw.encode("utf-8") + decompressed = _redis_decompress(raw) + obj = json.loads(decompressed.decode("utf-8")) except Exception as e: logger.debug(f"Redis JSON decode failed for {key}: {e}") return None diff --git a/vscode-extension/context-engine-uploader/package-lock.json b/vscode-extension/context-engine-uploader/package-lock.json new file mode 100644 index 00000000..938281a2 --- /dev/null +++ b/vscode-extension/context-engine-uploader/package-lock.json @@ -0,0 +1,15 @@ +{ + "name": "context-engine-uploader", + "version": "0.1.50", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "context-engine-uploader", + "version": "0.1.50", + "engines": { + "vscode": "^1.85.0" + } + } + } +}