codegraphcontext 0.6.12__py3-none-any.whl → 0.6.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,16 +32,59 @@ DEFAULT_EMBEDDED_BUFFER_POOL_BYTES = 4 * 1024**3
32
32
  MIN_DEFAULT_BUFFER_POOL_BYTES = 256 * 1024**2
33
33
 
34
34
 
35
+ def _cgroup_available_bytes():
36
+ """Memory headroom under the container's cgroup limit, or None when
37
+ unconfined. /proc/meminfo shows the HOST inside a container, so a pod
38
+ capped at 1 GiB on a 64 GiB host would otherwise size a 4 GiB pool and
39
+ be OOM-killed natively at first touch."""
40
+ # cgroup v2 (unified hierarchy)
41
+ try:
42
+ with open("/sys/fs/cgroup/memory.max") as f:
43
+ raw = f.read().strip()
44
+ if raw != "max":
45
+ limit = int(raw)
46
+ usage = 0
47
+ try:
48
+ with open("/sys/fs/cgroup/memory.current") as f:
49
+ usage = int(f.read().strip())
50
+ except (OSError, ValueError):
51
+ pass
52
+ return max(limit - usage, 0)
53
+ except (OSError, ValueError):
54
+ pass
55
+ # cgroup v1
56
+ try:
57
+ with open("/sys/fs/cgroup/memory/memory.limit_in_bytes") as f:
58
+ limit = int(f.read().strip())
59
+ if limit < 1 << 60: # v1 reports ~8 EiB when unlimited
60
+ usage = 0
61
+ try:
62
+ with open("/sys/fs/cgroup/memory/memory.usage_in_bytes") as f:
63
+ usage = int(f.read().strip())
64
+ except (OSError, ValueError):
65
+ pass
66
+ return max(limit - usage, 0)
67
+ except (OSError, ValueError):
68
+ pass
69
+ return None
70
+
71
+
35
72
  def _available_memory_bytes():
36
- """MemAvailable from /proc/meminfo, or None where unavailable (macOS…)."""
73
+ """The tighter of host MemAvailable (/proc/meminfo) and the cgroup
74
+ memory headroom, or None where neither is readable (macOS…)."""
75
+ host = None
37
76
  try:
38
77
  with open("/proc/meminfo") as f:
39
78
  for line in f:
40
79
  if line.startswith("MemAvailable:"):
41
- return int(line.split()[1]) * 1024
80
+ host = int(line.split()[1]) * 1024
81
+ break
42
82
  except OSError:
43
83
  pass
44
- return None
84
+ cgroup = _cgroup_available_bytes()
85
+ if host is not None and cgroup is not None:
86
+ return min(host, cgroup)
87
+ return host if host is not None else cgroup
45
88
 
46
89
 
47
90
  def resolve_embedded_buffer_pool_size() -> int:
@@ -803,6 +803,11 @@ class MCPServer:
803
803
  async def _run_loop(self, loop):
804
804
  request_count = 0
805
805
  while True:
806
+ # Reset per iteration: on a parse error `request` would otherwise
807
+ # still hold the PREVIOUS request, and the error response would
808
+ # reuse its id — a second response for an already-answered id,
809
+ # which desyncs clients that match responses by id.
810
+ request = None
806
811
  try:
807
812
  if request_count and request_count % 50 == 0:
808
813
  self.job_manager.cleanup_old_jobs(max_age_hours=24)
@@ -880,15 +885,19 @@ class MCPServer:
880
885
 
881
886
  except Exception as e:
882
887
  error_logger(f"Error processing request: {e}\n{traceback.format_exc()}")
883
- request_id = "unknown"
884
- if 'request' in locals() and isinstance(request, dict):
885
- request_id = request.get('id', "unknown")
888
+ # JSON-RPC: parse errors respond with id null and -32700;
889
+ # errors while handling a parsed request keep that request's id.
890
+ request_id = request.get('id') if isinstance(request, dict) else None
891
+ is_parse_error = not isinstance(request, dict)
886
892
 
887
893
  error_response = {
888
894
  "jsonrpc": "2.0", "id": request_id,
889
895
  "error": {
890
- "code": -32603,
891
- "message": f"Internal error: {str(e)}",
896
+ "code": -32700 if is_parse_error else -32603,
897
+ "message": (
898
+ f"Parse error: {str(e)}" if is_parse_error
899
+ else f"Internal error: {str(e)}"
900
+ ),
892
901
  },
893
902
  }
894
903
  print(json.dumps(error_response), flush=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codegraphcontext
3
- Version: 0.6.12
3
+ Version: 0.6.13
4
4
  Summary: An MCP server that indexes local code into a graph database to provide context to AI assistants.
5
5
  Author-email: Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
6
6
  License: MIT License
@@ -1,7 +1,7 @@
1
1
  codegraphcontext/__init__.py,sha256=mFY5raGZpG90gG6E8NH0R85mDl3Ikak2HQHOiwCXl-I,77
2
2
  codegraphcontext/__main__.py,sha256=21QjL_lfd6cy-clJYPBg6xKb_IuNDcvvWdaAJEvZ-HQ,99
3
3
  codegraphcontext/prompts.py,sha256=aK_oe7DQwHNYtpjOy5aqi2VTKs4KJihwF6O4E8z3IPA,8603
4
- codegraphcontext/server.py,sha256=aaplzU_SlkVsPdwiyf6RvXnGqnkvDilvrbC_euUYcAU,37408
4
+ codegraphcontext/server.py,sha256=EN4cHusoyn7FBHvJGUSAnQKgPyMtGhUhu3voVJ1mXTY,38023
5
5
  codegraphcontext/stdlibs.py,sha256=sWcjgJyGIGewilnBt4qXogw2cH4YWwHWkEXbCSIv5Zc,283
6
6
  codegraphcontext/tool_definitions.py,sha256=11A_9cOo_l9vunBUcM8xcxZFJMBsKx2_U4-bMwcjfH8,20001
7
7
  codegraphcontext/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -26,7 +26,7 @@ codegraphcontext/core/bundle_registry.py,sha256=xlVBe-fmvEOLY9xDq7w0vXFlTPzeFVIw
26
26
  codegraphcontext/core/cgc_bundle.py,sha256=tgcsfIzHxPTr2ktioN43mzS1JyYHeqFjnHXj9fKapY8,77146
27
27
  codegraphcontext/core/cgcignore.py,sha256=yJeRaPlDyOaSGGdXB5kwBlSqpEXtrqsSzo0UNMoqef8,12236
28
28
  codegraphcontext/core/database.py,sha256=ZLOHXv46hVxWiPYQala0Co7_Z8vqj5juaenudwq6DTU,14893
29
- codegraphcontext/core/database_embedded_kuzu.py,sha256=b-Xsu8HqoEbQhCQkIa-mGIYfsHIinhQDLe2G1GK-Umc,94058
29
+ codegraphcontext/core/database_embedded_kuzu.py,sha256=-vHI4xdbHgYwAfLQOcTfTTL_ijdyPvMIqNFHZzJQCg4,95641
30
30
  codegraphcontext/core/database_falkordb.py,sha256=8TSFfgKoaNdTzSx7P4qXMMs2kTNBzrcW5tZxR8JV4bY,35834
31
31
  codegraphcontext/core/database_falkordb_remote.py,sha256=HdkcmwgUxPy1bwiFqqcU8yMQYib7B3JarYQ1LlTwfJ8,7957
32
32
  codegraphcontext/core/database_kuzu.py,sha256=5I31dGm7wRo3YjIWeWGRVcX1eYRXYc7fPWnT7zHFjf0,1123
@@ -175,9 +175,9 @@ codegraphcontext/viz/dist/wasm/tree-sitter-typescript.wasm,sha256=hRVATc7tOOHthq
175
175
  codegraphcontext/viz/dist/wasm/tree-sitter.wasm,sha256=CCeVuI_hXktkBD-DW01xYPv5XoAYVRIqzJUJI5te-RY,196763
176
176
  codegraphcontext/viz/dist/wasm/web-tree-sitter.js,sha256=DIaCNqRylrT_PBVw8g4ImeSnhP9uXNe_ycOlUiVGPko,153666
177
177
  codegraphcontext/viz/dist/wasm/web-tree-sitter.wasm,sha256=CCeVuI_hXktkBD-DW01xYPv5XoAYVRIqzJUJI5te-RY,196763
178
- codegraphcontext-0.6.12.dist-info/licenses/LICENSE,sha256=rh8M-bJpQYJnw2vtRVgt0t7piMZXh5QzaKeNEI0vqqA,1061
179
- codegraphcontext-0.6.12.dist-info/METADATA,sha256=n0nhnZJEoOblr8ZkyYgdJwn4cF31t4QWYuWa_TrJf8g,34227
180
- codegraphcontext-0.6.12.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
181
- codegraphcontext-0.6.12.dist-info/entry_points.txt,sha256=LCxWCWMshdvYGoHBPuQZ8C-e4CiNSHCLXofrNSGHkoE,103
182
- codegraphcontext-0.6.12.dist-info/top_level.txt,sha256=CBgc6LAPZIO5FS0nSYYkylDifHsZTIqw3Gf5UwDxeGI,17
183
- codegraphcontext-0.6.12.dist-info/RECORD,,
178
+ codegraphcontext-0.6.13.dist-info/licenses/LICENSE,sha256=rh8M-bJpQYJnw2vtRVgt0t7piMZXh5QzaKeNEI0vqqA,1061
179
+ codegraphcontext-0.6.13.dist-info/METADATA,sha256=rE5iPIrSmM0RuDOXq5NMPg2W4Lkmfg3kWLD5-1OXn9o,34227
180
+ codegraphcontext-0.6.13.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
181
+ codegraphcontext-0.6.13.dist-info/entry_points.txt,sha256=LCxWCWMshdvYGoHBPuQZ8C-e4CiNSHCLXofrNSGHkoE,103
182
+ codegraphcontext-0.6.13.dist-info/top_level.txt,sha256=CBgc6LAPZIO5FS0nSYYkylDifHsZTIqw3Gf5UwDxeGI,17
183
+ codegraphcontext-0.6.13.dist-info/RECORD,,