Spec Thành SVG Flow Map
Mục Đích
Chuyển spec thành bộ artifact flow map SVG có thể đọc được bởi người và tool/code.
Skill này không tạo sơ đồ trang trí. Skill này tạo bản đồ ngữ nghĩa để phơi bày:
- luồng người dùng và UI
- luồng dữ liệu, state, storage, source-of-truth
- luồng auth, session, thiết bị, quyền, ranh giới bảo mật
- luồng sync, mạng, lifecycle, reconnect, recovery
- contract backend, API, hệ thống ngoài
- lỗi, recovery, background job, runtime command
- decision, branch, handoff pipeline, terminal state, out-of-scope reference
- gap spec, undefined behavior, owner decision, missing data, bottleneck, risk
- legend giải thích ở cuối SVG
Mục tiêu là vẽ đúng SPEC đang mô tả, không vẽ hệ thống mà agent nghĩ là đúng.
Đọc Tài Liệu Tham Chiếu Bắt Buộc
Trước khi vẽ bất kỳ logic triển khai SVG nào, đọc các file reference theo thứ tự:
references/source-fidelity.md
references/source-inventory-and-manifest.md
references/rendering-rules.md
references/svg-contract.md
references/verification-and-acceptance.md
Đọc thêm references/domain-detail-checklist.md khi scope có auth, session, scope, runtime command, business flow, sync, snapshot, report, print, lifecycle, settings, backend/API, hoặc contract ngoài.
Nếu reference bắt buộc không đọc được, dừng lại và báo BLOCKED.
Quy Tắc Cứng
- Không implement app/source code.
- Không sửa production source file.
- Không đoán hành vi thiếu.
- Không che giấu ambiguity.
- Không đặt logic quan trọng chỉ trong geometry hoặc vị trí visual.
- Mọi quan hệ flow quan trọng phải có text visible và XML metadata.
- Mọi decision node phải có đủ outgoing branches.
- Mọi edge phải có condition rõ ràng, dùng
condition="always" cho unconditional flow.
- Mọi pipeline handoff phải đi qua junction node thật.
- Mọi terminal state phải có node riêng.
- Mọi ambiguity chưa giải quyết phải thành gap node visible.
- Phải build source-union inventory trước khi vẽ logic triển khai.
- Phải build source-described flow manifest trước khi vẽ logic triển khai.
- Phải render logic triển khai từng flow, không render từ một bulk summary pass.
- Không collapse detail có tên thành generic node.
- Không improve, repair, normalize, hoặc tự nối flow vượt quá điều source thật sự nói.
- Nếu không thể hoàn thành map một cách an toàn, dừng lại và nói rõ lý do.
Nếu map có node unresolved với type SPEC_GAP, UNDEFINED_BEHAVIOR, hoặc OWNER_DECISION_REQUIRED, đặt implementation status là BLOCKED.
Nếu missing_source_items không rỗng, đặt implementation status là BLOCKED.
Đầu Vào Bắt Buộc
Đọc authority có sẵn cho spec slice được yêu cầu:
- Source spec.
- Related authority docs.
- Existing/reference SVGs và flow maps, nếu có.
- Existing verification reports, nếu có.
- UI prototype hoặc UI slot map, nếu có.
- State/source map, nếu có.
- Backend/API/contract map, nếu có.
- Actual wiring status, nếu có.
- Project rules.
Nếu input bắt buộc bị thiếu, không bịa hành vi. Đánh dấu nó là gap trong SVG và verification report.
Đầu Ra Bắt Buộc
Tạo hoặc cập nhật các file:
docs/flow-maps/<feature-name>.flow.svg
docs/flow-maps/<feature-name>.flow-map.md
docs/flow-maps/<feature-name>.flow-verification.md
Dùng lowercase kebab-case cho <feature-name> trừ khi project có quy tắc tên chặt hơn.
Quy Trình Bắt Buộc
- Đọc project rules và requested scope.
- Đọc source spec và related authority docs.
- Đọc existing/reference SVGs, flow maps, verification reports, UI maps, state maps, API maps, và contract maps khi có.
- Build source union inventory theo
references/source-inventory-and-manifest.md.
- Build source-described flow manifest từ inventory item được source mô tả trực tiếp.
- Tạo global lane/layout plan. Chưa vẽ logic triển khai.
- Với từng flow trong manifest, lặp:
đọc lại source sections liên quan
extract flow-local inventory
xác nhận flow đã có trong source-described flow manifest
vẽ chỉ flow đó
ghi visible nodes/edges/junctions/terminals/gaps
ghi metadata tương ứng
verify source coverage cho flow đó
mark mapped source inventory items
mark manifest item bằng mapped SVG ids hoặc gap ids
- Sau khi vẽ tất cả flow, chạy global consistency verification.
- Check missing source items.
- Check flow manifest omissions và unmanifested visible flows.
- Check collapse violations.
- Check reference SVG delta.
- Parse SVG như XML.
- Verify metadata/visible node round-trip.
- Thêm visible legend ở cuối SVG, là visible group cuối cùng trước
</svg>, và id phải khớp metadata.legend.visible_legend_id.
- Đặt implementation status.
Trạng Thái Kết Thúc
Đặt:
BLOCKED
khi còn unresolved gaps, undefined behavior, owner decisions, missing source items, collapse violations, hoặc failed reference deltas.
Đặt:
READY_FOR_OWNER_REVIEW
chỉ khi không còn blocker về SPEC_GAP, UNDEFINED_BEHAVIOR, OWNER_DECISION_REQUIRED, source coverage, collapse, hoặc reference delta.
Chỉ Owner mới được approve implementation sau khi review generated flow map.
Định Dạng Bàn Giao Cuối
Trả về đúng format:
# Bàn Giao Spec Flow Map
## File Đã Tạo / Cập Nhật
- docs/flow-maps/<feature-name>.flow.svg
- docs/flow-maps/<feature-name>.flow-map.md
- docs/flow-maps/<feature-name>.flow-verification.md
## Trạng Thái
BLOCKED or READY_FOR_OWNER_REVIEW
## Phát Hiện Chính
1.
2.
3.
## Hành Động Owner Cần Làm
- If BLOCKED: liệt kê chính xác spec sections, source inventory items, reference deltas, hoặc collapse violations cần làm rõ.
- If READY_FOR_OWNER_REVIEW: yêu cầu Owner review và approve SVG flow map trước implementation.
1---2name: spec-to-svg-flow-map3description: Chuyển spec sản phẩm, tính năng, UI, backend, auth, sync, lifecycle, external contract, hoặc spec đa nhánh thành SVG flow map ngữ nghĩa có metadata máy đọc được, source coverage, render từng flow, gap detection, verification report, và trạng thái BLOCKED hoặc READY_FOR_OWNER_REVIEW. Dùng khi cần biến spec thành flow map, audit độ đầy đủ của spec trước khi code, so sánh với diagram tham chiếu, phơi bày hành vi chưa định nghĩa, hoặc xác định quyết định Owner trước implementation.4---56# Spec Thành SVG Flow Map78## Mục Đích910Chuyển spec thành bộ artifact flow map SVG có thể đọc được bởi người và tool/code.1112Skill này không tạo sơ đồ trang trí. Skill này tạo bản đồ ngữ nghĩa để phơi bày:1314- luồng người dùng và UI15- luồng dữ liệu, state, storage, source-of-truth16- luồng auth, session, thiết bị, quyền, ranh giới bảo mật17- luồng sync, mạng, lifecycle, reconnect, recovery18- contract backend, API, hệ thống ngoài19- lỗi, recovery, background job, runtime command20- decision, branch, handoff pipeline, terminal state, out-of-scope reference21- gap spec, undefined behavior, owner decision, missing data, bottleneck, risk22- legend giải thích ở cuối SVG2324Mục tiêu là vẽ đúng SPEC đang mô tả, không vẽ hệ thống mà agent nghĩ là đúng.2526## Đọc Tài Liệu Tham Chiếu Bắt Buộc2728Trước khi vẽ bất kỳ logic triển khai SVG nào, đọc các file reference theo thứ tự:29301. `references/source-fidelity.md`312. `references/source-inventory-and-manifest.md`323. `references/rendering-rules.md`334. `references/svg-contract.md`345. `references/verification-and-acceptance.md`3536Đọc thêm `references/domain-detail-checklist.md` khi scope có auth, session, scope, runtime command, business flow, sync, snapshot, report, print, lifecycle, settings, backend/API, hoặc contract ngoài.3738Nếu reference bắt buộc không đọc được, dừng lại và báo `BLOCKED`.3940## Quy Tắc Cứng41421. Không implement app/source code.432. Không sửa production source file.443. Không đoán hành vi thiếu.454. Không che giấu ambiguity.465. Không đặt logic quan trọng chỉ trong geometry hoặc vị trí visual.476. Mọi quan hệ flow quan trọng phải có text visible và XML metadata.487. Mọi decision node phải có đủ outgoing branches.498. Mọi edge phải có condition rõ ràng, dùng `condition="always"` cho unconditional flow.509. Mọi pipeline handoff phải đi qua junction node thật.5110. Mọi terminal state phải có node riêng.5211. Mọi ambiguity chưa giải quyết phải thành gap node visible.5312. Phải build source-union inventory trước khi vẽ logic triển khai.5413. Phải build source-described flow manifest trước khi vẽ logic triển khai.5514. Phải render logic triển khai từng flow, không render từ một bulk summary pass.5615. Không collapse detail có tên thành generic node.5716. Không improve, repair, normalize, hoặc tự nối flow vượt quá điều source thật sự nói.5817. Nếu không thể hoàn thành map một cách an toàn, dừng lại và nói rõ lý do.5960Nếu map có node unresolved với type `SPEC_GAP`, `UNDEFINED_BEHAVIOR`, hoặc `OWNER_DECISION_REQUIRED`, đặt implementation status là `BLOCKED`.6162Nếu `missing_source_items` không rỗng, đặt implementation status là `BLOCKED`.6364## Đầu Vào Bắt Buộc6566Đọc authority có sẵn cho spec slice được yêu cầu:67681. Source spec.692. Related authority docs.703. Existing/reference SVGs và flow maps, nếu có.714. Existing verification reports, nếu có.725. UI prototype hoặc UI slot map, nếu có.736. State/source map, nếu có.747. Backend/API/contract map, nếu có.758. Actual wiring status, nếu có.769. Project rules.7778Nếu input bắt buộc bị thiếu, không bịa hành vi. Đánh dấu nó là gap trong SVG và verification report.7980## Đầu Ra Bắt Buộc8182Tạo hoặc cập nhật các file:8384```text85docs/flow-maps/<feature-name>.flow.svg86docs/flow-maps/<feature-name>.flow-map.md87docs/flow-maps/<feature-name>.flow-verification.md88```8990Dùng lowercase kebab-case cho `<feature-name>` trừ khi project có quy tắc tên chặt hơn.9192## Quy Trình Bắt Buộc93941. Đọc project rules và requested scope.952. Đọc source spec và related authority docs.963. Đọc existing/reference SVGs, flow maps, verification reports, UI maps, state maps, API maps, và contract maps khi có.974. Build source union inventory theo `references/source-inventory-and-manifest.md`.985. Build source-described flow manifest từ inventory item được source mô tả trực tiếp.996. Tạo global lane/layout plan. Chưa vẽ logic triển khai.1007. Với từng flow trong manifest, lặp:101102```text103đọc lại source sections liên quan104extract flow-local inventory105xác nhận flow đã có trong source-described flow manifest106vẽ chỉ flow đó107ghi visible nodes/edges/junctions/terminals/gaps108ghi metadata tương ứng109verify source coverage cho flow đó110mark mapped source inventory items111mark manifest item bằng mapped SVG ids hoặc gap ids112```1131148. Sau khi vẽ tất cả flow, chạy global consistency verification.1159. Check missing source items.11610. Check flow manifest omissions và unmanifested visible flows.11711. Check collapse violations.11812. Check reference SVG delta.11913. Parse SVG như XML.12014. Verify metadata/visible node round-trip.12115. Thêm visible legend ở cuối SVG, là visible group cuối cùng trước `</svg>`, và id phải khớp `metadata.legend.visible_legend_id`.12216. Đặt implementation status.123124## Trạng Thái Kết Thúc125126Đặt:127128```text129BLOCKED130```131132khi còn unresolved gaps, undefined behavior, owner decisions, missing source items, collapse violations, hoặc failed reference deltas.133134Đặt:135136```text137READY_FOR_OWNER_REVIEW138```139140chỉ khi không còn blocker về `SPEC_GAP`, `UNDEFINED_BEHAVIOR`, `OWNER_DECISION_REQUIRED`, source coverage, collapse, hoặc reference delta.141142Chỉ Owner mới được approve implementation sau khi review generated flow map.143144## Định Dạng Bàn Giao Cuối145146Trả về đúng format:147148```md149# Bàn Giao Spec Flow Map150151## File Đã Tạo / Cập Nhật152- docs/flow-maps/<feature-name>.flow.svg153- docs/flow-maps/<feature-name>.flow-map.md154- docs/flow-maps/<feature-name>.flow-verification.md155156## Trạng Thái157BLOCKED or READY_FOR_OWNER_REVIEW158159## Phát Hiện Chính1601.1612.1623.163164## Hành Động Owner Cần Làm165- If BLOCKED: liệt kê chính xác spec sections, source inventory items, reference deltas, hoặc collapse violations cần làm rõ.166- If READY_FOR_OWNER_REVIEW: yêu cầu Owner review và approve SVG flow map trước implementation.167```