fix(core): withhold the next hint on confirm gate previews #296
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #296"
general
weight: 0.35
abhijeet-dhumal
Description
Confirm gate previews no longer carry the
_meta.nexthint. That hint describes the step after an action has run, and a preview has not run anything.What was wrong
With
confirmed=False, every mutating tool correctly returns a preview and sends nothing to the cluster._inject_metathen attached the hint fromTOOL_NEXT_HINTSanyway:| tool |
_meta.nexton the preview (before) ||---|---|
|
fine_tune,run_custom_training,run_container_training| Monitor with get_training_job(name) and get_training_logs(name) ||
delete_training_job| Resubmit with fine_tune() or run_custom_training() if needed ||
update_training_job| Check get_training_job(name) to verify new status ||
create_runtime| Verify with list_runtimes() or get_runtime(name) ||
patch_runtime| Verify changes with get_runtime(name) ||
delete_runtime| Confirm removal with list_runtimes() |For clients that rely on
_metainstead of the server instructions, this is the main guidance after a preview. It points them at a job that does not exist, or at a delete that has not happened. Full details and a repro are in #295.Why withhold rather than replace
I considered swapping the hint for "call again with confirmed=True" and left it out on purpose. The confirm gate is there so a person approves the action, and a hint that points straight at the confirm call makes that step easier to skip. The preview
messagealready saysSet confirmed=True to proceed. This also matches how #237 handled blockedpre_flightresults: withholdnext, keepphase.What changes
1.
_is_preview()inkubeflow_mcp/core/server.pyrecognises both preview shapes:-
PreviewResponse:status="preview"at the top level- the legacy runtime shape that
docs/CONVENTIONS.mdlists as an exception:ToolResponsewithdata.action="preview"2.
_inject_metawithholdsnextwhen_is_blocked(result) or _is_preview(result).phaseis unchanged.Only the envelope
statuscounts, so a job whose own status sits indatais not mistaken for a preview. Executedupdate_training_jobresponses carrydata.action="suspend"or"resume", never"preview", so they keep their hint.No tool schema, parameter or response shape changes. The only visible difference is that
_metaon a preview is{"phase": ...}withoutnext.Related Issue
Fixes #295
Checklist
make test-python)make verify)git commit -s)Testing
New tests (
TestInjectMetaPreviewResponsesinserver_test.py)| test | checks |
|---|---|
|
test_every_mutating_tool_has_a_post_action_hint| all 8 tools really have a hint that could leak (guards the premise) ||
test_next_withheld_for_preview_response| nonexton aPreviewResponse, for all 8 tools ||
test_next_withheld_for_legacy_runtime_preview| nonexton the runtime tools'data.action="preview"shape ||
test_phase_preserved_for_preview|phaseis still there ||
test_next_present_after_confirmed_submission| a real submission keeps its hint ||
test_next_present_after_confirmed_update| executedupdate_training_job(data.action="suspend") keeps its hint ||
test_job_status_in_data_is_not_a_preview|data.status="preview"from a job does not trigger the guard ||
test_preview_over_mcp_has_no_next_hint| end to end through an MCP client:patch_runtimepreview returns_meta == {"phase": "platform"}|The responses are built from the real
PreviewResponseandToolResponsemodels rather than hand written dicts, so a change to either model shows up here.The tests fail without the fix
With
server.pyreverted tomain, the three tests that check the fix fail and the four guard tests still pass:The tests catch a wrong fix
I broke the new guard three ways and checked that a test fails each time:
| break | caught by |
|---|---|
|
status="preview"branch removed |test_next_withheld_for_preview_response|| legacy
data.actionbranch removed |test_next_withheld_for_legacy_runtime_preview,test_preview_over_mcp_has_no_next_hint|| any
data.actiontreated as a preview |test_next_present_after_confirmed_update|All 8 tools over MCP
I also ran every mutating tool through an in-memory MCP client with the Kubernetes API faked at
ApiClient.call_api, calling each withconfirmed=False:Full suite
719 passed, 8 skippedon three consecutive runsuv lock --check,ruff checkandruff format --checkclean, 84 files formattedThe two resilience tests fixed in #290 were deselected for these runs, since on Windows they fail intermittently on
mainfor an unrelated reason. They do not touch this code.