🐛 fix(conformance): round-6 review follow-ups -- wall-clock store deadline + awk prerequisite - #222
Conversation
…dline + awk prerequisite - 🐛 fix(conformance): assertion 8's store-sync loop now enforces STORE_SYNC_TIMEOUT as a wall-clock deadline (SECONDS-based) instead of counting iterations -- curl --max-time stalls could previously stretch the advertised window ~3x. - 📝 docs(conformance): --self-test prerequisites now name awk alongside jq (the SIGPIPE regression pin generates its stream with awk). Addresses CodeRabbit review on #221.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe self-test documentation now requires Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/tri-tool-conformance/run-matrix.sh`:
- Around line 848-861: Update the store-sync polling loop to calculate remaining
time before each curl request and pass the smaller of that value and 10 seconds
to curl’s --max-time. After the request and jq processing, only accept a
non-empty doc while SECONDS remains below deadline; preserve the existing sleep
and timeout behavior in the surrounding loop.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 50606b2f-d33c-4490-a61d-9982a0cb7068
📒 Files selected for processing (2)
scripts/tri-tool-conformance/README.mdscripts/tri-tool-conformance/run-matrix.sh
| # Wall-clock deadline, not iteration counting: each iteration can spend up | ||
| # to 10s inside curl --max-time on top of the 5s sleep, so counting | ||
| # iterations would let a stalled store consume ~3x the advertised window. | ||
| local doc="" dd_id="" dd_agent="" remaining | ||
| local deadline=$(( SECONDS + STORE_SYNC_TIMEOUT )) | ||
| while (( SECONDS < deadline )); do | ||
| doc="$(curl --silent --max-time 10 "http://127.0.0.1:3000/api/containers?limit=500" 2>/dev/null \ | ||
| | jq -c --arg n "$sentinel" '[(.data // .) | .[]? | select((.name // "") == $n or (.name // "") == ("/" + $n))] | first // empty' 2>/dev/null)" | ||
| if [ -n "$doc" ]; then | ||
| break | ||
| fi | ||
| sleep 5 | ||
| waited=$(( waited + 5 )) | ||
| remaining=$(( deadline - SECONDS )) | ||
| (( remaining <= 0 )) && break | ||
| sleep $(( remaining < 5 ? remaining : 5 )) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== file presence =="
git ls-files | grep -F 'scripts/tri-tool-conformance/run-matrix.sh' || true
echo "== relevant lines =="
if [ -f scripts/tri-tool-conformance/run-matrix.sh ]; then
nl -ba scripts/tri-tool-conformance/run-matrix.sh | sed -n '820,885p'
fi
echo "== STORE_SYNC_TIMEOUT usages =="
rg -n 'STORE_SYNC_TIMEOUT|run-matrix|assert|curl --max-time|SECONDS < deadline' scripts/tri-tool-conformance/run-matrix.sh scripts || true
echo "== shell/dependency hints =="
git ls-files | grep -E '(^|/)(Makefile|package.json|docker-compose|Dockerfile|README)' | head -100Repository: CodesWhat/sockguard
Length of output: 281
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== file status =="
stat scripts/tri-tool-conformance/run-matrix.sh 2>/dev/null || true
echo "== relevant lines around store-sync loop =="
sed -n '820,885p' scripts/tri-tool-conformance/run-matrix.sh
echo "== STORE_SYNC_TIMEOUT and loop references =="
rg -n 'STORE_SYNC_TIMEOUT|while \(\( SECONDS < deadline \)\)|curl --max-time|jq -c|--arg n "$sentinel"|assert|sentinel' scripts/tri-tool-conformance/run-matrix.sh scripts || true
echo "== deterministic shell probe for current loop behavior =="
python3 - <<'PY'
from pathlib import Path
p = Path('scripts/tri-tool-conformance/run-matrix.sh')
s = p.read_text()
block = s[s.index('# Wall-clock deadline'):s.index('assert', s.index('# Wall-clock deadline'))]
checks = {
'capped_at_10': 'curl --silent --max-time 10' in block,
'check_deadline_before_curl': 'while (( SECONDS < deadline ))' in block,
'check_remaining_before_sleep': 'remaining=$(( deadline - SECONDS ))' in block and '(( remaining <= 0 )) && break' in block,
'accept_only_while_alive': 'if [ -n "$doc" ]; then' in block and 'break' in block.split('if [ -n "$doc" ]; then')[1].split('fi')[0],
'remaining_used_in_curl_timeout': 'max-time' in block and 'remaining' not in block.split('curl --silent --max-time 10')[0] + block.split('curl --silent --max-time 10',1)[1].split('jq')[0] if 'curl --silent --max-time 10' in block else False,
}
for k,v in checks.items():
print(f'{k}={v}')
print('--- block ---')
print(block[:4000])
PYRepository: CodesWhat/sockguard
Length of output: 50375
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path('scripts/tri-tool-conformance/run-matrix.sh')
s = p.read_text()
start = s.index('# Wall-clock deadline, not iteration counting')
end = s.index('if [ -z "$doc" ]; then', start) + len(s[s.index('if [ -z "$doc" ]; then', start):s.index('fi', s.index('if [ -z "$doc" ]; then', start))])
block = s[start:end]
print(block)
print('--- structural checks ---')
checks = {
'loop_condition_uses_deadline': 'while (( SECONDS < deadline ))' in block,
'curl_uses_fixed_10s_max_time': 'curl --silent --max-time 10' in block,
'remaining_calculated_after_curl': 'doc="$(curl' in block and block.index('remaining=$(( deadline - SECONDS ))') > block.index('doc="$(curl'),
'sleep_condition_uses_remaining': 'sleep $(( remaining < 5 ? remaining : 5 ))' in block,
'accept_doc_without_deadline_recheck': block.index('if [ -n "$doc" ]; then') != block.index('') and 'while (( SECONDS < deadline ))' not in block.split('if [ -n "$doc" ]; then')[1].split('break')[0],
'fixed_max_time_becomes_zero_at_terminal_iteration': 'max-time' in block and 'remaining' not in block.split('curl --silent --max-time 10')[1].split('jq')[0],
}
for k, v in checks.items():
print(f'{k}: {v}')
PY
echo '--- curl timeout documentation availability ---'
if command -v curl >/dev/null 2>&1; then
curl --help max-time 2>/dev/null | head -20 || true
else
echo "curl not present"
fiRepository: CodesWhat/sockguard
Length of output: 2021
Bound the in-flight curl request to STORE_SYNC_TIMEOUT.
curl can use the full --max-time 10 even when less than 10s remain before the deadline, and jq can run after the deadline before doc is accepted. Compute remaining before the request, cap --max-time at remaining, and accept doc only while SECONDS < deadline.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/tri-tool-conformance/run-matrix.sh` around lines 848 - 861, Update
the store-sync polling loop to calculate remaining time before each curl request
and pass the smaller of that value and 10 seconds to curl’s --max-time. After
the request and jq processing, only accept a non-empty doc while SECONDS remains
below deadline; preserve the existing sleep and timeout behavior in the
surrounding loop.
Addresses both CodeRabbit findings from the sync PR #221 review, landed on dev/v1.6 first per branch discipline:
curl --max-time 10stalls the advertisedSTORE_SYNC_TIMEOUTcould stretch ~3x. Now aSECONDS-based absolute deadline with the final sleep capped to remaining time.--self-test's docs said jq-only; the round-6 SIGPIPE regression pin generates its synthetic stream with awk. README (both mentions) and the script header now name awk.--self-testgreen, shellcheck clean. After merge, #221 gets rebuilt on the updated dev/v1.6 tree.Refs #150, #220.
Changelog
STORE_SYNC_TIMEOUTwith aSECONDS-based wall-clock deadline.awkto the--self-testprerequisites.awksynthetic-stream generation for the SIGPIPE regression check.Concerns
awkis available in every supported self-test environment.shellcheckcleanliness after future changes to the deadline logic.