zettelkasten.dashboard.backend.routes.projects¶
zettelkasten.dashboard.backend.routes.projects ¶
Project CRUD, connect, cross, project-graph, search, and framing routes.
Split out of the former flat routes.py; behaviour is unchanged.
ProjectDrilldownRequest ¶
Bases: BaseModel
POST body for a project drill (Approach B: membership in the payload).
Source code in zettelkasten/dashboard/backend/routes/projects.py
get_federation ¶
Configured federated repos plus non-fatal validation errors.
The UI uses this to group/badge federated (read-only) graphs and to surface
misconfigured repos. Federation is configured by hand-editing a
federated_repos list in .zettelkasten/config.yaml.
Source code in zettelkasten/dashboard/backend/routes/projects.py
create_project_route ¶
Create a new LOCAL project, optionally as the UNION of selected source graphs and/or existing projects.
sources/cross are taken verbatim; each id in projects is resolved
to its manifest and its sources/cross folded in. Every ref must be
LOCAL — a federated (repo:-namespaced) ref is rejected up front, because
there is no federated write path and a union can only be written to the local
store. De-duplication is order-stable (first occurrence wins). Mirrors the MCP
create_project tool: a slug collision maps to 409, an invalid name to 400.
Source code in zettelkasten/dashboard/backend/routes/projects.py
connect_project ¶
Connect a project's sources to one another (LOCAL-only).
A freshly-unioned project has no edges between its newly-combined sources — this creates cross-source structure. Two modes:
mesh: author directrelatededges between semantically similar notes from different sources (dense mesh). Fully previewable viadry_runand reversible (every edge is stampedorigin='link-mesh').hubs: concept-hub synthesis.dry_runreturns cross-source cluster suggestions; apply mints one landscape_crosshub pernew_hubcluster (idempotent, ownership-safe viamaterialize_theme).
Federated (read-only) projects and the global write barrier are refused up front, exactly like every other project write.
Source code in zettelkasten/dashboard/backend/routes/projects.py
project_signature ¶
Stable, process-independent signature of a project's SOURCE files.
Folds in exactly the inputs the project graph/cluster payloads derive from —
each real source box's note-mtime fingerprint (:func:_graph_signature), the
_cross box, each source's _meta.yaml (:func:_meta_signature), the
global _citations store (:func:_citations_signature), and the project
manifest — reduced with the process-INDEPENDENT digests (:func:_sig_digest /
:func:_stable_int) so identical content yields the same token on every run
and across machines (mirrors the reasoning in :func:_sig_digest). Unlike the
route's in-memory cache key (which uses salted hash() and reads
_graph_sigs populated by a structural load), this computes the per-box
fingerprint DIRECTLY from the box directory — pure glob+stat, no note parsing —
so the dashboard can check bundle freshness without touching the native path.
Returns None for an unknown/unsafe project.
Source code in zettelkasten/dashboard/backend/routes/projects.py
build_project_bundle_payload ¶
Assemble the durable bundle payload for name (structure + layouts).
Force-warms each source box's embedding index in THIS process (eager load →
parse + embed + persist .kgl) so the cluster build below produces a real
layout instead of deferring with embeddings_status="warming". Then
assembles the full composite structure (max_nodes=0) and the base + fine
semantic layouts (t-SNE + clustering). Synchronous and native-heavy: run in a
worker subprocess / at write time, NEVER on the web request thread.
Returns {"structure", "layout", "granularities"} (layout is None
when the embedding stack is unavailable, so the reader still gets a re-parse-
free structure), or None for an unknown/unsafe project.
Source code in zettelkasten/dashboard/backend/routes/projects.py
load_fresh_project_bundle ¶
Return (bundle, signature) for name IFF a bundle built from the
CURRENT sources exists on disk, else None.
The web request-path entry point for serving a project from its pre-built
bundle. Cheap and native-free: computes the stable source signature
(:func:project_signature — pure glob+stat, no note parse) and reads the
signature-gated bundle. A None result (no bundle, or one built from now-
stale sources) means the caller falls through to the live assembly/compute —
the bundle is a pure accelerator, never a source of truth.
Source code in zettelkasten/dashboard/backend/routes/projects.py
get_project_graph ¶
get_project_graph(name: str, max_nodes: int = Query(0, ge=0, description='LOD cap: 0 = full graph; >0 keeps the top-N note nodes by link_count and collapses the rest (source/subsource hubs always pinned)'), bbox: str = Query(None, description="Viewport bbox 'x0,y0,x1,y1' in t-SNE space; with max_nodes>0, on-screen notes are kept in full detail (server-side viewport LOD)"), exclude_types: str = Query(None, description="Comma-separated note types to omit from the payload + LOD (e.g. 'quote'); they stay reachable via the note-detail API"), request: Request = None, response: Response = None) -> dict
Returns composite graph data for a project: nodes from all sources + cross + citations.
Source code in zettelkasten/dashboard/backend/routes/projects.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 | |
get_project_drilldown ¶
get_project_drilldown(name: str, group_id: str = Query(..., description='The super-node id (or its group_id) to drill into'), member_ids: 'list[str] | None' = Query(None, description="Approach B: the drilled glyph's exact build-time member id set (from the LOD payload), so drill resolution needs no server store. Prefer the POST route for large sets."), request: Request = None, response: Response = None) -> dict
Recursive drill-down for a project-graph LOD super-node.
Given a collapsed super-node's id, returns that group's CONNECTED sub-graph:
its member notes PLUS their REAL edges (inter-member connectivity preserved,
never stripped), re-clustered into finer semantic sub-supers at the next
granularity tier — or the real members when the group is small / cannot
subdivide (leaf=True). Degrades to an empty sub-graph while embeddings are
warming (semantic grouping needs the cluster map).
When member_ids is supplied (Approach B) membership resolves directly from
that set with no server-side store lookup; otherwise it degrades to the
store/live re-derivation for back-compat with old clients.
Source code in zettelkasten/dashboard/backend/routes/projects.py
post_project_drilldown ¶
post_project_drilldown(name: str, req: ProjectDrilldownRequest, request: Request = None, response: Response = None) -> dict
POST twin of :func:get_project_drilldown — carries the glyph's member_ids
in the body (preferred for large member sets that would bloat a query string).
Source code in zettelkasten/dashboard/backend/routes/projects.py
add_project_cross ¶
Claim a _cross note for a project (append to its cross: list).
Explicit, curated membership — the same note id may be claimed by several projects (one physical note, many references). LOCAL-ONLY; idempotent.
Source code in zettelkasten/dashboard/backend/routes/projects.py
remove_project_cross ¶
Release a _cross note from a project's cross: list (LOCAL-ONLY).
Removes only this project's reference; the note and every other project's claim on it are untouched. Idempotent.
Source code in zettelkasten/dashboard/backend/routes/projects.py
project_search ¶
Hybrid search across all sources in a project.
Fuses a semantic (embedding cosine) ranking with a keyword ranking via Reciprocal Rank Fusion, so exact term matches surface even when their embedding similarity is modest.
Source code in zettelkasten/dashboard/backend/routes/projects.py
1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 | |
frame_question ¶
Reframe the corpus along a research question (read-only lens).
Decomposes the question into facets (landscape hubs or caller-supplied),
projects the relevant notes per facet, labels each established/contested/
thin, and bundles per-facet citations. Mirrors the MCP frame_question.
Source code in zettelkasten/dashboard/backend/routes/projects.py
frame_answer ¶
Optional LLM-synthesized narrative answer over a frame (dashboard-only).
Recomputes the deterministic frame for the same request params (so the
grounding evidence and cache signature are derived server-side), then layers a
short grounded paragraph via :mod:zettelkasten.frame_answer. Returns
{"answer": str | None} — null when no LLM is configured or the frame
has no established/contested facet, so the UI simply renders no paragraph. The
MCP frame_question tool is intentionally left answer-free.
Source code in zettelkasten/dashboard/backend/routes/projects.py
frame_spine_suggest ¶
Propose a NEW spine (comparison matrix) seeded by a frame — READ-ONLY.
Recomputes the deterministic frame for the same request params (so the
grounding is derived server-side, never trusting a client-supplied frame),
then assembles a write-free spine PROPOSAL via
:mod:zettelkasten.spine_suggest: candidate rows from the frame's facets/hubs
and the suggest kind=structure clusters, dimension columns drafted from
the question by a tool-free LLM (deterministic fallback when none), thin
facets as gaps, plus a schema spec validated write-free. Phase 1 only
PROPOSES — it does not reorganize notes or extract. Returns
{"proposal", "validated_spec", "valid"}.
Source code in zettelkasten/dashboard/backend/routes/projects.py
frame_spine_create ¶
Materialize a spine by REORGANIZING existing notes (Phase 2 — WRITE).
Recomputes the deterministic frame server-side (exactly like
/frame/spine-suggest), runs :func:spine_suggest.suggest_spine to get the
write-free proposal, then BUILDS the spine by reusing the existing org
machinery — no bespoke edge-writer, no grounded extraction in the default
path:
- Resolve every proposal row's members to
{note_id, graph}(facet rows via the frame evidence source graph; cluster rows via title→id resolution over the named source graphs). Unresolvable members are dropped. - :func:
organizations.save_organizationa lens org from the proposal, keyed on a stableorg_idderived from the question+project (the idempotency guard — a repeat click re-promotes the same org). - Attach each row's resolved members to the FIRST column's cell and
:func:
organizations.promote_organization— the ONLY edge-writer, idempotent (reconcile-based) so a re-promote reuses the samespine_ref. - When
extractis true, ADDITIONALLY re-classify the already-attached notes into the spine's dimension cells across the SAME multi-row grid (:func:_enrich_grid_dimensionsover :func:remine.build_classify_fn) and re-promote the FULL enriched grid — every reorganize row hub is preserved, only dimension membership among EXISTING notes is added. This reuses the re-mine classifier without the single-row :func:remine.backfill_spinecollapse, and never reads source documents.
LOCAL-ONLY: federated (read-only) owners and the global ZK_DISABLE_WRITE
barrier are refused up front (mirrors _spine_write_guard). Returns the
created spine reference so the frontend can navigate to it.
Source code in zettelkasten/dashboard/backend/routes/projects.py
1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 | |