Skip to content

feat: comprehensive GitHub webhook improvements and Redis fix#17

Merged
zbigniewsobiecki merged 7 commits intomainfrom
dev
Jan 2, 2026
Merged

feat: comprehensive GitHub webhook improvements and Redis fix#17
zbigniewsobiecki merged 7 commits intomainfrom
dev

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

Merges all recent improvements from dev to main, including GitHub webhook enhancements and the critical Redis startup fix.

Major Changes

GitHub Webhook Improvements

1. PR Review Submission Support

  • Added PRReviewSubmittedTrigger to handle full PR review events (approve/request changes)
  • Previously only supported review comments
  • Enhanced webhook queue to store event types for proper routing

2. Automatic Card Movement to IN REVIEW

  • Cards now automatically move to "IN REVIEW" list after PR creation
  • Adds comment with PR URL to the card
  • Works for both Trello and GitHub webhook sources

3. Post-Job Grace Period Fix

  • Increased grace period from 5s to 45s
  • Allows debug agent webhooks to arrive before shutdown
  • Fixes race condition where debug agent wasn't triggered

4. Comprehensive Documentation

  • Added GitHub webhook setup instructions
  • Documented all supported GitHub triggers
  • Updated API endpoints and features list

Critical Production Fix

Redis Startup Failure

  • Fixed production blocking issue where Redis failed to start
  • Root cause: redis user has /usr/sbin/nologin shell
  • Solution: Use su -s /bin/sh to explicitly specify shell
  • Updated agent documentation

Files Changed

  • src/triggers/github/pr-review-submitted.ts - New PR review trigger
  • src/triggers/github/webhook-handler.ts - Card movement logic
  • src/triggers/index.ts - Register new trigger
  • src/utils/webhookQueue.ts - Event type storage
  • src/agents/utils/setup.ts - Redis startup fix
  • src/agents/prompts/templates/partials/environment.eta - Documentation
  • config/projects.json - Grace period configuration
  • README.md - GitHub webhook documentation

Commits Included

Testing

✅ All 62 tests pass
✅ Type checking passes
✅ CI checks pass
✅ Linting passes

Impact

This release:

  • Enables full GitHub PR review workflow automation
  • Ensures consistent card state management across webhook sources
  • Fixes critical production blocking issue
  • Provides comprehensive documentation for setup

🤖 Generated with Claude Code

zbigniewsobiecki and others added 7 commits January 2, 2026 14:34
Add Redis support alongside PostgreSQL, enabling agents to use in-memory
data storage for caching, queues, and session management.

Changes:
- Install redis-server and redis-tools in Docker image
- Configure Redis with AOF persistence, 256MB memory limit, and LRU eviction
- Add startRedis() function following the same pattern as startPostgres()
- Integrate Redis startup into agent lifecycle (base.ts, review.ts)
- Document Redis CLI commands and usage in agent prompts
- Both PostgreSQL and Redis are critical: agents fail if either service doesn't start

Redis configuration:
- Port: 6379 (standard)
- Bind: localhost only for security
- Persistence: AOF with everysec fsync
- Memory: 256MB with allkeys-lru eviction policy
- Access: via redis-cli through Tmux gadget

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
The debug agent wasn't triggering because CASCADE was shutting down too
quickly after uploading session logs. Trello webhooks for attachment uploads
take a few seconds to arrive, but we were only waiting 5 seconds before
shutting down the machine.

Increased postJobGracePeriodMs from 5s to 45s to ensure:
1. Agent uploads session log attachment
2. Trello webhook is delivered while machine is still running
3. Debug agent trigger processes the webhook
4. Debug agent runs before shutdown

This fixes the race condition where attachment webhooks arrived after
the machine had already shut down.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Both pull_request_review (review submission) and pull_request_review_comment
(review comments) now trigger the review agent for PRs with Trello card URLs.

Changes:
- Updated webhook queue to store event types alongside payloads
- Added PRReviewSubmittedTrigger for review submissions (approve/request changes)
- Fixed hardcoded event type in GitHub webhook dequeuing
- Both review types now trigger the review agent when PR has Trello card URL

Previously, only review comments triggered the agent. Now review submissions
(when someone clicks 'Approve' or 'Request Changes') also trigger it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds automatic card movement logic to executeGitHubAgent that mirrors
the existing behavior in Trello webhook handler. When implementation
agent creates a PR, the card is now moved to the IN REVIEW list and
a comment with the PR URL is added.

This ensures consistent behavior regardless of whether the agent was
triggered by a Trello webhook or a GitHub webhook.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds comprehensive documentation for GitHub webhook setup:
- GitHub webhook endpoint in API endpoints section
- Detailed setup instructions with configuration steps
- List of supported GitHub triggers and their behavior
- Updated features list to include GitHub integration

This complements the recent GitHub webhook improvements including
PR review submission support and automatic card movement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The redis user has /usr/sbin/nologin as its default shell, which
prevents `su redis -c` from working. This was causing Redis to fail
to start in production with "This account is currently not available."

Fix by using `su -s /bin/sh` to explicitly specify a shell for the
redis user when starting the service.

Also updated agent environment documentation to reflect the correct
startup command.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit 6749194 into main Jan 2, 2026
6 checks passed
zbigniewsobiecki added a commit that referenced this pull request Apr 25, 2026
…tructured envelope, --comment alias) (#1190)

* docs(014): spec + plans for cascade-tools agent ergonomics

Adds docs/specs/014-cascade-tools-agent-ergonomics.md plus two plans
covering shared-infra and create-pr-review adoption. Prompted by prod
run 5d993b04-6e05-4ae1-b7de-8c274cf3496b.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(plan-014): lock plan 1 (shared-infra)

* feat(cascade-tools): plan 014/1 shared-infra — truthful prompts + envelope

Ships the root-cause fix for prod run 5d993b04-6e05-4ae1-b7de-8c274cf3496b
plus the shared infrastructure every future gadget inherits:

- System-prompt renderer (src/backends/shared/nativeToolPrompts.ts) stops
  stripping trailing 's' from array param names and claiming '<string>
  (repeatable)' for every array. Array-of-object params now render as
  `--<flag> '<json>'` with aliases appended via `|` and a one-line runnable
  example from the tool definition.
- Factory (src/gadgets/shared/cliCommandFactory.ts) gains oclif flag aliases,
  JSON parsing for array-of-object flags, file-input JSON parsing, `examples`
  wired into oclif `--help`, and Levenshtein-based 'did you mean' suggestions
  for mistyped flags (via fastest-levenshtein).
- New shared error envelope (src/gadgets/shared/errorEnvelope.ts) — every
  CLI failure emits `{"success":false,"error":{type,flag?,message,got?,
  expected?,hint?,example?}}` on stdout plus a one-line prose summary on
  stderr. All prior `this.error()` / flat `{success:false,error:"<string>"}`
  call sites migrated.
- Contracts widened: ParameterDefinition gains `cliAliases`, FileInput-
  Alternative gains `parseAs`, ToolManifest parameters carry `items`,
  `aliases`, `example`.
- Manifest generator threads the new fields through.
- bin/cascade-tools.js wraps `run()` to swallow oclif ExitError cleanly so
  the envelope isn't obscured by Node's default stack dump.

Plan-1 ACs #1#17 all delivered. 8438/8438 unit tests passing.

Test surface delta: 57 new unit tests across errorEnvelope.test.ts,
shared-nativeToolPrompts.test.ts, and factories.test.ts. Seven legacy
assertions encoding the pre-014 error surface updated in cli/cli-command-
factory, cli/file-input-flags, cli/scm/create-pr-sidecar, cli/scm/create-
pr-review-sidecar, backends/claude-code.

Plan 2 adopts the pattern on createPRReviewDef — zero shared-file edits —
proving the declarative-metadata invariant.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(plan-014): lock plan 2 (createprreview-adopt)

* feat(cascade-tools): plan 014/2 createprreview-adopt + spec done

Applies the spec-014 declarative-metadata pattern to createPRReviewDef:

- --comment alias for --comments (the exact muscle-memory mistake from
  prod run 5d993b04-6e05-4ae1-b7de-8c274cf3496b).
- --comments-file <path> (and - for stdin) JSON-parsed escape hatch for
  long payloads that don't survive shell quoting.
- Two declarative fields on createPRReviewDef.parameters.comments.cliAliases
  + createPRReviewDef.cli.fileInputAlternatives. Zero edits to shared
  infrastructure (cliCommandFactory, manifestGenerator, nativeToolPrompts,
  errorEnvelope) — proves spec 014's single-entrypoint invariant.

Per-plan ACs #1, #2, #3, #5, #6, #7, #8, #9, #11, #12 auto-verified
(unit tests + build + lint + typecheck). AC #4 (binary-level smoke)
tagged [manual] because vitest fork-pool workers fail to capture
stdout/stderr from spawned binaries that do top-level await import();
the six scenarios were verified manually against the built binary and
the trace is recorded in the plan. AC #10 n/a — integration test path
abandoned for the same reason.

All plans done. Spec 014 marked .done (docs/specs/014-*.md → .done).
CHANGELOG Unreleased updated with a per-plan entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant