sourcecode 2.5.8__py3-none-any.whl → 2.5.11__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 +1 -1
- sourcecode/architecture_analyzer.py +70 -16
- sourcecode/cli.py +34 -2
- sourcecode/reconciliation.py +26 -9
- {sourcecode-2.5.8.dist-info → sourcecode-2.5.11.dist-info}/METADATA +1 -1
- {sourcecode-2.5.8.dist-info → sourcecode-2.5.11.dist-info}/RECORD +9 -9
- {sourcecode-2.5.8.dist-info → sourcecode-2.5.11.dist-info}/WHEEL +0 -0
- {sourcecode-2.5.8.dist-info → sourcecode-2.5.11.dist-info}/entry_points.txt +0 -0
- {sourcecode-2.5.8.dist-info → sourcecode-2.5.11.dist-info}/licenses/LICENSE +0 -0
sourcecode/__init__.py
CHANGED
|
@@ -5,9 +5,8 @@ from pathlib import Path
|
|
|
5
5
|
from typing import Literal, Optional
|
|
6
6
|
|
|
7
7
|
from sourcecode.reconciliation import (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
unattested_layers,
|
|
8
|
+
reconcile_architecture_evidence,
|
|
9
|
+
reconcile_code_modules,
|
|
11
10
|
)
|
|
12
11
|
|
|
13
12
|
from sourcecode.schema import (
|
|
@@ -280,6 +279,13 @@ class ArchitectureAnalyzer:
|
|
|
280
279
|
) -> ArchitectureAnalysis:
|
|
281
280
|
limitations: list[str] = []
|
|
282
281
|
evidence: list[dict] = []
|
|
282
|
+
# INV-F1-4: reconciliation rules that refute a layer/pattern must not
|
|
283
|
+
# apply their verdict silently — a pruned layer or a rejected pattern is
|
|
284
|
+
# a positively-detected contradiction the reader is entitled to see, or
|
|
285
|
+
# "no architecture" becomes indistinguishable from "we refuted the
|
|
286
|
+
# architecture claim". `_detect_layers` and its helpers append the
|
|
287
|
+
# findings' sink-neutral detail here; drained into `limitations` below.
|
|
288
|
+
self._refutations: list[str] = []
|
|
283
289
|
|
|
284
290
|
# Step 1: filter paths
|
|
285
291
|
filtered = self._filter_paths(sm.file_paths)
|
|
@@ -482,6 +488,17 @@ class ArchitectureAnalyzer:
|
|
|
482
488
|
"confidence": "low",
|
|
483
489
|
})
|
|
484
490
|
|
|
491
|
+
# INV-F1-4 sink: surface every refutation that shaped the returned
|
|
492
|
+
# result. Prefix frames it as a refutation; the detail (unchanged) states
|
|
493
|
+
# the contradiction, keeping it sink-neutral (INV-F1-5). Dedup: the
|
|
494
|
+
# layered→modular fallthrough can refute the same directory twice.
|
|
495
|
+
_seen: set[str] = set()
|
|
496
|
+
for _detail in self._refutations:
|
|
497
|
+
if _detail in _seen:
|
|
498
|
+
continue
|
|
499
|
+
_seen.add(_detail)
|
|
500
|
+
limitations.append(f"Architecture claim refuted on evidence: {_detail}")
|
|
501
|
+
|
|
485
502
|
return ArchitectureAnalysis(
|
|
486
503
|
requested=True,
|
|
487
504
|
pattern=pattern,
|
|
@@ -665,6 +682,13 @@ class ArchitectureAnalyzer:
|
|
|
665
682
|
best_priority = -1
|
|
666
683
|
best_matched: dict[str, list[str]] = {}
|
|
667
684
|
best_layer_files: dict[str, set[int]] = {}
|
|
685
|
+
# INV-F1-4: refutations that fired while assembling each candidate. Only
|
|
686
|
+
# those that shaped the RETURNED result are surfaced (below): the winning
|
|
687
|
+
# pattern's pruned layers, or — when no classical pattern qualifies — the
|
|
688
|
+
# contradictions that removed the contenders. A refutation of a candidate
|
|
689
|
+
# that lost on score anyway is not what the reader is being misled about.
|
|
690
|
+
cand_refutations: dict[str, list[str]] = {}
|
|
691
|
+
contradiction_details: list[str] = []
|
|
668
692
|
|
|
669
693
|
for pattern_name, layer_keys in LAYER_PATTERNS.items():
|
|
670
694
|
matched: dict[str, list[str]] = {}
|
|
@@ -692,16 +716,29 @@ class ArchitectureAnalyzer:
|
|
|
692
716
|
# template/asset-only layers are untouched, so a real Spring-MVC
|
|
693
717
|
# `templates/` view survives.
|
|
694
718
|
_layer_paths = {k: [source_paths[i] for i in v] for k, v in layer_files.items()}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
719
|
+
_refs: list[str] = []
|
|
720
|
+
_split_contradicted = False
|
|
721
|
+
for _f in reconcile_architecture_evidence(
|
|
722
|
+
pattern=pattern_name, layer_files=_layer_paths, repo_files=source_paths
|
|
723
|
+
):
|
|
724
|
+
_refs.append(_f.detail)
|
|
725
|
+
if _f.rule == "composition_runtime_split":
|
|
726
|
+
# A claim that IS a runtime split must show one: JobRunr, a JVM
|
|
727
|
+
# library, read "Fullstack with frontend, backend layers" off a
|
|
728
|
+
# `dashboard/ui/model/` package of 16 Java files. Nothing to
|
|
729
|
+
# prune — the pattern itself is what the evidence contradicts.
|
|
730
|
+
_split_contradicted = True
|
|
731
|
+
else:
|
|
732
|
+
# layer_language_coherence: drop the layers owned by a
|
|
733
|
+
# different runtime; template/asset-only layers are untouched,
|
|
734
|
+
# so a real Spring-MVC `templates/` view survives.
|
|
735
|
+
for _bad in _f.symbols:
|
|
736
|
+
matched.pop(_bad, None)
|
|
737
|
+
layer_files.pop(_bad, None)
|
|
738
|
+
if _split_contradicted:
|
|
739
|
+
contradiction_details.extend(_refs)
|
|
704
740
|
continue
|
|
741
|
+
cand_refutations[pattern_name] = _refs
|
|
705
742
|
|
|
706
743
|
# A pattern with unmet required keys cannot qualify (e.g. mvc needs a view).
|
|
707
744
|
required = _PATTERN_REQUIRED_KEYS.get(pattern_name)
|
|
@@ -717,6 +754,10 @@ class ArchitectureAnalyzer:
|
|
|
717
754
|
best_layer_files = layer_files
|
|
718
755
|
|
|
719
756
|
if best_score >= 2:
|
|
757
|
+
# The reported pattern is the one whose refutations misled the reader
|
|
758
|
+
# if left silent (keycloak's dropped `view` layer). Contradictions of
|
|
759
|
+
# OTHER, losing candidates did not shape this result — omit them.
|
|
760
|
+
self._refutations.extend(cand_refutations.get(best_pattern, []))
|
|
720
761
|
layer_confidence: Literal["high", "medium", "low"] = "medium" if best_score >= 3 else "low"
|
|
721
762
|
layers: list[ArchitectureLayer] = []
|
|
722
763
|
for layer_key, matched_dirs in best_matched.items():
|
|
@@ -729,6 +770,11 @@ class ArchitectureAnalyzer:
|
|
|
729
770
|
))
|
|
730
771
|
return best_pattern, layers
|
|
731
772
|
|
|
773
|
+
# No classical pattern qualified. If a contender was removed by a runtime
|
|
774
|
+
# split contradiction (jobrunr's "fullstack"), that is why — and the
|
|
775
|
+
# eventual fallthrough result would otherwise look like a silent absence.
|
|
776
|
+
self._refutations.extend(contradiction_details)
|
|
777
|
+
|
|
732
778
|
# 2. Spring domain-module detection (petclinic-style: deep common prefix + feature dirs)
|
|
733
779
|
spring_result = self._detect_spring_domain_modules(source_paths)
|
|
734
780
|
if spring_result is not None:
|
|
@@ -872,8 +918,13 @@ class ArchitectureAnalyzer:
|
|
|
872
918
|
# Architecture with orchestration, data layers" rested on ONE directory
|
|
873
919
|
# entry plus a settings.gradle, with 47 Java files visible and ignored.
|
|
874
920
|
# A logical code layer that holds no code of this repo is not one.
|
|
875
|
-
|
|
876
|
-
|
|
921
|
+
# INV-F1-4: this path only runs when no classical pattern won, so a
|
|
922
|
+
# pruning here directly shapes the returned result (fewer layers, or a
|
|
923
|
+
# drop below 2 that falls through to flat/unknown) — surface it.
|
|
924
|
+
for _f in reconcile_code_modules(layer_files=non_empty, repo_files=paths):
|
|
925
|
+
for _bad in _f.symbols:
|
|
926
|
+
non_empty.pop(_bad, None)
|
|
927
|
+
self._refutations.append(_f.detail)
|
|
877
928
|
if len(non_empty) >= 2:
|
|
878
929
|
return "layered", [
|
|
879
930
|
ArchitectureLayer(name=k, pattern="layered", files=v, confidence="low")
|
|
@@ -904,8 +955,11 @@ class ArchitectureAnalyzer:
|
|
|
904
955
|
# count alone let build and asset directories be reported as modules —
|
|
905
956
|
# ofbiz "docker, framework, runtime, gradle", neo4j "packaging",
|
|
906
957
|
# eureka "images" (five PNGs). The real modules survive untouched.
|
|
907
|
-
|
|
908
|
-
|
|
958
|
+
# INV-F1-4: same as the layered path — surface each refuted module.
|
|
959
|
+
for _f in reconcile_code_modules(layer_files=meaningful, repo_files=paths):
|
|
960
|
+
for _bad in _f.symbols:
|
|
961
|
+
meaningful.pop(_bad, None)
|
|
962
|
+
self._refutations.append(_f.detail)
|
|
909
963
|
if len(meaningful) >= 2:
|
|
910
964
|
return "modular", [
|
|
911
965
|
ArchitectureLayer(name=k, pattern="modular", files=v, confidence="low")
|
sourcecode/cli.py
CHANGED
|
@@ -7,7 +7,7 @@ import sys
|
|
|
7
7
|
import threading
|
|
8
8
|
import time
|
|
9
9
|
from pathlib import Path
|
|
10
|
-
from typing import Any, Optional, cast
|
|
10
|
+
from typing import Any, NoReturn, Optional, cast
|
|
11
11
|
|
|
12
12
|
import typer
|
|
13
13
|
|
|
@@ -293,6 +293,30 @@ _OPTIONS_WITH_VALUE: frozenset[str] = frozenset({
|
|
|
293
293
|
})
|
|
294
294
|
|
|
295
295
|
|
|
296
|
+
def _reject_path_before_subcommand(path_token: str, subcommand: str) -> "NoReturn":
|
|
297
|
+
"""Refuse `ask <path> <subcommand>` instead of silently scanning the CWD.
|
|
298
|
+
|
|
299
|
+
`_detected_path` is only read by the root analysis: a subcommand takes its own
|
|
300
|
+
`path` Argument, which defaults to the current directory. So the path token in
|
|
301
|
+
`ask spaghetti-api endpoints` was swallowed here and the subcommand ran against
|
|
302
|
+
the CWD — from a directory of checkouts that is every repository at once.
|
|
303
|
+
Measured: it answered with 1077 endpoints from keycloak, neo4j and eureka
|
|
304
|
+
instead of spaghetti-api's 7, exit code 0, no warning.
|
|
305
|
+
|
|
306
|
+
A wrong answer that looks right is the one failure this tool must not produce,
|
|
307
|
+
and the token order cannot be repaired by guessing: subcommands disagree about
|
|
308
|
+
where a path sits (`impact-chain <symbol> <path>`), so there is no slot to move
|
|
309
|
+
it to. Name the correct command and stop.
|
|
310
|
+
"""
|
|
311
|
+
print(
|
|
312
|
+
f"error: path '{path_token}' comes before the '{subcommand}' subcommand, "
|
|
313
|
+
f"so it would be ignored and the current directory scanned instead.\n"
|
|
314
|
+
f" use: ask {subcommand} {path_token}",
|
|
315
|
+
file=sys.stderr,
|
|
316
|
+
)
|
|
317
|
+
raise SystemExit(2)
|
|
318
|
+
|
|
319
|
+
|
|
296
320
|
def _preprocess_args(args: list[str]) -> list[str]:
|
|
297
321
|
"""Extract a repository path token from an args list and store it in _detected_path.
|
|
298
322
|
|
|
@@ -300,6 +324,8 @@ def _preprocess_args(args: list[str]) -> list[str]:
|
|
|
300
324
|
Correctly skips option values (e.g. ``yaml`` in ``--format yaml``).
|
|
301
325
|
If the first non-flag, non-value positional token is a known subcommand name,
|
|
302
326
|
args are returned unchanged so Click can dispatch the subcommand.
|
|
327
|
+
A path token followed by a subcommand is rejected — see
|
|
328
|
+
``_reject_path_before_subcommand``.
|
|
303
329
|
"""
|
|
304
330
|
result = list(args)
|
|
305
331
|
skip_next = False
|
|
@@ -315,11 +341,17 @@ def _preprocess_args(args: list[str]) -> list[str]:
|
|
|
315
341
|
skip_next = True
|
|
316
342
|
continue
|
|
317
343
|
if arg in _SUBCOMMANDS:
|
|
344
|
+
if _path_index >= 0:
|
|
345
|
+
# A path already claimed a slot, so this subcommand can only be
|
|
346
|
+
# the wrong-order form: the path would be dropped and the CWD
|
|
347
|
+
# scanned in its place.
|
|
348
|
+
_reject_path_before_subcommand(result[_path_index], arg)
|
|
318
349
|
return result # known subcommand — leave for Click to dispatch
|
|
350
|
+
if _path_index >= 0:
|
|
351
|
+
continue # a later positional is the subcommand's own business
|
|
319
352
|
# First genuine positional: treat as repository path
|
|
320
353
|
_set_detected_path(arg)
|
|
321
354
|
_path_index = i
|
|
322
|
-
break
|
|
323
355
|
if _path_index >= 0:
|
|
324
356
|
result.pop(_path_index)
|
|
325
357
|
return result
|
sourcecode/reconciliation.py
CHANGED
|
@@ -374,21 +374,38 @@ def _rule_composition_runtime_split(
|
|
|
374
374
|
]
|
|
375
375
|
|
|
376
376
|
|
|
377
|
+
def reconcile_code_modules(
|
|
378
|
+
*, layer_files: dict[str, list[str]], repo_files: "list[str]"
|
|
379
|
+
) -> list[ReconciliationFinding]:
|
|
380
|
+
"""Run the code-module attestation rule. Never raises.
|
|
381
|
+
|
|
382
|
+
Returns the findings (name AND detail), so a consumer can both prune the
|
|
383
|
+
refuted layers and SURFACE why — INV-F1-4: a rule that is applied silently
|
|
384
|
+
replaces one dishonesty with another.
|
|
385
|
+
|
|
386
|
+
Args:
|
|
387
|
+
layer_files: {claimed module -> its files}.
|
|
388
|
+
repo_files: every source file, supplying the repo's own runtime.
|
|
389
|
+
"""
|
|
390
|
+
try:
|
|
391
|
+
repo_runtimes = runtime_census({"_repo": list(repo_files)})["_repo"]
|
|
392
|
+
return _rule_layer_code_attestation(runtime_census(layer_files), repo_runtimes)
|
|
393
|
+
except Exception:
|
|
394
|
+
return []
|
|
395
|
+
|
|
396
|
+
|
|
377
397
|
def unattested_layers(
|
|
378
398
|
layer_files: dict[str, list[str]], repo_files: "list[str]"
|
|
379
399
|
) -> frozenset[str]:
|
|
380
400
|
"""Layers holding no code of the repo's runtime (convenience view).
|
|
381
401
|
|
|
382
|
-
|
|
402
|
+
Names only; consumers that must also surface the contradiction use
|
|
403
|
+
`reconcile_code_modules` instead. Never raises.
|
|
383
404
|
"""
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
out
|
|
387
|
-
|
|
388
|
-
out.update(f.symbols)
|
|
389
|
-
return frozenset(out)
|
|
390
|
-
except Exception:
|
|
391
|
-
return frozenset()
|
|
405
|
+
out: set[str] = set()
|
|
406
|
+
for f in reconcile_code_modules(layer_files=layer_files, repo_files=repo_files):
|
|
407
|
+
out.update(f.symbols)
|
|
408
|
+
return frozenset(out)
|
|
392
409
|
|
|
393
410
|
|
|
394
411
|
def reconcile_architecture_evidence(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
sourcecode/__init__.py,sha256=
|
|
1
|
+
sourcecode/__init__.py,sha256=dNBAjvpTNkiFYDXqXdJjx0saZlNREwHXUuF1drsfGuo,309
|
|
2
2
|
sourcecode/adaptive_scanner.py,sha256=XffluXKzJUXrMtjEiAOnSNPZnztdIcts17T9ouHeID0,10521
|
|
3
3
|
sourcecode/archetype.py,sha256=d7yoN6Tj4OBj-VgSMPEKg4WF9H8FypnZ5A6AkUh5oIE,34484
|
|
4
|
-
sourcecode/architecture_analyzer.py,sha256=
|
|
4
|
+
sourcecode/architecture_analyzer.py,sha256=Bv6OYeAdK88PvHZuryO6CkR6NLJMUqvLy9WkGsw1Fa4,59072
|
|
5
5
|
sourcecode/architecture_summary.py,sha256=oBkjx7hZxmpdKLt4EracjRKHJFOGuPTd6SadTyPxY7Q,29568
|
|
6
6
|
sourcecode/ast_extractor.py,sha256=FEsYTsMCXbJfSYQZRk1k-I-PjUNGnKqO1IxMftsgA5U,51351
|
|
7
7
|
sourcecode/cache.py,sha256=1V3vsaODAa2UBJAC0xpvxpmRdriCezQx5Q8JCcfgziE,31892
|
|
@@ -10,7 +10,7 @@ sourcecode/caller_metrics.py,sha256=HG8RCOkpzzsEGdnMRob6byrwjoj5__t0TEsBj4yR7ks,
|
|
|
10
10
|
sourcecode/canonical_ir.py,sha256=5hLAhhSpXNOdZAvPt-J-rXccJE6M3A6gVhmhU0Tym6Y,29269
|
|
11
11
|
sourcecode/cir_graphs.py,sha256=9G0HHj1kw2325IDyzo2OpX73BNswEckecf4MZUXB4JM,12078
|
|
12
12
|
sourcecode/classifier.py,sha256=9olDN5joeKHcwG9vf73X-t_son16hLVNib0rBbqk1vc,18865
|
|
13
|
-
sourcecode/cli.py,sha256=
|
|
13
|
+
sourcecode/cli.py,sha256=mlMgyRukRoHXYdAYHBN4z06LszwdRo0QLdhs0KYtup8,323804
|
|
14
14
|
sourcecode/code_notes_analyzer.py,sha256=EJemNCNc9Dn-1RZYu-aNbK0ELzmsyC4s6FdHi3XyNEI,9392
|
|
15
15
|
sourcecode/confidence_analyzer.py,sha256=KCRg8B4WH15LpOB7oYhE4dD5nou9Xi48RT3vpaO6Ar4,20868
|
|
16
16
|
sourcecode/context_cache.py,sha256=maws79rLKDwyZ7c9Q2LwlIxqZHRFlaKzErtO3mglWoA,25036
|
|
@@ -51,7 +51,7 @@ sourcecode/pr_impact.py,sha256=dCDVw83EDbyVf6F9ZmEQmsFz8ruVH7d4mpeKQCIZHM0,16805
|
|
|
51
51
|
sourcecode/prepare_context.py,sha256=PYygAKL_jwz8gGElgM9mroUSih18UKSSjv08ndfl4aA,222877
|
|
52
52
|
sourcecode/progress.py,sha256=qn30sWaHOkjTgXsSBmiPkz7Rsbwc5oSlIe6JNEMYp_k,3149
|
|
53
53
|
sourcecode/ranking_engine.py,sha256=ZAucq_YX2KkWUuAZf4P0lhtQ_38vEFnUhuGtSZd1S0E,12970
|
|
54
|
-
sourcecode/reconciliation.py,sha256=
|
|
54
|
+
sourcecode/reconciliation.py,sha256=NSGWsRQ-5l50aO_6YErDlu1kEbQB8zDtVf58h_Ro15c,26984
|
|
55
55
|
sourcecode/redactor.py,sha256=SB4hwIvg8h-hvcqKcDWaZvA-aSyn-at-BIRwa0tUv5E,3227
|
|
56
56
|
sourcecode/relevance_scorer.py,sha256=0AgEt4KrV73nioMqBgjhGjtY7L2C7L7cSyKtj3IKcrw,9408
|
|
57
57
|
sourcecode/rename_refactor.py,sha256=h6dNFlB9aZ_3q6heeHBkgXQeXaT03nvPSsYH6P8qxFg,12965
|
|
@@ -137,8 +137,8 @@ sourcecode/telemetry/consent.py,sha256=LIAO9ohJZF8OuZwM4u1VWtALlYfTCCKq4wV3Vwc7i
|
|
|
137
137
|
sourcecode/telemetry/events.py,sha256=LtzYfaX9Ilckj5PTvAcTpDa9mLqDsYPDUiDkRa58piY,2580
|
|
138
138
|
sourcecode/telemetry/filters.py,sha256=NHa5T-6DaZduQPFuC34jOqHWQgSizM-Ygq8aZ4j19ng,5834
|
|
139
139
|
sourcecode/telemetry/transport.py,sha256=4gGHsq0WeY9VywEZXA3vUxykfiYnw9uuqfjAAec7F8o,1681
|
|
140
|
-
sourcecode-2.5.
|
|
141
|
-
sourcecode-2.5.
|
|
142
|
-
sourcecode-2.5.
|
|
143
|
-
sourcecode-2.5.
|
|
144
|
-
sourcecode-2.5.
|
|
140
|
+
sourcecode-2.5.11.dist-info/METADATA,sha256=6j_zA5-pJ01V4qnmyhPDb3FtyvH5bqAccNhHVP6tO5s,10852
|
|
141
|
+
sourcecode-2.5.11.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
142
|
+
sourcecode-2.5.11.dist-info/entry_points.txt,sha256=-JEAdChrK5We51kZcb7OaDcyil-dHBjBPL-NhuO-QY8,89
|
|
143
|
+
sourcecode-2.5.11.dist-info/licenses/LICENSE,sha256=7DdHrU9Z_3e7dSvq4ISijZNjnuHo5NIHNiHDouMQ9JU,10491
|
|
144
|
+
sourcecode-2.5.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|