Skip to content

Add AGENTS.md with agent/contributor guidance - #541

Merged
davidbyttow merged 1 commit into
masterfrom
agents-md
Aug 8, 2026
Merged

Add AGENTS.md with agent/contributor guidance#541
davidbyttow merged 1 commit into
masterfrom
agents-md

Conversation

@davidbyttow

@davidbyttow davidbyttow commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

Adds an AGENTS.md so agents (and new contributors) get the repo's working knowledge up front:

CLAUDE.md now defers to AGENTS.md for the shared content and keeps only the Claude-specific worktree flow, so the two files can't drift.

🤖 Generated with Claude Code

Note

Add AGENTS.md with contributor and AI agent guidance

Moves setup instructions, common commands, repo layout, cgo/memory rules, testing conventions (golden files, leak detection, streaming parity), and macOS quirks into a new AGENTS.md file. Updates CLAUDE.md to defer to AGENTS.md rather than duplicating that content.

📊 Macroscope summarized 52e336a. 2 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

Setup, commands, package layout, and the conventions that have caused
real bugs when broken: libvips input-ref ownership (#531), band-count
background vectors (#534), libvips version guards for new properties
(#535), signature-based format detection over loader nicknames (#540).
Also documents the golden-file scheme, leak detector, byte-identity
requirement for streaming savers, and known macOS-local test failures.

CLAUDE.md now defers to AGENTS.md for shared content and keeps only the
Claude-specific worktree flow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread AGENTS.md
examples/ runnable examples (separate go modules)
```

`ImageRef` is a mutable handle: operations replace the underlying `VipsImage` via `setImage` (which unrefs the old one). `Close` and a GC finalizer release the ref; methods guard with `runtime.KeepAlive(r)` and `r.lock`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium AGENTS.md:45

The statement that ImageRef methods are guarded with r.lock is inaccurate: only a small subset of methods (Close, SetKill, setImage, and streaming materialize/write paths) acquire that mutex, while normal transform/export/metadata methods do not. This can mislead contributors into assuming concurrent method calls (including concurrent Close) are safe, when the underlying mutable VipsImage pointer is not protected on most paths. Consider correcting the wording to state that r.lock guards lifecycle/ownership transitions only, not general method calls, and add a note that callers must not invoke methods concurrently on the same ImageRef.

Suggested change
`ImageRef` is a mutable handle: operations replace the underlying `VipsImage` via `setImage` (which unrefs the old one). `Close` and a GC finalizer release the ref; methods guard with `runtime.KeepAlive(r)` and `r.lock`.
`ImageRef` is a mutable handle: operations replace the underlying `VipsImage` via `setImage` (which unrefs the old one). `Close` and a GC finalizer release the ref. Only lifecycle/ownership transitions (`Close`, `SetKill`, `setImage`, streaming materialize/write paths) acquire `r.lock`; normal transform/export/metadata methods do not, so callers must not invoke methods concurrently on the same `ImageRef`.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @AGENTS.md around line 45:

The statement that `ImageRef` methods are guarded with `r.lock` is inaccurate: only a small subset of methods (`Close`, `SetKill`, `setImage`, and streaming materialize/write paths) acquire that mutex, while normal transform/export/metadata methods do not. This can mislead contributors into assuming concurrent method calls (including concurrent `Close`) are safe, when the underlying mutable `VipsImage` pointer is not protected on most paths. Consider correcting the wording to state that `r.lock` guards lifecycle/ownership transitions only, not general method calls, and add a note that callers must not invoke methods concurrently on the same `ImageRef`.

@davidbyttow
davidbyttow merged commit 67c3214 into master Aug 8, 2026
3 checks passed
@davidbyttow
davidbyttow deleted the agents-md branch August 8, 2026 16:30
davidbyttow added a commit that referenced this pull request Aug 8, 2026
r.lock only guards lifecycle transitions (Close, SetKill, setImage,
streaming materialize/save); ordinary methods take no lock, so state
plainly that an ImageRef is not safe for concurrent use rather than
implying general methods are mutex-guarded.

Flagged by Macroscope on #541.

Co-authored-by: Claude Fable 5 <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