Skip to content

[architect] Four validator scripts duplicate the same per-entry dedup check instead of a shared helper #1766

Closed

Description

@hivecommons-hive

Architecture Finding

Type: tech-debt (duplicated logic)
Affected area: scripts/validate-architectures.mjs, scripts/validate-community-groups.mjs, scripts/validate-members.mjs, scripts/validate-projects-born.mjs

Four validator scripts each carry an independent, byte-near-identical copy
of the same per-entry dedup check: track seen values in a Set, push an
error on a repeat, differing only in variable names and the error message.

scripts/validate-case-studies.mjs, scripts/validate-radar-reports.mjs,
scripts/validate-metrics.mjs, and scripts/validate-launch-metrics.mjs
already centralize their version of this behind checkDuplicateOrMissingId()
in scripts/lib/validate-utils.mjs (see #1751/#1752). The four scripts above
were left out because that helper also treats a falsy value as an error on
its own — and all four already run a separate presence check on the same
field (checkNonEmptyString() or an inline check), so reusing it as-is would
double-report a single missing entry as both "missing" and "duplicate".

Impact

The same mechanical bug-fix or message-wording change to "how duplicates are
reported" has to be hand-applied in four places (plus the other four already
centralized), with no shared test coverage; a fix to one copy routinely
misses the others. New validators are likely to copy whichever inline
version they find first, growing the duplication further (npm run check:duplication already runs against a tracked clone-count ceiling in
.jscpd.json).

Recommendation

Add a checkDuplicateValue() helper — dedup-only, no presence check — in a
new scripts/lib/duplicate-check.mjs, and migrate the four scripts above to
it, each keeping its existing guard structure (unconditional, slug-style
if (value), or typeof === 'string') so none of them changes behavior for
a missing value.

Decision taken by hive: the new helper goes in its own file
(scripts/lib/duplicate-check.mjs) with its own test file
(tests/duplicate-check.test.mjs), rather than being added to
scripts/lib/validate-utils.mjs / tests/validate-utils.test.mjs. Those two
files are under active review in hold-gated PR #1761, and
tests/coverage-report-cli.test.mjs enforces 100% coverage of
validate-utils.mjs specifically from validate-utils.test.mjs, so any new
export there needs a same-PR test addition to that exact file. Keeping the
new, narrower check in its own module avoids touching #1761's claimed files
and needs no maintainer input to choose correctly.


Filed by architect agent (ACMM L5 — hold-gated mode)


🐝 Hive Agent: architect | Instance: hosted-available-lke648397-260827-5n31 | SHA: unknown

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

Activity

  1. added
    architectureCreated by Hive for agent-filed issue provenance
    tech-debtCreated by Hive for agent-filed issue provenance
    agent/architectCreated by Hive for agent-filed issue provenance
    stage/020-claimedClaimed by the scanner or a relay contributor
    on Oct 22, 2026
  2. hivecommons-hive commented on Oct 22, 2026

    @hivecommons-hive
    ContributorAuthor

    🛠️ Hive agent architect (hive hosted-available-lke648397-260827-5n31) started work on this issue at 2026-10-22T07:32:59Z. A pull request referencing this issue supersedes this mark; it lapses on its own at 2026-10-22T09:32:59Z if none appears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/architectCreated by Hive for agent-filed issue provenancearchitectureCreated by Hive for agent-filed issue provenancehive/claimed-by-architectstage/040-covered-by-prAn open PR covers this issuetech-debtCreated by Hive for agent-filed issue provenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions