Repository navigation
Conversation
Add _enqueue_semantic_refresh_changes call to _write_memory_with_refresh,
matching the existing behavior in _write_direct_with_refresh for resources/skills.
Root cause: memory writes (viking_remember) never triggered semantic queue
processing because _write_memory_with_refresh only ran refresh_schema_overview
(generates .overview.md template) + refresh_file_embedding, but skipped
enqueueing semantic messages. This meant .abstract.md was never generated
for memory directories.
Fix: enqueue semantic refresh with changes={'added': [uri]} after embedding,
matching the resource/skill write path pattern.
Related to volcengine#2797, volcengine#4612
Migration Note: Existing memory directories need manual reindexThis fix only triggers semantic processing for new writes after the fix is deployed. Memory directories populated before the fix (e.g. from session commit/extraction) never had One-time reindex command# Get user key (root_key cannot access data APIs)
USER_KEY=$(curl -s -H \"X-API-Key: \$ROOT_KEY\" http://127.0.0.1:{port}/api/v1/admin/accounts/default/users | python -c \"import sys,json; users=json.load(sys.stdin)[\\\"result\\\"]; print([u[\\\"api_key\\\"] for u in users if u[\\\"user_id\\\"]==\\\"home\\\"][0])\")
# Reindex each memory directory
for dir in entities cases preferences events experiences skills tools trajectories; do
curl -s -X POST -H \"X-API-Key: \$USER_KEY\" -H \"Content-Type: application/json\" \
-d \"{\\\"uri\\\": \\\"viking://user/home/memories/\$dir\\\", \\\"mode\\\": \\\"semantic_and_vectors\\\"}\" \
http://127.0.0.1:{port}/api/v1/content/reindex
doneWhy manual reindex is neededThe semantic queue only fires on write events — it does not retroactively scan existing directories for missing |
|
The root-cause half of #4612 — Two notes:
For triage context: this PR, #4615 (lock-error type fidelity so sidecar write conflicts re-enqueue instead of failing terminally), and #4365 (bare thematic-break abstracts) are complementary slices of the same #4612 symptom cluster — none overlaps another's files. |
|
Follow-up on my earlier review after your update — confirmed the reworked Two minor notes, both non-blocking:
LGTM from my side. |
|
Reviewed this against the surrounding write paths and the semantic queue internals. Direction is right and the change is appropriately thin — the downstream machinery ( 1. Medium — batch-write path is still uncovered. 2. Medium — dedupe interacts badly with
Data safety is fine, to be clear — 3. Low — 4. Low — 5. Test note — the two new tests assert the wiring (call + args), which is reasonable for a wiring fix, but neither covers the dedupe window nor the Validated locally: signature/defaults of |
…4657 review) Fix volcengine#2: Move register_semantic_root AFTER enqueue in _enqueue_semantic_refresh_changes. When SemanticQueue.enqueue returns "deduplicated" (45s dedupe window, volcengine#769), skip registration to prevent phantom roots that block _wait_for_request until timeout. Fix volcengine#1: Add _enqueue_semantic_refresh_changes call in _refresh_batch for memory groups. Without this, batch writes to memory files would not generate L0 directory abstracts — same root cause as the single-write fix. Reviewed-by: now-ing
…c_status Fix volcengine#1: Add _enqueue_semantic_refresh_changes in _refresh_batch for memory groups. Without this, batch writes to memory files would not generate L0 directory abstracts. Fix volcengine#2: Move register_semantic_root AFTER enqueue in _enqueue_semantic_refresh_changes. When SemanticQueue.enqueue returns "deduplicated" (45s dedupe window, volcengine#769), skip registration to prevent phantom roots that block _wait_for_request until timeout. Fix volcengine#3: Add _map_semantic_status() to properly map FreshnessAction to human-readable status strings (REFRESH_NOW->complete/queued, MARK_PENDING->deferred, NOOP->skipped, None->skipped). Fix volcengine#4: Use "modified" instead of "added" for replace/append modes in changes dict, matching semantic meaning. Fix volcengine#5: Add 16 tests (18 total) covering all fixes. Reviewed-by: now-ing
9eae14d to
32f40b8
Compare
…c_status Fix volcengine#1: Add _enqueue_semantic_refresh_changes in _refresh_batch for memory groups. Without this, batch writes to memory files would not generate L0 directory abstracts. Fix volcengine#2: Move register_semantic_root AFTER enqueue in _enqueue_semantic_refresh_changes. When SemanticQueue.enqueue returns "deduplicated" (45s dedupe window, volcengine#769), skip registration to prevent phantom roots that block _wait_for_request until timeout. Fix volcengine#3: Add _map_semantic_status() to properly map FreshnessAction to human-readable status strings (REFRESH_NOW->complete/queued, MARK_PENDING->deferred, NOOP->skipped, None->skipped). Fix volcengine#4: Use "modified" instead of "added" for replace/append modes in changes dict, matching semantic meaning. Fix volcengine#5: Add 16 tests (18 total) covering all fixes. Reviewed-by: now-ing
32f40b8 to
58a05c7
Compare
Fix volcengine#3: Add _map_semantic_status() to properly map FreshnessAction to human-readable status strings (REFRESH_NOW->complete/queued, MARK_PENDING->deferred, NOOP->skipped, None->skipped). Fix volcengine#4: Use "modified" instead of "added" for replace/append modes in changes dict, matching semantic meaning. Fix volcengine#5: Add 12 tests (14 total) covering semantic_status mapping, change_type based on mode, and integration with write flow. Reviewed-by: now-ing
58a05c7 to
6ec5d87
Compare
…4657 review) Fix volcengine#2: Move register_semantic_root AFTER enqueue in _enqueue_semantic_refresh_changes. When SemanticQueue.enqueue returns "deduplicated" (45s dedupe window, volcengine#769), skip registration to prevent phantom roots that block _wait_for_request until timeout. Fix volcengine#1: Add _enqueue_semantic_refresh_changes in _refresh_batch for memory groups. Without this, batch writes to memory files would not generate L0 directory abstracts — same root cause as the single-write fix. Reviewed-by: now-ing
Review fixes addressedAll 5 issues from your review have been addressed across 2 commits on top of the original fix: Commit 2 (
|
| # | Issue | Fix |
|---|---|---|
| 3 | semantic_status conflates outcomes |
Added _map_semantic_status() — REFRESH_NOW→complete/queued, MARK_PENDING→deferred, NOOP→skipped, None→skipped |
| 4 | changes={"added"} on overwrite |
Added change_type variable — create→added, replace/append→modified |
| 5 | Test coverage gap | 12 new tests for mapping, change_type, and integration |
Commit 3 (0c00fe8) — Phase 2: functional fixes
| # | Issue | Fix |
|---|---|---|
| 2 | dedupe + wait=True hangs |
Moved register_semantic_root AFTER enqueue. When SemanticQueue.enqueue returns "deduplicated" (45s window, #769), skip registration to prevent phantom roots. |
| 1 | batch-write path uncovered | Added _enqueue_semantic_refresh_changes in _refresh_batch for memory groups. |
Local production testing
Tested on local production server (v0.4.17.1, C:\Users\admin\.venvs\openviking):
CREATE write: semantic_status = "complete" ✅
REPLACE write: semantic_status = "complete" ✅
batch-write: semantic_status = "complete" ✅
Server health: ok ✅
Test suite
18/18 passed (2 original + 12 Phase 1 + 4 Phase 2).
Related PRs
This PR is complementary to #4615, #2957, #1304, #3679, #4365 — each addresses a different slice of the #4612/#2797 symptom cluster with no file overlap.
|
Verified all five fixes against head Confirmed working:
1. Batch memory branch should pass through changes={"added": list(uris)}Downstream this is not purely cosmetic: 2. One note on your related-PR list: #4365 is ours — I checked the overlap claim and it holds (that PR touches abstract-generation prompt handling, not |
…olcengine#4657 review) Fix volcengine#1 (from now-ing round-3 review): Batch memory branch in _refresh_batch now groups URIs by their refresh_kinds value instead of hardcoding 'added'. Downstream semantic_dag.py:207 derives _added_paths from changes['added'] alone — a batch replace/append on existing memory files previously reached the DAG misclassified as brand-new paths. Added test_refresh_batch_passes_through_refresh_kinds (19/19 passed). Fix volcengine#2 (from now-ing round-3 review): Added docstring to _map_semantic_status explaining the deduplicated + wait=True trade-off: when SemanticQueue.enqueue returns 'deduplicated' (45s dedupe window, volcengine#769), the planner's REFRESH_NOW action maps to 'complete' even though no worker is processing this request. Documented as acceptable because the earlier write's job covers the same directory and _process_memory_directory re-lists the whole directory anyway. Reviewed-by: now-ing
Round-3 review fixes addressedBoth residual issues from your latest review have been addressed in Fix 1 — Batch memory branch passes through
|
Summary
Add
_enqueue_semantic_refresh_changescall to_write_memory_with_refreshto trigger semantic queue processing for memory file writes, enabling automatic L0 directory abstract (.abstract.md) generation.Root Cause
Memory writes (e.g.
viking_remembervia content/write API) went through_write_memory_with_refreshwhich only ran:MemoryUpdater.refresh_schema_overview→ generates.overview.md(template-based)MemoryUpdater.refresh_file_embedding→ vectorizes the fileBut it did not enqueue semantic messages, unlike
_write_direct_with_refresh(used for resources/skills) which calls_enqueue_semantic_refresh_changes→ semantic queue →_process_memory_directory→ generates.abstract.md.Fix
17-line addition in
content_write.py::_write_memory_with_refresh: call_enqueue_semantic_refresh_changeswith{"added": [uri]}after embedding refresh, matching the resource/skill write path pattern.Wrapped in try/except to prevent semantic enqueue failure from blocking the write.
Verification
viking_remember→ Semantic queue: Processed 0→1.abstract.mdauto-generated within seconds of writeRelated