From b8d83eab1cf426d19c8e0183b9d896b77a62872b Mon Sep 17 00:00:00 2001 From: "Fei.Chen" Date: Thu, 8 Oct 2026 01:28:45 +0800 Subject: [PATCH] fix(skills): skip vendored dep trees in install verification script enumeration (#3943) * fix(skills): skip vendored dep trees in install verification script enumeration sortedScriptPaths fed every .py/.js/.sh in the bundle into one shell 'for f in ...' command. A skill that vendors a scientific venv (pandas/scipy/ matplotlib etc.) carries thousands of .py files under .venv/, and the generated command exceeds the exec single-argument limit (MAX_ARG_STRLEN, 128KiB): /bin/sh fails with 'argument list too long' (exit 255) before any check runs, so no dependency-heavy skill can ever install. Vendored trees are installed dependencies, not scripts the model can name; their health is already covered by the dependency verification passes. Skip .venv/ and node_modules/ prefixes in sortedScriptPaths, which fixes the tree check, the per-language parse passes and the runtime prerequisite pass at once. Verified by installing a 4862-file / 105MB quant skill (pandas+numpy+ scipy+statsmodels+matplotlib venv, real interpreter binary instead of symlinks since zips cannot carry them): install failed before the fix, reaches ready after it. * fix(skills): skip vendored trees at any depth, not only at the bundle root Bundles are author-zipped, so tools/.venv/ or sub/package/node_modules/ are as legal as root-level trees and enumerated just the same. The filter now matches vendored trees under any prefix; nested placements are covered by a regression test. --------- Co-authored-by: vicfei --- .../service/tenant_skill_install_test.go | 14 +++++++++++ .../service/tenant_skill_verify.go | 23 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/internal/application/service/tenant_skill_install_test.go b/internal/application/service/tenant_skill_install_test.go index abb56309..5c3d38c5 100644 --- a/internal/application/service/tenant_skill_install_test.go +++ b/internal/application/service/tenant_skill_install_test.go @@ -1401,6 +1401,20 @@ func TestSortedScriptPathsIsDeterministic(t *testing.T) { "only files the runtime can execute are scripts") } +func TestSortedScriptPathsSkipsVendoredTreesAtAnyDepth(t *testing.T) { + bundle := &SkillBundle{Files: map[string][]byte{ + "scripts/main.py": []byte("x"), + ".venv/lib/pkg/a.py": []byte("x"), + "node_modules/leftpad/index.js": []byte("x"), + "tools/.venv/lib/otherpkg/b.py": []byte("x"), + "sub/package/node_modules/pkg/c.mjs": []byte("x"), + }} + + require.Equal(t, []string{"scripts/main.py"}, + sortedScriptPaths(bundle, allScriptExtensions...), + "vendored trees are skipped at the bundle root and nested under subprojects") +} + type stubWorkspaceSandboxPolicy struct { disabled bool } diff --git a/internal/application/service/tenant_skill_verify.go b/internal/application/service/tenant_skill_verify.go index d6cf473a..8d8c73cd 100644 --- a/internal/application/service/tenant_skill_verify.go +++ b/internal/application/service/tenant_skill_verify.go @@ -426,12 +426,24 @@ var allScriptExtensions = []string{".py", ".js", ".mjs", ".cjs", ".sh"} // sortedScriptPaths returns the bundle's files with any of the given suffixes, // in a stable order so the emitted command is deterministic. +// +// Vendored dependency trees (.venv/, node_modules/) are skipped at any depth: +// they are installed dependencies, not scripts the model can name. A scientific +// stack vendors thousands of .py files, and enumerating them overflows the exec +// single-argument limit ("argument list too long") in every pass that builds +// one command from this list; the trees' health is covered by the dependency +// verification passes instead. Bundles are author-zipped, so a vendored tree +// can sit inside a subproject directory (tools/.venv/…) as easily as at the +// root — both placements are filtered. func sortedScriptPaths(bundle *SkillBundle, suffixes ...string) []string { if bundle == nil { return nil } var matches []string for rel := range bundle.Files { + if underVendoredTree(rel) { + continue + } for _, suffix := range suffixes { if strings.HasSuffix(rel, suffix) { matches = append(matches, rel) @@ -443,6 +455,17 @@ func sortedScriptPaths(bundle *SkillBundle, suffixes ...string) []string { return matches } +// underVendoredTree reports whether a bundle-relative path sits inside a +// .venv or node_modules tree, at the bundle root or nested under any prefix. +func underVendoredTree(rel string) bool { + for _, tree := range []string{".venv/", "node_modules/"} { + if strings.HasPrefix(rel, tree) || strings.Contains(rel, "/"+tree) { + return true + } + } + return false +} + // nodeDependencyNames lists the runtime dependencies package.json declares. // devDependencies are excluded: they are a build-time concern and the image // is not asked to carry them.