Signals and Signal Sources: Add layouts, permissions, and review actions
Back to Signals and Signal Sources.
Add layouts, permissions, and review actions
Section titled “Add layouts, permissions, and review actions”Capabilities create storage fields, not an instance-specific user experience. Add normal index and detail layouts that reference the generated field identifiers, then add the modules to a menu and grant roles access.
For signal triage, useful index tabs are:
- Classification errors.
- Pending classification.
- Relevant (
safe = true,relevant = true). - Safe but not relevant.
- Unsafe.
- All signals.
Keep these filters mutually exclusive by also filtering classified tabs by accepted or rejected. Otherwise the
default false values of unclassified checkbox fields can make pending signals appear as unsafe.
For failed classifications, expose a detail-layout button only when status == 'classification_failed'. Its webhook
workflow can call action/retrySignalClassification, followed by action/refresh. The action clears the previous
classification and error fields, sets pending_classification, and queues one deduplicated ClassifySignal job.
Human-review buttons should invoke workflows instead of making review_state and agent_release_state freely editable.
A typical setup provides:
- Approve and reject actions for cases.
- Approve and reject actions for work items.
- A separate release action that checks
review_state == 'approved'before settingagent_release_state = 'released'. - A withhold action that returns the release state to
withheld. reviewed_byorapproved_byset touser()in the workflow.
See Workflow-backed Buttons for the declarative UI and workflow pattern.
Add another signal driver
Section titled “Add another signal driver”Polling signal drivers are pull-based. Implement SignalDriver for a channel that can be polled, such as a webhook staging
table, message queue adapter, support API, filesystem inbox, or CRM event feed.
<?php
namespace App\Signals\Drivers;
use App\Signals\Contracts\SignalDriver;use App\Signals\SignalEnvelope;use App\Signals\SignalPollResult;use Carbon\CarbonImmutable;
final class SupportApiSignalDriver implements SignalDriver{ public function poll(array $configuration, array $cursor): SignalPollResult { $after = $cursor['last_id'] ?? null; $records = $this->loadRecords($configuration, $after);
$signals = array_map( fn(array $record) => new SignalEnvelope( sourceKey: 'ticket:' . $record['id'], type: 'support.ticket.received', occurredAt: CarbonImmutable::parse($record['created_at'])->utc(), payload: $record, ), $records, );
return new SignalPollResult( signals: $signals, cursor: ['last_id' => $records === [] ? $after : end($records)['id']], ); }
private function loadRecords(array $configuration, mixed $after): array { // Fetch records from the external channel. return []; }}Register it during application boot:
use App\Signals\Drivers\SupportApiSignalDriver;use App\Signals\SignalDriverManager;
public function boot(SignalDriverManager $signals): void{ $signals->extend('support_api', SupportApiSignalDriver::class);}Add support_api to the drivers option of SignalSources, expose any driver-specific fields, and map them through
the generic configuration JSON field. The built-in dedicated field mapping is fixed; arbitrary driver keys belong in that JSON. A driver must:
- Return stable
sourceKeyvalues within one source. - Return UTC occurrence times.
- Keep payloads JSON-serializable and bounded.
- Treat the incoming cursor as opaque driver state.
- Return the next cursor only after it has successfully collected the corresponding envelopes.
- Avoid irreversible changes to the external channel during polling.
Plan, apply, and enable
Section titled “Plan, apply, and enable”Use a targeted plan before changing a live system:
php bakery plan examplephp bakery apply exampleReview the complete plan. apply recalculates the plan and may include unrelated changes in a dirty system definition.
Recommended rollout order:
- Apply migrations and the four modules while all sources are disabled.
- Start or verify the queue worker and scheduler.
- Verify provider credentials and both model tiers with CLI agent runs.
- Enable one source with a small bootstrap window.
- Confirm
last_polled_at, source status, and newly created signal records. - Confirm rejected signals remain visible and accepted signals reach
processed. - Review generated cases and work items before releasing anything to agents.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Check |
|---|---|
Source stays idle | Is enabled true, and does the server invoke schedule:run every minute? |
Source becomes error | Inspect last_error, IMAP connectivity, credentials, encryption, folder names, and certificate validation. |
Signals stay pending_classification | Is the system queue worker running, and can the small model be resolved? |
Signals become classification_failed | Inspect error and the associated agent run. Fix the cause, then use the retry-classification button. The agent must return valid structured JSON. |
| Accepted signals never become cases | Ensure the Cases and CaseWorkItems capabilities are applied and the large model is available. |
| The same messages are fetched again | Check the source cursor and UIDVALIDITY. Duplicate signal records should still be prevented by source_key. |
Cursor returns to {} or the source becomes idle after php bakery apply | Remove the runtime fields from the seed and use policy: detach for the source entity. |
| Poll succeeds but creates no signals while newer mail exists | Compare the cursor UID with the highest persisted signal UID and IMAP UIDNEXT. A cursor behind already persisted messages advances in max_messages_per_poll batches without creating duplicates. |
| Old mail is not imported | Increase bootstrap_days, clear the source cursor intentionally, and poll again. Expect deduplication to skip known messages. |
| Too many messages are processed | Lower max_messages_per_poll; the driver enforces a maximum of 100 per folder and poll. |