A pure side-channel decorator around an IncomingMessageCallback, used to
capture a commit's own proposals for the WIRE-03/CONV-01 commit-legality
validators (src/core/components/integrity.ts).
WHY this exists: ts-mls has no OpenMLS StagedCommit equivalent —
processMessage returns the fully-applied newState in one step, and
IncomingMessageCallback is the only pre-apply hook, but it never sees the
resulting GroupContext. validateCommitLegality needs both the
pre-apply (parentState) and post-apply (resultingState) ClientState,
plus the commit's own proposals, so it can only run AFTER processMessage
resolves. This wrapper's sole job is to make the commit's proposals
available at that later point — it is a side channel, not a policy
decision. It feeds the same algorithm ported from MDK's
refs/mdk/crates/cgka-engine/src/app_components.rsvalidate_app_component_integrity_for_staged_commit.
callback delegates every decision to inner unchanged — this is a
decorator, NOT a policy change. The
refs/marmot/protocol-core/group-messaging.md admin gate, the
account-identity-proof check, and the admin-self-remove guard in
createAdminCommitPolicyCallback all keep their exact current behavior.
Its only extra effect: BEFORE returning inner(incoming), it appends the
proposal(s) to a private buffer — for incoming.kind === "commit",
incoming.proposals.map((p) => p.proposal); for incoming.kind === "proposal", the single incoming.proposal — so proposals are captured
even for a message inner itself rejects.
No validation logic may be added inside this wrapper or inside inner
(Pitfall 1 — validating inside the callback runs before the resulting
GroupContext exists and would produce wrong verdicts or throw mid-apply).
Contract: take() returns the buffered proposals, committer, and whether a
commit callback completed the capture, then resets all three. A standalone
proposal does not complete a commit capture.
Callers MUST call take() immediately before each processMessage call
(discarding the result, to clear any stale proposals left over from a
prior message) and again immediately after processMessage returns (to
read exactly the proposals of the commit just processed). This makes it
safe to reuse one callback/take() pair across a loop of several
commits processed with the same wrapped callback.
A pure side-channel decorator around an
IncomingMessageCallback, used to capture a commit's own proposals for the WIRE-03/CONV-01 commit-legality validators (src/core/components/integrity.ts).WHY this exists: ts-mls has no OpenMLS
StagedCommitequivalent —processMessagereturns the fully-appliednewStatein one step, andIncomingMessageCallbackis the only pre-apply hook, but it never sees the resultingGroupContext.validateCommitLegalityneeds both the pre-apply (parentState) and post-apply (resultingState)ClientState, plus the commit's own proposals, so it can only run AFTERprocessMessageresolves. This wrapper's sole job is to make the commit's proposals available at that later point — it is a side channel, not a policy decision. It feeds the same algorithm ported from MDK'srefs/mdk/crates/cgka-engine/src/app_components.rsvalidate_app_component_integrity_for_staged_commit.callbackdelegates every decision toinnerunchanged — this is a decorator, NOT a policy change. Therefs/marmot/protocol-core/group-messaging.mdadmin gate, the account-identity-proof check, and the admin-self-remove guard increateAdminCommitPolicyCallbackall keep their exact current behavior. Its only extra effect: BEFORE returninginner(incoming), it appends the proposal(s) to a private buffer — forincoming.kind === "commit",incoming.proposals.map((p) => p.proposal); forincoming.kind === "proposal", the singleincoming.proposal— so proposals are captured even for a messageinneritself rejects.No validation logic may be added inside this wrapper or inside
inner(Pitfall 1 — validating inside the callback runs before the resultingGroupContextexists and would produce wrong verdicts or throw mid-apply).Contract:
take()returns the buffered proposals, committer, and whether a commit callback completed the capture, then resets all three. A standalone proposal does not complete a commit capture. Callers MUST calltake()immediately before eachprocessMessagecall (discarding the result, to clear any stale proposals left over from a prior message) and again immediately afterprocessMessagereturns (to read exactly the proposals of the commit just processed). This makes it safe to reuse onecallback/take()pair across a loop of several commits processed with the same wrapped callback.