Repository navigation
feat(testing): bake source coordinates into observations (#1746) + label canonical/reference TrackResult views (#1674) - #1792
Merged
Conversation
…#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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1746. Conservative fix for #1674 + follow-up tracker #1791.
Summary
Two related diagnostic-clarity fixes for
ComplianceResultoutput, bundled because they touch the same files and tests.#1746 — Source coordinates on every
AdvisoryObservationAdvisoryObservationgains a requiredsource: ObservationSource(discriminated union):storyboard_step—code+storyboard_id+step_idstoryboard—code+storyboard_idprofile—code(from agent capability profile)probe—code(from network probe outside the storyboard pipeline)Every emission site in
comply.tsis populated: 17 incollectObservations, 4 incomplyImpl, 2 indetectAuthRejection. Regression test intest/lib/comply-advisory-rule-source.test.jsexercises a representative cross-section and structurally validates thesourceon each observation — a futureobservations.push({...})withoutsourcefails 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 onTrackResulttested_tracksis a.filter()oftracks— 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
TrackResultcarries_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 (
TestedTrackEntrywithoutscenarios/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 nestedscenariosreference identity; no deep clone, memory cost flat.Test plan
npx tsc --project tsconfig.lib.json --noEmit— cleannpm run build— cleannpm run format:checkon touched files — cleannode --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 passBoth changesets are minor
advisory-observation-source-1746.md— required-field addition, but no runtime behavior change for readers; constructors ofAdvisoryObservationoutside the SDK are essentially nonexistent (it's an output type).tested-tracks-view-marker-1674.md— purely additive optional field onTrackResult.🤖 Generated with Claude Code