graphite-code 1.9.2__py3-none-any.whl → 1.9.4__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/agent_hooks.py +13 -6
- graphite/cli.py +10 -8
- graphite/doctor.py +23 -4
- graphite/doctor_probes.py +171 -21
- graphite/incident_ledger.py +26 -0
- graphite/ingest.py +41 -0
- graphite/probe_process.py +11 -0
- {graphite_code-1.9.2.dist-info → graphite_code-1.9.4.dist-info}/METADATA +2 -2
- {graphite_code-1.9.2.dist-info → graphite_code-1.9.4.dist-info}/RECORD +13 -13
- {graphite_code-1.9.2.dist-info → graphite_code-1.9.4.dist-info}/WHEEL +0 -0
- {graphite_code-1.9.2.dist-info → graphite_code-1.9.4.dist-info}/entry_points.txt +0 -0
- {graphite_code-1.9.2.dist-info → graphite_code-1.9.4.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.9.
|
|
41
|
+
__version__ = "1.9.4"
|
graphite/agent_hooks.py
CHANGED
|
@@ -23,7 +23,7 @@ from .graph import edge_relations
|
|
|
23
23
|
from .graph_io import load_validated_graph_bundle
|
|
24
24
|
from .health import _edge_language, is_placeholder, persisted_resolution
|
|
25
25
|
from .incident_ledger import record_incident, repo_ledger_dir
|
|
26
|
-
from .ingest import
|
|
26
|
+
from .ingest import activation_root, repository_root
|
|
27
27
|
from .query import _CALL_RELATIONS
|
|
28
28
|
|
|
29
29
|
SESSION_CONTRACT = (
|
|
@@ -77,18 +77,25 @@ def _activate(root: Path) -> None:
|
|
|
77
77
|
"""Register this repo as open, so the daemon supervises it and leaves the
|
|
78
78
|
rest of the machine alone.
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
What is registered is `ingest.activation_root`'s answer, the rule the
|
|
81
|
+
CLI's backstop uses too. A directory below a checkout's root is never
|
|
82
|
+
registered: no build can run there, so the daemon would fail on it at
|
|
83
|
+
every discovery cycle for as long as the marker lived. A folder in no
|
|
84
|
+
repository is registered only where graphite is set up there, and a drive
|
|
85
|
+
or filesystem root never is, not even one holding `.git`. The payload's
|
|
86
|
+
`cwd` follows a `cd` in the shell and `Stop` renews the marker every turn,
|
|
87
|
+
so a session that wandered to a drive root would otherwise keep the whole
|
|
88
|
+
drive under supervision.
|
|
83
89
|
|
|
84
90
|
Guarded separately from the caller's own try/except: activation is
|
|
85
91
|
bookkeeping, and this module is fail-open by contract -- a broken registry
|
|
86
92
|
must never cost the agent its session context or its graph-first reminder.
|
|
87
93
|
"""
|
|
88
94
|
try:
|
|
89
|
-
|
|
95
|
+
opened = activation_root(root)
|
|
96
|
+
if opened is None:
|
|
90
97
|
return
|
|
91
|
-
mark_active(
|
|
98
|
+
mark_active(opened, "claude")
|
|
92
99
|
except Exception:
|
|
93
100
|
return
|
|
94
101
|
|
graphite/cli.py
CHANGED
|
@@ -53,7 +53,7 @@ from .graph_io import MAX_GRAPH_BYTES, GraphReadError, load_validated_graph_bund
|
|
|
53
53
|
from .health import persisted_resolution, ratio_percent, resolution_health
|
|
54
54
|
from . import hookinstall
|
|
55
55
|
from .incident_ledger import record_incident, repo_ledger_dir
|
|
56
|
-
from .ingest import collect_files, enclosing_git_root, repository_root, trusted_root
|
|
56
|
+
from .ingest import activation_root, collect_files, enclosing_git_root, repository_root, trusted_root
|
|
57
57
|
from .init import init_project, platform_choices, resolve_platform_selection
|
|
58
58
|
from .io import atomic_write_json
|
|
59
59
|
from .listing import listing_lines
|
|
@@ -3704,14 +3704,16 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
3704
3704
|
# GRAPHITE_DAEMON_CHILD, without which activation would never expire.
|
|
3705
3705
|
#
|
|
3706
3706
|
# What is registered is the REPOSITORY the command is typed in, not the
|
|
3707
|
-
# directory (#81)
|
|
3708
|
-
#
|
|
3709
|
-
#
|
|
3710
|
-
#
|
|
3711
|
-
#
|
|
3707
|
+
# directory (#81), and `ingest.activation_root` decides it for this path
|
|
3708
|
+
# and for `agent_hooks._activate` alike: never a drive or filesystem root,
|
|
3709
|
+
# not even one holding `.git`; otherwise a checkout's root; nothing for a
|
|
3710
|
+
# folder below a root, where no build can run; and a folder in no
|
|
3711
|
+
# repository only where graphite is set up there. Registering any folder
|
|
3712
|
+
# a command ran in put a whole drive under supervision when a command was
|
|
3713
|
+
# typed at its root.
|
|
3712
3714
|
if args.command not in _ACTIVATION_EXEMPT_COMMANDS and not _is_scratch_workspace(Path.cwd()):
|
|
3713
|
-
opened =
|
|
3714
|
-
if
|
|
3715
|
+
opened = activation_root(Path.cwd())
|
|
3716
|
+
if opened is not None:
|
|
3715
3717
|
activation.mark_active(opened, "cli")
|
|
3716
3718
|
|
|
3717
3719
|
try:
|
graphite/doctor.py
CHANGED
|
@@ -621,25 +621,44 @@ def check_llm_config(cfg: Config) -> DoctorCheck:
|
|
|
621
621
|
|
|
622
622
|
|
|
623
623
|
def _incidents_check(root: Path) -> DoctorCheck:
|
|
624
|
-
from .incident_ledger import
|
|
624
|
+
from .incident_ledger import (
|
|
625
|
+
fold_incidents,
|
|
626
|
+
read_incident_entries,
|
|
627
|
+
recurred_since_ack,
|
|
628
|
+
repo_ledger_dir,
|
|
629
|
+
)
|
|
625
630
|
|
|
626
631
|
entries, skipped = read_incident_entries(repo_ledger_dir(root))
|
|
627
632
|
views = [v for v in fold_incidents(entries) if v.state != "resolved"]
|
|
628
633
|
open_views = [v for v in views if v.state == "open"]
|
|
629
634
|
top = [f"{v.fingerprint} {v.code} {v.subject} x{v.count}" for v in open_views[:10]]
|
|
630
635
|
summary = f"{len(open_views)} open / {len(views) - len(open_views)} acked"
|
|
636
|
+
# Reported, not escalated: the status still turns only on open incidents,
|
|
637
|
+
# because an ack is the operator's decision. What changes is that a
|
|
638
|
+
# recurrence after it is SAID -- before, it raised a count and nothing else.
|
|
639
|
+
recurred = recurred_since_ack(entries)
|
|
640
|
+
recurred_views = [v for v in views if v.state == "acked" and v.fingerprint in recurred]
|
|
641
|
+
if recurred_views:
|
|
642
|
+
summary += f", {len(recurred_views)} recurred since ack"
|
|
631
643
|
if skipped:
|
|
632
644
|
summary += f", {skipped} corrupt line(s)"
|
|
633
645
|
status: DoctorStatus = "degraded" if open_views else "ready"
|
|
646
|
+
remediation: tuple[str, ...] = ()
|
|
647
|
+
if open_views:
|
|
648
|
+
remediation += ("graphite incidents list", "graphite incidents ack <fingerprint> -m NOTE")
|
|
649
|
+
if recurred_views:
|
|
650
|
+
remediation += tuple(
|
|
651
|
+
f"recurred since ack: {v.fingerprint} {v.code} {v.subject} x{v.count}, last {v.last_seen}"
|
|
652
|
+
for v in recurred_views[:10]
|
|
653
|
+
)
|
|
654
|
+
remediation += ("An ack does not re-open on recurrence; read the incident again.",)
|
|
634
655
|
return DoctorCheck(
|
|
635
656
|
code="incidents",
|
|
636
657
|
label="Incident ledger",
|
|
637
658
|
status=status,
|
|
638
659
|
summary=summary,
|
|
639
660
|
details={"top_open": top},
|
|
640
|
-
remediation=
|
|
641
|
-
if open_views
|
|
642
|
-
else (),
|
|
661
|
+
remediation=remediation,
|
|
643
662
|
)
|
|
644
663
|
|
|
645
664
|
|
graphite/doctor_probes.py
CHANGED
|
@@ -99,6 +99,74 @@ def identity_matches(stat, identity, require_directory):
|
|
|
99
99
|
return [stat.st_dev, stat.st_ino] == identity[:2]
|
|
100
100
|
return [stat.st_dev, stat.st_ino, stat.st_size, stat.st_mtime_ns] == identity
|
|
101
101
|
'''
|
|
102
|
+
#: Why the manifest builder refused, carried as the exit status it refused with.
|
|
103
|
+
#:
|
|
104
|
+
#: The child's streams never cross into this process (see `ProbeProcessError`),
|
|
105
|
+
#: so every refusal used to arrive as a bare `nonzero` and surface as
|
|
106
|
+
#: `probe_failed` with every diagnostic field empty. That is how a probe that
|
|
107
|
+
#: refused on every install with mcp beside graphite went unnoticed for months.
|
|
108
|
+
#: A status is a number, so it may cross where the streams may not, and it is
|
|
109
|
+
#: decoded here onto this fixed vocabulary -- nothing the child writes reaches a
|
|
110
|
+
#: report. Classes split only where the remedy differs. 70 is the unclassified
|
|
111
|
+
#: refusal and the child's excepthook status; it has no entry on purpose.
|
|
112
|
+
_MCP_REFUSAL_UNCLASSIFIED = "unclassified"
|
|
113
|
+
_MCP_BUILDER_REFUSALS: Mapping[int, str] = {
|
|
114
|
+
71: "installation_mismatch",
|
|
115
|
+
72: "environment_in_repository",
|
|
116
|
+
73: "dependency_missing",
|
|
117
|
+
74: "dependency_duplicated",
|
|
118
|
+
}
|
|
119
|
+
#: The same table as names the builder bootstrap raises with. Generated rather
|
|
120
|
+
#: than written out, so the child's statuses cannot drift from the decoder's.
|
|
121
|
+
_MCP_REFUSAL_STATUSES = "".join(
|
|
122
|
+
f"REFUSED_{token.upper()} = {status}\n" for status, token in _MCP_BUILDER_REFUSALS.items()
|
|
123
|
+
)
|
|
124
|
+
#: What each refusal means to the operator: the phrase that ends the summary,
|
|
125
|
+
#: then the remediation lines. Human wording, not a stable surface; the check's
|
|
126
|
+
#: `details` stay `{"code": "probe_failed"}` for every refusal.
|
|
127
|
+
_MCP_REFUSAL_REPORTS: Mapping[str, tuple[str, tuple[str, ...]]] = {
|
|
128
|
+
"dependency_missing": (
|
|
129
|
+
"a dependency of the MCP server has no installed copy where the probe looks",
|
|
130
|
+
(
|
|
131
|
+
"The probe stopped before starting the server: mcp, networkx or one of "
|
|
132
|
+
"their requirements is not installed on this interpreter's package paths.",
|
|
133
|
+
'Install the MCP extra into this interpreter: python -m pip install "graphite-code[mcp]"',
|
|
134
|
+
),
|
|
135
|
+
),
|
|
136
|
+
"dependency_duplicated": (
|
|
137
|
+
"a dependency of the MCP server is installed more than once",
|
|
138
|
+
(
|
|
139
|
+
"The probe stopped before starting the server: a distribution the server "
|
|
140
|
+
"needs is installed in two package directories, so it cannot tell which "
|
|
141
|
+
"copy the server would import.",
|
|
142
|
+
"Remove the extra copy; python -m pip list -v shows where each one is installed.",
|
|
143
|
+
),
|
|
144
|
+
),
|
|
145
|
+
"environment_in_repository": (
|
|
146
|
+
"installed packages were found inside the repository being checked",
|
|
147
|
+
(
|
|
148
|
+
"The probe stopped before starting the server: a package directory on "
|
|
149
|
+
"this interpreter's path lies inside the repository and holds installed "
|
|
150
|
+
"distributions -- usually a virtual environment created inside the clone.",
|
|
151
|
+
"Move the environment outside the repository.",
|
|
152
|
+
),
|
|
153
|
+
),
|
|
154
|
+
"installation_mismatch": (
|
|
155
|
+
"graphite's installation changed, or is not laid out as the probe verifies",
|
|
156
|
+
(
|
|
157
|
+
"The probe stopped before starting the server: the files it bound to "
|
|
158
|
+
"changed while it ran, or graphite is not installed where it was loaded from.",
|
|
159
|
+
"Run doctor again; if this repeats, reinstall graphite.",
|
|
160
|
+
),
|
|
161
|
+
),
|
|
162
|
+
_MCP_REFUSAL_UNCLASSIFIED: (
|
|
163
|
+
"the dependency manifest was refused for a reason the probe does not classify",
|
|
164
|
+
(
|
|
165
|
+
"The probe stopped before starting the server.",
|
|
166
|
+
"graphite incidents list records the refusal with its exit status.",
|
|
167
|
+
),
|
|
168
|
+
),
|
|
169
|
+
}
|
|
102
170
|
|
|
103
171
|
_MCP_MANIFEST_BUILDER_BOOTSTRAP = """\
|
|
104
172
|
import os
|
|
@@ -108,7 +176,7 @@ import sys
|
|
|
108
176
|
from importlib.machinery import PathFinder
|
|
109
177
|
|
|
110
178
|
sys.excepthook = lambda *_: os._exit(70)
|
|
111
|
-
""" + _MCP_IDENTITY_MATCHER + """\
|
|
179
|
+
""" + _MCP_IDENTITY_MATCHER + _MCP_REFUSAL_STATUSES + """\
|
|
112
180
|
def validate_binding(raw, require_directory):
|
|
113
181
|
if not isinstance(raw, dict) or set(raw) != {"canonical", "identity", "lexical"}:
|
|
114
182
|
raise SystemExit(70)
|
|
@@ -126,12 +194,12 @@ def validate_binding(raw, require_directory):
|
|
|
126
194
|
):
|
|
127
195
|
raise SystemExit(70)
|
|
128
196
|
if lexical.resolve(strict=True) != canonical or canonical.resolve(strict=True) != canonical:
|
|
129
|
-
raise SystemExit(
|
|
197
|
+
raise SystemExit(REFUSED_INSTALLATION_MISMATCH)
|
|
130
198
|
stat = canonical.stat()
|
|
131
199
|
if not identity_matches(stat, identity, require_directory):
|
|
132
|
-
raise SystemExit(
|
|
200
|
+
raise SystemExit(REFUSED_INSTALLATION_MISMATCH)
|
|
133
201
|
if canonical.is_dir() != require_directory:
|
|
134
|
-
raise SystemExit(
|
|
202
|
+
raise SystemExit(REFUSED_INSTALLATION_MISMATCH)
|
|
135
203
|
return lexical, canonical
|
|
136
204
|
def overlaps(left, right):
|
|
137
205
|
try:
|
|
@@ -180,7 +248,7 @@ if (
|
|
|
180
248
|
or expected_doctor.parent != trusted / "graphite"
|
|
181
249
|
or expected_mcp.parent != trusted / "graphite"
|
|
182
250
|
):
|
|
183
|
-
raise SystemExit(
|
|
251
|
+
raise SystemExit(REFUSED_INSTALLATION_MISMATCH)
|
|
184
252
|
stdlib_path = list(sys.path)
|
|
185
253
|
graphite_spec = PathFinder.find_spec("graphite", [str(trusted)])
|
|
186
254
|
if (
|
|
@@ -191,7 +259,7 @@ if (
|
|
|
191
259
|
or [pathlib.Path(item).resolve(strict=True) for item in graphite_spec.submodule_search_locations]
|
|
192
260
|
!= [expected_init.parent]
|
|
193
261
|
):
|
|
194
|
-
raise SystemExit(
|
|
262
|
+
raise SystemExit(REFUSED_INSTALLATION_MISMATCH)
|
|
195
263
|
doctor_spec = PathFinder.find_spec(
|
|
196
264
|
"graphite.doctor_probes", list(graphite_spec.submodule_search_locations)
|
|
197
265
|
)
|
|
@@ -200,11 +268,11 @@ if (
|
|
|
200
268
|
or doctor_spec.origin is None
|
|
201
269
|
or pathlib.Path(doctor_spec.origin).resolve(strict=True) != expected_doctor
|
|
202
270
|
):
|
|
203
|
-
raise SystemExit(
|
|
271
|
+
raise SystemExit(REFUSED_INSTALLATION_MISMATCH)
|
|
204
272
|
sys.path[:] = [str(trusted), *stdlib_path]
|
|
205
273
|
from graphite import doctor_probes
|
|
206
274
|
if pathlib.Path(doctor_probes.__file__).resolve(strict=True) != expected_doctor:
|
|
207
|
-
raise SystemExit(
|
|
275
|
+
raise SystemExit(REFUSED_INSTALLATION_MISMATCH)
|
|
208
276
|
cached_payload = sys.stdin.buffer.read()
|
|
209
277
|
raw_metadata_roots = json.loads(sys.argv[3])
|
|
210
278
|
if not isinstance(raw_metadata_roots, list) or len(raw_metadata_roots) > 64:
|
|
@@ -222,22 +290,32 @@ for raw in raw_metadata_roots:
|
|
|
222
290
|
if not canonical_candidate.is_dir():
|
|
223
291
|
continue
|
|
224
292
|
_, lexical, root = bind_path(raw, True)
|
|
225
|
-
|
|
293
|
+
# The trusted root is exempt from the refusal below and from nothing else:
|
|
294
|
+
# graphite probing its own checkout has its source inside the selected
|
|
295
|
+
# repository. Skipping it everywhere also dropped the site-packages an
|
|
296
|
+
# installed graphite usually shares with mcp and networkx: with them beside
|
|
297
|
+
# it, neither had a candidate and the probe read probe_failed.
|
|
298
|
+
if root == trusted and overlaps(root, selected):
|
|
226
299
|
continue
|
|
227
300
|
if overlaps(root, selected):
|
|
228
301
|
if any(doctor_probes.metadata.Distribution.discover(path=[str(lexical)])):
|
|
229
|
-
raise SystemExit(
|
|
302
|
+
raise SystemExit(REFUSED_ENVIRONMENT_IN_REPOSITORY)
|
|
230
303
|
continue
|
|
231
304
|
normalized = os.path.normcase(str(root))
|
|
232
305
|
if normalized in seen_roots:
|
|
233
306
|
raise SystemExit(70)
|
|
234
307
|
seen_roots.add(normalized)
|
|
235
308
|
metadata_roots.append(lexical)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
309
|
+
try:
|
|
310
|
+
if cached_payload:
|
|
311
|
+
manifest = json.loads(cached_payload.decode("utf-8"))
|
|
312
|
+
manifest = doctor_probes._validate_mcp_manifest(manifest, selected)
|
|
313
|
+
else:
|
|
314
|
+
manifest = doctor_probes._mcp_import_manifest(selected, tuple(metadata_roots))
|
|
315
|
+
except doctor_probes._McpDependencyMissing:
|
|
316
|
+
raise SystemExit(REFUSED_DEPENDENCY_MISSING) from None
|
|
317
|
+
except doctor_probes._McpDependencyDuplicated:
|
|
318
|
+
raise SystemExit(REFUSED_DEPENDENCY_DUPLICATED) from None
|
|
241
319
|
envelope = {
|
|
242
320
|
"bindings": {
|
|
243
321
|
"doctor": doctor_binding,
|
|
@@ -853,7 +931,9 @@ def _stream_excerpt(raw: object, *, limit: int = _PROBE_DIAGNOSTIC_STREAM_CHARS,
|
|
|
853
931
|
return f"{text[:limit]}...[{dropped} more chars]"
|
|
854
932
|
|
|
855
933
|
|
|
856
|
-
def _record_probe_diagnostics(
|
|
934
|
+
def _record_probe_diagnostics(
|
|
935
|
+
root: Path, failure: str, result: object = None, *, reason: str | None = None
|
|
936
|
+
) -> None:
|
|
857
937
|
"""Record what a failing probe knew, so the next occurrence explains itself.
|
|
858
938
|
|
|
859
939
|
`DoctorCheck.details` deliberately stays `{"code": ...}`: callers assert
|
|
@@ -861,12 +941,17 @@ def _record_probe_diagnostics(root: Path, failure: str, result: object = None) -
|
|
|
861
941
|
stderr should not travel. The repo incident ledger is local and bounded, so
|
|
862
942
|
that is where the evidence goes.
|
|
863
943
|
|
|
944
|
+
`reason` leads the detail when the caller knows WHY -- a refusal class, or
|
|
945
|
+
the type of an exception nothing classified. Only ever this module's own
|
|
946
|
+
vocabulary or a class name, never text a child produced.
|
|
947
|
+
|
|
864
948
|
Swallows everything. Diagnostics are a convenience; a probe that failed
|
|
865
949
|
because its own logging failed would be worse than the opacity this fixes.
|
|
866
950
|
"""
|
|
867
951
|
try:
|
|
868
952
|
detail = " | ".join(
|
|
869
953
|
(
|
|
954
|
+
*((f"reason={reason}",) if reason is not None else ()),
|
|
870
955
|
f"returncode={getattr(result, 'returncode', '<none>')}",
|
|
871
956
|
# Transport-side evidence, and the only evidence there IS when
|
|
872
957
|
# the transport raised rather than returned (graphite#51).
|
|
@@ -951,6 +1036,26 @@ def _degraded_probe(code: str, label: str, failure: str) -> DoctorCheck:
|
|
|
951
1036
|
)
|
|
952
1037
|
|
|
953
1038
|
|
|
1039
|
+
def _manifest_refused_probe(refusal: str) -> DoctorCheck:
|
|
1040
|
+
"""`probe_failed`, as before, but saying why the builder refused.
|
|
1041
|
+
|
|
1042
|
+
The code is unchanged -- `doctor --json` is a stable surface and callers
|
|
1043
|
+
assert `details` exactly -- so the reason travels in the summary and the
|
|
1044
|
+
remediation, which are human wording.
|
|
1045
|
+
"""
|
|
1046
|
+
phrase, remediation = _MCP_REFUSAL_REPORTS.get(
|
|
1047
|
+
refusal, _MCP_REFUSAL_REPORTS[_MCP_REFUSAL_UNCLASSIFIED]
|
|
1048
|
+
)
|
|
1049
|
+
return DoctorCheck(
|
|
1050
|
+
"deep_mcp",
|
|
1051
|
+
"MCP",
|
|
1052
|
+
"degraded",
|
|
1053
|
+
f"The MCP deep probe probe_failed: {phrase}.",
|
|
1054
|
+
{"code": "probe_failed"},
|
|
1055
|
+
remediation,
|
|
1056
|
+
)
|
|
1057
|
+
|
|
1058
|
+
|
|
954
1059
|
def _paths_overlap(left: Path, right: Path) -> bool:
|
|
955
1060
|
try:
|
|
956
1061
|
left.relative_to(right)
|
|
@@ -1348,6 +1453,37 @@ def _declared_distribution_name(distribution: metadata.Distribution) -> str | No
|
|
|
1348
1453
|
return meta["Name"] if "Name" in meta else None
|
|
1349
1454
|
|
|
1350
1455
|
|
|
1456
|
+
class _McpDependencyMissing(ValueError):
|
|
1457
|
+
"""A distribution in the MCP closure has no copy on the metadata roots.
|
|
1458
|
+
|
|
1459
|
+
A `ValueError`, as the bare raise it replaces was, so every caller that
|
|
1460
|
+
already treats a closure failure as a refusal still does. The builder child
|
|
1461
|
+
catches it by type to exit with the status that says which refusal it was.
|
|
1462
|
+
"""
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
class _McpDependencyDuplicated(ValueError):
|
|
1466
|
+
"""A distribution in the MCP closure has more than one copy on the roots.
|
|
1467
|
+
|
|
1468
|
+
Refused rather than resolved by path order: the probe cannot know that the
|
|
1469
|
+
copy it would pin is the one the real server imports.
|
|
1470
|
+
"""
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
class _McpManifestRefused(ValueError):
|
|
1474
|
+
"""The manifest builder child refused, decoded to the parent's vocabulary.
|
|
1475
|
+
|
|
1476
|
+
`refusal` is only ever a key of `_MCP_REFUSAL_REPORTS`, chosen by this
|
|
1477
|
+
process from the child's exit status. `transport` is the error the runner
|
|
1478
|
+
raised, kept so its counts and timings reach the incident ledger.
|
|
1479
|
+
"""
|
|
1480
|
+
|
|
1481
|
+
def __init__(self, refusal: str, transport: ProbeProcessError) -> None:
|
|
1482
|
+
super().__init__(refusal)
|
|
1483
|
+
self.refusal = refusal if refusal in _MCP_REFUSAL_REPORTS else _MCP_REFUSAL_UNCLASSIFIED
|
|
1484
|
+
self.transport = transport
|
|
1485
|
+
|
|
1486
|
+
|
|
1351
1487
|
def _mcp_distribution_closure(
|
|
1352
1488
|
metadata_roots: tuple[Path, ...] | None = None,
|
|
1353
1489
|
) -> dict[str, metadata.Distribution]:
|
|
@@ -1396,8 +1532,10 @@ def _mcp_distribution_closure(
|
|
|
1396
1532
|
distribution = metadata.distribution(requested)
|
|
1397
1533
|
else:
|
|
1398
1534
|
candidates = discovered.get(normalized, [])
|
|
1399
|
-
if
|
|
1400
|
-
raise
|
|
1535
|
+
if not candidates:
|
|
1536
|
+
raise _McpDependencyMissing
|
|
1537
|
+
if len(candidates) > 1:
|
|
1538
|
+
raise _McpDependencyDuplicated
|
|
1401
1539
|
distribution = candidates[0]
|
|
1402
1540
|
declared_name = _declared_distribution_name(distribution)
|
|
1403
1541
|
if not isinstance(declared_name, str) or _normalized_distribution_name(declared_name) != normalized:
|
|
@@ -1743,7 +1881,10 @@ def _build_mcp_manifest_bounded(
|
|
|
1743
1881
|
with _MCP_MANIFEST_CACHE_LOCK:
|
|
1744
1882
|
if _MCP_MANIFEST_CACHE == (cache_key, cached_payload):
|
|
1745
1883
|
_MCP_MANIFEST_CACHE = None
|
|
1746
|
-
|
|
1884
|
+
# A status the table does not name -- 70, a crash, or a runner that
|
|
1885
|
+
# reported none -- is a refusal still, just an unclassified one.
|
|
1886
|
+
refusal = _MCP_BUILDER_REFUSALS.get(exc.returncode or 0, _MCP_REFUSAL_UNCLASSIFIED)
|
|
1887
|
+
raise _McpManifestRefused(refusal, exc) from None
|
|
1747
1888
|
raise
|
|
1748
1889
|
if len(result.stdout) + len(result.stderr) > _MCP_OUTPUT_LIMIT_BYTES:
|
|
1749
1890
|
raise ProbeProcessError("output_limit")
|
|
@@ -1983,8 +2124,17 @@ def probe_mcp(
|
|
|
1983
2124
|
# carried as a number.
|
|
1984
2125
|
_record_probe_diagnostics(root, exc.code, exc)
|
|
1985
2126
|
return _degraded_probe("deep_mcp", "MCP", exc.code)
|
|
1986
|
-
except
|
|
1987
|
-
|
|
2127
|
+
except _McpManifestRefused as exc:
|
|
2128
|
+
# Its own incident code, not `probe_failed`: that fingerprint was acked
|
|
2129
|
+
# long ago, and an ack never re-opens, so a refusal recorded under it
|
|
2130
|
+
# would only raise a count nobody reads.
|
|
2131
|
+
_record_probe_diagnostics(root, "manifest_refused", exc.transport, reason=exc.refusal)
|
|
2132
|
+
return _manifest_refused_probe(exc.refusal)
|
|
2133
|
+
except Exception as exc:
|
|
2134
|
+
# Still unexplained to the reader, but no longer to the ledger: the type
|
|
2135
|
+
# separates a parent-side refusal (ValueError, OSError) from a bug in
|
|
2136
|
+
# this probe, which used to look exactly like one.
|
|
2137
|
+
_record_probe_diagnostics(root, "probe_failed", reason=type(exc).__name__)
|
|
1988
2138
|
return _degraded_probe("deep_mcp", "MCP", "probe_failed")
|
|
1989
2139
|
|
|
1990
2140
|
try:
|
graphite/incident_ledger.py
CHANGED
|
@@ -183,6 +183,32 @@ class IncidentView:
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
|
|
186
|
+
def recurred_since_ack(entries: list[dict[str, Any]]) -> frozenset[str]:
|
|
187
|
+
"""Fingerprints whose latest triage is an ack, seen again after it.
|
|
188
|
+
|
|
189
|
+
An ack never re-opens: only a resolve does (`fold_incidents`). So an
|
|
190
|
+
incident that keeps happening after it was acked shows nothing but a rising
|
|
191
|
+
count, and acks were written in the belief that a recurrence would re-open
|
|
192
|
+
them. Measured on this repository's own ledger: three acked incidents had
|
|
193
|
+
recurred unseen, one of them 41 times. Same ordering and comparison as
|
|
194
|
+
`fold_incidents`, so the two cannot disagree about what came after what.
|
|
195
|
+
"""
|
|
196
|
+
last_occurrence: dict[str, str] = {}
|
|
197
|
+
last_triage: dict[str, tuple[str, str]] = {}
|
|
198
|
+
for e in entries:
|
|
199
|
+
fp = str(e["fingerprint"])
|
|
200
|
+
ts = str(e.get("ts", ""))
|
|
201
|
+
if e.get("kind") == "occurrence":
|
|
202
|
+
last_occurrence[fp] = ts
|
|
203
|
+
else:
|
|
204
|
+
last_triage[fp] = (str(e["kind"]), ts)
|
|
205
|
+
return frozenset(
|
|
206
|
+
fp
|
|
207
|
+
for fp, (kind, ts) in last_triage.items()
|
|
208
|
+
if kind == "ack" and last_occurrence.get(fp, "") > ts
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
|
|
186
212
|
def fold_incidents(entries: list[dict[str, Any]]) -> list[IncidentView]:
|
|
187
213
|
"""Group chronologically-ordered entries into per-fingerprint views."""
|
|
188
214
|
slots: dict[str, dict[str, Any]] = {}
|
graphite/ingest.py
CHANGED
|
@@ -248,6 +248,9 @@ def repository_root(directory: Path) -> Path:
|
|
|
248
248
|
is asked last: the hooks ask for the root at every tool call.
|
|
249
249
|
|
|
250
250
|
Never raises: a directory that cannot be read stands for itself.
|
|
251
|
+
|
|
252
|
+
This answers where a session or command READS. What it may REGISTER with
|
|
253
|
+
the daemon is narrower, and `activation_root` decides that.
|
|
251
254
|
"""
|
|
252
255
|
try:
|
|
253
256
|
top = enclosing_git_root(directory)
|
|
@@ -260,6 +263,44 @@ def repository_root(directory: Path) -> Path:
|
|
|
260
263
|
return directory
|
|
261
264
|
|
|
262
265
|
|
|
266
|
+
def activation_root(directory: Path) -> Path | None:
|
|
267
|
+
"""The directory a session or command in `directory` registers as open, or
|
|
268
|
+
None for nothing.
|
|
269
|
+
|
|
270
|
+
Asked by the two paths that INFER activation from where they run: the
|
|
271
|
+
CLI's backstop and the agent hooks. `graphite activate` names its path and
|
|
272
|
+
is believed as given, so it does not ask.
|
|
273
|
+
|
|
274
|
+
- A drive or filesystem root never registers, not even one holding
|
|
275
|
+
`.git`. Registering whatever folder a command ran in handed the daemon
|
|
276
|
+
that folder to build: a command typed in a drive root put the whole
|
|
277
|
+
drive under supervision, and every build of it timed out until the
|
|
278
|
+
marker expired an hour later. A stray `.git` at a drive root is the
|
|
279
|
+
same drive, so it is asked about first -- the stance `trusted_root`
|
|
280
|
+
already takes. A repository whose root really is a drive root is
|
|
281
|
+
registered with `graphite activate`, which names its path.
|
|
282
|
+
- A checkout's root registers itself, set up or not. That is how a fresh
|
|
283
|
+
clone gets its first graph.
|
|
284
|
+
- A folder below a checkout's root registers nothing. No build can run
|
|
285
|
+
there (#80, #81), so the daemon would fail on the marker at every cycle.
|
|
286
|
+
- A folder in no repository registers itself only where graphite is set
|
|
287
|
+
up there (a graph, or `GRAPHITE.md`). A home directory, which often
|
|
288
|
+
holds a stray package manifest, is otherwise the drive-root case again.
|
|
289
|
+
|
|
290
|
+
Never raises: a directory that cannot be read registers nothing.
|
|
291
|
+
"""
|
|
292
|
+
try:
|
|
293
|
+
root = repository_root(directory)
|
|
294
|
+
if root.parent == root or _resolved(root).parent == _resolved(root):
|
|
295
|
+
return None
|
|
296
|
+
top = enclosing_git_root(root)
|
|
297
|
+
if top is not None:
|
|
298
|
+
return root if top == root else None
|
|
299
|
+
return root if _is_set_up(root) else None
|
|
300
|
+
except OSError:
|
|
301
|
+
return None
|
|
302
|
+
|
|
303
|
+
|
|
263
304
|
def _git_ls_files(
|
|
264
305
|
root: Path,
|
|
265
306
|
*,
|
graphite/probe_process.py
CHANGED
|
@@ -100,8 +100,18 @@ class ProbeProcessError(Exception):
|
|
|
100
100
|
budget_seconds: float | None = None,
|
|
101
101
|
stdout_bytes: int | None = None,
|
|
102
102
|
stderr_bytes: int | None = None,
|
|
103
|
+
returncode: int | None = None,
|
|
103
104
|
) -> None:
|
|
104
105
|
self.code = code if code in _SAFE_ERROR_CODES else "unexpected"
|
|
106
|
+
# The child's exit status on `nonzero`, which is the one fact that says
|
|
107
|
+
# WHICH refusal a bootstrap made: every refusal used to read
|
|
108
|
+
# `returncode=<none>`, because this error carried no status at all.
|
|
109
|
+
# A number, coerced like `os_error` and for the same reason -- it is
|
|
110
|
+
# safe to carry where the child's streams are not. Deliberately left out
|
|
111
|
+
# of the message, which tests pin.
|
|
112
|
+
self.returncode = (
|
|
113
|
+
returncode if isinstance(returncode, int) and not isinstance(returncode, bool) else None
|
|
114
|
+
)
|
|
105
115
|
# Coerced, never trusted: an OSError subclass can carry anything in
|
|
106
116
|
# `errno`, and only an int may reach the message.
|
|
107
117
|
self.os_error = os_error if isinstance(os_error, int) and not isinstance(os_error, bool) else None
|
|
@@ -757,6 +767,7 @@ def run_bounded_process(
|
|
|
757
767
|
budget_seconds=timeout_seconds,
|
|
758
768
|
stdout_bytes=stdout_seen,
|
|
759
769
|
stderr_bytes=stderr_seen,
|
|
770
|
+
returncode=process.returncode,
|
|
760
771
|
)
|
|
761
772
|
# Last, so it never speaks over a diagnosis -- but still raised rather than
|
|
762
773
|
# returned, because a run that may have leaked a process is not a success.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: graphite-code
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.4
|
|
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
|
|
@@ -49,7 +49,7 @@ Description-Content-Type: text/markdown
|
|
|
49
49
|
|
|
50
50
|
Local-first, deterministic knowledge graph extraction for codebases — zero-LLM, daemon-maintained, agent-agnostic.
|
|
51
51
|
|
|
52
|
-
**Status: 1.9.
|
|
52
|
+
**Status: 1.9.4, production/stable.** Published on PyPI as
|
|
53
53
|
[`graphite-code`](https://pypi.org/project/graphite-code/) with PEP 740
|
|
54
54
|
attestations; supported on Windows, Linux and macOS with Python 3.11–3.14
|
|
55
55
|
(every cell gates CI). What 1.x promises — CLI, JSON outputs, `graph.json`,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
graphite/__init__.py,sha256=
|
|
1
|
+
graphite/__init__.py,sha256=VWekp1kuBVFH3NsU4V7DG--BW0Io_xYYw2oK-aOf2dQ,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
|
|
5
5
|
graphite/activation.py,sha256=Jcgk8AFvqbMNQiPAa2MTzSO0BAYRC5FX6MsZUjbDe1I,5249
|
|
6
|
-
graphite/agent_hooks.py,sha256=
|
|
6
|
+
graphite/agent_hooks.py,sha256=7fpwi7PTxggbIFK805e1F2jLK0u0hg9G4xzvsbpvs9o,78005
|
|
7
7
|
graphite/agent_settings.py,sha256=Ec95ilPhkPOM3vW67pdsjYivnCyc5uCqWfCBu-DLI3A,11085
|
|
8
8
|
graphite/analyze.py,sha256=BwiZ4lkQ8Oo8WvnIGLI03YSNUpynYvV46tVbzHH5iWQ,9304
|
|
9
9
|
graphite/answer_contract.py,sha256=KTnGmtT6gvi28-PhLZp9vaj7FDvGrqLW_BvhAa-VPR4,31237
|
|
@@ -11,7 +11,7 @@ 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=KSE6UHWh6Xi8Yc0W6GJd5gicMOk82k3LSWn98gb47zc,166547
|
|
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
|
|
@@ -21,8 +21,8 @@ graphite/daemon_launch.py,sha256=d6VhJVARdhBSdGWPHxKgveDisX5JWHlDJeV6tjLJWKw,232
|
|
|
21
21
|
graphite/debt.py,sha256=mvxoFrICwbWP19YKlf1cZIPFg8qIf7Jgyr9kIweVBbE,4664
|
|
22
22
|
graphite/dependency_install.py,sha256=JpuIGFzGfZZYDA-ymnBVDiG3t-brpDZ4rwF99HxY7nQ,60103
|
|
23
23
|
graphite/detach.py,sha256=BlUjeh_UcjpQ9DMRZFOgxhk83zUbMSTPmXe6t1FFEKE,1270
|
|
24
|
-
graphite/doctor.py,sha256=
|
|
25
|
-
graphite/doctor_probes.py,sha256=
|
|
24
|
+
graphite/doctor.py,sha256=XSZHmd4ZNAd8gqIIL9BQgogyrXBXlQvaeVohQhfzUWs,36117
|
|
25
|
+
graphite/doctor_probes.py,sha256=VVVSJumkSDuDRyQwIz_WGNGOuf1FV8XxyAhcpB9Tzq8,100491
|
|
26
26
|
graphite/engine_identity.py,sha256=fXyc7hMFayqDzeIq_NzOtAkK6N1D8U2Rz8-H7CQuD10,12395
|
|
27
27
|
graphite/freshness.py,sha256=Rr3h0xxuD-GN83ESa_8GFpZZBB-2cdmyk_ULALbrlig,7892
|
|
28
28
|
graphite/git.py,sha256=3dWIVVBkEKK8IPIYx_vfAL6E6Syk26RSv_LONUQ7FpI,16047
|
|
@@ -32,8 +32,8 @@ graphite/health.py,sha256=Sh8P6_RvEBaFeICUbhncqw5I-Nlge9ASTkQpxSUtKfs,5525
|
|
|
32
32
|
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
|
-
graphite/incident_ledger.py,sha256=
|
|
36
|
-
graphite/ingest.py,sha256=
|
|
35
|
+
graphite/incident_ledger.py,sha256=fXL3seCIcBPexXlFhds9FeX_3svwo8qHfvca2NQFRiE,9748
|
|
36
|
+
graphite/ingest.py,sha256=ODpSYJ0wGtDpVlJ-gLiGU6AsofJTZmiaIjtRsZQj9R4,15899
|
|
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
|
|
@@ -45,7 +45,7 @@ graphite/mcp_server.py,sha256=fB3h1X91bkZ3rrLjT1HfA7MO2JIpIVfnFY5VinBx8IQ,19679
|
|
|
45
45
|
graphite/natural_query.py,sha256=3C-yAiTAUYAVlok2lWmfglB2501FTc39JmBfN_ndqdE,10790
|
|
46
46
|
graphite/overlays.py,sha256=iIsYh01l6Sfj3XxJi0eH9eD6YPib4J8S1Tlxe7v7NCM,26939
|
|
47
47
|
graphite/ownership.py,sha256=dAXStU4nH1X9nWPuaYZyoRFdJON3XpRXAfikg6usQBM,7072
|
|
48
|
-
graphite/probe_process.py,sha256=
|
|
48
|
+
graphite/probe_process.py,sha256=yR6HKnmnEqRCCwaET5r2DV0PIoCF6mEqxufANG4qCR4,44746
|
|
49
49
|
graphite/probe_workspace.py,sha256=ZadB6OHQlLeI_w_6LsLkrZjIcK7UQ4vSiausGySITzk,29527
|
|
50
50
|
graphite/process_contracts.py,sha256=ruqbZx6-9gfXPQvUFczg5KJedrcjbykEwRhb2Si3Vw8,1066
|
|
51
51
|
graphite/programs.py,sha256=VyYYMFSbSZUxcbhiIfZgZy8oUwSEMzLbqeyy6IBA9uU,7481
|
|
@@ -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.9.
|
|
117
|
-
graphite_code-1.9.
|
|
118
|
-
graphite_code-1.9.
|
|
119
|
-
graphite_code-1.9.
|
|
120
|
-
graphite_code-1.9.
|
|
116
|
+
graphite_code-1.9.4.dist-info/METADATA,sha256=obB3iKnIjKUbdyUly9oVR7FkOs8Qhvl2e8l7tp_Hm_M,48525
|
|
117
|
+
graphite_code-1.9.4.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
118
|
+
graphite_code-1.9.4.dist-info/entry_points.txt,sha256=-BpYAYFyn58DYi-hrFW9hMz6mTwNsYI44s9gaef4MiM,87
|
|
119
|
+
graphite_code-1.9.4.dist-info/licenses/LICENSE,sha256=mfotJ1Lk0VVUgoEPOIR7-x5cvYiz2UkuVH7e3fhoDiY,1066
|
|
120
|
+
graphite_code-1.9.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|