Skip to content

cdp_repair_action

Self-repair an L3 reusable action whose Maestro replay failed with SELECTOR_NOT_FOUND. Loads the action from .rn-agent/actions/<actionId>.yaml, snapshots the live device, fuzzy-matches the failed testID against current testIDs (Levenshtein-based), and patches the YAML in place. Guardrails: refuses if a human edited the YAML since the agent last wrote (mtime check), refuses if the rolling-24h repair budget is exhausted (3 attempts/24h). On success, bumps revision, demotes status to “experimental” until the next clean replay re-validates, and appends a RepairRecord to the sidecar. Pass dryRun=true to preview the diff without writing.

NameTypeRequiredDefaultConstraintsDescription
actionIdstringYesAction id matching <projectRoot>/.rn-agent/actions/<actionId>.yaml.
failedSelectorstringYesThe testID that the prior maestro_run reported as missing. Parse it from stderr like “Element with id ‘X’ not found” → X.
projectRootstringNoOverride project root (default: process.cwd()).
thresholdnumberNomin: 0, max: 1Fuzzy-match similarity threshold (0..1). Default 0.6. Lower if the screen has many similar testIDs and Levenshtein on the original is too strict.
dryRunbooleanNoDon’t write changes — return the diff that WOULD be applied. Useful for previewing repairs before committing.
agentReasoningstringNoFree-form one-liner the agent records in the RepairRecord. Helps audit “why did this repair happen”. Max ~200 chars recommended.
cdp_repair_action(actionId: <string>, failedSelector: <string>)