-
Notifications
You must be signed in to change notification settings - Fork 107
Staging->main #391
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
Staging->main #391
Changes from all commits
367ce8e
9bf6497
ddfe7bc
71bb1cd
6489f85
1dbbc58
67d82b9
e1b8588
755a2f4
3f5e4d7
4c00d49
dddfbb5
31ba4ef
bfef44f
8af91e5
cddd3eb
444e271
ce084c2
870a0c2
784c386
989bac7
93df5c9
c2b3551
48eba40
904f859
d7d4d2a
dc8e04b
f060d88
b6d2b67
927675c
364bbc1
befe74e
351082b
40bf368
0103263
3dd4d13
9859c08
d767956
90c6a5c
de08a9a
b884bb9
8ba85e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,3 +95,4 @@ Sanitization | |
| JOINs | ||
| subqueries | ||
| subquery | ||
| TTL | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| netcat-openbsd \ | ||
| git \ | ||
| build-essential \ | ||
| curl \ | ||
| ca-certificates \ | ||
| gnupg \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| && ln -sf /usr/local/bin/python3.12 /usr/bin/python3 \ | ||
| && ln -sf /usr/local/bin/python3.12 /usr/bin/python | ||
|
|
@@ -36,9 +39,15 @@ RUN PIP_BREAK_SYSTEM_PACKAGES=1 pipenv sync --system | |
|
|
||
| # Install Node.js (Node 22) so we can build the frontend inside the image. | ||
| # Use NodeSource setup script to get a recent Node version on Debian-based images. | ||
| RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ | ||
| && apt-get update && apt-get install -y nodejs \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| # Remove any pre-installed nodejs first to avoid conflicts. | ||
| RUN apt-get update \ | ||
| && apt-get remove -y nodejs || true \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ | ||
| && apt-get update \ | ||
| && apt-get install -y nodejs \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| && node --version && npm --version | ||
|
Comment on lines
+43
to
+50
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shell operator precedence issue silently swallows Because Additionally, Proposed fix-RUN apt-get update \
- && apt-get remove -y nodejs || true \
- && rm -rf /var/lib/apt/lists/* \
- && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
- && apt-get update \
- && apt-get install -y nodejs \
- && rm -rf /var/lib/apt/lists/* \
- && node --version && npm --version
+RUN apt-get update \
+ && (apt-get remove -y nodejs || true) \
+ && rm -rf /var/lib/apt/lists/* \
+ && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
+ && apt-get update \
+ && apt-get install -y --no-install-recommends nodejs \
+ && rm -rf /var/lib/apt/lists/* \
+ && node --version && npm --version🧰 Tools🪛 Trivy (0.69.1)[error] 43-50: 'apt-get' missing '--no-install-recommends' '--no-install-recommends' flag is missed: 'apt-get update && apt-get remove -y nodejs || true && rm -rf /var/lib/apt/lists/* && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && apt-get update && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/* && node --version && npm --version' Rule: DS-0029 (IaC/Dockerfile) 🤖 Prompt for AI Agents |
||
|
|
||
| # Copy only frontend package files so Docker can cache npm installs when | ||
| # package.json / package-lock.json don't change. | ||
|
|
@@ -57,7 +66,7 @@ COPY ./app ./app | |
|
|
||
| RUN npm --prefix ./app run build | ||
|
|
||
| # Copy application code | ||
| # Copy application code | ||
| COPY . . | ||
|
Comment on lines
+69
to
70
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if .dockerignore exists and what it excludes related to app/ build artifacts
if [ -f .dockerignore ]; then
echo "=== .dockerignore contents ==="
cat .dockerignore
else
echo "WARNING: No .dockerignore found"
fiRepository: FalkorDB/QueryWeaver Length of output: 95 🏁 Script executed: #!/bin/bash
# Check the Dockerfile around lines 69-70 for full context
echo "=== Dockerfile (full content) ==="
if [ -f Dockerfile ]; then
cat -n Dockerfile
else
echo "Dockerfile not found"
fi
echo ""
echo "=== .gitignore contents ==="
if [ -f .gitignore ]; then
cat .gitignore
else
echo "No .gitignore found"
fi
echo ""
echo "=== Check if app/node_modules or app/dist exist in repo ==="
git ls-files | grep -E '(app/node_modules|app/dist|app/build)' | head -20 || echo "No committed build artifacts or node_modules found"Repository: FalkorDB/QueryWeaver Length of output: 3629
The subsequent 🤖 Prompt for AI Agents |
||
|
|
||
| # Copy and make start.sh executable | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,17 @@ docker run -p 5000:5000 -it \ | |
|
|
||
| > For a full list of configuration options, consult `.env.example`. | ||
|
|
||
| ## Memory TTL (optional) | ||
|
|
||
| QueryWeaver stores per-user conversation memory in FalkorDB. By default these graphs persist indefinitely. Set `MEMORY_TTL_SECONDS` to apply a Redis TTL (in seconds) so idle memory graphs are automatically cleaned up. | ||
|
|
||
| ```bash | ||
| # Expire memory graphs after 1 week of inactivity | ||
| MEMORY_TTL_SECONDS=604800 | ||
| ``` | ||
|
|
||
| The TTL is refreshed on every user interaction, so active users keep their memory. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Documentation may overstate the TTL refresh guarantee. Line 69 says "The TTL is refreshed on every user interaction." As noted in the 🤖 Prompt for AI Agents |
||
|
|
||
| ## MCP server: host or connect (optional) | ||
|
|
||
| QueryWeaver includes optional support for the Model Context Protocol (MCP). You can either have QueryWeaver expose an MCP-compatible HTTP surface (so other services can call QueryWeaver as an MCP server), or configure QueryWeaver to call an external MCP server for model/context services. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,14 @@ async def dispatch(self, request: Request, call_next): | |
| return JSONResponse(status_code=403, content={"detail": "Forbidden"}) | ||
|
|
||
| response = await call_next(request) | ||
|
|
||
| # Add HSTS header to prevent man-in-the-middle attacks | ||
| # max-age=31536000: 1 year in seconds | ||
| # includeSubDomains: apply to all subdomains | ||
| # preload: eligible for browser HSTS preload lists | ||
| hsts_value = "max-age=31536000; includeSubDomains; preload" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [BLOCKER]: Middleware is stacked LIFO, so adding |
||
| response.headers["Strict-Transport-Security"] = hsts_value | ||
|
|
||
| return response | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ | |
| from typing import List, Dict, Any, Optional, Tuple | ||
| from datetime import datetime | ||
|
|
||
| from redis import RedisError | ||
|
|
||
| # Import Azure OpenAI components | ||
| from openai import AsyncAzureOpenAI | ||
|
|
||
|
|
@@ -47,10 +49,18 @@ def extract_embedding_model_name(full_model_name: str) -> str: | |
| class MemoryTool: | ||
| """Memory management tool for handling user memories and interactions.""" | ||
|
|
||
| # Optional TTL (in seconds) for the memory graph key. Set via MEMORY_TTL_SECONDS | ||
| # env var to enable automatic expiry (e.g. 604800 for 1 week). Unset = no expiry. | ||
| MEMORY_TTL_SECONDS: Optional[int] = ( | ||
| int(os.environ["MEMORY_TTL_SECONDS"]) | ||
| if os.environ.get("MEMORY_TTL_SECONDS") | ||
| else None | ||
| ) | ||
|
Comment on lines
+54
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If someone sets 🛡️ Proposed defensive parsing- MEMORY_TTL_SECONDS: Optional[int] = (
- int(os.environ["MEMORY_TTL_SECONDS"])
- if os.environ.get("MEMORY_TTL_SECONDS")
- else None
- )
+ `@staticmethod`
+ def _parse_ttl() -> Optional[int]:
+ raw = os.environ.get("MEMORY_TTL_SECONDS")
+ if not raw:
+ return None
+ try:
+ return int(raw)
+ except ValueError:
+ logging.warning("Invalid MEMORY_TTL_SECONDS=%r, ignoring", raw)
+ return None
+
+ MEMORY_TTL_SECONDS: Optional[int] = _parse_ttl()🤖 Prompt for AI Agents |
||
|
|
||
| def __init__(self, user_id: str, graph_id: str): | ||
| # Create FalkorDB driver with user-specific database | ||
| user_memory_db = f"{user_id}-memory" | ||
| falkor_driver = FalkorDriver(falkor_db=db, database=user_memory_db) | ||
| self.memory_db_name = f"{user_id}-memory" | ||
| falkor_driver = FalkorDriver(falkor_db=db, database=self.memory_db_name) | ||
|
|
||
|
|
||
| # Create Graphiti client with Azure OpenAI configuration | ||
|
|
@@ -60,6 +70,13 @@ def __init__(self, user_id: str, graph_id: str): | |
| self.graph_id = graph_id | ||
|
|
||
|
|
||
| async def _refresh_ttl(self) -> None: | ||
| """Set a TTL on the memory graph key using Redis EXPIRE.""" | ||
| try: | ||
| await db.execute_command("EXPIRE", self.memory_db_name, self.MEMORY_TTL_SECONDS) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [MAJOR]: |
||
| except RedisError as e: | ||
| logging.warning("Failed to refresh TTL for %s: %s", self.memory_db_name, e) | ||
|
|
||
| @classmethod | ||
| async def create(cls, user_id: str, graph_id: str, use_direct_entities: bool = True) -> "MemoryTool": | ||
| """Async factory to construct and initialize the tool.""" | ||
|
|
@@ -72,6 +89,9 @@ async def create(cls, user_id: str, graph_id: str, use_direct_entities: bool = T | |
| driver = self.graphiti_client.driver | ||
| await driver.execute_query(f"CREATE VECTOR INDEX FOR (p:Query) ON (p.embeddings) OPTIONS {{dimension:{vector_size}, similarityFunction:'euclidean'}}") | ||
|
|
||
| if cls.MEMORY_TTL_SECONDS is not None: | ||
| await self._refresh_ttl() | ||
|
Comment on lines
+92
to
+93
|
||
|
|
||
| return self | ||
|
|
||
| async def _ensure_entity_nodes_direct(self, user_id: str, database_name: str) -> bool: | ||
|
|
||
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.
Missing
target-branch: "staging"— intentional?The
pipandnpmentries both targetstaging, but this newgithub-actionsentry omitstarget-branch, so Dependabot will open PRs against the default branch (main). If the intent is to keep all dependency PRs flowing throughstagingfirst, addtarget-branch: "staging"here as well.Proposed fix
- package-ecosystem: "github-actions" directory: "/" + target-branch: "staging" schedule: interval: "weekly"📝 Committable suggestion
🤖 Prompt for AI Agents