Repository navigation
fix(mimocode): refuse a chat that would answer from Xiaomi's hosted model unsigned - #37629
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This closes an unsigned hosted-model egress gap with the same hook opencode already fills. It adds no knob and no duplicate, and nothing in it needs a product-shape decision. Not checked: whether MiMo Code 0.1.17 really advertises identical What this change shipsInventory (7 items) — 7 justifiedIntent: stop a MiMo Code chat on a host with no Xiaomi sign-in from quietly sending prompts to Xiaomi's hosted model (FIX, #37628).
[FIRST-PRINCIPLES-REVIEWED] 804a2ee Description read[DESCRIPTION-READ] 84f1f7e073ed0d59857d8bfe41ead2bbc71e8f53ee4486c139402e7e45d37569 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change reuses opencode's existing refusal hook and adds a sign-in presence check, so signed-in hosts and hosts with a Notes
[DESIGN-REVIEWED] 804a2ee Description read[DESCRIPTION-READ] 92b6dff06106c23b926e95116b362fd178ba9c31012a164ef10b91ac28ec27c0 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
2a25607 to
44d3e23
Compare
Code change approver recommendation: ApproveWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. Adds MimocodeAcpClient, which fills the existing _refuse_harness_default_model hook (the same pattern as opencode). Both callers are reached for mimocode: it takes its model via a config option, not at launch. The routing read-back now records config_model and a hosted_credential flag, worked out by existence only (env keys, the sign-in file path from the host_auth declaration, a non-blank provider.xiaomi.options.apiKey) from the same child env the spawn uses. Behaviour fails closed, opencode is unchanged, and new tests cover refusal, every pass-through case and each credential check. Nothing blocks. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
44d3e23 to
cae830c
Compare
Sensitive Change ReviewSensitive files changed:
|
…odel unsigned MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone.
cae830c to
804a2ee
Compare
Sensitive change review
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
I checked this head and found no blocking issue. MimocodeAcpClient fills the existing _refuse_harness_default_model hook through a positive serves=ACP_BACKEND_MIMOCODE class, so the Kiro path does not change. The credential check runs off the event loop, inside the read-back that runs on every spawn, and uses the same scrubbed child env the spawn uses. The refusal text redacts the model id. The _only_hosted refactor leaves opencode's behaviour the same. With the hook binding removed, both refusal tests fail, so the main refusal is pinned.
Done well: the PR reuses the host_auth MiMo Code declaration for every path and only checks that the sign-in file exists. It never opens that file.
Optional:
- No test covers the read-back's use of
_mimocode_hosted_credential_present(env)(mimocode.py:761). If that call is dropped, every signed-in host is refused and no test fails. A read-back case with a sign-in file undertmp_path, or withXIAOMI_API_KEYset, would catch it. A sibling test forMIMOCODE_AUTH_CONTENTwould also help. - The Backwards compatibility section says both "Breaking, narrowly" and "Removes nothing." Removing "Removes nothing." would make it consistent.
- The presence check counts a sign-in file for any provider. The docstrings already say this check is presence-only. If it ever matters, record it as a known limit.
…odel unsigned (#37629) MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone. Co-authored-by: Joe Guo <zejiangg@amazon.com> (cherry picked from commit c7c9357)
…odel unsigned (#37629) MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone. Co-authored-by: Joe Guo <zejiangg@amazon.com> (cherry picked from commit c7c9357)
…odel unsigned (#37629) MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone. Co-authored-by: Joe Guo <zejiangg@amazon.com> (cherry picked from commit c7c9357)
…odel unsigned (#37629) MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone. Co-authored-by: Joe Guo <zejiangg@amazon.com> (cherry picked from commit c7c9357)
… main (#39387) Backports to release/0.13.0 the fixes from #39342, squashed into one commit and brought up to date with release/0.13.0 after the Kiro Memory preview backport (#39360). Picks, in order; each [pick sha] is the commit on the #39342 branch, whose body has main's cherry-picked-from line: - fix(monitor): wake the session once when its watched PR merges or closes (#37776) [pick 84da419] - fix(security): match deny rules against Windows program suffixes and cmd/PowerShell in-word escapes (#33569) [pick e4941b7] - fix(mimocode): refuse a chat that would answer from Xiaomi's hosted model unsigned (#37629) [pick 1bfdce3] - fix(acp): end a quiet agent-started cycle on the shared runtime's stale gate (#37932) [pick fa870a2] - fix(conductor): re-read goal-conductor after a compaction (#37917) [pick ccdd67c] - fix(security): refuse a command nested past 32 substitutions before the floors walk it (#37875) [pick 2f9bd67] - fix(mates): carry a moved Bot's shell toolsSettings entry as execute_bash instead of holding it (#37973) [pick 16022f4] - fix: hold an app to its own sessions, jobs and runs (#37804) [pick 3dff0c0] - fix(acp): keep a KAS chat's stored record when its resume fails after the load (#37955) [pick 6ceb7b5] - fix(gateway): ignore a repeat SIGTERM during graceful shutdown (#38031) [pick b48287d] - fix(security): keep a quote in a $( ) from hiding a later ssh (#37558) [pick b9fed61] - fix(agent): rebuild takes a server's disabledTools from the kiro global (#38147) [pick c50bbcc] - fix(mcp_gateway): keep the backend when a stub leaves an open listen (#38121) [pick 3e9c7f9] - fix: refresh plan and model list after a kiro-cli sign-in to another account (#38053) [pick 5ad3d36] - fix(slack): keep a picture sent in a linked thread for the dashboard turn (#38076) [pick 7f8903e] - fix: keep a resolved tool policy when the gateway is too slow to answer (#36669) [pick 9be5691] - fix: open owner-only files and prune overlay folders without following links (#36994) [pick 6a1acc9] - fix: refuse the local token mint to app backends (#38113) [pick d166dab] - fix(subagent): hold a spawn's first prompt for its MCP servers (#38127) [pick e3e0298] - fix(security): refuse a headless git --output write with no approver (#36326) [pick 1abee40] - fix(restore): require an explicit mode, never default to replace (#38094) [pick ca86c06] - fix: make the deny gate's shell walk linear in command length (#36437) [pick 22c100b] - fix(chat): let a cancelled background start finish its session teardown (#36664) [pick b1dd34f] - fix(acp): refuse a start when two differing specs declare the agent's name (#38411) [pick 80ccfff] - fix: probe a silent turn while its co-tenant keeps the process busy (#38662) [pick 6354490] - fix(kas): let a reopened chat switch to models its load select omits (#38376) [pick 1640822] - fix(cloud): install a patched node 22 on run on aws instances (#38732) [pick 059cb90] - fix: write member record files without following links (#37303) [pick aac9642] - fix: fail a kas start fast once the host has turned its mcp off (#38677) [pick e147238] - fix(decisions): fall back to HTTP/1.1 when h2 is missing (#38759) [pick fc16482] - fix(mcp_gateway): free a spawn permit when its backend exits before initialize (#38793) [pick a084ba2] - fix(kas): start an app chat whose tool policy hides every kirocrew-cron tool (#38761) [pick ccea5a9] - fix(acp): give the tool-stall watchdog a margin over native waits (#34117) [pick b5d9e89] - fix(mcp): bind the working-folder answer to its launch; observe launch changes behind name grants (#38983) [pick a1069be] - fix(mcp): hide the gateway secret files from the npm install and third-party probe spawns (#39000) [pick 14d8571] - fix(sandbox): fold env name case on Windows in the agent env scrub (#33997) [pick 9bdce76] - fix(apps): let app turns follow the Auto approval mode (#38830) [pick e8336df] - fix: end a dashboard turn stopped while it is still being prepared (#36478) [pick 37fff93] - fix(acp): cleanup_session deletes the record on the session's own host (#39046) [pick 31b5ec4] - fix(acp): scan only the new part of a streamed tool result (#38852) [pick e2870db] - fix(sandbox): make an unscoped session host the OOM victim, not the gateway (#39189) [pick 2be6dde] - fix(security): read aws s3 downloads piped into tail, with 2>&1, or with an AWS_PROFILE prefix (#38271) [pick bf65d97] - fix: redact four display and log paths and use a fixed 502 message for session switch refusals (#38982) [pick 55d9ec7] - fix(sandbox): pin a credential-masking app's folder after the masks on the namespace backend (#34339) [pick afd2b14] - fix(acp): wait for systemd scope admission as its own startup stage (#37008) [pick 3e29c86] - fix(acp): wait for systemd scope admission on the AcpClient spawn path (#38303) [pick 85f0a25] - fix(acp): stamp the spawn instance on the AcpClient child (#38810) [pick f36eb5a] - fix: end the turn when the agent never confirms a stop (#38512) [pick 2665c9d] - fix(kas): renew a refused crew sign-in instead of failing every start (#38978) [pick 2f48cac] - fix(security): keep self-host detection when the ssh verb is a glob (#34056) [pick ab53f10] - fix(security): judge each substitution body for ssh-to-self (#37616) [pick d5b7ac3] - test: check the ssh floor's nesting bound below the gate's depth cap (#37964) [pick 6c9ae1d] - fix(mate): apply held Bot limits on shared claude sessions and refuse unnarrowed KAS children (#39212) [pick 721bbbe] - test(integration): wait out and reset the hidden-chat refresh between boots (#37933) [pick e77586d] - fix(browser): fall back to Kiro's Chromium under Automatic when Chrome's remote debugging is off (#39265) [pick 31912eb] Left out of #39342's set (not needed for 0.13.0): the provider_labels refactor, #34045, #36668, #39120 and #37627. Merge with release/0.13.0: kept both imports in runtime_session_load, runtime_spawn_launch and session_provider; session_allocation lists the memory_policy owner; the keep-record resume path passes kas_memory_mode as main does; dropped the ACP_BACKENDS_SESSION_EVICTION import that moved to session_provider_new_conversation.
Problem / Motivation
Goal: a MiMo Code chat on a host with no Xiaomi sign-in is stopped with a notice that names the fix, instead of quietly sending the prompt to Xiaomi's hosted model.
MiMo Code is built on opencode and has the gap #37480 closed for opencode. Measured on MiMo Code 0.1.17 from a scratch home with no sign-in, no key and no
modelin its config:session/newputs the session onxiaomi/mimo-v2.6-pro-ultraspeed, advertises threexiaomi/models, and the first prompt goes toapi.xiaomimimo.com/v1/chat/completionswith noAuthorizationheader. Crew showed nothing, because the start-time check runs for opencode only.Why it matters
An operator who picked MiMo Code and has not signed in has their chats, and whatever the model reads in the work dir, sent to a hosted service without a sign-in they made, with no sign that it happened.
Not a goal
session_handle_model_selection.ensure_served_default), which has no hosted-fallback check for opencode either. Predates this change.What changed (motivation → approach → change)
MimocodeAcpClient(AcpClient, serves=mimocode)(acp/client_mimocode.py, bound from the new owneracp/client_mimocode_session.py) fills only the_refuse_harness_default_modelhook that_ensure_served_defaultand the refused-pin exit of_apply_startup_modelalready call.AcpClient(acp_backend="mimocode")now builds it; the base hook is unchanged. The test is a newis_mimocode_hosted_fallback(acp/no_model_provider.py), sharing_only_hostedwith opencode's: the current model and every advertised model carry the hosted prefix (xiaomi/here). opencode's behaviour is unchanged. The new owner joins_CLIENT_OWNERS(acp/client.py) andNON_EGRESS_REDACTION_MODULES(security_posture.py), as opencode's did._verify_mimocode_routing) recordsHarnessReadBack.hosted_credentialthrough_mimocode_hosted_credential_present: True whenXIAOMI_API_KEYorMIMOCODE_AUTH_CONTENTis set in the child's environment, when the resolved config givesprovider.xiaomi.options.apiKey(_mimocode_config_has_xiaomi_key; measured: MiMo Code sends it as the bearer and advertises the same three models), or when the sign-in file the auth declaration names exists ($XDG_DATA_HOME/mimocode/auth.jsonwhen that is set, else~/.local/share/mimocode/auth.json). Presence only: the file is never opened. The paths come from the existinghost_authdeclaration, not new literals.modelfrommimo debug configintoconfig_model, as opencode's does.AcpNoModelProvider, non-transient and not retried, withmimocode_hosted_fallback_messagenaming MiMo Code's signed-out message and the pick-a-model fix.Backwards compatibility
Breaking, narrowly: a MiMo Code host with no sign-in file, no Xiaomi key in the environment and no
modelin its config used to chat on Xiaomi's hosted model and is now refused until it signs in, names a model, or picks one. Hosts signed in withmimo providers loginare unchanged. A host whose Xiaomi key isprovider.xiaomi.options.apiKeyinmimocode.jsonis unchanged too. Removes nothing.Tests
Proof: not provable -- other: proved by manual revert, see the list below
Manual revert, each with the new tests kept: the hook binding removed from
MimocodeAcpClient→ 2 tests fail (test_no_sign_in_refuses_before_any_prompt,test_a_refused_pin_that_leaves_the_hosted_default_is_refused);_mimocode_hosted_credential_presentforced to False → 3 fail (test_the_sign_in_file_exists,test_the_sign_in_file_under_xdg_data_home,test_xiaomi_api_key_is_set);_mimocode_config_has_xiaomi_keyforced to False →test_a_key_in_the_harness_configfails.New
test/test_acp_mimocode_hosted_fallback.py, with the model list from the live run:modelnamed in the harness config; an own provider beside the hosted list.XDG_DATA_HOME;XIAOMI_API_KEY; the read-back records the configmodel, and counts a non-blankprovider.xiaomi.options.apiKey(a blank one does not), with everyMIMOCODE_*,XIAOMI_API_KEYandXDG_DATA_HOMEcleared so the runner's shell cannot steer it.Related suites run locally: 98 test files touching MiMo Code, model selection, served default, the read-back, the client owners and the redaction posture: 7023 passed, 1 skipped.
test/test_client_bindings.pygainsMimocodeAcpClient's member inventory; its class-pick test now expectsMimocodeAcpClientfor mimocode and keepspias the backend that builds the base class. black, isort, flake8, mypy, semgrep diff scan and the flake-pattern ratchet pass. Local GPT and Opus reviews: PASS.Manual verification
Measured against MiMo Code 0.1.17 before the fix, over ACP, scratch home, all outbound HTTPS to a refusing local proxy, Xiaomi's base URL pointed at a local fake model: no credential → prompt sent with no
Authorization; a sign-in file → same advertised list, prompt sent withBearer. The fixed build was not re-driven against a live MiMo Code; the unit tests replay the captured list.Related Issues
Closes #37628
Sibling sweep
Swept: git grep -n "_refuse_harness_default_model" -- src/kiro_crew/acp
Sibling: src/kiro_crew/acp/client_opencode_session.py -- not affected -- opencode's own hook, unchanged
Sibling: src/kiro_crew/acp/session_handle_model_selection.py -- not affected -- pooled path has no hosted-fallback check for any harness; out of scope
Pattern harvest
Not generalizable: the condition is read from each harness's own default-model behaviour; opencode and MiMo Code are the two that start on a hosted model unasked.
Checklist
Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.