ai-engineering-loop 1.0.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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +272 -0
  3. package/adapters/dot/README.md +55 -0
  4. package/adapters/dot/coreview.md +88 -0
  5. package/adapters/dot/gitlab.md +128 -0
  6. package/adapters/dot/mattermost.md +102 -0
  7. package/adapters/dot/multi-branch.md +89 -0
  8. package/agents/devil-advocate.md +111 -0
  9. package/agents/judge.md +69 -0
  10. package/agents/maker.md +66 -0
  11. package/bin/ai-engineering-loop.js +633 -0
  12. package/core/configuration-precedence.md +102 -0
  13. package/core/context-impact-assessment.md +127 -0
  14. package/core/context-refresh-policy.md +116 -0
  15. package/core/definition-of-done.md +79 -0
  16. package/core/escalation-policy.md +99 -0
  17. package/core/goal-contract.md +88 -0
  18. package/core/iteration-policy.md +108 -0
  19. package/core/judge-policy.md +123 -0
  20. package/core/project-initialization.md +97 -0
  21. package/core/repo-config-schema.md +72 -0
  22. package/core/verification-loop.md +97 -0
  23. package/docs/antigravity-feasibility.md +90 -0
  24. package/docs/migration-plan.md +70 -0
  25. package/examples/backend-api/payment-idempotency/README.md +33 -0
  26. package/examples/backend-api/payment-idempotency/goal-contract.md +33 -0
  27. package/examples/backend-api/payment-idempotency/judge-verdict.md +28 -0
  28. package/examples/backend-api/payment-idempotency/review-findings.md +50 -0
  29. package/examples/dot/attendance-confirmation/README.md +22 -0
  30. package/examples/dot/attendance-confirmation/delivery-report.md +51 -0
  31. package/examples/dot/attendance-confirmation/goal-contract.md +39 -0
  32. package/examples/dot/attendance-confirmation/judge-verdict.md +43 -0
  33. package/examples/dot/attendance-confirmation/review-findings.md +57 -0
  34. package/examples/initialization/README.md +19 -0
  35. package/examples/initialization/discovery-trace.md +63 -0
  36. package/examples/initialization/generated-context.md +110 -0
  37. package/examples/mobile-app/offline-sync-queue/README.md +33 -0
  38. package/examples/mobile-app/offline-sync-queue/goal-contract.md +32 -0
  39. package/examples/mobile-app/offline-sync-queue/judge-verdict.md +27 -0
  40. package/examples/mobile-app/offline-sync-queue/review-findings.md +30 -0
  41. package/package.json +31 -0
  42. package/policies/discovery-safety-policy.md +51 -0
  43. package/policies/evidence-policy.md +70 -0
  44. package/policies/finding-policy.md +102 -0
  45. package/policies/no-progress-policy.md +92 -0
  46. package/profiles/README.md +42 -0
  47. package/profiles/backend-api.md +64 -0
  48. package/profiles/library.md +51 -0
  49. package/profiles/mobile-app.md +59 -0
  50. package/profiles/monorepo.md +46 -0
  51. package/profiles/web-app.md +65 -0
  52. package/scripts/init.sh +85 -0
  53. package/templates/repo-config/adapter.md +11 -0
  54. package/templates/repo-config/architecture.md +15 -0
  55. package/templates/repo-config/config.md +11 -0
  56. package/templates/repo-config/conventions.md +16 -0
  57. package/templates/repo-config/verification.md +13 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ega Gofur
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,272 @@
1
+ # AI Engineering Loop
2
+
3
+ <div align="center">
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/egagofur/ai-engineering-loop/pulls)
7
+ [![AI Engineering](https://img.shields.io/badge/AI-Engineering%20Loop-orange.svg)](https://github.com/egagofur/ai-engineering-loop)
8
+ [![Release](https://img.shields.io/badge/release-v1.0.0-purple.svg)](https://github.com/egagofur/ai-engineering-loop/releases)
9
+ [![Status](https://img.shields.io/badge/status-production--ready-success.svg)](https://github.com/egagofur/ai-engineering-loop)
10
+
11
+ **A Reusable, Framework-Agnostic AI Engineering Operating System for Autonomous Coding Agents**
12
+
13
+ *Featuring living project context, post-task impact assessment, contract-driven execution, deterministic machine verification, and independent adversarial review.*
14
+
15
+ [Overview](#overview--philosophy) • [Living Project Context](#living-project-context) • [CLI Commands](#cli-interface--commands) • [Agent Integration](#antigravity-agent-integration) • [Lifecycle](#lifecycle-stages) • [Architecture](#architecture--5-layer-configuration) • [Project Profiles](#project-profiles) • [Repository Structure](#repository-structure) • [Reference Examples](#reference-examples) • [Contributing](#contributing)
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ ## Overview & Philosophy
22
+
23
+ The AI Engineering Loop enforces a clean architectural separation between **Deterministic Living Context Bootstrap** and **Agent Intelligence**:
24
+
25
+ > **"The CLI bootstraps, tracks, and validates living context. The AI Agent reasons over that context to execute the engineering lifecycle."**
26
+
27
+ ```mermaid
28
+ flowchart TD
29
+ Start([User Task in Workspace]) --> PreCheck{Pre-Task Drift Check: metadata.json}
30
+
31
+ PreCheck -->|Context Missing| AutoInit[Stage 0: Bootstrap .ai-engineering-loop/]
32
+ PreCheck -->|Drift Detected| Reconcile[Stage 0: Reconcile Drifted Context]
33
+ PreCheck -->|Context Fresh| GC[Stage 1: Goal Contract: Explicit Acceptance Criteria]
34
+
35
+ AutoInit --> GC
36
+ Reconcile --> GC
37
+
38
+ subgraph CoreEngine [AI ENGINEERING OPERATING SYSTEM]
39
+ GC --> RCA[Stage 2: Root Cause Analysis]
40
+ RCA --> Plan[Stage 3: Implementation Plan]
41
+ Plan --> MA[Stage 4: Maker Agent: Surgical Diff & Tests]
42
+ MA --> DV{Stage 5: Deterministic Verification}
43
+
44
+ DV -->|Fail| MA
45
+ DV -->|Pass| DA[Stage 6: Devil's Advocate: Adversarial Review]
46
+
47
+ DA --> JD[Stage 7: Judge Agent: Impartial Magistrate]
48
+ end
49
+
50
+ JD -->|PASS| ImpactEval{Post-Task Context Impact Assessment}
51
+
52
+ ImpactEval -->|NONE: Typo, UI tweak| Adapter[Stage 8: Delivery Adapter: GitLab / GitHub]
53
+ ImpactEval -->|TARGETED: Dep/route changed| PartialRefresh[Surgical Context Update] --> Adapter
54
+ ImpactEval -->|MAJOR: Framework migration| FullRefresh[Full Context Reconciliation] --> Adapter
55
+
56
+ Adapter --> TargetRepo[(Target Repository)]
57
+ ```
58
+
59
+ ---
60
+
61
+ ## Living Project Context
62
+
63
+ The `.ai-engineering-loop/` directory is **Living Context**, not a static wiki generated once.
64
+
65
+ ### 1. Post-Task Context Impact Assessment
66
+ A task reaching `PASS` does **not** blindly trigger a full project refresh. The agent evaluates the impact level:
67
+ - **`NONE` (80–90% of tasks)**: Typo fixes, CSS tweaks, surgical bugfixes preserving architecture $\rightarrow$ Refresh SKIPPED.
68
+ - **`TARGETED` (10–15% of tasks)**: Manifest script change (`verification.md`), new module (`architecture.md`), new CI config (`adapter.md`) $\rightarrow$ Surgically update affected files only.
69
+ - **`MAJOR` (<5% of tasks)**: Framework migration, monorepo restructuring, auth overhaul $\rightarrow$ Full context reconciliation.
70
+
71
+ ### 2. Context Baseline (`metadata.json`)
72
+ Deterministic drift detection without a database:
73
+ - Tracks `repositoryRevision` (git commit SHA), `manifestChecksums`, and `lastReconciliation`.
74
+ - Enables instant **Level 0 (0ms)** drift verification on subsequent agent invocations.
75
+
76
+ ### 3. Strict Context Isolation
77
+ - **Project Context (`.ai-engineering-loop/`)**: Shared, living ground truth of engineering rules and architecture.
78
+ - **Task Context**: Transient task contracts, acceptance criteria, and active diff scope.
79
+ - **Loop State**: Ephemeral finding signatures, iteration counters, and retry attempts.
80
+
81
+ ---
82
+
83
+ ## CLI Interface & Commands
84
+
85
+ The CLI operates against the current working directory without maintaining a centralized project registry.
86
+
87
+ ```bash
88
+ # Bootstrap .ai-engineering-loop/ context from repository discovery
89
+ npx ai-engineering-loop init
90
+
91
+ # Check the validity, readiness, and baseline freshness of context
92
+ npx ai-engineering-loop status
93
+
94
+ # Reconcile drifted context against repository non-destructively
95
+ npx ai-engineering-loop refresh
96
+
97
+ # Verify context readiness and begin engineering loop
98
+ npx ai-engineering-loop run
99
+ ```
100
+
101
+ ### Command Responsibilities:
102
+
103
+ | Command | Purpose | Expected Writes | Mutates App Code? |
104
+ |---|---|---|:---:|
105
+ | **`init`** | Analyzes repository topology, manifests, and test scripts to generate `.ai-engineering-loop/`. | `.ai-engineering-loop/*` | **NO** |
106
+ | **`status`** | Audits the completeness of context files and checks baseline drift (`CURRENT` / `STALE`). | None | **NO** |
107
+ | **`refresh`** | Re-analyzes manifests and surgically updates drifted sections while preserving human notes. | `.ai-engineering-loop/*` | **NO** |
108
+ | **`run`** | Loads verified context and triggers the AI Agent to execute task engineering. | Governed by Task Scope | By Agent |
109
+
110
+ ---
111
+
112
+ ## Antigravity Agent Integration
113
+
114
+ When working inside the Antigravity IDE or compatible agentic platforms, you can invoke the loop via slash commands:
115
+
116
+ - **`/ai-engineering-loop init`**: Initialize project context only (non-destructive bootstrap).
117
+ - **`/ai-engineering-loop status`**: Check repository context health & baseline freshness.
118
+ - **`/ai-engineering-loop refresh`**: Reconcile drifted context files non-destructively.
119
+ - **`/ai-engineering-loop [task description]`**: Execute the full 8-stage engineering lifecycle with pre-task drift gate and post-task impact assessment.
120
+
121
+ ---
122
+
123
+ ## Lifecycle Stages
124
+
125
+ 1. **Stage 0: Living Context & Drift Gate ([`core/project-initialization.md`](core/project-initialization.md), [`core/context-refresh-policy.md`](core/context-refresh-policy.md))**:
126
+ - Check `metadata.json` baseline. If fresh $\rightarrow$ proceed. If missing or drifted $\rightarrow$ reconcile context.
127
+ 2. **Stage 1: Goal Contract ([`core/goal-contract.md`](core/goal-contract.md))**: Formulate explicit, testable Acceptance Criteria.
128
+ 3. **Stage 2: Root Cause Analysis**: End-to-end data tracing and git commit history examination.
129
+ 4. **Stage 3: Implementation Plan**: Structured diff proposal and test plan.
130
+ 5. **Stage 4: Maker Execution ([`agents/maker.md`](agents/maker.md))**: Surgical implementation and test engineering.
131
+ 6. **Stage 5: Deterministic Verification ([`core/verification-loop.md`](core/verification-loop.md))**: 100% green pass on tests, typechecks, linters, and builds.
132
+ 7. **Stage 6: Devil's Advocate Review ([`agents/devil-advocate.md`](agents/devil-advocate.md))**: Layered adversarial critique with concrete alternative diffs.
133
+ 8. **Stage 7: Judge & Impact Assessment ([`agents/judge.md`](agents/judge.md), [`core/context-impact-assessment.md`](core/context-impact-assessment.md))**: Impartial verdict (`PASS`/`ITERATE`/`ESCALATE`) followed by Context Impact Assessment (`NONE`/`TARGETED`/`MAJOR`).
134
+ 9. **Stage 8: Delivery Pipeline ([`adapters/`](adapters/))**: Automated PR/MR generation, multi-branch propagation, and notification dispatch.
135
+
136
+ ---
137
+
138
+ ## Architecture & 5-Layer Configuration
139
+
140
+ The system dynamically resolves configuration and review rules through a cascading 5-layer hierarchy:
141
+
142
+ $$\text{GLOBAL} \longrightarrow \text{ENGINEERING CORE} \longrightarrow \text{PROJECT TYPE PROFILE} \longrightarrow \text{PROJECT CONFIG (`.ai-engineering-loop/`)} \longrightarrow \text{TASK CONTRACT}$$
143
+
144
+ 1. **GLOBAL**: Host execution safety limits and maximum iteration ceilings (`MAX_ITERATIONS <= 5`).
145
+ 2. **ENGINEERING CORE**: Universal loop invariants ([Goal Contract](core/goal-contract.md), [Verification Loop](core/verification-loop.md), [Definition of Done](core/definition-of-done.md)).
146
+ 3. **PROJECT TYPE PROFILE ([`profiles/`](profiles/README.md))**: Archetype defaults for web applications, backend APIs, mobile apps, libraries, or monorepos.
147
+ 4. **PROJECT CONFIGURATION (`<repo>/.ai-engineering-loop/`)**: Target repository ground truth ([`verification.md`](templates/repo-config/verification.md), [`architecture.md`](templates/repo-config/architecture.md), [`conventions.md`](templates/repo-config/conventions.md)).
148
+ 5. **TASK CONTRACT**: Active task-scoped acceptance criteria and diff constraints.
149
+
150
+ ---
151
+
152
+ ## Project Profiles
153
+
154
+ Profiles define technology-specific characteristics and activate relevant review domains for the Devil's Advocate without modifying the core engine:
155
+
156
+ | Profile | Specification | Target Tech Stack | Active Review Focus |
157
+ |---|---|---|---|
158
+ | **`web-app`** | [web-app.md](profiles/web-app.md) | Next.js, Remix, Vite, React, Vue | DOM rendering, responsiveness (320px–4k), accessibility (a11y/ARIA), client state, Core Web Vitals |
159
+ | **`backend-api`** | [backend-api.md](profiles/backend-api.md) | Go, Node.js, Python, Java, PostgreSQL | Auth/IDOR, database transactions & ACID rollbacks, concurrency locks (`SELECT FOR UPDATE`), N+1 query loops |
160
+ | **`mobile-app`** | [mobile-app.md](profiles/mobile-app.md) | Flutter, React Native, iOS (Swift), Android (Kotlin) | Offline sync queues, OS lifecycle termination & state loss, permission denials, battery/GPS hygiene |
161
+ | **`library`** | [library.md](profiles/library.md) | npm/PyPI packages, SDKs, crates | SemVer public API stability, zero dependency bloat, cross-runtime compatibility, bundle tree-shaking |
162
+ | **`monorepo`** | [monorepo.md](profiles/monorepo.md) | Turborepo, Nx, Cargo/pnpm workspaces | Cross-package boundaries, circular dependencies, affected scope testing, workspace cache invalidation |
163
+
164
+ Profile index: [profiles/README.md](profiles/README.md).
165
+
166
+ ---
167
+
168
+ ## Repository Structure
169
+
170
+ ```text
171
+ ai-engineering-loop/
172
+
173
+ ├── README.md # Operating system overview & architecture
174
+ ├── LICENSE # MIT Open Source License
175
+ ├── package.json # CLI package manifest
176
+
177
+ ├── bin/ # CLI execution entrypoints
178
+ │ └── ai-engineering-loop.js # npx executable CLI (init, status, refresh, run)
179
+
180
+ ├── scripts/ # Shell installers
181
+ │ └── init.sh # Convenience one-liner installer
182
+
183
+ ├── core/ # Generic engineering loop specifications
184
+ │ ├── project-initialization.md # Auto-discovery & initialization lifecycle
185
+ │ ├── context-refresh-policy.md # Progressive drift hierarchy & living baseline
186
+ │ ├── context-impact-assessment.md # Post-task impact assessment (NONE, TARGETED, MAJOR)
187
+ │ ├── goal-contract.md # Task contract schema & acceptance criteria
188
+ │ ├── verification-loop.md # Dual-layer verification lifecycle
189
+ │ ├── definition-of-done.md # 5 pillars of Done & rejection triggers
190
+ │ ├── iteration-policy.md # Bounded autonomous loop (MAX_ITERATIONS = 3)
191
+ │ ├── escalation-policy.md # Deterministic human escalation triggers
192
+ │ ├── judge-policy.md # Evaluation rules, triage audit, & verdicts
193
+ │ ├── configuration-precedence.md # 5-layer precedence & conflict resolution
194
+ │ └── repo-config-schema.md # Schema for target repo .ai-engineering-loop/
195
+
196
+ ├── profiles/ # Project archetype profiles
197
+ │ ├── README.md # Profile catalog & auto-detection rules
198
+ │ ├── web-app.md # Frontend web applications
199
+ │ ├── backend-api.md # Backend APIs & microservices
200
+ │ ├── mobile-app.md # Native & cross-platform mobile apps
201
+ │ ├── library.md # Reusable SDKs & shared packages
202
+ │ └── monorepo.md # Multi-package monorepo workspaces
203
+
204
+ ├── agents/ # Triad agent role specifications
205
+ │ ├── maker.md # Maker agent: surgical diffs & unit tests
206
+ │ ├── devil-advocate.md # Adversarial reviewer: layered review rules & concrete diffs
207
+ │ └── judge.md # Judge agent: neutral magistrate & verdict computation
208
+
209
+ ├── policies/ # Operational schemas & algorithms
210
+ │ ├── discovery-safety-policy.md # Secret protection & non-destructive discovery rules
211
+ │ ├── finding-policy.md # Standardized finding schema & severity matrix
212
+ │ ├── evidence-policy.md # 5-level evidence hierarchy
213
+ │ └── no-progress-policy.md # Finding signature hashing & stagnation detection
214
+
215
+ ├── adapters/ # Pluggable delivery pipelines
216
+ │ └── dot/ # DOT Indonesia delivery adapter
217
+ │ ├── README.md # DOT adapter overview
218
+ │ ├── gitlab.md # glab CLI, issue cards, & MR generation
219
+ │ ├── multi-branch.md # main / staging / develop cherry-pick propagation
220
+ │ ├── coreview.md # @coreview-bot external review triage (Valid vs Halu)
221
+ │ └── mattermost.md # Channel mapping & MCP dispatch (from: "AI Agent")
222
+
223
+ ├── templates/ # Starter templates for target repositories
224
+ │ └── repo-config/ # Ready-to-copy .ai-engineering-loop/ files
225
+ │ ├── config.md # Project identity & profile binding
226
+ │ ├── architecture.md # Layers & boundary invariants
227
+ │ ├── conventions.md # Code standards & forbidden patterns
228
+ │ ├── verification.md # CLI test/lint/build commands
229
+ │ └── adapter.md # Configured release pipeline
230
+
231
+ ├── examples/ # End-to-end multi-archetype reference walkthroughs
232
+ │ ├── initialization/ # Unconfigured Monorepo auto-discovery trace
233
+ │ ├── dot/attendance-confirmation/ # Scenario A: DOT Web Application bugfix & multi-branch MRs
234
+ │ ├── backend-api/payment-idempotency/# Scenario B: Go/PostgreSQL race condition & idempotency fix
235
+ │ └── mobile-app/offline-sync-queue/ # Scenario C: Flutter/SQLite offline sync queue
236
+
237
+ └── docs/ # Meta-documentation & integration guides
238
+ ├── migration-plan.md # 8-phase legacy workflow mapping & rationale
239
+ └── antigravity-feasibility.md # Antigravity runtime evaluation & subagent orchestration
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Reference Examples
245
+
246
+ - **[Auto-Initialization Trace](examples/initialization/README.md)**: Demonstrates the step-by-step discovery of an unconfigured TypeScript/Go monorepo.
247
+ - **[Scenario A: DOT Web Application](examples/dot/attendance-confirmation/README.md)**: Resolves an attendance status bug across `main`, `staging`, and `develop` with `@coreview-bot` triage and Mattermost dispatch.
248
+ - **[Scenario B: Backend API Service](examples/backend-api/payment-idempotency/README.md)**: Eliminates double-spend race conditions in Go/PostgreSQL with `SELECT FOR UPDATE` and automated race test suites.
249
+ - **[Scenario C: Mobile Application](examples/mobile-app/offline-sync-queue/README.md)**: Implements an offline SQLite mutation queue in Flutter with network flapping tolerance and state preservation.
250
+
251
+ ---
252
+
253
+ ## Contributing
254
+
255
+ Contributions, feedback, and new adapter profiles are welcome.
256
+
257
+ 1. Fork the repository (`https://github.com/egagofur/ai-engineering-loop/fork`).
258
+ 2. Create your feature branch (`git checkout -b feature/new-adapter`).
259
+ 3. Ensure all changes adhere to [core/definition-of-done.md](core/definition-of-done.md).
260
+ 4. Open a Pull Request.
261
+
262
+ ---
263
+
264
+ ## License
265
+
266
+ This project is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
267
+
268
+ ---
269
+
270
+ <div align="center">
271
+ Designed for software engineering teams and autonomous AI coding agents.
272
+ </div>
@@ -0,0 +1,55 @@
1
+ # DOT Ecosystem Delivery Adapter
2
+
3
+ ## 1. Overview & Architecture
4
+
5
+ The **DOT Delivery Adapter** connects the generic [AI Engineering Loop](file:///Users/egagofur/Development/work/ai-engineering-loop/README.md) to the specific development infrastructure of **DOT Indonesia**.
6
+
7
+ The generic engineering loop guarantees that code is correct, verified, and adversarially tested. The DOT adapter is responsible for downstream release engineering, collaboration tools, issue tracking, and multi-environment synchronization.
8
+
9
+ ```mermaid
10
+ flowchart TD
11
+ subgraph CoreLoop [Generic AI Engineering Loop]
12
+ PASS([Judge Verdict: PASS])
13
+ end
14
+
15
+ subgraph DOTAdapter [DOT Delivery Pipeline]
16
+ PASS --> Issue[1. GitLab Issue Card via glab]
17
+ Issue --> BaseMR[2. Base Merge Request via glab]
18
+ BaseMR --> MultiBranch[3. Multi-Branch Cherry-Pick: staging & develop]
19
+ MultiBranch --> CoreviewTriage[4. External @coreview-bot Review Triage]
20
+ CoreviewTriage --> MattermostDispatch[5. Mattermost Markdown Notification via MCP]
21
+ end
22
+ ```
23
+
24
+ ---
25
+
26
+ ## 2. Adapter Modules
27
+
28
+ The DOT adapter is organized into four dedicated specification modules:
29
+
30
+ 1. **[GitLab Integration (`gitlab.md`)](file:///Users/egagofur/Development/work/ai-engineering-loop/adapters/dot/gitlab.md)**:
31
+ - CLI automation with `glab`.
32
+ - Standardized issue card templates with actual vs expected tables and QA testing steps.
33
+ - Standardized MR descriptions linking issue IDs and change summaries.
34
+ 2. **[Multi-Branch Propagation (`multi-branch.md`)](file:///Users/egagofur/Development/work/ai-engineering-loop/adapters/dot/multi-branch.md)**:
35
+ - Multi-environment branching model across `main`, `staging`, and `develop`.
36
+ - Clean cherry-picking workflow and target-specific test verification.
37
+ 3. **[Coreview External Reviewer Triage (`coreview.md`)](file:///Users/egagofur/Development/work/ai-engineering-loop/adapters/dot/coreview.md)**:
38
+ - Ingestion of `@coreview-bot` automated PR comments.
39
+ - Rigorous evaluation of bot suggestions into `VALID` (fix & propagate) vs `HALU` (false positive pushback).
40
+ 4. **[Mattermost Notifications (`mattermost.md`)](file:///Users/egagofur/Development/work/ai-engineering-loop/adapters/dot/mattermost.md)**:
41
+ - Repository-to-channel resolution using persistent configuration.
42
+ - MCP `mattermost_send_message` dispatch with mandatory `from: "AI Agent"` attribution.
43
+ - Environment-tagged Markdown blocks (`[MR DEV]`, `[MR STAGING]`, `[MR MAIN]`).
44
+
45
+ ---
46
+
47
+ ## 3. Separation of Concerns
48
+
49
+ | Generic Core Responsibility | DOT Adapter Responsibility |
50
+ |---|---|
51
+ | Goal Contract & Acceptance Criteria | GitLab Issue Card drafting |
52
+ | Unit testing, typecheck, lint, build | Running DOT-specific scripts (`npx jest --testPathIgnorePatterns="dotify-api"`) |
53
+ | Internal Devil's Advocate Review | External `@coreview-bot` triage on GitLab MRs |
54
+ | Judge verdict & completion certificate | Multi-environment cherry-picking & branch synchronization |
55
+ | Evidence collection & finding logs | Mattermost channel notifications & MR link delivery |
@@ -0,0 +1,88 @@
1
+ # DOT Adapter: Coreview Review Triage (`@coreview-bot`)
2
+
3
+ ## 1. Overview & Role of Coreview
4
+
5
+ In the DOT ecosystem, `@coreview-bot` operates as an external, company-level automated code reviewer attached to GitLab Merge Requests (specifically MRs targeting `develop`).
6
+
7
+ > [!IMPORTANT]
8
+ > **We do not have access to `@coreview-bot`'s internal rules or heuristics.**
9
+ > - Do not attempt to reverse-engineer or invent Coreview behavior.
10
+ > - Treat Coreview strictly as an external reviewer providing asynchronous critique on GitLab MRs.
11
+ > - Evaluate its comments objectively through the lens of the repository's ground truth.
12
+
13
+ ---
14
+
15
+ ## 2. Coreview Triage Workflow
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ MRDev[MR Targeting develop Created] --> FetchBot[Fetch Comments via glab mr view --comments]
20
+ FetchBot --> CheckComments{Bot Comments Found?}
21
+
22
+ CheckComments -->|No| Done([Complete Triage])
23
+ CheckComments -->|Yes| Evaluate{Evaluate Each Comment}
24
+
25
+ Evaluate -->|VALID: Real Defect| Fix[1. Surgical Code Fix<br>2. Run Tests & Linter<br>3. Commit & Cherry-pick to all branches<br>4. Reply with commit hash]
26
+ Evaluate -->|HALU: False Positive| Halu[1. Do NOT modify code<br>2. Reply on GitLab Note with technical explanation]
27
+
28
+ Fix --> Done
29
+ Halu --> Done
30
+ ```
31
+
32
+ ---
33
+
34
+ ## 3. Step 1: Fetching Bot Comments
35
+
36
+ After pushing the MR targeting `develop` (`[MR DEV]`), inspect the review comments posted by the bot:
37
+
38
+ ```bash
39
+ glab mr view <mr-id> --comments --repo <repo>
40
+ ```
41
+
42
+ ---
43
+
44
+ ## 4. Step 2: Rigorous Evaluation Protocol
45
+
46
+ Every Coreview comment must be categorized into one of two paths:
47
+
48
+ ### Case A: Feedback is VALID (Real Issue)
49
+ - **Criteria**:
50
+ - Uncovered a real type mismatch or potential runtime `undefined` / `null` exception.
51
+ - Identified an unhandled timezone conversion or unused import/variable.
52
+ - Highlighted a genuine performance or concurrency risk.
53
+ - **Action Plan**:
54
+ 1. Apply the fix surgically to the local working branch.
55
+ 2. Re-run all unit tests and static analysis:
56
+ ```bash
57
+ npx jest --testPathIgnorePatterns="dotify-api"
58
+ npx tsc --noEmit
59
+ ```
60
+ 3. Commit and push the fix to the branch:
61
+ ```bash
62
+ git commit -m "fix(coreview): resolve <issue summary>"
63
+ git push origin <branch-name>
64
+ ```
65
+ 4. Cherry-pick the new fix commit to all other active environment branches (`main`, `staging`).
66
+ 5. Post a resolution note on GitLab citing the commit hash:
67
+ ```bash
68
+ glab mr note <mr-id> --repo <repo> -m "Fixed in commit <commit-hash>: <technical explanation of the resolution>"
69
+ ```
70
+
71
+ ### Case B: Feedback is HALU (False Positive / Hallucinated)
72
+ - **Criteria**:
73
+ - The bot suggests calling an API, library method, or hook that does not exist in the codebase or standard library.
74
+ - The bot flags intentional architecture or established framework patterns as "errors".
75
+ - The bot proposes invalid TypeScript syntax or breaks existing type contracts.
76
+ - The bot misinterprets domain-specific business logic already agreed in the Goal Contract.
77
+ - **Action Plan**:
78
+ 1. **DO NOT modify any code.**
79
+ 2. Post a polite, evidence-backed technical rebuttal on the GitLab note explaining why the suggestion is invalid:
80
+ ```bash
81
+ glab mr note <mr-id> --repo <repo> -m "Feedback is invalid / false positive: <detailed technical explanation with file citations>."
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 5. Anti-Pattern: Blind Compliance
87
+
88
+ Agents must **never** rewrite working, verified code solely because an automated review bot posted a comment. If the bot's suggestion violates the [Goal Contract](file:///Users/egagofur/Development/work/ai-engineering-loop/core/goal-contract.md) or introduces broken dependencies, it MUST be triaged as `HALU` with evidence.
@@ -0,0 +1,128 @@
1
+ # DOT Adapter: GitLab Integration (`glab`)
2
+
3
+ ## 1. Purpose & Scope
4
+
5
+ This module encapsulates all GitLab operations within the DOT ecosystem. Once a code change has successfully passed the [Generic AI Engineering Loop](file:///Users/egagofur/Development/work/ai-engineering-loop/README.md), this adapter automates issue tracking and Merge Request (MR) generation via the `glab` CLI.
6
+
7
+ ---
8
+
9
+ ## 2. Step-by-Step GitLab Workflow
10
+
11
+ ```mermaid
12
+ flowchart TD
13
+ Pass([Core Loop PASS]) --> CheckIssue{Issue Exists?}
14
+
15
+ CheckIssue -->|No| CreateIssue[Create GitLab Issue Card via glab]
16
+ CheckIssue -->|Yes| UseIssue[Capture Existing Issue URL]
17
+
18
+ CreateIssue --> PushBranch[Push Working Branch to Remote]
19
+ UseIssue --> PushBranch
20
+
21
+ PushBranch --> CreateMR[Create Merge Request via glab]
22
+ CreateMR --> CaptureMR[Capture MR URL & ID for Multi-Branch / Bot Triage]
23
+ ```
24
+
25
+ ---
26
+
27
+ ## 3. Step 1: Git Context & Remote Repository Inspection
28
+
29
+ 1. Check current branch and git status:
30
+ ```bash
31
+ git status
32
+ git log -n 5 --stat
33
+ ```
34
+ 2. Determine repository path and remote URLs:
35
+ ```bash
36
+ git remote -v
37
+ ```
38
+ 3. Push working branch to remote:
39
+ ```bash
40
+ git push -u origin <branch-name>
41
+ ```
42
+
43
+ ---
44
+
45
+ ## 4. Step 2: GitLab Issue Card Generation
46
+
47
+ ### A. Check for Existing Issue
48
+ - Look for an existing issue number in:
49
+ - Branch name (e.g. `issue-235-...`, `fix/300-...`).
50
+ - Commit message (e.g. `fix(#300): ...`, `Refs #300`).
51
+ - Search open issues:
52
+ ```bash
53
+ glab issue list --repo <repo> --search "<keywords>"
54
+ ```
55
+
56
+ ### B. Create Standardized Issue Card
57
+ If no issue exists, create one in the designated tracker (e.g. `dot-system/dotify-new` for central Dotify tracker, or the target repository):
58
+
59
+ ```bash
60
+ glab issue create \
61
+ --repo <target-issue-repo> \
62
+ --title "[<Module>] <Summary>" \
63
+ --description "<Issue Description Markdown>" \
64
+ --assignee <username> \
65
+ --label "Ready to Test" \
66
+ --yes
67
+ ```
68
+
69
+ #### Standardized Issue Description Template:
70
+ ```markdown
71
+ ## Issue Description
72
+ [Detailed description of the bug or feature, explaining root cause and business impact.]
73
+
74
+ ## Scope
75
+ - [x] [Component 1 modified]
76
+ - [x] [Component 2 modified]
77
+ - [x] [Unit tests added in path/to/test.ts]
78
+
79
+ ## Testing Steps
80
+ 1. Login as [User Role / Email].
81
+ 2. Navigate to [Target Menu / URL].
82
+ 3. Perform [Action e.g. submit attendance, clock-in, approve overtime].
83
+ 4. Verify [Expected Result].
84
+
85
+ ## Expectation
86
+ | Kondisi / Skenario | Logika Lama (Sebelum) | Logika Baru (Sesudah) |
87
+ |---|---|---|
88
+ | [Scenario 1] | [Incorrect status/error] | [Correct expected status] |
89
+ | [Scenario 2] | [Unhandled edge case] | [Properly handled] |
90
+
91
+ ## Notes
92
+ - Base branch: `<target-base>`
93
+ - Verified with automated test suites.
94
+ ```
95
+
96
+ ---
97
+
98
+ ## 5. Step 3: Base Merge Request Creation
99
+
100
+ Create the primary Merge Request targeting the base branch (`main`, `staging`, or `develop`):
101
+
102
+ ```bash
103
+ glab mr create \
104
+ --repo <current-repo> \
105
+ --source-branch <branch-name> \
106
+ --target-branch <target-branch> \
107
+ --title "<type>(<scope>): <short description>" \
108
+ --description "<MR Description Markdown>" \
109
+ --assignee <username> \
110
+ --yes
111
+ ```
112
+
113
+ #### Standardized MR Description Template:
114
+ ```markdown
115
+ ## Issue
116
+ <GitLab Issue URL>
117
+
118
+ ## What did you do?
119
+ - <Concise point 1 explaining root cause fix>
120
+ - <Concise point 2 explaining edge cases handled>
121
+ - <Concise point 3 mentioning unit test coverage>
122
+
123
+ ## Screenshot / Video
124
+ <!-- Attach screenshots, terminal test logs, or UI captures if available -->
125
+
126
+ ## Note for Deployment
127
+ - No manual database migrations required. (or specify migration command if applicable)
128
+ ```
@@ -0,0 +1,102 @@
1
+ # DOT Adapter: Mattermost Notifications
2
+
3
+ ## 1. Overview & Objectives
4
+
5
+ The **Mattermost Notification Module** formats final release notes and automatically delivers them to designated team channels via the Mattermost MCP server or CLI.
6
+
7
+ This provides seamless visibility to QA engineers, product managers, and reviewers upon successful completion of the delivery pipeline.
8
+
9
+ ---
10
+
11
+ ## 2. Channel Resolution & Dispatch Flow
12
+
13
+ ```mermaid
14
+ flowchart TD
15
+ Complete[MRs Created Across Environments] --> CheckMap[Check /Users/egagofur/.gemini/config/mattermost-channel-mapping.json]
16
+
17
+ CheckMap --> Found{Channel Found for Repo?}
18
+
19
+ Found -->|Yes| Dispatch[Dispatch via MCP mattermost_send_message]
20
+ Found -->|No| PromptUser[Ask User for Target Channel]
21
+
22
+ PromptUser --> SaveMap[Save New Channel to mattermost-channel-mapping.json]
23
+ SaveMap --> Dispatch
24
+
25
+ Dispatch --> CheckMCP{MCP Success?}
26
+ CheckMCP -->|Yes| Done([Notification Complete])
27
+ CheckMCP -->|No / Failed| FallbackCLI[Fallback to Mattermost Agent CLI]
28
+ FallbackCLI --> Done
29
+ ```
30
+
31
+ ---
32
+
33
+ ## 3. Mandatory Attribution Rule
34
+
35
+ > [!IMPORTANT]
36
+ > When sending messages or replying to threads on Mattermost (via MCP tools or CLI):
37
+ > - **Always** include the sender attribution parameter (`from: "AI Agent"`) in MCP calls:
38
+ > ```json
39
+ > {
40
+ > "channel": "internal-dotify",
41
+ > "message": "...",
42
+ > "from": "AI Agent"
43
+ > }
44
+ > ```
45
+ > - **Always** include the CLI flag (`--from "AI Agent"`) in CLI calls:
46
+ > ```bash
47
+ > node /Users/egagofur/Development/work/kontribusi/mattermost-agent/dist/cli/index.js send <channel> "<message>" --from "AI Agent"
48
+ > ```
49
+ > - Do not omit or suppress sender attribution.
50
+
51
+ ---
52
+
53
+ ## 4. Channel Resolution Logic
54
+
55
+ 1. **Inspect Mapping File**:
56
+ Read `/Users/egagofur/.gemini/config/mattermost-channel-mapping.json` using the current repository name or project slug (e.g. `dotify-new`, `dotify-api`, `dot-system/dotify-new`).
57
+ 2. **Channel Found**:
58
+ Dispatch message to the mapped channel name (e.g. `"internal-dotify"`).
59
+ 3. **Channel Unknown**:
60
+ - **DO NOT GUESS** or broadcast to arbitrary channels.
61
+ - Ask the user to specify the target channel for this repository.
62
+ - Immediately persist the user's answer into `/Users/egagofur/.gemini/config/mattermost-channel-mapping.json` for future automated runs.
63
+
64
+ ---
65
+
66
+ ## 5. Standardized Mattermost Markdown Report Format
67
+
68
+ Render separate, ready-to-copy Markdown blocks for every generated Merge Request:
69
+
70
+ ```text
71
+ [MR <ENV_TAG>] <MR_URL>
72
+ Changes log
73
+ - <Concise change point 1>
74
+ - <Concise change point 2>
75
+ - <Concise change point 3>
76
+ ```
77
+
78
+ ### Environment Tags:
79
+ - `[MR DEV]`: Merge Request targeting `develop`.
80
+ - `[MR STAGING]`: Merge Request targeting `staging`.
81
+ - `[MR MAIN]` (or `[MR PROD]`): Merge Request targeting `main` / `master`.
82
+
83
+ ### Example Report:
84
+ ```text
85
+ [MR DEV] https://gitlab.dot.co.id/dot-system/dotify-new/-/merge_requests/948
86
+ Changes log
87
+ - Include user.type.hasNormalHours and timeEntities.overtimeNote in attendanceConfirmationPagination Prisma query.
88
+ - Create resolveAttendanceConfirmationDisplayStatus utility to properly evaluate hasPendingTimeEntities by checking overtimeNote, isWeekend, duration > 8, non-normal hours employees, and null statuses.
89
+ - Add comprehensive unit tests in src/server/attendance-confirmations/utils/resolve-display-status.test.ts covering all status permutations.
90
+
91
+ [MR STAGING] https://gitlab.dot.co.id/dot-system/dotify-new/-/merge_requests/947
92
+ Changes log
93
+ - Include user.type.hasNormalHours and timeEntities.overtimeNote in attendanceConfirmationPagination Prisma query.
94
+ - Create resolveAttendanceConfirmationDisplayStatus utility to properly evaluate hasPendingTimeEntities by checking overtimeNote, isWeekend, duration > 8, non-normal hours employees, and null statuses.
95
+ - Add comprehensive unit tests in src/server/attendance-confirmations/utils/resolve-display-status.test.ts covering all status permutations.
96
+
97
+ [MR MAIN] https://gitlab.dot.co.id/dot-system/dotify-new/-/merge_requests/946
98
+ Changes log
99
+ - Include user.type.hasNormalHours and timeEntities.overtimeNote in attendanceConfirmationPagination Prisma query.
100
+ - Create resolveAttendanceConfirmationDisplayStatus utility to properly evaluate hasPendingTimeEntities by checking overtimeNote, isWeekend, duration > 8, non-normal hours employees, and null statuses.
101
+ - Add comprehensive unit tests in src/server/attendance-confirmations/utils/resolve-display-status.test.ts covering all status permutations.
102
+ ```