Skip to content

feat: legal holds, session revocation, plugin governance, advisory intake - #760

Merged
Ayinkx merged 4 commits into
AyinkxLab:mainfrom
Savvy-B19:feat/phase11-hardening-governance
Nov 24, 2026
Merged

Ayinkx merged 4 commits into
AyinkxLab:mainfrom
Savvy-B19:feat/phase11-hardening-governance

Conversation

@Savvy-B19

Copy link
Copy Markdown
Contributor

Summary

Four governance and hardening features: scoped legal holds, session tracking with revoke-all, per-organization plugin governance, and a documented security advisory intake policy.

Closes #609
Closes #619
Closes #634
Closes #625

#609 — scoped legal holds

  • LegalHold model with workspace_id, scope (audit / workspace / all), reason, placing actor and timestamp, plus release metadata (actor, reason, timestamp).
  • app/services/legal_hold.py validates placement and release, requires manage_settings, and writes legal_hold_placed / legal_hold_released audit rows.
  • Enforced where data actually disappears: app/services/audit_retention.py purge_expired (an active audit-scoped hold blocks the purge, extending the existing boolean no-op rather than duplicating it), workspace deletion in app/workspaces/routes.py, and user-data deletion in app/services/data_deletion.py (returns 409 conflict).
  • Owner-only API: GET/POST /workspaces/api/workspaces/<id>/legal-holds and POST .../<hold_id>/release, with structured 400 invalid_input, 403 forbidden, 404 not_found.
  • Migration e9f8a7b6c5d4; docs in docs/audit-retention.md; tests in tests/test_legal_hold.py cover hold blocks purge and deletion, release allows them, scoping, permissions and invalid input.

#619 — session revocation for all devices

  • UserSession model (opaque token id, user, timestamps, user agent, revocation actor and reason).
  • app/services/user_sessions.py binds a session on sign-in, validates it per request, and can revoke the current session or all of them, auditing actor, reason and count.
  • app/auth/routes.py binds on register, login and MFA, revokes on logout, and logs out cookies whose tracked row is missing or revoked on the next request.
  • Endpoints: GET /auth/api/sessions, POST /auth/api/sessions/revoke-all, and admin POST /admin/users/<user_id>/sessions/revoke-all with a mandatory reason.
  • Migration a7e1c2d3b4f5; docs docs/session-revocation.md; tests in tests/test_session_revocation.py cover immediate self-revocation, admin revocation with its audit row, 403 for non-admins, 400 invalid input, 404 unknown user, and legacy sessions without a tracked id.

#634 — per-organization plugin governance

  • OrganizationPluginPolicy and PluginApproval, keyed on the organization owner, following the repo's existing "workspace owner is the organization" model.
  • app/services/plugin_governance.py supports allow, block and require_approval, persists approvals, checks org-admin rights through app/services/organizations.py, and audits plugin_policy_updated, plugin_install_approved and plugin_install_blocked.
  • Enforced at all four workspace install paths in app/plugins/routes.py (manifest, catalog, registered, marketplace). A blocked install is audited and committed before the refusal.
  • Endpoints: GET/PUT /plugins/api/workspaces/<id>/plugins/policy, POST .../plugins/<plugin_id>/approve.
  • Migration b4e2f1a3c5d7; docs docs/plugin-governance.md; tests in tests/test_plugin_governance.py cover all three modes, audit rows, permission failures and invalid bodies.

#625 — advisory intake and response targets

  • docs/security-advisory-intake.md: private intake channels, triage, severity table, acknowledgement and fix targets for critical and high reports, disclosure rules, what happens when a target is missed, and scope.
  • Linked from SECURITY.md and the README.
  • tests/test_security_advisory_policy.py keeps the page honest: it resolves the links, asserts the private channels and the exact targets, requires commitment-not-warranty language, and checks that SECURITY.md does not overclaim calendar SLAs.

Verification

python -m ruff check .                     -> All checks passed
python -m black --check .                  -> 591 files unchanged
python -m flask --app wsgi db heads        -> b4e2f1a3c5d7 (head), single head
pytest <new + neighbouring modules> -q     -> 192 passed in 49s

Suites run: test_legal_hold, test_session_revocation, test_plugin_governance, test_security_advisory_policy, test_audit_retention, test_data_deletion, test_docs_links, test_api_error_catalog, plus the migration head test.

Limitations

  • The full suite was not run; it is slow and has pre-existing unrelated failures on main.
  • Session tracking covers sessions created by the sign-in routes. A path that logs a user in without going through bind_current_session (some plugin or SSO flows) is not tracked and therefore not revocable.
  • A workspace-scoped legal hold blocks the whole user-deletion workflow when the user owns or belongs to any held workspace. That is deliberately coarse and fail-closed rather than row-level filtering.
  • Plugin governance is enforced on the HTTP install routes and keyed on the organization owner; the operator CLI install path is out of scope and documented as such.
  • UserSession.last_seen_at records sign-in time and is not refreshed per request, so it shows login time rather than true last activity.

@Savvy-B19
Savvy-B19 requested a review from Ayinkx as a code owner November 24, 2026 16:34
@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown

@Savvy-B19 is attempting to deploy a commit to the Ayinkx Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@Savvy-B19 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Ayinkx
Ayinkx merged commit 21fedee into AyinkxLab:main Nov 24, 2026
14 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants