Change skill mounting behaviour#43
Conversation
Greptile SummaryThis PR changes how skill bundles are mounted in the sandbox: stored skills now mount at
Confidence Score: 5/5Safe to merge; the path-traversal guard is correctly implemented and all new error paths are properly wired up. The logic changes are well-contained: slug validation is enforced at both container creation and request resolution time, the new ensure_unique_mount_paths check prevents silent file clobbering, and the new error variants map cleanly to HTTP 400 responses. Tests cover the security-critical path-traversal case and the collision detection. The only gap — not detecting duplicate inline names at container creation — degrades UX for a specific misconfigured container but never causes silent data loss or a security bypass. src/routes/api/containers.rs — the per-entry validation loop could be extended to detect duplicate inline skill names before persisting. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[RequestSkill list] --> B{Skill type?}
B -->|skill_reference| C[resolve_version_for_reference\nDB lookup by id / name / version]
B -->|inline| D[resolve_inline_skill\nvalidate slug name\ndecode base64]
C --> E[mount_path = /skills/name-version_seq]
D --> F[mount_path = /skills/name]
E --> G[ensure_unique_mount_paths\nquadratic scan over resolved list]
F --> G
G -->|conflict| H[SkillResolutionError::MountPathConflict\nHTTP 400 skill_mount_conflict]
G -->|ok| I[build_preamble per skill\nprepend to instructions]
I --> J[Vec SkillMount to ShellExecutor\nfiles written to sandbox at mount_path]
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/routes/api/containers.rs:593-597
**Missing duplicate-name check for inline skills at creation time**
The comment at `validate_skill_entry` says it mirrors the resolver's checks "so a misshaped inline skill never makes it onto a stored row," and this PR adds the slug-validity check to match. However, a container created with two inline skills that share the same `name` (both pass per-entry validation) will have `skill_mount_conflict` returned on every subsequent request that uses the container, because `ensure_unique_mount_paths` is only called at request resolution time — not here.
Unlike stored-skill conflicts (which can't be predicted at creation because the resolved version is unknown), inline skill mount paths are entirely determined by `name`, so the clash is detectable right now. A simple duplicate-name scan over the inline entries in `body.skills` before persisting would catch this class of always-broken containers at creation time, consistent with the stated motivation for the existing slug check.
Reviews (3): Last reviewed commit: "Review fixes" | Re-trigger Greptile |
No description provided.