universal-dev-standards 5.7.3 → 5.8.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.
@@ -0,0 +1,239 @@
1
+ # Behavior Snapshot Standard
2
+
3
+ > **Language**: English | 繁體中文
4
+
5
+ **Applicability**: Migration and refactoring projects requiring behavioral parity verification
6
+ **Scope**: universal (HTTP-based systems)
7
+
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ The Behavior Snapshot Standard defines a golden-file format for recording HTTP request/response pairs from an existing system. These snapshots serve two purposes:
13
+
14
+ 1. **Migration parity baseline** — verify the new system reproduces the same behavior as the old system
15
+ 2. **Refactoring characterization** — lock existing behavior before changing code (Gate 0 protocol)
16
+
17
+ ## References
18
+
19
+ | Standard/Source | Content |
20
+ |----------------|---------|
21
+ | XSPEC-201 | Refactor/Migration Completeness Protocol |
22
+ | Michael Feathers: *Working Effectively with Legacy Code* | Characterization test concept |
23
+ | Golden Master Testing | Pattern for recording and replaying expected outputs |
24
+
25
+ ---
26
+
27
+ ## Snapshot File Format
28
+
29
+ ### Location
30
+
31
+ ```
32
+ .snapshots/<feature-id>/<scenario>.json
33
+ ```
34
+
35
+ ### Schema
36
+
37
+ ```json
38
+ {
39
+ "feature_id": "FM-007",
40
+ "scenario": "happy_path",
41
+ "request": {
42
+ "method": "POST",
43
+ "path": "/api/orders/123/cancel",
44
+ "headers": {
45
+ "Content-Type": "application/json"
46
+ },
47
+ "body": {
48
+ "reason": "customer_request"
49
+ }
50
+ },
51
+ "response": {
52
+ "status": 200,
53
+ "body": {
54
+ "success": true,
55
+ "order_status": "cancelled",
56
+ "refund_initiated": true
57
+ }
58
+ },
59
+ "ignore_fields": ["refund_id", "cancelled_at"]
60
+ }
61
+ ```
62
+
63
+ ### Field Reference
64
+
65
+ | Field | Required | Description |
66
+ |-------|----------|-------------|
67
+ | `feature_id` | Yes | `FM-NNN` from feature-manifest.yaml |
68
+ | `scenario` | Yes | `snake_case` scenario name (`happy_path`, `not_found`, etc.) |
69
+ | `request.method` | Yes | HTTP method |
70
+ | `request.path` | Yes | URL path without base URL |
71
+ | `request.headers` | No | Headers needed for the request (no real auth tokens) |
72
+ | `request.body` | No | Request body (JSON) |
73
+ | `response.status` | Yes | Expected HTTP status code |
74
+ | `response.body` | Yes | Expected response body (fields to compare) |
75
+ | `ignore_fields` | No | Fields to skip during comparison (see guidance below) |
76
+
77
+ ---
78
+
79
+ ## Directory Structure
80
+
81
+ ```
82
+ .snapshots/
83
+ FM-001-UserLogin/
84
+ happy_path.json
85
+ invalid_credentials.json
86
+ account_locked.json
87
+ FM-007-OrderCancellation/
88
+ happy_path.json
89
+ order_not_found.json
90
+ order_already_cancelled.json
91
+ MANUAL-refund_webhook.json ← manually authored
92
+ ```
93
+
94
+ ### MANUAL- Prefix
95
+
96
+ Files prefixed `MANUAL-` contain snapshots that cannot be automatically recorded:
97
+ - Webhook endpoints triggered by third parties
98
+ - Scenarios requiring specific, hard-to-reproduce database state
99
+ - Background job / queue-triggered flows (non-HTTP entry points)
100
+
101
+ `MANUAL-` files are excluded from automated replay but are counted in coverage reporting.
102
+
103
+ ---
104
+
105
+ ## `ignore_fields` Guidance
106
+
107
+ ### Always Ignore (Non-Deterministic)
108
+
109
+ | Field Pattern | Reason |
110
+ |--------------|--------|
111
+ | `created_at`, `updated_at`, `timestamp` | Changes every request |
112
+ | `token`, `session_id`, `csrf_token` | Cryptographically random |
113
+ | `request_id`, `trace_id`, `correlation_id` | Random UUID |
114
+
115
+ ### Always Compare (Business Logic)
116
+
117
+ | Field Pattern | Reason |
118
+ |--------------|--------|
119
+ | `status`, `code`, `message`, `error_code` | Core business outcome |
120
+ | `order_status`, `payment_status` | State machine result |
121
+ | `amount`, `quantity`, `price` | Calculated business value |
122
+ | `success`, `refunded`, `cancelled` | Boolean business outcome |
123
+ | `user_id`, `order_id` (with fixed test data) | Referential integrity |
124
+
125
+ **Rule**: `ignore_fields` is for legitimately non-deterministic values. Using it to hide business logic differences defeats the purpose of parity testing.
126
+
127
+ ---
128
+
129
+ ## Parity Check Tool
130
+
131
+ Run `scripts/parity-check.ts` to replay all snapshots against a target system:
132
+
133
+ ```bash
134
+ npx tsx scripts/parity-check.ts --url http://new-system:8080 [--snapshots .snapshots] [--env uat|staging]
135
+ ```
136
+
137
+ ### Output
138
+
139
+ ```
140
+ 🔄 Parity Check — 119 snapshots against http://new-system:8080
141
+
142
+ ✅ FM-001 / happy_path
143
+ ✅ FM-001 / invalid_credentials
144
+ ❌ [PARITY-FAIL] FM-007 / happy_path
145
+ body.order_status: expected "cancelled", got "pending"
146
+ body.refund_initiated: expected true, got false
147
+
148
+ ─────────────────────────────────
149
+ Parity Results: 118/119 passed (99.2%)
150
+
151
+ ❌ 1 parity check(s) failed.
152
+ [PARITY-BLOCK] UAT/production deployment blocked. Fix parity failures first.
153
+ ```
154
+
155
+ ### Exit Codes
156
+
157
+ | Code | Meaning |
158
+ |------|---------|
159
+ | 0 | All snapshots pass |
160
+ | 1 | Failures found + `--env uat` or `production` → deployment blocked |
161
+ | 2 | Failures found + `--env staging` → warning only |
162
+
163
+ ---
164
+
165
+ ## Gate 0: Characterization Test Protocol (Refactoring)
166
+
167
+ Before starting any refactoring, characterization tests must exist and pass.
168
+
169
+ ### What Are Characterization Tests?
170
+
171
+ Characterization tests record what the existing code *actually does* — not what it *should* do. They lock observable behavior before changes begin. If a characterization test fails during refactoring, it signals unintended behavior change.
172
+
173
+ ```typescript
174
+ describe('characterization: OrderService.cancelOrder', () => {
175
+ // @characterization
176
+ it('returns status cancelled and sets refund_initiated=true for valid order', async () => {
177
+ const result = await orderService.cancelOrder('test-order-123', 'customer_request');
178
+ expect(result.order_status).toBe('cancelled');
179
+ expect(result.refund_initiated).toBe(true);
180
+ });
181
+ });
182
+ ```
183
+
184
+ ### Gate 0 Enforcement
185
+
186
+ 1. **Before first refactoring commit**: Run `npm test -- --grep characterization`
187
+ - Any failure → STOP. Fix the existing code before changing it.
188
+ 2. **During refactoring**: Every commit re-runs characterization tests
189
+ - Any failure → immediate warning of behavior drift
190
+ 3. **Gate 2 (completion)**: All characterization tests pass → refactoring complete
191
+
192
+ ### Anti-Pattern Warning
193
+
194
+ > Never start refactoring without Gate 0. Once you start changing code, it becomes impossible to tell whether a test failure is "I broke something" or "the test was wrong about old behavior."
195
+
196
+ ---
197
+
198
+ ## Integration with Migration Pipeline
199
+
200
+ ### Gate 1 Pre-Flight (`--variant migration`)
201
+
202
+ Before `/vo-pipeline --variant migration`:
203
+ 1. `artifacts/feature-manifest.yaml` must exist
204
+ 2. `.snapshots/` must contain at least one snapshot per feature
205
+
206
+ ### Parity Gate (Before UAT)
207
+
208
+ After all features are implemented, run parity check:
209
+ - 100% pass rate required (excluding `MANUAL-` files)
210
+ - Any failure blocks UAT promotion
211
+
212
+ ---
213
+
214
+ ## Anti-Patterns
215
+
216
+ | Anti-Pattern | Impact | Correct Approach |
217
+ |--------------|--------|------------------|
218
+ | Overusing `ignore_fields` | Business logic differences hidden | Only ignore non-deterministic fields |
219
+ | Skipping MANUAL snapshots | Untested webhook/background behavior | Author MANUAL snapshots before UAT |
220
+ | Recording snapshots from broken system | Wrong baseline | Verify old system behavior before recording |
221
+ | Characterization tests without `@characterization` | Gate 0 can't find them | Always annotate with `@characterization` |
222
+ | Starting refactoring before Gate 0 | Behavior drift undetectable | Run characterization tests first, always |
223
+
224
+ ---
225
+
226
+ ## Related Standards
227
+
228
+ - [Feature Manifest Standard](feature-manifest-standard.md) — FM-NNN schema for manifest features
229
+ - [Acceptance Criteria Traceability](acceptance-criteria-traceability.md) — `not_implemented` AC status
230
+ - [Refactoring Standards](refactoring-standards.md) — Characterization test requirements
231
+ - [Testing Standards](testing-standards.md) — Test implementation standards
232
+
233
+ ---
234
+
235
+ ## Version History
236
+
237
+ | Version | Date | Changes |
238
+ |---------|------|---------|
239
+ | 1.0.0 | 2026-05-12 | Initial version — snapshot schema, parity gate, Gate 0 characterization protocol (XSPEC-201) |
@@ -0,0 +1,213 @@
1
+ # Feature Manifest Standard
2
+
3
+ > **Language**: English | 繁體中文
4
+
5
+ **Applicability**: Migration and refactoring projects where an existing system is being ported or restructured
6
+ **Scope**: universal (language-agnostic manifest format)
7
+
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ The Feature Manifest Standard defines a machine-readable format (`feature-manifest.yaml`) for cataloguing all features of an existing system before migration or refactoring begins. It provides a structured bridge between the legacy system's capabilities and the new system's acceptance criteria, enabling tools (VibeOps `/vo-pipeline --variant migration`) to enforce completeness gates automatically.
13
+
14
+ ## References
15
+
16
+ | Standard/Source | Content |
17
+ |----------------|---------|
18
+ | XSPEC-200 | Migration Feature Inventory and Completeness Gate |
19
+ | XSPEC-201 | Refactor/Migration Completeness Protocol |
20
+ | XSPEC-199 | AC `not_implemented` status extension |
21
+
22
+ ---
23
+
24
+ ## When to Use
25
+
26
+ Use `feature-manifest.yaml` when:
27
+ - Migrating a system from one language/framework to another (e.g., PHP → C# .NET)
28
+ - Porting a legacy system to a new architecture
29
+ - Starting a major refactoring where existing behavior must be preserved
30
+
31
+ **Do not use** for greenfield development — the manifest is a reflection of an existing system, not a design document.
32
+
33
+ ---
34
+
35
+ ## Feature Manifest Format
36
+
37
+ ### File Location
38
+
39
+ ```
40
+ artifacts/feature-manifest.yaml
41
+ ```
42
+
43
+ ### Top-Level Structure
44
+
45
+ ```yaml
46
+ manifest_version: "1.0"
47
+ source_system:
48
+ language: php
49
+ framework: laravel
50
+ scan_date: "2026-05-12"
51
+ scan_coverage: "47/47 routes (100%)"
52
+
53
+ features:
54
+ - id: FM-001
55
+ name: UserLogin
56
+ # ... (see Feature Entry below)
57
+ ```
58
+
59
+ ### Feature Entry Schema
60
+
61
+ | Field | Type | Required | Description |
62
+ |-------|------|----------|-------------|
63
+ | `id` | string | Yes | `FM-NNN` (zero-padded) |
64
+ | `name` | string | Yes | PascalCase business feature name |
65
+ | `description` | string | Yes | Plain language description of business purpose |
66
+ | `http_method` | string | No | `GET`, `POST`, `PUT`, `PATCH`, `DELETE`; `null` for CLI/background |
67
+ | `route` | string | No | URL path; `null` for CLI/background |
68
+ | `controller` | string | Yes | `ClassName::methodName` |
69
+ | `confidence` | float | Yes | 0.0–1.0 (see Confidence Scoring) |
70
+ | `side_effects` | list | Yes | `DB_READ`, `DB_WRITE`, `EMAIL`, `QUEUE`, `HTTP_CALL`, `FILE` |
71
+ | `migration_risks` | list | No | Risk labels (see Migration Risks) |
72
+ | `ac_id` | string | No | `null` initially; set by Planner after manifest creation |
73
+ | `status` | string | Yes | Always `not_implemented` initially |
74
+
75
+ ### Complete Feature Entry Example
76
+
77
+ ```yaml
78
+ features:
79
+ - id: FM-007
80
+ name: OrderCancellation
81
+ description: 取消訂單並觸發退款流程
82
+ http_method: POST
83
+ route: /api/orders/{id}/cancel
84
+ controller: OrderController::cancel
85
+ confidence: 0.9
86
+ side_effects:
87
+ - DB_WRITE
88
+ - QUEUE
89
+ migration_risks:
90
+ - ORM_DIFFERENCES
91
+ ac_id: null
92
+ status: not_implemented
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Confidence Scoring
98
+
99
+ | Value | Meaning | Action |
100
+ |-------|---------|--------|
101
+ | 1.0 | Feature name and business purpose are unambiguous | Proceed to AC generation |
102
+ | 0.8 | Feature name is reasonable, purpose requires inference | Proceed with note |
103
+ | 0.5 | Likely infrastructure/utility, not primary business feature | Flag for human review |
104
+ | 0.3 | Unclear — cannot determine business purpose | **Halt; human must confirm** |
105
+
106
+ **Rule**: All features with `confidence < 0.5` must be reviewed by a human before Planner generates AC.
107
+
108
+ ---
109
+
110
+ ## Migration Risks
111
+
112
+ ### PHP → C# .NET
113
+
114
+ | Label | Description |
115
+ |-------|-------------|
116
+ | `SESSION_HANDLING` | PHP `$_SESSION` → ASP.NET Core Session/Cookie middleware |
117
+ | `ORM_DIFFERENCES` | Eloquent ORM vs Entity Framework behavioral differences |
118
+ | `TIMEZONE_HANDLING` | PHP timezone functions → .NET `DateTimeOffset` |
119
+ | `FILE_UPLOAD_PATH` | PHP `$_FILES` → ASP.NET Core `IFormFile` |
120
+ | `REGEX_DIFFERENCES` | PHP PCRE syntax vs .NET `System.Text.RegularExpressions` |
121
+ | `ARRAY_FUNCTIONS` | PHP `array_*` functions → LINQ equivalents |
122
+ | `EXCEPTION_HIERARCHY` | PHP exception hierarchy vs .NET exception hierarchy |
123
+
124
+ ### Generic
125
+
126
+ | Label | Description |
127
+ |-------|-------------|
128
+ | `ASYNC_MODEL` | Sync code → async/await migration |
129
+ | `NULL_SEMANTICS` | Null handling differences |
130
+ | `STRING_ENCODING` | String encoding/collation differences |
131
+
132
+ ---
133
+
134
+ ## FEATURE_STUB Marker Protocol
135
+
136
+ When implementing features from the manifest in the target codebase, use `FEATURE_STUB:` markers as placeholders:
137
+
138
+ ### Format
139
+
140
+ ```
141
+ // FEATURE_STUB: <FM-ID> <FeatureName> — <AC-ID> pending
142
+ ```
143
+
144
+ ### Example (C#)
145
+
146
+ ```csharp
147
+ // FEATURE_STUB: FM-007 OrderCancellation — AC-007 pending
148
+ public async Task<Result<OrderDto>> CancelOrderAsync(string orderId, CancellationReason reason)
149
+ {
150
+ throw new NotImplementedException();
151
+ }
152
+ ```
153
+
154
+ ### FEATURE_STUB vs WARNING:STUB
155
+
156
+ | Marker | Semantic | When to Use |
157
+ |--------|----------|-------------|
158
+ | `// WARNING: STUB` | Temporary fake logic (code runs but behavior is wrong) | Placeholder with incorrect business logic |
159
+ | `// FEATURE_STUB:` | Feature not yet implemented (no logic at all) | Feature from manifest that hasn't been coded yet |
160
+
161
+ **Both markers block CI** (main branch push and UAT/production deployment).
162
+
163
+ ### Lifecycle
164
+
165
+ 1. Feature added to manifest with `status: not_implemented`
166
+ 2. Developer adds `FEATURE_STUB:` placeholder in target code
167
+ 3. Developer implements the feature, removes `FEATURE_STUB:` marker
168
+ 4. Update manifest `status` → `implemented`
169
+ 5. Update AC traceability `status` → `uncovered` or `covered`
170
+
171
+ ---
172
+
173
+ ## Completeness Gates
174
+
175
+ ### Gate 1 (Pre-Pipeline)
176
+
177
+ Before `/vo-pipeline --variant migration` starts:
178
+ - `artifacts/feature-manifest.yaml` must exist
179
+ - `.snapshots/` directory must exist with at least one JSON file
180
+
181
+ ### Feature Completeness Gate (Pre-UAT)
182
+
183
+ CI blocks UAT deployment if:
184
+ - Any feature in manifest has `status: not_implemented` AND
185
+ - Corresponding `FEATURE_STUB:` exists in codebase
186
+
187
+ ---
188
+
189
+ ## Anti-Patterns
190
+
191
+ | Anti-Pattern | Impact | Correct Approach |
192
+ |--------------|--------|------------------|
193
+ | Starting migration without manifest | Feature gaps discovered in UAT | Always generate manifest first |
194
+ | Skipping low-confidence features | Silent functional omissions | Review and confirm all features |
195
+ | Using `uncovered` instead of `not_implemented` | CI doesn't block on missing features | Use `not_implemented` when code doesn't exist |
196
+ | Not removing `FEATURE_STUB:` after implementation | False "incomplete" signal in CI | Always clean up markers after implementation |
197
+
198
+ ---
199
+
200
+ ## Related Standards
201
+
202
+ - [Acceptance Criteria Traceability](acceptance-criteria-traceability.md) — `not_implemented` AC status
203
+ - [Behavior Snapshot Standard](behavior-snapshot.md) — HTTP parity baseline recording
204
+ - [Refactoring Standards](refactoring-standards.md) — Characterization tests for refactoring
205
+ - [Spec-Driven Development](spec-driven-development.md) — AC generation workflow
206
+
207
+ ---
208
+
209
+ ## Version History
210
+
211
+ | Version | Date | Changes |
212
+ |---------|------|---------|
213
+ | 1.0.0 | 2026-05-12 | Initial version — FM-NNN schema, confidence scoring, FEATURE_STUB protocol (XSPEC-200) |
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  source: ../../CHANGELOG.md
3
- source_version: 5.7.3
4
- translation_version: 5.7.3
5
- last_synced: 2026-05-08
3
+ source_version: 5.8.0
4
+ translation_version: 5.8.0
5
+ last_synced: 2026-05-12
6
6
  status: current
7
7
  ---
8
8
 
@@ -17,6 +17,15 @@ status: current
17
17
 
18
18
  ## [Unreleased]
19
19
 
20
+ ## [5.8.0] - 2026-05-12
21
+
22
+ ### 新增
23
+ - **`feature-manifest-standard`**(`ai/standards/feature-manifest-standard.ai.yaml`、`core/feature-manifest-standard.md`):新增标准,定义迁移/重构项目的 FM-NNN 机器可读功能清单格式。含信心评分、迁移风险标签(PHP→C#)、`FEATURE_STUB:` 标记协议与 Gate 1 完整性闸门。(XSPEC-200)
24
+ - **`behavior-snapshot`**(`ai/standards/behavior-snapshot.ai.yaml`、`core/behavior-snapshot.md`):新增标准,定义 HTTP 金文件快照格式,用于迁移等价性验证与重构特征化测试。含快照结构、`ignore_fields` 指引、parity gate exit codes 与 Gate 0 特征化测试协议。(XSPEC-201)
25
+
26
+ ### 变更
27
+ - **`acceptance-criteria-traceability`**:新增第 4 个 AC 状态 `not_implemented`(🚫)——区分「代码不存在」与 `uncovered`(代码存在但无测试)。更新覆盖率公式(分母排除 `not_implemented`)。新增 CI blocking gate:`not_implemented_count > 0` → blocking(独立于覆盖率 % gate)。新增状态分类决策树。(XSPEC-199)
28
+
20
29
  ## [5.7.3] - 2026-05-08
21
30
 
22
31
  ### 修复
@@ -14,7 +14,7 @@ status: current
14
14
 
15
15
  > **语言**: [English](../../README.md) | [繁體中文](../zh-TW/README.md) | 简体中文
16
16
 
17
- **版本**: 5.7.3 | **发布日期**: 2026-04-13 | **授权**: [双重授权](../../LICENSE) (CC BY 4.0 + MIT)
17
+ **版本**: 5.8.0 | **发布日期**: 2026-04-13 | **授权**: [双重授权](../../LICENSE) (CC BY 4.0 + MIT)
18
18
 
19
19
  语言无关、框架无关的软件项目文档标准。通过 AI 原生工作流,确保不同技术栈之间的一致性、质量和可维护性。
20
20
 
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  source: ../../CHANGELOG.md
3
- source_version: 5.7.3
4
- translation_version: 5.7.3
5
- last_synced: 2026-05-08
3
+ source_version: 5.8.0
4
+ translation_version: 5.8.0
5
+ last_synced: 2026-05-12
6
6
  status: current
7
7
  ---
8
8
 
@@ -17,6 +17,15 @@ status: current
17
17
 
18
18
  ## [Unreleased]
19
19
 
20
+ ## [5.8.0] - 2026-05-12
21
+
22
+ ### 新增
23
+ - **`feature-manifest-standard`**(`ai/standards/feature-manifest-standard.ai.yaml`、`core/feature-manifest-standard.md`):新增標準,定義移植/重構專案的 FM-NNN 機器可讀功能盤點格式。含信心評分、移植風險標籤(PHP→C#)、`FEATURE_STUB:` 標記協議與 Gate 1 完整性閘門。(XSPEC-200)
24
+ - **`behavior-snapshot`**(`ai/standards/behavior-snapshot.ai.yaml`、`core/behavior-snapshot.md`):新增標準,定義 HTTP 金文件快照格式,用於移植同等性驗證與重構特徵化測試。含快照結構、`ignore_fields` 指引、parity gate exit codes 與 Gate 0 特徵化測試協議。(XSPEC-201)
25
+
26
+ ### 修改
27
+ - **`acceptance-criteria-traceability`**:新增第 4 個 AC 狀態 `not_implemented`(🚫)——區分「程式碼不存在」與 `uncovered`(程式碼存在但無測試)。更新覆蓋率公式(分母排除 `not_implemented`)。新增 CI blocking gate:`not_implemented_count > 0` → blocking(獨立於覆蓋率 % gate)。新增狀態分類決策樹。(XSPEC-199)
28
+
20
29
  ## [5.7.3] - 2026-05-08
21
30
 
22
31
  ### 修復
@@ -14,7 +14,7 @@ status: current
14
14
 
15
15
  > **語言**: [English](../../README.md) | 繁體中文 | [简体中文](../zh-CN/README.md)
16
16
 
17
- **版本**: 5.7.3 | **發布日期**: 2026-04-13 | **授權**: [雙重授權](../../LICENSE) (CC BY 4.0 + MIT)
17
+ **版本**: 5.8.0 | **發布日期**: 2026-04-13 | **授權**: [雙重授權](../../LICENSE) (CC BY 4.0 + MIT)
18
18
 
19
19
  語言無關、框架無關的軟體專案文件標準。透過 AI 原生工作流,確保不同技術堆疊之間的一致性、品質和可維護性。
20
20