Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions context/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pages it lists state docproc's boundaries with the system tools and its callers
schemas. [`docs/design-review.md`](../docs/design-review.md) holds the design review of the five
promoted artifacts, and [`docs/acceptance.md`](../docs/acceptance.md) the acceptance and final
tasks' measurements of what v1.ai.processing delivers.
[`bunrei.md`](bunrei.md) holds Bunrei's planned boundary over docproc and docinfer.
[`bunrei.md`](bunrei.md) holds Bunrei's boundary over docproc and docinfer.

## Capability map

Expand All @@ -39,8 +39,10 @@ tasks' measurements of what v1.ai.processing delivers.
- **Run directory** (built): [rundir/doc.go](../rundir/doc.go),
[rundir/schema/doc.go](../rundir/schema/doc.go).
- **Command** (built): [cmd/docproc/main.go](../cmd/docproc/main.go).
- **Command on v0.12.0** (planned): [command-upgrade.md](command-upgrade.md), the bounds tests
and rsvg-convert.
- **Format coverage** (built): [docs/limits.md](../docs/limits.md), what each stage leaves unread.
- **Format coverage's open items** (planned): [tool-gaps.md](tool-gaps.md), docproc-ooxml's
equations and SmartArt among them.
- **Bunrei** (planned): [bunrei.md](bunrei.md).
- **Bunrei** (built): [bunrei.md](bunrei.md).
- **Releases** (built): [.github/workflows/release.yml](../.github/workflows/release.yml).
91 changes: 50 additions & 41 deletions context/bunrei.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
# bunrei

Bunrei, the data-intelligence capstone's processing service, is planned. It runs docinfer's jobs
over docproc's dispatcher, stages, and stores, which it wires, and builds the go-ai clients docinfer
calls. The capstone root's notes hold its contracts; this note holds what Bunrei keeps to itself:
its input, its jobs and their fencing, its tools and routes, and its state, which the `state` task
settles (`standards-lab/context/data-intelligence.md`, "Design").
Bunrei, the data-intelligence capstone's processing service, runs docinfer's jobs over docproc's
dispatcher, stages, and stores, which it wires, and builds the go-ai clients docinfer calls. The
capstone root's notes hold its contracts; this note holds what Bunrei keeps to itself: its input,
its jobs and their fencing, its tools and routes, and its state
(`standards-lab/context/data-intelligence.md`, "Design").

## Queries and Commands

The capstone root's [`protocol`](https://github.com/JaimeStill/capstone-data-intelligence/blob/main/context/protocol.md) note holds Bunrei's Queries and Commands, the
`client` module's types, the profiles, and the extraction spec, and its [`upload`](https://github.com/JaimeStill/capstone-data-intelligence/blob/main/context/upload.md)
`client` module's types, the profiles, and the three optional extracts, and its [`upload`](https://github.com/JaimeStill/capstone-data-intelligence/blob/main/context/upload.md)
note the resumable upload, which go-web-sdk's handler, mounted by Bunrei, serves; CompleteUpload
is Bunrei's one upload Command. Every Command that changes a job appends one event to the job's
subject under the expected-last-subject-sequence check, which is its transaction.

- **Input.** A job's input is durable past the work queue's `MaxDeliver` deliveries, staged in
blob storage at `input/<sha256>`: `dispatch.Input`'s `Reader` is blob storage's and its `SHA256`
the declared one, checked once by the dispatcher's spool ([`docs/api.md`](../docs/api.md), "Input
from a stream, or a path"); a mismatch fails the job at once.
blob storage at `input/ab/<sha256>`: `dispatch.Input`'s `Reader` is blob storage's and its
`SHA256` the declared one, checked once by the dispatcher's spool ([`docs/api.md`](../docs/api.md),
"Input from a stream, or a path"); a mismatch fails the job at once.
- **A job** is one input, the unit of retry (data-intelligence.md, "Distribution"), its ID a UUIDv7.
The replica running it extends its work-queue delivery while it runs, runs `job.Runner.Run` with
`docinfer.Options.Final` set on the last delivery, and on a redelivery resumes a store from its
last checkpoint (docinfer's `job` package doc).
- **A dead last delivery** gets no handler error, so nothing reports its exhaustion: Bunrei
appends `failed` to a running job with no live delivery and no deliveries left, found by a
`MaxDeliver` advisory or a sweep, the `state` task's choice.
- **Fencing.** `CancelJob` appends `cancel_requested`. The running replica watches its subject
through a headers-only consumer and ends the job's context on a `cancel_requested`, after which
only `cancelled` follows, or on a `started` newer than its own, after which it appends nothing. A
refused append reads the subject's tail and acts on either alike.
- **The profile** resolves to a `docinfer.Pipeline`, one per profile.
The work queue extends the job's delivery while it runs. The replica runs `job.Runner.Run` with
`docinfer.Options.Final` from `messaging.Worker.Final`, true on the last delivery, and on a
redelivery resumes a store from its last checkpoint (docinfer's `job` package doc).
- **A dead last delivery.** The work queue dead-letters a job past `MaxDeliver` without running
the handler. Bunrei's dead-letter worker takes it from `bunrei.work.dead` and appends `failed`,
and parks its own dead letters on `bunrei.work.dead.parked`; both subjects are on BUNREI_WORK.
- **Fencing.** `CancelJob` appends `cancel_requested`. The running replica follows its subject
through `Journal.Follow`, headers only, and ends the job's context on a `cancel_requested`, after
which only `cancelled` follows, or on a `started` newer than its own, after which it appends
nothing. A refused append reads the subject's tail and acts on either alike.
- **The profile** resolves to a `docinfer.Pipeline`, one per profile, and sets the vision prompt
and sampling. Its prompts are defaults: an active override replaces a stage's instructions at
each attempt's start (Bunrei's
[`docs/prompt-overrides.md`](https://github.com/JaimeStill/capstone-bunrei/blob/main/docs/prompt-overrides.md)).

## Tools and routes

Expand All @@ -46,29 +49,36 @@ the image.

## State and subjects

Bunrei holds only its jobs, its uploads, and each job's event stream. docproc's index and content
store and docinfer's cache are facets of its internal state, wired at its composition root.
Bunrei holds only its jobs, its uploads and submissions, and each job's event stream. docproc's
index and content store and docinfer's cache are facets of its internal state, wired at its
composition root.

```text
blob storage input/<sha256> a job's staged input
upload/<upload>/<offset> an upload's staged chunks
content/<sha256> docproc's Content, through docproc/storage
PostgreSQL docproc's index through docproc/postgres
blob storage input/ab/<sha256> a job's staged input, through docproc/storage
upload/<upload>/<offset>/<append id>
an upload's chunks
content/ab/<sha256> docproc's Content, through docproc/storage
PostgreSQL Bunrei's upload and submission tables
docproc's index through docproc/postgres
docinfer's Cache through docinfer/postgres
go-messaging's outbox and inbox, for Bunrei's events other than a job's
JetStream BUNREI_WORK bunrei.work: work-queue retention, one message
(file storage) per job, {"job"}
(file storage) per job, {"job"}; its dead letters on
bunrei.work.dead and bunrei.work.dead.parked
BUNREI_JOBS bunrei.job.<job>: every event of one job, on its
own subject; limits retention
BUNREI_UPLOADS bunrei.upload.<upload>, if the upload keeps a
stream
```

The host sweeps content by age ([`docs/api.md`](../docs/api.md), "Content"). Each job's events go on
one subject of its own, so the job has a gap-free sequence the sequence check guards; the subjects
share one stream, leaving no streams to reap. `standards-lab/context/messaging.md`'s conventions
govern committed mutations, not a job's progress stream. The browser never subscribes: Mikoshi relays
its own stream (data-intelligence.md, "Browser"). The names and retentions are the `state` task's.
BUNREI_JOBS keeps a job's events 30 days, and BUNREI_WORK has no max age. Bunrei's sweeper
deletes the rest past their ages: blobs by prefix, `content/` at 67 days (a put rewrites one older
than 7), `input/` at 30, and `upload/` at twice the 24-hour upload lifetime; docproc's index
entries at 30; outbox and inbox rows at 7 (Bunrei's
[`docs/configuration.md`](https://github.com/JaimeStill/capstone-bunrei/blob/main/docs/configuration.md)).
Each job's events go on one subject of its own, so the job has a gap-free sequence the sequence
check guards; the subjects share one stream, leaving no streams to reap.
`standards-lab/context/messaging.md`'s conventions govern committed mutations, not a job's progress
stream. The browser never subscribes: Mikoshi relays its own stream (data-intelligence.md,
"Browser").

## Events

Expand All @@ -78,14 +88,13 @@ a Bunrei setting, and the manifest.

## Requests to go-messaging

data-intelligence.md queues these asks of go-messaging's NATS provider, sized by the `state` and
`events` tasks, the `events` task assuming them met:
Bunrei needs these of go-messaging's NATS provider (data-intelligence.md), which meets each:

- A publish on a subject the caller names.
- A durable consumer filtered by subject.
- The CloudEvents `jobsequence` extension carried.
- Events delivered in order within a delivery group.
- A work-queue delivery its handler extends while it runs (an in-progress acknowledgement).
- A publish on a subject the caller names: v0.4.0's `messaging.Journal`, a guarded append and a
bounded read.
- A work-queue delivery its handler extends while it runs: v0.5.0's work queue.
- A durable consumer filtered by subject, the CloudEvents `jobsequence` extension carried, and
events delivered in order within a delivery group: the Journal's per-subject `Read` and `Follow`.

## Assumptions

Expand Down
13 changes: 13 additions & 0 deletions context/command-upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# cmd/docproc on docproc v0.12.0

cmd/docproc requires docproc v0.11.0 ([go.mod](../cmd/docproc/go.mod)). Its move to v0.12.0 is
planned and needs two changes beyond the version:

- **The bounds tests.** v0.12.0's `settings` package assembles an unset `soffice_memory` to
`tool_memory`'s value, so `startingBounds` in
[bounds_test.go](../cmd/docproc/internal/app/test/bounds_test.go) sets
`Stages.LibreOfficeMemory` to `Stages.Memory`. cmd/docproc reads no `soffice_memory`; its soffice
runs in a container under `Memory`.
- **rsvg-convert.** v0.12.0's office and picture routes require rsvg-convert on the host
([README](../README.md#the-system-tools)), and `Options.Timeout` bounds its runs, so
[docs/command.md](../docs/command.md)'s `DOCPROC_UNIT_TIMEOUT` row lists it.