graphfakos 0.0.1__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.
- graphfakos/__init__.py +75 -0
- graphfakos/__main__.py +17 -0
- graphfakos/adapters/__init__.py +8 -0
- graphfakos/adapters/fixture.py +166 -0
- graphfakos/cli.py +152 -0
- graphfakos/contracts.py +35 -0
- graphfakos/models.py +304 -0
- graphfakos/provider.py +96 -0
- graphfakos/py.typed +1 -0
- graphfakos/render.py +12 -0
- graphfakos/server.py +102 -0
- graphfakos/static.py +43 -0
- graphfakos/testing/__init__.py +7 -0
- graphfakos/testing/assertions.py +25 -0
- graphfakos/ui/__init__.py +9 -0
- graphfakos/ui/app.py +1280 -0
- graphfakos-0.0.1.dist-info/METADATA +233 -0
- graphfakos-0.0.1.dist-info/RECORD +22 -0
- graphfakos-0.0.1.dist-info/WHEEL +5 -0
- graphfakos-0.0.1.dist-info/entry_points.txt +4 -0
- graphfakos-0.0.1.dist-info/licenses/LICENSE +201 -0
- graphfakos-0.0.1.dist-info/top_level.txt +1 -0
graphfakos/__init__.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Reusable graph lens for agent memory and source knowledge graphs."""
|
|
2
|
+
|
|
3
|
+
from .adapters import FixtureGraphProvider, build_fixture_graph
|
|
4
|
+
from .models import (
|
|
5
|
+
GraphFakosCitation,
|
|
6
|
+
GraphFakosDiagnostics,
|
|
7
|
+
GraphFakosEdge,
|
|
8
|
+
GraphFakosGraph,
|
|
9
|
+
GraphFakosNode,
|
|
10
|
+
GraphFakosProvenance,
|
|
11
|
+
GraphFakosRequest,
|
|
12
|
+
GraphFakosScreen,
|
|
13
|
+
GraphFakosVisual,
|
|
14
|
+
)
|
|
15
|
+
from .provider import (
|
|
16
|
+
GraphFakosProvider,
|
|
17
|
+
diagnose_graph,
|
|
18
|
+
load_provider_graph,
|
|
19
|
+
validate_graph,
|
|
20
|
+
)
|
|
21
|
+
from .server import (
|
|
22
|
+
LocalViewerHttpServer,
|
|
23
|
+
LocalViewerServerResult,
|
|
24
|
+
RenderPath,
|
|
25
|
+
make_local_viewer_server,
|
|
26
|
+
serve_local_viewer,
|
|
27
|
+
)
|
|
28
|
+
from .static import render_static_html, write_static_html
|
|
29
|
+
from .ui import render_graph_viewer, render_provider_path, screen_manifest
|
|
30
|
+
|
|
31
|
+
__version__ = "0.0.1"
|
|
32
|
+
PACKAGE_STATUS = "semantic-alpha"
|
|
33
|
+
STABLE_IMPORT_ROOTS = (
|
|
34
|
+
"graphfakos",
|
|
35
|
+
"graphfakos.adapters",
|
|
36
|
+
"graphfakos.contracts",
|
|
37
|
+
"graphfakos.models",
|
|
38
|
+
"graphfakos.provider",
|
|
39
|
+
"graphfakos.render",
|
|
40
|
+
"graphfakos.server",
|
|
41
|
+
"graphfakos.static",
|
|
42
|
+
"graphfakos.testing",
|
|
43
|
+
"graphfakos.ui",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"PACKAGE_STATUS",
|
|
48
|
+
"STABLE_IMPORT_ROOTS",
|
|
49
|
+
"__version__",
|
|
50
|
+
"FixtureGraphProvider",
|
|
51
|
+
"GraphFakosCitation",
|
|
52
|
+
"GraphFakosDiagnostics",
|
|
53
|
+
"GraphFakosEdge",
|
|
54
|
+
"GraphFakosGraph",
|
|
55
|
+
"GraphFakosNode",
|
|
56
|
+
"GraphFakosProvider",
|
|
57
|
+
"GraphFakosProvenance",
|
|
58
|
+
"GraphFakosRequest",
|
|
59
|
+
"GraphFakosScreen",
|
|
60
|
+
"GraphFakosVisual",
|
|
61
|
+
"LocalViewerHttpServer",
|
|
62
|
+
"LocalViewerServerResult",
|
|
63
|
+
"RenderPath",
|
|
64
|
+
"build_fixture_graph",
|
|
65
|
+
"diagnose_graph",
|
|
66
|
+
"load_provider_graph",
|
|
67
|
+
"make_local_viewer_server",
|
|
68
|
+
"render_graph_viewer",
|
|
69
|
+
"render_provider_path",
|
|
70
|
+
"render_static_html",
|
|
71
|
+
"screen_manifest",
|
|
72
|
+
"serve_local_viewer",
|
|
73
|
+
"validate_graph",
|
|
74
|
+
"write_static_html",
|
|
75
|
+
]
|
graphfakos/__main__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""GraphFakos module entrypoint."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
from .cli import main, ui_preview_main
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _dispatch(argv: list[str]) -> int:
|
|
11
|
+
if argv and argv[0] == "ui-preview":
|
|
12
|
+
return ui_preview_main(argv[1:])
|
|
13
|
+
return main(argv)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
if __name__ == "__main__":
|
|
17
|
+
raise SystemExit(_dispatch(sys.argv[1:]))
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""Fake third-party provider used by tests and examples."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from graphfakos.models import (
|
|
6
|
+
GraphFakosCitation,
|
|
7
|
+
GraphFakosEdge,
|
|
8
|
+
GraphFakosGraph,
|
|
9
|
+
GraphFakosNode,
|
|
10
|
+
GraphFakosProvenance,
|
|
11
|
+
GraphFakosRequest,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def build_fixture_graph(request: GraphFakosRequest | None = None) -> GraphFakosGraph:
|
|
16
|
+
request = request or GraphFakosRequest()
|
|
17
|
+
provenance = (
|
|
18
|
+
GraphFakosProvenance(
|
|
19
|
+
id="prov:fixture",
|
|
20
|
+
provider_id="fixture",
|
|
21
|
+
source_type="third_party",
|
|
22
|
+
source_label="Fixture provider",
|
|
23
|
+
excerpt="Synthetic graph for provider contract tests.",
|
|
24
|
+
observed_at="2026-06-22T00:00:00+00:00",
|
|
25
|
+
confidence=1.0,
|
|
26
|
+
),
|
|
27
|
+
)
|
|
28
|
+
citations = (
|
|
29
|
+
GraphFakosCitation(
|
|
30
|
+
id="cite:fixture-readme",
|
|
31
|
+
label="Fixture README",
|
|
32
|
+
path="README.md",
|
|
33
|
+
line=1,
|
|
34
|
+
excerpt="Fixture graph source.",
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
nodes = (
|
|
38
|
+
GraphFakosNode(
|
|
39
|
+
id="memory:operator-preference",
|
|
40
|
+
label="Operator Preference",
|
|
41
|
+
kind="memory",
|
|
42
|
+
summary="The operator prefers copyable local validation commands.",
|
|
43
|
+
tags=("preference", "memory"),
|
|
44
|
+
score=0.98,
|
|
45
|
+
source="fixture",
|
|
46
|
+
provenance_ids=("prov:fixture",),
|
|
47
|
+
citation_ids=("cite:fixture-readme",),
|
|
48
|
+
),
|
|
49
|
+
GraphFakosNode(
|
|
50
|
+
id="document:viewer-spec",
|
|
51
|
+
label="Viewer Spec",
|
|
52
|
+
kind="document",
|
|
53
|
+
summary="Graph viewer requirements for package integration.",
|
|
54
|
+
tags=("document", "viewer"),
|
|
55
|
+
source="fixture",
|
|
56
|
+
provenance_ids=("prov:fixture",),
|
|
57
|
+
),
|
|
58
|
+
GraphFakosNode(
|
|
59
|
+
id="artifact:static-export",
|
|
60
|
+
label="Static Export",
|
|
61
|
+
kind="artifact",
|
|
62
|
+
summary="Portable HTML export generated by GraphFakos.",
|
|
63
|
+
tags=("artifact", "html"),
|
|
64
|
+
source="fixture",
|
|
65
|
+
),
|
|
66
|
+
GraphFakosNode(
|
|
67
|
+
id="provider:third-party",
|
|
68
|
+
label="Third-party Provider",
|
|
69
|
+
kind="provider",
|
|
70
|
+
summary="Provider implementing the GraphFakos protocol.",
|
|
71
|
+
tags=("provider", "third_party"),
|
|
72
|
+
source="fixture",
|
|
73
|
+
),
|
|
74
|
+
)
|
|
75
|
+
edges = (
|
|
76
|
+
GraphFakosEdge(
|
|
77
|
+
id="edge:preference-supports-spec",
|
|
78
|
+
source_id="memory:operator-preference",
|
|
79
|
+
target_id="document:viewer-spec",
|
|
80
|
+
kind="supports",
|
|
81
|
+
label="supports",
|
|
82
|
+
confidence=0.9,
|
|
83
|
+
provenance_ids=("prov:fixture",),
|
|
84
|
+
),
|
|
85
|
+
GraphFakosEdge(
|
|
86
|
+
id="edge:spec-produces-export",
|
|
87
|
+
source_id="document:viewer-spec",
|
|
88
|
+
target_id="artifact:static-export",
|
|
89
|
+
kind="produces",
|
|
90
|
+
label="produces",
|
|
91
|
+
confidence=0.85,
|
|
92
|
+
),
|
|
93
|
+
GraphFakosEdge(
|
|
94
|
+
id="edge:provider-serves-spec",
|
|
95
|
+
source_id="provider:third-party",
|
|
96
|
+
target_id="document:viewer-spec",
|
|
97
|
+
kind="serves",
|
|
98
|
+
label="serves",
|
|
99
|
+
confidence=0.88,
|
|
100
|
+
),
|
|
101
|
+
GraphFakosEdge(
|
|
102
|
+
id="edge:provider-serves-export",
|
|
103
|
+
source_id="provider:third-party",
|
|
104
|
+
target_id="artifact:static-export",
|
|
105
|
+
kind="serves",
|
|
106
|
+
label="serves",
|
|
107
|
+
confidence=0.82,
|
|
108
|
+
),
|
|
109
|
+
)
|
|
110
|
+
return GraphFakosGraph(
|
|
111
|
+
graph_id="fixture",
|
|
112
|
+
label="Fixture Knowledge Graph",
|
|
113
|
+
provider_id="fixture",
|
|
114
|
+
provider_label="Fixture Provider",
|
|
115
|
+
graph_role="third_party",
|
|
116
|
+
capabilities=(
|
|
117
|
+
"search",
|
|
118
|
+
"neighborhood",
|
|
119
|
+
"path",
|
|
120
|
+
"provenance",
|
|
121
|
+
"provider_status",
|
|
122
|
+
"static_export",
|
|
123
|
+
"local_preview",
|
|
124
|
+
),
|
|
125
|
+
nodes=nodes,
|
|
126
|
+
edges=edges,
|
|
127
|
+
provenance=provenance,
|
|
128
|
+
citations=citations,
|
|
129
|
+
warnings=(),
|
|
130
|
+
stats={"request_screen": request.screen, "node_count": len(nodes)},
|
|
131
|
+
generated_at="2026-06-22T00:00:00+00:00",
|
|
132
|
+
provider_payload={
|
|
133
|
+
"integration_summary": (
|
|
134
|
+
"This fixture shows how a package-local provider can publish "
|
|
135
|
+
"viewer-ready graph DTOs without importing any host runtime."
|
|
136
|
+
),
|
|
137
|
+
"integration_commands": (
|
|
138
|
+
"graphfakos-ui --screen explore --html-out graphfakos-ui-preview.html --json",
|
|
139
|
+
"graphfakos-ui --screen provider_status --serve --open",
|
|
140
|
+
),
|
|
141
|
+
},
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class FixtureGraphProvider:
|
|
146
|
+
provider_id = "fixture"
|
|
147
|
+
provider_label = "Fixture Provider"
|
|
148
|
+
graph_role = "third_party"
|
|
149
|
+
capabilities = (
|
|
150
|
+
"search",
|
|
151
|
+
"neighborhood",
|
|
152
|
+
"path",
|
|
153
|
+
"provenance",
|
|
154
|
+
"provider_status",
|
|
155
|
+
"static_export",
|
|
156
|
+
"local_preview",
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
def load_graph(self, request: GraphFakosRequest) -> GraphFakosGraph:
|
|
160
|
+
return build_fixture_graph(request)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
__all__ = [
|
|
164
|
+
"FixtureGraphProvider",
|
|
165
|
+
"build_fixture_graph",
|
|
166
|
+
]
|
graphfakos/cli.py
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"""Command-line entrypoints for GraphFakos."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
|
|
8
|
+
from .adapters import FixtureGraphProvider
|
|
9
|
+
from .models import GraphFakosRequest, GraphFakosScreen
|
|
10
|
+
from .server import serve_local_viewer
|
|
11
|
+
from .static import write_static_html
|
|
12
|
+
from .ui import render_provider_path
|
|
13
|
+
|
|
14
|
+
_SCREENS: tuple[GraphFakosScreen, ...] = (
|
|
15
|
+
"explore",
|
|
16
|
+
"neighborhood",
|
|
17
|
+
"path",
|
|
18
|
+
"provenance",
|
|
19
|
+
"timeline",
|
|
20
|
+
"provider_status",
|
|
21
|
+
"context_preview",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def smoke_payload() -> dict[str, object]:
|
|
26
|
+
return {
|
|
27
|
+
"package": "graphfakos",
|
|
28
|
+
"version": "0.0.1",
|
|
29
|
+
"status": "semantic-alpha",
|
|
30
|
+
"semantic_contract": True,
|
|
31
|
+
"openminion_imports": False,
|
|
32
|
+
"stable_import_roots": [
|
|
33
|
+
"graphfakos",
|
|
34
|
+
"graphfakos.adapters",
|
|
35
|
+
"graphfakos.contracts",
|
|
36
|
+
"graphfakos.models",
|
|
37
|
+
"graphfakos.provider",
|
|
38
|
+
"graphfakos.render",
|
|
39
|
+
"graphfakos.server",
|
|
40
|
+
"graphfakos.static",
|
|
41
|
+
"graphfakos.testing",
|
|
42
|
+
"graphfakos.ui",
|
|
43
|
+
],
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _request_from_args(args: argparse.Namespace) -> GraphFakosRequest:
|
|
48
|
+
filters = {
|
|
49
|
+
key: value
|
|
50
|
+
for key, value in {
|
|
51
|
+
"node_kind": args.node_kind,
|
|
52
|
+
"edge_kind": args.edge_kind,
|
|
53
|
+
"tag": args.tag,
|
|
54
|
+
"source": args.source,
|
|
55
|
+
"min_score": args.min_score,
|
|
56
|
+
}.items()
|
|
57
|
+
if value not in (None, "")
|
|
58
|
+
}
|
|
59
|
+
return GraphFakosRequest(
|
|
60
|
+
screen=args.screen,
|
|
61
|
+
query=args.query,
|
|
62
|
+
focus_node_id=args.focus_node_id,
|
|
63
|
+
selected_edge_id=args.selected_edge_id,
|
|
64
|
+
source_node_id=args.source_node_id,
|
|
65
|
+
target_node_id=args.target_node_id,
|
|
66
|
+
max_depth=args.max_depth,
|
|
67
|
+
filters=filters,
|
|
68
|
+
layout=args.layout,
|
|
69
|
+
limit=args.limit,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _print_payload(payload: object, *, as_json: bool) -> None:
|
|
74
|
+
if as_json:
|
|
75
|
+
print(json.dumps(payload, sort_keys=True))
|
|
76
|
+
return
|
|
77
|
+
print(payload)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def ui_preview_main(argv: list[str] | None = None) -> int:
|
|
81
|
+
parser = argparse.ArgumentParser(description="GraphFakos local graph viewer")
|
|
82
|
+
parser.add_argument("--screen", choices=_SCREENS, default="explore")
|
|
83
|
+
parser.add_argument("--query", default="")
|
|
84
|
+
parser.add_argument("--focus-node-id")
|
|
85
|
+
parser.add_argument("--selected-edge-id")
|
|
86
|
+
parser.add_argument("--source-node-id")
|
|
87
|
+
parser.add_argument("--target-node-id")
|
|
88
|
+
parser.add_argument("--max-depth", type=int, default=1)
|
|
89
|
+
parser.add_argument("--node-kind", default="")
|
|
90
|
+
parser.add_argument("--edge-kind", default="")
|
|
91
|
+
parser.add_argument("--tag", default="")
|
|
92
|
+
parser.add_argument("--source", default="")
|
|
93
|
+
parser.add_argument("--min-score", default="")
|
|
94
|
+
parser.add_argument("--layout", default="force")
|
|
95
|
+
parser.add_argument("--limit", type=int, default=25)
|
|
96
|
+
parser.add_argument("--html-out", default="graphfakos-ui-preview.html")
|
|
97
|
+
parser.add_argument("--serve", action="store_true")
|
|
98
|
+
parser.add_argument("--open", action="store_true")
|
|
99
|
+
parser.add_argument("--host", default="127.0.0.1")
|
|
100
|
+
parser.add_argument("--port", type=int, default=8767)
|
|
101
|
+
parser.add_argument("--json", action="store_true")
|
|
102
|
+
args = parser.parse_args(argv)
|
|
103
|
+
|
|
104
|
+
provider = FixtureGraphProvider()
|
|
105
|
+
request = _request_from_args(args)
|
|
106
|
+
if args.serve:
|
|
107
|
+
result = serve_local_viewer(
|
|
108
|
+
render_path=lambda path, query: render_provider_path(
|
|
109
|
+
provider,
|
|
110
|
+
request,
|
|
111
|
+
path,
|
|
112
|
+
query,
|
|
113
|
+
),
|
|
114
|
+
default_path=f"/{request.screen}",
|
|
115
|
+
host=args.host,
|
|
116
|
+
port=args.port,
|
|
117
|
+
open_browser=args.open,
|
|
118
|
+
)
|
|
119
|
+
_print_payload(result.to_dict(), as_json=args.json)
|
|
120
|
+
return 0
|
|
121
|
+
|
|
122
|
+
payload = write_static_html(
|
|
123
|
+
provider,
|
|
124
|
+
request,
|
|
125
|
+
args.html_out,
|
|
126
|
+
open_browser=args.open,
|
|
127
|
+
)
|
|
128
|
+
graph = provider.load_graph(request)
|
|
129
|
+
payload.update(
|
|
130
|
+
{
|
|
131
|
+
"provider_id": graph.provider_id,
|
|
132
|
+
"node_count": len(graph.nodes),
|
|
133
|
+
"edge_count": len(graph.edges),
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
_print_payload(payload, as_json=args.json)
|
|
137
|
+
return 0
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def main(argv: list[str] | None = None) -> int:
|
|
141
|
+
parser = argparse.ArgumentParser(description="graphfakos package smoke")
|
|
142
|
+
parser.add_argument("--json", action="store_true")
|
|
143
|
+
args = parser.parse_args(argv)
|
|
144
|
+
_print_payload(smoke_payload(), as_json=args.json)
|
|
145
|
+
return 0
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
__all__ = [
|
|
149
|
+
"main",
|
|
150
|
+
"smoke_payload",
|
|
151
|
+
"ui_preview_main",
|
|
152
|
+
]
|
graphfakos/contracts.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Public provider contract exports for GraphFakos adapters."""
|
|
2
|
+
|
|
3
|
+
from .models import (
|
|
4
|
+
GraphFakosCitation,
|
|
5
|
+
GraphFakosDiagnostics,
|
|
6
|
+
GraphFakosEdge,
|
|
7
|
+
GraphFakosGraph,
|
|
8
|
+
GraphFakosNode,
|
|
9
|
+
GraphFakosProvenance,
|
|
10
|
+
GraphFakosRequest,
|
|
11
|
+
GraphFakosScreen,
|
|
12
|
+
GraphFakosVisual,
|
|
13
|
+
)
|
|
14
|
+
from .provider import (
|
|
15
|
+
GraphFakosProvider,
|
|
16
|
+
diagnose_graph,
|
|
17
|
+
load_provider_graph,
|
|
18
|
+
validate_graph,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"GraphFakosCitation",
|
|
23
|
+
"GraphFakosDiagnostics",
|
|
24
|
+
"GraphFakosEdge",
|
|
25
|
+
"GraphFakosGraph",
|
|
26
|
+
"GraphFakosNode",
|
|
27
|
+
"GraphFakosProvider",
|
|
28
|
+
"GraphFakosProvenance",
|
|
29
|
+
"GraphFakosRequest",
|
|
30
|
+
"GraphFakosScreen",
|
|
31
|
+
"GraphFakosVisual",
|
|
32
|
+
"diagnose_graph",
|
|
33
|
+
"load_provider_graph",
|
|
34
|
+
"validate_graph",
|
|
35
|
+
]
|