Repository navigation
fix(census): a function's own library import is not an unresolved caller; name what a caveated reference lacks - #1135
Merged
pengfei-threemoonslab merged 4 commits intoNov 14, 2026
Conversation
The caller census exempted a module_not_found reference bound only by another library's import, but looked the name up at module scope while the resolver had followed the function's own binding. A function-local `from agents import Runner` or `import uvicorn` therefore made `Runner.run(...)` an unresolved reference to any builder named `run` (development members MIS_TALENT-5 to -8), and a module-level library import of the same name was consulted in place of a function-local application import (fail-open). Read the binding the resolver followed. Exempt only one absolute import inside a function of a module neither the read scope nor the repository provides; second bindings, class bodies, nonlocal/global, relative imports and modules the scope or repository holds stay limits. The module-level rule is unchanged. A reference that reaches a definition but is not established because of caveats printed ": None"; name the definition and the caveats instead. Closes #1134
pengfei-threemoonslab
added a commit
that referenced
this pull request
Nov 9, 2026
…rison ahead of Packaging, with the full-corpus timings (#1046) The 1.3.0 section lists Application comparison before Packaging, and #1135 adds the same heading at that point; placed after Packaging, merging both would leave two Application comparison headings without a textual conflict. The timings now come from one development-corpus run of this head (load 2-6, every member under the cap, every answer identical to the pre-fix answers).
6 of 11 tasks
… into review-1135 # Conflicts: # CHANGELOG.md
pengfei-threemoonslab
added a commit
that referenced
this pull request
Nov 14, 2026
pengfei-threemoonslab
added a commit
that referenced
this pull request
Nov 14, 2026
…n's import-search checks (#1046) (#1137) * perf(readers): read each module's import-search edges once per read (#1046) * perf(readers): read each module's import-search refusal once per read, checked per carrier set (#1046) * perf(readers): compute a parsed file version's patch map once per run (#1046) * docs(changelog): diff --application import-search reads once per reader (#1046) * docs(changelog): name what keeps agr_ai_curation#858 and #860 near the cap (#1046) * docs(changelog): agr_ai_curation#860 measured on this change (#1046) * docs(changelog): file the import-search entry under Application comparison ahead of Packaging, with the full-corpus timings (#1046) The 1.3.0 section lists Application comparison before Packaging, and #1135 adds the same heading at that point; placed after Packaging, merging both would leave two Application comparison headings without a textual conflict. The timings now come from one development-corpus run of this head (load 2-6, every member under the cap, every answer identical to the pre-fix answers). * docs(changelog): fold the two Application comparison sections #1135 and #1137 each opened an `### Application comparison` section under Unreleased. Keep one heading, with #1135's entry first and #1137's after it.
pengfei-threemoonslab
added a commit
that referenced
this pull request
Nov 14, 2026
This was referenced Nov 15, 2026
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.
Problem
Two precision defects in the #963 caller census (
BuilderCalls._censusinsrc/agents_shipgate/inputs/builder_calls.py), seen in the v1.3.0 development run (04fc9ced,~/.cache/shipgate-q2/out-cut-04fc9ced):Tiendat2703_MIS_TALENT-5to-8withhold rows on texts such as'run' (run_risk_flow.py:35) has an unresolved reference at app/Agent/financeAgent.py:153: no file inside the read scope provides module 'agents' imported by app/Agent/financeAgent.py, and the same foruvicornatapp/ngrok.py:47. The census is looking for callers of the script entryrun; it findsRunner.run(...)anduvicorn.run(...). At the head pin both imports are function-local (from agents import Runnerinside atry:inrun_finance_preflight_agent,import uvicorninmain(), read by the closurerun_server), and the repository holds noagentsoruvicornmodule anywhere.: None. 1,376 occurrences ofhas an unresolved reference at …: Noneacross 10 members of that run (359 in rowuncertainty), mostlymosnin_realestatecrm-612(1,051), thensurrealdb_agent-memory-openai-agents-sdk-1,carlospolop_chack-agent-25,SponsioLabs_Sponsio-173,ITMO-NSS-team_FEDOT.MAS-30/36/38/42,liauto-siada_siada-cli-6,Lling0000_OpenCMO-41.Cause
_elsewherealready exempts amodule_not_foundreference whose name is bound only by another library's import (another_library→ImportResolver.repository_holds, which separates application code outside the read scope from a third-party package, Google ADK: trace bounded FunctionTool factories into agent tool bindings #865). But it looked the name up inmodule.bindings, the module scope. The resolver had followed the function's own binding (_resolve_reference→ScopeIndex.enclosing_bindings→resolve_local_import), so for a function-local import the lookup found nothing and the reference counted as unresolved. When a module-level library import had the same name, it was consulted in place of the local import the resolver actually followed — the opposite error (fail-open):from agents import Runnerat module level plusfrom common.tools import Runner(application code outside the scope) in a function exemptedRunner.run(...).Resolution.detailisNonewhen a reference reaches a definition butcaveats(code that runs first imports something unread that could reassign it) keep it from being established. The census formattedresolution.detailunconditionally.Bug, not a deliberate rule
LOCAL_BINDINGbranch directly above in_elsewherealready reads the scope-aware binding (self.scopes(module).enclosing_bindings(evaluation_site(...), head)); only theMODULE_NOT_FOUNDbranch read module scope.another_libraryto function-local imports:_expanding_importswalks every import statement in the caller (ast.walk), including function-local ones, andlist_expressions(borrower census, ~l.3930) resolves a non-top-level import withresolve_local_importand then appliesanother_library(statement, alias)to that statement.docs/engineering/caller-supplied-agent-lists.mdsays the census "finds direct callers in the read scope, including local imports"; it states no rule that a local third-party import is unresolved.local_shadows_module_library).Fix
_elsewhere: formodule_not_found, read the binding the resolver followed. When the reference sits in a scope that binds its head,_local_library_importdecides; otherwise the module-level rule is unchanged, byte for byte._local_library_importexempts only: exactly one binding of the name in the enclosing scope; that binding is an absoluteimport/from … importwhose statement belongs to a function (def/async def), possibly undertry/if; nononlocal/globalof the name anywhere inside that function; the repository does not hold the module (another_library, the existing Google ADK: trace bounded FunctionTool factories into agent tool bindings #865 notion, which covers a localagents/package oruvicorn.pyanywhere in the repository import roots); and no file in the read scope provides the import's top-level package (_absoluteraisesmodule_not_found), so the failure is the import itself and not a deeper hop through local code._unresolved_detailrenders aNonedetail in words:'<reference>' reaches its definition at <ref>:<line>, but <caveats>; a defensive fallback names the resolver reason. Every non-Nonedetail is returned unchanged.What stays fail-closed, and why
uvicorn.py,agents/__init__.py, even outside the read scope)repository_holds).Runner = …, a second import,del, a loop target …)local_bindingbefore this change;_local_library_importalso refuseslen(local) != 1.nonlocal/globalof the name in any scope nested in the functionScopeIndexlisting it in the outer scope.LOAD_NAME: before (or without) the class's own binding the name falls back to the module.from .vendor import x)another_libraryis false forlevel > 0).from helpers import Runnerwherehelpers.pyimportsuvicorn)A single function-local import under
try/ifis exempt on purpose: a name bound anywhere in a function is local to all of it, so if the import does not run the name is unbound (UnboundLocalError), never the module's or a builtin. That is why the conditional-binding rule the module path needs (CONDITIONAL_BINDING) does not apply here; a second, conditional rebinding still does.Tests
tests/test_builder_calls.pytest_another_librarys_run_is_not_an_unresolved_caller(6): module-level SDK import (unchanged), function-local SDK import, undertryin anasync def,import uvicornread by a closure,from uvicorn import run(same name as the builder), function-localgoogle.adk.runners.test_a_local_import_that_could_be_application_code_keeps_its_limit(9): repository module, repository package, local import shadowing a module-level library import, rebound, imported twice,nonlocal, class body, relative, scope module importing the library.test_an_unresolved_reference_with_caveats_says_what_is_unknown: the exact new text, and no limit ends inNone.tests/test_builder_bindings.py::test_a_function_local_third_party_builder_is_a_different_callable(sdk/adk × rebound): the SDK and ADK readers keep a builder complete beside a function-local third-partybuild, and incomplete when the function rebinds it.Against
origin/main'sbuilder_calls.pythe new census tests fail as expected (the five local positives, the shadowing negative, and the text test), and the reader test's non-rebound cases fail. Removing each guard of_local_library_importin a scratch copy fails the matching negative (class body,nonlocal,another_library×4, top-level-package); thelen(local) != 1guard is defensive (_resolve_referencealready returnslocal_bindingfor several bindings).Focused suites:
tests/test_builder_calls.py,tests/test_builder_bindings.py,tests/test_application_diff*.py,tests/test_constructor_*.pyand every other*constructor*suite,tests/test_openai_api.py,tests/test_google_adk.py,tests/test_adk_tool_factories.py,tests/test_agent_bindings.py,tests/test_imported_tool_bindings.py,tests/test_imported_tool_review.py,tests/test_list_expressions.py,tests/test_framework_matrix.py,tests/test_tool_reach.pyand the other suites that name the census or the SDK reader (about 7,900 tests,-n 4): exit 0.ruff check .: clean.Spot check (pinned copy of this head,
run.pylogic via the subset helper, 900 s cap)Engine: a detached worktree of
c6f19d67(this PR's first commit; the second changes onlyCHANGELOG.md), against the 1.3.0 release answers in~/.cache/shipgate-q2/out-cut-04fc9ced. Output:~/.cache/shipgate-q2/out-pr1-c6f19d67.Tiendat2703_MIS_TALENT-5agents/uvicornlimits gone, none newTiendat2703_MIS_TALENT-6Tiendat2703_MIS_TALENT-7Tiendat2703_MIS_TALENT-8surrealdb_agent-memory-openai-agents-sdk-1: Nonetexts rewordedITMO-NSS-team_FEDOT.MAS-36: Nonetexts rewordedmosnin_realestatecrm-612: Nonetexts reworded (they appear in every row)SponsioLabs_Sponsio-173: Nonetexts rewordedbuild_risk_agent@app/Agent/risk_compliance_agent.py→process_risk_context. Every'run' (run_risk_flow.py:35) has an unresolved reference at …: no file inside the read scope provides module 'agents'/'uvicorn' …limit is gone, and theruncensus is now clean. The constructor caller chain then stops one hop further, at a limit this PR does not touch:'run_validated_pipeline' (app/Agent/validated_pipeline.py:208)'s retained namespace is used through computed access or as a value at app/api.py:25(the feat(readers): follow caller-supplied agent lists #963 retained-namespace gate, part of the Application diff regression: CRM#5 and MIS_TALENT#7 lost established rows after 2026-10-05 (likely #963) #1001 policy question). So the rows staynot_established, for that reason only.: None: 0 occurrences remain in the 8 answers (was 1,376 across 10 members in the full 1.3.0 run; 4 of those 10 are in this subset). Examples of the new wording:'main' (examples/01_quickstart.py:20) has an unresolved reference at examples/01_quickstart.py:41: 'main' reaches its definition at examples/01_quickstart.py:20, but examples/01_quickstart.py:17 imports 'agent_memory_openai_agents_sdk', which the repository holds outside the read scope, which is not read and could reassign it'make_chippi_agent' (chippi.py:295) has an unresolved reference at modal_app.py:813: 'make_chippi_agent' reaches its definition at chippi.py:295, but modal_app.py:153 changes or retains sys.path.insert; import search identity is unread… reaches its definition at packages/fedotmas/src/fedotmas/mas/builder.py:41, but packages/fedotmas/src/fedotmas/common/llm.py:64 has unread import-search …: Noneones (checked by normalising the detail and comparing every string; the summarycauses[].patternabstractions change with them).surrealdb…-1(4.1 → 8.8 s), whose answer changed only in text. Per exempted reference, the new check reads the top-level package's listings, which the resolver has already read, plus the repository import-root listings thatrepository_holdsreads for the module-level rule, and it walks the function's AST once.Corpus comparison (development, 49 PRs)
Run.
benchmark/application-q2/run.py --jobs 4from a detached worktree of this head (58992ff7f3), over~/.cache/shipgate-q2/reposwith every pin present (no--fetch), 900 s cap. It started at 06:32:56Z, once the one-minute load had fallen to 10.9 (after a 9-minute wait), and finished at 07:07:51Z at load 5.9. Output:~/.cache/shipgate-q2/out-pr1-58992ff7. Baseline: the run behind the 1.3.0 ledger (04fc9ced, whosesrc/is byte-identical to this PR's base),~/.cache/shipgate-q2/out-cut-04fc9ced. The comparison keys rows by (scope, agent, agent source, tool) for each member.Current head (2026-11-10). The corpus was measured on
58992ff7f3. The head is now69b1dfeec7, which merges main's #1130 in; that merge's only conflict wasCHANGELOG.md. #1130 changescore.trust_roots,core.agent_boundaryandschemas.verification, whichdiff --applicationimports. So I re-ran 8 members on69b1dfeec7:jpka/attest#3,surrealdb/agent-memory-openai-agents-sdk#1,cuppibla/adk_tutorial#9,ITMO-NSS-team/FEDOT.MAS#36,Tiendat2703/MIS_TALENT#7,kkmiecik-coder/CRM#5,cianfhoghlaim/tuatha#1andmosnin/realestatecrm#612. All 8 answers are identical to the measured run (answer_idand every row;~/.cache/shipgate-q2/out-pr1-69b1dfee-sample).partial, 6not_established, 4timeoutnot_establishedrowschangemovedanswer_id): Nonein any answer filesummaryblock's copies)run.pyexits 1 on this head, as it does onmain, only because those four members exceed 900 s. That slowdown dates from #964 and is a separate fix.The 14 answers that differ, and how. I walked every string of each answer, leaving out the engine block and the
summaryreading, and compared base with head:: Nonecensus detail, and each differs only in that detail: it is the old string withNonereplaced by the new'<reference>' reaches its definition at <file:line>, but <caveats>wording, checked by a full-string match. The other 40 carried the MIS_TALENTmodule 'agents'/'uvicorn'census texts. No other string changed.build_risk_agent@app/Agent/risk_compliance_agent.py→process_risk_context). Theruncaller census no longer namesRunner.run/uvicorn.run. The chain now stops at the next caller, whose module or retained namespace is used through computed access inapp/api.py(for example'run_pipeline' (app/Agent/pipeline.py:161)'s module is used through computed access or as a value at app/api.py:24on Update pytest requirement from <9,>=8 to >=8,<10 #5). That is the feat(readers): follow caller-supplied agent lists #963 gate, part of Application diff regression: CRM#5 and MIS_TALENT#7 lost established rows after 2026-10-05 (likely #963) #1001's policy question, so the rows staynot_established.: Nonerewording only. FEDOT.MAS Update pytest-cov requirement from <7,>=5 to >=5,<8 #30/[codex] Improve SEO and AI-search docs #36/Add release_decision block to report schema (v0.8) #38/Add capability intent diff report #42, OpenCMO#41, Sponsio#173 and surrealdb#1 change inlimitsonly. chack-agent#25 changes in 1 row, siada-cli#6 in 3 rows, and realestatecrm#612 in all 43 rows. These are exactly the ten members whose answers carried: Nonetexts.The four members this run could not answer. They time out on main, so their part of this change was measured with #1137, which changes no answer, merged on top. That was a local merge (
63e7616938, not pushed), with a full corpus run at 08:28–08:50Z;run.pyexits 0 and all 49 members answer.: Nonedetails.: Nonedetails and the 40 MIS_TALENTagents/uvicorntexts change. Nothing else changes, and no row changes status.Q1/Q2. Both stay 0/49: no answer establishes a row on either side. This PR removes two wrong reasons. It does not change which gate withholds a row.
Reproduce:
Then compare member by member against
out-cut-04fc9ced:The script lives outside the repository. It reads
runs.jsonand<slug>.jsonfrom both directories and usessummarize.py'sanswer_id. The per-member table is saved as~/.cache/shipgate-q2/pr1-vs-release.md.Closes #1134
🤖 Generated with Claude Code