Recovery

Troubleshooting and recovery

Use structured errors, request IDs, recovery fields, dry-runs, and idempotency keys so humans and agents can recover without unsafe retries.

Rule

Retry reads with backoff. Retry writes only with idempotency metadata or after a fresh dry-run.

Unauthorized

Refresh the token, verify scope, and never print the token value.

Lock conflict

List locks, identify the owner, and wait or ask for release before editing.

Rate limited

Back off. Use pagination and avoid repeated token minting loops.

Service unavailable

Record `requestId`, retry safe reads once, and escalate persistent failures.

Structured error fields

ForgeLore errors include `code`, `message`, `retryable`, `safeToRetry`, `requiredScope`, `requestId`, `nextAction`, `docsUrl`, and `recovery` when available.

Recovery commands

$forgelore agent recover VALIDATION_ERROR
$forgelore agent recover FORBIDDEN
$forgelore agent recover LOCK_CONFLICT
$forgelore lore doctor <lore-remote>

Agent recovery loop

  1. Read the structured error envelope.
  2. Stop immediately if `safeToRetry` is false.
  3. If a scope is missing, report the required scope and do not escalate privileges automatically.
  4. If a lock conflict exists, list locks and report the owner/path before changing assets.
  5. If retry is safe, use backoff and idempotency keys for writes.

When to escalate

Escalate after a safe retry fails, when `safeToRetry` is false, or when recovery requires a role change, force unlock, payment action, permanent deletion, secret access, or production infrastructure change. Include the error code and request ID, but never include credentials.