Skip to content

Commit bc9b23c

Browse files
committed
docs: update AGENTS.md files with current versions and dependency info
1 parent 7f369d3 commit bc9b23c

3 files changed

Lines changed: 44 additions & 30 deletions

File tree

AGENTS.md

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
## Project Overview
44

5-
Cosmos is a Go monorepo with four HTTP modules: contract (interfaces), router (HTTP routing), problem (RFC 9457 errors), framework (complete framework). Go 1.25.0 workspace with replace directives.
5+
Cosmos is a Go monorepo with four HTTP modules: contract (interfaces), router (HTTP routing), problem (RFC 9457 errors), framework (complete framework). Go workspace with replace directives.
66

7-
Dependency hierarchy: contract (zero deps) → router/problem (standalone) → framework (uses all)
7+
Dependency hierarchy: problem (zero deps) → contract (depends on problem) → router (standalone) → framework (uses all)
88

9-
Current versions: contract v0.9.0, framework v0.10.0, problem v0.3.0, router v0.3.0
9+
Current versions: contract v0.10.0, framework v0.11.0, problem v0.4.0, router v0.4.0
1010

1111
## Setup Commands
1212

@@ -36,13 +36,15 @@ Always run tests from workspace root for proper module resolution. Each module h
3636
## Framework Patterns
3737

3838
Error-returning handlers (unlike stdlib, Cosmos handlers return errors):
39+
3940
```go
4041
func handler(w http.ResponseWriter, r *http.Request) error {
4142
return response.JSON(w, http.StatusOK, data)
4243
}
4344
```
4445

4546
Middleware composition:
47+
4648
```go
4749
func MyMiddleware() framework.Middleware {
4850
return func(next framework.Handler) framework.Handler {
@@ -55,6 +57,7 @@ func MyMiddleware() framework.Middleware {
5557
```
5658

5759
Secure server (always use instead of http.ListenAndServe):
60+
5861
```go
5962
server := framework.NewServer(":8080", app) // has timeout defaults
6063
server.ListenAndServe()
@@ -63,32 +66,37 @@ server.ListenAndServe()
6366
## Common Patterns
6467

6568
Router:
69+
6670
```go
6771
r := router.New[http.Handler]()
6872
r.Use(middleware)
6973
r.Get("/users/{id}", handler)
7074
```
7175

7276
Problem Details:
77+
7378
```go
7479
ErrNotFound.With("resource_id", id).ServeHTTP(w, r)
7580
```
7681

7782
Cache:
83+
7884
```go
7985
cache.Remember(ctx, key, ttl, func() (any, error) {
8086
return computeValue(), nil
8187
})
8288
```
8389

8490
Database transactions:
91+
8592
```go
8693
db.WithTransaction(ctx, func(tx contract.Database) error {
8794
return tx.Exec(ctx, query, args...)
8895
})
8996
```
9097

9198
Database connection pool:
99+
92100
```go
93101
db.Configure(func(raw *sql.DB) {
94102
raw.SetMaxOpenConns(25)
@@ -98,13 +106,15 @@ db.Configure(func(raw *sql.DB) {
98106
```
99107

100108
Sessions:
109+
101110
```go
102111
session := request.MustSession(r)
103112
session.Put("user_id", 123)
104113
session.Regenerate() // After auth
105114
```
106115

107116
Request helpers:
117+
108118
```go
109119
id, err := request.ParamInt(r, "id") // typed int parsing
110120
body, err := request.LimitedJSON[T](r, -1) // size-limited body (default 10MB)
@@ -113,11 +123,13 @@ hooks, ok := request.TryHooks(r) // non-panicking hooks access
113123
```
114124

115125
Response helpers:
126+
116127
```go
117128
response.SafeRedirect(w, http.StatusFound, "/dashboard") // validates relative path
118129
```
119130

120131
Encryption with AAD and key zeroing:
132+
121133
```go
122134
enc, _ := crypto.NewAES(key)
123135
enc.AdditionalData = []byte("context-binding")
@@ -128,6 +140,7 @@ defer enc.Close() // zeros key material
128140
## Built-in Middleware
129141

130142
Available in `framework/middleware`:
143+
131144
- `Recover()` / `RecoverWith(fn)` — panic recovery with error wrapping
132145
- `Logger(slog.Logger)` — structured request logging (fires AfterResponse)
133146
- `CSRF(origins...)` / `CSRFWith(csrf, problem)` — cross-origin protection
@@ -138,6 +151,7 @@ Available in `framework/middleware`:
138151
- `HTTP(func(http.Handler) http.Handler)` — stdlib middleware adapter
139152

140153
Session middleware in `framework/session`:
154+
141155
- `Middleware(driver)` / `MiddlewareWith(driver, opts)` — session lifecycle
142156

143157
## Common Gotchas
@@ -177,41 +191,41 @@ Session middleware in `framework/session`:
177191

178192
## Test Coverage
179193

180-
| Module | Coverage | Notes |
181-
|---|---|---|
182-
| contract/request | 100% | |
183-
| contract/response | 100% | |
184-
| router | 100% | Dead code removed |
185-
| problem | 100% | |
186-
| problem/internal | 100% | |
187-
| framework (root) | 100% | |
188-
| framework/middleware | 100% | |
189-
| framework/session | 95.4% | Remaining: rand failure path |
190-
| framework/cache | memory 100%, redis 0% | Redis requires external server |
191-
| framework/crypto | 90.2% | Remaining: rand failure paths |
192-
| framework/hash | 95.8% | Remaining: bcrypt internal error |
193-
| framework/event | memory 100%, pure logic 100% | External brokers require servers |
194-
| framework/database | 0% | Pure sqlx adapter, requires DB |
194+
| Module | Coverage | Notes |
195+
| -------------------- | ---------------------------- | -------------------------------- |
196+
| contract/request | 100% | |
197+
| contract/response | 100% | |
198+
| router | 100% | Dead code removed |
199+
| problem | 100% | |
200+
| problem/internal | 100% | |
201+
| framework (root) | 100% | |
202+
| framework/middleware | 100% | |
203+
| framework/session | 95.4% | Remaining: rand failure path |
204+
| framework/cache | memory 100%, redis 0% | Redis requires external server |
205+
| framework/crypto | 90.2% | Remaining: rand failure paths |
206+
| framework/hash | 95.8% | Remaining: bcrypt internal error |
207+
| framework/event | memory 100%, pure logic 100% | External brokers require servers |
208+
| framework/database | 0% | Pure sqlx adapter, requires DB |
195209

196210
## File Locations
197211

198212
- Workspace: go.work
199-
- Module configs: */go.mod
213+
- Module configs: \*/go.mod
200214
- Mock config: contract/.mockery.yml
201-
- CI workflows: .github/workflows/*.yml
202-
- Contracts: contract/*.go
203-
- Request helpers: contract/request/*.go
204-
- Response helpers: contract/response/*.go
215+
- CI workflows: .github/workflows/\*.yml
216+
- Contracts: contract/\*.go
217+
- Request helpers: contract/request/\*.go
218+
- Response helpers: contract/response/\*.go
205219
- Framework core: framework/handler.go, framework/framework.go, framework/server.go
206220
- Framework hooks: framework/hooks.go, framework/hooks_writer.go
207221
- Router: router/router.go
208222
- Problem: problem/problem.go
209-
- Middleware: framework/middleware/*.go
210-
- Session: framework/session/*.go
223+
- Middleware: framework/middleware/\*.go
224+
- Session: framework/session/\*.go
211225
- Cache: framework/cache/memory.go, framework/cache/redis.go
212226
- Crypto: framework/crypto/aes.go, framework/crypto/chacha20.go
213227
- Hash: framework/hash/argon2.go, framework/hash/bcrypt.go
214228
- Database: framework/database/sql.go
215229
- Events: framework/event/memory.go, framework/event/redis.go, framework/event/nats.go, framework/event/amqp.go, framework/event/mqtt.go
216-
- Agent skills: .agents/skills/cosmos-*/
230+
- Agent skills: .agents/skills/cosmos-\*/
217231
- Docs site: ../docs/src/content/docs/cosmos/

contract/AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
## Module Overview
44

5-
Contract module: service interfaces (Cache, Database, Session, Crypto, Hash) and request/response helpers. Zero dependencies except testing. Foundation for all Cosmos modules.
5+
Contract module: service interfaces (Cache, Database, Session, Crypto, Hash) and request/response helpers. Foundation for all Cosmos modules.
66

77
Module: github.com/studiolambda/cosmos/contract
8-
Dependencies: Zero (testify for tests, mockery as tool)
8+
Dependencies: problem (request/hooks.go, request/session.go use problem types), testify for tests, mockery as tool
99

1010
## Setup Commands
1111

@@ -99,7 +99,7 @@ contract/
9999

100100
## Common Gotchas
101101

102-
- Zero dependencies: no external imports
102+
- Depends on problem module (not zero-dep): request helpers use problem types
103103
- Type assertions for session values: val.(int)
104104
- Context always first parameter
105105
- Mock expectations must match exactly

framework/AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Framework module: complete HTTP framework with error-returning handlers, middleware, sessions, caching, crypto, hashing, database. Built on router, problem, and contract modules.
66

77
Module: github.com/studiolambda/cosmos/framework
8-
Dependencies: router, problem, contract, sqlx, go-redis, go-cache, golang.org/x/crypto
8+
Dependencies: router v0.4.0, problem v0.4.0, contract v0.10.0, sqlx, go-redis, go-cache, golang.org/x/crypto, golang.org/x/time, argon2, nats, amqp091, paho.golang (MQTT), sqlite3
99

1010
## Setup Commands
1111

0 commit comments

Comments
 (0)