Skip to content

feat(miner): resolve the real per-repo MinerGoalSpec from a cloned worktree (#5132)#5255

Merged
JSONbored merged 1 commit into
mainfrom
feat/miner-goal-spec-wiring-5132
Jul 12, 2026
Merged

feat(miner): resolve the real per-repo MinerGoalSpec from a cloned worktree (#5132)#5255
JSONbored merged 1 commit into
mainfrom
feat/miner-goal-spec-wiring-5132

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Advances #5132

`runMinerAttempt`'s `killSwitchScope` needs `MinerGoalSpec.killSwitch.paused` from the target repo's real `.gittensory-miner.yml`. `checkMinerKillSwitch` (`governor-kill-switch.js`, #2341) already resolves the scope once given that value, but nothing in this package ever fetched/parsed the file itself.

Unlike `self-review-context.js`/`rejection-signal.js`/`ams-policy.js` (which fetch live over `raw.githubusercontent.com` before any clone exists), this reads the file from an ALREADY-CLONED repo on disk -- by the time a real attempt reaches this point, `attempt-worktree.js`'s `prepareAttemptWorktree` (#5237, and its own `attempt-cli.js` wiring in #5252) has already cloned it, so no extra network round trip is needed.

Known gap, same discipline as this epic's other standalone pieces: not yet wired into `attempt-cli.js`'s `runAttempt`, since that wiring needs a real `repoPath` from #5252's worktree preparation, which is open/CI-green but not yet merged as of this PR. Follow-up once it lands (mirrors how `resolveRejectionSignaled` shipped standalone in #5241 before being wired into `attempt-cli.js` in the same PR once review flagged it).

Test plan

  • `npx vitest run test/unit/miner-goal-spec-resolver.test.ts` -- 6/6 (no candidate file, root `.yml`, `.github/` fallback, `.json` fallback, malformed content, unreadable file)
  • `node --check packages/gittensory-miner/lib/miner-goal-spec.js`
  • `npm run --prefix packages/gittensory-miner build` (added to the check list)
  • `npm run test:engine-parity`
  • `npx tsc --noEmit`

@superagent-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 12, 2026

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 de33906 Commit Preview URL

Branch Preview URL
Jul 12 2026, 12:21 PM

@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.36%. Comparing base (45a3741) to head (de33906).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5255   +/-   ##
=======================================
  Coverage   94.36%   94.36%           
=======================================
  Files         474      474           
  Lines       40089    40089           
  Branches    14617    14617           
=======================================
+ Hits        37829    37831    +2     
+ Misses       1585     1583    -2     
  Partials      675      675           
Flag Coverage Δ
shard-1 46.25% <ø> (-0.15%) ⬇️
shard-2 34.74% <ø> (+0.01%) ⬆️
shard-3 32.07% <ø> (-0.05%) ⬇️
shard-4 31.84% <ø> (-0.20%) ⬇️
shard-5 33.61% <ø> (-0.10%) ⬇️
shard-6 45.09% <ø> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

gittensory-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-12 12:26:14 UTC

4 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 adds a small, self-contained resolver (`resolveMinerGoalSpec`) that reads a `.gittensory-miner.yml`/`.json` from an already-cloned repo on disk and hands it to the engine's existing tolerant parser, mirroring the established injected-fs pattern used by `ams-policy.js`. It correctly delegates candidate discovery to `discoverMinerGoalSpecPath` and never throws, degrading to safe defaults on missing/unreadable/malformed content. The described gap (not yet wired into `attempt-cli.js`'s `runAttempt`) is explicitly and honestly disclosed as blocked on an unmerged dependency (#5252), consistent with this epic's stated incremental-shipping discipline.

Nits — 5 non-blocking
  • The `discoverMinerGoalSpecPath` callback recomputes `join(repoPath, candidate)` and the same join is repeated in the read step — a nit, not a defect, but could be simplified by returning the full path from discovery.
  • The JSDoc block in miner-goal-spec.js is quite long relative to the 38-line file; consider trimming once the standalone-vs-wired distinction is no longer relevant.
  • Once feat(miner): wire real git worktree preparation into the attempt CLI (#5132) #5252 lands, wire `resolveMinerGoalSpec` into `attempt-cli.js`'s `runAttempt` as described, and add an integration test verifying `killSwitchScope` actually receives the resolved `paused` value.
  • Consider consolidating the repeated 'never throws, degrades to safe defaults' doc pattern (shared across ams-policy.js, this file, etc.) into a shared JSDoc reference to reduce duplication.
  • nit: packages/gittensory-miner/lib/miner-goal-spec.js:28 documents that injected filesystem functions receive the full joined path, but the tests only indirectly exercise that for one suffix case and do not assert the exact paths passed to existsSync/readFileSync.

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: 44 registered-repo PR(s), 36 merged, 470 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 44 PR(s), 470 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: 44 PR(s), 470 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

@gittensory-orb gittensory-orb Bot added the manual-review Gittensor contributor context label Jul 12, 2026
…rktree

Advances #5132

runMinerAttempt's killSwitchScope needs MinerGoalSpec.killSwitch.paused
from the target repo's real .gittensory-miner.yml. checkMinerKillSwitch
(governor-kill-switch.js, #2341) already resolves the scope once given
that value, but nothing in this package ever fetched/parsed the file
itself. Unlike self-review-context.js/rejection-signal.js/ams-policy.js
(which fetch live over raw.githubusercontent.com before any clone
exists), this reads the file from an ALREADY-CLONED repo on disk --
by the time a real attempt reaches this point, attempt-worktree.js's
prepareAttemptWorktree (#5237/#5252) has already cloned it, so no
extra network round trip is needed.

KNOWN GAP, same discipline as this epic's other standalone pieces:
not yet wired into attempt-cli.js's runAttempt, since that wiring
needs a real repoPath from #5252's worktree preparation (open,
CI-green, not yet merged as of this PR). Follow-up once it lands.
@JSONbored JSONbored force-pushed the feat/miner-goal-spec-wiring-5132 branch from 2e58b3d to de33906 Compare July 12, 2026 12:20
JSONbored added a commit that referenced this pull request Jul 12, 2026
Closes #5132

The final assembly: attempt-cli.js now fetches a real SelfReviewContext
(#5145), builds a real coding-task spec (#5239, blocking on an
infeasible verdict), resolves the real AmsPolicySpec execution policy
(#5249, extended here with maxIterations/maxTurnsPerIteration -- the
same operator-risk-policy gap capLimits/submissionMode/slopThreshold
already covered), assembles the real IterateLoopInput + Governor
chokepoint context, and calls runMinerAttempt for real -- the first
point in this epic where a real coding agent actually executes rather
than every path ending in a reported block.

New attempt-input-builder.js holds the two pure composers
(buildAttemptGovernorContext, buildAttemptLoopInput) so the assembly
logic is independently unit-tested, mirroring coding-task-spec.js's
own precedent.

Real outcomes now surface distinct exit codes: 0 (submitted), 7
(abandon), 8 (stale), 9 (blocked by submission gate), 10 (governed),
plus the existing 4 (blocked_infeasible, repurposed from the old
blocked_missing_prerequisite placeholder), 5 (rejection_signaled), 6
(worktree_preparation_failed). The worktree is cleaned up on
submission, retained on any other real outcome for post-mortem
inspection (cleanupAttemptWorktree's own retention policy).

KNOWN, DOCUMENTED GAPS (not fabricated -- see attempt-input-builder.js
and attempt-cli.js's own header comments):
- governor.killSwitchRepoPaused only checks the GLOBAL env-var kill
  switch; a real per-repo .gittensory-miner.yml pause needs
  miner-goal-spec.js (#5255, open) wired in as a fast-follow.
- governor.convergenceInput is an honest first-attempt-shaped literal,
  not a real per-issue attempt-history query -- attempt-log.js's
  schema has no repo+issue index, and reenqueue counts aren't tracked
  anywhere yet (non-convergence.ts's own header: that belongs on the
  portfolio-queue table once it grows attempt-history columns, a real
  separate schema change).

This closes #5132 for the core attempt pipeline; #5135 (the autonomous
supervising loop) remains as separate, explicitly-flagged
safety-critical follow-up work.
@JSONbored JSONbored merged commit 28949be into main Jul 12, 2026
20 checks passed
@JSONbored JSONbored deleted the feat/miner-goal-spec-wiring-5132 branch July 12, 2026 12:26
JSONbored added a commit that referenced this pull request Jul 12, 2026
Closes #5132

The final assembly: attempt-cli.js now fetches a real SelfReviewContext
(#5145), builds a real coding-task spec (#5239, blocking on an
infeasible verdict), resolves the real AmsPolicySpec execution policy
(#5249, extended here with maxIterations/maxTurnsPerIteration -- the
same operator-risk-policy gap capLimits/submissionMode/slopThreshold
already covered), assembles the real IterateLoopInput + Governor
chokepoint context, and calls runMinerAttempt for real -- the first
point in this epic where a real coding agent actually executes rather
than every path ending in a reported block.

New attempt-input-builder.js holds the two pure composers
(buildAttemptGovernorContext, buildAttemptLoopInput) so the assembly
logic is independently unit-tested, mirroring coding-task-spec.js's
own precedent.

Real outcomes now surface distinct exit codes: 0 (submitted), 7
(abandon), 8 (stale), 9 (blocked by submission gate), 10 (governed),
plus the existing 4 (blocked_infeasible, repurposed from the old
blocked_missing_prerequisite placeholder), 5 (rejection_signaled), 6
(worktree_preparation_failed). The worktree is cleaned up on
submission, retained on any other real outcome for post-mortem
inspection (cleanupAttemptWorktree's own retention policy).

KNOWN, DOCUMENTED GAPS (not fabricated -- see attempt-input-builder.js
and attempt-cli.js's own header comments):
- governor.killSwitchRepoPaused only checks the GLOBAL env-var kill
  switch; a real per-repo .gittensory-miner.yml pause needs
  miner-goal-spec.js (#5255, open) wired in as a fast-follow.
- governor.convergenceInput is an honest first-attempt-shaped literal,
  not a real per-issue attempt-history query -- attempt-log.js's
  schema has no repo+issue index, and reenqueue counts aren't tracked
  anywhere yet (non-convergence.ts's own header: that belongs on the
  portfolio-queue table once it grows attempt-history columns, a real
  separate schema change).

This closes #5132 for the core attempt pipeline; #5135 (the autonomous
supervising loop) remains as separate, explicitly-flagged
safety-critical follow-up work.
JSONbored added a commit that referenced this pull request Jul 12, 2026
…5261)

* feat(miner): wire the real runMinerAttempt call into attempt-cli.js

Closes #5132

The final assembly: attempt-cli.js now fetches a real SelfReviewContext
(#5145), builds a real coding-task spec (#5239, blocking on an
infeasible verdict), resolves the real AmsPolicySpec execution policy
(#5249, extended here with maxIterations/maxTurnsPerIteration -- the
same operator-risk-policy gap capLimits/submissionMode/slopThreshold
already covered), assembles the real IterateLoopInput + Governor
chokepoint context, and calls runMinerAttempt for real -- the first
point in this epic where a real coding agent actually executes rather
than every path ending in a reported block.

New attempt-input-builder.js holds the two pure composers
(buildAttemptGovernorContext, buildAttemptLoopInput) so the assembly
logic is independently unit-tested, mirroring coding-task-spec.js's
own precedent.

Real outcomes now surface distinct exit codes: 0 (submitted), 7
(abandon), 8 (stale), 9 (blocked by submission gate), 10 (governed),
plus the existing 4 (blocked_infeasible, repurposed from the old
blocked_missing_prerequisite placeholder), 5 (rejection_signaled), 6
(worktree_preparation_failed). The worktree is cleaned up on
submission, retained on any other real outcome for post-mortem
inspection (cleanupAttemptWorktree's own retention policy).

KNOWN, DOCUMENTED GAPS (not fabricated -- see attempt-input-builder.js
and attempt-cli.js's own header comments):
- governor.killSwitchRepoPaused only checks the GLOBAL env-var kill
  switch; a real per-repo .gittensory-miner.yml pause needs
  miner-goal-spec.js (#5255, open) wired in as a fast-follow.
- governor.convergenceInput is an honest first-attempt-shaped literal,
  not a real per-issue attempt-history query -- attempt-log.js's
  schema has no repo+issue index, and reenqueue counts aren't tracked
  anywhere yet (non-convergence.ts's own header: that belongs on the
  portfolio-queue table once it grows attempt-history columns, a real
  separate schema change).

This closes #5132 for the core attempt pipeline; #5135 (the autonomous
supervising loop) remains as separate, explicitly-flagged
safety-critical follow-up work.

* fix(miner): use a real FocusManifest fixture in attempt-cli tests

CI's typecheck (not caught by an earlier stale local tsc run --
incremental cache silently no-op'd) correctly failed: the hand-rolled
{present, settings, gate, warnings} manifest fixture doesn't satisfy
FocusManifest's real shape (source, wantedPaths, preferredLabels,
linkedIssuePolicy, and 8 more required fields). Uses the engine's own
parseFocusManifest(undefined) to build a genuinely valid absent
manifest instead, and drops the `as never` cast in
miner-attempt-input-builder.test.ts that was silently working around
the same gap there.

* fix(miner): use a real RepositoryRecord shape in attempt-cli test fixtures

CI's typecheck (again not caught locally -- verified this time with a
genuinely fresh tsc run, all .tsbuildinfo caches cleared) correctly
failed: the hand-rolled repo fixture used the wrong field names
entirely (private/ownerLogin) instead of RepositoryRecord's real
shape (isPrivate/owner, plus required isInstalled/isRegistered).
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. manual-review Gittensor contributor context

Projects

Development

Successfully merging this pull request may close these issues.

1 participant