@shanyucoder/flowgrid 0.1.5 → 0.1.8

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.
Files changed (157) hide show
  1. package/README.md +1 -1
  2. package/adapters/laravel/registries/codegen.registry.json +9 -9
  3. package/bin/flowgrid.mjs +326 -115
  4. package/bin/lib/agent-mcp.mjs +4 -0
  5. package/bin/lib/agent-profiles.mjs +30 -6
  6. package/bin/lib/audit-run.mjs +1 -1
  7. package/bin/lib/cli-update.mjs +48 -8
  8. package/bin/lib/doctor.mjs +90 -3
  9. package/bin/lib/harness-overlay.mjs +12 -5
  10. package/bin/lib/harness-sync.mjs +17 -3
  11. package/bin/lib/init-adapters.mjs +75 -0
  12. package/bin/lib/init-scaffold.mjs +9 -0
  13. package/bin/lib/inject-consumer-scripts.mjs +115 -0
  14. package/bin/lib/merge-stack-config.mjs +89 -0
  15. package/bin/lib/project-gitignore.mjs +1 -0
  16. package/bin/lib/repo-maps-align.mjs +203 -0
  17. package/dist/graph/config/load-config.js +7 -2
  18. package/dist/graph/config/load-config.js.map +1 -1
  19. package/dist/graph/mcp/tools.js +1 -1
  20. package/dist/graph/mcp/tools.js.map +1 -1
  21. package/dist/graph/registry/load-registries.d.ts +1 -0
  22. package/dist/graph/registry/load-registries.js +14 -1
  23. package/dist/graph/registry/load-registries.js.map +1 -1
  24. package/engines/cases/render-cases.mjs +67 -5
  25. package/engines/docs/lib/render-api-summary-markdown.mjs +28 -0
  26. package/engines/docs/lib/render-bundle-markdown.mjs +77 -2
  27. package/engines/docs/lib/render-data-model-markdown.mjs +171 -0
  28. package/engines/docs/lib/render-design-tables.mjs +89 -7
  29. package/engines/docs/lib/render-template.mjs +6 -0
  30. package/engines/docs/render-docs.mjs +6 -2
  31. package/engines/docs/vitepress/config.ts +7 -7
  32. package/engines/docs/vitepress/surfaces-nav.mjs +45 -14
  33. package/engines/openapi/check-backend-spec.mjs +2 -2
  34. package/engines/openapi/lib/markdown-table.mjs +8 -0
  35. package/engines/openapi/lib/render-backend-spec-markdown.mjs +78 -0
  36. package/engines/registry-sync/be-capabilities-sync.mjs +118 -0
  37. package/engines/registry-sync/fe-design-sync.mjs +258 -0
  38. package/engines/registry-sync/run-registry-sync.mjs +107 -0
  39. package/engines/shared/e2e-output-layout.mjs +68 -0
  40. package/engines/shared/flowgrid-e2e-root.mjs +19 -0
  41. package/engines/shared/resolve-flowgrid-context.mjs +176 -0
  42. package/engines/spec/lib/audit-api-gaps.mjs +1 -1
  43. package/engines/spec/lib/audit-bundle-gaps.mjs +92 -3
  44. package/engines/spec/lib/audit-db-tables.mjs +529 -0
  45. package/engines/spec/lib/audit-e2e-coverage.mjs +88 -30
  46. package/engines/spec/lib/bundle-schema.mjs +4 -1
  47. package/engines/spec/split-bundle.mjs +11 -1
  48. package/engines/testcase/runners/generate-api.mjs +23 -23
  49. package/engines/testcase/runners/generate.mjs +19 -17
  50. package/engines/testcase/runners/lib/bootstrap-context.mjs +44 -0
  51. package/engines/testcase/runners/lib/write-files.mjs +37 -9
  52. package/harness/agents/antigravity/rules/antigravity-mcp.mdc +12 -0
  53. package/harness/agents/gemini/rules/gemini-mcp.mdc +11 -0
  54. package/harness/agents/gemini_antigravity/rules/antigravity-mcp.mdc +8 -6
  55. package/harness/be/skills/{grill-api → audit-api}/SKILL.md +8 -7
  56. package/harness/common/extracts/artifact-graph.md +2 -2
  57. package/harness/common/extracts/artifactgraph-phase-hooks.md +2 -2
  58. package/harness/common/extracts/docs-mark-detect.md +2 -2
  59. package/harness/common/extracts/entity-relationship.md +23 -0
  60. package/harness/common/rules/flowgrid-ux-common.mdc +3 -3
  61. package/harness/common/skills/configure-repo-maps/SKILL.md +4 -2
  62. package/harness/docs/extracts/agent-execution-protocol.md +1 -1
  63. package/harness/docs/extracts/api-codegen-readiness.md +34 -0
  64. package/harness/docs/extracts/api-codegen-tags.md +30 -0
  65. package/harness/docs/extracts/api-contract.md +43 -0
  66. package/harness/docs/extracts/api-spec-sync.md +35 -0
  67. package/harness/docs/extracts/artifactgraph-hooks-docs.md +1 -1
  68. package/harness/docs/extracts/call-external.md +16 -0
  69. package/harness/docs/extracts/common-scope.md +9 -10
  70. package/harness/docs/extracts/db-audit-wizard.md +45 -0
  71. package/harness/docs/extracts/derived-data.md +18 -0
  72. package/harness/docs/extracts/design-leaf-signoff.md +16 -0
  73. package/harness/docs/extracts/extract-registry.docs.json +9 -1
  74. package/harness/docs/extracts/spec-core.md +7 -3
  75. package/harness/docs/extracts/spec-evolution.md +21 -0
  76. package/harness/docs/extracts/spec-prd-lite.md +19 -0
  77. package/harness/docs/extracts/spec-requirement.md +6 -2
  78. package/harness/docs/extracts/spec-ssot-prep.md +25 -0
  79. package/harness/docs/extracts/tpl-module.md +12 -0
  80. package/harness/docs/extracts/verify-gate.md +33 -0
  81. package/harness/docs/extracts/wire-spec-feedback.md +31 -0
  82. package/harness/docs/rules/agent-compliance.mdc +1 -1
  83. package/harness/docs/rules/team-flow-spec.mdc +3 -4
  84. package/harness/docs/skills/adopt/SKILL.md +2 -0
  85. package/harness/docs/skills/api/SKILL.md +4 -5
  86. package/harness/docs/skills/api-spec/SKILL.md +19 -6
  87. package/harness/docs/skills/api-update/SKILL.md +3 -3
  88. package/harness/docs/skills/architecture/SKILL.md +1 -1
  89. package/harness/docs/skills/business-process/SKILL.md +2 -0
  90. package/harness/docs/skills/common/SKILL.md +2 -2
  91. package/harness/docs/skills/common-spec/SKILL.md +10 -47
  92. package/harness/docs/skills/db-erd/SKILL.md +26 -0
  93. package/harness/docs/skills/grill/SKILL.md +28 -22
  94. package/harness/docs/skills/grill-api/SKILL.md +4 -6
  95. package/harness/docs/skills/grill-api-spec/SKILL.md +44 -24
  96. package/harness/docs/skills/grill-bqa/SKILL.md +28 -13
  97. package/harness/docs/skills/grill-common-spec/SKILL.md +10 -35
  98. package/harness/docs/skills/grill-dev/SKILL.md +7 -6
  99. package/harness/docs/skills/grill-docs/SKILL.md +10 -3
  100. package/harness/docs/skills/module/SKILL.md +3 -1
  101. package/harness/docs/skills/openapi/SKILL.md +2 -1
  102. package/harness/docs/skills/overview/SKILL.md +7 -1
  103. package/harness/docs/skills/spec/SKILL.md +42 -9
  104. package/harness/docs/skills/update-spec/SKILL.md +4 -1
  105. package/harness/fe/extracts/wire-audit-loop.md +72 -0
  106. package/harness/fe/extracts/wire-phase.md +45 -0
  107. package/harness/fe/rules/platform-design-vocabulary.mdc +1 -1
  108. package/harness/fe/rules/team-flow-prototype.mdc +8 -4
  109. package/harness/fe/skills/gen-common/SKILL.md +11 -84
  110. package/harness/fe/skills/grill-prototype/SKILL.md +51 -25
  111. package/harness/fe/skills/grill-test/SKILL.md +78 -20
  112. package/harness/fe/skills/grill-wire/SKILL.md +81 -0
  113. package/harness/fe/skills/prototype/SKILL.md +3 -2
  114. package/harness/fe/skills/wire/SKILL.md +7 -2
  115. package/harness/shared/AGENTS.md +3 -3
  116. package/harness/shared/SSOT_AGENT_PROTOCOL.md +3 -3
  117. package/harness/tests/extracts/grill-api-hook.md +69 -0
  118. package/harness/tests/extracts/grill-scenario-flow.md +39 -0
  119. package/harness/tests/extracts/grill-screen-tc.md +40 -0
  120. package/harness/tests/extracts/testcase-gen-cli.md +57 -0
  121. package/harness/tests/extracts/testcase-plan.md +29 -0
  122. package/harness/tests/extracts/tests-verify-gate.md +29 -0
  123. package/harness/tests/extracts/wire-test-handoff.md +37 -0
  124. package/harness/tests/skills/grill-testcase/SKILL.md +1 -0
  125. package/harness/tests/skills/test-api/SKILL.md +14 -6
  126. package/harness/tests/skills/testcase/SKILL.md +3 -1
  127. package/harness/tests/templates/TC.example-api.yaml +7 -1
  128. package/harness/tests/templates/TC.example.yaml +4 -1
  129. package/harness/tests/templates/tpl-testcase-plan.md +75 -0
  130. package/package.json +1 -1
  131. package/stacks/fastapi.json +1 -0
  132. package/stacks/laravel.json +1 -0
  133. package/stacks/nestjs.json +72 -0
  134. package/stacks/nextjs-nest.json +1 -0
  135. package/stacks/nuxt4-nest.json +1 -0
  136. package/templates/project-skeleton/architecture/03-business-process/FLOW-template.md +2 -0
  137. package/templates/project-skeleton/overview/index.md +68 -2
  138. package/templates/project-skeleton/overview/operational-areas/_template.md +37 -0
  139. package/templates/project-skeleton/surfaces/common/data-model/index.md +10 -2
  140. package/templates/shared/api-03-mock.stub.yaml +14 -0
  141. package/templates/shared/backend-api.bundle.yaml +3 -0
  142. package/templates/shared/backend-api.yaml +4 -0
  143. package/templates/shared/be-capabilities.registry.base.json +8 -0
  144. package/templates/shared/bundle-authoring.md +39 -3
  145. package/templates/shared/default-layout.ejs +131 -18
  146. package/templates/shared/design-spec.yaml +2 -3
  147. package/templates/shared/design.registry.base.json +38 -0
  148. package/templates/shared/feature.bundle.yaml +16 -9
  149. package/templates/shared/ir/generated/spec.md +281 -0
  150. package/templates/shared/qa-item.yaml +1 -1
  151. package/templates/shared/tpl-api-contract.md +133 -0
  152. package/templates/shared/tpl-screen-data-model.md +76 -0
  153. package/templates/tests-skeleton/cases/README.md +4 -0
  154. package/templates/tests-skeleton/catalog/locale.yaml +9 -0
  155. package/templates/tests-skeleton/tpl-testcase-plan.md +9 -0
  156. package/harness/docs/skills/api-integration/SKILL.md +0 -110
  157. package/harness/docs/skills/grill-integration-spec/SKILL.md +0 -51
@@ -20,7 +20,7 @@ When executing any skill (`/spec`, `/grill`, `/grill-bqa`, etc.):
20
20
  3. **NO RAM CACHING:** All persistent changes **[MANDATORY]** immediately written via `{{FLOWGRID_WRITE_TOOL}}`. Never hold uncommitted state in chat/RAM. When a grill proposal is not yet confirmed → discuss directly in chat thread. **[STRICTLY FORBIDDEN]** to create temporary `*-proposal.md` files or overwrite product SSOT prior to explicit confirmation.
21
21
  4. **ZERO BUSINESS HALLUCINATION:** Ground data strictly from (1) User prompt and (2) ArtifactGraph registry. **[STRICTLY FORBIDDEN]** to invent fields, validations, database structures, or flows. Missing information must remain empty or be tagged `#missing_info`. No unprompted guessing.
22
22
  5. **GRILL HARD GATE:** ArtifactGraph re-check → micro-scope → provide structured recommendation (`(Recommended)`) → **STOP and prompt Member**. **[STRICTLY FORBIDDEN]** to write to SSOT before explicit user confirmation.
23
- 6. **DSL / COMMON:** Human lead decides common promotions. The agent only executes `/common`, `/common-spec`, `/docs-mark`, or confirmation post-grill. `/spec` strictly consumes common definitions. **[STRICTLY FORBIDDEN]** to invent or overwrite common libraries spontaneously.
23
+ 6. **DSL / COMMON:** Human lead decides common promotions. The agent only executes `/common` (Markdown patterns), `/docs-mark`, custom-base handoff, or confirmation post-grill. `/spec` consumes patterns + FE base via `flowgrid-ux-common.mdc`. **[STRICTLY FORBIDDEN]** `common/yaml`, `/common-spec`, `/gen-common`.
24
24
  7. **ISOLATION:** Execute strictly within the invoked skill scope. **[STRICTLY FORBIDDEN]** to merge sibling features or output fake Markdown reports when YAML contracts are required.
25
25
 
26
26
  **Path SSOT:** `surfaces/<surface>/CMP-*/<slug>/` (NO `modules/` segment).
@@ -6,7 +6,7 @@ alwaysApply: false
6
6
 
7
7
  # Team Flow — Spec
8
8
 
9
- Active commands: `/spec`, `/grill-bqa`, `/grill-dev`, `/grill-docs`, `/update-spec`, `/update-spec-legacy` — one per session.
9
+ Active commands: `/spec`, `/grill-bqa`, `/grill-dev`, `/grill-docs`, `/update-spec` — one per session.
10
10
 
11
11
  > [!CRITICAL] MANDATORY AGENT INSTRUCTION
12
12
  > You MUST read and strictly enforce all guidelines in the target skill's `SKILL.md` file before starting any step in this pipeline.
@@ -18,18 +18,17 @@ Active commands: `/spec`, `/grill-bqa`, `/grill-dev`, `/grill-docs`, `/update-sp
18
18
  | `/grill-dev` | `.cursor/skills/grill-dev/SKILL.md` |
19
19
  | `/grill-docs` | `.cursor/skills/grill-docs/SKILL.md` |
20
20
  | `/update-spec` | `.cursor/skills/update-spec/SKILL.md` |
21
- | `/update-spec-legacy` | `.cursor/skills/update-spec-legacy/SKILL.md` |
22
21
  | Grill metadata rules | `.cursor/rules/team-flow-grill.mdc` |
23
22
 
24
23
  Shared: resolve skill `extractBundle` → `.cursor/extracts/extract-registry.docs.json` (e.g. `bqa-grill`, `dev-grill`, `grill-docs`).
25
24
 
26
25
  ## Pipeline
27
26
 
28
- 1. **`/spec`** — `*.bundle.yaml` design v1 + testcase round 1. Per-zone: DSL/registry → bundle; gaps → `#needs-component` / `#needs-ui` + `flowgrid-ux-common` proposals → `AskQuestion`. No `gen` / `codegen`.
27
+ 1. **`/spec`** — `*.bundle.yaml` only (`feature.bundle.yaml` template; not `design-spec.yaml`). Include `successMetrics` / `nonGoals` when known. Per-zone: DSL/registry → bundle; `audit spec` `gaps[]` + non-blocking `warnings[]`. BA deliverable: `ir/generated/spec.md` after split+render. No `gen` / `codegen` in first pass.
29
28
  2. **`/grill-bqa`** — UI, acceptance, breadcrumb, delete rules.
30
29
  3. **`/grill-dev`** — codegen-ready bundle + `tags`; emit bộ code FE dry-run handoff.
31
30
  4. **`/grill-docs`** — optional reconcile when BQA↔Dev contradict.
32
- 5. **`/update-spec`** / **`/update-spec-legacy`** — controlled delta + `#update:*` (not full rewrite).
31
+ 5. **`/update-spec`** — controlled delta + `#update:*` (legacy trace → `/legacy /spec` hoặc delta legacy trong cùng skill; not full rewrite).
33
32
  6. **`/prototype`** — FE-lane handoff only after bộ code dry-run passes.
34
33
 
35
34
  - Render: `docs_render` / `flowgrid render` (pnpm fallback during transition)
@@ -12,6 +12,8 @@ extractBundle: architecture-core
12
12
 
13
13
  **Audit Interlock:** Run `flowgrid audit legacy <target-id>`. Consume JSON gap report to verify mapping or prompt member if index is missing.
14
14
 
15
+ **Handoff SSOT spec:** Sau adopt, member drill [spec-ssot-prep.md](../../../docs/workflows/spec-ssot-prep.md) — Phase 0 → `/legacy /spec` per `W-*` (không nhảy thẳng bundle không có ID trong inventory).
16
+
15
17
  ---
16
18
 
17
19
  ## Rule: Pre-Scan Mode Selection (AskQuestion Wizard)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: api
3
- description: EXCLUSIVE /api — Backend Router ONLY. Immediately routes to /api-spec or /api-integration without generating gross files.
3
+ description: EXCLUSIVE /api — Backend Router ONLY. Immediately routes to /api-spec, /api-update, or /grill-api-spec without generating gross files.
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
@@ -18,14 +18,13 @@ disable-model-invocation: true
18
18
 
19
19
  | Condition | Route to |
20
20
  |---|---|
21
- | No `01-backend-spec.yaml` + Portal-backed | `/api-spec` |
22
- | No `01-backend-spec.yaml` + webhook/partner/no FE (`base: none`) | `/api-integration` |
21
+ | No `01-backend-spec.yaml` (portal-backed or BE-only / webhook / partner) | `/api-spec` |
23
22
  | Portal specs changed / merge deferred child functions | `/api-update` |
24
23
  | BE-only requirement (no FE contract change) | `/api-update --be-only` |
25
- | Spec exists but not codegen-ready / `approval.status` not `approved` | `/grill-api-spec` or `/grill-integration-spec` (per `source.kind`) |
24
+ | Spec exists but not codegen-ready / `approval.status` not `approved` | `/grill-api-spec` |
26
25
  | `approval.status: approved` + explicit implement request | bộ code BE `/api` (switch to BE repo skill — NOT this skill) |
27
26
 
28
- - **[MANDATORY]** Locate `01-backend-spec.yaml` under: `…/api/<seq>/` (screen leaf), `…/common/yaml/<slug>/`, or `…/integrations/…/api/<seq>/`.
27
+ - **[MANDATORY]** Locate `01-backend-spec.yaml` under: `…/api/<seq>/` (screen leaf), `…/common/yaml/<slug>/`, or any surface leaf dedicated to external-channel APIs.
29
28
  - **[STRICTLY FORBIDDEN]** Do NOT skip `/grill-api-spec` for new features, cross-portal, or legacy-derived contracts.
30
29
  - PHPUnit coverage: NOT routed here — use `/unit-be` directly.
31
30
 
@@ -6,7 +6,7 @@ disable-model-invocation: true
6
6
 
7
7
  > [!CRITICAL] MANDATORY PRE-FLIGHT
8
8
  > **[MANDATORY]** Re-read this entire `SKILL.md` via file-read tool. STRICTLY FORBIDDEN to rely on memory.
9
- > **[MANDATORY]** Read template `.flowgrid/templates/backend-api.bundle.yaml` BEFORE generating any YAML.
9
+ > **[MANDATORY]** Read `.flowgrid/templates/backend-api.yaml`, `.flowgrid/templates/tpl-api-contract.md`, and `.cursor/extracts/api-contract.md` BEFORE generating any YAML.
10
10
  > If missing → STOP: *"Template missing. Run `flowgrid init`."*
11
11
  > **[MANDATORY]** Read entire `ir/design.yaml` first (actions + nested items with `apiRefs`). If `ir/` is missing, read `*.bundle.yaml`.
12
12
 
@@ -22,9 +22,9 @@ Hashtag extracts: `#call-external` → `call-external.md`; `#cross-entity-servic
22
22
 
23
23
  ## Rule: Audit Interlock
24
24
 
25
- - **[MANDATORY]** Always run static audit first: `flowgrid audit api <target-api.bundle.yaml>`.
25
+ - **[MANDATORY]** After drafting or updating `01-backend-spec.yaml`, run `flowgrid audit api <path-to-01-backend-spec.yaml>`.
26
26
  - ✅ Consume JSON gap report to fix issues or trigger AskQuestion wizard (≥3 options).
27
- - ❌ Do not skip audit and proceed to authoring directly.
27
+ - ❌ Do not hand off without audit on the `01` file. Do **not** use `flowgrid check` on `01` (`check` is bundle IR only).
28
28
 
29
29
  ---
30
30
 
@@ -94,7 +94,7 @@ Hashtag extracts: `#call-external` → `call-external.md`; `#cross-entity-servic
94
94
  api/01/
95
95
  01-backend-spec.yaml ← VALID YAML (double-quote all colons)
96
96
  02-openapi.yaml
97
- 03-mock-data.yaml
97
+ 03-mock.yaml
98
98
  ```
99
99
  - **[MANDATORY]** Common APIs → LCA `common/yaml/<component-slug>/`.
100
100
  - **[MANDATORY]** One `01-backend-spec.yaml` = one module + one primary entity. Never dump every screen API into one file.
@@ -102,12 +102,24 @@ Hashtag extracts: `#call-external` → `call-external.md`; `#cross-entity-servic
102
102
 
103
103
  ---
104
104
 
105
+ ## Rule: BE-only / external channel (no portal FE)
106
+
107
+ Use the **same** skill (`/api-spec`) and same trio layout when there is no portal screen (`feature.source.base: none`, webhooks, partner/public APIs).
108
+
109
+ - **[MANDATORY]** Place contract trio under a normal surface leaf, e.g. `surfaces/<external-surface>/<provider>/<slug>/api/<seq>/` (dedicated surface for partner/webhook channel — not a separate skill).
110
+ - **[MANDATORY]** Set `feature.source.kind`, `base: none`, `integrationRefs[]` (or equivalent refs), empty `portalRefs`, `contexts.portalLayout: none`, and `contexts.auth` (API key / HMAC / OAuth).
111
+ - **[MANDATORY]** Domain tags: `#webhook-inbound`, `#webhook-outbound`, `#partner-api`, `#public-api`, `#call-external`, `#err:*` (include `#err:signature-invalid`, `#err:rate-limit`, `#err:unauthorized` when relevant).
112
+ - **[MANDATORY]** Scan sibling `…/api/<seq>/` and surface `common/yaml/` before creating new endpoints; reuse via `#reuse-api` when applicable.
113
+ - **[STRICTLY FORBIDDEN]** Do not invent HMAC secrets or partner validation logic; use AskQuestion or `qa/open/` tech debt.
114
+
115
+ ---
116
+
105
117
  ## Rule: YAML Syntax Safety
106
118
 
107
119
  - **[MANDATORY]** All strings containing `:` must be double-quoted.
108
120
  - ✅ `summary: "Create: New Employee Registration"`
109
121
  - ❌ `summary: Create: New Employee Registration`
110
- - **[MANDATORY]** Run `flowgrid check --spec …/api/01/01-backend-spec.yaml` before handoff.
122
+ - **[MANDATORY]** Run `flowgrid api:check --spec …/api/01/01-backend-spec.yaml` before handoff.
111
123
  - **[MANDATORY]** Domain tags only (`#call-external`, `#cross-entity-service`, `#err:*`). No `#gen:*` or `codegen` block from this skill.
112
124
 
113
125
  ---
@@ -133,4 +145,5 @@ Hashtag extracts: `#call-external` → `call-external.md`; `#cross-entity-servic
133
145
  - [ ] All new endpoints use explicit action URI suffixes.
134
146
  - [ ] `#err:*` tags applied per endpoint nature (not-found + IDOR on `{id}`, validation on POST/PUT, etc.).
135
147
  - [ ] Strings with `:` in YAML are double-quoted. No `.md` written directly.
136
- - [ ] `flowgrid check` passed with zero errors.
148
+ - [ ] `flowgrid api:check --spec …/01-backend-spec.yaml` passed.
149
+ - [ ] `flowgrid render` (or hub render script) so `ir/generated/api.md` is current for reviewers.
@@ -40,8 +40,8 @@ Shared extracts: `api-spec-sync.md`, `spec-evolution.md`, `entity-relationship.m
40
40
  - `#reuse-api` actions → do NOT create a new `01`.
41
41
  - Do NOT treat projected `design.api` as BE SSOT.
42
42
  2. **[MANDATORY]** Diff requirements, endpoints, acceptance vs `01-backend-spec.yaml`.
43
- 3. **[MANDATORY]** Patch `01-backend-spec.yaml` (+ `03-mock-data.yaml` if samples change).
44
- 4. **[MANDATORY]** Run: `flowgrid check --spec …/01-backend-spec.yaml` → `flowgrid openapi_gen --spec …/01-backend-spec.yaml` (writes sibling `02`).
43
+ 3. **[MANDATORY]** Patch `01-backend-spec.yaml` (+ `03-mock.yaml` if samples change).
44
+ 4. **[MANDATORY]** Run: `flowgrid api:check --spec …/01-backend-spec.yaml` → `flowgrid openapi_gen --spec …/01-backend-spec.yaml` (writes sibling `02`).
45
45
  5. **[MANDATORY]** Bump `feature.version` + add `changeLog` entry.
46
46
  6. **[STRICTLY FORBIDDEN]** Never hand-edit `02-openapi.yaml` as SSOT. Never write `.md` directly.
47
47
 
@@ -77,6 +77,6 @@ Shared extracts: `api-spec-sync.md`, `spec-evolution.md`, `entity-relationship.m
77
77
 
78
78
  - [ ] Target is `…/api/<seq>/01-backend-spec.yaml` (or `common/yaml/<slug>/`), not a `01` on the FE leaf.
79
79
  - [ ] `01` patched; `02` regenerated via `openapi:gen` (not hand-edited).
80
- - [ ] Gates passed: `flowgrid check` + `flowgrid openapi_gen`.
80
+ - [ ] Gates passed: `flowgrid api:check --spec …/01` + `flowgrid openapi_gen` + `flowgrid render` (refresh `ir/generated/api.md`).
81
81
  - [ ] `changeLog` + `feature.version` bumped.
82
82
  - [ ] No `.md` written directly. No `openQuestions` in YAML.
@@ -22,7 +22,7 @@ extractBundle: architecture-core
22
22
  | Product overview / operational areas | `/overview` |
23
23
  | Business/interaction surfaces | `/surfaces` |
24
24
  | Common UX/UI rules (Markdown) | `/common` |
25
- | Common technical bundles for codegen (YAML) | `/common-spec` / `/grill-common-spec` |
25
+ | Shared UI templates / registry on FE base | [custom-base](../../../docs/workflows/custom-base.md) · `/build-template-code` |
26
26
  | Module / CMP box | `/module` |
27
27
  | Screen / API detail | `/spec` |
28
28
  | Where it runs / Infrastructure | `/deployment` |
@@ -12,6 +12,8 @@ extractBundle: architecture-core
12
12
 
13
13
  **Mindset:** Model the process by **business actions on surfaces**, not by repository or service topology.
14
14
 
15
+ **Template:** `architecture/03-business-process/FLOW-template.md` (or surfaces `common/processes/FLOW-*.md`) — include **Success metrics** and **Non-goals** in §1 when information exists.
16
+
15
17
  ---
16
18
 
17
19
  ## Rule: Audit Interlock
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: common
3
- description: EXCLUSIVE /common — Use this to define common business rules, UX/UI rules, and patterns for a Surface as Markdown documentation. DO NOT use this to generate YAML technical bundles (use /common-spec for that).
3
+ description: EXCLUSIVE /common — Markdown rules under common/patterns/ (and cross-flow context). DO NOT author common/yaml or gen-common (deprecated).
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
@@ -35,7 +35,7 @@ Markdown rules for a **named scope** (cluster / module / surface / global). Not
35
35
  - **[MANDATORY]** Use clear, non-technical language geared towards Business / QA / Dev alignment.
36
36
  - **[MANDATORY]** Define rules based on surface type when applicable (e.g. Kiosk UI rules differ from Web Portal rules).
37
37
  - **[STRICTLY FORBIDDEN]** Do NOT output fake i18n tables or framework prose. Focus on actual rules (e.g. "Confirm dialog must always block background").
38
- - **[STRICTLY FORBIDDEN]** Do NOT generate YAML bundles here — use `/common-spec` for codegen bundles.
38
+ - **[STRICTLY FORBIDDEN]** Do NOT generate `common/yaml`, CMN bundles, or invoke `/gen-common` / `/common-spec` (deprecated). UI patterns are enforced via FE base + `flowgrid-ux-common.mdc`; new templates → [custom-base](../../../docs/workflows/custom-base.md).
39
39
 
40
40
  ---
41
41
 
@@ -1,55 +1,18 @@
1
1
  ---
2
2
  name: common-spec
3
- extractBundle: spec-core
4
- description: EXCLUSIVE /common-spec — Use this to define common technical bundles (YAML) for a Surface for Codegen. DO NOT output Markdown files.
3
+ description: DEPRECATED — common no longer uses YAML bundles on the docs hub. Use /common (Markdown) or custom-base.
5
4
  disable-model-invocation: true
6
5
  ---
7
6
 
8
- > [!CRITICAL] MANDATORY PRE-FLIGHT
9
- > **[MANDATORY]** Re-read this entire `SKILL.md` via file-read tool. STRICTLY FORBIDDEN to rely on memory.
10
- > **[MANDATORY]** Read `.cursor/extracts/common-scope.md` first to resolve the LCA path.
7
+ # /common-spec — DEPRECATED
11
8
 
12
- # /common-spec — Common Technical Bundle (YAML)
9
+ Common technical bundles (`common/yaml`, `*.bundle.yaml` under `surfaces/.../common`) are **no longer** part of the product workflow.
13
10
 
14
- **Target Path:** `<LCA>/common/yaml/<slug>/<slug>.bundle.yaml` (LCA from `common-scope.md`).
11
+ | Need | Use |
12
+ |------|-----|
13
+ | Cross-flow product doc | `common/processes/FLOW-*.md` |
14
+ | Shared UX/business rules | `/common` → `common/patterns/*.md` |
15
+ | UI patterns (delete flow, badges, flat design, …) | FE **base** + `flowgrid-ux-common.mdc` during `/spec` / grill |
16
+ | New shared component / codegen template | [custom-base](../../../docs/workflows/custom-base.md) → `build-template-code` |
15
17
 
16
- **Gate:** Only use when user explicitly invokes `/common-spec` or confirmed a grill proposal to promote common.
17
-
18
- ---
19
-
20
- ## Rule: Platform-Agnostic Generation
21
-
22
- - **[MANDATORY]** Use `design.shell.tag` to match target surface type:
23
- - Web Portal → `#shell: DataListPage`
24
- - WinForms Kiosk → `#shell: KioskCheckIn`
25
- - Gateway → `#shell: OtAdapter`
26
- - **[MANDATORY]** Populate `spec.clients` if applicable.
27
- - **[RECOMMENDED]** For known Web patterns (e.g. `confirm-dialog`): ask if user wants to inherit from seed template in `templates/project-skeleton/surfaces/common/yaml/`.
28
- - **[MANDATORY]** For non-Web surfaces → generate new bundle tailored to that requirement. Do NOT force Web template inheritance.
29
-
30
- ---
31
-
32
- ## Rule: Output
33
-
34
- - **[MANDATORY]** Output MUST be `.bundle.yaml`. Do NOT write `.md` directly.
35
- - **[MANDATORY]** All strings containing `:` must be double-quoted.
36
- - **[MANDATORY]** After writing: instruct user to run `flowgrid split -- <path>` (must emit `ir/design.yaml`), then `flowgrid render`. Run `flowgrid split --check` to verify.
37
- - **[STRICTLY FORBIDDEN]** Do NOT send BE `/api` a common FE bundle. bộ code → FE `/gen-common` only.
38
-
39
- ---
40
-
41
- ## Workflow
42
-
43
- 1. Read `common-scope.md`. Identify consumers → one LCA `common/yaml/<slug>/`.
44
- - Example module-local: `surfaces/admin/CMP-ADM-002/common/yaml/confirm-dialog/confirm-dialog.bundle.yaml`
45
- 2. Generate `.bundle.yaml` using `portal-feature-bundle/v1` schema.
46
- 3. Instruct user: `flowgrid split -- <path>` → `flowgrid render`.
47
-
48
- ---
49
-
50
- ## Verification Checklist
51
-
52
- - [ ] LCA resolved from `common-scope.md`; path correctly scoped.
53
- - [ ] `design.shell.tag` matches target surface type.
54
- - [ ] `.bundle.yaml` output only (no `.md`). YAML strings with `:` are double-quoted.
55
- - [ ] `flowgrid split --check` passes (emits `ir/design.yaml`).
18
+ **If invoked:** STOP and redirect — do not author `common/yaml` or run `flowgrid split` for CMN bundles.
@@ -10,16 +10,33 @@ extractBundle: architecture-core
10
10
 
11
11
  # /db-erd — Business Data Model (ERD)
12
12
 
13
+ **Phase:** **0 Architecture** — sau `/overview`, `/module`, `/business-process` khi có entity/bảng mới. **Trước** `/spec` leaf.
14
+
15
+ **Hub SSOT:** [architecture-data.md](../../../docs/workflows/architecture-data.md)
16
+
13
17
  **Target Path:** `<LCA>/common/db-erd.md` — LCA resolved from `.cursor/extracts/common-scope.md`.
14
18
  VitePress/publish menu label: **`db-erd`** (not the H1 heading).
15
19
 
20
+ **Handoff:** Design `/spec` đọc file này; chi tiết cột → `design.sections[].db` + `spec.entities` — **không** duplicate full ER trên bundle.
21
+
16
22
  ---
17
23
 
18
24
  ## Rule: Modeling Approach
19
25
 
20
26
  - **[MANDATORY]** Use Mermaid `erDiagram`. Start from business entities and domain data ownership — NOT from a raw repository schema dump.
21
27
  - **[MANDATORY]** Place shared entities in the common scope when reused by multiple surfaces or modules.
28
+ - **[MANDATORY]** Document per entity: business name, owning `CMP-*` / surface, primary key, main attributes (not every UI-only field).
22
29
  - **[STRICTLY FORBIDDEN]** Do NOT use this skill as a per-repository ORM/schema export unless the repository boundary strictly represents the actual data boundary.
30
+ - **[STRICTLY FORBIDDEN]** Do NOT author per-screen `db:` bindings here — that is `/spec` (Phase 1).
31
+
32
+ ---
33
+
34
+ ## Rule: Phase 0 sequence
35
+
36
+ 1. Confirm LCA with `common-scope.md` (same as `/common` patterns).
37
+ 2. Read existing `db-erd.md` at wider LCA if any — extend, do not fork duplicate ER.
38
+ 3. Write/update `<LCA>/common/db-erd.md`.
39
+ 4. Optional: link entities in `common/data-model/index.md` (prose / `#derived-data` only).
23
40
 
24
41
  ---
25
42
 
@@ -27,3 +44,12 @@ VitePress/publish menu label: **`db-erd`** (not the H1 heading).
27
44
 
28
45
  - **[MANDATORY]** Reference source mappings from `legacy-repos.local.json`.
29
46
  - **[MANDATORY]** Map legacy schema to the business data model and entity ownership.
47
+
48
+ ---
49
+
50
+ ## Verification Checklist
51
+
52
+ - [ ] LCA path correct; single `db-erd.md` at that level.
53
+ - [ ] Mermaid `erDiagram` renders; entities have owner module/surface.
54
+ - [ ] Main relationships and cardinality documented.
55
+ - [ ] No per-screen column inventory (deferred to `/spec`).
@@ -1,46 +1,52 @@
1
1
  ---
2
2
  name: grill
3
- description: /grill — General discovery/gap-fill grill before authoring any skill. Routes to the correct specialized grill.
3
+ description: /grill — Gap router only. Routes to specialized grill skills; never authors SSOT inline.
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
7
7
  > [!CRITICAL] MANDATORY PRE-FLIGHT
8
8
  > **[MANDATORY]** Re-read this entire `SKILL.md` via file-read tool. STRICTLY FORBIDDEN to rely on memory.
9
9
 
10
- # /grill — Discovery & Gap Fill Router
10
+ # /grill — Discovery & Gap Router
11
11
 
12
- **Mindset:** Discovery and resolution of ambiguity — not authoring. Route to the correct specialized grill.
12
+ **Mindset:** Surface **gaps / orphans / misalignment** — route to one specialized grill. **Not** authoring, **not** multi-phase product planning.
13
+
14
+ SSOT flow: `docs/workflows/grill-and-human-review.md` · close checklist: `docs/workflows/gates.md#close-one-function`.
13
15
 
14
16
  ---
15
17
 
16
18
  ## Rule: Routing Logic
17
19
 
18
- - **[MANDATORY]** Route based on what is unclear or incomplete:
19
-
20
- | Context | Route to |
21
- |---|---|
22
- | UI/UX acceptance, copy, layout gaps | `/grill-bqa` |
23
- | Codegen tags, API contracts, `bundle.gen` | `/grill-dev` |
24
- | Backend API spec trio (Portal FE exists) | `/grill-api-spec` |
25
- | Integration contract (webhook/partner/no FE) | `/grill-integration-spec` |
26
- | Architecture-level design (services, C4) | `/architecture-grill` |
27
- | Common YAML bundle audit | `/grill-common-spec` |
28
- | Doc hub content quality | `/grill-docs` |
29
-
30
- - **[STRICTLY FORBIDDEN]** Do NOT use `/grill` as a catch-all that attempts to resolve all gaps inline — always route to the specialized grill for that domain.
20
+ - **[MANDATORY]** Pick **one** row — then run that skill in a **new focused session** when possible:
21
+
22
+ | Gap context | Route to |
23
+ | --- | --- |
24
+ | UI acceptance, copy, validation, UX affordance | `/grill-bqa` |
25
+ | `bundle.gen`, codegen profile, `#gen:*`, endpoint `action` on `01` | `/grill-dev` |
26
+ | BQA ↔ Dev contradiction on same bundle | `/grill-docs` |
27
+ | `01-backend-spec.yaml` contract (portal or `base: none`) | `/grill-api-spec` |
28
+ | Generated BE routes/code vs `01` | `/audit-api` (BE repo) |
29
+ | Prototype / mock boundary / testIds before ship UI | `/grill-prototype` |
30
+ | `TC-*.yaml` plan, matrix, trace bundle (tests-docs hub) | `/grill-testcase` |
31
+ | Playwright `*.spec.ts` ↔ TC ↔ PO (after `/test` green) | `/grill-test` |
32
+ | Unit tests (FE or BE lane) | `/grill-unit` or `/grill-api-unit` |
33
+ | Architecture / C4 / cross-service boundary | `/architecture-grill` |
34
+ | Shared rule Markdown (`common/patterns`) | `/common` — not YAML grill |
35
+
36
+ - **[STRICTLY FORBIDDEN]** Resolve all domains in one `/grill` chat.
37
+ - **[STRICTLY FORBIDDEN]** Use `/grill-docs` for first-pass spec — only **reconcile** after `/grill-bqa` + `/grill-dev`.
31
38
 
32
39
  ---
33
40
 
34
41
  ## Rule: Missing Information Protocol
35
42
 
36
- - **[MANDATORY]** All discovered gaps → trigger `AskQuestion` wizard per specialized skill guidelines. Present one question at a time with **≥3 options**.
37
- - **[MANDATORY]** After member answers → route to the appropriate specialized skill.
38
- - **[STRICTLY FORBIDDEN]** Do NOT invent business rules, API contracts, or UI copy during general grill.
43
+ - **[MANDATORY]** Delegate AskQuestion wizard to the target skill (≥3 options, Law 2 hard stop at ≥10 gaps).
44
+ - **[STRICTLY FORBIDDEN]** Invent business rules, API contracts, or UI copy in the router.
39
45
 
40
46
  ---
41
47
 
42
48
  ## Verification Checklist
43
49
 
44
- - [ ] Identified correct specialized grill for the gap type.
45
- - [ ] Gaps surfaced via AskQuestion wizard (≥3 options).
46
- - [ ] Routed to correct specialized skill with gap context.
50
+ - [ ] Exactly one specialized grill chosen for the reported gap type.
51
+ - [ ] Member told which audit CLI the target skill will run (`audit spec`, `cases:gate`, `audit e2e`, `audit api`, …).
52
+ - [ ] No SSOT files authored from this router.
@@ -1,15 +1,13 @@
1
1
  ---
2
2
  name: grill-api
3
- description: >-
4
- /grill-api — Discovery router for backend API grill. Routes to /grill-api-spec
5
- (Portal-backed) or /grill-integration-spec (webhook/partner/no FE) based on source.kind.
3
+ description: /grill-api — docs-hub router to /grill-api-spec only. BE code audit uses /audit-api on API repo.
6
4
  disable-model-invocation: true
7
5
  ---
8
6
 
9
7
  > [!CRITICAL] MANDATORY PRE-FLIGHT
10
8
  > **[MANDATORY]** Re-read this entire `SKILL.md` via file-read tool. STRICTLY FORBIDDEN to rely on memory.
11
9
 
12
- # /grill-api — Backend Grill Router
10
+ # /grill-api — Contract grill router (docs hub)
13
11
 
14
12
  ---
15
13
 
@@ -20,7 +18,7 @@ disable-model-invocation: true
20
18
  | Context | Route to |
21
19
  |---|---|
22
20
  | `feature.source.base` is Portal | `/grill-api-spec` |
23
- | `feature.source.base: none` / webhook / partner | `/grill-integration-spec` |
21
+ | `feature.source.base: none` / webhook / partner | `/grill-api-spec` |
24
22
 
25
- - **[MANDATORY]** If `01-backend-spec.yaml` does not exist yet → run `/api-spec` or `/api-integration` first.
23
+ - **[MANDATORY]** If `01-backend-spec.yaml` does not exist yet → run `/api-spec` first.
26
24
  - **[STRICTLY FORBIDDEN]** Do NOT attempt to audit the API contract from within this routing skill — delegate immediately.
@@ -1,57 +1,77 @@
1
1
  ---
2
2
  name: grill-api-spec
3
- description: EXCLUSIVE /grill-api-spec — ONLY for auditing backend API contracts under surfaces/ (Portal FE backed). DO NOT generate Markdown reports.
3
+ description: EXCLUSIVE /grill-api-spec — audit backend API contracts under surfaces/. DO NOT generate Markdown reports.
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
7
7
  > [!CRITICAL] MANDATORY PRE-FLIGHT
8
8
  > **[MANDATORY]** Re-read this entire `SKILL.md` via file-read tool. STRICTLY FORBIDDEN to rely on memory.
9
- > **[MANDATORY]** Read entire `ir/design.yaml`. If `ir/` is missing, read entire `*.bundle.yaml`.
9
+ > **[MANDATORY]** Read `.cursor/extracts/api-codegen-readiness.md`, `api-codegen-tags.md`, `verify-gate.md`, and `api-contract.md`.
10
+ > **[MANDATORY]** When `feature.source.base` ≠ `none`: read entire `ir/design.yaml`. If `ir/` is missing, read entire `*.bundle.yaml`.
11
+ > **[MANDATORY]** When `feature.source.base: none` (webhook/partner/public API, no portal FE): do **not** use `ir/design.yaml` as BE contract — audit `01-backend-spec.yaml` only.
10
12
 
11
- # /grill-api-spec — API Contract Audit (Portal FE)
13
+ # /grill-api-spec — API Contract Audit
12
14
 
13
15
  After `/api-spec`. Before bộ code BE `/api`. No code implementation on docs hub.
14
16
 
15
- Shared extracts: `spec-evolution.md`, `api-spec-sync.md`, `entity-relationship.md`, `api-codegen-readiness.md`, `api-codegen-tags.md`, `agent-discipline.md`, `verify-gate.md`
17
+ Shared extracts: `spec-evolution.md`, `api-spec-sync.md`, `entity-relationship.md`, `api-codegen-readiness.md`, `api-codegen-tags.md`, `call-external.md`, `agent-discipline.md`, `verify-gate.md`
16
18
 
17
19
  ---
18
20
 
19
21
  ## Rule: Scope
20
22
 
21
- - **[MANDATORY]** Audit `…/api/<seq>/01-backend-spec.yaml`; never a `01` directly on the function slug leaf itself.
23
+ - **[MANDATORY]** Audit `…/api/<seq>/01-backend-spec.yaml` under any surface path (`surfaces/<surface>/…/api/<seq>/`, including dedicated external-channel surfaces).
22
24
  - **[STRICTLY FORBIDDEN]** No BQA 3-Pillars reports. No framework code snippets. No writing `ir/*`.
23
25
 
24
26
  ---
25
27
 
26
28
  ## Rule: Audit Steps
27
29
 
30
+ **Portal-backed (`feature.source.base` ≠ `none`):**
31
+
28
32
  - **[MANDATORY]** Step 1 — Reuse check: `#reuse-api` actions/items must have NO extra trio; `reuseFrom` must point to an existing `01`.
29
33
  - **[MANDATORY]** Step 2 — Cross-check requirements vs endpoints, entities, permissions, validations, errors.
30
- - **[MANDATORY]** Step 3 — Engineering & Error hashtag audit:
31
- - Verify `#call-external`, `#cross-service`, `#cross-entity-service`, `#derived-data`.
32
- - `#tech-debt:*` MUST be `#tech-debt:QA-<feature.id>-NNNN` with a matching file in `qa/open/`.
33
- - Endpoint error storming: `{id}` routes → `#err:not-found` (404) + `#err:idor-violation` (403); POST/PUT → `#err:validation` (422); authed routes → `#err:permission-denied` (403).
34
- - **[MANDATORY]** Step 4 — Enrich `01` with: `codegen.profile|entity|module`, `api.endpoints[].action`, `#gen:*` tags, `approval`.
35
- - **[MANDATORY]** Step 5 — Run gates:
36
- - `flowgrid check --spec surfaces/<surface>/CMP-*/<NN…>/api/<seq>/01-backend-spec.yaml`
37
- - `flowgrid openapi_gen --spec …/01-backend-spec.yaml`
38
- - `flowgrid openapi_render`
39
- - **[MANDATORY]** Only ask member for product decisions; resolve technical gaps from codebase/Portal evidence.
34
+ - **[MANDATORY]** Step 3 — Engineering & Error hashtag audit (`#call-external`, `#tech-debt:QA-*`, error storming matrix).
35
+ - **[MANDATORY]** Step 4 — Enrich `01` with `codegen.profile|entity|module`, `api.endpoints[].action`, `#gen:*`, `approval`.
36
+
37
+ **BE-only / external channel (`feature.source.base: none`):**
38
+
39
+ - **[MANDATORY]** Authentication, `securitySchemes`, idempotency keys, retry policies, non-CRUD actions.
40
+ - **[MANDATORY]** Enrich with `#gen:*`, `#manual-service`, `#call-external`, `codegen.profile|entity|module`, `endpoints[].action`.
41
+ - **[MANDATORY]** Partner/webhook error tags: `#err:signature-invalid`, `#err:rate-limit`, `#err:unauthorized` where applicable.
40
42
 
41
43
  ---
42
44
 
43
- ## Rule: Missing Information
45
+ ## Rule: Gates
46
+
47
+ Run from docs hub cwd (or pass `--docs-root`); paths relative to docs hub:
48
+
49
+ **Deterministic audit (lượng):**
50
+
51
+ 1. `flowgrid audit api <path-to-01-backend-spec.yaml>` — consume `gaps[]` / `confirms[]` on the contract.
52
+ 2. When portal-backed and sibling `*.bundle.yaml` exists: `flowgrid audit fe-be <bundle.yaml>` — `apiRef` ↔ `01` parity.
44
53
 
45
- - **[MANDATORY]** Unknown facts → `AskQuestion` wizard, one question at a time, ≥3 options: (1) Recommended, (2) Other, (3) "Log as Tech Debt".
46
- - **[STRICTLY FORBIDDEN]** No `openQuestions` in YAML. No inventing endpoint logic.
54
+ **Contract toolchain:**
55
+
56
+ 3. `flowgrid api:check --spec <path-to-01-backend-spec.yaml>`
57
+ 4. `flowgrid openapi_gen --spec <same-01>`
58
+ 5. `flowgrid openapi_render`
59
+
60
+ Re-run steps 1–5 after patching `01` until audit gaps are resolved or logged as `#tech-debt:QA-*`.
61
+
62
+ - **[STRICTLY FORBIDDEN]** Do **not** run `flowgrid check` on `01-backend-spec.yaml` — `flowgrid check` is for `*.bundle.yaml` IR sync only.
47
63
 
48
64
  ---
49
65
 
50
66
  ## Verification Checklist
51
67
 
52
- - [ ] `#reuse-api` actions have no extra trio; `reuseFrom` points to existing `01`.
53
- - [ ] Target: `01-backend-spec.yaml` under `…/api/<seq>/` or `…/common/yaml/<slug>/`.
54
- - [ ] Error matrix: `{id}` → 404 + 403 IDOR; POST/PUT → 422; global via OpenAPI `$ref`.
55
- - [ ] `#gen:*` + `action` populated on new `01` files.
56
- - [ ] Gates executed: `flowgrid check` + `openapi:gen` + `openapi:render` exit 0.
57
- - [ ] `approval.status` updated on new `01` YAML.
68
+ - [ ] Target: `01-backend-spec.yaml` under `…/api/<seq>/`.
69
+ - [ ] Portal-backed: `#reuse-api` + error matrix; BE-only: auth + idempotency + retry + `#call-external`.
70
+ - [ ] `audit api` (+ `audit fe-be` when portal bundle present) consumed; no silent structural gaps.
71
+ - [ ] Gates: `api:check` + `openapi_gen` + `openapi_render` exit 0.
72
+ - [ ] `approval.status` updated on `01` YAML.
73
+ - [ ] No `openQuestions` in YAML; no `.md` written directly.
74
+
75
+ ## Handoff
76
+
77
+ - `approval.status: approved` → bộ code BE `/api` with `--spec …/01-backend-spec.yaml`
@@ -26,17 +26,30 @@ disable-model-invocation: true
26
26
 
27
27
  ---
28
28
 
29
+ ## Rule: Audit Interlock (`flowgrid audit spec`)
30
+
31
+ - **[MANDATORY]** Before Step A: run `flowgrid audit spec <*.bundle.yaml> --type <pageType>`.
32
+ - `<pageType>` from `gen.codegen.profile` when set; else infer from prompt (list | create | detail | auth | admin-crud | …) — same table as `docs/workflows/grill-and-human-review.md`.
33
+ - If profile unknown → AskQuestion to lock profile **before** audit (do not use `--type unknown`).
34
+ - **[MANDATORY]** Consume `gaps[]` (patch bundle) and `confirms[]` (AskQuestion with `(Recommended)` from audit): `CONFIRM_UX_*` + **`CONFIRM_DB_*`** (`db-audit-wizard.md`).
35
+ - **[MANDATORY]** After any bundle patch in Step A or B: **re-run** `flowgrid audit spec` until structural `gaps[]` empty or deferred via `qa/open/QA-<bundle.id>-NNNN.yaml`.
36
+ - **[RECOMMENDED]** Resolve `warnings[]` (placeholders, missing metrics/non-goals) when BQA has answers; sync `userStories` if UX copy changed.
37
+ - **[MANDATORY]** After reconcile: `flowgrid split` + `flowgrid render` — stakeholder review uses `ir/generated/spec.md`.
38
+ - **[STRICTLY FORBIDDEN]** Skip audit and rely on manual zone review only.
39
+
40
+ ---
41
+
29
42
  ## Rule: Missing Information / Gap Handling & Workload Threshold (Law 2)
30
43
 
31
44
  - **[MANDATORY]** For `#missing_info` / open gaps: re-check ArtifactGraph → micro-scope → evaluate total gap volume:
32
45
  - **Small Scope (≤5 questions):** `AskQuestion` wizard in chat thread — **one question at a time**, **≥3 options**: (1) `(Recommended)`, (2) `Other` (free text), (3) `Log as Tech Debt (Pending)`.
33
46
  - **Large Scope (≥10 gaps):** **[MANDATORY HARD STOP IN CHAT]**. Do not spam single questions in chat. Generate an implementation plan / Plan Mode document partitioned into sequential Phases (3–5 gaps per phase) with disk offloading at boundaries.
34
- - **[MANDATORY]** If member selects "Log as Tech Debt" → create `qa-inbox.md` entry. Close later with `/qa-resolve`.
47
+ - **[MANDATORY]** If member selects "Log as Tech Debt" → create `qa/open/QA-<bundle.id>-NNNN.yaml`. Close later with `/qa-resolve`.
35
48
  - **[STRICTLY FORBIDDEN]** Never write `openQuestions` in YAML. Never silently overwrite settled SSOT without explicit confirmation.
36
49
 
37
50
  ---
38
51
 
39
- ## Rule: UI Error Handling (3 Outcomes)
52
+ ## Rule: UI Error Handling (4-tier outcomes)
40
53
 
41
54
  - **[MANDATORY]** Every user action / API call in `design.yaml` MUST have the 6-block Action Flow and 4-tier outcomes documented:
42
55
  1. `preconditions`: UI validity, record status, RBAC permissions, disabled reason.
@@ -81,18 +94,19 @@ disable-model-invocation: true
81
94
  ## Workflow
82
95
 
83
96
  **Step A — fact-lock** (`grillStatus.bqaFacts`):
84
- 1. Compare `design.zones/behavior/actions` vs `legacy.ui` vs common UI; cross-check affordances via `flowgrid-ux-common.mdc` when DSL tags exist but behavior is thin.
85
- 2. Audit business focus (summary, requirements, CSS, error flows).
86
- 3. Cross-check common patterns.
87
- 4. Audit UI error handling flows (all 3 outcomes per action).
88
- 5. Patch bundle → `flowgrid split`.
89
- 6. Set `grillStatus.bqaFacts: done`.
97
+ 1. Run `flowgrid audit spec <bundle> --type <pageType>`; patch structural `gaps[]`.
98
+ 2. Compare `design.zones/behavior/actions` vs `legacy.ui` vs common UI; cross-check affordances via `flowgrid-ux-common.mdc` when DSL tags exist but behavior is thin.
99
+ 3. Audit business focus (summary, requirements, CSS, error flows).
100
+ 4. Cross-check common patterns.
101
+ 5. Audit UI error handling flows (4-tier outcomes per action).
102
+ 6. Patch bundle → re-run audit spec → `flowgrid split`.
103
+ 7. Set `grillStatus.bqaFacts: done`.
90
104
 
91
105
  **Step B — member wizard** (`grillStatus.bqaOpen`):
92
- 7. AskQuestion for remaining gaps (batches ≤5).
93
- 8. Apply member decisions to bundle.
94
- 9. Set `grillStatus.bqaOpen: done`.
95
- 10. User runs `docs_render` / `flowgrid render`.
106
+ 8. AskQuestion for remaining `confirms[]` / BQA gaps (batches ≤5).
107
+ 9. Apply member decisions to bundle → re-run `flowgrid audit spec`.
108
+ 10. Set `grillStatus.bqaOpen: done`.
109
+ 11. User runs `docs_render` / `flowgrid render`.
96
110
 
97
111
  ---
98
112
 
@@ -112,7 +126,8 @@ disable-model-invocation: true
112
126
 
113
127
  - [ ] Load policy complied (did not load codegen, legacy source code, or generated `*.md`).
114
128
  - [ ] Step A completed with `grillStatus.bqaFacts: done` before Step B.
115
- - [ ] Every action/API call in `design.yaml` has all 3 error outcomes (Success + CommonError + SpecificError).
129
+ - [ ] `flowgrid audit spec` run before Step A, after patches, and before handoff to `/grill-dev`.
130
+ - [ ] Every action/API call in `design.yaml` has 4-tier outcomes (success, business, security, system).
116
131
  - [ ] `summary` is 100% Non-tech; `spec.requirements` covers Validations, State Machine, Permissions, Edge Cases.
117
132
  - [ ] All gaps used AskQuestion wizard + member confirm (or `QA-*` pointer). No `openQuestions` in YAML.
118
133
  - [ ] `grillStatus.bqaOpen: done` after this pass.