@devries-cameron20 / composio Mirror · read-only / commits / 15a03c10f
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Syncing…

ci: add dead-code detection (knip + vulture + orphaned-CI check) (#3787)

## What Adds a **report-only** `Dead Code` CI workflow that surfaces likely-orphaned code on every PR, across all three surfaces — TypeScript, Python, and GitHub Actions. Follow-up to the root `Dockerfile` cleanup (#3783) and the dead-code sweep in #3786: instead of finding this stuff by hand, catch it automatically. | Surface | Tool | Wiring | |---|---|---| | TypeScript | [**knip**](https://knip.dev) | `knip.json`; runs via `pnpm dlx knip@5`. Finds unused files, exports, types, and dependencies. | | Python | [**vulture**](https://github.com/jendrikseipp/vulture) | `dead_code` nox session + `make dead-code`; allowlist at `python/config/vulture_allowlist.py`. Finds unused functions/classes/variables (complements Ruff's F401/F841). | | GitHub Actions | small bash script | `.github/scripts/check-orphan-ci.sh` — flags reusable workflows and composite actions with no callers. | ## Why report-only (not blocking) Every job writes findings to the run's **Step Summary** and **never fails the build**. These tools carry unavoidable false positives on a library monorepo — public API surface, dynamic imports, import-map targets (e.g. core's `#platform`), framework entry points. A red ❌ on false positives would just train everyone to ignore the check. Once a job's config is refined enough that a clean run is the steady state, it can be flipped to blocking. ## Validation (ran each locally) - **knip**: 0 unused *files* after scoping out the e2e-test workspaces (knip crashes traversing `ts/e2e-tests/**` — pre-existing knip bug, filed via `ignoreWorkspaces`) and build/docs artifacts. Export/dep categories surface advisory items. - **vulture**: clean run (report-only); allowlist suppresses the 3 `TYPE_CHECKING` re-exports in `custom_tool.py`; `build/`/`dist/` excluded. Surfaces 4 genuine minor items (`bases`, `desc`×3). - **orphan-CI script**: finds none — the repo has no orphaned CI plumbing today. - **Pinning**: `jk actions check` clean for this workflow; `actions/checkout` is SHA-pinned, the two local composite actions need no pin. Local usage is documented under **Dead code detection** in `CONTRIBUTING.md`. ## Note on scope These cover TS/Python/GHA — they would *not* have caught the root `Dockerfile` itself (an arbitrary root file no tool tracks). That class stays a manual-review concern; the orphan-CI script is the closest analogue for the CI surface.

Alberto Schiabel committed Jul 10, 2026 at 02:17 UTC 15a03c10fb1d1a792d21133741bba53463594267
7 files changed +275 -1
.github/scripts/check-orphan-ci.sh new
+71
@@ -0,0 +1,71 @@
1 +#!/usr/bin/env bash
2 +#
3 +# Report orphaned CI plumbing — the GitHub Actions analogue of the "dead file"
4 +# problem knip/vulture catch for TS/Python:
5 +#
6 +# * composite actions under .github/actions/* that no workflow `uses:`
7 +# * reusable workflows (on: workflow_call) that nothing calls AND that have
8 +# no self-trigger (push/pull_request/schedule/...), i.e. truly unreachable
9 +#
10 +# Report-only: prints findings and always exits 0 so it never blocks CI on a
11 +# heuristic. Vet anything it prints by hand before deleting.
12 +
13 +set -uo pipefail
14 +
15 +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
16 +workflows_dir="$repo_root/.github/workflows"
17 +actions_dir="$repo_root/.github/actions"
18 +
19 +findings=0
20 +
21 +note() {
22 + findings=$((findings + 1))
23 + echo " - $1"
24 +}
25 +
26 +echo "### Orphaned CI check"
27 +echo ""
28 +echo "Composite actions with no callers:"
29 +
30 +if [[ -d "$actions_dir" ]]; then
31 + for action_yml in "$actions_dir"/*/action.yml "$actions_dir"/*/action.yaml; do
32 + [[ -f "$action_yml" ]] || continue
33 + name="$(basename "$(dirname "$action_yml")")"
34 + # A caller references it as `uses: ./.github/actions/<name>`.
35 + if ! grep -rqs "uses:.*\.github/actions/$name\b" "$workflows_dir" "$actions_dir"; then
36 + note "action \`$name\` (.github/actions/$name) is referenced by no workflow"
37 + fi
38 + done
39 +fi
40 +[[ $findings -eq 0 ]] && echo " _(none)_"
41 +
42 +before_wf=$findings
43 +echo ""
44 +echo "Reusable workflows that are unreachable:"
45 +
46 +for wf in "$workflows_dir"/*.yml "$workflows_dir"/*.yaml; do
47 + [[ -f "$wf" ]] || continue
48 + # Only reusable workflows are candidates.
49 + grep -qs "workflow_call:" "$wf" || continue
50 + base="$(basename "$wf")"
51 + # Called by another workflow?
52 + if grep -rqs "uses:.*\.github/workflows/$base\b" "$workflows_dir"; then
53 + continue
54 + fi
55 + # Self-triggering (has a real event trigger besides workflow_call)?
56 + if grep -Eqs "^[[:space:]]+(push|pull_request|schedule|workflow_dispatch|release|issues|issue_comment|repository_dispatch|merge_group):" "$wf"; then
57 + continue
58 + fi
59 + note "workflow \`$base\` exposes workflow_call but has no caller and no self-trigger"
60 +done
61 +[[ $findings -eq $before_wf ]] && echo " _(none)_"
62 +
63 +echo ""
64 +if [[ $findings -eq 0 ]]; then
65 + echo "No orphaned CI plumbing found."
66 +else
67 + echo "Found $findings orphaned CI item(s) above — review before removing."
68 +fi
69 +
70 +# Report-only.
71 +exit 0
.github/workflows/dead-code.yml new
+107
@@ -0,0 +1,107 @@
1 +name: Dead Code
2 +
3 +# Surfaces likely-dead code on every PR so orphaned files/exports/deps get
4 +# noticed instead of rotting (see the root Dockerfile cleanup, #3783).
5 +#
6 +# Report-only by design: every job writes findings to the run's Step Summary
7 +# and never fails the build. These tools carry false positives (public API
8 +# surface, dynamic imports, import-map targets), so a red X here would train
9 +# people to ignore it. Tighten a job to blocking only once its config is
10 +# refined enough that a clean run is the steady state.
11 +
12 +on:
13 + push:
14 + branches: [master, next]
15 + paths:
16 + - 'ts/**'
17 + - 'python/**'
18 + - '.github/actions/**'
19 + - '.github/workflows/**'
20 + - '.github/scripts/check-orphan-ci.sh'
21 + - 'knip.json'
22 + - 'package.json'
23 + - 'pnpm-workspace.yaml'
24 + - 'pnpm-lock.yaml'
25 + - 'mise.toml'
26 + - 'mise.lock'
27 + pull_request:
28 + branches: [master, next]
29 + paths:
30 + - 'ts/**'
31 + - 'python/**'
32 + - '.github/actions/**'
33 + - '.github/workflows/**'
34 + - '.github/scripts/check-orphan-ci.sh'
35 + - 'knip.json'
36 + - 'package.json'
37 + - 'pnpm-workspace.yaml'
38 + - 'pnpm-lock.yaml'
39 + - 'mise.toml'
40 + - 'mise.lock'
41 +
42 +concurrency:
43 + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
44 + cancel-in-progress: ${{ github.event_name == 'pull_request' }}
45 +
46 +permissions:
47 + contents: read
48 +
49 +jobs:
50 + knip:
51 + name: TypeScript (knip)
52 + runs-on: ubuntu-latest
53 + steps:
54 + - name: Checkout Code
55 + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
56 +
57 + - name: Setup Node.js, pnpm, Bun
58 + uses: ./.github/actions/setup-node-pnpm-bun
59 +
60 + - name: Install dependencies
61 + run: pnpm install --frozen-lockfile
62 +
63 + - name: Run knip (report-only)
64 + run: |
65 + {
66 + echo '## Knip — TypeScript dead code'
67 + echo ''
68 + echo 'Unused files, exports, types and dependencies. False positives'
69 + echo 'usually mean a missing `entry` in `knip.json`; vet before deleting.'
70 + echo ''
71 + echo '```'
72 + pnpm dlx knip@5 --no-exit-code --no-progress 2>&1 || true
73 + echo '```'
74 + } >> "$GITHUB_STEP_SUMMARY"
75 +
76 + vulture:
77 + name: Python (vulture)
78 + runs-on: ubuntu-latest
79 + steps:
80 + - name: Checkout Code
81 + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
82 +
83 + - name: Setup Python with UV
84 + uses: ./.github/actions/setup-python-uv
85 +
86 + - name: Run vulture (report-only)
87 + run: |
88 + {
89 + echo '## Vulture — Python dead code'
90 + echo ''
91 + echo 'Likely-unused functions, classes and variables. Suppress'
92 + echo 'confirmed false positives in `python/config/vulture_allowlist.py`.'
93 + echo ''
94 + echo '```'
95 + (cd python && uv run nox -s dead_code) 2>&1 || true
96 + echo '```'
97 + } >> "$GITHUB_STEP_SUMMARY"
98 +
99 + orphaned-ci:
100 + name: GitHub Actions (orphan check)
101 + runs-on: ubuntu-latest
102 + steps:
103 + - name: Checkout Code
104 + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
105 +
106 + - name: Check for orphaned workflows and composite actions
107 + run: bash .github/scripts/check-orphan-ci.sh >> "$GITHUB_STEP_SUMMARY"
CONTRIBUTING.md
+22
@@ -127,6 +127,28 @@ pnpm check:peer-deps
127 pnpm update:peer-deps
128 ```
129
130 +### Dead code detection
131 +
132 +The `Dead Code` CI workflow reports likely-orphaned code on every PR (findings
133 +land in the run's Step Summary; it never fails the build). Run the same checks
134 +locally:
135 +
136 +```bash
137 +# TypeScript — unused files, exports, types and dependencies
138 +pnpm dlx knip@5 # config in knip.json
139 +
140 +# Python — unused functions, classes and variables
141 +cd python && make dead-code # vulture; allowlist in python/config/vulture_allowlist.py
142 +
143 +# GitHub Actions — orphaned reusable workflows and composite actions
144 +bash .github/scripts/check-orphan-ci.sh
145 +```
146 +
147 +These tools carry false positives (public API surface, dynamic imports,
148 +import-map targets), so treat their output as advisory: verify a finding is
149 +truly unreferenced before deleting, and suppress confirmed false positives via
150 +`knip.json` / `vulture_allowlist.py`.
151 +
152 ## Coding Standards
153
154 ### TypeScript
knip.json new
+21
@@ -0,0 +1,21 @@
1 +{
2 + "$schema": "https://unpkg.com/knip@5/schema.json",
3 + "ignoreWorkspaces": [
4 + "ts/e2e-tests/**"
5 + ],
6 + "ignoreBinaries": [
7 + "mise",
8 + "swift",
9 + "python",
10 + "python3",
11 + "vhs",
12 + "ps",
13 + "ruff"
14 + ],
15 + "ignore": [
16 + "**/.next/**",
17 + "**/build/**",
18 + "docs/**",
19 + "**/*.d.ts"
20 + ]
21 +}
python/Makefile
+4 -1
@@ -1,4 +1,4 @@
1 -.PHONY: clean-build sync provider create-provider env fmt chk snt tst type_inference bump build format check sanity test
1 +.PHONY: clean-build sync provider create-provider env fmt chk snt tst type_inference dead-code bump build format check sanity test
2
3 clean-build:
4 @rm -rf dist/ build/
@@ -53,6 +53,9 @@ fmt:
53 chk:
54 @nox -s chk
55
56 +dead-code:
57 + @nox -s dead_code
58 +
59 snt:
60 @nox -s snt
61
python/config/vulture_allowlist.py new
+17
@@ -0,0 +1,17 @@
1 +# Vulture allowlist — confirmed false positives.
2 +#
3 +# Vulture (see the `dead_code` nox session) cannot see some usages: symbols
4 +# referenced only through `__all__`, dynamic attribute access, framework entry
5 +# points, or `TYPE_CHECKING`-only re-exports look "unused" to it. List such
6 +# confirmed-intentional names here so they stop showing up in the report.
7 +#
8 +# The idiom is a *bare reference* to the name (a load), one per line — that is
9 +# what marks it "used". Keep a comment explaining why each entry is a false
10 +# positive, and prune entries when the underlying symbol is deleted.
11 +
12 +# Re-exported for downstream typing via `__all__` in
13 +# composio/core/models/custom_tool.py (TYPE_CHECKING-only imports, so vulture
14 +# does not connect the __all__ string to the import binding).
15 +SessionAttachResponseExperimental # noqa: B018, F821
16 +SessionCreateResponseExperimental # noqa: B018, F821
17 +SessionRetrieveResponseExperimental # noqa: B018, F821
python/noxfile.py
+33
@@ -139,3 +139,36 @@ def type_inference(session: Session):
139 "tests/test_type_inference_llamaindex.py",
140 "tests/test_type_inference_openai_agents.py",
141 )
142 +
143 +
144 +# Modules scanned for dead code (source only, no tests/examples/scripts)
145 +modules_for_vulture = [
146 + "composio/",
147 + "providers/",
148 +]
149 +
150 +
151 +@nox.session(name="dead_code")
152 +def dead_code(session: Session):
153 + """Report likely-dead code (unused functions, classes, variables).
154 +
155 + Report-only: vulture exits 1 when it finds candidates, but we do not fail
156 + the session on that so it never blocks CI on false positives. Vet the
157 + output by hand; suppress confirmed false positives by adding the symbol to
158 + ``config/vulture_allowlist.py``. Ruff already covers unused imports (F401)
159 + and unused locals (F841) in the `chk` session; vulture adds cross-module
160 + unused functions/classes that ruff cannot see.
161 + """
162 + session.install("vulture>=2.14")
163 + session.run(
164 + "vulture",
165 + *modules_for_vulture,
166 + "config/vulture_allowlist.py",
167 + "--min-confidence",
168 + "80",
169 + "--exclude",
170 + "*/build/*,*/dist/*,*/.venv/*,*/.nox/*,*/__pycache__/*",
171 + # vulture exit codes: 0 = clean, 3 = candidates found. Report-only, so
172 + # neither should fail the session. (1/2 are real usage/parse errors.)
173 + success_codes=[0, 3],
174 + )