40 lines
2.1 KiB
Plaintext
40 lines
2.1 KiB
Plaintext
{
|
|
"rules": [
|
|
{
|
|
"description": "Project Overview",
|
|
"rule": "This is a distributed cart management system in Go using the actor model. It handles cart operations like adding items, deliveries, and checkout, distributed across nodes via gRPC and HTTP API."
|
|
},
|
|
{
|
|
"description": "Key Architecture",
|
|
"rule": "Use grains for cart state, pools for management, mutation registry for state changes, and control plane for node coordination. Ownership via consistent hashing ring."
|
|
},
|
|
{
|
|
"description": "Coding Standards",
|
|
"rule": "Follow Go conventions. Use mutation registry for all state changes. Regenerate protobuf code after proto changes; never edit .pb.go files. Handle errors properly, use cookies for cart IDs in HTTP."
|
|
},
|
|
{
|
|
"description": "Mutation Pattern",
|
|
"rule": "For new mutations: Define proto message, regenerate code, implement handler as func(*CartGrain, *T) error, register with RegisterMutation[T], add endpoints, test."
|
|
},
|
|
{
|
|
"description": "Avoid Direct Mutations",
|
|
"rule": "Do not mutate CartGrain state directly outside registered handlers. Use the registry for consistency."
|
|
},
|
|
{
|
|
"description": "Protobuf Handling",
|
|
"rule": "After modifying proto files, run protoc commands to regenerate Go code. Ensure protoc-gen-go and protoc-gen-go-grpc are installed."
|
|
},
|
|
{
|
|
"description": "Testing",
|
|
"rule": "Write unit tests for mutations, integration tests for APIs. Run go test ./... regularly."
|
|
},
|
|
{
|
|
"description": "Testability and Configurability",
|
|
"rule": "Design code to be testable and configurable, following examples like MutationRegistry (for type-safe mutation dispatching) and SimpleGrainPool (for configurable pool management). Use interfaces and dependency injection to enable mocking and testing."
|
|
},
|
|
{
|
|
"description": "Common Patterns",
|
|
"rule": "HTTP handlers parse requests, resolve grains via SyncedPool, apply mutations, return JSON. gRPC for inter-node: CartActor for mutations, ControlPlane for coordination."
|
|
}
|
|
]
|
|
} |