agent-enderun 0.7.2 → 0.7.5

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 (177) hide show
  1. package/.enderun/BRAIN_DASHBOARD.md +47 -0
  2. package/.enderun/PROJECT_MEMORY.md +139 -0
  3. package/.enderun/STATUS.md +62 -0
  4. package/.enderun/agents/agent_army_schema.json +85 -0
  5. package/.enderun/agents/analyst/agent.json +23 -0
  6. package/.enderun/agents/analyst/prompt.md +225 -0
  7. package/.enderun/agents/backend/agent.json +24 -0
  8. package/.enderun/agents/backend/prompt.md +331 -0
  9. package/.enderun/agents/devops/agent.json +61 -0
  10. package/.enderun/agents/devops/prompt.md +127 -0
  11. package/.enderun/agents/explorer/agent.json +22 -0
  12. package/.enderun/agents/explorer/prompt.md +115 -0
  13. package/.enderun/agents/frontend/agent.json +24 -0
  14. package/.enderun/agents/frontend/prompt.md +313 -0
  15. package/.enderun/agents/git/agent.json +22 -0
  16. package/.enderun/agents/git/prompt.md +99 -0
  17. package/.enderun/agents/manager/agent.json +48 -0
  18. package/.enderun/agents/manager/prompt.md +231 -0
  19. package/.enderun/agents/mobile/agent.json +21 -0
  20. package/.enderun/agents/mobile/prompt.md +91 -0
  21. package/.enderun/agents/native/agent.json +21 -0
  22. package/.enderun/agents/native/prompt.md +96 -0
  23. package/.enderun/agents/orchestrator/agent.json +53 -0
  24. package/.enderun/agents/orchestrator/prompt.md +124 -0
  25. package/.enderun/agents/qa/agent.json +57 -0
  26. package/.enderun/agents/qa/prompt.md +69 -0
  27. package/.enderun/agents/schema/agent-lifecycle-schema.json +65 -0
  28. package/.enderun/agents/security/agent.json +54 -0
  29. package/.enderun/agents/security/prompt.md +154 -0
  30. package/.enderun/gemini.md +19 -0
  31. package/.enderun/knowledge/corporate-governance/analyst-contract-integrity-guide.md +92 -0
  32. package/.enderun/knowledge/corporate-governance/audit-logging-standard.md +59 -0
  33. package/.enderun/knowledge/corporate-governance/backend-high-risk-endpoint-guide.md +125 -0
  34. package/.enderun/knowledge/corporate-governance/branded-types-law.md +77 -0
  35. package/.enderun/knowledge/corporate-governance/contract-drift-detection-simulation.md +92 -0
  36. package/.enderun/knowledge/corporate-governance/corporate-governance-playbook.md +89 -0
  37. package/.enderun/knowledge/corporate-governance/corporate-project-kickoff-checklist.md +56 -0
  38. package/.enderun/knowledge/corporate-governance/corporate-project-kickoff-simulation.md +144 -0
  39. package/.enderun/knowledge/corporate-governance/corporate-project-scaffolding-sop.md +103 -0
  40. package/.enderun/knowledge/corporate-governance/domain-error-handling-standard.md +75 -0
  41. package/.enderun/knowledge/corporate-governance/frontend-high-risk-modal-guide.md +211 -0
  42. package/.enderun/knowledge/corporate-governance/governance-baseline-briefing-template.md +54 -0
  43. package/.enderun/knowledge/corporate-governance/high-risk-action-approval-flow-simulation.md +167 -0
  44. package/.enderun/knowledge/corporate-governance/high-risk-actions-managerapproval.md +76 -0
  45. package/.enderun/knowledge/corporate-governance/high-risk-security-modal-hermes-flow.md +49 -0
  46. package/.enderun/knowledge/corporate-governance/manager-first-30-days-guide.md +112 -0
  47. package/.enderun/knowledge/corporate-governance/manager-first-three-briefings.md +79 -0
  48. package/.enderun/knowledge/deployment_checklist.md +7 -0
  49. package/{.antigravitycli → .enderun}/knowledge/framework_vs_user_project_boundary.md +3 -3
  50. package/{.antigravitycli → .enderun}/knowledge/frontend_professionalization_guidelines.md +17 -20
  51. package/{.antigravitycli → .enderun}/knowledge/hermes_live_test_guidelines.md +9 -9
  52. package/{.antigravitycli → .enderun}/knowledge/hermes_protocol.md +2 -2
  53. package/.enderun/knowledge/kentim_constitution.md +34 -0
  54. package/{.antigravitycli → .enderun}/knowledge/manager_authority_audit_enforcement.md +11 -11
  55. package/{.antigravitycli → .enderun}/knowledge/project_scaffold_guidelines.md +8 -8
  56. package/{.antigravitycli → .enderun}/knowledge/reference_application_guidelines.md +7 -7
  57. package/.enderun/logs/analyst.json +1 -0
  58. package/.enderun/logs/backend.json +1 -0
  59. package/.enderun/logs/devops.json +1 -0
  60. package/.enderun/logs/explorer.json +1 -0
  61. package/.enderun/logs/frontend.json +1 -0
  62. package/.enderun/logs/git.json +1 -0
  63. package/.enderun/logs/manager.json +20 -0
  64. package/.enderun/logs/mobile.json +1 -0
  65. package/.enderun/logs/native.json +1 -0
  66. package/.enderun/logs/orchestrator.json +1 -0
  67. package/.enderun/logs/qa.json +1 -0
  68. package/.enderun/logs/security.json +1 -0
  69. package/.enderun/memory-graph/agent-contexts/analyst.json +1 -0
  70. package/.enderun/memory-graph/agent-contexts/backend.json +1 -0
  71. package/.enderun/memory-graph/agent-contexts/devops.json +1 -0
  72. package/.enderun/memory-graph/agent-contexts/explorer.json +1 -0
  73. package/.enderun/memory-graph/agent-contexts/frontend.json +1 -0
  74. package/.enderun/memory-graph/agent-contexts/git.json +1 -0
  75. package/.enderun/memory-graph/agent-contexts/manager.json +1 -0
  76. package/.enderun/memory-graph/agent-contexts/mobile.json +1 -0
  77. package/.enderun/memory-graph/agent-contexts/native.json +1 -0
  78. package/.enderun/memory-graph/agent-contexts/orchestrator.json +1 -0
  79. package/.enderun/memory-graph/agent-contexts/qa.json +1 -0
  80. package/.enderun/memory-graph/agent-contexts/security.json +1 -0
  81. package/.enderun/memory-graph/graph.json +26 -0
  82. package/.enderun/memory-graph/shared-facts.json +52 -0
  83. package/.enderun/monitoring/.gitkeep +0 -0
  84. package/.enderun/queue/README.md +36 -0
  85. package/ENDERUN.md +4 -4
  86. package/README.md +151 -89
  87. package/bin/cli.js +13 -2138
  88. package/bin/hermes-sandbox.js +0 -0
  89. package/bin/validate-agent-army.js +3 -3
  90. package/docs/architecture/approval-flows.md +2 -37
  91. package/docs/backend/error-handling.md +2 -51
  92. package/docs/frontend/component-patterns.md +2 -47
  93. package/docs/getting-started.md +7 -15
  94. package/docs/roadmap.md +2 -2
  95. package/framework-mcp/dist/index.js +0 -0
  96. package/framework-mcp/dist/schemas.js +3 -3
  97. package/framework-mcp/dist/tools/framework.js +17 -10
  98. package/framework-mcp/dist/tools/governance.js +696 -0
  99. package/framework-mcp/dist/tools/index.js +14 -12
  100. package/framework-mcp/dist/tools/memory.js +106 -0
  101. package/framework-mcp/dist/tools/monitoring.js +294 -0
  102. package/framework-mcp/dist/tools/orchestration.js +368 -0
  103. package/framework-mcp/dist/tools/pipeline.js +267 -0
  104. package/framework-mcp/dist/utils.js +25 -3
  105. package/framework-mcp/package.json +3 -3
  106. package/framework-mcp/src/schemas.ts +3 -3
  107. package/framework-mcp/src/tools/framework.ts +18 -10
  108. package/framework-mcp/src/tools/governance.ts +891 -0
  109. package/framework-mcp/src/tools/index.ts +14 -12
  110. package/framework-mcp/src/tools/memory.ts +103 -0
  111. package/framework-mcp/src/tools/monitoring.ts +351 -0
  112. package/framework-mcp/src/tools/orchestration.ts +439 -0
  113. package/framework-mcp/src/tools/pipeline.ts +353 -0
  114. package/framework-mcp/src/utils.ts +24 -3
  115. package/framework-mcp/tsconfig.json +2 -1
  116. package/gemini.md +19 -0
  117. package/package.json +14 -20
  118. package/.antigravitycli/BRAIN_DASHBOARD.md +0 -43
  119. package/.antigravitycli/ENDERUN.md +0 -253
  120. package/.antigravitycli/PROJECT_MEMORY.md +0 -78
  121. package/.antigravitycli/STATUS.md +0 -21
  122. package/.antigravitycli/agents/agent_army_schema.json +0 -79
  123. package/.antigravitycli/agents/analyst/agent.json +0 -55
  124. package/.antigravitycli/agents/backend/agent.json +0 -58
  125. package/.antigravitycli/agents/explorer/agent.json +0 -50
  126. package/.antigravitycli/agents/frontend/agent.json +0 -56
  127. package/.antigravitycli/agents/git/agent.json +0 -53
  128. package/.antigravitycli/agents/manager/agent.json +0 -82
  129. package/.antigravitycli/agents/mobile/agent.json +0 -52
  130. package/.antigravitycli/agents/native/agent.json +0 -56
  131. package/.antigravitycli/assets/manager.png +0 -0
  132. package/.antigravitycli/blueprints/README.md +0 -82
  133. package/.antigravitycli/blueprints/backend/errors/config/meta.json +0 -16
  134. package/.antigravitycli/blueprints/backend/errors/domain-error.ts +0 -64
  135. package/.antigravitycli/knowledge/README.md +0 -22
  136. package/.antigravitycli/knowledge/database_governance_guidelines.md +0 -118
  137. package/.antigravitycli/knowledge/deployment_checklist.md +0 -133
  138. package/.antigravitycli/knowledge/documentation_ownership.md +0 -122
  139. package/.antigravitycli/knowledge/documentation_ownership_status.md +0 -122
  140. package/.antigravitycli/knowledge/enterprise_capabilities_reference.md +0 -149
  141. package/.antigravitycli/knowledge/enterprise_frontend_adaptation.md +0 -232
  142. package/.antigravitycli/knowledge/enterprise_project_adaptation.md +0 -168
  143. package/.antigravitycli/knowledge/frontend_real_battle_test_protocol.md +0 -162
  144. package/antigravity.md +0 -15
  145. package/docs/architecture/decisions/README.md +0 -31
  146. package/docs/architecture/notification-strategy.md +0 -38
  147. package/docs/backend/audit-logging.md +0 -34
  148. package/docs/frontend/forms.md +0 -40
  149. package/docs/frontend/notifications.md +0 -37
  150. package/framework-mcp/dist/tools/academy.js +0 -182
  151. package/framework-mcp/dist/tools/database.js +0 -57
  152. package/framework-mcp/dist/tools/repository.js +0 -101
  153. package/framework-mcp/dist/tools/scaffold.js +0 -132
  154. package/framework-mcp/src/tools/academy.ts +0 -180
  155. package/framework-mcp/src/tools/database.ts +0 -54
  156. package/framework-mcp/src/tools/repository.ts +0 -101
  157. package/framework-mcp/src/tools/scaffold.ts +0 -150
  158. /package/{.antigravitycli/messages → .enderun/benchmarks}/.gitkeep +0 -0
  159. /package/{.antigravitycli → .enderun}/cli-commands.json +0 -0
  160. /package/{.antigravitycli → .enderun}/config.json +0 -0
  161. /package/{.antigravitycli → .enderun}/knowledge/api_design_rules.md +0 -0
  162. /package/{.antigravitycli → .enderun}/knowledge/async_error_handling.md +0 -0
  163. /package/{.antigravitycli → .enderun}/knowledge/blueprint_driven_construction.md +0 -0
  164. /package/{.antigravitycli → .enderun}/knowledge/branded_types_pattern.md +0 -0
  165. /package/{.antigravitycli → .enderun}/knowledge/code_review_checklist.md +0 -0
  166. /package/{.antigravitycli → .enderun}/knowledge/contract_versioning.md +0 -0
  167. /package/{.antigravitycli → .enderun}/knowledge/database_migration.md +0 -0
  168. /package/{.antigravitycli → .enderun}/knowledge/git_commit_strategy.md +0 -0
  169. /package/{.antigravitycli → .enderun}/knowledge/legacy_onboarding.md +0 -0
  170. /package/{.antigravitycli → .enderun}/knowledge/monitoring_setup.md +0 -0
  171. /package/{.antigravitycli → .enderun}/knowledge/performance_guidelines.md +0 -0
  172. /package/{.antigravitycli → .enderun}/knowledge/repository_patterns.md +0 -0
  173. /package/{.antigravitycli → .enderun}/knowledge/responsive_design_standards.md +0 -0
  174. /package/{.antigravitycli → .enderun}/knowledge/security_scanning.md +0 -0
  175. /package/{.antigravitycli → .enderun}/knowledge/testing_standards.md +0 -0
  176. /package/{.antigravitycli → .enderun}/knowledge/troubleshooting_guide.md +0 -0
  177. /package/{.antigravitycli → .enderun}/knowledge/zero_ui_library_policy.md +0 -0
@@ -0,0 +1,125 @@
1
+ # High-Risk Endpoint Implementation Guide (@backend)
2
+
3
+ **Applies to**: Any backend endpoint that performs privileged or high-risk administrative actions.
4
+
5
+ **Goal**: Provide @backend with a concrete, production-grade implementation pattern that strictly enforces corporate governance.
6
+
7
+ ---
8
+
9
+ ## 1. Required Imports and Types
10
+
11
+ ```ts
12
+ import {
13
+ UserID,
14
+ RoleID,
15
+ ManagerApproval,
16
+ HighRiskActionPayload
17
+ } from '../types';
18
+ import { HighRiskActionRequiresApprovalError } from '../types/errors';
19
+ import { auditLogRepository } from '../repositories/audit-log.repository';
20
+ ```
21
+
22
+ ---
23
+
24
+ ## 2. High-Risk Endpoint Pattern (Recommended Structure)
25
+
26
+ ```ts
27
+ // apps/backend/src/routes/users/promote-to-superadmin.route.ts
28
+
29
+ interface PromoteToSuperAdminBody extends HighRiskActionPayload {
30
+ userId: UserID;
31
+ newRole: 'SuperAdmin';
32
+ }
33
+
34
+ fastify.post('/api/v1/users/:id/promote-to-superadmin', async (request, reply) => {
35
+ const { id } = request.params;
36
+ const body = request.body as PromoteToSuperAdminBody;
37
+
38
+ // === MANDATORY HIGH-RISK GOVERNANCE CHECK ===
39
+ if (!body.isHighRiskAdminAction || !body.managerApproval) {
40
+ throw new HighRiskActionRequiresApprovalError(
41
+ 'Promotion to SuperAdmin is a high-risk action',
42
+ { requiredFields: ['isHighRiskAdminAction', 'managerApproval'] }
43
+ );
44
+ }
45
+
46
+ // Validate managerApproval structure
47
+ const approval = body.managerApproval;
48
+ if (approval.approvedBy !== 'manager') {
49
+ throw new HighRiskActionRequiresApprovalError('Approval must be issued by @manager');
50
+ }
51
+
52
+ // Optional: Add time-based or policy-based validation here
53
+ // (e.g., approval must be less than 15 minutes old)
54
+
55
+ const targetUserId = id as UserID;
56
+
57
+ // === EXECUTE THE PRIVILEGED ACTION ===
58
+ const updatedUser = await userService.promoteToSuperAdmin(targetUserId);
59
+
60
+ // === AUDIT LOGGING (MANDATORY) ===
61
+ await auditLogRepository.create({
62
+ traceId: approval.traceId,
63
+ actorId: request.user.id as UserID, // the person who triggered the action
64
+ action: 'USER_PROMOTED_TO_SUPERADMIN',
65
+ targetId: targetUserId,
66
+ beforeState: { role: updatedUser.previousRole },
67
+ afterState: { role: 'SuperAdmin' },
68
+ managerApprovalId: approval.approvalId,
69
+ reason: approval.reason,
70
+ });
71
+
72
+ return {
73
+ success: true,
74
+ user: updatedUser,
75
+ approvalUsed: approval.approvalId,
76
+ };
77
+ });
78
+ ```
79
+
80
+ ---
81
+
82
+ ## 3. Error Handling
83
+
84
+ Always throw typed domain errors:
85
+
86
+ - Use `HighRiskActionRequiresApprovalError` when governance requirements are not met.
87
+ - Never return generic 403 or 400 with vague messages.
88
+
89
+ ---
90
+
91
+ ## 4. Testing Requirements (Testable Rules)
92
+
93
+ Every high-risk endpoint **must** have the following test cases:
94
+
95
+ - [ ] Request without `isHighRiskAdminAction` → `HighRiskActionRequiresApprovalError`
96
+ - [ ] Request without `managerApproval` → `HighRiskActionRequiresApprovalError`
97
+ - [ ] `managerApproval.approvedBy !== 'manager'` → `HighRiskActionRequiresApprovalError`
98
+ - [ ] Valid approval token → Action succeeds + audit log is created
99
+ - [ ] Valid approval but action fails later → Audit log still created with failure status (if possible)
100
+
101
+ ---
102
+
103
+ ## 5. Anti-Patterns (Strictly Forbidden)
104
+
105
+ - Bypassing validation “because the frontend already checked”
106
+ - Logging the full `managerApproval.signature` in normal logs
107
+ - Skipping audit logging for “internal admin users”
108
+ - Using plain `string` for `userId` or `approvalId` inside the endpoint
109
+ - Returning raw error objects to the client
110
+
111
+ ---
112
+
113
+ ## 6. Integration Points
114
+
115
+ This pattern must be combined with:
116
+ - `domain-error-handling-standard.md`
117
+ - `audit-logging-standard.md`
118
+ - `branded-types-law.md`
119
+
120
+ @backend is responsible for refusing to implement any high-risk feature until the above three standards are satisfied in the design.
121
+
122
+ **Reference files** (must be read before implementation):
123
+ - `high-risk-actions-managerapproval.md`
124
+ - `high-risk-action-approval-flow-simulation.md`
125
+ - `corporate-project-scaffolding-sop.md`
@@ -0,0 +1,77 @@
1
+ # Branded Types Law
2
+
3
+ **Status:** Mandatory — Zero Tolerance
4
+
5
+ ## Why This Exists
6
+ Plain `string` or `number` for identifiers (user IDs, role IDs, approval tokens, etc.) is a major source of bugs and security issues in large systems. Agent Enderun enforces **Branded Types** to make domain identifiers type-safe at compile time.
7
+
8
+ ## Definition
9
+ ```ts
10
+ type Brand<T, BrandName extends string> = T & { readonly __brand: BrandName };
11
+
12
+ type UserID = Brand<string, 'UserID'>;
13
+ type RoleID = Brand<string, 'RoleID'>;
14
+ type ApprovalID = Brand<string, 'ApprovalID'>;
15
+ ```
16
+
17
+ ## Rules
18
+ 1. Every identifier that represents a domain entity **must** be a branded type.
19
+ 2. Backend is the source of truth (`apps/backend/src/types`).
20
+ 3. Frontend must maintain an exact local copy and update it when notified via Hermes.
21
+ 4. Never cast `as any` or use `string` directly when a branded type is available.
22
+ 5. Database columns can remain as strings, but the TypeScript layer must brand them immediately after reading.
23
+
24
+ ## Enforcement
25
+ - @backend must refuse to implement any feature that introduces non-branded IDs.
26
+ - @analyst will run static analysis to detect violations.
27
+ - Any PR that introduces plain strings for IDs must be rejected.
28
+
29
+ ## Example Correct Usage
30
+ ```ts
31
+ const promoteUser = async (userId: UserID, newRole: SystemRole, approval: ManagerApproval) => { ... }
32
+ ```
33
+
34
+ ## Recommended Folder Structure
35
+
36
+ ```
37
+ apps/backend/src/types/
38
+ ├── brand.ts # Generic Brand utility
39
+ ├── identifiers.ts # UserID, RoleID, ApprovalID, TraceID...
40
+ ├── approval.ts # ManagerApproval + HighRiskActionPayload
41
+ ├── errors.ts # DomainError hierarchy
42
+ ├── user.ts
43
+ ├── role.ts
44
+ └── index.ts # Re-exports
45
+ ```
46
+
47
+ ## Concrete Implementation Examples
48
+
49
+ **brand.ts**
50
+ ```ts
51
+ export type Brand<T, BrandName extends string> = T & { readonly __brand: BrandName };
52
+ ```
53
+
54
+ **identifiers.ts**
55
+ ```ts
56
+ import { Brand } from './brand';
57
+
58
+ export type UserID = Brand<string, 'UserID'>;
59
+ export type RoleID = Brand<string, 'RoleID'>;
60
+ export type ApprovalID = Brand<string, 'ApprovalID'>;
61
+ export type TraceID = Brand<string, 'TraceID'>;
62
+ ```
63
+
64
+ ## Common Anti-Patterns (Forbidden)
65
+ - `userId: string`
66
+ - `roleId: number`
67
+ - Passing raw database rows directly to the frontend without branding
68
+ - Using `as any` to bypass branded type checks
69
+ - Casting database IDs directly without branding at the repository layer
70
+
71
+ ## Testable Rules (for @analyst)
72
+
73
+ - Static analysis must fail on any non-branded identifier used in public APIs or service methods.
74
+ - All identifiers in `apps/backend/src/types` must extend the `Brand` utility.
75
+ - Frontend type copies must match backend branded types exactly (contract drift detection).
76
+
77
+ This law is non-negotiable for any project using Agent Enderun at enterprise scale.
@@ -0,0 +1,92 @@
1
+ # Contract Drift Detection & Resolution Simulation
2
+
3
+ **Purpose**: This simulation shows how @analyst, @backend, @frontend, and @manager should handle a contract drift situation in a corporate project according to Agent Enderun standards.
4
+
5
+ **Scenario**: During development of the User Management module, @backend adds a new required field `lastLoginAt` to the `User` type without notifying the team.
6
+
7
+ ---
8
+
9
+ ## Step 1 – Drift is Detected
10
+
11
+ **@analyst** runs the contract integrity check (as per its responsibilities in the Corporate Project Scaffolding SOP).
12
+
13
+ **Detection**:
14
+ - `apps/backend/src/types/user.ts` has changed.
15
+ - `apps/web/src/types/api-contracts.ts` (frontend copy) does not contain the new field.
16
+ - Hash in `contract.version.json` has not been updated.
17
+
18
+ **@analyst** sends a Hermes message to @manager and @frontend:
19
+
20
+ ```json
21
+ {
22
+ "type": "contract_drift_detected",
23
+ "traceId": "TRACE-20260525-CONTRACT-DRIFT-007",
24
+ "payload": {
25
+ "changedFile": "apps/backend/src/types/user.ts",
26
+ "newField": "lastLoginAt: string",
27
+ "frontendCopyStatus": "outdated",
28
+ "severity": "high"
29
+ }
30
+ }
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Step 2 – @manager Assessment
36
+
37
+ **@manager** receives the notification and loads:
38
+ - `branded-types-law.md`
39
+ - `corporate-project-scaffolding-sop.md`
40
+
41
+ **@manager response**:
42
+
43
+ This is a contract drift. Per our governance rules, no one may continue implementation on the affected feature until the drift is resolved.
44
+
45
+ **Immediate actions**:
46
+ 1. @backend must pause any work depending on the new field.
47
+ 2. @frontend must be briefed to update the local type copy.
48
+ 3. @analyst will verify the fix and update the contract version.
49
+
50
+ I am now issuing a formal pause on the User detail feature until resolution.
51
+
52
+ ---
53
+
54
+ ## Step 3 – Resolution Process
55
+
56
+ **@backend** (after receiving the briefing):
57
+
58
+ Understood. I will not merge or continue work using the new field until the contract is synchronized.
59
+
60
+ **@frontend**:
61
+
62
+ I have updated `apps/web/src/types/api-contracts.ts` to include `lastLoginAt`.
63
+
64
+ **@analyst**:
65
+
66
+ - Verified that both backend and frontend types now match.
67
+ - Updated `contract.version.json` (MINOR version bump).
68
+ - Confirmed no other files are affected.
69
+
70
+ **@manager** (final resolution message):
71
+
72
+ Contract drift resolved.
73
+
74
+ - Backend and frontend types are now in sync.
75
+ - Contract version updated.
76
+ - Feature development on the affected area may resume.
77
+
78
+ All future type changes must follow the Hermes notification process defined in the Scaffolding SOP.
79
+
80
+ ---
81
+
82
+ ## Lessons from This Simulation
83
+
84
+ - Contract drift is treated as a serious governance issue.
85
+ - @analyst has real authority to pause work.
86
+ - @manager uses the standards to protect the project from technical debt.
87
+ - Resolution must be documented (even if small) in PROJECT_MEMORY.md.
88
+
89
+ **Reference files**:
90
+ - `branded-types-law.md`
91
+ - `corporate-project-scaffolding-sop.md`
92
+ - `corporate-project-kickoff-checklist.md`
@@ -0,0 +1,89 @@
1
+ # Corporate Governance Playbook
2
+
3
+ **Version**: 1.0
4
+ **Purpose**: This is the single master reference that ties together all corporate governance standards for Agent Enderun. It provides navigation, summaries, and the recommended order of study for agents and teams.
5
+
6
+ ---
7
+
8
+ ## Core Philosophy
9
+
10
+ We do not ship pre-built applications.
11
+ We internalize strong governance patterns into the agents so they can guide any corporate project correctly from the first day.
12
+
13
+ ---
14
+
15
+ ## Document Hierarchy
16
+
17
+ ### Foundational Laws & Standards
18
+ | Document | Focus | Must Read By |
19
+ |----------|-------|--------------|
20
+ | `branded-types-law.md` | Compile-time safety for identifiers | All agents |
21
+ | `high-risk-actions-managerapproval.md` | Protection of privileged operations | All agents |
22
+ | `domain-error-handling-standard.md` | Typed, safe error system | @backend, @analyst |
23
+ | `audit-logging-standard.md` | Tamper-evident privileged action records | @backend, @analyst, @manager |
24
+
25
+ ### UI & Coordination Patterns
26
+ | Document | Focus | Must Read By |
27
+ |----------|-------|--------------|
28
+ | `high-risk-security-modal-hermes-flow.md` | Frontend high-risk action handling | @frontend, @manager |
29
+ | `frontend-high-risk-modal-guide.md` | Concrete component + hook implementation | @frontend |
30
+
31
+ ### Backend Implementation
32
+ | Document | Focus | Must Read By |
33
+ |----------|-------|--------------|
34
+ | `backend-high-risk-endpoint-guide.md` | Production-grade high-risk endpoint pattern | @backend |
35
+
36
+ ### Process & Scaffolding
37
+ | Document | Focus | Must Read By |
38
+ |----------|-------|--------------|
39
+ | `corporate-project-scaffolding-sop.md` | Step-by-step process for new corporate projects | @manager (primary) |
40
+ | `corporate-project-kickoff-checklist.md` | Mandatory checklist at project start | @manager + team |
41
+ | `governance-baseline-briefing-template.md` | First-day briefing text | @manager |
42
+ | `manager-first-three-briefings.md` | Ready templates for early project phases | @manager |
43
+
44
+ ### Simulations (Learning & Reference)
45
+ | Document | Focus |
46
+ |----------|-------|
47
+ | `corporate-project-kickoff-simulation.md` | Full multi-session project start example |
48
+ | `high-risk-action-approval-flow-simulation.md` | End-to-end high-risk action cycle |
49
+ | `contract-drift-detection-simulation.md` | How to detect and resolve contract drift |
50
+
51
+ ### Analyst & Compliance
52
+ | Document | Focus |
53
+ |----------|-------|
54
+ | `analyst-contract-integrity-guide.md` | @analyst’s verification responsibilities and processes |
55
+
56
+ ---
57
+
58
+ ## Recommended Reading Order (for New Projects)
59
+
60
+ 1. **@manager** (before anything else)
61
+ - `corporate-project-scaffolding-sop.md`
62
+ - `corporate-project-kickoff-checklist.md`
63
+ - `governance-baseline-briefing-template.md`
64
+
65
+ 2. **All Agents**
66
+ - `branded-types-law.md`
67
+ - `high-risk-actions-managerapproval.md`
68
+
69
+ 3. **Specialist Agents**
70
+ - @backend → `backend-high-risk-endpoint-guide.md` + `domain-error-handling-standard.md`
71
+ - @frontend → `frontend-high-risk-modal-guide.md`
72
+ - @analyst → `analyst-contract-integrity-guide.md`
73
+
74
+ 4. **Simulations** (for deeper understanding)
75
+ - Start with `corporate-project-kickoff-simulation.md`
76
+
77
+ ---
78
+
79
+ ## When to Reference This Playbook
80
+
81
+ - At the start of every new corporate project
82
+ - When any high-risk feature is being planned
83
+ - During contract changes
84
+ - When @analyst detects governance or contract issues
85
+ - During project retrospectives
86
+
87
+ ---
88
+
89
+ **This playbook is the single source of truth for corporate governance in Agent Enderun.**
@@ -0,0 +1,56 @@
1
+ # Corporate Project Kickoff Checklist
2
+
3
+ **Owner:** @manager
4
+ **Audience:** Human user + all specialist agents
5
+
6
+ This checklist must be completed (and documented in `PROJECT_MEMORY.md`) at the very beginning of any corporate or enterprise-grade project.
7
+
8
+ ---
9
+
10
+ ## Phase 0 – Governance Alignment
11
+
12
+ - [ ] @manager has read all files in `.gemini/knowledge/corporate-governance/`
13
+ - [ ] User has been given the Governance Baseline Briefing
14
+ - [ ] User has explicitly acknowledged the corporate standards
15
+ - [ ] Decision recorded in `PROJECT_MEMORY.md` under "Critical Decisions"
16
+
17
+ ## Phase 1 – Project Structure & Contracts
18
+
19
+ - [ ] `apps/backend/src/types` folder structure created
20
+ - [ ] Branded Types utility + core identifiers defined
21
+ - [ ] `ManagerApproval` and `HighRiskActionPayload` interfaces defined
22
+ - [ ] `contract.version.json` initialized
23
+ - [ ] @frontend has created matching type copies in `apps/web/src/types`
24
+ - [ ] @analyst has been briefed on contract integrity responsibility
25
+
26
+ ## Phase 2 – High-Risk Governance Infrastructure (if privileged operations expected)
27
+
28
+ - [ ] High-risk validation logic designed for @backend
29
+ - [ ] Security Modal + Hermes briefing flow designed for @frontend
30
+ - [ ] Audit logging strategy defined (see audit-logging-standard.md)
31
+ - [ ] Domain Error hierarchy created (including `HighRiskActionRequiresApprovalError`)
32
+ - [ ] Both @backend and @frontend agents have received explicit briefings referencing the knowledge files
33
+
34
+ ## Phase 3 – Tooling & Process
35
+
36
+ - [ ] @analyst has confirmed contract drift detection process
37
+ - [ ] Documentation ownership rule explained (all architecture decisions go to `docs/architecture/decisions/`)
38
+ - [ ] First ADR (Architecture Decision Record) created for governance baseline
39
+ - [ ] @manager has updated `PROJECT_MEMORY.md` with initial trace and active tasks
40
+
41
+ ## Phase 4 – Team Alignment
42
+
43
+ - [ ] All active agents have loaded the latest versions of:
44
+ - `branded-types-law.md`
45
+ - `high-risk-actions-managerapproval.md`
46
+ - `high-risk-security-modal-hermes-flow.md`
47
+ - `audit-logging-standard.md`
48
+ - `domain-error-handling-standard.md`
49
+ - [ ] @manager has confirmed that no specialist agent may begin implementation work until the above items are complete
50
+
51
+ ---
52
+
53
+ **@manager Note**:
54
+ Do not proceed to feature development until this checklist is fully completed and acknowledged by the user. Shortcuts at this stage create expensive technical debt later.
55
+
56
+ Mark items as done in `PROJECT_MEMORY.md` under a dedicated "Kickoff Checklist" section.
@@ -0,0 +1,144 @@
1
+ # Corporate Project Kickoff Simulation
2
+
3
+ **Purpose**: This document provides a realistic, step-by-step simulation of how @manager should conduct the first sessions when a user starts a new corporate/enterprise project using Agent Enderun.
4
+
5
+ **Scenario**: A company wants to build an internal "Enterprise User & Access Management" platform. The project will have normal CRUD operations plus high-risk administrative actions (role elevation, system configuration changes).
6
+
7
+ ---
8
+
9
+ ## Session 1 – Initial Contact & Governance Baseline
10
+
11
+ **User**:
12
+ "Hi, I need to build a user management system for our company. It should support roles like User, Admin, and SuperAdmin. Admins should be able to promote users, but promoting to SuperAdmin should be very controlled."
13
+
14
+ **@manager (after loading all corporate-governance knowledge)**:
15
+
16
+ Thank you. Before we discuss any features or technology, we need to establish the governance foundation for this project.
17
+
18
+ This appears to be a corporate/enterprise project involving privileged operations. Therefore, we will follow Agent Enderun’s corporate standards from day one.
19
+
20
+ The non-negotiable pillars are:
21
+
22
+ 1. **Branded Types** for all identifiers (see `branded-types-law.md`)
23
+ 2. **High-Risk Administrative Actions** protected by explicit `managerApproval` + Hermes coordination (see `high-risk-actions-managerapproval.md`)
24
+ 3. **Contract-first development** — types before implementation
25
+ 4. **Audit logging** for all privileged operations (see `audit-logging-standard.md`)
26
+ 5. **Typed Domain Errors** instead of generic exceptions (see `domain-error-handling-standard.md`)
27
+
28
+ These standards exist to make the system safe, auditable, and maintainable at scale.
29
+
30
+ I have prepared the **Corporate Project Kickoff Checklist**. We will go through the relevant parts together over the next sessions.
31
+
32
+ Do you accept these operating rules for this project?
33
+
34
+ **User**:
35
+ "Yes, that makes sense. We need proper controls especially around SuperAdmin promotions."
36
+
37
+ **@manager**:
38
+ Excellent. Acknowledgment recorded.
39
+
40
+ We will now begin Phase 0 and Phase 1 of the Corporate Project Scaffolding SOP.
41
+
42
+ First action: We will establish the type foundation before writing any feature code.
43
+
44
+ ---
45
+
46
+ ## Session 2 – Contract & Type Foundation
47
+
48
+ **@manager** (briefing to @backend and @frontend):
49
+
50
+ Team,
51
+
52
+ We are now in Phase 1 of the Corporate Project Scaffolding SOP.
53
+
54
+ Required immediate deliverables:
55
+
56
+ **@backend**:
57
+ - Create `apps/backend/src/types/brand.ts`
58
+ - Create `apps/backend/src/types/identifiers.ts` with `UserID`, `RoleID`, `ApprovalID`, `TraceID`
59
+ - Create `apps/backend/src/types/approval.ts` with `ManagerApproval` and `HighRiskActionPayload`
60
+ - Create `apps/backend/src/types/errors.ts` including `HighRiskActionRequiresApprovalError`
61
+ - Initialize `apps/backend/contract.version.json`
62
+
63
+ **@frontend**:
64
+ - Create matching type copies in `apps/web/src/types/api-contracts.ts`
65
+ - Begin designing the base `HighRiskSecurityModal` component structure (implementation will come in Phase 2)
66
+
67
+ **@analyst**:
68
+ - Establish contract integrity verification process
69
+
70
+ No backend routes or frontend pages may be implemented until these contracts are defined and approved by me.
71
+
72
+ Please confirm when the type foundation is ready for review.
73
+
74
+ ---
75
+
76
+ ## Session 3 – High-Risk Governance Infrastructure
77
+
78
+ **User**:
79
+ "We need to implement the 'Promote to SuperAdmin' feature soon."
80
+
81
+ **@manager**:
82
+
83
+ Understood. However, according to the Corporate Project Scaffolding SOP (Phase 2), we must build the high-risk governance infrastructure **before** implementing any privileged feature.
84
+
85
+ This means:
86
+
87
+ - @backend must implement strict validation that rejects any role elevation request unless `isHighRiskAdminAction: true` + valid `managerApproval` is present.
88
+ - @frontend must build a prominent, non-dismissible Security Modal that forces the user to provide a reason before initiating the Hermes briefing to me (@manager).
89
+ - Audit logging must be designed for every high-risk action (see `audit-logging-standard.md`).
90
+
91
+ Only after these two layers exist will we proceed to implement the actual promotion feature.
92
+
93
+ @backend and @frontend — I am now issuing the official briefing for Phase 2.
94
+
95
+ Please reference:
96
+ - `high-risk-actions-managerapproval.md`
97
+ - `high-risk-security-modal-hermes-flow.md`
98
+ - `domain-error-handling-standard.md`
99
+
100
+ Confirm when the infrastructure design is ready for my approval.
101
+
102
+ ---
103
+
104
+ ## Session 4 – Delegation Example (After Infrastructure Approval)
105
+
106
+ **@manager** (to @backend):
107
+
108
+ @backend,
109
+
110
+ The high-risk infrastructure has been approved.
111
+
112
+ You may now implement the following:
113
+
114
+ **Feature**: `POST /api/v1/users/:id/role`
115
+
116
+ Requirements:
117
+ - Must use branded types only (`UserID`, `RoleID`, `ApprovalID`)
118
+ - Must reject the request with `HighRiskActionRequiresApprovalError` if the high-risk payload is missing or invalid
119
+ - Must create an audit log entry using the `AuditLog` domain (see `audit-logging-standard.md`)
120
+ - Must follow the contract defined in `apps/backend/src/types/api-contracts.ts`
121
+
122
+ Reference files:
123
+ - `high-risk-actions-managerapproval.md`
124
+ - `branded-types-law.md`
125
+ - `domain-error-handling-standard.md`
126
+
127
+ Do not proceed with any other privileged features until this endpoint is complete and reviewed.
128
+
129
+ ---
130
+
131
+ ## Key Behaviors Demonstrated in This Simulation
132
+
133
+ - @manager never allows feature work before governance foundation
134
+ - @manager consistently references the knowledge files
135
+ - @manager uses the Corporate Project Kickoff Checklist and Scaffolding SOP as the operating process
136
+ - @manager educates the user while protecting the standards
137
+ - All delegations are precise and reference the corporate governance documents
138
+
139
+ This is the expected behavior for any corporate project.
140
+
141
+ ---
142
+
143
+ **Note for Agents**:
144
+ When conducting real sessions, adapt the language but never skip the governance steps. Shortcuts at the beginning create expensive problems later.
@@ -0,0 +1,103 @@
1
+ # Corporate Enterprise Project Scaffolding SOP (for @manager)
2
+
3
+ **Version:** 1.1
4
+ **Purpose**: This is the mandatory standard process that @manager must follow when a user initiates a new project with corporate, enterprise, or regulated characteristics.
5
+
6
+ **Core Philosophy**:
7
+ Agent Enderun does **not** ship pre-built reference applications inside `apps/`.
8
+ Our value is in internalizing governance standards into the agents so that we can **guide the user** to build correctly, step by step, from the very first file.
9
+
10
+ ---
11
+
12
+ ## Phase 0 – Discovery & Governance Baseline (Non-Negotiable First Step)
13
+
14
+ Before any code is written or any feature is discussed in detail:
15
+
16
+ 1. **Load Corporate Governance Knowledge** (mandatory reads):
17
+ - `branded-types-law.md`
18
+ - `high-risk-actions-managerapproval.md`
19
+ - `high-risk-security-modal-hermes-flow.md`
20
+ - `audit-logging-standard.md`
21
+ - `governance-baseline-briefing-template.md`
22
+ - `audit-logging-standard.md` (when created)
23
+
24
+ 2. **Assess Project Context**:
25
+ - Does the project involve multiple users, roles, permissions, or privileged operations?
26
+ - Is there any requirement for audit trails, compliance, or high-risk administrative actions?
27
+ - Default assumption: Treat every new project as enterprise-grade unless the user explicitly states it is a simple internal prototype with no privileged actions.
28
+
29
+ 3. **Establish the Governance Contract** (before any technical discussion):
30
+ - Clearly communicate that the project will follow Agent Enderun corporate standards.
31
+ - Introduce the non-negotiable pillars:
32
+ - Branded Types for all domain identifiers
33
+ - High-risk actions protected exclusively by `managerApproval` + Hermes coordination
34
+ - Contract-first development (types before implementation)
35
+ - Comprehensive audit logging for privileged operations
36
+ - Obtain explicit user acknowledgment.
37
+
38
+ 4. **Document the Baseline Decision** in `docs/architecture/decisions/`.
39
+
40
+ **Rule**: No feature work, no architecture discussion, and no delegation may begin until Phase 0 is complete and acknowledged.
41
+
42
+ ---
43
+
44
+ ## Phase 1 – Foundation Layer (Contracts Before Any Implementation)
45
+
46
+ 1. **Create the Type System First** (`apps/backend/src/types`):
47
+ - `brand.ts` – Generic `Brand<T, Name>` utility
48
+ - `identifiers.ts` – `UserID`, `RoleID`, `ApprovalID`, `TraceID`, etc.
49
+ - `approval.ts` – `ManagerApproval` and `HighRiskActionPayload`
50
+ - `errors.ts` – DomainError base + concrete errors (including `HighRiskActionRequiresApprovalError`)
51
+ - `user.ts` / `role.ts` – Core domain entities
52
+ - `api-contracts.ts` – Initial request/response shapes for the first feature
53
+
54
+ 2. **Initialize Contract Versioning**:
55
+ - Create `apps/backend/contract.version.json` with proper MAJOR.MINOR version and hash.
56
+
57
+ 3. **Brief Supporting Agents**:
58
+ - Brief `@analyst` to establish contract integrity verification process.
59
+ - Brief `@frontend` to create parallel type copies and the base Security Modal component.
60
+
61
+ **Strict Rule**: No backend route, no React component, and no database schema may be implemented until the relevant contracts are defined and approved by @manager.
62
+
63
+ ---
64
+
65
+ ## Phase 2 – High-Risk Governance Infrastructure (Before Any Privileged Feature)
66
+
67
+ If the project will contain user/role management, configuration changes, or any privileged operations:
68
+
69
+ 1. Design and document the complete `managerApproval` validation flow with `@backend`.
70
+ 2. Design and implement the Security Modal + Hermes briefing user flow with `@frontend`.
71
+ 3. Ensure both specialist agents have explicit instructions in their briefings referencing the corporate governance knowledge files.
72
+ 4. Verify that `@backend` will reject any high-risk request lacking the proper payload, and that `@frontend` will never bypass the modal.
73
+
74
+ Only after these two infrastructure layers exist may actual feature development for privileged areas begin.
75
+
76
+ ---
77
+
78
+ ## Phase 3 – Feature Development Under Strict Governance
79
+
80
+ When delegating any work to `@backend` or `@frontend`:
81
+
82
+ The briefing message **must** include:
83
+ - Exact path to the contract types for this feature.
84
+ - Classification of whether the feature contains high-risk actions.
85
+ - Explicit references to the relevant files in `.gemini/knowledge/corporate-governance/`.
86
+ - Requirement to notify @manager before implementing any high-risk path.
87
+ - Mandate to produce ADR documentation for any new governance decisions.
88
+
89
+ After delivery:
90
+ - Require `@analyst` to perform contract alignment verification.
91
+ - Require documentation of the implementation in the project’s decision records.
92
+
93
+ ---
94
+
95
+ ## Phase 4 – Continuous Enforcement & Education
96
+
97
+ - At the start of every session, re-read the corporate governance knowledge files.
98
+ - Any proposal to “add governance later” or bypass standards must be treated as a process violation and rejected.
99
+ - @manager is responsible for continuously educating the user and the specialist agents on the standards throughout the lifetime of the project.
100
+
101
+ ---
102
+
103
+ **This SOP is the primary mechanism by which Agent Enderun scales enterprise discipline without shipping example code.**