[Bug]: New Session Skills lose the outer PathLock lease and conflict with their own tree lock
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
- Use a temporary local RAGFS filesystem and a valid Skill policy plan containing a name, description and body.
- Acquire the skills-root tree lock with
async with policy_set.lock() as lease. - Call
SkillPolicyUpdater.apply(plan, policy_set, ctx, transaction_handle=lease)with the real SkillProcessor and VikingFS. - Check
result.errorsand read back the expectedSKILL.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.
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
memory.session_skill_extraction_enabled = true,server.agent_evolution.enabled = false(so the standaloneextract_session_skillspath runs).- Commit a session whose content is an explicit reusable procedure (task + execution + result).
- 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.mdnever is, so empty skill dirs accumulate underviking://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/skillsreturns{"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.