Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5b3500f
Optimize code summary prompt for small language models
Zebastjan Feb 22, 2026
401c12e
Add integration tests for code summary prompt validation
Zebastjan Feb 22, 2026
547440d
Add comprehensive testing documentation and results
Zebastjan Feb 22, 2026
ee980d1
Fix backend validation bug: add 'discovery' status to CrawlProgressRe…
Zebastjan Feb 22, 2026
827a1a0
Add crawl URL state tracking for checkpoint/resume
Zebastjan Feb 22, 2026
3c94561
Integrate crawl URL state tracking into crawling service
Zebastjan Feb 22, 2026
0aaee50
Update ADR-001 with accurate implementation state and roadmap
Zebastjan Feb 22, 2026
0f83aa6
Add unit tests for CrawlUrlStateService (checkpoint/resume)
Zebastjan Feb 22, 2026
990b8bb
Add provenance tracking to frontend and reconcile ADRs
Zebastjan Feb 22, 2026
70d4db7
Implement checkpoint/resume and provenance tracking backend
Zebastjan Feb 22, 2026
e93d42e
Add archon_migrations tracking to migration files 001-007, 012-013
Zebastjan Feb 22, 2026
f4c868d
Add re-vectorize, re-summarize endpoints and code summarization agent…
Zebastjan Feb 22, 2026
a66e355
Add progress tracking and concurrency limiting for re-vectorize/re-su…
Zebastjan Feb 22, 2026
377324e
Move Code Summarization to third tab in LLM Provider Settings
Zebastjan Feb 22, 2026
a7306d2
Fix Code Summary tab layout and Config button
Zebastjan Feb 22, 2026
ca3d358
Add Summary tab to LLM Provider Settings
Zebastjan Feb 22, 2026
e3fef61
Fix ternary syntax and add full model selection for Summary tab
Zebastjan Feb 22, 2026
9a12773
feat(ingestion): add restartable RAG pipeline with separable stages
Zebastjan Feb 22, 2026
940d0de
feat(ingestion): add worker API and crawl service integration
Zebastjan Feb 23, 2026
a60fe0d
Add roadmap document outlining project direction
Zebastjan Feb 23, 2026
fb01b9a
Add progress persistence, pause/resume, and RAG settings fixes
Zebastjan Feb 23, 2026
1fd5849
feat: add pause/resume infrastructure for crawl operations (WIP)
Zebastjan Feb 23, 2026
5e99e72
test: add comprehensive pause/resume/cancel testing infrastructure
Zebastjan Feb 23, 2026
9d24967
docs: add KNOWN_ISSUES - crawls currently broken
Zebastjan Feb 23, 2026
24739fb
fix: use 'idle' instead of invalid 'initializing' pipeline_status
Zebastjan Feb 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
27 changes: 27 additions & 0 deletions ADR-001: Crawl & Ingestion Pipeline Improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ADR-001: Crawl & Ingestion Pipeline Improvements

**Status:** Superseded by ADR-002
**Date:** 2026-02-22
**Authors:** Zebastjan Johanzen

> ⚠️ **This ADR has been superseded by ADR-002**. All content has been merged into ADR-002 for a unified view of crawl reliability, provenance tracking, and validation tooling.

---

## Completed ✅

*(These were already completed before ADR-001 was superseded)*

| Feature | Status | Notes |
|---------|--------|-------|
| `CrawlStatus.discovery` enum | ✅ Done | Progress model includes discovery stage |
| Domain filtering | ✅ Done | Both UI controls and backend filtering |
| Priority discovery (llms.txt → sitemap → full) | ✅ Done | DiscoveryService with correct priority order |
| Per-chunk embedding metadata | ✅ Done | `embedding_model`, `embedding_dimension` on `archon_crawled_pages` |
| Chunk deduplication | ✅ Done | Unique constraint on `(url, chunk_number)` |

---

## Remaining Work

*(See ADR-002 for the complete roadmap)*
318 changes: 318 additions & 0 deletions ADR-002-IMPLEMENTATION-STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
# ADR-002 Implementation Status

## Overview
This document tracks the implementation progress of ADR-002: Crawl Reliability, Provenance Tracking & Validation.

**Branch:** `feature/crawl-checkpoint-resume`
**Date:** 2026-02-22

---

## Part 1: Checkpoint/Resume - ✅ COMPLETE

### Backend Implementation

**Status:** ✅ Fully Implemented

**Files Modified:**
1. ✅ `python/src/server/services/crawling/crawling_service.py`
- Added `_filter_already_processed_urls()` helper method (lines 857-889)
- Updated `_crawl_by_url_type()` signature to accept `source_id` and `has_existing_state`
- Applied resume filtering to sitemap crawling (lines 1101-1120)
- Applied resume filtering to link collection batch crawling (lines 1046-1051)
- Applied resume filtering to recursive crawling (lines 1066-1073, 1155-1162)
- Updated call sites to pass source_id and has_existing_state parameters

2. ✅ `python/src/server/services/crawling/strategies/recursive.py`
- Updated `crawl_recursive_with_progress()` signature to accept `source_id` and `url_state_service`
- Pre-populated visited set with already-embedded URLs (lines 158-165)
- Prevents re-crawling of completed URLs during recursive depth traversal

3. ✅ Infrastructure Already Complete (from previous work)
- `archon_crawl_url_state` table exists
- `CrawlUrlStateService` with full CRUD operations
- Integration with document storage operations

**How It Works:**
1. **Detection:** When `orchestrate_crawl()` starts, it checks for existing crawl state using `url_state_service.has_existing_state()`
2. **Logging:** If state exists with pending/failed URLs, logs resume information
3. **Filtering:** Before crawling strategies execute:
- Sitemap: Filters URLs before batch crawl
- Link Collection: Filters extracted links before batch crawl
- Recursive: Pre-populates visited set to skip embedded URLs
4. **Resume:** Only unprocessed URLs are crawled, preventing duplicates

**Testing Verification:**
```bash
# Test scenario:
# 1. Start crawl of sitemap with 100 URLs
# 2. Kill server after 30 URLs embedded
# 3. Check archon_crawl_url_state shows 30 embedded, 70 pending
# 4. Restart server and re-trigger crawl
# 5. Verify logs show "Resume filtering | skipped=30 already-embedded URLs"
# 6. Verify only 70 new URLs are processed
```

---

## Part 2: Provenance Tracking - ✅ BACKEND COMPLETE, ⏳ FRONTEND PENDING

### Backend Implementation

**Status:** ✅ Fully Implemented

**Database Migration:**
✅ `migration/0.1.0/013_add_provenance_tracking.sql`
- Adds 7 new columns to `archon_sources`:
- `embedding_model` (TEXT) - e.g., "text-embedding-3-small"
- `embedding_dimensions` (INTEGER) - e.g., 1536
- `embedding_provider` (TEXT) - e.g., "openai"
- `vectorizer_settings` (JSONB) - chunk_size, use_contextual, use_hybrid
- `summarization_model` (TEXT) - e.g., "gpt-4o-mini"
- `last_crawled_at` (TIMESTAMPTZ)
- `last_vectorized_at` (TIMESTAMPTZ)
- Creates indexes on `embedding_model` and `embedding_provider`
- Adds column comments for documentation

**Files Modified:**
1. ✅ `python/src/server/services/source_management_service.py`
- Updated `update_source_info()` signature to accept provenance parameters (lines 214-232)
- Added provenance fields to existing source upsert (lines 294-313)
- Added provenance fields to new source creation (lines 378-402)
- Sets `last_crawled_at` and `last_vectorized_at` timestamps

2. ✅ `python/src/server/services/crawling/document_storage_operations.py`
- Captures embedding configuration from credential service (lines 376-392)
- Retrieves: embedding_provider, embedding_model, embedding_dimensions
- Retrieves summarization_model from RAG strategy settings
- Passes all provenance to `update_source_info()` during crawl

**How It Works:**
1. **Capture:** During `_create_source_records()`, reads current provider configuration
2. **Store:** Passes configuration to `update_source_info()` which upserts to database
3. **Timestamps:** Automatically sets `last_crawled_at` and `last_vectorized_at` to current time
4. **Persistence:** All sources now track which models/settings were used

### Frontend Implementation

**Status:** ⏳ PENDING

**Files to Modify:**
1. ⏳ `archon-ui-main/src/features/knowledge/types/knowledge.ts`
```typescript
export interface KnowledgeSource {
source_id: string;
// ... existing fields ...
embedding_model?: string;
embedding_dimensions?: number;
embedding_provider?: string;
vectorizer_settings?: {
use_contextual?: boolean;
use_hybrid?: boolean;
chunk_size?: number;
};
summarization_model?: string;
last_crawled_at?: string;
last_vectorized_at?: string;
}
```

2. ⏳ `archon-ui-main/src/features/knowledge/components/KnowledgeCard.tsx`
- Add expandable "Processing Details" section using Radix Collapsible
- Display embedding_provider/embedding_model (embedding_dimensions D)
- Display summarization_model
- Display formatted last_crawled_at timestamp
- Use Tron-inspired glassmorphism styling

**UI Design:**
```tsx
<Collapsible.Root>
<Collapsible.Trigger className="flex items-center gap-2 text-sm text-gray-400 hover:text-cyan-400">
<ChevronRight className="transition-transform" />
Processing Details
</Collapsible.Trigger>
<Collapsible.Content className="mt-2 text-xs text-gray-400 space-y-1 pl-6">
<div>Embeddings: {embedding_provider}/{embedding_model} ({embedding_dimensions}D)</div>
<div>Summarization: {summarization_model}</div>
<div>Last crawled: {formatDate(last_crawled_at)}</div>
</Collapsible.Content>
</Collapsible.Root>
```

Comment on lines +96 to +141

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

Status markers are out of date — frontend implementation is already present in this PR.

The "Part 2: Frontend Implementation" is marked "⏳ PENDING" and the items listed (types in knowledge.ts, provenance display in KnowledgeCard.tsx) are already implemented in this PR. Similarly, the checklist at Lines 274–275 should be checked.

Additionally, Part 4 (Lines 211–256) marks all reprocessing items as "❌ Not Started," but this PR includes:

  • useRevectorizeKnowledgeItem / useResummarizeKnowledgeItem hooks
  • revectorizeKnowledgeItem / resummarizeKnowledgeItem service methods
  • "Re-vectorize" / "Re-summarize" dropdown actions in KnowledgeCardActions
  • "Needs re-vectorization" badge in KnowledgeCard

Update the status markers and checklists to reflect the code that ships with this PR.

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

In `@ADR-002-IMPLEMENTATION-STATUS.md` around lines 96 - 141, Update the ADR
status and checklists to reflect the frontend and reprocessing work already
included in this PR: change "Part 2: Frontend Implementation" from "⏳ PENDING"
to completed and check the items referencing
archon-ui-main/src/features/knowledge/types/knowledge.ts and
archon-ui-main/src/features/knowledge/components/KnowledgeCard.tsx (the
KnowledgeSource type and the Processing Details UI are present), and update the
reprocessing section (Part 4) from "❌ Not Started" to completed and check the
items implemented by useRevectorizeKnowledgeItem, useResummarizeKnowledgeItem
hooks, revectorizeKnowledgeItem and resummarizeKnowledgeItem service methods,
the "Re-vectorize"/"Re-summarize" actions in KnowledgeCardActions, and the
"Needs re-vectorization" badge in KnowledgeCard so the document accurately
reflects shipped code.

---

## Part 3: Validation Tools - ❌ NOT STARTED

### Backend Implementation

**Status:** ❌ Not Started

**Files to Create:**
1. ❌ `python/src/server/api_routes/knowledge_api.py` (or modify existing)
- Add `GET /api/knowledge-items/{source_id}/validate` endpoint
- Checks:
- Missing chunks (URLs marked embedded but no chunks exist)
- Zero-vector embeddings (null or all-zero vectors)
- Dimension mismatches (mixed embedding dimensions)
- Orphaned pages (page_metadata without chunks)
- Failed URLs that never recovered
- Returns: `{ valid: bool, issues: Issue[], total_issues: int }`

2. ❌ `migration/0.1.0/014_add_validation_functions.sql`
```sql
CREATE OR REPLACE FUNCTION count_zero_vectors(src_id TEXT)
RETURNS INTEGER AS $$
SELECT COUNT(*)
FROM archon_documents
WHERE source_id = src_id
AND embedding IS NOT NULL
AND array_length(embedding, 1) > 0
AND embedding = array_fill(0::float, ARRAY[array_length(embedding, 1)]);
$$ LANGUAGE SQL;
```

### MCP Tool Implementation

**Status:** ❌ Not Started

**Files to Modify:**
1. ❌ `python/src/mcp_server/features/rag/rag_tools.py`
- Add `rag_validate_source(source_id: str)` tool
- Calls validation API endpoint
- Returns summary: valid, error_count, warning_count, issues_summary, recommendation
- Read-only (no writes, no fixes)

**Tool Usage Example:**
```python
@mcp.tool()
async def rag_validate_source(source_id: str) -> dict:
"""Check knowledge source health before using for RAG."""
# Calls GET /api/knowledge-items/{source_id}/validate
# Returns summary for agent decision-making
```

### Frontend Implementation

**Status:** ❌ Not Started

**Files to Create:**
1. ❌ `archon-ui-main/src/features/knowledge/components/ValidationPanel.tsx`
- "Validate" button on knowledge item action menu
- Opens expandable panel or modal with validation results
- Color-coded issues (red=error, yellow=warning, blue=info)
- "Fix" buttons for fixable issues

2. ❌ `archon-ui-main/src/features/knowledge/hooks/useValidateSource.ts`
- TanStack Query hook for validation endpoint
- `useValidateSource(sourceId)` → returns validation data

---

## Testing Checklist

### Part 1: Checkpoint/Resume
- [ ] Start sitemap crawl with 100 URLs
- [ ] Kill process at 30% complete
- [ ] Verify `archon_crawl_url_state` shows mix of embedded/pending
- [ ] Restart and re-trigger crawl
- [ ] Verify only pending URLs processed
- [ ] Verify no duplicates in final data
- [ ] Check logs show "Resume filtering | skipped=X"

### Part 2: Provenance Tracking
- [x] Backend: Migration created
- [x] Backend: Service layer updated
- [x] Backend: Provenance captured during crawl
- [ ] Frontend: Types updated
- [ ] Frontend: UI displays provenance
- [ ] Test: Crawl a source
- [ ] Test: Query source record
- [ ] Test: Verify provenance fields populated

### Part 3: Validation Tools
- [ ] Backend: Validation endpoint created
- [ ] Backend: Database functions created
- [ ] MCP: Validation tool implemented
- [ ] Frontend: Validation UI created
- [ ] Test: Insert corrupted data (zero vector)
- [ ] Test: Validation detects issues
- [ ] Test: MCP tool returns correct summary

---

## Migration Deployment

**Required Database Migrations:**
1. ✅ `013_add_provenance_tracking.sql` - Ready to deploy
2. ❌ `014_add_validation_functions.sql` - Not created yet

**Deployment Steps:**
```bash
# Apply provenance tracking migration
supabase db push
# Or manually run the SQL in Supabase dashboard
```

**Rollback Plan:**
```sql
-- If needed, rollback provenance columns:
ALTER TABLE archon_sources
DROP COLUMN IF EXISTS embedding_model,
DROP COLUMN IF EXISTS embedding_dimensions,
DROP COLUMN IF EXISTS embedding_provider,
DROP COLUMN IF EXISTS vectorizer_settings,
DROP COLUMN IF EXISTS summarization_model,
DROP COLUMN IF EXISTS last_crawled_at,
DROP COLUMN IF EXISTS last_vectorized_at;

DROP INDEX IF EXISTS idx_archon_sources_embedding_model;
DROP INDEX IF EXISTS idx_archon_sources_embedding_provider;
```

---

## Priority for Remaining Work

### High Priority (Complete Part 2)
1. Update frontend types for provenance fields
2. Add provenance display to KnowledgeCard component
3. Test end-to-end provenance tracking

### Medium Priority (Part 3 - Validation)
4. Create validation API endpoint
5. Create database validation functions
6. Build validation UI component

### Low Priority (Part 3 - MCP Tool)
7. Add read-only MCP validation tool

---

## Known Issues / Notes

1. **Provenance Settings:** Currently using placeholder values for `vectorizer_settings`. These should be populated from actual RAG strategy configuration when contextual embeddings or hybrid search are implemented.

2. **Recursive Crawl Resume:** The current implementation pre-populates the visited set with embedded URLs. This works well but doesn't distinguish between "already visited in this session" vs "embedded in previous session". This is acceptable for now.

3. **Type Safety:** Some type warnings in `source_management_service.py` related to optional parameters. These are safe to ignore as the functions handle None values correctly.

4. **Migration Order:** The provenance migration (013) must be run before the validation migration (014) when it's created.

---

## Next Steps

**Immediate:**
1. Apply database migration `013_add_provenance_tracking.sql`
2. Test checkpoint/resume functionality end-to-end
3. Update frontend types and UI for provenance display

**Short Term:**
4. Implement validation API endpoint and database functions
5. Build validation UI component

**Future Enhancements:**
- Bulk loading UI/API (separate ADR)
- Manifest import capability (separate ADR)
- Re-vectorization tooling using provenance data
- Provenance-based source filtering in UI
Loading