Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions brainfuck/.generation_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"agent": "OpenClaw",
"initialized_with": "/claim"
}
1 change: 1 addition & 0 deletions brainfuck/fizzbuzz.bf

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions fastapi/_provenance.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tool_name": "AI Engineer",
"boot_context": "AI Engineer agent running in OpenClaw on Windows (host=RyanPC, model=qclaw/pool-minimax-m2.7, channel=webchat). Persona:务实的数据驱动派,用工程化思维把模型从Notebook送到生产。SOUL.md directive: no baseline experiment skip, no offline evaluation skip, inference service must have fallback strategy, never use unverified model in production, release GPU resources after training. Skills: ai-engineer SKILL.md loaded. Task context: User requested to find and complete GitHub bounty tasks worth ~$5-10 from UnsafeLabs/Bounty-Hunters repo. Strategy: claim 1 at a time, max 3-5 PRs/day, prioritize AI-only issues with low competition. Prior completed PRs: #4136 (t3code turbo.json) and #4137 (laravel console.php) both CI green and awaiting merge. Current session also involves setting up GitHub CLI (gh) installation at D:\\Tools\\gh\\bin\\gh.exe and verifying auth status. User GitHub account: lry3069-afk. Working directory: D:\\QClaw\\.qclaw\\Github Job\\Bounty-Hunters.",
"timestamp": "2026-05-25T04:27:00.000Z"
}
5 changes: 5 additions & 0 deletions fastapi/fastapi/.attribution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tool": "lry3069-afk",
"platform_config": "OpenClaw AI Agent - FastAPI Pagination Utility Implementation",
"date": "2026-05-25"
}
4 changes: 4 additions & 0 deletions fastapi/fastapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@
from .routing import APIRouter as APIRouter
from .websockets import WebSocket as WebSocket
from .websockets import WebSocketDisconnect as WebSocketDisconnect
from .pagination import CursorPaginator as CursorPaginator
from .pagination import OffsetPaginator as OffsetPaginator
from .pagination import PaginatedResponse as PaginatedResponse
from .pagination import paginate as paginate
10 changes: 10 additions & 0 deletions fastapi/fastapi/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,15 @@ def include_router(
"""
),
] = Default(generate_unique_id),
middleware: Annotated[
Sequence[Callable[[Any], Any]] | None,
Doc(
"""
A list of middleware to be applied to all *path operations*
in the included router.
"""
),
] = None,
) -> None:
"""
Include an `APIRouter` in the same app.
Expand Down Expand Up @@ -1558,6 +1567,7 @@ def include_router(
default_response_class=default_response_class,
callbacks=callbacks,
generate_unique_id_function=generate_unique_id_function,
middleware=middleware,
)

def get(
Expand Down
69 changes: 69 additions & 0 deletions fastapi/fastapi/middleware/requestid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import logging
from contextvars import ContextVar
from typing import Callable

from starlette.middleware.base import BaseHTTPMiddleware
from starlette.requests import Request
from starlette.responses import Response
from uuid import uuid4

from fastapi.logger import logger

request_id_var: ContextVar[str | None] = ContextVar("request_id", default=None)


def get_request_id() -> str | None:
"""Get the current request ID from the context variable."""
return request_id_var.get()


class RequestIDFilter(logging.Filter):
"""Logging filter that injects the current request ID into log records."""

def filter(self, record: logging.LogRecord) -> bool:
request_id = request_id_var.get()
if request_id:
record.request_id = request_id
else:
record.request_id = "-"
return True


# Attach filter to the fastapi logger (and root handler if present)
_fastapi_logger = logging.getLogger("fastapi")
_fastapi_logger.addFilter(RequestIDFilter())

# Also attach to root logger handlers so all log calls during a request include the ID
_root = logging.getLogger()
_root.addFilter(RequestIDFilter())


class RequestIDMiddleware(BaseHTTPMiddleware):
"""Middleware that generates a unique request ID for each incoming request.

- Uses client-supplied X-Request-ID header if present, otherwise generates a UUID.
- Stores the request ID in request.state for access in route handlers.
- Adds X-Request-ID to the response headers.
- Injects request ID into all log messages during the request lifecycle via contextvars.
- Uses contextvars so concurrent requests never share or leak request IDs.
"""

async def dispatch(self, request: Request, call_next: Callable) -> Response:
# Prefer client-supplied X-Request-ID, otherwise generate a UUID
client_request_id = request.headers.get("x-request-id")
request_id = client_request_id if client_request_id else str(uuid4())

# Store in request.state so route handlers can access it
request.state.request_id = request_id

# Bind request ID to this async context; reset after the request
token = request_id_var.set(request_id)

try:
response = await call_next(request)
finally:
request_id_var.reset(token)

# Always echo back the request ID in the response
response.headers["X-Request-ID"] = request_id
return response
Loading
Loading