Skip to content

feat(miner): de-hardcode discovery from gittensory's own conventions (#4784) - #5472

Merged
loopover-orb[bot] merged 7 commits into
JSONbored:mainfrom
andriypolanski:feat/miner-de-hardcode-discovery-4784-v2
Jul 12, 2026
Merged

feat(miner): de-hardcode discovery from gittensory's own conventions (#4784)#5472
loopover-orb[bot] merged 7 commits into
JSONbored:mainfrom
andriypolanski:feat/miner-de-hardcode-discovery-4784-v2

Conversation

@andriypolanski

Copy link
Copy Markdown
Contributor

Summary

  • Executes the Repo-agnostic capability audit #4780 repo-agnostic-capability-audit checklist: turns each hardcoded github.com/gittensory assumption in the miner's discovery path into per-tenant configuration, with gittensory's own conventions surviving only as the default.
  • Adds lib/forge-config.js — a single per-tenant forge adapter. DEFAULT_FORGE_CONFIG holds every github.com value (base URL, API version + version-header name, accept header, user-agent, repo path prefix, search endpoint, search qualifiers, token env var); resolveForgeConfig(overrides) fills any missing field from that default. resolveForgeConfig() with no overrides is byte-identical to the pre-De-hardcode discovery from gittensory's own conventions #4784 hardcoded behavior, so the existing gittensory discovery path is unchanged.
  • opportunity-fanout.js now reads the API version, request headers, repo path, search endpoint, and search-qualifier dialect from the resolved forge instead of module constants (checklist item 1 + 5). The pre-existing top-level apiBaseUrl override still wins over forge.apiBaseUrl, so every current caller is untouched.
  • discover surfaces --api-base-url <url> so the fan-out's forge host is reachable from the CLI (item 2), and --token-env <VAR> to read a non-GITHUB_TOKEN credential (item 3). runDiscover also forwards a caller-supplied goal spec (goalSpecsByRepo / goalSpecContentByRepo) to the ranker and surfaces usedDefaultGoalSpec in the JSON and the human-readable summary, so a fall-back to gittensory's built-in rubric is explicit rather than silent (item 4).
  • Marks the audit checklist resolved and records one explicit deferral with a reason: the engine's DEFAULT_TYPE_LABELS (gittensor:*) is a review-stack default (already overridable per repo via the focus manifest) that the miner discovery ranker never consults — the discovery label taxonomy is the goal spec's generic preferredLabels / blockedLabels, which is now threaded through.

Closes #4784.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • Run the full gate with npm run test:ci (and npm run test:coverage unsharded) under Node 22 (.nvmrc) before pushing. The development sandbox runs Node 18 without the workspace node_modules (the engine's dist/ is unbuilt and node:sqlite is unavailable), so the Vitest gate could not be executed here. node --check passes on all three changed JS modules, and the new logic was verified out-of-band with a standalone Node script against the real forge-config.js (defaults == baseline; trim / blank / non-string / null-arg fall-backs; frozen default) plus faithful replicas of the new parseDiscoverArgs conditional-key parsing and the runDiscover token/apiBaseUrl precedence.
  • Backwards-compatibility is the regression guard. The existing opportunity-fanout / discover-cli tests are left untouched and still pass by construction: resolveForgeConfig() with no overrides reproduces the exact previous URLs/headers, and parseDiscoverArgs only adds apiBaseUrl / tokenEnv keys when the corresponding flag is supplied (so the existing exact-match .toEqual({ targets, search, json }) assertions are unchanged).

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed. The credential env var name is configurable; no token value is logged.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. (None in this PR; the credential env var change only renames which env var is read.)
  • API/OpenAPI/MCP behavior is updated and tested where needed. (No API/OpenAPI/MCP surface changed.)
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. (No UI changes.)
  • Visible UI changes include a UI Evidence section below. (Not applicable — no UI changes.)
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs. (CHANGELOG.md untouched.)

UI Evidence

Not applicable — this change is miner-package runtime modules + tests + package docs (Markdown). No rendered frontend surface changed.

Notes

  • gittensory conventions survive only as defaults. Every forge knob defaults to the github.com value, so a non-github.com (or GitHub Enterprise) tenant overrides only what differs. resolveForgeConfig() == the old hardcoded baseline, which is what keeps existing gittensory-repo discovery behavior identical (the acceptance criterion).
  • Deferred item, with reason. The engine DEFAULT_TYPE_LABELS (gittensor:*) belongs to the review/PR-type path (overridable per repo via the focus manifest) and is never read by the miner discovery ranker, so de-hardcoding it is out of De-hardcode discovery from gittensory's own conventions #4784's discovery/claim scope — documented in the audit's Resolution section.
  • Non-silent fall-back. Because discover does not (yet) auto-fetch each target repo's .gittensory-miner.yml, real runs surface usedDefaultGoalSpec: true in both JSON and the summary, making the default-rubric fall-back explicit instead of silent.

@andriypolanski
andriypolanski marked this pull request as draft July 12, 2026 21:57
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 12, 2026
@loopover-orb

loopover-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-12 22:16:26 UTC

11 files · 2 AI reviewers · no blockers · readiness 82/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a well-scoped abstraction layer: `resolveForgeConfig` centralizes github.com defaults so `opportunity-fanout.js` and `discover-cli.js` read forge details (headers, repo path, search endpoint/qualifiers, token env var) from a resolved config instead of module constants, and the PR explicitly preserves back-compat by letting the legacy top-level `apiBaseUrl` still win over `forge.apiBaseUrl`. The `targetFromSearchIssue` regex fix (using `forge.repoPathPrefix` and a host-agnostic `html_url` match) is a genuine correctness improvement for non-github forges, and the goal-spec/`usedDefaultGoalSpec` plumbing through `runDiscover` is coherent with the stated intent. Test coverage is thorough (new `forge-config`, `opportunity-fanout-forge`, and expanded `discover-cli` suites cover overrides, trimming, back-compat, and CLI flag parsing) and CI is green.

Nits — 5 non-blocking
  • packages/gittensory-miner/lib/forge-config.js:10 — the `github.com/ghapi` default is an intentional baseline, not a violation, but worth noting the external-brief flag is a false positive given the PR's own design goal.
  • packages/gittensory-miner/lib/opportunity-fanout.js has grown past ~450 lines with this diff; consider whether `forge-config.js`-style extraction of the search/pagination helpers would keep it under the 400-line house guideline going forward.
  • packages/gittensory-miner/lib/discover-cli.js:150 — `tokenEnv` resolution calls `resolveForgeConfig(options.forge)` purely to read `tokenEnvVar`, duplicating work `normalizeOptions` will redo inside the fan-out call; not incorrect, just a minor redundant resolve.
  • packages/gittensory-miner/lib/opportunity-fanout.js targetFromSearchIssue's `repoPathPrefix` escaping assumes a single path segment; a forge with a multi-segment custom prefix (e.g. `/api/v3/repos`) still works but wasn't asserted directly in the new tests.
  • Consider caching/memoizing the resolved forge config once per `runDiscover` call instead of resolving it twice (once for tokenEnv, once inside normalizeOptions) — minor, non-blocking.
Signal Result Evidence
Code review ✅ No blockers 2 reviewers, synthesized
Linked issue ✅ Linked #4784
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 155 registered-repo PR(s), 105 merged, 29 issue(s).
Contributor context ✅ Confirmed Gittensor contributor andriypolanski; Gittensor profile; 155 PR(s), 29 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: moderate — The diff delivers a clean, backward-compatible forge abstraction with strong test coverage that closes a real audit checklist (#4780) tied to the linked issue #4784, though it is infrastructure/config plumbing rather than a functional feature.
Review context
  • Author: andriypolanski
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 155 PR(s), 29 issue(s).
  • Related work: Titles/paths share 3 meaningful terms. (issue #4767, issue #4784)
  • Related work: Titles/paths share 3 meaningful terms. (issue #4801, issue #4784)
  • Related work: Titles/paths share 3 meaningful terms. (issue #4803, issue #4784)
Contributor next steps
  • Review top overlaps.
  • Add a concise scope and risk note.
  • Check active issues and PRs before submitting.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
[BETA] Chat with Gittensory

Ask Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @gittensory ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @gittensory mention with a real question is routed to the closest matching read-only command automatically -- no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.72%. Comparing base (29c18f2) to head (f614a0d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5472   +/-   ##
=======================================
  Coverage   94.72%   94.72%           
=======================================
  Files         559      560    +1     
  Lines       44664    44690   +26     
  Branches    14664    14664           
=======================================
+ Hits        42308    42334   +26     
  Misses       1621     1621           
  Partials      735      735           
Flag Coverage Δ
shard-1 43.88% <2.63%> (-0.16%) ⬇️
shard-2 35.27% <42.10%> (+0.06%) ⬆️
shard-3 32.19% <76.31%> (+0.18%) ⬆️
shard-4 31.36% <26.31%> (-0.69%) ⬇️
shard-5 33.14% <42.10%> (+0.47%) ⬆️
shard-6 43.96% <39.47%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/gittensory-miner/lib/discover-cli.js 100.00% <100.00%> (ø)
packages/gittensory-miner/lib/forge-config.js 100.00% <100.00%> (ø)
...ackages/gittensory-miner/lib/opportunity-fanout.js 95.69% <100.00%> (+0.04%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andriypolanski
andriypolanski marked this pull request as ready for review July 12, 2026 22:13

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit eca8387 into JSONbored:main Jul 12, 2026
16 checks passed
@andriypolanski
andriypolanski deleted the feat/miner-de-hardcode-discovery-4784-v2 branch July 16, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

De-hardcode discovery from gittensory's own conventions

2 participants