Fail-closed bot compliance on Legal API errors (#5) #27

Merged
PlasticDigits merged 2 commits from 5-bot-fail-closed-compliance-when-legal-api-errors-replace-unwrap-or-false- into main 2026-08-11 01:25:54 +00:00
PlasticDigits commented 2026-08-11 01:10:19 +00:00 (Migrated from gitlab.com)

Summary

  • Introduce bot/src/compliance.rs (ComplianceCheck::{SignedLatest, NotSignedLatest, Unknown}) so Legal API status errors never coerce to unsigned.
  • Wire handle_group_message, announce_terms_update, run_kicks, and handle_member_joined through classify_status — Unknown holds DB state and skips kicks; structured warn logs include chat_id/user_id/context.
  • Add test:rust-bot CI job, unit tests for the policy matrix, and agent skill skills/bot-enforcement/SKILL.md with README/gap cross-links.

Closes #5

Acceptance criteria (from #5)

  • No unwrap_or(false) on compliance status in enforcement/kick paths
  • API error during handle_group_message does not mark non-compliant
  • API error during run_kicks does not ban/kick
  • API error during terms-announce member loop does not mass-mark
  • Ok(true) clears; Ok(false) marks
  • Structured warning logs on Unknown
  • Unit tests cover three outcomes; CI runs cargo test for bot/
  • README / code comment / skill documents fail-closed invariant

Not in this MR (issue out of scope)

  • Circuit breaker / API-healthy flag / status cache
  • Grace reset on rejoin, admin kick exemption, lurker tracking, property upsert, Telegram HMAC
  • Bot scheduler/handlers Telegram integration tests

Test plan

  • cd bot && cargo test (8 passed)
  • cd bot && cargo fmt --check && cargo clippy --all-targets -- -D warnings
  • Code search: no unwrap_or(false) on is_signed_latest in bot/src
  • CI test:rust-bot + lint:rust-bot green on this MR
  • Reviewer confirms policy matrix matches acceptance criteria

Closes #5

## Summary - Introduce `bot/src/compliance.rs` (`ComplianceCheck::{SignedLatest, NotSignedLatest, Unknown}`) so Legal API status errors never coerce to unsigned. - Wire `handle_group_message`, `announce_terms_update`, `run_kicks`, and `handle_member_joined` through `classify_status` — Unknown holds DB state and skips kicks; structured `warn` logs include `chat_id`/`user_id`/`context`. - Add `test:rust-bot` CI job, unit tests for the policy matrix, and agent skill [`skills/bot-enforcement/SKILL.md`](skills/bot-enforcement/SKILL.md) with README/gap cross-links. Closes #5 ## Acceptance criteria (from #5) - [x] No `unwrap_or(false)` on compliance status in enforcement/kick paths - [x] API error during `handle_group_message` does not mark non-compliant - [x] API error during `run_kicks` does not ban/kick - [x] API error during terms-announce member loop does not mass-mark - [x] `Ok(true)` clears; `Ok(false)` marks - [x] Structured warning logs on Unknown - [x] Unit tests cover three outcomes; CI runs `cargo test` for `bot/` - [x] README / code comment / skill documents fail-closed invariant ## Not in this MR (issue out of scope) - Circuit breaker / API-healthy flag / status cache - Grace reset on rejoin, admin kick exemption, lurker tracking, property upsert, Telegram HMAC - Bot scheduler/handlers Telegram integration tests ## Test plan - [x] `cd bot && cargo test` (8 passed) - [x] `cd bot && cargo fmt --check && cargo clippy --all-targets -- -D warnings` - [x] Code search: no `unwrap_or(false)` on `is_signed_latest` in `bot/src` - [ ] CI `test:rust-bot` + `lint:rust-bot` green on this MR - [ ] Reviewer confirms policy matrix matches acceptance criteria Closes #5
PlasticDigits commented 2026-08-11 01:10:21 +00:00 (Migrated from gitlab.com)

restored source branch 5-bot-fail-closed-compliance-when-legal-api-errors-replace-unwrap-or-false-

restored source branch `5-bot-fail-closed-compliance-when-legal-api-errors-replace-unwrap-or-false-`
PlasticDigits commented 2026-08-11 01:10:44 +00:00 (Migrated from gitlab.com)

marked this merge request as ready

marked this merge request as **ready**
PlasticDigits commented 2026-08-11 01:10:44 +00:00 (Migrated from gitlab.com)

added 1 commit

  • 90b3b797 - Fail-closed bot compliance when Legal API status errors (#5).

Compare with previous version

added 1 commit <ul><li>90b3b797 - Fail-closed bot compliance when Legal API status errors (#5).</li></ul> [Compare with previous version](/PlasticDigits/cl8y-ecosystem-legal/-/merge_requests/9/diffs?diff_id=1953669114&start_sha=8d6be646a0570e2d82ce22bb1fddb7d5ab9c66c6)
PlasticDigits commented 2026-08-11 01:11:00 +00:00 (Migrated from gitlab.com)

Local verification complete (cd bot && cargo test → 8 passed; clippy -D warnings clean). GitLab CI jobs on this MR are currently failing with ci_quota_exceeded (not a code failure) — please re-run the pipeline when minutes are available, especially lint:rust-bot and test:rust-bot.

Local verification complete (`cd bot && cargo test` → 8 passed; clippy `-D warnings` clean). GitLab CI jobs on this MR are currently failing with `ci_quota_exceeded` (not a code failure) — please re-run the pipeline when minutes are available, especially `lint:rust-bot` and `test:rust-bot`.
PlasticDigits commented 2026-08-11 01:11:04 +00:00 (Migrated from gitlab.com)

mentioned in issue #5

mentioned in issue #5
PlasticDigits commented 2026-08-11 01:25:42 +00:00 (Migrated from gitlab.com)

added 3 commits

  • 90b3b797...4afa9976 - 2 commits from branch main
  • 6470432a - Merge origin/main into MR !27; resolve security-ops skill conflict

Compare with previous version

added 3 commits <ul><li>90b3b797...4afa9976 - 2 commits from branch <code>main</code></li><li>6470432a - Merge origin/main into MR !27; resolve security-ops skill conflict</li></ul> [Compare with previous version](/PlasticDigits/cl8y-ecosystem-legal/-/merge_requests/9/diffs?diff_id=1953682304&start_sha=90b3b79786e67058b5b1a8cbbdab223ab8f3b186)
PlasticDigits commented 2026-08-11 01:25:42 +00:00 (Migrated from gitlab.com)

mentioned in commit 6470432a8e

mentioned in commit 6470432a8e4cb2df985b7c67743cb5cb3dd03f4e
PlasticDigits commented 2026-08-11 01:25:55 +00:00 (Migrated from gitlab.com)

mentioned in commit 9f45ac6e58

mentioned in commit 9f45ac6e586f7df5e52e9147a58a954a5edd310d
PlasticDigits (Migrated from gitlab.com) merged commit 9f45ac6e58 into main 2026-08-11 01:25:55 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-ecosystem-legal!27
No description provided.