@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.
Files changed (161) hide show
  1. package/LICENSE.md +13 -0
  2. package/MANIFEST.json +24 -0
  3. package/README.md +67 -0
  4. package/RELEASES.md +28 -0
  5. package/WELCOME.md +35 -0
  6. package/agents/application-blueprint.md +407 -0
  7. package/agents/auditor.md +665 -0
  8. package/agents/design-reviewer.md +392 -0
  9. package/agents/domain-expert-agent.md +510 -0
  10. package/agents/domain-research-agent.md +360 -0
  11. package/agents/engineering-agent-dotnet.md +218 -0
  12. package/agents/engineering-agent-phaser.md +275 -0
  13. package/agents/engineering-agent-typescript.md +300 -0
  14. package/agents/engineering-agent.md +143 -0
  15. package/agents/monitor.md +395 -0
  16. package/agents/production-erp-expert.md +506 -0
  17. package/agents/project-knowledge-agent.md +271 -0
  18. package/agents/qa-agent.md +498 -0
  19. package/agents/tera-business-transformation-consultant.md +290 -0
  20. package/agents/tera-client-engagement.md +891 -0
  21. package/agents/tera-software-designer.md +237 -0
  22. package/agents/tera-strategic-advisor.md +325 -0
  23. package/agents/tera-system-evolution.md +759 -0
  24. package/agents/tera.md +520 -0
  25. package/agents/ui-designer.md +426 -0
  26. package/commands/tera-approve.md +34 -0
  27. package/commands/tera-diagnose.md +47 -0
  28. package/commands/tera-gate.md +40 -0
  29. package/commands/tera-help.md +41 -0
  30. package/commands/tera-new-project.md +35 -0
  31. package/commands/tera-plan.md +34 -0
  32. package/commands/tera-request-build.md +45 -0
  33. package/commands/tera-resume.md +34 -0
  34. package/commands/tera-review.md +52 -0
  35. package/commands/tera-status.md +38 -0
  36. package/commands/tera-update.md +48 -0
  37. package/core/project-control/templates/TASK_TEMPLATE.md +146 -0
  38. package/core/tera-system/AGENT_ACTIVATION_MATRIX.md +285 -0
  39. package/core/tera-system/AGENT_DEPENDENCY_MAP.md +117 -0
  40. package/core/tera-system/AGENT_GENERATION_TEMPLATE.md +312 -0
  41. package/core/tera-system/AGENT_PERMISSION_MODEL.md +343 -0
  42. package/core/tera-system/AIS_PROTOCOL.md +191 -0
  43. package/core/tera-system/TERA_AGENT_CONDUCT.md +102 -0
  44. package/core/tera-system/TERA_CONTINUOUS_IMPROVEMENT_POLICY.md +111 -0
  45. package/core/tera-system/TERA_DISTRIBUTION_POLICY.md +291 -0
  46. package/core/tera-system/TERA_PROJECT_DECISION.md +281 -0
  47. package/core/tera-system/TERA_USER_GUIDE.md +462 -0
  48. package/core/tera-system/TOOLING_AND_MCP_POLICY.md +285 -0
  49. package/core/tera-system/TeraApplicationQuestionBank.md +362 -0
  50. package/core/tera-system/TeraArchitectureMap.md +91 -0
  51. package/core/tera-system/TeraClientPolicy.md +366 -0
  52. package/core/tera-system/TeraHelperAgents.md +970 -0
  53. package/core/tera-system/TeraPolicyMap.md +131 -0
  54. package/core/tera-system/TeraPreExecutionGate.md +818 -0
  55. package/core/tera-system/TeraPreparationDocumentationGovernance.md +370 -0
  56. package/core/tera-system/TeraPricingPolicy.md +674 -0
  57. package/core/tera-system/TeraProjectIntakePolicy.md +164 -0
  58. package/core/tera-system/TeraScenarioStressTests.md +168 -0
  59. package/core/tera-system/TeraSubAgents.md +854 -0
  60. package/core/tera-system/TeraSystemMaintenanceChecklist.md +80 -0
  61. package/core/tera-system/TeraTokenPolicy.md +362 -0
  62. package/core/tera-system/Tera_Project_Preparation_Files.md +1045 -0
  63. package/core/tera-system/agent-helpers/application-blueprint-details.md +177 -0
  64. package/core/tera-system/client-helpers/tera-client-engagement-discovery-domains.md +99 -0
  65. package/core/tera-system/client-helpers/tera-client-engagement-gates.md +258 -0
  66. package/core/tera-system/client-helpers/tera-client-engagement-pricing.md +341 -0
  67. package/core/tera-system/client-helpers/tera-client-engagement-protocols.md +692 -0
  68. package/core/tera-system/consulting-helpers/BTCA_METHODOLOGY_FRAMEWORK.md +195 -0
  69. package/core/tera-system/consulting-helpers/BTCA_REPORT_TEMPLATES.md +266 -0
  70. package/core/tera-system/design-system/ACCESSIBILITY_RULES.md +31 -0
  71. package/core/tera-system/design-system/COMPONENT_LIBRARY_SCHEMA.md +46 -0
  72. package/core/tera-system/design-system/DESIGN_MD_INTEGRATION.md +59 -0
  73. package/core/tera-system/design-system/DESIGN_REVIEW_STANDARDS.md +241 -0
  74. package/core/tera-system/design-system/DESIGN_SOURCE_PROTOCOL.md +61 -0
  75. package/core/tera-system/design-system/DESIGN_SYSTEM_OVERVIEW.md +66 -0
  76. package/core/tera-system/design-system/DESIGN_TOKENS_SCHEMA.md +66 -0
  77. package/core/tera-system/design-system/EXTERNAL_REFERENCE_ANALYSIS.md +52 -0
  78. package/core/tera-system/design-system/FIGMA_INTEGRATION.md +138 -0
  79. package/core/tera-system/design-system/INTERNAL_KITS_INDEX.md +26 -0
  80. package/core/tera-system/design-system/LAYOUT_PATTERNS.md +52 -0
  81. package/core/tera-system/design-system/MOBILE_UI_UX_STANDARDS.md +342 -0
  82. package/core/tera-system/design-system/RTL_LTR_RULES.md +39 -0
  83. package/core/tera-system/design-system/UI_ACCEPTANCE_GATE.md +80 -0
  84. package/core/tera-system/design-system/kits/KIT_ADMIN_DASHBOARD.md +102 -0
  85. package/core/tera-system/engineering-governance/ENGINEERING_AGENT_RESPONSIBILITIES.md +210 -0
  86. package/core/tera-system/engineering-governance/ENGINEERING_BEST_PRACTICES.md +468 -0
  87. package/core/tera-system/engineering-governance/ENGINEERING_GOVERNANCE_GATE.md +131 -0
  88. package/core/tera-system/engineering-governance/ENGINEERING_REVIEW_CHECKLIST.md +129 -0
  89. package/core/tera-system/engineering-governance/QUALITY_GATE_THRESHOLDS.md +159 -0
  90. package/core/tera-system/engineering-helpers/engineering-agent-core.md +171 -0
  91. package/core/tera-system/knowledge-base/OPENHANDS_ARCHITECTURE_REFERENCE.md +243 -0
  92. package/core/tera-system/knowledge-base/manufacturing/00_INDEX.md +32 -0
  93. package/core/tera-system/knowledge-base/manufacturing/01_MANUFACTURING_ERP_CORE_CONCEPTS.md +7 -0
  94. package/core/tera-system/knowledge-base/manufacturing/02_SAP_MANUFACTURING_RESEARCH.md +7 -0
  95. package/core/tera-system/knowledge-base/manufacturing/03_DYNAMICS_365_MANUFACTURING_RESEARCH.md +7 -0
  96. package/core/tera-system/knowledge-base/manufacturing/04_ORACLE_MANUFACTURING_RESEARCH.md +7 -0
  97. package/core/tera-system/knowledge-base/manufacturing/05_ODOO_MANUFACTURING_RESEARCH.md +7 -0
  98. package/core/tera-system/knowledge-base/manufacturing/06_ERPNEXT_MANUFACTURING_RESEARCH.md +7 -0
  99. package/core/tera-system/knowledge-base/manufacturing/07_MANUFACTURING_COSTING_GUIDE.md +7 -0
  100. package/core/tera-system/knowledge-base/manufacturing/08_PRODUCTION_DISCOVERY_QUESTIONS.md +7 -0
  101. package/core/tera-system/knowledge-base/manufacturing/09_MANUFACTURING_BLUEPRINT_CHECKLIST.md +7 -0
  102. package/core/tera-system/knowledge-base/manufacturing/10_PRODUCTION_TEST_SCENARIOS.md +7 -0
  103. package/core/tera-system/knowledge-base/manufacturing/11_QUALITY_REWORK_AND_SCRAP_GUIDE.md +7 -0
  104. package/core/tera-system/knowledge-base/manufacturing/12_MRP_AND_PLANNING_GUIDE.md +7 -0
  105. package/core/tera-system/knowledge-base/manufacturing/13_LOCAL_AND_REGIONAL_MANUFACTURING_CONTEXT.md +7 -0
  106. package/core/tera-system/knowledge-base/manufacturing/14_VENDOR_COMPARISON_MATRIX.md +7 -0
  107. package/core/tera-system/product-standards/maintenance-apps/BEST_PRACTICES_DOMAIN.md +325 -0
  108. package/core/tera-system/product-standards/maintenance-apps/STANDARD_DEFINITION.md +142 -0
  109. package/core/tera-system/profiles/PROFILES_INDEX.md +57 -0
  110. package/core/tera-system/profiles/TEMPLATE.md +47 -0
  111. package/core/tera-system/profiles/dotnet-blazor-ef.md +76 -0
  112. package/core/tera-system/profiles/dotnet-razorpages-adonet.md +137 -0
  113. package/core/tera-system/profiles/dotnet-wpf-sqlite.md +159 -0
  114. package/core/tera-system/profiles/effect-bun-opencode.md +109 -0
  115. package/core/tera-system/profiles/flutter-mobile.md +369 -0
  116. package/core/tera-system/profiles/nextjs-prisma.md +110 -0
  117. package/core/tera-system/profiles/phaser-react-node.md +302 -0
  118. package/core/tera-system/profiles/react-pwa.md +97 -0
  119. package/core/tera-system/runtime/CLIENT_DISCOVERY_PROTOCOL.md +145 -0
  120. package/core/tera-system/runtime/DOMAIN_INTELLIGENCE_PROTOCOL.md +124 -0
  121. package/core/tera-system/runtime/MVP_DEFINITION_PROTOCOL.md +176 -0
  122. package/core/tera-system/runtime/TERA_RUNTIME_CHECKLISTS.md +646 -0
  123. package/core/tera-system/runtime/TERA_RUNTIME_PROTOCOLS.md +50 -0
  124. package/core/tera-system/runtime/TERA_RUNTIME_PROTOCOLS_CLIENT.md +355 -0
  125. package/core/tera-system/runtime/TERA_RUNTIME_PROTOCOLS_CORE.md +799 -0
  126. package/core/tera-system/runtime/TERA_RUNTIME_TEMPLATES.md +908 -0
  127. package/core/tera-system/runtime/TERA_RUNTIME_TEMPLATES_DELIVERY.md +584 -0
  128. package/core/tera-system/runtime/TERA_RUNTIME_TEMPLATES_PREPARATION.md +376 -0
  129. package/core/tera-system/runtime/TERA_SOLUTION_PREPARATION_PROTOCOL.md +335 -0
  130. package/core/tera-system/runtime/TERA_SOLUTION_PREPARATION_TEMPLATES.md +397 -0
  131. package/core/tera-system/runtime/VERSION_LIFECYCLE_PROTOCOL.md +296 -0
  132. package/core/tera-system/semgrep-rules/README.md +32 -0
  133. package/core/tera-system/semgrep-rules/tera-security.yml +66 -0
  134. package/core/tera-system/semgrep-rules/tera-standards.yml +49 -0
  135. package/core/tera-system/teranoo-ui/README.md +48 -0
  136. package/core/tera-system/teranoo-ui/components/button.tsx +51 -0
  137. package/core/tera-system/teranoo-ui/components/card.tsx +49 -0
  138. package/core/tera-system/teranoo-ui/components/dashboard-layout.tsx +36 -0
  139. package/core/tera-system/teranoo-ui/components/data-table.tsx +146 -0
  140. package/core/tera-system/teranoo-ui/components/empty-state.tsx +31 -0
  141. package/core/tera-system/teranoo-ui/components/kpi-card.tsx +42 -0
  142. package/core/tera-system/teranoo-ui/components/page-header.tsx +25 -0
  143. package/core/tera-system/teranoo-ui/components/search-input.tsx +40 -0
  144. package/core/tera-system/teranoo-ui/components/sidebar.tsx +66 -0
  145. package/core/tera-system/teranoo-ui/components/stats-card.tsx +37 -0
  146. package/core/tera-system/teranoo-ui/registry.json +77 -0
  147. package/core/tera-system/teranoo-ui/styles/teranoo-theme.css +61 -0
  148. package/opencode.tera.example.json +30 -0
  149. package/package.json +37 -0
  150. package/scripts/build.mjs +110 -0
  151. package/scripts/install.js +244 -0
  152. package/scripts/lib/license.mjs +90 -0
  153. package/scripts/lib/public-key.pem +3 -0
  154. package/scripts/tera-license.mjs +63 -0
  155. package/tools/tera-clean.ps1 +97 -0
  156. package/tools/tera-fetch.ps1 +165 -0
  157. package/tools/tera-release.ps1 +96 -0
  158. package/tools/tera-schedule.ps1 +59 -0
  159. package/tools/tera-update.ps1 +472 -0
  160. package/tools/tera-watch.ps1 +154 -0
  161. package/tools/update-client-repositories.ps1 +92 -0
@@ -0,0 +1,131 @@
1
+ # ENGINEERING_GOVERNANCE_GATE.md
2
+
3
+ ## Tera Engineering Governance Gate
4
+
5
+ | Metadata | |
6
+ |---|---|
7
+ | **Status** | Active system gate |
8
+ | **Source** | `tera-system/engineering-governance/ENGINEERING_BEST_PRACTICES.md` |
9
+ | **Used By** | Tera Pre-Execution Gate, Post-Execution Review, Engineering agents, Auditor, Monitor, QA |
10
+ | **Last Updated** | 2026-07-01 |
11
+
12
+ ---
13
+
14
+ ## 1. Purpose
15
+
16
+ This gate turns engineering best practices into operational checks before and after implementation tasks.
17
+
18
+ It does not replace:
19
+
20
+ - `TeraPreExecutionGate.md`;
21
+ - active Technology Profiles;
22
+ - Design Governance;
23
+ - Security review;
24
+ - QA acceptance review.
25
+
26
+ It adds maintainability and architecture checks to prevent structural decay.
27
+
28
+ ---
29
+
30
+ ## 2. When the Gate Applies
31
+
32
+ Apply this gate when a task creates or modifies any of the following:
33
+
34
+ - application source code;
35
+ - modules/features;
36
+ - UI components with logic;
37
+ - API/server actions/controllers;
38
+ - services/use cases/domain rules;
39
+ - validation logic;
40
+ - permissions/security checks;
41
+ - database schema/migrations/repositories;
42
+ - shared utilities/components;
43
+ - tests;
44
+ - architecture or coding standards.
45
+
46
+ For documentation-only edits, apply only if the document defines engineering rules.
47
+
48
+ ---
49
+
50
+ ## 3. Project Size Adjustment
51
+
52
+ | Project Level | Gate Strictness |
53
+ |---|---|
54
+ | Compact | Check obvious bloat, module clarity, no UI/business logic mixing for important rules |
55
+ | Standard | Check module boundaries, service/use-case separation, validation, permissions, tests when needed |
56
+ | Full | Check layered architecture, cross-module coupling, audit/logging, performance, integration boundaries, stronger tests |
57
+
58
+ Do not force Full architecture on Compact projects unless approved by Tera and the user.
59
+
60
+ ---
61
+
62
+ ## 4. Pre-Execution Checks
63
+
64
+ Before approving or delegating an implementation task, Tera must verify:
65
+
66
+ | # | Check | Required Result |
67
+ |---|---|---|
68
+ | 1 | Does the task identify the affected module or shared/core area? | Yes / N/A |
69
+ | 2 | Is the task small enough to avoid architectural mixing? | Yes |
70
+ | 3 | Could the task create a file likely to exceed responsibility or size limits? | No / Mitigated |
71
+ | 4 | Is business logic kept out of UI where applicable? | Yes / N/A |
72
+ | 5 | Is module-specific logic kept out of `shared/`? | Yes / N/A |
73
+ | 6 | Are validation rules placed at the correct layer? | Yes / N/A |
74
+ | 7 | Are permissions enforced outside frontend when relevant? | Yes / N/A |
75
+ | 8 | Are database changes traceable through the approved migration/schema task path? | Yes / N/A |
76
+ | 9 | Are API response/error expectations consistent with the project? | Yes / N/A |
77
+ | 10 | Are tests required for important logic? If yes, are they in scope or deferred with reason? | Yes / N/A |
78
+ | 11 | Does the task avoid unnecessary libraries, folders, abstractions, or docs? | Yes |
79
+ | 12 | Does the task reference active Technology Profile rules when stack-specific structure matters? | Yes / N/A |
80
+ | 13 | Does the task introduce generic or vague naming patterns (`helper`, `common`, `manager`, `data`)? | No / N/A |
81
+ | 14 | If the task involves external API calls, are timeout and error-handling defined? | Yes / N/A |
82
+ | 15 | If the task involves sensitive write operations (payment, order, invoice), is idempotency considered? | Yes / N/A |
83
+
84
+ If a required check fails, the task cannot receive `Pre-Execution Gate: PASS` until corrected, split, or explicitly approved as a documented exception.
85
+
86
+ ---
87
+
88
+ ## 5. Post-Execution Checks
89
+
90
+ Before accepting or closing an implementation task, Tera or an independent reviewer must verify:
91
+
92
+ | # | Check | Required Result |
93
+ |---|---|---|
94
+ | 1 | Changed files are in the approved module/shared/core targets. | Yes |
95
+ | 2 | No file became obviously multi-responsibility or oversized without reason. | Yes |
96
+ | 3 | UI code did not absorb business rules that belong in services/use cases/domain. | Yes / N/A |
97
+ | 4 | Shared utilities/components were not used as dumping grounds. | Yes |
98
+ | 5 | Validation exists at backend/service/API layer when required. | Yes / N/A |
99
+ | 6 | Permissions are not frontend-only when security matters. | Yes / N/A |
100
+ | 7 | Database changes match the approved schema/migration scope. | Yes / N/A |
101
+ | 8 | API/error behavior is consistent with project standards. | Yes / N/A |
102
+ | 9 | Important logic has tests, or missing tests are recorded as an issue/deferred item. | Yes / Deferred with reason |
103
+ | 10 | No unnecessary abstractions, libraries, or folders were introduced. | Yes |
104
+ | 11 | Any engineering deviation is recorded in task review, `ISSUES_AND_GAPS.md`, or `DECISIONS_LOG.md` as appropriate. | Yes / N/A |
105
+ | 12 | New or changed files follow clear naming conventions without generic dumping-ground names. | Yes / N/A |
106
+ | 13 | External service integrations handle timeouts, retries, and failure gracefully. | Yes / N/A |
107
+ | 14 | Sensitive write operations are idempotent or implement deduplication. | Yes / N/A |
108
+
109
+ ---
110
+
111
+ ## 6. Failure Results
112
+
113
+ | Result | Meaning | Required Action |
114
+ |---|---|---|
115
+ | PASS | Engineering structure is acceptable for the project level | Continue review/acceptance path |
116
+ | NEEDS_FIX | Issue can be corrected within same task scope | Return to responsible agent with exact fixes |
117
+ | BLOCKED | Requires user/Tera decision, architecture change, or task split | Stop affected task and record blocker |
118
+ | DEFERRED_WITH_RECORD | Not blocking now, but must be tracked | Record in `ISSUES_AND_GAPS.md` or future task |
119
+
120
+ ---
121
+
122
+ ## 7. Exception Rule
123
+
124
+ Engineering ideals may be relaxed only when:
125
+
126
+ - the project is intentionally Compact;
127
+ - the task is a limited scaffold or spike;
128
+ - the exception is temporary and recorded;
129
+ - Tera documents the reason and follow-up if needed.
130
+
131
+ Unrecorded exceptions are not valid.
@@ -0,0 +1,129 @@
1
+ # ENGINEERING_REVIEW_CHECKLIST.md
2
+
3
+ ## Engineering Review Checklist
4
+
5
+ | Metadata | |
6
+ |---|---|
7
+ | **Status** | Active checklist |
8
+ | **Used By** | Auditor, Tera, Monitor, QA, Engineering reviewers |
9
+ | **Source** | `ENGINEERING_BEST_PRACTICES.md` + `ENGINEERING_GOVERNANCE_GATE.md` |
10
+ | **Last Updated** | 2026-07-01 |
11
+
12
+ ---
13
+
14
+ ## 1. Review Scope
15
+
16
+ Use this checklist when reviewing code, implementation batches, task outputs, or release readiness.
17
+
18
+ Review only the relevant areas. Do not expand a small review into a full audit unless Tera or the owner asks for it.
19
+
20
+ ---
21
+
22
+ ## 2. Architecture and Structure
23
+
24
+ - [ ] Modules/features are clear.
25
+ - [ ] Code is not organized only by random generic folders.
26
+ - [ ] `core/`, `shared/`, and `modules/` boundaries are respected where applicable.
27
+ - [ ] Module-specific logic is not placed in `shared/`.
28
+ - [ ] Cross-module dependencies are intentional and not circular/random.
29
+ - [ ] New abstractions are justified by current need, not speculation.
30
+
31
+ ---
32
+
33
+ ## 3. File and Responsibility Health
34
+
35
+ - [ ] No changed file is clearly handling unrelated responsibilities.
36
+ - [ ] Files approaching `300–400` lines are reviewed for responsibility creep.
37
+ - [ ] Functions/components have clear names and one primary purpose.
38
+ - [ ] Large orchestration functions are split into readable operations when useful.
39
+
40
+ ---
41
+
42
+ ## 4. UI / Application / Domain Separation
43
+
44
+ - [ ] UI components are not owners of business rules.
45
+ - [ ] Important business operations live in services/use cases/domain/rules according to project size.
46
+ - [ ] Data mapping/formatting is separated when it becomes non-trivial.
47
+ - [ ] UI changes do not introduce hidden API/security/database behavior.
48
+
49
+ ---
50
+
51
+ ## 5. Shared Code and DRY
52
+
53
+ - [ ] Shared code is genuinely shared by more than one module.
54
+ - [ ] No `utils` dumping ground was created or expanded without structure.
55
+ - [ ] Duplicate logic is left, watched, or extracted according to practical repetition and risk.
56
+ - [ ] Extracted helpers have clear names and narrow responsibility.
57
+
58
+ ---
59
+
60
+ ## 6. Validation, Errors, and Permissions
61
+
62
+ - [ ] Validation is not frontend-only when data integrity matters.
63
+ - [ ] Backend/API/service validation exists for important inputs.
64
+ - [ ] Error format and messages follow project conventions.
65
+ - [ ] Permissions are enforced beyond UI hiding when security matters.
66
+ - [ ] Security-sensitive changes are escalated to SecurityAgent or Tera as required.
67
+
68
+ ---
69
+
70
+ ## 7. Database and API
71
+
72
+ - [ ] Database schema changes match the approved task and migration strategy.
73
+ - [ ] No manual or untraceable database change is implied.
74
+ - [ ] Naming and relations are clear.
75
+ - [ ] Indexes/pagination are considered for important query paths.
76
+ - [ ] API response and error behavior is consistent.
77
+
78
+ ---
79
+
80
+ ## 8. Testing and Acceptance
81
+
82
+ - [ ] Important business rules have tests or a documented reason for deferral.
83
+ - [ ] Permission and validation behavior is testable.
84
+ - [ ] API or integration behavior has appropriate verification.
85
+ - [ ] UI/E2E tests are used only when they add justified confidence.
86
+ - [ ] Acceptance criteria are mapped to actual output.
87
+
88
+ ---
89
+
90
+ ## 9. Documentation and Decisions
91
+
92
+ - [ ] Architecture-affecting changes are documented.
93
+ - [ ] Deviations are recorded in `DECISIONS_LOG.md` or task review notes.
94
+ - [ ] Risks/gaps are recorded in `ISSUES_AND_GAPS.md`.
95
+ - [ ] The task handback names changed files and meaningful decisions.
96
+
97
+ ---
98
+
99
+ ## 10. Naming and Code Standards
100
+
101
+ - [ ] File, function, and variable names express purpose clearly.
102
+ - [ ] No generic names like `helper`, `common`, `manager`, `data`, `process`, or `handle`.
103
+ - [ ] Naming style is consistent within the project (camelCase / PascalCase / snake_case).
104
+ - [ ] File names match their primary export or responsibility.
105
+
106
+ ---
107
+
108
+ ## 11. External Integration and Idempotency
109
+
110
+ - [ ] External calls have explicit timeouts and retry limits.
111
+ - [ ] Service failures are handled gracefully without crashing the system.
112
+ - [ ] Sensitive write operations (payments, orders, invoices) are idempotent or use request-id deduplication.
113
+ - [ ] Race conditions on shared records are handled with locking or transactions.
114
+
115
+ ---
116
+
117
+ ## 12. Review Output Classification
118
+
119
+ Classify every finding as one of:
120
+
121
+ | Classification | Meaning |
122
+ |---|---|
123
+ | Must Fix Now | Blocks acceptance or creates serious maintainability/security risk |
124
+ | Should Fix Soon | Important but can be scheduled safely |
125
+ | Defer With Record | Not blocking current phase, must be tracked |
126
+ | Observation | Useful note, no action required now |
127
+ | Not Applicable | Outside current review scope |
128
+
129
+ Auditors and reviewers must not turn every observation into a blocking issue.
@@ -0,0 +1,159 @@
1
+ <!-- © 2026 Majed Khaireddin (Alabasi1980). Tera System — Proprietary. All rights reserved. -->
2
+
3
+ # QUALITY_GATE_THRESHOLDS.md
4
+
5
+ ## 1. Purpose
6
+
7
+ This file defines default quality-gate rule classes, evidence requirements, and P1/P2 thresholds for Auditor.
8
+
9
+ It is a reference for `.opencode/agents/auditor.md` and must not be treated as a universal automatic pass/fail table.
10
+
11
+ Core rule:
12
+
13
+ ```text
14
+ Threshold exceeded = finding candidate.
15
+ Severity depends on impact, context, confidence, evidence quality, and whether the issue is new in the diff.
16
+ ```
17
+
18
+ ## 2. Rule Classes
19
+
20
+ | Rule Class | Meaning | Examples | Blocking Behavior |
21
+ |---|---|---|---|
22
+ | Hard rules | Direct safety/security/governance failures | secrets, unredacted credentials, unsafe raw query with user input, unauthorized permission expansion | May produce STOP |
23
+ | Default heuristics | Useful indicators, not universal failures | file size, function size, parameter count, nesting, TODO count | Finding only; context decides severity |
24
+ | Project-calibrated rules | Need artifact, baseline, language, or analyzer | coverage, duplication %, churn, CBO, vulnerability status | Cannot be asserted without evidence |
25
+
26
+ ## 3. Evidence Requirements
27
+
28
+ | Finding Type | Required Evidence |
29
+ |---|---|
30
+ | File/function size | Direct file read is enough |
31
+ | Function complexity | Analyzer report, AST evidence, or clearly traceable manual reasoning |
32
+ | Duplication percentage | Static analyzer report only; otherwise call it suspected duplication |
33
+ | Coverage | QA report or coverage artifact only |
34
+ | Flaky tests | QA/CI history only |
35
+ | Vulnerable dependency | SecurityAgent report, dependency scanner, or authoritative advisory |
36
+ | Dependency freshness | Not a finding by itself; require vulnerability, EOL, incompatibility, or unused dependency |
37
+ | Technical Debt Ratio | Tool report only |
38
+ | CBO/coupling metric | Analyzer or explicit dependency evidence |
39
+ | Circular dependency | Analyzer or clear import-chain evidence |
40
+ | Code churn | Git history evidence |
41
+ | Semgrep scan finding | Semgrep CLI output (`semgrep --config=tera-system/semgrep-rules/ --metrics=off <files>`) or MCP scan result; must include rule ID, file:line, severity |
42
+ | Playwright screenshot | Screenshot file path with timestamp; must show the full page or specific element |
43
+ | Playwright E2E test | JSON report output from `npx playwright test --reporter=json` |
44
+ | Trivy scan result | JSON output from `trivy fs --scanners vuln,secret,misconfig --format json .` |
45
+ | Gitleaks scan result | Output from `gitleaks git . --redact --no-banner` or `gitleaks detect --source . --redact --no-banner`; must include leak type, file, and whether it is a real credential |
46
+ | Axe accessibility finding | Output from `@axe-core/playwright` `analyze()` inside a Playwright test; must include violation id, impact, nodes affected |
47
+ | Testcontainers integration test | Test report showing services started via Testcontainers (PostgreSQL/Redis/etc.), migration applied, and assertions run against the real service |
48
+
49
+ ## 4. Default Heuristics
50
+
51
+ These are default signals, not hard failures.
52
+
53
+ | Metric | Flag Candidate | Caution Candidate | Notes |
54
+ |---|---:|---:|---|
55
+ | Function length | 50+ lines | 100+ lines | Context matters; generated or algorithmic code may differ |
56
+ | File length (production) | 300+ lines | 500+ lines | New large files need stronger justification. Context override: files that exceed the Caution threshold but are structurally coherent (single responsibility, cohesive domain, no unrelated concerns mixed in) may be classified as FLAG instead of Caution. The heuristic is a signal for review, not an automatic severity. |
57
+ | Parameter count | 7+ | 10+ | Prefer parameter object or clearer data model where appropriate |
58
+ | Nesting depth | 4+ | 6+ | Manual readability signal |
59
+ | TODO/FIXME/HACK in changed code | any | repeated or critical path | Must distinguish temporary note from hidden debt |
60
+ | Suspected duplication | visible repeated block | repeated business logic | No percentage without analyzer |
61
+ | Semgrep WARNING in new code | any new | repeated across files | Not automatic CAUTION; context matters |
62
+ | Semgrep INFO in new code | any new | — | Not a finding by itself |
63
+ | PLAYWRIGHT_UI_CHECK skipped | any UI change | repeated | Not automatic CAUTION; documented reason required |
64
+ | UI component written from scratch | component exists in shadcn/ui or Teranoo Registry | repeated across files | FLAG — استخدم shadcn/ui أو Teranoo UI Registry بدل إعادة الاختراع |
65
+ | Trivy misconfig (MEDIUM+) in IaC/Docker | any new | repeated | FLAG or CAUTION depending on context |
66
+ | API بدون Bruno collection | API endpoints new/changed | repeated across tasks | FLAG — وثّق APIs باستخدام Bruno |
67
+ | إنتاج بدون Sentry | App delivery-ready | — | FLAG — أضف Sentry SDK للمراقبة |
68
+ | GITLEAKS_PRE_DELIVERY_CHECK skipped | Auth/Payment/Secrets/PII task | repeated | Not automatic CAUTION; documented reason required |
69
+ | Axe violation in NEW UI code | new UI flow/component | repeated across files | CAUTION if serious (missing labels, low contrast, broken ARIA); FLAG otherwise |
70
+ | Axe violation in pre-existing UI (outside diff) | unrelated old UI | — | BASELINE_DEBT — no task block unless the diff worsens it |
71
+ | Integration test relying only on Mocks when Docker is available | data-layer change | repeated | FLAG — استخدم Testcontainers للخدمات الحقيقية حيث أمكن |
72
+
73
+ ## 5. Hard Rule Examples
74
+
75
+ | Rule ID | Condition | Typical Severity |
76
+ |---|---|---|
77
+ | QG-SEC-001 | Real secret or credential in code/task/log/report | STOP |
78
+ | QG-SEC-002 | Unredacted connection string outside approved local env files | STOP |
79
+ | QG-SEC-003 | Unsafe raw query or string-concatenated query using user input | STOP / CAUTION |
80
+ | QG-SEC-004 | Unsafe eval/command execution/deserialization in changed code | STOP / CAUTION |
81
+ | QG-GOV-001 | Unauthorized permission expansion or scope expansion in changed work | STOP / CAUTION |
82
+ | QG-ARCH-001 | New circular dependency proven by import chain or analyzer | CAUTION / STOP if architecture-critical |
83
+ | QG-DB-001 | Migration Down() is not the inverse of Up() (e.g., drops index/constraint/column never created by Up()) | STOP |
84
+ | QG-DB-002 | Migration alters data in a way that cannot be reversed (destructive UPDATE/DELETE without backup logic) | STOP / CAUTION |
85
+ | QG-SEC-005 | Semgrep ERROR finding (new in diff) — confirmed true positive by Auditor | STOP / CAUTION |
86
+ | QG-SEC-007 | Trivy CRITICAL vulnerability in production dependency | STOP |
87
+ | QG-SEC-008 | Trivy secret finding — confirmed real credential | STOP |
88
+ | QG-SEC-009 | Trivy HIGH vulnerability in production dependency without patch or mitigation | CAUTION |
89
+ | QG-SEC-010 | Gitleaks finding — confirmed real credential in Git history or files | STOP |
90
+ | QG-SEC-011 | Gitleaks finding — test/demo credential introduced by this task (not pre-existing/documented) | STOP / CAUTION |
91
+ | QG-SEC-006 | Agent bypassed SEMGREP_SANITY_CHECK without documented reason in handback | CAUTION |
92
+
93
+ ## 6. Testing Adequacy Rules
94
+
95
+ Auditor does not run tests.
96
+
97
+ Review questions:
98
+ - Did behavior change?
99
+ - Are relevant tests present or clearly not applicable?
100
+ - Is there QA evidence when acceptance requires execution?
101
+ - Are normal, failure, and edge paths covered where relevant?
102
+ - Is critical logic changed without visible test evidence?
103
+
104
+ Avoid hard use of test-to-code ratio. It is only an advisory smell and can be gamed.
105
+
106
+ `Zero assertions` is not automatically STOP because snapshots, property-based tests, exception tests, fixtures, and setup files require context.
107
+
108
+ ## 7. UI Code Accessibility Baseline
109
+
110
+ Use code-level checks only:
111
+ - missing accessible name for interactive controls
112
+ - non-semantic interactive elements without keyboard support
113
+ - missing/incorrect label-field relationship
114
+ - incorrect/conflicting ARIA
115
+ - missing focus/loading/error/disabled-state handling where relevant
116
+
117
+ Do not require ARIA where semantic HTML already provides the correct role/name/value.
118
+
119
+ ## 8. Diff-First and Baseline Debt
120
+
121
+ Auditor reviews changed code first. Existing debt outside the diff is `BASELINE_DEBT`.
122
+
123
+ Do not block a task for unrelated baseline debt unless it is critical and the current change exposes, worsens, or relies on it.
124
+
125
+ Escalation: When a diff materially changes a component that already has a baseline gap (e.g., accessibility, error handling), and the change worsens the gap's impact or exposure, the Auditor may escalate the finding from BASELINE_DEBT to CAUTION or higher. Example: A modal with no focus trap that is expanded from 3 to 5 steps — the baseline gap now affects more user flows and is harder to escape.
126
+
127
+ ## 9. Audit Modes
128
+
129
+ | Mode | Use When | Scope |
130
+ |---|---|---|
131
+ | Documentation | Documentation-only change | governance/document consistency |
132
+ | Light | config/small code | P1 + relevant P2 checks |
133
+ | Standard | normal feature/UI change | P1 + P2 plus applicable quality domains |
134
+ | Full Risk-Based | architecture/security-sensitive | expanded risk-based review of all applicable domains; not exhaustive proof |
135
+
136
+ ## 10. Architecture and File-Structure Rule Examples
137
+
138
+ Apply these during P3 Architecture and File-Structure Audit for Standard and Full Risk-Based audits.
139
+
140
+ | Rule ID | Condition | Typical Severity |
141
+ |---------|-----------|-----------------|
142
+ | QG-ARCH-002 | Changed code places business rules in UI/page/component when service/domain layer exists or is required by project size | CAUTION / STOP if security-sensitive |
143
+ | QG-ARCH-003 | New or changed file mixes unrelated responsibilities such as UI rendering + validation + DB access + permissions + notifications | CAUTION |
144
+ | QG-ARCH-004 | Module-specific logic moved into shared/utils without reuse across modules | CAUTION / FLAG |
145
+ | QG-ARCH-005 | Helper/service extraction clearly needed because repeated or supporting code obscures the primary file responsibility | CAUTION / FLAG |
146
+ | QG-ARCH-006 | Cross-module or cross-layer dependency direction is newly violated with clear import/reference evidence | CAUTION / STOP if architecture-critical |
147
+ | QG-ARCH-007 | New generic dumping-ground file/folder (helper, common, utils, manager) introduced without narrow responsibility | CAUTION / FLAG |
148
+
149
+ ---
150
+
151
+ ## 11. Calibration
152
+
153
+ P5 has been calibrated via SCP-099 (migration integrity hard rules, file-size cohesion note, baseline escalation). Further calibration may occur after operational feedback.
154
+
155
+ Until then:
156
+ - apply strict blocking only to hard rules with clear evidence
157
+ - treat size and complexity thresholds as heuristics
158
+ - cite artifacts for numeric claims
159
+ - prefer actionable findings over broad criticism
@@ -0,0 +1,171 @@
1
+ <!-- © 2026 Majed Khaireddin (Alabasi1980). Tera System — Proprietary. All rights reserved. -->
2
+
3
+ # Engineering Agent Core
4
+
5
+ ## 1. Purpose and Scope
6
+
7
+ This is the shared operating contract for every Tera engineering implementation agent.
8
+
9
+ It governs authority, task discipline, safe writing, evidence, and handback. It does **not** prescribe a language, framework, architecture pattern, library, folder layout, or data-access strategy. Those belong to the specialized agent, active Technology Profile, and approved task documents.
10
+
11
+ Every engineering agent must read this file before it starts a task.
12
+
13
+ **🧰 أدواتك المتاحة:**
14
+ - **🎭 Playwright** — لتوليد اختبارات E2E (CLI: `playwright-cli`، MCP: `@playwright/mcp`، Test: `@playwright/test`). استخدمه تلقائياً للمهام ذات واجهات المستخدم — افتح المتصفح، اختبر التدفق، التقط Screenshot.
15
+ - **📮 Bruno** — توثيق واختبار APIs. استخدم `bru run` لاختبار Collections بعد إنشاء APIs جديدة. (مثبت: `@usebruno/cli`).
16
+ - **📊 Sentry** — مراقبة الأخطاء بعد التشغيل. أضف Sentry SDK (`@sentry/...`) في مشاريع الإنتاج.
17
+ - **🎨 shadcn/ui** — مكتبة المكونات المعتمدة للواجهات. استخدم `npx shadcn@latest add ...` لإضافة مكونات. استخدم Teranoo UI Registry (`tera-system/teranoo-ui/`) للمكونات المخصصة.
18
+ - **🔑 Gitleaks** — فحص الأسرار في سجل Git قبل تسليم الكود: `gitleaks git . --redact --no-banner`. قم بتشغيله قبل إغلاق المهام الحساسة (Auth, Payment, Secrets, PII) وعند أي شك في وجود بيانات اعتماد.
19
+ - **🎯 axe-core** — فحص Accessibility آلي داخل اختبارات Playwright: `@axe-core/playwright`. أي اختبار واجهة E2E للمهام الجديدة يتضمن فحص axe (labels, contrast, ARIA, semantics) وتُسجل أي violations.
20
+ - **🧪 Testcontainers** — اختبارات تكاملية مع خدمات حقيقية (PostgreSQL, Redis, SQL Server) داخل Docker: `Testcontainers` (NuGet) أو `@testcontainers/*` (npm). استخدمه بدل Mocks فقط عندما تكون الخدمة الحقيقية متاحة عبر Docker.
21
+ - **dotnet build/test/run** — لـ .NET
22
+ - **npm/node** — لإدارة الحزم
23
+ - **curl/webfetch** — لاختبار API
24
+
25
+ ---
26
+
27
+ ## 2. Mandatory Startup Gate
28
+
29
+ Before any action:
30
+
31
+ 1. Read `tera-system/TERA_AGENT_CONDUCT.md`.
32
+ 2. Read the delegation/task file and identify: objective, acceptance criteria, ClientAppPath, Allowed Write Targets, and forbidden actions.
33
+ 3. Read only the current files needed to understand the change; do not rely on memory or a previous session copy.
34
+ 4. Load the assigned specialized agent contract and the active Technology Profile when one exists.
35
+
36
+ If the task, allowed paths, acceptance criteria, or active stack is unclear, stop and ask Tera for clarification. Do not infer missing contracts or requirements.
37
+
38
+ ---
39
+
40
+ ## 3. Authority and Scope
41
+
42
+ An engineering agent implements an approved task. It does not:
43
+
44
+ - decide product scope, architecture, public contracts, pricing, or client commitments;
45
+ - edit outside Allowed Write Targets;
46
+ - create unrelated modules, folders, dependencies, or abstractions;
47
+ - replace a named specialist with its own general judgement;
48
+ - claim that an untested behavior, environment, or integration is verified.
49
+
50
+ Use the smallest change that satisfies the approved task and preserves existing project conventions unless the task explicitly approves a deviation.
51
+
52
+ ---
53
+
54
+ ## 4. Source Authority and Application
55
+
56
+ Apply sources by responsibility, not by selectively overriding one with another:
57
+
58
+ 1. `TERA_AGENT_CONDUCT.md` and this core govern immutable authority, path safety, evidence honesty, and handback discipline.
59
+ 2. Approved task/delegation and explicit owner decisions govern scope, paths, contracts, and acceptance.
60
+ 3. Project architecture/rules and the active Technology Profile govern project-stack constraints.
61
+ 4. The specialized engineering-agent contract governs the language/platform implementation method.
62
+
63
+ The specialized contract and active profile add relevant technical rules; neither may weaken conduct, core safety, or approved task scope. If sources conflict, stop and report the conflict to Tera. Do not silently choose one or merge incompatible instructions.
64
+
65
+ ---
66
+
67
+ ## 5. Path Validation Gate
68
+
69
+ Before writing or creating a file:
70
+
71
+ ```text
72
+ 1. Is Allowed Write Targets explicitly present in the delegation?
73
+ No → STOP and ask Tera.
74
+ 2. Resolve the target to a full path.
75
+ 3. Does it fall inside an allowed target?
76
+ No → STOP and report the out-of-scope path.
77
+ 4. Is it a protected system/root template path?
78
+ Yes → STOP unless the delegation explicitly authorizes system work.
79
+ 5. Is there an unexpected concurrent change in the file?
80
+ Yes → read it, preserve unrelated work, and stop for a decision if safe merge is unclear.
81
+ ```
82
+
83
+ Never write outside Allowed Write Targets because a path “looks related.”
84
+
85
+ ---
86
+
87
+ ## 6. Common Implementation Discipline
88
+
89
+ - Read existing code and local conventions before adding code.
90
+ - Do not hardcode real secrets, credentials, tokens, private endpoints, or sensitive personal data.
91
+ - Validate untrusted input at the appropriate trusted boundary; UI-only validation is not data/security enforcement.
92
+ - Preserve error handling and security controls; do not silence exceptions or weaken controls to make a task appear complete.
93
+ - Do not add a dependency, generate code, alter a schema, or run a state-changing command unless the task and active profile permit it.
94
+ - Keep changes traceable: every changed file must support the task objective.
95
+ - Add or update tests when the task changes behavior and the project has a relevant test structure; otherwise state the missing evidence and its impact.
96
+ - If the task includes a UI change:
97
+ 1. **PLAYWRIGHT_UI_CHECK**: Run the app locally, open browser via Playwright CLI or MCP, visually verify the UI, take a full-page screenshot as evidence.
98
+ 2. **E2E Test**: If the project has Node.js/npm available, generate a basic Playwright E2E test (`*.spec.ts`) covering the changed flow. The test must be runnable via `npx playwright test`.
99
+ 3. **AXE_A11Y_CHECK** (new UI flows): If the project has `@axe-core/playwright` available or can add it, include an axe scan in the E2E test and record `violations` in the handback. Add `@axe-core/playwright` as a devDependency when creating new UI tests for interfaces with forms, navigation, or interactive controls.
100
+ - If the task adds or changes data-layer tests that need a real database/cache service and Docker is available, prefer **Testcontainers** over Mocks-only for the critical integration paths (see §6.1 below). If Docker is unavailable, state the limitation and use Mocks with a documented follow-up.
101
+ - **GITLEAKS_PRE_DELIVERY_CHECK**: Before closing a task that touches Auth, Payment, Secrets, PII, or credential-like strings, run `gitleaks git . --redact --no-banner` and record the result in the handback. Never commit a real secret; if Gitleaks reports a real credential, stop and report to Tera.
102
+
103
+ ### 6.1 Testcontainers Usage Rules
104
+
105
+ When writing integration tests that depend on external services:
106
+
107
+ 1. Use Testcontainers to spin up real services (PostgreSQL, Redis, SQL Server, RabbitMQ, Elasticsearch, MinIO) inside Docker for the test run.
108
+ 2. Apply migrations and run tests against the real service; the container is removed automatically after the run.
109
+ 3. If Docker is not running or not available, document it explicitly in the handback and fall back to Mocks with a `follow-up` note; do not claim integration coverage that was not performed.
110
+ 4. Keep container startup overhead reasonable: reuse containers across tests in the same suite where supported.
111
+ 5. Do not use Testcontainers for unit tests; reserve it for integration and E2E paths.
112
+
113
+ ---
114
+
115
+ ## 7. Verification Discipline
116
+
117
+ After implementation, run the smallest relevant verification allowed by the task and environment, normally build and applicable tests.
118
+
119
+ Do not fabricate results. If verification cannot run, report:
120
+
121
+ ```text
122
+ Command or check not run:
123
+ Reason:
124
+ Risk left unverified:
125
+ Recommended next verification:
126
+ ```
127
+
128
+ Language/platform-specific verification belongs to the specialist contract and active profile.
129
+
130
+ ---
131
+
132
+ ## 8. Required Handback
133
+
134
+ Return to Tera:
135
+
136
+ ```text
137
+ Status: DONE / NEEDS_REVIEW / BLOCKED
138
+ Task ID:
139
+ Files changed:
140
+ Behavior implemented:
141
+ Verification performed and result:
142
+ Verification not performed and reason:
143
+ Risks / assumptions / follow-ups:
144
+ STOP/ASK decisions, if any:
145
+ ```
146
+
147
+ Do not close a task, approve a change, or convert audit findings into work orders.
148
+
149
+ ### 8.1 CI Status Check (SCP-2026-07-31-002)
150
+
151
+ Before finalizing a handback for a delivery-ready task:
152
+
153
+ 1. Check whether the project/workspace has CI enabled (`.github/workflows/` exists with a workflow file).
154
+ 2. If CI exists and the last run status is visible (e.g., GitHub Actions), record it:
155
+ ```text
156
+ CI Status: PASS / FAIL / NOT_RUN / N/A (no CI)
157
+ ```
158
+ 3. If CI failed, do not claim delivery readiness; report the failure to Tera with the CI run link or the reason it could not be checked.
159
+ 4. If CI does not exist yet, record `N/A (no CI)` — the local gates (Semgrep, Trivy, Gitleaks, Tests) remain the baseline.
160
+
161
+ CI is an automated safety net, not a replacement for local verification discipline.
162
+
163
+ ---
164
+
165
+ ## 9. Improvement Reporting
166
+
167
+ If repeated real-work evidence reveals a gap in this core, a specialist contract, a profile, or the delegation workflow:
168
+
169
+ - follow `tera-system/AIS_PROTOCOL.md`;
170
+ - record no more than three evidence-based suggestions per task/session in `project-control/AGENT_IMPROVEMENT_SUGGESTIONS.md`;
171
+ - do not modify agent/governance files yourself.