Skip to content

Edit context includes verified forwarding implementations - #1494

Open
zlareb1 wants to merge 4 commits into
mainfrom
fix/edit-context-forwarded-definition
Open

zlareb1 wants to merge 4 commits into
mainfrom
fix/edit-context-forwarded-definition

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Changelog category

  • Improvement

Changelog entry

code.edit_context includes the implementation behind a verified Python forwarding definition when the index holds both at the same revision.

Why

An edit lookup can reach a short public entry point whose implementation lives in another definition. The caller and the implementation belong in one response when the retained source and call edge prove the forwarding relationship.

Scope and risk

The edit lookup reuses the source and graph checks from code.grep. A complete wrapper must contain one forwarding call. The graph must resolve that call to one target and the index must retain the full target at the wrapper's revision. A call in a default argument can share that line, so the handler checks the entire definition for competing calls. The written callee must match the indexed target name. For a bare call, the indexed Git blob must provide one unconditional lexical binding without a competing binding in the source file. The response's primary definition and its test examples keep their existing roles. The additional block uses the existing enrichment deadline and its tokens count toward the trace.

Compatibility, rollout and rollback

  • forwarded_definition is an optional code.edit_context response field with the target name, path, line span, and body.
  • This read uses the current index and requires no migration or backfill. Reverting removes the response field.

Tests

  • pytest -q tests/integration/test_code_plane.py -k verified_forwarded_implementation passed six fixtures against a private index covering a direct target, a different revision, mismatched names, a rebound name, and a competing call in a default argument.
  • A frozen repository replay verified the target body byte for byte on both parser and compiler indexes. The same requests also verified the ordinary definition lookup and the existing grep expansion.
  • make format-check, make lint, and make typecheck passed. The standalone replay and the focused integration check cover the changed read path.

AI assistance in the code

  • AI-generated with Codex. Checked the changed handlers, retained source checks, transport payload, and regenerated SDKs.

Checklist

  • Local format, lint, type checks, and focused integration pass.
  • SDKs and operation reference are regenerated.
  • The body names the wire change and rollout requirements.
  • Commits are signed off.

Note

Medium Risk
Adds optional enrichment on a core read path with AST, blob, and graph checks; failures are silent omissions but wrong verification could leak misleading bodies.

Overview
code.edit_context can now return an optional forwarded_definition (GrepDependency) alongside the resolved wrapper when the index proves a single Python forwarding call to one callee at the same revision.

Verification reuses the grep dependency machinery: the wrapper must be a one-statement def/async def with one call on that line (no default-arg collisions), the served body must match the indexed revision, bare calls need a unique module-level binding without shadowing, and the call graph must resolve to exactly one target. code.symbol and other routes omit the field; serialization drops it when empty. Tokens count toward the edit-context budget and trace route.

SDKs (Python/TypeScript/Rust contracts), ops reference, and MCP descriptions document the new wire field. Integration and unit tests cover direct forwarding plus negative cases (revision skew, aliases, shadowing, rebound names, signature/default-arg noise).

Reviewed by Cursor Bugbot for commit e6f473a. Bugbot is set up for automated code reviews on this repo. Configure here.

A named lookup can return a short forwarding function and its tests while the implementation is in a separate definition. Reuse the source and call-edge checks from grep to provide that implementation at the same revision.

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 25, 2026 8:54pm UTC
loom-telemetry Ready Ready Preview Nov 25, 2026 8:54pm UTC

Request Review

A default argument can share the return call line. Reject competing syntax, and accept a parser-proven alias when the graph agrees on its target.

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
A module may rebind an alias after import even when the parser retained a high-confidence edge. Require a same-name call witness before serving the target body.

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>

This branch has not been deployed

No deployments
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