Skip to content

test(discord-bridge): lock in access_tier classification (PR #481 follow-up C) - #482

Merged
sonichi merged 1 commit into
mainfrom
test/discord-bridge-access-tier
Apr 20, 2026
Merged

sonichi merged 1 commit into
mainfrom
test/discord-bridge-access-tier

Conversation

@sonichi

@sonichi sonichi commented Apr 20, 2026

Copy link
Copy Markdown
Owner

Summary

Regression test for the PR #481 follow-up that Chi approved (MacBook's option C, 2026-04-20).

After PR #481 (channel-aware bot filter) + Mini's access.json tightening (dropped sibling-bot IDs from global `allowFrom`), a bare #bot2bot post from MacBook should classify as `access_tier=team`, not owner. This test guards that invariant structurally so a blind refactor can't quietly regress it.

Approach

Follows the `env-loader.test.py` pattern: structural assertions on the source file, no live processes, no mocks.

Checks:

  1. `access_tier` defaults to `"other"` (fail-closed).
  2. `if sender_id in allowed: access_tier = "owner"` exists.
  3. `else` branch unions channel allowFroms into `team_ids`.
  4. Owner-tier assignment appears BEFORE team-tier assignment in the block (ordering matters for correctness).

Test plan

  • `python3 tests/discord-bridge-access-tier.test.py` → PASS locally
  • Run on CI
  • Intentionally break `discord-bridge.py` (reorder or remove the owner check) and confirm the test fails

Related

🤖 Generated with Claude Code

Regression guard for PR #481 follow-up: sibling-bot bare posts to
#bot2bot are classified as access_tier=team (not owner) after Mini's
access.json tightening drops sibling-bot IDs from the global allowFrom.

Structural assertions on src/discord-bridge.py:
- access_tier defaults to "other" (fail-closed)
- global allowed → owner
- channel-level allowFrom union → team (fallback)
- ordering: owner check before team check

Mirrors env-loader.test.py pattern (cheap structural grep-based test,
no live processes).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@sonichi sonichi left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

LGTM from MacBook node. Ran python3 tests/discord-bridge-access-tier.test.py locally against current src/discord-bridge.py → PASS (all 4 guards triggered correctly: defaults-to-other, global→owner, else→team via channel allowFroms union, ordering).

Complementary to #483 (my runtime validator that checks the live access.json for sibling-bot-IDs-in-global over-grants). Yours guards against code-level regression of the classification logic; mine guards against config-level misconfig. Both fit; no overlap.

One small observation (not blocking): the regex on line ~47 for the block-locator uses a (?=\n # Dedup:|\n # Deterministic tier|\n\ndef |\Z) fence — if someone reorders comments or trims whitespace, the block-locator could fail-open (block=empty) before the specific assertions run. Consider making the fallback error-by-default if the block is <50 chars. Not urgent; won't block merge.

@sonichi
sonichi merged commit 2cb4aab into main Apr 20, 2026
1 check passed
@sonichi
sonichi deleted the test/discord-bridge-access-tier branch April 20, 2026 20:02
liususan091219 pushed a commit to liususan091219/sutando-fork that referenced this pull request May 28, 2026
…i#482)

Regression guard for PR sonichi#481 follow-up: sibling-bot bare posts to
#bot2bot are classified as access_tier=team (not owner) after Mini's
access.json tightening drops sibling-bot IDs from the global allowFrom.

Structural assertions on src/discord-bridge.py:
- access_tier defaults to "other" (fail-closed)
- global allowed → owner
- channel-level allowFrom union → team (fallback)
- ordering: owner check before team check

Mirrors env-loader.test.py pattern (cheap structural grep-based test,
no live processes).

Co-authored-by: Chi <wangchi@Chis-Mac-mini.local>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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