Skip to content

[M2.3c4a] Serialize privilege changes and invalidate affected credentials - #89

Merged
samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.3c4a-privilege-change-locks
Nov 5, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.3c4a-privilege-change-locks

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Task

M2.3c4a, stacked on #88. Review in order; no automatic merge.

What changed and why

Add an identity boundary for privilege changes that locks the actor and affected account in canonical UUID order before organization locks. Fresh password/configured MFA proof is required. Changed privileges invalidate the affected account's sessions and version-bound API tokens in the same transaction as the role/audit writes; self-changes return a rotated session. Another administrator's session remains valid.

No-ops preserve credentials but audit proof confirmation, since an MFA counter/recovery code may still be consumed. Proof explicitly expires when its callback ends, including inherited detached asynchronous work. The internal verified-account directory returns only account id/email/active state for authorized membership commands.

Membership and role-binding commands follow in M2.3c4b/c. Callers must enter this boundary before holding any account or organization lock and repeat resource authorization under its locks.

How it was tested

  • All 177 real-PostgreSQL integration tests pass.
  • Twelve targeted identity-boundary tests pass with 100% statement, branch and function coverage.
  • A real PostgreSQL row-lock barrier forces reciprocal administrator changes to overlap: one succeeds, the other rejects its stale identity, without deadlock.
  • Tests cover affected-token/session invalidation, caller-session preservation, self-rotation, no-ops, invalid targets/proof, directory filtering, audit rollback, MFA consumption rollback and detached proof expiry.
  • API lint, typecheck, 103 unit tests and production build pass. Web/domain, Go and protobuf checks passed in preceding slices; CI reruns them.

Security considerations

Callbacks never receive password hashes or MFA material. Role mutations, proof consumption, audit and security-version changes share one transaction. A failed identity audit restores the business write and credentials. No new dependency, shell invocation or credential logging path. CodeQL remains skipped by repository configuration; enabled security checks run in CI.

Checklist

  • M2.3c4a acceptance met; PLAN/SPEC updated
  • Local checks and full PostgreSQL suite pass
  • Concurrent changes, stale callers and rollback covered
  • New identity state changes and proof-only no-ops audited
  • No secrets or generated artifacts edited manually

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.3c3c2-resource-catalogs branch from d89cbee to 9530152 Compare November 5, 2026 14:47
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m2.3c3c2-resource-catalogs to main November 5, 2026 14:47
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.3c4a-privilege-change-locks branch from 9df2046 to 1c34e55 Compare November 5, 2026 14:48
@samuelmbabhazi
samuelmbabhazi merged commit ab77453 into main Nov 5, 2026
2 of 11 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.3c4a-privilege-change-locks branch November 5, 2026 14:49
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
## Task

M2.3c4b, stacked on #89. Review in order; no automatic merge.

## What changed and why

Add reauthenticated organization membership commands for existing
verified accounts, explicit role changes and removal. Actor/subject
account locks precede the organization lock; live authorization and
owner count are then rechecked before writing. Administrators manage
non-owners, owners manage ownership, and simultaneous departures cannot
remove the final owner.

Membership changes and audits share the credential-invalidation
transaction. Self-demotion returns a rotated session. Same-role requests
preserve credential versions; removal cascades resource bindings.
Directory candidates are rechecked after locking to reject changed
email/active state. Unknown or unverified accounts are not invited by
this slice.

Also add pure, closed organization/resource-role parsers with
canonical-value tests. HTTP and administration screens follow in
M2.3d/f.

## How it was tested

- Seven real restricted-PostgreSQL acceptance tests pass, covering
administrator/owner restrictions, last-owner races, duplicate additions,
self-demotion, invalid/stale/inactive inputs, directory races, cascading
grants and rollback for every command.
- Application coverage: 97% statements, 94% branches, 100% functions and
lines.
- All 94 domain and 103 API unit tests pass, with API/domain lint,
typechecks and production builds.
- The preceding full 177-test integration suite passed; CI runs the
expanded suite and browser checks. Web, Go and protobuf checks passed
earlier in the stack.
- One local Nx native-runner process crashed; rerunning with its native
command runner disabled completed successfully.

## Security considerations

Only authorized organization administrators can resolve a membership
candidate. Commands never receive password hashes and cannot move a
membership across tenants. Role changes recheck current account versions
under ordered locks; the database's deferred owner guard remains a
second defense. Failed audits roll back membership and credential state
together. No new dependency, shell invocation or secret exposure. CodeQL
remains skipped by repository configuration; enabled security checks run
in CI.

## Checklist

- [x] M2.3c4b acceptance met; PLAN/SPEC updated
- [x] TDD role policy and real PostgreSQL command acceptance pass
- [x] Relevant lint, typechecks, unit tests and builds pass
- [x] Every membership mutation emits an atomic audit event
- [x] No secrets or generated artifacts edited manually
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant