Skip to content

Commit 6c5fb6f

Browse files
committed
chore(claude): Update CLAUDE.md
1 parent d9d5f3b commit 6c5fb6f

1 file changed

Lines changed: 24 additions & 18 deletions

File tree

CLAUDE.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ bazel run //examples/server/gateway:gateway
3535

3636
# Run tests
3737
bazel test //...
38+
39+
# Run tests with verbose output
40+
bazel test //... --test_output=all --test_arg=-v
3841
```
3942

40-
### Go Module
43+
### Dependency Management
4144

42-
The project has both `go.mod` (for Go dependencies) and `MODULE.bazel` (for Bazel). Dependencies are:
43-
- **YARPC**: Uber's RPC framework
44-
- **gRPC**: Standard gRPC
45-
- **Zap**: Structured logging
46-
- **Tally**: Metrics collection
47-
- **Protobuf**: Protocol buffers
45+
The project has both `go.mod` (for Go dependencies) and `MODULE.bazel` (for Bazel)
4846

4947
## Architecture
5048

@@ -71,6 +69,7 @@ When working with databases and distributed systems, follow these principles:
7169
- Design schemas for append-only patterns where possible
7270
- Avoid in-place updates; prefer creating new records and marking old ones as superseded
7371
- Handle concurrent modifications with conflict resolution strategies
72+
- Avoid transactions in favor of optimistic concurrency and retries
7473

7574
5. **Idempotency Keys**: For operations that modify state:
7675
- Include unique request IDs
@@ -84,8 +83,8 @@ type Request struct {
8483
ID string
8584
Version int // For optimistic locking
8685
Status Status
87-
CreatedAt time.Time
88-
UpdatedAt time.Time
86+
CreatedAt int64
87+
UpdatedAt int64
8988
}
9089

9190
// Instead of mutating, create new version
@@ -95,7 +94,7 @@ func (r Request) WithStatus(status Status) Request {
9594
Version: r.Version + 1,
9695
Status: status,
9796
CreatedAt: r.CreatedAt,
98-
UpdatedAt: time.Now(),
97+
UpdatedAt: time.Now().UnixMilli(),
9998
}
10099
}
101100
```
@@ -215,11 +214,7 @@ extensions/{new_extension}/
215214

216215
Entities are domain objects used across the project. They live in the `entities/` directory, organized by domain:
217216

218-
**Note:** Entities are organized hierarchically by domain (queue, storage, workflow, etc.) to maintain clear boundaries and separation of concerns. This organization helps:
219-
- Group related entities together
220-
- Make dependencies explicit
221-
- Scale as the number of entities grows
222-
- Maintain domain-driven design principles
217+
**Note:** Entities are organized hierarchically by domain (queue, storage, workflow, etc.) to maintain clear boundaries and separation of concerns.
223218

224219
```
225220
entities/
@@ -249,9 +244,14 @@ entities/{domain}/
249244
**Guidelines:**
250245
1. Group entities by domain (queue, storage, workflow, etc.)
251246
2. Keep entities pure and framework-agnostic
252-
3. Add corresponding tests
253-
4. Update BUILD.bazel with go_library and go_test targets
254-
5. Import entities using: `github.com/uber/submitqueue/entities/{domain}`
247+
3. Prefer timestamps (int64 as Unix epoch milliseconds) over `time.Time` objects
248+
4. Prefer using entities as value types and not references
249+
5. Every field should have a comment explaining the meaning of it
250+
6. If needed, entity object should reference another entity object by ID (as int or string) and not reference directly
251+
7. When entity field is a enum, prefer string enums with clear name
252+
8. When designing enums, prefer to assign sentinels ("" for strings or 0 for ints) to unreachable enum types for application logic flow control
253+
9. Update BUILD.bazel with go_library and go_test targets
254+
10. Import entities using: `github.com/uber/submitqueue/entities/{domain}`
255255

256256
**Examples:**
257257
- Queue entities: `entities/queue/message.go`, `entities/queue/delivery.go`
@@ -418,6 +418,12 @@ make test # Run tests
418418
- Tests: `{file}_test.go`
419419
- BUILD files: Always `BUILD.bazel`
420420

421+
## Testing Guidelines
422+
423+
1. **Avoid asserting on error messages**: Assert on error type if it is a part of the contract, or assert generic error otherwise.
424+
2. **Avoid blocking operations for synchronization**: Do not use `time.Sleep` or similar blocking operations to synchronize state. Design the tested routine to signal back (e.g., via channels, callbacks, or condition variables).
425+
3. **Use testify assertions**: Use `stretchr/assert` or `require` instead of `t.Fatal()`.
426+
421427
## Important Notes
422428

423429
1. **Never use WORKSPACE**: This repo uses Bzlmod exclusively

0 commit comments

Comments
 (0)