Skip to content

feat(miner-foundation): extract predicted-gate types into gittensory-engine (#2276) - #3873

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
e11734937-beep:feat/predicted-gate-engine-extract-2276
Jul 6, 2026
Merged

feat(miner-foundation): extract predicted-gate types into gittensory-engine (#2276)#3873
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
e11734937-beep:feat/predicted-gate-engine-extract-2276

Conversation

@e11734937-beep

Copy link
Copy Markdown
Contributor

Closes #2276

What

Moves the pure, dependency-light predicted-gate surface out of src/rules/predicted-gate.ts into a new packages/gittensory-engine/src/predicted-gate.ts, re-exported from the engine barrel, so a miner can model its own "will my PR pass the gate?" verdict locally with the exact shapes the maintainer gate uses. This is the types-and-pure-helpers-first slice; buildPredictedGateVerdict itself follows in the keystone (#2283).

Moved (ported verbatim):

  • PredictedGateVerdict, PredictedGateInput types
  • predictedGateNote (+ its PREDICTED_GATE_NOTE_* constants)
  • publicSafeFinding

src/rules/predicted-gate.ts now re-exports the two types and imports the helpers instead of defining them, so there is exactly one definition. buildPredictedGateVerdict stays in src/ and calls the imported/bound helpers unchanged.

Boundary wiring (please read — deviates slightly from the issue text)

The issue text suggests importing from the bare specifier @jsonbored/gittensory-engine and adding it to root package.json. I followed the already-merged convention from the scoring extraction (#2282, src/scoring/preview.ts) and the duplicate-winner extraction (#2278) instead, because it is what actually keeps CI green:

  • Relative source path, not the bare specifier. src/rules/predicted-gate.ts imports ../../packages/gittensory-engine/src/predicted-gate. The engine's package.json exports resolve to its built dist/, which is not guaranteed to exist when root typecheck/test:coverage run in CI (the engine is built later in the job). The relative source path avoids that ordering dependency with zero config changes — no root dep, no tsconfig paths, no vitest alias — exactly matching the two prior extractions. I verified typecheck exits 0 with the engine dist/ moved aside.
  • Two small union mirrors. PredictedGateVerdict needs GatePolicyPack (src/types.ts) and GateCheckConclusion (src/rules/advisory.ts). The engine package is isolated (rootDir: "src", types: []) and cannot import across into src/, so these two-/five-member unions are mirrored engine-side with src/ kept canonical — mirroring the scoring/types.ts convention from feat(miner-foundation): extract scoring preview/model modules into gittensory-engine #2282.
  • publicSafeFinding takes its redaction fn as an argument. The original publicSafeFinding calls sanitizePublicComment (which lives in src/github/commands.ts and has ~145 call sites across src/). Rather than relocate that core sanitizer here (out of scope for a "keep the surface small" slice), the engine helper accepts sanitize as a parameter and src/ binds the canonical sanitizePublicComment. The sanitizer can move to the engine alongside buildPredictedGateVerdict in feat(miner-foundation): move buildPredictedGateVerdict into gittensory-engine and re-point src/ #2283, where it is actually needed engine-side.

Verification

  • npm run typecheck → exit 0 (also verified exit 0 with packages/gittensory-engine/dist moved aside — the source-path shim resolves without the built engine)
  • npm run build --workspace @jsonbored/gittensory-engine → exit 0 (new module compiles under the engine's isolated tsconfig)
  • The existing predicted-gate suite + engine-parity fixtures + contract parity pass unmodified
  • npm run test:coverage → exit 0; src/rules/predicted-gate.ts at 100% (statements/branches/functions/lines)
  • ui:typecheck / ui:lint (0 errors) / ui:test, rees:test all green
  • git diff --check clean

…engine (JSONbored#2276)

Move the PredictedGateVerdict/PredictedGateInput types and the predictedGateNote/
publicSafeFinding pure helpers out of src/rules/predicted-gate.ts into
packages/gittensory-engine/src/predicted-gate.ts, re-exported from the engine barrel,
so a miner can model its own predicted gate verdict locally with the same shapes the
maintainer gate uses. This is the types-and-pure-helpers-first slice;
buildPredictedGateVerdict itself follows in the keystone (JSONbored#2283).

src/rules/predicted-gate.ts re-exports the two types and imports the helpers via the
relative source path (../../packages/gittensory-engine/src/predicted-gate), matching
this repo's existing engine-consumption convention (see src/scoring/preview.ts), so
typecheck and test:coverage never depend on the engine's built dist/ that is not
guaranteed present when they run in CI. The two small union shapes the surface needs
(GatePolicyPack, GateCheckConclusion) are mirrored engine-side with src kept canonical,
mirroring the scoring/types.ts convention. publicSafeFinding takes its redaction
function as an argument so the engine stays isolated from src/github/commands'
sanitizePublicComment; src binds the canonical sanitizer. The existing predicted-gate
test suite passes unmodified.
@e11734937-beep
e11734937-beep requested a review from JSONbored as a code owner July 6, 2026 22:36
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.54%. Comparing base (008a5d8) to head (d10b1b8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3873   +/-   ##
=======================================
  Coverage   93.54%   93.54%           
=======================================
  Files         337      338    +1     
  Lines       33334    33335    +1     
  Branches    12192    12192           
=======================================
+ Hits        31181    31182    +1     
  Misses       1528     1528           
  Partials      625      625           
Files with missing lines Coverage Δ
packages/gittensory-engine/src/predicted-gate.ts 100.00% <100.00%> (ø)
src/rules/predicted-gate.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 6, 2026
@loopover-orb

loopover-orb Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Tip

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

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-06 23:10:33 UTC

3 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a clean, verbatim mechanical extraction of predicted-gate types and two pure helpers (predictedGateNote, publicSafeFinding, plus PredictedGateVerdict/PredictedGateInput) into packages/gittensory-engine/src/predicted-gate.ts, with src/rules/predicted-gate.ts re-exporting the types and importing the helpers instead of defining them — exactly one definition remains. The publicSafeFinding signature change (sanitize injected as an argument rather than closed over) is correctly bound at the call site with sanitizePublicComment, preserving prior behavior. The choice to import via a relative source path instead of the bare @​jsonbored/gittensory-engine specifier is well-justified and matches the already-merged convention from #2278/#2282, avoiding a dist/ build-ordering dependency in CI — all checks pass on this commit. The one real tradeoff is the hand-maintained mirror of GatePolicyPack and GateCheckConclusion, which is a documented, convention-consistent drift risk rather than a defect.

Nits — 6 non-blocking
  • The GatePolicyPack/GateCheckConclusion mirrors in packages/gittensory-engine/src/predicted-gate.ts:17-20 rely on a code comment ('keep in sync by hand') rather than any automated check — worth a lightweight type-equality assertion or a shared fixture so a future edit to src/types.ts's GatePolicyPack silently drifting from the mirror gets caught by CI rather than a human diff review.
  • No dedicated test file was added under packages/gittensory-engine for predictedGateNote/publicSafeFinding — coverage currently flows only through src/rules/predicted-gate.ts's existing suite via the re-export; consider adding an engine-level unit test importing directly from packages/gittensory-engine/src/predicted-gate.ts so the engine package is independently verifiable, matching the pattern set by scoring/preview.ts's tests.
  • The large header comment block in packages/gittensory-engine/src/predicted-gate.ts is duplicated in spirit with the JSDoc already on PredictedGateVerdict just below it — minor redundancy, not worth blocking on given the established convention in this file family.
  • Add a small engine-package test file (e.g. packages/gittensory-engine/src/predicted-gate.test.ts) exercising predictedGateNote's four branches and publicSafeFinding's action?-undefined branch directly, independent of src/rules/predicted-gate.ts's re-export.
  • Consider a compile-time structural check (e.g. a `satisfies`/assignment test) tying src/types.ts GatePolicyPack and src/rules/advisory.ts GateCheckConclusion to their engine mirrors so drift fails typecheck instead of relying on comments.
  • Code changes lack test evidence — Add focused regression tests or explain why existing coverage is sufficient.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2276
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low 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: 60 registered-repo PR(s), 33 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor e11734937-beep; Gittensor profile; 60 PR(s), 0 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: e11734937-beep
  • 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: 60 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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.

🟩 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

@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 daef526 into JSONbored:main Jul 6, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(miner-foundation): extract predicted-gate types into gittensory-engine

1 participant