Skip to content

Commit d6d79a1

Browse files
committed
updates adding 2nd queue for ai pr review triggering on our end
1 parent 52e1826 commit d6d79a1

6 files changed

Lines changed: 920 additions & 6 deletions

File tree

.env.dist

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,35 @@
22
# https://github.com/organizations/interserver/settings/hooks
33
GITHUB_WEBHOOKS_SECRET=
44

5-
# Notification queue settings — when NOTIF_QUEUE_ENABLED=true the github
6-
# webhook pushes envelopes onto Redis for the teams-chat-bot to consume.
7-
# When false (default), it falls through to direct Power Automate POSTs.
5+
# =============================================================================
6+
# Notification Queue (for RocketChat/Teams chat notifications)
7+
# =============================================================================
8+
# When NOTIF_QUEUE_ENABLED=true the github webhook pushes envelopes onto Redis
9+
# for the teams-chat-bot to consume. When false (default), it falls through to
10+
# direct Power Automate POSTs.
811
NOTIF_QUEUE_ENABLED=true
912
NOTIF_QUEUE_KEY_PREFIX=notif:
1013

14+
# =============================================================================
15+
# Code Review Queue (for automated PR code review)
16+
# =============================================================================
17+
# GitHub personal access token with repo scope to post PR comments.
18+
# Create at: https://github.com/settings/tokens
19+
GITHUB_TOKEN=
20+
21+
# Local directory where PR branches are checked out for analysis.
22+
# Should have adequate disk space. Each checkout is shallow (depth 1) and
23+
# is deleted after analysis.
24+
CHECKOUT_ROOT=/tmp/pr-checkouts
25+
26+
# OpenCode CLI analyze command template. {dir} is replaced with the checkout path.
27+
# The command should output JSON issues array (see parseAnalysisOutput).
28+
OPENCODE_ANALYZE_CMD=opencode analyze --dir {dir} --output json 2>/dev/null
29+
30+
# OpenCode CLI improve/fix command template. {dir}, {file}, {line} are replaced.
31+
# Should output JSON with the fixed file content (see parseImproveOutput).
32+
OPENCODE_IMPROVE_CMD=opencode improve --dir {dir} --file {file} --line {line} --output json 2>/dev/null
33+
1134
# Redis / Dragonfly connection (used by NotificationQueue when enabled).
1235
# These are only consulted as a fallback — the canonical values come from
1336
# /home/sites/mystage/include/config/config.settings.php which src/config.php

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.logs
12
.env
23
vendor/
34
src/config.php

CLAUDE.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ vendor/bin/phpunit
1010
vendor/bin/phpstan analyse
1111
vendor/bin/php-cs-fixer fix --dry-run
1212
vendor/bin/php-cs-fixer fix
13+
php scripts/github-code-review.php
1314
```
1415

1516
## Architecture
1617

1718
- **Entry**: `web/github.php` (active) · `web/github-old.php` (legacy, RC-only)
18-
- **Core**: `src/GithubWebhook.php` · `src/GithubMessageBuilder.php` · `src/NotificationQueue.php` · `src/IgnoredEventException.php` · `src/NotImplementedException.php`
19-
- **Config**: `.env` (copied from `.env.dist`) — defines `GITHUB_WEBHOOKS_SECRET`, `NOTIF_QUEUE_ENABLED`, `NOTIF_QUEUE_KEY_PREFIX`, `REDIS_HOST`, `REDIS_PORT`, `LOG_LEVEL`, `RATE_LIMIT_WINDOW`. RocketChat / Teams webhook URLs live in `src/config.php` (gitignored) under `$chatChannels['rocketchat']` / `$chatChannels['teams']`
19+
- **Core**: `src/GithubWebhook.php` · `src/GithubMessageBuilder.php` · `src/NotificationQueue.php` · `src/CodeReviewQueue.php` · `src/IgnoredEventException.php` · `src/NotImplementedException.php`
20+
- **Config**: `.env` (copied from `.env.dist`) — defines `GITHUB_WEBHOOKS_SECRET`, `NOTIF_QUEUE_ENABLED`, `NOTIF_QUEUE_KEY_PREFIX`, `REDIS_HOST`, `REDIS_PORT`, `LOG_LEVEL`, `RATE_LIMIT_WINDOW`, plus code-review queue keys. RocketChat / Teams webhook URLs live in `src/config.php` (gitignored) under `$chatChannels['rocketchat']` / `$chatChannels['teams']`
2021
- **Logs**: `log/Y/m/d/` — JSON files named `His_eventtype_action_user_repo.json` (verbosity controlled by `LOG_LEVEL`)
22+
- **Code review**: `src/CodeReviewQueue.php` enqueues push events for async review by `scripts/github-code-review.php`
2123
- **Field analysis**: `scripts/analyze_fields.php`, `scripts/filter_webhook.php`, `scripts/filter_webhook_batch.php` produce reports under `field_analysis_full/` (per-group JSON, `frequency_matrix.json`, `FIELD_CATEGORIZATION.md`)
2224
- **Tests**: `tests/` via `phpunit.xml` · fixtures in `tests/events/{event_name}/`
2325
- **Quality**: `phpstan.neon` · `phpstan-bootstrap.php` · `.php-cs-fixer.dist.php` (PSR2 + PHP74Migration)
@@ -41,7 +43,8 @@ $Msg = $Builder->build();
4143
// or unavailable
4244
$queue = new NotificationQueue();
4345
$queue->enqueueMessage($room, $Msg['text'], $dedupKey, $EventType, $action, $RepositoryName, $Message, $fallbackWebhookUrl);
44-
// 5. Log disposition via NotificationQueue::getLastStatus()
46+
// 5. For push events, also enqueue to CodeReviewQueue for async review
47+
// 6. Log disposition via NotificationQueue::getLastStatus()
4548
```
4649

4750
## NotificationQueue

0 commit comments

Comments
 (0)