Skip to content

[AAASM-5743] 🐛 (core): Tell a caller-supplied client the truth about its own checks - #371

Open
Chisanan232 wants to merge 3 commits into
mainfrom
v0.0.1/AAASM-5743/fix/audit_warning_provenance
Open

[AAASM-5743] 🐛 (core): Tell a caller-supplied client the truth about its own checks#371
Chisanan232 wants to merge 3 commits into
mainfrom
v0.0.1/AAASM-5743/fix/audit_warning_provenance

Conversation

@Chisanan232

@Chisanan232 Chisanan232 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

A caller who did exactly the right thing — supplied a real enforcing gateway client, and declared honestly that it drops audit — was told at every startup that their policy checks route through the allow-all no-op and that a DENY cannot block a tool call.

Measured false for such a client: its check returns {denied: true, pending: false, reason: "MY OWN POLICY DENIES"}. Precisely inverted, for the most sophisticated adopter.

Root cause

resolveAuditSink collapses two distinct states into one value:

  • shipped-and-discarding, and
  • caller-supplied-and-declared-discarding.

warnAuditEventsDiscarded received only mode, so it could not tell whose client it was describing — and two of its sentences differ between the two.

This is AAASM-5681's shape in a third direction. That ticket fixed the mode branch (twice — the first fix inverted the defect into napi-inprocess before N9/N10 pinned it both ways). This is the provenance branch, which nobody had looked at.

Fix

Provenance is passed in rather than re-derived, following the rule AAASM-5681 established the hard way: a claim that varies by a branch has to be expressed by that branch, not by wording placed near it.

For a caller-supplied client the SDK now makes no claim about enforcement at all — it did not build that client and does not know what its check does. The warning still fires, because the caller declared the events are dropped and that part is true; what changed is whose client it describes and what it refuses to assert.

Acceptance criteria

AC1 — no statement false for a caller-supplied client. Both false sentences are asserted absent; the honest one is asserted present.

AC2 — pinned in both directions, neither passing on the other's coverage. Two mutations at the call site:

mutation reddens
callerSupplied forced false (fix reverted) only a caller's client declaring "discarded" is told nothing that is false for it
callerSupplied forced true (fix inverted) only the shipped cases — in auto, DOES say policy checks route through the allow-all no-op client (pre-existing, AAASM-5681) and the new a SHIPPED discarding client still gets the shipped wording

Disjoint. That is the N9/N10 property this AC asks for.

The caller-supplied case also drives its own check and observes the deny before judging the wording — a check that is never called cannot falsify a claim about what check does.

AC3 — the existing negative control still holds. No declaration still yields "caller-supplied" and no warning.

AC4 — the four per-mode assertions from AAASM-5681 pass unchanged. The in auto one is load-bearing in the table above: it is one of the tests that catches the inverted mutation.

Testing

  • Unit tests added/updated

tests/audit-sink-disposition.test.ts 17/17. Full suite 744 passed, 2 skipped. pnpm lint clean, pnpm typecheck clean.

Type of Change

  • 🔧 Bug fix

Breaking Changes

  • No — warnAuditEventsDiscarded is module-private; the warning text changes for one previously-wrong case.

Related Issues

A caller who supplies a real enforcing client and honestly declares
`auditSink: "discarded"` was told at every startup that their policy checks
route through the allow-all no-op and that a DENY cannot block a tool.
Measured false for such a client: its `check` returned a genuine deny.

`resolveAuditSink` collapses shipped-and-discarding with
caller-supplied-and-declared-discarding into one value, and the warning was told
only the mode — so it could not tell whose client it was describing. Provenance
is now passed in, following the rule AAASM-5681 established twice: a claim that
varies by a branch is expressed by that branch, not by wording near it.

For a caller-supplied client the SDK now makes no claim about enforcement at
all, which is the honest position — it did not build that client.

AAASM-5743.
Forcing callerSupplied false reddens only the caller-supplied case; forcing it
true reddens only the shipped ones, including the pre-existing AAASM-5681
per-mode assertion. Neither passes on the other coverage, which is what
AAASM-5681 N9/N10 established for the mode branch and AAASM-5743 AC2 asks for
here.

The caller case drives its own `check` and observes the deny before judging the
wording — a check that is never called cannot falsify a claim about what check
does.
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

AAASM-5681 gave the enforcement clause a CHECK_CAPABLE_MODE arm. Coverage
measurement put it at zero executions, and the reason is structural, not a
missing test: reaching it needs `discarded` in napi-inprocess, and
`createNativeClient` THROWS on an unloadable binding in that mode rather than
falling back to the stub — the stub is only ever built for grpc-sidecar. So the
client always has canRegister: true and declares "forwarded".

The arm therefore held a claim-bearing sentence that no run could emit. It is
removed, and the invariant that makes it unreachable is pinned instead: if a
future change lets napi-inprocess fall back to a stub, that test reddens and the
arm has to come back with it.

Found by codecov flagging the patch, then measured rather than assumed
(AAASM-5743).
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant