Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# LLMint — Copilot Instructions

> Copilot acts as **Tier C — Execution Workforce** in this repository.
> Implement well-specified issues, open draft PRs, never merge or approve.

## Project Overview

**LLMint** is the token economics middleware for the Chitin platform. It tracks LLM costs, enforces budget rules, and enables model cascading. Octi Pulpo imports LLMint for dispatch budget gating.

**Core principle**: Every token has a cost. LLMint makes that cost visible and enforceable.

## Tech Stack

- **Languages**: Go + Python
- **Go module**: `github.com/chitinhq/llmint`
- **Version**: v0.1.0 (semver — breaking changes require major bump)

## Repository Structure

```
cmd/llmint/ # Go binary entrypoint
internal/
├── tracker/ # Cost tracking per request/session
├── budget/ # Budget rules and enforcement
├── cascade/ # Model cascading logic (Haiku → Sonnet → Opus)
└── config/ # Configuration
llmint/ # Python package (analytics, cost reporting)
```
Comment on lines +18 to +28
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “Repository Structure” tree doesn’t match this repo (there’s no cmd/ or internal/; instead there are provider/, middleware/, cabi/, and python/). Please align this section with the actual directories so Copilot/agents don’t optimize for a non-existent layout.

Copilot uses AI. Check for mistakes.

## Build & Test

```bash
# Go
go build ./...
go test ./...
golangci-lint run

# Python
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python test instructions (python -m pytest tests/) are inaccurate for this repo. CI runs Python tests from the python/ subdir (and installs the package first), so the documented commands should mirror that to prevent routine agent runs from failing.

Suggested change
# Python
# Python
cd python
python -m pip install -e .

Copilot uses AI. Check for mistakes.
python -m pytest tests/
```

## Coding Standards

- Follow Go conventions (`gofmt`, `go vet`)
- Python: follow existing style, type hints preferred
- Error handling: always check and wrap errors with context
- This is a published module — API stability matters, semver is enforced

## Governance Rules

### DENY
- `git push` to main — always use feature branches
- `git force-push` — never rewrite shared history
- Write to `.env`, SSH keys, credentials
- Write or delete `.claude/` files
- Execute `rm -rf` or destructive shell commands

### ALWAYS
- Create feature branches: `agent/<type>/issue-<N>`
- Run `go build ./... && go test ./...` before creating PRs
- Include governance report in PR body
- Link PRs to issues (`Closes #N`)

## Three-Tier Model

- **Tier A — Architect** (Claude Opus): Sprint planning, architecture, risk
- **Tier B — Senior** (@claude on GitHub): Complex implementation, code review
- **Tier C — Execution** (Copilot): Implement specified issues, open draft PRs

### PR Rules

- **NEVER merge PRs** — only Tier B or humans merge
- **NEVER approve PRs** — post first-pass review comments only
- Max 300 lines changed per PR (soft limit)
- Always open as **draft PR** first
- If ambiguous, label `needs-spec` and stop

## Critical Areas

- `internal/budget/` — budget enforcement, cost impact on all dispatch
- `internal/cascade/` — model selection, affects token spend
- Public Go API surface — semver, don't break consumers

## Branch Naming

```
agent/feat/issue-<N>
agent/fix/issue-<N>
agent/refactor/issue-<N>
agent/test/issue-<N>
agent/docs/issue-<N>
```

## Autonomy Directive

- **NEVER pause to ask for clarification** — make your best judgment
- If the issue is ambiguous, label it `needs-spec` and stop
- Default to the **safest option** in every ambiguous situation
Comment on lines +96 to +98
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “Autonomy Directive” is internally inconsistent: it says “NEVER pause to ask for clarification — make your best judgment” but then says “If the issue is ambiguous, label it needs-spec and stop.” Please reconcile these instructions (choose one behavior) to avoid unpredictable agent actions.

Suggested change
- **NEVER pause to ask for clarification** — make your best judgment
- If the issue is ambiguous, label it `needs-spec` and stop
- Default to the **safest option** in every ambiguous situation
- **Do not pause to ask for clarification during execution** — make your best judgment only when the issue is sufficiently specified
- If the issue is ambiguous, label it `needs-spec` and stop
- When multiple safe implementations fit a sufficiently specified issue, default to the **safest option**

Copilot uses AI. Check for mistakes.
29 changes: 29 additions & 0 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]

jobs:
claude-review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
plugins: 'code-review@claude-code-plugins'
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
39 changes: 39 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

jobs:
claude:
Comment on lines +1 to +14
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider setting explicit permissions: for this workflow/job instead of relying on the repo default GITHUB_TOKEN permissions. Minimizing token scope (and only enabling the specific write permissions the action needs) reduces blast radius if the workflow is abused.

Copilot uses AI. Check for mistakes.
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
Comment on lines +16 to +17
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow can be triggered by any GitHub user commenting @claude, and it runs with secrets.ANTHROPIC_API_KEY. Please add a gate on the commenter’s trust level (e.g., github.event.comment.author_association in OWNER|MEMBER|COLLABORATOR) to prevent untrusted users from burning API quota / triggering paid runs.

Suggested change
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'issue_comment' &&
contains(github.event.comment.body, '@claude') &&
contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) ||
(github.event_name == 'pull_request_review_comment' &&
contains(github.event.comment.body, '@claude') &&
contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) ||

Copilot uses AI. Check for mistakes.
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
additional_permissions: |
actions: read
36 changes: 36 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Agent Identity

At session start, if you see `[AgentGuard] No agent identity set`, ask the user:
1. **Role**: developer / reviewer / ops / security / planner
2. **Driver**: human / claude-code / copilot / ci

Then run: `scripts/write-persona.sh <driver> <role>`
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scripts/write-persona.sh is referenced as a required step, but there is no scripts/ directory in this repo. Either add the script (and ensure it’s used by the tooling) or update this doc to reference an existing setup step so agents don’t fail on first run.

Suggested change
Then run: `scripts/write-persona.sh <driver> <role>`
Then record the selected identity in the session and continue using `driver=<driver>` and `role=<role>` for the rest of the task.

Copilot uses AI. Check for mistakes.

## Project

LLMint is the token economics middleware for the Chitin platform. It tracks LLM costs, enforces budget rules, and enables model cascading (Haiku → Sonnet → Opus).

**Module**: `github.com/chitinhq/llmint`
**Languages**: Go + Python
**Version**: v0.1.0 (semver enforced)

## Key Directories

- `cmd/llmint/` — binary entrypoint
- `internal/tracker/` — cost tracking per request/session
- `internal/budget/` — budget rules and enforcement (cost impact, careful)
- `internal/cascade/` — model cascading logic
- `llmint/` — Python package for analytics
Comment on lines +19 to +23
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The listed “Key Directories” (cmd/llmint/, internal/*, llmint/) don’t exist in this repository (current top-level dirs include cabi/, provider/, middleware/, python/, examples/). Please update this section to match the actual repo layout to avoid misleading agent guidance.

Suggested change
- `cmd/llmint/`binary entrypoint
- `internal/tracker/`cost tracking per request/session
- `internal/budget/`budget rules and enforcement (cost impact, careful)
- `internal/cascade/`model cascading logic
- `llmint/`Python package for analytics
- `cabi/`C ABI bindings and interoperability layer
- `provider/`provider integrations and related abstractions
- `middleware/`middleware for request handling, policy, and cost controls
- `python/`Python package and bindings
- `examples/`example integrations and usage samples

Copilot uses AI. Check for mistakes.

## Build

```bash
go build ./...
go test ./...
golangci-lint run
python -m pytest tests/
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python test command here (python -m pytest tests/) doesn’t match the repo’s Python layout; tests live under python/tests/ and CI runs them via cd python && pytest tests/ after installing python as an editable package. Updating this avoids giving agents a build command that fails from the repo root.

Suggested change
python -m pytest tests/
cd python && pytest tests/

Copilot uses AI. Check for mistakes.
```

## Assembly Line

LLMint is imported by Octi Pulpo for dispatch budget gating. Every agent task has a cost budget in its work contract — LLMint enforces it.
Loading