docs: Claude Code architecture research + 1:1 refactor plan#15
Open
Planckbaka wants to merge 23 commits into
Open
docs: Claude Code architecture research + 1:1 refactor plan#15Planckbaka wants to merge 23 commits into
Planckbaka wants to merge 23 commits into
Conversation
Test coverage improvements across all packages (agent, llm, tui, config): - Agent: 90+ new test files covering runner, hooks, MCP, memory, compaction, subagent, watchdog, IPC, bridge, LSP, skills, team, web tools, permissions - LLM: adapter tests, OpenAI/Anthropic continuation, retry, coverage boost - TUI: component tests (chat, confirm, input, status, slash menu), view render tests, history tests, app table tests, raw input tests - Config: config wizard tests, full config roundtrip tests Feature additions aligned with Claude Code architecture research: - Auto-continuation system (adapter-level max_tokens escalation, continuation prompts) - Compaction 4-layer pipeline (toolResultBudget → snipCompact → microCompact → autoCompact) - Subagent recursive spawn prevention + 30-iteration limit - Hook recursive guard + event expansion (12 → 20 events) - YoloClassifier LLM auto-approval with 3-layer defense against prompt injection - MCPTransport interface extraction (StdioTransport + HTTPTransport over HTTP+SSE) - OAuth 2.0 + PKCE flow (manual-copy primary, env var bypass, file-based token storage) - Memory LLM side-query selection with per-file budget (4096 bytes) - Tool pool change-signal rebuild (/mcp reload, plugins.json mtime detection) - ADK state placeholder sanitization in prompt builder - Runner cleanup: remove unused WithStateDelta, nil guards on hooks Anti-slop cleanup: removed redundant ListTools RPC, fixed mtime to use time.Time, cleaned test data leak in AGENTS.md. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… skills, shell handlers Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… stale coverage files Extract 6 test helpers (sseServer, openAISSEServer, captureBodyServer, capturePathServer, captureBodySSEServer, captureBodyOpenAISSE) to replace 25 inline httptest.NewServer boilerplate blocks. Remove AI section dividers, empty test, and consolidate ioReadAll. Add *.out and coverage.* to .gitignore. Delete 4 stale coverage output files. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Deep multi-dimensional research on real Claude Code (v2.1.x, mid-2026) sourced via anysearch against docs.claude.com / code.claude.com / anthropic.com / github.com/anthropics, plus a 6-area audit of the current iroha codebase and adversarial verification of 38 load-bearing claims (13/16 dimensions covered). Contents (docs/claude-code-architecture/): - research/ : 16 detailed CC architecture specs (agent loop, canonical tools, tool-exec engine, streaming protocol, session/transcript, context compaction, system-prompt assembly, memory/CLAUDE.md, permissions, hooks, MCP, subagents/Task, skills, slash-commands/plan, TUI/IDE/config, sandbox/security) - audit/ : 6 capability inventories of iroha + ADK/Genkit coupling maps - gap-analysis.md : iroha-vs-CC delta, per cluster (present/partial/ missing/divergent), with the structural ADK-coupling blocker called out - refactor-plan.md : native-engine rewrite roadmap (4 decisions + Phase 0->4) to reach 1:1 fidelity by decoupling from Google ADK/Genkit - verify-verdicts.md: 38 fact-checks with corrections (e.g. CLAUDE.md is injected as a USER message not system prompt; permission order is deny->ask->allow; MCP protocol should be 2025-06-18) - README.md : master overview + navigation + the core decision Core cross-confirmed finding: iroha has NO native agent loop -- it is outsourced to Google ADK's internal Flow.Run. A 1:1 replica therefore requires replacing the loop driver (not swapping types), reusing the ~85% of the codebase that is already framework-free. Note: this commit contains only the research/spec deliverable. The existing modified tracked files in the working tree are unrelated WIP and are intentionally left uncommitted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The research deliverable for the 1:1 Claude Code replica effort: a complete
docs/claude-code-architecture/tree.Why
Before refactoring iroha into a faithful Claude Code replica, we needed a precise, source-grounded spec of how the real thing works (v2.1.x). This PR lands that spec + the gap analysis + the refactor plan so the implementation work has a single source of truth.
Contents
research/— 16 detailed architecture specs (agent loop, canonical tools, tool-exec engine, streaming protocol, session/transcript, context compaction, system-prompt assembly, memory/CLAUDE.md, permissions, hooks, MCP, subagents/Task, skills, slash-commands/plan, TUI/IDE/config, sandbox/security). Sourced via anysearch againstdocs.claude.com/code.claude.com/anthropic.com/github.com/anthropics.audit/— 6 honest capability inventories of the current iroha codebase, each with an ADK/Genkit coupling map.gap-analysis.md— iroha-vs-CC delta per cluster (present / partial / missing / divergent).refactor-plan.md— native-engine rewrite roadmap (4 decisions, Phase 0→4) to reach 1:1 fidelity by decoupling from Google ADK/Genkit.verify-verdicts.md— adversarial fact-checks (38 claims) with corrections.README.md— master overview + navigation.Core finding (cross-confirmed by research + audit)
iroha has no native agent loop — it is outsourced to Google ADK's internal
Flow.Run. Real Claude Code ownsquery()→queryLoop()(one code path). A 1:1 replica therefore requires replacing the loop driver, not swapping types, reusing the ~85% of the codebase that is already framework-free.Key verified facts that correct common assumptions:
2024-11-05).type:"result", notmessage_stop.pkg/agent,pkg/tui,pkg/llm) are unrelated WIP and were intentionally left uncommitted; they should be reviewed/committed separately.mainbut not pushed toorigin/main(test/feature work). This PR will propose merging those along with the docs.mainhas diverged fromorigin/main: origin hasa539b02(PR refactor: deslop coverage_boost_test.go + upgrade CI #4 "deslop + upgrade CI") which localmainlacks, while localmainhas its own different deslop commit (78757fe). A merge of this PR may conflict oncoverage_boost_test.go/ CI files and will need reconciliation. Worth deciding separately how to alignmainwithorigin/main.Next step (not in this PR)
Phase 0 of the refactor: additive
pkg/engine/(native message/event/tokenizer/Model types + genai↔native bridge), keeping the existing ADK loop compiling.🤖 Generated with Claude Code