Graph Updates¶
akms.graph.update_graph
¶
update_graph.py — PCD/AgentMemory → Local State Mutations (§2.7 of system design).
Applies the persistent zone of Phase Completion Documents (or individual AgentMemories) to the graph. Pure algorithmic mutation with deterministic threshold-based dedup (token Jaccard + exact-id signal), no LLM calls.
Writes exclusively to local_state.yaml and local-nodes/ — never touches global node files.
Mutation pipeline
- Process nodes_used → confidence boost/decay + activations
- Propagate confidence hits to neighbors via edge weights
- Process pitfalls_discovered → local_edges
- Process new_knowledge → dedup check → local-nodes/
- Create session node entries
- Write local_state.yaml
- Call build_graph() to recompile graph.json
update_graph
¶
update_graph(
source: AgentMemory | PCD | dict,
repo_root: str | Path,
config: PropagationConfig | None = None,
global_vault: str | Path | None = None,
recompile: bool = True,
) -> dict
Apply persistent zone mutations from a PCD or AgentMemory to the graph.
This is the main entry point for Phase 4. It: 1. Loads the current compiled graph 2. Processes nodes_used → confidence mutations 3. Propagates decay to neighbors 4. Processes pitfalls → local_edges 5. Creates session node entry 6. Processes new_knowledge → local-nodes/ 7. Writes local_state.yaml 8. Recompiles graph.json via build_graph()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
AgentMemory | PCD | dict
|
AgentMemory, PCD, or persistent zone dict. |
required |
repo_root
|
str | Path
|
Path to the repository root. |
required |
config
|
PropagationConfig | None
|
PropagationConfig (loads from file or uses defaults if None). |
None
|
global_vault
|
str | Path | None
|
Override path to global vault. |
None
|
recompile
|
bool
|
Whether to call build_graph() after mutations. Default True. |
True
|
Returns:
| Type | Description |
|---|---|
dict
|
Dict with mutation summary: |
dict
|
{ "confidence_events": [...], "propagation_events": [...], "pitfall_events": [...], "knowledge_events": [...], "session_node_id": str, |
dict
|
} |
Source code in packages/akms/src/akms/graph/update_graph.py
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 | |