Skip to main content

materialize_skill_refs

Function materialize_skill_refs 

Source
pub fn materialize_skill_refs(
    dir: &NativeWriteDir,
) -> Result<(), WriteTargetError>
Expand description

Write every REFERENCED_SKILL_FILES entry beneath a pinned dir.

Why: this is the write #7779 caught landing in a victim directory — the old signature took a PATH, so the create_dir_all/atomic_write pair re-walked <project>/.trusty-code/skill-refs long after check_native_write_target had approved it, and followed whatever had been swapped in since. What: every entry’s <skill>/ directory is opened as a pinned child of dir (NativeWriteDir::child) and the file is written openat-relative to that handle, so the kernel resolves it against the validated inode rather than the path. A file whose content already matches is left alone, so repeated deploys do no writes; the rewrite is atomic, so a concurrent reader never sees a partial file. Postcondition: every entry is readable at dir.path()/<relative path> with its embedded content. Test: materialize_skill_refs_writes_readable_files, agents::deploy::deploy_tests::swapped_skill_refs_dir_never_reaches_the_victim.