Skip to content
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
348c545
refactor: trigger final review check
Mar 21, 2026
50c182b
Bounty 169: Autonomous Platinum 9.0 (Final Restoration)
Mar 21, 2026
f7ea698
Bounty 169: Sovereign Platinum 13.0 (Absolute Restoration)
Mar 21, 2026
2994917
Bounty 169: Sovereign Absolute 15.0 (Full Restoration)
Mar 21, 2026
5bdef27
Bounty 169: Sovereign Absolute 15.0 (Full Restoration)
Mar 21, 2026
85ff668
Bounty 169: Sovereign Absolute 18.2 (Grand Restoration)
Mar 21, 2026
5bb1e63
Bounty 169: Sovereign Absolute 18.2 (Grand Restoration)
Mar 21, 2026
2163cce
Bounty 169: Sovereign Absolute 20.0 (Autonomous Finish)
Mar 22, 2026
8261b46
[ShanaBoo] feat(api): implement elite health monitoring (T1-010)
Mar 23, 2026
c67dde6
[ShanaBoo] feat(scripts): implement elite environment setup automatio…
Mar 23, 2026
88dbe0f
[ShanaBoo] feat(frontend): implement elite bounty tags with dynamic g…
Mar 23, 2026
13db96e
[ShanaBoo] fix(frontend): fix tsconfig types to resolve React indexing
Mar 23, 2026
3e496e5
feat(backend): implement Elite Search Engine (Mission #82)
Mar 23, 2026
b432095
Fix NameError: skills_logic is now correctly passed in search_bounties
Mar 23, 2026
d876193
Merge origin/main into feature/80-health-hot-rel: Sovereign 14.0 Reco…
Mar 23, 2026
60f63e3
fix(ci): solve PR #797 conflicts, linting, and imports
Mar 23, 2026
eafd2a8
fix(ci): address ruff regressions, pytest path, and anchor install
Mar 23, 2026
560b781
fix(ci): synchronize payout locks and refactor test imports for envir…
Mar 23, 2026
856fe7d
fix(ci): address ruff formatting, unused imports, and postgres json i…
Mar 23, 2026
f413054
fix(lint): resolve ruff violations and optimize test configuration
Mar 23, 2026
84480b9
fix(lint): resolve remaining ruff violations and optimize diagnostics
Mar 23, 2026
362f228
fix: resolve db index conflict and ruff white-space violations
Mar 23, 2026
90380bd
fix(ci): resolve overlapping indexes and finalize ruff cleanup
Mar 23, 2026
700bed5
style(lint): align code with ruff formatter standards
Mar 23, 2026
bca5dae
style(lint): finalize ruff formatting compliance across test suite
Mar 23, 2026
4262ad6
style: split long Query parameters in bounties API for ruff formatting
Mar 23, 2026
2d4f899
fix(ci): resolve webhook_log index collision and lazy-load oauth config
Mar 23, 2026
5b00e9d
style(lint): synchronized global repository with ruff standards
Mar 23, 2026
3fc7580
fix(db): synchronize columns to UUID to resolve datatype mismatch
Mar 23, 2026
b0f98b5
fix(db): synchronize escrow and boost models to UUID to resolve datat…
Mar 23, 2026
d2a3c6b
fix(ci): rectify import block integrity in escrow and boost models
Mar 23, 2026
c65f1c6
style(lint): remove unused ForeignKey imports in escrow/boost
Mar 23, 2026
efb12a2
fix(backend): global GUID refactor, sanitize alembic.ini, fix test is…
Mar 23, 2026
127f6bf
fix(backend): restore foundational imports and finalize GUID standard…
Mar 23, 2026
fc969ef
fix(tests): resolve 500 payout error by enforcing E2E db isolation
Mar 23, 2026
d36ebda
style(tests): reformat E2E conftest with ruff
Mar 23, 2026
7a00012
fix(backend): resolve cascading CI regressions for PR #797
Mar 23, 2026
33d605d
fix(backend): resolve mass import naming conflicts for BountyDB acros…
Mar 23, 2026
3861beb
fix(backend): resolve naming conflicts (BountyInternal), fix imports …
Mar 23, 2026
e35690a
chore: trigger CI sync [понедельник, 23 марта 2026 г. 22:08:35 (+04)]
Mar 23, 2026
3a4b522
chore: trigger CI sync [Mon Mar 23 22:08:35 +04 2026]
Mar 23, 2026
c303df5
fix(backend): correct exported naming for BountyDB in search service
Mar 23, 2026
f2ffd58
fix(tests): resolve collector-level ImportErrors for search and migra…
Mar 23, 2026
c0ecd33
fix(ci): global infrastructure realignment (schemas, vitest, admin, a…
Mar 23, 2026
5df2e46
fix(ci): infrastructure realignment phase 2 (redis, asyncio, enums)
Mar 23, 2026
6294979
fix(ci): expert infrastructure stabilization (loop collision, state l…
Mar 23, 2026
e038e24
fix(lint): remove unused asyncio import in conftest.py
Mar 23, 2026
2336e7e
style(lint): format long set literals in test_dispute_flow.py
Mar 23, 2026
0672840
fix(ci): align postgres credentials and de-hardcode test databases
Mar 23, 2026
7e7cd75
fix(ci): final expert stabilization (rust 1.85, pytest-asyncio import…
Mar 23, 2026
39c0866
fix(lint): remove unused asyncio import in backend/tests/conftest.py
Mar 23, 2026
28311ae
fix(lint): remove unused pytest import in backend/tests/conftest.py
Mar 23, 2026
7088a40
fix(lint): final global format and lint cleanup in backend
Mar 23, 2026
8607862
fix(ci): restore broken imports and resolve NameErrors from shadow edits
Mar 23, 2026
f845ccc
[FIX] Security hardening, health check leak, search logic and CI lint…
Mar 23, 2026
4911a94
[FIX] Remove unused AdminRole import in payouts API to fix Ruff lint …
Mar 23, 2026
25e3128
[FIX] Resolve Ruff F821 by using TYPE_CHECKING for AdminRole in payou…
Mar 23, 2026
4fe2906
[FIX] Comprehensive backend stability: SQLAlchemy mappings, timezone-…
Mar 24, 2026
89392a4
[FIX] Zero-Hardcode Reconstruction: Fix critical imports, centralize …
Mar 24, 2026
ca6ebd4
[FIX] Elite Reconstruction v2: Complete backend stability, consolidat…
Mar 24, 2026
b4d7242
[FIX] Zero-Hardcode Final Restoration: Restore CI-compliant Anchor st…
Mar 24, 2026
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
21 changes: 21 additions & 0 deletions Mission_80_Prompt.md
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.
32 changes: 32 additions & 0 deletions Mission_80_Specs.md
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`.
29 changes: 29 additions & 0 deletions Mission_82_Prompt.md
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.**
36 changes: 36 additions & 0 deletions Mission_82_Specs.md
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.
3 changes: 3 additions & 0 deletions backend/app/api/bounties.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ async def search_bounties(
sort: str = Query("newest"),
page: int = Query(1, ge=1),
per_page: int = Query(20, ge=1, le=100),
skills_logic: str = Query("any", description="Logic for multiple skills: any (OR) or all (AND)"),
svc: BountySearchService = Depends(_get_search_service),
) -> BountySearchResponse:
"""Execute a full-text search with filters and return ranked results."""
Expand All @@ -222,11 +223,13 @@ async def search_bounties(
status=status,
tier=tier,
skills=skill_list,
skills_logic=skills_logic,
category=category,
creator_type=creator_type,
creator_id=creator_id,
reward_min=reward_min,
reward_max=reward_max,
deadline_before=deadline_before,
sort=sort,
page=page,
per_page=per_page,
Expand Down
18 changes: 18 additions & 0 deletions backend/app/api/buybacks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Buyback API endpoints for $FNDRY tokenomics."""

from typing import Optional

Check failure on line 3 in backend/app/api/buybacks.py

View workflow job for this annotation

GitHub Actions / Backend Lint (Ruff)

ruff (F401)

app/api/buybacks.py:3:20: F401 `typing.Optional` imported but unused help: Remove unused import: `typing.Optional`
from fastapi import APIRouter, Depends, HTTPException

Check failure on line 4 in backend/app/api/buybacks.py

View workflow job for this annotation

GitHub Actions / Backend Lint (Ruff)

ruff (F401)

app/api/buybacks.py:4:41: F401 `fastapi.HTTPException` imported but unused help: Remove unused import

Check failure on line 4 in backend/app/api/buybacks.py

View workflow job for this annotation

GitHub Actions / Backend Lint (Ruff)

ruff (F401)

app/api/buybacks.py:4:32: F401 `fastapi.Depends` imported but unused help: Remove unused import
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Unused imports: Optional and Depends are imported but never used.

Proposed fix
-from typing import Optional
-from fastapi import APIRouter, Depends, HTTPException
+from fastapi import APIRouter
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from typing import Optional
from fastapi import APIRouter, Depends, HTTPException
from fastapi import APIRouter, HTTPException
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/app/api/buybacks.py` around lines 3 - 4, Remove the unused imports in
backend/app/api/buybacks.py: delete Optional and Depends from the import line so
only APIRouter and HTTPException are imported; ensure no other code in the
module relies on Optional or Depends (e.g., in any route functions or dependency
declarations) before removing them.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Missing authentication on buyback recording endpoint.

The record_buyback endpoint allows anyone to record buyback events without authentication. This is a treasury-impacting operation that should require admin authorization.

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
Verify each finding against the current code and only fix it if needed.

In `@backend/app/api/buybacks.py` around lines 10 - 13, The record_buyback
endpoint currently allows unauthenticated access and lacks a return type
annotation; update the router decorator and function signature to require an
admin auth dependency (e.g., add a Depends(get_current_admin) or whatever admin
auth dependency your project uses) so only authorized admins can call
record_buyback, and add an explicit return type annotation (-> BuybackResponse)
to the async def record_buyback(buyback_in: BuybackCreate) signature; ensure you
pass the authenticated admin principal into the handler if needed and continue
to call payout_service.create_buyback(buyback_in) inside the function.


@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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Missing input validation bounds on pagination parameters.

The skip and limit parameters lack validation constraints. Without bounds, a malicious client could request limit=999999999 causing performance issues or memory exhaustion.

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 Query from fastapi.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/app/api/buybacks.py` around lines 15 - 18, The list_buybacks endpoint
(function list_buybacks) currently accepts unbounded skip and limit params; add
FastAPI Query validators to constrain them (import Query) and prevent abuse —
e.g., change parameters to skip: int = Query(0, ge=0) and limit: int =
Query(100, ge=1, le=1000) (adjust max as policy requires), then pass them
through to payout_service.list_buybacks(skip=skip, limit=limit); this ensures
bounds validation is enforced at the HTTP layer.

Loading
Loading