Repository navigation
refactor: centralize duplicate/missing-id checks in validate-metrics.mjs and validate-launch-metrics.mjs - #1751
Conversation
…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>
|
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 Hive will keep the |
There was a problem hiding this comment.
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— newmessageparameter 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 usedpath: metric.idwith no fallback; the new call passesmetric.idas path directly, preserving that (includingundefinedpath on missing id). Message'duplicate or missing metric id'preserved exactly.scripts/validate-launch-metrics.mjs:75-82— keeps itssignal.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 unconditionalids.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.mjson 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
✅ Deploy Preview for endusers ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
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. |
|
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. |
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.mjsalready migrated to
checkDuplicateOrMissingId()in validate-utils.mjs(#1739). This gives the helper an optional
messageparameter — defaultunchanged, 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