Job Types
Every Astra job has a type that determines what signal triggered it, which files Astra loads, and what the PR looks like. There are eight types.
This page is a reference — if you just want to get started, skip to Getting Started.
Quick Reference
| Job Type | Signal Source | Typical PR |
|---|---|---|
error_fix | Errors tab | Null check, guard clause, error handling |
n1_optimization | Methods tab (N+1 detector) | Batch find() outside loop |
index_recommendation | Database tab (COLLSCAN) | createIndex migration + field-order rationale |
query_optimization | Database tab (slow aggregations) | Pipeline reorder, $match earlier |
publication_optimization | System → Code Health | Add fields: projection to publication |
deprecated_api_migration | System → Code Health | Meteor.call → Meteor.callAsync, etc. |
vulnerability_fix | System → Security (npm audit) | Dependency bump or patched version pin |
general_optimization | Manual, from any metric | Ad-hoc performance work with trace context |
Error Fix
Triggers on: uncaught exceptions and failed method invocations surfaced in the Errors tab.
What Astra does: reads the grouped error with its full stack trace, the method handler (or publication handler) the error originated in, and any helpers called along the way. Writes a fix plus a regression test that reproduces the error.
Example PR:
fix(orders): guard against missing customer on checkout
The
orders.checkoutmethod throwsTypeError: Cannot read properties of undefined (reading 'email')whenMeteor.users.findOneAsync()returns no document. This happens when a user deletes their account mid-session. Added a guard and aMeteor.Error('user-not-found')with a corresponding test case.
N+1 Fix
Triggers on: method traces flagged by the N+1 detector — a method that issues the same query shape more than N times in one invocation.
What Astra does: identifies the hot loop, lifts the query outside the loop, and rewrites the callers to use the batched result (usually via Map keyed by _id). Keeps the method's public signature unchanged.
Example PR:
perf(invoices): batch customer lookups in invoices.listForPeriod
invoices.listForPeriodcalledCustomers.findOneAsync(invoice.customerId)inside aforEach, producing 1 + N queries. Replaced with a singlefind({ _id: { $in: customerIds } })and aMaplookup. P95 latency on the method drops from 840ms to 92ms at 200 invoices.
Index Recommendation
Triggers on: slow queries flagged with a COLLSCAN stage in the Database tab.
What Astra does: reads the query shape and sort from the captured trace, proposes a compound index using Meteor's field-order rules (equality → sort → range), and writes a migration that calls createIndexAsync. Includes the rationale in the PR body.
Example PR:
perf(orders): add compound index on
{customerId, createdAt}
orders.forCustomerwas doing a COLLSCAN onorders(12M docs) for the query{customerId: X}with sort{createdAt: -1}. Added{customerId: 1, createdAt: -1}compound index. Mongoexplain()confirms the IXSCAN in the PR comment.
Query Optimization
Triggers on: slow aggregation pipelines captured by the agent (collectSlowAggregations).
What Astra does: reorders $match earlier, consolidates $project + $addFields, and replaces $lookup with a pre-fetched join where a compound index is missing. Leaves result shape unchanged.
Example PR:
perf(analytics): reorder pipeline in siteHealth.summary
$matchontimestampwas running after$group, scanning the full collection. Moved$matchto stage 1 and added an index hint. Aggregation runtime drops from 4.2s to 180ms.
Publication Optimization
Triggers on: publications flagged by the PublicationTracer for over-fetching — returning a cursor without a fields: projection, or projecting fields that are never read by subscribers.
What Astra does: adds a fields: projection that matches the fields the client actually uses (inferred from accompanying client code in the repo).
Example PR:
perf(publications): narrow fields on users.currentProfile
The publication returned the entire
usersdocument includingservices.password.bcryptandservices.resume. Client only readsprofile.name,profile.avatar, andemails. Added afields:projection, dropping DDP payload size from 2.1 KB to 180 B per document.
Publication optimizations can also be a security fix — over-fetching pubs routinely leak password hashes or reset tokens to the client. Astra flags these with a security label on the PR.
API Migration
Triggers on: deprecated Meteor 2.x APIs detected by the agent: sync Meteor.call, sync Collection.find().fetch(), Meteor.wrapAsync, etc.
What Astra does: rewrites the call site to the Meteor 3.x async equivalent, propagates await up the call stack, and converts the enclosing function to async as needed.
Example PR:
refactor: migrate Orders.findOne to findOneAsync
Orders.findOneis deprecated in Meteor 3.x. Replaced 14 call sites withfindOneAsyncand adjusted the enclosing methods to async. All tests pass.
Vulnerability Fix
Triggers on: high or critical advisories reported by the agent's npm audit scan.
What Astra does: bumps the affected dependency to the patched version (prefers a minor or patch bump — falls back to a major bump with a note if required). Runs the test suite before opening the PR.
Example PR:
chore(deps): bump lodash from 4.17.20 to 4.17.21 (CVE-2021-23337)
Fixes a high-severity command injection vulnerability. No code changes required. Tests pass.
General Optimization
Triggers on: manual triggering from the Methods, Database, or System tabs when the signal does not match a more specific type. Also used when a metric anomaly fires and you ask Astra to investigate.
What Astra does: loads the relevant trace plus surrounding code and makes a narrowly-scoped improvement. These PRs are the most variable — treat them as a starting point for a conversation, not a final answer.
Example PR:
perf(dashboard): memoize expensive selector in MetricsView
The
aggregateByHostselector recomputed on every render because its input array was recreated each time. Memoized withuseMemokeyed on the underlying map. Removes a 300ms stall on the Metrics tab.
Picking Allowed Job Types
The Allowed Job Types filter in Trigger Settings lets you whitelist which types Astra is permitted to run automatically. A conservative starting set is:
error_fixvulnerability_fixdeprecated_api_migration
These are the lowest-risk, highest-signal types. Add n1_optimization and index_recommendation once you are comfortable reviewing performance PRs, and save query_optimization / general_optimization for last — they benefit most from manual triggering.
Next Steps
- Triggering Astra — How automatic and manual triggers work
- Getting Started — Activate Astra on your first site
- Overview — Pipeline and safety model