Security dependency updates (security-deps)
Overview
Alakai works alongside Dependabot. Dependabot detects the vulnerabilities (alerts) and opens pull requests when it can; Alakai covers what Dependabot leaves unresolved:
- Opens the fix PR when an alert has a patched version and Dependabot did not open a PR against the branch the team works on. Dependabot only opens security PRs against the default branch, and many repositories work on another one.
- Repairs Dependabot PRs whose build or tests fail.
- Verifies Dependabot PRs in repositories with no automated checks, and comments the result.
- Notifies Slack when a critical vulnerability has no patched version.
Everything is off by default: SECURITY_DEPS_ENABLED=false in core, and each application
opts in with security.dependencies.enabled: true.
How it works
Core decides what there is to do; the worker does it. A worker is launched only when there is work, which keeps the orchestrator's shared worker slots free.
1. Trigger: SecurityDepsScheduler (core)
core/src/application/securityDeps/SecurityDepsScheduler.ts follows the DigestScheduler
pattern: one node-cron job per enabled application, in the configured timezone. With
SECURITY_DEPS_ENABLED=false no cron is registered.
On each trigger, for one application:
- Idempotency guard. One run per application per day, taken with an atomic
SET NXon<prefix>:security-deps:lastrun:<repo>:<YYYY-MM-DD>(48 h TTL; the date is the current day in the configured timezone). If the key exists, nothing happens. - Pre-check, with no LLM and no worker. Core queries GitHub and builds the day's work (sections below).
- Slack notice for critical alerts with no fix.
- Enqueue one
security-depstask on the shared queue (IMPLEMENTATION_SQS_QUEUE_URL) only if there is work: at least one alert group to fix or one Dependabot PR to handle. Otherwise the result is logged and the run ends.
Pre-check errors:
- The alerts API answers 403 or 404 (alerts disabled, or the GitHub App lacks the permission): a warning with the reason, no task. Not a scheduler error; the guard stays.
- Any other error is logged as an error and the guard (and any Dependabot PR marker taken in that run) is released, so the next trigger retries. The same happens when the enqueue fails.
<prefix> is TASK_TRACKING_REDIS_KEY_PREFIX.
2. Actionable alerts
A Dependabot alert is actionable when it is open, its severity is at or above minSeverity
(default high; from lowest to highest: low, medium, high, critical) and it has a patched version
(first_patched_version). Every ecosystem is included, production and development dependencies
alike.
Alerts are grouped by ecosystem + package + manifest. Each group targets the highest patched version among its alerts (the lowest version that resolves them all). Groups are ordered by severity (critical first), then by package name.
3. A single Alakai PR per repository
Alakai keeps one open security PR per repository, against the security branch:
- With none open, the run creates the branch
alakai/security/deps-<YYYY-MM-DD>and opens the PR. If that branch already exists on GitHub without an open PR (for example a same-day retry after the PR could not be opened), it uses the first free-2,-3, ... suffix. - With one open (head branch starting with
alakai/security/deps-, against the security branch), the run adds commits to it and rewrites its description. It does not open another. - Each fixed group is its own commit, so one update can be reverted without losing the rest.
- The PR description carries a hidden block (
<!-- alakai-security-deps: {...} -->) listing the groups already fixed. Core reads it so it does not ask for those groups again: the alerts stay open on GitHub until the fix reaches the default branch.
Core drops a group when:
- it is listed, at the group's target version or higher, in the hidden block of the open Alakai PR or, when the security branch is not the repository default branch, of one of the 10 most recently merged Alakai security PRs into the security branch. (When the security branch is the default branch, an alert still open after the merge means the fix did not work, so merged PRs are not read.) A newer advisory that needs a higher version is processed again: the worker adds a commit to the same PR and the entry is replaced with the new version. Reading the merged PRs stops the same groups from being requested every day when the security branch is not the default one (the alerts stay open until the fix reaches the default branch); or
- there is an open Dependabot PR against the security branch that updates the same package,
in the same manifest directory (the
in /<dir>suffix of the title, or thein the /<dir> directorylines of a grouped PR, including single-package titles that mention a group oracross N directories; no suffix means the root) and ecosystem (from thedependabot/<ecosystem>/...branch), to at least the group's target version. A Dependabot PR whose target version cannot be parsed counts; one to a still-vulnerable version does not. A Dependabot PR against another branch does not count.
Of the remaining groups each run takes at most 4 (SECURITY_DEPS_MAX_GROUPS_PER_RUN). The rest
wait for the next day.
4. Dependabot PRs Alakai handles
Core looks at the open PRs authored by dependabot[bot] whose base is the security branch. For
each, from the check runs of its head commit:
| Check runs | What Alakai does |
|---|---|
Any failed (failure, timed_out, startup_failure) | Repair |
| None at all | Verify (and repair if it does not pass) |
| All passed, or some still running | Nothing |
A PR is handled once per commit: when it is enqueued core stores
<prefix>:security-deps:pr:<repo>:<number>:<sha> (30-day TTL). When Dependabot updates the PR the
commit changes and it is evaluated again.
Each run takes at most 2 Dependabot PRs (SECURITY_DEPS_MAX_DEPENDABOT_PRS_PER_RUN), oldest first.
Without the "Checks: read" permission (the check-runs API answers 403) core logs a warning, skips the Dependabot PRs of that repository and still enqueues the alert groups.
5. Slack notice: critical alerts with no fix
For each open critical alert without a patched version, core posts a message to
SECURITY_SLACK_CHANNEL_ID with the repo, the package, the advisory (GHSA, CVE and link) and the
manifest.
- Each alert is announced once:
<prefix>:security-deps:notified:<repo>:<alert number>, with no expiry. - Without
SECURITY_SLACK_CHANNEL_IDnothing is posted and a warning is logged. - If the post fails the marker is not kept and the next run retries. It never blocks the task.
6. The worker
workers/security-deps/ (WORKER_TYPE=security-deps). One task per repository. The payload
(SecurityDepsPayload in @alakai/shared-types) carries the repo, the security branch, the
groups to fix, the Dependabot PRs to handle (with their action), the open Alakai PR if any, the
reviewers and the time limits.
Part 1 — alert groups
- Clone the security branch, or the branch of the open Alakai PR.
- For each group, run the coding agent (
CodingAgent,implementmode). The prompt gives the ecosystem, package, manifest, vulnerable range, fixed version, advisories and, for npm, the package manager detected from the lockfile. The agent upgrades the dependency with the smallest possible change, installs and runs build and tests when it can, adapts the code if the upgrade breaks something, and returns a structured result:status(fixed,fixed_unverifiedorunfixable), a summary, what it verified (build and tests:passed,failedornot_available) and notes for the PR. - The result is checked without the LLM: the working tree must have changed.
unfixable, a failed run or no change discards whatever is left and moves to the next group. Otherwise the group is one commit (fix(deps): bump <package> to <version>). A group counts asfixedonly when nothing the agent ran failed and at least one of build / tests passed. - With at least one commit, the worker pushes and opens the PR or updates the open one. If the
push fails, the groups are
failed. If the push succeeds but opening or updating the PR fails (after one retry), the groups stayfixed(their commits are on GitHub) and the result carries a separatepublishErrorwith the branch; the orchestrator logssecurity-deps.run.publish-failed.- Title:
fix(deps): security updates <YYYY-MM-DD>. - Body: a table with one row per group (package, version change, severity, advisories with links, build and test result) and the hidden block.
- Draft when any group is
fixed_unverified; regular when all arefixed. Updating an existing PR never changes its draft state. - Labels:
security,dependencies,automated pr,ai-generated. - Reviewers: the application's
responsibleUsers.
- Title:
Part 2 — Dependabot PRs. For each PR in the payload the worker clones the PR branch and runs
the agent with the action (verify: install and run build and tests, repair if they fail because
of the update; repair: it also gets the names of the failed checks and must leave build and
tests passing). Only when the agent reports repaired, changed code and everything passes does
the worker commit (fix: adapt code to <package> <version>) and push to the Dependabot PR branch.
When it reports passing (nothing needed fixing), any change left in the tree (for example
lockfile churn from an install) is logged by file name and discarded, and the PR is reported as
verified: a push would stop Dependabot from updating its PR. It always
comments the result on the PR: what was verified, what happened and, when it changed something,
what and why. When it could not repair the PR it comments and pushes nothing.
Once a Dependabot PR has a commit from Alakai, Dependabot stops updating that PR on its own. The comment says so. Asking Dependabot to recreate the PR discards Alakai's change.
Verification outside npm. The worker image has Node.js, git and, for this worker only,
corepack-backed yarn and pnpm: wrappers in /opt/alakai/security-deps-bin that the worker puts
first on its PATH at startup (SECURITY_DEPS_TOOLS_DIR overrides the directory). The other
workers keep the image's global yarn and PATH. For Gradle, CocoaPods, Swift and other ecosystems the agent updates the version in the
repository files but cannot build: those groups are fixed_unverified and the PR is a draft that
says so.
Result. The worker reports the outcome per group (fixed, fixed_unverified, unfixable,
skipped, failed) and per Dependabot PR (verified, repaired, skipped, failed), with the
reason and the PR URL. A failing group or PR never stops the others. The task ends in failure
only when nothing at all could be done (for example, the initial clone fails). The orchestrator
only logs security-deps.run.completed / security-deps.run.failed (and
security-deps.run.publish-failed when the commits were pushed but no PR shows them).
GitHub token. The token is handed to git clone and git push through the process
environment, scoped to github.com; the clone's remote is the plain HTTPS URL and no file of the
clone ever holds the token, so the agent and third-party install scripts cannot read it from the
repository. Repository hooks are disabled for the worker's own git commands.
7. Limits
- Time: 25 minutes per agent run. With 4 groups and 2 PRs the worst case is 150 minutes; the
worker starts no new run once 150 minutes have passed and reports the rest as
skipped. - Task in Redis: the orchestrator keeps the stored task for 6 hours (it was 4, raised for the 200-minute deep security audit), so the completion callback of a long run is not lost.
- Cost:
SECURITY_DEPS_MAX_COST_USD(default 10). The worker adds the estimated cost after each agent run and, once it reaches the cap, starts no more runs and reports it. A run is never cut short. A model with no known price (SEEDED_MODELSin@alakai/analytics) is not capped and a warning is logged.
8. Security PRs and the other workers
Where this feature is on (SECURITY_DEPS_ENABLED=true and the repository's
security.dependencies.enabled: true), bug-hunter and pr-classifier do not run on PRs
whose branch starts with alakai/security/ nor on PRs opened by dependabot[bot]. Everywhere else
those PRs are hunted and classified as before.
Configuration
config.json
The application overrides the project, and the project overrides the default.
Under projects.<project>.security:
"security": {
"dependencies": {
"schedule": { "days": ["Mon", "Tue", "Wed", "Thu", "Fri"], "hour": 6, "timezone": "America/Montevideo" },
"minSeverity": "high"
}
}
Under applications.<app>.security:
"security": {
"branch": "dev",
"dependencies": { "enabled": true }
}
dependencies.enabledexists only on the application and defaults tofalse.branchis optional; without it the application'sbaseBranchis used, and without that the repository default branch.scheduleandminSeveritycan be set on the project or on the application. Ascheduleis taken as a whole (days,hourandtimezoneare all required inside it).- Defaults: weekdays at 06:00
America/Montevideo, andminSeverity: "high". - An application with no
securityblock behaves exactly as before. An invalid value (unknown severity or weekday, hour out of range, invalid timezone) fails the config load. - The config is read once when core starts: a change needs a core restart, like the digest.
securityis not part of the legacyreposschema.
Environment variables
| Variable | Service | Default |
|---|---|---|
SECURITY_DEPS_ENABLED | core | false |
SECURITY_SLACK_CHANNEL_ID | core | Unset (no notice) |
SECURITY_DEPS_MAX_GROUPS_PER_RUN | core | 4 |
SECURITY_DEPS_MAX_DEPENDABOT_PRS_PER_RUN | core | 2 |
SECURITY_DEPS_MAX_COST_USD | worker | 10 |
SECURITY_DEPS_TOOLS_DIR | worker | /opt/alakai/security-deps-bin (used only if it exists) |
SECURITY_DEPS_LLM_PROVIDER | worker | anthropic |
SECURITY_DEPS_LLM_MODEL | worker | claude-sonnet-5-5 |
SECURITY_DEPS_LLM_EFFORT | worker | Provider default |
SECURITY_DEPS_LLM_API_KEY | worker | Required. Own key, no fallback to IMPLEMENTATION |
The feature has its own key so its spend is tracked apart from IMPLEMENTATION. Workers share one
task definition, so SECURITY_DEPS_LLM_API_KEY must exist in the Secrets Manager secret before that
task definition is deployed; a missing secret stops every worker from starting. See
LLM providers.
Prerequisites outside the code
- GitHub App permissions: "Dependabot alerts: read" and "Checks: read". Add them to the App and accept them on the organization installation. Without the first one the pre-check logs a warning and does nothing; without the second one it logs a warning, skips the Dependabot PRs and still fixes the alert groups.
- Dependabot alerts enabled on the repository.
- Deploy core before the worker: the analytics migration that adds the
SECURITY_DEPSinteraction type runs when core starts.
Analytics
Every agent run is recorded with the SECURITY_DEPS interaction type, the model and the tokens
(see Analytics).
Known limitations
- Check statuses reported through the legacy commit-status API are not read, only check runs (GitHub Actions and Checks API integrations). A repository whose CI only reports commit statuses looks like it has no checks, so its Dependabot PRs are verified by the agent.
- An alert group the agent reports as
unfixable, or for which it makes no change (for example because the security branch already has the fix while the alert is still open on the default branch), is not recorded anywhere, so it is requested again on the next run. - The git commands of the worker run with the worker's full environment (including
GITHUB_APP_PRIVATE_KEY), like theimplementationworker. A git config or filter planted in the clone during an install could read it. This is a cross-worker issue to be fixed for all workers at once. - When the PR cannot be opened after a successful push, the commits stay on the branch with no PR; the groups are not in any hidden block, so they are requested again on the next run (on a new, suffixed branch the same day).
- Only the 10 most recently merged Alakai security PRs are read (scanning at most the 300 most recently updated closed PRs into the security branch). A group merged longer ago whose alert is still open is requested again.
- If the worker fails after core marked a Dependabot PR commit, that commit is not retried automatically. The task can be retried from the dashboard.
- The image runs Node 24 only. Repositories on another Node version, or needing native or mobile
build tools, usually end as
fixed_unverified(draft PR). - There is no global monthly cost cap, no on-demand run from Slack and no dashboard view for this flow yet.
Local testing
See the security-deps worker section of the local setup guide and
workers/security-deps/README.md.
Tests
| Area | Tests |
|---|---|
| Config | core/test/config/securityDepsConfig.test.ts |
| Alerts, Dependabot PR action, hidden block | packages/github/test/securityDeps.test.ts |
| GitHub clients | packages/github/test/dependabotAlerts.test.ts, securityDepsClients.test.ts |
| Scheduler, pre-check, Slack notice | core/test/application/securityDeps/SecurityDepsScheduler.test.ts |
| Redis markers | core/test/infrastructure/securityDeps/RedisSecurityDepsStateStore.test.ts |
| Worker | workers/security-deps/test/*.test.ts |
| Orchestrator | orchestrator/test/securityDeps.test.ts, notifier.test.ts |
| Other workers skipped | core/test/application/{bugHunter,prClassifier}/*.test.ts, core/test/interfaces/http/githubWebhooksRoute.test.ts |