Skip to content

DXBRB-569: Add snapshot score CLI commands - #150

Merged
williamjgray merged 2 commits into
mainfrom
DXBRB-569-snapshot-scores-cli
Nov 16, 2026
Merged

williamjgray merged 2 commits into
mainfrom
DXBRB-569-snapshot-scores-cli

Conversation

@williamjgray

Copy link
Copy Markdown
Contributor

Summary

Adds five dx snapshots score commands and puts all six, including the existing workflowScores, on one shared factory and renderer.

 dx snapshots
+  allocationPercentages list   # /snapshots.allocationPercentages
   csatComments list
+  csatScores list              # /snapshots.csatScores
   driverComments list
+  driverScores list            # /snapshots.driverScores
+  dxiScores list               # /snapshots.dxiScores
+  impactScores list            # /snapshots.impactScores
   info
   list
   settings
   snapshotTeams list
   workflowScores list          # /snapshots.workflowScores

Every score command takes --id plus --team-ids, --snapshot-team-ids, --group-ids, --branch-ids, and --attribute-ids, and returns the same { filters, results } envelope.

snapshotScoresCommand(config)        # options, help examples, fetch, --json
  renderSnapshotScores(config, ...)  # title, filters, count, web link
    for each result
      config.heading(result)
      hidden? -> "(Hidden)"
      config.details(result)         # ui.dl
      config.table.render(result)    # distribution / items / drivers

Each command is a config constant (DRIVER_SCORES_COMMAND, etc.) with its endpoint, web link section and query, and three small callbacks. Snapshot web links now default to branch=ALL, matching the app URLs.

Also updates the CHANGELOG and the dx-cli skill docs. The docs site article is intentionally left for a follow-up.

Evidence

  • Before:
    $ dx snapshots driverScores list --id MjUyNbaY
    error: unknown command 'driverScores'
    
    After:
    $ dx snapshots driverScores list --id MjUyNbaY
    # Snapshot Driver Scores
    Displaying 2 drivers.
    https://app.getdx.com/snapshots/MjUyNbaY/drivers?branch=ALL
    ## Deep work
    Driver ID:  drv-deep
    Score:      65
    ...
    
  • Tests: src/commands/snapshots.test.ts 40/40 pass, covering human output with visible and hidden results, --json passthrough, filter forwarding, missing --id, and the DXI empty state. tsc, eslint, and prettier --check are clean.

Merge Danger

Door: two-way

Pure additions plus an internal refactor of workflowScores. Reverting the commit restores the previous behavior.

Blast Radius: small

The only user-visible change to an existing command is the workflowScores web link gaining branch=ALL. Driver and CSAT distribution labels are mapped from API keys; unknown keys fall back to a humanized label rather than being dropped.

🤖 Generated with Claude Code

Add dx snapshots allocationPercentages, csatScores, driverScores,
dxiScores, and impactScores list commands. All six score commands,
including workflowScores, now share one command factory and renderer
with the same filter options and response envelope. Web links default
to branch=ALL.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@williamjgray williamjgray changed the title DXBRB-547: Add snapshot score CLI commands DXBRB-569: Add snapshot score CLI commands Nov 13, 2026
@williamjgray williamjgray self-assigned this Nov 13, 2026
@williamjgray
williamjgray requested a review from a team November 13, 2026 23:35
@ryanbjones

Copy link
Copy Markdown

Follow-up API contract audit against get-dx/app master at b40c232d. Found additional fixture/type assumptions beyond the CSAT field; details inline. Please align the score fixtures with the serializers and SQL, then give the fixtures explicit response types (for example, satisfies) with concrete CSAT/driver distribution keys so extra fields cannot silently pass. Existing snapshot tests pass, but their mocked payloads currently mask these mismatches.

CSAT has no separate not-applicable count

CLI location

Please remove not_applicable_count and the corresponding output assertion. The CSAT serializer returns only the five satisfaction counts plus idk_na_count; there is no separate not-applicable count. This fixture currently tests a response the app does not emit.

Impact metadata and scale do not match the app

CLI location

Please use the actual Speed/Quality metadata and scales here. The built-in definitions use scoring_method: "Percent favorable", target_role: "all", and five options (Speed: Very slow through Very fast, values 1–5), not "average" and a two-option scale. The score should agree with the favorable-response percentage. Quality still retains its options when hidden; only its score/distribution are nulled by the serializer. Update the output assertions along with these fixtures.

Allocation bucket should be innovation

CLI location

bucket: "features" is not an app bucket. AllocationQuestionItem permits "innovation", "ktlo", or null, and the allocation serializer passes that value through. Please change this fixture and its table assertion to "innovation", and narrow the CLI bucket type to those actual values.

Driver score and role values are inconsistent

CLI location

Please align the driver fixture values with the app as well: these three-point counts produce round(100 * 20 / (4 + 10 + 20)) = 59, not 65, under SQL::SCORE_CALC. The Factor model also uses dev / nondev / all and a non-null target role, whereas these driver fixtures use "developer" and null. Use real role values here and in the DXI driver fixture, and update the expected output.

DXI score and visibility are inconsistent

CLI location

This DXI fixture cannot come from the app: a single contributing driver scored 65 gives a DXI of 65, not 72, because DxiTrends averages the contributing scores. Also, DxiScores computes hidden once for the whole filtered cohort, so one response cannot mix a visible scale with a hidden scale. Please test visible and hidden responses separately; a hidden result should retain driver metadata with null scores rather than using an empty list just to model hiding.

Benchmark percentiles are numbers

CLI location

The comment about decimal strings is not supported by the current app contract. BenchmarkFactor stores p50/p75/p90 as integers; driver, impact, and DXI serializers return those integers, and the workflow serializer explicitly calls to_f. Please keep these percentile types numeric rather than adding an assumed string response shape.

Workflow fixtures do not match the serializer

CLI location

This nullable distribution type is correct, but the workflow fixture reused by this refactor still models an impossible response: hidden distribution is [] instead of null; options are empty despite a populated distribution; and the two workflows have different total_cohort/hidden states in one response. The serializer derives options from the distribution, and WorkflowAggregateScores uses the same filtered cohort for every workflow. It also inner-joins options, so the existing test that manufactures an empty distribution does not model an API response. Please split hidden/visible responses and use real options and consistent counts; the displayed fixture counts imply a weighted score of 6.4407, not 10.5.

Comment thread src/commands/snapshots.test.ts Outdated
satisfied_count: 1,
very_satisfied_count: 1,
idk_na_count: 2,
not_applicable_count: 3,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this field is not returned

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 5aa3a17. The CSAT distribution is now a concrete type with the five satisfaction counts plus idk_na_count, so an extra key fails typecheck.

Comment thread src/commands/snapshots.test.ts Outdated
},
score: 65,
distribution: {
bad_count: 4,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be worth having one of the responses with the 5 pt scale distribution (never-> always) since that will be most common

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 5aa3a17. Deep work is now a 5-point driver (never through always, score 53 from the counts), Code review stays 3-point (score 59), and Documentation is the hidden one. The test asserts both scales render.

Comment thread src/commands/snapshots.ts Outdated
blocks.push(...config.heading(result));

if (result.hidden) {
blocks.push(ui.p(ui.dim("(Hidden)")));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Explain hidden and unavailable results in human output

The built CLI prints only (Hidden) for a suppressed result and Score: (None) for an all-N/A CSAT result. For a non-technical user those do not explain whether access failed, the command failed, or there were insufficient responses. Please say that hidden results are below the minimum reporting threshold; distinguish an unavailable score due to no scored answers from an empty result set, and suggest checking/broadening filters where appropriate. Keep --json unchanged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5aa3a17. Hidden results now print "Hidden: too few responses to meet the account's minimum reporting threshold." An empty result set prints "No were returned for this snapshot." A visible result with a null score prints "Unavailable (no scored answers)" instead of "(None)". When the user passed any filter flag, both the hidden and empty messages append "Check the filter IDs or broaden the filters." The hint keys on the CLI flags rather than the API echo, so an unrecognized ID still gets it. --json is unchanged.

Comment thread src/commands/snapshots.ts
label: "Filter workflow scores by team IDs",
command:
"dx snapshots workflowScores list --id MjUyNbaY --team-ids MTExNDg5,MTExNDg4",
label: `Filter ${config.noun} by team IDs`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Show users how to obtain the IDs required by these commands

The generated --help examples contain sample IDs, but do not tell a first-time user where to get their own snapshot/team/attribute IDs. Please add a short read-only path such as dx snapshots list → dx snapshots snapshotTeams list --id <snapshot_id> → the score command, plus ID discovery guidance for supported filters. The DXI help should also mention its main-branch restriction. This would let someone use these commands without consulting the agent skill or knowing the API already.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5aa3a17. Every score command's --help now has a Notes section: snapshot IDs from dx snapshots list, snapshot team IDs from dx snapshots snapshotTeams list --id <snapshot_id>, team IDs from dx teams list, attribute IDs from dx attributeGroups list, branch IDs from dx snapshots settings branches list (snapshots:admin), and group IDs from the web app since there is no CLI or API for them. The notes also explain hidden results. The DXI help adds the main-branch restriction. The skill docs point at the same commands.

@ryanbjones

ryanbjones commented Nov 13, 2026 •

Copy link
Copy Markdown

I recommend removing web links from the score output for this release, including the shared workflow renderer, because the query parameters and ID can be base64 in our CLI but numeric IDs in the UI params. And param names may not match exactly

Drop web links from all six score commands, including workflowScores,
because the web app's filter params and ID encoding differ from the
API's. Explain hidden results, empty result sets, and visible results
with no scored answers in human output, and hint at the filters when
the user passed any. Add help notes on where to find snapshot, team,
attribute, and branch IDs, plus the DXI main-branch rule.

Align types with the app: numeric benchmark percentiles, concrete
CSAT and driver distribution keys, and innovation/ktlo allocation
buckets. Rewrite the test fixtures to match the serializers and SQL,
with scores that agree with their counts, real target roles and
impact scales, and separate visible and hidden responses for
workflows and DXI.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@williamjgray

Copy link
Copy Markdown
Contributor Author

Addressed the API contract audit and the web link recommendation in 5aa3a17.

Web links are removed from all six score commands, including the shared renderer that workflowScores uses. The web filter key mapping and the branch=ALL default are gone. Comments, teams, info, and list keep their links. The changelog notes the change.

Fixtures and types now follow the serializers and SQL, and each fixture uses satisfies against the exported response type:

  • CSAT: not_applicable_count removed; distribution is a concrete type. Added a visible all-N/A item to exercise the unavailable-score message.
  • Impact: Speed and Quality use Percent favorable, target_role: "all", and the five real options. Speed scores 50 from its counts. Hidden Quality keeps its options with null score and distribution.
  • Allocation: bucket is innovation, and the type is narrowed to "innovation" | "ktlo" | null. The hidden question keeps its item with a null percentage.
  • Drivers: 5-point Deep work scores 53 and 3-point Code review scores 59 under SCORE_CALC. Roles are dev and nondev, never null.
  • DXI: visible and hidden responses are separate. The 5-point result averages its two drivers to 62, the 3-point result is 59. The hidden response keeps driver metadata with null scores.
  • Benchmarks: percentiles are number only; the decimal-string comment is gone.
  • Workflows: options are derived from the distribution, both workflows share one cohort and hidden state per response, scores are 6.4407 and 1.4831 from the weighted counts, and the hidden fixture uses a null distribution. The manufactured empty-distribution test is removed. Hidden workflows are tested in their own response.

@williamjgray
williamjgray merged commit f6a555f into main Nov 16, 2026
4 checks passed
@williamjgray
williamjgray deleted the DXBRB-569-snapshot-scores-cli branch November 16, 2026 17:22
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.

2 participants