diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9268816..566f301d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: steps: - uses: actions/checkout@v7.0.1 - - uses: jdx/mise-action@v5.3.0 + - uses: jdx/mise-action@v5.4.0 with: install_args: actionlint shellcheck github:standards-lab/claude-plugins @@ -110,7 +110,7 @@ jobs: steps: - uses: actions/checkout@v7.0.1 - - uses: jdx/mise-action@v5.3.0 + - uses: jdx/mise-action@v5.4.0 with: install_args: go golangci-lint @@ -144,7 +144,7 @@ jobs: if: hashFiles(format('tools/{0}/*.slnx', matrix.tool)) != '' run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang zlib1g-dev - - uses: jdx/mise-action@v5.3.0 + - uses: jdx/mise-action@v5.4.0 with: working_directory: tools/${{ matrix.tool }} @@ -187,7 +187,7 @@ jobs: steps: - uses: actions/checkout@v7.0.1 - - uses: jdx/mise-action@v5.3.0 + - uses: jdx/mise-action@v5.4.0 with: install_args: go @@ -216,7 +216,7 @@ jobs: - name: Install the NativeAOT prerequisites run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang zlib1g-dev - - uses: jdx/mise-action@v5.3.0 + - uses: jdx/mise-action@v5.4.0 with: working_directory: tools/ooxml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0d1b3ff..5c9139b5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,7 +57,7 @@ jobs: if: hashFiles(format('tools/{0}/*.slnx', needs.tag.outputs.format)) != '' run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang zlib1g-dev - - uses: jdx/mise-action@v5.3.0 + - uses: jdx/mise-action@v5.4.0 with: working_directory: tools/${{ needs.tag.outputs.format }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 41ce61f6..05addd65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,49 @@ tool under `tools/` keeps its own. ## [Unreleased] +## [v0.11.0] - 2026-11-28 + +This release adds the package `settings`, which holds a run's settings as one flat JSON object, so +a host that takes its bounds as JSON, rather than as cmd/docproc's `DOCPROC_` variables, reads, +validates, and assembles them into the shapes `stages.Build` and `dispatch.New` take. No existing +API changes, `dispatch.Version` stays "1", and the run directory's schema stays "2". + +### Added + +- Package `settings`, on the standard library and docproc's own packages alone. Its 21 keys are + each named for the `DOCPROC_` variable cmd/docproc reads it from, without the prefix and in + snake case: `tool_memory`, `unit_timeout`, `stream_idle`, `max_parts`, `max_bytes`, + `max_depth`, `bomb_ratio`, `bomb_size`, `archive_entries`, `claim_release`, `concurrency`, + `pdf_dpi`, `pdf_text`, `pdf_max_pixels`, `frame_max_side`, `magick_area`, `magick_memory`, + `magick_map`, `magick_disk`, `audio_limit`, and `output_writes`. The library sets no bound of its + own, so every key but four is required, and zero is no bound. The four optional keys, unset, take + a default: `concurrency` 1, `pdf_dpi` `document.DefaultDPI`, `audio_limit` + `audio.DefaultWindowLimit`, and `output_writes`, the most outputs one part writes to the content + store at once, 1. Set, `audio_limit` is over 4s and each other is at least 1. A duration is a + Go duration string, such as `"90s"`, and `bomb_ratio` and `bomb_size` are both zero, for no bomb + rule, or both above it. The [API page](docs/api.md#settings) states each key's format and the + field it lands in. +- `settings.Settings`, one pointer field per key, nil when unset, so an unset key is told from an + explicit zero; a Go caller sets a key with `new`. +- `settings.Decode`, which reads settings from one JSON object and validates them; input that + isn't one object, an unknown key, a value of the wrong JSON type, and trailing data are refused. +- `Settings.Validate`, which refuses settings a run can't take, each refusal naming its key, and + every unset required key in one error. +- `settings.ErrRequest`, which every refusal wraps. +- `settings.KeyError`, which refuses the values of the keys in its `Keys` for its `Reason`, so a + host names its own source for each key; it wraps `ErrRequest`. +- `settings.Run`, the settings in the library's shapes: the `stages.Options` a host passes + `stages.Build`, every option no key covers left at its zero value for the host to set; and the + `dispatch.Limits`, `Release`, and `OutputWrites`, as `Puts`, the host passes `dispatch.New` in + its `Config`. +- `Settings.Assemble`, which validates settings and returns their `Run`, each optional key left + unset at its default. + +### Changed + +- `picture.LibreOfficeImage` is `gotenberg/gotenberg:9.10.3-libreoffice`, from 9.10.2-libreoffice, + pinned by its multi-arch index digest. + ## [v0.10.0] - 2026-11-27 This release captures each format's own metadata as a record output named `metadata`: an office @@ -606,7 +649,8 @@ fixtures scripts stay in the spike. The [limits page](docs/limits.md) states them: each stage's tool's limits, docproc-ooxml's behavior under a memory bound, the Threader's memory, and the formats no stage reads. -[Unreleased]: https://github.com/standards-lab/docproc/compare/v0.10.0...HEAD +[Unreleased]: https://github.com/standards-lab/docproc/compare/v0.11.0...HEAD +[v0.11.0]: https://github.com/standards-lab/docproc/compare/v0.10.0...v0.11.0 [v0.10.0]: https://github.com/standards-lab/docproc/compare/v0.9.0...v0.10.0 [v0.9.0]: https://github.com/standards-lab/docproc/compare/v0.8.0...v0.9.0 [v0.8.0]: https://github.com/standards-lab/docproc/compare/v0.7.0...v0.8.0 diff --git a/README.md b/README.md index d91e5c16..1c09aaf8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ tags. ## Install ```sh -go get github.com/standards-lab/docproc@v0.10.0 +go get github.com/standards-lab/docproc@v0.11.0 ``` The module's releases are tagged `vX.Y.Z`, and [`CHANGELOG.md`](CHANGELOG.md) states what each diff --git a/cmd/docproc/CHANGELOG.md b/cmd/docproc/CHANGELOG.md index 1e976c86..d03e63ea 100644 --- a/cmd/docproc/CHANGELOG.md +++ b/cmd/docproc/CHANGELOG.md @@ -10,6 +10,31 @@ postgres modules, and each system tool under `tools/` keep their own. ## [Unreleased] +## [v0.2.9] - 2026-11-28 + +This release reads its run bounds through the docproc base module's new package `settings`, at +v0.11.0, and adds `DOCPROC_OUTPUT_WRITES`. Its exit codes and run directory's schema are +unchanged, and every existing variable keeps its meaning and its default. + +### Added + +- `DOCPROC_OUTPUT_WRITES`, the most outputs one part writes to the content store at once + (`dispatch.Config.Puts`), at least 1, so zero is refused; unset or empty, it is 1, the bound + `docproc run` held before. + +### Changed + +- The module requires the docproc base module at v0.11.0, whose + [CHANGELOG](../../CHANGELOG.md) states its changes in full. `docproc run` reads each + `DOCPROC_` variable into its key of a `settings.Settings` and assembles them into a + `settings.Run`, the bounds it passes `stages.Build` and `dispatch.New`. Each variable keeps its + meaning, its format, and its default, and `DOCPROC_CONCURRENCY` and `DOCPROC_PDF_DPI` still read + zero as their default. A refused value still fails `docproc run` before any tool is looked up, + and its message names the variable, such as `bounds: DOCPROC_OUTPUT_WRITES: 0 is below 1`. +- soffice runs in `gotenberg/gotenberg:9.10.3-libreoffice`, from 9.10.2-libreoffice, pinned by + its multi-arch index digest. +- The module requires go-core v0.14.0, from v0.12.0; nothing `docproc run` does changes with it. + ## [v0.2.8] - 2026-11-27 This release requires the docproc base module at v0.10.0, whose changes reach `docproc run` as @@ -319,7 +344,8 @@ and go-core v0.12.0, in place of the spike's port of go-cli-sdk v0.2.0's. writes, read back through `rundir`, and the report it renders of a fixture run and of a killed run. -[Unreleased]: https://github.com/standards-lab/docproc/compare/cmd/docproc/v0.2.8...HEAD +[Unreleased]: https://github.com/standards-lab/docproc/compare/cmd/docproc/v0.2.9...HEAD +[v0.2.9]: https://github.com/standards-lab/docproc/compare/cmd/docproc/v0.2.8...cmd/docproc/v0.2.9 [v0.2.8]: https://github.com/standards-lab/docproc/compare/cmd/docproc/v0.2.7...cmd/docproc/v0.2.8 [v0.2.7]: https://github.com/standards-lab/docproc/compare/cmd/docproc/v0.2.6...cmd/docproc/v0.2.7 [v0.2.6]: https://github.com/standards-lab/docproc/compare/cmd/docproc/v0.2.5...cmd/docproc/v0.2.6 diff --git a/cmd/docproc/go.mod b/cmd/docproc/go.mod index 57259783..93fd5b88 100644 --- a/cmd/docproc/go.mod +++ b/cmd/docproc/go.mod @@ -5,8 +5,10 @@ go 1.27.4 require ( github.com/standards-lab/docproc v0.10.0 github.com/standards-lab/go-cli-sdk v0.4.0 - github.com/standards-lab/go-core v0.12.0 + github.com/standards-lab/go-core v0.14.0 golang.org/x/sys v0.50.0 ) require golang.org/x/text v0.44.0 // indirect + +replace github.com/standards-lab/docproc => ../.. diff --git a/cmd/docproc/go.sum b/cmd/docproc/go.sum index a5895ae8..1ac05c49 100644 --- a/cmd/docproc/go.sum +++ b/cmd/docproc/go.sum @@ -1,9 +1,7 @@ -github.com/standards-lab/docproc v0.10.0 h1:4neT6syfThhNA9YmfHKMRt6OXt1MXSI9uJbFGOUE19k= -github.com/standards-lab/docproc v0.10.0/go.mod h1:ZA8JYQPooA6YA84b00Lpu5AiSL2VSj/u7QnenltqVBA= github.com/standards-lab/go-cli-sdk v0.4.0 h1:232dyKPD5kqshp0BMEVEZaedwJfvnDVqWLv7m1NQWmI= github.com/standards-lab/go-cli-sdk v0.4.0/go.mod h1:7Y1BCcHtuu8Unxc+Hryjlln+0fbiMYa5xY75aueJ/rY= -github.com/standards-lab/go-core v0.12.0 h1:sqrzK6QSppEYpwvVAyiWgzNuOsjfK0Kwe86GPuZpHsU= -github.com/standards-lab/go-core v0.12.0/go.mod h1:Yl/R+gM9YWczsePBCKXdPGh3FSdZ/5i8SapLIh3BDHU= +github.com/standards-lab/go-core v0.14.0 h1:n8FRpoCqE0HErfo5V1iWASipo3ORx36V6ESQhgFZ27E= +github.com/standards-lab/go-core v0.14.0/go.mod h1:Yl/R+gM9YWczsePBCKXdPGh3FSdZ/5i8SapLIh3BDHU= golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs= golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo= diff --git a/cmd/docproc/internal/app/app.go b/cmd/docproc/internal/app/app.go index be68f6f7..1304e8b9 100644 --- a/cmd/docproc/internal/app/app.go +++ b/cmd/docproc/internal/app/app.go @@ -7,6 +7,8 @@ import ( "github.com/standards-lab/go-core/graph" "github.com/standards-lab/go-core/lifecycle" + "github.com/standards-lab/docproc/settings" + "github.com/standards-lab/docproc/cmd/docproc/internal/run" ) @@ -60,7 +62,7 @@ func (a *App) Run(ctx context.Context, args []string) int { // comment repeats it. type Nodes struct { LifecycleConfig *graph.Node[lifecycle.Config] - Bounds *graph.Node[Bounds] + Bounds *graph.Node[settings.Run] StageBuilder *graph.Node[run.StageBuilder] RunConfig *graph.Node[run.Config] } diff --git a/cmd/docproc/internal/app/bounds_test.go b/cmd/docproc/internal/app/bounds_test.go index edaf2ea8..963222f8 100644 --- a/cmd/docproc/internal/app/bounds_test.go +++ b/cmd/docproc/internal/app/bounds_test.go @@ -19,6 +19,7 @@ import ( "github.com/standards-lab/docproc/inspect" "github.com/standards-lab/docproc/media" "github.com/standards-lab/docproc/picture" + "github.com/standards-lab/docproc/settings" "github.com/standards-lab/docproc/stages" "github.com/standards-lab/docproc/cmd/docproc/internal/app" @@ -48,10 +49,11 @@ var boundVars = []string{ "DOCPROC_MAGICK_MAP", "DOCPROC_MAGICK_DISK", "DOCPROC_AUDIO_LIMIT", + "DOCPROC_OUTPUT_WRITES", } -func startingBounds() app.Bounds { - return app.Bounds{ +func startingBounds() settings.Run { + return settings.Run{ Stages: stages.Options{ Memory: 2 * gib, Timeout: 10 * time.Minute, @@ -63,8 +65,9 @@ func startingBounds() app.Bounds { Magick: picture.Limits{Area: 256_000_000, Memory: 1 * gib, Map: 2 * gib, Disk: 8 * gib}, Audio: audio.Request{Limit: 30 * time.Second}, }, - Limits: dispatch.Limits{Parts: 100_000, Bytes: 32 * gib, Depth: 16}, - Release: 10 * time.Second, + Limits: dispatch.Limits{Parts: 100_000, Bytes: 32 * gib, Depth: 16}, + Release: 10 * time.Second, + OutputWrites: 1, } } @@ -75,12 +78,12 @@ func clearBounds(t *testing.T) { } } -func buildBounds(t *testing.T) (app.Bounds, error) { +func buildBounds(t *testing.T) (settings.Run, error) { t.Helper() a := app.New(cli.Streams{}) sys, err := a.Graph().Build(a.Nodes().Bounds) if err != nil { - return app.Bounds{}, err + return settings.Run{}, err } return sys.Get(a.Nodes().Bounds), nil } @@ -114,29 +117,29 @@ func TestBounds_StartingValuesTakenByStages(t *testing.T) { func TestBounds_EachVariableOverridesItsBound(t *testing.T) { for _, tc := range []struct { name, value string - set func(*app.Bounds) + set func(*settings.Run) }{ - {"DOCPROC_TOOL_MEMORY", "536870912", func(b *app.Bounds) { b.Stages.Memory = 512 << 20 }}, - {"DOCPROC_UNIT_TIMEOUT", "90s", func(b *app.Bounds) { b.Stages.Timeout = 90 * time.Second }}, - {"DOCPROC_STREAM_IDLE", "1m30s", func(b *app.Bounds) { b.Stages.Idle = 90 * time.Second }}, - {"DOCPROC_MAX_PARTS", "50", func(b *app.Bounds) { b.Limits.Parts = 50 }}, - {"DOCPROC_MAX_BYTES", "1048576", func(b *app.Bounds) { b.Limits.Bytes = 1 << 20 }}, - {"DOCPROC_MAX_DEPTH", "4", func(b *app.Bounds) { b.Limits.Depth = 4 }}, - {"DOCPROC_BOMB_RATIO", "250.5", func(b *app.Bounds) { b.Stages.Inspect.BombRatio = 250.5 }}, - {"DOCPROC_BOMB_SIZE", "1024", func(b *app.Bounds) { b.Stages.Inspect.BombSize = 1024 }}, - {"DOCPROC_ARCHIVE_ENTRIES", "10", func(b *app.Bounds) { b.Stages.Inspect.Entries = 10 }}, - {"DOCPROC_CLAIM_RELEASE", "500ms", func(b *app.Bounds) { b.Release = 500 * time.Millisecond }}, - {"DOCPROC_CONCURRENCY", "4", func(b *app.Bounds) { b.Stages.Concurrency = 4 }}, - {"DOCPROC_PDF_DPI", "300", func(b *app.Bounds) { b.Stages.Document.DPI = 300 }}, - {"DOCPROC_PDF_TEXT", "false", func(b *app.Bounds) { b.Stages.Document.Text = false }}, - {"DOCPROC_PDF_MAX_PIXELS", "1000", func(b *app.Bounds) { b.Stages.Document.MaxPixels = 1000 }}, - {"DOCPROC_FRAME_MAX_SIDE", "720", func(b *app.Bounds) { b.Stages.Video.MaxSide = 720 }}, - {"DOCPROC_MAGICK_AREA", "1000000", func(b *app.Bounds) { b.Stages.Magick.Area = 1_000_000 }}, - {"DOCPROC_MAGICK_MEMORY", "1024", func(b *app.Bounds) { b.Stages.Magick.Memory = 1024 }}, - {"DOCPROC_MAGICK_MAP", "2048", func(b *app.Bounds) { b.Stages.Magick.Map = 2048 }}, - {"DOCPROC_MAGICK_DISK", "0", func(b *app.Bounds) { b.Stages.Magick.Disk = 0 }}, - {"DOCPROC_AUDIO_LIMIT", "45s", func(b *app.Bounds) { b.Stages.Audio.Limit = 45 * time.Second }}, - {"DOCPROC_AUDIO_LIMIT", "4001ms", func(b *app.Bounds) { b.Stages.Audio.Limit = 4001 * time.Millisecond }}, + {"DOCPROC_TOOL_MEMORY", "536870912", func(b *settings.Run) { b.Stages.Memory = 512 << 20 }}, + {"DOCPROC_UNIT_TIMEOUT", "90s", func(b *settings.Run) { b.Stages.Timeout = 90 * time.Second }}, + {"DOCPROC_STREAM_IDLE", "1m30s", func(b *settings.Run) { b.Stages.Idle = 90 * time.Second }}, + {"DOCPROC_MAX_PARTS", "50", func(b *settings.Run) { b.Limits.Parts = 50 }}, + {"DOCPROC_MAX_BYTES", "1048576", func(b *settings.Run) { b.Limits.Bytes = 1 << 20 }}, + {"DOCPROC_MAX_DEPTH", "4", func(b *settings.Run) { b.Limits.Depth = 4 }}, + {"DOCPROC_BOMB_RATIO", "250.5", func(b *settings.Run) { b.Stages.Inspect.BombRatio = 250.5 }}, + {"DOCPROC_BOMB_SIZE", "1024", func(b *settings.Run) { b.Stages.Inspect.BombSize = 1024 }}, + {"DOCPROC_ARCHIVE_ENTRIES", "10", func(b *settings.Run) { b.Stages.Inspect.Entries = 10 }}, + {"DOCPROC_CLAIM_RELEASE", "500ms", func(b *settings.Run) { b.Release = 500 * time.Millisecond }}, + {"DOCPROC_CONCURRENCY", "4", func(b *settings.Run) { b.Stages.Concurrency = 4 }}, + {"DOCPROC_PDF_DPI", "300", func(b *settings.Run) { b.Stages.Document.DPI = 300 }}, + {"DOCPROC_PDF_TEXT", "false", func(b *settings.Run) { b.Stages.Document.Text = false }}, + {"DOCPROC_PDF_MAX_PIXELS", "1000", func(b *settings.Run) { b.Stages.Document.MaxPixels = 1000 }}, + {"DOCPROC_FRAME_MAX_SIDE", "720", func(b *settings.Run) { b.Stages.Video.MaxSide = 720 }}, + {"DOCPROC_MAGICK_AREA", "1000000", func(b *settings.Run) { b.Stages.Magick.Area = 1_000_000 }}, + {"DOCPROC_MAGICK_MEMORY", "1024", func(b *settings.Run) { b.Stages.Magick.Memory = 1024 }}, + {"DOCPROC_MAGICK_MAP", "2048", func(b *settings.Run) { b.Stages.Magick.Map = 2048 }}, + {"DOCPROC_MAGICK_DISK", "0", func(b *settings.Run) { b.Stages.Magick.Disk = 0 }}, + {"DOCPROC_AUDIO_LIMIT", "45s", func(b *settings.Run) { b.Stages.Audio.Limit = 45 * time.Second }}, + {"DOCPROC_AUDIO_LIMIT", "4001ms", func(b *settings.Run) { b.Stages.Audio.Limit = 4001 * time.Millisecond }}, } { t.Run(tc.name+"="+tc.value, func(t *testing.T) { clearBounds(t) @@ -156,6 +159,102 @@ func TestBounds_EachVariableOverridesItsBound(t *testing.T) { } } +func TestBounds_OutputWritesOverride(t *testing.T) { + for _, tc := range []struct { + value string + want int + }{ + {"", 1}, + {"4", 4}, + } { + t.Run("DOCPROC_OUTPUT_WRITES="+tc.value, func(t *testing.T) { + clearBounds(t) + t.Setenv("DOCPROC_OUTPUT_WRITES", tc.value) + + got, err := buildBounds(t) + + if err != nil { + t.Fatalf("Build: %v", err) + } + want := startingBounds() + want.OutputWrites = tc.want + if !reflect.DeepEqual(got, want) { + t.Errorf("bounds = %+v\nwant %+v", got, want) + } + }) + } +} + +func TestBounds_OutputWritesRefused(t *testing.T) { + for _, tc := range []struct{ value, want string }{ + {"0", "bounds: DOCPROC_OUTPUT_WRITES: 0 is below 1"}, + {"-2", "bounds: DOCPROC_OUTPUT_WRITES: -2 is below 1"}, + {"x", `bounds: DOCPROC_OUTPUT_WRITES: "x" is not a whole number`}, + } { + t.Run(tc.value, func(t *testing.T) { + clearBounds(t) + t.Setenv("DOCPROC_OUTPUT_WRITES", tc.value) + + _, err := buildBounds(t) + + if err == nil || err.Error() != tc.want { + t.Errorf("Build: %v, want %q", err, tc.want) + } + }) + } +} + +func TestBounds_ZeroIsTheDefault(t *testing.T) { + for _, tc := range []struct { + name string + set func(*settings.Run) + }{ + {"DOCPROC_CONCURRENCY", func(b *settings.Run) { b.Stages.Concurrency = 1 }}, + {"DOCPROC_PDF_DPI", func(b *settings.Run) { b.Stages.Document.DPI = document.DefaultDPI }}, + } { + t.Run(tc.name, func(t *testing.T) { + clearBounds(t) + t.Setenv(tc.name, "0") + + got, err := buildBounds(t) + + if err != nil { + t.Fatalf("Build: %v", err) + } + want := startingBounds() + tc.set(&want) + if !reflect.DeepEqual(got, want) { + t.Errorf("bounds = %+v\nwant %+v", got, want) + } + }) + } +} + +func TestBounds_BombRuleMessage(t *testing.T) { + clearBounds(t) + t.Setenv("DOCPROC_BOMB_SIZE", "0") + + _, err := buildBounds(t) + + want := "bounds: DOCPROC_BOMB_RATIO and DOCPROC_BOMB_SIZE: set both above zero, or both to zero for no bomb rule" + if err == nil || err.Error() != want { + t.Errorf("Build: %v, want %q", err, want) + } +} + +func TestBounds_ParseAndRangeRefusalsJoined(t *testing.T) { + clearBounds(t) + t.Setenv("DOCPROC_OUTPUT_WRITES", "many") + t.Setenv("DOCPROC_UNIT_TIMEOUT", "-1s") + + _, err := buildBounds(t) + + want := "bounds: DOCPROC_OUTPUT_WRITES: \"many\" is not a whole number\nDOCPROC_UNIT_TIMEOUT: -1s is below zero" + if err == nil || err.Error() != want { + t.Errorf("Build: %v, want %q", err, want) + } +} + func TestBounds_EveryVariableIsRead(t *testing.T) { for _, name := range boundVars { t.Run(name, func(t *testing.T) { @@ -377,3 +476,24 @@ func TestRun_VersionReadsNoBound(t *testing.T) { t.Errorf("nodes built = %q, want none", log) } } + +func TestRun_OutputWritesRefusedBeforeLookup(t *testing.T) { + in := write(t, t.TempDir(), "hello.txt", helloText) + out := filepath.Join(t.TempDir(), "out") + lookup, looked := probes(apptest.NoTools) + + r := runCmd(t, context.Background(), func(a *app.App) { + t.Setenv("DOCPROC_OUTPUT_WRITES", "0") + apptest.Tools(a, lookup) + }, in, "--out", out) + + if r.code != process.ExitFailure { + t.Errorf("code = %d, want %d", r.code, process.ExitFailure) + } + if want := "docproc run: bounds: DOCPROC_OUTPUT_WRITES: 0 is below 1"; !strings.HasPrefix(r.stderr, want) { + t.Errorf("stderr = %q, want it to start with %q", r.stderr, want) + } + if log := looked.Log(); len(log) != 0 { + t.Errorf("tools looked up = %q, want none", log) + } +} diff --git a/cmd/docproc/internal/app/doc.go b/cmd/docproc/internal/app/doc.go index b80ec5df..ad508fc2 100644 --- a/cmd/docproc/internal/app/doc.go +++ b/cmd/docproc/internal/app/doc.go @@ -7,9 +7,10 @@ // - app.go: [App], [New], and [Nodes], which call the layer files' define and mount functions // in layer order, lowest first; // - infrastructure.go: defineInfrastructure, the configuration, read from DOCPROC_ variables: -// the lifecycle configuration and [Bounds], a run's bounds at docproc's starting values; +// the lifecycle configuration and the bounds, a settings.Settings at docproc's starting +// values, each variable overriding its key, assembled into a settings.Run; // - domain.go: defineDomain and mountDomain, the services over docproc's library, the stage -// builder, stages.Build over the host's tools, and the run config over it and [Bounds], and +// builder, stages.Build over the host's tools, and the run config over it and the bounds, and // the commands, from the command packages under internal/, that run them: run, from // internal/run; // - version.go: the version command, which declares no nodes. diff --git a/cmd/docproc/internal/app/domain.go b/cmd/docproc/internal/app/domain.go index 8477d65b..a7a14f56 100644 --- a/cmd/docproc/internal/app/domain.go +++ b/cmd/docproc/internal/app/domain.go @@ -16,11 +16,8 @@ import ( func defineDomain(g *graph.Graph, n *Nodes) { n.StageBuilder = g.Define("stage builder", newStageBuilder) n.RunConfig = g.Define("run config", func(s *graph.Scope) (run.Config, error) { - b := s.Use(n.Bounds) return run.Config{ - Stages: b.Stages, - Limits: b.Limits, - Release: b.Release, + Bounds: s.Use(n.Bounds), Build: s.Use(n.StageBuilder), Docproc: docprocBuild(), }, nil diff --git a/cmd/docproc/internal/app/infrastructure.go b/cmd/docproc/internal/app/infrastructure.go index 37b0ac6a..27b2661d 100644 --- a/cmd/docproc/internal/app/infrastructure.go +++ b/cmd/docproc/internal/app/infrastructure.go @@ -3,21 +3,15 @@ package app import ( "errors" "fmt" - "math" "strconv" + "strings" "time" "github.com/standards-lab/go-core/config" "github.com/standards-lab/go-core/graph" "github.com/standards-lab/go-core/lifecycle" - "github.com/standards-lab/docproc/audio" - "github.com/standards-lab/docproc/dispatch" - "github.com/standards-lab/docproc/document" - "github.com/standards-lab/docproc/inspect" - "github.com/standards-lab/docproc/media" - "github.com/standards-lab/docproc/picture" - "github.com/standards-lab/docproc/stages" + "github.com/standards-lab/docproc/settings" ) const envPrefix = "DOCPROC" @@ -33,129 +27,128 @@ func newLifecycleConfig(*graph.Scope) (lifecycle.Config, error) { return cfg, err } -// Bounds are a run's bounds, in the shapes the library takes them, so a run hands them on as -// they are: Stages to stages.Build, and Limits and Release to the dispatch.Config, with the -// stages.Set's Inspect, these options validated, as its Inspect. The library sets no bound of -// its own; each here starts at docproc's starting value, which its variable overrides. -type Bounds struct { - // Stages carry the run bounds, the inspection options, and the PDF, audio, video, and - // ImageMagick bounds; every other option is the zero value, so every route is wired and every - // other request is at its own defaults. - Stages stages.Options - // Limits are each dispatch's caps. - Limits dispatch.Limits - // Release bounds a claim's release once a dispatch's context has ended: - // dispatch.Config.Release. - Release time.Duration -} - const gib = 1 << 30 -const ( - bombRatioVar = "bomb ratio" - bombSizeVar = "bomb size" -) - // See docs/command.md, "Configuration". -func newBounds(*graph.Scope) (Bounds, error) { - b := Bounds{ - Stages: stages.Options{ - Memory: 2 * gib, - Timeout: 10 * time.Minute, - Idle: 2 * time.Minute, - Inspect: inspect.Options{BombRatio: 1000, BombSize: 1 * gib, Entries: 100_000}, - - Concurrency: 1, - Document: document.ImagesRequest{DPI: 150, Text: true, MaxPixels: 64_000_000}, - Video: media.Request{MaxSide: 2048}, - Magick: picture.Limits{Area: 256_000_000, Memory: 1 * gib, Map: 2 * gib, Disk: 8 * gib}, - Audio: audio.Request{Limit: 30 * time.Second}, - }, - Limits: dispatch.Limits{Parts: 100_000, Bytes: 32 * gib, Depth: 16}, - Release: 10 * time.Second, +func newBounds(*graph.Scope) (settings.Run, error) { + s := settings.Settings{ + ToolMemory: new(int64(2 * gib)), + UnitTimeout: new(10 * time.Minute), + StreamIdle: new(2 * time.Minute), + MaxParts: new(100_000), + MaxBytes: new(int64(32 * gib)), + MaxDepth: new(16), + BombRatio: new(float64(1000)), + BombSize: new(uint64(1 * gib)), + ArchiveEntries: new(100_000), + ClaimRelease: new(10 * time.Second), + Concurrency: new(1), + PDFDPI: new(150), + PDFText: new(true), + PDFMaxPixels: new(int64(64_000_000)), + FrameMaxSide: new(2048), + MagickArea: new(int64(256_000_000)), + MagickMemory: new(int64(1 * gib)), + MagickMap: new(int64(2 * gib)), + MagickDisk: new(int64(8 * gib)), + AudioLimit: new(30 * time.Second), + OutputWrites: new(1), } errs := []error{ - readEnv(&b.Stages.Memory, "tool memory", parseCount[int64]), - readEnv(&b.Stages.Timeout, "unit timeout", parseDuration), - readEnv(&b.Stages.Idle, "stream idle", parseDuration), - readEnv(&b.Limits.Parts, "max parts", parseCount[int]), - readEnv(&b.Limits.Bytes, "max bytes", parseCount[int64]), - readEnv(&b.Limits.Depth, "max depth", parseCount[int]), - readEnv(&b.Stages.Inspect.BombRatio, bombRatioVar, parseRatio), - readEnv(&b.Stages.Inspect.BombSize, bombSizeVar, parseCount[uint64]), - readEnv(&b.Stages.Inspect.Entries, "archive entries", parseCount[int]), - readEnv(&b.Release, "claim release", parseDuration), - readEnv(&b.Stages.Concurrency, "concurrency", parseCount[int]), - readEnv(&b.Stages.Document.DPI, "pdf dpi", parseCount[int]), - readEnv(&b.Stages.Document.Text, "pdf text", strconv.ParseBool), - readEnv(&b.Stages.Document.MaxPixels, "pdf max pixels", parseCount[int64]), - readEnv(&b.Stages.Video.MaxSide, "frame max side", parseCount[int]), - readEnv(&b.Stages.Magick.Area, "magick area", parseCount[int64]), - readEnv(&b.Stages.Magick.Memory, "magick memory", parseCount[int64]), - readEnv(&b.Stages.Magick.Map, "magick map", parseCount[int64]), - readEnv(&b.Stages.Magick.Disk, "magick disk", parseCount[int64]), - readEnv(&b.Stages.Audio.Limit, "audio limit", parseAudioLimit), + readEnv(&s.ToolMemory, "tool_memory", parseCount[int64]), + readEnv(&s.UnitTimeout, "unit_timeout", parseDuration), + readEnv(&s.StreamIdle, "stream_idle", parseDuration), + readEnv(&s.MaxParts, "max_parts", parseCount[int]), + readEnv(&s.MaxBytes, "max_bytes", parseCount[int64]), + readEnv(&s.MaxDepth, "max_depth", parseCount[int]), + readEnv(&s.BombRatio, "bomb_ratio", parseRatio), + readEnv(&s.BombSize, "bomb_size", parseSize), + readEnv(&s.ArchiveEntries, "archive_entries", parseCount[int]), + readEnv(&s.ClaimRelease, "claim_release", parseDuration), + readZeroIsDefault(&s.Concurrency, "concurrency"), + readZeroIsDefault(&s.PDFDPI, "pdf_dpi"), + readEnv(&s.PDFText, "pdf_text", strconv.ParseBool), + readEnv(&s.PDFMaxPixels, "pdf_max_pixels", parseCount[int64]), + readEnv(&s.FrameMaxSide, "frame_max_side", parseCount[int]), + readEnv(&s.MagickArea, "magick_area", parseCount[int64]), + readEnv(&s.MagickMemory, "magick_memory", parseCount[int64]), + readEnv(&s.MagickMap, "magick_map", parseCount[int64]), + readEnv(&s.MagickDisk, "magick_disk", parseCount[int64]), + readEnv(&s.AudioLimit, "audio_limit", parseDuration), + readEnv(&s.OutputWrites, "output_writes", parseCount[int]), } - if (b.Stages.Inspect.BombRatio == 0) != (b.Stages.Inspect.BombSize == 0) { - errs = append(errs, fmt.Errorf("%s and %s: set both above zero, or both to zero for no bomb rule", - config.EnvName(envPrefix, bombRatioVar), config.EnvName(envPrefix, bombSizeVar))) - } - return b, errors.Join(errs...) + run, err := s.Assemble() + return run, errors.Join(append(errs, variables(err)...)...) +} + +func readEnv[T any](dest **T, key string, parse func(string) (T, error)) error { + return config.SetFromEnv(dest, config.EnvName(envPrefix, key), parse) } -func readEnv[T any](dest *T, bound string, parse func(string) (T, error)) error { - var v *T - err := config.SetFromEnv(&v, config.EnvName(envPrefix, bound), parse) - if v != nil { - *dest = *v +func readZeroIsDefault(dest **int, key string) error { + err := readEnv(dest, key, parseCount[int]) + if *dest != nil && **dest == 0 { + *dest = nil } return err } -func parseCount[T int | int64 | uint64](s string) (T, error) { +func variables(err error) []error { + if err == nil { + return nil + } + refusals := []error{err} + if joined, ok := err.(interface{ Unwrap() []error }); ok { + refusals = joined.Unwrap() + } + errs := make([]error, len(refusals)) + for i, refusal := range refusals { + var ke *settings.KeyError + if !errors.As(refusal, &ke) { + errs[i] = refusal + continue + } + names := make([]string, len(ke.Keys)) + for j, key := range ke.Keys { + names[j] = config.EnvName(envPrefix, key) + } + errs[i] = fmt.Errorf("%s: %s", strings.Join(names, " and "), ke.Reason) + } + return errs +} + +func parseCount[T int | int64](s string) (T, error) { n, err := strconv.ParseInt(s, 10, 64) switch { case errors.Is(err, strconv.ErrRange), err == nil && int64(T(n)) != n: return 0, fmt.Errorf("%s is out of range", s) case err != nil: return 0, fmt.Errorf("%q is not a whole number", s) - case n < 0: - return 0, fmt.Errorf("%d is below zero", n) } return T(n), nil } -func parseDuration(s string) (time.Duration, error) { - d, err := time.ParseDuration(s) - switch { - case err != nil: - return 0, fmt.Errorf("%q is not a duration, such as 90s or 10m", s) - case d < 0: - return 0, fmt.Errorf("%s is below zero", d) +func parseSize(s string) (uint64, error) { + n, err := parseCount[int64](s) + if err == nil && n < 0 { + return 0, fmt.Errorf("%d is below zero", n) } - return d, nil + return uint64(n), err } -func parseAudioLimit(s string) (time.Duration, error) { - d, err := parseDuration(s) +func parseDuration(s string) (time.Duration, error) { + d, err := time.ParseDuration(s) if err != nil { - return 0, err - } - if _, err := audio.NewPlanner(audio.Request{Limit: d}); d == 0 || err != nil { - return 0, fmt.Errorf("%v isn't over %v, twice the %v overlap between windows", - d, 2*audio.DefaultOverlap, audio.DefaultOverlap) + return 0, fmt.Errorf("%q is not a duration, such as 90s or 10m", s) } return d, nil } func parseRatio(s string) (float64, error) { r, err := strconv.ParseFloat(s, 64) - switch { - case err != nil, math.IsNaN(r), math.IsInf(r, 0): - return 0, fmt.Errorf("%q is not a finite number", s) - case r < 0: - return 0, fmt.Errorf("%g is below zero", r) + if err != nil { + return 0, fmt.Errorf("%q is not a number", s) } return r, nil } diff --git a/cmd/docproc/internal/run/commands.go b/cmd/docproc/internal/run/commands.go index 54149453..068733f6 100644 --- a/cmd/docproc/internal/run/commands.go +++ b/cmd/docproc/internal/run/commands.go @@ -5,14 +5,13 @@ import ( "io" "runtime" "slices" - "time" "github.com/standards-lab/go-cli-sdk" "github.com/standards-lab/go-core/graph" - "github.com/standards-lab/docproc/dispatch" "github.com/standards-lab/docproc/route" "github.com/standards-lab/docproc/rundir/schema" + "github.com/standards-lab/docproc/settings" "github.com/standards-lab/docproc/stages" ) @@ -23,14 +22,10 @@ type StageBuilder func(ctx context.Context, opts stages.Options) (stages.Set, er // Config is what the run command runs under: the run's bounds, in the library's shapes, the // stage builder, and the docproc build that writes the run. type Config struct { - // Stages are the options the stages are built under; the command adds the routes --exclude - // names to their Exclude. - Stages stages.Options - // Limits are each dispatch's caps, dispatch.Config.Limits. - Limits dispatch.Limits - // Release bounds a claim's release once a dispatch's context has ended, - // dispatch.Config.Release. - Release time.Duration + // Bounds are the run's bounds: the options the stages are built under, to whose Exclude the + // command adds the routes --exclude names, and the Limits, Release, and OutputWrites, as Puts, + // each dispatch takes. + Bounds settings.Run // Build builds the stages; it is required. Build StageBuilder // Docproc is what writes the run, the manifest's "docproc". @@ -95,7 +90,7 @@ func command(cfg *graph.Node[Config]) *cli.Command { return err } c := inv.Get(cfg) - c.Stages.Exclude = slices.Concat(c.Stages.Exclude, excluded) + c.Bounds.Stages.Exclude = slices.Concat(c.Bounds.Stages.Exclude, excluded) r := &runner{cfg: c, w: inv.Stdout, out: out, args: inv.Args, inputs: inputs, workers: workers, report: render} return r.run(ctx) }, diff --git a/cmd/docproc/internal/run/doc.go b/cmd/docproc/internal/run/doc.go index 5dee1319..535e6f6a 100644 --- a/cmd/docproc/internal/run/doc.go +++ b/cmd/docproc/internal/run/doc.go @@ -14,16 +14,15 @@ // // The run's manifest names its docproc build, its workers, its path arguments, how many inputs they // named, the tools the stage builder tried, and the stage table. Each output's content is in the -// run directory's content store, put there by the dispatcher one at a time per dispatch, since a -// put is a copy on the local disk the workers' dispatches already keep busy, and a part the index -// has seen replays its log, its children's included, through the dispatcher, so every line is this -// run's own. An input's own part line, its last, carries its file's metadata, through os.Stat and -// statx's birth time where the kernel gives one, and its type as net/http.DetectContentType sniffs -// it, and its time, from its first event to its last, both taken on the pool's loop. A quarantined -// part's file is kept in the run directory, and its line names the kept file whenever it exists, -// whether this run or an earlier one kept it; an unread child, as an archive's entry with an unsafe -// name, has no file and no SHA-256, so nothing of it is kept. An input whose dispatch stopped -// before its own event is an error line. +// run directory's content store, written there by the dispatcher, its bounds' OutputWrites at once +// per part, and a part the index has seen replays its log, its children's included, through the +// dispatcher, so every line is this run's own. An input's own part line, its last, carries its +// file's metadata, through os.Stat and statx's birth time where the kernel gives one, and its type +// as net/http.DetectContentType sniffs it, and its time, from its first event to its last, both +// taken on the pool's loop. A quarantined part's file is kept in the run directory, and its line +// names the kept file whenever it exists, whether this run or an earlier one kept it; an unread +// child, as an archive's entry with an unsafe name, has no file and no SHA-256, so nothing of it is +// kept. An input whose dispatch stopped before its own event is an error line. // // As each input's own event arrives, the terminal prints one line: its path, route, outcome, // outputs, children, and time, a failed part's error cut to its first line and at most 400 runes, diff --git a/cmd/docproc/internal/run/runner.go b/cmd/docproc/internal/run/runner.go index 01e2e21e..59443405 100644 --- a/cmd/docproc/internal/run/runner.go +++ b/cmd/docproc/internal/run/runner.go @@ -18,8 +18,6 @@ import ( "github.com/standards-lab/docproc/cmd/docproc/internal/report" ) -const puts = 1 - type runner struct { cfg Config w io.Writer @@ -31,7 +29,7 @@ type runner struct { } func (r *runner) run(ctx context.Context) error { - set, err := r.cfg.Build(ctx, r.cfg.Stages) + set, err := r.cfg.Build(ctx, r.cfg.Bounds.Stages) if err != nil { return err } @@ -101,10 +99,10 @@ func (r *runner) dispatch(ctx context.Context, set stages.Set, rec *recorder) (e Index: rec.dir.Index(), Content: rec.dir.Content(), Dir: work, - Limits: r.cfg.Limits, + Limits: r.cfg.Bounds.Limits, Inspect: set.Inspect, - Puts: puts, - Release: r.cfg.Release, + Puts: r.cfg.Bounds.OutputWrites, + Release: r.cfg.Bounds.Release, }) if err != nil { return err diff --git a/context/README.md b/context/README.md index ef5b0722..edbad8f0 100644 --- a/context/README.md +++ b/context/README.md @@ -32,7 +32,8 @@ tasks' measurements of what v1.ai.processing delivers. [onenote/doc.go](../onenote/doc.go), [sevenzip/doc.go](../sevenzip/doc.go). - **Media** (built): [audio/doc.go](../audio/doc.go), [media/doc.go](../media/doc.go), [picture/doc.go](../picture/doc.go), [document/doc.go](../document/doc.go). -- **Dispatch** (built): [dispatch/doc.go](../dispatch/doc.go), [stages/doc.go](../stages/doc.go). +- **Dispatch** (built): [dispatch/doc.go](../dispatch/doc.go), [stages/doc.go](../stages/doc.go), + [settings/doc.go](../settings/doc.go). - **Stores** (built): [dispatch/dispatchtest/doc.go](../dispatch/dispatchtest/doc.go), [storage/doc.go](../storage/doc.go), [postgres/doc.go](../postgres/doc.go). - **Run directory** (built): [rundir/doc.go](../rundir/doc.go), diff --git a/context/bunrei.md b/context/bunrei.md index 0dd643cc..aef5b4fc 100644 --- a/context/bunrei.md +++ b/context/bunrei.md @@ -76,7 +76,8 @@ data-intelligence.md queues these asks of go-messaging's NATS provider, sized by ## Assumptions -- Assumes Bunrei wires docproc's `stages` as `cmd/docproc` does. +- Assumes Bunrei wires docproc's `stages` and `dispatch` from a `settings.Run`, as `cmd/docproc` + does. - Assumes one `docinfer.Bounds` per replica, shared by its pipelines, one per profile. - Assumes Bunrei speaks Chat Completions to the gateway, its consumer key the bearer token. - Assumes the consumer stores chunks by their identity, so a batch a redelivered job repeats changes diff --git a/docs/api.md b/docs/api.md index 4f42edf7..a0bc1b11 100644 --- a/docs/api.md +++ b/docs/api.md @@ -61,6 +61,9 @@ dispatch/dispatchtest the Index and Content conformance suites and the fixt stages Build and its Options, Routes and ParseRoutes, the stage adapters, unexported, the failure classification, the identities +settings a run's settings as one JSON object, validated and assembled + into stages.Options, dispatch.Limits, and the release and + output-writes bounds internal/tooltest, test helpers: the unit tier's stand-in tool, golden sums, and goldentest, mediatest media's stand-in ffmpeg run rundir, rundir/schema cmd/docproc's run directory: its shapes, read and written @@ -69,9 +72,9 @@ metadata the metadata records' shapes, one per format; imports ``` No root package. Another module reaches `dispatch`, `dispatch/dispatchtest`, `route`, `inspect`, -`stages.Build`, `rundir`, and the record types docinfer decodes (the plan records, `metadata`'s -records, the readers' line types, `email.Threader`); the module builds on every 64-bit platform, and -only running a tool needs Linux. +`stages.Build`, `settings`, `rundir`, and the record types docinfer decodes (the plan records, +`metadata`'s records, the readers' line types, `email.Threader`); the module builds on every 64-bit +platform, and only running a tool needs Linux. ## Inspection and routing @@ -1043,6 +1046,87 @@ How the stages are built, and why: because of a document, so it is the run's; 7zz's 8, out of memory, is the content's, as an allocation refused under the memory bound is. +## Settings + +`settings` holds a run's settings as one flat JSON object, so a host that takes its bounds as +JSON, rather than as `cmd/docproc`'s `DOCPROC_` variables, reads and validates them in one step +and hands them to `stages.Build` and `dispatch.New` as they are. Each key is named for the +variable `cmd/docproc` reads it from, without the prefix and in snake case. It imports the +standard library and docproc's own packages alone. + +```go +package settings +type Settings struct { // one pointer field per key, nil when unset; the json tags are the keys + ToolMemory *int64; UnitTimeout, StreamIdle *time.Duration + MaxParts *int; MaxBytes *int64; MaxDepth *int + BombRatio *float64; BombSize *uint64; ArchiveEntries *int + ClaimRelease *time.Duration; Concurrency, PDFDPI *int; PDFText *bool; PDFMaxPixels *int64 + FrameMaxSide *int; MagickArea, MagickMemory, MagickMap, MagickDisk *int64 + AudioLimit *time.Duration; OutputWrites *int +} +// Decode reads settings from one JSON object and validates them, as Validate does; input that +// isn't one object, an unknown key, and a value of the wrong JSON type are refused too. +func Decode(data []byte) (Settings, error) +func (s Settings) Validate() error // each refusal names its key; one names every unset required key +// Assemble validates s and returns its Run, each optional key left unset at its default. +func (s Settings) Assemble() (Run, error) +type Run struct { + Stages stages.Options // for stages.Build; every option no key covers is the zero value + Limits dispatch.Limits // dispatch.Config.Limits + Release time.Duration // dispatch.Config.Release + OutputWrites int // dispatch.Config.Puts +} +var ErrRequest = errors.New("invalid request") // every refusal wraps it +// KeyError is the refusal of the values of the keys it names, one key or both bomb_ratio and +// bomb_size; it wraps ErrRequest. Unknown keys and unset required keys aren't KeyErrors. +type KeyError struct { Keys []string; Reason string } +``` + +The keys, their formats, where each lands, and whether it is required: + +```text +key JSON field required +tool_memory whole bytes stages.Options.Memory yes +unit_timeout duration stages.Options.Timeout yes +stream_idle duration stages.Options.Idle yes +max_parts whole number dispatch.Limits.Parts yes +max_bytes whole bytes dispatch.Limits.Bytes yes +max_depth whole number dispatch.Limits.Depth yes +bomb_ratio number inspect.Options.BombRatio yes +bomb_size whole bytes inspect.Options.BombSize yes +archive_entries whole number inspect.Options.Entries yes +claim_release duration dispatch.Config.Release yes +concurrency whole number, from 1 stages.Options.Concurrency no, 1 +pdf_dpi whole number, from 1 document.ImagesRequest.DPI no, document.DefaultDPI +pdf_text boolean document.ImagesRequest.Text yes +pdf_max_pixels whole number document.ImagesRequest.MaxPixels yes +frame_max_side whole number media.Request.MaxSide yes +magick_area whole number picture.Limits.Area yes +magick_memory whole bytes picture.Limits.Memory yes +magick_map whole bytes picture.Limits.Map yes +magick_disk whole bytes picture.Limits.Disk yes +audio_limit duration, over 4s audio.Request.Limit no, audio.DefaultWindowLimit +output_writes whole number, from 1 dispatch.Config.Puts no, 1 +``` + +The library ships no policy, so every key but four is required, and zero is no bound: a required +key left unset is refused, never defaulted. The four optional keys are the ones whose library value +already has a default: an unset `pdf_dpi` assembles to `document.DefaultDPI`, 150; an unset +`audio_limit` to `audio.DefaultWindowLimit`, 30s; and an unset `concurrency` or `output_writes`, +the most outputs one part writes to the content store at once, to 1. A set `pdf_dpi`, +`concurrency`, or `output_writes` is at least 1, and a set `audio_limit` is over 4s, twice +`audio.DefaultOverlap`, the shortest window the audio cutter takes. A duration is a Go duration +string, such as `"90s"` or `"10m"`, as `time.ParseDuration` reads it, and a number in its place is +refused; every value is zero or more, and `bomb_ratio` and `bomb_size` are both zero, for no bomb +rule, or both above it. + +`Run.Stages` sets only the fields the table names. `Exclude`, `Env`, `Inspect.Policy`, `Picture`, +`Document.PagesPerProcess`, and every other field of the video, audio, and ImageMagick requests +stay the zero value, each host's own to set before `Build`. A host passes `Run.Limits` and +`Release` to `dispatch.New` in its `Config`, and `OutputWrites` as its `Puts`, with the +`stages.Set`'s `Inspect` as its `Inspect`, so the dispatcher and the stages share one validated +value of the inspection options. + ## Content The content store holds every output's content by its SHA-256, and a host puts its own texts in diff --git a/docs/command.md b/docs/command.md index a1685f4b..52035bfb 100644 --- a/docs/command.md +++ b/docs/command.md @@ -86,3 +86,4 @@ shutdown. | `DOCPROC_MAGICK_MAP` | The most bytes of the pixel cache that may be memory-mapped (`-limit map`) | 2 GiB | | `DOCPROC_MAGICK_DISK` | The most bytes of the pixel cache that may be on disk (`-limit disk`) | 8 GiB | | `DOCPROC_AUDIO_LIMIT` | The longest audio window, its overlaps included (`Options.Audio.Limit`); a host sets it to its model's request size, the longest audio one request takes. A source no longer than it is one window. It must be over 4s, twice the 2 s overlap between windows, so zero is refused | 30s | +| `DOCPROC_OUTPUT_WRITES` | The most outputs one part writes to the content store at once (`dispatch.Config.Puts`); each write copies to the local disk, which the workers' dispatches already keep busy. It must be at least 1, so zero is refused | 1 | diff --git a/docs/layers.md b/docs/layers.md index 07b83cce..924928f4 100644 --- a/docs/layers.md +++ b/docs/layers.md @@ -34,8 +34,8 @@ The boundaries' pages: docs-corpus v0.2.0. - [Consumers of structured text](structured-text.md): the rule that every piece of text exists once. -- [docproc's API](api.md): inspection and routing, running the tools, dispatch, content, the - index, the event shapes, and the run directory. +- [docproc's API](api.md): inspection and routing, running the tools, dispatch, settings, + content, the index, the event shapes, and the run directory. - [The design review](design-review.md): each finding's settled design and disposition. ## Assumptions diff --git a/docs/packages.md b/docs/packages.md index e8b2487f..0c5e202e 100644 --- a/docs/packages.md +++ b/docs/packages.md @@ -14,6 +14,7 @@ | `dispatch` | The walk over an input's parts to their stages; the Stage contract and its error classes; the content store and its layout, and the index, each with a file and a memory implementation; the shapes of its events, parts, outputs, and warnings; and the Meta keys every stage sets and the record media types. It imports `route` and `inspect` alone. | | `dispatch/dispatchtest` | The Index and Content conformance suites, for every store, the module's own and a provider's, and the fixture stage a host's tests dispatch over. | | `stages` | `Build` and its `Options`: docproc's shipped wiring, each route's stage over its format package and tools, found on the host, under the host's run bounds and requests, with the one failure classification and each stage's identity. `cmd/docproc` is its first caller. | +| `settings` | A run's settings as one flat JSON object, each key named for its `DOCPROC_` variable: `Decode` reads and validates them, refusing every unset required key in one error, and `Settings.Assemble` returns their `Run`, the `stages.Options`, `dispatch.Limits`, and release and output-writes bounds a host passes `stages.Build` and `dispatch.New`, each unset optional key at its default. It imports no package outside the standard library and docproc. | | `rundir` | `cmd/docproc`'s run directory, read and written: `Open` to read it and `Create` to write it, its runs, the latest that ended, each run's manifest and record, its content store and the path of a content's file, its index, a quarantined part's kept file, and a run's report directory, `runs//report/`. One process writes a run directory. | | `rundir/schema` | The run directory's schema `"2"`: the shapes `cmd/docproc` writes and a reader decodes, a record line, a manifest, an input's file, and a time, each in UTC. It imports no docproc package but `dispatch` and `inspect`. | | `metadata` | The metadata records' shapes, one per format, each a JSON value under a versioned media type `dispatch` declares: `Office`, an office package's properties and the format it was converted from; `PDF`, a PDF's information dictionary, XMP metadata, and version; `Media`, an audio or video file's container format, duration, bit rate, and tags, and its streams; and `Picture`, a picture's EXIF capture time, camera, orientation, size, GPS position, and properties. It imports no docproc package but `dispatch`, so a reader decodes a record without compiling the stages. | diff --git a/picture/spec.go b/picture/spec.go index 077751ba..df0432a1 100644 --- a/picture/spec.go +++ b/picture/spec.go @@ -34,8 +34,8 @@ const LibreOfficeMinimum = "24.2" // runs in it under the runner's full lockdown, with no relaxation, so // tool.Image{Ref: LibreOfficeImage} is the whole of it. A caller may run another image, or soffice // on the host through the exec runner. -const LibreOfficeImage = "gotenberg/gotenberg:9.10.2-libreoffice@sha256:" + - "4e262b3ba32cc99dd95455a2ee7e11d2a9b5f8e562e3f9cf8550a16c814e5421" +const LibreOfficeImage = "gotenberg/gotenberg:9.10.3-libreoffice@sha256:" + + "bf3efd63f83fa2ae3f9a8b422aca28984f696a31df94d3159059a1d2c296cc99" // LibreOfficeSpec declares LibreOffice's soffice, minimum 24.2, for either runner's constructor; // the container runner makes it the entrypoint in place of the image's own. soffice --version diff --git a/postgres/CHANGELOG.md b/postgres/CHANGELOG.md index 1cd7bc85..86c580d1 100644 --- a/postgres/CHANGELOG.md +++ b/postgres/CHANGELOG.md @@ -10,6 +10,18 @@ each system tool under `tools/` keep their own. ## [Unreleased] +## [v0.1.9] - 2026-11-28 + +This release requires the docproc base module at v0.11.0. Its exported API is unchanged. + +### Changed + +- The module requires the docproc base module at v0.11.0, from v0.10.0, and passes its + `dispatchtest.Index` suite; its [CHANGELOG](../CHANGELOG.md) states the base module's changes. + The base module adds the package `settings`, a run's settings as one JSON object, and moves + soffice's image. No stage's identity changes, so a run over the index replays a caller's earlier + entries as before. The index itself is unchanged. + ## [v0.1.8] - 2026-11-27 This release requires the docproc base module at v0.10.0. Its exported API is unchanged. @@ -161,7 +173,8 @@ tier runs on; and pgx v5.13.0, whose `database/sql` driver the host's pool must skipped. The host drives it from a sweeper; the age has no default. A non-positive age and a budget below 1 are refused, matching `dispatch.ErrRequest`, and a nil `db` panics. -[Unreleased]: https://github.com/standards-lab/docproc/compare/postgres/v0.1.8...HEAD +[Unreleased]: https://github.com/standards-lab/docproc/compare/postgres/v0.1.9...HEAD +[v0.1.9]: https://github.com/standards-lab/docproc/compare/postgres/v0.1.8...postgres/v0.1.9 [v0.1.8]: https://github.com/standards-lab/docproc/compare/postgres/v0.1.7...postgres/v0.1.8 [v0.1.7]: https://github.com/standards-lab/docproc/compare/postgres/v0.1.6...postgres/v0.1.7 [v0.1.6]: https://github.com/standards-lab/docproc/compare/postgres/v0.1.5...postgres/v0.1.6 diff --git a/postgres/README.md b/postgres/README.md index 92f2f2c4..135683f4 100644 --- a/postgres/README.md +++ b/postgres/README.md @@ -9,7 +9,7 @@ requires the base module, sqlate, sqlate's `postgres` dialect, and pgx. ## Install ```sh -go get github.com/standards-lab/docproc/postgres@v0.1.8 +go get github.com/standards-lab/docproc/postgres@v0.1.9 ``` [`CHANGELOG.md`](CHANGELOG.md) states what each release changes. The package's documentation, diff --git a/settings/doc.go b/settings/doc.go new file mode 100644 index 00000000..666ff8c5 --- /dev/null +++ b/settings/doc.go @@ -0,0 +1,58 @@ +// Package settings holds a run's settings as one flat JSON object, on the standard library and +// this module's own packages alone: the run bounds a host passes stages.Build in its Options, +// the dispatch.Limits and the release and output-writes bounds it passes dispatch.New in its +// Config, and the PDF, video, ImageMagick, and audio bounds of the stages' requests. Each key is +// named for the DOCPROC_ variable cmd/docproc reads it from, without the prefix and in snake case. +// +// [Decode] reads the settings from JSON and validates them in one step; [Settings.Validate] +// validates settings a Go caller built, each unset key nil, set with new, such as new(int64(0)). +// The library sets no bound of its own, so every key but four is required, and zero is no bound: +// a required key left unset is refused, every such key named in one error. +// +// key JSON field required +// tool_memory whole bytes stages.Options.Memory yes +// unit_timeout duration stages.Options.Timeout yes +// stream_idle duration stages.Options.Idle yes +// max_parts whole number dispatch.Limits.Parts yes +// max_bytes whole bytes dispatch.Limits.Bytes yes +// max_depth whole number dispatch.Limits.Depth yes +// bomb_ratio number inspect.Options.BombRatio yes +// bomb_size whole bytes inspect.Options.BombSize yes +// archive_entries whole number inspect.Options.Entries yes +// claim_release duration dispatch.Config.Release yes +// concurrency whole number, from 1 stages.Options.Concurrency no, 1 +// pdf_dpi whole number, from 1 document.ImagesRequest.DPI no, document.DefaultDPI +// pdf_text boolean document.ImagesRequest.Text yes +// pdf_max_pixels whole number document.ImagesRequest.MaxPixels yes +// frame_max_side whole number media.Request.MaxSide yes +// magick_area whole number picture.Limits.Area yes +// magick_memory whole bytes picture.Limits.Memory yes +// magick_map whole bytes picture.Limits.Map yes +// magick_disk whole bytes picture.Limits.Disk yes +// audio_limit duration, over 4s audio.Request.Limit no, audio.DefaultWindowLimit +// output_writes whole number, from 1 dispatch.Config.Puts no, 1 +// +// A duration is a Go duration string, such as "90s" or "10m", as time.ParseDuration reads it; a +// number in its place is refused. Every value is zero or more, and bomb_ratio and bomb_size are +// both zero, for no bomb rule, or both above it. An optional key, unset, takes the default the +// table names: document.DefaultDPI, 150 DPI, and audio.DefaultWindowLimit, 30s; set, it is at +// least 1, or for audio_limit over twice audio.DefaultOverlap, 4s, the shortest window the audio +// cutter takes. A refusal names its key and wraps [ErrRequest], as does input that isn't one JSON +// object, an unknown key, and a value of the wrong JSON type; a refused value is a [KeyError]. +// +// [Settings.Assemble] validates the settings and assembles them into a [Run], in the shapes the +// library takes them: the stages.Options a host passes stages.Build, each field the table names +// set and every other option the zero value, the host's own, such as Exclude and Env; and the +// dispatch.Limits, Release, and OutputWrites, as Puts, it passes dispatch.New in its Config. An +// optional key left unset assembles to its default. +// +// Its exported identifiers: +// +// - [Settings] holds a run's settings, one pointer field per key, nil when unset; +// [Settings.Validate] refuses settings a run can't take. +// - [Decode] reads settings from JSON and validates them. +// - [Run] is settings in the library's shapes; [Settings.Assemble] validates settings and +// returns their Run. +// - [ErrRequest] is refused settings' cause; [KeyError] is the refusal of the values of the +// keys it names, so a host names its own source for each key. +package settings diff --git a/settings/main_test.go b/settings/main_test.go new file mode 100644 index 00000000..22991f60 --- /dev/null +++ b/settings/main_test.go @@ -0,0 +1,34 @@ +package settings_test + +import ( + "fmt" + "os" + "testing" + + "github.com/standards-lab/docproc/internal/tooltest" +) + +func TestMain(m *testing.M) { + tooltest.Main(m, map[string]tooltest.Program{ + "gs": version("--version", false, "10.08.0", 0), + "qpdf": version("--version", false, "qpdf version 11.9.0", 0), + "pdfdetach": version("-v", true, "pdfdetach version 26.10.0", 99), + "pdftotext": version("-v", true, "pdftotext version 26.10.0", 0), + "pdfinfo": version("-v", true, "pdfinfo version 26.10.0", 0), + }) +} + +func version(flag string, stderr bool, line string, code int) tooltest.Program { + return func(r tooltest.Run) int { + if len(r.Args) == 1 && r.Args[0] == flag { + if stderr { + fmt.Fprintln(os.Stderr, line) + } else { + fmt.Println(line) + } + return code + } + fmt.Fprintf(os.Stderr, "%s stand-in: unexpected arguments %q\n", r.Program, r.Args) + return 2 + } +} diff --git a/settings/run.go b/settings/run.go new file mode 100644 index 00000000..bfdc6e29 --- /dev/null +++ b/settings/run.go @@ -0,0 +1,82 @@ +package settings + +import ( + "time" + + "github.com/standards-lab/docproc/audio" + "github.com/standards-lab/docproc/dispatch" + "github.com/standards-lab/docproc/document" + "github.com/standards-lab/docproc/inspect" + "github.com/standards-lab/docproc/media" + "github.com/standards-lab/docproc/picture" + "github.com/standards-lab/docproc/stages" +) + +// Run is a run's settings in the shapes the library takes them, so a host hands them on as they +// are: Stages to stages.Build, and Limits, Release, and OutputWrites, as Puts, to dispatch.New's +// Config, with the stages.Set's Inspect as its Inspect. +type Run struct { + // Stages carry the run bounds, the inspection options, the concurrency, and the PDF, video, + // ImageMagick, and audio bounds. Every option no key covers is the zero value, the host's to + // set: Exclude, Env, Inspect.Policy, Picture, and every other field of the Document, Video, + // Magick, and Audio requests. + Stages stages.Options + // Limits are each dispatch's caps: dispatch.Config.Limits. + Limits dispatch.Limits + // Release bounds a claim's release once a dispatch's context has ended: + // dispatch.Config.Release. + Release time.Duration + // OutputWrites is the most outputs one part writes to the content store at once: + // dispatch.Config.Puts. + OutputWrites int +} + +// Assemble validates s, as Validate does, and returns its Run, each optional key left unset at +// its default: PDFDPI at document.DefaultDPI, AudioLimit at audio.DefaultWindowLimit, and +// Concurrency and OutputWrites at 1. Settings Validate refuses are refused with its error, which +// wraps ErrRequest. +func (s Settings) Assemble() (Run, error) { + if err := s.Validate(); err != nil { + return Run{}, err + } + return Run{ + Stages: stages.Options{ + Memory: *s.ToolMemory, + Timeout: *s.UnitTimeout, + Idle: *s.StreamIdle, + Inspect: inspect.Options{ + BombRatio: *s.BombRatio, + BombSize: *s.BombSize, + Entries: *s.ArchiveEntries, + }, + Concurrency: or(s.Concurrency, 1), + Document: document.ImagesRequest{ + DPI: or(s.PDFDPI, document.DefaultDPI), + Text: *s.PDFText, + MaxPixels: *s.PDFMaxPixels, + }, + Video: media.Request{MaxSide: *s.FrameMaxSide}, + Magick: picture.Limits{ + Area: *s.MagickArea, + Memory: *s.MagickMemory, + Map: *s.MagickMap, + Disk: *s.MagickDisk, + }, + Audio: audio.Request{Limit: or(s.AudioLimit, audio.DefaultWindowLimit)}, + }, + Limits: dispatch.Limits{ + Parts: *s.MaxParts, + Bytes: *s.MaxBytes, + Depth: *s.MaxDepth, + }, + Release: *s.ClaimRelease, + OutputWrites: or(s.OutputWrites, 1), + }, nil +} + +func or[T any](v *T, unset T) T { + if v == nil { + return unset + } + return *v +} diff --git a/settings/run_linux_test.go b/settings/run_linux_test.go new file mode 100644 index 00000000..f96c6d37 --- /dev/null +++ b/settings/run_linux_test.go @@ -0,0 +1,110 @@ +//go:build linux + +package settings_test + +import ( + "errors" + "reflect" + "slices" + "strings" + "testing" + + "github.com/standards-lab/docproc/dispatch" + "github.com/standards-lab/docproc/internal/tooltest" + "github.com/standards-lab/docproc/route" + "github.com/standards-lab/docproc/settings" + "github.com/standards-lab/docproc/stages" +) + +func build(t *testing.T, run settings.Run) stages.Set { + t.Helper() + links := map[string]string{} + for _, program := range []string{"gs", "qpdf", "pdfdetach", "pdftotext", "pdfinfo"} { + links[program] = tooltest.Link(t, t.TempDir(), program, nil) + } + lookup := func(program string) (string, error) { + if link, ok := links[program]; ok { + return link, nil + } + return "", errors.New("not here") + } + run.Stages.Exclude = slices.DeleteFunc(stages.Routes(), func(r route.Route) bool { + return r == route.Document || r == route.Text + }) + set, err := stages.Build(t.Context(), lookup, run.Stages) + if err != nil { + t.Fatal(err) + } + for _, tl := range set.Tools { + if tl.Err != nil { + t.Fatalf("%s: %v", tl.Program, tl.Err) + } + } + return set +} + +func documentIdentity(t *testing.T, set stages.Set) dispatch.Identity { + t.Helper() + row := set.Rows[slices.Index(stages.Routes(), route.Document)] + if row.State != dispatch.Wired { + t.Fatalf("document %s, %q; want it wired", row.State, row.Reason) + } + return row.Stage +} + +func TestAssembledStages(t *testing.T) { + base := map[string]any{"tool_memory": tooltest.Memory, "pdf_dpi": unset{}} + run := assemble(t, base) + set := build(t, run) + if !reflect.DeepEqual(set.Inspect, run.Stages.Inspect) || set.Inspect.BombRatio != 1000 || set.Inspect.Entries != 100_000 { + t.Errorf("the set's inspection options %+v, want the assembled %+v", set.Inspect, run.Stages.Inspect) + } + unsetDPI := documentIdentity(t, set) + + base["pdf_dpi"] = 300 + if id := documentIdentity(t, build(t, assemble(t, base))); id.Config == unsetDPI.Config { + t.Errorf("pdf_dpi 300: the document stage's identity %s, the same as at the default DPI", id) + } + base["pdf_dpi"] = unset{} + base["pdf_text"] = false + if id := documentIdentity(t, build(t, assemble(t, base))); id.Config == unsetDPI.Config { + t.Errorf("pdf_text false: the document stage's identity %s, the same as reading the text", id) + } +} + +func TestAssembledDispatch(t *testing.T) { + const text = "a run's settings, assembled\n" + for name, tc := range map[string]struct { + maxBytes int + want dispatch.Outcome + }{ + "under max_bytes": {len(text), dispatch.Prepared}, + "past max_bytes": {len(text) - 1, dispatch.Limited}, + } { + run := assemble(t, map[string]any{"tool_memory": tooltest.Memory, "max_bytes": tc.maxBytes, "output_writes": 2}) + set := build(t, run) + d, err := dispatch.New(dispatch.Config{ + Stages: set.Stages, + Index: dispatch.NewMemoryIndex(0), + Content: dispatch.NewMemoryContent(), + Dir: t.TempDir(), + Inspect: set.Inspect, + Limits: run.Limits, + Release: run.Release, + Puts: run.OutputWrites, + }) + if err != nil { + t.Fatal(err) + } + var last dispatch.Event + for ev, err := range d.Dispatch(t.Context(), dispatch.Input{Reader: strings.NewReader(text), Name: "settings.txt"}) { + if err != nil { + t.Fatal(err) + } + last = ev + } + if last.Outcome != tc.want { + t.Errorf("%s: the input %s, %q; want %s", name, last.Outcome, last.Reason, tc.want) + } + } +} diff --git a/settings/run_test.go b/settings/run_test.go new file mode 100644 index 00000000..6a4753fc --- /dev/null +++ b/settings/run_test.go @@ -0,0 +1,102 @@ +package settings_test + +import ( + "errors" + "reflect" + "testing" + "time" + + "github.com/standards-lab/docproc/audio" + "github.com/standards-lab/docproc/dispatch" + "github.com/standards-lab/docproc/document" + "github.com/standards-lab/docproc/inspect" + "github.com/standards-lab/docproc/media" + "github.com/standards-lab/docproc/picture" + "github.com/standards-lab/docproc/settings" + "github.com/standards-lab/docproc/stages" +) + +func assemble(t *testing.T, edits map[string]any) settings.Run { + t.Helper() + s, err := settings.Decode(encode(t, edits)) + if err != nil { + t.Fatal(err) + } + run, err := s.Assemble() + if err != nil { + t.Fatal(err) + } + return run +} + +func TestAssemble(t *testing.T) { + want := func(concurrency, dpi int, limit time.Duration, outputWrites int) settings.Run { + return settings.Run{ + Stages: stages.Options{ + Memory: 2 << 30, + Timeout: 10 * time.Minute, + Idle: 2 * time.Minute, + Inspect: inspect.Options{BombRatio: 1000, BombSize: 1 << 30, Entries: 100_000}, + Concurrency: concurrency, + Document: document.ImagesRequest{DPI: dpi, Text: true, MaxPixels: 64_000_000}, + Video: media.Request{MaxSide: 2048}, + Magick: picture.Limits{Area: 256_000_000, Memory: 1 << 30, Map: 2 << 30, Disk: 8 << 30}, + Audio: audio.Request{Limit: limit}, + }, + Limits: dispatch.Limits{Parts: 100_000, Bytes: 32 << 30, Depth: 16}, + Release: 10 * time.Second, + OutputWrites: outputWrites, + } + } + for name, tc := range map[string]struct { + edits map[string]any + want settings.Run + }{ + "every key set": { + map[string]any{"concurrency": 4, "pdf_dpi": 300, "audio_limit": "45s", "output_writes": 3}, + want(4, 300, 45*time.Second, 3), + }, + "every optional key unset": { + map[string]any{"concurrency": unset{}, "pdf_dpi": unset{}, "audio_limit": unset{}, "output_writes": unset{}}, + want(1, document.DefaultDPI, audio.DefaultWindowLimit, 1), + }, + "optional keys null": { + map[string]any{"concurrency": nil, "pdf_dpi": nil, "audio_limit": nil, "output_writes": nil}, + want(1, 150, 30*time.Second, 1), + }, + "zero bounds": { + map[string]any{"concurrency": 4, "pdf_dpi": 300, "audio_limit": "45s", "output_writes": 3, + "tool_memory": 0, "unit_timeout": "0s", "max_bytes": 0, "bomb_ratio": 0, "bomb_size": 0, "pdf_text": false}, + func() settings.Run { + r := want(4, 300, 45*time.Second, 3) + r.Stages.Memory, r.Stages.Timeout, r.Limits.Bytes = 0, 0, 0 + r.Stages.Inspect.BombRatio, r.Stages.Inspect.BombSize = 0, 0 + r.Stages.Document.Text = false + return r + }(), + }, + } { + if got := assemble(t, tc.edits); !reflect.DeepEqual(got, tc.want) { + t.Errorf("%s: assembled\n%+v\nwant\n%+v", name, got, tc.want) + } + } +} + +func TestAssembleRefuses(t *testing.T) { + s, err := settings.Decode(encode(t, nil)) + if err != nil { + t.Fatal(err) + } + for name, edit := range map[string]func(*settings.Settings){ + "the zero value": func(s *settings.Settings) { *s = settings.Settings{} }, + "a required key nil": func(s *settings.Settings) { s.MagickDisk = nil }, + "output_writes zero": func(s *settings.Settings) { s.OutputWrites = new(0) }, + } { + c := s + edit(&c) + run, err := c.Assemble() + if !errors.Is(err, settings.ErrRequest) || !reflect.DeepEqual(run, settings.Run{}) { + t.Errorf("%s: %+v, %v; want the zero Run and ErrRequest", name, run, err) + } + } +} diff --git a/settings/settings.go b/settings/settings.go new file mode 100644 index 00000000..439fef6a --- /dev/null +++ b/settings/settings.go @@ -0,0 +1,280 @@ +package settings + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "math" + "reflect" + "strings" + "time" + + "github.com/standards-lab/docproc/audio" +) + +// ErrRequest is the cause of refused settings: input Decode can't read, or settings Validate +// refuses. +var ErrRequest = errors.New("invalid request") + +// A KeyError is a refusal of the values of the keys it names: one key, or both bomb_ratio and +// bomb_size, and the reason, so a host names its own source for each key, as cmd/docproc names +// its DOCPROC_ variable. It wraps ErrRequest. Every refusal of a key's value is a KeyError; the +// refusals of input that isn't one JSON object, an unknown key, and unset required keys aren't. +type KeyError struct { + // Keys are the refused keys, as the JSON names them. + Keys []string + // Reason is why the values are refused, such as "-1 is below zero". + Reason string +} + +// Error is "settings: " and the keys, joined with " and ", the reason, and ErrRequest's text, +// each separated by ": ". +func (e *KeyError) Error() string { + return fmt.Sprintf("settings: %s: %s: %v", strings.Join(e.Keys, " and "), e.Reason, ErrRequest) +} + +// Unwrap returns ErrRequest. +func (e *KeyError) Unwrap() error { return ErrRequest } + +// Settings are a run's settings, one key for each, nil when unset. Every key but PDFDPI, +// Concurrency, AudioLimit, and OutputWrites is required, and zero is no bound. +type Settings struct { + // ToolMemory is every tool's memory bound in bytes, tool_memory. + ToolMemory *int64 `json:"tool_memory"` + // UnitTimeout is a unit run's bound, unit_timeout. + UnitTimeout *time.Duration `json:"unit_timeout"` + // StreamIdle is a stream run's idle bound, stream_idle. + StreamIdle *time.Duration `json:"stream_idle"` + // MaxParts is the most parts one dispatch admits, max_parts. + MaxParts *int `json:"max_parts"` + // MaxBytes is the most bytes one dispatch's parts may come to, max_bytes. + MaxBytes *int64 `json:"max_bytes"` + // MaxDepth is the deepest part one dispatch admits, max_depth. + MaxDepth *int `json:"max_depth"` + // BombRatio is the bomb rule's ratio of expanded to compressed size, bomb_ratio. + BombRatio *float64 `json:"bomb_ratio"` + // BombSize is the bomb rule's expanded size in bytes, bomb_size. + BombSize *uint64 `json:"bomb_size"` + // ArchiveEntries is the most entries an archive may hold, archive_entries. + ArchiveEntries *int `json:"archive_entries"` + // ClaimRelease bounds a claim's release once a dispatch's context has ended, claim_release. + ClaimRelease *time.Duration `json:"claim_release"` + // Concurrency is how many of a PDF's pages and an audio part's windows are held at once, + // concurrency. + Concurrency *int `json:"concurrency"` + // PDFDPI is the DPI a PDF's pages are rendered at, pdf_dpi. + PDFDPI *int `json:"pdf_dpi"` + // PDFText is whether a PDF page's text layer is read, pdf_text. + PDFText *bool `json:"pdf_text"` + // PDFMaxPixels is the most pixels a page's PNG may hold, pdf_max_pixels. + PDFMaxPixels *int64 `json:"pdf_max_pixels"` + // FrameMaxSide is the largest side a video frame is written at, in pixels, frame_max_side. + FrameMaxSide *int `json:"frame_max_side"` + // MagickArea is the most pixels one image may hold in ImageMagick's pixel cache, + // magick_area. + MagickArea *int64 `json:"magick_area"` + // MagickMemory is the most bytes of heap the pixel cache may take, magick_memory. + MagickMemory *int64 `json:"magick_memory"` + // MagickMap is the most bytes of the pixel cache that may be memory-mapped, magick_map. + MagickMap *int64 `json:"magick_map"` + // MagickDisk is the most bytes of the pixel cache that may be on disk, magick_disk. + MagickDisk *int64 `json:"magick_disk"` + // AudioLimit is the longest audio window, its overlaps included, audio_limit. + AudioLimit *time.Duration `json:"audio_limit"` + // OutputWrites is the most outputs one part writes to the content store at once, output_writes. + OutputWrites *int `json:"output_writes"` +} + +type wire struct { + Settings + UnitTimeout json.RawMessage `json:"unit_timeout"` + StreamIdle json.RawMessage `json:"stream_idle"` + ClaimRelease json.RawMessage `json:"claim_release"` + AudioLimit json.RawMessage `json:"audio_limit"` +} + +// Decode reads settings from a JSON object and validates them, as Validate does. Input that isn't +// one JSON object, an unknown key, a value of the wrong type, and a duration that isn't a Go +// duration string are each an error wrapping ErrRequest. +func Decode(data []byte) (Settings, error) { + dec := json.NewDecoder(bytes.NewReader(data)) + dec.DisallowUnknownFields() + var w wire + if err := dec.Decode(&w); err != nil { + return Settings{}, decodeError(err) + } + if _, err := dec.Token(); err != io.EOF { + return Settings{}, refuse("the input holds more than one JSON value") + } + s := w.Settings + err := errors.Join( + parseDuration(&s.UnitTimeout, "unit_timeout", w.UnitTimeout), + parseDuration(&s.StreamIdle, "stream_idle", w.StreamIdle), + parseDuration(&s.ClaimRelease, "claim_release", w.ClaimRelease), + parseDuration(&s.AudioLimit, "audio_limit", w.AudioLimit), + ) + if err != nil { + return Settings{}, err + } + if err := s.Validate(); err != nil { + return Settings{}, err + } + return s, nil +} + +func decodeError(err error) error { + var syntax *json.SyntaxError + var typ *json.UnmarshalTypeError + switch { + case errors.As(err, &syntax), errors.Is(err, io.EOF), errors.Is(err, io.ErrUnexpectedEOF): + return refuse("the input isn't JSON: %v", err) + case errors.As(err, &typ) && typ.Field == "": + return refuse("the input is a JSON %s, not an object", typ.Value) + case errors.As(err, &typ): + return refuseKey(typ.Field, "a JSON %s isn't %s", typ.Value, describe(typ.Type)) + } + if name, ok := strings.CutPrefix(err.Error(), "json: unknown field "); ok { + return refuse("unknown key %s", name) + } + return refuse("%v", err) +} + +func describe(t reflect.Type) string { + switch t.Kind() { + case reflect.Uint64: + return "a whole number of zero or more" + case reflect.Int, reflect.Int64: + return "a whole number" + case reflect.Float64: + return "a number" + case reflect.Bool: + return "a boolean" + } + return "a " + t.String() +} + +func parseDuration(dest **time.Duration, key string, raw json.RawMessage) error { + if raw == nil || string(raw) == "null" { + return nil + } + var s string + if err := json.Unmarshal(raw, &s); err != nil { + return refuseKey(key, "%s isn't a duration string, such as \"90s\" or \"10m\"", raw) + } + d, err := time.ParseDuration(s) + if err != nil { + return refuseKey(key, "%q isn't a duration, such as \"90s\" or \"10m\"", s) + } + *dest = &d + return nil +} + +// Validate refuses settings a run can't take, each refusal naming its key and wrapping ErrRequest: +// every required key unset, named in one error; a value below zero; BombRatio not finite, or one +// of BombRatio and BombSize zero and not the other; PDFDPI, Concurrency, or OutputWrites set below +// 1; and AudioLimit set to a limit the audio cutter refuses, or to zero. +func (s Settings) Validate() error { + var errs []error + if missing := s.missing(); len(missing) > 0 { + errs = append(errs, refuse("required keys unset: %s", strings.Join(missing, ", "))) + } + errs = append(errs, + atLeast("tool_memory", s.ToolMemory, 0), + atLeast("unit_timeout", s.UnitTimeout, 0), + atLeast("stream_idle", s.StreamIdle, 0), + atLeast("max_parts", s.MaxParts, 0), + atLeast("max_bytes", s.MaxBytes, 0), + atLeast("max_depth", s.MaxDepth, 0), + atLeast("archive_entries", s.ArchiveEntries, 0), + atLeast("claim_release", s.ClaimRelease, 0), + atLeast("concurrency", s.Concurrency, 1), + atLeast("pdf_dpi", s.PDFDPI, 1), + atLeast("pdf_max_pixels", s.PDFMaxPixels, 0), + atLeast("frame_max_side", s.FrameMaxSide, 0), + atLeast("magick_area", s.MagickArea, 0), + atLeast("magick_memory", s.MagickMemory, 0), + atLeast("magick_map", s.MagickMap, 0), + atLeast("magick_disk", s.MagickDisk, 0), + atLeast("output_writes", s.OutputWrites, 1), + s.bomb(), + s.audioLimit(), + ) + return errors.Join(errs...) +} + +func (s Settings) missing() []string { + var missing []string + for _, k := range []struct { + key string + set bool + }{ + {"tool_memory", s.ToolMemory != nil}, + {"unit_timeout", s.UnitTimeout != nil}, + {"stream_idle", s.StreamIdle != nil}, + {"max_parts", s.MaxParts != nil}, + {"max_bytes", s.MaxBytes != nil}, + {"max_depth", s.MaxDepth != nil}, + {"bomb_ratio", s.BombRatio != nil}, + {"bomb_size", s.BombSize != nil}, + {"archive_entries", s.ArchiveEntries != nil}, + {"claim_release", s.ClaimRelease != nil}, + {"pdf_text", s.PDFText != nil}, + {"pdf_max_pixels", s.PDFMaxPixels != nil}, + {"frame_max_side", s.FrameMaxSide != nil}, + {"magick_area", s.MagickArea != nil}, + {"magick_memory", s.MagickMemory != nil}, + {"magick_map", s.MagickMap != nil}, + {"magick_disk", s.MagickDisk != nil}, + } { + if !k.set { + missing = append(missing, k.key) + } + } + return missing +} + +func atLeast[T ~int | ~int64](key string, v *T, floor T) error { + switch { + case v == nil || *v >= floor: + return nil + case floor == 0: + return refuseKey(key, "%v is below zero", *v) + } + return refuseKey(key, "%v is below %v", *v, floor) +} + +func (s Settings) bomb() error { + switch { + case s.BombRatio == nil: + return nil + case !(*s.BombRatio >= 0) || math.IsInf(*s.BombRatio, 1): + return refuseKey("bomb_ratio", "%g isn't a finite number of zero or more", *s.BombRatio) + case s.BombSize != nil && (*s.BombRatio == 0) != (*s.BombSize == 0): + return &KeyError{ + Keys: []string{"bomb_ratio", "bomb_size"}, + Reason: "set both above zero, or both to zero for no bomb rule", + } + } + return nil +} + +func (s Settings) audioLimit() error { + if s.AudioLimit == nil { + return nil + } + if _, err := audio.NewCutter(audio.Request{Limit: *s.AudioLimit}); *s.AudioLimit == 0 || err != nil { + return refuseKey("audio_limit", "%v isn't over %v, twice the %v overlap between windows", + *s.AudioLimit, 2*audio.DefaultOverlap, audio.DefaultOverlap) + } + return nil +} + +func refuse(format string, args ...any) error { + return fmt.Errorf("settings: "+format+": %w", append(args, ErrRequest)...) +} + +func refuseKey(key, format string, args ...any) error { + return &KeyError{Keys: []string{key}, Reason: fmt.Sprintf(format, args...)} +} diff --git a/settings/settings_test.go b/settings/settings_test.go new file mode 100644 index 00000000..ecc8d4b8 --- /dev/null +++ b/settings/settings_test.go @@ -0,0 +1,277 @@ +package settings_test + +import ( + "encoding/json" + "errors" + "math" + "reflect" + "slices" + "strings" + "testing" + "time" + + "github.com/standards-lab/docproc/settings" +) + +type unset struct{} + +func full() map[string]any { + return map[string]any{ + "tool_memory": 2 << 30, + "unit_timeout": "10m", + "stream_idle": "2m", + "max_parts": 100_000, + "max_bytes": 32 << 30, + "max_depth": 16, + "bomb_ratio": 1000, + "bomb_size": 1 << 30, + "archive_entries": 100_000, + "claim_release": "10s", + "concurrency": 1, + "pdf_dpi": 150, + "pdf_text": true, + "pdf_max_pixels": 64_000_000, + "frame_max_side": 2048, + "magick_area": 256_000_000, + "magick_memory": 1 << 30, + "magick_map": 2 << 30, + "magick_disk": 8 << 30, + "audio_limit": "30s", + "output_writes": 1, + } +} + +func encode(t *testing.T, edits map[string]any) []byte { + t.Helper() + m := full() + for k, v := range edits { + if _, ok := v.(unset); ok { + delete(m, k) + continue + } + m[k] = v + } + data, err := json.Marshal(m) + if err != nil { + t.Fatal(err) + } + return data +} + +func TestDecodeFull(t *testing.T) { + s, err := settings.Decode(encode(t, nil)) + if err != nil { + t.Fatal(err) + } + want := settings.Settings{ + ToolMemory: new(int64(2 << 30)), + UnitTimeout: new(10 * time.Minute), + StreamIdle: new(2 * time.Minute), + MaxParts: new(100_000), + MaxBytes: new(int64(32 << 30)), + MaxDepth: new(16), + BombRatio: new(1000.0), + BombSize: new(uint64(1 << 30)), + ArchiveEntries: new(100_000), + ClaimRelease: new(10 * time.Second), + Concurrency: new(1), + PDFDPI: new(150), + PDFText: new(true), + PDFMaxPixels: new(int64(64_000_000)), + FrameMaxSide: new(2048), + MagickArea: new(int64(256_000_000)), + MagickMemory: new(int64(1 << 30)), + MagickMap: new(int64(2 << 30)), + MagickDisk: new(int64(8 << 30)), + AudioLimit: new(30 * time.Second), + OutputWrites: new(1), + } + if !reflect.DeepEqual(s, want) { + t.Errorf("Decode = %+v, want %+v", s, want) + } +} + +func TestDecodeAccepts(t *testing.T) { + zeros := map[string]any{"bomb_ratio": 0, "bomb_size": 0, "pdf_text": false} + for _, key := range []string{ + "tool_memory", "max_parts", "max_bytes", "max_depth", "archive_entries", "pdf_max_pixels", + "frame_max_side", "magick_area", "magick_memory", "magick_map", "magick_disk", + } { + zeros[key] = 0 + } + for _, key := range []string{"unit_timeout", "stream_idle", "claim_release"} { + zeros[key] = "0s" + } + for name, edits := range map[string]map[string]any{ + "every required key zero": zeros, + "pdf_dpi unset": {"pdf_dpi": unset{}}, + "audio_limit unset": {"audio_limit": unset{}}, + "concurrency unset": {"concurrency": unset{}}, + "output_writes unset": {"output_writes": unset{}}, + "every optional key null": {"pdf_dpi": nil, "audio_limit": nil, "concurrency": nil, "output_writes": nil}, + "audio_limit just over 4s": {"audio_limit": "4001ms"}, + } { + s, err := settings.Decode(encode(t, edits)) + if err != nil { + t.Errorf("%s: %v", name, err) + continue + } + for key, v := range edits { + if _, ok := v.(unset); (ok || v == nil) && set(s, key) { + t.Errorf("%s: %s set, want nil", name, key) + } + } + } +} + +func set(s settings.Settings, key string) bool { + v := reflect.ValueOf(s) + for i := range v.NumField() { + if strings.Split(v.Type().Field(i).Tag.Get("json"), ",")[0] == key { + return !v.Field(i).IsNil() + } + } + panic("no key " + key) +} + +func TestDecodeRefuses(t *testing.T) { + for name, tc := range map[string]struct { + data []byte + want []string + }{ + "not JSON": {[]byte("tool_memory = 1"), []string{"isn't JSON"}}, + "empty": {nil, []string{"isn't JSON"}}, + "truncated": {[]byte(`{"tool_memory": 1`), []string{"isn't JSON"}}, + "an array": {[]byte(`[]`), []string{"not an object"}}, + "two values": {append(encode(t, nil), []byte(" {}")...), []string{"more than one JSON value"}}, + "an unknown key": {encode(t, map[string]any{"max_part": 1}), []string{`"max_part"`}}, + } { + check(t, name, tc.data, tc.want) + } +} + +func TestDecodeRefusesValues(t *testing.T) { + for name, tc := range map[string]struct { + edits map[string]any + want []string + }{ + "a duration as a number": {map[string]any{"unit_timeout": 600}, []string{"unit_timeout", "duration string"}}, + "an unparsable duration": {map[string]any{"stream_idle": "two minutes"}, []string{"stream_idle", `"two minutes"`}}, + "claim_release as a number": {map[string]any{"claim_release": 10}, []string{"claim_release"}}, + "audio_limit as a number": {map[string]any{"audio_limit": 30}, []string{"audio_limit"}}, + "a count as a string": {map[string]any{"max_parts": "100"}, []string{"max_parts", "whole number"}}, + "a count as a fraction": {map[string]any{"max_depth": 1.5}, []string{"max_depth", "whole number"}}, + "pdf_text as a string": {map[string]any{"pdf_text": "true"}, []string{"pdf_text", "boolean"}}, + "bomb_ratio as a string": {map[string]any{"bomb_ratio": "1000"}, []string{"bomb_ratio", "a number"}}, + "bomb_size below zero": {map[string]any{"bomb_size": -1}, []string{"bomb_size", "zero or more"}}, + "a negative duration": {map[string]any{"unit_timeout": "-1s"}, []string{"unit_timeout", "below zero"}}, + "a negative size": {map[string]any{"tool_memory": -1}, []string{"tool_memory", "below zero"}}, + "a negative count": {map[string]any{"archive_entries": -1}, []string{"archive_entries", "below zero"}}, + "a negative ratio": {map[string]any{"bomb_ratio": -0.5}, []string{"bomb_ratio"}}, + "bomb_ratio alone zero": {map[string]any{"bomb_ratio": 0}, []string{"bomb_ratio and bomb_size"}}, + "bomb_size alone zero": {map[string]any{"bomb_size": 0}, []string{"bomb_ratio and bomb_size"}}, + "pdf_dpi zero": {map[string]any{"pdf_dpi": 0}, []string{"pdf_dpi", "below 1"}}, + "concurrency zero": {map[string]any{"concurrency": 0}, []string{"concurrency", "below 1"}}, + "output_writes zero": {map[string]any{"output_writes": 0}, []string{"output_writes", "below 1"}}, + "audio_limit zero": {map[string]any{"audio_limit": "0s"}, []string{"audio_limit", "4s"}}, + "audio_limit 4s": {map[string]any{"audio_limit": "4s"}, []string{"audio_limit", "4s"}}, + "audio_limit below zero": {map[string]any{"audio_limit": "-30s"}, []string{"audio_limit"}}, + "two refusals at once": { + map[string]any{"max_bytes": -1, "magick_disk": -2}, + []string{"max_bytes: -1 is below zero", "magick_disk: -2 is below zero"}, + }, + } { + check(t, name, encode(t, tc.edits), tc.want) + } +} + +func TestDecodeNamesEveryMissingKey(t *testing.T) { + required := []string{ + "tool_memory", "unit_timeout", "stream_idle", "max_parts", "max_bytes", "max_depth", + "bomb_ratio", "bomb_size", "archive_entries", "claim_release", "pdf_text", + "pdf_max_pixels", "frame_max_side", "magick_area", "magick_memory", "magick_map", + "magick_disk", + } + check(t, "an empty object", []byte(`{}`), []string{"required keys unset: " + strings.Join(required, ", ")}) + for _, key := range required { + check(t, key+" unset", encode(t, map[string]any{key: unset{}}), []string{"required keys unset: " + key + ":"}) + check(t, key+" null", encode(t, map[string]any{key: nil}), []string{"required keys unset: " + key + ":"}) + } +} + +func TestValidate(t *testing.T) { + s, err := settings.Decode(encode(t, nil)) + if err != nil { + t.Fatal(err) + } + if err := s.Validate(); err != nil { + t.Errorf("Validate of decoded settings: %v", err) + } + for name, tc := range map[string]struct { + edit func(*settings.Settings) + want string + }{ + "bomb_ratio NaN": {func(s *settings.Settings) { s.BombRatio = new(math.NaN()) }, "bomb_ratio"}, + "bomb_ratio infinite": {func(s *settings.Settings) { s.BombRatio = new(math.Inf(1)) }, "bomb_ratio"}, + "stream_idle negative": {func(s *settings.Settings) { s.StreamIdle = new(-time.Second) }, "stream_idle: -1s is below zero"}, + "max_depth unset": {func(s *settings.Settings) { s.MaxDepth = nil }, "required keys unset: max_depth"}, + } { + c := s + tc.edit(&c) + err := c.Validate() + if !errors.Is(err, settings.ErrRequest) || !strings.Contains(err.Error(), tc.want) { + t.Errorf("%s: %v, want ErrRequest naming %q", name, err, tc.want) + } + } +} + +func check(t *testing.T, name string, data []byte, want []string) { + t.Helper() + _, err := settings.Decode(data) + if !errors.Is(err, settings.ErrRequest) { + t.Errorf("%s: %v, want ErrRequest", name, err) + return + } + for _, w := range want { + if !strings.Contains(err.Error(), w) { + t.Errorf("%s: %v, want it to name %q", name, err, w) + } + } +} + +func TestKeyError(t *testing.T) { + for name, tc := range map[string]struct { + edits map[string]any + keys []string + reason string + }{ + "a value below zero": {map[string]any{"max_bytes": -1}, []string{"max_bytes"}, "-1 is below zero"}, + "a value below 1": {map[string]any{"output_writes": 0}, []string{"output_writes"}, "0 is below 1"}, + "the bomb rule half off": {map[string]any{"bomb_size": 0}, []string{"bomb_ratio", "bomb_size"}, "set both above zero, or both to zero for no bomb rule"}, + "a wrong JSON type": {map[string]any{"pdf_text": "true"}, []string{"pdf_text"}, "a JSON string isn't a boolean"}, + "an unparsable duration": {map[string]any{"unit_timeout": "soon"}, []string{"unit_timeout"}, `"soon" isn't a duration, such as "90s" or "10m"`}, + } { + _, err := settings.Decode(encode(t, tc.edits)) + var ke *settings.KeyError + if !errors.As(err, &ke) || !errors.Is(err, settings.ErrRequest) { + t.Errorf("%s: %v, want a KeyError wrapping ErrRequest", name, err) + continue + } + if !slices.Equal(ke.Keys, tc.keys) || ke.Reason != tc.reason { + t.Errorf("%s: KeyError %q, %q; want %q, %q", name, ke.Keys, ke.Reason, tc.keys, tc.reason) + } + if want := "settings: " + strings.Join(tc.keys, " and ") + ": " + tc.reason + ": invalid request"; err.Error() != want { + t.Errorf("%s: %q, want %q", name, err, want) + } + } + for name, data := range map[string][]byte{ + "an unknown key": encode(t, map[string]any{"max_part": 1}), + "a required key unset": encode(t, map[string]any{"max_depth": unset{}}), + } { + _, err := settings.Decode(data) + var ke *settings.KeyError + if !errors.Is(err, settings.ErrRequest) || errors.As(err, &ke) { + t.Errorf("%s: %v, want ErrRequest and no KeyError", name, err) + } + } +} diff --git a/storage/CHANGELOG.md b/storage/CHANGELOG.md index b4c48483..fe454b4f 100644 --- a/storage/CHANGELOG.md +++ b/storage/CHANGELOG.md @@ -10,6 +10,17 @@ each system tool under `tools/` keep their own. ## [Unreleased] +## [v0.1.9] - 2026-11-28 + +This release requires the docproc base module at v0.11.0. Its exported API is unchanged. + +### Changed + +- The module requires the docproc base module at v0.11.0, from v0.10.0, and passes its + `dispatchtest.Content` suite; its [CHANGELOG](../CHANGELOG.md) states the base module's changes. + The base module adds the package `settings`, a run's settings as one JSON object, and moves + soffice's image; neither changes what this module stores or how. + ## [v0.1.8] - 2026-11-27 This release requires the docproc base module at v0.10.0. Its exported API is unchanged. @@ -128,7 +139,8 @@ The first release. It requires `github.com/standards-lab/docproc` v0.1.0, whose a missing container; the live tier, under `-tags integration`, runs it over go-storage's S3 provider against the compose harness's SeaweedFS. -[Unreleased]: https://github.com/standards-lab/docproc/compare/storage/v0.1.8...HEAD +[Unreleased]: https://github.com/standards-lab/docproc/compare/storage/v0.1.9...HEAD +[v0.1.9]: https://github.com/standards-lab/docproc/compare/storage/v0.1.8...storage/v0.1.9 [v0.1.8]: https://github.com/standards-lab/docproc/compare/storage/v0.1.7...storage/v0.1.8 [v0.1.7]: https://github.com/standards-lab/docproc/compare/storage/v0.1.6...storage/v0.1.7 [v0.1.6]: https://github.com/standards-lab/docproc/compare/storage/v0.1.5...storage/v0.1.6 diff --git a/storage/README.md b/storage/README.md index 1df1ef5f..57629d67 100644 --- a/storage/README.md +++ b/storage/README.md @@ -11,7 +11,7 @@ requires `s3`, for its live tier alone. ## Install ```sh -go get github.com/standards-lab/docproc/storage@v0.1.8 +go get github.com/standards-lab/docproc/storage@v0.1.9 ``` [`CHANGELOG.md`](CHANGELOG.md) states what each release changes. The package's documentation, diff --git a/tools/mail/mise.toml b/tools/mail/mise.toml index d79575c4..4c051d41 100644 --- a/tools/mail/mise.toml +++ b/tools/mail/mise.toml @@ -1,10 +1,10 @@ # docproc-mail's toolchain and its check, publish, golden, mboxrd, currency, and upgrade tasks. # See docs/tool-builds.md [tools] -cargo-deny = "0.22.1" +cargo-deny = "0.22.2" "github:EmbarkStudios/cargo-about" = "0.9.3" jq = "1.8.2" -rust = { version = "1.100.0", profile = "minimal", components = "clippy,rustfmt", targets = "x86_64-unknown-linux-musl,aarch64-unknown-linux-musl" } +rust = { version = "1.100.1", profile = "minimal", components = "clippy,rustfmt", targets = "x86_64-unknown-linux-musl,aarch64-unknown-linux-musl" } shellcheck = "0.11.0" [env] diff --git a/tools/onenote/mise.toml b/tools/onenote/mise.toml index cb6adb09..576836ec 100644 --- a/tools/onenote/mise.toml +++ b/tools/onenote/mise.toml @@ -1,10 +1,10 @@ # docproc-onenote's toolchain and its check, publish, golden, currency, and upgrade tasks. # See docs/tool-builds.md [tools] -cargo-deny = "0.22.1" +cargo-deny = "0.22.2" "github:EmbarkStudios/cargo-about" = "0.9.3" jq = "1.8.2" -rust = { version = "1.100.0", profile = "minimal", components = "clippy,rustfmt", targets = "x86_64-unknown-linux-musl,aarch64-unknown-linux-musl" } +rust = { version = "1.100.1", profile = "minimal", components = "clippy,rustfmt", targets = "x86_64-unknown-linux-musl,aarch64-unknown-linux-musl" } shellcheck = "0.11.0" [env]