Repository navigation
test(discord-bridge+send_allowlist): 22 structural tests for delivery-idempotency (#1048) and shared allowlist (#1029) - #1160
Conversation
VasiliyRad
left a comment
There was a problem hiding this comment.
Not approving yet — scope mismatch + undocumented production changes.
-
Title says "test(...)" but ships production code.
src/discord-bridge.py(+124/-46),src/send_allowlist.py(+106 new), andsrc/health-check.py(+14/-2) are feature implementations, not tests. The PR body documents #1048 and #1029 well, but the commit-message prefixtest(...)is misleading — this isfeat+test. -
Undocumented join-trigger fast path (lines 2247-2268). A new
_dv_message_is_join_phrase/_dv_handle_join_triggerblock was added to_handle_discord_messagethat bypassesrequireMention. This isn't mentioned in the PR description at all and appears unrelated to either #1048 or #1029. Should be a separate PR or at minimum documented. -
Undocumented
poll_proactiveowner-resolution change (lines 3347-3354). Adds explicitaccess_data.get("owner")lookup (#1117 per inline comment). Also unrelated to either referenced PR. -
Test assertions are structural greps, not behavioral. The 22 tests verify strings exist in source files (e.g.,
"def _mark_delivered" in bridge). They won't catch semantic regressions like wrong sentinel ordering or a broken skip path. This is fine as a smoke-check layer, but the PR body implies stronger coverage than delivered. -
build_log.mdis a new file covering passes 207-214. If the repo already has abuild_log.mdconvention elsewhere (workspace), shipping one in the repo root may conflict.
Suggestion: Split the unrelated changes (join-trigger, owner-resolution) into their own PRs, retitle this one to feat+test(...), and it's good to go. The sentinel implementation and allowlist extraction look correct.
|
Status update (2026-05-26): VasiliyRad's review is correct — the production code in this diff ( Verification: cherry-picking just the test commit ( A rebase onto |
…-idempotency (sonichi#1048) and shared allowlist (sonichi#1029) mkdir exist_ok, fail-open on exception, call order check (is_delivered < mark_delivered < clear_delivered), log message, _mark_delivered after channel.send in poll_results. SEND_ALLOWED_PREFIXES (/tmp/sutando-), is_path_sendable(), realpath traversal defense, isfile check, os.sep suffix check, discord-bridge imports from send_allowlist. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
050de1f to
4836a59
Compare
|
Branch rebased onto origin/main — bundled junk (build_log.md, health-check.py, health-check-bridge-multi-pid.test.py) stripped. Diff is now clean: only the intended test file(s). |
What
Structural tests for two merged PRs:
poll_resultssend_allowlist.pyas the shared file-attachment policy moduleBackground
PR #1048 — delivery-idempotency
Before this fix, if the bridge crashed between
channel.send()returning success andarchive_file()completing, on restart the result file would still be inresults/and would be re-sent — duplicate delivery. Fix: three sentinel helpers around the send/archive sequence:_is_delivered(task_id)— check before send_mark_delivered(task_id)— touch after send_clear_delivered(task_id)— remove after archivePR #1029 — send_allowlist shared module
The file-attachment delivery policy (
[file:|send:|attach:]markers) was duplicated betweendiscord-bridge.pyanddm-result.py. The copies had silently diverged —dm-result.pywas missing Desktop, Documents, and personal-notes roots.src/send_allowlist.pyis the single source of truth for the policy now.Tests (22 assertions)
discord-bridge.py (PR #1048) — 13 assertions
DELIVERED_DIRdefined →state/discord-delivered_delivered_sentinel_pathhelper exists.sentinelextension_mark_delivereddefined_is_delivereddefined_clear_delivereddefined_mark_deliveredusesmkdir(parents=True, exist_ok=True)_mark_deliveredhastry/except(sentinel failure never kills send)_is_deliveredreturnsFalseon exception (fail-open)_is_delivered(task_id)called in poll_results_mark_delivered(task_id)called in poll_results_clear_delivered(task_id)called in poll_results_is_delivered<_mark_delivered<_clear_delivered_mark_deliveredappears afterchannel.sendin poll_resultssend_allowlist.py (PR #1029) — 9 assertions
SEND_ALLOWED_ROOTSdefinedresults/andnotes/in rootsSEND_ALLOWED_PREFIXESdefined/tmp/sutando-prefix includedis_path_sendable()definedrealpath()used to defeat symlink/traversal attacksos.path.isfile()check rejects directoriesos.sepsuffix prevents prefix-pollution attacksdiscord-bridge.pyimports fromsend_allowlistRun
🤖 Generated with Claude Code