R6 class for managing persistent project memory using SQLite. Stores code snippets, error fixes, and execution graphs for resuming failed long-running jobs.
db_pathPath to the SQLite database file.
project_rootRoot directory of the project.
new()Create or connect to a project memory database.
ProjectMemory$new(project_root = tempdir(), db_name = "memory.sqlite")project_rootProject root directory. Defaults to tempdir().
db_nameDatabase filename. Defaults to "memory.sqlite".
A new ProjectMemory object.
store_snippet()Store a successful code snippet for future reference.
ProjectMemory$store_snippet(
code,
description = NULL,
tags = NULL,
context = NULL
)codeThe R code that was executed successfully.
descriptionOptional description of what the code does.
tagsOptional character vector of tags for categorization.
contextOptional context about when/why this code was used.
The ID of the stored snippet.
store_fix()Store an error fix for learning.
ProjectMemory$store_fix(
original_code,
error,
fixed_code,
fix_description = NULL
)original_codeThe code that produced the error.
errorThe error message.
fixed_codeThe corrected code.
fix_descriptionDescription of what was fixed.
The ID of the stored fix.
find_similar_fix()Find a similar fix from memory.
ProjectMemory$find_similar_fix(error)errorThe error message to match.
A list with the fix details, or NULL if not found.
search_snippets()Search for relevant code snippets.
ProjectMemory$search_snippets(query, limit = 10)querySearch query (matches description, tags, or code).
limitMaximum number of results.
A data frame of matching snippets.
store_workflow_node()Store execution graph node for workflow persistence.
ProjectMemory$store_workflow_node(
workflow_id,
node_id,
node_type,
code,
status = "pending",
result = NULL,
dependencies = NULL
)workflow_idUnique identifier for the workflow.
node_idUnique identifier for this node.
node_typeType of node (e.g., "transform", "model", "output").
codeThe code for this node.
statusNode status ("pending", "running", "completed", "failed").
resultOptional serialized result.
dependenciesCharacter vector of node IDs this depends on.
The database row ID.
update_node_status()Update workflow node status.
ProjectMemory$update_node_status(workflow_id, node_id, status, result = NULL)workflow_idWorkflow identifier.
node_idNode identifier.
statusNew status.
resultOptional result to store.
get_workflow()Get workflow state for resuming.
ProjectMemory$get_workflow(workflow_id)workflow_idWorkflow identifier.
A list with workflow nodes and their states.
get_resumable_nodes()Resume a failed workflow from the last successful point.
ProjectMemory$get_resumable_nodes(workflow_id)workflow_idWorkflow identifier.
List of node IDs that need to be re-executed.
store_conversation()Store a conversation turn for context.
ProjectMemory$store_conversation(session_id, role, content, metadata = NULL)session_idSession identifier.
roleMessage role ("user", "assistant", "system").
contentMessage content.
metadataOptional metadata list.
get_conversation()Get conversation history for a session.
ProjectMemory$get_conversation(session_id, limit = 100)session_idSession identifier.
limitMaximum number of messages.
A data frame of conversation messages.
store_review()Store or update a human review for an AI-generated chunk.
ProjectMemory$store_review(
chunk_id,
file_path,
chunk_label,
prompt,
response,
status = "pending",
ai_agent = NULL,
uncertainty = NULL,
session_id = NULL,
review_mode = NULL,
runtime_mode = NULL,
artifact_json = NULL,
execution_status = NULL,
execution_output = NULL,
final_code = NULL,
error_message = NULL
)chunk_idUnique identifier for the chunk.
file_pathPath to the source file.
chunk_labelChunk label from knitr.
promptThe prompt sent to the AI.
responseThe AI's response.
statusReview status ("pending", "approved", "rejected").
ai_agentOptional agent name.
uncertaintyOptional uncertainty level.
session_idOptional session identifier for transcript/provenance.
review_modeOptional normalized review mode.
runtime_modeOptional normalized runtime mode.
artifact_jsonOptional JSON review artifact payload.
execution_statusOptional execution state.
execution_outputOptional execution output text.
final_codeOptional finalized executable code.
error_messageOptional execution or generation error.
The database row ID.
store_review_artifact()Store structured review artifact metadata for a chunk.
ProjectMemory$store_review_artifact(
chunk_id,
artifact,
session_id = NULL,
review_mode = NULL,
runtime_mode = NULL
)chunk_idChunk identifier.
artifactA serializable list representing the review artifact.
session_idOptional session identifier.
review_modeOptional normalized review mode.
runtime_modeOptional normalized runtime mode.
Invisible TRUE.
get_review()Get a review by chunk ID.
ProjectMemory$get_review(chunk_id)chunk_idChunk identifier.
A list with review details, or NULL if not found.
get_review_artifact()Get a parsed review artifact by chunk ID.
ProjectMemory$get_review_artifact(chunk_id)chunk_idChunk identifier.
A list artifact, or NULL if none is stored.
get_review_runtime_record()Get a review together with its parsed artifact.
ProjectMemory$get_review_runtime_record(chunk_id)chunk_idChunk identifier.
A list with review and artifact, or NULL if not found.
get_reviews_for_file()Get all reviews for a given source file.
ProjectMemory$get_reviews_for_file(file_path)file_pathSource document path.
A data frame of reviews ordered by updated time.
record_review_saveback()Record a saveback lifecycle event for one or more chunk reviews.
ProjectMemory$record_review_saveback(
chunk_ids,
source_path,
html_path = NULL,
status = "requested",
rerendered = FALSE,
message = NULL
)chunk_idsCharacter vector of chunk identifiers.
source_pathSource document path.
html_pathOptional rendered HTML path.
statusSaveback status string.
rerenderedWhether a rerender occurred.
messageOptional message.
Invisible TRUE.
update_execution_result()Update execution result fields for a chunk review.
ProjectMemory$update_execution_result(
chunk_id,
execution_status,
execution_output = NULL,
final_code = NULL,
error_message = NULL
)chunk_idChunk identifier.
execution_statusExecution state string.
execution_outputOptional execution output text.
final_codeOptional finalized executable code.
error_messageOptional execution error.
Invisible TRUE.
append_review_event()Append an audit event for a reviewed chunk.
ProjectMemory$append_review_event(chunk_id, event_type, payload = NULL)chunk_idChunk identifier.
event_typeEvent type string.
payloadOptional serializable payload list.
The database row ID.
update_review_status()Update review status.
ProjectMemory$update_review_status(chunk_id, status)chunk_idChunk identifier.
statusNew status ("approved" or "rejected").
get_pending_reviews()Get pending reviews, optionally filtered by file.
ProjectMemory$get_pending_reviews(file_path = NULL)file_pathOptional file path filter.
A data frame of pending reviews.
stats()Get memory statistics.
ProjectMemory$stats()A list with counts and sizes.
clear()Clear all memory (use with caution).
ProjectMemory$clear(confirm = FALSE)confirmMust be TRUE to proceed.
clone()The objects of this class are cloneable with this method.
ProjectMemory$clone(deep = FALSE)deepWhether to make a deep clone.