Skip to content

Knowledge & Search API

The knowledge system provides semantic search across project content and knowledge pattern mining from execution history.

Search across project requirements, knowledge patterns, and execution nodes using vector similarity.

http
GET /api/v1/projects/{project_id}/search?q=user+authentication
Authorization: Bearer <token>

Query Parameters

ParameterTypeDefaultDescription
qstringrequiredSearch query text
source_typestringallFilter by requirement, knowledge_pattern, or execution_node
limitint10Max results (1–50)
thresholdfloat0.5Minimum similarity score (0–1)

Response 200 OK

json
{
  "query": "user authentication",
  "results": [
    {
      "source_type": "requirement",
      "source_id": "uuid",
      "chunk_index": 0,
      "similarity": 0.87,
      "content_preview": "Implement JWT-based authentication..."
    }
  ],
  "total": 3
}

Find Similar Items

Find items similar to a specific source document.

http
GET /api/v1/projects/{project_id}/search/similar/requirement/{requirement_id}
Authorization: Bearer <token>

Knowledge Patterns

Knowledge patterns are reusable insights extracted from execution history — bug fixes, successful strategies, anti-patterns, and code patterns.

List Patterns

http
GET /api/v1/knowledge-patterns?project_id={project_id}
Authorization: Bearer <token>

Query Parameters

ParameterTypeDescription
project_idUUIDFilter by project
pattern_typestringFilter by bug_fix, success, anti_pattern, code_pattern
status_filterstringFilter by active, draft, deprecated

Create Pattern

http
POST /api/v1/knowledge-patterns
Authorization: Bearer <token>
Content-Type: application/json

{
  "project_id": "uuid",
  "pattern_type": "bug_fix",
  "title": "Fix N+1 query in user listing",
  "description": "SQLAlchemy lazy loading causes N+1 queries",
  "trigger_conditions": ["user listing endpoint", "pagination"],
  "resolution_steps": ["Use joinedload() for relationships"],
  "applicable_contexts": ["fastapi", "sqlalchemy"],
  "confidence": 0.9
}

Update Pattern

http
PUT /api/v1/knowledge-patterns/{pattern_id}
Authorization: Bearer <token>

Delete Pattern

Requires admin role.

http
DELETE /api/v1/knowledge-patterns/{pattern_id}
Authorization: Bearer <token>

Activate / Deprecate

Move a pattern from draft to active, or mark as deprecated.

http
POST /api/v1/knowledge-patterns/{pattern_id}/activate
POST /api/v1/knowledge-patterns/{pattern_id}/deprecate
Authorization: Bearer <token>

Extract from Execution

Automatically extract knowledge patterns from a completed execution graph.

http
POST /api/v1/executions/{graph_id}/extract-patterns
Authorization: Bearer <token>

Pattern Recommendations

Get recommended patterns for a project, sorted by usage frequency and confidence.

http
GET /api/v1/projects/{project_id}/knowledge/recommend?limit=5
Authorization: Bearer <token>

Bugfix Report

Aggregated summary of pattern distribution and most-used patterns.

http
GET /api/v1/projects/{project_id}/knowledge/bugfix-report
Authorization: Bearer <token>

Response 200 OK

json
{
  "summary": [
    { "pattern_type": "bug_fix", "count": 12, "avg_confidence": 0.85, "total_usage": 45 }
  ],
  "top_patterns": [
    { "id": "uuid", "title": "Fix N+1 query", "usage_count": 8, "confidence": 0.92 }
  ]
}

Autonomy Configuration

Control the level of automation for AI agent execution.

Get Autonomy Config

http
GET /api/v1/projects/{project_id}/autonomy
Authorization: Bearer <token>

Update Autonomy Settings

Requires admin role.

http
PUT /api/v1/projects/{project_id}/autonomy?level=1&auto_approve_threshold=8.0&spot_check_ratio=0.2
Authorization: Bearer <token>

Autonomy Levels

LevelBehavior
L0All gates require human approval
L1Auto-approve gates above score threshold
L2Auto-approve with spot-check sampling

Forgexa — AI Software Factory