Skip to content

refactor(contracts): share read-tool policies and validation context checks - #1237

Merged
yyjeqhc merged 2 commits into
mainfrom
refactor/consolidate-tool-contracts-and-validation
Oct 21, 2026
Merged

yyjeqhc merged 2 commits into
mainfrom
refactor/consolidate-tool-contracts-and-validation

Conversation

@yyjeqhc

@yyjeqhc yyjeqhc commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Why

Twenty Runner-backed Project read tools repeat the same visibility, scope, authority, effect and idempotency declaration. Runner admission, detached recovery and Registry reconciliation also repeat the same validation-step and metadata consistency rules. Keeping copies makes a contract change easy to apply unevenly.

Changes

  • Share the fixed read-only declaration for 8 LSP, 6 Git and 6 file tools. Each declaration still explicitly selects its audit policy, category, Runner capability, path hint and Session evidence policy; write/execution tools retain their existing declarations.
  • Share Artifact ranged-read continuation argument constraints while retaining each operation's selector, description, required fields and SHA-256 fence.
  • Put bounded unique validation-step names and optional metadata/name agreement on the existing ShellJobContext type. Keep operation-specific admission, authority checks, check order and error messages at their current boundaries.
  • Use the existing ExecutionPurpose parser instead of three copied eight-value allowlists.
  • Teach the existing source-based discovery catalog and corpus checks to recognize the shared constructor. Corpus scope and visibility are read from its actual Rust body rather than duplicated as parser constants.

No tool, Runner wire field, persisted field, permission or output contract is removed.

Size

Counts include comments and blank lines in the Git diff; production/test classification follows dedicated test paths and cfg(test) scopes.

Scope Added Deleted Net reduction
Production (Rust and Python) 170 457 287
Tests (Rust and Python) 64 5 -59
Total 234 462 228

The installed MSI cloc 0.6.2 reports 257 fewer Rust code lines across the changed files (5,881 → 5,624). The Rust-only physical reduction is 246 lines; the Python corpus/parser support adds 18 net lines. No test scenario or assertion was removed.

Validation

Performed on MSI Windows against base 66dc970:

  • Captured every ToolDefinition and output schema with experimental-code-mode and workspace-checkpoints enabled before and after: all 193 entries exactly equal.
  • Core validation-context tests: 2 passed.
  • Tool contracts, all features: 328 passed, 1 ignored.
  • Registry reconciliation tests: 83 passed.
  • Runner recovery-context tests: 7 passed.
  • Python discovery/catalog/corpus/selection tests: 33 passed, 1 POSIX-only skip.
  • Final cargo fmt --all -- --check and git diff --check.

The temporary inventory example was removed after comparison. No full-workspace or cross-platform process suite was run.

@yyjeqhc
yyjeqhc merged commit 6186468 into main Oct 21, 2026
18 checks passed
@yyjeqhc
yyjeqhc deleted the refactor/consolidate-tool-contracts-and-validation branch October 21, 2026 07:17
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