Skip to content

fix(control-plane): enrollment and admin-role changes write an audit line - #959

Merged
webchang merged 1 commit into
rossoctl:mainfrom
webchang:pr/members-audit
Nov 20, 2026
Merged

webchang merged 1 commit into
rossoctl:mainfrom
webchang:pr/members-audit

Conversation

@webchang

Copy link
Copy Markdown
Member

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, through
auditBestEffort, as the credential and config-bundle writes do:

  • subject is the admin who made the change;
  • a new optional member field (OwnershipIndex.audit, written to sh:cp:audit when set) names the subject
    whose enrollment or role changed;
  • decision is subject_enrolled, subject_unenrolled, admin_granted or admin_revoked.

An unchanged answer (the routes' record: null) writes nothing. The members provenance record is
unchanged; the audit line mirrors it. docs/operate/day-2/observability.md lists the new field and the four
decisions.

A grant's expiry (until) is not carried: the audit entry has no field for it, and it stays on the
provenance 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 members
provenance 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.ts gains two tests:

  • one enroll, unenroll, grant and revoke each write one line, with the acting admin, the member and the
    decision, to both the Redis stream and the stdout mirror;
  • unchanged answers (enroll again, enroll a settings subject, the same grant again, revoke a non-admin,
    unenroll an unknown subject) write none.

Both fail without the change and pass with it. tsc --noEmit is clean, and the control-plane suite passes
(2026 passed, 4 skipped).

Assisted-By: Claude Code

…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]>
@webchang
webchang requested a review from pdettori as a code owner November 20, 2026 16:06
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 20, 2026
@pdettori pdettori added this to the v0.11.1 milestone Nov 20, 2026
@pdettori pdettori added the enhancement New feature or request label Nov 20, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'. auditBestEffort mirrors to stdout before the Redis write, and swallows a Redis failure with a line saying the write itself succeeded; deps.index is built beside the members store in main.ts from the same client, so there is no deployment with the store and no audit sink.
  • subject is the acting admin and the new member names 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: record is 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.audit writes member only when set, and docs/operate/day-2/observability.md lists 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
webchang merged commit 9e9958e into rossoctl:main Nov 20, 2026
18 checks passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

control-plane: enrollment and admin-role changes write no audit line

3 participants