Skip to content

CF-5 OrcChat Library experience - #14

Merged
hardcoreerik merged 3 commits into
masterfrom
feat/cf5-orcchat-library
Jun 29, 2026
Merged

CF-5 OrcChat Library experience#14
hardcoreerik merged 3 commits into
masterfrom
feat/cf5-orcchat-library

Conversation

@hardcoreerik

@hardcoreerik hardcoreerik commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implements CF-5 per docs/The Orc Context Fabric.md: source-bound chat via a new library drawer (add/index/search corpora, web-find import), Quick/Study query routing through FabricAskService, cited-and-verified answer bubbles, a source-preview rail, and a per-conversation cited-conclusion notebook.
  • Wires FabricAskService / FabricIndexingOrchestrator / LibraryViewModel into ChatPanel and MainWindow, gated behind the existing ExperimentalNativeMainChatEnabled opt-in (off by default).
  • Adds a segment-scoped claim replace path (FabricNativeReaderService.ReadSegmentsAsync, FabricEvidenceGraphImporter.ReplaceSegmentEvidenceCard, DocumentGraphRepository.ReplaceClaimsForSegment) so indexing retries don't wipe other segments' claims or leave stale ones behind.
  • Second commit addresses a self-run review pass: dropped attachments on the fabric send path, an indexing re-entrancy race, a wrong progress-label lookup, unguarded async-void Click handlers, and wires the previously untested-but-unwired RetryFailedAsync to a "Repair" button.

Status

Framework/integration exit passed in focused tests (351 unit + 73 headless, all green; full solution builds clean). The literal CF-5 exit gate — index the real Darwin PDF with a loaded native model and get a cited cross-chapter answer — has not been run yet; that's the remaining acceptance step before this phase is done (see roadmap docs).

Test plan

  • dotnet test OrchestratorIDE.UnitTests — 351 passed
  • dotnet test OrchestratorIDE.Avalonia.HeadlessTests — 73 passed
  • dotnet build on every project in the repo (no regressions)
  • Real end-to-end run with a loaded native model + the Darwin PDF (manual, not yet done)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a new library drawer and source preview experience in chat, including corpus attach/detach, quick/study mode switching, citation footnotes, and notebook saving.
    • Enabled corpus-backed answers with cited responses and visible indexing progress.
    • Added web import support for finding and adding supported documents directly into a corpus.
  • Bug Fixes
    • Improved handling for source preview visibility, citation navigation, and segment-level reindexing.
  • Tests
    • Added headless and unit coverage for chat routing, library UI state, citation preview behavior, ask flow, and indexing/retry scenarios.
  • Documentation
    • Updated roadmap and CF-5 implementation notes.

hardcoreerik and others added 3 commits June 29, 2026 07:13
Adds source-bound chat: a library drawer for adding/indexing corpora,
Quick/Study query routing through FabricAskService, cited-and-verified
answer bubbles with a source-preview rail, and web-find import. Wires
FabricAskService/FabricIndexingOrchestrator/LibraryViewModel into
ChatPanel and MainWindow behind the existing experimental native-runtime
opt-in, with a new FabricNativeReaderService.ReadSegmentsAsync scoped
re-read for indexing retries that doesn't wipe other segments' claims.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- ChatPanel: fall through to plain chat instead of silently dropping
  pending attachments when a corpus is attached.
- FabricEvidenceGraphImporter/DocumentGraphRepository: add a
  segment-scoped claim replace (ReplaceSegmentEvidenceCard /
  ReplaceClaimsForSegment) so a retry that returns fewer claims than
  before no longer leaves the dropped ones orphaned in the graph.
- LibraryDrawerControl: guard BeginIndexing against re-entrant calls for
  the same document (double-click / overlapping imports were racing two
  concurrent IndexDocumentAsync runs against the same SQLite rows); fix
  the active-progress lookup to reuse its own filter instead of falling
  back to whichever entry was inserted first; wrap the async-void Click
  handlers in try/catch with an inline error banner instead of letting
  network/import failures become unhandled UI-thread exceptions; wire
  FabricIndexingOrchestrator.RetryFailedAsync to a new "Repair" button
  (it previously had unit tests but no UI call site).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Framework/integration exit passed in focused headless/scripted-runtime
tests (351 unit + 73 headless, all green); the real native-model
end-to-end exit gate (index the real Darwin PDF, ask a cited
cross-chapter question) has not yet been run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c84ee6c3-cf2b-4207-a8f2-58227787755a

📥 Commits

Reviewing files that changed from the base of the PR and between d7a6af7 and 0c37efd.

📒 Files selected for processing (37)
  • OrchestratorIDE.Avalonia.HeadlessTests/Cf5TestHarness.cs
  • OrchestratorIDE.Avalonia.HeadlessTests/OrcChatCitationNavigationTests.cs
  • OrchestratorIDE.Avalonia.HeadlessTests/OrcChatContextFabricQueryTests.cs
  • OrchestratorIDE.Avalonia.HeadlessTests/OrcChatLibraryTests.cs
  • OrchestratorIDE.Avalonia/MainWindow.axaml.cs
  • OrchestratorIDE.Avalonia/OrchestratorIDE.Avalonia.csproj
  • OrchestratorIDE.Avalonia/UI/Controls/LibraryDrawerControl.axaml
  • OrchestratorIDE.Avalonia/UI/Controls/LibraryDrawerControl.axaml.cs
  • OrchestratorIDE.Avalonia/UI/Controls/SourcePreviewPanel.axaml
  • OrchestratorIDE.Avalonia/UI/Controls/SourcePreviewPanel.axaml.cs
  • OrchestratorIDE.Avalonia/UI/Panels/ChatPanel.axaml
  • OrchestratorIDE.Avalonia/UI/Panels/ChatPanel.axaml.cs
  • OrchestratorIDE.Avalonia/UI/ViewModels/CitationViewModel.cs
  • OrchestratorIDE.Avalonia/UI/ViewModels/IndexProgressViewModel.cs
  • OrchestratorIDE.Avalonia/UI/ViewModels/LibraryViewModel.cs
  • OrchestratorIDE.UnitTests/ContextFabricAskServiceTests.cs
  • OrchestratorIDE.UnitTests/ContextFabricIndexingOrchestratorTests.cs
  • OrchestratorIDE/Services/ContextFabric/DocumentGraphRepository.cs
  • OrchestratorIDE/Services/ContextFabric/FabricAskService.cs
  • OrchestratorIDE/Services/ContextFabric/FabricEvidenceGraphImporter.cs
  • OrchestratorIDE/Services/ContextFabric/FabricIndexingOrchestrator.cs
  • OrchestratorIDE/Services/ContextFabric/FabricNativeReaderService.cs
  • OrchestratorIDE/Services/ContextFabric/FabricWebImporter.cs
  • OrchestratorIDE/Services/ConversationNotebookStore.cs
  • docs/ROADMAP.md
  • docs/The Orc Context Fabric.md
  • docs/research/design_handoff_cf5_orcchat_library/CLAUDE_CODE_PROMPT.md
  • docs/research/design_handoff_cf5_orcchat_library/ChatPanel_CF5_changes.md
  • docs/research/design_handoff_cf5_orcchat_library/OrcChat Library.dc.html
  • docs/research/design_handoff_cf5_orcchat_library/README.md
  • docs/research/design_handoff_cf5_orcchat_library/src/ConversationNotebookStore.cs
  • docs/research/design_handoff_cf5_orcchat_library/src/FabricAskService.cs
  • docs/research/design_handoff_cf5_orcchat_library/src/FabricIndexingOrchestrator.cs
  • docs/research/design_handoff_cf5_orcchat_library/src/FabricWebImporter.cs
  • docs/research/design_handoff_cf5_orcchat_library/src/ViewModels/CitationViewModel.cs
  • docs/research/design_handoff_cf5_orcchat_library/src/ViewModels/IndexProgressViewModel.cs
  • docs/research/design_handoff_cf5_orcchat_library/src/ViewModels/LibraryViewModel.cs

📝 Walkthrough

Walkthrough

Implements the CF-5 OrcChat Library experience end-to-end: new backend services (FabricAskService, FabricIndexingOrchestrator, FabricNativeReaderService.ReadSegmentsAsync, FabricWebImporter, ConversationNotebookStore, DocumentGraphRepository.ReplaceClaimsForSegment), three new view models, two new Avalonia controls (LibraryDrawerControl, SourcePreviewPanel), extensive ChatPanel CF-5 send-path integration, MainWindow wiring, unit and headless UI tests, and accompanying design/research documentation.

Changes

CF-5 OrcChat Library Feature

Layer / File(s) Summary
Core CF-5 service contracts
OrchestratorIDE/Services/ContextFabric/FabricAskService.cs, FabricIndexingOrchestrator.cs, FabricWebImporter.cs, OrchestratorIDE/Services/ConversationNotebookStore.cs
Defines public records and enums flowing through the CF-5 pipeline: FabricAskResult/FabricAnswerClaimResult/FabricCitationDetail, IndexStageKind/IndexStageEvent, WebImportCandidate/WebImportResult, and ConversationNotebookEntry.
DocumentGraphRepository.ReplaceClaimsForSegment
OrchestratorIDE/Services/ContextFabric/DocumentGraphRepository.cs
New segment-scoped claim replacement: validates inputs, then in a transaction deletes existing citations and claims for the segment and upserts replacements.
FabricAskService end-to-end ask orchestration
OrchestratorIDE/Services/ContextFabric/FabricAskService.cs
Implements AskAsync: builds evidence plan, packs evidence, streams model output via IRoleRuntime.StreamRoleCompletionAsync, parses JSON draft (with fenced-code-block stripping and abstention fallback), verifies citations, and returns a fully populated FabricAskResult.
FabricIndexingOrchestrator and ReadSegmentsAsync
OrchestratorIDE/Services/ContextFabric/FabricIndexingOrchestrator.cs, FabricNativeReaderService.cs, FabricEvidenceGraphImporter.cs
IndexDocumentAsync emits Reading→Reducing→Complete progress with non-fatal reduction errors; RetryFailedAsync scopes to specific segment ids; ReadSegmentsAsync re-reads only requested segments and calls updated ReplaceSegmentEvidenceCard to avoid orphaned graph claims.
FabricWebImporter
OrchestratorIDE/Services/ContextFabric/FabricWebImporter.cs
SearchAsync filters web hits by supported extension; DownloadAndImportAsync enforces 50 MB cap both from Content-Length and mid-stream, writes to a temp file, and delegates to FabricLibraryService.ImportFileAsync.
ConversationNotebookStore persistence
OrchestratorIDE/Services/ConversationNotebookStore.cs
JSON-file-backed store under .orc/chat/: Load returns empty list on missing/corrupt file; Append loads then overwrites; Clear deletes if present.
CF-5 view models
OrchestratorIDE.Avalonia/UI/ViewModels/CitationViewModel.cs, IndexProgressViewModel.cs, LibraryViewModel.cs
CitationViewModel record with verification-state booleans; IndexProgressViewModel (INotifyPropertyChanged, Apply posts to UIThread); LibraryViewModel/CorpusCardViewModel with observable corpora/search collections, CRUD/import methods, and UIThread-posted refresh.
LibraryDrawerControl
OrchestratorIDE.Avalonia/UI/Controls/LibraryDrawerControl.axaml, LibraryDrawerControl.axaml.cs
New Avalonia control: corpus card rendering (attach/detach/re-index/repair, status pills), async file/folder import, per-document indexing orchestration with re-entrancy guard, web-find sub-view, notebook section, storage footer, and dismissible error banner.
SourcePreviewPanel
OrchestratorIDE.Avalonia/UI/Controls/SourcePreviewPanel.axaml, SourcePreviewPanel.axaml.cs
New Avalonia control: LoadCitation populates metadata row, verification badge, and highlighted source text via Inlines/Runs; header has close button; footer wires SaveToNotebookRequested.
ChatPanel CF-5 integration
OrchestratorIDE.Avalonia/UI/Panels/ChatPanel.axaml, ChatPanel.axaml.cs
Layout restructured to three-column Grid (library drawer, chat stack, source preview). Code-behind adds CorpusAttachmentState, SetFabricServices, SendFabricAsync (routes corpus-bound sends past normal ChatEngine path), BuildCitedAnswerView, BuildCoverageLine, citation dedup/footnotes, OpenSourcePreview, and corpus attach/detach/mode-toggle/notebook-save handlers.
MainWindow wiring and project file
OrchestratorIDE.Avalonia/MainWindow.axaml.cs, OrchestratorIDE.Avalonia.csproj
InitContextFabricLibrary constructs all CF-5 service instances and calls _chatPanel.SetFabricServices; csproj adds Compile entries for the four new CF-5 source files.
Unit tests: FabricAskService and FabricIndexingOrchestrator
OrchestratorIDE.UnitTests/ContextFabricAskServiceTests.cs, ContextFabricIndexingOrchestratorTests.cs
ContextFabricAskServiceTests covers supported citation, mismatch, abstention, and blank-question rejection. ContextFabricIndexingOrchestratorTests covers full index, read-only, no-segment fast-fail, retry semantics, and evidence-card claim replacement.
Headless UI tests
OrchestratorIDE.Avalonia.HeadlessTests/Cf5TestHarness.cs, OrcChatLibraryTests.cs, OrcChatCitationNavigationTests.cs, OrcChatContextFabricQueryTests.cs
Cf5TestHarness/FakeFabricRuntime provide in-memory SQLite and canned JSON runtime. OrcChatLibraryTests checks default visibility, drawer toggle, and corpus attach/detach/mode. OrcChatCitationNavigationTests verifies source preview open/close. OrcChatContextFabricQueryTests drives SendAsync through the Fabric path and inspects rendered bubble content.
Design handoff docs and ROADMAP
docs/ROADMAP.md, docs/The Orc Context Fabric.md, docs/research/design_handoff_cf5_orcchat_library/*
ROADMAP updated to reflect CF-0 through CF-4 passed and CF-5 framework complete. Fabric doc adds CF-5 implementation status. Research folder adds the full HTML mockup, ChatPanel edit instructions, implementation prompt, and source stubs used during development.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ChatPanel
  participant FabricAskService
  participant IRoleRuntime
  participant FabricCitationVerifier
  participant SourcePreviewPanel
  participant ConversationNotebookStore

  User->>ChatPanel: SendAsync(question)
  ChatPanel->>ChatPanel: corpus attached → SendFabricAsync
  ChatPanel->>FabricAskService: AskAsync(question, corpusId, mode)
  FabricAskService->>IRoleRuntime: StreamRoleCompletionAsync(evidence prompt)
  IRoleRuntime-->>FabricAskService: streamed JSON tokens
  FabricAskService->>FabricCitationVerifier: VerifyClaim(claim, allowRepair=true)
  FabricCitationVerifier-->>FabricAskService: verification items
  FabricAskService-->>ChatPanel: FabricAskResult
  ChatPanel->>ChatPanel: BuildCitedAnswerView(result) → cited bubble + footnotes
  User->>ChatPanel: click citation footnote
  ChatPanel->>SourcePreviewPanel: LoadCitation(citationVm, libraryVm)
  User->>ChatPanel: Save to Notebook
  ChatPanel->>ConversationNotebookStore: Append(path, entry)
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • hardcoreerik/TheOrc#10: CF-5 services and tests directly consume FabricLibraryRepository and ingestion types introduced in the CF-1 ingestion framework PR.
  • hardcoreerik/TheOrc#12: CF-5 extends the CF-3 native reading/evidence-import pipeline by adding FabricNativeReaderService.ReadSegmentsAsync and updating FabricEvidenceGraphImporter.ReplaceSegmentEvidenceCard.
  • hardcoreerik/TheOrc#13: CF-5 FabricAskService builds directly on CF-4's FabricQueryPlanner, EvidencePackBuilder, and FabricCitationVerifier, and extends DocumentGraphRepository with claim/citation replacement established in that PR.

Poem

🐇 Hop, hop, the library's alive,
Corpus cards and citations arrive!
Quick mode or Study — I choose my path,
The evidence pack does the evidence math.
A cited conclusion saved to the shelf,
This rabbit reviewed it all by itself! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly names the main change: the CF-5 OrcChat Library experience.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cf5-orcchat-library

Comment @coderabbitai help to get the list of available commands.

@hardcoreerik
hardcoreerik merged commit 2397d78 into master Jun 29, 2026
2 checks passed
@hardcoreerik
hardcoreerik deleted the feat/cf5-orcchat-library branch July 18, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant