@polymorphism-tech/morph-spec 8.43.0 → 8.45.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.
- package/CLAUDE.md +16 -13
- package/README.md +10 -10
- package/bin/morph-spec.js +10 -13
- package/bin/validate.js +379 -379
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +2 -4
- package/docs/QUICKSTART.md +6 -6
- package/framework/CLAUDE.md +6 -8
- package/framework/MORPH.md +39 -45
- package/framework/agents.json +8 -9
- package/framework/commands/morph-apply.md +1 -3
- package/framework/commands/morph-hotfix.md +1 -1
- package/framework/commands/morph-proposal.md +2 -2
- package/framework/docs/CLI.md +22 -17
- package/framework/evals/review-checklist.md +90 -0
- package/framework/evals/trace-schema.md +2 -12
- package/framework/hooks/README.md +2 -3
- package/framework/hooks/claude-code/core/heavy-gate.js +1 -1
- package/framework/hooks/claude-code/core/protect-spec-files.js +2 -2
- package/framework/hooks/claude-code/core/telemetry-log.js +2 -2
- package/framework/hooks/claude-code/core/trace-autogen.js +1 -22
- package/framework/hooks/claude-code/core/validate-completion.js +3 -56
- package/framework/hooks/claude-code/core/worktree-env-inject.js +1 -4
- package/framework/hooks/claude-code/statusline.sh +11 -11
- package/framework/hooks/git/commit-msg/conventional-commits.sh +33 -33
- package/framework/hooks/git/pre-commit/agents.sh +25 -25
- package/framework/hooks/git/pre-commit/orchestrator.sh +64 -64
- package/framework/hooks/git/pre-commit/specs.sh +50 -50
- package/framework/hooks/git/pre-push/run-tests.sh +44 -44
- package/framework/hooks/shared/build-check.js +1 -1
- package/framework/hooks/shared/comment-scanner.js +1 -1
- package/framework/hooks/shared/phase-utils.js +0 -5
- package/framework/hooks/shared/stdin-reader.js +26 -26
- package/framework/phases.json +4 -6
- package/framework/rubrics/backend.json +1 -1
- package/framework/rubrics/default.json +1 -1
- package/framework/rubrics/frontend.json +1 -1
- package/framework/rules/ai-agents-standards.md +1 -0
- package/framework/rules/morph-workflow.md +6 -6
- package/framework/schemas/feature.schema.json +2 -28
- package/framework/schemas/tasks.schema.json +6 -2
- package/framework/skills/README.md +1 -2
- package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
- package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
- package/framework/skills/core/morph-apply/SKILL.md +145 -246
- package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
- package/framework/skills/core/morph-hotfix/SKILL.md +5 -3
- package/framework/skills/core/morph-implement/SKILL.md +101 -201
- package/framework/skills/core/morph-machine/SKILL.md +3 -3
- package/framework/skills/core/morph-media/SKILL.md +1 -1
- package/framework/skills/core/morph-plan/SKILL.md +171 -287
- package/framework/skills/core/morph-proposal/SKILL.md +4 -5
- package/framework/skills/core/morph-review/SKILL.md +109 -430
- package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
- package/framework/skills/core/morph-standards/SKILL.md +2 -2
- package/framework/skills/core/morph-uiux/SKILL.md +2 -3
- package/framework/standards/STANDARDS.json +54 -10
- package/framework/standards/ai-agents/agent-archetypes.md +1 -1
- package/framework/standards/ai-agents/agent-session.md +1 -1
- package/framework/standards/ai-agents/agent-spec.md +1 -1
- package/framework/standards/ai-agents/batching.md +1 -1
- package/framework/standards/ai-agents/context-providers.md +1 -1
- package/framework/standards/ai-agents/conversational-agent-with-phases.md +1 -1
- package/framework/standards/ai-agents/cost-and-budget.md +1 -1
- package/framework/standards/ai-agents/durable-workflows-hitl.md +1 -1
- package/framework/standards/ai-agents/guardrails.md +1 -1
- package/framework/standards/ai-agents/llm-runtime-defaults.md +1 -1
- package/framework/standards/ai-agents/mcp-server.md +1 -1
- package/framework/standards/ai-agents/mcp-tools.md +1 -1
- package/framework/standards/ai-agents/media-pipeline.md +1 -1
- package/framework/standards/ai-agents/media-video.md +1 -1
- package/framework/standards/ai-agents/middleware-patterns.md +1 -1
- package/framework/standards/ai-agents/modalities-image-gen.md +1 -1
- package/framework/standards/ai-agents/modalities-speech-to-text.md +1 -1
- package/framework/standards/ai-agents/modalities-text-to-speech.md +1 -1
- package/framework/standards/ai-agents/modalities-vision.md +1 -1
- package/framework/standards/ai-agents/multi-agent-patterns.md +1 -1
- package/framework/standards/ai-agents/observability-patterns.md +3 -3
- package/framework/standards/ai-agents/production.md +2 -2
- package/framework/standards/ai-agents/prompt-sources.md +1 -1
- package/framework/standards/ai-agents/providers/model-registry.md +1 -1
- package/framework/standards/ai-agents/rag-custom-pgvector.md +1 -1
- package/framework/standards/ai-agents/service-tier-flex.md +1 -1
- package/framework/standards/ai-agents/setup.md +1 -1
- package/framework/standards/ai-agents/structured-output.md +1 -1
- package/framework/standards/ai-agents/sweet-spot.md +1 -1
- package/framework/standards/ai-agents/testing-ai.md +1 -1
- package/framework/standards/ai-agents/tool-adapters.md +226 -0
- package/framework/standards/ai-agents/vector-data-extensions.md +1 -1
- package/framework/standards/ai-agents/workflows.md +1 -1
- package/framework/standards/infrastructure/docker/local-compose-isolation.md +11 -1
- package/framework/templates/CLAUDE.md.core.template +1 -1
- package/framework/templates/IDE-SNIPPETS.md +262 -262
- package/framework/templates/README.md +1 -1
- package/framework/templates/REGISTRY.json +0 -81
- package/framework/templates/code/dotnet/abstractions/api-endpoint.cs +7 -7
- package/framework/templates/code/dotnet/feature/endpoint.cs.hbs +21 -21
- package/framework/templates/code/dotnet/feature/request.cs.hbs +4 -4
- package/framework/templates/code/dotnet/feature/response.cs.hbs +4 -4
- package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -91
- package/framework/templates/docs/spec.md +19 -205
- package/framework/templates/docs/ui-components.md +52 -52
- package/framework/templates/docs/ui-design-system.md +76 -76
- package/framework/templates/docs/ui-flows.md +167 -167
- package/framework/templates/frontend/nextjs/client-component.tsx.hbs +26 -26
- package/framework/templates/frontend/nextjs/feature-form.tsx.hbs +56 -56
- package/framework/templates/frontend/nextjs/tsconfig.json.hbs +26 -26
- package/framework/templates/infrastructure/docker/Dockerfile.template +58 -58
- package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
- package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
- package/framework/templates/infrastructure/github/README.md +56 -56
- package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +45 -45
- package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +27 -27
- package/framework/templates/infrastructure/github/workflows/docker-build-push.yml.hbs +59 -59
- package/framework/templates/infrastructure/github/workflows/dotnet-build.yml.hbs +39 -39
- package/framework/templates/meta-prompts/fusion/fusion-agent.md +76 -76
- package/framework/templates/meta-prompts/fusion/fusion-aggregator.md +100 -100
- package/framework/templates/meta-prompts/validators/pre-commit-validator.md +95 -95
- package/framework/templates/state.template.json +17 -17
- package/framework/templates/ui/design-system.css +226 -226
- package/package.json +2 -2
- package/src/commands/e2e/e2e.js +1 -1
- package/src/commands/project/heavy.js +1 -1
- package/src/commands/project/status.js +3 -3
- package/src/commands/project/worktree.js +34 -16
- package/src/commands/state/approve.js +9 -50
- package/src/commands/state/finish.js +4 -0
- package/src/commands/state/gate-check.js +18 -107
- package/src/commands/state/gate-decision.js +1 -1
- package/src/commands/state/report-check.js +42 -17
- package/src/commands/validation/mutate.js +1 -1
- package/src/commands/validation/scout-check.js +28 -0
- package/src/commands/validation/validate-feature.js +5 -32
- package/src/commands/validation/verify.js +16 -25
- package/src/core/paths/output-schema.js +0 -2
- package/src/core/state/state-manager.js +1 -2
- package/src/core/templates/template-renderer.js +477 -477
- package/src/dashboard/app/lib/format.js +5 -0
- package/src/dashboard/app/main.jsx +13 -13
- package/src/dashboard/app/pages/FeatureDetail.jsx +16 -22
- package/src/dashboard/app/pages/Features.jsx +7 -7
- package/src/dashboard/app/pages/PhasePipeline.jsx +1 -1
- package/src/dashboard/app/pages/Rubrics.jsx +7 -11
- package/src/dashboard/scanner/docs-scanner.js +1 -2
- package/src/dashboard/scanner/features-scanner.js +3 -4
- package/src/dashboard/scanner/rubrics-scanner.js +12 -12
- package/src/dashboard/vite.config.js +24 -24
- package/src/lib/agents/output-collector.js +0 -1
- package/src/lib/detectors/design-system-detector.js +188 -188
- package/src/lib/e2e/compose-env.js +5 -2
- package/src/lib/evaluator-report.js +52 -334
- package/src/lib/generators/design-system-generator.js +508 -508
- package/src/lib/generators/handoff-generator.js +4 -5
- package/src/lib/git/evidence-staleness.js +39 -0
- package/src/lib/installers/memory-installer.js +2 -2
- package/src/lib/mutation/manifest.js +8 -2
- package/src/lib/mutation/report.js +5 -3
- package/src/lib/mutation/runner.js +9 -7
- package/src/lib/risk-detector.js +63 -125
- package/src/lib/scout/scout-check.js +293 -0
- package/src/lib/tasks/eval-node.js +4 -34
- package/src/lib/tasks/task-classifier.js +30 -30
- package/src/lib/tasks/task-parser.js +209 -209
- package/src/lib/tasks/tasks-json-parser.js +7 -5
- package/src/lib/tasks/test-nodes.js +1 -1
- package/src/lib/tasks/test-runner.js +1 -1
- package/src/lib/validators/contracts/contract-compliance-validator.js +4 -42
- package/src/lib/validators/css/css-validator.js +340 -340
- package/src/lib/validators/reuse/reuse-validator.js +6 -8
- package/src/lib/validators/verify-runner.js +1 -1
- package/src/lib/worktree/env-allocator.js +35 -5
- package/src/scripts/setup-infra.js +1 -1
- package/src/utils/agent-id-mapper.js +11 -11
- package/src/utils/agents-installer.js +5 -9
- package/src/utils/claude-settings-manager.js +300 -300
- package/src/utils/hooks-installer.js +3 -10
- package/src/utils/skills-installer.js +1 -1
- package/framework/evals/proof-rubrics/README.md +0 -76
- package/framework/evals/proof-rubrics/eval-de-modelo.md +0 -80
- package/framework/evals/proof-rubrics/fiacao.md +0 -54
- package/framework/evals/proof-rubrics/guard-cego.md +0 -52
- package/framework/evals/proof-rubrics/media-claims.md +0 -109
- package/framework/evals/proof-rubrics/mutation-proof.md +0 -107
- package/framework/evals/proof-rubrics/observabilidade-genai.md +0 -119
- package/framework/evals/proof-rubrics/verde-nao-e-coberto.md +0 -48
- package/framework/evals/rubrics/README.md +0 -45
- package/framework/evals/rubrics/architecture.md +0 -103
- package/framework/evals/rubrics/code-quality.md +0 -98
- package/framework/evals/rubrics/condensed.md +0 -57
- package/framework/evals/rubrics/contracts.md +0 -67
- package/framework/evals/rubrics/test-coverage.md +0 -99
- package/framework/evals/scenarios/dotnet-crud.yaml +0 -42
- package/framework/evals/scenarios/nextjs-auth.yaml +0 -38
- package/framework/evals/suites/standard.yaml +0 -5
- package/framework/hooks/claude-code/core/post-edit-typecheck.js +0 -127
- package/framework/skills/core/morph-eval/SKILL.md +0 -64
- package/framework/templates/.idea/morph-templates.xml +0 -92
- package/framework/templates/.vscode/morph-templates.code-snippets +0 -186
- package/framework/templates/docs/clarifications.md +0 -253
- package/framework/templates/docs/onboarding.md +0 -122
- package/framework/templates/docs/schema-analysis.md +0 -119
- package/framework/templates/docs/user-stories.md +0 -34
- package/src/commands/state/score.js +0 -147
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
namespace {{pascalCase PROJECT_NAME}}.Features.{{pascalCase FEATURE_NAME}}Feature.{{pascalCase SLICE_NAME}};
|
|
2
|
-
|
|
3
|
-
// TODO: Add properties matching the {{pascalCase SLICE_NAME}} command
|
|
4
|
-
public sealed record {{pascalCase SLICE_NAME}}Request();
|
|
1
|
+
namespace {{pascalCase PROJECT_NAME}}.Features.{{pascalCase FEATURE_NAME}}Feature.{{pascalCase SLICE_NAME}};
|
|
2
|
+
|
|
3
|
+
// TODO: Add properties matching the {{pascalCase SLICE_NAME}} command
|
|
4
|
+
public sealed record {{pascalCase SLICE_NAME}}Request();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
namespace {{pascalCase PROJECT_NAME}}.Features.{{pascalCase FEATURE_NAME}}Feature.{{pascalCase SLICE_NAME}};
|
|
2
|
-
|
|
3
|
-
// TODO: Add properties matching the {{pascalCase SLICE_NAME}} response
|
|
4
|
-
public sealed record {{pascalCase SLICE_NAME}}Response(Guid Id);
|
|
1
|
+
namespace {{pascalCase PROJECT_NAME}}.Features.{{pascalCase FEATURE_NAME}}Feature.{{pascalCase SLICE_NAME}};
|
|
2
|
+
|
|
3
|
+
// TODO: Add properties matching the {{pascalCase SLICE_NAME}} response
|
|
4
|
+
public sealed record {{pascalCase SLICE_NAME}}Response(Guid Id);
|
|
@@ -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;
|
|
@@ -3,206 +3,33 @@
|
|
|
3
3
|
| Field | Value |
|
|
4
4
|
|-------|-------|
|
|
5
5
|
| **ID** | {{FEATURE_NAME}} |
|
|
6
|
-
| **Status** | Draft / In Review / Approved / In Progress / Done |
|
|
7
6
|
| **Created** | {{DATE}} |
|
|
8
7
|
| **Stack** | {{STACK}} |
|
|
9
|
-
| **Complexity** | Low / Medium / High |
|
|
10
|
-
| **Estimated Cost** | $X/month |
|
|
11
|
-
| **Agents** | Core: All / Specialists: {list} |
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
> Behavior lives in the use cases (`2-plan/usecases/UC-*.md`). This file says HOW they are realized —
|
|
10
|
+
> do not repeat postconditions here.
|
|
14
11
|
|
|
15
|
-
##
|
|
12
|
+
## Architecture
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
**Solution:** {High-level solution}
|
|
20
|
-
|
|
21
|
-
**Success Criteria:**
|
|
22
|
-
- [ ] {Criterion 1}
|
|
23
|
-
- [ ] {Criterion 2}
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Requirements
|
|
28
|
-
|
|
29
|
-
**Functional:** FR1: {desc} | FR2: {desc} | FR3: {desc}
|
|
30
|
-
|
|
31
|
-
**Non-Functional:** NFR1: Performance - {target} | NFR2: Reliability - {target}
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## User Stories
|
|
36
|
-
|
|
37
|
-
### US001: {Title}
|
|
38
|
-
**As** {user type} **I want** {feature} **so that** {benefit}
|
|
39
|
-
|
|
40
|
-
**Acceptance Criteria:** 1. {criterion} 2. {criterion}
|
|
41
|
-
|
|
42
|
-
**Edge Cases:** {edge case}: {handling}
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## Technical Architecture
|
|
47
|
-
|
|
48
|
-
### Stack
|
|
49
|
-
| Component | Technology |
|
|
50
|
-
|-----------|------------|
|
|
51
|
-
| Frontend | {Next.js / .NET 10} |
|
|
52
|
-
| Backend | .NET 10 / C# 14 |
|
|
53
|
-
| Database | {Azure SQL / Cosmos DB} |
|
|
14
|
+
{Components, how they connect, main data flows. Enough to implement without basic questions.}
|
|
54
15
|
|
|
55
16
|
### Data Model
|
|
56
17
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
| Id | Guid | PK |
|
|
61
|
-
| {Property} | {Type} | {Constraints} |
|
|
62
|
-
| CreatedAt | datetime2 | Default: GETUTCDATE() |
|
|
18
|
+
| Entity | Field | Type | Notes |
|
|
19
|
+
|--------|-------|------|-------|
|
|
20
|
+
| {Entity} | {field} | {type} | {constraint, index, relation} |
|
|
63
21
|
|
|
64
22
|
### Contracts
|
|
65
23
|
|
|
66
|
-
```csharp
|
|
67
|
-
public interface I{{pascalCase FEATURE_NAME}}Service
|
|
68
|
-
{
|
|
69
|
-
Task<{{pascalCase FEATURE_NAME}}Dto> GetByIdAsync(int id);
|
|
70
|
-
Task<{{pascalCase FEATURE_NAME}}Dto> CreateAsync(Create{{pascalCase FEATURE_NAME}}Request request);
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**Contracts Workflow:** Generate `contracts.cs` FIRST → validate names → reference in spec → approve with user.
|
|
75
|
-
|
|
76
|
-
**Validation Checklist:**
|
|
77
|
-
- [ ] Property names are descriptive (not generic "Data", "Value")
|
|
78
|
-
- [ ] Records use correct types (Stream vs byte[], Guid vs string)
|
|
79
|
-
- [ ] Response DTOs have all properties needed for UI
|
|
80
|
-
- [ ] Request DTOs have implicit validations (required, nullable)
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## Domain Complexity
|
|
85
|
-
|
|
86
|
-
**Nível:** {1 — CRUD / 2 — Business Logic / 3 — Bounded Context}
|
|
87
|
-
|
|
88
|
-
**Justificativa:** {Por que este nível foi escolhido — mencionar invariants, eventos ou BCs se Nível 2+}
|
|
89
|
-
|
|
90
|
-
**Padrões Aplicados:**
|
|
91
|
-
- {Nível 1: Entity simples, Service CRUD, DTOs}
|
|
92
|
-
- {Nível 2: AggregateRoot, Value Objects, Domain Events, CQRS}
|
|
93
|
-
- {Nível 3: Bounded Context isolation, cross-BC events, Linguagem Ubíqua}
|
|
94
|
-
|
|
95
|
-
**Padrões Omitidos:**
|
|
96
|
-
- {ex: Bounded Contexts — sistema single-domain}
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## Architecture Style: Vertical Slice
|
|
101
|
-
|
|
102
|
-
> Preencher SOMENTE se `config.architecture.style === "vertical-slice"`. Omitir em projetos DDD.
|
|
103
|
-
|
|
104
|
-
**Architecture Style:** Vertical Slice Architecture (VSA)
|
|
105
|
-
|
|
106
|
-
**Entity Fields:**
|
|
107
|
-
| Field | Type | Constraints |
|
|
108
|
-
|-------|------|-------------|
|
|
109
|
-
| Id | Guid | PK, `Guid.CreateVersion7()` |
|
|
110
|
-
| {Field} | {C# Type} | {Required / Optional / Unique} |
|
|
111
|
-
| CreatedAt | DateTimeOffset | Auto |
|
|
112
|
-
|
|
113
|
-
**Operations:**
|
|
114
|
-
| Slice | HTTP | Route | Has Validator |
|
|
115
|
-
|-------|------|-------|---------------|
|
|
116
|
-
| Create{Entity} | POST | {ROUTE} | Yes |
|
|
117
|
-
| GetAll{Entity}s | GET | {ROUTE} | No |
|
|
118
|
-
| Get{Entity}ById | GET | {ROUTE}/{id} | Yes |
|
|
119
|
-
| Update{Entity} | PUT | {ROUTE}/{id} | Yes |
|
|
120
|
-
| Delete{Entity} | DELETE | {ROUTE}/{id} | Yes |
|
|
121
|
-
|
|
122
|
-
**Error Types ({Entity}Errors):**
|
|
123
|
-
- `{Entity}Errors.{ErrorName}()` — {description}
|
|
124
|
-
|
|
125
|
-
**Validation Rules:**
|
|
126
|
-
| Field | Rules |
|
|
127
|
-
|-------|-------|
|
|
128
|
-
| {Field} | NotEmpty(), MaxLength({N}), {etc.} |
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## Aggregate Blueprint (Nível 2+ apenas)
|
|
133
|
-
|
|
134
|
-
> Omitir esta seção se Nível 1 (CRUD) ou se Architecture Style = Vertical Slice.
|
|
135
|
-
|
|
136
|
-
### Aggregate Root: {EntityName}
|
|
137
|
-
|
|
138
|
-
**Invariants:**
|
|
139
|
-
- {Invariant 1 em linguagem natural}
|
|
140
|
-
- {Invariant 2}
|
|
141
|
-
|
|
142
|
-
**Estados e Transições:**
|
|
143
24
|
```
|
|
144
|
-
{
|
|
25
|
+
{METHOD} /api/{route}
|
|
26
|
+
Request: { ... }
|
|
27
|
+
Response: { ... } | ProblemDetails 400/404/409
|
|
145
28
|
```
|
|
146
29
|
|
|
147
|
-
|
|
148
|
-
- `{EntityName}CreatedEvent` — publicado ao criar
|
|
149
|
-
- `{EntityName}StatusChangedEvent` — publicado em mudança de estado
|
|
150
|
-
|
|
151
|
-
**Value Objects:**
|
|
152
|
-
- `{ValueObjectName}` — {por que não é primitivo simples}
|
|
153
|
-
|
|
154
|
-
**Referências Cross-Aggregate (por ID):**
|
|
155
|
-
- `{OtherEntity}Id: Guid`
|
|
156
|
-
|
|
157
|
-
### Linguagem Ubíqua
|
|
158
|
-
|
|
159
|
-
| Termo | Definição | Código |
|
|
160
|
-
|-------|-----------|--------|
|
|
161
|
-
| {Termo} | {Definição do negócio} | `{ClassName.MethodName()}` |
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## UI/UX Design (if front-end)
|
|
166
|
-
|
|
167
|
-
### Wireframes
|
|
168
|
-
```
|
|
169
|
-
{ASCII wireframe per screen - include states: loading, error, empty}
|
|
170
|
-
```
|
|
30
|
+
## Technical edge cases
|
|
171
31
|
|
|
172
|
-
|
|
173
|
-
1. {Step} → {System response}
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
## Flows
|
|
178
|
-
|
|
179
|
-
### {Flow Name}
|
|
180
|
-
**Trigger:** {what starts this flow}
|
|
181
|
-
1. {Actor} {action} → {system response}
|
|
182
|
-
2. If {condition}: Path A / Else: Path B
|
|
183
|
-
**End State:** {final state}
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## Cost Estimate
|
|
188
|
-
|
|
189
|
-
| Resource | SKU | Monthly Cost | Justification |
|
|
190
|
-
|----------|-----|--------------|---------------|
|
|
191
|
-
| {Resource} | {SKU} | ${X} | {Why} |
|
|
192
|
-
| **Total** | | **${X}/month** | |
|
|
193
|
-
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
## ADRs (Architectural Decision Records)
|
|
197
|
-
|
|
198
|
-
### ADR-001: {Decision Title}
|
|
199
|
-
**Status:** Proposed / Accepted
|
|
200
|
-
**Context:** {Why decide now}
|
|
201
|
-
**Decision:** {What we chose}
|
|
202
|
-
**Alternatives:** 1. {Alt} (pros/cons) 2. {Alt} (pros/cons)
|
|
203
|
-
**Trade-offs:** {key trade-offs}
|
|
204
|
-
|
|
205
|
-
---
|
|
32
|
+
- {Edge case} → {how it is handled}
|
|
206
33
|
|
|
207
34
|
## UCs e ADRs que esta feature altera ou revoga
|
|
208
35
|
|
|
@@ -217,27 +44,14 @@ public interface I{{pascalCase FEATURE_NAME}}Service
|
|
|
217
44
|
| UC-{nn} | parcial | UC-{nn} | {where the old one still holds} |
|
|
218
45
|
| {feature}/ADR-{nnn} | total | — | — |
|
|
219
46
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
## Security
|
|
223
|
-
|
|
224
|
-
| Action | Required Policy |
|
|
225
|
-
|--------|-----------------|
|
|
226
|
-
| View | CanView{Feature} |
|
|
227
|
-
| Create | CanManage{Feature} |
|
|
47
|
+
## Contrato de implementação
|
|
228
48
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
49
|
+
- **Standards:** {ids from `morph-spec standards --find`, plus `architecture-code-comments` and the stack's test standard}
|
|
50
|
+
- **Proibições desta feature:** {beyond MORPH.md "Stack baked-in", or "nenhuma"}
|
|
51
|
+
- **Verificação de runtime:** {how the stack comes up (`morph-spec e2e up {feature}`), which flows the evaluator navigates, which become Playwright specs, auth setup — or why it does not apply}
|
|
52
|
+
- **Baseline:** {the COMMAND that measures it — `dotnet test`, `npm test` — never a number}
|
|
53
|
+
- **Pré-requisito:** {a PREDICATE — `git merge-base --is-ancestor origin/main HEAD` exits 0 — never a SHA}
|
|
234
54
|
|
|
235
55
|
## Out of Scope
|
|
236
|
-
- {Item}
|
|
237
56
|
|
|
238
|
-
|
|
239
|
-
- [ ] Code implemented
|
|
240
|
-
- [ ] Tests >80% coverage
|
|
241
|
-
- [ ] Code review approved
|
|
242
|
-
- [ ] Deploy to staging
|
|
243
|
-
- [ ] Recap.md generated
|
|
57
|
+
- {Item}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
# UI Components: {{titleCase FEATURE_NAME}}
|
|
2
|
-
|
|
3
|
-
| Field | Value |
|
|
4
|
-
|-------|-------|
|
|
5
|
-
| **Feature** | {{FEATURE_NAME}} |
|
|
6
|
-
| **Created** | {{DATE}} |
|
|
7
|
-
| **Stack** | {{STACK}} |
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
{{#if (eq STACK "nextjs-neon")}}
|
|
12
|
-
## Component Library: shadcn/ui
|
|
13
|
-
|
|
14
|
-
### C001: Button
|
|
15
|
-
|
|
16
|
-
```tsx
|
|
17
|
-
import { Button } from '@/components/ui/button';
|
|
18
|
-
|
|
19
|
-
<Button onClick={handleSave} disabled={!isValid}>
|
|
20
|
-
Save
|
|
21
|
-
</Button>
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### C002: Data Table
|
|
25
|
-
|
|
26
|
-
```tsx
|
|
27
|
-
import { DataTable } from '@/components/ui/data-table';
|
|
28
|
-
|
|
29
|
-
<DataTable columns={columns} data={items} />
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
{{/if}}
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## Form Validation
|
|
37
|
-
|
|
38
|
-
| Field | Rule | Error Message |
|
|
39
|
-
|-------|------|---------------|
|
|
40
|
-
| **Name** | Required, max 100 | "Name is required" |
|
|
41
|
-
| **Email** | Valid email | "Invalid email" |
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
## Accessibility
|
|
46
|
-
- [ ] All inputs have labels
|
|
47
|
-
- [ ] Error messages announced
|
|
48
|
-
- [ ] Keyboard navigation works
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
*Generated with MORPH Framework*
|
|
1
|
+
# UI Components: {{titleCase FEATURE_NAME}}
|
|
2
|
+
|
|
3
|
+
| Field | Value |
|
|
4
|
+
|-------|-------|
|
|
5
|
+
| **Feature** | {{FEATURE_NAME}} |
|
|
6
|
+
| **Created** | {{DATE}} |
|
|
7
|
+
| **Stack** | {{STACK}} |
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
{{#if (eq STACK "nextjs-neon")}}
|
|
12
|
+
## Component Library: shadcn/ui
|
|
13
|
+
|
|
14
|
+
### C001: Button
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { Button } from '@/components/ui/button';
|
|
18
|
+
|
|
19
|
+
<Button onClick={handleSave} disabled={!isValid}>
|
|
20
|
+
Save
|
|
21
|
+
</Button>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### C002: Data Table
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { DataTable } from '@/components/ui/data-table';
|
|
28
|
+
|
|
29
|
+
<DataTable columns={columns} data={items} />
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
{{/if}}
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Form Validation
|
|
37
|
+
|
|
38
|
+
| Field | Rule | Error Message |
|
|
39
|
+
|-------|------|---------------|
|
|
40
|
+
| **Name** | Required, max 100 | "Name is required" |
|
|
41
|
+
| **Email** | Valid email | "Invalid email" |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Accessibility
|
|
46
|
+
- [ ] All inputs have labels
|
|
47
|
+
- [ ] Error messages announced
|
|
48
|
+
- [ ] Keyboard navigation works
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
*Generated with MORPH Framework*
|