fix(runtime): make the WriteStdin contract derivable and drift-proof - #4378
Open
liugddx wants to merge 1 commit into
Open
fix(runtime): make the WriteStdin contract derivable and drift-proof#4378liugddx wants to merge 1 commit into
liugddx wants to merge 1 commit into
Conversation
WriteStdin publishes a loose provider schema and enforces a separate strict validator, but the two were built inline in buildWriteStdinTool and the description carried no concrete payload. A model could not derive a single legal call from the tool alone: the published schema accepts shapes the strict layer rejects, and nothing pinned the documented form to what the runtime actually accepts. Extract the pair into createWriteStdinSchemas() so both layers can be exercised together, add a concrete minimal example to the description, and pin one minimal legal payload per action type (text, named key, key chord, mouse click/move/scroll, resize-only) in WRITE_STDIN_MINIMAL_EXAMPLES. Add a contract-conformance test asserting every documented example is accepted by BOTH the provider and strict layers, that the advertised description example round-trips through both, that provider null/0/'' placeholders are normalized away, and — as a non-vacuous control — that genuine contract violations (mouse click without a button, a non-canonical ref, input+actions together) are still rejected. This is presentation- and test-only: no schema semantics, permission classification, or runtime behavior change. Part of apache#4267. Closes apache#4354. Co-Authored-By: Claude Opus 4.8 <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
WriteStdinexposes a loose provider schema (so providers that injectnull/0/''placeholders are tolerated) and enforces a separate strict validator. The two schemas were built inline insidebuildWriteStdinTool, and the tool description carried no concrete payload. The net effect: a model cannot derive a single legal call from the tool alone — the published schema advertises shapes the strict layer rejects, and nothing tied the documented form to what the runtime actually accepts.This change makes the contract derivable and keeps it from drifting:
createWriteStdinSchemas()so the provider (loose) schema and the strict validator can be exercised together.{"ref":"maka://runtime/background-tasks/<id>","actions":[{"type":"key","key":"enter"}]}.WRITE_STDIN_MINIMAL_EXAMPLES— text, named key, key chord, mouse click, mouse move, mouse scroll, and resize-only.Why it's safe
Presentation- and test-only. No schema semantics, permission classification, or runtime behavior changes. The strict validator, its normalization, and byte caps are untouched — the factory extraction is a pure refactor, verified by the existing
buildWriteStdinToolstill consuming the same pair.Tests
New
describe('WriteStdin provider/strict contract conformance')inshell-tools.test.ts:providerParametersandstrictParameters.{type:'key',key:'enter'}.input+actionstogether are all rejected.Causal proof (fail-without / pass-with): temporarily replacing the advertised description example with a strict-invalid shape (a mouse click missing its
button) makes test 2 fail (# fail 2); restoring it returns the suite to green (# pass 14, the sole remaining failure being an unrelated pre-existing/bin/echospawn test that only runs on POSIX). So the conformance tests gate the documented shape against the real schema rather than passing vacuously.Part of #4267. Closes #4354.