-
Notifications
You must be signed in to change notification settings - Fork 57
[MISSION #80-82] Elite Search & Infrastructure Upgrade (T1 Full Suite) #797
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
Changes from 17 commits
348c545
50c182b
f7ea698
2994917
5bdef27
85ff668
5bb1e63
2163cce
8261b46
c67dde6
88dbe0f
13db96e
3e496e5
b432095
d876193
60f63e3
eafd2a8
560b781
856fe7d
f413054
84480b9
362f228
90380bd
700bed5
bca5dae
4262ad6
2d4f899
5b00e9d
3fc7580
b0f98b5
d2a3c6b
c65f1c6
efb12a2
127f6bf
fc969ef
d36ebda
7a00012
33d605d
3861beb
e35690a
3a4b522
c303df5
f2ffd58
c0ecd33
5df2e46
6294979
e038e24
2336e7e
0672840
7e7cd75
39c0866
28311ae
7088a40
8607862
f845ccc
4911a94
25e3128
4fe2906
89392a4
ca6ebd4
b4d7242
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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # System Reliability Engineering Prompt (Mission #80) | ||
|
|
||
| Act as a Senior Backend Architect specializing in Reliability Engineering and FastAPI. | ||
|
|
||
| ## Context | ||
| We are upgrading the SolFoundry backend health monitoring suite. The goal is to move from basic connectivity checks to comprehensive infrastructure telemetry. | ||
|
|
||
| ## Task | ||
| Implement the `GET /api/health` logic in `backend/app/api/health.py` based on the provided specifications. | ||
|
|
||
| ## Key Requirements for the Implementation: | ||
| 1. **Parallelism**: Use `asyncio.gather` to poll PostgreSQL, Redis, Solana RPC, and GitHub API simultaneously. | ||
| 2. **Robustness**: Implement strict timeouts for each check to avoid cascading delays. | ||
| 3. **Telemetry**: Integrate `psutil` to extract core system health (CPU/RAM). | ||
| 4. **Clean Schema**: Ensure the JSON response is structured for easy parsing by external monitors (e.g., Datadog, Prometheus). | ||
|
|
||
| ## Input Files: | ||
| - `backend/app/api/health.py` (Current implementation) | ||
| - `Mission_80_Specs.md` | ||
|
|
||
| Please provide the complete Python code for the enhanced `health.py` module. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Mission #80: SolFoundry API Health Check Upgrade (Elite Suite) | ||
|
|
||
| ## 🎯 Objective | ||
| Implement a robust, production-grade health monitoring system for the SolFoundry FastAPI backend. This system must provide real-time status of internal dependencies and external infrastructure integrations. | ||
|
|
||
| ## 🏗️ Technical Requirements | ||
|
|
||
| ### 1. Endpoint Specification | ||
| - **Path**: `GET /api/health` | ||
| - **Output**: JSON object with nested service statuses. | ||
| - **Success Code**: `200 OK` (All core services healthy). | ||
| - **Failure Code**: `503 Service Unavailable` (Core services degraded). | ||
|
|
||
| ### 2. Monitoring Targets | ||
|
|
||
| #### A. Internal Services | ||
| - **Database**: PostgreSQL connectivity (SQLAlchemy/Alembic). | ||
| - **Redis**: Cache and Task Queue availability. | ||
|
|
||
| #### B. External Infrastructure | ||
| - **Solana RPC**: Execute `getHealth` on the configured cluster (Mainnet/Devnet). | ||
| - **GitHub API**: Check current rate-limit usage to prevent integration downtime during bounty sync. | ||
|
|
||
| #### C. System Telemetry | ||
| - **CPU Usage**: Average percentage across all cores. | ||
| - **Memory Consumption**: Available vs. Total RAM. | ||
| - **Disk I/O**: Available space on the logging/data partition. | ||
|
|
||
| ### 🛠️ Architecture Guidelines | ||
| - Use `asyncio.gather` for parallelized checking to prevent endpoint lag. | ||
| - Implement short timeouts (e.g., 200ms) for dependency checks to ensure fast failover detection. | ||
| - Unified status mapping: `healthy`, `degraded`, or `unavailable`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # AI Prompt: Implementing Elite Search for SolFoundry (Mission #82) | ||
|
|
||
| **Role**: Senior Backend Architect (FastAPI / PostgreSQL Specialist). | ||
| **Task**: Upgrade the SolFoundry Bounty Search Engine to "Elite" Tier (Mission #82). | ||
|
|
||
| **Current Context**: | ||
| - Repository: SolFoundry (Solana-based AI Software Factory). | ||
| - Language: Python 3.11, FastAPI, SQLAlchemy (Async). | ||
| - Search: PostgreSQL `tsvector` with `plainto_tsquery`. | ||
| - Files for reference: | ||
| - `backend/app/api/bounties.py` (Router with the bug) | ||
| - `backend/app/services/bounty_search_service.py` (Core search logic) | ||
| - `backend/app/models/bounty_table.py` (SQLAlchemy schema) | ||
| - `backend/app/models/bounty.py` (Pydantic models) | ||
|
|
||
| **Mission Objectives**: | ||
| 1. **Add `project_name`**: The frontend (React) expects `projectName` (camelCase in JSON, `project_name` in DB). Add it to all layers and ensure it's searchable. | ||
| 2. **Optimizer Search Vector**: Currently, the `search_vector` handles title and description. Extend it to include `project_name` with higher weight. | ||
| 3. **Fix Router Bug**: Ensure `deadline_before` is correctly passed and handled as a `datetime` object in `BountySearchParams`. | ||
| 4. **Skills Selection Logic**: Implement a way to toggle between "Contains ANY of these skills" (OR) and "Contains ALL of these skills" (AND) in the API. PostgreSQL `?&` vs `?|` operators. | ||
| 5. **Refine Ranking**: How can we balance text relevance (Rank) with bounty popularity and reward size? | ||
|
|
||
| **Instructions**: | ||
| - Provide the corrected code blocks for `bounties.py`, `bounty_search_service.py`, and the model files. | ||
| - Ensure type safety (Pydantic) and asynchronous DB access. | ||
| - Propose a SQL migration strategy or explain how the `search_vector` should be regenerated. | ||
| - Keep the code "Elite": performant, clean, and properly documented. | ||
|
|
||
| **Let's build the best search engine on Solana.** |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Technical Specification: SolFoundry Bounty Search Engine (Mission #82) | ||
|
|
||
| ## Context | ||
| SolFoundry requires a high-performance "Elite" search engine for the bounty board. The current implementation uses PostgreSQL Full-Text Search (TSVECTOR) but has significant gaps: | ||
| 1. **Missing Metadata**: `projectName` is used in the frontend but doesn't exist in the database or search index. | ||
| 2. **Routing Bug**: The `deadline_before` filter is present in the API schema but isn't passed from the router to the search service. | ||
| 3. **Skill Filtering Logic**: Currently uses a simple "OR" check (`?|` operator). Advanced hunters need "AND" logic to find specific multi-skill stacks. | ||
|
|
||
| ## Core Requirements | ||
|
|
||
| ### 1. Unified Search Vector | ||
| Update the PostgreSQL `search_vector` to include more weights: | ||
| - **Weight A**: Title | ||
| - **Weight B**: Project Name (NEW) | ||
| - **Weight C**: Description | ||
| - **Weight D**: Category / Required Skills (optional) | ||
|
|
||
| ### 2. Schema Normalization | ||
| - Add `project_name: VARCHAR(100)` to the `bounties` table. | ||
| - Sync Pydantic models: `BountyBase`, `BountyDB`, `BountyListItem`, `BountyResponse`. | ||
|
|
||
| ### 3. Advanced Filtering & Logic | ||
| - **AND Logic for Skills**: Add an optional `skills_logic` parameter (`"any"` | `"all"`) to the search API. | ||
| - **Solana/FNDRY Pricing**: Ability to filter by exact currency type if multi-currency support expands. | ||
| - **Deadline Fix**: Restore the functional `deadline_before` ISO filtering. | ||
|
|
||
| ### 4. Search Ranking System | ||
| Refine `best_match` sorting: | ||
| - Rank results by title match first, then project name, then description. | ||
| - Combine text relevance with `popularity` and `reward_amount` for a "Hot Relevance" score. | ||
|
|
||
| ## Architectural Constraints | ||
| - **Database**: PostgreSQL 15+ using `AsyncSession`. | ||
| - **Backend**: FastAPI / Pydantic v2. | ||
| - **Performance**: Search must resolve in < 150ms for the average query. | ||
| - **Fallback**: Maintain the `search_bounties_memory` fallback for development environments without DB access. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| """Buyback API endpoints for $FNDRY tokenomics.""" | ||
|
|
||
| from fastapi import APIRouter | ||
| from app.models.payout import BuybackCreate, BuybackResponse, BuybackListResponse | ||
| from app.services import payout_service | ||
|
|
||
| router = APIRouter(prefix="/buybacks", tags=["treasury"]) | ||
|
|
||
| @router.post("/", response_model=BuybackResponse, summary="Record a buyback") | ||
| async def record_buyback(buyback_in: BuybackCreate): | ||
| """Record a manual SOL -> FNDRY buyback event and update treasury stats.""" | ||
| return await payout_service.create_buyback(buyback_in) | ||
|
Comment on lines
+10
to
+13
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. Missing authentication on buyback recording endpoint. The Additionally, the function lacks a return type annotation for consistency with FastAPI conventions. Proposed fix for type annotation `@router.post`("/", response_model=BuybackResponse, summary="Record a buyback")
-async def record_buyback(buyback_in: BuybackCreate):
+async def record_buyback(buyback_in: BuybackCreate) -> BuybackResponse:
"""Record a manual SOL -> FNDRY buyback event and update treasury stats."""
return await payout_service.create_buyback(buyback_in)🤖 Prompt for AI Agents |
||
|
|
||
| @router.get("/", response_model=BuybackListResponse, summary="List buybacks") | ||
| async def list_buybacks(skip: int = 0, limit: int = 100): | ||
| """Retrieve a paginated list of all recorded buyback events.""" | ||
| return await payout_service.list_buybacks(skip=skip, limit=limit) | ||
|
Comment on lines
+16
to
+19
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. Missing input validation bounds on pagination parameters. The Proposed fix with validation `@router.get`("/", response_model=BuybackListResponse, summary="List buybacks")
-async def list_buybacks(skip: int = 0, limit: int = 100):
+async def list_buybacks(
+ skip: int = Query(0, ge=0, description="Number of records to skip"),
+ limit: int = Query(100, ge=1, le=1000, description="Maximum records per page"),
+) -> BuybackListResponse:
"""Retrieve a paginated list of all recorded buyback events."""
return await payout_service.list_buybacks(skip=skip, limit=limit)Note: You'll need to import 🤖 Prompt for AI Agents |
||
Uh oh!
There was an error while loading. Please reload this page.