create-mercato-app 0.6.7-develop.6690.1.d1d863d951 → 0.6.7-develop.6692.1.d0a4413933

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 (74) hide show
  1. package/agentic/guides/backend-ui.md +1 -1
  2. package/agentic/guides/spec-delivery.md +22 -0
  3. package/agentic/shared/AGENTS.md.template +2 -2
  4. package/agentic/shared/ai/skills/om-auto-implement-spec/SKILL.md +21 -0
  5. package/agentic/shared/ai/skills/om-implement-spec/SKILL.md +9 -5
  6. package/agentic/shared/ai/skills/om-implement-spec/references/phases-and-gates.md +26 -5
  7. package/agentic/shared/ai/specs/README.md +4 -3
  8. package/agentic/shared/ai/specs/SPEC-000-template.md +226 -10
  9. package/dist/agentic/guides/backend-ui.md +1 -1
  10. package/dist/agentic/guides/module-facts.json +108 -108
  11. package/dist/agentic/guides/modules/ai_assistant.md +1 -1
  12. package/dist/agentic/guides/modules/api_docs.md +1 -1
  13. package/dist/agentic/guides/modules/api_keys.md +1 -1
  14. package/dist/agentic/guides/modules/attachments.md +1 -1
  15. package/dist/agentic/guides/modules/audit_logs.md +1 -1
  16. package/dist/agentic/guides/modules/auth.md +1 -1
  17. package/dist/agentic/guides/modules/business_rules.md +1 -1
  18. package/dist/agentic/guides/modules/catalog.md +1 -1
  19. package/dist/agentic/guides/modules/channel_gmail.md +1 -1
  20. package/dist/agentic/guides/modules/channel_imap.md +1 -1
  21. package/dist/agentic/guides/modules/checkout.md +1 -1
  22. package/dist/agentic/guides/modules/communication_channels.md +1 -1
  23. package/dist/agentic/guides/modules/configs.md +1 -1
  24. package/dist/agentic/guides/modules/content.md +1 -1
  25. package/dist/agentic/guides/modules/currencies.md +1 -1
  26. package/dist/agentic/guides/modules/customer_accounts.md +1 -1
  27. package/dist/agentic/guides/modules/customers.md +1 -1
  28. package/dist/agentic/guides/modules/dashboards.md +1 -1
  29. package/dist/agentic/guides/modules/data_sync.md +1 -1
  30. package/dist/agentic/guides/modules/dictionaries.md +1 -1
  31. package/dist/agentic/guides/modules/directory.md +1 -1
  32. package/dist/agentic/guides/modules/entities.md +1 -1
  33. package/dist/agentic/guides/modules/events.md +1 -1
  34. package/dist/agentic/guides/modules/feature_toggles.md +1 -1
  35. package/dist/agentic/guides/modules/gateway_stripe.md +1 -1
  36. package/dist/agentic/guides/modules/generators.md +1 -1
  37. package/dist/agentic/guides/modules/inbox_ops.md +1 -1
  38. package/dist/agentic/guides/modules/integrations.md +1 -1
  39. package/dist/agentic/guides/modules/messages.md +1 -1
  40. package/dist/agentic/guides/modules/notifications.md +1 -1
  41. package/dist/agentic/guides/modules/onboarding.md +1 -1
  42. package/dist/agentic/guides/modules/payment_gateways.md +1 -1
  43. package/dist/agentic/guides/modules/perspectives.md +1 -1
  44. package/dist/agentic/guides/modules/planner.md +1 -1
  45. package/dist/agentic/guides/modules/portal.md +1 -1
  46. package/dist/agentic/guides/modules/progress.md +1 -1
  47. package/dist/agentic/guides/modules/query_index.md +1 -1
  48. package/dist/agentic/guides/modules/record_locks.md +1 -1
  49. package/dist/agentic/guides/modules/resources.md +1 -1
  50. package/dist/agentic/guides/modules/sales.md +1 -1
  51. package/dist/agentic/guides/modules/scheduler.md +1 -1
  52. package/dist/agentic/guides/modules/search.md +1 -1
  53. package/dist/agentic/guides/modules/security.md +1 -1
  54. package/dist/agentic/guides/modules/shipping_carriers.md +1 -1
  55. package/dist/agentic/guides/modules/sso.md +1 -1
  56. package/dist/agentic/guides/modules/staff.md +1 -1
  57. package/dist/agentic/guides/modules/storage_s3.md +1 -1
  58. package/dist/agentic/guides/modules/sync_akeneo.md +1 -1
  59. package/dist/agentic/guides/modules/sync_excel.md +1 -1
  60. package/dist/agentic/guides/modules/system_status_overlays.md +1 -1
  61. package/dist/agentic/guides/modules/translations.md +1 -1
  62. package/dist/agentic/guides/modules/webhooks.md +1 -1
  63. package/dist/agentic/guides/modules/wms.md +1 -1
  64. package/dist/agentic/guides/modules/workflows.md +1 -1
  65. package/dist/agentic/guides/spec-delivery.md +22 -0
  66. package/dist/agentic/guides/upstream/manifest.json +1 -1
  67. package/dist/agentic/shared/AGENTS.md.template +2 -2
  68. package/dist/agentic/shared/ai/skills/om-auto-implement-spec/SKILL.md +21 -0
  69. package/dist/agentic/shared/ai/skills/om-implement-spec/SKILL.md +9 -5
  70. package/dist/agentic/shared/ai/skills/om-implement-spec/references/phases-and-gates.md +26 -5
  71. package/dist/agentic/shared/ai/specs/README.md +4 -3
  72. package/dist/agentic/shared/ai/specs/SPEC-000-template.md +226 -10
  73. package/package.json +3 -3
  74. package/template/AGENTS.md +2 -2
@@ -26,7 +26,7 @@ For a new editable entity or module, unless the brief explicitly excludes an ope
26
26
 
27
27
  ## DataTable
28
28
 
29
- - Use `DataTable` with stable colon-form `entityId`, `apiPath`, and `extensionTableId`. These are host contracts, not cosmetic props.
29
+ - Use `DataTable` with a stable colon-form `entityId`, explicit typed data/pagination loaded through shared API helpers, and `extensionTableId`. These are host contracts, not cosmetic props; `DataTable` has no `apiPath` prop.
30
30
  - Use shared column helpers, `RowActions` with stable action IDs, built-in filter/search/export/column controls, and DataTable bulk-action surfaces.
31
31
  - When owning pagination, wire page, page size, total count, and change handlers together. Do not slice a server page again in the client.
32
32
  - Use the table's empty state and shared loading/error components. A successful empty result is not an error.
@@ -0,0 +1,22 @@
1
+ # Specification Delivery
2
+
3
+ Use this guide for a new application, multi-module feature, or other non-trivial business slice.
4
+
5
+ ## Authoring readiness gate
6
+
7
+ 1. Invoke `om-spec-writing` before authoring or revising. Mentioning the skill or reading only `SPEC-000-template.md` is not sufficient.
8
+ 2. After invocation, read `.ai/specs/SPEC-000-template.md` and preserve every section; use `N/A — reason` only when a section genuinely does not apply.
9
+ 3. Keep status `Draft` until no blocking open question remains and every requirement maps to an acceptance criterion, implementation phase, and self-contained test oracle.
10
+ 4. For each affected UI route, inspect and cite the closest existing Open Mercato page plus `.ai/guides/backend-ui.md`; specify its text mockup/structure, actions, data source and mutations, permissions, canonical shell/components, and loading/empty/error/conflict/keyboard/a11y/responsive/light/dark states. Tabular admin data names `DataTable`; CRUD create/edit names `CrudForm`; backend reads name shared API helpers; every exception has an explicit rationale.
11
+ 5. New applications and multi-module requests also define domain vocabulary/invariants, measurable success, navigation/widgets, module ownership and extension points, architecture/data flow, and concrete risk scenarios. A page inventory alone is not an app architecture.
12
+ 6. Phases are dependency-ordered complete vertical slices with concrete deliverables, acceptance IDs, bounded slices, tests, validation commands, business value, and observable exit gates. Do not defer required behavior to a catch-all “integration/polish” phase.
13
+ 7. Mark the spec `Ready for implementation` only after the traceability and final compliance matrices pass and the user approves implementation.
14
+
15
+ ## Implementation phase gate
16
+
17
+ - Use `om-implement-spec` for local delivery and `om-auto-implement-spec` for whole-spec PR delivery.
18
+ - Only the current unblocked phase may be in progress. Parallelize independent slices inside that phase only; never start a dependent module/phase before its prerequisite exit gate passes.
19
+ - Delegation does not bypass routing. Before any UI slice, actually invoke `om-backend-ui-design` and read `.ai/guides/backend-ui.md`; naming them in an agent prompt is not invocation. Every implementation brief names the active phase, routed guides/skills, closest reference page, canonical primitives, acceptance IDs, owned files, and validation oracle.
20
+ - Reject raw backend tables/forms/fetch, copied component families, arbitrary values, hard-coded palette/status colors, and light-only styling unless the approved spec records a necessary exception. UI phase evidence exercises affected routes in light and dark mode and at narrow width, including loading/empty/error/conflict and keyboard behavior.
21
+ - A phase remains open while it has stubs, missing integration evidence, unmet acceptance IDs, or failing validation. Generated discovery, file count, and typecheck alone do not prove completion.
22
+ - If no remote/tracker exists, report PR delivery unavailable and invoke local `om-implement-spec` phase-by-phase; never improvise a concurrent whole-spec build.
@@ -93,7 +93,7 @@ Pinned delivery skills: `yarn install-skills` (refresh: `--update`). Read BOTH `
93
93
 
94
94
  | Route ID | Delivery need | Skill |
95
95
  |---|---|---|
96
- | `spec-pr` | Write/revise spec | `om-spec-writing` (OMH-005) + exact `.ai/agentic.config.json` for its specs-directory setting |
96
+ | `spec-pr` | Write/revise spec | MUST invoke `om-spec-writing` (OMH-005) + `.ai/guides/spec-delivery.md` + config specs path |
97
97
  | `spec-pr` | Implement approved phases locally | `om-implement-spec` (OMH-006) |
98
98
  | `spec-pr` | Whole-spec / commit+ready PR / issue / review | `om-auto-implement-spec` / `om-auto-create-pr` / `om-auto-fix-issue` / `om-auto-review-pr` |
99
99
  | `testing` | Integration/E2E/UI QA | `om-integration-tests` / `om-auto-qa-pr` |
@@ -105,7 +105,7 @@ Absent skill: run `yarn install-skills` once; never substitute.
105
105
 
106
106
  - Load matched guides once, then only needed references/facts.
107
107
  - Hard budgets: guide > skill > references; open a reference only for its named subject.
108
- - Specs: list names; open one task match; skip README/template.
108
+ - Specs: open one match; `spec-pr` reads template via spec-delivery.
109
109
  - Inspect app call sites before bounded `framework-context`.
110
110
  - Additive page/form/table/conflict UI skips it.
111
111
  - Never bulk-read guide, skill, fact, or source trees.
@@ -0,0 +1,21 @@
1
+ > **Repo-local override.** This folder extends the external `om-auto-implement-spec` skill installed from `open-mercato/skills`. Apply these standalone readiness and no-remote rules on top of the external workflow; do not install this file as a replacement skill.
2
+
3
+ # Standalone portability overrides — `om-auto-implement-spec`
4
+
5
+ Everything tracker-facing uses the operations and guards from `.ai/trackers/github.md`. Resolve an automatic base branch through **default-branch**; never assume `main` or `develop`.
6
+
7
+ ## 1. Audit the resolved spec before choosing an engine
8
+
9
+ After resolving the spec and before creating implementation tasks, read `.ai/specs/SPEC-000-template.md` and `.ai/skills/om-implement-spec/references/phases-and-gates.md`, then run the complete readiness audit. The spec must be `Ready for implementation`, have no blocking open questions, map every requirement to an acceptance criterion/phase/self-contained test oracle, define every affected UI and API contract, and give every phase dependencies plus an observable exit gate. UI contracts must cite an installed reference and require the platform shell/components, shared API helpers, semantic tokens, and light/dark plus responsive state coverage.
10
+
11
+ An incomplete or `Draft` spec is not an engine plan. Stop implementation, report the missing readiness items, and route revision through `om-spec-writing`; never fill the gaps inside generated agent prompts.
12
+
13
+ ## 2. Preserve phase dependencies in PR delivery
14
+
15
+ When a remote and tracker are available, keep the external PR workflow but seed its execution plan from the spec phases. Only the current unblocked phase may be in progress. Parallel agents may own independent slices inside that phase only, and each brief must name routed guides/skills, closest installed reference, canonical primitives, acceptance IDs, owned files, and a validation oracle. Invoke routed skills before delegation, including `om-backend-ui-design` for rendered surfaces. A phase advances only after its integration paths and exit gate pass.
16
+
17
+ Do not launch one agent per future module, mark blocked phases in progress, or treat generated files/typecheck as proof that a business slice is implemented.
18
+
19
+ ## 3. No-remote fallback is local and phase-safe
20
+
21
+ Standalone apps commonly start without a Git remote. If the tracker operations cannot resolve a repository/remote, report that PR delivery is unavailable and invoke the local `.ai/skills/om-implement-spec/SKILL.md` against the resolved spec, phase-by-phase. Do not improvise the external PR engine locally, claim a PR exists, or collapse the whole spec into concurrent module scaffolding.
@@ -10,15 +10,19 @@ Leave the app working after every phase and keep implementation traceable to the
10
10
  ## Workflow
11
11
 
12
12
  1. Read the full spec, root `AGENTS.md`, existing related specs, and `references/phases-and-gates.md`; resolve contradictions before coding.
13
- 2. Map each selected phase to Task Router rows and package/module facts. Use `om-framework-context` only for missing exact-version details.
14
- 3. Break work into cohesive dependency-ordered slices. Use one bounded subagent per independent research/implementation/test/review task when available; never let agents overlap files without coordination.
15
- 4. Implement one slice through real call sites, run its focused tests, and update spec/progress evidence before starting dependent work.
16
- 5. Run generation/migration probes at their owning slice. Ask before schema application, dependency changes, public-contract changes, or scope reduction.
17
- 6. Execute integration paths from the spec, then type/lint/test/build gates and a code review. Remediate findings before reporting completion.
13
+ 2. Run the reference's readiness audit. A `Draft`, blocking open question, missing requirement traceability, or unspecified UI/API contract returns to `om-spec-writing`; do not infer the missing design while implementing.
14
+ 3. Map the selected current phase to Task Router rows and package/module facts. Invoke every routed skill before delegating or coding; for any rendered surface this includes `om-backend-ui-design` and `.ai/guides/backend-ui.md`. A prompt that merely names a skill is not a substitute for loading it. Use `om-framework-context` only for missing exact-version details.
15
+ 4. Break only that phase into cohesive dependency-ordered slices. Use one bounded subagent per independent research/implementation/test/review task when available; never let agents overlap files or enter a later phase.
16
+ 5. Implement one complete slice through real call sites, run its focused tests, and update spec/progress evidence before starting dependent work.
17
+ 6. Run generation/migration probes at their owning slice. Ask before schema application, dependency changes, public-contract changes, or scope reduction.
18
+ 7. Close the current phase with its specified integration paths and exit gate. Only then may the next phase enter implementation; after the final phase run type/lint/test/build gates and a code review.
18
19
 
19
20
  ## Rules
20
21
 
21
22
  - Do not silently skip acceptance criteria, collapse phases, or treat partial scaffolding as implementation.
23
+ - Only one dependency-ordered phase may be `in_progress`. A phase remains open when it has stubs, failing validation, missing integration evidence, or unmet acceptance IDs, regardless of how many files were generated.
24
+ - Parallel agents may own independent slices inside the active phase only. Every brief names its owned files, routed guides/skills, closest installed reference, canonical primitives, acceptance IDs, and validation oracle.
25
+ - Backend UI must use the platform page shell, `DataTable`/`CrudForm` where their contracts apply, shared API helpers, exported controls, and semantic tokens. Raw tables/forms/fetch, copied component families, arbitrary values, hard-coded palette/status colors, and light-only styling require an approved spec exception.
22
26
  - Each completed implementation phase must leave a working app (`working-phases`) and report its smallest focused validation gate (`smallest-validation`); `integration-coverage` belongs to writing the spec, not implementing already approved phases.
23
27
  - Preserve compatibility and standalone writable boundaries; never patch installed/generated files.
24
28
  - Regression tests must fail before their fix and use self-contained fixtures.
@@ -2,11 +2,32 @@
2
2
 
3
3
  Load this reference before implementation.
4
4
 
5
+ ## Readiness audit
6
+
7
+ Before creating implementation tasks, require all of the following:
8
+
9
+ 1. The spec status is `Ready for implementation`, not `Draft`.
10
+ 2. No blocking open question is unresolved.
11
+ 3. Every requirement maps to an acceptance criterion, phase, and self-contained test oracle.
12
+ 4. Every affected UI route cites the closest installed reference and names its structure/mockup, actions, data source/mutations, permissions, canonical shell/components, and loading/empty/error/conflict/keyboard/a11y/responsive/light/dark states. Lists and CRUD surfaces name `DataTable`/`CrudForm` and shared API helpers unless an approved exception explains why they cannot satisfy the interaction.
13
+ 5. Every affected API/command names its auth, scope, input, response/event, error, concurrency, and compatibility contracts.
14
+ 6. Each phase names dependencies, concrete deliverables, acceptance IDs, tests, validation commands, and an observable exit gate.
15
+
16
+ If any item is absent, stop implementation and return the spec to `om-spec-writing`. Do not fill design gaps opportunistically in agent prompts.
17
+
18
+ ## Phase state machine
19
+
5
20
  1. Build a requirement-to-phase matrix with acceptance path, affected modules/packages, routed guides/skills, dependencies, BC surfaces, schema impact, and test oracle.
6
- 2. Order by foundations then complete vertical slices. Every phase leaves generation/typecheck/tests working.
7
- 3. Assign independent research, implementation, integration-test, and review tasks to bounded subagents when available; one owner per file/slice.
8
- 4. After each slice, run focused tests and record files/commands/results plus remaining work in the spec/progress artifact.
9
- 5. Run schema probe at the data slice; run generation at each discovery slice; never defer all integration until the end.
10
- 6. Final gate: all spec API/UI paths with self-contained fixtures, affected safety cases, typecheck/lint/test/build, packed standalone boundary when relevant, and code review findings resolved.
21
+ 2. Keep phases in `pending in_progress → verified` order. Only one phase may be `in_progress`; a phase can start only when every declared dependency is `verified`.
22
+ 3. Order by foundations and then complete vertical slices. Do not launch one agent per later module or implement all entities/APIs first and postpone their required UI/integration to a catch-all phase.
23
+ 4. Inside the active phase, assign only independent research, implementation, integration-test, and review slices to bounded agents. Give each one owned files, routed guides/skills, closest installed reference, canonical primitives, acceptance IDs, and a validation oracle; one owner per file/slice. Invoke routed skills before delegation—especially `om-backend-ui-design` for rendered surfaces—rather than paraphrasing guessed conventions into the prompt.
24
+ 5. After each slice, run focused tests and record files/commands/results plus remaining work in the spec/progress artifact. File count, generated discovery, and typecheck alone never prove a business slice works.
25
+ 6. Run the schema probe at its data slice and generation at every discovery slice; never defer all integration until the end.
26
+
27
+ ## Phase exit gate
28
+
29
+ A phase becomes `verified` only when all of its specified deliverables exist through real call sites, no required page is a stub, every mapped acceptance ID is exercised, its self-contained API/UI paths pass, and its focused generation/typecheck/tests are green. For affected UI, compare the result with the cited reference and verify the platform shell/components, shared API helpers, semantic tokens, light/dark themes, narrow width, quality states, keyboard flow, and absence of undocumented raw-table/form/fetch or hard-coded-color substitutes. A failure keeps the phase `in_progress` and blocks every dependent phase.
30
+
31
+ After the final phase, run all spec API/UI paths with self-contained fixtures, affected safety cases, typecheck/lint/test/build, the packed standalone boundary when relevant, and code review. Resolve findings before reporting completion.
11
32
 
12
33
  If an acceptance criterion cannot be met without scope/architecture/public-contract change, stop and ask rather than silently revising the spec.
@@ -21,6 +21,7 @@ Example: 2026-03-01-inventory-module.md
21
21
 
22
22
  ## Workflow
23
23
 
24
- 1. Before coding any significant feature, check for an existing spec
25
- 2. If none: create from SPEC-000-template.md, review with team, then code
26
- 3. After implementation: update the spec's Changelog and Acceptance Criteria
24
+ 1. Route every new application, multi-module feature, or non-trivial business slice through `om-spec-writing` and `.ai/guides/spec-delivery.md`.
25
+ 2. After invoking the skill, create the skeleton from `SPEC-000-template.md`; keep it `Draft` while blocking questions or incomplete contracts remain.
26
+ 3. Set `Ready for implementation` only after the final compliance report and requirement traceability pass and the user approves implementation.
27
+ 4. Implement through `om-implement-spec` (local) or `om-auto-implement-spec` (PR), one dependency-ordered phase at a time; update the Changelog, acceptance evidence, and phase state as work lands.
@@ -3,33 +3,249 @@
3
3
  **Date**: {YYYY-MM-DD}
4
4
  **Status**: Draft
5
5
 
6
+ > Use `om-spec-writing` for every new application, multi-module feature, or other non-trivial business slice. Keep every section below; write `N/A — {reason}` when a section does not apply. Change the status to `Ready for implementation` only after every blocking open question is resolved and the traceability table covers every requirement.
7
+
6
8
  ## TLDR
7
9
 
8
- {2-3 sentence summary}
10
+ {What is being built, who benefits, which existing Open Mercato capabilities are reused, and the smallest coherent outcome.}
9
11
 
10
12
  ## Problem Statement
11
13
 
12
- {What problem this feature solves}
14
+ {Current workflow, concrete pain, evidence, affected users, and why existing behavior is insufficient.}
15
+
16
+ ## Overview and Success Measures
17
+
18
+ - **Primary outcome:** {Measurable business result and target.}
19
+ - **Leading indicators:** {Signals available before the final outcome.}
20
+ - **Baseline:** {Current measurable state or `unknown — measurement plan`.}
21
+ - **Market / product reference:** {Comparable product or workflow studied; what is adopted, rejected, and why.}
22
+
23
+ ## Goals
24
+
25
+ - **REQ-001** — {Observable business outcome.}
26
+ - **REQ-002** — {Observable business outcome.}
27
+
28
+ ## Non-goals
29
+
30
+ - {Explicitly excluded behavior, module, integration, or migration.}
13
31
 
14
32
  ## Proposed Solution
15
33
 
16
- {High-level approach}
34
+ {Describe the product and technical approach, how it closes each stated problem, and why it is the smallest platform-native solution that can deliver the goals.}
35
+
36
+ ### Design Decisions and Alternatives
37
+
38
+ | Decision | Rationale | Alternative considered | Why rejected / deferred |
39
+ |---|---|---|---|
40
+ | {choice} | {why it fits the requirements and platform} | {alternative} | {tradeoff} |
41
+
42
+ ## Domain Vocabulary and Business Rules
43
+
44
+ | Term / invariant | Precise meaning or rule | Source of truth | Failure behavior |
45
+ |---|---|---|---|
46
+ | {term} | {one unambiguous meaning, formula, lifecycle, or constraint} | {module/entity/provider} | {reject/degrade/retry/audit} |
47
+
48
+ Define fields, states, transitions, calculations, ownership, and invariants precisely enough that implementation does not need to invent domain behavior.
49
+
50
+ ## Users, Permissions, and Scope
51
+
52
+ | Actor | Allowed outcomes | Scope rule | Required feature IDs |
53
+ |---|---|---|---|
54
+ | {actor} | {view/create/update/etc.} | {own/team/organization/system} | `{module}.view`, `{module}.manage` |
55
+
56
+ Document how trusted `tenantId` and `organizationId` are derived. Describe any legitimate system-scope operation and the installed contract that authorizes it.
57
+
58
+ ## Reuse and Ownership Map
59
+
60
+ | Capability | Reuse / extend / app-own | Existing module or new module | Integration seam | Why |
61
+ |---|---|---|---|---|
62
+ | {capability} | {reuse/UMES/app-owned} | `{module}` | {ID/snapshot/event/enricher/extension/optional DI} | {decision} |
63
+
64
+ Name the installed records that remain the source of truth. Do not duplicate CRM, auth, directory, notification, workflow, or other installed capabilities in app-owned entities.
65
+
66
+ ## Architecture and Data Flow
67
+
68
+ ```text
69
+ {actor/surface} -> {API/command} -> {owning entity}
70
+ -> {event/subscriber/integration}
71
+ ```
72
+
73
+ - **Module boundaries:** {Why each new module owns a distinct invariant; merge modules that must remain transactionally consistent.}
74
+ - **Extension points:** {Installed page/menu/widget/enricher/interceptor/event seams used instead of modifying installed code.}
75
+ - **Alternatives considered:** {Simpler platform-native alternative and why it was not selected.}
76
+ - **Compatibility:** {Existing API/data/UI behavior that must remain stable.}
77
+
78
+ ## User Journeys
79
+
80
+ ### Journey J-001 — {Name}
81
+
82
+ 1. {Actor starts from a named page or API.}
83
+ 2. {Primary action and system response.}
84
+ 3. {Success state and downstream side effects.}
85
+ 4. {Recoverable failure, permission denial, conflict, and retry behavior.}
86
+
87
+ ## UI and Interaction Contracts
88
+
89
+ List every new or changed page before implementation. Inspect the closest existing Open Mercato page and `.ai/guides/backend-ui.md`; record that reference below. Tabular admin data uses `DataTable`, CRUD create/edit surfaces use `CrudForm`, and backend reads use the shared API helpers. Any custom page or component exception needs an explicit rationale and approval in this section.
90
+
91
+ | Surface / route | Purpose and primary actions | Data source / mutations | Closest installed reference | Canonical shell / components | Required states | Requirement IDs |
92
+ |---|---|---|---|---|---|---|
93
+ | `/backend/{route}` | {list/create/edit/etc.} | `{API paths / command IDs}` | `{module/path or component family}` | `Page`, `PageBody`, `DataTable`, `CrudForm`, {others} | loading, empty, error, conflict, success, permission denied | REQ-001 |
94
+
95
+ ### UI architecture
96
+
97
+ | Role | Navigation groups in order | Dashboard / injected widgets | Login-to-primary-task flow |
98
+ |---|---|---|---|
99
+ | {role} | {group → item} | {widget, host, click-through} | {page → action → result; target ≤3 clicks} |
100
+
101
+ | Surface / widget | Empty state guidance and action | Responsive behavior | Keyboard / focus behavior |
102
+ |---|---|---|---|
103
+ | {surface} | {localized explanation + next action} | {narrow/mobile layout} | {focus order, submit/cancel, announcements} |
104
+
105
+ ### `/backend/{route}` — {Page name}
106
+
107
+ ```text
108
+ ┌────────────────────────────────────────────────────────────┐
109
+ │ {Page title} [{Primary action}]│
110
+ │ {Filters / summary / navigation} │
111
+ ├────────────────────────────────────────────────────────────┤
112
+ │ {DataTable, CrudForm groups, calendar, or detail sections} │
113
+ ├────────────────────────────────────────────────────────────┤
114
+ │ {Pagination / save-delete actions / status feedback} │
115
+ └────────────────────────────────────────────────────────────┘
116
+ ```
117
+
118
+ - **Behavior:** {sorting/filtering/pagination, validation, keyboard behavior, navigation, destructive confirmation, optimistic-lock conflict recovery.}
119
+ - **Responsive and accessibility:** {focus order, labels, screen-reader status, small-screen behavior.}
120
+ - **Localization:** {translation namespaces and dynamic values.}
121
+ - **Design-system and theming:** {semantic tokens and shared primitives; verify light and dark mode, contrast, reduced motion, and no hard-coded palette/status colors.}
122
+
123
+ For backend UI, implementation must invoke `om-backend-ui-design` and follow `.ai/guides/backend-ui.md`. Raw `<table>`, raw admin `<form>`, raw `fetch`, copied component families, arbitrary Tailwind values, hard-coded light-only colors, and manual `dark:` patches fail readiness unless the approved contract explains why the platform primitive cannot support the interaction. A custom calendar, board, or clinical workspace may be justified, but its surrounding shell, controls, status treatment, dialogs, states, and tokens remain platform-native.
17
124
 
18
125
  ## Data Models
19
126
 
20
- {Entity definitions, relationships}
127
+ ### `{Entity}`
128
+
129
+ | Field | Type / nullability | Scope / index | Sensitive / encrypted | Lifecycle and validation |
130
+ |---|---|---|---|---|
131
+ | `id` | UUID, required | primary key | no | immutable |
132
+ | `tenant_id` / `organization_id` | UUID, required | composite scope indexes | no | trusted context only |
133
+ | `updated_at` | timestamp, required | optimistic-lock version | no | updated on every edit |
134
+
135
+ Document entity ownership, soft-delete or append-only rules, cross-module IDs/snapshots, uniqueness, transactions, encryption maps, retention, migrations, and compatibility impact.
136
+
137
+ ## API, Command, and Error Contracts
138
+
139
+ | Method / command | Path / ID | Auth and feature gate | Input | Success response / event | Errors and concurrency | Requirement IDs |
140
+ |---|---|---|---|---|---|---|
141
+ | `GET` | `/api/{path}` | auth + `{module}.view` | {query schema} | `{ items, totalCount }` | 400/401/403 | REQ-001 |
142
+ | `POST` | `/api/{path}` | auth + `{module}.manage` | {body schema} | 201 + `{module}.{entity}.created` | 400/403/409 | REQ-002 |
143
+
144
+ State whether each route uses `makeCrudRoute` or a custom guarded command route. Include per-method `metadata`, OpenAPI schemas, scope derivation, idempotency, optimistic locking, and stable public-contract implications.
145
+
146
+ ## Events, Jobs, Notifications, and Cross-Module Flows
147
+
148
+ | Trigger | Producer | Consumer | Side effect | Retry / idempotency / audit behavior |
149
+ |---|---|---|---|---|
150
+ | `{module}.{entity}.{action}` | `{module}` | `{subscriber}` | {result} | {contract} |
151
+
152
+ Describe scheduled work, progress, cache invalidation, failure recovery, and optional-module behavior where applicable.
153
+
154
+ ## Security, Privacy, and Compliance
155
+
156
+ - **Authorization:** {feature gates and record-level scope; never role-name checks.}
157
+ - **Tenant isolation:** {read/write filters and fail-closed behavior.}
158
+ - **Sensitive data:** {encryption map, safe reads, redaction, retention, audit policy.}
159
+ - **Abuse and failure modes:** {enumeration, injection, replay, concurrency, destructive action, secret exposure.}
160
+
161
+ ## Integration Coverage
162
+
163
+ Tests must be self-contained and map to real API and UI paths.
164
+
165
+ | Test ID | Level | Setup / fixture | Actions | Assertions | Requirement IDs |
166
+ |---|---|---|---|---|---|
167
+ | TEST-001 | integration | {tenant/org/users/records} | {API or browser flow} | {success + persisted state + event} | REQ-001 |
168
+ | TEST-002 | security | {second tenant / insufficient feature} | {forbidden read/write} | {fail closed; no data leak} | REQ-001 |
169
+ | TEST-003 | UI | {records and permissions} | {loading/empty/error/conflict/keyboard flow} | {observable result} | REQ-002 |
170
+
171
+ ## Implementation Phases
172
+
173
+ Phases are dependency ordered. Only the current phase may enter implementation; parallel work is limited to independent slices inside that phase. Each phase must leave a working app and close with its own evidence before the next phase starts.
21
174
 
22
- ## API Contracts
175
+ ### Phase 1 — {Foundation or first complete vertical slice}
23
176
 
24
- {Endpoints, request/response schemas}
177
+ - **Depends on:** none
178
+ - **Outcome:** {user-visible or independently verifiable result}
179
+ - **Why this order / value delivered:** {dependency and measurable business value available at phase completion}
180
+ - **Deliverables:** {specific entities, commands, routes, pages, subscribers, migrations}
181
+ - **Independent slices / estimated commits:** {bounded work that may run in parallel inside this phase only}
182
+ - **Requirements closed:** REQ-001
183
+ - **Tests:** TEST-001, TEST-002
184
+ - **Validation:** `yarn generate`, {focused typecheck/tests/integration paths}
185
+ - **Exit gate:** {observable criteria proving this phase works end to end, including affected UI in light/dark and narrow-width states}
186
+
187
+ ### Phase 2 — {Next complete vertical slice}
188
+
189
+ - **Depends on:** Phase 1 exit gate
190
+ - **Outcome:** {result}
191
+ - **Why this order / value delivered:** {dependency and measurable business value}
192
+ - **Deliverables:** {specific files/seams}
193
+ - **Independent slices / estimated commits:** {bounded work inside this phase}
194
+ - **Requirements closed:** REQ-002
195
+ - **Tests:** TEST-003
196
+ - **Validation:** {focused commands}
197
+ - **Exit gate:** {observable criteria}
198
+
199
+ ## Requirement Traceability
200
+
201
+ | Requirement | Journey / surface | Data/API/event contracts | Phase | Tests | Acceptance criterion |
202
+ |---|---|---|---|---|---|
203
+ | REQ-001 | J-001, `/backend/{route}` | `{entity}`, `GET /api/{path}` | Phase 1 | TEST-001, TEST-002 | AC-001 |
204
+
205
+ Every requirement must map to a phase, at least one test oracle, and a measurable acceptance criterion. No phase may be a catch-all “integration and polish” bucket for behavior required by earlier slices.
206
+
207
+ ## Rollout, Migration, and Rollback
208
+
209
+ {Migration generation/application boundary, seed/setup work, feature flags, compatibility bridge, observability, rollout order, and reversible rollback steps.}
210
+
211
+ ## Risks and Tradeoffs
212
+
213
+ | Risk / tradeoff | Impact | Mitigation / detection | Residual risk |
214
+ |---|---|---|---|
215
+ | {risk} | {impact} | {test/metric/guard} | {accepted remainder} |
216
+
217
+ Cover data integrity and concurrency, cascading/event failures, tenant isolation and privacy, migration/rollback, external-service degradation, scale/storage, and operational detection. Do not use “standard risks” as a substitute for concrete failure scenarios.
25
218
 
26
219
  ## Acceptance Criteria
27
220
 
28
- - [ ] {Criterion 1}
29
- - [ ] {Criterion 2}
221
+ - [ ] **AC-001** — {Measurable end-to-end result, including actor and scope.}
222
+ - [ ] **AC-002** — {Measurable failure/safety result.}
223
+ - [ ] Every listed backend surface matches its recorded Open Mercato reference and uses the canonical shell/components, shared API helpers, semantic tokens, and complete loading, empty, error, conflict, keyboard, accessibility, responsive, light-mode, and dark-mode states.
224
+ - [ ] Every affected API and UI path has self-contained integration coverage and the configured validation gate passes.
225
+
226
+ ## Final Compliance Report
227
+
228
+ | Check | Status | Evidence / resolution |
229
+ |---|---|---|
230
+ | Applicable `AGENTS.md` files and routed guides/skills reviewed | pass/fail | {paths} |
231
+ | Data models, APIs, events, UI, and tests are internally consistent | pass/fail | {traceability rows} |
232
+ | Every workflow completes end to end without a catch-all integration phase | pass/fail | {journeys/phases} |
233
+ | Platform-native reuse and extension points were chosen before custom code | pass/fail | {reuse decisions} |
234
+ | UI contracts identify references, canonical components, and theme/state coverage | pass/fail | {surfaces} |
235
+ | Every phase has dependencies, bounded slices, tests, value, and an observable exit gate | pass/fail | {phases} |
236
+
237
+ Verdict must be exactly `Ready for implementation` or `Blocked — {unresolved items}`. The document status may change to ready only when every row passes.
238
+
239
+ ## Open Questions
240
+
241
+ Blocking questions must be resolved before setting `Status: Ready for implementation`.
242
+
243
+ | ID | Question | Owner | Blocking? | Resolution / decision date |
244
+ |---|---|---|---|---|
245
+ | Q-001 | {question} | {owner} | yes/no | {pending or decision} |
30
246
 
31
247
  ## Changelog
32
248
 
33
249
  | Date | Change |
34
- |------|--------|
35
- | {date} | Initial spec |
250
+ |---|---|
251
+ | {date} | Initial draft |
@@ -26,7 +26,7 @@ For a new editable entity or module, unless the brief explicitly excludes an ope
26
26
 
27
27
  ## DataTable
28
28
 
29
- - Use `DataTable` with stable colon-form `entityId`, `apiPath`, and `extensionTableId`. These are host contracts, not cosmetic props.
29
+ - Use `DataTable` with a stable colon-form `entityId`, explicit typed data/pagination loaded through shared API helpers, and `extensionTableId`. These are host contracts, not cosmetic props; `DataTable` has no `apiPath` prop.
30
30
  - Use shared column helpers, `RowActions` with stable action IDs, built-in filter/search/export/column controls, and DataTable bulk-action surfaces.
31
31
  - When owning pagination, wire page, page size, total count, and change handlers together. Do not slice a server page again in the client.
32
32
  - Use the table's empty state and shared loading/error components. A successful empty result is not an error.