Skip to content
cd ..~/abhay/projects/moon.md · 7.4K · case study 02 of 09

9 files open · click a tab, or use prev / next at the bottom of the page

// case 02 — Coding agent · 2026

Moon.md

A VS Code coding agent that edits a hidden copy of your project and lands only when you say yes.

> Plans, edits and tests in a hidden copy; fails over to a backup model on its own.

MY ROLEMCP tools, context, resilience and security
TIMELINENov 2026 · Techfest IIT Bombay
TEAM4 people · team Simpletons
STACK
TrueForgeMCPTypeScriptVS Code APItree-sitterReactClaudeDeepSeek
moon · agent mode · review 3 hunks
$ /agent add rate limiting to the login route
scout: picked 4 files from the project map (tree-sitter)
read app/auth/routes.py · app/limits.py
edit 2 files in the hidden copy
run pytest -q (hidden copy)
OK tests passed · 3 hunks ready for review
WAIT main model: no reply in 12 s → switched to backup
circuit breaker open · probing main model in background
OK review: accept 3 / 3 hunks · apply with backup
$
PIPELINE
1VS Code
2TrueForge loop
3MCP tools
4Hidden copy
5Diff review
MAINClaude
BACKUPDeepSeek
FAILOVER~10–12 s
lands only when you say yes
// 01 — context

the problem_

cat problem.md

Built for the TrueFoundry Forge-a-thon at Techfest 2026-27 (IIT Bombay): a coding agent whose loop runs on TrueForge, TrueFoundry's open-source agent harness. Coding agents are good at writing code and bad at being trusted: they edit your real files, hang when the model provider is down and lose their place after an error.

Moon's answer is to do all the work somewhere safe, show every change as a reviewable diff, and keep going when a model fails.

## constraints
  • Never write before review
  • Any TrueForge model
  • Stop at any moment
  • Model outages
  • Real repos, size budget
  • Untrusted tool results
./my-role.sh --verbose

abhay@os ~ % what did I actually do?

  1. 01Built the MCP server the agent works through: read, search, find a definition, edit, run a command and apply, served on localhost with a token and filtered results.
  2. 02Built context assembly: a ranked tree-sitter project map cut to a size budget, @file and @symbol mentions, and a scout subagent that reports which files it picked and why.
  3. 03Built resilience: a watchdog, a circuit breaker and automatic fallback from Claude to DeepSeek V4.1 Flash after ~10–12 s with no reply, switching back only between tasks.
  4. 04Built the security core: an approval ledger, a command policy, secret redaction and hidden-character checks.
  5. 05Wrote the retrieval eval: Flask requests with known right files, plus a held-out set written after tuning.

[ ok ] exit 0 · 5 tasks · owner: abhay

// 02 — results

what moved_

Three numbers I'd put on a slide. Measured in production, not in a benchmark I wrote the night before.

FAILOVER~10–12 sto switch to the backup modelAutomatic, announced, files unchanged.
REVIEWper hunkaccept or rejectAll-or-nothing apply with a backup and "undo this whole run".
MODELSanymodel configured in TrueForgeChange names in config/moon.json, no code changes.
// 03 — architecture

how it fits_

Moon never calls a model provider directly. Every request is a TrueForge session; the editor's abilities are MCP tools, and the agent decides what to read and change.

open architecture.excalidraw — moon
EDITOR
Moon panelReact webview
Inline diffsaccept per hunk
sessions
TRUEFORGE
Agent loopapprovals · compaction
Scoutsubagent
MCP
MOON CORE
MCP serverinline + agent
Hidden copytests run here
Breakermain ↔ backup
model calls
MODELS
Claudemain
DeepSeek V4.1 Flashbackup · Azure
request / write pathresponse / events backnothing touches disk before review
// 04 — key decisions

git blame me_

adr-001.md
CHOSE

Work in a hidden copy of the project

REJECTED

Editing the workspace directly

TRADE-OFF

Copying costs time on big repos, but Stop really means stop: the copy is deleted and the workspace is untouched.

adr-002.md
CHOSE

Switch back to the main model only at the next task

REJECTED

Switching back the moment it recovers

TRADE-OFF

The backup may keep a task it started, but a task never changes model halfway through.

adr-003.md
CHOSE

Everything as MCP tools

REJECTED

Custom calls from the extension

TRADE-OFF

One more process to run, but any TrueForge model can drive the same tools and approvals.

// 05 — under the hood

the good bit_

vim packages/core/src/resilience/circuit-breaker.tsTypeScript
1export type BreakerState = 'closed' | 'open' | 'recovered'
2
3export class CircuitBreaker {
4 /** The main model failed: use the backup and start the background checks. */
5 trip(): void {
6 if (this.current === 'open') return
7 this.set('open')
8 this.nextWaitMs = this.times.firstProbeMs
9 this.schedule()
10 }
11
12 /** At the start of a task: true (once) when Moon should switch back. */
13 takeRecovery(): boolean {
14 if (this.current !== 'recovered') return false
15 this.set('closed')
16 return true
17 }
18}
NORMAL packages/core/src/resilience/circuit-breaker.ts18 lines · utf-8

closed = main model, open = backup, recovered = main is back from the next task. The background probes are tiny TrueForge sessions, never direct model calls.

less lessons.txt

If I built it again, I'd change…

  1. L1Don't switch mid-taskWhen the main model comes back, Moon switches at the start of the next task, never in the middle of one.
  2. L2A wrong key never healsBackoff probes alone would wait forever on a bad key, so the breaker also re-checks the moment model settings change.
  3. L3Write the held-out set lastThe retrieval eval got a second set of requests, written after tuning, so the score wasn't measured on what we tuned against.

lessons.txt (END) — press q to quit

// 06 — timeline

git log --since_

Nov 2026 · Techfest IIT Bombay

git log --reverse --format=milestone moon
  1. 01Nov 2026Phase 1MCP server, read-only tools, agent chat and the Moon panel.
  2. 02Nov 2026Phase 4Project map, rules, @-mentions, context budget, scout.
  3. 03Nov 2026ResilienceWatchdog, circuit breaker, automatic fallback.
  4. 04Nov 2026Security + evalsApproval ledger, command policy, retrieval and security evals.
cd ~/work./contact — itsabhay@abhay.si