Repository navigation
fix(skills): set per-skill directory mode to 0755 through the pinned descriptor - #154
Merged
Merged
Conversation
…descriptor mkdir's mode argument is masked by the process umask, so under umask 0077 <root>/<key>/ ended up 0700 and a separate agent identity could not read SKILL.md, though the reconcile reported success. The README promises 0755 regardless of the umask. After a successful create, chmod the directory through the descriptor the code already pins, never its path. A directory that already existed keeps its mode, and the managed root is left to the user. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
JS counterpart: launchdarkly/js-ai-sdk#129 · Spec: https://github.com/launchdarkly/ai-sdks-monorepo/pull/53 |
andrewklatzke
approved these changes
Oct 9, 2026
jeffdupont
approved these changes
Oct 9, 2026
…mode Linux copies a setgid parent's bit onto a new directory so files created inside inherit the shared group. fchmod sets exactly the bits it is given, so the bare 0755 cleared it. Carry S_ISGID over from fstat on the same descriptor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Setgid follow-up to the spec: https://github.com/launchdarkly/ai-sdks-monorepo/pull/54 (the first spec PR, #53, is merged). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the Bugbot finding on #87 (comment 4232816271).
What was wrong:
safe_fs.open_or_create_directorycreated<root>/<key>/withos.mkdir(..., 0o755), but the process umask still masks that mode, and nothing set it afterwards. Underumask 0077the directory came out0700, so an agent running as a different identity couldn't readSKILL.md, even thoughwrite_skillsreported success. The README's privilege-separation section promises per-skill directories at0755no matter what the umask is.Fix: after a successful create, the code sets the mode to
0755withos.fchmodon the directory descriptor it already pins. This is gated on_SUPPORTS_FCHMOD, the same way_FILE_MODEis applied to files. It never chmods the path, because a swap between the mkdir and the open could redirect a path-based chmod.<root>/<key>/keeps its mode.Path.mkdir()inskills_fsand isn't touched here.S_ISGIDbit, andfchmoduses exactly the bits passed, so a bare0755cleared it. Files written inside would then get the reconcile identity's primary group instead of the shared group. The mode is now(mode & S_ISGID) | 0755, with the current mode read throughos.fstaton the same descriptor. macOS doesn't propagate the bit, so nothing changes there.*at()family (Windows), there's no descriptor, so the mode isn't corrected there. Windows has no POSIX directory modes anyway, and that fallback still only does the existinglstatcheck.Tests (POSIX only):
test_created_skill_directory_is_0755_under_a_restrictive_umaskrunswrite_skillsunderumask 0o077and asserts<root>/<key>/is0755andSKILL.mdis0644. It fails without the fix (0700).test_created_skill_directory_keeps_an_inherited_setgid_bitmakes the root2755and asserts the new skill directory is2755. It's skipped unless a probe directory under that root actually inherits the bit, so it runs on Linux and skips on macOS. On Linux (Docker,python:3.12) it fails without the setgid change.test_create_leaves_an_existing_directory_mode_alonechecks that an existing0700directory stays0700.Full suite: 1521 passed on macOS (the setgid test skips) and 1522 passed on Linux. ruff and mypy are clean.
The JS fix is in a separate PR, linked below. The spec lines are in launchdarkly/ai-sdks-monorepo#53 (merged) and its setgid follow-up.
🤖 Generated with Claude Code