Skip to main content

How to test incident support end to end locally

This runs the whole @Alakai investigate flow from your machine against your local Slack app, a test GitHub repo and a CloudWatch log group seeded with synthetic errors:

Slack ──ngrok──▶ core :3000 ──▶ LocalStack SQS ──▶ orchestrator :8080 ──(you run it)──▶ incident-support worker
▲ │ ▲ │
└── report ◀──────┴────────────── Redis (task, investigation, RoundInput, lock) ◀──────────┘
orchestrator ◀── POST /task-complete ───────────────┘

With ENV=local the orchestrator doesn't start ECS tasks, so you run each worker once by hand (make run-latest for rounds, make run-once for the fix PR). Everything else — Slack ack, report replacement, button, PR link — is real.

Feature reference: Incident Support. Spec: Houlak/alakai#151.

Time: ~45 min the first time (mostly Slack/AWS/repo prep), ~5 min per scenario afterwards.

Want a real incident instead of synthetic logs? Investigate a real bug in the sandbox Time Off app walks through triggering a genuine 500 in the deployed sandbox service and investigating it with this same local setup.


0. Prerequisites​

  • Node 20+, Yarn, Docker, redis-cli, jq, AWS CLI v2, ngrok.

  • Check out the feature branch and build the shared packages:

    git checkout feat/incident-support
    yarn install
    for p in logger shared-types branch-naming analytics execution-store github llm cloudwatch-logs incident-store; do
    yarn workspace @alakai/$p build
    done
  • Access you need:

    • Admin on the local-dev Slack app (to change scopes, events and interactivity).
    • The GitHub App installed on a test repo with Contents, Pull requests and Issues read & write.
    • AWS credentials for Alakai's sandbox account that can create a log group, put log events and run Logs Insights queries.
    • An LLM key for the INCIDENT_SUPPORT module (OpenAI or Anthropic) and one for IMPLEMENTATION (fix PRs).

1. Prepare the test repo​

Use a throwaway repo (the fix PR scenario opens a real PR), e.g. houlak/alakai-incident-e2e. Give the agent something real to find:

  1. A small service with a planted bug, e.g. src/checkout.ts:

    export function computeTotal(cart: { items?: Array<{ price: number; qty: number }> }) {
    // BUG: items can be undefined for carts restored from a saved session
    return cart.items!.reduce((sum, i) => sum + i.price * i.qty, 0);
    }
  2. Optional but recommended: docs/alakai.md describing the service (the worker puts it in the prompt).

  3. A dev branch (used as the staging ref below).

  4. Shortly before testing, merge a small PR into main (e.g. "refactor: restore carts from saved sessions"). Rounds only list PRs merged between 1h before the thread started and now, so this fills Recent changes.


2. Seed a CloudWatch log group (sandbox account)​

The worker queries real CloudWatch Logs Insights. Create a group and push synthetic errors with current timestamps (they must fall in the investigation window). One line includes an email and a test card number so you can check redaction.

export AWS_PROFILE=<sandbox-profile> AWS_REGION=us-east-1
GROUP=/alakai/incident-e2e/prod

aws logs create-log-group --log-group-name "$GROUP" 2>/dev/null || true
aws logs create-log-stream --log-group-name "$GROUP" --log-stream-name api 2>/dev/null || true

now=$(($(date +%s) * 1000))
events=$(jq -n --argjson t "$now" '[range(0; 20) as $i | {
timestamp: ($t - 600000 + ($i * 20000)),
message: (if $i % 4 == 0
then "INFO POST /checkout 200 user=jane.doe@example.com card=4111 1111 1111 1111"
else "ERROR POST /checkout 500 TypeError: Cannot read properties of undefined (reading '\''reduce'\'') at computeTotal (src/checkout.ts:3:22) requestId=req-\($i)"
end)
}]')
aws logs put-log-events --log-group-name "$GROUP" --log-stream-name api --log-events "$events"

Re-run the put-log-events part before each test session so the errors are recent. Logs Insights usually sees new events within a minute.


3. Configure the local Slack app​

In api.slack.com/apps → your local-dev app:

  1. OAuth & Permissions → Bot Token Scopes: make sure it has app_mentions:read, channels:history, chat:write and add reactions:write. Reinstall the app to the workspace and copy the Bot User OAuth Token (xoxb-…) if it changed.

  2. Start a tunnel to core and keep it running:

    ngrok http 3000 # copy https://<sub>.ngrok-free.app
  3. Event Subscriptions: Request URL https://<sub>.ngrok-free.app/slack/events (verifies once core is up, step 6). Under Subscribe to bot events make sure app_mention is listed. Nothing else is needed — Alakai never subscribes to message.channels.

  4. Interactivity & Shortcuts: turn On, Request URL https://<sub>.ngrok-free.app/slack/interactions. Save.

  5. Create a public test channel (private channels aren't supported), /invite the bot, and copy the channel ID (channel name → View channel details → bottom of the About tab, C…).

ngrok URLs change on restart. When they do, update both Request URLs.


4. Start local infrastructure​

docker run -d --name alakai-redis -p 6379:6379 redis:latest
cd .local-aws && make up && make infra && cd .. # SQS queue: http://localhost:4566/000000000000/alakai-queue

5. Configuration files​

5.1 core/config.json (REPO_WORKFLOW_CONFIG_SOURCE=file)​

Add the test app (keep any apps you already have). staging deliberately has no logs entry so you can test the code-only path.

{
"projects": {
"e2e": {
"applications": {
"e2e-api": {
"repo": "houlak/alakai-incident-e2e",
"responsibleUsers": ["<your-github-login>"],
"slackChannelIds": ["<C-test-channel>"],
"logs": {
"prod": { "awsAccountId": "<sandbox-account-id>", "awsRegion": "us-east-1", "logGroups": ["/alakai/incident-e2e/prod"] }
},
"incidentSupport": {
"enabled": true,
"defaultEnv": "prod",
"refs": { "prod": "main", "staging": "dev" },
"aliases": ["checkout api"]
}
}
}
}
}
}

For the app-choice scenario (7.6) add a second enabled app on the same channel. It needs a different repo (a repo can belong to only one app):

"e2e-web": {
"repo": "houlak/<another-test-repo>",
"slackChannelIds": ["<C-test-channel>"],
"incidentSupport": { "enabled": true, "defaultEnv": "prod", "refs": { "prod": "main" } }
}

Slack channel (slackChannelIds). This is what connects the Slack channel to the app: Alakai only answers @Alakai investigate in channels listed in an enabled app's slackChannelIds, and that list also decides which apps it can pick from in that channel.

  • Replace <C-test-channel> with the channel ID you copied in step 3.5 (it starts with C, e.g. C07ABC12345). Use the ID, not the name (#alakai-incident-test won't match).
  • The channel must be public, and the bot must be a member (/invite @<your-bot>).
  • You can list several channels: ["C07ABC12345", "C07DEF67890"].
  • Restart core after editing config.json; it's only read at startup.
  • If it's wrong, Alakai replies "Incident support isn't configured for this channel."

responsibleUsers must be GitHub logins with access to the repo, and not the account that opens the PR.

5.2 Environment per process​

Use the same Redis, the same REDIS_KEY_PREFIX (orchestrator ↔ workers) and the same INCIDENT_STORE_KEY_PREFIX (everywhere). Keep INCIDENT_SUPPORT_ROUND_TIMEOUT_MIN identical in core, the orchestrator and the worker.

core/.env (on top of your usual local core env: SLACK_SIGNING_SECRET, planner key, GitHub App, …)

ENV=local
PORT=3000
SLACK_BOT_TOKEN=xoxb-...
REPO_WORKFLOW_CONFIG_SOURCE=file
TASK_TRACKING_REDIS_URL=redis://localhost:6379
IMPLEMENTATION_SQS_QUEUE_URL=http://localhost:4566/000000000000/alakai-queue
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=test # LocalStack accepts any credentials
AWS_SECRET_ACCESS_KEY=test
INCIDENT_STORE_KEY_PREFIX=alakai-incidents-local
INCIDENT_SUPPORT_MAX_ROUNDS=4
INCIDENT_SUPPORT_AWAITING_TTL_HOURS=24
INCIDENT_SUPPORT_ROUND_TIMEOUT_MIN=10

orchestrator/.env

ENV=local
PORT=8080 # core already uses 3000
SQS_QUEUE_URL=http://localhost:4566/000000000000/alakai-queue
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
REDIS_URL=redis://localhost:6379
REDIS_KEY_PREFIX=alakai-local
SLACK_BOT_TOKEN=xoxb-... # the orchestrator posts reports and PR links
INCIDENT_STORE_KEY_PREFIX=alakai-incidents-local
INCIDENT_SUPPORT_ROUND_TIMEOUT_MIN=10

workers/incident-support/.env — cd workers/incident-support && make env-init, then fill in:

REDIS_URL=redis://localhost:6379
REDIS_KEY_PREFIX=alakai-local
INCIDENT_STORE_KEY_PREFIX=alakai-incidents-local
ORCHESTRATOR_URL=http://localhost:8080
INCIDENT_SUPPORT_LLM_PROVIDER=anthropic # or openai
INCIDENT_SUPPORT_LLM_MODEL=claude-opus-5-5 # required for anthropic
INCIDENT_SUPPORT_LLM_API_KEY=<key>
GITHUB_APP_ID=<id>
GITHUB_APP_PRIVATE_KEY=<pem with \n>
AWS_PROFILE=<sandbox-profile> # real AWS for CloudWatch (run `aws sso login` first if SSO)
INCIDENT_SUPPORT_ROUND_TIMEOUT_MIN=10

Never put TASK_ID in this file (see the comment in .env.sample).

workers/implementation/.env — for the fix PR (make env-init there):

REDIS_URL=redis://localhost:6379
REDIS_KEY_PREFIX=alakai-local
ORCHESTRATOR_URL=http://localhost:8080
INCIDENT_STORE_KEY_PREFIX=alakai-incidents-local
IMPLEMENTATION_LLM_PROVIDER=anthropic
IMPLEMENTATION_LLM_MODEL=claude-opus-5-5
IMPLEMENTATION_LLM_API_KEY=<key>
GITHUB_APP_ID=<id>
GITHUB_APP_PRIVATE_KEY=<pem with \n>
TASK_ID= # filled from the orchestrator log in scenario 7.8

6. Start the services​

Three terminals (plus ngrok):

cd core && yarn dev # expect "Incident support: enabled"
cd orchestrator && yarn dev # consumes LocalStack, serves :8080/task-complete
cd workers/incident-support # where you'll run `make run-latest`

Check:

curl -s localhost:3000/healthz; curl -s localhost:8080/health

Then go back to Slack → Event Subscriptions and confirm the Request URL shows Verified.


7. Scenarios​

Each round follows the same loop:

  1. Mention Alakai in Slack → 👀 and "Investigating… (started HH:MM UTC)" within ~3 s.
  2. The orchestrator logs Worker launched and message deleted { taskType: 'incident-support', taskArn: 'local:task:skipped-ecs' }.
  3. In workers/incident-support: make run-latest (within 15 min, the round lock's lifetime).
  4. 1–5 min later the "Investigating…" message is replaced by the report.

Useful while testing: make running (running rounds and task ids), make investigation key=<C…:thread_ts>, make round-input TASK_ID=<id>. The investigation key is the channel ID and thread timestamp, also printed in core's incident.round.enqueued log.

7.1 First report (top-level mention)​

Post a top-level message in the channel:

@Alakai investigate checkout returns 500 for e2e-api since this morning

Run the loop. Expected:

  • The mention becomes the thread; the report replaces "Investigating…" and shows, in order: Summary, Confidence, Evidence, Suspected cause, Recent changes, Questions, Next steps, under a header with the app (e2e-api), env (prod) and round 1.
  • Evidence: ≤ 5 excerpts, each with a working Logs Insights link. The email and card number appear as [REDACTED].
  • Suspected cause: links like …/blob/<sha>/src/checkout.ts#L3 (pinned to the checked-out commit).
  • Recent changes: the PR you merged in step 1.4.
  • At most 3 numbered questions. An Open fix PR button if the agent proposed a concrete fix.
  • Redis: make investigation key=… shows status: "awaiting_input", round: 1, totalRounds: 1.

7.2 Answer questions (untagged replies, then tag)​

  1. Reply in the thread without tagging: 1: yes, only restored carts. Nothing happens (Slack doesn't send it to Alakai).
  2. Reply 2: started after the 10:00 deploy, again untagged.
  3. Tag: @Alakai that's all we know.

Run the loop. Expected: round 2 report. make round-input TASK_ID=<id> shows all three replies in threadMessages, redacted, and no channelContext (round 1 only).

7.3 "Still working"​

Mention Alakai, then before running the worker mention it again: @Alakai also check payments. Expected: "Still working — I'll include this in the next round." and no second SQS message. Then run the loop; the extra message is picked up in the next round.

7.4 Final round and reopen​

Restart core with INCIDENT_SUPPORT_MAX_ROUNDS=2 to make this quick (and the worker with the same value for the "round N of M" prompt line). In a thread with one completed round, tag Alakai and run the loop. Expected: round 2 is marked final and has no questions. Tag again: the investigation reopens at round 1 and the report builds on the saved summary.

7.5 Environment without logs (code-only)​

New top-level message:

@Alakai investigate env=staging checkout totals are wrong

Expected: the round checks out dev; Evidence shows "not available — …" (no logs config for staging); Suspected cause and Recent changes are still filled.

Also try plain wording: @Alakai investigate checkout api in staging is failing (alias + env words).

7.6 App choice in a shared channel (needs the second app)​

@Alakai investigate something is broken

Expected: Alakai only asks which app (listing e2e-api, e2e-web); no worker launches (make running is empty). Reply @Alakai e2e-api → round 1 starts. Also: @Alakai investigate app=nope x → reply listing valid slugs.

7.7 Routing priority over the ClickUp intent​

  • Top-level: @Alakai investigate why users can't create a ticket → incident investigation, not ClickUp.
  • Inside an investigation thread: @Alakai 1: yes, we opened an issue yesterday → next round, not ClickUp.
  • Top-level without investigate: @Alakai hi → short usage help.

7.8 Open fix PR​

On a report that shows Open fix PR:

  1. Click it. Expected: an acknowledgement in the thread; the orchestrator logs Worker launched … { taskType: 'implementation' }. Copy that taskId.
  2. cd workers/implementation, set TASK_ID=<taskId> in .env, then make run-once.
  3. Expected on GitHub: one PR against main titled fix: …, labels ai-generated + incident, your login as reviewer, body with the report and the Slack thread link.
  4. Expected in Slack: the PR link in the thread. Redis: status: "resolved", fixPr.status: "opened".
  5. Click the button again → Alakai posts the existing PR link; no new task.

Close the PR and delete its branch afterwards.

7.9 Failure paths​

  • LLM error: set a bad INCIDENT_SUPPORT_LLM_API_KEY in the worker .env, mention, run the loop → "Investigation failed: … — tag me to retry" replaces "Investigating…". First round of a budget → status: "failed"; tagging again reopens.
  • Crashed worker: mention but don't run the worker. With INCIDENT_SUPPORT_ROUND_TIMEOUT_MIN=1 in core and the orchestrator, the lock expires after 6 min; the next mention treats the round as failed and starts a new one (core logs incident.round.failed with reason: "stale").
  • Expiry: restart core with INCIDENT_SUPPORT_AWAITING_TTL_HOURS=0.02 (~72 s). Wait after a report, then tag → the investigation silently expired and reopens with the saved summary.

7.10 Both LLM vendors​

Repeat 7.1 with INCIDENT_SUPPORT_LLM_PROVIDER=openai (default model gpt-6-sol) and with anthropic.


8. Troubleshooting​

SymptomLikely causeFix
No 👀 at allEvent Request URL not verified / ngrok URL changed / bot not in channelRe-verify the URL in Slack, /invite the bot, check core logs for Slack app mention routed
"Incident support isn't configured on this Alakai deployment"INCIDENT_STORE_KEY_PREFIX or TASK_TRACKING_REDIS_URL missing in coreSet both and restart core
"Incident support isn't configured for this channel"Channel ID not in an enabled app's slackChannelIdsFix config.json, restart core
👀 appears but no "Investigating…"chat:write missing or bot not a channel memberAdd the scope, reinstall, invite the bot
make run-latest: "No running investigation found"Prefix mismatch, or core failed to enqueueSame INCIDENT_STORE_KEY_PREFIX everywhere; check core for incident.round.enqueued
Worker: No payload found in RedisOrchestrator not running or REDIS_KEY_PREFIX differsStart the orchestrator; match REDIS_KEY_PREFIX in orchestrator and worker
Worker: Failed to post task completion … fetch failedORCHESTRATOR_URL doesn't match the orchestrator's PORTUse http://localhost:8080 and PORT=8080
Report never replaces "Investigating…"SLACK_BOT_TOKEN or INCIDENT_STORE_KEY_PREFIX missing in the orchestratorSet both in orchestrator/.env, restart
Orchestrator logs incident.round.ignoredDuplicate or late result (e.g. you ran the same task twice)Expected; start a new round
Evidence "not available — access denied"Worker AWS credentials can't query the groupaws sso login, check AWS_PROFILE and IAM permissions
Evidence empty though errors existEvents older than the window, or not indexed yetRe-run the seeding in step 2; wait a minute
Clicking the button does nothingInteractivity off or wrong Request URLSet …/slack/interactions, save, retry
"That button belongs to an older report"A newer round replaced the fixUse the button on the latest report
Fix PR opens without reviewerresponsibleUsers not a collaborator, or is the PR authorUse another login; labels/reviewers are best-effort and logged

9. Clean up​

cd workers/incident-support && make clear key=<C…:thread_ts> # per investigation, optional
cd .local-aws && make reset && make down
docker rm -f alakai-redis
aws logs delete-log-group --log-group-name /alakai/incident-e2e/prod --profile <sandbox-profile>

Also remove the test app from core/config.json, close any test PRs, and revert the Slack app's Request URLs if other people use it.