# Decisions Log (ADRs)

> Significant, durable architectural/product decisions. Append-only — supersede, never rewrite.

_Compiled 2026-07-23 from repo-verified sources (`TD_001_005_VERIFICATION_PACKAGE.md`, `FINAL_REPOSITORY_ANSWERS.md`, code)._

---

### DR-001: Execution ownership — Numu is the authoritative executor 🔒 LOCKED
- **Decision:** Numu is the authoritative **business-action executor**; Make.com is the **orchestration + AI reasoning** layer only.
- **Consequence:** After approval, Numu executes via `AgentActionExecutor` → canonical `Startup/InvestorLabelActionService`.
- **Supersedes:** earlier docs describing Make as the executor (see [`deprecated.md`](deprecated.md)).
- **Status:** Accepted / locked. (Exact Make re-validation split: Unknown - requires confirmation.)

### DR-002: MCP host is native PHP
- **Decision:** Implement the MCP protocol natively in Laravel/PHP (`AiMcpController` + `McpToolRegistry`).
- **Supersedes:** the standalone Node/TypeScript `mcp-server/` (now deprecated).

### DR-003: MCP writes apply immediately (no approval queue)
- **Decision:** The interactive MCP connector applies writes immediately; the old `change_request.submit` suggestion workflow was removed. (Governance/approval applies to the **managed-agent** runtime, not the connector.)

### DR-004: Deduplication = merge-on-insert
- **Decision:** Duplicates are absorbed into a canonical row (`additional_monday_item_ids`, `is_duplicate`); no satellite rows.
- **Supersedes:** an earlier scoring-based dedup approach.

### DR-005: No DELETE; notes/tags retention
- **Decision:** No DELETE operations are exposed **on the AI/API/MCP surface**; notes are create/edit-only there (the **admin dashboard** may delete notes — clarified by DR-010); tags are no-delete/no-detach.

### DR-006: Bilingual data with transliteration
- **Decision:** Arabic/English name pairs (`*_ar`/`*_en`) with a Claude-backed transliteration pipeline + `transliteration_cache`.

### DR-007: Dual environment enums are intentional
- **Decision:** Knowledge/Runtime use `dev/staging/production`; Decision/Policy/Agents use `dev/test/prod`. This split is by design, not a defect.

### DR-008: Knowledge Cache — single table, registry-driven, versioned
- **Decision:** One `agent_knowledge_cache` table; packages composed from `agent_knowledge_registry.json`; immutable per `(agent, environment)`; drivers `local` (default) and `graph` (inert until Azure grants access).

### DR-009: EntityNote body maximum length = 5000 (single invariant)
- **Date:** 2026-07-23
- **Status:** Accepted
- **Context:** The note-body max length diverged across write paths — Admin `NotesController` enforced 4000, while the AI/MCP `AiNoteWriteController` and the `note_create`/`note_update` MCP tool schemas enforced 5000.
- **Problem:** No single authoritative limit; the same field could accept different input depending on the channel.
- **Options considered:** (a) standardize on 4000; (b) standardize on 5000; (c) leave divergent. Chose (b).
- **Decision:** EntityNote body maximum is **5000 characters** across **all** write paths, sourced from one constant `EntityNote::BODY_MAX_LENGTH`.
- **Reason:** Single invariant across every channel; 5000 was already the AI/MCP limit and `entity_notes.body` is a `TEXT` column, so no schema change is required.
- **Impact:** `NotesController` now uses the shared constant (was 4000); `AiNoteWriteController` and the MCP tool schemas reference the same constant. No DB migration; audit/rollback behavior unchanged.
- **Affected files:** `app/Models/EntityNote.php`, `app/Http/Controllers/Admin/NotesController.php`, `app/Http/Controllers/Api/V1/Ai/AiNoteWriteController.php`, `app/Services/Ai/Mcp/McpToolRegistry.php`, `tests/Unit/EntityNoteBodyLengthTest.php`, and this log.

### DR-010: Note deletion is admin-only (AI/MCP cannot delete notes)
- **Date:** 2026-07-23
- **Status:** Accepted
- **Context:** Admin `NotesController` hard-deletes notes (`DELETE admin/notes/{note}`, `admin.auth`-gated), while the AI/API/MCP surface exposes no note deletion — yet the KB stated a blanket "notes are edit-never-delete", which was inaccurate for the admin dashboard.
- **Problem:** The documented policy contradicted the (correct) code behavior.
- **Decision:** **Admin users may delete notes.** **AI/API/MCP consumers may not** — they are create/edit-only. Deletion permissions: Admin = create/update/delete; AI/MCP = create/update, no delete.
- **Reason:** Human administrative control is deliberately broader than autonomous AI permissions; AI note operations stay non-destructive (append/edit, fully audited and rollback-able).
- **Impact:** No code change — behavior already matched. `NotesController::destroy` retained (admin-gated). No `note_delete` tool/route/agent-action exists; `AiRollbackService` refuses to reverse a note-create into a delete. KB reconciled: the blanket "edit-never-delete" replaced with the role-scoped policy.
- **Affected files:** `docs/ai/05-development/database-rules.md`, `docs/ai/07-operation/change-management.md`, `docs/ai/03-ai-agents/tools.md`, `docs/ai/03-ai-agents/permissions.md`, `docs/ai/02-business/investors.md`, `docs/ai/02-business/startups.md`, `tests/Unit/NoteDeletionPolicyTest.php`, and this log (incl. the DR-005 clarification).

### DR-011: Admin note deletion requires an audit record (hard delete retained)
- **Date:** 2026-07-23
- **Status:** Accepted
- **Context:** DR-010 keeps admin note deletion as a hard delete, but an un-audited hard delete erases history and conflicts with the platform's accountability / append-only principles.
- **Problem:** A destructive admin action left no trace of what was removed.
- **Decision:** Keep the hard delete for admins, but every admin note deletion **must write an `ActivityLog` row before removal** (action `note_deleted`) capturing the deleted note id, parent entity type/id, full body snapshot, original author, and the deleting admin. Reuses the existing `ActivityLogger` / `activity_logs` infrastructure — no soft delete, no new audit table, no migration.
- **Reason:** Preserve administrative control while maintaining accountability.
- **Impact:** Deletion remains destructive but traceable; the audit is written atomically in the same transaction as the delete (both roll back on failure). AI/MCP deletion remains unavailable (DR-010).
- **Affected files:** `app/Services/ActivityLogger.php` (new `recordNoteDeletion`), `app/Http/Controllers/Admin/NotesController.php` (`destroy` wires the audit), `tests/Feature/Notes/NoteDeletionAuditTest.php`, and the KB files below.

### DR-012: OAuth resource audiences derive from the deployment URL
- **Date:** 2026-09-06
- **Status:** Accepted
- **Context:** `OauthClaudeClientSeeder` had production MCP resource URLs hard-coded. Running the same code in development would bind OAuth access tokens to the wrong resource audience.
- **Decision:** Build the seeded MCP `allowed_resources` from `config('app.url')`, then append `/api/v1/ai/mcp/read` and `/api/v1/ai/mcp/full`.
- **Reason:** OAuth audience validation is an exact URL comparison. Development, staging, and production must each mint tokens for their own public URL without a source-code host change.
- **Impact:** Operators set the deployment `APP_URL`, run `config:cache`, and re-seed `OauthClaudeClientSeeder` for that environment. Existing OAuth tokens bound to a prior audience remain invalid for a new host and must complete the normal OAuth authorization flow again. Sanctum PAT behavior is unchanged.
- **Affected files:** `database/seeders/OauthClaudeClientSeeder.php`, `docs/NUMU_MCP_API_DOCUMENTATION.md`, `docs/postman/NUMU_MCP_ENVIRONMENT.json`, `docs/ai/07-operation/ai-api-auth-investigation.md`, and this log.

### Pending / to record
- **DR-XXX: Deal entity** — whether to introduce a first-class `Deal` domain. **Unknown - requires confirmation** (see [`../02-business/deals.md`](../02-business/deals.md)).
- **Model ID resolution** (`claude-sonnet-5`, `claude-opus-4-8`) per environment: **Unknown - requires confirmation.**
