Files
local 5b027eb0db feat: add extraction schema, sidebar nav, few-shot prompting, and prompt settings
Overhaul extraction pipeline with new TradeItem model, conversation flow,
and dedicated extraction endpoint. Add sidebar navigation with NavMenu
component and landing page. Introduce few-shot prompting service and
tests. Add prompt settings and email upload specs. Update OpenSpec
tooling with improved export-spec and extract-feature commands. Archive
completed changes and export full specs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 23:39:23 +01:00

2.7 KiB

ADDED Requirements

Requirement: Few-shot example folder structure

The system SHALL store few-shot examples at examples/extraction/few-shot/ with numbered subdirectories (e.g., 01/, 02/). Each subdirectory SHALL contain input.html (the example email) and output.json (the expected ExtractionResult JSON).

Scenario: Example folder layout

  • WHEN the application starts
  • THEN it reads example pairs from examples/extraction/few-shot/ in numeric directory order

Scenario: Adding a new example

  • WHEN a new subdirectory (e.g., 04/) is added with input.html and output.json
  • THEN the new example is included in the few-shot ChatHistory prefix after the next application restart

Requirement: Extraction instruction template

The system SHALL load a fixed instruction template from examples/extraction/instruction-template.txt that defines the extraction task, the TradeItem schema, and the mapping rules (date parsing, leg flattening, currency mapping, breakclause defaults). This template is NOT the user-editable system prompt.

Scenario: Template loaded at startup

  • WHEN the application starts
  • THEN the instruction template is loaded from disk and used as the system message in the extraction ChatHistory

Scenario: Template content

  • WHEN the instruction template is loaded
  • THEN it contains the TradeItem field definitions, expected JSON output format, and explicit mapping rules

Requirement: ChatHistory assembly with few-shot examples

The system SHALL provide a FewShotService that assembles a reusable ChatHistory prefix at startup: the instruction template as a system message, followed by alternating User (input.html) and Assistant (output.json) messages for each example. Each extraction request SHALL clone this prefix and append the real email as the final user message.

Scenario: ChatHistory prefix structure

  • WHEN the service assembles the prefix with 3 examples
  • THEN the ChatHistory contains: 1 system message + 3 user messages + 3 assistant messages (7 messages total)

Scenario: Prefix cached and cloned per request

  • WHEN an extraction request arrives
  • THEN the service clones the cached prefix (not re-reading from disk) and appends the email content as a new user message

Requirement: Evaluation example folder

The system SHALL support an examples/extraction/evaluation/ folder for bulk examples used in offline testing. This folder is NOT loaded at startup and NOT used in the few-shot prompt.

Scenario: Evaluation folder ignored at runtime

  • WHEN the application starts
  • THEN it does not load examples from examples/extraction/evaluation/