Skip to content

feat(miner): wire the attempt CLI subcommand's real dependencies (#5132) - #5152

Merged
JSONbored merged 1 commit into
mainfrom
feat/miner-attempt-cli-5132
Jul 12, 2026
Merged

feat(miner): wire the attempt CLI subcommand's real dependencies (#5132)#5152
JSONbored merged 1 commit into
mainfrom
feat/miner-attempt-cli-5132

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Scope

  • The PR title follows type(scope): short summary Conventional Commit format.
  • 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.
  • Maintainer-only PR (epic Epic: Miner Wave 3.5 — Wire the autonomous loop end-to-end #5130, milestone "Miner Wave 3.5") — linked-issue-nit not applicable.

Validation

  • git diff --check
  • npm run typecheck
  • npm run test:coverage locally (737 test files, 0 failures). packages/gittensory-miner/** is outside vitest's coverage.include glob (only src/** + packages/gittensory-engine/src/** are collected), so codecov/patch cannot measure this diff — confirmed via an empty lcov.info for these files. Full unit test coverage was still written (34 new tests across the 3 new files) as real correctness verification, independent of the Codecov gate.
  • npm run build:miner + npm run test:miner-pack
  • npx tsx scripts/check-engine-parity.ts
  • npm audit --audit-level=moderate
  • npm run test:workers / npm run build:mcp / npm run test:mcp-pack / npm run ui:* — skipped, no src/**, apps/**, or MCP-surface files touched by this diff (confined to packages/gittensory-miner/** + 3 new test/unit/*.ts files).
  • New behavior has unit tests for new branches, fallback paths, and error paths (malformed GraphQL responses, unconfigured driver, allocator failure, paused mode, live-mode opt-in).

If any required check was skipped, explain why:

  • Workers/MCP/UI checks skipped: this diff only touches packages/gittensory-miner/** and test/unit/*.ts — none of those pipelines build or test miner-package changes.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • N/A — no auth/cookie/CORS/GitHub App/Cloudflare/session changes.
  • N/A — no API/OpenAPI/MCP surface changes.
  • N/A — no UI changes.
  • N/A — no visible UI changes.
  • N/A — no public docs/changelog changes needed.

Notes

Adds the `gittensory-miner attempt` subcommand: real GitHub-backed
fetchLiveIssueSnapshot (GraphQL closedByPullRequestsReferences), a
real executeLocalWrite (child_process, mirrors the #5131 driver
spawn), and orchestration that gives worktree-allocator.js its first
production caller and wires the four ledgers plus the #5131 driver
and #5133 slop assessor into a real AttemptDeps object.

runMinerAttempt still isn't reachable: it needs a SelfReviewContext
(tracked by #5145, filed alongside this) and a coding-task-spec
builder (title/instructions/acceptanceCriteriaPath, a second gap
found while building this) that don't exist yet. Rather than
fabricate either, the command builds and verifies every other real
dependency and reports the block explicitly instead of calling
runMinerAttempt with invalid input.
@JSONbored JSONbored linked an issue Jul 12, 2026 that may be closed by this pull request
3 tasks
@JSONbored JSONbored self-assigned this Jul 12, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui 3e6177f Commit Preview URL

Branch Preview URL
Jul 12 2026, 08:52 AM

@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.34%. Comparing base (6c40d1e) to head (3e6177f).
⚠️ Report is 15 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5152   +/-   ##
=======================================
  Coverage   94.34%   94.34%           
=======================================
  Files         473      473           
  Lines       39927    39927           
  Branches    14557    14557           
=======================================
  Hits        37669    37669           
  Misses       1583     1583           
  Partials      675      675           
Flag Coverage Δ
shard-1 46.34% <ø> (-0.01%) ⬇️
shard-2 34.41% <ø> (-0.26%) ⬇️
shard-3 30.80% <ø> (-1.23%) ⬇️
shard-4 33.08% <ø> (+1.11%) ⬆️
shard-5 33.54% <ø> (-0.23%) ⬇️
shard-6 45.20% <ø> (+0.32%) ⬆️

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

🚀 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: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

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-12 09:01:59 UTC

11 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · unstable

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR wires the `attempt` CLI subcommand to real infrastructure (GitHub GraphQL live-issue fetch, child_process-based executeLocalWrite, worktree allocator, four ledgers, the #5131 driver and #5133 slop assessor), and honestly reports `blocked_missing_prerequisite` instead of calling `runMinerAttempt` with fabricated `SelfReviewContext`/task-spec data — matching the stated rationale rather than faking a pass. The `--live` opt-in logic, `parseAttemptArgs` validation, and cleanup-on-every-exit-path (`finally` closes allocator/ledgers even on mid-flow throws) are all covered by tests that exercise the real code paths via dependency injection rather than mocked stubs. `fetchLiveIssueSnapshot` correctly normalizes GitHub's GraphQL `closedByPullRequestsReferences` response and fails closed (returns null) on any malformed/error response, matching its documented never-throws contract.

Nits — 5 non-blocking
  • packages/gittensory-miner/lib/attempt-cli.js:126 — `runAttempt` calls `buildAttemptDeps` purely to validate the coding-agent driver is configured, then discards the constructed `AttemptDeps` (including the driver instance) entirely; if `constructProductionCodingAgentDriver` does any nontrivial setup this is wasted work on every blocked invocation — worth a one-line comment noting it's intentionally throwaway.
  • packages/gittensory-miner/lib/attempt-cli.js — exit codes (2/3/4) and tracking issue number 5145 are repeated as bare literals across the file; a small `const EXIT_CODES = {...}` or comment block would make the contract easier to scan.
  • packages/gittensory-miner/lib/live-issue-snapshot.js:10 — `DEFAULT_GRAPHQL_URL` hardcodes `api.github.com`, fine for github.com but note it's overridable via `options.graphqlUrl` for GHE, which is already exercised in the tests.
  • packages/gittensory-miner/lib/attempt-cli.js:35 and live-issue-snapshot.js:74 — both functions are dense (many sequential validation branches); consider small named-predicate helpers if either grows further, though current size is still readable.
  • Consider hoisting the CLI exit codes into named constants (e.g. `EXIT_USAGE_ERROR = 2`) in attempt-cli.js for readability, per the external brief's magic-number flags.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
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 (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 45 registered-repo PR(s), 37 merged, 409 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 45 PR(s), 409 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 45 PR(s), 409 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
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

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 12, 2026
@JSONbored
JSONbored merged commit f166c07 into main Jul 12, 2026
20 checks passed
@JSONbored
JSONbored deleted the feat/miner-attempt-cli-5132 branch July 12, 2026 09:03
JSONbored added a commit that referenced this pull request Jul 12, 2026
…line (#5132)

packages/gittensory-miner/lib/worktree-allocator.js (given "its first
real caller" in #5152) only does SQLite slot bookkeeping + mkdir --
it runs zero git commands. workingDirectory handed to runIterateLoop
would have been an empty, non-git directory: the coding agent driver
would have nothing real to edit.

Adds repo-clone.js (a per-repo base-clone cache: git clone once,
then fetch + hard-reset to the base branch on every subsequent
attempt so content stays fresh) and attempt-worktree.js, which
composes it with @jsonbored/gittensory-engine's addWorktree/
removeWorktree/shouldRetainWorktree primitives -- these already
existed, tested, but were never called from this package (confirmed
via git grep: zero production call sites anywhere in
packages/gittensory-miner before this).

A test caught a real wiring bug before this ever shipped:
prepareAttemptWorktree initially forgot to forward its own
remoteUrl/runGit test-injection options through to ensureRepoCloned,
so every call silently hit the real GitHub URL regardless of what
the caller passed -- caught by the REGRESSION integration test
(a real local repo, real git worktree add, asserting real repo
content lands on a real branch), not by review.
JSONbored added a commit that referenced this pull request Jul 12, 2026
…line (#5132) (#5237)

* feat(miner): wire real git worktree preparation into the attempt pipeline (#5132)

packages/gittensory-miner/lib/worktree-allocator.js (given "its first
real caller" in #5152) only does SQLite slot bookkeeping + mkdir --
it runs zero git commands. workingDirectory handed to runIterateLoop
would have been an empty, non-git directory: the coding agent driver
would have nothing real to edit.

Adds repo-clone.js (a per-repo base-clone cache: git clone once,
then fetch + hard-reset to the base branch on every subsequent
attempt so content stays fresh) and attempt-worktree.js, which
composes it with @jsonbored/gittensory-engine's addWorktree/
removeWorktree/shouldRetainWorktree primitives -- these already
existed, tested, but were never called from this package (confirmed
via git grep: zero production call sites anywhere in
packages/gittensory-miner before this).

A test caught a real wiring bug before this ever shipped:
prepareAttemptWorktree initially forgot to forward its own
remoteUrl/runGit test-injection options through to ensureRepoCloned,
so every call silently hit the real GitHub URL regardless of what
the caller passed -- caught by the REGRESSION integration test
(a real local repo, real git worktree add, asserting real repo
content lands on a real branch), not by review.

* fix(miner): reject path-traversal owner/repo segments in repo-clone

normalizeRepoFullName only checked for exactly one "/" separator, so a
value like "../foo" passed validation and resolveRepoCloneDir/ensureRepoCloned
would join it straight into the clone base dir, escaping the intended
clone directory. Reject "."/".." segments and restrict owner/repo to
GitHub's actual allowed character set.
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. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wire CLI dispatch for the real attempt pipeline (attempt command)

1 participant