agent-enderun 1.10.4 → 1.11.1

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 (210) hide show
  1. package/README.md +34 -45
  2. package/dist/framework-mcp/tests/tools/quality/check_lint.test.js +1 -1
  3. package/dist/framework-mcp/tests/tools/quality/check_lint.test.js.map +1 -1
  4. package/dist/src/cli/adapters/core.d.ts +1 -1
  5. package/dist/src/cli/adapters/core.js +0 -1
  6. package/dist/src/cli/adapters/core.js.map +1 -1
  7. package/dist/src/cli/adapters/index.d.ts +1 -0
  8. package/dist/src/cli/adapters/index.js +1 -0
  9. package/dist/src/cli/adapters/index.js.map +1 -1
  10. package/dist/src/cli/adapters/scaffold.d.ts +1 -1
  11. package/dist/src/cli/adapters/scaffold.js +13 -7
  12. package/dist/src/cli/adapters/scaffold.js.map +1 -1
  13. package/dist/src/cli/commands/init/scaffold-core.d.ts +5 -2
  14. package/dist/src/cli/commands/init/scaffold-core.js +28 -6
  15. package/dist/src/cli/commands/init/scaffold-core.js.map +1 -1
  16. package/dist/src/cli/commands/init.js +31 -4
  17. package/dist/src/cli/commands/init.js.map +1 -1
  18. package/dist/src/cli/commands/orchestrate.d.ts +9 -7
  19. package/dist/src/cli/commands/orchestrate.js +40 -4
  20. package/dist/src/cli/commands/orchestrate.js.map +1 -1
  21. package/dist/src/cli/commands/plan.d.ts +3 -1
  22. package/dist/src/cli/commands/plan.js +79 -22
  23. package/dist/src/cli/commands/plan.js.map +1 -1
  24. package/dist/src/cli/index.js +11 -15
  25. package/dist/src/cli/index.js.map +1 -1
  26. package/dist/src/cli/utils/compliance.js +0 -1
  27. package/dist/src/cli/utils/compliance.js.map +1 -1
  28. package/dist/src/cli/utils/config-schema.d.ts +7 -7
  29. package/dist/src/cli/utils/pkg.d.ts +19 -0
  30. package/dist/src/cli/utils/pkg.js +29 -5
  31. package/dist/src/cli/utils/pkg.js.map +1 -1
  32. package/dist/src/modules/adapters/definitions.js +1 -1
  33. package/dist/src/modules/adapters/definitions.js.map +1 -1
  34. package/dist/src/modules/adapters/shared.js +7 -4
  35. package/dist/src/modules/adapters/shared.js.map +1 -1
  36. package/dist/src/modules/agents/definitions.d.ts +1 -1
  37. package/dist/src/modules/agents/definitions.js +129 -69
  38. package/dist/src/modules/agents/definitions.js.map +1 -1
  39. package/dist/src/modules/agents/registry/analyst.js +5 -1
  40. package/dist/src/modules/agents/registry/analyst.js.map +1 -1
  41. package/dist/src/modules/agents/registry/backend.js +5 -4
  42. package/dist/src/modules/agents/registry/backend.js.map +1 -1
  43. package/dist/src/modules/agents/registry/database.js +2 -1
  44. package/dist/src/modules/agents/registry/database.js.map +1 -1
  45. package/dist/src/modules/agents/registry/devops.js +2 -0
  46. package/dist/src/modules/agents/registry/devops.js.map +1 -1
  47. package/dist/src/modules/agents/registry/explorer.js +1 -0
  48. package/dist/src/modules/agents/registry/explorer.js.map +1 -1
  49. package/dist/src/modules/agents/registry/git.js +3 -1
  50. package/dist/src/modules/agents/registry/git.js.map +1 -1
  51. package/dist/src/modules/agents/registry/manager.js +8 -2
  52. package/dist/src/modules/agents/registry/manager.js.map +1 -1
  53. package/dist/src/modules/agents/registry/native.js +5 -1
  54. package/dist/src/modules/agents/registry/native.js.map +1 -1
  55. package/dist/src/modules/agents/registry/security.js +1 -0
  56. package/dist/src/modules/agents/registry/security.js.map +1 -1
  57. package/dist/src/shared/constants.d.ts +1 -1
  58. package/dist/src/shared/constants.js +10 -9
  59. package/dist/src/shared/constants.js.map +1 -1
  60. package/dist/tests/approve.test.js +4 -9
  61. package/dist/tests/approve.test.js.map +1 -1
  62. package/dist/tests/integration/agent_flow.test.js +2 -2
  63. package/dist/tests/integration/agent_flow.test.js.map +1 -1
  64. package/dist/tests/orchestrate.test.js +2 -7
  65. package/dist/tests/orchestrate.test.js.map +1 -1
  66. package/framework-mcp/dist/constants.js +64 -0
  67. package/framework-mcp/dist/index.js +109 -0
  68. package/framework-mcp/dist/tools/control_plane/locking.js +64 -0
  69. package/framework-mcp/dist/tools/control_plane/registry.js +34 -0
  70. package/framework-mcp/dist/tools/dashboard/start_dashboard.js +29 -0
  71. package/framework-mcp/dist/tools/definitions.js +300 -0
  72. package/framework-mcp/dist/tools/file_system/batch_surgical_edit.js +59 -0
  73. package/framework-mcp/dist/tools/file_system/patch_file.js +25 -0
  74. package/framework-mcp/dist/tools/file_system/read_file.js +51 -0
  75. package/framework-mcp/dist/tools/file_system/replace_text.js +43 -0
  76. package/framework-mcp/dist/tools/file_system/write_file.js +38 -0
  77. package/framework-mcp/dist/tools/framework/audit_deps.js +41 -0
  78. package/framework-mcp/dist/tools/framework/get_status.js +5 -0
  79. package/framework-mcp/dist/tools/framework/orchestrate.js +5 -0
  80. package/framework-mcp/dist/tools/framework/run_tests.js +25 -0
  81. package/framework-mcp/dist/tools/framework/update_contract_hash.js +5 -0
  82. package/framework-mcp/dist/tools/framework/update_memory.js +8 -0
  83. package/framework-mcp/dist/tools/index.js +62 -0
  84. package/framework-mcp/dist/tools/memory/get_insights.js +34 -0
  85. package/framework-mcp/dist/tools/memory/read_memory.js +28 -0
  86. package/framework-mcp/dist/tools/messaging/log_action.js +22 -0
  87. package/framework-mcp/dist/tools/messaging/send_message.js +87 -0
  88. package/framework-mcp/dist/tools/observability/check_ports.js +26 -0
  89. package/framework-mcp/dist/tools/observability/get_health.js +19 -0
  90. package/framework-mcp/dist/tools/quality/check_lint.js +28 -0
  91. package/framework-mcp/dist/tools/search/get_gaps.js +48 -0
  92. package/framework-mcp/dist/tools/search/get_map.js +43 -0
  93. package/framework-mcp/dist/tools/search/grep_search.js +76 -0
  94. package/framework-mcp/dist/tools/search/list_dir.js +28 -0
  95. package/framework-mcp/dist/tools/shell/run_command.js +46 -0
  96. package/framework-mcp/dist/tools/types.js +1 -0
  97. package/framework-mcp/dist/utils/cli.js +20 -0
  98. package/framework-mcp/dist/utils/compliance.js +29 -0
  99. package/framework-mcp/dist/utils/fs.js +44 -0
  100. package/framework-mcp/dist/utils/metrics.js +56 -0
  101. package/framework-mcp/dist/utils/security.js +60 -0
  102. package/framework-mcp/package.json +19 -0
  103. package/framework-mcp/src/constants.ts +78 -0
  104. package/framework-mcp/src/declarations.d.ts +17 -0
  105. package/framework-mcp/src/index.ts +132 -0
  106. package/framework-mcp/src/tools/control_plane/locking.ts +71 -0
  107. package/framework-mcp/src/tools/control_plane/registry.ts +38 -0
  108. package/framework-mcp/src/tools/dashboard/start_dashboard.ts +33 -0
  109. package/framework-mcp/src/tools/definitions.ts +302 -0
  110. package/framework-mcp/src/tools/file_system/batch_surgical_edit.ts +79 -0
  111. package/framework-mcp/src/tools/file_system/patch_file.ts +33 -0
  112. package/framework-mcp/src/tools/file_system/read_file.ts +58 -0
  113. package/framework-mcp/src/tools/file_system/replace_text.ts +52 -0
  114. package/framework-mcp/src/tools/file_system/write_file.ts +45 -0
  115. package/framework-mcp/src/tools/framework/audit_deps.ts +49 -0
  116. package/framework-mcp/src/tools/framework/get_status.ts +7 -0
  117. package/framework-mcp/src/tools/framework/orchestrate.ts +7 -0
  118. package/framework-mcp/src/tools/framework/run_tests.ts +28 -0
  119. package/framework-mcp/src/tools/framework/update_contract_hash.ts +7 -0
  120. package/framework-mcp/src/tools/framework/update_memory.ts +10 -0
  121. package/framework-mcp/src/tools/index.ts +66 -0
  122. package/framework-mcp/src/tools/memory/get_insights.ts +41 -0
  123. package/framework-mcp/src/tools/memory/read_memory.ts +31 -0
  124. package/framework-mcp/src/tools/messaging/log_action.ts +28 -0
  125. package/framework-mcp/src/tools/messaging/send_message.ts +89 -0
  126. package/framework-mcp/src/tools/observability/check_ports.ts +30 -0
  127. package/framework-mcp/src/tools/observability/get_health.ts +24 -0
  128. package/framework-mcp/src/tools/quality/check_lint.ts +33 -0
  129. package/framework-mcp/src/tools/search/get_gaps.ts +54 -0
  130. package/framework-mcp/src/tools/search/get_map.ts +48 -0
  131. package/framework-mcp/src/tools/search/grep_search.ts +76 -0
  132. package/framework-mcp/src/tools/search/list_dir.ts +34 -0
  133. package/framework-mcp/src/tools/shell/run_command.ts +56 -0
  134. package/framework-mcp/src/tools/types.ts +89 -0
  135. package/framework-mcp/src/utils/cli.ts +20 -0
  136. package/framework-mcp/src/utils/compliance.ts +37 -0
  137. package/framework-mcp/src/utils/fs.ts +45 -0
  138. package/framework-mcp/src/utils/metrics.ts +73 -0
  139. package/framework-mcp/src/utils/security.ts +66 -0
  140. package/framework-mcp/tests/tools/file_system/file_system_tools.test.ts +212 -0
  141. package/framework-mcp/tests/tools/messaging/send_message.test.ts +136 -0
  142. package/framework-mcp/tests/tools/quality/check_lint.test.ts +46 -0
  143. package/framework-mcp/tests/tools/shell/run_command.test.ts +55 -0
  144. package/framework-mcp/tsconfig.json +14 -0
  145. package/package.json +5 -3
  146. package/src/cli/adapters/core.ts +2 -3
  147. package/src/cli/adapters/index.ts +1 -0
  148. package/src/cli/adapters/scaffold.ts +20 -7
  149. package/src/cli/commands/init/scaffold-core.ts +45 -6
  150. package/src/cli/commands/init.ts +31 -2
  151. package/src/cli/commands/orchestrate.ts +41 -4
  152. package/src/cli/commands/plan.ts +89 -23
  153. package/src/cli/index.ts +14 -19
  154. package/src/cli/utils/compliance.ts +8 -9
  155. package/src/cli/utils/pkg.ts +42 -13
  156. package/src/modules/adapters/definitions.ts +1 -1
  157. package/src/modules/adapters/shared.ts +7 -4
  158. package/src/modules/agents/definitions.ts +140 -73
  159. package/src/modules/agents/registry/analyst.ts +5 -1
  160. package/src/modules/agents/registry/backend.ts +5 -4
  161. package/src/modules/agents/registry/database.ts +2 -1
  162. package/src/modules/agents/registry/devops.ts +2 -0
  163. package/src/modules/agents/registry/explorer.ts +1 -0
  164. package/src/modules/agents/registry/git.ts +3 -1
  165. package/src/modules/agents/registry/manager.ts +8 -2
  166. package/src/modules/agents/registry/native.ts +5 -1
  167. package/src/modules/agents/registry/security.ts +1 -0
  168. package/src/shared/constants.ts +14 -13
  169. package/templates/prompts/bug-fix-recipe.md +20 -0
  170. package/templates/prompts/contract-design-recipe.md +21 -0
  171. package/templates/prompts/db-management-recipe.md +25 -0
  172. package/templates/prompts/deployment-recipe.md +23 -0
  173. package/templates/prompts/new-feature-recipe.md +19 -0
  174. package/templates/prompts/performance-optimization-recipe.md +23 -0
  175. package/templates/prompts/pull-request-template.md +21 -0
  176. package/templates/prompts/refactoring-recipe.md +21 -0
  177. package/templates/prompts/security-audit-recipe.md +20 -0
  178. package/templates/standards/architecture-standards.md +23 -0
  179. package/templates/standards/auth-standards.md +125 -0
  180. package/templates/standards/crud-governance.md +21 -0
  181. package/templates/standards/deployment-standards.md +21 -0
  182. package/templates/standards/frontend-standards.md +37 -0
  183. package/templates/standards/github-actions-standards.md +43 -0
  184. package/templates/standards/i18n-standards.md +17 -0
  185. package/templates/standards/kysely-standards.md +47 -0
  186. package/templates/standards/llm-governance.md +15 -0
  187. package/templates/standards/logging-and-secrets.md +34 -0
  188. package/templates/standards/mobile-standards.md +23 -0
  189. package/templates/standards/observability-standards.md +15 -0
  190. package/templates/standards/performance-standards.md +15 -0
  191. package/templates/standards/pino-standards.md +46 -0
  192. package/templates/standards/playwright-standards.md +54 -0
  193. package/templates/standards/quality-standards.md +31 -0
  194. package/templates/standards/react-query-standards.md +72 -0
  195. package/templates/standards/react-router-standards.md +62 -0
  196. package/templates/standards/security-audit-standards.md +16 -0
  197. package/templates/standards/security-standards.md +21 -0
  198. package/templates/standards/swagger-standards.md +50 -0
  199. package/templates/standards/tailwind-standards.md +20 -0
  200. package/templates/standards/testing-standards.md +31 -0
  201. package/templates/standards/typeorm-standards.md +49 -0
  202. package/templates/standards/vitest-standards.md +110 -0
  203. package/src/cli/commands/app.ts +0 -56
  204. package/src/cli/utils/app-backend.ts +0 -257
  205. package/src/cli/utils/app-docs.ts +0 -83
  206. package/src/cli/utils/app-frontend.ts +0 -263
  207. package/src/cli/utils/app-inferrer.ts +0 -63
  208. package/src/cli/utils/app-mobile.ts +0 -113
  209. package/src/cli/utils/app-types.ts +0 -248
  210. package/src/cli/utils/app.ts +0 -6
@@ -0,0 +1,21 @@
1
+ # 📜 Engineering Recipe: Contract-First Design
2
+
3
+ This recipe governs the @architect agent's protocol for creating type-safe agreements between system layers.
4
+
5
+ ## 🏁 Phase 1: Requirement Alignment
6
+ 1. **Analysis:** Read user requirements and Business Analyst (@analyst) reports.
7
+ 2. **Scope Discovery:** Identify the domain objects, actions, and events required for the feature.
8
+
9
+ ## 📐 Phase 2: Technical Modeling
10
+ 1. **Branded Types:** Define semantic IDs in `src/types/brands.ts` (e.g., `OrderId`, `ProductSKU`).
11
+ 2. **Domain Models:** Create or update interfaces in `src/types/models.ts`. Ensure they extend `BaseEntity`.
12
+ 3. **Constants:** Update `src/types/constants.ts` for enums and fixed state values.
13
+
14
+ ## 🔏 Phase 3: Hash Sealing
15
+ 1. **Integrity Check:** Run `agent-enderun verify-contract` to check existing state.
16
+ 2. **Commitment:** Run `agent-enderun update-contract` to generate new SHA-256 signatures for the updated types.
17
+ 3. **Audit:** Verify that `contract.version.json` accurately reflects the new architecture.
18
+
19
+ ## 📡 Phase 4: Synchronization
20
+ 1. **Distribution:** Ensure the updated `src/types` directory is correctly linked or copied to both Frontend and Backend projects.
21
+ 2. **Verification:** Trigger @backend and @frontend agents to read the new contract and plan their implementations.
@@ -0,0 +1,25 @@
1
+ # 🗄️ Engineering Recipe: Database Management & Migrations
2
+
3
+ This recipe governs the @database agent's protocol for schema creation, table modifications, and data integrity.
4
+
5
+ ## 📐 Phase 1: Contract-First Definition
6
+ 1. **Type Mapping:** Define the new table or column in `src/types/models.ts` using Branded Types for IDs.
7
+ 2. **Validation:** Ensure the interface extends `BaseEntity` (id, createdAt, updatedAt).
8
+
9
+ ## 🚀 Phase 2: Migration Generation
10
+ 1. **Scripting:** Write a reversible migration (up/down) using the project's migration tool (e.g., Kysely or SQL).
11
+ 2. **Atomic Changes:** One migration per logical feature. Never bundle unrelated schema changes.
12
+ 3. **Naming:** Use timestamp-prefixed naming (e.g., `20240101_add_customers_table.ts`).
13
+
14
+ ## 🧱 Phase 3: Infrastructure Setup (If New DB)
15
+ 1. **Initialization:** Verify the connection string in `.env`.
16
+ 2. **Health Check:** Run `check_active_ports` to ensure the DB engine is reachable.
17
+
18
+ ## 🛠️ Phase 4: Implementation & Repository Update
19
+ 1. **Repo Layer:** Create or update the Repository class to include the new query logic.
20
+ 2. **Strict Mode:** Ensure no raw SQL is used; leverage the query builder exclusively.
21
+
22
+ ## ✅ Phase 5: Verification & Zero-Downtime Audit
23
+ 1. **Dry Run:** If supported, dry-run the migration to check for locking issues.
24
+ 2. **Validation:** Run `agent-enderun verify-contract` to ensure code and schema are synced.
25
+ 3. **Handoff:** Update `PROJECT_MEMORY.md` with the new schema version.
@@ -0,0 +1,23 @@
1
+ # 🚀 Engineering Recipe: Infrastructure Deployment
2
+
3
+ This recipe governs the @devops agent's protocol for safe, traceable, and reversible system rollouts.
4
+
5
+ ## 🏁 Phase 1: Pre-Deployment Environment Audit
6
+ 1. **Integrity Check:** Run `agent-enderun check` to ensure all discipline rules are met.
7
+ 2. **Health Scan:** Execute `get_system_health` and `check_active_ports` on the target environment.
8
+ 3. **Config Sync:** Verify that all keys in `.env.example` are present in the target environment's secrets manager.
9
+
10
+ ## 🧱 Phase 2: Build & Validation
11
+ 1. **Compilation:** Run `npm run build` and capture any stderr.
12
+ 2. **Contract Verify:** Run `agent-enderun verify-contract` to ensure FE/BE synchronization.
13
+ 3. **Test Suite:** Execute the full test battery. Failure in a single test blocks deployment.
14
+
15
+ ## 📡 Phase 3: Controlled Rollout
16
+ 1. **Atomic Swap:** Deploy the new bundle/service using the project's orchestration scripts.
17
+ 2. **Database Sync:** If migrations are pending, follow the `db-management-recipe.md` first.
18
+ 3. **Log Monitoring:** Tail `logs/manager.json` for immediate post-deploy spikes in errors.
19
+
20
+ ## ✅ Phase 4: Post-Deploy & Rollback Readiness
21
+ 1. **Observability:** Verify system metrics stabilize within 5 minutes.
22
+ 2. **Traceability:** Record the deployment Trace ID and commit hash in `PROJECT_MEMORY.md`.
23
+ 3. **Rollback Check:** Ensure the previous stable version is tagged and reachable in Git.
@@ -0,0 +1,19 @@
1
+ # ✨ New Feature Development Recipe
2
+
3
+ The "Nizam-ı Enderun" steps to follow when adding a new module or feature.
4
+
5
+ ## 1. Contract Design (Phase 1)
6
+ - First, update the `contract.version.json` file and the relevant TypeScript types.
7
+ - Do not start writing code without getting approval from `@architect`.
8
+
9
+ ## 2. Mock-Free Development (Phase 2)
10
+ - Add the new feature to the correct directory under `apps/backend` or `apps/web`.
11
+ - If database changes are required, coordinate with the `@database` agent.
12
+
13
+ ## 3. Responsive & i18n (Phase 3)
14
+ - Use `{ base: '...', md: '...' }` responsive syntax in frontend developments.
15
+ - Move all texts to the `locales/` directory immediately.
16
+
17
+ ## 4. Completion (Phase 4)
18
+ - Ensure no TODOs remain using `get_project_gaps`.
19
+ - Verify that you haven't created any new package pollution with `audit_dependencies`.
@@ -0,0 +1,23 @@
1
+ # ⚡ Engineering Recipe: Performance Optimization
2
+
3
+ This recipe governs the protocol for identifying and resolving system bottlenecks (Frontend, Backend, or Database).
4
+
5
+ ## 📊 Phase 1: Profiling & Bottleneck Identification
6
+ 1. **Metric Collection:** Read `observability/metrics.json` or run `get_system_health`.
7
+ 2. **Log Audit:** Scan `logs/manager.json` for slow actions or timeouts.
8
+ 3. **Trace Analysis:** Use `TraceID` to follow a slow request through all layers.
9
+
10
+ ## 🧠 Phase 2: Root Cause Analysis
11
+ 1. **SQL Audit:** Check for N+1 query patterns or missing indexes in `repository/` files.
12
+ 2. **Algorithm Audit:** Scan for O(n²) loops or heavy synchronous operations.
13
+ 3. **Frontend Audit:** Check for unnecessary re-renders or massive bundle sizes.
14
+
15
+ ## 🛠️ Phase 3: Surgical Optimization
16
+ 1. **DB Level:** Add missing indexes or refactor complex joins.
17
+ 2. **Logic Level:** Implement caching (e.g., Redis or in-memory) for frequent read operations.
18
+ 3. **UI Level:** Apply memoization, virtualization (FlashList), or code-splitting.
19
+
20
+ ## ✅ Phase 4: Validation & Comparison
21
+ 1. **Benchmarking:** Re-run the action and compare new metrics with the baseline.
22
+ 2. **Regression Check:** Run `agent-enderun check` and existing tests to ensure logic is intact.
23
+ 3. **Knowledge Update:** Record the optimization strategy in `knowledge/performance-history.md`.
@@ -0,0 +1,21 @@
1
+ # 📦 Pull Request Title: [TRC-{TraceId}] Brief Description
2
+
3
+ ## 📝 Summary
4
+ <!-- What did you change and why? -->
5
+
6
+ ## 🔗 Related Tasks
7
+ - **Trace ID:** [Link to Trace/Task or ID]
8
+ - **Issue:** [Link to issue if applicable]
9
+
10
+ ## 🛡️ Governance & Compliance Checklist
11
+ - [ ] Code passes `npm run enderun:test`.
12
+ - [ ] Code passes `npm run enderun:check` (Compliance Scanner).
13
+ - [ ] No `any` type usage added.
14
+ - [ ] No secrets or hardcoded API keys.
15
+ - [ ] New functionality is registered in `src/modules/agents/definitions.ts` (if applicable).
16
+
17
+ ## 🧪 Testing Notes
18
+ <!-- How did you verify the fix? -->
19
+
20
+ ## 🛠️ Risk Assessment
21
+ <!-- Any potential side effects? -->
@@ -0,0 +1,21 @@
1
+ # 🛠️ Surgical Refactoring Recipe
2
+
3
+ This recipe defines how to modernize existing code without breaking other parts of the project.
4
+
5
+ ## 1. Reconnaissance
6
+ - Use `grep_search` to find all references to the function to be refactored.
7
+ - Understand the module's dependency graph with `get_project_map`.
8
+ - Verify the baseline by running existing tests (`run_tests`).
9
+
10
+ ## 2. Planning (Strategy)
11
+ - Break the change into small, atomic steps.
12
+ - Define new types and interfaces first.
13
+
14
+ ## 3. Surgical Execution
15
+ - **RULE:** Never delete a file completely. Only use `replace_text` or `batch_surgical_edit`.
16
+ - Maintain type safety (ban on `any`) at every step.
17
+ - Update `PROJECT_MEMORY.md` after every major change.
18
+
19
+ ## 4. Validation
20
+ - Ensure no regressions occurred using `run_tests`.
21
+ - Audit code quality with the `@quality` agent.
@@ -0,0 +1,20 @@
1
+ # 🛡️ Engineering Recipe: Advanced Security Audit
2
+
3
+ This recipe governs the @security agent's protocol for identifying and mitigating vulnerabilities within the Agent Enderun framework.
4
+
5
+ ## 🏁 Phase 1: Automated Reconnaissance
6
+ 1. **Secret Scan:** Run `grep_search` for keywords: `apiKey`, `secret`, `password`, `token`, `private_key`.
7
+ 2. **SQL Injection Audit:** Scan for `raw SQL` or template literals bypassing the query builder.
8
+ 3. **Auth Check:** Verify that all sensitive routes have active `auth` guards and Role-Based Access Control (RBAC).
9
+
10
+ ## 🧠 Phase 2: Contextual Analysis
11
+ 1. **Impact Mapping:** For every identified risk, read the surrounding code to determine if it's exposed to the public internet.
12
+ 2. **Configuration Check:** Verify `.env.example` contains all required keys and no real secrets are committed to Git.
13
+
14
+ ## 🛠️ Phase 3: Surgical Mitigation
15
+ 1. **Fix:** Use `replace_text` to move hardcoded secrets to `.env` or refactor raw SQL to Kysely.
16
+ 2. **Sanitization:** Apply input validation using Zod schemas for all external data.
17
+
18
+ ## ✅ Phase 4: Verification & Logging
19
+ 1. **Discipline Check:** Run `agent-enderun check` to ensure no new violations were introduced.
20
+ 2. **Action Log:** Execute `log_agent_action` with a summary of found vs. fixed vulnerabilities.
@@ -0,0 +1,23 @@
1
+ # 📐 Corporate Architecture Standards (AL Framework)
2
+
3
+ This project is developed in accordance with the "Nizam-ı Mimari" (Architectural Order) rules defined by Agent Enderun.
4
+
5
+ ## 1. Directory Structure (Monorepo Standard)
6
+ - `apps/backend/`: Business logic, API, and database layers.
7
+ - `apps/web/`: Frontend (React/Next.js) layer.
8
+ - `packages/shared/`: Type definitions and helpers shared between Backend and Frontend.
9
+
10
+ ## 2. Layered Architecture
11
+ All business logic must follow this hierarchy:
12
+ 1. **Routes/Controllers:** API entry points and request validation.
13
+ 2. **Services:** Where business logic is coordinated.
14
+ 3. **Repositories/Models:** Database access and raw data mutations.
15
+
16
+ ## 3. Type Safety and Contracts
17
+ - The hash in the `contract.version.json` file must always match the active code.
18
+ - The use of the `any` type is strictly forbidden.
19
+ - All asynchronous operations must be wrapped in `try-catch` blocks and proper error management (ErrorHandler).
20
+
21
+ ## 4. AL (Agent Lifecycle) Phase Discipline
22
+ - Development progresses sequentially from Phase 0 to Phase 4.
23
+ - Application code (Phase 2) cannot be written before contracts are approved (Phase 1).
@@ -0,0 +1,125 @@
1
+ # Authentication & Authorization Standards
2
+
3
+ > JWT + bcrypt authentication and role-based access control for Fastify APIs.
4
+
5
+ ## Overview
6
+
7
+ Enterprise-grade authentication system using JSON Web Tokens (JWT) for stateless authentication and bcrypt for secure password hashing.
8
+
9
+ ## Setup
10
+
11
+ ```bash
12
+ # Required dependencies
13
+ npm install bcrypt jsonwebtoken
14
+ npm install -D @types/bcrypt @types/jsonwebtoken
15
+ ```
16
+
17
+ ## Token Management
18
+
19
+ ```typescript
20
+ import jwt from "jsonwebtoken";
21
+
22
+ const JWT_SECRET = process.env.JWT_SECRET || "change-me-in-production";
23
+ const JWT_EXPIRES_IN = process.env.JWT_EXPIRES_IN || "24h";
24
+
25
+ interface AuthPayload {
26
+ sub: string; // User ID
27
+ email: string; // User email
28
+ role: string; // User role (ADMIN, DEVELOPER, VIEWER)
29
+ iat?: number; // Issued at
30
+ exp?: number; // Expires at
31
+ }
32
+
33
+ export function generateToken(payload: AuthPayload): string {
34
+ return jwt.sign(payload, JWT_SECRET, { expiresIn: JWT_EXPIRES_IN });
35
+ }
36
+
37
+ export function verifyToken(token: string): AuthPayload {
38
+ return jwt.verify(token, JWT_SECRET) as AuthPayload;
39
+ }
40
+ ```
41
+
42
+ ## Middleware
43
+
44
+ ```typescript
45
+ import type { FastifyRequest, FastifyReply } from "fastify";
46
+
47
+ export async function authenticate(
48
+ request: FastifyRequest,
49
+ reply: FastifyReply,
50
+ ): Promise<void> {
51
+ const authHeader = request.headers.authorization;
52
+ if (!authHeader?.startsWith("Bearer ")) {
53
+ throw new UnauthorizedError("Missing authorization header");
54
+ }
55
+ const token = authHeader.slice(7);
56
+ const payload = verifyToken(token);
57
+ (request as any).user = payload;
58
+ }
59
+
60
+ export function requireRole(...roles: string[]) {
61
+ return async (request: FastifyRequest, reply: FastifyReply) => {
62
+ const user = (request as any).user as AuthPayload;
63
+ if (!user || !roles.includes(user.role)) {
64
+ throw new ForbiddenError("Insufficient permissions");
65
+ }
66
+ };
67
+ }
68
+ ```
69
+
70
+ ## Password Security
71
+
72
+ ```typescript
73
+ import bcrypt from "bcrypt";
74
+
75
+ const SALT_ROUNDS = 12;
76
+
77
+ // Hash password for storage
78
+ export async function hashPassword(password: string): Promise<string> {
79
+ return bcrypt.hash(password, SALT_ROUNDS);
80
+ }
81
+
82
+ // Verify password against hash
83
+ export async function verifyPassword(
84
+ password: string,
85
+ hash: string,
86
+ ): Promise<boolean> {
87
+ return bcrypt.compare(password, hash);
88
+ }
89
+ ```
90
+
91
+ ## CRUD Governance Integration
92
+
93
+ Admin-level mutations (user creation, role changes, schema modifications) **MUST** follow the CRUD Governance protocol:
94
+ - Route through `@manager` for approval
95
+ - Require human sign-off via `agent-enderun approve <traceId>`
96
+ - Log all authorization decisions
97
+
98
+ ## API Endpoints
99
+
100
+ | Method | Path | Auth Required | Role Required | Description |
101
+ |--------|------|:------------:|:------------:|-------------|
102
+ | POST | `/api/v1/auth/register` | No | No | Create new user |
103
+ | POST | `/api/v1/auth/login` | No | No | Login & get token |
104
+ | GET | `/api/v1/auth/me` | Yes | No | Get current user |
105
+ | PUT | `/api/v1/auth/password` | Yes | No | Change password |
106
+
107
+ ## Environment Variables
108
+
109
+ ```bash
110
+ JWT_SECRET=your-secret-key-at-least-32-chars-long
111
+ JWT_EXPIRES_IN=24h
112
+ ```
113
+
114
+ ## Best Practices
115
+
116
+ 1. **Password Hashing**: Always use bcrypt with minimum 12 salt rounds
117
+ 2. **Token Expiry**: Use short-lived tokens (24h max). Implement refresh tokens for longer sessions
118
+ 3. **Secret Rotation**: Rotate JWT_SECRET periodically in production
119
+ 4. **Rate Limiting**: Apply rate limiting on login/register endpoints to prevent brute force
120
+ 5. **HTTPS Only**: Never transmit tokens over unencrypted connections
121
+ 6. **Password Strength**: Enforce minimum password requirements (8+ chars, mixed case, numbers)
122
+ 7. **Audit Logging**: Log all authentication attempts (success/failure) for security monitoring
123
+ 8. **No Plain Text**: Never log or store passwords in plain text
124
+ 9. **Token Storage**: Store tokens securely (httpOnly cookies for web, secure storage for mobile)
125
+ 10. **Role Hierarchy**: ADMIN > MANAGER > DEVELOPER > VIEWER — validate permissions at each level
@@ -0,0 +1,21 @@
1
+ # 🏛️ Corporate CRUD and Governance Standards
2
+
3
+ This document defines the strict rules applicable to data mutation and administrative operations in projects managed by the Agent Enderun army.
4
+
5
+ ## 1. High-Risk Operations
6
+ The following operations are considered "High-Risk" and cannot be performed autonomously by specialist agents (@backend, @database, etc.):
7
+ - Database schema changes (DDL).
8
+ - Bulk data deletion or purging (Bulk Delete/Purge).
9
+ - User authorization and role assignment systems.
10
+ - Payment system (Billing) integrations.
11
+ - PII (Personal Data) export.
12
+
13
+ ## 2. Approval Flow
14
+ - When a specialist agent receives a high-risk operation request, they must reject the operation and report the status to `@manager`.
15
+ - `@manager` analyzes the request and creates a task awaiting `managerApproval`.
16
+ - The operation is held until a human overseer (Human-in-the-Loop) grants approval via the `agent-enderun approve [TraceID]` command.
17
+
18
+ ## 3. Data Discipline
19
+ - **Branded Types:** All IDs (UserID, OrderID, etc.) must strictly follow the branded types format.
20
+ - **Kysely Only:** Raw SQL queries are forbidden. Only the type-safe Kysely query builder may be used.
21
+ - **Repository Pattern:** Database operations cannot be performed directly within controllers; they must pass through the service and repository layers.
@@ -0,0 +1,21 @@
1
+ # 🚀 Deployment and Release Standards
2
+
3
+ This document outlines the protocols for deploying, updating, and rolling back services managed by Agent Enderun.
4
+
5
+ ## 1. Release Strategy
6
+ - **Version Control:** All releases must follow Semantic Versioning (SemVer) and be tagged in Git with the format `vX.Y.Z`.
7
+ - **Atomic Commits:** Each deployment must be linked to a specific Git commit, which itself must contain a `Trace ID` in the commit message.
8
+
9
+ ## 2. Deployment Workflow
10
+ - **CI/CD Integration:** Every deployment must pass the `npm run enderun:test` and `npm run enderun:check` pipeline.
11
+ - **Environment Isolation:** Deployments must use environment-specific configurations (.env.{env}) and never cross-pollinate variables.
12
+
13
+ ## 3. Rollback Procedures (The Hermes Safety Valve)
14
+ - **Immediate Rollback:** If a deployment causes an escalation alert from an agent or a production failure, a rollback must be initiated within 5 minutes.
15
+ - **Git Revert Strategy:**
16
+ - Rollbacks are executed by checking out the previous stable tag (e.g., `git checkout v1.0.9`).
17
+ - A "Fix-Forward" approach is only allowed for P0 security patches; otherwise, "Revert-First" is the law.
18
+ - **Database Safety:**
19
+ - Every Migration script must strictly include a corresponding `down()` or `revert()` path.
20
+ - Database rollbacks must be tested in the staging environment before production execution.
21
+ - **Post-Mortem Requirement:** Every rollback triggers an automatic `@manager` task to create a `docs/post-mortems/TRACE_ID.md` report.
@@ -0,0 +1,37 @@
1
+ # 🎨 Corporate Frontend and Responsive Standards
2
+
3
+ This document defines the UI/UX standards for projects managed by Agent Enderun. All interfaces must comply with "Mobile-First", "Fluid Responsive", and "Cross-Device Adaptive" principles.
4
+
5
+ ## 1. Design System: Panda CSS & Tailwind Integration
6
+ - **Zero UI Library:** Heavy external UI libraries like Ant Design or MUI are not used. All styles are written with type-safe **Panda CSS** or structured **Tailwind CSS**.
7
+ - **Token Usage:** Colors, spacing, and font sizes must be managed via the `token()` function or standard CSS variables.
8
+ - **Responsive Syntax:** Object-based responsive syntax is mandatory:
9
+ ```typescript
10
+ css({
11
+ width: { base: '100%', md: '50%', lg: '33.33%' },
12
+ padding: { base: '4', md: '8' }
13
+ })
14
+ ```
15
+
16
+ ## 2. Mobile-First and Fluid Design
17
+ - **Mobile-First Approach:** Styles must always be written for the smallest screen size (`base`), then expanded to larger screens using `sm`, `md`, `lg`, `xl`, and `2xl` breakpoints.
18
+ - **Fluid Grid & Flexbox:** Layouts should not be restricted by fixed widths. `flex-wrap` and CSS Grid (`grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))`) are preferred.
19
+ - **Fluid Typography:** Font sizes should scale dynamically based on screen width:
20
+ ```css
21
+ font-size: clamp(1rem, 2vw + 0.5rem, 2rem);
22
+ ```
23
+ - **Container Bounds:** The main body of the page must have responsive padding and a maximum width limit (standard of `1280px` or `1440px`).
24
+
25
+ ## 3. Viewport Safety
26
+ - **Overflow Guard:** Horizontal scrollbars are strictly forbidden. `box-sizing: border-box` must be applied to all elements, and widths must be restricted with `max-width: 100%`.
27
+ - **Dynamic Viewport Units:** To avoid issues with mobile browser address bars, use `dvh` (Dynamic Viewport Height) and `dvw` instead of `vh` and `vw`.
28
+ - **Touch Targets:** Clickable elements (buttons, links, inputs) on mobile devices must have a minimum size of `44px x 44px`.
29
+
30
+ ## 4. Component Governance
31
+ - **Atomic Design:** UI components must be collected under `apps/web/src/components/ui/`.
32
+ - **Page Isolation:** Reusable atomic components should be preferred over defining styles within page files.
33
+ - **Image Optimization:** Use the `picture` tag or `srcset` for responsive images, and support `@2x` resolutions for retina displays. SVGs must always be scalable via `viewBox`.
34
+
35
+ ## 5. Accessibility and Performance
36
+ - **WCAG AA:** All color contrasts and keyboard navigation structures must comply with WCAG AA standards.
37
+ - **Lighthouse Score:** A score of 90+ for performance, accessibility, and SEO should be targeted for all pages.
@@ -0,0 +1,43 @@
1
+ # CI/CD Pipeline Standards (GitHub Actions)
2
+
3
+ > Automated quality gates and deployment pipelines.
4
+
5
+ ## Overview
6
+
7
+ GitHub Actions CI/CD pipeline for automated testing, type-checking, and quality assurance.
8
+
9
+ ## Pipeline Structure
10
+
11
+ ```yaml
12
+ name: CI/CD Pipeline
13
+ on: [push, pull_request]
14
+
15
+ jobs:
16
+ quality:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-node@v4
21
+ with: { node-version: '22' }
22
+ - run: npm ci
23
+ - run: npm run lint
24
+ - run: npm run typecheck
25
+ - run: npm test
26
+ ```
27
+
28
+ ## Quality Gates
29
+
30
+ 1. **TypeScript Check**: Zero type errors (`tsc --noEmit`)
31
+ 2. **Lint Check**: ESLint must pass with zero warnings
32
+ 3. **Unit Tests**: All tests must pass
33
+ 4. **Coverage**: Minimum 80% line coverage
34
+
35
+ ## Best Practices
36
+
37
+ 1. Run tests on every push and pull request
38
+ 2. Cache node_modules for faster builds
39
+ 3. Use matrix builds for multi-version testing
40
+ 4. Never deploy without passing quality gates
41
+ 5. Keep pipeline runs under 10 minutes
42
+
43
+ > **Note**: Deployment is managed by the development team, not automated by this pipeline.
@@ -0,0 +1,17 @@
1
+ # 🌐 Corporate Multi-Language (i18n) Standards
2
+
3
+ This document defines the localization and multi-language management rules for projects managed by Agent Enderun.
4
+
5
+ ## 1. Centralized Management
6
+ - **Hardcoded Forbidden:** No text visible to the user shall be written directly into the code (JSX/HTML/TS).
7
+ - **Locales Directory:** All languages are stored as JSON files under `apps/web/public/locales/` or `apps/web/src/locales/`.
8
+ - **Key-Value Standard:** Meaningful and hierarchical keys are used (e.g., `common.buttons.save`, `errors.auth.invalid_password`).
9
+
10
+ ## 2. Technical Implementation
11
+ - **i18next:** The `next-i18next` or `react-i18next` library is standard in projects.
12
+ - **Dynamic Content:** i18n interpolation (`{{name}}`) must be used for text containing variables.
13
+ - **Pluralization:** Singular/plural cases must be managed using the i18n library's own rules.
14
+
15
+ ## 3. Auditing
16
+ - When the `@frontend` agent creates a new UI component, it automatically moves texts to the relevant JSON files.
17
+ - Missing translation key (missing key) checks are performed by `@quality`.
@@ -0,0 +1,47 @@
1
+ # Kysely ORM Standards
2
+
3
+ > Type-safe SQL query builder for TypeScript. Use for database operations.
4
+
5
+ ## Setup
6
+
7
+ ```typescript
8
+ import { Kysely, SqliteDialect } from 'kysely';
9
+ import Database from 'better-sqlite3';
10
+ import type { DB } from './types';
11
+
12
+ const dialect = new SqliteDialect({
13
+ database: new Database(process.env.DATABASE_PATH || './dev.db'),
14
+ });
15
+
16
+ export const db = new Kysely<DB>({ dialect });
17
+ ```
18
+
19
+ ## Table Definitions
20
+
21
+ Define types in `src/database/kysely/types.ts`:
22
+
23
+ ```typescript
24
+ export interface UsersTable {
25
+ id: string;
26
+ email: string;
27
+ full_name: string;
28
+ role: string;
29
+ password_hash: string;
30
+ created_at: string;
31
+ updated_at: string;
32
+ deleted_at: string | null;
33
+ }
34
+
35
+ export interface DB {
36
+ users: UsersTable;
37
+ customers: CustomersTable;
38
+ }
39
+ ```
40
+
41
+ ## Best Practices
42
+
43
+ 1. Always use `where("deleted_at", "is", null)` for soft-delete
44
+ 2. Use `returningAll()` after insert/update
45
+ 3. Use `db.fn.countAll()` for pagination
46
+ 4. Keep types in sync with actual schema
47
+ 5. Use transactions for multi-step operations
@@ -0,0 +1,15 @@
1
+ # 🤖 LLM Governance and Data Protection
2
+
3
+ This document outlines the security and discipline rules for interacting with Large Language Models within Enderun-managed projects.
4
+
5
+ ## 1. Trust Zone
6
+ - **Input Sanitization:** All user-provided data must be sanitized before being sent to an LLM context to prevent Prompt Injection attacks.
7
+ - **PII Protection:** Absolutely no Personally Identifiable Information (PII) or customer-sensitive credentials should ever be included in prompts.
8
+
9
+ ## 2. Token Discipline
10
+ - **Context Pruning:** Agents must proactively clear unnecessary context and follow the memory pruning protocol (`.enderun/memory/archive/`) to maintain prompt efficiency.
11
+ - **Prompt Scoping:** Prompts should be scoped to the minimum required knowledge to prevent "Context Drift".
12
+
13
+ ## 3. Autonomous Behavior
14
+ - **Human-in-the-Loop:** Any action marked as `ACTION` category requiring state mutation must trigger an approval flow.
15
+ - **Escalation:** If an agent encounters an ambiguity that exceeds its capability (capability < 9), it must stop and escalate to `@manager`.
@@ -0,0 +1,34 @@
1
+ # 🪵 Corporate Logging and Secret Management (.env) Standards
2
+
3
+ This document defines the logging discipline and sensitive data (secret) management rules for projects managed by the Agent Enderun army.
4
+
5
+ ## 1. Logging Discipline (Zero Console Policy)
6
+ - **console.log Forbidden:** The use of `console.log`, `console.warn`, or `console.error` in production code is strictly forbidden.
7
+ - **Enterprise Logger Usage:** All logging operations must be performed via the project's central logger system (`src/shared/logger.ts`).
8
+ ```typescript
9
+ import { logger } from "@/shared/logger";
10
+
11
+ logger.info("User logged in", { userId: "..." });
12
+ logger.error("Database connection error", { error: "..." });
13
+ ```
14
+ - **Log Levels:**
15
+ - `DEBUG`: Detailed technical information during development.
16
+ - `INFO`: Normal system flow (e.g., service started, task completed).
17
+ - `WARN`: Situations that are not errors but require attention.
18
+ - `ERROR`: Errors that do not break system operation but require investigation.
19
+ - `FATAL`: Critical errors that cause system crashes.
20
+
21
+ ## 2. Secret Management and .env Discipline
22
+ - **Sensitive Data (Secrets):** API keys, database passwords, JWT secrets, and private keys are NEVER hardcoded into the code.
23
+ - **.env Usage:** All sensitive data and environment-specific settings are managed via the `.env` file.
24
+ - **.env.example:** An up-to-date `.env.example` file must always exist in the root directory of the project. This file should contain only the keys, not the actual values.
25
+ - **Dynamic Checks:** Agents must verify the absence of a value in the `.env` file before application runtime.
26
+
27
+ ## 3. Security and PII (Personally Identifiable Information) Discipline
28
+ - **Git Ignored:** The `.env` file must always be included in `.gitignore` and never committed to the source control system.
29
+ - **Secret Masking:** Sensitive technical data such as passwords, credit card numbers, or API keys must never be written clearly in logs (they must be masked using `***` or similar).
30
+ - **PII Governance (GDPR/KVKK):**
31
+ - Real user data (Emails, Phone Numbers, Full Names, National IDs) must NEVER be logged or stored in agent memories.
32
+ - If a task requires processing PII, use anonymized placeholders or unique hashes in logs.
33
+ - **@security** agent must audit any new log entry for potential PII leakage.
34
+ - **Zero-Trust Memory:** Ajan hafızaları (PROJECT_MEMORY.md) asla gerçek müşteri verisi içermemelidir; sadece teknik meta-data ve mimari kararlar saklanmalıdır.
@@ -0,0 +1,23 @@
1
+ # 📱 Corporate Mobile Development Standards (React Native / Expo)
2
+
3
+ This document defines the strict rules and performance standards in mobile application development processes.
4
+
5
+ ## 1. Technology Stack and Structure
6
+ - **Framework:** Expo (Managed Workflow) and React Native.
7
+ - **Styling:** `react-native-reanimated` and type-safe style objects or Tailwind (NativeWind).
8
+ - **Navigation:** Expo Router (File-based navigation) and Safe Link structures.
9
+
10
+ ## 2. Design for Every Screen (Responsive Mobile Layout)
11
+ - **Screen Resolution Independence:** Fixed `px` widths and heights should never be used. Instead, flexbox ratios, percentage widths, and dynamic values from the `useWindowDimensions` hook should be used.
12
+ - **SafeArea Security:** All screen structures must be wrapped with `SafeAreaProvider` and `SafeAreaView` (or dynamic `insets` object) from `react-native-safe-area-context` to prevent collision with notched screens, status bars, and home indicators.
13
+ - **Font Sizes and Accessibility:** To prevent text truncation or overflow when system font sizes are changed (Accessibility Font Scaling), `numberOfLines` / `ellipsizeMode` should be used in `Text` components or containers providing dynamic height should be designed.
14
+ - **Orientation Adaptation:** Interfaces should be adaptable to both portrait and landscape usage scenarios; especially on tablets, double-column (Master-Detail) or Grid layouts should be adjusted based on dynamic screen aspect ratios.
15
+
16
+ ## 3. Performance and Fluidity
17
+ - **Performant Lists:** To maintain performance in large data lists, `FlashList` (Shopify) must be used instead of `ScrollView` or `FlatList`.
18
+ - **Image Resources:** Images should be cached with `expo-image`, WebP formats should be preferred for fast loading, and aspect ratios (`contentFit`) should be preserved when scaling.
19
+ - **Touch Targets:** All touch interaction areas must be at least `44dp x 44dp`.
20
+
21
+ ## 4. Hardware and Offline Operation
22
+ - **Permissions:** Sensitive permissions (location, camera, notifications) should only be requested when the feature is used, and the reason should be clearly shown to the user.
23
+ - **Offline First:** Network requests should be cached with `React Query`; MMKV (or SQLite) should be used for local persistent storage.
@@ -0,0 +1,15 @@
1
+ # 📊 Observability and Monitoring Standards
2
+
3
+ This document defines the requirements for logging, tracing, and observability within Enderun-managed projects.
4
+
5
+ ## 1. Traceability
6
+ - **Trace ID Enforcement:** Every single request, message, or task delegated between agents must include the active `Trace ID` in its metadata.
7
+ - **Context Logging:** Logs must be structured in JSON format where possible, containing at least: `timestamp`, `level`, `agentName`, `traceId`, `action`, and `message`.
8
+
9
+ ## 2. Audit Trail
10
+ - **High-Risk Actions:** All administrative or high-risk actions (e.g., DB changes, User role updates) must be recorded in `observability/audit_log.md` with a timestamp, actor agent, and outcome.
11
+ - **Immutable Logs:** Audit logs should be appended only and never modified or deleted.
12
+
13
+ ## 3. Monitoring
14
+ - **Health Checks:** Ajanlar periyodik olarak `get_system_health` aracını çağırmalıdır.
15
+ - **Alerting:** Critical errors or timeouts must immediately trigger an `ALERT` message to the `@manager` agent for escalation.
@@ -0,0 +1,15 @@
1
+ # 📈 Performance Monitoring Standards
2
+
3
+ This document defines the metrics and monitoring requirements to ensure the Enderun Army operates at peak efficiency.
4
+
5
+ ## 1. Core Metrics
6
+ - **Task Latency (Completion Time):** Time from task delegation (`PENDING`) to completion (`SUCCESS`) must be tracked.
7
+ - **Token Consumption:** The total LLM tokens used per `Trace ID` must be logged and analyzed to identify inefficient prompts.
8
+ - **Agent Error Rates:** The frequency of `FAILED` or `RETRY` statuses per agent must be monitored.
9
+
10
+ ## 2. Telemetry Implementation
11
+ - **Standardized Logging:** Every task completion event must include the `Trace ID`, the duration (in milliseconds), and the tool/agent interaction summary.
12
+ - **Performance Budgeting:** Each agent role has an estimated token budget. Budget overflows must be reported by the `@analyst` agent.
13
+
14
+ ## 3. Bottleneck Identification
15
+ - **Critical Path Analysis:** Agents identified as bottlenecking the orchestration loop (frequent `WAITING` or `BLOCKED` states) must be reviewed for logic optimization.