Skip to content

[architect] Gate proposal: cross-file duplicated boilerplate (19+ merged extract-shared PRs with no automated check) #7491

Closed

Description

@hivecommons-hive

Architecture Finding

Type: tech-debt (missing CI gate)
Affected area: repo-wide — src/components/, src/app/, scripts/

Cross-file duplicated boilerplate keeps recurring across this repo, and it
has only ever been caught by manual per-session scanning, not by CI. At
least 19 distinct "extract shared X" / dedupe PRs have already merged, each
in a different pair of files/packages, including:

A fresh jscpd --min-lines 10 --min-tokens 50 scan of src/, scripts/
(excluding *.test.ts(x), CSS, and vendor/) still finds 0.67% duplicated
lines across 14 clone pairs today, several not yet reviewed, e.g.:

  • app/docs/page-map.ts duplicated against app/sitemap.ts (project-list
    mapping logic)
  • components/docs/DocsNavbar.tsx duplicated against
    components/navbar/NavbarLogo.tsx
  • components/docs/MobileTOC.tsx duplicated against
    components/docs/TableOfContents.tsx
  • components/navbar/MobileCommunitySection.tsx duplicated against
    components/navbar/MobileContributeSection.tsx
  • components/Footer.tsx duplicated against components/docs/DocsFooter.tsx
    at three more sites beyond the already-fixed back-to-top button (refactor: extract shared BackToTopButton from Footer/DocsFooter #7478)

(CSS duplication in app/globals.css and the CommunityDropdown/
ContributeDropdown pair were already reviewed in a prior scan and judged
lower-value/riskier to extract — excluded from this finding.)

Impact

Without an automated gate, every one of the 19 fixes above was found by
manual scanning rather than CI feedback, and new duplication (the five
sites above) accumulates between scans instead of being caught at PR time.

Recommendation

A companion PR adds .jscpd.json (1.0% threshold — just above the current
0.67% baseline so it fails on new duplication while giving headroom to
land a few more of the sites above before ratcheting down) and an
npm run duplication-check script that runs it.

Wiring this into CI still needs a .github/workflows/*.yml edit, which
this agent's token cannot push (no workflows permission at the
contributor tier). The exact addition needed, as a new step in an
existing lint-style job (or its own job — a sequencing choice left to
maintainer preference):

      - name: Duplication check
        run: npm run duplication-check

This needs a human or an ISSUES_PRS_MERGE-tier agent to apply, since the
diff touches .github/workflows/.

Risk: governance (workflow-file permission ceiling at this agent's tier;
not a design call this agent can make).


Filed by architect agent (ACMM L6 — full mode)

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

Activity

  1. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Oct 22, 2026
  2. hivecommons-hive commented on Oct 22, 2026

    @hivecommons-hive
    ContributorAuthor

    A merged PR referenced this issue without closing it. Carrying the remainder back here so the issue timeline shows what is still open.

    Remainder from the PR body:

    workflow-file CI wiring for the duplication-check
    step requires a token with workflows permission, which this agent's tier
    does not have

    This comment is edited in place by the task-list sweep on every cycle; it is not duplicated.

  3. hivecommons-hive commented on Oct 22, 2026

    @hivecommons-hive
    ContributorAuthor

    What to reply

    • /hive done: you did the step only you can do; Hive re-checks it and closes the issue once it is verified
    • /hive approve: go with the recommendation
    • /hive decision <your instructions>: go ahead, following your instructions
    • /hive help: show these again

    If what this issue waited on has been done (a merged fix, or an action taken outside this repository), a maintainer can reply /fixed to close it as completed; Hive clears its park labels.

    Only a maintainer with write access can un-park; everything else is ignored. Full command reference: https://github.com/hivecommons/hive/blob/v5/src/docs/maintainer-commands.md.

  4. clubanderson commented on Oct 24, 2026

    @clubanderson
    Member

    /hive decision Yes — add a jscpd ratchet gate, same tool and config in both kubestellar/docs (#7491, config PR #7492 merged) and kubestellar/console-kb (#3869, config PR #3870 merged); do not introduce a second duplication tool. Design: (1) commit a jscpd-baseline.json with the current clone count from the merged config; (2) a duplication-check CI job runs jscpd and fails only if the clone count increases vs. baseline (never on existing debt); (3) continue-on-error: true (warning-only) for the first 2 weeks after the workflow lands, then flip to enforcing in a one-line follow-up; (4) a PR that lowers duplication updates the baseline downward in the same PR. The hive prepares the baseline file + npm script + exact workflow YAML; the owner pushes the .github/workflows/ file since the hive token lacks workflows scope. Cross-linked: #7491 ↔ kubestellar/console-kb#3869. Labelled hold (owner push) + triage/accepted.

  5. added
    triage/acceptedIndicates an issue or PR is ready to be actively worked on.
    and removed
    stage/045-needs-decisionIssue parked on a person: needs-human or a maintainer decision is owed before the hive picks it up
    on Oct 24, 2026
  6. hivecommons-hive commented on Oct 27, 2026

    @hivecommons-hive
    ContributorAuthor

    Adding kubestellar/console's instances to this accepted ruling (jscpd ratchet gate, same tool/config, continue-on-error warm-up per the decision above).

    Console has no .jscpd.json and a current ad-hoc jscpd --min-lines 10 --min-tokens 50 scan of pkg/, cmd/ finds 411 clones / 5.39% duplicated tokens, concentrated in pkg/store's sqlite_*.go row-scan-loop pattern recurring across gpu/rewards/stellar*/users tables (already partly addressed: ListTeams/GetUserTeams dedup merged via #24573/#24574).

    Filing the config-only PR for console now (same shape as docs #7492 / console-kb #3870's .jscpd.json + script): Decision taken by hive: applying the ruling on kubestellar/docs#7491. The CI-wiring step under .github/workflows/ is the same owner-only remainder as docs/console-kb.

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

  7. hivecommons-hive commented on Oct 31, 2026

    @hivecommons-hive
    ContributorAuthor

    Applying this ruling in another repo in scope: kubestellar/console-marketplace
    has the same pattern (19+ "extract shared X" / dedupe PRs merged over time,
    every one found by manual architect scanning, no automated gate). Filed
    kubestellar/console-marketplace#1030 (gate application + owner-only
    workflow-wiring step) and opened kubestellar/console-marketplace#1031
    (companion PR: .jscpd.json + jscpd-baseline.json + scripts/jscpd-ratchet.mjs,
    baseline 10 clones today).

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

  8. hivecommons-hive commented on Oct 31, 2026

    @hivecommons-hive
    ContributorAuthor

    Applying this ruling in another repo in scope: kubestellar/homebrew-tap has
    the same pattern (8+ "dedupe duplicated test helper/regex" PRs merged over
    time — #704, #710, #743, #745, #756, #757/#758 — every one found by manual
    architect scanning, no automated gate). Filed
    kubestellar/homebrew-tap#767 (gate application + owner-only
    workflow-wiring step) and opened kubestellar/homebrew-tap#768 (companion
    PR: .jscpd.json + jscpd-baseline.json + scripts/jscpd-ratchet.mjs,
    baseline 1 clone today). Note: unlike docs/console-marketplace, test files
    are intentionally included in this repo's scan scope since that's where
    its recurring duplication actually lives.

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

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/architectIssue filed by the architect agentarchitecturehelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.holdtech-debttriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions