Skip to content

test(core): pin the secret-redaction escape hatch (and compact) to the root barrel - #747

Open
rejifald wants to merge 1 commit into
mainfrom
claude/exciting-lovelace-662ab5
Open

test(core): pin the secret-redaction escape hatch (and compact) to the root barrel#747
rejifald wants to merge 1 commit into
mainfrom
claude/exciting-lovelace-662ab5

Conversation

@rejifald

Copy link
Copy Markdown
Owner

Why

public-api-surface.spec.ts exists for one reason, stated in its own header: smoke.spec.ts
exercises stitch end-to-end, but nothing pins the export surface itself, so an accidental
removal or rename of a public symbol slips past the suite and is caught only by attw/build, late.

Four documented value exports of the root barrel were never in FUNCTIONS, so the guard did not
cover them.

What this does

Adds them, each with a comment in the file's existing style explaining why the symbol is public —
mirroring what is already written above parseDuration/parseBytes/parseRate.

Export Why it is public
registerSecretKey Widens the secret-key denylist so a host's custom credential param name is scrubbed in every trace sink (start.url, OTLP url.full, input.query). The escape hatch for a credential the built-in set/stems don't catch.
isSecretKey The matching predicate — a host audits which of its query params / body keys the scrubbers already cover.
redactSecretsDeep Scrubs a plain value with that predicate; what .inspect({ redact }) hands the caller.
compact The exactOptionalPropertyTypes companion — config authoring under that flag otherwise needs the ...(key !== undefined ? { key } : {}) spread dance at every call site.

The trio is placed after the OTLP block and compact after the parsers, matching src/index.ts
ordering.

Why the secret-redaction trio in particular

Two things make this pin load-bearing rather than hypothetical:

  • ADR 0021's export table lists all three
    as stitchapistitchapi. Keeping them on the root was an explicit decision when the auth
    surface moved to stitchapi/auth, even though apiKey({ in: 'query', name }) — which lives on
    the subpath now — is what registers into them automatically.
  • A real cross-package consumer: @stitchapi/query-core imports isSecretKey from this
    barrel
    (packages/query-core/src/index.ts:19) to extend
    the denylist with header names, rather than fork a parallel list that would drift. That is the
    same peer-package argument the parsers' comment already makes.

The fourth one — a sweep, not the original ask

The task named three. The defect class is "a public value export on the root barrel with nothing
pinning it", so I diffed every value export of src/index.ts against everything the spec
covers: FUNCTIONS, the systemClock shape test, the error-class test, and the
httpSurface/graphqlSurface id test.

compact (src/index.ts:82) was the fourth gap and had no
dedicated spec either — the compact hits in stream.spec.ts / json-stream-buffer.spec.ts are
the unrelated internal stream-buffer compaction, not this export. Fixed here rather than left
as follow-up work.

Those four were the only gaps; everything on the barrel is now covered.

Reviewer notes

  • Test-only change. No source file is touched, so there is no bundle-size or API impact — the
    bundle-advertised-size tether is unaffected.
  • The pin is structural, not tautological: expect(typeof api[name]).toBe('function') fails on
    undefined the moment an export is removed or renamed, which is exactly the event this file
    guards.
  • A docs gap this surfaced, deliberately not fixed here. These three have no reference page
    apps/docs/content/docs/reference/helpers.mdx has no "Secret redaction" section (its headings run
    Transport / Tracing & OTLP / Store), and the names appear nowhere under apps/docs/. They are
    public API on ADR 0021's authority and query-core's import, not on the docs site's. That is the
    known root-barrel-exports-without-a-reference-page gap and belongs in its own docs PR.

Verification

  • pnpm test in packages/core: 169 files / 1578 tests passed.
  • The four new pins confirmed to actually execute (--reporter=verbose), not silently skip.
  • Pre-commit gates green: prettier (unchanged), check:lint clean across 37 packages, check:types
    across all 39 workspace projects.

🤖 Generated with Claude Code

@rejifald
rejifald force-pushed the claude/exciting-lovelace-662ab5 branch 2 times, most recently from 6e8b112 to 0b927b5 Compare August 16, 2026 14:50
…the root barrel

`public-api-surface.spec.ts` exists so an accidental removal or rename of a
documented value export can't slip past the suite, but four exports it was
supposed to cover were never in `FUNCTIONS`:

- `registerSecretKey` / `isSecretKey` / `redactSecretsDeep` — the
  trace-redaction escape hatch. ADR 0021's export table deliberately keeps all
  three on the ROOT when the auth surface moved to `stitchapi/auth`, and
  `@stitchapi/query-core` imports `isSecretKey` from this barrel to extend the
  denylist with header names rather than fork a parallel list that would drift.
  The pin is load-bearing today, not hypothetical.
- `compact` — found by sweeping the same defect class (a public value export on
  the barrel with nothing pinning it) across every export of `src/index.ts`.
  The `compact` hits in the stream specs are the unrelated internal
  stream-buffer compaction, so nothing covered it.

Each entry carries a comment explaining why the symbol is public, mirroring
what's already written above the `duration`/`size`/`rate` token grammars.

Diffed all root value exports against `FUNCTIONS`, the `systemClock` shape
test, the error-class test and the surface-id test: those four were the only
gaps, and everything on the barrel is now covered.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rejifald
rejifald force-pushed the claude/exciting-lovelace-662ab5 branch from 0b927b5 to ab46848 Compare August 16, 2026 15:10
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