OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: New Session Skills lose the outer PathLock lease and conflict with their own tree lock

Open ousugo opened this issue 2 months ago • 1 comments

Issue Origin

Observed or reproduced in a real environment

Bug Description

New Session Skill creation fails while the training engine holds the skills-root tree lock. SkillPolicyUpdater.apply receives transaction_handle, but the creation path drops it before SkillOperationUpdater → SkillProcessor → VikingFS.write_context. Native PathLock treats the nested write as a different owner and rejects it.

Steps to Reproduce

  1. Use a temporary local RAGFS filesystem and a valid Skill policy plan containing a name, description and body.
  2. Acquire the skills-root tree lock with async with policy_set.lock() as lease.
  3. Call SkillPolicyUpdater.apply(plan, policy_set, ctx, transaction_handle=lease) with the real SkillProcessor and VikingFS.
  4. Check result.errors and read back the expected SKILL.md.

The same creation succeeds without the outer lock. Forwarding only the existing lease through the creation chain makes the locked case succeed. The reproduction uses real filesystem writes and native PathLock; only LLM overview generation and embedding enqueue are replaced.

Expected Behavior

Creation reuses the caller's lease to write the directory, SKILL.md, .abstract.md and .overview.md. The caller retains ownership of its tree lock until it exits the outer context.

Actual Behavior

Creation fails with a lock timeout and no SKILL.md is produced, despite a valid extraction result.

Error Logs

Failed to write viking://user/default/skills/code-review: internal error: lock error: lock acquire timed out after 0ms

The duration in the error can vary.

OpenViking Version

0.4.20; also reproduced against main commit 43762f1609f8c48e66ec4a3f3c9f3532ca9f2997.

Python Version

3.11

Operating System

Linux

Model Backend

Not required for the isolated lock reproduction.

Additional Context

Proposed fix: transport the existing caller-owned lease through the creation chain, including directory and auxiliary writes, with optional arguments defaulting to None. Do not disable locking, increase the timeout, or release the outer lease from a nested operation.

This report is specifically about new Skill creation. Existing Skill update policy and error/task reporting are separate and outside this fix.

Related, but distinct:

  • https://github.com/volcengine/OpenViking/pull/4807 fixes the earlier missing-description blocker.
  • https://github.com/volcengine/OpenViking/pull/4438 fixes experience/trajectory lease coverage, not this Skill creation path.

ousugo avatar Sep 14 '26 10:09 ousugo

Additional field confirmation on 0.4.20 (real environment, Hermes as the harness)

Hit exactly this failure — and the extractor itself succeeds, so the bug is real and silent:

Reproduction

  1. memory.session_skill_extraction_enabled = true, server.agent_evolution.enabled = false (so the standalone extract_session_skills path runs).
  2. Commit a session whose content is an explicit reusable procedure (task + execution + result).
  3. The extractor produces a skill and tries to write viking://user/default/skills/<name>/SKILL.md.

Observed (server.log, verbatim; local time CST = 12:54:55 UTC)

20:54:55,034 I ragfs::lock::manager: pathlock acquire batch entered wait state owner_id=49b52675-4887-439b-9cc6-c...
20:54:55,035 E openviking.storage.viking_fs._base - [VikingFS] Failed to write viking://user/default/skills/openviking-rerank-config-troubleshooting: internal error: lock error: lock acquire timed out after 0ms
20:54:55,035 E openviking.session.skill.skill_operation_updater - Failed to apply session skill operation for viking://user/default/skills/openviking-rerank-config-troubleshooting/SKILL.md: Failed to write ...: internal error: lock error: lock acquire timed out after 0ms
20:54:55,050 I openviking.session.session - Extracted 2 memories for long_term
20:54:55,062 I openviking.session.session - Session ovskill-test-b1 memory extraction completed

Earlier occurrences are byte-identical (.../openviking-configuration-tuning/SKILL.md), 10 times, last one at 18:01:15,309 — deterministic, not a race. Note the memory writes in the same commit succeed, only the skill write is rejected.

Impact

  • Session Skill creation is effectively 100% broken here: the directory IS created, SKILL.md never is, so empty skill dirs accumulate under viking://user/default/skills/.
  • No retry: after a service restart the extractor never re-attempts the same skill.
  • Silent to the client: the commit task result reports session_skills_extracted: 0, session_skill_uris: [] — it looks like nothing was extracted, while the extracted content and the LLM tokens spent producing it are simply discarded.
  • GET /api/v1/skills returns {"skills": [], "total": 0} while the empty directories exist on disk, which makes it easy to miss.

Workaround — we set memory.session_skill_extraction_enabled = false and will re-enable it once the outer lease is forwarded (#5018).

Happy to validate a build containing #5018: the repro above is deterministic and reproduces every time with the same session content.

Environment: OpenViking 0.4.20 (current PyPI release), macOS, single user, local RAGFS, Hermes memory plugin as the only client.

za8209 avatar Sep 15 '26 13:09 za8209