feat: verify: block on commands, with optional onFail remediation (closes #38)#86
Conversation
Profiles and per-repo raid.yaml files accept a top-level `verify:` list. Each entry runs `tasks:` to assert a precondition; an optional `onFail:` remediation gets one chance to fix things before raid re-runs `tasks:` once. RunVerify returns a structured VERIFY_FAILED error so JSON consumers and the future doctor integration (#42) can pivot on the code. No new CLI command in this PR — RunVerify is wired to doctor in #42. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #86 +/- ##
==========================================
- Coverage 92.33% 92.33% -0.01%
==========================================
Files 36 37 +1
Lines 3355 3380 +25
==========================================
+ Hits 3098 3121 +23
- Misses 166 168 +2
Partials 91 91 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds declarative verify: configuration support for profiles and per-repo configs, including execution logic, schema support, public re-exports, structured errors, tests, templates, and documentation.
Changes:
- Introduces
VerifyandRunVerifywith optional one-shotonFailremediation. - Adds
verifyfields to profile/repo models and schemas, including merge behavior for per-reporaid.yaml. - Documents verify blocks and adds tests for execution, validation, and public error exports.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/internal/lib/verify.go |
Adds verify model and runner logic. |
src/internal/lib/verify_test.go |
Tests verify pass/fail/remediation behavior. |
src/internal/lib/repo.go |
Adds repo-level verify config and merge support. |
src/internal/lib/repo_test.go |
Tests repo schema validation for verify blocks. |
src/internal/lib/profile.go |
Adds profile-level verify config. |
src/internal/lib/profile_test.go |
Tests profile schema validation for verify blocks. |
src/internal/lib/errs/raid_error.go |
Adds VERIFY_FAILED error code. |
src/internal/lib/errs/constructors.go |
Adds VerifyFailed structured error constructor. |
src/internal/lib/errs/raid_error_test.go |
Covers verify error constructor. |
src/raid/raid.go |
Re-exports verify type and runner. |
src/raid/errs/errs.go |
Re-exports verify error code and constructor. |
src/raid/errs/errs_test.go |
Tests public verify error export. |
schemas/raid-defs.schema.json |
Defines shared verify schema. |
schemas/raid-profile.schema.json |
Wires verify into profile schema. |
schemas/raid-repo.schema.json |
Wires verify into repo schema. |
src/resources/profile-template |
Adds commented verify example. |
src/resources/repo-template |
Adds commented verify example. |
site/docs/references/schema.mdx |
Adds schema reference docs for verify. |
site/docs/whats-new.mdx |
Adds upcoming release note for verify support. |
| // OnFail is the optional one-shot remediation. When present, a | ||
| // first-pass failure triggers OnFail followed by exactly one | ||
| // re-run of Tasks. Empty OnFail means the first failure is final. | ||
| OnFail []Task `json:"onFail,omitempty"` |
| # Each entry asserts a dependency or environmental precondition. raid doctor | ||
| # runs every verify and reports pass/fail. An optional `onFail:` remediation | ||
| # gets exactly one chance to fix things before the entry is reported as failed. |
| # Each entry asserts a dependency or environmental precondition. raid doctor | ||
| # runs every verify and reports pass/fail. An optional `onFail:` remediation | ||
| # gets exactly one chance to fix things before the entry is reported as failed. |
|
|
||
| Declarative precondition checks. Each entry runs `tasks:` to assert that a dependency or environmental requirement is in place. An optional `onFail:` remediation gets exactly one chance to fix things — if remediation succeeds, raid re-runs `tasks:` once; if that pass succeeds the verify is reported as remediated, otherwise it fails. | ||
|
|
||
| Verify entries are accepted on both profiles and per-repo `raid.yaml` files. They share execution context with `install:` — the active environment, raid vars, and task options all apply. Today verify entries are surfaced by `raid doctor`; future releases will add a dedicated `raid verify` command. |
| CodeRepoNotCloned = "REPO_NOT_CLONED" | ||
| CodeEnvNotFound = "ENV_NOT_FOUND" | ||
| CodeCommandNotFound = "COMMAND_NOT_FOUND" | ||
| CodeVerifyFailed = "VERIFY_FAILED" |
- Add explicit yaml tags to Verify (gopkg.in/yaml.v3 lowercases by default, so `onFail:` in YAML was being silently dropped from OnFail). Add a YAML round-trip test covering camelCase extraction. - Fix repo-template, profile-template, and schema.mdx wording: `raid doctor` integration is deferred to #42; entries are accepted by the schema today and will be surfaced by doctor in a future release. - Document VERIFY_FAILED in site/docs/references/errors.mdx so users consuming structured errors can discover the new code. Co-Authored-By: Copilot <copilot@github.com>
|
Auto-review by meeseeks Updates pushed: 1 commit
Copilot comments addressed: 5 of 5
Skipped: 0 Codecov patch: 92.00% (project 92.33%) — within 8pt rule (-0.33pp), pass. The 2 uncovered lines flagged are in Other CI: green (build/macos/ubuntu/windows, docs, version-check, CodeQL all pass) |
Summary
Closes #38.
Profiles and per-repo
raid.yamlfiles now accept a top-levelverify:list. Each entry runstasks:to assert a precondition (a tool installed, a port reachable, a credentials file present), and an optionalonFail:remediation gets exactly one chance to fix things — if it succeeds, raid re-runstasks:once and the verify is reported as remediated; otherwise it surfaces as a structuredVERIFY_FAILEDerror (categoryconfig, exit2).Verifytype andRunVerify(v) errorhelper insrc/internal/lib/verify.go; re-exported viasrc/raid/raid.go.Verify []Verifyfield onProfileandRepo(the latter merged from per-reporaid.yamllike other fields).verifyArray$definraid-defs.schema.json, wired into bothraid-profile.schema.jsonandraid-repo.schema.jsonvia$ref. Entries requirename+tasksand accept the full shared task surface (incl.options.continueOnFailure) — same$refused byinstall.tasks, environments, and commands.CodeVerifyFailed(VERIFY_FAILED) underCategoryConfigwith aVerifyFailed(name, cause)constructor; re-exported throughsrc/raid/errs.# verify:example so authors see the shape afterraid profile create.Out of scope (deferred to #42): no
raid verifyCLI command. Verify entries are valid config andRunVerifyis ready to call, but the doctor wiring that surfaces them as health-report findings ships with #42.Verify execution shares context with
install:— the active env, raid vars, and task options all apply. No isolation flags, no retry-with-backoff (one re-run afteronFail, per the issue).Test plan
go test ./... -race— all packages greensrc/internal/lib/verify_test.gocover: passes, fails-without-onFail (assertsVERIFY_FAILEDcode +details.verify), remediation-succeeds (asserts retry pass ran via marker), remediation-fails (asserts retry did NOT run), second-pass-fails, empty-tasks no-op,IsZeroprofile_test.go/repo_test.goexercise accept/reject paths (missingname, missingtasks, unknown field)RunVerifyandVerifyFailedat 100% line coverage; project coverage 95.0%TestPublishedSchemas_matchEmbeddedgreen (site/static/schema/v1/regenerated via docusaurus plugin on build — gitignored, not committed)cd site && npm run build— no broken links/docs/references/schema#verify) andwhats-new.mdx 0.14.0 — upcomingentry added🤖 Generated with Claude Code