| name | applying-staging-candidate |
| description | Use internally when /refactor-mart dispatches one approved Type: stg candidate |
Applying Staging Candidate
Apply one approved staging candidate and update only that candidate section.
Inputs
Parse exactly two positional arguments:
<plan-file> <candidate-id>
Read references only when needed:
references/staging-validation-contract.md before deciding scope, rewrites, validation, or status writeback.
references/status-writeback.md before updating plan status.
Checks
- Missing plan file: stop with
PLAN_NOT_FOUND.
- Missing candidate section: stop with
CANDIDATE_NOT_FOUND.
- Before editing files or plan status, extract the plan
Targets plus the candidate Output: and Validation: model names, then scan matching catalog table and view entries for unresolved diagnostics with severity: "error". If any exist, stop with CATALOG_ERRORS_UNRESOLVED, report the catalog object and error code, and do not apply, validate, or update the candidate.
- Candidate not approved with
- [x] Approve: yes: stop with CANDIDATE_NOT_APPROVED.
Type: is not stg: stop with NON_STAGING_CANDIDATE; do not change execution status.
- Missing or invalid
Output: for a stg_* model: mark this candidate blocked.
- Missing or ambiguous downstream scope: mark this candidate
blocked.
Workflow
- Read the plan and isolate
## Candidate: <candidate-id>.
- Extract
Output: and Validation:.
- Resolve staging output and downstream consumers using
references/staging-validation-contract.md.
- Create or update the declared
stg_* model.
- Rewire every resolved downstream consumer file so it references the declared
stg_* model with ref().
- Run the smallest validation command covering the staging model and resolved consumers. Prefer the command listed in
Validation:.
- Update only this candidate section using
references/status-writeback.md.
Completion
Report:
applying-staging-candidate complete -- <candidate-id>
status: applied|failed|blocked
validation: <command or reason>
plan: <plan-file>