sinapse-ai 1.21.0 → 1.23.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 (115) hide show
  1. package/.claude/hooks/doc-first-gate.cjs +32 -3
  2. package/.claude/hooks/enforce-story-gate.cjs +53 -3
  3. package/.claude/rules/coderabbit-integration.md +6 -0
  4. package/.claude/rules/documentation-first-reference.md +146 -0
  5. package/.claude/rules/documentation-first.md +27 -119
  6. package/.claude/rules/mandatory-delegation-reference.md +93 -0
  7. package/.claude/rules/mandatory-delegation.md +29 -93
  8. package/.claude/rules/project-intelligence-reference.md +159 -0
  9. package/.claude/rules/project-intelligence.md +37 -155
  10. package/.claude/rules/safe-collaboration-reference.md +163 -0
  11. package/.claude/rules/safe-collaboration.md +32 -173
  12. package/.sinapse-ai/core/doctor/checks/index.js +1 -1
  13. package/.sinapse-ai/core/execution/build-orchestrator.js +4 -3
  14. package/.sinapse-ai/core/execution/subagent-dispatcher.js +2 -2
  15. package/.sinapse-ai/core/ideation/ideation-engine.js +2 -1
  16. package/.sinapse-ai/core/orchestration/cli-commands.js +13 -0
  17. package/.sinapse-ai/core/orchestration/doc-first-resolver.js +93 -2
  18. package/.sinapse-ai/core/orchestration/executors/epic-3-executor.js +15 -2
  19. package/.sinapse-ai/core/orchestration/executors/epic-4-executor.js +3 -1
  20. package/.sinapse-ai/core/orchestration/index.js +5 -0
  21. package/.sinapse-ai/core/orchestration/spec-complexity.js +141 -0
  22. package/.sinapse-ai/core-config.yaml +30 -0
  23. package/.sinapse-ai/data/entity-registry.yaml +46 -25
  24. package/.sinapse-ai/development/agents/architect.md +3 -15
  25. package/.sinapse-ai/development/agents/data-engineer.md +3 -15
  26. package/.sinapse-ai/development/agents/developer.md +3 -24
  27. package/.sinapse-ai/development/agents/devops.md +4 -25
  28. package/.sinapse-ai/development/agents/quality-gate.md +3 -25
  29. package/.sinapse-ai/development/knowledge-base/token-economy-guide.md +1 -1
  30. package/.sinapse-ai/development/tasks/resolve-github-issue.md +1 -1
  31. package/.sinapse-ai/docs/standards/SINAPSE-LIVRO-DE-OURO-V2.1-COMPLETE.md +6 -2
  32. package/.sinapse-ai/docs/standards/SINAPSE-LIVRO-DE-OURO-V2.2-SUMMARY.md +4 -1
  33. package/.sinapse-ai/install-manifest.yaml +44 -40
  34. package/.sinapse-ai/product/templates/story-tmpl.yaml +11 -6
  35. package/.sinapse-ai/quality/judge-calibration/README.md +75 -0
  36. package/.sinapse-ai/quality/judge-calibration/calibration-log.md +70 -0
  37. package/.sinapse-ai/quality/judge-calibration/golden-set.json +105 -0
  38. package/.sinapse-ai/quality/judge-calibration/scenarios.json +90 -0
  39. package/CHANGELOG.md +41 -11
  40. package/README.en.md +1 -1
  41. package/README.md +6 -6
  42. package/bin/sinapse-minimal.js +5 -4
  43. package/docs/community/README-community-snippet-core.md +1 -1
  44. package/docs/community/README-community-snippet-mcp.md +2 -2
  45. package/docs/framework/README.md +2 -2
  46. package/docs/framework/architecture-overview.md +2 -2
  47. package/docs/framework/core-architecture.md +1 -1
  48. package/docs/framework/feature-process.md +5 -5
  49. package/docs/framework/guiding-principles.md +1 -1
  50. package/docs/framework/roadmap.md +4 -4
  51. package/docs/framework/source-tree.md +1 -1
  52. package/docs/framework/versioning-and-releases.md +1 -1
  53. package/docs/getting-started.md +1 -1
  54. package/docs/guides/agent-selection-guide.md +1 -1
  55. package/docs/guides/agents/traces/README.md +1 -1
  56. package/docs/guides/config-migration-guide.md +1 -1
  57. package/docs/guides/development-setup.md +1 -1
  58. package/docs/guides/docker-mcp-setup.md +5 -5
  59. package/docs/guides/getting-started.md +1 -1
  60. package/docs/guides/git-workflow-guide.md +3 -3
  61. package/docs/guides/ide-integration.md +3 -3
  62. package/docs/guides/ide-sync-guide.md +1 -1
  63. package/docs/guides/mcp/desktop-commander.md +2 -2
  64. package/docs/guides/mcp/docker-gateway-tutorial.md +1 -1
  65. package/docs/guides/mcp-global-setup.md +3 -3
  66. package/docs/guides/memory-intelligence-system.md +10 -10
  67. package/docs/guides/meta-agent-commands.md +1 -1
  68. package/docs/guides/quality-gates.md +1 -1
  69. package/docs/guides/security-hardening.md +1 -1
  70. package/docs/guides/service-discovery.md +1 -1
  71. package/docs/guides/squad-examples/README.md +1 -1
  72. package/docs/guides/squads-guide.md +1 -1
  73. package/docs/guides/testing-guide.md +2 -2
  74. package/docs/guides/user-guide.md +22 -22
  75. package/docs/guides/workflows/BROWNFIELD-DISCOVERY-WORKFLOW.md +3 -3
  76. package/docs/guides/workflows/BROWNFIELD-SERVICE-WORKFLOW.md +1 -1
  77. package/docs/guides/workflows/GREENFIELD-UI-WORKFLOW.md +2 -2
  78. package/docs/guides/workflows/SPEC-PIPELINE-WORKFLOW.md +3 -3
  79. package/docs/guides/workflows/STORY-DEVELOPMENT-CYCLE-WORKFLOW.md +3 -3
  80. package/docs/guides/workflows/pro-developer-workflow.md +2 -2
  81. package/docs/guides/workflows-guide.md +1 -1
  82. package/docs/guides/workflows-overview.md +1 -1
  83. package/docs/installation/npx-install.md +1 -1
  84. package/docs/installation/uninstallation.md +1 -1
  85. package/docs/installation/v4-quick-start.md +1 -1
  86. package/docs/pt/guides/user-guide.md +18 -18
  87. package/docs/pt/security.md +2 -2
  88. package/docs/security/overview.md +2 -2
  89. package/docs/security/security-best-practices.md +1 -1
  90. package/docs/sinapse-agent-flows/architect-system.md +1 -1
  91. package/docs/sinapse-agent-flows/data-engineer-system.md +1 -1
  92. package/docs/sinapse-agent-flows/dev-system.md +1 -1
  93. package/docs/sinapse-agent-flows/devops-system.md +2 -2
  94. package/docs/sinapse-agent-flows/qa-system.md +1 -1
  95. package/docs/sinapse-agent-flows/sm-system.md +2 -2
  96. package/docs/sinapse-agent-flows/snps-orqx-system.md +4 -4
  97. package/docs/sinapse-agent-flows/squad-creator-system.md +1 -1
  98. package/docs/sinapse-workflows/README.md +2 -2
  99. package/docs/sinapse-workflows/brownfield-discovery-workflow.md +3 -3
  100. package/docs/sinapse-workflows/brownfield-service-workflow.md +3 -3
  101. package/docs/sinapse-workflows/greenfield-ui-workflow.md +2 -2
  102. package/docs/sinapse-workflows/spec-pipeline-workflow.md +3 -3
  103. package/docs/sinapse-workflows/story-development-cycle-workflow.md +3 -3
  104. package/docs/troubleshooting.md +1 -1
  105. package/package.json +5 -1
  106. package/scripts/calibrate-judge.js +134 -0
  107. package/scripts/validate-all.js +5 -0
  108. package/scripts/validate-constitution.js +58 -0
  109. package/scripts/validate-story-acs.js +174 -0
  110. package/scripts/validate-tool-descriptions.js +128 -0
  111. package/scripts/wave-gate.js +1 -1
  112. package/squads/claude-code-mastery/agents/project-integrator.md +3 -10
  113. package/squads/claude-code-mastery/knowledge-base/context-window-optimization.md +2 -2
  114. package/squads/claude-code-mastery/knowledge-base/memory-systems-reference.md +1 -1
  115. package/squads/squad-copy/knowledge-base/ai-copy-human-loop-canon.md +1 -1
@@ -30,17 +30,30 @@
30
30
  const fs = require('fs');
31
31
  const path = require('path');
32
32
 
33
- /** Paths that require doc-first before code changes (mirror enforce-story-gate). */
33
+ /** Code directories (fast path) mirror enforce-story-gate. Expanded beyond the
34
+ * original 8 to cover common back-end/full-stack layouts; combined with CODE_EXT
35
+ * below so code in ANY non-exempt, non-config location is gated. */
34
36
  const CODE_PATHS = [
35
- 'packages/', 'src/', 'app/', 'lib/', 'bin/',
37
+ 'packages/', 'src/', 'app/', 'apps/', 'lib/', 'bin/',
36
38
  'components/', 'pages/', 'api/', 'services/',
39
+ 'server/', 'client/', 'backend/', 'frontend/', 'functions/',
40
+ 'worker/', 'workers/', 'routes/', 'controllers/', 'models/',
41
+ 'handlers/', 'middleware/', 'hooks/', 'stores/', 'store/',
42
+ 'features/', 'modules/', 'domain/', 'views/', 'screens/',
43
+ 'contexts/', 'providers/', 'utils/', 'helpers/', 'cmd/',
44
+ 'internal/', 'pkg/',
37
45
  ];
38
46
 
47
+ /** Code file extensions — catches code in ANY non-exempt, non-config location. */
48
+ const CODE_EXT = /\.(m?[jt]sx?|cjs|vue|svelte|astro|py|go|rs|java|rb|php|swift|kt|kts|c|cc|cpp|h|hpp|cs|scala|ex|exs|clj|dart)$/i;
49
+
39
50
  /** Paths always exempt. */
40
51
  const EXEMPT_PATHS = [
41
52
  '.claude/', '.sinapse-ai/', '.sinapse/', '.sinapse-custom/',
42
53
  'docs/', 'tests/', '__tests__/', 'test/',
43
54
  'node_modules/', '.git/', 'squads/', 'outputs/',
55
+ // Build outputs / generated — never gated.
56
+ '.next/', 'dist/', 'build/', 'out/', 'coverage/', '.vercel/', '.turbo/', '.cache/',
44
57
  ];
45
58
 
46
59
  /** Config files always exempt (scaffolding a project is allowed pre-docs). */
@@ -73,8 +86,24 @@ function isExempt(rel) {
73
86
  return EXEMPT_PATHS.some((ep) => rel.startsWith(ep));
74
87
  }
75
88
 
89
+ /**
90
+ * Config-like files exempt by PATTERN in ANY folder (so extension-based detection
91
+ * never over-blocks tooling config): `*.config.{js,ts,mjs,cjs}`, `*.d.ts`, and
92
+ * dotfile rc configs (`.eslintrc.json`, `.prettierrc.cjs`).
93
+ */
94
+ function isConfigLike(rel) {
95
+ const base = path.basename(rel);
96
+ return (
97
+ /\.config\.[cm]?[jt]s$/i.test(base) ||
98
+ /\.d\.ts$/i.test(base) ||
99
+ /^\.[a-z0-9_-]+rc(\.[a-z]+)?$/i.test(base)
100
+ );
101
+ }
102
+
76
103
  function isCodePath(rel) {
77
- return CODE_PATHS.some((cp) => rel.startsWith(cp));
104
+ if (isConfigLike(rel)) return false;
105
+ if (CODE_PATHS.some((cp) => rel.startsWith(cp))) return true;
106
+ return CODE_EXT.test(rel);
78
107
  }
79
108
 
80
109
  function main() {
@@ -24,17 +24,33 @@ const path = require('path');
24
24
  // Configuration
25
25
  // ---------------------------------------------------------------------------
26
26
 
27
- /** Paths that require an active story before code changes. */
27
+ /**
28
+ * Code directories (fast path). Expanded beyond the original 8 to cover common
29
+ * back-end / full-stack layouts. NOTE: this is no longer the ONLY signal — any
30
+ * code file (by extension) in a non-exempt, non-config location is also gated
31
+ * (see isCodePath), so this list is a fast-path, not a hole-prone allowlist.
32
+ */
28
33
  const CODE_PATHS = [
29
- 'packages/', 'src/', 'app/', 'lib/', 'bin/',
34
+ 'packages/', 'src/', 'app/', 'apps/', 'lib/', 'bin/',
30
35
  'components/', 'pages/', 'api/', 'services/',
36
+ 'server/', 'client/', 'backend/', 'frontend/', 'functions/',
37
+ 'worker/', 'workers/', 'routes/', 'controllers/', 'models/',
38
+ 'handlers/', 'middleware/', 'hooks/', 'stores/', 'store/',
39
+ 'features/', 'modules/', 'domain/', 'views/', 'screens/',
40
+ 'contexts/', 'providers/', 'utils/', 'helpers/', 'cmd/',
41
+ 'internal/', 'pkg/',
31
42
  ];
32
43
 
44
+ /** Code file extensions — catches code in ANY non-exempt, non-config location. */
45
+ const CODE_EXT = /\.(m?[jt]sx?|cjs|vue|svelte|astro|py|go|rs|java|rb|php|swift|kt|kts|c|cc|cpp|h|hpp|cs|scala|ex|exs|clj|dart)$/i;
46
+
33
47
  /** Paths always exempt from story requirement. */
34
48
  const EXEMPT_PATHS = [
35
49
  '.claude/', '.sinapse-ai/', '.sinapse/', '.sinapse-custom/',
36
50
  'docs/', 'tests/', '__tests__/', 'test/',
37
51
  'node_modules/', '.git/', 'squads/', 'outputs/',
52
+ // Build outputs / generated — never gated.
53
+ '.next/', 'dist/', 'build/', 'out/', 'coverage/', '.vercel/', '.turbo/', '.cache/',
38
54
  ];
39
55
 
40
56
  /** Config files always exempt. */
@@ -49,6 +65,29 @@ const EXEMPT_FILES = [
49
65
  'postcss.config.js', 'postcss.config.cjs',
50
66
  ];
51
67
 
68
+ /**
69
+ * Config-like files exempt by PATTERN in ANY folder (so the extension-based
70
+ * detection never over-blocks tooling config): `*.config.{js,ts,mjs,cjs}`,
71
+ * `*.d.ts` type decls, and dotfile rc configs (`.eslintrc.json`, `.prettierrc.cjs`).
72
+ */
73
+ function isConfigLike(rel) {
74
+ const base = path.basename(rel);
75
+ return (
76
+ /\.config\.[cm]?[jt]s$/i.test(base) ||
77
+ /\.d\.ts$/i.test(base) ||
78
+ /^\.[a-z0-9_-]+rc(\.[a-z]+)?$/i.test(base)
79
+ );
80
+ }
81
+
82
+ /** True if this project IS the SINAPSE framework's own repo (Art. III exception). */
83
+ function isFrameworkRepo(root) {
84
+ try {
85
+ return JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')).name === 'sinapse-ai';
86
+ } catch {
87
+ return false;
88
+ }
89
+ }
90
+
52
91
  /** Story statuses that allow implementation. */
53
92
  const VALID_STATUSES = ['ready', 'inprogress', 'in progress', 'in_progress', 'inreview', 'in review', 'in_review', 'done'];
54
93
 
@@ -76,7 +115,13 @@ function isExempt(rel) {
76
115
  }
77
116
 
78
117
  function isCodePath(rel) {
79
- return CODE_PATHS.some((cp) => rel.startsWith(cp));
118
+ // Config-like files are never gated, even inside code dirs.
119
+ if (isConfigLike(rel)) return false;
120
+ // Fast path: known code directory.
121
+ if (CODE_PATHS.some((cp) => rel.startsWith(cp))) return true;
122
+ // Catch-all: a code file (by extension) anywhere non-exempt, non-config —
123
+ // this is what closes the "code in server/ or root escapes the gate" hole.
124
+ return CODE_EXT.test(rel);
80
125
  }
81
126
 
82
127
  /**
@@ -180,6 +225,11 @@ function main() {
180
225
  // Only enforce on code paths
181
226
  if (!isCodePath(rel)) process.exit(0);
182
227
 
228
+ // Framework's own repo operates above the story layer (Art. III exception) —
229
+ // mirror doc-first-gate. The expanded detection now reaches scripts/ etc., so
230
+ // without this the framework's own development would be over-blocked.
231
+ if (isFrameworkRepo(root)) process.exit(0);
232
+
183
233
  // Check for active story
184
234
  if (hasActiveStory(root)) process.exit(0);
185
235
 
@@ -9,6 +9,12 @@ paths:
9
9
 
10
10
  # CodeRabbit Integration — Detailed Rules
11
11
 
12
+ > **Single source of truth.** This rule (auto-loaded) plus the machine config in
13
+ > `.sinapse-ai/core-config.yaml` (`coderabbit_integration`) are the ONE canonical
14
+ > definition of the CodeRabbit integration — WSL execution mechanics, self-healing
15
+ > thresholds, review commands, severity handling and report location. Agents
16
+ > **reference** this; they must not copy the mechanics into their own definitions.
17
+
12
18
  ## Self-Healing Configuration
13
19
 
14
20
  ### Dev Phase (@developer — Story Development Cycle Phase 3)
@@ -0,0 +1,146 @@
1
+ ---
2
+ paths:
3
+ - "packages/**"
4
+ - "squads/**"
5
+ - "bin/**"
6
+ - "scripts/**"
7
+ - "tests/**"
8
+ - ".sinapse-ai/**"
9
+ - "docs/epics/**"
10
+ - "docs/stories/**"
11
+ - "docs/prd.md"
12
+ - "docs/project-brief.md"
13
+ - "src/**"
14
+ - "app/**"
15
+ - "pages/**"
16
+ - "components/**"
17
+ ---
18
+
19
+ # Documentation-First — Operational Reference
20
+
21
+ > Companion to `documentation-first.md` (the always-on core law + gates). This file
22
+ > carries the operational detail and loads when you work on code or product docs.
23
+
24
+ ## Required Pipeline (detail)
25
+
26
+ 1. **Epic** — The initiative MUST have an epic defined (or an existing one identified)
27
+ 2. **Story** — Each work unit MUST have a story file in `docs/stories/` with:
28
+ - Clear acceptance criteria (Given/When/Then preferred)
29
+ - Defined scope (IN/OUT)
30
+ - Dependencies mapped
31
+ - Complexity estimate
32
+ 3. **Validation** — Story MUST be validated (@product-lead) before implementation starts
33
+ 4. **Status** — Story status MUST be >= `Ready` before any code is written
34
+
35
+ ## Automatic Behavior
36
+
37
+ | User Says | Agent Does |
38
+ |-----------|-----------|
39
+ | "Implementa feature X" | Creates story FIRST, then implements |
40
+ | "Corrige esse bug" | Creates bug-fix story FIRST, then fixes |
41
+ | "Faz isso rapidinho" | Creates story anyway — no shortcuts |
42
+ | "Pula a documentacao" | REFUSES. Explains this is NON-NEGOTIABLE |
43
+ | "So quero o codigo" | Routes to @sprint-lead for story, then @developer |
44
+
45
+ ## Enforcement model — floor-reactive by design (honest)
46
+
47
+ Doc-first is enforced by a **deterministic reactive floor**, not by proactive prose: on a build request, `sinapse route` classifies the project type and **blocks** when the required artifacts are missing (story `Ready`; epic/PRD/architecture for large projects). This floor holds even if the agent forgets the rule, and it is covered by passing tests.
48
+
49
+ Audit AF-20260629 **refuted** the earlier "prose without enforcement" hypothesis — the floor genuinely classifies and blocks. What is *not* wired into the prompt is the proactive **layer-2 conduction** (auto-walking the user through PRD → epic → story turn by turn). That layer is intentional **roadmap**, not a missing guardrail: no new always-on hook is added here by design (a reactive floor is lower-risk than a proactive prompt injector).
50
+
51
+ ## Project Type Gate — detail
52
+
53
+ > **Why this exists:** A bare `epic + story` pipeline is necessary but not sufficient for **large projects**. A site, landing page, SaaS platform, mobile app, or backend service needs *upstream* artifacts (project brief, PRD, architecture, design spec) **before** stories can be written meaningfully. Without this gate, the framework writes stories from a vague verbal description and produces generic / off-brand output.
54
+
55
+ ### Classification matrix
56
+
57
+ The first thing every agent does on a briefing is **classify the project type** by intent + keywords:
58
+
59
+ | Project type | Trigger keywords (PT/EN) | Required workflow |
60
+ |---|---|---|
61
+ | `site` | site, website, institutional, página | `greenfield-ui.yaml` |
62
+ | `lp` | landing page, LP, captura, sales page | `greenfield-ui.yaml` |
63
+ | `app` | app, mobile, ios, android, react native | `greenfield-ui.yaml` |
64
+ | `platform` | plataforma, dashboard, admin, portal | `greenfield-fullstack.yaml` |
65
+ | `saas` | SaaS, software as a service, app web | `greenfield-fullstack.yaml` |
66
+ | `api` | API, backend, microservice, serviço | `greenfield-service.yaml` |
67
+ | `service` | worker, integration, automation, ETL | `greenfield-service.yaml` |
68
+ | `feature` | feature, funcionalidade (existing project) | SDC (Story Development Cycle) |
69
+ | `fix` | bug, conserta, corrige, ajusta, tweak | SDC YOLO mode |
70
+ | `refactor` | refatora, limpa, renomeia | SDC interactive mode |
71
+
72
+ ### The gate
73
+
74
+ ```
75
+ project_type ∈ [site, lp, app, platform, saas, api, service]
76
+ AND no epic exists in docs/epics/
77
+ → BLOCK execution
78
+ → INVOKE the required greenfield workflow
79
+ → No "implement first, document later" — ever
80
+ ```
81
+
82
+ ### Required upstream artifacts per project type
83
+
84
+ | Project type | Required artifacts BEFORE first story |
85
+ |---|---|
86
+ | `site` / `lp` / `app` | project-brief.md → prd.md → front-end-spec.md → front-end-architecture.md |
87
+ | `platform` / `saas` | project-brief.md → prd.md → front-end-spec.md → fullstack-architecture.md |
88
+ | `api` / `service` | project-brief.md → prd.md → service-architecture.md |
89
+ | `feature` (in existing project) | epic.md → story.md (no upstream re-doc needed) |
90
+ | `fix` / `refactor` | story.md only (SDC) |
91
+
92
+ ### Complexity gate (Spec Pipeline trigger)
93
+
94
+ When the user briefing is ambiguous or the scope is large, the gate ALSO triggers the Spec Pipeline (see `workflow-execution.md` § 3):
95
+
96
+ ```
97
+ complexity_score ≥ 16 (COMPLEX class) → run Spec Pipeline FIRST
98
+ → @project-lead gathers requirements
99
+ → @architect assesses + plans
100
+ → @analyst researches
101
+ → @project-lead writes spec.md
102
+ → @quality-gate critiques
103
+ → only then: epic + stories
104
+ ```
105
+
106
+ ### Examples
107
+
108
+ | User says | Classification | What the framework does |
109
+ |---|---|---|
110
+ | "criar um site pra meu cliente Acme" | `site` | Invokes `greenfield-ui.yaml` (5-agent Phase 1) |
111
+ | "monta uma plataforma SaaS de gestão" | `saas` (COMPLEX) | Spec Pipeline → then `greenfield-fullstack.yaml` |
112
+ | "API de cobrança Asaas" | `api` | Invokes `greenfield-service.yaml` |
113
+ | "corrige o botão verde da home" | `fix` | SDC YOLO direct |
114
+ | "implementa dark mode na plataforma" | `feature` | SDC interactive |
115
+ | "landing page do lançamento de outubro" | `lp` | Invokes `greenfield-ui.yaml` |
116
+
117
+ ## Workflow Enforcement
118
+
119
+ ### CORRECT Flow (always)
120
+ ```
121
+ User briefing
122
+ → @sprint-lead *draft (create story)
123
+ → @product-lead *validate (validate story)
124
+ → @developer *develop (implement)
125
+ → @quality-gate *qa-gate (quality check)
126
+ → @devops *push (deploy)
127
+ ```
128
+
129
+ ### FORBIDDEN Flow (never)
130
+ ```
131
+ User briefing → @developer *develop (BLOCKED — no story)
132
+ User briefing → Direct code writing (BLOCKED — no story)
133
+ ```
134
+
135
+ ## Anti-Patterns (FORBIDDEN) — full list
136
+
137
+ - Writing ANY code without a story
138
+ - "Quick fix" without documentation
139
+ - Implementing features based only on verbal description
140
+ - Skipping story validation
141
+ - Starting implementation with a Draft story (must be Ready)
142
+ - Treating documentation as "optional" or "we'll do it later"
143
+ - Any agent accepting implementation work without verifying story exists
144
+ - Routing a `site` / `lp` / `app` / `platform` / `saas` / `api` request directly to a domain orchestrator (e.g., `@design-orqx`, `@brand-orqx`) **before** the greenfield workflow runs and produces project-brief.md + prd.md
145
+ - Skipping the Spec Pipeline on COMPLEX briefings (score ≥ 16)
146
+ - Generating UI without DS grounding (see `~/.claude/rules/design-system-grounding.md`)
@@ -2,37 +2,21 @@
2
2
 
3
3
  > **Constitution Article III — Elevated to NON-NEGOTIABLE**
4
4
  > Applies to ALL agents, ALL projects, ALL requests. No exceptions.
5
+ > This is the always-on CORE (the law + the gates). Operational detail
6
+ > (classification matrix, upstream-artifact tables, workflow files, examples)
7
+ > lives in `documentation-first-reference.md` and loads when you work on code.
5
8
 
6
9
  ## Rule
7
10
 
8
- Before ANY code implementation begins, the full documentation pipeline MUST be completed. This is AUTOMATIC behavior no user needs to request it.
9
-
10
- ### Required Pipeline
11
+ Before ANY code implementation begins, the documentation pipeline MUST be completed —
12
+ AUTOMATIC behavior, never something the user requests:
11
13
 
12
14
  ```
13
15
  User briefing → Epic (if new initiative) → Story → Validation → Implementation
14
16
  ```
15
17
 
16
- 1. **Epic** The initiative MUST have an epic defined (or an existing one identified)
17
- 2. **Story** Each work unit MUST have a story file in `docs/stories/` with:
18
- - Clear acceptance criteria (Given/When/Then preferred)
19
- - Defined scope (IN/OUT)
20
- - Dependencies mapped
21
- - Complexity estimate
22
- 3. **Validation** — Story MUST be validated (@product-lead) before implementation starts
23
- 4. **Status** — Story status MUST be >= `Ready` before any code is written
24
-
25
- ## Automatic Behavior (NON-NEGOTIABLE)
26
-
27
- This is NOT something the user needs to request. It happens AUTOMATICALLY on every briefing:
28
-
29
- | User Says | Agent Does |
30
- |-----------|-----------|
31
- | "Implementa feature X" | Creates story FIRST, then implements |
32
- | "Corrige esse bug" | Creates bug-fix story FIRST, then fixes |
33
- | "Faz isso rapidinho" | Creates story anyway — no shortcuts |
34
- | "Pula a documentacao" | REFUSES. Explains this is NON-NEGOTIABLE |
35
- | "So quero o codigo" | Routes to @sprint-lead for story, then @developer |
18
+ If the user says "faz rapidinho", "pula a documentação", or "só quero o código":
19
+ create the story anyway the agent REFUSES shortcuts. This is NON-NEGOTIABLE.
36
20
 
37
21
  ## Gate: BLOCK
38
22
 
@@ -44,109 +28,33 @@ No implementation proceeds without ALL of these:
44
28
 
45
29
  **Attempting to write code without a valid story → BLOCKED.**
46
30
 
47
- ## Enforcement model — floor-reactive by design (honest)
48
-
49
- Doc-first is enforced by a **deterministic reactive floor**, not by proactive prose: on a build request, `sinapse route` classifies the project type and **blocks** when the required artifacts are missing (story `Ready`; epic/PRD/architecture for large projects). This floor holds even if the agent forgets the rule, and it is covered by passing tests.
50
-
51
- Audit AF-20260629 **refuted** the earlier "prose without enforcement" hypothesis — the floor genuinely classifies and blocks. What is *not* wired into the prompt is the proactive **layer-2 conduction** (auto-walking the user through PRD → epic → story turn by turn). That layer is intentional **roadmap**, not a missing guardrail: no new always-on hook is added here by design (a reactive floor is lower-risk than a proactive prompt injector).
52
-
53
31
  ## Project Type Gate (NON-NEGOTIABLE)
54
32
 
55
- > **Why this exists:** A bare `epic + story` pipeline is necessary but not sufficient for **large projects**. A site, landing page, SaaS platform, mobile app, or backend service needs *upstream* artifacts (project brief, PRD, architecture, design spec) **before** stories can be written meaningfully. Without this gate, the framework writes stories from a vague verbal description and produces generic / off-brand output.
56
-
57
- ### Classification matrix
58
-
59
- The first thing every agent does on a briefing is **classify the project type** by intent + keywords:
60
-
61
- | Project type | Trigger keywords (PT/EN) | Required workflow |
62
- |---|---|---|
63
- | `site` | site, website, institutional, página | `greenfield-ui.yaml` |
64
- | `lp` | landing page, LP, captura, sales page | `greenfield-ui.yaml` |
65
- | `app` | app, mobile, ios, android, react native | `greenfield-ui.yaml` |
66
- | `platform` | plataforma, dashboard, admin, portal | `greenfield-fullstack.yaml` |
67
- | `saas` | SaaS, software as a service, app web | `greenfield-fullstack.yaml` |
68
- | `api` | API, backend, microservice, serviço | `greenfield-service.yaml` |
69
- | `service` | worker, integration, automation, ETL | `greenfield-service.yaml` |
70
- | `feature` | feature, funcionalidade (existing project) | SDC (Story Development Cycle) |
71
- | `fix` | bug, conserta, corrige, ajusta, tweak | SDC YOLO mode |
72
- | `refactor` | refatora, limpa, renomeia | SDC interactive mode |
73
-
74
- ### The gate
75
-
76
- ```
77
- project_type ∈ [site, lp, app, platform, saas, api, service]
78
- AND no epic exists in docs/epics/
79
- → BLOCK execution
80
- → INVOKE the required greenfield workflow
81
- → No "implement first, document later" — ever
82
- ```
83
-
84
- ### Required upstream artifacts per project type
85
-
86
- | Project type | Required artifacts BEFORE first story |
87
- |---|---|
88
- | `site` / `lp` / `app` | project-brief.md → prd.md → front-end-spec.md → front-end-architecture.md |
89
- | `platform` / `saas` | project-brief.md → prd.md → front-end-spec.md → fullstack-architecture.md |
90
- | `api` / `service` | project-brief.md → prd.md → service-architecture.md |
91
- | `feature` (in existing project) | epic.md → story.md (no upstream re-doc needed) |
92
- | `fix` / `refactor` | story.md only (SDC) |
33
+ A bare `epic + story` is NOT sufficient for large projects. On every briefing the
34
+ agent FIRST classifies the project type; for `site / lp / app / platform / saas /
35
+ api / service` with no epic in `docs/epics/` → **BLOCK execution and invoke the
36
+ required greenfield workflow** (project-brief → PRD → spec/architecture → stories).
37
+ No "implement first, document later" ever. Ambiguous or large briefings
38
+ (complexity ≥ 16 COMPLEX) ALSO trigger the Spec Pipeline first.
93
39
 
94
- ### Complexity gate (Spec Pipeline trigger)
95
-
96
- When the user briefing is ambiguous or the scope is large, the gate ALSO triggers the Spec Pipeline (see `workflow-execution.md` § 3):
97
-
98
- ```
99
- complexity_score ≥ 16 (COMPLEX class) → run Spec Pipeline FIRST
100
- → @project-lead gathers requirements
101
- → @architect assesses + plans
102
- → @analyst researches
103
- → @project-lead writes spec.md
104
- → @quality-gate critiques
105
- → only then: epic + stories
106
- ```
107
-
108
- ### Examples
109
-
110
- | User says | Classification | What the framework does |
111
- |---|---|---|
112
- | "criar um site pra meu cliente Acme" | `site` | Invokes `greenfield-ui.yaml` (5-agent Phase 1) |
113
- | "monta uma plataforma SaaS de gestão" | `saas` (COMPLEX) | Spec Pipeline → then `greenfield-fullstack.yaml` |
114
- | "API de cobrança Asaas" | `api` | Invokes `greenfield-service.yaml` |
115
- | "corrige o botão verde da home" | `fix` | SDC YOLO direct |
116
- | "implementa dark mode na plataforma" | `feature` | SDC interactive |
117
- | "landing page do lançamento de outubro" | `lp` | Invokes `greenfield-ui.yaml` |
118
-
119
- ## Workflow Enforcement
120
-
121
- ### CORRECT Flow (always)
122
- ```
123
- User briefing
124
- → @sprint-lead *draft (create story)
125
- → @product-lead *validate (validate story)
126
- → @developer *develop (implement)
127
- → @quality-gate *qa-gate (quality check)
128
- → @devops *push (deploy)
129
- ```
130
-
131
- ### FORBIDDEN Flow (never)
132
- ```
133
- User briefing → @developer *develop (BLOCKED — no story)
134
- User briefing → Direct code writing (BLOCKED — no story)
135
- ```
40
+ Enforcement is a deterministic reactive floor: `sinapse route` classifies and
41
+ blocks when required artifacts are missing — it holds even if the agent forgets.
136
42
 
137
43
  ## Exception
138
44
 
139
- The ONLY exception is framework governance work by @sinapse-orqx (constitutional amendments, ecosystem health), which operates above the story layer. Even then, changes SHOULD be documented.
45
+ ONLY framework governance work by @sinapse-orqx (constitutional amendments,
46
+ ecosystem health) operates above the story layer. Even then, changes SHOULD be documented.
140
47
 
141
48
  ## Anti-Patterns (FORBIDDEN)
142
49
 
143
- - Writing ANY code without a story
144
- - "Quick fix" without documentation
145
- - Implementing features based only on verbal description
146
- - Skipping story validation
147
- - Starting implementation with a Draft story (must be Ready)
148
- - Treating documentation as "optional" or "we'll do it later"
149
- - Any agent accepting implementation work without verifying story exists
150
- - Routing a `site` / `lp` / `app` / `platform` / `saas` / `api` request directly to a domain orchestrator (e.g., `@design-orqx`, `@brand-orqx`) **before** the greenfield workflow runs and produces project-brief.md + prd.md
50
+ - Writing ANY code without a story; "quick fix" without documentation
51
+ - Starting implementation with a Draft story (must be Ready); skipping validation
52
+ - Routing a large-project request to a domain orchestrator before the greenfield
53
+ workflow produces project-brief.md + prd.md
151
54
  - Skipping the Spec Pipeline on COMPLEX briefings (score ≥ 16)
152
- - Generating UI without DS grounding (see `~/.claude/rules/design-system-grounding.md`)
55
+ - Treating documentation as "optional" or "we'll do it later"
56
+
57
+ > **Detail (loads on code work):** classification matrix (triggers per project
58
+ > type), required upstream artifacts per type, complexity dimensions, correct /
59
+ > forbidden flows, examples, enforcement-model notes — see
60
+ > `documentation-first-reference.md`.
@@ -0,0 +1,93 @@
1
+ ---
2
+ paths:
3
+ - "squads/**"
4
+ - ".sinapse-ai/development/**"
5
+ - ".claude/commands/**"
6
+ - ".claude/agents/**"
7
+ ---
8
+
9
+ # Mandatory Delegation — Operational Reference
10
+
11
+ > Companion to `mandatory-delegation.md` (the always-on core law). This file carries
12
+ > the full matrices and handoff detail and loads when you work on agent/squad files.
13
+
14
+ ## Delegation Matrix
15
+
16
+ ### Framework Agents (Development Workflow)
17
+
18
+ | Request Type | Delegate To |
19
+ |-------------|-------------|
20
+ | Code implementation | @developer (Pixel) |
21
+ | Story creation | @sprint-lead (Sync) |
22
+ | Story validation | @product-lead (Axis) |
23
+ | Architecture decisions | @architect (Stratum) |
24
+ | Quality/testing | @quality-gate (Litmus) |
25
+ | Database work | @data-engineer (Tensor) |
26
+ | UX/UI design | @ux-design-expert (Mosaic) |
27
+ | Git push/PR/release | @devops (Pipeline) |
28
+ | Epic orchestration | @project-lead (Beacon) |
29
+ | Research/analysis | @analyst (Scope) |
30
+
31
+ ### Squad Orchestrators (Domain Expertise)
32
+
33
+ | Request Domain | Delegate To |
34
+ |---------------|-------------|
35
+ | Branding, identidade visual | @brand-orqx (Meridian) |
36
+ | Vendas, CRM, pipeline | @commercial-orqx (Pipeline) |
37
+ | Conteudo, editorial | @content-orqx |
38
+ | Copywriting, persuasao | @copy-orqx (Quill) |
39
+ | Animacoes web, motion | @animations-orqx (Kinetic) |
40
+ | UX/UI, design system | @design-orqx (Nexus) |
41
+ | Financeiro, pricing | @finance-orqx (Ledger) |
42
+ | Growth, SEO, analytics | @growth-orqx (Catalyst) |
43
+ | Midia paga, ads | @paidmedia-orqx (Apex) |
44
+ | Produto, roadmap | @product-orqx (Vector) |
45
+ | Pesquisa, inteligencia | @research-orqx (Prism) |
46
+ | Claude Code mastery | @swarm-orqx (Relay) |
47
+ | Conselho estrategico | @council-orqx (Zenith) |
48
+ | Storytelling, pitch | @storytelling-orqx (Arc) |
49
+ | Cybersecurity | @cyber-orqx (Fortress) |
50
+ | Clonagem cognitiva | @cloning-orqx (Helix) |
51
+ | Cursos, workshops | @courses-orqx (Syllabus) |
52
+
53
+ ## What Orchestrators CAN Do (their actual domain)
54
+
55
+ Orchestrators have their OWN domain of expertise:
56
+
57
+ | Orchestrator | Own Domain (can execute directly) |
58
+ |-------------|----------------------------------|
59
+ | Imperator (sinapse-orqx) | Routing, diagnostico, plano de orquestracao, coordenacao cross-squad, framework governance |
60
+ | Squad *-orqx | Routing intra-squad, coordenacao de agentes do squad, handoff management |
61
+
62
+ Everything OUTSIDE their orchestration domain MUST be delegated.
63
+
64
+ ## Universal Auto-Routing — detail
65
+
66
+ **On EVERY user message (not just orchestrator):**
67
+ 1. Detect the domain of the request
68
+ 2. If a specialist exists → delegate automatically (no confirmation needed)
69
+ 3. Brief acknowledgment: "Delegando para @specialist..."
70
+ 4. Return the result to the user
71
+
72
+ **Auto-detect project state on first interaction:**
73
+ - Check for `.sinapse-ai/` → SINAPSE-managed (continue SDC)
74
+ - Check for `package.json` or `.git` → Brownfield (run quick tech scan first)
75
+ - Empty directory → Greenfield (ask project type, scaffold)
76
+
77
+ **Cross-agent handoff (automatic, never ask user):**
78
+ - Agent needs git push → auto-delegate to @devops
79
+ - Agent needs tests → auto-delegate to @quality-gate
80
+ - Agent needs schema → auto-delegate to @data-engineer
81
+ - Agent needs story → auto-create via fast-track or @sprint-lead
82
+ - Agent needs architecture decision → auto-delegate to @architect
83
+
84
+ ## Anti-Patterns (FORBIDDEN) — full list
85
+
86
+ - Orchestrator writing application code
87
+ - Orchestrator making architectural decisions without @architect
88
+ - Orchestrator creating stories without @sprint-lead
89
+ - Orchestrator running quality checks without @quality-gate
90
+ - Orchestrator doing database work without @data-engineer
91
+ - Orchestrator doing ANY specialist work outside of orchestration
92
+ - Saying "vou fazer isso eu mesmo" instead of delegating
93
+ - Absorbing a request and executing it instead of routing