Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
9f2253c
fix(brain): improve session-start recall queries with type filters
Snider Mar 15, 2026
9df5ed1
feat(docker): local development stack for community onboarding
Snider Mar 15, 2026
7da0294
refactor: restructure agents → prompts/personas, add plan templates
Snider Mar 15, 2026
6045805
feat(plugin): add dispatch, status, recall, scan commands
Snider Mar 15, 2026
d3bbda3
fix(plugin): prefix commands with core: namespace to avoid clashes
Snider Mar 15, 2026
4c0c5f6
chore: update GEMINI.md
Snider Mar 15, 2026
3ac81d4
chore: sync go.mod dependencies
Snider Mar 15, 2026
f0cb5dd
chore: update dependencies
Snider Mar 15, 2026
99e8456
feat: add agents.yaml config for dispatch concurrency control
Snider Mar 15, 2026
290a582
feat(plugin): add review and sweep commands, update dispatch with per…
Snider Mar 15, 2026
03b77bd
fix(plugin): drop core: prefix — commands use code: namespace from dir
Snider Mar 15, 2026
4d43b4c
fix(plugin): restore core: prefix on commands
Snider Mar 15, 2026
4373af1
fix(plugin): use bare command names — plugin adds code: prefix automa…
Snider Mar 15, 2026
afbc915
rename: claude/code → claude/core for /core: command namespace
Snider Mar 15, 2026
fd7be94
fix(plugin): rename plugin from code → core for /core: namespace
Snider Mar 15, 2026
86040da
chore(plugin): bump version to 0.3.0 for core/ rename
Snider Mar 15, 2026
7321262
fix(plugin): update marketplace listing code → core, bump to v0.3.0
Snider Mar 15, 2026
e77140a
feat: per-agent concurrency — claude: 1, gemini: 3, codex: 1
Snider Mar 15, 2026
e6dbce3
feat: rate config for quota-aware scheduling — gemini burst/sustained…
Snider Mar 15, 2026
670e4c9
feat(templates): add 5 audit templates for self-healing codebase
Snider Mar 15, 2026
cce41fa
fix(plugin): remove block-docs hook — was blocking specs and RFCs
Snider Mar 16, 2026
88e5fc6
refactor(plugin): remove restrictive hooks, clean up orphaned scripts
Snider Mar 16, 2026
54e9fe0
chore: bump core plugin to v0.4.0 (hook cleanup)
Snider Mar 16, 2026
225b0b4
feat(issues): phase 2 — migration, models, routes for issue tracker
Snider Mar 16, 2026
5a0b126
feat(issues): phase 3 — Actions and API controllers for issues and sp…
Snider Mar 16, 2026
12a22aa
test(issues): phase 5 — feature tests for Issue and Sprint models and…
Snider Mar 16, 2026
0b8d7b1
fix(issues): use workspace_id from middleware, not workspace object
Snider Mar 16, 2026
d659f1c
chore: reduce gemini concurrency to 1 (free tier quota)
Snider Mar 16, 2026
796eb83
feat: add local-agent.sh wrapper + local concurrency config
Snider Mar 16, 2026
d153787
fix: add keep_alive to local-agent.sh — unloads model after 5m idle
Snider Mar 16, 2026
a389388
feat(ui): core-agent-panel Lit custom element
Snider Mar 16, 2026
e359522
feat(issues): add epic type
Snider Mar 16, 2026
0f12156
docs: Charon onboarding guide — ecosystem changes March 2026
Snider Mar 16, 2026
84e2b62
feat: core-agent MCP binary using core/mcp subsystems
Snider Mar 16, 2026
2ea5095
refactor: move brain + agentic packages into core/agent, use core/cli
Snider Mar 16, 2026
5fbaf4f
fix(brain): use hostname-based agent_id instead of hardcoded cladius
Snider Mar 16, 2026
85dd055
fix(brain): shared brain — don't filter by agent_id on recall
Snider Mar 16, 2026
37f6d61
feat: agent messaging — direct chronological messages between agents
Snider Mar 16, 2026
ec6b07d
chore: bump plugin to v0.5.0 (agent messaging)
Snider Mar 16, 2026
7b8b93b
feat: merge review/verify into core plugin, add messaging MCP tools
Snider Mar 16, 2026
5f83cf9
fix: messaging routes use auth.api, fix InboxInput schema
Snider Mar 16, 2026
4e8fff6
chore: update core/mcp, drop go-ml/go-duckdb dependency
Snider Mar 16, 2026
267a5e5
fix(dispatch): use --output-format text for claude agent logging
Snider Mar 16, 2026
42788a2
refactor(dispatch): use go-process for agent spawning
Snider Mar 16, 2026
56397d7
chore: bump claude concurrency to 3, activate charon
Snider Mar 16, 2026
5eb26f9
refactor: replace fmt.Errorf/os.* with go-io/go-log conventions
Snider Mar 16, 2026
662217c
chore: sync dependencies for v0.3.3
Snider Mar 16, 2026
58749c8
feat: agent completion events + plugin hooks
Snider Mar 17, 2026
cb56cfb
fix: initialise go-process for dispatch, fix Notification hook matcher
Snider Mar 17, 2026
67705e2
fix: remove SessionStart completion check, keep idle_prompt only
Snider Mar 17, 2026
da1c45b
feat: sandbox dispatched agents to workspace directory
Snider Mar 17, 2026
71decc2
feat: auto-create PR on Forge after agent completion
Snider Mar 17, 2026
132ade1
feat: add agentic_watch tool with MCP progress notifications
Snider Mar 17, 2026
0ca253f
feat: add monitor subsystem — background ecosystem watcher
Snider Mar 17, 2026
99733bd
chore: bump plugin to v0.7.0
Snider Mar 17, 2026
ccfd68c
feat: fire resource subscription notification on agent status change
Snider Mar 17, 2026
c639a84
fix: PID polling fallback for process completion detection
Snider Mar 17, 2026
b95a367
feat: add check-inbox.sh with marker-based change detection
Snider Mar 17, 2026
90b0319
feat(agent): v0.2.0 — HTTP daemon, remote dispatch, review queue, ver…
Snider Mar 17, 2026
0622982
chore: bump plugin to v0.9.0, update description and keywords
Snider Mar 17, 2026
e677d15
fix: remove hardcoded paths, gitignore binaries
Snider Mar 17, 2026
317be4c
fix: use CORE_WORKSPACE env var in shell scripts, fallback to ~/Code/…
Snider Mar 17, 2026
06b7213
chore: add .mcp.json for Claude Code MCP integration
Snider Mar 17, 2026
462d512
fix: plugin provides local core-agent MCP (not remote mcp.lthn.sh)
Snider Mar 17, 2026
7a75a39
chore: bump plugin to v0.10.0
Snider Mar 17, 2026
8c76f49
fix: bump marketplace.json to v0.10.0, fix hooks.json structure, remo…
Snider Mar 17, 2026
327d78d
fix: config search uses CoreRoot() — ~/Code/.core/agents.yaml
Snider Mar 17, 2026
742ca07
fix: remove all hardcoded machine paths from Go code
Snider Mar 17, 2026
7248928
refactor: remove 28K lines of dead/legacy code
Snider Mar 17, 2026
4832827
fix: address code review findings (critical + high)
Snider Mar 17, 2026
6d04c89
fix: address all code review findings (medium + low)
Snider Mar 17, 2026
e66ea05
fix: address re-review findings — nil pointer, races, curl, clone error
Snider Mar 17, 2026
8c16258
refactor: simplify internals — consolidate, deduplicate, fix bugs
Snider Mar 17, 2026
81be471
feat: add mandatory closeout sequence to coding template
Snider Mar 17, 2026
1b4b0bf
feat: add core:agent-task-code-review and core:agent-task-code-simpli…
Snider Mar 17, 2026
1e351f3
feat: embed prompts into pkg/prompts via go:embed
Snider Mar 17, 2026
977feb0
refactor: strip redundant folder prefix from persona filenames
Snider Mar 17, 2026
d9cd7f9
feat: split security persona into functional roles
Snider Mar 17, 2026
1716122
feat: restructure personas — domain as context, role as lens
Snider Mar 17, 2026
73fa4ba
feat: expand personas with cross-domain functional roles
Snider Mar 17, 2026
9f4afb9
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
Snider Mar 17, 2026
a1c2ed2
refactor: move prompt templates from Go strings to embedded markdown
Snider Mar 17, 2026
f1e1c08
refactor: restructure personas into semantic task-based domains
Snider Mar 17, 2026
433deb1
refactor: split templates/ into prompts/, tasks/, flows/
Snider Mar 17, 2026
fe98fcc
feat: add build flow specs for 9 languages/tools
Snider Mar 17, 2026
aed8226
refactor: singular naming + task/code/ namespace
Snider Mar 17, 2026
e7b47bf
feat: TaskBundle — task file + directory of additionals
Snider Mar 17, 2026
85bdf26
feat: add orchestration skills + local dispatch scripts
Snider Mar 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 4 additions & 16 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,10 @@
},
"plugins": [
{
"name": "code",
"source": "./claude/code",
"description": "Core development hooks, auto-approve workflow, and research data collection",
"version": "0.2.0"
},
{
"name": "review",
"source": "./claude/review",
"description": "Code review automation - PR review, security checks",
"version": "0.2.0"
},
{
"name": "verify",
"source": "./claude/verify",
"description": "Work verification - ensure tests pass, no debug statements",
"version": "0.1.0"
"name": "core",
"source": "./claude/core",
"description": "Core agent platform — dispatch (local + remote), verify+merge, CodeRabbit/Codex review queue, GitHub mirror, cross-agent messaging, OpenBrain integration",
"version": "0.10.0"
},
{
"name": "core-php",
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
.idea/
.core/
docker/.env
ui/node_modules
# Compiled binaries
core-agent
mcp
*.exe
9 changes: 9 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"mcpServers": {
"core": {
"type": "stdio",
"command": "core-agent",
"args": ["mcp"]
}
}
}
215 changes: 95 additions & 120 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,163 +1,138 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This file provides guidance to Claude Code when working with code in this repository.

## Overview
## Session Context

**core-agent** is a polyglot monorepo (Go + PHP) for AI agent orchestration. The Go side handles agent-side execution, CLI commands, and autonomous agent loops. The PHP side (Laravel package `lthn/agent`) provides the backend API, persistent storage, multi-provider AI services, and admin panel. They communicate via REST API.
Running on **Claude Max20 plan** with **1M context window** (Opus 4.6).

The repo also contains Claude Code plugins (5), Codex plugins (13), a Gemini CLI extension, and two MCP servers.
## Overview

## Core CLI — Always Use It
**core-agent** is the AI agent orchestration platform for the Core ecosystem. Single Go binary (`core-agent`) that runs as an MCP server — either via stdio (Claude Code integration) or HTTP daemon (cross-agent communication).

**Never use raw `go`, `php`, or `composer` commands.** The `core` CLI wraps both toolchains and is enforced by PreToolUse hooks that will block violations.
**Module:** `forge.lthn.ai/core/agent`

| Instead of... | Use... |
|---------------|--------|
| `go test` | `core go test` |
| `go build` | `core build` |
| `go fmt` | `core go fmt` |
| `go vet` | `core go vet` |
| `golangci-lint` | `core go lint` |
| `composer test` / `./vendor/bin/pest` | `core php test` |
| `./vendor/bin/pint` / `composer lint` | `core php fmt` |
| `./vendor/bin/phpstan` | `core php stan` |
| `php artisan serve` | `core php dev` |
## Build & Test

## Build & Test Commands
```bash
go build ./... # Build all packages
go build ./cmd/core-agent/ # Build the binary
go test ./... -count=1 -timeout 60s # Run tests
go vet ./... # Vet
go install ./cmd/core-agent/ # Install to $GOPATH/bin
```

Cross-compile for Charon (Linux):
```bash
# Go
core go test # Run all Go tests
core go test --run TestMemoryRegistry_Register_Good # Run single test
core go qa # Full QA: fmt + vet + lint + test
core go qa full # QA + race detector + vuln scan
core go cov # Test coverage
core build # Verify Go packages compile

# PHP
core php test # Run Pest suite
core php test --filter=AgenticManagerTest # Run specific test file
core php fmt # Format (Laravel Pint)
core php stan # Static analysis (PHPStan)
core php qa # Full PHP QA pipeline

# MCP servers (standalone builds)
cd cmd/mcp && go build -o agent-mcp . # Stdio MCP server
cd google/mcp && go build -o google-mcp . # HTTP MCP server (port 8080)

# Workspace
make setup # Full bootstrap (deps + core + clone repos)
core dev health # Status across repos
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o core-agent-linux ./cmd/core-agent/
```

## Architecture

```
Forgejo
|
[ForgejoSource polls]
|
v
+-- Go: jobrunner Poller --+ +-- PHP: Laravel Backend --+
| ForgejoSource | | AgentApiController |
| DispatchHandler ---------|----->| /v1/plans |
| CompletionHandler | | /v1/sessions |
| ResolveThreadsHandler | | /v1/plans/*/phases |
+--------------------------+ +-------------+------------+
|
[Eloquent models]
AgentPlan, AgentPhase,
AgentSession, BrainMemory
cmd/core-agent/main.go Entry point (mcp + serve commands)
pkg/agentic/ MCP tools — dispatch, verify, remote, mirror, review queue
pkg/brain/ OpenBrain — recall, remember, messaging
pkg/monitor/ Background monitoring + repo sync
pkg/prompts/ Embedded templates + personas (go:embed)
```

### Go Packages (`pkg/`)
### Binary Modes

- **`lifecycle/`** — Core domain layer. Task, AgentInfo, Plan, Phase, Session types. Agent registry (Memory/SQLite/Redis backends), task router (capability matching + load scoring), allowance system (quota enforcement), dispatcher (orchestrates dispatch with exponential backoff), event system, brain (vector store), context (git integration).
- **`loop/`** — Autonomous agent reasoning engine. Prompt-parse-execute cycle against any `inference.TextModel` with tool calling and streaming.
- **`orchestrator/`** — Clotho protocol for dual-run verification and agent orchestration.
- **`jobrunner/`** — Poll-dispatch engine for agent-side work execution. Polls Forgejo for work items, executes phases, reports results.
- `core-agent mcp` — stdio MCP server for Claude Code
- `core-agent serve` — HTTP daemon (Charon, CI, cross-agent). PID file, health check, registry.

### Go Commands (`cmd/`)
### MCP Tools (33)

- **`tasks/`** — `core ai tasks`, `core ai task [id]` — task management
- **`agent/`** — `core ai agent` — agent machine management (add, list, status, fleet)
- **`dispatch/`** — `core ai dispatch` — work queue processor (watch, run)
- **`workspace/`** — `core workspace task`, `core workspace agent` — git worktree isolation
- **`mcp/`** — Standalone stdio MCP server exposing `marketplace_list`, `marketplace_plugin_info`, `core_cli`, `ethics_check`
| Category | Tools |
|----------|-------|
| Dispatch | `agentic_dispatch`, `agentic_dispatch_remote`, `agentic_status`, `agentic_status_remote` |
| Workspace | `agentic_prep_workspace`, `agentic_resume`, `agentic_watch` |
| PR/Review | `agentic_create_pr`, `agentic_list_prs`, `agentic_create_epic`, `agentic_review_queue` |
| Mirror | `agentic_mirror` (Forge → GitHub sync) |
| Scan | `agentic_scan` (Forge issues) |
| Brain | `brain_recall`, `brain_remember`, `brain_forget` |
| Messaging | `agent_send`, `agent_inbox`, `agent_conversation` |
| Plans | `agentic_plan_create`, `agentic_plan_read`, `agentic_plan_update`, `agentic_plan_delete`, `agentic_plan_list` |
| Files | `file_read`, `file_write`, `file_edit`, `file_delete`, `file_rename`, `file_exists`, `dir_list`, `dir_create` |
| Language | `lang_detect`, `lang_list` |

### PHP (`src/php/`)
### Agent Types

- **Namespace**: `Core\Mod\Agentic\` (service provider: `Boot`)
- **Models/** — 19 Eloquent models (AgentPlan, AgentPhase, AgentSession, BrainMemory, Task, Prompt, etc.)
- **Services/** — AgenticManager (multi-provider: Claude/Gemini/OpenAI), BrainService (Ollama+Qdrant), ForgejoService, AI services with stream parsing and retry traits
- **Controllers/** — AgentApiController (REST endpoints)
- **Actions/** — Single-purpose action classes (Brain, Forge, Phase, Plan, Session, Task)
- **View/** — Livewire admin panel components (Dashboard, Plans, Sessions, ApiKeys, Templates, Playground, etc.)
- **Mcp/** — MCP tool implementations (Brain, Content, Phase, Plan, Session, State, Task, Template)
- **Migrations/** — 10 migrations (run automatically on boot)
| Agent | Command | Use |
|-------|---------|-----|
| `claude:opus` | Claude Code | Complex coding, architecture |
| `claude:sonnet` | Claude Code | Standard tasks |
| `claude:haiku` | Claude Code | Quick/cheap tasks, discovery |
| `gemini` | Gemini CLI | Fast batch ops |
| `codex` | Codex CLI | Autonomous coding |
| `codex:review` | Codex review | Deep security analysis |
| `coderabbit` | CodeRabbit CLI | Code quality review |

## Claude Code Plugins (`claude/`)
### Dispatch Flow

Five plugins installable individually or via marketplace:
```
dispatch → agent works → closeout sequence (review → fix → simplify → re-review)
→ commit → auto PR → inline tests → pass → auto-merge on Forge
→ push to GitHub → CodeRabbit reviews → merge or dispatch fix agent
```

| Plugin | Commands |
|--------|----------|
| **code** | `/code:remember`, `/code:yes`, `/code:qa` |
| **review** | `/review:review`, `/review:security`, `/review:pr`, `/review:pipeline` |
| **verify** | `/verify:verify`, `/verify:ready`, `/verify:tests` |
| **qa** | `/qa:qa`, `/qa:fix`, `/qa:check`, `/qa:lint` |
| **ci** | `/ci:ci`, `/ci:workflow`, `/ci:fix`, `/ci:run`, `/ci:status` |
### Personas (pkg/prompts/lib/personas/)

### Hooks (code plugin)
116 personas across 16 domains. Path = context, filename = lens.

**PreToolUse**: `prefer-core.sh` blocks destructive operations (`rm -rf`, `sed -i`, `xargs rm`, `find -exec rm`, `grep -l | ...`, `mv/cp *`) and raw go/php commands. `block-docs.sh` prevents random `.md` file creation.
```
prompts.Persona("engineering/security-developer") # code-level security review
prompts.Persona("smm/security-secops") # social media incident response
prompts.Persona("devops/senior") # infrastructure architecture
```

**PostToolUse**: Auto-formats Go (`gofmt`) and PHP (`pint`) after edits. Warns about debug statements (`dd()`, `dump()`, `fmt.Println()`).
### Templates (pkg/prompts/lib/templates/)

**PreCompact**: Saves session state. **SessionStart**: Restores session context.
Prompt templates for different task types: `coding`, `conventions`, `security`, `verify`, plus YAML plan templates (`bug-fix`, `code-review`, `new-feature`, `refactor`, etc.)

## Other Directories
## Key Patterns

- **`codex/`** — 13 Codex plugins mirroring Claude structure plus ethics, guardrails, perf, issue, coolify, awareness
- **`agents/`** — 13 specialist agent categories (design, engineering, marketing, product, testing, etc.) with example configs and system prompts
- **`google/gemini-cli/`** — Gemini CLI extension (TypeScript, `npm run build`)
- **`google/mcp/`** — HTTP MCP server exposing `core_go_test`, `core_dev_health`, `core_dev_commit`
- **`docs/`** — `architecture.md` (deep dive), `development.md` (comprehensive dev guide), `docs/plans/` (design documents)
- **`scripts/`** — Environment setup scripts (`install-core.sh`, `install-deps.sh`, `agent-runner.sh`, etc.)
### Shared Paths (pkg/agentic/paths.go)

## Testing Conventions
All paths use `CORE_WORKSPACE` env var, fallback `~/Code/.core`:
- `WorkspaceRoot()` — agent workspaces
- `CoreRoot()` — ecosystem config
- `PlansRoot()` — agent plans
- `AgentName()` — `AGENT_NAME` env or hostname detection
- `GitHubOrg()` — `GITHUB_ORG` env or "dAppCore"

### Go
### Error Handling

Uses `testify/assert` and `testify/require`. Name tests with suffixes:
- `_Good` — happy path
- `_Bad` — expected error conditions
- `_Ugly` — panics and edge cases
`coreerr.E("pkg.Method", "message", err)` from go-log. Always 3 args. NEVER `fmt.Errorf`.

Use `require` for preconditions (stops on failure), `assert` for verifications (reports all failures).
### File I/O

### PHP
`coreio.Local.Read/Write/EnsureDir` from go-io. `WriteMode(path, content, 0600)` for sensitive files. NEVER `os.ReadFile/WriteFile`.

Pest with Orchestra Testbench. Feature tests use `RefreshDatabase`. Helpers: `createWorkspace()`, `createApiKey($workspace, ...)`.
### HTTP Responses

## Coding Standards
Always check `err != nil` BEFORE accessing `resp.StatusCode`. Split into two checks.

## Plugin (claude/core/)

The Claude Code plugin provides:
- **MCP server** via `mcp.json` (auto-registers core-agent)
- **Hooks** via `hooks.json` (PostToolUse inbox notifications, auto-format, debug warnings)
- **Agents**: `agent-task-code-review`, `agent-task-code-simplifier`
- **Commands**: dispatch, status, review, recall, remember, scan, etc.
- **Skills**: security review, architecture review, test analysis, etc.

- **UK English**: colour, organisation, centre, licence, behaviour
- **Go**: standard `gofmt`, errors via `core.E("scope.Method", "what failed", err)`
- **PHP**: `declare(strict_types=1)`, full type hints, PSR-12 via Pint, Pest syntax for tests
- **Shell**: `#!/bin/bash`, JSON input via `jq`, output `{"decision": "approve"|"block", "message": "..."}`
- **Commits**: conventional — `type(scope): description` (e.g. `feat(lifecycle): add exponential backoff`)
- **Licence**: EUPL-1.2 CIC
## Testing Conventions

## Prerequisites
- `_Good` — happy path
- `_Bad` — expected error conditions
- `_Ugly` — panics and edge cases
- Use `testify/assert` + `testify/require`

| Tool | Version | Purpose |
|------|---------|---------|
| Go | 1.26+ | Go packages, CLI, MCP servers |
| PHP | 8.2+ | Laravel package, Pest tests |
| Composer | 2.x | PHP dependencies |
| `core` CLI | latest | Wraps Go/PHP toolchains (enforced by hooks) |
| `jq` | any | JSON parsing in shell hooks |
## Coding Standards

Go module is `forge.lthn.ai/core/agent`, participates in a Go workspace (`go.work`) resolving all `forge.lthn.ai/core/*` dependencies locally.
- **UK English**: colour, organisation, centre, initialise
- **Commits**: `type(scope): description` with `Co-Authored-By: Virgil <virgil@lethean.io>`
- **Licence**: EUPL-1.2
- **SPDX**: `// SPDX-License-Identifier: EUPL-1.2` on every file
56 changes: 56 additions & 0 deletions CODEX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# CODEX.md

Instructions for OpenAI Codex when working in the Core ecosystem.

## MCP Tools Available

You have access to core-agent MCP tools. Use them:

- `brain_recall` — Search OpenBrain for context about any package, pattern, or decision
- `brain_remember` — Store what you learn for other agents (Claude, Gemini, future LEM)
- `agentic_dispatch` — Dispatch tasks to other agents
- `agentic_status` — Check agent workspace status

**ALWAYS `brain_remember` significant findings** — your deep analysis of package internals, error patterns, security observations. This builds the shared knowledge base.

## Core Ecosystem Conventions

### Go Packages (forge.lthn.ai/core/*)

- **Error handling**: `coreerr.E("pkg.Method", "what failed", err)` from `go-log`. NEVER `fmt.Errorf` or `errors.New`.
- Import as: `coreerr "forge.lthn.ai/core/go-log"`
- Always 3 args: operation, message, cause (use `nil` if no cause)
- `coreerr.E` returns `*log.Err` which implements `error` and `Unwrap()`

- **File I/O**: `coreio.Local.Read/Write/Delete/EnsureDir` from `go-io`. NEVER `os.ReadFile/WriteFile/MkdirAll`.
- Import as: `coreio "forge.lthn.ai/core/go-io"`
- Security: go-io validates paths, prevents traversal

- **Process management**: `go-process` for spawning external commands. Supports Timeout, GracePeriod, KillGroup.

- **UK English**: colour, organisation, centre, initialise (never American spellings)

- **Test naming**: `TestFoo_Good` (happy path), `TestFoo_Bad` (expected errors), `TestFoo_Ugly` (panics/edge cases)

- **Commits**: `type(scope): description` with `Co-Authored-By: Virgil <virgil@lethean.io>`

### PHP Packages (CorePHP)

- **Actions pattern**: Single-purpose classes with `use Action` trait, static `::run()` helper
- **Tenant isolation**: `BelongsToWorkspace` trait on ALL models with tenant data
- **Strict types**: `declare(strict_types=1)` in every file
- **Testing**: Pest syntax, not PHPUnit

## Review Focus Areas

When reviewing code, prioritise:

1. **Security**: Path traversal, injection, hardcoded secrets, unsafe input
2. **Error handling**: coreerr.E() convention compliance
3. **File I/O**: go-io usage, no raw os.* calls
4. **Tenant isolation**: BelongsToWorkspace on all tenant models (PHP)
5. **Test coverage**: Are critical paths tested?

## Training Data

Your reviews generate training data for LEM (our fine-tuned model). Be thorough and structured in your findings — every observation helps improve the next generation of reviews.
Loading