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.
- package/.enderun/BRAIN_DASHBOARD.md +47 -0
- package/.enderun/PROJECT_MEMORY.md +139 -0
- package/.enderun/STATUS.md +62 -0
- package/.enderun/agents/agent_army_schema.json +85 -0
- package/.enderun/agents/analyst/agent.json +23 -0
- package/.enderun/agents/analyst/prompt.md +225 -0
- package/.enderun/agents/backend/agent.json +24 -0
- package/.enderun/agents/backend/prompt.md +331 -0
- package/.enderun/agents/devops/agent.json +61 -0
- package/.enderun/agents/devops/prompt.md +127 -0
- package/.enderun/agents/explorer/agent.json +22 -0
- package/.enderun/agents/explorer/prompt.md +115 -0
- package/.enderun/agents/frontend/agent.json +24 -0
- package/.enderun/agents/frontend/prompt.md +313 -0
- package/.enderun/agents/git/agent.json +22 -0
- package/.enderun/agents/git/prompt.md +99 -0
- package/.enderun/agents/manager/agent.json +48 -0
- package/.enderun/agents/manager/prompt.md +231 -0
- package/.enderun/agents/mobile/agent.json +21 -0
- package/.enderun/agents/mobile/prompt.md +91 -0
- package/.enderun/agents/native/agent.json +21 -0
- package/.enderun/agents/native/prompt.md +96 -0
- package/.enderun/agents/orchestrator/agent.json +53 -0
- package/.enderun/agents/orchestrator/prompt.md +124 -0
- package/.enderun/agents/qa/agent.json +57 -0
- package/.enderun/agents/qa/prompt.md +69 -0
- package/.enderun/agents/schema/agent-lifecycle-schema.json +65 -0
- package/.enderun/agents/security/agent.json +54 -0
- package/.enderun/agents/security/prompt.md +154 -0
- package/.enderun/gemini.md +19 -0
- package/.enderun/knowledge/corporate-governance/analyst-contract-integrity-guide.md +92 -0
- package/.enderun/knowledge/corporate-governance/audit-logging-standard.md +59 -0
- package/.enderun/knowledge/corporate-governance/backend-high-risk-endpoint-guide.md +125 -0
- package/.enderun/knowledge/corporate-governance/branded-types-law.md +77 -0
- package/.enderun/knowledge/corporate-governance/contract-drift-detection-simulation.md +92 -0
- package/.enderun/knowledge/corporate-governance/corporate-governance-playbook.md +89 -0
- package/.enderun/knowledge/corporate-governance/corporate-project-kickoff-checklist.md +56 -0
- package/.enderun/knowledge/corporate-governance/corporate-project-kickoff-simulation.md +144 -0
- package/.enderun/knowledge/corporate-governance/corporate-project-scaffolding-sop.md +103 -0
- package/.enderun/knowledge/corporate-governance/domain-error-handling-standard.md +75 -0
- package/.enderun/knowledge/corporate-governance/frontend-high-risk-modal-guide.md +211 -0
- package/.enderun/knowledge/corporate-governance/governance-baseline-briefing-template.md +54 -0
- package/.enderun/knowledge/corporate-governance/high-risk-action-approval-flow-simulation.md +167 -0
- package/.enderun/knowledge/corporate-governance/high-risk-actions-managerapproval.md +76 -0
- package/.enderun/knowledge/corporate-governance/high-risk-security-modal-hermes-flow.md +49 -0
- package/.enderun/knowledge/corporate-governance/manager-first-30-days-guide.md +112 -0
- package/.enderun/knowledge/corporate-governance/manager-first-three-briefings.md +79 -0
- package/.enderun/knowledge/deployment_checklist.md +7 -0
- package/{.antigravitycli → .enderun}/knowledge/framework_vs_user_project_boundary.md +3 -3
- package/{.antigravitycli → .enderun}/knowledge/frontend_professionalization_guidelines.md +17 -20
- package/{.antigravitycli → .enderun}/knowledge/hermes_live_test_guidelines.md +9 -9
- package/{.antigravitycli → .enderun}/knowledge/hermes_protocol.md +2 -2
- package/.enderun/knowledge/kentim_constitution.md +34 -0
- package/{.antigravitycli → .enderun}/knowledge/manager_authority_audit_enforcement.md +11 -11
- package/{.antigravitycli → .enderun}/knowledge/project_scaffold_guidelines.md +8 -8
- package/{.antigravitycli → .enderun}/knowledge/reference_application_guidelines.md +7 -7
- package/.enderun/logs/analyst.json +1 -0
- package/.enderun/logs/backend.json +1 -0
- package/.enderun/logs/devops.json +1 -0
- package/.enderun/logs/explorer.json +1 -0
- package/.enderun/logs/frontend.json +1 -0
- package/.enderun/logs/git.json +1 -0
- package/.enderun/logs/manager.json +20 -0
- package/.enderun/logs/mobile.json +1 -0
- package/.enderun/logs/native.json +1 -0
- package/.enderun/logs/orchestrator.json +1 -0
- package/.enderun/logs/qa.json +1 -0
- package/.enderun/logs/security.json +1 -0
- package/.enderun/memory-graph/agent-contexts/analyst.json +1 -0
- package/.enderun/memory-graph/agent-contexts/backend.json +1 -0
- package/.enderun/memory-graph/agent-contexts/devops.json +1 -0
- package/.enderun/memory-graph/agent-contexts/explorer.json +1 -0
- package/.enderun/memory-graph/agent-contexts/frontend.json +1 -0
- package/.enderun/memory-graph/agent-contexts/git.json +1 -0
- package/.enderun/memory-graph/agent-contexts/manager.json +1 -0
- package/.enderun/memory-graph/agent-contexts/mobile.json +1 -0
- package/.enderun/memory-graph/agent-contexts/native.json +1 -0
- package/.enderun/memory-graph/agent-contexts/orchestrator.json +1 -0
- package/.enderun/memory-graph/agent-contexts/qa.json +1 -0
- package/.enderun/memory-graph/agent-contexts/security.json +1 -0
- package/.enderun/memory-graph/graph.json +26 -0
- package/.enderun/memory-graph/shared-facts.json +52 -0
- package/.enderun/monitoring/.gitkeep +0 -0
- package/.enderun/queue/README.md +36 -0
- package/ENDERUN.md +4 -4
- package/README.md +151 -89
- package/bin/cli.js +13 -2138
- package/bin/hermes-sandbox.js +0 -0
- package/bin/validate-agent-army.js +3 -3
- package/docs/architecture/approval-flows.md +2 -37
- package/docs/backend/error-handling.md +2 -51
- package/docs/frontend/component-patterns.md +2 -47
- package/docs/getting-started.md +7 -15
- package/docs/roadmap.md +2 -2
- package/framework-mcp/dist/index.js +0 -0
- package/framework-mcp/dist/schemas.js +3 -3
- package/framework-mcp/dist/tools/framework.js +17 -10
- package/framework-mcp/dist/tools/governance.js +696 -0
- package/framework-mcp/dist/tools/index.js +14 -12
- package/framework-mcp/dist/tools/memory.js +106 -0
- package/framework-mcp/dist/tools/monitoring.js +294 -0
- package/framework-mcp/dist/tools/orchestration.js +368 -0
- package/framework-mcp/dist/tools/pipeline.js +267 -0
- package/framework-mcp/dist/utils.js +25 -3
- package/framework-mcp/package.json +3 -3
- package/framework-mcp/src/schemas.ts +3 -3
- package/framework-mcp/src/tools/framework.ts +18 -10
- package/framework-mcp/src/tools/governance.ts +891 -0
- package/framework-mcp/src/tools/index.ts +14 -12
- package/framework-mcp/src/tools/memory.ts +103 -0
- package/framework-mcp/src/tools/monitoring.ts +351 -0
- package/framework-mcp/src/tools/orchestration.ts +439 -0
- package/framework-mcp/src/tools/pipeline.ts +353 -0
- package/framework-mcp/src/utils.ts +24 -3
- package/framework-mcp/tsconfig.json +2 -1
- package/gemini.md +19 -0
- package/package.json +14 -20
- package/.antigravitycli/BRAIN_DASHBOARD.md +0 -43
- package/.antigravitycli/ENDERUN.md +0 -253
- package/.antigravitycli/PROJECT_MEMORY.md +0 -78
- package/.antigravitycli/STATUS.md +0 -21
- package/.antigravitycli/agents/agent_army_schema.json +0 -79
- package/.antigravitycli/agents/analyst/agent.json +0 -55
- package/.antigravitycli/agents/backend/agent.json +0 -58
- package/.antigravitycli/agents/explorer/agent.json +0 -50
- package/.antigravitycli/agents/frontend/agent.json +0 -56
- package/.antigravitycli/agents/git/agent.json +0 -53
- package/.antigravitycli/agents/manager/agent.json +0 -82
- package/.antigravitycli/agents/mobile/agent.json +0 -52
- package/.antigravitycli/agents/native/agent.json +0 -56
- package/.antigravitycli/assets/manager.png +0 -0
- package/.antigravitycli/blueprints/README.md +0 -82
- package/.antigravitycli/blueprints/backend/errors/config/meta.json +0 -16
- package/.antigravitycli/blueprints/backend/errors/domain-error.ts +0 -64
- package/.antigravitycli/knowledge/README.md +0 -22
- package/.antigravitycli/knowledge/database_governance_guidelines.md +0 -118
- package/.antigravitycli/knowledge/deployment_checklist.md +0 -133
- package/.antigravitycli/knowledge/documentation_ownership.md +0 -122
- package/.antigravitycli/knowledge/documentation_ownership_status.md +0 -122
- package/.antigravitycli/knowledge/enterprise_capabilities_reference.md +0 -149
- package/.antigravitycli/knowledge/enterprise_frontend_adaptation.md +0 -232
- package/.antigravitycli/knowledge/enterprise_project_adaptation.md +0 -168
- package/.antigravitycli/knowledge/frontend_real_battle_test_protocol.md +0 -162
- package/antigravity.md +0 -15
- package/docs/architecture/decisions/README.md +0 -31
- package/docs/architecture/notification-strategy.md +0 -38
- package/docs/backend/audit-logging.md +0 -34
- package/docs/frontend/forms.md +0 -40
- package/docs/frontend/notifications.md +0 -37
- package/framework-mcp/dist/tools/academy.js +0 -182
- package/framework-mcp/dist/tools/database.js +0 -57
- package/framework-mcp/dist/tools/repository.js +0 -101
- package/framework-mcp/dist/tools/scaffold.js +0 -132
- package/framework-mcp/src/tools/academy.ts +0 -180
- package/framework-mcp/src/tools/database.ts +0 -54
- package/framework-mcp/src/tools/repository.ts +0 -101
- package/framework-mcp/src/tools/scaffold.ts +0 -150
- /package/{.antigravitycli/messages → .enderun/benchmarks}/.gitkeep +0 -0
- /package/{.antigravitycli → .enderun}/cli-commands.json +0 -0
- /package/{.antigravitycli → .enderun}/config.json +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/api_design_rules.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/async_error_handling.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/blueprint_driven_construction.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/branded_types_pattern.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/code_review_checklist.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/contract_versioning.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/database_migration.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/git_commit_strategy.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/legacy_onboarding.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/monitoring_setup.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/performance_guidelines.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/repository_patterns.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/responsive_design_standards.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/security_scanning.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/testing_standards.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/troubleshooting_guide.md +0 -0
- /package/{.antigravitycli → .enderun}/knowledge/zero_ui_library_policy.md +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Domain Error Handling & Typed Errors Standard
|
|
2
|
+
|
|
3
|
+
**Applies to**: All backend and shared contract code in enterprise projects using Agent Enderun.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
In large-scale corporate systems, generic `Error` or string-based error messages lead to fragile code, poor debugging, and insecure error handling. We enforce a typed, domain-aware error system.
|
|
7
|
+
|
|
8
|
+
## Core Principles
|
|
9
|
+
|
|
10
|
+
1. Every domain error must be represented by a dedicated class that extends a base `DomainError`.
|
|
11
|
+
2. Errors must carry machine-readable codes, not just human messages.
|
|
12
|
+
3. Errors must be serializable in a consistent, safe format for API responses.
|
|
13
|
+
4. Never use `throw new Error("something went wrong")` in production business logic.
|
|
14
|
+
|
|
15
|
+
## Standard Error Hierarchy
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// apps/backend/src/types/errors.ts
|
|
19
|
+
|
|
20
|
+
export abstract class DomainError extends Error {
|
|
21
|
+
abstract readonly code: string;
|
|
22
|
+
abstract readonly statusCode: number;
|
|
23
|
+
readonly details?: Record<string, unknown>;
|
|
24
|
+
|
|
25
|
+
constructor(message: string, details?: Record<string, unknown>) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.details = details;
|
|
28
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
toJSON() {
|
|
32
|
+
return {
|
|
33
|
+
error: {
|
|
34
|
+
code: this.code,
|
|
35
|
+
message: this.message,
|
|
36
|
+
details: this.details,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Example concrete errors
|
|
43
|
+
export class UserNotFoundError extends DomainError {
|
|
44
|
+
readonly code = 'USER_NOT_FOUND';
|
|
45
|
+
readonly statusCode = 404;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class InsufficientPermissionsError extends DomainError {
|
|
49
|
+
readonly code = 'INSUFFICIENT_PERMISSIONS';
|
|
50
|
+
readonly statusCode = 403;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class HighRiskActionRequiresApprovalError extends DomainError {
|
|
54
|
+
readonly code = 'HIGH_RISK_ACTION_REQUIRES_APPROVAL';
|
|
55
|
+
readonly statusCode = 403;
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage Rules
|
|
60
|
+
|
|
61
|
+
- Business logic must throw specific domain errors, never generic ones.
|
|
62
|
+
- API layer (Fastify error handler) converts `DomainError` instances into safe JSON responses.
|
|
63
|
+
- Never expose stack traces or internal details to clients.
|
|
64
|
+
- Frontend must be able to handle known error codes and show appropriate user-facing messages.
|
|
65
|
+
|
|
66
|
+
## Integration with High-Risk Governance
|
|
67
|
+
|
|
68
|
+
When a high-risk action is attempted without proper `managerApproval`, the backend **must** throw `HighRiskActionRequiresApprovalError`. This error code is then used by the frontend to trigger the security modal flow.
|
|
69
|
+
|
|
70
|
+
## Enforcement
|
|
71
|
+
|
|
72
|
+
- `@backend` must reject any implementation that uses raw `Error` or `throw new Error(...)` for domain cases.
|
|
73
|
+
- `@analyst` will periodically scan for anti-patterns using static analysis.
|
|
74
|
+
|
|
75
|
+
This standard ensures consistent, safe, and debuggable error handling across the entire system.
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Security Modal + Hermes Briefing Component Implementation Guide (@frontend)
|
|
2
|
+
|
|
3
|
+
**Applies to**: Any UI flow that can trigger high-risk administrative actions.
|
|
4
|
+
|
|
5
|
+
**Goal**: Provide @frontend with a concrete, reusable, and governance-compliant pattern using Panda CSS and proper state management.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Component Architecture (Recommended)
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
apps/web/src/components/ui/
|
|
13
|
+
├── HighRiskSecurityModal/
|
|
14
|
+
│ ├── HighRiskSecurityModal.tsx
|
|
15
|
+
│ ├── HighRiskSecurityModal.types.ts
|
|
16
|
+
│ └── HighRiskSecurityModal.styles.ts (Panda CSS)
|
|
17
|
+
├── hooks/
|
|
18
|
+
│ └── useHighRiskApproval.ts (Hermes briefing logic)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Core Types
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
// HighRiskSecurityModal.types.ts
|
|
27
|
+
import { ManagerApproval, TraceID } from '../../../types/api-contracts';
|
|
28
|
+
|
|
29
|
+
export interface HighRiskActionContext {
|
|
30
|
+
actionType: string; // e.g. "PROMOTE_TO_SUPERADMIN"
|
|
31
|
+
targetId: string;
|
|
32
|
+
targetDescription: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface HighRiskApprovalResult {
|
|
36
|
+
approved: boolean;
|
|
37
|
+
managerApproval?: ManagerApproval;
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 3. Hook: useHighRiskApproval (Hermes Coordination)
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// hooks/useHighRiskApproval.ts
|
|
47
|
+
|
|
48
|
+
export function useHighRiskApproval() {
|
|
49
|
+
const [status, setStatus] = useState<'idle' | 'awaiting_manager' | 'approved' | 'rejected'>('idle');
|
|
50
|
+
const [approval, setApproval] = useState<ManagerApproval | null>(null);
|
|
51
|
+
|
|
52
|
+
const requestApproval = async (context: HighRiskActionContext, reason: string) => {
|
|
53
|
+
setStatus('awaiting_manager');
|
|
54
|
+
|
|
55
|
+
// In real implementation, this sends a Hermes message to @manager
|
|
56
|
+
const hermesMessage = {
|
|
57
|
+
type: 'high_risk_approval_request',
|
|
58
|
+
traceId: generateTraceId() as TraceID,
|
|
59
|
+
payload: {
|
|
60
|
+
action: context.actionType,
|
|
61
|
+
targetId: context.targetId,
|
|
62
|
+
reason,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Simulated Hermes round-trip (in real system this would be async via MCP/tools)
|
|
67
|
+
const response = await sendHermesToManager(hermesMessage);
|
|
68
|
+
|
|
69
|
+
if (response.status === 'approved') {
|
|
70
|
+
setApproval(response.managerApproval);
|
|
71
|
+
setStatus('approved');
|
|
72
|
+
return { approved: true, managerApproval: response.managerApproval };
|
|
73
|
+
} else {
|
|
74
|
+
setStatus('rejected');
|
|
75
|
+
return { approved: false };
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return { status, approval, requestApproval };
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 4. Security Modal Component (Panda CSS)
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
// HighRiskSecurityModal.tsx
|
|
89
|
+
|
|
90
|
+
import { css } from '../../../styled-system/css';
|
|
91
|
+
|
|
92
|
+
interface Props {
|
|
93
|
+
isOpen: boolean;
|
|
94
|
+
context: HighRiskActionContext;
|
|
95
|
+
onClose: () => void;
|
|
96
|
+
onApproved: (approval: ManagerApproval) => void;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function HighRiskSecurityModal({ isOpen, context, onClose, onApproved }: Props) {
|
|
100
|
+
const [reason, setReason] = useState('');
|
|
101
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
102
|
+
const { status, approval, requestApproval } = useHighRiskApproval();
|
|
103
|
+
|
|
104
|
+
const handleRequestApproval = async () => {
|
|
105
|
+
if (!reason.trim()) return;
|
|
106
|
+
|
|
107
|
+
setIsSubmitting(true);
|
|
108
|
+
const result = await requestApproval(context, reason);
|
|
109
|
+
|
|
110
|
+
if (result.approved && result.managerApproval) {
|
|
111
|
+
onApproved(result.managerApproval);
|
|
112
|
+
onClose();
|
|
113
|
+
}
|
|
114
|
+
setIsSubmitting(false);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
if (!isOpen) return null;
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<div className={css({ position: 'fixed', inset: 0, bg: 'rgba(0,0,0,0.7)', zIndex: 1000 })}>
|
|
121
|
+
<div className={css({
|
|
122
|
+
bg: 'white',
|
|
123
|
+
maxW: '480px',
|
|
124
|
+
mx: 'auto',
|
|
125
|
+
mt: '10vh',
|
|
126
|
+
p: '6',
|
|
127
|
+
borderRadius: 'lg',
|
|
128
|
+
border: '2px solid {colors.red.600}',
|
|
129
|
+
})}>
|
|
130
|
+
<h2 className={css({ color: 'red.600', fontSize: 'xl', fontWeight: 'bold' })}>
|
|
131
|
+
⚠️ High-Risk Administrative Action
|
|
132
|
+
</h2>
|
|
133
|
+
|
|
134
|
+
<p className={css({ mt: 3 })}>
|
|
135
|
+
You are about to perform: <strong>{context.actionType}</strong><br />
|
|
136
|
+
Target: {context.targetDescription}
|
|
137
|
+
</p>
|
|
138
|
+
|
|
139
|
+
<label className={css({ display: 'block', mt: 4, fontWeight: 'medium' })}>
|
|
140
|
+
Reason for this action (required for audit and approval):
|
|
141
|
+
</label>
|
|
142
|
+
<textarea
|
|
143
|
+
value={reason}
|
|
144
|
+
onChange={(e) => setReason(e.target.value)}
|
|
145
|
+
className={css({ w: 'full', h: '100px', mt: 2, p: 3, border: '1px solid gray' })}
|
|
146
|
+
placeholder="Explain why this privileged action is necessary..."
|
|
147
|
+
/>
|
|
148
|
+
|
|
149
|
+
<div className={css({ display: 'flex', gap: 3, mt: 5 })}>
|
|
150
|
+
<button onClick={onClose} disabled={isSubmitting}>
|
|
151
|
+
Cancel
|
|
152
|
+
</button>
|
|
153
|
+
<button
|
|
154
|
+
onClick={handleRequestApproval}
|
|
155
|
+
disabled={isSubmitting || !reason.trim()}
|
|
156
|
+
className={css({ bg: 'red.600', color: 'white' })}
|
|
157
|
+
>
|
|
158
|
+
{status === 'awaiting_manager'
|
|
159
|
+
? 'Waiting for @manager approval via Hermes...'
|
|
160
|
+
: 'Request Manager Approval'}
|
|
161
|
+
</button>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<p className={css({ fontSize: 'xs', color: 'gray.500', mt: 4 })}>
|
|
165
|
+
This action will be fully audited. A valid managerApproval token is required.
|
|
166
|
+
</p>
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## 5. Usage in a Page
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
const handlePromoteClick = (user: User) => {
|
|
179
|
+
setSelectedUser(user);
|
|
180
|
+
setModalOpen(true);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const handleApproved = (approval: ManagerApproval) => {
|
|
184
|
+
// Now safe to call the high-risk API with the token
|
|
185
|
+
promoteUser(user.id, approval);
|
|
186
|
+
};
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 6. Anti-Patterns (Forbidden)
|
|
192
|
+
|
|
193
|
+
- Calling high-risk API endpoints directly from event handlers
|
|
194
|
+
- Generating fake `managerApproval` objects on the client
|
|
195
|
+
- Making the modal dismissible while the Hermes request is in flight
|
|
196
|
+
- Storing approval tokens in localStorage for later reuse
|
|
197
|
+
- Skipping the “reason” field
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 7. Testing Requirements
|
|
202
|
+
|
|
203
|
+
- Modal appears when high-risk action is triggered
|
|
204
|
+
- API call is blocked until valid approval is received
|
|
205
|
+
- Reason field is mandatory
|
|
206
|
+
- Proper error states when @manager rejects the request
|
|
207
|
+
|
|
208
|
+
**Reference files**:
|
|
209
|
+
- `high-risk-security-modal-hermes-flow.md`
|
|
210
|
+
- `high-risk-action-approval-flow-simulation.md`
|
|
211
|
+
- `corporate-project-scaffolding-sop.md`
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Governance Baseline Briefing Template (for @manager)
|
|
2
|
+
|
|
3
|
+
**Use Case**: Use this as the foundation for the first major response when a user starts a new project that appears to be corporate or enterprise in nature.
|
|
4
|
+
|
|
5
|
+
**Goal**: Establish the governance contract early, set expectations, and position the standards as non-negotiable enablers rather than obstacles.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Template
|
|
10
|
+
|
|
11
|
+
Thank you for initiating this project with Agent Enderun.
|
|
12
|
+
|
|
13
|
+
Before we discuss any specific features, architecture, or technology choices, we must establish the governance baseline that will guide all work.
|
|
14
|
+
|
|
15
|
+
### Corporate Governance Standards
|
|
16
|
+
|
|
17
|
+
This project will follow Agent Enderun’s enterprise governance model. The three foundational pillars are:
|
|
18
|
+
|
|
19
|
+
1. **Branded Types Law**
|
|
20
|
+
All domain identifiers (UserID, RoleID, ApprovalID, etc.) must use compile-time branded types. Plain strings or numbers for identifiers are not permitted.
|
|
21
|
+
|
|
22
|
+
2. **High-Risk Administrative Action Governance**
|
|
23
|
+
Any operation that elevates roles, changes system configuration, performs bulk operations, or accesses sensitive audit data is classified as high-risk. These actions may only be executed after:
|
|
24
|
+
- Explicit `isHighRiskAdminAction: true` flag, and
|
|
25
|
+
- A valid `managerApproval` token containing a signed reason and trace ID.
|
|
26
|
+
|
|
27
|
+
3. **Contract-First Development + Hermes Coordination**
|
|
28
|
+
API contracts and type definitions are created before implementation. Any change to shared contracts must be communicated via Hermes to the relevant specialist agents.
|
|
29
|
+
|
|
30
|
+
These standards exist to make the system auditable, safe, and maintainable at scale. They are not optional.
|
|
31
|
+
|
|
32
|
+
### How We Will Work Together
|
|
33
|
+
|
|
34
|
+
- We will **not** start by building features.
|
|
35
|
+
- We will first define the type foundation and governance infrastructure.
|
|
36
|
+
- Only after the foundation is in place will we proceed to implement user-facing functionality.
|
|
37
|
+
- I (@manager) will personally review and approve the governance approach for any high-risk area before implementation begins.
|
|
38
|
+
|
|
39
|
+
### Next Immediate Steps
|
|
40
|
+
|
|
41
|
+
If you agree with this approach, please confirm. Once confirmed, we will begin with:
|
|
42
|
+
|
|
43
|
+
1. Creation of the Branded Types foundation and core `ManagerApproval` contract.
|
|
44
|
+
2. Definition of the first set of API contracts.
|
|
45
|
+
3. (If privileged operations are expected) Design of the high-risk approval flow and security modal pattern.
|
|
46
|
+
|
|
47
|
+
Would you like to proceed with this governance-first approach, or do you have any questions or concerns before we begin?
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
**Usage Notes for @manager**:
|
|
52
|
+
- Adapt the language based on how much the user already understands.
|
|
53
|
+
- If the user pushes back on governance, treat it as a signal to spend more time on education rather than proceeding faster.
|
|
54
|
+
- Always document the user’s acknowledgment in `PROJECT_MEMORY.md` under Critical Decisions.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# High-Risk Action Approval Flow Simulation
|
|
2
|
+
|
|
3
|
+
**Purpose**: This simulation demonstrates the complete end-to-end flow of a high-risk administrative action in a corporate project, from the moment the user clicks the button in the UI until the action is executed and audited.
|
|
4
|
+
|
|
5
|
+
**Scenario**: A company administrator wants to promote a regular user to SuperAdmin. This action is classified as high-risk.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Step 1 – User Triggers the Action (Frontend)
|
|
10
|
+
|
|
11
|
+
**UI Context**: Admin dashboard → User list → “Promote to SuperAdmin” button next to a user named “Alice”.
|
|
12
|
+
|
|
13
|
+
**User clicks the button.**
|
|
14
|
+
|
|
15
|
+
**Frontend behavior** (as per `high-risk-security-modal-hermes-flow.md`):
|
|
16
|
+
|
|
17
|
+
- Immediately opens a prominent, non-dismissible `HighRiskSecurityModal`.
|
|
18
|
+
- Modal displays:
|
|
19
|
+
- Clear warning: “This action will grant full system privileges to the selected user.”
|
|
20
|
+
- Required “Reason” textarea.
|
|
21
|
+
- Buttons: “Cancel” and “Request Manager Approval via Hermes”.
|
|
22
|
+
|
|
23
|
+
**User enters the reason**:
|
|
24
|
+
“Alice needs SuperAdmin access to handle critical production incidents during the migration period. Security team has reviewed and approved.”
|
|
25
|
+
|
|
26
|
+
User clicks “Request Manager Approval via Hermes”.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Step 2 – Hermes Briefing to @manager
|
|
31
|
+
|
|
32
|
+
**Frontend** constructs and sends a Hermes message to @manager:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"type": "high_risk_approval_request",
|
|
37
|
+
"traceId": "TRACE-20260525-USER-PROMO-042",
|
|
38
|
+
"payload": {
|
|
39
|
+
"action": "PROMOTE_TO_SUPERADMIN",
|
|
40
|
+
"targetUserId": "user_0192",
|
|
41
|
+
"proposedBy": "admin_007",
|
|
42
|
+
"reason": "Alice needs SuperAdmin access to handle critical production incidents during the migration period. Security team has reviewed and approved."
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**@manager receives the briefing.**
|
|
48
|
+
|
|
49
|
+
**@manager internal process** (as per corporate-governance knowledge):
|
|
50
|
+
|
|
51
|
+
- Reads `high-risk-actions-managerapproval.md`
|
|
52
|
+
- Reads `audit-logging-standard.md`
|
|
53
|
+
- Assesses risk level (very high – SuperAdmin elevation)
|
|
54
|
+
- Checks current project context and any existing policies
|
|
55
|
+
|
|
56
|
+
**@manager response** (sent back via Hermes):
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"type": "high_risk_approval_response",
|
|
61
|
+
"traceId": "TRACE-20260525-USER-PROMO-042",
|
|
62
|
+
"status": "approved",
|
|
63
|
+
"managerApproval": {
|
|
64
|
+
"approvalId": "approval_88471",
|
|
65
|
+
"traceId": "TRACE-20260525-USER-PROMO-042",
|
|
66
|
+
"approvedBy": "manager",
|
|
67
|
+
"approvedAt": "2026-05-25T00:31:12Z",
|
|
68
|
+
"signature": "mgr-sig-20260525-88471",
|
|
69
|
+
"reason": "Approved for production incident handling during migration window. 30-day time-limited approval recommended."
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Step 3 – Frontend Receives Approval and Dispatches Request
|
|
77
|
+
|
|
78
|
+
**Frontend**:
|
|
79
|
+
- Receives the signed `managerApproval` token.
|
|
80
|
+
- Closes the security modal.
|
|
81
|
+
- Shows temporary status: “Manager approval received. Executing action…”
|
|
82
|
+
- Attaches the token to the API request:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const payload = {
|
|
86
|
+
userId: "user_0192" as UserID,
|
|
87
|
+
newRole: "SuperAdmin",
|
|
88
|
+
isHighRiskAdminAction: true,
|
|
89
|
+
managerApproval: {
|
|
90
|
+
approvalId: "approval_88471",
|
|
91
|
+
traceId: "TRACE-20260525-USER-PROMO-042",
|
|
92
|
+
approvedBy: "manager",
|
|
93
|
+
approvedAt: "2026-05-25T00:31:12Z",
|
|
94
|
+
signature: "mgr-sig-20260525-88471",
|
|
95
|
+
reason: "Approved for production incident handling during migration window. 30-day time-limited approval recommended."
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
await fetch(`/api/v1/users/${userId}/role`, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
body: JSON.stringify(payload)
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Step 4 – Backend Validation and Execution
|
|
108
|
+
|
|
109
|
+
**@backend** receives the request.
|
|
110
|
+
|
|
111
|
+
**Validation steps** (mandatory per `high-risk-actions-managerapproval.md` and `domain-error-handling-standard.md`):
|
|
112
|
+
|
|
113
|
+
1. Checks `isHighRiskAdminAction === true`
|
|
114
|
+
2. Validates presence and structure of `managerApproval`
|
|
115
|
+
3. Verifies `managerApproval.approvedBy === "manager"`
|
|
116
|
+
4. (In real system) Validates cryptographic signature or secure reference
|
|
117
|
+
|
|
118
|
+
If any check fails → throws `HighRiskActionRequiresApprovalError`
|
|
119
|
+
|
|
120
|
+
**Execution**:
|
|
121
|
+
|
|
122
|
+
- Updates user role in database
|
|
123
|
+
- Creates audit log entry (see `audit-logging-standard.md`):
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
await auditLogRepository.create({
|
|
127
|
+
traceId: "TRACE-20260525-USER-PROMO-042",
|
|
128
|
+
actorId: "admin_007" as UserID,
|
|
129
|
+
action: "USER_ROLE_ELEVATED_TO_SUPERADMIN",
|
|
130
|
+
targetId: "user_0192" as UserID,
|
|
131
|
+
beforeState: { role: "Admin" },
|
|
132
|
+
afterState: { role: "SuperAdmin" },
|
|
133
|
+
managerApprovalId: "approval_88471",
|
|
134
|
+
reason: "Approved for production incident handling during migration window..."
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- Returns success response with the used `approvalId`
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Step 5 – Frontend Feedback and Audit Visibility
|
|
143
|
+
|
|
144
|
+
**Frontend**:
|
|
145
|
+
- Shows success message: “Alice has been promoted to SuperAdmin. Action recorded with approval ID: approval_88471”
|
|
146
|
+
- (Optional but recommended) Shows link to view the audit trail entry for this action
|
|
147
|
+
|
|
148
|
+
**Audit log entry** is now queryable by authorized personnel (themselves subject to high-risk approval if they want to view full details).
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Key Governance Elements Demonstrated
|
|
153
|
+
|
|
154
|
+
- User cannot bypass the security modal
|
|
155
|
+
- Reason is mandatory and travels with the approval
|
|
156
|
+
- @manager performs explicit risk assessment before issuing the token
|
|
157
|
+
- Backend strictly validates the token before any state change
|
|
158
|
+
- Full audit trail is created with reference to the approval
|
|
159
|
+
- Trace ID connects the entire flow (UI → Hermes → Backend → Audit)
|
|
160
|
+
|
|
161
|
+
This is the expected behavior for any high-risk action in a corporate project using Agent Enderun.
|
|
162
|
+
|
|
163
|
+
**Anti-patterns shown as forbidden in this simulation**:
|
|
164
|
+
- Frontend directly calling the API without the modal and approval
|
|
165
|
+
- Backend executing the role change without validating `managerApproval`
|
|
166
|
+
- Skipping audit logging for a privileged action
|
|
167
|
+
- Re-using an old approval token without fresh @manager review
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# High-Risk Administrative Actions & ManagerApproval Pattern
|
|
2
|
+
|
|
3
|
+
**Applies to:** Any operation that changes user roles/permissions, system configuration, bulk data operations, or audit access.
|
|
4
|
+
|
|
5
|
+
## Core Principle
|
|
6
|
+
From ENDERUN.md Corporate CRUD Governance:
|
|
7
|
+
> High-risk administrative operations are strictly under @manager control. Specialist agents must refuse and immediately redirect such requests to @manager.
|
|
8
|
+
|
|
9
|
+
## Required Payload Shape
|
|
10
|
+
Every high-risk request **must** include:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
interface HighRiskActionPayload {
|
|
14
|
+
isHighRiskAdminAction: true; // Explicit boolean flag
|
|
15
|
+
managerApproval: ManagerApproval; // Cryptographically or procedurally signed token
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ManagerApproval {
|
|
19
|
+
approvalId: ApprovalID;
|
|
20
|
+
traceId: TraceID;
|
|
21
|
+
approvedBy: 'manager';
|
|
22
|
+
approvedAt: string; // ISO-8601
|
|
23
|
+
signature: string; // In real systems: cryptographic signature or secure reference
|
|
24
|
+
reason: string; // Human-readable justification (mandatory)
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Backend Enforcement Rules (@backend)
|
|
29
|
+
1. If the action affects roles/permissions at Admin level or higher → treat as high-risk.
|
|
30
|
+
2. Reject the request immediately (403) if either `isHighRiskAdminAction` or `managerApproval` is missing.
|
|
31
|
+
3. Validate that `managerApproval.approvedBy === 'manager'`.
|
|
32
|
+
4. Log the full approval token for audit.
|
|
33
|
+
5. Never perform the state change before validation.
|
|
34
|
+
|
|
35
|
+
## Frontend Requirements (@frontend)
|
|
36
|
+
1. Any button or flow that can trigger a high-risk action must first open a **prominent, non-dismissible security modal**.
|
|
37
|
+
2. The modal must:
|
|
38
|
+
- Clearly explain the risk and consequences.
|
|
39
|
+
- Require the user to enter a "reason".
|
|
40
|
+
- Only then initiate the Hermes briefing to @manager.
|
|
41
|
+
3. The actual API call may only be made **after** a valid `managerApproval` token is returned from the briefing flow.
|
|
42
|
+
|
|
43
|
+
## Hermes Coordination
|
|
44
|
+
- @frontend → Hermes briefing to @manager with proposed action + reason.
|
|
45
|
+
- @manager performs risk assessment and either:
|
|
46
|
+
- Issues a signed `managerApproval` token, or
|
|
47
|
+
- Rejects the request.
|
|
48
|
+
- Only after receiving the token does the frontend dispatch the high-risk request to backend.
|
|
49
|
+
|
|
50
|
+
## Concrete Payload Example (TypeScript)
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
// Request body for elevating a user to SuperAdmin
|
|
54
|
+
interface PromoteToSuperAdminRequest {
|
|
55
|
+
userId: UserID;
|
|
56
|
+
newRole: 'SuperAdmin';
|
|
57
|
+
isHighRiskAdminAction: true;
|
|
58
|
+
managerApproval: {
|
|
59
|
+
approvalId: ApprovalID;
|
|
60
|
+
traceId: TraceID;
|
|
61
|
+
approvedBy: 'manager';
|
|
62
|
+
approvedAt: string;
|
|
63
|
+
signature: string;
|
|
64
|
+
reason: string;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Example High-Risk Actions (Non-Exhaustive)
|
|
70
|
+
- Elevating any user to Admin or SuperAdmin
|
|
71
|
+
- Resetting system-wide configuration
|
|
72
|
+
- Bulk user deletion or data purge
|
|
73
|
+
- Exporting full audit logs containing PII
|
|
74
|
+
- Changing authentication providers or security policies
|
|
75
|
+
|
|
76
|
+
This pattern is the foundation of trustworthy enterprise governance in Agent Enderun.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# High-Risk Security Modal + Hermes Briefing Flow (Frontend Pattern)
|
|
2
|
+
|
|
3
|
+
**Owner:** @frontend
|
|
4
|
+
**Related:** high-risk-actions-managerapproval.md
|
|
5
|
+
|
|
6
|
+
## When to Use
|
|
7
|
+
Any UI action that can result in a high-risk backend operation (see list in high-risk-actions document).
|
|
8
|
+
|
|
9
|
+
## Required UI Behavior
|
|
10
|
+
|
|
11
|
+
1. **Trigger Detection**
|
|
12
|
+
- The component must recognize that the intended action is high-risk (role elevation, bulk ops, etc.).
|
|
13
|
+
|
|
14
|
+
2. **Security Modal (Mandatory)**
|
|
15
|
+
- Modal must be prominent (red/danger styling, large title "High-Risk Administrative Action").
|
|
16
|
+
- Must clearly state what is about to happen and the potential impact.
|
|
17
|
+
- Must contain a required free-text "Reason" field (this becomes part of the approval token).
|
|
18
|
+
- Must have clear "Cancel" and "Request Manager Approval" actions.
|
|
19
|
+
- Should not be dismissible by clicking outside while the request is in flight.
|
|
20
|
+
|
|
21
|
+
3. **Hermes Briefing Flow**
|
|
22
|
+
- On "Request Manager Approval":
|
|
23
|
+
- Frontend sends a Hermes message to @manager containing:
|
|
24
|
+
- Proposed action
|
|
25
|
+
- Affected entities (e.g. userId)
|
|
26
|
+
- User-entered reason
|
|
27
|
+
- Current user context
|
|
28
|
+
- UI enters "Awaiting @manager approval" state (loading indicator + clear message).
|
|
29
|
+
|
|
30
|
+
4. **Approval Reception**
|
|
31
|
+
- When @manager responds with a valid `managerApproval` token (via Hermes or secure channel), the frontend:
|
|
32
|
+
- Attaches the token to the request payload (`isHighRiskAdminAction: true`, `managerApproval`).
|
|
33
|
+
- Dispatches the actual API call.
|
|
34
|
+
- Shows success/failure feedback.
|
|
35
|
+
|
|
36
|
+
5. **Audit & Traceability**
|
|
37
|
+
- The Trace ID from the approval must be visible or logged in the UI success state.
|
|
38
|
+
- The full approval reason must be recorded.
|
|
39
|
+
|
|
40
|
+
## Anti-Patterns (Forbidden)
|
|
41
|
+
- Performing the high-risk API call without the modal + reason.
|
|
42
|
+
- Faking or locally generating the `managerApproval` object in the browser.
|
|
43
|
+
- Hiding the risk from the user ("just click confirm").
|
|
44
|
+
- Re-using old approval tokens.
|
|
45
|
+
|
|
46
|
+
## Recommended Component Location
|
|
47
|
+
`apps/web/src/components/ui/HighRiskSecurityModal.tsx` (or similar compound component).
|
|
48
|
+
|
|
49
|
+
This pattern ensures that high-risk actions are never accidental and always carry a full audit trail through @manager.
|