Skip to content

🐛 fix(conformance): round-6 review follow-ups -- wall-clock store deadline + awk prerequisite - #222

Merged
scttbnsn merged 1 commit into
dev/v1.6from
fix/round6-review-followups
Aug 9, 2026
Merged

🐛 fix(conformance): round-6 review follow-ups -- wall-clock store deadline + awk prerequisite#222
scttbnsn merged 1 commit into
dev/v1.6from
fix/round6-review-followups

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Addresses both CodeRabbit findings from the sync PR #221 review, landed on dev/v1.6 first per branch discipline:

  • Wall-clock store deadline (major): assertion 8's store-sync loop counted iterations, so with curl --max-time 10 stalls the advertised STORE_SYNC_TIMEOUT could stretch ~3x. Now a SECONDS-based absolute deadline with the final sleep capped to remaining time.
  • awk prerequisite (minor): --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-test green, shellcheck clean. After merge, #221 gets rebuilt on the updated dev/v1.6 tree.

Refs #150, #220.

Changelog

  • 🔧 Changed assertion 8 to enforce STORE_SYNC_TIMEOUT with a SECONDS-based wall-clock deadline.
  • 🔧 Changed the final store-sync sleep to stop at the remaining deadline.
  • ✨ Added awk to the --self-test prerequisites.
  • 🔧 Documented awk synthetic-stream generation for the SIGPIPE regression check.

Concerns

  • Confirm awk is available in every supported self-test environment.
  • Preserve shellcheck cleanliness after future changes to the deadline logic.

…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.
@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sockguard-website Ready Ready Preview Aug 9, 2026 8:03am

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The self-test documentation now requires jq and awk. It identifies awk as the generator for the synthetic SIGPIPE regression stream. Remote-update store synchronization now uses a wall-clock deadline based on SECONDS and limits each sleep to the remaining time.

Possibly related PRs

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/round6-review-followups

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 015e0f5 and e930c70.

📒 Files selected for processing (2)
  • scripts/tri-tool-conformance/README.md
  • scripts/tri-tool-conformance/run-matrix.sh

Comment on lines +848 to +861
# 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 ))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 -100

Repository: 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])
PY

Repository: 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"
fi

Repository: 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.

@scttbnsn
scttbnsn merged commit cbc6998 into dev/v1.6 Aug 9, 2026
39 checks passed
@scttbnsn
scttbnsn deleted the fix/round6-review-followups branch August 9, 2026 08:08
scttbnsn added a commit that referenced this pull request Aug 9, 2026
… fix)

Tree-replacement sync: main's content set exactly to dev/v1.6 (#220 round-6
conformance-harness fix plus #222 review follow-ups). Content-identical to
the dev branch by construction; verified with git diff --quiet against
origin/dev/v1.6 before push.
scttbnsn added a commit that referenced this pull request Aug 9, 2026
… fix) (#221)

Tree-replacement sync: main's content set exactly to dev/v1.6 (#220 round-6
conformance-harness fix plus #222 review follow-ups). Content-identical to
the dev branch by construction; verified with git diff --quiet against
origin/dev/v1.6 before push.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant