feat(vm): add deterministic gameplay math and domain coverage gates
Intrepid/Prometeu/Runtime/pipeline/pr-master There was a failure building this commit
Intrepid/Prometeu/Runtime/pipeline/pr-master There was a failure building this commit
This commit is contained in:
@@ -10,29 +10,14 @@ CYAN=$'\033[36m'
|
||||
RESET=$'\033[0m'
|
||||
|
||||
line_percent() {
|
||||
jq -r --arg domain "${1}" --arg root "${ROOT}" '
|
||||
.domains[$domain].paths as $paths
|
||||
| def matches_domain:
|
||||
. as $file
|
||||
| any($paths[]; . as $p | ($file.filename | startswith($root + "/" + $p) or startswith("./" + $p) or startswith($p)));
|
||||
def pct($covered; $count):
|
||||
if $count > 0 then (($covered * 10000 / $count | floor) / 100) else 0 end;
|
||||
reduce (
|
||||
input.data[]?.files[]?
|
||||
| select(matches_domain)
|
||||
) as $file (
|
||||
{lines: {count: 0, covered: 0}};
|
||||
.lines.count += ($file.summary.lines.count // 0)
|
||||
| .lines.covered += ($file.summary.lines.covered // 0)
|
||||
)
|
||||
| pct(.lines.covered; .lines.count)
|
||||
' "${CONFIG_PATH}" "${2}"
|
||||
jq -r --arg domain "${1}" '.domains[$domain].line_percent' <<< "${AUDIT_RESULT}"
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
coverage-domain-evidence.sh --list
|
||||
coverage-domain-evidence.sh --audit [report.json]
|
||||
coverage-domain-evidence.sh [--check] [--show-summary-details] [--show-paths] [--show-tracked-files] [--show-matched-files] [--verbose] <domain> [report.json]
|
||||
coverage-domain-evidence.sh [--show-summary-details] [--show-paths] [--show-tracked-files] [--show-matched-files] [--verbose] --check-all [report.json]
|
||||
|
||||
@@ -56,6 +41,11 @@ if [[ "$1" == "--list" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$1" == "--audit" ]]; then
|
||||
python3 "${ROOT}/scripts/audit-coverage-domains.py" --report "${2:-${DEFAULT_REPORT}}"
|
||||
exit
|
||||
fi
|
||||
|
||||
CHECK_MODE=0
|
||||
CHECK_ALL=0
|
||||
SHOW_PATHS=0
|
||||
@@ -114,6 +104,7 @@ done
|
||||
|
||||
if [[ ${CHECK_ALL} -eq 1 ]]; then
|
||||
REPORT_PATH="${1:-${DEFAULT_REPORT}}"
|
||||
python3 "${ROOT}/scripts/audit-coverage-domains.py" --report "${REPORT_PATH}" --quiet
|
||||
FAIL=0
|
||||
|
||||
while IFS= read -r domain; do
|
||||
@@ -151,17 +142,24 @@ if [[ ${SHOW_PATHS} -eq 1 ]]; then
|
||||
jq -r --arg domain "${DOMAIN}" '.domains[$domain].paths[]' "${CONFIG_PATH}" | while IFS= read -r prefix; do
|
||||
echo " - ${prefix}"
|
||||
done
|
||||
echo "Excluded repository paths:"
|
||||
jq -r --arg domain "${DOMAIN}" '.domains[$domain].exclude_paths[]?' "${CONFIG_PATH}" | while IFS= read -r prefix; do
|
||||
echo " - ${prefix}"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
|
||||
if [[ ${SHOW_TRACKED_FILES} -eq 1 ]]; then
|
||||
echo "Tracked files present in repository:"
|
||||
while IFS= read -r path; do
|
||||
(
|
||||
cd "${ROOT}"
|
||||
rg --files . | sed 's#^\./##'
|
||||
) | rg "^${path//\//\\/}" || true
|
||||
done < <(jq -r --arg domain "${DOMAIN}" '.domains[$domain].paths[]' "${CONFIG_PATH}")
|
||||
(
|
||||
cd "${ROOT}"
|
||||
rg --files crates
|
||||
) | jq -Rr --arg domain "${DOMAIN}" --slurpfile config "${CONFIG_PATH}" '
|
||||
$config[0].domains[$domain] as $mapping
|
||||
| . as $name
|
||||
| select(any($mapping.paths[]; . as $p | $name | startswith($p))
|
||||
and (any($mapping.exclude_paths[]?; . as $p | $name | startswith($p)) | not))
|
||||
'
|
||||
echo
|
||||
fi
|
||||
|
||||
@@ -174,32 +172,13 @@ if [[ ! -f "${REPORT_PATH}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
jq -r --arg domain "${DOMAIN}" --arg root "${ROOT}" --argjson baseline "${BASELINE}" --argjson show_matched_files "${SHOW_MATCHED_FILES}" --argjson show_summary_details "${SHOW_SUMMARY_DETAILS}" '
|
||||
.domains[$domain].paths as $paths
|
||||
| def matches_domain:
|
||||
. as $file
|
||||
| any($paths[]; . as $p | ($file.filename | startswith($root + "/" + $p) or startswith("./" + $p) or startswith($p)));
|
||||
AUDIT_RESULT="$(python3 "${ROOT}/scripts/audit-coverage-domains.py" --report "${REPORT_PATH}" --json)"
|
||||
|
||||
jq -r --arg domain "${DOMAIN}" --argjson show_matched_files "${SHOW_MATCHED_FILES}" --argjson show_summary_details "${SHOW_SUMMARY_DETAILS}" '
|
||||
def pct($covered; $count):
|
||||
if $count > 0 then (($covered * 10000 / $count | floor) / 100) else 0 end;
|
||||
reduce (
|
||||
input.data[]?.files[]?
|
||||
| select(matches_domain)
|
||||
) as $file (
|
||||
{
|
||||
files: [],
|
||||
lines: {count: 0, covered: 0},
|
||||
functions: {count: 0, covered: 0},
|
||||
regions: {count: 0, covered: 0}
|
||||
};
|
||||
.files += [$file.filename]
|
||||
| .lines.count += ($file.summary.lines.count // 0)
|
||||
| .lines.covered += ($file.summary.lines.covered // 0)
|
||||
| .functions.count += ($file.summary.functions.count // 0)
|
||||
| .functions.covered += ($file.summary.functions.covered // 0)
|
||||
| .regions.count += ($file.summary.regions.count // 0)
|
||||
| .regions.covered += ($file.summary.regions.covered // 0)
|
||||
)
|
||||
| . + {line_percent: pct(.lines.covered; .lines.count)}
|
||||
.domains[$domain]
|
||||
| . + {lines: {count: .lines_count, covered: .lines_covered}}
|
||||
| (if $show_summary_details == 1 then "lines: " + (.line_percent | tostring) + "% (" + (.lines.covered|tostring) + "/" + (.lines.count|tostring) + ")" else empty end),
|
||||
(if $show_summary_details == 1 then " files_in_report: " + (.files | length | tostring) else empty end),
|
||||
(if $show_summary_details == 1 then
|
||||
@@ -211,9 +190,9 @@ jq -r --arg domain "${DOMAIN}" --arg root "${ROOT}" --argjson baseline "${BASELI
|
||||
(if $show_matched_files == 1 then "" else empty end),
|
||||
(if $show_matched_files == 1 then "Matched report files:" else empty end),
|
||||
(if $show_matched_files == 1 then (.files[]? | " - " + .) else empty end)
|
||||
' "${CONFIG_PATH}" "${REPORT_PATH}"
|
||||
' <<< "${AUDIT_RESULT}"
|
||||
|
||||
LINE_PERCENT="$(line_percent "${DOMAIN}" "${REPORT_PATH}")"
|
||||
LINE_PERCENT="$(line_percent "${DOMAIN}")"
|
||||
|
||||
if awk "BEGIN { exit !(${LINE_PERCENT} >= ${BASELINE}) }"; then
|
||||
GATE_STATUS="${GREEN}PASS${RESET}"
|
||||
|
||||
Reference in New Issue
Block a user