Skip to main content

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 TypeSignal SourceTypical PR
error_fixErrors tabNull check, guard clause, error handling
n1_optimizationMethods tab (N+1 detector)Batch find() outside loop
index_recommendationDatabase tab (COLLSCAN)createIndex migration + field-order rationale
query_optimizationDatabase tab (slow aggregations)Pipeline reorder, $match earlier
publication_optimizationSystem → Code HealthAdd fields: projection to publication
deprecated_api_migrationSystem → Code HealthMeteor.callMeteor.callAsync, etc.
vulnerability_fixSystem → Security (npm audit)Dependency bump or patched version pin
general_optimizationManual, from any metricAd-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.checkout method throws TypeError: Cannot read properties of undefined (reading 'email') when Meteor.users.findOneAsync() returns no document. This happens when a user deletes their account mid-session. Added a guard and a Meteor.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.listForPeriod called Customers.findOneAsync(invoice.customerId) inside a forEach, producing 1 + N queries. Replaced with a single find({ _id: { $in: customerIds } }) and a Map lookup. 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.forCustomer was doing a COLLSCAN on orders (12M docs) for the query {customerId: X} with sort {createdAt: -1}. Added {customerId: 1, createdAt: -1} compound index. Mongo explain() 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

$match on timestamp was running after $group, scanning the full collection. Moved $match to 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 users document including services.password.bcrypt and services.resume. Client only reads profile.name, profile.avatar, and emails. Added a fields: projection, dropping DDP payload size from 2.1 KB to 180 B per document.

Data exposure

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.findOne is deprecated in Meteor 3.x. Replaced 14 call sites with findOneAsync and 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 aggregateByHost selector recomputed on every render because its input array was recreated each time. Memoized with useMemo keyed 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_fix
  • vulnerability_fix
  • deprecated_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