graphite-code 1.5.0__py3-none-any.whl → 1.7.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.
- graphite/__init__.py +1 -1
- graphite/cli.py +16 -2
- graphite/daemon.py +112 -6
- graphite/daemon_health.py +83 -2
- graphite/doctor.py +9 -0
- graphite/git.py +12 -0
- graphite/ingest.py +49 -7
- {graphite_code-1.5.0.dist-info → graphite_code-1.7.0.dist-info}/METADATA +3 -2
- {graphite_code-1.5.0.dist-info → graphite_code-1.7.0.dist-info}/RECORD +12 -12
- {graphite_code-1.5.0.dist-info → graphite_code-1.7.0.dist-info}/WHEEL +0 -0
- {graphite_code-1.5.0.dist-info → graphite_code-1.7.0.dist-info}/entry_points.txt +0 -0
- {graphite_code-1.5.0.dist-info → graphite_code-1.7.0.dist-info}/licenses/LICENSE +0 -0
graphite/__init__.py
CHANGED
|
@@ -38,4 +38,4 @@ __all__ = ["__version__"]
|
|
|
38
38
|
#: Coarse and hand-maintained by construction. It is a release label, not
|
|
39
39
|
#: evidence that a given fix is present -- to answer that, survey for the marker
|
|
40
40
|
#: the fix introduced, or compare `graphite --version` fingerprints.
|
|
41
|
-
__version__ = "1.
|
|
41
|
+
__version__ = "1.7.0"
|
graphite/cli.py
CHANGED
|
@@ -783,6 +783,7 @@ def cmd_check(args: argparse.Namespace) -> int:
|
|
|
783
783
|
if not args.json:
|
|
784
784
|
raise ValueError(_below_a_root(root, top))
|
|
785
785
|
status: dict[str, Any] = {
|
|
786
|
+
"schema_version": 1,
|
|
786
787
|
"stale": True,
|
|
787
788
|
"reason": "below_repository_root",
|
|
788
789
|
"repository_root": top.as_posix() if trusted_root(top) else None,
|
|
@@ -799,6 +800,7 @@ def cmd_check(args: argparse.Namespace) -> int:
|
|
|
799
800
|
cfg = _project_scoped_config(args, root, canonical=True)
|
|
800
801
|
status = check_graph_freshness(root, cfg, ignore_engine=args.ignore_engine)
|
|
801
802
|
if args.json:
|
|
803
|
+
status["schema_version"] = 1
|
|
802
804
|
status["resolution_health"] = persisted_resolution(
|
|
803
805
|
root,
|
|
804
806
|
on_error=lambda exc: record_incident(
|
|
@@ -1288,7 +1290,7 @@ def cmd_validate(args: argparse.Namespace) -> int:
|
|
|
1288
1290
|
return 1
|
|
1289
1291
|
report = validate_graph_bundle(bundle)
|
|
1290
1292
|
if args.json:
|
|
1291
|
-
print(json.dumps(report, ensure_ascii=False, indent=2))
|
|
1293
|
+
print(json.dumps({"schema_version": 1, **report}, ensure_ascii=False, indent=2))
|
|
1292
1294
|
else:
|
|
1293
1295
|
if report["ok"]:
|
|
1294
1296
|
print(
|
|
@@ -2021,6 +2023,18 @@ def cmd_daemon_status(args: argparse.Namespace) -> int:
|
|
|
2021
2023
|
more_hint=" — use --json for the full list",
|
|
2022
2024
|
):
|
|
2023
2025
|
print(line)
|
|
2026
|
+
# A project the daemon could not snapshot is not in `projects` -- it
|
|
2027
|
+
# never entered the supervised set -- but it is a project the daemon
|
|
2028
|
+
# is failing to maintain, so it is named here too (#113).
|
|
2029
|
+
failures = status.get("snapshot_failures", [])
|
|
2030
|
+
for line in listing_lines(
|
|
2031
|
+
failures if isinstance(failures, list) else [],
|
|
2032
|
+
lambda f: f"{f.get('root')} | snapshot failed: {f.get('error')}",
|
|
2033
|
+
cap=_DAEMON_STATUS_PROJECT_CAP,
|
|
2034
|
+
empty=None,
|
|
2035
|
+
more_hint=" — use --json for the full list",
|
|
2036
|
+
):
|
|
2037
|
+
print(line)
|
|
2024
2038
|
return 0
|
|
2025
2039
|
|
|
2026
2040
|
|
|
@@ -2036,7 +2050,7 @@ def cmd_daemon_health(args: argparse.Namespace) -> int:
|
|
|
2036
2050
|
)
|
|
2037
2051
|
report = evaluate_daemon_health(base, state_dir=state_dir, options=options)
|
|
2038
2052
|
if args.json:
|
|
2039
|
-
print(json.dumps(report, ensure_ascii=False, indent=2))
|
|
2053
|
+
print(json.dumps({"schema_version": 1, **report}, ensure_ascii=False, indent=2))
|
|
2040
2054
|
else:
|
|
2041
2055
|
print(format_health_text(report), end="")
|
|
2042
2056
|
return 1 if args.fail_on_error and not report["ok"] else 0
|
graphite/daemon.py
CHANGED
|
@@ -164,6 +164,74 @@ class BuildResult:
|
|
|
164
164
|
return self.returncode == buildlock.REFUSED_EXIT_STATUS
|
|
165
165
|
|
|
166
166
|
|
|
167
|
+
_MAX_CAUSE_DEPTH = 5
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _exception_identity(exc: BaseException) -> str:
|
|
171
|
+
"""One exception's path-free identity.
|
|
172
|
+
|
|
173
|
+
A `GitError` carries its own: `diagnostic()` names the class, the step
|
|
174
|
+
that failed and the errno, and is built from fixed tokens and an integer
|
|
175
|
+
so no path and no Git text can ride along. Every other exception
|
|
176
|
+
contributes its class name and nothing else -- the message may name a
|
|
177
|
+
path, and the class is what separates the causes.
|
|
178
|
+
|
|
179
|
+
An exception that is not a `GitError` may still know its own identity:
|
|
180
|
+
anything offering `diagnostic()` is asked for it, on the same contract
|
|
181
|
+
-- fixed tokens, no path, no message text. `IngestEnumerationError` is
|
|
182
|
+
the second class that offers one, and it is what separates the ways
|
|
183
|
+
enumerating a repository can fail. Asking rather than isinstance-ing
|
|
184
|
+
keeps the daemon from having to know where the exception came from.
|
|
185
|
+
"""
|
|
186
|
+
diagnostic = getattr(exc, "diagnostic", None)
|
|
187
|
+
if callable(diagnostic):
|
|
188
|
+
return str(diagnostic())
|
|
189
|
+
return type(exc).__name__
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def describe_exception_chain(exc: BaseException) -> str:
|
|
193
|
+
"""An exception and whatever caused it, in one path-free line.
|
|
194
|
+
|
|
195
|
+
`str(exc)` says WHAT failed and not WHY, and for the daemon's snapshot
|
|
196
|
+
path that difference is the whole diagnosis: seven distinct sites raise
|
|
197
|
+
`GitLaunchError` inside `_run_bounded` alone, and only its step token
|
|
198
|
+
and errno separate them. On 2026-10-27 the daemon failed every snapshot
|
|
199
|
+
of an activated repository for thirteen minutes and the log could not
|
|
200
|
+
say why -- the cause was in the exception's chain, and the chain was
|
|
201
|
+
discarded.
|
|
202
|
+
"""
|
|
203
|
+
parts: list[str] = []
|
|
204
|
+
seen: set[int] = set()
|
|
205
|
+
current: BaseException | None = exc
|
|
206
|
+
while current is not None and len(parts) < _MAX_CAUSE_DEPTH and id(current) not in seen:
|
|
207
|
+
seen.add(id(current))
|
|
208
|
+
parts.append(_exception_identity(current))
|
|
209
|
+
current = current.__cause__
|
|
210
|
+
return " <- ".join(parts)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
@dataclass(frozen=True)
|
|
214
|
+
class SnapshotFailure:
|
|
215
|
+
"""An activated project the daemon could not snapshot (#113).
|
|
216
|
+
|
|
217
|
+
Kept out of the supervised set on purpose. A project with no snapshot has
|
|
218
|
+
no change set to diff and nothing to build, so putting it there would
|
|
219
|
+
make the build path act on an empty one. It is reported instead: a
|
|
220
|
+
failure that is only in the log is a failure nobody sees.
|
|
221
|
+
"""
|
|
222
|
+
|
|
223
|
+
root: Path
|
|
224
|
+
error: str
|
|
225
|
+
failed_at: str = field(default_factory=utc_now)
|
|
226
|
+
|
|
227
|
+
def to_status(self) -> dict[str, object]:
|
|
228
|
+
return {
|
|
229
|
+
"root": str(self.root),
|
|
230
|
+
"error": self.error,
|
|
231
|
+
"failed_at": self.failed_at,
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
167
235
|
@dataclass
|
|
168
236
|
class ProjectRuntime:
|
|
169
237
|
root: Path
|
|
@@ -527,23 +595,30 @@ def _write_status(
|
|
|
527
595
|
options: DaemonOptions,
|
|
528
596
|
cycle: int,
|
|
529
597
|
provider_lifecycle: dict[str, object] | None = None,
|
|
598
|
+
snapshot_failures: dict[Path, SnapshotFailure] | None = None,
|
|
530
599
|
) -> dict[str, object]:
|
|
600
|
+
failures = list((snapshot_failures or {}).values())
|
|
531
601
|
projects = [state.to_status() for _, state in sorted(states.items(), key=lambda item: str(item[0]).lower())]
|
|
532
602
|
healthy = sum(1 for state in states.values() if state.last_error is None and not state.needs_initial_build)
|
|
533
|
-
|
|
603
|
+
# A project whose snapshot failed is a project the daemon is failing to
|
|
604
|
+
# maintain, so it counts as failing -- it was activated, and no graph is
|
|
605
|
+
# being kept for it (#113).
|
|
606
|
+
failing = sum(1 for state in states.values() if state.last_error is not None) + len(failures)
|
|
534
607
|
pending = sum(1 for state in states.values() if state.needs_initial_build)
|
|
535
608
|
payload: dict[str, object] = {
|
|
536
609
|
"status": "ok" if failing == 0 else "degraded",
|
|
537
610
|
"updated_at": utc_now(),
|
|
538
611
|
"base_path": str(base),
|
|
539
612
|
"cycle": cycle,
|
|
540
|
-
"project_count": len(projects),
|
|
613
|
+
"project_count": len(projects) + len(failures),
|
|
541
614
|
"healthy_projects": healthy,
|
|
542
615
|
"failing_projects": failing,
|
|
543
616
|
"pending_projects": pending,
|
|
544
617
|
# Repositories currently open in a coding agent -- the whole supervised
|
|
545
|
-
# set. An unopened repo is absent by construction, not by pruning.
|
|
546
|
-
|
|
618
|
+
# set. An unopened repo is absent by construction, not by pruning. A
|
|
619
|
+
# repo the daemon cannot snapshot is open but unsupervised, so it
|
|
620
|
+
# belongs here too (#113).
|
|
621
|
+
"active_projects": sorted(str(root) for root in set(states) | set(snapshot_failures or {})),
|
|
547
622
|
"limits": {
|
|
548
623
|
"scan_interval_seconds": options.scan_interval_seconds,
|
|
549
624
|
"discover_interval_seconds": options.discover_interval_seconds,
|
|
@@ -555,6 +630,10 @@ def _write_status(
|
|
|
555
630
|
"build_timeout_seconds": options.build_timeout_seconds,
|
|
556
631
|
},
|
|
557
632
|
"projects": projects,
|
|
633
|
+
"snapshot_failures": [
|
|
634
|
+
failure.to_status()
|
|
635
|
+
for failure in sorted(failures, key=lambda item: str(item.root).lower())
|
|
636
|
+
],
|
|
558
637
|
}
|
|
559
638
|
if provider_lifecycle is not None:
|
|
560
639
|
payload["provider_lifecycle"] = provider_lifecycle
|
|
@@ -627,6 +706,11 @@ def run_daemon(
|
|
|
627
706
|
provider_worker.start()
|
|
628
707
|
|
|
629
708
|
states: dict[Path, ProjectRuntime] = {}
|
|
709
|
+
# Projects that are activated but whose snapshot failed. They are NOT in
|
|
710
|
+
# `states` -- there is no snapshot to diff or build -- but they are
|
|
711
|
+
# reported, because a failure that only reaches the log is a failure
|
|
712
|
+
# nobody acts on (#113).
|
|
713
|
+
snapshot_failures: dict[Path, SnapshotFailure] = {}
|
|
630
714
|
last_discovery = 0.0
|
|
631
715
|
last_status: dict[str, object] = {}
|
|
632
716
|
cycle = 0
|
|
@@ -649,8 +733,21 @@ def run_daemon(
|
|
|
649
733
|
project_cfg = daemon_config_for_project(cfg, project, options)
|
|
650
734
|
snap = snapshot(project, project_cfg)
|
|
651
735
|
except Exception as exc:
|
|
652
|
-
|
|
736
|
+
# The error is kept, not just logged: the report has to
|
|
737
|
+
# be able to say WHY the graph is not being maintained
|
|
738
|
+
# (#113).
|
|
739
|
+
snapshot_failures[project] = SnapshotFailure(
|
|
740
|
+
root=project,
|
|
741
|
+
error=str(exc).strip() or type(exc).__name__,
|
|
742
|
+
)
|
|
743
|
+
logger.event(
|
|
744
|
+
"project_snapshot_failed",
|
|
745
|
+
project=str(project),
|
|
746
|
+
error=str(exc),
|
|
747
|
+
cause=describe_exception_chain(exc),
|
|
748
|
+
)
|
|
653
749
|
continue
|
|
750
|
+
snapshot_failures.pop(project, None)
|
|
654
751
|
states[project] = ProjectRuntime(
|
|
655
752
|
root=project,
|
|
656
753
|
snapshot=snap,
|
|
@@ -663,6 +760,9 @@ def run_daemon(
|
|
|
663
760
|
if project not in discovered:
|
|
664
761
|
logger.event("project_deactivated", project=str(project))
|
|
665
762
|
del states[project]
|
|
763
|
+
for project in list(snapshot_failures):
|
|
764
|
+
if project not in discovered:
|
|
765
|
+
del snapshot_failures[project]
|
|
666
766
|
|
|
667
767
|
# An engine upgrade invalidates every supervised graph at once, but
|
|
668
768
|
# the file-diff path cannot see it: a repo whose files are untouched
|
|
@@ -718,7 +818,12 @@ def run_daemon(
|
|
|
718
818
|
except Exception as exc:
|
|
719
819
|
state.last_error = str(exc)
|
|
720
820
|
state.failure_count += 1
|
|
721
|
-
logger.event(
|
|
821
|
+
logger.event(
|
|
822
|
+
"project_scan_failed",
|
|
823
|
+
project=str(project),
|
|
824
|
+
error=str(exc),
|
|
825
|
+
cause=describe_exception_chain(exc),
|
|
826
|
+
)
|
|
722
827
|
# Failures before a build is attempted (git enumeration,
|
|
723
828
|
# snapshotting, watcher errors) never reached the incident
|
|
724
829
|
# writer, so they were durable only in status.json, which ages
|
|
@@ -774,6 +879,7 @@ def run_daemon(
|
|
|
774
879
|
options,
|
|
775
880
|
cycle,
|
|
776
881
|
None if provider_worker is None else provider_worker.snapshot(),
|
|
882
|
+
snapshot_failures,
|
|
777
883
|
)
|
|
778
884
|
if options.once:
|
|
779
885
|
if provider_worker is not None:
|
graphite/daemon_health.py
CHANGED
|
@@ -205,6 +205,17 @@ def evaluate_daemon_health(
|
|
|
205
205
|
opts.max_project_success_age_seconds,
|
|
206
206
|
)
|
|
207
207
|
for project in project_health["failing"]:
|
|
208
|
+
if project.get("failure_source") == "snapshot":
|
|
209
|
+
# The reason travels with the report: "how many" is not an answer
|
|
210
|
+
# an operator can act on (#113).
|
|
211
|
+
_append_bounded(errors, {
|
|
212
|
+
"code": "project_snapshot_failed",
|
|
213
|
+
"message": (
|
|
214
|
+
f"project snapshot failed: {project['root']}: {project.get('last_error') or ''}"
|
|
215
|
+
).rstrip(": "),
|
|
216
|
+
"project": project,
|
|
217
|
+
})
|
|
218
|
+
continue
|
|
208
219
|
_append_bounded(errors, {
|
|
209
220
|
"code": "project_failing",
|
|
210
221
|
"message": f"project build failing: {project['root']}",
|
|
@@ -436,12 +447,32 @@ def _project_health(
|
|
|
436
447
|
pending: list[dict[str, Any]] = []
|
|
437
448
|
old: list[dict[str, Any]] = []
|
|
438
449
|
counts = {"failing": 0, "pending": 0, "not_built_recently": 0}
|
|
450
|
+
# Snapshot failures come first: they are the ones the report exists to
|
|
451
|
+
# name, and the category list is capped. The entry carries the same
|
|
452
|
+
# fields a build failure carries -- a consumer reading `build_count` off
|
|
453
|
+
# a failing project must not find the key missing -- with the values
|
|
454
|
+
# that are true of a project that was never built.
|
|
455
|
+
for failure in status.get("snapshot_failures", []):
|
|
456
|
+
counts["failing"] += 1
|
|
457
|
+
if len(failing) < _MAX_CATEGORY_DETAILS:
|
|
458
|
+
failing.append({
|
|
459
|
+
"root": failure.get("root"),
|
|
460
|
+
"file_count": None,
|
|
461
|
+
"build_count": 0,
|
|
462
|
+
"failure_count": 0,
|
|
463
|
+
"last_error": failure.get("error"),
|
|
464
|
+
"last_success_at": None,
|
|
465
|
+
"last_success_age_seconds": None,
|
|
466
|
+
"needs_initial_build": True,
|
|
467
|
+
"failure_source": "snapshot",
|
|
468
|
+
"failed_at": failure.get("failed_at"),
|
|
469
|
+
})
|
|
439
470
|
for item in status.get("projects", []):
|
|
440
471
|
project = _project_summary(item, now)
|
|
441
472
|
if item.get("last_error") is not None:
|
|
442
473
|
counts["failing"] += 1
|
|
443
474
|
if len(failing) < _MAX_CATEGORY_DETAILS:
|
|
444
|
-
failing.append(project)
|
|
475
|
+
failing.append({**project, "failure_source": "build"})
|
|
445
476
|
if item.get("needs_initial_build") or int(item.get("build_count") or 0) == 0:
|
|
446
477
|
counts["pending"] += 1
|
|
447
478
|
if len(pending) < _MAX_CATEGORY_DETAILS:
|
|
@@ -531,6 +562,30 @@ def _invalid_project_field(item: Mapping[str, Any]) -> str | None:
|
|
|
531
562
|
return None
|
|
532
563
|
|
|
533
564
|
|
|
565
|
+
def _invalid_snapshot_failure_field(item: Mapping[str, Any]) -> str | None:
|
|
566
|
+
"""The fields a snapshot-failure record must carry, and their bounds.
|
|
567
|
+
|
|
568
|
+
`error` may be empty: the daemon always writes a reason, but a record
|
|
569
|
+
whose reason is missing is still a FAILURE, and dropping it would make it
|
|
570
|
+
invisible again -- the defect this report exists to close (#113). A record
|
|
571
|
+
with no reason is counted and named; only the reason is absent.
|
|
572
|
+
"""
|
|
573
|
+
root = item.get("root")
|
|
574
|
+
if (
|
|
575
|
+
not isinstance(root, str)
|
|
576
|
+
or not _bounded_clean_string(root, _MAX_ROOT_LENGTH, nullable=False)
|
|
577
|
+
or not root.strip()
|
|
578
|
+
):
|
|
579
|
+
return "root"
|
|
580
|
+
error = item.get("error")
|
|
581
|
+
if not isinstance(error, str) or not _bounded_clean_string(error, _MAX_LAST_ERROR_LENGTH, nullable=False):
|
|
582
|
+
return "error"
|
|
583
|
+
failed_at = item.get("failed_at")
|
|
584
|
+
if not isinstance(failed_at, str) or not _bounded_clean_string(failed_at, _MAX_TIMESTAMP_LENGTH, nullable=False):
|
|
585
|
+
return "failed_at"
|
|
586
|
+
return None
|
|
587
|
+
|
|
588
|
+
|
|
534
589
|
def _normalize_status(
|
|
535
590
|
raw_status: object,
|
|
536
591
|
) -> tuple[dict[str, Any], list[dict[str, Any]], dict[str, int]]:
|
|
@@ -605,11 +660,37 @@ def _normalize_status(
|
|
|
605
660
|
"truncated_count": truncated_count,
|
|
606
661
|
})
|
|
607
662
|
|
|
663
|
+
# A project the daemon could not snapshot (#113). Normalized explicitly,
|
|
664
|
+
# like every other key here: a key health is allowed to classify on and
|
|
665
|
+
# does not name explicitly is silently dropped, which is how the failure
|
|
666
|
+
# went unreported in the first place.
|
|
667
|
+
raw_failures = raw_status.get("snapshot_failures")
|
|
668
|
+
valid_failures: list[dict[str, Any]] = []
|
|
669
|
+
if raw_failures is not None and not isinstance(raw_failures, list):
|
|
670
|
+
issues.append(_schema_issue("snapshot_failures"))
|
|
671
|
+
elif isinstance(raw_failures, list):
|
|
672
|
+
for index, item in enumerate(raw_failures[:_MAX_INPUT_PROJECTS]):
|
|
673
|
+
if not isinstance(item, Mapping):
|
|
674
|
+
if len(issues) < _MAX_SCHEMA_ISSUES:
|
|
675
|
+
issues.append(_schema_issue("snapshot_failure", index))
|
|
676
|
+
continue
|
|
677
|
+
invalid_field = _invalid_snapshot_failure_field(item)
|
|
678
|
+
if invalid_field is not None:
|
|
679
|
+
if len(issues) < _MAX_SCHEMA_ISSUES:
|
|
680
|
+
issues.append(_schema_issue(invalid_field, index))
|
|
681
|
+
continue
|
|
682
|
+
valid_failures.append({
|
|
683
|
+
"root": item["root"],
|
|
684
|
+
"error": item["error"],
|
|
685
|
+
"failed_at": item["failed_at"],
|
|
686
|
+
})
|
|
687
|
+
status["snapshot_failures"] = valid_failures
|
|
688
|
+
|
|
608
689
|
raw_project_count = raw_status.get("project_count")
|
|
609
690
|
if not _nonnegative_int(raw_project_count):
|
|
610
691
|
if len(issues) < _MAX_SCHEMA_ISSUES:
|
|
611
692
|
issues.append(_schema_issue("project_count"))
|
|
612
|
-
status["project_count"] = len(valid_projects)
|
|
693
|
+
status["project_count"] = len(valid_projects) + len(valid_failures)
|
|
613
694
|
|
|
614
695
|
raw_daemon_status = raw_status.get("status")
|
|
615
696
|
if raw_daemon_status is not None and (
|
graphite/doctor.py
CHANGED
|
@@ -37,6 +37,7 @@ _FILE_LIMIT = 10_000
|
|
|
37
37
|
_PROCESS_CLEANUP_SECONDS = 0.2
|
|
38
38
|
_DAEMON_ISSUES_EXCLUDED_FROM_GLOBAL = {
|
|
39
39
|
"project_failing",
|
|
40
|
+
"project_snapshot_failed",
|
|
40
41
|
"project_pending_initial_build",
|
|
41
42
|
"project_not_built_recently",
|
|
42
43
|
"project_nested_repo_unsupervised",
|
|
@@ -431,9 +432,17 @@ def check_daemon(root: Path, daemon_base: Path) -> DoctorCheck:
|
|
|
431
432
|
raw_projects = raw_status.get("projects", []) if isinstance(raw_status, MappingABC) else []
|
|
432
433
|
if not isinstance(raw_projects, list):
|
|
433
434
|
raw_projects = []
|
|
435
|
+
# A project the daemon could not snapshot is registered -- it is
|
|
436
|
+
# activated -- even though it never entered the supervised set (#113).
|
|
437
|
+
raw_failures = raw_status.get("snapshot_failures", []) if isinstance(raw_status, MappingABC) else []
|
|
438
|
+
if not isinstance(raw_failures, list):
|
|
439
|
+
raw_failures = []
|
|
434
440
|
registered = any(
|
|
435
441
|
isinstance(item, MappingABC) and _normalized_root(item.get("root")) == selected
|
|
436
442
|
for item in raw_projects
|
|
443
|
+
) or any(
|
|
444
|
+
isinstance(item, MappingABC) and _normalized_root(item.get("root")) == selected
|
|
445
|
+
for item in raw_failures
|
|
437
446
|
)
|
|
438
447
|
failing = bool(selected and _category_contains(report, "failing", selected))
|
|
439
448
|
pending = bool(selected and _category_contains(report, "pending", selected))
|
graphite/git.py
CHANGED
|
@@ -121,6 +121,18 @@ class GitOutputLimitError(GitError):
|
|
|
121
121
|
"""Raised when Git stdout exceeds the configured bound."""
|
|
122
122
|
|
|
123
123
|
|
|
124
|
+
class GitCommandFailedError(_StepGitError):
|
|
125
|
+
"""Raised when a Git command ran and exited non-zero.
|
|
126
|
+
|
|
127
|
+
Git's own text is discarded on purpose -- it routinely embeds the
|
|
128
|
+
checkout path -- and the run's stderr is never captured at all. The exit
|
|
129
|
+
status is neither: it is an integer, and it is the only thing left that
|
|
130
|
+
says WHICH failure this was. Without it the enumeration error carried no
|
|
131
|
+
cause at all, so a daemon that failed every snapshot of a repository
|
|
132
|
+
could not say why (#113).
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
|
|
124
136
|
class GitUnsupportedVersionError(_StepGitError):
|
|
125
137
|
"""Raised when Git's protected command configuration is unavailable.
|
|
126
138
|
|
graphite/ingest.py
CHANGED
|
@@ -10,7 +10,7 @@ from typing import Callable, Iterable
|
|
|
10
10
|
from . import ownership
|
|
11
11
|
from .cache import file_hash
|
|
12
12
|
from .config import Config
|
|
13
|
-
from .git import GitError, GitRunner
|
|
13
|
+
from .git import GitCommandFailedError, GitError, GitRunner
|
|
14
14
|
from .hook_entry import MARKER as _SETUP_MARKER
|
|
15
15
|
|
|
16
16
|
|
|
@@ -21,6 +21,28 @@ class IngestError(RuntimeError):
|
|
|
21
21
|
"""Raised when repository files cannot be enumerated safely."""
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
class IngestEnumerationError(RuntimeError):
|
|
25
|
+
"""Which way enumerating a repository failed, in one path-free word.
|
|
26
|
+
|
|
27
|
+
`IngestError` says WHAT failed and not WHY, and every enumeration
|
|
28
|
+
failure raises the same message, so a daemon that could not snapshot a
|
|
29
|
+
repository logged "IngestError" and could not say which failure it was
|
|
30
|
+
-- the same loss #113 fixed for Git's exit status. This is the CAUSE
|
|
31
|
+
those sites now raise, and it carries the reason.
|
|
32
|
+
|
|
33
|
+
The reason is a fixed token, never a path and never Git's own text, so
|
|
34
|
+
the chain the daemon logs stays path-free.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def __init__(self, reason: str) -> None:
|
|
38
|
+
super().__init__(reason)
|
|
39
|
+
self.reason = reason
|
|
40
|
+
|
|
41
|
+
def diagnostic(self) -> str:
|
|
42
|
+
"""Path-free identity: the class and the reason, nothing else."""
|
|
43
|
+
return f"{type(self).__name__}:{self.reason}"
|
|
44
|
+
|
|
45
|
+
|
|
24
46
|
@dataclass(frozen=True)
|
|
25
47
|
class FileEntry:
|
|
26
48
|
rel_path: str # posix-style relative path
|
|
@@ -248,7 +270,9 @@ def _git_ls_files(
|
|
|
248
270
|
enclosing = enclosing_git_root(root)
|
|
249
271
|
if enclosing != root:
|
|
250
272
|
if enclosing is not None:
|
|
251
|
-
raise IngestError("nested Git roots are unsupported")
|
|
273
|
+
raise IngestError("nested Git roots are unsupported") from (
|
|
274
|
+
IngestEnumerationError("nested_git_root")
|
|
275
|
+
)
|
|
252
276
|
return None
|
|
253
277
|
try:
|
|
254
278
|
result = GitRunner(root).run(
|
|
@@ -258,7 +282,12 @@ def _git_ls_files(
|
|
|
258
282
|
except GitError as exc:
|
|
259
283
|
raise IngestError("unable to enumerate Git repository safely") from exc
|
|
260
284
|
if result.returncode != 0:
|
|
261
|
-
|
|
285
|
+
# The message stays the path-free constant it has always been; the
|
|
286
|
+
# cause carries the exit status, which is an integer and is the only
|
|
287
|
+
# thing left that says which failure this was (#113).
|
|
288
|
+
raise IngestError("unable to enumerate Git repository safely") from GitCommandFailedError(
|
|
289
|
+
"git command failed", reason=f"exit_{result.returncode}"
|
|
290
|
+
)
|
|
262
291
|
try:
|
|
263
292
|
output = result.stdout.decode("utf-8")
|
|
264
293
|
except UnicodeDecodeError as exc:
|
|
@@ -266,7 +295,9 @@ def _git_ls_files(
|
|
|
266
295
|
if not output:
|
|
267
296
|
return []
|
|
268
297
|
if not output.endswith("\x00"):
|
|
269
|
-
raise IngestError("unable to enumerate Git repository safely")
|
|
298
|
+
raise IngestError("unable to enumerate Git repository safely") from (
|
|
299
|
+
IngestEnumerationError("output_not_nul_terminated")
|
|
300
|
+
)
|
|
270
301
|
|
|
271
302
|
selected: list[str] = []
|
|
272
303
|
start = 0
|
|
@@ -276,13 +307,24 @@ def _git_ls_files(
|
|
|
276
307
|
):
|
|
277
308
|
end = output.find("\x00", start)
|
|
278
309
|
if end < 0:
|
|
279
|
-
|
|
310
|
+
# Unreachable while the invariant above holds: the output ends
|
|
311
|
+
# with NUL, and the loop only runs while `start` is inside it,
|
|
312
|
+
# so there is always a NUL at or after `start`. Kept, because
|
|
313
|
+
# the invariant is a property of the parser and not of the
|
|
314
|
+
# caller.
|
|
315
|
+
raise IngestError("unable to enumerate Git repository safely") from (
|
|
316
|
+
IngestEnumerationError("record_not_nul_terminated")
|
|
317
|
+
)
|
|
280
318
|
record_count += 1
|
|
281
319
|
if record_count > MAX_GIT_FILE_RECORDS:
|
|
282
|
-
raise IngestError("unable to enumerate Git repository safely")
|
|
320
|
+
raise IngestError("unable to enumerate Git repository safely") from (
|
|
321
|
+
IngestEnumerationError("too_many_records")
|
|
322
|
+
)
|
|
283
323
|
normalized = _normalize_git_path(root, output[start:end])
|
|
284
324
|
if normalized is None:
|
|
285
|
-
raise IngestError("unable to enumerate Git repository safely")
|
|
325
|
+
raise IngestError("unable to enumerate Git repository safely") from (
|
|
326
|
+
IngestEnumerationError("path_not_contained")
|
|
327
|
+
)
|
|
286
328
|
if is_eligible is None or is_eligible(normalized):
|
|
287
329
|
selected.append(normalized)
|
|
288
330
|
start = end + 1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: graphite-code
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: Local-first, zero-LLM knowledge graph extraction for codebases.
|
|
5
5
|
Project-URL: Homepage, https://github.com/jared0565/graphite
|
|
6
6
|
Project-URL: Repository, https://github.com/jared0565/graphite
|
|
@@ -37,6 +37,7 @@ Provides-Extra: dev
|
|
|
37
37
|
Requires-Dist: mypy>=1.14; extra == 'dev'
|
|
38
38
|
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
39
39
|
Requires-Dist: pytest-timeout>=2.3; extra == 'dev'
|
|
40
|
+
Requires-Dist: pytest-xdist>=3.5; extra == 'dev'
|
|
40
41
|
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
41
42
|
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
42
43
|
Provides-Extra: local-llm
|
|
@@ -48,7 +49,7 @@ Description-Content-Type: text/markdown
|
|
|
48
49
|
|
|
49
50
|
Local-first, deterministic knowledge graph extraction for codebases — zero-LLM, daemon-maintained, agent-agnostic.
|
|
50
51
|
|
|
51
|
-
**Status: 1.
|
|
52
|
+
**Status: 1.7.0, production/stable.** Published on PyPI as
|
|
52
53
|
[`graphite-code`](https://pypi.org/project/graphite-code/) with PEP 740
|
|
53
54
|
attestations; supported on Windows, Linux and macOS with Python 3.11–3.14
|
|
54
55
|
(every cell gates CI). What 1.x promises — CLI, JSON outputs, `graph.json`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
graphite/__init__.py,sha256=
|
|
1
|
+
graphite/__init__.py,sha256=h7w8E5zcEDstaoiLb4ApnaHeJFStv6Lv_6yWi__sJ2E,2181
|
|
2
2
|
graphite/__main__.py,sha256=Bp5bcXE6M0AnuNW1LjOXOEvGG5r0fXZoeRb_k5Yxphs,149
|
|
3
3
|
graphite/_cleanup_worker.py,sha256=oIXOPa1jHVP8ePRSwn27nZEHOAc4DSBrjeH2Ds9wuq8,19619
|
|
4
4
|
graphite/_win32_ctypes.py,sha256=YLH4kpKjL7zUUOs9E8C-Kjdy45PJBd6eRUeKwiKdSV4,1476
|
|
@@ -11,21 +11,21 @@ graphite/bootstrap.py,sha256=OPDzN9jSr8IE1N7xOnVKk3FgO2UqBTOUNcNV-pZAsus,8448
|
|
|
11
11
|
graphite/buildlock.py,sha256=QXo4cnGGCmhxuuYdy6f5OHF82Yg6zHUMxLVdxwG49ic,5393
|
|
12
12
|
graphite/cache.py,sha256=Mh28dYg9irXBvH-oa8jpFSM-ehXcs5FuNVHVzF_WRA8,9143
|
|
13
13
|
graphite/channel.py,sha256=UNFAGuws6XFbkBu0fnVLepBDxT1BWAJlW33IPVlDi9M,72908
|
|
14
|
-
graphite/cli.py,sha256=
|
|
14
|
+
graphite/cli.py,sha256=2I97jYhTwfZZ7X7BSK6G4KRKqD8Mc8m21Zgri2NqDA4,162487
|
|
15
15
|
graphite/cluster.py,sha256=j5dFT40DD7scD4h8d7XJoAGQIcJKpsKsrFceiJkOuzw,4066
|
|
16
16
|
graphite/config.py,sha256=ZWhWOWYEyKGoHCp6vWI4M4NQM57ohf5BaX0Ty8HfWYM,9267
|
|
17
17
|
graphite/context.py,sha256=vWMuFxqDGby-9Gs_t9XNJzKR-nZqwMdbU2y6N_GypWU,13215
|
|
18
|
-
graphite/daemon.py,sha256=
|
|
19
|
-
graphite/daemon_health.py,sha256=
|
|
18
|
+
graphite/daemon.py,sha256=HX-Txkb3ov6b7IIVKukWY4iswEae2rbMCsIAn1OvoRM,36061
|
|
19
|
+
graphite/daemon_health.py,sha256=cdBUGOsK6rdu2lk3kavH9e66_SsWL2GDtqYpVpvrT2s,34299
|
|
20
20
|
graphite/daemon_launch.py,sha256=d6VhJVARdhBSdGWPHxKgveDisX5JWHlDJeV6tjLJWKw,2329
|
|
21
21
|
graphite/debt.py,sha256=mvxoFrICwbWP19YKlf1cZIPFg8qIf7Jgyr9kIweVBbE,4664
|
|
22
22
|
graphite/dependency_install.py,sha256=hcwRmg74BfweXfRzzgRqHhLGEEIWokNLebJCxM2D80k,58600
|
|
23
23
|
graphite/detach.py,sha256=BlUjeh_UcjpQ9DMRZFOgxhk83zUbMSTPmXe6t1FFEKE,1270
|
|
24
|
-
graphite/doctor.py,sha256=
|
|
24
|
+
graphite/doctor.py,sha256=CknFB3EeBiiWbQc9IePBDuQWf6foMbI9Bbq871SNxvg,35249
|
|
25
25
|
graphite/doctor_probes.py,sha256=pSU62zuHv3pxcXZWquUUvd6UVur-grfrr3CJ0PM8uis,89852
|
|
26
26
|
graphite/engine_identity.py,sha256=hZYA9fBsg2fj_61Rtkc84XzJrdsa2MaDFOLZJV4I7eE,8951
|
|
27
27
|
graphite/freshness.py,sha256=kkhs-ArInlv1XxedmQRAFiThvrHt11mN5UAGCQCU4A8,5284
|
|
28
|
-
graphite/git.py,sha256=
|
|
28
|
+
graphite/git.py,sha256=3dWIVVBkEKK8IPIYx_vfAL6E6Syk26RSv_LONUQ7FpI,16047
|
|
29
29
|
graphite/graph.py,sha256=2mhbIrx4ekidgXnw3gLWDtGcVdvOmYfpZ4oATtwbao0,4284
|
|
30
30
|
graphite/graph_io.py,sha256=rWjc3_Lq7DOg1_XuM4eY8GH9GwIHowo0CcABTIRtLyc,6563
|
|
31
31
|
graphite/health.py,sha256=Sh8P6_RvEBaFeICUbhncqw5I-Nlge9ASTkQpxSUtKfs,5525
|
|
@@ -33,7 +33,7 @@ graphite/hook_entry.py,sha256=0lfCZB9-B_9QBKagLhV_VIMVFcrOeAwpLcFXUjhMMpg,2655
|
|
|
33
33
|
graphite/hookinstall.py,sha256=7qfboCBjP7DAeugbXXjZDDg-0aP7GJc_WhqxgJsOlV4,10215
|
|
34
34
|
graphite/hookshim.py,sha256=4to9xkNOWPjbk1Es97KTTknjJM9gdHkbEDjCQq8ntec,3771
|
|
35
35
|
graphite/incident_ledger.py,sha256=wHW-P_PJNollM_L9bAXHaxFeLb89wMXs7XX0VrH7aSw,8654
|
|
36
|
-
graphite/ingest.py,sha256=
|
|
36
|
+
graphite/ingest.py,sha256=FG4YNRTds7GFypV8HgT_DOlTzw4zoVw2aaKwGPrSxX0,13892
|
|
37
37
|
graphite/init.py,sha256=yoCyQ83UJ7Nb_suq_HUAVOwPhHbqpWfKtfD4P3n_LPE,41322
|
|
38
38
|
graphite/io.py,sha256=YBXfMcPsv1Lzun8ByW4BQlfgMm54akckLFrUhwWtleI,2996
|
|
39
39
|
graphite/launchd_agent.py,sha256=rmKhhCbB-9FDU_3A1b2OlZxKpxZqdgtYnLbzkFMs_rI,4529
|
|
@@ -113,8 +113,8 @@ graphite/routing/zai_edit.py,sha256=Kra2tI9GkntQAhV1vNHlFlp4sY-ksq2-bY4N9fEfLEc,
|
|
|
113
113
|
graphite/routing/zai_executor.py,sha256=cHUl7DbWRUhYg9Lwm3OiP6H3dI70y_b8iAWCyfgOPi0,6636
|
|
114
114
|
graphite/routing/zai_probe.py,sha256=HL2vM8s2J4-n8Bp3l7QLpWLEk-PhZrt_rLc2cY65hvU,4771
|
|
115
115
|
graphite/ts_resolver.mjs,sha256=wiKDWkJIC9__3wL49ty4W8hRc5biisNNtFhH1aFA47A,10822
|
|
116
|
-
graphite_code-1.
|
|
117
|
-
graphite_code-1.
|
|
118
|
-
graphite_code-1.
|
|
119
|
-
graphite_code-1.
|
|
120
|
-
graphite_code-1.
|
|
116
|
+
graphite_code-1.7.0.dist-info/METADATA,sha256=_YssabdvTH_ygGcoSIiAUxKdoftnKNb3009FdOGiSio,48525
|
|
117
|
+
graphite_code-1.7.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
118
|
+
graphite_code-1.7.0.dist-info/entry_points.txt,sha256=-BpYAYFyn58DYi-hrFW9hMz6mTwNsYI44s9gaef4MiM,87
|
|
119
|
+
graphite_code-1.7.0.dist-info/licenses/LICENSE,sha256=mfotJ1Lk0VVUgoEPOIR7-x5cvYiz2UkuVH7e3fhoDiY,1066
|
|
120
|
+
graphite_code-1.7.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|