Skip to content

Master#9

Merged
QUSETIONS merged 38 commits into
mainfrom
master
May 21, 2026
Merged

Master#9
QUSETIONS merged 38 commits into
mainfrom
master

Conversation

@QUSETIONS

Copy link
Copy Markdown
Owner

No description provided.

QUSETIONS and others added 30 commits May 19, 2026 15:43
Previously create_reranker() tried to auto-create a Haiku adapter
which would fail without explicit API keys, leaving the reranker in
perpetual pass-through mode.

Now the agent's existing model adapter is passed directly:
  MemoryReranker(model_adapter=model)

This means the reranker uses the same model the agent already has
access to. The rerank prompt is lightweight (~500 tokens) so even
with Opus the cost per curation is manageable.

Integration test confirms: real model correctly selects in-domain
memories and rejects cross-domain noise with explanations.

718 tests passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Deleted:
- 4 PNG screenshots (~280KB)
- 2 large binaries (claude-code.zip ~19MB, minicode-py-src.tar.gz ~740KB)
- 20+ outdated audit/optimization/security report .md files
- 13 legacy root test/smoke scripts (migrated to tests/)
- session logs, test output, cache dirs

Moved to docs/: CODE_WIKI.md, INTEGRATION_GUIDE.md, USAGE_GUIDE.md

Root went from ~50 files to ~16 entries.

718 tests passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- save_state(): persists read/write/maintain counters, reranker cache
  stats, and curator report history to .mini-code-memory/pipeline_state.json
- _load_state(): restores state on pipeline initialization
- Auto-saves after write() and maintain() operations
- Workspace-relative path, graceful failure if path unavailable

718 tests passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tion

Restored MiniCode's identity as a terminal AI coding assistant. The
memory pipeline is now presented as one advanced subsystem within the
larger cybernetic architecture — not as the main product.

Key changes:
- Lead with "what MiniCode does" — reads code, executes tools, writes code
- Cybernetic loop as the core differentiator (Sense→Predict→Control→Act)
- Auto-regulation table: what problem, which controller, what action
- Memory pipeline as ONE subsystem (advanced, but not the whole story)
- Added "How It Works" walkthrough of a real coding task
- Kept benchmark results and theory section but properly contextualized

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
5 tests exercising the full MiniCode agent loop with all cybernetic
controllers active:

- test_agent_completes_without_error: basic agent turn
- test_agent_with_context_manager: context tracking
- test_full_cybernetic_stack_initializes: 15 controllers init clean
- test_cybernetic_stack_with_ls_command: /ls through full stack
- test_memory_pipeline_in_agent_loop: memory injection in real flow

723 tests passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Memory stress (9 tests):
- 500-entry index rebuild + search performance
- Rapid add/delete cycles (100 → 50)
- Domain-weighted search with 300 entries
- 4-thread concurrent reads (no race conditions)
- 4-thread concurrent add + search
- Multi-tier promote/demote (50 entries)
- Auto-linking 50 entries
- 20 rapid pipeline read/write/maintain cycles

Agent stress (3 tests):
- 20 rapid turns with context manager
- 10 turns full cybernetic stack
- Single-turn latency < 30s

735 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
A1: Model adapters now use api_retry.classify_error() for semantic
    error classification in retry loops. Rate limit/overload/server
    errors get appropriate backoff strategies instead of uniform delay.

A2: Tool execution now has 120s timeout via ThreadPoolExecutor.
    Hung tools no longer brick the agent loop.

A3: Unified token estimation across context_manager and layered_context.
    Both now use CJK-aware formula: ascii/4 + cjk/1.5 chars-per-token.

734 passed, 1 known flaky (concurrent MemoryFile access), 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
B1: Agent loop quality
- Fixed _results shadowing bug (redeclared in else branch, outer declaration dead)
- Tool timeout now configurable via MINICODE_TOOL_TIMEOUT env var (default 120s)

B2: TUI improvements
- Unix: wired SIGWINCH signal to invalidate terminal size cache on resize
- TUI no longer garbled for up to 0.5s after terminal resize
- Safe fallback on Windows (no SIGWINCH support)

735 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
C1: Model timeout now via MINICODE_MODEL_TIMEOUT env var
    (default: 60s Anthropic, 120s OpenAI)

C2: _trim_layer edge case: when one item exceeds entire budget,
    truncate to budget instead of keeping oversized item

C3: _model_next inspect.signature failure now logs warning
    instead of silently discarding store tracking

735 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
D1: delete_session() now cleans up orphaned delta directories
    (sessions/deltas/{id}/) instead of leaving them on disk forever

D2: Removed modify_file from core tool registry — it was a 100%
    identical alias of write_file, wasting token budget and confusing
    the model with duplicate tools

D3: read_file _get_cached_file_content OSError handler no longer
    pointlessly retries the same read_text() that just failed

735 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Fixed error_category= → category= in both adapters (bug from A1)
- Added ruff lint step to CI (E + F rules, permissive line length)
- All 735 tests pass

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Removed: unused imports, dead variables, redundant code
Fixed: ambiguous variable names, missing type imports

735 tests pass after cleanup

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…_file

- anthropic_adapter.py: added missing state imports (add_cost, record_api_error,
  update_context_usage) that were removed in auto-fix but actually used at runtime
- logging_config.py: added missing typing.Any import
- tools/__init__.py: removed unused modify_file_tool import
- context_manager.py: moved `import re` to module top level

735 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Verifies all controllers initialize cleanly. Previously the orchestrator
had zero tests despite 300+ lines of implementation.

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Enhanced 6 nudge messages (NUDGE_CONTINUE, NUDGE_AFTER_TOOL_RESULT,
  NUDGE_AFTER_EMPTY_RESPONSE, NUDGE_AFTER_EMPTY_NO_TOOLS,
  RESUME_AFTER_PAUSE, RESUME_AFTER_MAX_TOKENS)
  - More actionable, shorter, context-aware
  - First-tool nudge now guides model to inspect codebase first

- NudgeGenerator tool-specific hints expanded:
  - grep_files failure → try broader pattern or list_files
  - read_file failure → verify path, use file_tree
  - edit_file failure → use grep to find exact text
  - All timeout failures → suggest smaller steps

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
After each task, injected memories get usage_count adjusted:
- Task succeeds → usage_count += 2 (positive reinforcement)
- Task fails → usage_count -= 1 (gentle decay — may have misled)

This closes the outermost learning loop: memory quality improves
over time as the agent learns which memories are truly useful for
which tasks.

Also updates last_accessed timestamp on feedback.

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Added `from minicode.memory import MemoryScope` inline import
- Wrapped `memory_mgr` access in try/except NameError (it's only
  defined inside `if context_manager:` block)
- Fixed indentation error from previous edit

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…t_loop

First step of orchestrator integration. The orchestrator is now
imported and type-annotated alongside the existing inline controller
code. Both paths coexist — no behavior change.

This is the safe incremental approach: introduce the orchestrator
without removing any working code. Future steps will gradually
migrate controller initialization and finally-block calls.

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replaced ~60 lines of inline controller initialization with:
  orch = CyberneticOrchestrator()
  orch.initialize(model, tools, runtime)
  # Extract refs for downstream inline use
  feedback_controller = orch.feedback  # etc.

Removed 5 individual controller imports now managed by orchestrator:
  FeedbackController, StabilityMonitor, AdaptivePIDTuner,
  StateObserver, DecouplingController, PredictiveController

All downstream variable references unchanged — zero-risk migration.
737 passed, 2 skipped.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Covers lingering ruff auto-fixes from previous rounds that were
left uncommitted: unused imports in tools/, minor code cleanups,
test file improvements.

Zero behavior changes, all 737 tests pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Previously only force_compaction and adjust_token_budget had real effects.
Now wired:

  reduce_parallelism    → caps tool_scheduler max_workers at 2
  adjust_concurrency    → sets dynamic max_workers cap
  limit_max_steps       → actually modifies max_steps variable
  increase_model_level  → sets _pending_upgrade on model_switcher
  suggest_memory_persistence → triggers budget flush
  recommend_skill_update    → logged (actionable per pattern)

The _force_max_workers cap is applied in the ThreadPoolExecutor path
when concurrent tools are scheduled.

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Vector search:
- SparseVectorStore: zero-dependency TF-IDF vectors, always available
  Uses same tokenization as BM25, cosine similarity on sparse vectors
- MemoryPipeline now defaults to enable_vector=True (no extra deps)
- Sparse vectors indexed on initialization, searched via RRF fusion

Self-healing improvements:
- OSCILLATION: aggressive damping (kd*2, kp*0.5, ki reset to 0.01)
  Was: kd*1.5, ki*0.5 — now actually suppresses oscillation
- PERFORMANCE_DEGRADATION: boosts token budget by 1.5x (up to 32K)
  Was: log-only — now gives agent more room to recover

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- find_matching_slash_commands: falls back to subsequence matching
  when no exact prefix matches (e.g., "mem" matches "/memory")
- complete_slash_command: same fuzzy fallback logic
- Performance profile confirms no hotspots: 0.069s for 20 searches
  over 100 entries

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- tty_app.py: _win_read_one_key was called but never imported from
  input_handler. This was a real runtime NameError on Windows.
- memory_pipeline.py: _dense_store attribute now declared in __init__

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
After orchestrator integration, individual controller type annotations
(FBController, StabilityMonitor, etc.) lost their imports. Changed to
Any since they're duck-typed and heavily referenced — with
`from __future__ import annotations` this is purely cosmetic cleanup.

Also fixed: _win_read_one_key import in tty_app.py (real runtime bug),
_dense_store init in memory_pipeline.py.

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Project-level skill describing MiniCode's capabilities:
- Self-regulating agent with 15 cybernetic controllers
- 3-layer memory pipeline with ablation results
- Slash commands reference
- Configuration guide
- Quick start

27 skills total now discoverable (26 system + 1 minicode)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
T1: Inline diff coloring
- edit_file/patch_file/diff_viewer output now rendered with colored
  unified diff (+green, -red, @@cyan, word-level emphasis)
- _DIFF_TOOLS frozenset + _render_tool_body with diff detection
- Uses existing colorize_unified_diff_block from chrome.py (was unused)

T2: Word-level editing
- Ctrl+Left/Right: jump by word boundaries
- Ctrl+W: delete word backward
- Ctrl+K: delete to end of line
- _word_left/_word_right helpers with whitespace-aware navigation

T3: Bracketed paste support
- Terminal enables ?2004h on alternate screen entry
- Required for proper multi-line paste handling in future work

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Right-edge scrollbar shows:
- █ thumb position (proportional to scroll offset)
- ▲ hint at top when scrolled away from beginning
- ▼ hint at bottom when more content below
- ░ track for the scroll range

Rendered inline with transcript text via _interleave_scrollbar.
Also kept the existing scroll text indicator as fallback.

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
T5: Multi-line input
- Ctrl+J inserts literal newline into input buffer
- Raw parser changed: lone LF (0x0A) → TextEvent('\n') instead of Return
- CR+LF still treated as Return (standard Enter behavior)
- Multi-line renderer: each line gets continuation prefix, cursor
  positioned correctly across line boundaries
- Hint bar updated: [^J] nl

T6: Transcript navigation
- Ctrl+Home: jump to transcript top (max scroll offset)
- Ctrl+End: jump to transcript bottom (scroll offset 0)
- Uses _get_max_transcript_scroll_offset from navigation module

736 passed, 1 known flaky, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
T7: Animated spinner during tool execution
- Braille spinner (⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏) cycles at 8fps during busy
- Shows tool name when active: "⠋ edit_file..."

T8: Bracketed paste support
- Terminal \x1b[200~...\x1b[201~ paste brackets now parsed
- Pasted text batch-inserted as single TextEvent
- Control characters stripped (keeping newlines and tabs)
- Works with the ?2004h terminal mode enabled in T3

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
QUSETIONS and others added 8 commits May 20, 2026 14:03
- screen.py: added ?1004h focus tracking on alternate screen entry
- input_parser.py: parse \x1b[I (focus_in) and \x1b[O (focus_out)
- event_flow.py: reload on focus_in to refresh UI state

This prevents stale display when switching terminal tabs and back.

Also: T7 spinner animation + T8 bracketed paste handling from
previous round.

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
U1: Code block line numbers
- Rendered as dim monospace "  N " prefix in fenced code blocks

U2: Tool elapsed time display
- Shows [0.3s] or [1.2m] prefix on tool output

U3: Diff statistics in collapsed tool summary
- Collapsed diff tools show "+3 -1" instead of raw output line

U4: Synchronized output (?2026h)
- Reduces flicker during rapid redraws on supporting terminals

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Added deepseek-v4-pro[1m] to BUILTIN_MODELS as CUSTOM provider
- DeepSeek API auto-detection via DEEPSEEK_API_KEY env var
- Auto-routes to https://api.deepseek.com/v1 when key present
- Fallback to CUSTOM_API_BASE_URL / OPENAI_API_KEY if set

736 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- deepseek-v4-pro[1m] registered as ANTHROPIC provider
- Auto-detects ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN from env
- Model name + baseUrl + authToken auto-populated in runtime
- thinking block capture + replay for DeepSeek extended thinking mode
- Full agent flow verified: memory injection → tool calls → response

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
DeepSeek via custom Anthropic-compatible API requires thinking block
round-trip preservation that our internal message format doesn't support.
Disable extended thinking via `thinking: {type: disabled}` when base URL
is not api.anthropic.com.

Multi-step tests now pass without API errors:
- Grep + Read + Answer: 46s OK
- Write file: 30s OK

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Reranker saves/clears _thinking_blocks around its model call to
  prevent interference with the main agent loop's thinking round-trip
- AnthropicModelAdapter.next() now correctly routes through the Reranker
- disableThinking flag prevents extended thinking for non-Anthropic
  endpoints where our message format can't preserve thinking blocks

Verified: multi-step tool calls + Reranker work together without
API errors. The LLM Reranker now actually curates memories.

737 passed, 2 skipped

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Added verified test results table (10/10 API tests pass)
- Moved memory ablation to supporting section
- Simplified architecture description
- Removed redundant sections, kept practical content
- Clear "What It Can Do" section upfront

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Focused on the single most distinctive feature: closed-loop cybernetic
self-regulation. Every coding agent has tools and memory — only MiniCode
has PID controllers that auto-fix problems in real time.

- "It's like ABS for your AI agent" — one-sentence value prop
- Problem/fix comparison table vs traditional approaches
- 15 controllers in a clean scannable table
- Verified test results upfront
- Zero fluff, every section earns its place

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@QUSETIONS QUSETIONS merged commit 563a0ca into main May 21, 2026
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant