Skip to content

feat(testing): bake source coordinates into observations (#1746) + label canonical/reference TrackResult views (#1674) - #1792

Merged
bokelley merged 3 commits into
mainfrom
bokelley/observation-source-coordinates
May 16, 2026
Merged

bokelley merged 3 commits into
mainfrom
bokelley/observation-source-coordinates

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Closes #1746. Conservative fix for #1674 + follow-up tracker #1791.

Summary

Two related diagnostic-clarity fixes for ComplianceResult output, bundled because they touch the same files and tests.

#1746 — Source coordinates on every AdvisoryObservation

AdvisoryObservation gains a required source: ObservationSource (discriminated union):

  • storyboard_step — code + storyboard_id + step_id
  • storyboard — code + storyboard_id
  • profile — code (from agent capability profile)
  • probe — code (from network probe outside the storyboard pipeline)

Every emission site in comply.ts is populated: 17 in collectObservations, 4 in complyImpl, 2 in detectAuthRejection. Regression test in test/lib/comply-advisory-rule-source.test.js exercises a representative cross-section and structurally validates the source on each observation — a future observations.push({...}) without source fails the build, closing the class of bugs #1736 surfaced (unbacked hard-coded advisories).

Text output gains a ↳ source: (code · storyboard_id/step_id) line under each advisory; JSON includes the field by structural recursion. Triagers can grep the storyboard YAML straight from a failing run.

#1674 — _view: 'canonical' | 'reference' marker on TrackResult

tested_tracks is a .filter() of tracks — same JS object references, so JSON serializes every passing scenario twice. Triagers wasted hours on false "duplicate execution" hypotheses (#1658, salesagent#331).

Conservative fix: every TrackResult carries _view:

  • tracks[n]._view === 'canonical' (source of truth)
  • tested_tracks[n]._view === 'reference' (filtered view; shallow copy)

Consumers dedupe with result.tracks.flatMap(t => t.scenarios) or filter on _view === 'canonical'. CI pipelines should keep using --summary-output / buildComplianceSummary() for the stable dedupe-by-design surface.

The duplication remains for back-compat. The breaking type-split that fully removes it (TestedTrackEntry without scenarios/skipped_scenarios) is tracked at #1791 — slated for bundling with the AdCP 3.1 adoption umbrella (#1580).

Both construction sites updated (complyImpl + runWithDegradedProfile). Shallow copy preserves nested scenarios reference identity; no deep clone, memory cost flat.

Test plan

  • npx tsc --project tsconfig.lib.json --noEmit — clean
  • npm run build — clean
  • npm run format:check on touched files — clean
  • node --test test/lib/comply-advisory-rule-source.test.js test/lib/comply-tested-tracks-view.test.js test/lib/compliance.test.js test/lib/compliance-summary.test.js test/lib/storyboard-observations.test.js test/lib/compliance-umbrella.test.js test/lib/storyboard-track-silent-rollup.test.js test/lib/storyboard-skip-counting.test.js — 79 tests pass

Both changesets are minor

  • advisory-observation-source-1746.md — required-field addition, but no runtime behavior change for readers; constructors of AdvisoryObservation outside the SDK are essentially nonexistent (it's an output type).
  • tested-tracks-view-marker-1674.md — purely additive optional field on TrackResult.

🤖 Generated with Claude Code

bokelley and others added 3 commits May 16, 2026 11:07
…#1746)

Adds required `source: ObservationSource` to `AdvisoryObservation`. The
discriminated-union shape carries the rule code plus storyboard/step
coordinates when applicable:

- storyboard_step — storyboard_id + step_id (most evaluator rules)
- storyboard      — storyboard_id (rollups across scenarios)
- profile         — derived from capability profile (no coordinates)
- probe           — network probe outside the storyboard pipeline

Every emission site in comply.ts is populated: 17 in collectObservations,
4 in complyImpl (tool-discovery), 2 in detectAuthRejection. Regression
test exercises a representative cross-section and structurally validates
source.kind/code plus coordinates when the kind requires them — a future
push() without source fails the build.

Text output gains a `↳ source: (code · storyboard_id/step_id)` line under
each advisory; JSON includes the field by structural recursion. Triagers
can grep the storyboard YAML directly from a failing run.

Closes #1746.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ComplianceResult.tested_tracks is a .filter() of .tracks — same JS
object references, so JSON.stringify serializes every scenario twice.
Triagers grepping --json output wasted hours on false "duplicate
execution" hypotheses (#1658, salesagent#331).

Conservative fix: every TrackResult carries _view = 'canonical' |
'reference'. Consumers wanting a deduplicated view filter on _view ===
'canonical' or iterate `tracks` and ignore `tested_tracks`. CI pipelines
should keep reading buildComplianceSummary() / --summary-output for the
stable dedupe-by-design contract.

The duplication remains; the breaking type-split that removes it (a
narrower TestedTrackEntry omitting scenarios/skipped_scenarios) is
tracked at #1791 for bundling with the AdCP 3.1 adoption umbrella
(#1580).

Both construction sites updated (complyImpl + runWithDegradedProfile).
Shallow-copy on the tested_tracks side preserves nested scenarios
reference identity — no deep clone, memory cost stays flat. Regression
test pins the canonical/reference labeling, shallow-copy invariant, and
the documented dedup recipe.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…_id + kebab-case code

Two non-blocking notes from PR #1792 expert review:

- source.storyboard_id is sourced from TestResult.scenario which is
  ${storyboard_id}/${phase_id} (not the bare storyboard ID). Document
  that the field is composite — still greppable against storyboard
  YAML, just with extra phase-level specificity.

- source.code is intentionally kebab-case to match storyboard step-id
  conventions in compliance YAML, even though the rest of the SDK
  surface is snake_case. Document the divergence so adopters greppable-
  searching reports know which casing to look for.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.

Bake storyboard/step coordinates into every AdvisoryObservation

1 participant