@akjamie/agentic-sdlc 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +300 -107
- package/assets/schema/schema.yaml +11 -5
- package/assets/schema/templates/design.md +192 -11
- package/assets/skills/api-design/SKILL.md +204 -0
- package/assets/skills/asdlc-archive/SKILL.md +3 -2
- package/assets/skills/asdlc-impl-review/SKILL.md +162 -51
- package/assets/skills/asdlc-lint/SKILL.md +3 -0
- package/assets/skills/asdlc-new/SKILL.md +75 -24
- package/assets/skills/asdlc-spec-review/SKILL.md +14 -2
- package/assets/skills/batch-grill-me/SKILL.md +11 -7
- package/assets/skills/frontend-design/SKILL.md +84 -0
- package/assets/skills/grilling/SKILL.md +43 -17
- package/bin/asdlc.js +0 -0
- package/package.json +2 -2
- package/src/cli.js +3 -0
- package/src/commands/archive.js +34 -6
- package/src/commands/lint.js +31 -7
- package/src/commands/new.js +113 -23
- package/src/commands/test.js +137 -0
- package/src/lib/agents.js +5 -4
- package/src/lib/exec.js +5 -1
- package/src/lib/policy.js +6 -0
- package/src/lib/speclint.js +6 -1
- package/assets/ci/Jenkinsfile +0 -80
|
@@ -1,16 +1,197 @@
|
|
|
1
|
-
# Design: <!-- change id -->
|
|
1
|
+
# Technical Design: <!-- change id -->
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
> Requirement: "<!-- requirement summary -->"
|
|
4
|
+
> Purpose: Concrete architecture, interface contracts, external integration models, and UI/UX specifications.
|
|
5
|
+
> NOTE: This document guides implementation (HOW). Do NOT duplicate behavioral BDD requirements from spec.md.
|
|
5
6
|
|
|
6
|
-
##
|
|
7
|
-
<!--
|
|
7
|
+
## 1. Context & Background
|
|
8
|
+
<!-- Current state, existing architectural patterns, dependencies, and constraints needed to ground the approach. -->
|
|
8
9
|
|
|
9
|
-
##
|
|
10
|
-
<!--
|
|
10
|
+
## 2. System Architecture & Component Interaction
|
|
11
|
+
<!--
|
|
12
|
+
Component breakdown, responsibilities, data flow, and lifecycles.
|
|
13
|
+
Embed a self-contained Mermaid flowchart, sequenceDiagram, or stateDiagram:
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
```mermaid
|
|
16
|
+
sequenceDiagram
|
|
17
|
+
autonumber
|
|
18
|
+
actor User
|
|
19
|
+
participant Client as Frontend/UI
|
|
20
|
+
participant Svc as Service/API Layer
|
|
21
|
+
participant Ext as External 3rd-Party API
|
|
22
|
+
User->>Client: Triggers action
|
|
23
|
+
Client->>Svc: Request with validated params
|
|
24
|
+
Svc->>Ext: Upstream call (cached/debounced)
|
|
25
|
+
Ext-->>Svc: Response or error
|
|
26
|
+
Svc-->>Client: Normalized contract
|
|
27
|
+
Client-->>User: Render state (success/empty/error)
|
|
28
|
+
```
|
|
29
|
+
-->
|
|
14
30
|
|
|
15
|
-
##
|
|
16
|
-
<!--
|
|
31
|
+
## 3. Interface Contracts & Data Models
|
|
32
|
+
<!--
|
|
33
|
+
Specify exact TypeScript interfaces, JSON schemas, or DTO structures.
|
|
34
|
+
Follow the `api-design` skill for enterprise REST conventions.
|
|
35
|
+
|
|
36
|
+
1. Resource Endpoint Definitions:
|
|
37
|
+
- Method + Path: e.g. `POST /api/v1/payment-intents` (plural nouns, kebab-case, no verbs in URLs)
|
|
38
|
+
- Headers: `Content-Type: application/json`, `Idempotency-Key` (for mutations)
|
|
39
|
+
- Request DTO:
|
|
40
|
+
```typescript
|
|
41
|
+
interface CreatePaymentIntentRequest {
|
|
42
|
+
amountCents: number;
|
|
43
|
+
currency: 'usd' | 'eur' | 'cny';
|
|
44
|
+
customerId: string;
|
|
45
|
+
metadata?: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
- Success Response DTO (200 / 201):
|
|
49
|
+
```typescript
|
|
50
|
+
interface PaymentIntentResponse {
|
|
51
|
+
data: {
|
|
52
|
+
id: string;
|
|
53
|
+
status: 'requires_payment_method' | 'succeeded' | 'canceled';
|
|
54
|
+
amountCents: number;
|
|
55
|
+
createdAt: string; // ISO 8601 UTC
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
- Error Response Contract:
|
|
60
|
+
Option A: Stripe-style Error Envelope (Recommended for Developer APIs)
|
|
61
|
+
```typescript
|
|
62
|
+
interface ApiErrorResponse {
|
|
63
|
+
error: {
|
|
64
|
+
code: string; // e.g. 'validation_failed', 'resource_not_found'
|
|
65
|
+
message: string; // Human-readable summary
|
|
66
|
+
details?: Array<{ field: string; code: string; message: string }>;
|
|
67
|
+
requestId?: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
Option B: RFC 7807 Problem Details (Content-Type: application/problem+json)
|
|
72
|
+
```typescript
|
|
73
|
+
interface ProblemDetailsResponse {
|
|
74
|
+
type: string; // URI reference (e.g. 'https://api.example.com/errors/validation-failed')
|
|
75
|
+
title: string; // Short summary (e.g. 'Validation Failed')
|
|
76
|
+
status: number; // HTTP status code (e.g. 422)
|
|
77
|
+
detail?: string; // Specific occurrence explanation
|
|
78
|
+
instance?: string; // URI identifying specific occurrence (e.g. '/api/v1/orders/123')
|
|
79
|
+
invalidParams?: Array<{ name: string; reason: string }>;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
2. Pagination Contract (when returning collections):
|
|
83
|
+
- Cursor-based (preferred): `cursor`, `limit`, `has_more`, `next_cursor`
|
|
84
|
+
- Offset-based (admin tables): `page`, `per_page`, `total`, `total_pages`
|
|
85
|
+
-->
|
|
86
|
+
|
|
87
|
+
## 4. External Services & 3rd-Party API Integration
|
|
88
|
+
<!--
|
|
89
|
+
MANDATORY if this change integrates external vendor APIs or services.
|
|
90
|
+
Follow `api-design` resilience patterns.
|
|
91
|
+
- Endpoints & Authentication: Exact URLs, parameters, headers, and secret management.
|
|
92
|
+
- Rate Limiting & Quotas: Upstream limit constraints (e.g. 100 req/min, 5,000/day).
|
|
93
|
+
- Client Lifecycle & Caching Strategy:
|
|
94
|
+
- Cache type: in-memory Map / TTL cache / Redis.
|
|
95
|
+
- Cache key formulation, TTL duration, eviction policy.
|
|
96
|
+
- Lifecycle: Reuse client instance (singleton/service pool); NEVER re-instantiate clients per request.
|
|
97
|
+
- Idempotency & Retry Policy:
|
|
98
|
+
- Header: `Idempotency-Key: <uuid>` on outbound mutations.
|
|
99
|
+
- Exponential backoff with jitter on 429 / 503; respect `Retry-After`.
|
|
100
|
+
- Error Taxonomy & Degradation/Fallback:
|
|
101
|
+
- Ambiguous input: Candidate list returned, never wrong guess.
|
|
102
|
+
- Upstream 4xx/5xx / Quota exhaustion: User-friendly error message, fallback cache, retry with exponential backoff.
|
|
103
|
+
- Offline/Network failure: Clear degradation banner without unhandled rejections.
|
|
104
|
+
- Unverified endpoints/limits: Tag with [UNVERIFIED: <reason>] for explicit human review.
|
|
105
|
+
-->
|
|
106
|
+
|
|
107
|
+
## 5. UI/UX Design, Visual Hierarchy & Aesthetics
|
|
108
|
+
<!--
|
|
109
|
+
MANDATORY if this change adds or modifies user interfaces (Web, Mobile, Desktop).
|
|
110
|
+
Zero tolerance for unstyled, raw, or generic "AI slop" HTML!
|
|
111
|
+
Follow the `frontend-design` skill (Anthropic official) and Vercel Web Interface Guidelines.
|
|
112
|
+
|
|
113
|
+
🚫 Anti-AI Slop Mandate:
|
|
114
|
+
- NO generic glowing borders or arbitrary purple-on-black cards.
|
|
115
|
+
- NO arbitrary gradient text wrapping a single word in a headline.
|
|
116
|
+
- NO uniform pill buttons everywhere; align button variants with visual hierarchy.
|
|
117
|
+
- NO monotonous 3-card grids without spatial rhythm.
|
|
118
|
+
-->
|
|
119
|
+
|
|
120
|
+
### 5.1 Design Direction & Subject Grounding (REQUIRED)
|
|
121
|
+
<!--
|
|
122
|
+
Ground the design in the domain's real vernacular and audience (e.g., high-density analytical dashboard vs playful consumer app).
|
|
123
|
+
- Mockup link / Figma URL: <url or file path>
|
|
124
|
+
- Brand styleguide / design tokens: <reference or existing CSS tokens file>
|
|
125
|
+
- Reference application / URL: <benchmark url>
|
|
126
|
+
- Design Thesis: <1-2 sentences on tone, hero moment, and personality (e.g., editorial, brutalist-clean, Swiss modern)>
|
|
127
|
+
-->
|
|
128
|
+
- Reference: <!-- insert link, file, or brand token reference -->
|
|
129
|
+
- Design Thesis: <!-- e.g., high-density devtools, restrained palette, monospace accents -->
|
|
130
|
+
|
|
131
|
+
### 5.2 Visual Theme & Design Tokens
|
|
132
|
+
<!-- Derive 4-6 concrete, deliberate Hex codes: -->
|
|
133
|
+
- Color Palette:
|
|
134
|
+
- `--color-primary`: <!-- deliberate brand hue, e.g. #4f46e5 -->
|
|
135
|
+
- `--color-background`: <!-- deep canvas base, e.g. #0b0f19 or #fafafa -->
|
|
136
|
+
- `--color-surface`: <!-- card/surface elevation, e.g. #111827 or #ffffff -->
|
|
137
|
+
- `--color-border`: <!-- subtle boundary, e.g. #1f2937 or #e5e7eb -->
|
|
138
|
+
- `--color-accent`: <!-- high-contrast secondary accent for badges/active -->
|
|
139
|
+
- `--color-text-primary`: <!-- WCAG AA/AAA compliant contrast -->
|
|
140
|
+
- `--color-text-muted`: <!-- secondary reading text -->
|
|
141
|
+
- Typography Hierarchy:
|
|
142
|
+
- Heading / Display Font: <!-- e.g. 'Plus Jakarta Sans', 'Outfit', 'Syne' -->
|
|
143
|
+
- Body / UI Font: <!-- e.g. 'Inter', 'Geist', system-ui -->
|
|
144
|
+
- Monospace / Numbers: <!-- e.g. 'JetBrains Mono', tabular-nums -->
|
|
145
|
+
- Scale: hero (32px-48px, bold, -0.02em), section (20px-24px), body (14px-16px), micro (12px)
|
|
146
|
+
- Spacing & Radii:
|
|
147
|
+
- `--radius`: <!-- e.g. 8px / 12px -->
|
|
148
|
+
- `--spacing-unit`: <!-- e.g. 8px -->
|
|
149
|
+
|
|
150
|
+
### 5.3 Hero Moment & Component Layout
|
|
151
|
+
- Hero Treatment: <!-- what first-screen element anchors the page? live preview, search bar, metrics overview -->
|
|
152
|
+
- Breakpoints:
|
|
153
|
+
- Mobile (<= 640px): single-column, tap targets >= 44px.
|
|
154
|
+
- Tablet (641px - 1024px): 2-column adaptive grid.
|
|
155
|
+
- Desktop (> 1024px): 3-column / sidebar + main grid with sticky navigation.
|
|
156
|
+
|
|
157
|
+
### 5.4 Mandatory Interactive States (Vercel Guidelines)
|
|
158
|
+
Every UI component must specify all 5 states:
|
|
159
|
+
1. Default: Token-governed styling.
|
|
160
|
+
2. Hover / Focus: Purposeful micro-transitions (150ms-200ms ease); visible focus rings (`:focus-visible`).
|
|
161
|
+
3. Loading State: Content-shaped skeleton cards or spinners (never blank screens or layout shifts).
|
|
162
|
+
4. Empty State: Domain icon/illustration, empathetic copy, and single obvious action prompt.
|
|
163
|
+
5. Error State: Inline non-blocking banner with actionable message and retry button.
|
|
164
|
+
|
|
165
|
+
## 6. Security Architecture & Operational NFRs (Optional / When Applicable)
|
|
166
|
+
<!--
|
|
167
|
+
Document this section when the change introduces public interfaces, handles sensitive/user data,
|
|
168
|
+
integrates external rate-limited services, or has explicit latency/resource constraints.
|
|
169
|
+
For changes without external dependencies or strict SLAs, omit this section or mark as (N/A).
|
|
170
|
+
Do NOT invent arbitrary default values.
|
|
171
|
+
-->
|
|
172
|
+
|
|
173
|
+
### 6.1 Security & Threat Mitigation (If Applicable)
|
|
174
|
+
<!-- Detail concrete defense mechanisms if the change touches auth, inputs, or secrets: -->
|
|
175
|
+
- Authentication & Authorization: <!-- Caller identity verification, role/scope enforcement, or N/A -->
|
|
176
|
+
- Input Validation & Boundaries: <!-- Schema constraints, bounds, sanitization, or N/A -->
|
|
177
|
+
- Secret & Credential Lifecycle: <!-- Injected via environment variables, never logged, or N/A -->
|
|
178
|
+
- Data Privacy & PII Protection: <!-- Data classification, retention policies, or N/A -->
|
|
179
|
+
|
|
180
|
+
### 6.2 Performance Budgets & Operational NFRs (If Applicable)
|
|
181
|
+
<!-- Document operational constraints only when required by architecture, scale, or SLAs: -->
|
|
182
|
+
- Latency Budgets & SLAs: <!-- Target p95/p99 latency or response time bounds, if applicable -->
|
|
183
|
+
- Resource Bounds & Lifecycles: <!-- Cache size caps, TTL expiration, memory guards, if applicable -->
|
|
184
|
+
- Upstream Quota & Rate Limit Protection: <!-- Singleton client reuse, exponential backoff, if applicable -->
|
|
185
|
+
- Graceful Degradation: <!-- Downstream timeout bounds, stale/offline fallback, if applicable -->
|
|
186
|
+
|
|
187
|
+
## 7. Key Decisions & Alternatives
|
|
188
|
+
<!--
|
|
189
|
+
Document technical decisions made during grilling:
|
|
190
|
+
- Decision 1: [Choice] vs [Alternative] -> Rationale.
|
|
191
|
+
- Decision 2: ...
|
|
192
|
+
-->
|
|
193
|
+
|
|
194
|
+
## 8. Migration, Rollout & Rollback
|
|
195
|
+
<!--
|
|
196
|
+
Database migrations, deployment steps, feature flags, or rollback procedures (if applicable).
|
|
197
|
+
-->
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-design
|
|
3
|
+
description: "Industry-standard RESTful API design guidelines: resource naming, HTTP semantics, structured error taxonomy (Stripe-style and RFC 7807), cursor pagination, idempotency keys, and rate-limiting resilience."
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
origin: "Best-of-market REST standards (Stripe, Zalando, Google API Design Guide, RFC 7807 / RFC 9457, RFC 9110)"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Enterprise RESTful API Design Guidelines
|
|
10
|
+
|
|
11
|
+
This skill guides coding agents to design consistent, resilient, and developer-friendly REST APIs. It establishes strict architectural conventions across resource modeling, status codes, response envelopes, error handling, idempotency, and versioning.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. Resource Modeling & URL Hierarchy
|
|
16
|
+
|
|
17
|
+
### 🔗 URL Conventions
|
|
18
|
+
- **Nouns over verbs**: Resources represent entities, not remote procedure calls.
|
|
19
|
+
- **Plural, lowercase, kebab-case**: `/api/v1/team-members`, `/api/v1/payment-intents`.
|
|
20
|
+
- **Hierarchical nesting for ownership**:
|
|
21
|
+
- `GET /api/v1/organizations/:orgId/projects`
|
|
22
|
+
- `GET /api/v1/projects/:projectId/tasks/:taskId`
|
|
23
|
+
- *Rule*: Limit nesting to 2 levels maximum (`/parents/:id/children/:id`). For deeper relationships, use top-level resources with query filters: `/api/v1/comments?task_id=:taskId`.
|
|
24
|
+
- **Non-CRUD Actions**: When an operation does not map cleanly to standard CRUD, use explicit sub-resource action verbs sparingly:
|
|
25
|
+
- `POST /api/v1/orders/:id/cancel`
|
|
26
|
+
- `POST /api/v1/auth/refresh-token`
|
|
27
|
+
- `POST /api/v1/reports/export`
|
|
28
|
+
|
|
29
|
+
### 🚫 URL Anti-Patterns
|
|
30
|
+
| Anti-Pattern | Bad Example | Correct Design |
|
|
31
|
+
| :--- | :--- | :--- |
|
|
32
|
+
| Verbs in URLs | `GET /api/v1/getUsers` | `GET /api/v1/users` |
|
|
33
|
+
| Method in URLs | `POST /api/v1/users/delete` | `DELETE /api/v1/users/:id` |
|
|
34
|
+
| Singular resource | `/api/v1/user/:id` | `/api/v1/users/:id` |
|
|
35
|
+
| Mixed casing | `/api/v1/teamMembers` or `team_members` | `/api/v1/team-members` |
|
|
36
|
+
| Query params as path | `/api/v1/orders/status/active` | `/api/v1/orders?status=active` |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 2. HTTP Method Semantics & Status Codes
|
|
41
|
+
|
|
42
|
+
### 📋 Method Contract Matrix
|
|
43
|
+
| Method | Idempotent | Safe | Typical Response Code | Semantics |
|
|
44
|
+
| :--- | :---: | :---: | :---: | :--- |
|
|
45
|
+
| **GET** | Yes | Yes | `200 OK` | Retrieve resource representation without side effects. |
|
|
46
|
+
| **POST** | No | No | `201 Created` (with `Location`) | Create a new subordinate resource or trigger a process. |
|
|
47
|
+
| **PUT** | Yes | No | `200 OK` / `204 No Content` | Complete replacement of the identified resource. |
|
|
48
|
+
| **PATCH** | No (RFC 9110) | No | `200 OK` / `204 No Content` | Partial modification of specific resource attributes (can be made idempotent with JSON Patch or conditional headers). |
|
|
49
|
+
| **DELETE** | Yes | No | `204 No Content` | Remove resource; subsequent calls return `404` or `204`. |
|
|
50
|
+
|
|
51
|
+
### 🎯 Status Code Invariants
|
|
52
|
+
- **200 OK**: Request succeeded with response body.
|
|
53
|
+
- **201 Created**: Resource created; MUST include `Location: /api/v1/resources/:id` header.
|
|
54
|
+
- **204 No Content**: Action succeeded with zero response body (common for `DELETE`).
|
|
55
|
+
- **400 Bad Request**: Malformed JSON syntax, invalid query parameters.
|
|
56
|
+
- **401 Unauthorized**: Missing, expired, or invalid authentication credentials.
|
|
57
|
+
- **403 Forbidden**: Authenticated caller lacks permissions/scopes for this resource.
|
|
58
|
+
- **404 Not Found**: Resource does not exist (or hidden for security).
|
|
59
|
+
- **409 Conflict**: Duplicate key, concurrent state modification, or invariant violation.
|
|
60
|
+
- **422 Unprocessable Entity**: Semantically invalid payload (schema valid, but business validation failed).
|
|
61
|
+
- **429 Too Many Requests**: Rate limit exceeded; MUST include `Retry-After` header.
|
|
62
|
+
- **500 Internal Server Error**: Unexpected unhandled failure; NEVER expose stack traces or DB credentials.
|
|
63
|
+
- **502 Bad Gateway / 503 Service Unavailable**: Downstream dependency failure or maintenance mode.
|
|
64
|
+
|
|
65
|
+
> [!CAUTION]
|
|
66
|
+
> **Zero Tolerance for "200 OK Errors"**: NEVER return HTTP 200 with `{ "status": "error", "message": "..." }`. The HTTP status code is the protocol-level source of truth.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 3. Standard Response Envelopes & Error Contracts
|
|
71
|
+
|
|
72
|
+
### 📦 Success Responses
|
|
73
|
+
```typescript
|
|
74
|
+
// Single Resource Response:
|
|
75
|
+
interface ItemResponse<T> {
|
|
76
|
+
data: T;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Collection Response:
|
|
80
|
+
interface CollectionResponse<T> {
|
|
81
|
+
data: T[];
|
|
82
|
+
meta: {
|
|
83
|
+
total?: number; // Omitted for infinite scroll cursor queries
|
|
84
|
+
has_more: boolean;
|
|
85
|
+
next_cursor?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 🚨 Standardized Error Envelopes
|
|
91
|
+
|
|
92
|
+
Choose one consistent error representation across the API:
|
|
93
|
+
|
|
94
|
+
#### Option A: Stripe-Style Error Envelope (Recommended for Developer-Facing Web APIs)
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"error": {
|
|
98
|
+
"code": "validation_failed",
|
|
99
|
+
"message": "The request payload failed field validation",
|
|
100
|
+
"details": [
|
|
101
|
+
{
|
|
102
|
+
"field": "email",
|
|
103
|
+
"code": "invalid_format",
|
|
104
|
+
"message": "Must be a valid RFC 5322 email address"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"field": "amount_cents",
|
|
108
|
+
"code": "out_of_bounds",
|
|
109
|
+
"message": "Amount must be greater than 0"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"request_id": "req_01h8xyz789"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### Option B: RFC 7807 Problem Details (`application/problem+json`)
|
|
118
|
+
IETF standard format specifying machine-readable problem details for HTTP APIs:
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"type": "https://api.example.com/errors/validation-failed",
|
|
122
|
+
"title": "Validation Failed",
|
|
123
|
+
"status": 422,
|
|
124
|
+
"detail": "The request payload failed validation on 2 fields",
|
|
125
|
+
"instance": "/api/v1/payment-intents",
|
|
126
|
+
"invalid_params": [
|
|
127
|
+
{
|
|
128
|
+
"name": "email",
|
|
129
|
+
"reason": "Must be a valid RFC 5322 email address"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "amount_cents",
|
|
133
|
+
"reason": "Amount must be greater than 0"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 4. Pagination Strategies
|
|
142
|
+
|
|
143
|
+
### 1. Cursor-Based Pagination (Recommended for High Volume / Real-Time Data)
|
|
144
|
+
- **Request**: `GET /api/v1/events?limit=25&starting_after=evt_123` (or `cursor=eyJpZCI6MTIzfQ`)
|
|
145
|
+
- **Response**:
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"data": [ ... ],
|
|
149
|
+
"meta": {
|
|
150
|
+
"has_more": true,
|
|
151
|
+
"next_cursor": "evt_148"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
- **Advantages**: Stable under concurrent inserts/deletes, consistent performance (O(1) indexed lookup), no duplicate records.
|
|
156
|
+
|
|
157
|
+
### 2. Offset-Based Pagination (Acceptable for Internal Admin Tables)
|
|
158
|
+
- **Request**: `GET /api/v1/users?page=2&per_page=50`
|
|
159
|
+
- **Response**:
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"data": [ ... ],
|
|
163
|
+
"meta": {
|
|
164
|
+
"total": 450,
|
|
165
|
+
"page": 2,
|
|
166
|
+
"per_page": 50,
|
|
167
|
+
"total_pages": 9
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 5. Filtering, Sorting, and Field Projections
|
|
175
|
+
|
|
176
|
+
- **Filtering**: Use explicit query parameters:
|
|
177
|
+
`GET /api/v1/orders?status=shipped&created_after=2026-01-01T00:00:00Z`
|
|
178
|
+
- **Sorting**: Multi-field comma-separated sorting with `-` prefix for descending order:
|
|
179
|
+
`GET /api/v1/products?sort=-price,created_at`
|
|
180
|
+
- **Sparse Fieldsets / Projections**:
|
|
181
|
+
`GET /api/v1/users?fields=id,name,email`
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 6. Reliability & Production Hardening
|
|
186
|
+
|
|
187
|
+
### 🔒 Idempotency Keys (Stripe Pattern)
|
|
188
|
+
For mutating operations (financial transactions, webhook dispatches, state transitions):
|
|
189
|
+
- Client sends header: `Idempotency-Key: <unique-uuid>`.
|
|
190
|
+
- Server checks distributed cache (Redis / DB) with 24h TTL.
|
|
191
|
+
- If request is currently processing: return `409 Conflict` or wait.
|
|
192
|
+
- If already completed: replay cached response code and body with `Idempotent-Replay: true`.
|
|
193
|
+
|
|
194
|
+
### ⏱️ Rate Limiting Headers
|
|
195
|
+
Every API response should supply rate-limiting telemetry:
|
|
196
|
+
- `X-RateLimit-Limit`: Maximum requests permitted per window.
|
|
197
|
+
- `X-RateLimit-Remaining`: Remaining request quota.
|
|
198
|
+
- `X-RateLimit-Reset`: UTC epoch timestamp when current window resets.
|
|
199
|
+
- `Retry-After`: Seconds to wait before retrying (on `429 Too Many Requests`).
|
|
200
|
+
|
|
201
|
+
### 📦 Upstream Service Invariants
|
|
202
|
+
- **Connection pooling & singleton clients**: Never re-create API client instances per request.
|
|
203
|
+
- **Timeout budgets**: Hard timeouts on all outbound calls (e.g., 3000ms connect, 5000ms read).
|
|
204
|
+
- **Graceful degradation**: Fall back to stale cache or return candidate list on ambiguous inputs; never crash the caller.
|
|
@@ -37,8 +37,9 @@ asdlc archive <CHANGE_ID>
|
|
|
37
37
|
|
|
38
38
|
The CLI:
|
|
39
39
|
1. Moves `openspec/changes/<SLUG>/` into `openspec/changes/archive/<SLUG>/`.
|
|
40
|
-
2.
|
|
41
|
-
3.
|
|
40
|
+
2. Syncs living specs into `openspec/specs/` and records the capability in `README.md`.
|
|
41
|
+
3. Rebuilds the AST knowledge graph (`graphify-out/`) against the new HEAD commit.
|
|
42
|
+
4. Creates `AGENTS.md` (if missing) and regenerates its `system-status` block with newly calculated architectural hubs and god nodes.
|
|
42
43
|
|
|
43
44
|
### Step 4: Confirm Archive Completion
|
|
44
45
|
Summarize the result to the user:
|