Skip to content

docproc-settings: a settings package for a dispatch's run settings; DOCPROC_OUTPUT_WRITES; v0.11.0 - #47

Merged
JaimeStill merged 9 commits into
mainfrom
docproc-settings
Nov 29, 2026
Merged

JaimeStill merged 9 commits into
mainfrom
docproc-settings

Conversation

@JaimeStill

Copy link
Copy Markdown
Contributor

capstone.data-intelligence.bunrei · task 12/17 · docproc-settings

Summary

  • docproc gains a settings package: a dispatch's run settings as one JSON object of 21 flat
    snake-case keys, refused by name when wrong, assembled into the library's own shapes.
  • 17 keys are required (an explicit 0 means no bound); pdf_dpi, audio_limit,
    concurrency, and output_writes are optional, defaulting to document.DefaultDPI,
    audio.DefaultWindowLimit, 1, and 1.
  • cmd/docproc now reads its DOCPROC_ variables into one settings.Settings, gains
    DOCPROC_OUTPUT_WRITES, and keeps every existing variable's meaning, default, exit code, and
    run dir.
  • Upgrades: go-core v0.14.0, rust 1.100.1, cargo-deny 0.22.2, gotenberg 9.10.3-libreoffice,
    mise-action v5.4.0; MimeKit, MsgKit, typed-path stay held.
  • Releases docproc v0.11.0, storage/v0.1.9, postgres/v0.1.9, cmd/docproc/v0.2.9
    (CHANGELOGs and README install lines written).

Core changes

  1. settings.Decode / Validate: one JSON object in, every refusal naming its key and matching
    ErrRequest; every unset required key named in one error. Why: the library ships no policy,
    so a host must state each bound.
    func Decode(data []byte) (Settings, error)
    func (s Settings) Validate() error
    type KeyError struct { Keys []string; Reason string } // Unwrap → ErrRequest
  2. settings.Run: the assembly. Why: jobs and cmd/docproc wire stages and dispatch from the
    same value; uncovered options (Exclude, Env, Picture, …) stay each host's own.
    type Run struct { Stages stages.Options; Limits dispatch.Limits; Release time.Duration; OutputWrites int }
    func (s Settings) Assemble() (Run, error)
  3. cmd/docproc's bounds node builds a settings.Settings from today's starting values plus
    the environment and returns its Run; app.Bounds and the runner's const puts are gone.
  4. output_writes / DOCPROC_OUTPUT_WRITES: the most outputs one part writes to the content
    store at once (default 1), landing in dispatch.Config.Puts, which keeps its v0.10.0 name.

Verify

mise run check: ✓ docproc check: ok (every module and tool); ✓ capstone-bunrei 0 issues.
mise run currency (docproc): only MimeKit, MsgKit, typed-path, held.

From ~/architecture/docproc/cmd/docproc, go build -o /tmp/docproc ., then in a dir with
in.txt:

  1. DOCPROC_MAX_PARTS=-1 DOCPROC_UNIT_TIMEOUT=ten DOCPROC_PDF_TEXT=maybe DOCPROC_AUDIO_LIMIT=3s DOCPROC_TOOL_MEMORY=abc PATH=/nonexistent /tmp/docproc run in.txt --out o → bounds: and one
    line naming each of the five variables, no tool table, exit 1.
  2. DOCPROC_OUTPUT_WRITES=0 … → DOCPROC_OUTPUT_WRITES: 0 is below 1, exit 1;
    DOCPROC_OUTPUT_WRITES=x → "x" is not a whole number, exit 1; DOCPROC_PUTS=0 is no
    longer read, exit 0.
  3. DOCPROC_BOMB_RATIO=0 … → DOCPROC_BOMB_RATIO and DOCPROC_BOMB_SIZE: set both above zero, or both to zero for no bomb rule, exit 1.
  4. DOCPROC_OUTPUT_WRITES=4 /tmp/docproc run in.txt --out r1 → text prepared 1,
    failed parts 0, exit 0.
  5. /tmp/docproc run and --workers 0 → exit 2, as before.
  6. grep -A2 ^require go.mod at docproc's root → golang.org/x/text alone.

Decided without you

  1. Added settings.KeyError (standards review): cmd/docproc was rewriting settings' message
    text to name the variables; now it reads Keys through errors.As. A new export beyond the
    brief's list. Reject it and cmd/docproc goes back to parsing text.
  2. Range rules moved from cmd/docproc's parsers into settings, so a few refusals of existing
    variables are worded differently (e.g. DOCPROC_BOMB_RATIO=-3 → "isn't a finite number of
    zero or more"; a negative DOCPROC_AUDIO_LIMIT → the over-4s message). Each is still refused
    and names its variable.
  3. cmd/docproc reads a 0 for DOCPROC_CONCURRENCY / DOCPROC_PDF_DPI as unset, so their
    documented "zero is the default" holds; a JSON host gets Decode's stricter refusal of a set
    0, and jobs keeps the strict rule (new Decision).
  4. A set audio_limit of 0 is refused, as cmd/docproc refused it; Decode takes []byte;
    Settings has no MarshalJSON.
  5. Release order follows the repo's convention: go.mods stay on v0.10.0 (cmd/docproc with
    replace => ../..) until base v0.11.0 is tagged; a docproc-settings-require PR then bumps
    storage, postgres, and cmd/docproc to it and drops the replace, and the three sub-module tags
    go on its merge commit.
  6. No tools/mail or tools/onenote CHANGELOG entries for the toolchain bumps: their output
    contract doesn't change.
  7. Dropped decision "docproc-settings: a key whose zero means no bound … is required …":
    settings/doc.go and docproc's docs/api.md "Settings" state it.

Redirects and escalations

  1. Redirect, brief: rename the puts key and DOCPROC_PUTS to output_writes and
    DOCPROC_OUTPUT_WRITES; dispatch.Config.Puts keeps its name. Done in 6cbb32c, standards
    fix 1cc4d4f, spec review: no gaps.

Merge danger: one-way door for the four tags (module proxy, then Bunrei's jobs); all else
two-way · blast radius: docproc's four modules, cmd/docproc's operators (one new variable,
DOCPROC_OUTPUT_WRITES) · docproc: merge waits on CI (gh pr checks --watch), each tag on
marathon ci; the integration tier against gotenberg 9.10.3 runs only in CI (containers) ·
capstone-bunrei: the goal record only, merge waits on CI · tags: v0.11.0, then
storage/v0.1.9, postgres/v0.1.9, cmd/docproc/v0.2.9 after the require PR

Needs you: none

cmd/docproc requires go-core v0.14.0, from v0.12.0. Neither v0.13.0's
breaking change, EventKind.Raise taking a trailing event.RaiseOptions, nor
v0.14.0's new sse package reaches cmd/docproc, which raises no event, so the
bump needs no adaptation. cmd/docproc's CHANGELOG is unchanged: its prior
entries name a dependency only when it requires the next base release.

docproc-mail and docproc-onenote move to Rust 1.100.1 and cargo-deny 0.22.2.
Their CHANGELOGs are unchanged, as the toolchain is not their output contract.

picture.LibreOfficeImage moves to gotenberg/gotenberg 9.10.3-libreoffice,
pinned by its multi-arch index digest from crane, with an Unreleased entry
in the base CHANGELOG. The integration tier was not run against the new
image.

The workflows move to jdx/mise-action v5.4.0.

MimeKit, MsgKit, and typed-path stay held with their hold reasons; currency
reports only them.
settings.Settings holds docproc's 21 run settings, one flat snake-case
key per DOCPROC_ variable plus puts, each a pointer field so unset (nil)
is told from an explicit zero, which means no bound. A Go caller sets a
key with new(v). Decode reads JSON and validates in one step; Validate
validates settings built in code. Every refusal names its key and wraps
settings.ErrRequest.

Decisions:
- Decode takes []byte, so every error is the input's: input that isn't
  one JSON object, an unknown key, a wrong JSON type, or trailing data.
- Durations decode as Go duration strings through an unexported wire
  struct of json.RawMessage fields shadowing the four duration keys, so
  Settings keeps *time.Duration fields for Go callers.
- Validate joins every refusal; the missing required keys are one error.
- audio_limit set to zero is refused, as cmd/docproc's parseAudioLimit
  refuses it, alongside anything audio.NewCutter refuses.
- bomb_size stays uint64, as inspect.Options takes it; a negative one is
  refused at decoding, naming the key.
- The package imports audio alone of docproc's packages; the assembly
  into stages.Options and dispatch.Config is the next slice's.
settings.Run holds a run's settings as stages.Options, dispatch.Limits,
the claim release bound, and the puts in flight, mirroring cmd/docproc's
Bounds plus Puts. Settings.Assemble validates first and refuses with
ErrRequest, so an unvalidated value never dereferences a nil key. An
unset optional key assembles to its default: pdf_dpi to
document.DefaultDPI, audio_limit to audio.DefaultWindowLimit, and
concurrency and puts to 1. Every option no key covers stays zero, the
host's own.

settings now imports stages and dispatch; go list -deps shows no cycle
and no requirement beyond golang.org/x/text.

Tests: a table test from JSON through Decode to the whole Run, every
field compared, so uncovered fields are proven zero; refusals of
unvalidated values; stages.Build over stand-in document tools, where
pdf_dpi and pdf_text change the document stage's identity and the set's
inspection options are the assembled ones; and dispatch.New over the
assembled Limits, Release, and Puts, where max_bytes decides whether a
text input is prepared or limited.

docs/api.md gains the Settings section (signatures, key table, required
and optional keys, formats, defaults); packages.md, layers.md, the
api.md package list, and context/README.md list the package.
…ettings.Run; DOCPROC_PUTS

newBounds starts a settings.Settings with all 21 keys at docproc's starting values (puts 1,
the old runner const), lets each DOCPROC_ variable override its key through go-core's
config.SetFromEnv (unset or empty keeps the starting value), and returns s.Assemble(). The
bounds node now holds a settings.Run; the app.Bounds type is gone, and run.Config carries the
settings.Run as Bounds in place of its Stages, Limits, and Release, so the runner takes Puts from
it. DOCPROC_PUTS is new; docs/command.md gains its row.

Refusals: cmd/docproc's parsers keep only the per-variable format checks (a whole number, in
range for its type; a Go duration; a number; a switch; bomb_size, unsigned, below zero). Every
range and cross-key rule (below zero, below 1, the bomb pair, finite bomb ratio, the audio
limit) comes from settings.Validate through Assemble. Each refusal is joined after the parse
errors with its settings key mapped to its variable by config.EnvName, the settings package's
own naming rule, and the "settings: " prefix and ErrRequest suffix dropped, so the operator sees
e.g. "bounds: DOCPROC_PUTS: 0 is below 1" and "bounds: DOCPROC_BOMB_RATIO and
DOCPROC_BOMB_SIZE: set both above zero, or both to zero for no bomb rule"; the existing
audio-limit message is unchanged.

cmd/docproc's go.mod replaces github.com/standards-lab/docproc with ../.., as 0dab39f, 27b1246,
and 1e0bff1 did, so its GOWORK=off build and tests take this checkout's settings package until
v0.11.0 is tagged; the require stays v0.10.0, and go mod tidy drops v0.10.0's go.sum lines.

Tests: bounds_test.go's helpers take settings.Run (startingBounds gains Puts 1) and boundVars
lists DOCPROC_PUTS, so the every-variable tests cover it; no assertion changed. New:
DOCPROC_PUTS overrides puts and empty keeps 1; 0, -2, and x fail naming DOCPROC_PUTS; zero
DOCPROC_CONCURRENCY and DOCPROC_PDF_DPI keep their documented default; the bomb pair's whole
message; a parse and a range refusal joined; a bad DOCPROC_PUTS fails docproc run before any
tool lookup.

Decisions:
- DOCPROC_CONCURRENCY and DOCPROC_PDF_DPI at 0 leave their key unset, so Assemble gives 1 and
  document.DefaultDPI, keeping "zero is 1" and "zero is document.DefaultDPI"; settings refuses
  an explicit 0 for both.
- Refusal text is rewritten from settings' messages rather than duplicated: settings has no
  structured refusal, and its keys are by design the variables' names.

mise run check passes.
…, postgres v0.1.9, cmd/docproc v0.2.9

- CHANGELOG.md: [Unreleased] becomes [v0.11.0] - 2026-11-28, an empty Unreleased above it and
  the compare links extended, as d66d5f3 did. Added lists the settings package: Settings,
  Decode, Validate, ErrRequest, Run, Assemble, the 21 keys, the four optional ones and their
  defaults; the Gotenberg 9.10.3 entry stays under Changed. The README's go get line names
  v0.11.0.
- storage v0.1.9 and postgres v0.1.9: their CHANGELOGs require base v0.11.0 and say what reaches
  a caller (nothing stored or indexed changes; no stage identity moves); their README install
  lines name v0.1.9.
- cmd/docproc v0.2.9: Added DOCPROC_PUTS; Changed the move onto settings, every existing
  variable keeping its meaning, format, and default, the Gotenberg 9.10.3 image as v0.2.8 listed
  its pin moves, and go-core v0.14.0.

Decisions:
- The go.mod files don't move here. v0.11.0 isn't tagged, and check:go resolves each module with
  GOWORK=off, so storage and postgres stay on v0.10.0 and cmd/docproc keeps its replace => ../..
  with the require at v0.10.0, as 0dab39f left it. At SHIP, after v0.11.0 is tagged, one commit
  bumps the three requires to v0.11.0 and drops cmd/docproc's replace, as 0cb2f43 did, before
  the provider and command tags.
- The provider CHANGELOGs and READMEs are written now rather than in that later commit, since
  the brief puts them in this slice.

mise run check passes.
…e refusal, not its text

cmd/docproc rewrote settings' error strings, cutting their prefix and suffix and
splitting the key off the reason, so a change to settings' wording would silently
mis-name a variable. A refused value is now a settings.KeyError carrying its keys
and reason, wrapping ErrRequest, as dispatch.StoreError and tool.VersionError carry
theirs; cmd/docproc renders it. Every message is unchanged.

Standard: construction-and-execution (a refusal matches its package's ErrRequest),
consistency with the library's structured errors.
… wires stages and dispatch from a settings.Run
The settings key puts becomes output_writes, settings.Settings.Puts and
settings.Run.Puts become OutputWrites, and cmd/docproc's DOCPROC_PUTS
becomes DOCPROC_OUTPUT_WRITES, in code, tests, doc comments, docs, and
the unreleased v0.11.0 and cmd/docproc v0.2.9 changelog entries.

- dispatch.Config.Puts, shipped in v0.10.0, keeps its name; the key
  table maps output_writes to it, and Run.OutputWrites is passed as Puts.
- The docs describe the key as the most outputs one part writes to the
  content store at once, at least 1, default 1.
- Behavior is unchanged: optional, default 1, a value below 1 refused
  naming output_writes (DOCPROC_OUTPUT_WRITES in cmd/docproc).
…Bounds names OutputWrites as dispatch's Puts

- cmd/docproc/CHANGELOG.md: the v0.2.9 lede's first line ran to 103 columns after the rename; rewrapped to 100.
- run.Config.Bounds' doc ran to 100+ columns and called OutputWrites a dispatch's field; it now reads "the Limits, Release, and OutputWrites, as Puts, each dispatch takes", as settings.Run's doc does.
@JaimeStill
JaimeStill merged commit 3672190 into main Nov 29, 2026
13 checks passed
@JaimeStill
JaimeStill deleted the docproc-settings branch November 29, 2026 02:29
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