Repository navigation
✨ feat(lab): LAB-H04 assert helpers for DOC-02 verdicts - #267
Merged
Merged
Conversation
Offline-sourceable count/checksum compare helpers that emit LAB-DOC-02 verdicts (plus BLOCKED) and never coerce skip/blocked/limit into pass.
There was a problem hiding this comment.
Pull request overview
Adds a new Bash “lab assert” helper library and a meta-test suite to ensure LAB-DOC-02 verdict mappings and comparison helpers (counts + checksum) behave consistently and never coerce non-pass states into pass.
Changes:
- Introduces
hack/lab/lib/assert.shwith verdict validation, structured JSON emitters, count comparison, checksum comparison, and outcome→verdict mapping helpers. - Adds
hack/test/lab_assert_meta_test.shto validate allowed verdicts, pass/fail semantics, reason requirements, JSON shapes, and comparison-to-verdict mapping.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| hack/test/lab_assert_meta_test.sh | Adds a meta-test harness to validate verdict mapping and comparison helper behavior. |
| hack/lab/lib/assert.sh | Adds the assert/verdict helper library (verdict rules + counts/checksum comparison + mapping). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+97
to
+101
| def keys_order: ["source", "store", "inventory", "sink"]; | ||
| def as_counts: | ||
| if type != "object" then error("counts must be a JSON object") end | ||
| | . as $o | ||
| | reduce keys_order[] as $k ({}; .[$k] = ($o[$k] // null)); |
Comment on lines
+114
to
+121
| )" || { | ||
| printf 'lab_assert: compare_counts failed to parse JSON\n' >&2 | ||
| return 1 | ||
| } | ||
|
|
||
| printf '%s\n' "${result}" | ||
| [[ "$(jq -r '.outcome' <<<"${result}")" == "match" ]] | ||
| } |
Comment on lines
+88
to
+91
| if [[ -z "${expected}" || -z "${actual}" ]]; then | ||
| printf 'lab_assert: compare_counts requires expected and actual JSON\n' >&2 | ||
| return 1 | ||
| fi |
Comment on lines
+137
to
+144
| # Function may print JSON on stdout even on mismatch — accept stderr or stdout. | ||
| cmp_body="${cmp_mismatch:-$(cat "${TMP}/cmp.err")}" | ||
| # Re-run capturing both streams into a file via a subshell that ignores exit. | ||
| cmp_body="$( | ||
| set +e | ||
| lab_assert_compare_counts "${match_expected}" "${mismatch_actual}" >"${TMP}/cmp.out" 2>"${TMP}/cmp.err2" | ||
| cat "${TMP}/cmp.out" | ||
| )" |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
origin/main(changelog-sync tip); meta tests green.Test plan
bash hack/test/lab_assert_meta_test.shbash hack/test/lab_harness_meta_suite.sh