Skip to content

Commit d312526

Browse files
Machine instructions
1 parent a05fc29 commit d312526

1 file changed

Lines changed: 127 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Instructions for AI Agents
2+
3+
## Overview
4+
5+
Hutch is a Ruby library for enabling asynchronous inter-service communication
6+
using RabbitMQ. It provides a conventions-based framework for consumers and
7+
producers using topic exchanges.
8+
9+
Its key dependencies are [Bunny](https://github.com/ruby-amqp/bunny) (MRI Ruby)
10+
or [March Hare](https://github.com/ruby-amqp/march_hare) (JRuby), two RabbitMQ clients that use AMQP 0-9-1.
11+
12+
On top, Hutch uses [carrot-top](https://github.com/change/carrot-top) for the RabbitMQ HTTP API,
13+
and [ActiveSupport](https://github.com/rails/rails/tree/main/activesupport) from Ruby on Rails.
14+
15+
## Target Ruby Version
16+
17+
This library targets Ruby 3.1 and later versions
18+
For JRuby, the supported series are 9.x and 10.x.
19+
20+
## Build and Test
21+
22+
```bash
23+
bundle install
24+
25+
bundle exec rspec spec
26+
```
27+
28+
To run tests use `rspec` directly (not Rake).
29+
30+
## Key Files
31+
32+
### Core
33+
34+
* `lib/hutch.rb`: top-level module, global consumer registry, a connection singleton
35+
* `lib/hutch/broker.rb`: RabbitMQ connection and channel lifecycle, topology declaration, [delivery acknowledgements](https://www.rabbitmq.com/docs/confirms), [publisher confirms](https://www.rabbitmq.com/docs/confirms), [TLS](https://www.rabbitmq.com/docs/ssl), HTTP API client
36+
* `lib/hutch/worker.rb`: the main consumer loop: topology and consumer setup, delivery dispatch, error handling
37+
* `lib/hutch/consumer.rb`: `Hutch::Consumer` module included by consumer classes; DSL: `consume`, `queue_name`, `lazy_queue`, `quorum_queue`, `arguments`, `queue_options`, `serializer`
38+
* `lib/hutch/publisher.rb`: message serialization, routing, publisher confirms
39+
* `lib/hutch/message.rb`: message wrapper (delivery_info, properties, payload)
40+
* `lib/hutch/config.rb`: configuration with 3-tier precedence (defaults < ENV `HUTCH_*` < config file < explicit set)
41+
* `lib/hutch/cli.rb`: CLI (based on `OptionParser`), Rails app detection, consumer loading, daemonization
42+
* `lib/hutch/exceptions.rb`: `ConnectionError`, `AuthenticationError`, `WorkerSetupError`, `PublishError`
43+
* `lib/hutch/logging.rb`: configurable logger with `HutchFormatter`
44+
* `lib/hutch/waiter.rb`: signal handling (`SIGINT`, `SIGTERM`, `SIGQUIT` for shutdown; `SIGUSR2` for thread dumps)
45+
* `lib/hutch/version.rb`: the `Hutch::VERSION` constant
46+
47+
### Adapters
48+
49+
* `lib/hutch/adapter.rb`: runtime adapter selector (Bunny on MRI, March Hare on JRuby)
50+
* `lib/hutch/adapters/bunny.rb`: Bunny adapter
51+
* `lib/hutch/adapters/march_hare.rb`: March Hare adapter
52+
53+
### Serializers
54+
55+
* `lib/hutch/serializers/json.rb`: JSON serialization via `multi_json`
56+
* `lib/hutch/serializers/identity.rb`: pass-through (no-op) serializer
57+
58+
### Error Handlers
59+
60+
* `lib/hutch/error_handlers/base.rb`: base class
61+
* `lib/hutch/error_handlers/logger.rb`: logs errors (default)
62+
* `lib/hutch/error_handlers/sentry.rb`: sentry-ruby integration
63+
* `lib/hutch/error_handlers/sentry_raven.rb`: legacy sentry-raven integration
64+
* `lib/hutch/error_handlers/honeybadger.rb`: Honeybadger
65+
* `lib/hutch/error_handlers/airbrake.rb`: Airbrake
66+
* `lib/hutch/error_handlers/rollbar.rb`: Rollbar
67+
* `lib/hutch/error_handlers/bugsnag.rb`: Bugsnag
68+
69+
### Tracers
70+
71+
* `lib/hutch/tracers/null_tracer.rb`: no-op (default)
72+
* `lib/hutch/tracers/newrelic.rb`: NewRelic APM
73+
* `lib/hutch/tracers/datadog.rb`: Datadog tracing
74+
75+
### Acknowledgement Strategies
76+
77+
* `lib/hutch/acknowledgements/base.rb`: base interface (a chain of responsibility)
78+
* `lib/hutch/acknowledgements/nack_on_all_failures.rb`: the default fallback
79+
80+
## Test Suite
81+
82+
The test suite uses RSpec:
83+
84+
```bash
85+
bundle exec rspec spec
86+
```
87+
88+
Test files mirror the `lib/hutch/` structure under `spec/hutch/`. Tests are filtered
89+
by adapter at runtime: Bunny specs are excluded on JRuby, March Hare specs on MRI.
90+
91+
## Comments
92+
93+
* Only add important comments that express the non-obvious intent, both in tests and in the implementation
94+
* Keep the comments short
95+
* Pay attention to the grammar of your comments, including punctuation, full stops, articles, and so on
96+
97+
## Change Log
98+
99+
If asked to perform change log updates, consult and modify `CHANGELOG.md` and stick to its
100+
existing writing style.
101+
102+
## Releases
103+
104+
### How to Roll (Produce) a New Release
105+
106+
Suppose the current development version in `CHANGELOG.md` has
107+
a `## X.Y.0 (in development)` section at the top.
108+
109+
To produce a new release:
110+
111+
1. Update `CHANGELOG.md`: replace `(in development)` with today's date, e.g. `(Mar 30, 2026)`. Make sure all notable changes since the previous release are listed
112+
2. Update the version in `lib/hutch/version.rb` to match (remove the `.pre` suffix)
113+
3. Commit with the message `X.Y.0` (just the version number, nothing else)
114+
4. Tag the commit: `git tag vX.Y.0`
115+
5. Bump the dev version: add a new `## X.(Y+1).0 (in development)` section to `CHANGELOG.md` with `No changes yet.` underneath, and update `lib/hutch/version.rb` to the next dev version with a `.pre` suffix
116+
6. Commit with the message `Bump dev version`
117+
7. Push: `git push && git push --tags`
118+
119+
## Git Instructions
120+
121+
* Do not commit changes automatically without an explicit permission to do so
122+
* Never add yourself to the list of commit co-authors
123+
* Never mention yourself in commit messages in any way (no "Generated by", no AI tool links, etc)
124+
125+
## Style Guide
126+
127+
* Never add full stops to Markdown list items

0 commit comments

Comments
 (0)