MonceApp v0.1.0

System Architecture

User: "Train this CSV and solve this CNF"
                    │
                    ▼
┌───────────────────────────────────────────────────────┐
│  (-monceai) PRE-CHECK                                 │
│  npcalc: formula? → exact result, skip model          │
└───────────────────┬───────────────────────────────────┘
                    │ not a formula
                    ▼
┌───────────────────────────────────────────────────────┐
│  (monceai-) INPUT LAYER                               │
│  enhance_system() → system prompt + domain context    │
│  Factory context injected only if factory_id > 0      │
└───────────────────┬───────────────────────────────────┘
                    │
                    ▼
┌───────────────────────────────────────────────────────┐
│  CONVERSE CALL 1 — Bedrock Converse API               │
│  Model sees: user message + tool definitions          │
│  Model returns: N toolUse blocks (parallel request)   │
└───────────────────┬───────────────────────────────────┘
                    │
         ┌──────────┼──────────┬───────────┐
         ▼          ▼          ▼           ▼
    snake_csv    sat_cnf   snake_match  ask_charles
    snakebatch   npdollars  local JSON  charles API
    /v6/train    /cnf/solve  (~50ms)    (~500ms)
         │          │          │           │
         └──────────┼──────────┴───────────┘
                    │  ThreadPoolExecutor
                    │  all results collected
                    ▼
┌───────────────────────────────────────────────────────┐
│  CONVERSE CALL 2 — Synthesize                         │
│  Model sees: original + ALL tool results              │
│  Model returns: one natural language response          │
└───────────────────┬───────────────────────────────────┘
                    │
                    ▼
┌───────────────────────────────────────────────────────┐
│  (-monceai) OUTPUT LAYER                              │
│  sat_validate() → glass mentions → Snake SAT audit    │
│  np_calc result attached if formula was pre-computed   │
└───────────────────┬───────────────────────────────────┘
                    │
                    ▼
            One response to user

3 Payloads, 1 Response

#PayloadDirectionWhat
1Converse call→ BedrockUser message + tools → model decides what to call
2Tool results→ BedrockParallel tool outputs → model synthesizes answer
3Final response→ UserClean text, no tool internals visible

Parallel Tool Execution

When the model requests multiple tools in one response, they fire simultaneously via ThreadPoolExecutor. Wall clock = slowest tool, not sum.

# Model returns 2 toolUse blocks:
[snake_csv(csv=...), sat_cnf(dimacs=...)]

# Both fire in parallel:
snake_csv  ████░░░░░░  166ms  → snakebatch.aws.monce.ai
sat_cnf    ████████░░  362ms  → npdollars.aws.monce.ai
                    ↑
            wall clock: 362ms (not 528ms)

10 Tools (invisible to user)

ToolBackendLatencyWhat
snake_csvsnakebatch.aws.monce.ai/v6/train~200msTrain SAT classifier from inline CSV
sat_cnfnpdollars.aws.monce.ai/cnf/solve~400msSolve DIMACS CNF via swarm
snake_matchLocal JSON~50msMatch glass field against SAT model
snake_trainsnakebatch.aws.monce.ai~2-15sFull distributed training
sat_solvemonceai SDK → npdollars~1-60sSAT solve via SDK
run_extractionclaude.aws.monce.ai~30-60s8-stage VLM extraction pipeline
ask_charlescharles.aws.monce.ai~500msMemory bot — team/project context
get_pipeline_statsclaude.aws.monce.ai/stats~200msLive pipeline metrics
model_inventoryLocal~1msList Snake models on disk
query_articlesdata.aws.monce.ai~300msArticle catalog search

Tool Routing

ProviderToolsWhy
Anthropic (Claude)All 10Converse tool_use works reliably
Amazon (Nova)NoneContext-only — enhanced system prompt, no tool_use

charles-auma Pipeline — 3 Execution Paths

User: "6x7"
    │
    ▼
[REGEX] parse_multiplication("6x7") → (6, 7) ✓
    │
    ▼
[mulcnf] encode_multiplication(6, 7)
    │    A=110 B=111 → 27-var carry-chain adder CNF
    ▼
[npdollars/Kissat] SAT in 97ms → assignment
    │
    ▼
[decode] bits → 42 = 6×7
    │
    ▼ DONE — 0 Haiku calls, 0 tokens, ~200ms
User: "solve x^3 - 6x + 4 = 0"
    │
    ▼
[REGEX] no multiplication/division detected
    │
    ▼
[Haiku UPHILL] encode for 3 engines (1 LLM call)
    │    auma: f="-(x**3-6*x+4)**2", Real(-10,10)
    │    dimacs: constraint encoding
    │    csv: training data
    │
    ├───── RACE ──────────────────
    │    AUMA      x≈0.733  ← FIRST
    │    npdollars SAT      ...
    │    snakebatch trained  ...
    ├─────────────────────────────
    │
    ▼
[Haiku DOWNHILL] synthesize (1 LLM call)
    │    "x ≈ 0.733, verified by NP calc"
    ▼
DONE — 2 Haiku calls

charles-science Pipeline

User: "factor 10403"
    |
    v
[Haiku] extract 16 boolean features
    |    {has_equation:1, has_factor:1, has_integer:1, ...}
    v
[Snake SAT Router] -> "auma" @ 100% confidence (0ms)
    |
    v
[Haiku] extract params for auma
    |    f = -(10403 - x*y)^2, Integer(2,10402)
    v
[AUMA + charles memory] fire in parallel
    |         |
    v         v
result    context
    |         |
    v---------v
[Sonnet] synthesize: 10403 = 101 x 103

Infrastructure (10 services)

ServiceHostRole
MonceAppmonceapp.aws.monce.ai13 models, 8 workers, 100 concurrent users
AUMAauma.aws.monce.aiUniversal maximization O(n^a). paper
Sudokusudoku.aws.monce.aiPolynomial BCP solver. UI
NPDollarsnpdollars.aws.monce.aiSwarm SAT solver. /cnf
SnakeBatchsnakebatch.aws.monce.aiDistributed Snake training. /csv
Chesschess.aws.monce.aiAUMA chess engine vs Stockfish d22
Snake APIsnake.aws.monce.aiProduction SAT models, 3-tier matching
Charlescharles.aws.monce.aiHaiku memory bot
Claude Pipelineclaude.aws.monce.ai8-stage VLM extraction
Monce Datadata.aws.monce.aiS3 data sync, KPIs, synonym management

Concurrency (t3.small, $15/month)

TestResultWall clock
100 concurrent Haiku100/10026s
100 concurrent charles-json96/10090s
10 concurrent charles-science10/1065s
Server memory after blast553MB / 1.9GBalive