Repository navigation
fix(control-plane): enrollment and admin-role changes write an audit line - #959
Merged
Merged
Conversation
…line The four member write routes (enrollSubject, unenrollSubject, grantAdmin, revokeAdmin) recorded each change on the members provenance stream but never called auditBestEffort, so a change of who has access, or who is an admin, left no line in sh:cp:audit or on stdout, unlike the credential and config bundle writes. Each route now mirrors a change to the audit log with the acting admin as `subject`, the changed subject in a new optional `member` field, and the decision subject_enrolled, subject_unenrolled, admin_granted or admin_revoked. An unchanged answer (record null) writes nothing. The provenance record is unchanged. Closes rossoctl#958 Signed-off-by: Rong Chang <[email protected]> Assisted-By: Claude (Anthropic AI) <[email protected]>
ingpaolodettori-dev
approved these changes
Nov 20, 2026
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Review — fix(control-plane): enrollment and admin-role changes write an audit line
Right gap: the members provenance stream held the record and the audit log did not, so an operator reading sh:cp:audit saw the credential write and never the grant that made it possible.
- The wiring is the credential routes'.
auditBestEffortmirrors to stdout before the Redis write, and swallows a Redis failure with a line saying the write itself succeeded;deps.indexis built beside the members store inmain.tsfrom the same client, so there is no deployment with the store and no audit sink. subjectis the acting admin and the newmembernames the subject changed — the right split, and the target string in a failed-write line (member=github:…) is a subject id, never a secret.- Only a change is audited:
recordis null for an unchanged answer and the line is written after the update, so a retry or a no-op cannot invent history. The second test pins that for all four routes, including the two subtler ones (a settings subject is already enrolled; a non-admin has nothing to revoke). - No other decision's line grows a field:
OwnershipIndex.auditwritesmemberonly when set, anddocs/operate/day-2/observability.mdlists it and the four decisions.
On the until you asked about: I would carry it. An admin_granted for an hour and one forever read the same in the audit log otherwise, and "who was an admin at T" is exactly the question this stream exists to answer. The field is additive (the expiry the grant carries, alongside credential, configRef and the rest), and the provenance record stays the authority.
Checks 18/18 green. Author: webchang (MEMBER — maintainer). One commit, signed off.
webchang
added a commit
to webchang/moca
that referenced
this pull request
Nov 22, 2026
57 commits past Moca v0.11.0 (rossoctl#953-rossoctl#976), among them rossoctl#959 (the member routes write audit lines), rossoctl#960 (gate-image.py, Moca's general gate), rossoctl#976 (the vault credential store, inert with egress credentials off) and the lease-mode vmpool changes. No conflict; the fork-only set is unchanged. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #958
What
The four member write routes in
packages/control-plane/src/member-handlers.ts(enrollSubject,unenrollSubject,grantAdmin,revokeAdmin) now write an audit line for each change, throughauditBestEffort, as the credential and config-bundle writes do:subjectis the admin who made the change;memberfield (OwnershipIndex.audit, written tosh:cp:auditwhen set) names the subjectwhose enrollment or role changed;
decisionissubject_enrolled,subject_unenrolled,admin_grantedoradmin_revoked.An unchanged answer (the routes'
record: null) writes nothing. Themembersprovenance record isunchanged; the audit line mirrors it.
docs/operate/day-2/observability.mdlists the new field and the fourdecisions.
A grant's expiry (
until) is not carried: the audit entry has no field for it, and it stays on theprovenance record. Happy to add one if you'd like it in the audit line too.
Why
Before this change, a change of who has access, or who is an admin, was recorded only on the
membersprovenance stream. An operator following the audit log saw a credential change but not the admin grant that
made it possible.
Tests
packages/control-plane/test/members.test.tsgains two tests:decision, to both the Redis stream and the stdout mirror;
unenroll an unknown subject) write none.
Both fail without the change and pass with it.
tsc --noEmitis clean, and the control-plane suite passes(2026 passed, 4 skipped).
Assisted-By: Claude Code