Skip to content

Models

domain.fetch_pipeline.models

Summary

Data models for fetch pipeline progress reporting and ambiguity resolution.

Classes

Ambiguity

Bases: BaseModel

Record of an ambiguity pause awaiting resolution.

Attributes:

Name Type Description
fetch_request_id PyObjectId

Owning fetch request.

step_index int

Pipeline stage index at which the pause occurred.

line str

Raw OCR line that triggered the ambiguity.

ocr_amount float

Amount read from the OCR line.

ocr_balance float

Balance read from the OCR line.

prev_balance float

Balance carried into the ambiguous transaction.

candidates List[AmbiguityCandidate]

Amount/balance candidates offered for resolution.

chosen Optional[AmbiguityCandidate]

Candidate selected by the resolver, if any.

resolved_at Optional[str]

ISO timestamp of resolution, if resolved.

status str

Lifecycle status, defaulting to "pending".

AmbiguityCandidate

Bases: BaseModel

Amount/balance pair offered as a resolution candidate.

Attributes:

Name Type Description
amount float

Candidate transaction amount.

balance float

Candidate balance after the transaction.

ProgressEvent

Bases: BaseModel

SSE progress event emitted while a fetch request runs.

Attributes:

Name Type Description
fetch_request_id str

Owning fetch request id.

step str

Progress step name.

status str

Progress status value.

message ProgressMessage

Detail payload; defaults to an empty message.

timestamp str

ISO timestamp of the event.

ProgressMessage

Bases: BaseModel

Optional detail payload attached to a progress event.

Attributes:

Name Type Description
lines Optional[int]

Count of raw lines processed.

blocks Optional[int]

Count of transaction blocks produced.

count Optional[int]

Count of items at the current step.

unit Optional[str]

Unit label for count.

raw_ocr_line Optional[str]

Raw OCR line, e.g. the ambiguous line.

error Optional[str]

Error message when the step failed.

ProgressStatus

Bases: str, Enum

Lifecycle status values for a progress step.

Attributes:

Name Type Description
STARTED ProgressStatus

Step began.

COMPLETED ProgressStatus

Step finished.

SKIPPED ProgressStatus

Step was not needed.

PAUSED ProgressStatus

Step paused for ambiguity resolution.

PROGRESS ProgressStatus

Step is in progress.

FAILED ProgressStatus

Step failed.

ProgressStep

Bases: str, Enum

Pipeline stage names used in progress events.

Attributes:

Name Type Description
RAW_LINES ProgressStep

Raw OCR line extraction step.

TXN_BLOCKS ProgressStep

Transaction block grouping step.

TXN_DICTS ProgressStep

Transaction dict construction step.

RESUME_EXTRACT ProgressStep

Resume-from-saved-stages step.

EXTRACT ProgressStep

Continued extraction step.

PAUSED ProgressStep

Ambiguity pause state.

RAW_EXPENSES ProgressStep

Raw expense materialization step.

ENRICH_ENTITY ProgressStep

Entity enrichment step.

ENRICH_TAGS ProgressStep

Tag enrichment step.

SAVE_EXPENSES ProgressStep

Expense persistence step.