Reads trace entries from .rrlmgraph/task_trace.jsonl and/or the
task_traces table in the project's graph.sqlite database,
applies exponential decay with a 30-day half-life
\((w = 2^{-\Delta d / 30})\), and accumulates per-node weights
as \(\sum_i w_i \cdot (1 + \text{polarity}_i)\). The result is
min-max-normalised to \([0, 1]\) and stored in the
task_trace_weight vertex attribute.
Usage
update_task_weights(
graph,
useful_nodes = NULL,
alpha = 0.3,
decay = 0.99,
trace_file = NULL,
sqlite_path = NULL
)Arguments
- graph
An
rrlm_graph/igraphobject.- useful_nodes
Character vector of node names that were helpful in the current traversal. Also accepts
NULLorcharacter(0)to skip the EMA boost.- alpha
Numeric(1). EMA learning rate \((0, 1)\). Default
0.3. Used only for the in-memory EMA boost; ignored when trace data is present.- decay
Numeric(1). Multiplicative decay applied to all other nodes in the EMA fallback path. Default
0.99.- trace_file
Character(1) or
NULL. Explicit path to the JSONL file.NULL(default) infers the path from the"project_root"graph attribute.- sqlite_path
Character(1) or
NULL. Path to the SQLite database exported byexport_to_sqlite.NULL(default) infers the path as.rrlmgraph/graph.sqliteunder the project root. Set toNA_character_to skip SQLite lookup entirely.
Details
Reading from both sources ensures that traces written by the MCP server's
add_task_trace tool (which writes directly to SQLite) are
included alongside traces written by log_task_trace() (which
writes to JSONL).
When no trace data exists anywhere, falls back to the exponential
moving-average (EMA) stub so that query_context() can still
boost useful_nodes in memory.
Examples
if (FALSE) { # \dontrun{
g <- build_rrlm_graph("mypkg")
g <- update_task_weights(g, useful_nodes = c("pkg::load_data"))
} # }