API/Contract Design - Defining Component Interfaces
Foundational Principle
Component contracts and interfaces must be defined before technology/protocol selection.
Jumping to implementation without contract definition creates:
- Integration failures discovered during development
- Inconsistent data structures across components
- Teams blocked waiting for interface clarity
- Rework when assumptions about contracts differ
The API Design answers: WHAT data/operations components expose and consume?
The API Design never answers: HOW those are implemented (protocols, serialization, specific tech).
Phase 0: API Standards Discovery (MANDATORY)
Before defining contracts, check for organizational naming standards.
See shared-patterns/standards-discovery.md for complete workflow.
Context: API field naming standards
Output: docs/pre-dev/{feature-name}/api-standards-ref.md
Use AskUserQuestion tool:
Question: "Do you have a data dictionary or API field naming standards to reference?"
- Header: "API Standards"
- multiSelect: false
- Options:
- "No - Use industry best practices" (description: "Generate contracts using standard naming conventions")
- "Yes - URL to document" (description: "Provide a URL to your data dictionary or standards document")
- "Yes - File path" (description: "Provide a local file path (.md, .json, .yaml, .csv)")
If "Yes" Selected:
1. Load the document:
| Source Type |
Tool |
Actions |
| URL |
WebFetch |
Fetch document content; parse for field definitions, naming rules, validation patterns |
| File path |
Read |
Read file content; support .md (Markdown tables), .json (structured), .yaml (structured), .csv (tabular) |
2. Extract standards:
MUST extract these elements if present:
| Element |
What to Extract |
Example |
| Field naming convention |
camelCase, snake_case, PascalCase |
userId vs user_id |
| Standard field names |
Common fields used across APIs |
createdAt, updatedAt, isActive |
| Data type formats |
How to represent dates, IDs, amounts |
ISO8601, UUID v4, Decimal(10,2) |
| Validation patterns |
Regex, constraints, rules |
Email RFC 5322, phone E.164 |
| Standard error codes |
Organizational error naming |
EMAIL_ALREADY_EXISTS vs DuplicateEmail |
| Pagination fields |
Standard query/response pagination |
page, pageSize, totalCount |
3. Save extracted standards:
Output to: docs/pre-dev/{feature-name}/api-standards-ref.md
Format:
# API Standards Reference - {Feature Name}
Source: {URL or file path}
Extracted: {timestamp}
## Field Naming Conventions
- IDs: `{pattern}` (example)
- Timestamps: `{pattern}` (example)
- Booleans: `{pattern}` (example)
- Collections: `{pattern}` (example)
## Standard Fields
| Field | Type | Format | Validation | Example |
|-------|------|--------|------------|---------|
| userId | string | UUID v4 | Required, unique | "550e8400-e29b-41d4-a716-446655440000" |
| email | string | RFC 5322 | Required, unique | "user@example.com" |
| createdAt | string | ISO 8601 | Auto-generated | "2026-01-23T10:30:00Z" |
## Standard Error Codes
| Code | Usage | HTTP Equivalent (for reference) |
|------|-------|--------------------------------|
| EMAIL_ALREADY_EXISTS | Duplicate email registration | 409 Conflict |
| INVALID_INPUT | Validation failure | 400 Bad Request |
## Validation Patterns
| Pattern Type | Rule | Example |
|-------------|------|---------|
| Email | RFC 5322, max 254 chars | "user@example.com" |
| Phone | E.164 format | "+5511987654321" |
## Pagination Standards
| Field | Type | Description |
|-------|------|-------------|
| page | integer | 1-indexed page number |
| pageSize | integer | Items per page (max 100) |
| totalCount | integer | Total items across all pages |
4. Apply throughout Gate 4:
- Use standard field names in operation definitions
- Reference validation patterns in contract constraints
- Apply naming conventions consistently
- Note any justified deviations with rationale
If Dictionary Conflicts with Existing Codebase:
If Phase 0 from Gate 0 (Research) found existing patterns that conflict with the dictionary:
STOP and use AskUserQuestion:
Question: "Dictionary says {dictionary_pattern}, but codebase uses {codebase_pattern}. Which should we follow?"
- Header: "Standards Conflict"
- multiSelect: false
- Options:
- "Follow dictionary" (description: "Use organizational standards, refactor existing code later")
- "Follow codebase" (description: "Maintain consistency with existing implementation")
- "Hybrid approach" (description: "Let me decide per-field")
If "No" Selected (Industry Best Practices):
Proceed with standard naming conventions:
- camelCase for field names (JavaScript/TypeScript)
- snake_case for field names (Python/Ruby/SQL)
- ISO 8601 for timestamps
- UUID v4 for identifiers
- RFC 5322 for emails
Document the choice in api-standards-ref.md with rationale.
Mandatory Workflow
| Phase |
Activities |
| 0. API Standards Discovery |
Check for organizational field naming standards (data dictionary); load from URL or file if provided; extract field conventions, types, validation patterns; save to api-standards-ref.md for reference throughout gate |
| 1. Contract Analysis |
Load approved TRD (Gate 3), Feature Map (Gate 2), PRD (Gate 1); identify integration points from TRD component diagram; extract data flows |
| 2. Contract Definition |
Per interface: define operations, specify inputs/outputs, define errors, document events, set constraints (validation, rate limits), version contracts; apply standards from Phase 0 if available |
| 3. Gate 4 Validation |
Verify all checkboxes in validation checklist before proceeding to Data Modeling |
Explicit Rules
✅ DO Include
Operation names/descriptions, input parameters (name, type, required/optional, constraints), output structure (fields, types, nullable), error codes/descriptions, event types/payloads, validation rules, rate limits/quotas, idempotency requirements, auth/authz needs (abstract), versioning strategy
❌ NEVER Include
HTTP verbs (GET/POST/PUT), gRPC/GraphQL/WebSocket details, URL paths/routes, serialization formats (JSON/Protobuf), framework code, database queries, infrastructure, specific auth libraries
Abstraction Rules
| Element |
Abstract (✅) |
Protocol-Specific (❌) |
| Operation |
"CreateUser" |
"POST /api/v1/users" |
| Data Type |
"EmailAddress (validated)" |
"string with regex" |
| Error |
"UserAlreadyExists" |
"HTTP 409 Conflict" |
| Auth |
"Requires authenticated user" |
"JWT Bearer token" |
| Format |
"ISO8601 timestamp" |
"time.RFC3339" |
Rationalization Table
| Excuse |
Reality |
| "No need to ask about data dictionary" |
Organizations have standards. Check first, don't assume. Phase 0 is MANDATORY. |
| "I'll just use common sense for field names" |
"Common sense" varies. Ask for standards, or explicitly choose best practices. |
| "Skip Phase 0, user will mention standards if important" |
User doesn't know when to mention it. YOU must ask proactively. |
| "REST is obvious, just document endpoints" |
Protocol choice goes in Dependency Map. Define contracts abstractly. |
| "We need HTTP codes for errors" |
Error semantics matter; HTTP codes are protocol. Abstract the errors. |
| "Teams need to see JSON examples" |
JSON is serialization. Define structure; format comes later. |
| "The contract IS the OpenAPI spec" |
OpenAPI is protocol-specific. Design contracts first, generate specs later. |
| "gRPC/GraphQL affects the contract" |
Protocols deliver contracts. Design protocol-agnostic contracts first. |
| "We already know it's REST" |
Knowing doesn't mean documenting prematurely. Stay abstract. |
| "Framework validates inputs" |
Validation logic is universal. Document rules; implementation comes later. |
| "This feels redundant with TRD" |
TRD = components exist. API = how they talk. Different concerns. |
| "URL structure matters for APIs" |
URLs are HTTP-specific. Focus on operations and data. |
| "But API Design means REST API" |
API = interface. Could be REST, gRPC, events, or in-process. Stay abstract. |
Red Flags - STOP
If you catch yourself writing any of these in API Design, STOP:
- HTTP methods (GET, POST, PUT, DELETE, PATCH)
- URL paths (/api/v1/users, /users/{id})
- Protocol names (REST, GraphQL, gRPC, WebSocket)
- Status codes (200, 404, 500)
- Serialization formats (JSON, XML, Protobuf)
- Authentication tokens (JWT, OAuth2 tokens, API keys)
- Framework code (Express routes, gRPC service definitions)
- Transport mechanisms (HTTP/2, TCP, UDP)
When you catch yourself: Replace protocol detail with abstract contract. "POST /users" → "CreateUser operation"
Gate 4 Validation Checklist
| Category |
Requirements |
| Contract Completeness |
All component-to-component interactions have contracts; all external integrations covered; all event/message contracts defined; client-facing APIs specified |
| Operation Clarity |
Each operation has clear purpose/description; consistent naming convention; idempotency documented; batch operations identified |
| Data Specification |
All inputs typed and documented; required vs optional explicit; outputs complete; null/empty cases handled |
| Error Handling |
All scenarios identified; error codes/types defined; actionable messages; retry/recovery documented |
| Event Contracts |
All events named/described; payloads specified; ordering/delivery semantics documented; versioning defined |
| Constraints & Policies |
Validation rules explicit; rate limits defined; timeouts specified; backward compatibility exists |
| Technology Agnostic |
No protocol specifics; no serialization formats; no framework names; implementable in any protocol |
Gate Result: ✅ PASS (all checked) → Data Modeling | ⚠️ CONDITIONAL (remove protocol details) | ❌ FAIL (incomplete)
Contract Template Structure
Output to docs/pre-dev/{feature-name}/api-design.md with these sections:
| Section |
Content |
| Overview |
TRD/Feature Map/PRD references, status, last updated |
| Versioning Strategy |
Approach (semantic/date-based), backward compatibility policy, deprecation process |
| Component Contracts |
Per component: purpose, integration points (inbound/outbound), operations |
Per-Operation Structure
| Field |
Content |
| Purpose |
What the operation does |
| Inputs |
Table: Parameter, Type, Required, Constraints, Description |
| Validation Rules |
Format patterns, business rules |
| Outputs (Success) |
Table: Field, Type, Nullable, Description + abstract structure |
| Errors |
Table: Error Code, Condition, Description, Retry? |
| Idempotency |
Behavior on duplicate calls |
| Authorization |
Required permissions (abstract) |
| Related Operations |
Events triggered, downstream calls |
Event Contract Structure
| Field |
Content |
| Purpose/When Emitted |
Trigger conditions |
| Payload |
Table: Field, Type, Nullable, Description |
| Consumers |
Services that consume this event |
| Delivery Semantics |
At-least-once, at-most-once, exactly-once |
| Ordering/Retention |
Ordering guarantees, retention period |
Additional Sections
| Section |
Content |
| Cross-Component Integration |
Per integration: purpose, operations used, data flow diagram (abstract), error handling |
| External System Contracts |
Operations exposed to us, operations we expose, per-operation details |
| Custom Type Definitions |
Per type: base type, format, constraints, example |
| Naming Conventions |
Operations (verb+noun), parameters (camelCase), events (past tense), errors (noun+condition) |
| Rate Limiting & Quotas |
Per-operation limits table, quota policies, exceeded limit behavior |
| Backward Compatibility |
Breaking vs non-breaking changes, deprecation timeline |
| Testing Contracts |
Contract testing strategy, example test scenarios |
| Gate 4 Validation |
Date, validator, checklist, approval status |
Common Violations
| Violation |
Wrong |
Correct |
| Protocol Details |
"Endpoint: POST /api/v1/users, Status: 201 Created, 409 Conflict" |
"Operation: CreateUser, Errors: EmailAlreadyExists, InvalidInput" |
| Implementation Code |
JavaScript regex validation code |
"email must match RFC 5322 format, max 254 chars" |
| Technology Types |
JSON example with "uuid", "Date", "Map<String,Any>" |
Table with abstract types: Identifier (UUID format), Timestamp (ISO8601), ProfileObject |
Confidence Scoring
| Factor |
Points |
Criteria |
| Contract Completeness |
0-30 |
All ops: 30, Most: 20, Gaps: 10 |
| Interface Clarity |
0-25 |
Clear/unambiguous: 25, Some interpretation: 15, Vague: 5 |
| Integration Complexity |
0-25 |
Simple point-to-point: 25, Moderate deps: 15, Complex orchestration: 5 |
| Error Handling |
0-20 |
All scenarios: 20, Common cases: 12, Minimal: 5 |
Action: 80+ autonomous generation | 50-79 present options | <50 ask clarifying questions
After Approval
- ✅ Lock contracts - interfaces are now implementation reference
- 🎯 Use contracts as input for Data Modeling (
ring:pre-dev-data-model)
- 🚫 Never add protocol specifics retroactively
- 📋 Keep technology-agnostic until Dependency Map
The Bottom Line
If you wrote API contracts with HTTP endpoints or gRPC services, remove them.
Contracts are protocol-agnostic. Period. No REST. No GraphQL. No HTTP codes.
Protocol choices go in Dependency Map. That's a later phase. Wait for it.
Define the contract. Stay abstract. Choose protocol later.
1---2name: ring-pre-dev-api-design3description: Gate 4: API contracts document - defines component interfaces and data contracts before protocol/technology selection. Large Track only.4---5
6# API/Contract Design - Defining Component Interfaces
7
8## Foundational Principle
9
10**Component contracts and interfaces must be defined before technology/protocol selection.**
11
12Jumping to implementation without contract definition creates:
13- Integration failures discovered during development
14- Inconsistent data structures across components
15- Teams blocked waiting for interface clarity
16- Rework when assumptions about contracts differ
17
18**The API Design answers**: WHAT data/operations components expose and consume?
19**The API Design never answers**: HOW those are implemented (protocols, serialization, specific tech).
20
21## Phase 0: API Standards Discovery (MANDATORY)
22
23**Before defining contracts, check for organizational naming standards.**
24
25See [shared-patterns/standards-discovery.md](../shared-patterns/standards-discovery.md) for complete workflow.
26
27**Context:** API field naming standards
28**Output:** `docs/pre-dev/{feature-name}/api-standards-ref.md`
29
30Use AskUserQuestion tool:
31
32**Question:** "Do you have a data dictionary or API field naming standards to reference?"
33- Header: "API Standards"
34- multiSelect: false
35- Options:
36 - "No - Use industry best practices" (description: "Generate contracts using standard naming conventions")
37 - "Yes - URL to document" (description: "Provide a URL to your data dictionary or standards document")
38 - "Yes - File path" (description: "Provide a local file path (.md, .json, .yaml, .csv)")
39
40### If "Yes" Selected:
41
42**1. Load the document:**
43
44| Source Type | Tool | Actions |
45|------------|------|---------|
46| URL | WebFetch | Fetch document content; parse for field definitions, naming rules, validation patterns |
47| File path | Read | Read file content; support .md (Markdown tables), .json (structured), .yaml (structured), .csv (tabular) |
48
49**2. Extract standards:**
50
51MUST extract these elements if present:
52
53| Element | What to Extract | Example |
54|---------|----------------|---------|
55| **Field naming convention** | camelCase, snake_case, PascalCase | `userId` vs `user_id` |
56| **Standard field names** | Common fields used across APIs | `createdAt`, `updatedAt`, `isActive` |
57| **Data type formats** | How to represent dates, IDs, amounts | ISO8601, UUID v4, Decimal(10,2) |
58| **Validation patterns** | Regex, constraints, rules | Email RFC 5322, phone E.164 |
59| **Standard error codes** | Organizational error naming | `EMAIL_ALREADY_EXISTS` vs `DuplicateEmail` |
60| **Pagination fields** | Standard query/response pagination | `page`, `pageSize`, `totalCount` |
61
62**3. Save extracted standards:**
63
64Output to: `docs/pre-dev/{feature-name}/api-standards-ref.md`
65
66Format:
67```markdown
68# API Standards Reference - {Feature Name}
69
70Source: {URL or file path}
71Extracted: {timestamp}
72
73## Field Naming Conventions
74- IDs: `{pattern}` (example)
75- Timestamps: `{pattern}` (example)
76- Booleans: `{pattern}` (example)
77- Collections: `{pattern}` (example)
78
79## Standard Fields
80| Field | Type | Format | Validation | Example |
81|-------|------|--------|------------|---------|
82| userId | string | UUID v4 | Required, unique | "550e8400-e29b-41d4-a716-446655440000" |
83| email | string | RFC 5322 | Required, unique | "user@example.com" |
84| createdAt | string | ISO 8601 | Auto-generated | "2026-01-23T10:30:00Z" |
85
86## Standard Error Codes
87| Code | Usage | HTTP Equivalent (for reference) |
88|------|-------|--------------------------------|
89| EMAIL_ALREADY_EXISTS | Duplicate email registration | 409 Conflict |
90| INVALID_INPUT | Validation failure | 400 Bad Request |
91
92## Validation Patterns
93| Pattern Type | Rule | Example |
94|-------------|------|---------|
95| Email | RFC 5322, max 254 chars | "user@example.com" |
96| Phone | E.164 format | "+5511987654321" |
97
98## Pagination Standards
99| Field | Type | Description |
100|-------|------|-------------|
101| page | integer | 1-indexed page number |
102| pageSize | integer | Items per page (max 100) |
103| totalCount | integer | Total items across all pages |
104```
105
106**4. Apply throughout Gate 4:**
107
108- **Use standard field names** in operation definitions
109- **Reference validation patterns** in contract constraints
110- **Apply naming conventions** consistently
111- **Note any justified deviations** with rationale
112
113### If Dictionary Conflicts with Existing Codebase:
114
115If Phase 0 from Gate 0 (Research) found existing patterns that conflict with the dictionary:
116
117**STOP and use AskUserQuestion:**
118
119**Question:** "Dictionary says `{dictionary_pattern}`, but codebase uses `{codebase_pattern}`. Which should we follow?"
120- Header: "Standards Conflict"
121- multiSelect: false
122- Options:
123 - "Follow dictionary" (description: "Use organizational standards, refactor existing code later")
124 - "Follow codebase" (description: "Maintain consistency with existing implementation")
125 - "Hybrid approach" (description: "Let me decide per-field")
126
127### If "No" Selected (Industry Best Practices):
128
129Proceed with standard naming conventions:
130- camelCase for field names (JavaScript/TypeScript)
131- snake_case for field names (Python/Ruby/SQL)
132- ISO 8601 for timestamps
133- UUID v4 for identifiers
134- RFC 5322 for emails
135
136**Document the choice** in `api-standards-ref.md` with rationale.
137
138## Mandatory Workflow
139
140| Phase | Activities |
141|-------|------------|
142| **0. API Standards Discovery** | Check for organizational field naming standards (data dictionary); load from URL or file if provided; extract field conventions, types, validation patterns; save to `api-standards-ref.md` for reference throughout gate |
143| **1. Contract Analysis** | Load approved TRD (Gate 3), Feature Map (Gate 2), PRD (Gate 1); identify integration points from TRD component diagram; extract data flows |
144| **2. Contract Definition** | Per interface: define operations, specify inputs/outputs, define errors, document events, set constraints (validation, rate limits), version contracts; **apply standards from Phase 0 if available** |
145| **3. Gate 4 Validation** | Verify all checkboxes in validation checklist before proceeding to Data Modeling |
146
147## Explicit Rules
148
149### ✅ DO Include
150Operation names/descriptions, input parameters (name, type, required/optional, constraints), output structure (fields, types, nullable), error codes/descriptions, event types/payloads, validation rules, rate limits/quotas, idempotency requirements, auth/authz needs (abstract), versioning strategy
151
152### ❌ NEVER Include
153HTTP verbs (GET/POST/PUT), gRPC/GraphQL/WebSocket details, URL paths/routes, serialization formats (JSON/Protobuf), framework code, database queries, infrastructure, specific auth libraries
154
155### Abstraction Rules
156
157| Element | Abstract (✅) | Protocol-Specific (❌) |
158|---------|--------------|----------------------|
159| Operation | "CreateUser" | "POST /api/v1/users" |
160| Data Type | "EmailAddress (validated)" | "string with regex" |
161| Error | "UserAlreadyExists" | "HTTP 409 Conflict" |
162| Auth | "Requires authenticated user" | "JWT Bearer token" |
163| Format | "ISO8601 timestamp" | "time.RFC3339" |
164
165## Rationalization Table
166
167| Excuse | Reality |
168|--------|---------|
169| "No need to ask about data dictionary" | Organizations have standards. Check first, don't assume. Phase 0 is MANDATORY. |
170| "I'll just use common sense for field names" | "Common sense" varies. Ask for standards, or explicitly choose best practices. |
171| "Skip Phase 0, user will mention standards if important" | User doesn't know when to mention it. YOU must ask proactively. |
172| "REST is obvious, just document endpoints" | Protocol choice goes in Dependency Map. Define contracts abstractly. |
173| "We need HTTP codes for errors" | Error semantics matter; HTTP codes are protocol. Abstract the errors. |
174| "Teams need to see JSON examples" | JSON is serialization. Define structure; format comes later. |
175| "The contract IS the OpenAPI spec" | OpenAPI is protocol-specific. Design contracts first, generate specs later. |
176| "gRPC/GraphQL affects the contract" | Protocols deliver contracts. Design protocol-agnostic contracts first. |
177| "We already know it's REST" | Knowing doesn't mean documenting prematurely. Stay abstract. |
178| "Framework validates inputs" | Validation logic is universal. Document rules; implementation comes later. |
179| "This feels redundant with TRD" | TRD = components exist. API = how they talk. Different concerns. |
180| "URL structure matters for APIs" | URLs are HTTP-specific. Focus on operations and data. |
181| "But API Design means REST API" | API = interface. Could be REST, gRPC, events, or in-process. Stay abstract. |
182
183## Red Flags - STOP
184
185If you catch yourself writing any of these in API Design, **STOP**:
186
187- HTTP methods (GET, POST, PUT, DELETE, PATCH)
188- URL paths (/api/v1/users, /users/{id})
189- Protocol names (REST, GraphQL, gRPC, WebSocket)
190- Status codes (200, 404, 500)
191- Serialization formats (JSON, XML, Protobuf)
192- Authentication tokens (JWT, OAuth2 tokens, API keys)
193- Framework code (Express routes, gRPC service definitions)
194- Transport mechanisms (HTTP/2, TCP, UDP)
195
196**When you catch yourself**: Replace protocol detail with abstract contract. "POST /users" → "CreateUser operation"
197
198## Gate 4 Validation Checklist
199
200| Category | Requirements |
201|----------|--------------|
202| **Contract Completeness** | All component-to-component interactions have contracts; all external integrations covered; all event/message contracts defined; client-facing APIs specified |
203| **Operation Clarity** | Each operation has clear purpose/description; consistent naming convention; idempotency documented; batch operations identified |
204| **Data Specification** | All inputs typed and documented; required vs optional explicit; outputs complete; null/empty cases handled |
205| **Error Handling** | All scenarios identified; error codes/types defined; actionable messages; retry/recovery documented |
206| **Event Contracts** | All events named/described; payloads specified; ordering/delivery semantics documented; versioning defined |
207| **Constraints & Policies** | Validation rules explicit; rate limits defined; timeouts specified; backward compatibility exists |
208| **Technology Agnostic** | No protocol specifics; no serialization formats; no framework names; implementable in any protocol |
209
210**Gate Result:** ✅ PASS (all checked) → Data Modeling | ⚠️ CONDITIONAL (remove protocol details) | ❌ FAIL (incomplete)
211
212## Contract Template Structure
213
214Output to `docs/pre-dev/{feature-name}/api-design.md` with these sections:
215
216| Section | Content |
217|---------|---------|
218| **Overview** | TRD/Feature Map/PRD references, status, last updated |
219| **Versioning Strategy** | Approach (semantic/date-based), backward compatibility policy, deprecation process |
220| **Component Contracts** | Per component: purpose, integration points (inbound/outbound), operations |
221
222### Per-Operation Structure
223
224| Field | Content |
225|-------|---------|
226| **Purpose** | What the operation does |
227| **Inputs** | Table: Parameter, Type, Required, Constraints, Description |
228| **Validation Rules** | Format patterns, business rules |
229| **Outputs (Success)** | Table: Field, Type, Nullable, Description + abstract structure |
230| **Errors** | Table: Error Code, Condition, Description, Retry? |
231| **Idempotency** | Behavior on duplicate calls |
232| **Authorization** | Required permissions (abstract) |
233| **Related Operations** | Events triggered, downstream calls |
234
235### Event Contract Structure
236
237| Field | Content |
238|-------|---------|
239| **Purpose/When Emitted** | Trigger conditions |
240| **Payload** | Table: Field, Type, Nullable, Description |
241| **Consumers** | Services that consume this event |
242| **Delivery Semantics** | At-least-once, at-most-once, exactly-once |
243| **Ordering/Retention** | Ordering guarantees, retention period |
244
245### Additional Sections
246
247| Section | Content |
248|---------|---------|
249| **Cross-Component Integration** | Per integration: purpose, operations used, data flow diagram (abstract), error handling |
250| **External System Contracts** | Operations exposed to us, operations we expose, per-operation details |
251| **Custom Type Definitions** | Per type: base type, format, constraints, example |
252| **Naming Conventions** | Operations (verb+noun), parameters (camelCase), events (past tense), errors (noun+condition) |
253| **Rate Limiting & Quotas** | Per-operation limits table, quota policies, exceeded limit behavior |
254| **Backward Compatibility** | Breaking vs non-breaking changes, deprecation timeline |
255| **Testing Contracts** | Contract testing strategy, example test scenarios |
256| **Gate 4 Validation** | Date, validator, checklist, approval status |
257
258## Common Violations
259
260| Violation | Wrong | Correct |
261|-----------|-------|---------|
262| **Protocol Details** | "Endpoint: POST /api/v1/users, Status: 201 Created, 409 Conflict" | "Operation: CreateUser, Errors: EmailAlreadyExists, InvalidInput" |
263| **Implementation Code** | JavaScript regex validation code | "email must match RFC 5322 format, max 254 chars" |
264| **Technology Types** | JSON example with "uuid", "Date", "Map<String,Any>" | Table with abstract types: Identifier (UUID format), Timestamp (ISO8601), ProfileObject |
265
266## Confidence Scoring
267
268| Factor | Points | Criteria |
269|--------|--------|----------|
270| Contract Completeness | 0-30 | All ops: 30, Most: 20, Gaps: 10 |
271| Interface Clarity | 0-25 | Clear/unambiguous: 25, Some interpretation: 15, Vague: 5 |
272| Integration Complexity | 0-25 | Simple point-to-point: 25, Moderate deps: 15, Complex orchestration: 5 |
273| Error Handling | 0-20 | All scenarios: 20, Common cases: 12, Minimal: 5 |
274
275**Action:** 80+ autonomous generation | 50-79 present options | <50 ask clarifying questions
276
277## After Approval
278
2791. ✅ Lock contracts - interfaces are now implementation reference
2802. 🎯 Use contracts as input for Data Modeling (`ring:pre-dev-data-model`)
2813. 🚫 Never add protocol specifics retroactively
2824. 📋 Keep technology-agnostic until Dependency Map
283
284## The Bottom Line
285
286**If you wrote API contracts with HTTP endpoints or gRPC services, remove them.**
287
288Contracts are protocol-agnostic. Period. No REST. No GraphQL. No HTTP codes.
289
290Protocol choices go in Dependency Map. That's a later phase. Wait for it.
291
292**Define the contract. Stay abstract. Choose protocol later.**