sourcecode 2.6.10__py3-none-any.whl → 3.0.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.
Files changed (40) hide show
  1. sourcecode/__init__.py +1 -1
  2. sourcecode/archetype.py +11 -0
  3. sourcecode/cache.py +44 -3
  4. sourcecode/caller_metrics.py +19 -0
  5. sourcecode/cli.py +629 -85
  6. sourcecode/context_cache.py +9 -0
  7. sourcecode/contract_pipeline.py +14 -3
  8. sourcecode/deployment_prefix.py +229 -0
  9. sourcecode/detectors/java.py +7 -1
  10. sourcecode/envelope.py +193 -0
  11. sourcecode/explain.py +32 -0
  12. sourcecode/format_contract.py +11 -5
  13. sourcecode/git_analyzer.py +74 -12
  14. sourcecode/hibernate_strat.py +11 -4
  15. sourcecode/migrate_check.py +13 -0
  16. sourcecode/posture.py +458 -0
  17. sourcecode/pr_impact.py +135 -16
  18. sourcecode/prepare_context.py +126 -35
  19. sourcecode/repository_ir.py +355 -14
  20. sourcecode/retrieval/steps_endpoint.py +32 -8
  21. sourcecode/retrieval/steps_graph.py +9 -1
  22. sourcecode/retrieval/steps_intf.py +32 -6
  23. sourcecode/retrieval/steps_txsec.py +114 -6
  24. sourcecode/schemas/envelope-v1.schema.json +74 -0
  25. sourcecode/security_posture.py +41 -8
  26. sourcecode/semantic_integration_engine.py +11 -0
  27. sourcecode/serializer.py +52 -6
  28. sourcecode/spring_findings.py +44 -0
  29. sourcecode/spring_impact.py +44 -10
  30. sourcecode/spring_profiles.py +218 -0
  31. sourcecode/spring_security_audit.py +5 -3
  32. sourcecode/validation_inference.py +58 -6
  33. sourcecode/validation_surface.py +91 -0
  34. sourcecode/verify_repo.py +252 -0
  35. sourcecode/verify_rules.py +135 -12
  36. {sourcecode-2.6.10.dist-info → sourcecode-3.0.0.dist-info}/METADATA +3 -1
  37. {sourcecode-2.6.10.dist-info → sourcecode-3.0.0.dist-info}/RECORD +40 -34
  38. {sourcecode-2.6.10.dist-info → sourcecode-3.0.0.dist-info}/WHEEL +0 -0
  39. {sourcecode-2.6.10.dist-info → sourcecode-3.0.0.dist-info}/entry_points.txt +0 -0
  40. {sourcecode-2.6.10.dist-info → sourcecode-3.0.0.dist-info}/licenses/LICENSE +0 -0
sourcecode/__init__.py CHANGED
@@ -4,4 +4,4 @@ ASK Engine is the product. ``ask`` is the canonical CLI command; ``sourcecode``
4
4
  the legacy compatibility alias and the Python/PyPI package name. See
5
5
  docs/PRODUCT_IDENTITY.md (normative)."""
6
6
 
7
- __version__ = "2.6.10"
7
+ __version__ = "3.0.0"
sourcecode/archetype.py CHANGED
@@ -604,12 +604,23 @@ class ArchetypeClassifier:
604
604
  # Gini alone labeling a REST API an "engine") — is a single point of view and
605
605
  # must not read as high confidence (field-eval Fase 0).
606
606
  distinct_signals = len({e.signal for e in top.evidence if e.contribution > 0})
607
+ # Diversity by COUNT is satisfiable while one signal carries the
608
+ # verdict: an audited repo was labelled "engine" at high confidence on
609
+ # 1.500 of a 1.504 score — a fan-in Gini alone, with the second signal
610
+ # contributing 0.3%. Counting it as two views is a fiction, so a label
611
+ # whose top signal supplies almost all of its score cannot be "high"
612
+ # however many other signals nominally touch it.
613
+ _contributions = sorted(
614
+ (e.contribution for e in top.evidence if e.contribution > 0), reverse=True
615
+ )
616
+ top_signal_share = (_contributions[0] / top.score) if _contributions else 1.0
607
617
  if (
608
618
  confident_enough
609
619
  and rel_margin >= 0.4
610
620
  and mass_backed
611
621
  and graph_backed
612
622
  and distinct_signals >= 2
623
+ and top_signal_share <= 0.8
613
624
  ):
614
625
  confidence = "high"
615
626
  elif confident_enough and rel_margin >= 0.25 and mass_backed:
sourcecode/cache.py CHANGED
@@ -75,11 +75,52 @@ SCHEMA_VERSION: str = "2"
75
75
  #: Bump to invalidate all L1 core caches (independent of snapshot version).
76
76
  CORE_SCHEMA_VERSION: str = "1"
77
77
 
78
- #: Bump when analysis logic or output schema changes — NOT on every package release.
79
- #: This is the stable part of the L1 core cache key. Package version bumps (patch,
80
- #: minor) must NOT bump this value unless the cached data format actually changed.
78
+ #: Manual override for invalidating all L1 core caches. Rarely needed now that the
79
+ #: key carries :func:`analyzer_fingerprint`; kept as an escape hatch for cases the
80
+ #: fingerprint cannot see (a changed dependency, a corrected cache format).
81
+ #: Package version bumps must NOT bump this value.
81
82
  ANALYZER_CACHE_VERSION: str = "1"
82
83
 
84
+
85
+ def analyzer_fingerprint() -> str:
86
+ """Content hash of the analysis code, memoised for the process.
87
+
88
+ A cache key built only from the repository state and a hand-maintained version
89
+ constant cannot notice that the analyzer itself changed. That discipline failed
90
+ exactly as designed-by-humans disciplines do: five consecutive fixes to analysis
91
+ logic shipped without anyone bumping ``ANALYZER_CACHE_VERSION``, so an upgraded
92
+ install kept serving pre-fix results from cache on an unchanged commit — the
93
+ fixes looked inert until the user cleared the cache by hand.
94
+
95
+ Hashing file *content* (not mtime) keeps the key stable across reinstalls and
96
+ identical checkouts on different machines, so caches stay shareable. Any edit to
97
+ any module invalidates every entry: over-invalidation costs a re-analysis,
98
+ under-invalidation reports facts the current code would not produce.
99
+
100
+ Falls back to the package version when the source is unreadable (zipimport,
101
+ frozen builds) — degraded, never wrong-by-silence.
102
+ """
103
+ global _ANALYZER_FINGERPRINT
104
+ if _ANALYZER_FINGERPRINT is not None:
105
+ return _ANALYZER_FINGERPRINT
106
+ digest = hashlib.sha256()
107
+ try:
108
+ pkg_root = Path(__file__).resolve().parent
109
+ sources = sorted(pkg_root.rglob("*.py"))
110
+ if not sources:
111
+ raise OSError("no analyzer sources found")
112
+ for src in sources:
113
+ digest.update(src.relative_to(pkg_root).as_posix().encode("utf-8"))
114
+ digest.update(src.read_bytes())
115
+ _ANALYZER_FINGERPRINT = digest.hexdigest()[:12]
116
+ except Exception:
117
+ from sourcecode import __version__ as _pkg_version
118
+ _ANALYZER_FINGERPRINT = f"pkg-{_pkg_version}"
119
+ return _ANALYZER_FINGERPRINT
120
+
121
+
122
+ _ANALYZER_FINGERPRINT: Optional[str] = None
123
+
83
124
  #: Fields eligible for CAS deduplication (applied to top-level JSON dict keys).
84
125
  _CAS_FIELDS: frozenset[str] = frozenset([
85
126
  "file_paths",
@@ -40,3 +40,22 @@ CALLER_METRIC_RECONCILIATION: str = (
40
40
  "references or DI-interface resolution). The top-level impact.direct_callers array "
41
41
  "may be truncated for output size — use stats.direct_caller_count for the true total."
42
42
  )
43
+
44
+
45
+ # Cycle / tangle metrics come from TWO different graphs. Both are correct; they
46
+ # answer different questions, and without saying so the pair reads as one command
47
+ # contradicting another (external audit 2026-07-25: modernize reported 15 cyclic
48
+ # tangles while retrieve subsystem-coupling reported import_cycles: 0).
49
+ CYCLE_METRIC_RECONCILIATION: str = (
50
+ "Cycle metrics differ across commands BY DESIGN. modernize.cross_module_tangles "
51
+ "is computed over the SYMBOL dependency graph, aggregated to subsystem packages: "
52
+ "coupling_type=cyclic means two subsystems reference each other (a 2-cycle "
53
+ "between package groups). The module-graph metrics (import_cycles, cyclic_density, "
54
+ "scc_mass — used by archetype and the subsystem-coupling retrieval intent) are "
55
+ "computed over the MODULE/DIRECTORY graph, are bounded for cost (node/edge caps), "
56
+ "and count strongly-connected components among modules. A repo can therefore "
57
+ "show mutual package-level coupling (tangles > 0) with no module-level SCC "
58
+ "(import_cycles = 0): the coupling exists between package groups inside the same "
59
+ "module. Neither number invalidates the other — read tangles for decomposition "
60
+ "risk and import_cycles for module-graph topology."
61
+ )