Diagnosing Your Feed
Introduction
The doctor checks your definitions, schema, and recorded activities and reports how to fix gaps. In local and testing environments, an unregistered verb throws UnknownVerb by default; a concrete Story definition registers the verb and its headline. By default, publishing without a headline definition throws UnauthoredActivity in local and testing environments. When storyfeed.grammar.strict is disabled, the activity can publish with a null headline; the doctor can find these gaps in already-recorded activities.
Running the Doctor
php artisan storyfeed:doctorFor an order-placement activity recorded with strict grammar disabled and no headline definition, the report shows:
Snapshots compile: cached (STORYFEED_SNAPSHOTS)
Installed: storyfeed/storyfeed dev-main@8b55f7b
No headline resolves for `order.place` — headlines will be null. Guard it in a test with `HeadlineCoverage::assertCoversRecorded()`.
No icon resolves for `order.place`. Guard it in a test with `HeadlineCoverage::assertCoversRecorded()`.
Note: verb `place` has no AS2.0 mapping — will serialize as base `Activity`.
2 finding(s) — see above.
Run with --stubs to print the registrations these imply.
--fail-on=error exit non-zero when an error is present (`warning` gates on warnings too)
--only=<check> report one check at a time; --list names them
--json the same report, machine-readableThe report opens with the snapshot mode and every installed storyfeed/* package, with its commit, so a pasted report says which code produced it. A finding that a coverage assertion guards ends by naming it. The count excludes notes and acknowledged findings. With no active errors or warnings and no acknowledgments, the command prints Storyfeed looks healthy. The flags at the end print on every run.
Most checks query recorded activities, so use a database with traffic, such as staging or a production copy. With no activities, configuration, schema, and registry checks can still report findings; traffic-dependent checks have nothing to inspect.
Running Selected Checks
--list prints the check names, and --only runs the ones you name:
php artisan storyfeed:doctor --list
php artisan storyfeed:doctor --only=grammar --only=verbsEvery check is listed in Doctor Checks.
Reading a Finding
Each finding includes a code, severity, and message. The text report colours messages by severity. Use --json to return the full report:
php artisan storyfeed:doctor --json{
"healthy": false,
"count": 2,
"acknowledged_count": 0,
"severity": "error",
"findings": [
{
"code": "grammar.missing",
"severity": "error",
"message": "No headline resolves for `order.place` — headlines will be null. Guard it in a test with `HeadlineCoverage::assertCoversRecorded()`.",
"subject": {
"type": "order",
"verb": "place"
},
"fix": {
"registry": "grammar",
"key": "order.place",
"tokens": [":actor", ":object", ":target", ":context", ":origin", ":result", ":instrument", ":location", ":generator"],
"snippet": "Story::for(Order::class)->verb('place')->headline(':actor placed :object');",
"definition": "Story::for(Order::class)->verb('place')->headline(':actor placed :object');",
"guard": "Storyfeed\\Testing\\HeadlineCoverage::assertCoversRecorded()"
},
"acknowledgment": null
}
],
"installed": {
"storyfeed/storyfeed": {
"version": "dev-main",
"reference": "8b55f7b53d823c9c7f4031265fa33611211eb5f0"
}
}
}The other findings use the same structure. Findings without a generated fix have "fix": null. acknowledgment is the written reason for an accepted finding, or null. The code's first segment identifies the check; subject identifies what it checked. definition contains the line printed by --stubs, and guard names the test assertion that fails while the finding stands, or is null. installed lists each installed storyfeed/* package.
| Severity | Meaning |
|---|---|
error | the feed displays incorrect content, or publication will throw |
warning | something is missing or inconsistent, but the feed still displays correctly |
info | additional information that may not require a change |
Fixing Common Findings
| Finding | Means | Fix |
|---|---|---|
grammar.missing | a recorded type and verb has no headline | write it in routes/feed.php, or print it with --stubs |
grammar.icon_missing | a recorded type and verb has no icon | add ->icon() |
aggregates.missing | activities group, and the group has no headline | add a group headline, or print it with --stubs |
verbs.undeclared | a recorded verb is not in your vocabulary, usually a typo | fix the call site, or register the verb |
feeds.unclassified | no restricted named feed includes or excludes a verb | add the verb to a feed's only() or except() |
surface.unaliased | a Feedable model has no morph alias, so publishing about it throws | give it an alias, or return its parent's from getMorphClass() (Surface) |
entities.unfeedable | activities name a model that does not implement Feedable | implement Feedable, then run storyfeed:trickle |
backlog.uncached | entities have uncached labels and links | schedule storyfeed:trickle |
tables.missing | a package table does not exist | run the migrations |
See Doctor Checks for all findings.
links.* findings are notes about sampled named-feed pages; see Link Sampling.
Handling Deliberate Findings
To accept a deliberate finding, copy its exact code and complete typed subject from storyfeed:doctor --json into doctor.acknowledgments, with a written reason:
'doctor' => [
'stale_after' => 30,
'acknowledgments' => [
[
'code' => 'grammar.icon_missing',
'subject' => ['type' => 'order', 'verb' => 'place'],
'reason' => 'The order feed deliberately displays headlines without icons.',
],
],
],See Acknowledgment Policy for the supported codes and how accepted findings are counted.
Acknowledging a Custom Query Exclusion
For example, a portal feed may exclude clause rewrites from repeat groups in its custom query while rendering them on the object axis. The doctor can still report aggregates.missing for repeat.agreement.rewrite, because the declared Live mode and verb filter admit that pair. First verify that no surface can return the group, then inspect its complete subject:
php artisan storyfeed:doctor --only=aggregates --jsonIf the finding's subject is exactly the example below, add this entry to the doctor.acknowledgments list in config/storyfeed.php:
[
'code' => 'aggregates.missing',
'subject' => [
'axis' => 'repeat',
'verb' => 'rewrite',
'key' => 'repeat.agreement.rewrite',
'read_by' => 'portal',
],
'reason' => 'The portal custom query excludes rewrite repeat groups; rewrites render on the object axis.',
],Copy your own subject rather than adapting only the key: read_by must match the complete comma-separated reader string, or null, from the finding. Rebuild the configuration cache if your deployment uses one, then rerun php artisan storyfeed:doctor --fail-on=error. The accepted finding stays visible with its reason and no longer fails the command or generates stubs. Other missing headlines still fail. If a reader is added or removed, the subject no longer matches: review the exclusion again before updating the acknowledgment. Changes within an existing custom query are opaque to the doctor, so revisit the reason whenever that query changes.
Generating Missing Definitions
Use --stubs to print suggested definitions for routes/feed.php:
php artisan storyfeed:doctor --stubsuse App\Models\Order;
use Storyfeed\Facades\Story;
Story::for(Order::class)->verb('place')->headline(':actor placed :object');
// order.place: an icon from your app's own set; doctor cannot choose one.
// Story::for(Order::class)->verb('place')->icon('…');Review each stub before adding it. Incomplete stubs, such as icons, are commented out with an explanation. The finding remains until you supply the missing definition. See Doctor Checks for the definitions --stubs generates.
To write Story classes instead, run make:story --from-doctor.
Running the Doctor in CI
By default, findings leave the exit status at 0. Use --fail-on to fail the command at a chosen severity:
php artisan storyfeed:doctor --fail-on=warning # Fails on a warning or an error.
php artisan storyfeed:doctor --fail-on=error # Fails on an error only.Coverage assertions check headlines in your test suite before traffic exists. The doctor checks recorded activities.