# Feed-on-SX conformance config — sourced by lib/guest/conformance.sh.
#
# Every feed suite runs in a fresh session with the same preloads and a single
# pass/fail counter pair — the canonical MODE=counters shape. The counters and
# the feed-test helper (previously defined inline in the old conformance.sh) are
# preloaded via lib/feed/test-harness.sx.

LANG_NAME=feed
MODE=counters
COUNTERS_PASS=feed-test-pass
COUNTERS_FAIL=feed-test-fail
TIMEOUT_PER_SUITE=300

PRELOADS=(
  spec/stdlib.sx
  lib/r7rs.sx
  lib/apl/runtime.sx
  lib/feed/normalize.sx
  lib/feed/stream.sx
  lib/feed/api.sx
  lib/feed/fanout.sx
  lib/feed/dedupe.sx
  lib/feed/aggregate.sx
  lib/feed/rank.sx
  lib/feed/acl.sx
  lib/feed/fed.sx
  lib/feed/content.sx
  lib/feed/notify.sx
  lib/feed/home.sx
  lib/feed/trending.sx
  lib/feed/mute.sx
  lib/feed/page.sx
  lib/feed/thread.sx
  lib/feed/test-harness.sx
)

SUITES=(
  "basic:lib/feed/tests/basic.sx"
  "fanout:lib/feed/tests/fanout.sx"
  "rank:lib/feed/tests/rank.sx"
  "integration:lib/feed/tests/integration.sx"
  "content:lib/feed/tests/content.sx"
  "notify:lib/feed/tests/notify.sx"
  "home:lib/feed/tests/home.sx"
  "dedupe:lib/feed/tests/dedupe.sx"
  "trending:lib/feed/tests/trending.sx"
  "mute:lib/feed/tests/mute.sx"
  "page:lib/feed/tests/page.sx"
  "thread:lib/feed/tests/thread.sx"
)

# Preserve the historical scoreboard schema so consumers of
# lib/feed/scoreboard.json keep working.
emit_scoreboard_json() {
  local n=${#GC_NAMES[@]} i
  printf '{\n'
  printf '  "suites": {\n'
  for ((i=0; i<n; i++)); do
    [ "$i" -gt 0 ] && printf ',\n'
    printf '    "%s": {"pass": %d, "fail": %d}' \
      "${GC_NAMES[$i]}" "${GC_PASS[$i]}" "${GC_FAIL[$i]}"
  done
  printf '\n  },\n'
  printf '  "total_pass": %d,\n' "$GC_TOTAL_PASS"
  printf '  "total_fail": %d,\n' "$GC_TOTAL_FAIL"
  printf '  "total": %d\n' "$GC_TOTAL"
  printf '}\n'
}

emit_scoreboard_md() {
  local n=${#GC_NAMES[@]} i p f
  printf '# feed Conformance Scoreboard\n\n'
  printf '_Generated by `lib/feed/conformance.sh`_\n\n'
  printf '| Suite | Pass | Fail | Total |\n'
  printf '|-------|-----:|-----:|------:|\n'
  for ((i=0; i<n; i++)); do
    p=${GC_PASS[$i]}; f=${GC_FAIL[$i]}
    printf '| %s | %d | %d | %d |\n' "${GC_NAMES[$i]}" "$p" "$f" "$((p+f))"
  done
  printf '| **Total** | **%d** | **%d** | **%d** |\n' \
    "$GC_TOTAL_PASS" "$GC_TOTAL_FAIL" "$GC_TOTAL"
}
