Skip to content

feat(core): enhanced result object .report() + source discriminator (ADR 0019)#343

Merged
rejifald merged 1 commit into
feat/adr-0018-inspect-raw-redactionfrom
feat/adr-0019-enhanced-result-object
Jun 29, 2026
Merged

feat(core): enhanced result object .report() + source discriminator (ADR 0019)#343
rejifald merged 1 commit into
feat/adr-0018-inspect-raw-redactionfrom
feat/adr-0019-enhanced-result-object

Conversation

@rejifald

Copy link
Copy Markdown
Owner

Implements ADR 0019 (flipped to Accepted in this PR). Third of three stacked implementation PRs for ADR 0016's deferrals; supersedes the docs-only #337.

Stacked on #342 (ADR 0018). Base is feat/adr-0018-inspect-raw-redaction — review/merge #342 first; the diff here is 0019-only. Retarget to main once #342 lands.

What & why

Adds the run-diagnostics surface ADR 0016 deliberately held the line against, and folds in the source discriminator (two of 0016's four deferrals).

  • Inspection<T> gains source: 'live' | 'cache' | 'stream' — the interpretant of raw (why it is/isn't null). It lands on the minimal object, not the report, because it explains an existing Inspection field — revising 0016's guess that source belonged on the enhanced object. 'cache'/'stream' are structural nulls; 'live' means a request ran.
  • new .report()RunReport<T> extends Inspection<T> adding attempts, timing { ms, waited? }, the redacted config, and the cache outcome. .inspect() stays the minimal "raw + drift" probe; RunReport is "how did this run go?".

Plumbing audit (the heart of the ADR)

Everything is derived from the existing event spineattempts, done.ms, Σ progress.waitedMs, the phase:'cache' detail — so no new engine events. A shared drainRun feeds both .inspect() and .report(); source precedence is stream > cache > live. Per-attempt latency is deliberately deferred (the spine has no per-attempt request spans).

Privacy

config is the already-redacted __config, never __rawConfig; raw stays non-enumerable and inherits 0018's redact. v1 echoes the static redacted config (per-call input overrides not reflected) — the fallback the ADR permits.

Verification

Pre-commit gate green (format, lint, monorepo typecheck). packages/core tests: 1108 passed, incl. 10 new .report()/source tests. No engine.ts changes.

🤖 Generated with Claude Code

…ADR 0019)

Add the run-diagnostics surface ADR 0016 held the line against, plus the
`source` discriminator (folds in two of 0016's four deferrals).

- `Inspection<T>` gains `source: 'live' | 'cache' | 'stream'` — the
  interpretant of `raw` (why it is/isn't null). It lands on the minimal
  object (not the report) because it explains an Inspection field; revises
  0016's guess that source belonged on the enhanced object.
- new `.report()` -> `RunReport<T> extends Inspection<T>` adding `attempts`,
  `timing { ms, waited? }`, the redacted `config`, and the `cache` outcome.
  `.inspect()` stays the minimal "raw + drift" probe.

Built entirely from the existing event spine — `attempts`/`done.ms`/
`Σ progress.waitedMs`/the `phase:'cache'` detail — so NO new engine events
(per-attempt latency is deferred). A shared `drainRun` feeds both consumers;
`source` precedence is stream > cache > live. `config` is the already-redacted
`__config`, never `__rawConfig`. Never throws.

Flips ADR 0019 to Accepted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rejifald rejifald merged commit 2a0867d into feat/adr-0018-inspect-raw-redaction Jun 29, 2026
rejifald added a commit that referenced this pull request Jun 29, 2026
#343 merged into this branch added the .report() instance method but the
generated playground-completions.generated.ts was not re-run, so the
verify gate's `git diff --exit-code` on the generated file failed.
Pure regeneration via `pnpm --filter @stitchapi/docs gen:completions`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
rejifald added a commit that referenced this pull request Jun 30, 2026
…DR 0019) (#342)

Lands two ADR 0016 deferrals (ADR 0019's #343 was stacked into this branch, so both ship together):

- ADR 0018: opt-in InspectOptions.redact (default off) scrubs secret-named fields from .inspect()'s raw via redactSecretsDeep; isSecretQueryKey → isSecretKey (alias kept). A safe-sharing convenience, never a leak guarantee.
- ADR 0019: .report() → RunReport<T> extends Inspection<T> (attempts, timing, redacted config, cache outcome) + the 'source' discriminator on Inspection. Built off the existing event spine; no new engine events.

Bundle budget raised 23.55→23.95 / 19.0→19.45 KB (both attach to the core Stitch surface, ~0.45 KB); advertised whole-entry size ~23→~24 kB. Resolves main's P5 (value→data) / P17 (waited/elapsed de-suffix) renames.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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