Skip to content

fix(ingestion): wire memory persistence contract into the ingestion hook - #612

Merged
jamiepine merged 3 commits into
spacedriveapp:mainfrom
rajpaulsingh6-stack:fix/ingestion-persistence-contract
Aug 8, 2026
Merged

fix(ingestion): wire memory persistence contract into the ingestion hook#612
jamiepine merged 3 commits into
spacedriveapp:mainfrom
rajpaulsingh6-stack:fix/ingestion-persistence-contract

Conversation

@rajpaulsingh6-stack

Copy link
Copy Markdown
Contributor

Fixes #611

Problem

process_chunk() in src/agent/ingestion.rs creates a MemoryPersistenceContractState and hands it to the branch tool server via BranchToolProfile::MemoryPersistence, but the SpacebotHook for the same run is built with SpacebotHook::new(...) only — the contract is never attached to the hook.

The hook's on_tool_result (src/hooks/spacebot.rs) is the only production caller of set_terminal_outcome, and it is guarded by let Some(contract_state) = &self.memory_persistence_contract. With the contract unset, that guard short-circuits on every ingestion run, so even a successful memory_persistence_complete tool call never registers. process_chunk then always fails its has_terminal_outcome() check with:

completed without memory_persistence_complete signal

The file is kept for retry, and the ingestion poll loop (default 30 s, no retry cap) retries it forever — indefinite repeated LLM calls for every ingested file.

Fix

Attach the contract to the hook, exactly as src/agent/branch.rs already does for chat-driven branches (hook = hook.with_memory_persistence_contract(contract_state.clone());):

let hook = hook.with_memory_persistence_contract(contract_state.clone());

One line, immediately after the SpacebotHook::new(...) call in process_chunk.

Verified on a production deployment running a patched v0.5.0 build: with this change, ingestion chunks complete, files are deleted after successful ingestion, and the retry loop no longer fires.

🤖 Generated with Claude Code

Without this, set_terminal_outcome is unreachable for ingestion chunks and every file fails "completed without memory_persistence_complete signal", retrying indefinitely.
…ream

Reverts an accidental edit introduced in the previous commit; the branch now differs from main only by the hook wiring line.
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b5949254-663c-4101-b586-dbc39c0c3bc5

📥 Commits

Reviewing files that changed from the base of the PR and between ac52277 and 95a37c2.

📒 Files selected for processing (1)
  • src/agent/ingestion.rs

Walkthrough

process_chunk now attaches the shared memory-persistence contract state to the ingestion SpacebotHook before the ingestion agent runs.

Changes

Ingestion memory contract

Layer / File(s) Summary
Attach contract state to ingestion hook
src/agent/ingestion.rs
process_chunk passes the shared memory-persistence contract state to SpacebotHook before processing the chunk.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the ingestion fix and the missing memory persistence contract wiring.
Description check ✅ Passed The description explains the ingestion failure, root cause, one-line fix, and expected retry behavior.
Linked Issues check ✅ Passed The change attaches the contract to the ingestion hook and directly addresses issue #611 requirements.
Out of Scope Changes check ✅ Passed The described changes are limited to the intended ingestion fix and restoration of an unrelated test edit.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jamiepine jamiepine left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-validated against repaired CI on current main (post-#617). Files verified disjoint from the rest of the merge batch.

@jamiepine
jamiepine merged commit 7f8c33f into spacedriveapp:main Aug 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ingestion: memory_persistence_complete signal never registers — every ingested file fails and retries indefinitely

2 participants