Skip to main content

Module cooccurrence

Module cooccurrence 

Source
Expand description

Hebbian file co-access graph — “files that fire together, wire together”.

§The idea (neuroscience → retrieval)

Hebbian theory: synapses between co-active neurons strengthen (long-term potentiation, LTP), while unused ones weaken (long-term depression / the Ebbinghaus forgetting curve). We apply the same rule to files: whenever a task surfaces a set of files together, we strengthen the association between every pair; on each update all weights decay slightly, so stale associations fade. Over time the graph learns the project’s real working paths — which the static import/AST graph cannot capture.

The learned association is an additive retrieval signal: given a file the agent is looking at, related returns the files history says tend to be touched alongside it.

The store is a small per-project JSON file; reads/writes are whole-file and cheap because the graph is pruned aggressively (decay + min-weight + caps).

Structs§

CoAccessGraph
Persistent, decaying co-access graph for one project.

Functions§

export_edges
Canonical undirected co-access edges for project_root (strongest first), for dashboard overlay and graph folding. Empty when traversal edges are off.
load
Load the co-access graph for project_root (empty if none / unreadable).
record_access
Record that files were accessed together for one task, persisting the reinforced graph. No-op for fewer than two distinct files.
record_focus_access
Record a streaming co-access: the just-touched focus file against the recent working set others (star association). Paths are normalized to repo-relative. No-op when traversal edges are disabled or there is nothing to associate. Persisted.
record_set_access
Record that a set of files was surfaced together (e.g. search results) after normalizing to repo-relative. No-op when disabled or <2 distinct files.
related
Files historically co-accessed with file, strongest association first.
traversal_enabled
Whether traversal (co-access) edges are enabled ([graph] traversal_edges).