Skip to content

test(sdk): spike proving CTR resolver handles two-axis mode combinations - #1437

Merged
GarthDB merged 1 commit into
mainfrom
spike/ctr-two-axis-mode-resolution
Sep 9, 2026
Merged

test(sdk): spike proving CTR resolver handles two-axis mode combinations#1437
GarthDB merged 1 commit into
mainfrom
spike/ctr-two-axis-mode-resolution

Conversation

@GarthDB

@GarthDB GarthDB commented Sep 9, 2026

Copy link
Copy Markdown
Member

Description

Test-only spike proving the existing CTR resolver can already express and resolve combinatorial modes (e.g. a token varying by both color theme AND contrast), with no code changes to the resolver itself. Adds ctr_resolution_handles_two_axis_cross_product to sdk/core/src/graph.rs:

  1. A synthetic fixture with sibling CTRs whose scope.options cover a full colorScheme × contrast cross-product, asserting resolve_relationship_ref_in_context resolves every one of the 6 combinations to its distinct expected value — via the existing best_relationship_candidate "most matched requested keys wins" scoring, unmodified.
  2. A small (~20 line) read-only helper, concept_diverges_on_axis, built on top of the existing context-aware resolver, that derives whether a token's value actually diverges on a given mode axis (holding other axes at their ModeSetRecord default). Asserted against both a two-axis token (diverges on both) and a single-axis control (diverges on only one).

No production code changed — this is a proof/discovery artifact for design discussion, not a fix.

Related Issue

Bead spectrum-design-data-cn3v ("Model Figma exporter collections as mode-groups + modeless alias layer"), filed following up on DNA-1953 / PR #1435 and Nate Baldwin's Slack feedback (thread C0BUQU7JDA7 / p1788883017424349, comment p1788988579332039) about the Figma library's real collection/mode architecture.

Motivation and Context

Nate described the S2 Figma library's real structure: hidden "mode-group" collections (one per axis: color theme, contrast, etc.) that only contain a token if its value actually diverges on that axis, plus a single public "modeless" collection that daisy-chains aliases through whichever mode-group collections a token belongs to — supporting combinatorial modes (e.g. two independent dropdowns for a token varying by both color theme and contrast).

Before committing to an exporter redesign for that model, this spike answers the open question: can the existing CTR resolution logic (which already does specificity-based sibling matching over an N-key scope.options map) serve as the derivation engine for it? Result: yes — the resolver already proves the hard part (correct multi-axis resolution and divergence detection). The real remaining gaps are below the resolver: no token varies on two axes in real data today (token/set schemas are single-axis; contrast has a declared mode set but zero token usage), and the exporter itself still maps one collection to one axis with no modeless/alias-chain layer. Findings and recommendation recorded as a comment on cn3v.

How Has This Been Tested?

  • cargo test -p design-data-core ctr_resolution_handles_two_axis_cross_product --lib — new test passes.
  • moon run sdk:test — full workspace suite: 1419 tests run, 1419 passed, 1 skipped (unchanged from before this change).
  • cargo fmt --manifest-path sdk/Cargo.toml --all via pre-commit hook.

Screenshots (if appropriate):

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Test / spike only — no production behavior change

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

🤖 Generated with Claude Code

Spike for bead spectrum-design-data-cn3v (Nate Baldwin's mode-group /
modeless Figma variables model, Slack C0BUQU7JDA7 p1788988579332039).

Adds a synthetic-fixture test proving the existing CTR resolver, with no
changes, already resolves every point of a colorScheme x contrast
cross-product correctly via best_relationship_candidate's existing
"most matched requested keys wins" scoring over N-key scope.options maps.
Also adds a small read-only helper that derives whether a concept's value
actually diverges on a given mode axis (holding others at their
ModeSetRecord default) -- the primitive Nate's "mode-group collection
membership" needs, built entirely on the existing context-aware resolver.

Confirms the resolver is not the blocker for combinatorial modes; the
remaining gaps (no multi-axis token data today, single-axis-only
token/set schemas, and the Figma exporter's one-collection-per-axis
model with no modeless/alias-chain layer) live below the resolver and
are tracked on cn3v.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a1d682c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🎨 Token Changes Report

Tokens Changed (0)

Original Branch: main


This comment was automatically generated by the token diff tool. 🤖

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🧩 Component Schema Changes Report

No component schema changes detected.

This comment was automatically generated by the component schema diff tool. 🤖

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Run report for a1d682cb

Total time: 2m 15s | Comparison time: 4m | Estimated savings: 1m 44s (43.5% faster)

Action Time Status Info
⬛️ SetupProto(0.57.4) 0ms Skipped
🟩 SyncWorkspace 10.6ms Passed
🟩 SyncProject(sdk) 0.5ms Passed
⬛️ SetupToolchain(node:20.17.0) 11.9ms Skipped
⬛️ SetupToolchain(pnpm:10.17.1) 2.2ms Skipped
⬛️ SetupToolchain(javascript) 0ms Skipped
⬛️ SetupEnvironment(javascript, sdk) 0.4ms Skipped
⬛️ SetupToolchain(rust:1.88.0) 420.8ms Skipped
🟩 SetupEnvironment(rust, sdk) 195.9ms Passed
⬛️ InstallDependencies(rust, sdk) 7.7ms Skipped
🟩 RunTask(sdk:fmt-check) 1.2s Passed
🟩 InstallDependencies(javascript, sdk) 4.2s Passed
🟩 RunTask(sdk:codegen-check) 139.4ms Passed
🟩 RunTask(sdk:lint) 44.4s Passed
🟩 RunTask(sdk:test-doc) 1m 40s Passed
🟩 RunTask(sdk:test) 2m 11s Passed SLOW
Changed files
sdk/core/src/graph.rs

@GarthDB
GarthDB merged commit d22d38d into main Sep 9, 2026
9 checks passed
@GarthDB
GarthDB deleted the spike/ctr-two-axis-mode-resolution branch September 9, 2026 23:48
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