You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+251-1Lines changed: 251 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# ActivityPub AI Assistant Guide
2
2
3
-
This file provides guidance for AI agents contributing to this repository
3
+
This file provides comprehensive guidance for AI agents contributing to this repository.
4
+
5
+
> **Note:** This document contains detailed code examples and implementation patterns. For a concise human-readable overview, see [README.md](README.md).
4
6
5
7
## Project Overview
6
8
@@ -234,6 +236,8 @@ Currently unsupported
234
236
235
237
## Architecture Patterns
236
238
239
+
**📚 See `/adr` directory for Architecture Decision Records**
240
+
237
241
- Dependency injection is heavily used to manage dependencies and facilitate
238
242
testing
239
243
- The `Result` pattern is preferred over throwing errors, with an exhaustive
@@ -250,6 +254,81 @@ Currently unsupported
250
254
- Views can talk directly to the database if necessary
251
255
- Views should not be responsible for any business logic
252
256
257
+
### Read/Write Separation
258
+
259
+
The codebase follows a CQRS-inspired pattern:
260
+
261
+
**Write Path (Commands):**
262
+
- Controller → Service → Repository → Entity
263
+
- Follows strict layering and repository pattern
264
+
- Handles business logic, validations, and domain events
265
+
266
+
**Read Path (Queries):**
267
+
- Controller → View → Database
268
+
- Views make optimized queries directly to the database
269
+
- Returns DTOs with presentation-ready data
270
+
- Includes user-specific context (e.g., followedByMe, blockedByMe)
271
+
272
+
---
273
+
274
+
## Critical Patterns & Gotchas
275
+
276
+
### Database Lookups Use SHA256 Hashes
277
+
278
+
⚠️ **Never use direct string comparisons for ActivityPub IDs** - see [ADR-0009](adr/0009-hash-based-database-lookups.md)
`dispatchers.ts` contains 1100+ lines of legacy factory functions. New handlers should follow the class-based pattern in `/activity-handlers/` - see [ADR-0006](adr/0006-class-based-architecture.md)
331
+
253
332
---
254
333
255
334
## Code Conventions
@@ -264,6 +343,177 @@ Currently unsupported
264
343
265
344
---
266
345
346
+
## Code Patterns
347
+
348
+
These patterns are based on our architecture decisions (see `/adr` directory):
349
+
350
+
### Immutable Entities with Domain Events
351
+
352
+
```typescript
353
+
// ❌ Avoid: Mutable entities with dirty flags
354
+
classPost {
355
+
private _likeCount:number;
356
+
private _likeCountDirty:boolean;
357
+
358
+
like() {
359
+
this._likeCount++;
360
+
this._likeCountDirty=true;
361
+
}
362
+
}
363
+
364
+
// ✅ Prefer: Immutable entities that generate events
├── mq # Implementation of a PubSub backed MessageQueue for Fedify
28
-
├── publishing
29
-
└── test # Helpers for tests
30
-
```
1
+
# Contributing to ActivityPub Service
31
2
32
3
## Development Guidelines
33
4
34
-
This section documents quirks and conventions specific to our implementation.
5
+
For architectural patterns, code standards, and development guidelines, please see the [Architecture & Development Guidelines](README.md#️-architecture--development-guidelines) section in the main README.
35
6
36
-
### Do's
7
+
##Submitting Changes
37
8
38
-
- Do model business logic in the Entities
39
-
- Do use services in HTTP handlers & Fedify wirings
9
+
1. Create a feature branch from `main`
10
+
2. Make your changes following the patterns documented in README
11
+
3. Ensure tests pass: `yarn test`
12
+
4. Submit a pull request with a clear description
40
13
41
-
### Don'ts
14
+
##Code Review Process
42
15
43
-
- Don't add code to dispatchers.ts
44
-
- Don't add code to handlers.ts
16
+
- All PRs require at least one review
17
+
- Check that new code follows our architectural patterns (see ADRs)
0 commit comments