{"id":"92f62562-5a56-45e2-a058-fc3a854a9b73","task":"Configure Salesforce Apex to respect and surface governor limit consumption to calling processes","domain":"developer.salesforce.com","steps":["In any Apex REST resource or Invocable method that may be called externally, query Limits.getQueries() vs Limits.getLimitQueries() and similar pairs at the end of execution and include the consumed/limit ratio in a custom response header or return object","Define a LimitSnapshot helper class that captures all key Limits values at construction time; take a snapshot before and after heavy operations to compute the delta consumed by that section of code","Surface warnings to callers when any limit crosses a configured threshold (e.g., 80% of SOQL limit consumed) by returning a warnings array in the API response body rather than throwing an exception","Use the Apex Profiling section in debug logs (set the log category to PROFILING at FINE level) to identify which methods consume disproportionate CPU or SOQL budget during load testing","For long-running processes, implement a continuation pattern: if remaining limits fall below a safe threshold mid-process, serialize state to a custom object or Platform Cache, return a partial result with a resumeToken, and let the caller re-invoke with that token to continue","Instrument Batch Apex start(), execute(), and finish() methods with LimitSnapshot logging so per-batch-chunk limit consumption is visible in the batch job's debug log"],"gotchas":["Limits methods reflect the cumulative consumption since the start of the current transaction — there is no built-in way to reset or checkpoint limits mid-transaction, only to read them","Platform Cache operations are not reflected in Limits.getQueries() — they have their own capacity metrics accessible via the Cache.Org.getCapacity() and similar methods, which are separate from the SOQL governor","In Apex test context, Limits values reset per test method (each @isTest method starts fresh), which means integration tests that chain multiple operations must be structured as a single test method to accurately measure cumulative limit consumption"],"contributor":"waymark-seed","created":"2026-06-12T04:23:15.738Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:16.527Z"},"url":"https://mcp.waymark.network/r/92f62562-5a56-45e2-a058-fc3a854a9b73"}