@polymorphism-tech/morph-spec 9.7.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/CLAUDE.md +11 -11
  2. package/README.md +4 -4
  3. package/bin/morph-spec.js +41 -44
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +24 -30
  8. package/framework/MORPH.md +47 -123
  9. package/framework/agents.json +6 -374
  10. package/framework/commands/morph-apply.md +1 -1
  11. package/framework/commands/morph-archive.md +4 -3
  12. package/framework/commands/morph-hotfix.md +8 -30
  13. package/framework/commands/morph-infra.md +2 -2
  14. package/framework/commands/morph-media.md +10 -9
  15. package/framework/commands/morph-review.md +15 -0
  16. package/framework/commands/morph-status.md +1 -1
  17. package/framework/docs/CLI.md +100 -102
  18. package/framework/evals/review-checklist.md +46 -54
  19. package/framework/hooks/README.md +4 -4
  20. package/framework/hooks/claude-code/__pycache__/statusline.cpython-313.pyc +0 -0
  21. package/framework/hooks/claude-code/core/README.md +1 -1
  22. package/framework/hooks/claude-code/core/denylist.json +4 -4
  23. package/framework/hooks/claude-code/core/gate-guard.js +9 -0
  24. package/framework/hooks/claude-code/core/masked-exit.js +49 -0
  25. package/framework/hooks/claude-code/core/state-sync.js +4 -1
  26. package/framework/hooks/claude-code/core/telemetry-log.js +1 -2
  27. package/framework/hooks/claude-code/core/test-budget.js +10 -70
  28. package/framework/hooks/claude-code/core/validate-completion.js +11 -24
  29. package/framework/hooks/claude-code/core/worktree-context.js +5 -22
  30. package/framework/hooks/claude-code/core/worktree-create.js +6 -45
  31. package/framework/hooks/claude-code/core/worktree-env-inject.js +2 -10
  32. package/framework/hooks/shared/e2e-check.js +0 -0
  33. package/framework/hooks/shared/gate-event.js +2 -2
  34. package/framework/hooks/shared/graph-refresh.js +20 -3
  35. package/framework/hooks/shared/heavy-command.js +32 -1
  36. package/framework/hooks/shared/heavy-config.js +1 -1
  37. package/framework/hooks/shared/heavy-slots.js +41 -4
  38. package/framework/hooks/shared/next-step.js +63 -24
  39. package/framework/hooks/shared/phase-utils.js +6 -9
  40. package/framework/hooks/shared/report-progress.js +86 -0
  41. package/framework/hooks/shared/state-reader.js +3 -2
  42. package/framework/hooks/statusline.js +332 -0
  43. package/framework/phases.json +32 -10
  44. package/framework/rules/ai-agents-standards.md +9 -1
  45. package/framework/rules/csharp-standards.md +4 -0
  46. package/framework/rules/ef-standards.md +20 -0
  47. package/framework/rules/frontend-standards.md +1 -1
  48. package/framework/rules/implement-report.md +25 -0
  49. package/framework/rules/infrastructure-standards.md +2 -0
  50. package/framework/rules/nextjs-standards.md +7 -0
  51. package/framework/rules/plan-grammar.md +53 -0
  52. package/framework/rules/ui-design.md +27 -0
  53. package/framework/schemas/config.schema.json +12 -19
  54. package/framework/schemas/feature.schema.json +7 -1
  55. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  56. package/framework/skills/core/create-umbraco-lp/references/umbraco-lp-patterns.md +1 -1
  57. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +2 -2
  58. package/framework/skills/core/morph-apply/SKILL.md +38 -166
  59. package/framework/skills/core/morph-apply/references/debugging.md +8 -0
  60. package/framework/skills/core/morph-apply/references/hotfix.md +42 -0
  61. package/framework/skills/core/morph-apply/references/machine.md +29 -0
  62. package/framework/skills/core/{morph-media/SKILL.md → morph-apply/references/media.md} +11 -74
  63. package/framework/skills/core/morph-apply/references/review.md +65 -0
  64. package/framework/skills/core/morph-plan/SKILL.md +42 -108
  65. package/framework/skills/core/morph-plan/references/critique.md +40 -0
  66. package/framework/skills/core/morph-plan/references/interview.md +25 -0
  67. package/framework/skills/core/morph-uiux/SKILL.md +47 -64
  68. package/framework/skills/core/morph-uiux/surfaces.json +32 -0
  69. package/framework/standards/STANDARDS.json +32 -5
  70. package/framework/standards/STANDARDS.meta.json +5 -1
  71. package/framework/standards/ai-agents/agent-session.md +2 -3
  72. package/framework/standards/ai-agents/context-providers.md +2 -2
  73. package/framework/standards/ai-agents/durable-workflows-hitl.md +2 -2
  74. package/framework/standards/ai-agents/providers/model-registry.md +2 -2
  75. package/framework/standards/ai-agents/rag-custom-pgvector.md +6 -6
  76. package/framework/standards/ai-agents/setup.md +1 -1
  77. package/framework/standards/ai-agents/tool-adapters.md +2 -2
  78. package/framework/standards/architecture/stack-baseline.md +47 -0
  79. package/framework/standards/backend/integrations/neon-auth/neon-auth.md +2 -4
  80. package/framework/standards/frontend/design-system/ai-image-generation.md +51 -12
  81. package/framework/standards/frontend/design-system/ai-video-generation.md +50 -4
  82. package/framework/standards/frontend/design-system/art-direction.md +2 -2
  83. package/framework/standards/frontend/scroll-driven/frame-scrub.md +12 -2
  84. package/framework/standards/frontend/scroll-driven/scroll-components.md +76 -4
  85. package/framework/templates/.idea/morph-templates.xml +92 -0
  86. package/framework/templates/.vscode/morph-templates.code-snippets +186 -0
  87. package/framework/templates/IDE-SNIPPETS.md +262 -262
  88. package/framework/templates/REGISTRY.json +1 -2
  89. package/framework/templates/code/dotnet/abstractions/api-endpoint.cs +7 -7
  90. package/framework/templates/code/dotnet/feature/request.cs.hbs +4 -4
  91. package/framework/templates/code/dotnet/feature/response.cs.hbs +4 -4
  92. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -91
  93. package/framework/templates/context/ARCHITECTURE.md +1 -1
  94. package/framework/templates/docs/plan.md +12 -12
  95. package/framework/templates/docs/ui-mockups.md +17 -105
  96. package/framework/templates/frontend/nextjs/client-component.tsx.hbs +26 -26
  97. package/framework/templates/frontend/nextjs/tsconfig.json.hbs +26 -26
  98. package/framework/templates/infrastructure/docker/Dockerfile.template +58 -58
  99. package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
  100. package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
  101. package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +45 -45
  102. package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +27 -27
  103. package/framework/templates/infrastructure/github/workflows/docker-build-push.yml.hbs +59 -59
  104. package/framework/templates/infrastructure/github/workflows/dotnet-build.yml.hbs +39 -39
  105. package/framework/templates/state.template.json +17 -17
  106. package/framework/templates/ui/design-system.css +226 -226
  107. package/package.json +1 -1
  108. package/src/commands/e2e/e2e.js +88 -23
  109. package/src/commands/graph/diff.js +74 -0
  110. package/src/commands/graph/status.js +1 -1
  111. package/src/commands/observability/cost.js +2 -4
  112. package/src/commands/observability/telemetry.js +1 -1
  113. package/src/commands/project/doctor.js +23 -39
  114. package/src/commands/project/fleet.js +5 -6
  115. package/src/commands/project/init.js +63 -36
  116. package/src/commands/project/stack-scan.js +3 -42
  117. package/src/commands/project/stack-set.js +26 -0
  118. package/src/commands/project/status.js +12 -13
  119. package/src/commands/project/update.js +39 -3
  120. package/src/commands/project/worktree.js +27 -16
  121. package/src/commands/state/advance.js +17 -17
  122. package/src/commands/state/approve.js +0 -6
  123. package/src/commands/state/archive.js +27 -1
  124. package/src/commands/state/auto-approval.js +1 -1
  125. package/src/commands/state/create.js +0 -5
  126. package/src/commands/state/finish.js +43 -1
  127. package/src/commands/state/gate-check.js +37 -30
  128. package/src/commands/state/gate-decision.js +3 -2
  129. package/src/commands/state/next.js +1 -0
  130. package/src/commands/state/recap.js +67 -0
  131. package/src/commands/state/report-check.js +39 -146
  132. package/src/commands/validation/plan-check.js +16 -11
  133. package/src/commands/validation/validate-feature.js +3 -3
  134. package/src/commands/validation/verify.js +6 -6
  135. package/src/core/paths/output-schema.js +3 -3
  136. package/src/core/state/state-manager.js +2 -4
  137. package/src/dashboard/app/components/CommandPalette.jsx +2 -5
  138. package/src/dashboard/app/components/GatePauses.jsx +116 -0
  139. package/src/dashboard/app/components/SessionMap.jsx +77 -0
  140. package/src/dashboard/app/main.jsx +13 -13
  141. package/src/dashboard/app/pages/Activity.jsx +4 -0
  142. package/src/dashboard/app/pages/AgentMap.jsx +1 -2
  143. package/src/dashboard/app/pages/FeatureDetail.jsx +129 -186
  144. package/src/dashboard/app/pages/Features.jsx +7 -7
  145. package/src/dashboard/app/pages/PhasePipeline.jsx +1 -1
  146. package/src/dashboard/app/pages/Portfolio.jsx +40 -5
  147. package/src/dashboard/scanner/activity-scanner.js +29 -0
  148. package/src/dashboard/scanner/agents-scanner.js +11 -14
  149. package/src/dashboard/scanner/features-scanner.js +45 -24
  150. package/src/dashboard/scanner/project-api.js +11 -2
  151. package/src/dashboard/scanner/skills-scanner.js +11 -1
  152. package/src/dashboard/vite.config.js +24 -24
  153. package/src/lib/e2e/applicability.js +3 -1
  154. package/src/lib/git/tree-state.js +1 -16
  155. package/src/lib/graph/diff-tree.js +127 -0
  156. package/src/lib/graph/graphify-runtime.js +12 -5
  157. package/src/lib/heavy/gate.js +22 -1
  158. package/src/lib/installers/memory-installer.js +2 -2
  159. package/src/lib/installers/rules-installer.js +57 -0
  160. package/src/lib/installers/stack-assets.js +17 -0
  161. package/src/lib/installers/stack-sync.js +219 -0
  162. package/src/lib/plan/checks.js +55 -110
  163. package/src/lib/plan/critique.js +28 -0
  164. package/src/lib/plan/media.js +42 -0
  165. package/src/lib/plan/plan-html.js +125 -0
  166. package/src/lib/plan/plan-parser.js +34 -45
  167. package/src/lib/recap/piper.js +36 -0
  168. package/src/lib/recap/recap.js +232 -0
  169. package/src/lib/review-reports.js +33 -7
  170. package/src/lib/risk-detector.js +90 -11
  171. package/src/lib/specs/screen-checklist.js +33 -48
  172. package/src/lib/stack/dotnet-build-ignores.js +8 -9
  173. package/src/lib/tasks/test-nodes.js +24 -6
  174. package/src/lib/tasks/test-runner.js +40 -1
  175. package/src/lib/telemetry/metrics.js +27 -29
  176. package/src/lib/validators/reuse/reuse-validator.js +1 -9
  177. package/src/lib/validators/verify-runner.js +50 -19
  178. package/src/lib/worktree/fleet-scanner.js +7 -20
  179. package/src/lib/worktree/worktree-audit.js +0 -37
  180. package/src/scripts/setup-infra.js +15 -50
  181. package/src/utils/agents-installer.js +27 -201
  182. package/src/utils/hooks-installer.js +11 -95
  183. package/framework/hooks/claude-code/core/warn-bash-source-write.js +0 -23
  184. package/framework/hooks/claude-code/statusline.py +0 -699
  185. package/framework/hooks/claude-code/statusline.sh +0 -11
  186. package/framework/hooks/shared/agent-reap.js +0 -74
  187. package/framework/hooks/shared/slice-progress.js +0 -110
  188. package/framework/skills/core/morph-hotfix/SKILL.md +0 -133
  189. package/framework/skills/core/morph-machine/SKILL.md +0 -46
  190. package/framework/skills/core/morph-review/SKILL.md +0 -129
  191. package/framework/skills/core/morph-standards/SKILL.md +0 -52
  192. package/framework/standards/PROVENANCE.json +0 -119
  193. package/src/commands/project/worktree-reap.js +0 -34
  194. package/src/commands/state/handoff.js +0 -65
  195. package/src/commands/validation/mutate.js +0 -263
  196. package/src/commands/validation/scout-check.js +0 -28
  197. package/src/lib/generators/handoff-generator.js +0 -172
  198. package/src/lib/mutation/adapters.js +0 -79
  199. package/src/lib/mutation/commands.js +0 -61
  200. package/src/lib/mutation/dotnet-introspection.js +0 -281
  201. package/src/lib/mutation/manifest.js +0 -144
  202. package/src/lib/mutation/plan.js +0 -44
  203. package/src/lib/mutation/report.js +0 -68
  204. package/src/lib/mutation/runner.js +0 -301
  205. package/src/lib/mutation/schemata.js +0 -60
  206. package/src/lib/mutation/snapshot.js +0 -65
  207. package/src/lib/mutation/subset.js +0 -109
  208. package/src/lib/mutation/trx.js +0 -50
  209. package/src/lib/scout/scout-check.js +0 -293
  210. package/src/lib/validators/traceability-check.js +0 -103
  211. package/src/lib/worktree/agent-reaper.js +0 -247
@@ -1,91 +1,91 @@
1
- -- TEMPLATE: pgvector-embeddings-migration.sql
2
- -- PURPOSE: Creates the kb_embeddings table for custom RAG — chunk storage with pgvector.
3
- -- READS STANDARD: ai-agents-rag-custom-pgvector
4
- -- PLACEHOLDERS:
5
- -- {{SCHEMA}} — target schema (default: public)
6
- -- LAST-VERIFIED: 2026-05-19
7
- --
8
- -- PREREQUISITES:
9
- -- - pgvector extension enabled in Neon (see infrastructure-neon-pgvector).
10
- -- - NpgsqlDataSourceBuilder.UseVector() called in the project's DB setup.
11
- --
12
- -- DIMENSION NOTE:
13
- -- embedding vector(1536) matches text-embedding-3-small (default 1536 dimensions).
14
- -- If the project uses a different embedding model, adjust the dimension to match.
15
- -- NEVER mix embedding models on a single column — vectors live in different spaces.
16
-
17
- -- ============================================================
18
- -- 1. EXTENSION
19
- -- ============================================================
20
-
21
- CREATE EXTENSION IF NOT EXISTS vector;
22
-
23
- -- ============================================================
24
- -- 2. TABLE
25
- -- ============================================================
26
-
27
- CREATE TABLE {{SCHEMA}}.kb_embeddings (
28
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
29
- tenant_id uuid NOT NULL,
30
- source text NOT NULL, -- document identifier or source URL
31
- chunk_index int NOT NULL, -- position of this chunk within the source document
32
- content text NOT NULL, -- chunk text returned to the agent as context
33
- embedding vector(1536) NOT NULL, -- vector dimension must match embedding model
34
- metadata jsonb NOT NULL DEFAULT '{}',
35
- created_at timestamptz NOT NULL DEFAULT now()
36
- );
37
-
38
- COMMENT ON TABLE {{SCHEMA}}.kb_embeddings IS 'RAG knowledge base — chunk text and pgvector embeddings for semantic search.';
39
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.tenant_id IS 'Tenant partition. Every query MUST filter on this column. Never query across tenants.';
40
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.source IS 'Document identifier or URL. Used for citation and re-indexing detection.';
41
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.chunk_index IS 'Zero-based position of this chunk within the source document.';
42
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.content IS 'Chunk text returned to the agent. Plain text, no markup.';
43
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.embedding IS 'Float vector. Dimension MUST match the embedding model declared in model-registry.json.';
44
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.metadata IS 'Arbitrary JSON metadata (section headers, page numbers, doc type, etc.). Used for filtering.';
45
-
46
- -- ============================================================
47
- -- 3. INDEXES
48
- -- ============================================================
49
-
50
- -- HNSW index for cosine similarity — production-grade recall, no training data required.
51
- -- vector_cosine_ops: use <=> operator (cosine distance, ascending = most similar first).
52
- -- m=16, ef_construction=64 are pgvector defaults. Tune per infrastructure-neon-pgvector §HNSW Parameters.
53
- CREATE INDEX ix_kb_embeddings_hnsw
54
- ON {{SCHEMA}}.kb_embeddings
55
- USING hnsw (embedding vector_cosine_ops)
56
- WITH (m = 16, ef_construction = 64);
57
-
58
- -- Index for the mandatory tenant_id filter (applied in every search query).
59
- CREATE INDEX ix_kb_embeddings_tenant
60
- ON {{SCHEMA}}.kb_embeddings (tenant_id);
61
-
62
- -- Composite index for source-level operations (re-indexing, deletion by document).
63
- CREATE INDEX ix_kb_embeddings_source
64
- ON {{SCHEMA}}.kb_embeddings (tenant_id, source);
65
-
66
- -- ============================================================
67
- -- 4. ROW-LEVEL SECURITY (multi-tenant)
68
- -- ============================================================
69
-
70
- -- RLS enforces tenant isolation at the database level as a second line of defence.
71
- -- The application already filters on tenant_id in every query; RLS is the backstop.
72
- --
73
- -- See templates/code/sql/postgresql-rls-policy.sql for the policy pattern that
74
- -- binds app.current_tenant_id (a session-level setting) to the RLS policy.
75
- --
76
- -- Uncomment and adapt once RLS is wired in the project:
77
- --
78
- -- ALTER TABLE {{SCHEMA}}.kb_embeddings ENABLE ROW LEVEL SECURITY;
79
- --
80
- -- CREATE POLICY kb_embeddings_tenant_isolation
81
- -- ON {{SCHEMA}}.kb_embeddings
82
- -- USING (tenant_id = current_setting('app.current_tenant_id')::uuid);
83
-
84
- -- ============================================================
85
- -- ROLLBACK
86
- -- ============================================================
87
-
88
- -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_hnsw;
89
- -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_tenant;
90
- -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_source;
91
- -- DROP TABLE IF EXISTS {{SCHEMA}}.kb_embeddings CASCADE;
1
+ -- TEMPLATE: pgvector-embeddings-migration.sql
2
+ -- PURPOSE: Creates the kb_embeddings table for custom RAG — chunk storage with pgvector.
3
+ -- READS STANDARD: ai-agents-rag-custom-pgvector
4
+ -- PLACEHOLDERS:
5
+ -- {{SCHEMA}} — target schema (default: public)
6
+ -- LAST-VERIFIED: 2026-05-19
7
+ --
8
+ -- PREREQUISITES:
9
+ -- - pgvector extension enabled in Neon (see infrastructure-neon-pgvector).
10
+ -- - NpgsqlDataSourceBuilder.UseVector() called in the project's DB setup.
11
+ --
12
+ -- DIMENSION NOTE:
13
+ -- embedding vector(1536) matches text-embedding-3-small (default 1536 dimensions).
14
+ -- If the project uses a different embedding model, adjust the dimension to match.
15
+ -- NEVER mix embedding models on a single column — vectors live in different spaces.
16
+
17
+ -- ============================================================
18
+ -- 1. EXTENSION
19
+ -- ============================================================
20
+
21
+ CREATE EXTENSION IF NOT EXISTS vector;
22
+
23
+ -- ============================================================
24
+ -- 2. TABLE
25
+ -- ============================================================
26
+
27
+ CREATE TABLE {{SCHEMA}}.kb_embeddings (
28
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
29
+ tenant_id uuid NOT NULL,
30
+ source text NOT NULL, -- document identifier or source URL
31
+ chunk_index int NOT NULL, -- position of this chunk within the source document
32
+ content text NOT NULL, -- chunk text returned to the agent as context
33
+ embedding vector(1536) NOT NULL, -- vector dimension must match embedding model
34
+ metadata jsonb NOT NULL DEFAULT '{}',
35
+ created_at timestamptz NOT NULL DEFAULT now()
36
+ );
37
+
38
+ COMMENT ON TABLE {{SCHEMA}}.kb_embeddings IS 'RAG knowledge base — chunk text and pgvector embeddings for semantic search.';
39
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.tenant_id IS 'Tenant partition. Every query MUST filter on this column. Never query across tenants.';
40
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.source IS 'Document identifier or URL. Used for citation and re-indexing detection.';
41
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.chunk_index IS 'Zero-based position of this chunk within the source document.';
42
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.content IS 'Chunk text returned to the agent. Plain text, no markup.';
43
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.embedding IS 'Float vector. Dimension MUST match the embedding model declared in model-registry.json.';
44
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.metadata IS 'Arbitrary JSON metadata (section headers, page numbers, doc type, etc.). Used for filtering.';
45
+
46
+ -- ============================================================
47
+ -- 3. INDEXES
48
+ -- ============================================================
49
+
50
+ -- HNSW index for cosine similarity — production-grade recall, no training data required.
51
+ -- vector_cosine_ops: use <=> operator (cosine distance, ascending = most similar first).
52
+ -- m=16, ef_construction=64 are pgvector defaults. Tune per infrastructure-neon-pgvector §HNSW Parameters.
53
+ CREATE INDEX ix_kb_embeddings_hnsw
54
+ ON {{SCHEMA}}.kb_embeddings
55
+ USING hnsw (embedding vector_cosine_ops)
56
+ WITH (m = 16, ef_construction = 64);
57
+
58
+ -- Index for the mandatory tenant_id filter (applied in every search query).
59
+ CREATE INDEX ix_kb_embeddings_tenant
60
+ ON {{SCHEMA}}.kb_embeddings (tenant_id);
61
+
62
+ -- Composite index for source-level operations (re-indexing, deletion by document).
63
+ CREATE INDEX ix_kb_embeddings_source
64
+ ON {{SCHEMA}}.kb_embeddings (tenant_id, source);
65
+
66
+ -- ============================================================
67
+ -- 4. ROW-LEVEL SECURITY (multi-tenant)
68
+ -- ============================================================
69
+
70
+ -- RLS enforces tenant isolation at the database level as a second line of defence.
71
+ -- The application already filters on tenant_id in every query; RLS is the backstop.
72
+ --
73
+ -- See templates/code/sql/postgresql-rls-policy.sql for the policy pattern that
74
+ -- binds app.current_tenant_id (a session-level setting) to the RLS policy.
75
+ --
76
+ -- Uncomment and adapt once RLS is wired in the project:
77
+ --
78
+ -- ALTER TABLE {{SCHEMA}}.kb_embeddings ENABLE ROW LEVEL SECURITY;
79
+ --
80
+ -- CREATE POLICY kb_embeddings_tenant_isolation
81
+ -- ON {{SCHEMA}}.kb_embeddings
82
+ -- USING (tenant_id = current_setting('app.current_tenant_id')::uuid);
83
+
84
+ -- ============================================================
85
+ -- ROLLBACK
86
+ -- ============================================================
87
+
88
+ -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_hnsw;
89
+ -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_tenant;
90
+ -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_source;
91
+ -- DROP TABLE IF EXISTS {{SCHEMA}}.kb_embeddings CASCADE;
@@ -88,7 +88,7 @@
88
88
  ## Centralidade (grafo de codebase)
89
89
 
90
90
  Símbolos com mais conexões depois do saneamento — o que quebra mais se mudar.
91
- Detalhe de um símbolo: `morph-spec graph explain <nome>`.
91
+ Detalhe de um símbolo: `morph-spec graph explain <nome>` (sem grafo, símbolo ausente ou ambíguo: `grep -rn <nome>`).
92
92
 
93
93
  | Símbolo | Arquivo | Grau |
94
94
  |---------|---------|------|
@@ -15,10 +15,21 @@
15
15
 
16
16
  - <o que foi assumido sem prova; "nenhuma" vale>
17
17
 
18
+ ## Padrões assumidos
19
+
20
+ <!-- Valor de baixo risco que você decidiu sem perguntar, numerado: o usuário veta por número ("veta 2").
21
+ Auth, credencial, permissão, pagamento e apagar dado nunca entram aqui: viram pergunta. "nenhum" vale. -->
22
+
23
+ 1. <padrão e o valor escolhido>
24
+
25
+ <!-- Opcional, só se algo muda de estado: uma seção "Estados" (h2) com uma transição por linha,
26
+ "- origem → destino: gatilho". O plan-check desenha a máquina em 2-plan/plan.html. -->
27
+
18
28
  ## Cenários
19
29
 
20
30
  <!-- Um cenário por comportamento observável. `prova:` é teste | e2e | eval | manual | leitura.
21
31
  `prova: teste` exige `risco:` regra | dinheiro | contrato | concorrência | dado | regressão; sem risco, `leitura`.
32
+ `degrau:` migrar | irreversível quando um revert não desfaz (toda migration é migrar); sem a linha, refazer.
22
33
  Cenário que fala de arquivo, grep ou texto exige a linha "> Por que artefato:" logo abaixo. -->
23
34
 
24
35
  - **C1** — Dado <estado>, quando <ação>, então <resultado observável>.
@@ -56,19 +67,8 @@ nenhum
56
67
  |---|---|---|---|
57
68
  | <conceito> | REUSAR | <arquivo ou símbolo existente> | |
58
69
 
59
- ## Fatias
60
-
61
- <!-- Uma fatia = uma unidade de entrega (com ou sem dispatch), relatório em 3-implement/reports/Fn.md.
62
- arquivos ≤ 8; superfície e depende são opcionais; toda Cn é coberta por alguma fatia. -->
63
-
64
- ### F1 — <título>
65
- - persona: dotnet-senior
66
- - standards: <id>
67
- - arquivos: <caminho/a.cs>, <caminho/b.cs>
68
- - cobre: C1
69
-
70
70
  ## Contrato de implementação
71
71
 
72
- <Assinaturas, records, enums e rotas que as fatias precisam honrar.>
72
+ <Assinaturas, records, enums e rotas que a implementação honra; runtime do e2e; baseline de teste como comando.>
73
73
 
74
74
  ## Errata
@@ -1,119 +1,31 @@
1
- # UI Mockups & Wireframes: {{titleCase FEATURE_NAME}}
1
+ # Mockups: {{titleCase FEATURE_NAME}}
2
2
 
3
- | Field | Value |
4
- |-------|-------|
5
- | **Feature** | {{FEATURE_NAME}} |
6
- | **Created** | {{DATE}} |
3
+ <!-- Uma `## Tela:` por tela nova ou alterada. As opções navegáveis ficam em 1-design/opcoes/{tela}.html;
4
+ a escolhida vira 1-design/prototipos/{tela}.html, com os prints {tela}-1280.png e {tela}-390.png ao lado,
5
+ e um seletor de estado (data-estado="vazio|carregando|erro", ?estado=) com {tela}-{estado}-390.png de cada
6
+ estado que o checklist diz que se aplica. Faltando um, o Gate uiux pausa. -->
7
7
 
8
- ---
9
-
10
- ## Screen Inventory
11
-
12
- | Screen ID | Name | Route | Priority |
13
- |-----------|------|-------|----------|
14
- | **S001** | {Screen Name} | /path | High |
15
- | **S002** | {Screen Name} | /path | Medium |
16
-
17
- ---
18
-
19
- ## Tela: {Primary Screen}
8
+ ## Tela: {Nome da tela}
20
9
 
21
10
  **Protótipo:** 1-design/prototipos/{tela}.html
22
-
23
- O protótipo renderizado é a fonte visual da tela; os prints `{tela}-1280.png` e `{tela}-390.png` ficam ao lado dele, e sem os três arquivos o Gate uiux pausa. O layout em texto abaixo é opcional.
24
-
25
- ### Desktop Layout
26
-
27
- ```
28
- ┌─────────────────────────────────────┐
29
- │ Header [User ▼] │
30
- ├─────────────────────────────────────┤
31
- │ │
32
- │ [Title] │
33
- │ │
34
- │ ┌──────────────────────────────┐ │
35
- │ │ Main Content Area │ │
36
- │ │ │ │
37
- │ │ [Card 1] [Card 2] │ │
38
- │ │ │ │
39
- │ │ ┌────────────────────────┐ │ │
40
- │ │ │ Data Table │ │ │
41
- │ │ │ ... │ │ │
42
- │ │ └────────────────────────┘ │ │
43
- │ └──────────────────────────────┘ │
44
- │ │
45
- └─────────────────────────────────────┘
46
- ```
47
-
48
- ### Mobile Layout
49
-
50
- ```
51
- ┌──────────────────────┐
52
- │ ☰ Title [User ▼]│
53
- ├──────────────────────┤
54
- │ │
55
- │ [Card 1] │
56
- │ │
57
- │ [Card 2] │
58
- │ │
59
- │ [View All Items] │
60
- │ │
61
- └──────────────────────┘
62
- ```
11
+ **Direção escolhida:** <qual opção de opcoes/{tela}.html e por quê, numa frase>
63
12
 
64
13
  ### Checklist de tela
65
14
 
66
- Troque cada `…` pela decisão — "não se aplica" vale se escrito; `…`, vazio ou "a definir" reprovam o Gate uiux.
15
+ Troque cada `…` pela decisão. "Não se aplica" vale se escrito; `…`, vazio ou "a definir" reprovam o Gate uiux.
67
16
 
68
17
  | Item | Decisão |
69
18
  |---|---|
70
- | Superfície | … |
71
- | Volume esperado | … |
72
- | Paginação | … |
73
- | Ordenação | … |
74
- | Filtro | … |
75
- | Estado vazio | … |
76
- | Estado carregando | … |
77
- | Estado de erro | … |
78
- | Mobile | … |
79
- | Abas | … |
80
-
81
- ---
82
-
83
- ## States
84
-
85
- ### Loading
86
- - Show skeleton placeholders
87
- - Spinner for primary content
88
-
89
- ### Empty
90
- - Icon + message
91
- - Clear call-to-action button
92
-
93
- ### Error
94
- - Warning icon
95
- - User-friendly message
96
- - Retry button
97
-
98
- ### Success (After Action)
99
- - Toast notification
100
- - Auto-dismiss after 3s
101
-
102
- ---
103
-
104
- ## Interactions
105
-
106
- - **Hover**: Subtle elevation increase
107
- - **Click**: Scale down (0.98)
108
- - **Transitions**: Fade-in 200ms
19
+ | Lista no servidor | … |
20
+ | Estados vazio e carregando | … |
21
+ | Erro com próxima ação | … |
22
+ | Uma ação primária | … |
23
+ | Celular | … |
109
24
 
110
- ---
25
+ ### Componentes
111
26
 
112
- ## Accessibility
113
- - [ ] 44x44px minimum touch targets
114
- - [ ] Focus indicators visible
115
- - [ ] Proper heading hierarchy (H1 → H2 → H3)
27
+ - <componente do design system reusado, ou novo e por quê>
116
28
 
117
- ---
29
+ ### Fluxo
118
30
 
119
- *Generated with MORPH Framework*
31
+ 1. <passo do usuário até o resultado>
@@ -1,26 +1,26 @@
1
- // features/{{kebabCase featureName}}/components/{{kebabCase featureName}}-list.tsx
2
- 'use client';
3
-
4
- import { use{{pascalCase featureName}}s } from '@/features/{{kebabCase featureName}}/hooks/use-{{kebabCase featureName}}s';
5
- import { DataTable } from '@/components/data-table';
6
- import type { {{pascalCase featureName}} } from '@/features/{{kebabCase featureName}}/types/{{kebabCase featureName}}.types';
7
- import type { ColumnDef } from '@tanstack/react-table';
8
-
9
- const columns: ColumnDef<{{pascalCase featureName}}>[] = [
10
- { accessorKey: 'id', header: 'ID' },
11
- { accessorKey: 'name', header: 'Name' },
12
- ];
13
-
14
- interface {{pascalCase featureName}}ListProps {
15
- initialData?: {{pascalCase featureName}}[];
16
- }
17
-
18
- export function {{pascalCase featureName}}List({ initialData }: {{pascalCase featureName}}ListProps) {
19
- const { data = initialData ?? [], isLoading } = use{{pascalCase featureName}}s();
20
-
21
- if (isLoading) {
22
- return <div className="flex items-center justify-center h-32">Loading...</div>;
23
- }
24
-
25
- return <DataTable columns={columns} data={data} />;
26
- }
1
+ // features/{{kebabCase featureName}}/components/{{kebabCase featureName}}-list.tsx
2
+ 'use client';
3
+
4
+ import { use{{pascalCase featureName}}s } from '@/features/{{kebabCase featureName}}/hooks/use-{{kebabCase featureName}}s';
5
+ import { DataTable } from '@/components/data-table';
6
+ import type { {{pascalCase featureName}} } from '@/features/{{kebabCase featureName}}/types/{{kebabCase featureName}}.types';
7
+ import type { ColumnDef } from '@tanstack/react-table';
8
+
9
+ const columns: ColumnDef<{{pascalCase featureName}}>[] = [
10
+ { accessorKey: 'id', header: 'ID' },
11
+ { accessorKey: 'name', header: 'Name' },
12
+ ];
13
+
14
+ interface {{pascalCase featureName}}ListProps {
15
+ initialData?: {{pascalCase featureName}}[];
16
+ }
17
+
18
+ export function {{pascalCase featureName}}List({ initialData }: {{pascalCase featureName}}ListProps) {
19
+ const { data = initialData ?? [], isLoading } = use{{pascalCase featureName}}s();
20
+
21
+ if (isLoading) {
22
+ return <div className="flex items-center justify-center h-32">Loading...</div>;
23
+ }
24
+
25
+ return <DataTable columns={columns} data={data} />;
26
+ }
@@ -1,26 +1,26 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "lib": ["dom", "dom.iterable", "esnext"],
5
- "allowJs": false,
6
- "skipLibCheck": true,
7
- "strict": true,
8
- "noUncheckedIndexedAccess": true,
9
- "noImplicitOverride": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "noEmit": true,
12
- "esModuleInterop": true,
13
- "module": "esnext",
14
- "moduleResolution": "bundler",
15
- "resolveJsonModule": true,
16
- "isolatedModules": true,
17
- "jsx": "preserve",
18
- "incremental": true,
19
- "plugins": [{ "name": "next" }],
20
- "paths": {
21
- "@/*": ["./src/*"]
22
- }
23
- },
24
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
- "exclude": ["node_modules"]
26
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": false,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noUncheckedIndexedAccess": true,
9
+ "noImplicitOverride": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "noEmit": true,
12
+ "esModuleInterop": true,
13
+ "module": "esnext",
14
+ "moduleResolution": "bundler",
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "jsx": "preserve",
18
+ "incremental": true,
19
+ "plugins": [{ "name": "next" }],
20
+ "paths": {
21
+ "@/*": ["./src/*"]
22
+ }
23
+ },
24
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
+ "exclude": ["node_modules"]
26
+ }
@@ -1,58 +1,58 @@
1
- # Multi-stage Dockerfile for Next.js Production Build
2
- # Optimized for Next.js 15 with App Router
3
-
4
- FROM node:20-alpine AS base
5
-
6
- # Install dependencies only when needed
7
- FROM base AS deps
8
- RUN apk add --no-cache libc6-compat
9
- WORKDIR /app
10
-
11
- # Copy package files
12
- COPY package.json package-lock.json* ./
13
- RUN npm ci
14
-
15
- # Rebuild the source code only when needed
16
- FROM base AS builder
17
- WORKDIR /app
18
- COPY --from=deps /app/node_modules ./node_modules
19
- COPY . .
20
-
21
- # Set build-time environment variables
22
- ENV NEXT_TELEMETRY_DISABLED 1
23
-
24
- # Build Next.js application
25
- RUN npm run build
26
-
27
- # Production image, copy all the files and run next
28
- FROM base AS runner
29
- WORKDIR /app
30
-
31
- ENV NODE_ENV production
32
- ENV NEXT_TELEMETRY_DISABLED 1
33
-
34
- # Create nextjs user
35
- RUN addgroup --system --gid 1001 nodejs
36
- RUN adduser --system --uid 1001 nextjs
37
-
38
- # Copy built application
39
- COPY --from=builder /app/public ./public
40
-
41
- # Set the correct permission for prerender cache
42
- RUN mkdir .next
43
- RUN chown nextjs:nodejs .next
44
-
45
- # Automatically leverage output traces to reduce image size
46
- # https://nextjs.org/docs/advanced-features/output-file-tracing
47
- COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
48
- COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
49
-
50
- USER nextjs
51
-
52
- EXPOSE 3000
53
-
54
- ENV PORT 3000
55
- ENV HOSTNAME "0.0.0.0"
56
-
57
- # Run Next.js server
58
- CMD ["node", "server.js"]
1
+ # Multi-stage Dockerfile for Next.js Production Build
2
+ # Optimized for Next.js 15 with App Router
3
+
4
+ FROM node:20-alpine AS base
5
+
6
+ # Install dependencies only when needed
7
+ FROM base AS deps
8
+ RUN apk add --no-cache libc6-compat
9
+ WORKDIR /app
10
+
11
+ # Copy package files
12
+ COPY package.json package-lock.json* ./
13
+ RUN npm ci
14
+
15
+ # Rebuild the source code only when needed
16
+ FROM base AS builder
17
+ WORKDIR /app
18
+ COPY --from=deps /app/node_modules ./node_modules
19
+ COPY . .
20
+
21
+ # Set build-time environment variables
22
+ ENV NEXT_TELEMETRY_DISABLED 1
23
+
24
+ # Build Next.js application
25
+ RUN npm run build
26
+
27
+ # Production image, copy all the files and run next
28
+ FROM base AS runner
29
+ WORKDIR /app
30
+
31
+ ENV NODE_ENV production
32
+ ENV NEXT_TELEMETRY_DISABLED 1
33
+
34
+ # Create nextjs user
35
+ RUN addgroup --system --gid 1001 nodejs
36
+ RUN adduser --system --uid 1001 nextjs
37
+
38
+ # Copy built application
39
+ COPY --from=builder /app/public ./public
40
+
41
+ # Set the correct permission for prerender cache
42
+ RUN mkdir .next
43
+ RUN chown nextjs:nodejs .next
44
+
45
+ # Automatically leverage output traces to reduce image size
46
+ # https://nextjs.org/docs/advanced-features/output-file-tracing
47
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
48
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
49
+
50
+ USER nextjs
51
+
52
+ EXPOSE 3000
53
+
54
+ ENV PORT 3000
55
+ ENV HOSTNAME "0.0.0.0"
56
+
57
+ # Run Next.js server
58
+ CMD ["node", "server.js"]