Skip to content

refactor: centralize duplicate/missing-id checks in validate-metrics.mjs and validate-launch-metrics.mjs - #1751

Merged
mrbobbytables merged 1 commit into
mainfrom
arch/centralize-metrics-id-dedup
Oct 21, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
arch/centralize-metrics-id-dedup

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Refactor

validate-metrics.mjs and validate-launch-metrics.mjs each carried their own
copy of the per-entry id-dedup check (!id || seen.has(id) → push error →
seen.add(id)) that validate-case-studies.mjs and validate-radar-reports.mjs
already migrated to checkDuplicateOrMissingId() in validate-utils.mjs
(#1739). This gives the helper an optional message parameter — default
unchanged, so the two already-migrated callers are unaffected — and routes
both remaining validators through it with their existing custom messages
("duplicate or missing metric id", "duplicate or missing signal id"),
preserved exactly so the existing message-matching tests in
tests/validate-metrics.test.mjs and tests/validate-launch-metrics.test.mjs
still pass unchanged.

Added one new unit test in tests/validate-utils.test.mjs covering the
message-override parameter. Verified: node --test tests/validate-utils.test.mjs
tests/validate-metrics.test.mjs tests/validate-launch-metrics.test.mjs (113
passed), full suite before/after (2993→2994 tests, same 6 pre-existing
unrelated date-flaky failures in both), eslint clean, and
scripts/check-duplication.mjs still within ceiling.

Fixes #1750


Filed by architect agent (ACMM L5 — hold-gated mode). Hold-gated: human review required.

— hive: agent=architect backend=copilot model=claude-opus-4-6 copilot=1.0.88

…mjs and validate-launch-metrics.mjs

Both scripts carried an independent copy of the id-dedup check that
validate-case-studies.mjs and validate-radar-reports.mjs already migrated to
validate-utils.checkDuplicateOrMissingId() (#1739). Give the helper an
optional message parameter (defaulting to the existing generic message, so
the two already-migrated callers are unaffected) and route both remaining
validators through it with their existing custom messages, so the dedup rule
now has one implementation instead of four near-identical copies.

Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "architect" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3–L5; an outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@hivecommons-hive hivecommons-hive Bot left a comment

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.

Read the helper and all four call sites at head 4303878; this looks correct to me.

Verified against the tree, not just the diff:

  • scripts/lib/validate-utils.mjs:285-299 — new message parameter defaults to 'duplicate or missing id', so the two already-migrated callers (validate-case-studies.mjs:47, validate-radar-reports.mjs:47, both still 4-arg) are byte-for-byte unaffected.
  • scripts/validate-metrics.mjs:73-79 — old code used path: metric.id with no fallback; the new call passes metric.id as path directly, preserving that (including undefined path on missing id). Message 'duplicate or missing metric id' preserved exactly.
  • scripts/validate-launch-metrics.mjs:75-82 — keeps its signal.id || '(missing id)' path fallback and the 'duplicate or missing signal id' message exactly.
  • Unconditional seen.add(id) in the helper matches both validators' old unconditional ids.add(...), so falsy-id dedup behavior is unchanged.
  • Ran node --test tests/validate-utils.test.mjs tests/validate-metrics.test.mjs tests/validate-launch-metrics.test.mjs on the PR branch: 113 pass, 0 fail — matching the body's claim.

No findings. PR carries the hold label (hold-gated lane), so merge remains a maintainer's call.

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@netlify

netlify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for endusers ready!

Name Link
🔨 Latest commit 4303878
🔍 Latest deploy log https://app.netlify.com/projects/endusers/deploys/6ad8d99618077df4a81a2202
😎 Deploy Preview https://deploy-preview-1751--endusers.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mrbobbytables

Copy link
Copy Markdown
Member

The maintainer explicitly authorized releasing this hold and submitting the reviewed refactor to the normal merge queue. The existing shared-helper adoption remains behavior-preserving and scoped to these two validators; required repository-validation and lint checks are green. No merge protections or checks are bypassed.

@mrbobbytables
mrbobbytables added this pull request to the merge queue Oct 21, 2026
@mrbobbytables

Copy link
Copy Markdown
Member

P3 follow-through: completed a bounded semantic inventory of the Set-based duplicate checks in the current validators at main 5ddf6b0. This PR covers the two remaining inline ID checks equivalent to the shared helper. Architecture records validate required fields separately and report duplicate-only errors; members check duplicates only for string IDs; end-user snapshots validate sourceId separately; group slugs are recorded only when truthy. Project-name and case-study URL checks have their own type, diagnostic and validation-flow contracts. Those are not drop-in migrations to checkDuplicateOrMissingId and are intentionally unchanged. No additional equivalent ID-check migration was identified in the reviewed validators. Keep this as the single bounded adoption change, without a new guard or per-file cleanup series. The earlier P3 validator/CSS refactors and advisory reconciliation are already delivered.

Merged via the queue into main with commit 342b7f8 Oct 21, 2026
14 checks passed
@mrbobbytables
mrbobbytables deleted the arch/centralize-metrics-id-dedup branch October 26, 2026 01:50
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.

[architect] validate-metrics.mjs and validate-launch-metrics.mjs duplicate the id-dedup check validate-utils.mjs already centralizes

1 participant