Skip to content

feat(core): clip-model hf- ids minted at parse, emitted as data-hf-id (R1)#1270

Open
vanceingalls wants to merge 1 commit into
graphite-base/1270from
06-07-feat_core_clip-model_hf-_ids_minted_at_parse_emitted_as_data-hf-id_r1_
Open

feat(core): clip-model hf- ids minted at parse, emitted as data-hf-id (R1)#1270
vanceingalls wants to merge 1 commit into
graphite-base/1270from
06-07-feat_core_clip-model_hf-_ids_minted_at_parse_emitted_as_data-hf-id_r1_

Conversation

@vanceingalls
Copy link
Copy Markdown
Collaborator

@vanceingalls vanceingalls commented Jun 8, 2026

What

Wires ensureHfIds (PR #1269) into parseHtml so every parsed composition gets stable data-hf-id attributes before the element model is built.

Clip model id chain:

const id = el.getAttribute("data-hf-id") || el.id || `element-${++idCounter}`;

data-hf-id is now the primary identity; existing HTML id attrs and the counter fallback are preserved for backwards compatibility.

Bridge for legacy callers: updateElementInHtml and removeElementFromHtml in htmlParser.ts now try [data-hf-id="${id}"] when getElementById fails, so string-based callers that pass a hf-xxxx value continue to work without knowing about the new field.

Why

Without this PR, ensureHfIds is a no-op — the helper exists but nothing calls it. This is the commit that makes T2 tests turn green and makes every parseHtml call produce stable hf- ids. Depends on PR #1269.

How

// before DOMParser.parseFromString:
const withIds = ensureHfIds(html);
const doc = parser.parseFromString(withIds, "text/html");

htmlParser.ts baseline snapshots updated to reflect the hf- id format (see 168c0452c).

Test plan

  • T2 spec: 3 previously-.fails tests now pass — elements get hf- prefixed ids, format matches /^hf-[a-z0-9]{4}$/, adding a sibling doesn't change existing ids
  • All pre-existing htmlParser.test.ts baselines updated and passing
  • Existing stableIds.test.ts baselines (round-trip, uniqueness, existing-id preservation) still green

Copy link
Copy Markdown
Collaborator Author

vanceingalls commented Jun 8, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vanceingalls vanceingalls changed the base branch from 06-07-feat_core_ensurehfids_node-id_pass_shared_hf-_mint_helper_r1_ to graphite-base/1270 June 8, 2026 17:24
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