Skip to content

docs: correct Nil processor description, errors.As guidance, and file structure#68

Open
MasterOfBinary wants to merge 3 commits into
masterfrom
fix/doc-corrections
Open

docs: correct Nil processor description, errors.As guidance, and file structure#68
MasterOfBinary wants to merge 3 commits into
masterfrom
fix/doc-corrections

Conversation

@MasterOfBinary

Copy link
Copy Markdown
Owner

Summary

Fixes documentation drift found in a full-repo review.

Changes

  • Nil processor (HIGH drift): CLAUDE.md, AGENTS.md, and README.md described it as a benchmarking pass-through, but it actually sleeps for a configurable Duration (and can mark items cancelled). Corrected to match processor/doc.go.
  • errors.As guidance: clarified that the engine wraps errors as pointers, so callers must target the pointer type — var se *batch.SourceError; errors.As(err, &se). The value-target form does not match.
  • File structure: refreshed CLAUDE.md's stale layout to reflect the actual tree (config.go, errors.go, constants.go, helpers.go, the example_*_test.go files, concrete processor/source files).
  • doc.go nits: removed a misleading // Output: marker from the root package doc comment; added a concurrency caution to the source/doc.go example (data and errors should be consumed concurrently).

Testing

go vet ./..., go build ./..., and go test ./... all pass (documentation and package-doc comments only).

Backwards compatibility

Documentation only.


Part of a 5-PR set from a full-repo review; file-disjoint and independently mergeable in any order.

🤖 Generated with Claude Code

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates documentation across several files (AGENTS.md, CLAUDE.md, README.md, doc.go, and source/doc.go) to clarify file structures, describe the Nil processor's timing behavior, warn about concurrent channel consumption, and explain how to use errors.As with pointer types. The feedback suggests simplifying the explanation of errors.As in AGENTS.md and CLAUDE.md to avoid non-idiomatic Go patterns like using new() with a pointer type.

Comment thread AGENTS.md
- Items with errors are tracked individually through the Error field
- Batch processing continues despite individual item errors
- Use `errors.As` to check error types (SourceError, ProcessorError)
- Use `errors.As` to check error types (SourceError, ProcessorError). The engine wraps errors as pointers (`&SourceError{...}`, `&ProcessorError{...}`), so `errors.As` must target the pointer type — e.g. `var se *batch.SourceError; errors.As(err, &se)` (equivalently `errors.As(err, new(*batch.SourceError))`). A value-target such as `var se batch.SourceError; errors.As(err, &se)` will not match.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The parenthetical (equivalently errors.As(err, new(*batch.SourceError))) is technically correct but highly non-idiomatic in Go.

In Go, the standard and idiomatic way to use errors.As with a pointer type is:

var se *batch.SourceError
errors.As(err, &se)

Using new(*batch.SourceError) is rarely seen and can confuse readers because it returns a double pointer (**batch.SourceError), requiring extra dereferencing to access the error fields.

Additionally, the phrase "The engine wraps errors as pointers" could be more precisely stated as "The engine returns errors as pointers" or "The engine instantiates errors as pointers", since "wrapping" in Go errors typically refers to the Unwrap chain rather than pointer vs. value types.

Consider simplifying and refining this sentence:

- Use `errors.As` to check error types (SourceError, ProcessorError). The engine returns errors as pointers (`*SourceError`, `*ProcessorError`), so `errors.As` must target the pointer type — e.g., `var se *batch.SourceError; errors.As(err, &se)`. A value-target such as `var se batch.SourceError; errors.As(err, &se)` will not match.

Comment thread CLAUDE.md
- Items with errors are tracked individually through the Error field
- Batch processing continues despite individual item errors
- Use `errors.As` to check error types (SourceError, ProcessorError) No newline at end of file
- Use `errors.As` to check error types (SourceError, ProcessorError). The engine wraps errors as pointers (`&SourceError{...}`, `&ProcessorError{...}`), so `errors.As` must target the pointer type — e.g. `var se *batch.SourceError; errors.As(err, &se)` (equivalently `errors.As(err, new(*batch.SourceError))`). A value-target such as `var se batch.SourceError; errors.As(err, &se)` will not match. No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The parenthetical (equivalently errors.As(err, new(*batch.SourceError))) is technically correct but highly non-idiomatic in Go.

In Go, the standard and idiomatic way to use errors.As with a pointer type is:

var se *batch.SourceError
errors.As(err, &se)

Using new(*batch.SourceError) is rarely seen and can confuse readers because it returns a double pointer (**batch.SourceError), requiring extra dereferencing to access the error fields.

Additionally, the phrase "The engine wraps errors as pointers" could be more precisely stated as "The engine returns errors as pointers" or "The engine instantiates errors as pointers", since "wrapping" in Go errors typically refers to the Unwrap chain rather than pointer vs. value types.

Consider simplifying and refining this sentence:

- Use `errors.As` to check error types (SourceError, ProcessorError). The engine returns errors as pointers (`*SourceError`, `*ProcessorError`), so `errors.As` must target the pointer type — e.g., `var se *batch.SourceError; errors.As(err, &se)`. A value-target such as `var se batch.SourceError; errors.As(err, &se)` will not match.

@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.73%. Comparing base (ba2a756) to head (849789b).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #68   +/-   ##
=======================================
  Coverage   96.73%   96.73%           
=======================================
  Files          12       12           
  Lines         368      368           
=======================================
  Hits          356      356           
  Misses          9        9           
  Partials        3        3           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

MasterOfBinary and others added 3 commits May 30, 2026 00:31
Fix #8: the Nil processor was described as "passes items through
unchanged (for benchmarking)", which is wrong. Per processor/nil.go it
sleeps for a configurable Duration (and can mark items cancelled via
MarkCancelled). Corrected in CLAUDE.md, AGENTS.md, and README.md to match
processor/doc.go.

Fix #9: the engine emits wrapped errors as pointers (&SourceError{},
&ProcessorError{} in batch/batch.go), so errors.As must target the
pointer type. Made the CLAUDE.md/AGENTS.md guidance explicit with a
concrete example; README already used the pointer form.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Root doc.go: removed the "// Output:" marker from the package doc comment.
It was not a real runnable Example and could mislead readers into thinking
the snippet's output was verified; the illustrative code is kept with a
plain comment.

source/doc.go: the example drained out fully and then errs sequentially.
That only works because Channel emits no errors; added a caution that
data and errors should generally be consumed concurrently, since the
Batch engine reads both channels at the same time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rebased fix/doc-corrections onto master (ba2a756), which merged the
single-use Batch API (#64) and the golangci-lint v2.12.2 install line
(#78) into the same doc files this PR edits.

The rebase auto-merged without textual conflicts, but doc.go required a
genuine three-way reconciliation: master rewrote the package-doc snippet
to the new API (errs, err := b.Go(...); if err != nil { log.Fatal(err) };
batch.IgnoreErrors(errs)) while this PR independently removed the
misleading "// Output:" marker from that same block. Both edits were
combined off the common ancestor, so the result keeps the new API and
drops the marker — no manual conflict markers were ever produced.

Reconciliation outcome:
- Kept master's content: single-use semantics, Go's (<-chan error, error)
  signature, ErrBatchUsed/ErrNilSource, nil-Config default note, the
  removal of IDBufferSize, and the golangci-lint install command.
- Re-applied this PR's still-valid corrections on top: Nil processor now
  documented as sleeping for a Duration (CLAUDE.md/AGENTS.md/README.md),
  errors.As pointer-target guidance (CLAUDE.md/AGENTS.md, verified against
  the &SourceError{}/&ProcessorError{} sends in batch/batch.go), File
  Structure refresh, and the doc.go / source/doc.go "// Output:" cleanups.
- Dropped nothing as redundant: master and this PR touched disjoint
  concerns, so every correction this PR intended still applies.

Verified post-rebase: go build ./..., go vet ./..., golangci-lint
v2.12.2 run --timeout=3m (0 issues), go test ./... (all packages pass,
including the runnable root Example), gofmt -l . empty.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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