Files
GuoQing Zhang 87bfe5cff6 fix(knowledge): run approval gate before persisting space membership
For APPROVAL knowledge spaces, subscribe_space() wrote the PENDING
space_channel_member row *before* invoking the approval gate. When the
scenario was missing/disabled the gate raised ApprovalScenarioDisabledError,
so the user saw an error but the PENDING membership was already committed.
On the next click the top-of-function 'already pending -> return pending'
early-return short-circuited before the gate, masking the error (first click
errors, second click silently succeeds).

Invoke the gate first and persist membership only after it decides
(pass -> ACTIVE, pending/exception -> PENDING) via a new
_persist_space_member() helper. A missing scenario now leaves no membership
and errors consistently on every click.

Also repair pre-existing bitrot in the approval integration tests (quota
is_admin, str-enum decision/task_ids, unmocked department DAO).
2026-06-18 15:58:31 +08:00
..