Skip to content

Type context and transcript parameters from checked inference - #1144

Merged
trissim merged 5 commits into
mainfrom
next/toad-types-01
Oct 23, 2026
Merged

trissim merged 5 commits into
mainfrom
next/toad-types-01

Conversation

@trissim

@trissim trissim commented Oct 23, 2026 •

Copy link
Copy Markdown

Add checked parameter types across eight production modules using autotyping 24.9.0 followed by Pyrefly 1.4.0. Correct wrong inferred types to the existing owners (TurnContext, NativeContextData, PageEnd, SavedHistory, TargetTree, SidebarGroup and SidebarModelView). Checking exposed three calls to the deleted ContextManifest.require_request_id; they now use the declared DispatchRequest owner, manifest.request_id.require_id().

Tool comparison on copies of the worst file, core/context_inspection.py (121 missing parameters): Pyrefly fills 15, autotyping --aggressive fills 11, autotyping followed by Pyrefly fills 25. Read and corrected examples including required: bool for a widget collection, Self for unrelated owners, and tuple[()] for contributor paths.

Counts (AST, production only, self/cls excluded; includes positional-only, keyword-only and both variadics):

  • Eight-file batch: 557 -> 469 unannotated parameters; explicit Any remains 0.
  • Whole src/toad: 2,174 -> 2,086 unannotated parameters; explicit Any remains 14.
  • Full-production Pyrefly check against Core main 051fe6b617: 1,338 -> 1,325 errors, zero new diagnostics compared by path/code/description multiplicity. Existing checker failures are not a passing check.
  • All eight touched modules imported under python -I with source roots explicit; compileall passed for each. No pytest; tests/ unchanged. Inference/check/import/compile ran nice -n 19, Pyrefly -j 1.

Stops retained in the counts:

  • src/toad/transcript_preparation.py:67: measured receives both TranscriptPage and WirePage (wire_history.py:126); rejecting the inferred TranscriptPage-only parameter avoids hiding the missing shared page contract.
  • src/toad/transcript_state.py:400: schedule needs an owner with source preparation and run_worker; TranscriptSourcePreparation alone does not declare both. This file remains unchanged.
  • src/toad/transcript_publication.py:849: typing contents/output with concrete conversation owners introduces a cycle. Rejected those imports rather than hiding them in a function or new TYPE_CHECKING block.
  • src/toad/widgets/context_explorer.py:119,143: inferred TreeNode[ContextNode] still admits absent data in the external tree API. Rejected those parameter annotations; no cast or defensive guard was added.

Assumed:

  • Existing declared parents, not unions of sibling classes, define accepted inputs.
  • Existing checker errors are a baseline for identifying newly introduced errors, not evidence of correctness.
  • Unresolved parameters remain visible in the counts; this batch does not claim to type the whole package.

Review correction at this head: both matches methods take ConversationSessionBinding, their existing shared input parent; both bound_to methods take Conversation. SourcePublicationRequests.request has one typed constructor parameter and no variadics. Observed requests bind presentation with partial at their two callers; request captures the existing BoundFrame and supplies binding/owner/generation to the constructor. AgentBinding now declares observe_thread_presentation, which its concrete members already implement. Both remain concrete. This correction reduces unannotated parameters 2,094 -> 2,086; all eight touched modules import/compile; checker remains at 1,325 errors with zero new diagnostics.

Core stop, unchanged: src/toad/transcript_publication.py:215 show_draft accepts TranscriptDraftUpdate | TranscriptSnapshotUpdate and reads draft. Core's members at agent_comms/acp_extension.py:624 and :632 both declare draft, but their parent AgentCommsUpdate does not. Core owns the missing shared draft capability; no union or field change made in this correction.

Assumed for correction: ConversationSessionBinding is the existing input parent; a captured frame's constructor inputs are bound synchronously before submission. No changes to #1115 or its worktree.

Run autotyping followed by Pyrefly, then correct inferred types against existing callers and capability parents. Reject object, narrow empty defaults, sibling unions and cyclic imports. Use DispatchRequest.require_id for the three stale ContextManifest calls exposed by checking.
@trissim
trissim marked this pull request as ready for review October 23, 2026 10:50
Copilot AI balanced review requested due to automatic review settings October 23, 2026 10:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Match against the existing ConversationSessionBinding parent. Request takes a constructor with the captured binding, owner and generation; observed constructors bind their presentation explicitly at the caller. Declare the existing presentation-observation capability on AgentBinding rather than erase the view type.
trissim and others added 3 commits October 23, 2026 07:12
request() built a throwaway BoundFrame and copied its three fields into a
callable typed with those same fields (MEMB-5). The binding's capture
already builds the publication from its kind; request types the kind and
its one extra argument and hands both to capture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main renamed AgentBinding to AgentConnection and moved SessionView to
SessionScope; the batch annotations are reapplied on main's versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
show_draft took a union of two update classes to read two fields both
declare; it now takes those values, and no union of our own classes stands
in for a parent neither shares.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trissim
trissim merged commit 661fc63 into main Oct 23, 2026
2 of 3 checks passed
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.

2 participants