sourcecode 1.46.0__py3-none-any.whl → 1.50.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sourcecode/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """sourcecode — Deterministic codebase context maps for AI coding agents."""
2
2
 
3
- __version__ = "1.46.0"
3
+ __version__ = "1.50.0"
@@ -3829,6 +3829,18 @@ def extract_java_endpoints(root: Path) -> "dict[str, Any]":
3829
3829
  all_symbols: list[SymbolRecord] = []
3830
3830
  extends_map: dict[str, str] = {}
3831
3831
 
3832
+ # F-2: detect WebFlux / functional (RouterFunction) routing. Such routes register
3833
+ # via a fluent DSL (route().GET("/path", handler)) instead of @RequestMapping
3834
+ # annotations, so the annotation-based surface built below does not see them. We
3835
+ # deliberately do NOT synthesize endpoint entries: the literal paths here are
3836
+ # relative (the real path includes nest()/group-version prefixes that cannot be
3837
+ # resolved statically), and emitting partial paths would mislead more than an empty
3838
+ # surface. Instead we count them and surface an honest limitation so a zero/partial
3839
+ # annotation surface is never read as "this app exposes no endpoints".
3840
+ _FN_ROUTE_RE = _re.compile(r'\.(?:GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s*\(\s*"')
3841
+ _fn_route_files: set[str] = set()
3842
+ _fn_route_count = 0
3843
+
3832
3844
  for jf in java_files:
3833
3845
  try:
3834
3846
  source = jf.read_text(encoding="utf-8", errors="replace")
@@ -3838,6 +3850,11 @@ def extract_java_endpoints(root: Path) -> "dict[str, Any]":
3838
3850
  rel = str(jf.relative_to(root)).replace("\\", "/")
3839
3851
  except ValueError:
3840
3852
  rel = str(jf).replace("\\", "/")
3853
+ if "RouterFunction" in source or "RequestPredicates" in source:
3854
+ _fn_hits = len(_FN_ROUTE_RE.findall(source))
3855
+ if _fn_hits:
3856
+ _fn_route_files.add(rel)
3857
+ _fn_route_count += _fn_hits
3841
3858
  _, symbols, _ = _extract_symbols(source, rel, extra_capture=_extra_capture)
3842
3859
  for sym in symbols:
3843
3860
  all_symbols.append(sym)
@@ -4045,6 +4062,26 @@ def extract_java_endpoints(root: Path) -> "dict[str, Any]":
4045
4062
  result["spec_sourced_endpoints"] = len(_spec_endpoints)
4046
4063
  if _openapi_spec_path:
4047
4064
  result["openapi_spec"] = _openapi_spec_path
4065
+ # F-2: surface functional/RouterFunction routing as an honest limitation. Not modeled
4066
+ # in the surface above; counted so an empty/partial annotation surface is not misread.
4067
+ if _fn_route_count:
4068
+ result["functional_routing"] = {
4069
+ "files": len(_fn_route_files),
4070
+ "route_registrations": _fn_route_count,
4071
+ "modeled": False,
4072
+ }
4073
+ _fr_msg = (
4074
+ f"{_fn_route_count} functional route registration(s) across "
4075
+ f"{len(_fn_route_files)} file(s) use WebFlux/RouterFunction routing "
4076
+ f'(route().GET("/path", handler)), which is NOT modeled here — this surface '
4077
+ f"covers annotation-based (@RequestMapping/@GetMapping) endpoints only."
4078
+ )
4079
+ if not endpoints:
4080
+ _fr_msg += (
4081
+ " This surface is EMPTY despite functional routes being present — "
4082
+ "do NOT read it as 'no endpoints'; the app's HTTP surface is unmodeled."
4083
+ )
4084
+ result.setdefault("warnings", []).append(_fr_msg)
4048
4085
  return result
4049
4086
 
4050
4087
 
@@ -44,7 +44,18 @@ _SCHEMA_VERSION = "1.0"
44
44
  # Only appears on class nodes, never method nodes. Including it
45
45
  # chains through DTOs and entities that merely reference the service
46
46
  # type, inflating caller counts without semantic value.
47
- _SKIP_EDGE_TYPES: frozenset[str] = frozenset({"contained_in", "imports"})
47
+ # implements / — CH-006: structural type declarations, NOT calls. The reverse edge
48
+ # extends on an interface/base lists its implementors/subclasses; an
49
+ # implementor does not *call* the interface by virtue of implementing
50
+ # it. Traversing these attributes every SIBLING implementor of a shared
51
+ # interface as a "caller". On a high-fanout in-repo hub interface (e.g.
52
+ # halo's CustomEndpoint, 43 implementors) this turned a leaf endpoint
53
+ # into 42 false direct callers / risk:high. Interface→impl expansion that
54
+ # IS wanted (CH-001a/b) flows through ImplementationGraph indices, not
55
+ # through these reverse-graph edges, so excluding them here is loss-free.
56
+ _SKIP_EDGE_TYPES: frozenset[str] = frozenset(
57
+ {"contained_in", "imports", "implements", "extends"}
58
+ )
48
59
 
49
60
  # Max BFS depth guard — caller growth is bounded per _bfs_callers
50
61
  _BFS_DEFAULT_DEPTH = 4
@@ -148,6 +159,68 @@ _STEREOTYPE_ANNOTATIONS = frozenset({
148
159
  _VALUE_TYPE_KINDS = frozenset({"class", "enum", "record"})
149
160
 
150
161
 
162
+ # ---------------------------------------------------------------------------
163
+ # CH-005 — framework/external-interface DI blind-spot detection
164
+ # ---------------------------------------------------------------------------
165
+ # When a class implements/extends a type that is NOT an in-repo symbol (a
166
+ # framework or library supertype — e.g. Spring Security's RedirectStrategy, a
167
+ # servlet Filter, a JPA base), the class is typically invoked polymorphically
168
+ # *through that external type* and wired by framework DI/config. No in-repo call
169
+ # edge ever names the impl's own method, and ImplementationGraph.build()
170
+ # deliberately drops external supertypes (cir_graphs: `to_fqn not in
171
+ # known_symbols` → skipped), so CH-001b cannot expand to the interface. Result:
172
+ # impact-chain reports 0 callers / risk:low at confidence=high — a dangerous
173
+ # false negative, since the real blast radius flows through framework wiring the
174
+ # static call-graph never traverses. Detect the external supertype positively,
175
+ # warn, and downgrade confidence (parallel to the CH-003 value-type guard).
176
+ #
177
+ # Inert marker interfaces carry no methods → no polymorphic dispatch → no hidden
178
+ # blast radius, so they are excluded to avoid firing on plain Serializable DTOs.
179
+ _INERT_MARKER_SUPERTYPES = frozenset({
180
+ "Serializable", "java.io.Serializable",
181
+ "Cloneable", "java.lang.Cloneable",
182
+ "Externalizable", "java.io.Externalizable",
183
+ })
184
+
185
+
186
+ def _external_supertypes(cir, class_fqn: str) -> list[str]:
187
+ """Return supertypes of class_fqn that are NOT in-repo symbols.
188
+
189
+ Reads raw implements/extends edges from cir.dependencies and keeps only those
190
+ whose target cannot be resolved to a single in-repo class (i.e. framework /
191
+ library types). Mirrors ImplementationGraph's resolution rules (exact FQN
192
+ match, then unambiguous simple-name match) so the internal/external split is
193
+ identical. Inert marker interfaces are dropped. Order-preserving, deduped.
194
+ """
195
+ deps = getattr(cir, "dependencies", None) or []
196
+ known: set[str] = set(getattr(cir, "symbols", None) or [])
197
+ simple_to_fqn: dict[str, list[str]] = {}
198
+ for sym in known:
199
+ if "#" not in sym and "." in sym:
200
+ simple_to_fqn.setdefault(sym.rsplit(".", 1)[1], []).append(sym)
201
+
202
+ external: list[str] = []
203
+ for edge in deps:
204
+ if edge.get("type") not in ("implements", "extends"):
205
+ continue
206
+ frm = normalize_owner_fqn((edge.get("from") or "").strip())
207
+ if frm != class_fqn:
208
+ continue
209
+ to = (edge.get("to") or "").strip()
210
+ if not to or ">" in to or "<" in to:
211
+ continue
212
+ simple = to.rsplit(".", 1)[1] if "." in to else to
213
+ if simple in _INERT_MARKER_SUPERTYPES or to in _INERT_MARKER_SUPERTYPES:
214
+ continue
215
+ # Internal if it resolves to exactly one in-repo class (exact or simple-name).
216
+ if to in known:
217
+ continue
218
+ if len(simple_to_fqn.get(simple, [])) == 1:
219
+ continue
220
+ external.append(to)
221
+ return list(dict.fromkeys(external))
222
+
223
+
151
224
  def _is_unmodeled_value_type(cir, class_fqn: str, model) -> bool:
152
225
  """True iff class_fqn is positively a plain value/DTO type whose blast radius
153
226
  flows only through type-usage edges the impact graph does not model.
@@ -605,6 +678,12 @@ class ImpactOrchestrator:
605
678
  t0 = time.monotonic()
606
679
  depth = max(1, min(depth, _BFS_HARD_LIMIT))
607
680
  warnings: list[str] = []
681
+ # F-1: not every warning degrades confidence. The CH-001a/b interface↔impl
682
+ # expansion notices are INFORMATIONAL (they describe normal, correct operation)
683
+ # and previously forced every Spring interface/impl query — the common case — down
684
+ # to confidence=medium permanently. Only genuinely degrading conditions (capped
685
+ # traversal) set this flag; resolution=="partial" is handled separately below.
686
+ confidence_reducing = False
608
687
 
609
688
  # ── 1. Resolve symbol ─────────────────────────────────────────────
610
689
  resolution, seed_fqns, sym_warnings = _resolve_symbol(symbol, cir.symbols)
@@ -702,6 +781,7 @@ class ImpactOrchestrator:
702
781
  "Hub-class guard active: symbol has > 500 direct callers — "
703
782
  "indirect caller traversal capped at depth=1."
704
783
  )
784
+ confidence_reducing = True # capped traversal → result is incomplete
705
785
 
706
786
  # ── 3. Endpoints affected ─────────────────────────────────────────
707
787
  all_callers = direct_callers + indirect_callers
@@ -750,16 +830,38 @@ class ImpactOrchestrator:
750
830
  impact_findings_raw,
751
831
  )
752
832
 
753
- # CH-003: empty blast radius on a positively-identified value/DTO type is a
754
- # type-usage blind spot, not proof of dead code warn + drop confidence.
833
+ # Empty blast radius is ambiguous: genuinely-unused code OR an unmodeled-edge
834
+ # blind spot. Two positively-detected blind spots reclassify it from a
835
+ # high-confidence "safe to change" into a low-confidence "look further".
755
836
  empty_blast = (
756
837
  not direct_callers and not indirect_callers
757
838
  and not endpoints_affected and not subtype_classes_added
758
839
  )
840
+ class_level_seed = "#" not in resolved_symbol and resolution != "not_found"
841
+
842
+ # CH-005: framework/external-interface DI blind spot. Checked first because
843
+ # its diagnosis (polymorphic invocation via an external supertype + framework
844
+ # wiring) is more specific than the value-type fallback for the same symbol.
845
+ external_supertypes: list[str] = []
846
+ if empty_blast and class_level_seed:
847
+ external_supertypes = _external_supertypes(cir, resolved_symbol)
848
+ framework_di_blind_spot = bool(external_supertypes)
849
+ if framework_di_blind_spot:
850
+ warnings.append(
851
+ "Framework/external-interface DI blind spot (CH-005): this class "
852
+ "implements/extends external type(s) [" + ", ".join(external_supertypes)
853
+ + "] and is likely invoked polymorphically through them and wired by "
854
+ "framework DI/config. The static call-graph has no in-repo edge naming "
855
+ "this class's methods, so 0 callers is NOT proof it is unused — search "
856
+ "DI/security/config wiring for the supertype to find the real callers."
857
+ )
858
+
859
+ # CH-003: empty blast radius on a positively-identified value/DTO type is a
860
+ # type-usage blind spot, not proof of dead code — warn + drop confidence.
759
861
  value_type_blind_spot = (
760
862
  empty_blast
761
- and "#" not in resolved_symbol
762
- and resolution != "not_found"
863
+ and class_level_seed
864
+ and not framework_di_blind_spot
763
865
  and _is_unmodeled_value_type(cir, resolved_symbol, model)
764
866
  )
765
867
  if value_type_blind_spot:
@@ -773,9 +875,9 @@ class ImpactOrchestrator:
773
875
  confidence: str
774
876
  if resolution == "not_found":
775
877
  confidence = "low"
776
- elif value_type_blind_spot:
878
+ elif framework_di_blind_spot or value_type_blind_spot:
777
879
  confidence = "low"
778
- elif resolution == "partial" or warnings:
880
+ elif resolution == "partial" or confidence_reducing:
779
881
  confidence = "medium"
780
882
  else:
781
883
  confidence = "high"
@@ -803,6 +905,11 @@ class ImpactOrchestrator:
803
905
  "risk_score": risk_score,
804
906
  "model_build_time_ms": model.build_time_ms,
805
907
  "query_time_ms": elapsed_ms,
908
+ "blind_spots": (
909
+ (["framework_di"] if framework_di_blind_spot else [])
910
+ + (["value_type"] if value_type_blind_spot else [])
911
+ ),
912
+ "external_supertypes": external_supertypes,
806
913
  },
807
914
  )
808
915
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sourcecode
3
- Version: 1.46.0
3
+ Version: 1.50.0
4
4
  Summary: Persistent structural context and ultra-fast repeated analysis for AI coding agents
5
5
  License-File: LICENSE
6
6
  Keywords: agents,ai,codebase,context,developer-tools,llm
@@ -40,7 +40,7 @@ Description-Content-Type: text/markdown
40
40
 
41
41
  **Persistent structural context and ultra-fast repeated analysis for AI coding agents.**
42
42
 
43
- ![Version](https://img.shields.io/badge/version-1.46.0-blue)
43
+ ![Version](https://img.shields.io/badge/version-1.50.0-blue)
44
44
  ![Python](https://img.shields.io/badge/python-3.9%2B-green)
45
45
 
46
46
  ---
@@ -368,6 +368,8 @@ sourcecode endpoints /path/to/repo --output endpoints.json
368
368
 
369
369
  Extracts all Spring MVC (`@GetMapping`, `@PostMapping`, `@RequestMapping`, etc.) and JAX-RS (`@GET`, `@POST`, `@Path`) endpoint methods. Returns HTTP method, path, controller class, and handler method.
370
370
 
371
+ **Functional / WebFlux routing (honest limitation).** Routes registered via the functional DSL — `route().GET("/path", handler)` / `RouterFunction` / `CustomEndpoint`, common in reactive Spring apps — are **not** modeled (their real paths depend on `nest()`/group-version prefixes that can't be resolved statically). Rather than emit partial paths that would mislead, the output reports a `functional_routing` block (`files`, `route_registrations`, `modeled: false`) plus a warning. When the annotation surface is empty but functional routes exist, the warning explicitly tells you not to read it as "no endpoints". Annotation-based (MVC/JAX-RS) repos are unaffected.
372
+
371
373
  **Custom security annotations.** Enterprise repos often guard endpoints with a bespoke annotation instead of `@PreAuthorize`/`@Secured`. Drop a `sourcecode.config.json` at the repo root to teach the scanner about it — otherwise those endpoints report `policy: "none_detected"`:
372
374
 
373
375
  ```json
@@ -435,6 +437,12 @@ Unlike `impact` (which traces the caller graph), `impact-chain` builds on the Sp
435
437
  | `security_surfaces` | Per-endpoint security policy + SEC finding IDs |
436
438
  | `impact_findings` | TX-001..005 and SEC-001..003 findings that touch the call chain |
437
439
  | `risk_level` | `critical` \| `high` \| `medium` \| `low` |
440
+ | `confidence` | `high` \| `medium` \| `low` — `low` on a detected blind spot, `medium` on partial resolution or capped traversal. Informational interface↔impl expansion notices do **not** lower it, so a clean resolved query stays `high`. |
441
+ | `metadata.blind_spots` | `framework_di` and/or `value_type` when an empty result is unmodeled-edge driven, not real dead code |
442
+
443
+ **Framework/DI blind spot (CH-005).** An empty blast radius is ambiguous: genuinely unused, or invoked through an edge the static graph does not model. When the target class implements/extends an **external** framework type (e.g. Spring Security's `RedirectStrategy`, a servlet `Filter`) it is typically wired by framework DI/config and invoked polymorphically — no in-repo edge names its methods, so `direct_callers` is `0`. Rather than report that as `risk:low` at high confidence (a dangerous false negative that reads as "safe to change"), `impact-chain` detects the external supertype, drops `confidence` to `low`, lists it in `metadata.external_supertypes`, and emits a `CH-005` warning telling you to search the DI/security/config wiring for the supertype. Inert markers (`Serializable`, `Cloneable`) are excluded.
444
+
445
+ **Caller precision (CH-006).** `implements`/`extends` are structural type declarations, not calls — so they are excluded from the caller graph. Querying a class that implements a high-fanout interface (e.g. a 40-implementor `CustomEndpoint` or a shared `Mapper<E,D>` base) does **not** report its sibling implementors as callers; only real `injects`/`calls` edges count. This prevents a leaf class from being inflated to a large false blast radius.
438
446
 
439
447
  **Event topology** — query the publisher/consumer graph for a Spring event class:
440
448
 
@@ -1,4 +1,4 @@
1
- sourcecode/__init__.py,sha256=wdCd8tksQK-HjW2hTdGl_yIjBeUdzZy-xU36D1PCWmo,103
1
+ sourcecode/__init__.py,sha256=pCkOXPgXyXxjAbBGF1i4NrzrWef2vm102RXTjjOE8go,103
2
2
  sourcecode/adaptive_scanner.py,sha256=XffluXKzJUXrMtjEiAOnSNPZnztdIcts17T9ouHeID0,10521
3
3
  sourcecode/architecture_analyzer.py,sha256=liCwQmLgb5vplohy8arjYxs_HOIv5C9MjLh_gY6bc5Q,44115
4
4
  sourcecode/architecture_summary.py,sha256=z34_6v7cSwy98cof2UVciGho7SCrZ93tiqMmq5WNzRQ,20405
@@ -44,7 +44,7 @@ sourcecode/redactor.py,sha256=SB4hwIvg8h-hvcqKcDWaZvA-aSyn-at-BIRwa0tUv5E,3227
44
44
  sourcecode/relevance_scorer.py,sha256=0AgEt4KrV73nioMqBgjhGjtY7L2C7L7cSyKtj3IKcrw,9408
45
45
  sourcecode/rename_refactor.py,sha256=h6dNFlB9aZ_3q6heeHBkgXQeXaT03nvPSsYH6P8qxFg,12965
46
46
  sourcecode/repo_classifier.py,sha256=FG1vaWKdWXsWdl-S8hjVMiTqcwgaRXkDyvK4rPcOGtQ,22681
47
- sourcecode/repository_ir.py,sha256=WjDYwbBm-eWp-k6aSdBrgO_XcRGuP-Llp0TZHBhq8bY,208237
47
+ sourcecode/repository_ir.py,sha256=eBC8Jh1rBH8xE46atHmdGNQxcjuROyUCr0iCuhqviUc,210340
48
48
  sourcecode/ris.py,sha256=RcqLVwC-doFcKKViYDkCjZLBqf_wzLES7-F6vHEeWzE,20419
49
49
  sourcecode/runtime_classifier.py,sha256=uTAD6BDCiBLUZEDRfqk718kM4RTT_vAbfkcOI2_Xx58,18432
50
50
  sourcecode/scanner.py,sha256=WdOQ78mMzjR1NjmKTlbxdgwinnCTfAhxCVLBEFQiFHU,8899
@@ -54,7 +54,7 @@ sourcecode/semantic_analyzer.py,sha256=4OdG6tTSnTvq3_dSWMbQu8Ad1ndSCKeG-b9qM4hIx
54
54
  sourcecode/serializer.py,sha256=TGzftrSKitZrtl6Hh-R05s4KdTOxwTmph_lGDbo2Wzg,125015
55
55
  sourcecode/spring_event_topology.py,sha256=5_ON_21Le5zbG-1GRc5GLIi5HJfy_QjcXLVPC5WeUGQ,18055
56
56
  sourcecode/spring_findings.py,sha256=G7Or2lKBUQbcTDqudLvSs9XvNg_YoAa-_lBOG_ULs8E,5457
57
- sourcecode/spring_impact.py,sha256=rUKSiCfXh9NpC9a97KvjCu6Kn8bYezTnMDY3F7sgtCI,38737
57
+ sourcecode/spring_impact.py,sha256=WUbBw6Ne9esN_KczIs9BCJdRAmjDKtU6E2_auo-771s,44865
58
58
  sourcecode/spring_model.py,sha256=zOAgFmrRbG4a6KLm1TJl55aWMyPNsz3OS3FSczqPG6A,16594
59
59
  sourcecode/spring_security_audit.py,sha256=XtPJ1SXlZJ8k6VYmaWuAp7Bbir4UmreAL7doIGQ5I7o,20595
60
60
  sourcecode/spring_semantic.py,sha256=O1nKSGVzlukuxLHQVuCPxc-XrcrMFxwlHA20_dmEGgM,13307
@@ -101,8 +101,8 @@ sourcecode/telemetry/consent.py,sha256=wLMvGNJeSSyZoNkQXpoUioY6mMv4Qdvuw7S9jAEWn
101
101
  sourcecode/telemetry/events.py,sha256=LtzYfaX9Ilckj5PTvAcTpDa9mLqDsYPDUiDkRa58piY,2580
102
102
  sourcecode/telemetry/filters.py,sha256=NHa5T-6DaZduQPFuC34jOqHWQgSizM-Ygq8aZ4j19ng,5834
103
103
  sourcecode/telemetry/transport.py,sha256=4gGHsq0WeY9VywEZXA3vUxykfiYnw9uuqfjAAec7F8o,1681
104
- sourcecode-1.46.0.dist-info/METADATA,sha256=EVvziqzOlPxygHshUqVQ3DYrYPRDKzQwLf0ewY9twKY,32359
105
- sourcecode-1.46.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
106
- sourcecode-1.46.0.dist-info/entry_points.txt,sha256=ex3F9rmbXeyDIoFQHtkEqTsKSaJow8F0LrVu8XfIktQ,57
107
- sourcecode-1.46.0.dist-info/licenses/LICENSE,sha256=7DdHrU9Z_3e7dSvq4ISijZNjnuHo5NIHNiHDouMQ9JU,10491
108
- sourcecode-1.46.0.dist-info/RECORD,,
104
+ sourcecode-1.50.0.dist-info/METADATA,sha256=AMKgfVLsoGpmtnK3Vk75eHizMToSqxiiPsoMzTA-res,34684
105
+ sourcecode-1.50.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
106
+ sourcecode-1.50.0.dist-info/entry_points.txt,sha256=ex3F9rmbXeyDIoFQHtkEqTsKSaJow8F0LrVu8XfIktQ,57
107
+ sourcecode-1.50.0.dist-info/licenses/LICENSE,sha256=7DdHrU9Z_3e7dSvq4ISijZNjnuHo5NIHNiHDouMQ9JU,10491
108
+ sourcecode-1.50.0.dist-info/RECORD,,