@tera-system/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +13 -0
- package/MANIFEST.json +24 -0
- package/README.md +67 -0
- package/RELEASES.md +28 -0
- package/WELCOME.md +35 -0
- package/agents/application-blueprint.md +407 -0
- package/agents/auditor.md +665 -0
- package/agents/design-reviewer.md +392 -0
- package/agents/domain-expert-agent.md +510 -0
- package/agents/domain-research-agent.md +360 -0
- package/agents/engineering-agent-dotnet.md +218 -0
- package/agents/engineering-agent-phaser.md +275 -0
- package/agents/engineering-agent-typescript.md +300 -0
- package/agents/engineering-agent.md +143 -0
- package/agents/monitor.md +395 -0
- package/agents/production-erp-expert.md +506 -0
- package/agents/project-knowledge-agent.md +271 -0
- package/agents/qa-agent.md +498 -0
- package/agents/tera-business-transformation-consultant.md +290 -0
- package/agents/tera-client-engagement.md +891 -0
- package/agents/tera-software-designer.md +237 -0
- package/agents/tera-strategic-advisor.md +325 -0
- package/agents/tera-system-evolution.md +759 -0
- package/agents/tera.md +520 -0
- package/agents/ui-designer.md +426 -0
- package/commands/tera-approve.md +34 -0
- package/commands/tera-diagnose.md +47 -0
- package/commands/tera-gate.md +40 -0
- package/commands/tera-help.md +41 -0
- package/commands/tera-new-project.md +35 -0
- package/commands/tera-plan.md +34 -0
- package/commands/tera-request-build.md +45 -0
- package/commands/tera-resume.md +34 -0
- package/commands/tera-review.md +52 -0
- package/commands/tera-status.md +38 -0
- package/commands/tera-update.md +48 -0
- package/core/project-control/templates/TASK_TEMPLATE.md +146 -0
- package/core/tera-system/AGENT_ACTIVATION_MATRIX.md +285 -0
- package/core/tera-system/AGENT_DEPENDENCY_MAP.md +117 -0
- package/core/tera-system/AGENT_GENERATION_TEMPLATE.md +312 -0
- package/core/tera-system/AGENT_PERMISSION_MODEL.md +343 -0
- package/core/tera-system/AIS_PROTOCOL.md +191 -0
- package/core/tera-system/TERA_AGENT_CONDUCT.md +102 -0
- package/core/tera-system/TERA_CONTINUOUS_IMPROVEMENT_POLICY.md +111 -0
- package/core/tera-system/TERA_DISTRIBUTION_POLICY.md +291 -0
- package/core/tera-system/TERA_PROJECT_DECISION.md +281 -0
- package/core/tera-system/TERA_USER_GUIDE.md +462 -0
- package/core/tera-system/TOOLING_AND_MCP_POLICY.md +285 -0
- package/core/tera-system/TeraApplicationQuestionBank.md +362 -0
- package/core/tera-system/TeraArchitectureMap.md +91 -0
- package/core/tera-system/TeraClientPolicy.md +366 -0
- package/core/tera-system/TeraHelperAgents.md +970 -0
- package/core/tera-system/TeraPolicyMap.md +131 -0
- package/core/tera-system/TeraPreExecutionGate.md +818 -0
- package/core/tera-system/TeraPreparationDocumentationGovernance.md +370 -0
- package/core/tera-system/TeraPricingPolicy.md +674 -0
- package/core/tera-system/TeraProjectIntakePolicy.md +164 -0
- package/core/tera-system/TeraScenarioStressTests.md +168 -0
- package/core/tera-system/TeraSubAgents.md +854 -0
- package/core/tera-system/TeraSystemMaintenanceChecklist.md +80 -0
- package/core/tera-system/TeraTokenPolicy.md +362 -0
- package/core/tera-system/Tera_Project_Preparation_Files.md +1045 -0
- package/core/tera-system/agent-helpers/application-blueprint-details.md +177 -0
- package/core/tera-system/client-helpers/tera-client-engagement-discovery-domains.md +99 -0
- package/core/tera-system/client-helpers/tera-client-engagement-gates.md +258 -0
- package/core/tera-system/client-helpers/tera-client-engagement-pricing.md +341 -0
- package/core/tera-system/client-helpers/tera-client-engagement-protocols.md +692 -0
- package/core/tera-system/consulting-helpers/BTCA_METHODOLOGY_FRAMEWORK.md +195 -0
- package/core/tera-system/consulting-helpers/BTCA_REPORT_TEMPLATES.md +266 -0
- package/core/tera-system/design-system/ACCESSIBILITY_RULES.md +31 -0
- package/core/tera-system/design-system/COMPONENT_LIBRARY_SCHEMA.md +46 -0
- package/core/tera-system/design-system/DESIGN_MD_INTEGRATION.md +59 -0
- package/core/tera-system/design-system/DESIGN_REVIEW_STANDARDS.md +241 -0
- package/core/tera-system/design-system/DESIGN_SOURCE_PROTOCOL.md +61 -0
- package/core/tera-system/design-system/DESIGN_SYSTEM_OVERVIEW.md +66 -0
- package/core/tera-system/design-system/DESIGN_TOKENS_SCHEMA.md +66 -0
- package/core/tera-system/design-system/EXTERNAL_REFERENCE_ANALYSIS.md +52 -0
- package/core/tera-system/design-system/FIGMA_INTEGRATION.md +138 -0
- package/core/tera-system/design-system/INTERNAL_KITS_INDEX.md +26 -0
- package/core/tera-system/design-system/LAYOUT_PATTERNS.md +52 -0
- package/core/tera-system/design-system/MOBILE_UI_UX_STANDARDS.md +342 -0
- package/core/tera-system/design-system/RTL_LTR_RULES.md +39 -0
- package/core/tera-system/design-system/UI_ACCEPTANCE_GATE.md +80 -0
- package/core/tera-system/design-system/kits/KIT_ADMIN_DASHBOARD.md +102 -0
- package/core/tera-system/engineering-governance/ENGINEERING_AGENT_RESPONSIBILITIES.md +210 -0
- package/core/tera-system/engineering-governance/ENGINEERING_BEST_PRACTICES.md +468 -0
- package/core/tera-system/engineering-governance/ENGINEERING_GOVERNANCE_GATE.md +131 -0
- package/core/tera-system/engineering-governance/ENGINEERING_REVIEW_CHECKLIST.md +129 -0
- package/core/tera-system/engineering-governance/QUALITY_GATE_THRESHOLDS.md +159 -0
- package/core/tera-system/engineering-helpers/engineering-agent-core.md +171 -0
- package/core/tera-system/knowledge-base/OPENHANDS_ARCHITECTURE_REFERENCE.md +243 -0
- package/core/tera-system/knowledge-base/manufacturing/00_INDEX.md +32 -0
- package/core/tera-system/knowledge-base/manufacturing/01_MANUFACTURING_ERP_CORE_CONCEPTS.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/02_SAP_MANUFACTURING_RESEARCH.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/03_DYNAMICS_365_MANUFACTURING_RESEARCH.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/04_ORACLE_MANUFACTURING_RESEARCH.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/05_ODOO_MANUFACTURING_RESEARCH.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/06_ERPNEXT_MANUFACTURING_RESEARCH.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/07_MANUFACTURING_COSTING_GUIDE.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/08_PRODUCTION_DISCOVERY_QUESTIONS.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/09_MANUFACTURING_BLUEPRINT_CHECKLIST.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/10_PRODUCTION_TEST_SCENARIOS.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/11_QUALITY_REWORK_AND_SCRAP_GUIDE.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/12_MRP_AND_PLANNING_GUIDE.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/13_LOCAL_AND_REGIONAL_MANUFACTURING_CONTEXT.md +7 -0
- package/core/tera-system/knowledge-base/manufacturing/14_VENDOR_COMPARISON_MATRIX.md +7 -0
- package/core/tera-system/product-standards/maintenance-apps/BEST_PRACTICES_DOMAIN.md +325 -0
- package/core/tera-system/product-standards/maintenance-apps/STANDARD_DEFINITION.md +142 -0
- package/core/tera-system/profiles/PROFILES_INDEX.md +57 -0
- package/core/tera-system/profiles/TEMPLATE.md +47 -0
- package/core/tera-system/profiles/dotnet-blazor-ef.md +76 -0
- package/core/tera-system/profiles/dotnet-razorpages-adonet.md +137 -0
- package/core/tera-system/profiles/dotnet-wpf-sqlite.md +159 -0
- package/core/tera-system/profiles/effect-bun-opencode.md +109 -0
- package/core/tera-system/profiles/flutter-mobile.md +369 -0
- package/core/tera-system/profiles/nextjs-prisma.md +110 -0
- package/core/tera-system/profiles/phaser-react-node.md +302 -0
- package/core/tera-system/profiles/react-pwa.md +97 -0
- package/core/tera-system/runtime/CLIENT_DISCOVERY_PROTOCOL.md +145 -0
- package/core/tera-system/runtime/DOMAIN_INTELLIGENCE_PROTOCOL.md +124 -0
- package/core/tera-system/runtime/MVP_DEFINITION_PROTOCOL.md +176 -0
- package/core/tera-system/runtime/TERA_RUNTIME_CHECKLISTS.md +646 -0
- package/core/tera-system/runtime/TERA_RUNTIME_PROTOCOLS.md +50 -0
- package/core/tera-system/runtime/TERA_RUNTIME_PROTOCOLS_CLIENT.md +355 -0
- package/core/tera-system/runtime/TERA_RUNTIME_PROTOCOLS_CORE.md +799 -0
- package/core/tera-system/runtime/TERA_RUNTIME_TEMPLATES.md +908 -0
- package/core/tera-system/runtime/TERA_RUNTIME_TEMPLATES_DELIVERY.md +584 -0
- package/core/tera-system/runtime/TERA_RUNTIME_TEMPLATES_PREPARATION.md +376 -0
- package/core/tera-system/runtime/TERA_SOLUTION_PREPARATION_PROTOCOL.md +335 -0
- package/core/tera-system/runtime/TERA_SOLUTION_PREPARATION_TEMPLATES.md +397 -0
- package/core/tera-system/runtime/VERSION_LIFECYCLE_PROTOCOL.md +296 -0
- package/core/tera-system/semgrep-rules/README.md +32 -0
- package/core/tera-system/semgrep-rules/tera-security.yml +66 -0
- package/core/tera-system/semgrep-rules/tera-standards.yml +49 -0
- package/core/tera-system/teranoo-ui/README.md +48 -0
- package/core/tera-system/teranoo-ui/components/button.tsx +51 -0
- package/core/tera-system/teranoo-ui/components/card.tsx +49 -0
- package/core/tera-system/teranoo-ui/components/dashboard-layout.tsx +36 -0
- package/core/tera-system/teranoo-ui/components/data-table.tsx +146 -0
- package/core/tera-system/teranoo-ui/components/empty-state.tsx +31 -0
- package/core/tera-system/teranoo-ui/components/kpi-card.tsx +42 -0
- package/core/tera-system/teranoo-ui/components/page-header.tsx +25 -0
- package/core/tera-system/teranoo-ui/components/search-input.tsx +40 -0
- package/core/tera-system/teranoo-ui/components/sidebar.tsx +66 -0
- package/core/tera-system/teranoo-ui/components/stats-card.tsx +37 -0
- package/core/tera-system/teranoo-ui/registry.json +77 -0
- package/core/tera-system/teranoo-ui/styles/teranoo-theme.css +61 -0
- package/opencode.tera.example.json +30 -0
- package/package.json +37 -0
- package/scripts/build.mjs +110 -0
- package/scripts/install.js +244 -0
- package/scripts/lib/license.mjs +90 -0
- package/scripts/lib/public-key.pem +3 -0
- package/scripts/tera-license.mjs +63 -0
- package/tools/tera-clean.ps1 +97 -0
- package/tools/tera-fetch.ps1 +165 -0
- package/tools/tera-release.ps1 +96 -0
- package/tools/tera-schedule.ps1 +59 -0
- package/tools/tera-update.ps1 +472 -0
- package/tools/tera-watch.ps1 +154 -0
- package/tools/update-client-repositories.ps1 +92 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# ENGINEERING_AGENT_RESPONSIBILITIES.md
|
|
2
|
+
|
|
3
|
+
## Engineering Governance Responsibilities by Agent
|
|
4
|
+
|
|
5
|
+
| Metadata | |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **Status** | Active responsibility map |
|
|
8
|
+
| **Source** | `ENGINEERING_BEST_PRACTICES.md` |
|
|
9
|
+
| **Last Updated** | 2026-07-04 |
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Purpose
|
|
14
|
+
|
|
15
|
+
This file defines how engineering governance is distributed across Tera and its agents.
|
|
16
|
+
|
|
17
|
+
No single agent reviews everything. Each agent receives the part of the engineering ideals related to its role.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 2. Tera Agent
|
|
22
|
+
|
|
23
|
+
Tera must:
|
|
24
|
+
|
|
25
|
+
- decide the project engineering governance level: Compact / Standard / Full;
|
|
26
|
+
- ensure preparation and execution plans include maintainability constraints;
|
|
27
|
+
- run or reference the Engineering Governance Gate before implementation tasks when applicable;
|
|
28
|
+
- prevent scope expansion and over-engineering;
|
|
29
|
+
- decide when Auditor, Monitor, QA, Security, or other agents are needed;
|
|
30
|
+
- record engineering deviations as issues, decisions, or task review notes.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 3. SolutionArchitectureAgent
|
|
35
|
+
|
|
36
|
+
Must focus on:
|
|
37
|
+
|
|
38
|
+
- module boundaries;
|
|
39
|
+
- layer selection appropriate to project size;
|
|
40
|
+
- service/use-case/domain separation where justified;
|
|
41
|
+
- avoiding enterprise architecture in small projects;
|
|
42
|
+
- documenting architecture decisions and tradeoffs.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 4. EngineeringAgent
|
|
47
|
+
|
|
48
|
+
Must implement according to:
|
|
49
|
+
|
|
50
|
+
- approved module/folder structure;
|
|
51
|
+
- single responsibility;
|
|
52
|
+
- no UI/business logic mixing when avoidable;
|
|
53
|
+
- no random `shared/` or `utils` dumping;
|
|
54
|
+
- active Technology Profile;
|
|
55
|
+
- task Allowed Write Targets;
|
|
56
|
+
- tests when required by the task or important business logic.
|
|
57
|
+
|
|
58
|
+
Must escalate when the existing structure conflicts with the task or would require architectural deviation.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 5. Auditor
|
|
63
|
+
|
|
64
|
+
Auditor (مُدقق) is defined in its own file: `.opencode/agents/auditor.md`.
|
|
65
|
+
|
|
66
|
+
This section only documents the engineering-adjacent boundary.
|
|
67
|
+
|
|
68
|
+
### 5.1 Core methodology
|
|
69
|
+
|
|
70
|
+
Auditor is a Tera-managed quality gate sub-agent. It follows the diff-first, evidence-based methodology defined in `.opencode/agents/auditor.md`:
|
|
71
|
+
|
|
72
|
+
1. Confirm authorized invocation by Tera or Monitor.
|
|
73
|
+
2. Review changed code/files first, then directly affected units.
|
|
74
|
+
3. Verify documentation, Handback, Compliance Record, and available evidence artifacts.
|
|
75
|
+
4. Apply P1/P2 quality checks using `QUALITY_GATE_THRESHOLDS.md`.
|
|
76
|
+
5. Classify findings as STOP / CAUTION / FLAG / BASELINE_DEBT.
|
|
77
|
+
6. Produce a QUAUD report and return it to the orchestrator.
|
|
78
|
+
|
|
79
|
+
### 5.2 Engineering review scope
|
|
80
|
+
|
|
81
|
+
When code or implementation output is in scope, Auditor must review:
|
|
82
|
+
|
|
83
|
+
- module and file structure;
|
|
84
|
+
- oversized or multi-responsibility files;
|
|
85
|
+
- UI/business logic separation;
|
|
86
|
+
- shared/utils misuse;
|
|
87
|
+
- validation, permissions, error handling, and tests relevant to the task;
|
|
88
|
+
- whether deviations are documented.
|
|
89
|
+
|
|
90
|
+
Auditor must not focus only on superficial formatting or minor documentation issues.
|
|
91
|
+
|
|
92
|
+
### 5.3 Audit reports
|
|
93
|
+
|
|
94
|
+
Auditor writes formal reports only under `project-control/audit-reports/` when that path is included in Allowed Write Targets, and returns a summary to the invoking orchestrator.
|
|
95
|
+
|
|
96
|
+
### 5.4 Uncertainty protocol
|
|
97
|
+
|
|
98
|
+
When documentation is missing, sources conflict, or the audit scope is unclear, Auditor must:
|
|
99
|
+
1. Ask the orchestrator for the missing evidence or allowed artifact.
|
|
100
|
+
2. Use external verification only when allowed and relevant.
|
|
101
|
+
3. Return `DEFERRED` or `NEEDS_FIX` when evidence is insufficient.
|
|
102
|
+
4. Never guess or fabricate audit findings.
|
|
103
|
+
|
|
104
|
+
### 5.5 Authority
|
|
105
|
+
|
|
106
|
+
Auditor remains advisory and cannot approve, close, commit, or implement. Findings become executable only when Tera, Monitor, ProjectControlAgent, or Majed converts them into tasks/issues.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 6. Monitor
|
|
111
|
+
|
|
112
|
+
Monitor (رقيب) is defined in its own file: `.opencode/agents/monitor.md`.
|
|
113
|
+
|
|
114
|
+
This section only documents the engineering-adjacent boundary:
|
|
115
|
+
|
|
116
|
+
Monitor is a plan-compliance auditor, not a code quality reviewer. Monitor audit framework is governed by **7 immutable rules** (defined in `.opencode/agents/monitor.md` §5):
|
|
117
|
+
|
|
118
|
+
1. **Plan match** — task exists in batch and master plans.
|
|
119
|
+
2. **Dependencies** — fulfilled before task start.
|
|
120
|
+
3. **Engineering Gate** — ENGINEERING_GOVERNANCE_GATE.md referenced when tasks touch Code/API/DB/UI/Tests.
|
|
121
|
+
4. **Compliance Record** — all 8 items complete in task file.
|
|
122
|
+
5. **Handback vs Git diff** — cross-check using `git diff --name-only`.
|
|
123
|
+
6. **Scope creep** — changed files not linked to any task in current plan.
|
|
124
|
+
7. **Architectural drift** — unplanned modules, APIs, DB, UI not in Master Plan.
|
|
125
|
+
|
|
126
|
+
Monitor has **Plan Rejection Authority** (`.opencode/agents/monitor.md` §6): may reject or request review of a plan when it is missing, ambiguous, contains unlinked tasks, lacks compliance records, or skips engineering governance gates. Final decision rests with Majed.
|
|
127
|
+
|
|
128
|
+
Monitor must not become a general code auditor; detailed code quality review belongs to Auditor and QA.
|
|
129
|
+
|
|
130
|
+
Monitor keeps a working state in `MONITOR_STATE.md` (not a source of truth; no priority over Git or governing records — SCP-2026-08-16-004).
|
|
131
|
+
Monitor findings use `BLOCKING / MATERIAL / NOTE` only — never Auditor's `STOP/CAUTION/FLAG/BASELINE_DEBT`. Monitor never executes fixes.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 7. qa-agent
|
|
136
|
+
|
|
137
|
+
QA must focus on:
|
|
138
|
+
|
|
139
|
+
- testability of important business logic;
|
|
140
|
+
- acceptance criteria coverage;
|
|
141
|
+
- validation and permission behavior from user/API perspective;
|
|
142
|
+
- workflow/status transition correctness;
|
|
143
|
+
- whether missing tests create acceptance risk.
|
|
144
|
+
|
|
145
|
+
QA does not replace SecurityAgent for specialized security review.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## 8. SecurityAgent
|
|
150
|
+
|
|
151
|
+
SecurityAgent must focus on:
|
|
152
|
+
|
|
153
|
+
- permissions enforced beyond UI;
|
|
154
|
+
- auth/session/JWT/cookie/middleware safety;
|
|
155
|
+
- secret handling and redaction;
|
|
156
|
+
- sensitive config;
|
|
157
|
+
- server-side validation for security-sensitive inputs;
|
|
158
|
+
- audit log expectations for sensitive operations.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 9. ProjectControlAgent
|
|
163
|
+
|
|
164
|
+
ProjectControlAgent must ensure:
|
|
165
|
+
|
|
166
|
+
- engineering deviations are recorded;
|
|
167
|
+
- task review findings are linked to `TASK-ID`;
|
|
168
|
+
- issues/gaps have severity, status, and recommended action;
|
|
169
|
+
- decisions are recorded when architecture or maintainability tradeoffs are accepted;
|
|
170
|
+
- project state reflects significant governance changes.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 10. PerformanceAgent
|
|
175
|
+
|
|
176
|
+
PerformanceAgent must focus on:
|
|
177
|
+
|
|
178
|
+
- pagination and bounded queries;
|
|
179
|
+
- indexes for important access paths;
|
|
180
|
+
- heavy reports or dashboards;
|
|
181
|
+
- unnecessary data loading;
|
|
182
|
+
- performance risks without pushing premature optimization.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 11. DesignReviewer
|
|
187
|
+
|
|
188
|
+
DesignReviewer (ناقد) is defined in its own file: `.opencode/agents/design-reviewer.md`.
|
|
189
|
+
DesignReviewer review standards reference: `tera-system/design-system/DESIGN_REVIEW_STANDARDS.md`.
|
|
190
|
+
|
|
191
|
+
This section only documents the engineering-adjacent boundary:
|
|
192
|
+
|
|
193
|
+
DesignReviewer remains visual/design focused. It may report engineering-adjacent issues only when they affect UI consistency or maintainability, such as:
|
|
194
|
+
|
|
195
|
+
- duplicated visual components;
|
|
196
|
+
- inconsistent component variants;
|
|
197
|
+
- layout patterns not following `28_UI_UX_GUIDELINES.md`;
|
|
198
|
+
- UI implementation that makes future visual changes unnecessarily hard.
|
|
199
|
+
|
|
200
|
+
DesignReviewer may build static HTML/CSS prototypes from design sources for visual review when Majed requests. Prototypes are for review only, not production code. Temporary files stored in `project-control/prototypes/` and deleted after approval.
|
|
201
|
+
|
|
202
|
+
DesignReviewer must not become a general code architecture auditor.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 12. Domain Agents
|
|
207
|
+
|
|
208
|
+
Domain agents may recommend workflow, status, approval, or domain-rule structure, but they must not turn external references into implementation scope automatically.
|
|
209
|
+
|
|
210
|
+
Engineering adoption remains Tera's decision.
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
# ENGINEERING_BEST_PRACTICES.md
|
|
2
|
+
|
|
3
|
+
## Tera Engineering Governance Layer — Best Practices
|
|
4
|
+
|
|
5
|
+
| Metadata | |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **Status** | Active system policy |
|
|
8
|
+
| **Source** | Derived from Majed's `temp/Note01.md` / `temp/Developer Best Practice.md` and normalized for Tera governance |
|
|
9
|
+
| **Scope** | All future Tera-managed applications, adjusted by project size and technology profile |
|
|
10
|
+
| **Last Updated** | 2026-07-01 |
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 1. Purpose
|
|
15
|
+
|
|
16
|
+
This file defines Tera's engineering ideals for maintainable application code, architecture, and delivery.
|
|
17
|
+
|
|
18
|
+
The goal is to prevent applications from becoming:
|
|
19
|
+
|
|
20
|
+
- oversized and hard to change;
|
|
21
|
+
- randomly structured;
|
|
22
|
+
- tightly coupled;
|
|
23
|
+
- UI-heavy with hidden business logic;
|
|
24
|
+
- weak in validation, permissions, testing, or error handling;
|
|
25
|
+
- dependent on AI-generated code without governance.
|
|
26
|
+
|
|
27
|
+
This policy is not a license to over-engineer. It must be applied proportionally to the project size, domain risk, approved scope, and active Technology Profile.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 2. Core Principle
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
Every application must be structured for safe change.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Safe change means:
|
|
38
|
+
|
|
39
|
+
- modules are clear;
|
|
40
|
+
- responsibilities are separated;
|
|
41
|
+
- files remain reviewable;
|
|
42
|
+
- business rules are not hidden in UI;
|
|
43
|
+
- validation, permissions, errors, and tests are consistent;
|
|
44
|
+
- database and API changes are traceable;
|
|
45
|
+
- AI agents cannot expand or degrade architecture silently.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 3. Project Size Levels
|
|
50
|
+
|
|
51
|
+
| Level | Use When | Engineering Governance Depth |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| **Compact** | small CRUD / prototype / internal utility | Basic modules, file-size awareness, no random shared/utils, minimal tests for important rules |
|
|
54
|
+
| **Standard** | typical web app with dashboard, API, auth, database | Feature/module structure, service/use-case separation where useful, validation/error/security rules, task-level review |
|
|
55
|
+
| **Full** | ERP, SaaS, multi-role, workflow-heavy, high data/security risk | Layered architecture, domain/application/infrastructure separation, audit logs, integration boundaries, stronger testing and review |
|
|
56
|
+
|
|
57
|
+
Tera decides the level during project preparation and records it in the active application workspace, normally in `project-preparation/08_TECHNICAL_ARCHITECTURE.md` or a project-specific engineering standards file.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 4. Structure by Responsibility
|
|
62
|
+
|
|
63
|
+
Prefer module/feature-oriented structure over random flat folders.
|
|
64
|
+
|
|
65
|
+
Recommended conceptual structure:
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
src/
|
|
69
|
+
core/
|
|
70
|
+
config/
|
|
71
|
+
errors/
|
|
72
|
+
logger/
|
|
73
|
+
security/
|
|
74
|
+
database/
|
|
75
|
+
shared/
|
|
76
|
+
components/
|
|
77
|
+
utils/
|
|
78
|
+
validators/
|
|
79
|
+
types/
|
|
80
|
+
constants/
|
|
81
|
+
modules/
|
|
82
|
+
[module-name]/
|
|
83
|
+
ui/
|
|
84
|
+
application/
|
|
85
|
+
domain/
|
|
86
|
+
infrastructure/
|
|
87
|
+
tests/
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Rules:
|
|
91
|
+
|
|
92
|
+
- Every important business feature belongs to an explicit module.
|
|
93
|
+
- `shared/` contains only code used by more than one module.
|
|
94
|
+
- Module-specific rules must not be moved into `shared/` merely for convenience.
|
|
95
|
+
- Technology-specific folder naming may differ, but responsibility boundaries must remain clear.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 5. File Size and Responsibility
|
|
100
|
+
|
|
101
|
+
Any file approaching roughly `300–400` lines should be reviewed for responsibility creep.
|
|
102
|
+
|
|
103
|
+
Large files are not automatically forbidden, but they are suspicious when they combine:
|
|
104
|
+
|
|
105
|
+
- data fetching;
|
|
106
|
+
- validation;
|
|
107
|
+
- error handling;
|
|
108
|
+
- UI rendering;
|
|
109
|
+
- permissions;
|
|
110
|
+
- formatting;
|
|
111
|
+
- exports;
|
|
112
|
+
- notifications;
|
|
113
|
+
- database operations.
|
|
114
|
+
|
|
115
|
+
Rule:
|
|
116
|
+
|
|
117
|
+
```text
|
|
118
|
+
If a file cannot state its responsibility in one sentence, it must be reviewed.
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 6. Single Responsibility
|
|
124
|
+
|
|
125
|
+
Each file, function, component, class, service, or use case should have one primary reason to change.
|
|
126
|
+
|
|
127
|
+
Bad signal:
|
|
128
|
+
|
|
129
|
+
```text
|
|
130
|
+
createInvoiceAndValidateCustomerAndUpdateStockAndSendEmail()
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Better pattern:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
validateCustomer()
|
|
137
|
+
createInvoice()
|
|
138
|
+
reserveStock()
|
|
139
|
+
sendInvoiceEmail()
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
An application service or use case may coordinate multiple operations, but should not hide every rule inside one large function.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 7. UI and Business Logic Separation
|
|
147
|
+
|
|
148
|
+
UI receives input and displays output. It must not become the owner of business rules.
|
|
149
|
+
|
|
150
|
+
Business logic belongs in one of these areas according to stack and project size:
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
application/
|
|
154
|
+
domain/
|
|
155
|
+
services/
|
|
156
|
+
use-cases/
|
|
157
|
+
rules/
|
|
158
|
+
validators/
|
|
159
|
+
repositories/
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
For example, invoice tax calculation, stock reservation, approval rules, customer credit checks, and permission checks must not be buried inside page components.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 8. DRY With Judgment
|
|
167
|
+
|
|
168
|
+
Do not extract every small duplicate too early.
|
|
169
|
+
|
|
170
|
+
| Repetition | Decision |
|
|
171
|
+
|---:|---|
|
|
172
|
+
| once | leave it |
|
|
173
|
+
| twice | watch it |
|
|
174
|
+
| three times | usually extract |
|
|
175
|
+
| more than three | extract unless there is a clear reason not to |
|
|
176
|
+
|
|
177
|
+
Good shared candidates:
|
|
178
|
+
|
|
179
|
+
- date/currency formatting;
|
|
180
|
+
- common validation;
|
|
181
|
+
- API response helpers;
|
|
182
|
+
- pagination;
|
|
183
|
+
- current-user helpers;
|
|
184
|
+
- permission helpers;
|
|
185
|
+
- logging;
|
|
186
|
+
- upload/export utilities.
|
|
187
|
+
|
|
188
|
+
Forbidden pattern:
|
|
189
|
+
|
|
190
|
+
```text
|
|
191
|
+
shared/utils/ becomes a dumping ground.
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## 9. Naming Conventions
|
|
197
|
+
|
|
198
|
+
Names must express purpose clearly. Generic or vague names are not acceptable.
|
|
199
|
+
|
|
200
|
+
Avoid:
|
|
201
|
+
|
|
202
|
+
```text
|
|
203
|
+
helper
|
|
204
|
+
common
|
|
205
|
+
manager
|
|
206
|
+
data
|
|
207
|
+
process
|
|
208
|
+
handle
|
|
209
|
+
temp
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Guidelines:
|
|
213
|
+
|
|
214
|
+
- Functions/methods use verbs: `calculateTotal`, `validateInput`, `sendInvoiceEmail`.
|
|
215
|
+
- Classes, components, and variables use nouns: `InvoiceService`, `userList`, `PaymentGateway`.
|
|
216
|
+
- Constants use UPPER_SNAKE_CASE: `MAX_RETRY_COUNT`, `DEFAULT_PAGE_SIZE`.
|
|
217
|
+
- Use one consistent style per project (camelCase / PascalCase / snake_case) according to the language.
|
|
218
|
+
- File names should match their primary export or responsibility.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 10. Validation
|
|
223
|
+
|
|
224
|
+
Validation must not exist only in UI.
|
|
225
|
+
|
|
226
|
+
Rules:
|
|
227
|
+
|
|
228
|
+
- UI validation improves user experience.
|
|
229
|
+
- Backend/API/service validation protects the system.
|
|
230
|
+
- Common validators belong in shared validation only when genuinely shared.
|
|
231
|
+
- Module-specific validation stays inside the module.
|
|
232
|
+
- Database constraints are for data integrity; do not move business validation into database constraints unless explicitly approved.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## 11. Error Handling
|
|
237
|
+
|
|
238
|
+
Applications must use consistent error handling instead of ad-hoc messages everywhere.
|
|
239
|
+
|
|
240
|
+
Recommended concepts:
|
|
241
|
+
|
|
242
|
+
```text
|
|
243
|
+
core/errors/
|
|
244
|
+
app-error
|
|
245
|
+
validation-error
|
|
246
|
+
authorization-error
|
|
247
|
+
not-found-error
|
|
248
|
+
error-handler
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
User-facing errors should be consistent and should not expose internal technical details.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## 12. Permissions and Security Enforcement
|
|
256
|
+
|
|
257
|
+
Do not rely on hiding UI buttons as security.
|
|
258
|
+
|
|
259
|
+
Permissions must be enforced where relevant:
|
|
260
|
+
|
|
261
|
+
- frontend for UX;
|
|
262
|
+
- backend/API/server actions for actual enforcement;
|
|
263
|
+
- service/domain layer where business-sensitive rules require it;
|
|
264
|
+
- database policies only when explicitly approved for the stack and deployment model.
|
|
265
|
+
|
|
266
|
+
Examples:
|
|
267
|
+
|
|
268
|
+
```text
|
|
269
|
+
canApproveInvoice(user, invoice)
|
|
270
|
+
canDeleteCustomer(user, customer)
|
|
271
|
+
canViewCost(user)
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## 13. Configuration and Secrets
|
|
277
|
+
|
|
278
|
+
Configuration must be centralized and environment-aware.
|
|
279
|
+
|
|
280
|
+
Rules:
|
|
281
|
+
|
|
282
|
+
- Do not scatter URLs, sizes, currencies, or flags across the codebase.
|
|
283
|
+
- Real secrets must never be written into source code, project-control records, task files, logs, handbacks, or fallback config values.
|
|
284
|
+
- Use `.env`, environment variables, or approved local secret storage only.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## 14. Logging and Audit
|
|
289
|
+
|
|
290
|
+
Do not log everything, but important actions must be traceable.
|
|
291
|
+
|
|
292
|
+
Relevant events include:
|
|
293
|
+
|
|
294
|
+
- failed login attempts;
|
|
295
|
+
- deletes;
|
|
296
|
+
- approvals;
|
|
297
|
+
- permission changes;
|
|
298
|
+
- sensitive business operations;
|
|
299
|
+
- API errors;
|
|
300
|
+
- integration failures;
|
|
301
|
+
- system exceptions.
|
|
302
|
+
|
|
303
|
+
For ERP and administration-heavy systems, Audit Log is often essential.
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## 15. Database Design and Migrations
|
|
308
|
+
|
|
309
|
+
Database design must be traceable and consistent.
|
|
310
|
+
|
|
311
|
+
Rules:
|
|
312
|
+
|
|
313
|
+
- names are clear and consistent;
|
|
314
|
+
- relations use explicit IDs / foreign keys where supported;
|
|
315
|
+
- indexes exist for important search/filter paths;
|
|
316
|
+
- status values are explicit enums or reference records;
|
|
317
|
+
- created/updated metadata exists when useful;
|
|
318
|
+
- soft delete is considered for sensitive administrative data;
|
|
319
|
+
- schema changes use migrations or the approved stack-specific equivalent;
|
|
320
|
+
- no manual production database changes without trace.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## 16. API Design
|
|
325
|
+
|
|
326
|
+
APIs should be predictable and consistent.
|
|
327
|
+
|
|
328
|
+
Rules:
|
|
329
|
+
|
|
330
|
+
- endpoint naming is stable;
|
|
331
|
+
- responses have a consistent shape;
|
|
332
|
+
- errors have a consistent format;
|
|
333
|
+
- pagination/filtering/sorting are explicit when needed;
|
|
334
|
+
- versioning is used only when needed;
|
|
335
|
+
- API changes must not silently break planned consumers.
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## 17. External Integration
|
|
340
|
+
|
|
341
|
+
When integrating with external services, the system must remain resilient.
|
|
342
|
+
|
|
343
|
+
Requirements:
|
|
344
|
+
|
|
345
|
+
- Define explicit timeouts for every external call.
|
|
346
|
+
- Implement limited retry with backoff for transient failures.
|
|
347
|
+
- Handle service outages gracefully: fail with a clear user message instead of crashing.
|
|
348
|
+
- Use Circuit Breaker or equivalent pattern when the external service is critical and failure-prone.
|
|
349
|
+
- Never rely on external service availability without fallback or clear user feedback.
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## 18. Idempotency and Concurrency
|
|
354
|
+
|
|
355
|
+
Operations that create side effects (payments, invoices, stock deductions, order confirmations) must be safe to retry.
|
|
356
|
+
|
|
357
|
+
Design principles:
|
|
358
|
+
|
|
359
|
+
- Use idempotency keys or request IDs for sensitive write operations.
|
|
360
|
+
- Handle race conditions on shared records using optimistic locking, transactions, or explicit locks.
|
|
361
|
+
- Prevent double processing when the same request arrives more than once.
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## 19. Testing
|
|
366
|
+
|
|
367
|
+
Testing must focus on important risk, not test-count vanity.
|
|
368
|
+
|
|
369
|
+
Default priorities:
|
|
370
|
+
|
|
371
|
+
- Unit tests for business rules and calculations.
|
|
372
|
+
- Integration/API tests for workflows and endpoints.
|
|
373
|
+
- UI/E2E tests only where they provide real confidence and cost is justified.
|
|
374
|
+
|
|
375
|
+
Examples that often need tests:
|
|
376
|
+
|
|
377
|
+
- permissions;
|
|
378
|
+
- approvals/status transitions;
|
|
379
|
+
- invoice/tax/stock calculations;
|
|
380
|
+
- validation rules;
|
|
381
|
+
- deletion prevention;
|
|
382
|
+
- negative quantity prevention;
|
|
383
|
+
- critical API behavior.
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## 20. Documentation and Decisions
|
|
388
|
+
|
|
389
|
+
Projects do not need bloated documentation, but they need governing documentation.
|
|
390
|
+
|
|
391
|
+
Recommended project-level documents when justified:
|
|
392
|
+
|
|
393
|
+
```text
|
|
394
|
+
ARCHITECTURE.md
|
|
395
|
+
CODING_STANDARDS.md
|
|
396
|
+
DATABASE_GUIDELINES.md
|
|
397
|
+
API_GUIDELINES.md
|
|
398
|
+
TESTING_GUIDELINES.md
|
|
399
|
+
SECURITY_GUIDELINES.md
|
|
400
|
+
DECISIONS.md
|
|
401
|
+
CHANGELOG.md
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Within Tera-managed projects, these may be represented by project-preparation and project-control files instead of literal docs, unless the application needs standalone engineering docs.
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## 21. Git and CI/CD
|
|
409
|
+
|
|
410
|
+
Rules:
|
|
411
|
+
|
|
412
|
+
- commits should be small and understandable;
|
|
413
|
+
- one commit should not mix unrelated topics;
|
|
414
|
+
- never commit secrets or local temporary files;
|
|
415
|
+
- at minimum, important projects should support lint/test/build checks before release;
|
|
416
|
+
- CI/CD complexity must match project size.
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## 22. Performance
|
|
421
|
+
|
|
422
|
+
Avoid premature optimization, but prevent obvious structural performance mistakes.
|
|
423
|
+
|
|
424
|
+
Watch for:
|
|
425
|
+
|
|
426
|
+
- screens loading thousands of records without pagination;
|
|
427
|
+
- missing indexes on common filters;
|
|
428
|
+
- heavy reports without bounded queries;
|
|
429
|
+
- unnecessary data fetching;
|
|
430
|
+
- unoptimized images;
|
|
431
|
+
- expensive operations hidden in UI rendering.
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## 23. AI Governance
|
|
436
|
+
|
|
437
|
+
AI-generated work must be constrained by official project files and task scope.
|
|
438
|
+
|
|
439
|
+
Agents must:
|
|
440
|
+
|
|
441
|
+
1. understand the approved structure before changing code;
|
|
442
|
+
2. not create duplicate files or folders;
|
|
443
|
+
3. not edit outside the task scope;
|
|
444
|
+
4. not break APIs silently;
|
|
445
|
+
5. not change database structure without a schema/migration task;
|
|
446
|
+
6. add tests when important logic changes;
|
|
447
|
+
7. update or request documentation updates when behavior changes;
|
|
448
|
+
8. report exactly what files were changed;
|
|
449
|
+
9. explain the purpose and impact of each modified file;
|
|
450
|
+
10. record important decisions when the task introduces architectural or behavioral changes;
|
|
451
|
+
11. identify and communicate risks before executing potentially destructive operations (deletions, bulk changes, permission changes, or data migrations).
|
|
452
|
+
|
|
453
|
+
---
|
|
454
|
+
|
|
455
|
+
## 24. The Twelve Non-Negotiables
|
|
456
|
+
|
|
457
|
+
1. Use clear modules.
|
|
458
|
+
2. Separate business logic from UI.
|
|
459
|
+
3. Prevent oversized files.
|
|
460
|
+
4. Extract shared code carefully, not blindly.
|
|
461
|
+
5. Test important business logic.
|
|
462
|
+
6. Enforce permissions beyond the frontend.
|
|
463
|
+
7. Use consistent error handling and logging.
|
|
464
|
+
8. Record important architecture decisions.
|
|
465
|
+
9. Use migrations or traceable database changes.
|
|
466
|
+
10. Govern AI-generated code with task scope, gates, and review.
|
|
467
|
+
11. Protect secrets: never store passwords, tokens, API keys, or credentials in source code, task files, logs, or handbacks.
|
|
468
|
+
12. Do not break existing API contracts without justification and documented migration.
|