Skip to content

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

Merged
JSONbored merged 3 commits into
mainfrom
feat/full-attempt-assembly-5132
Jul 12, 2026
Merged

feat(miner): wire the real runMinerAttempt call into attempt-cli.js#5261
JSONbored merged 3 commits into
mainfrom
feat/full-attempt-assembly-5132

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

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.

Checked against #5132's own acceptance criteria:

  • Running the command against a real target in dry-run produces a real AttemptResult (not a test double).
  • Dry-run remains the default (unchanged -- --live opt-in still required).
  • The command respects the governor chokepoint (maintainer: wire the fail-closed Governor chokepoint before every write action #2340) exactly as runMinerAttempt's own tests already verify (the governor context is threaded through unchanged into evaluateGovernorChokepointGatePersisted).

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 (feat(miner): resolve the real per-repo MinerGoalSpec from a cloned worktree (#5132) #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).

Neither gap is in #5132's own stated acceptance criteria; both fail toward under-restricting rather than silently letting something through that shouldn't be. #5135 (the autonomous supervising loop) remains as separate, explicitly-flagged safety-critical follow-up work.

Test plan

  • npx vitest run test/unit/miner-attempt-cli.test.ts -- 30/30 (full rewrite: real-pipeline happy path with real loopInput/governor assembly verification, every one of the 5 runMinerAttempt outcomes with their distinct exit codes, infeasible-verdict blocking, worktree retention-on-non-submit regression, plus every pre-existing blocked-path test updated for the new required mocks)
  • npx vitest run test/unit/miner-attempt-input-builder.test.ts -- 10/10 new tests for the two pure composers
  • npx vitest run test/unit/ams-policy-spec-parser.test.ts test/unit/miner-ams-policy.test.ts -- 100% coverage confirmed on the extended ams-policy-spec.ts (maxIterations/maxTurnsPerIteration)
  • Full miner test sweep (test/unit/miner-*.test.ts, 94 files): identical pass/fail counts confirmed against a pristine origin/main worktree -- zero new failures, only new passing coverage (the only failures are a confirmed pre-existing, environment-only subprocess-resolution gap unrelated to this change)
  • npm run test:engine-parity
  • node --check on both new files; npm run --prefix packages/gittensory-miner build
  • 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 0e2c0ae Commit Preview URL

Branch Preview URL
Jul 12 2026, 12:38 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.37%. Comparing base (864c52d) to head (84af8cb).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5261   +/-   ##
=======================================
  Coverage   94.37%   94.37%           
=======================================
  Files         474      474           
  Lines       40114    40116    +2     
  Branches    14627    14627           
=======================================
+ Hits        37856    37858    +2     
  Misses       1583     1583           
  Partials      675      675           
Flag Coverage Δ
shard-1 46.41% <0.00%> (-0.01%) ⬇️
shard-2 34.73% <100.00%> (+<0.01%) ⬆️
shard-3 32.09% <0.00%> (-0.01%) ⬇️
shard-4 32.08% <100.00%> (+<0.01%) ⬆️
shard-5 33.66% <0.00%> (+<0.01%) ⬆️
shard-6 44.75% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
packages/gittensory-engine/src/ams-policy-spec.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.

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

gittensory-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown

Tip

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

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-12 12:45:44 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR wires the previously-blocked attempt-cli.js pipeline into a real end-to-end run: fetch SelfReviewContext, build a coding-task spec (blocking cleanly on infeasible verdicts), resolve AmsPolicySpec (extended with maxIterations/maxTurnsPerIteration, correctly floored and defaulted), assemble the Governor context + IterateLoopInput via the new pure attempt-input-builder.js, and finally call runMinerAttempt with distinct exit codes per real outcome. The composers are pure and unit-tested in isolation, the CLI-level tests cover submitted/abandon/stale/blocked/governed plus the infeasible-block and worktree-retention paths with real assertions on the assembled loopInput/governor context, and the documented gaps (repo-level kill-switch, convergence history) are honestly called out rather than faked. Note that `validate-code`/`validate` are failing on this commit — worth checking what those catch (likely lint/type) before merge, since nothing in the visible diff obviously explains it.

Nits — 6 non-blocking
  • packages/gittensory-miner/lib/attempt-cli.js: the synthetic `targetIssue` fallback (`{ number, title: "", body: null, labels: [] }`) omits fields present on a real issue record from `fakeReviewContext` (`repoFullName`, `state`, `linkedPrs`) — confirm `buildCodingTaskSpec` doesn't dereference those on the not-found path.
  • Exit codes 4/7/8/9/10 are bare numeric literals scattered across the switch/return statements; a shared enum/const map (mirroring the existing 2/3/5/6 literals) would make the outcome→exit-code contract easier to audit as more outcomes are added.
  • attempt-cli.js has grown to ~412 lines with the new pipeline stages; consider whether the infeasible-block and runMinerAttempt-assembly sections are ready to split into a helper now that attempt-input-builder.js already carries the pure composers.
  • The `validate-code`/`validate` CI checks are failing on this commit — please confirm what they flag (lint/typecheck) before merge.
  • Add an explicit unit test for `buildCodingTaskSpec`'s target_not_found path fed the exact fallback shape attempt-cli.js constructs, so the shape contract between the two files is pinned down rather than only exercised via a hand-rolled mock in the CLI test.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #5132
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: 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 ✅ Passing No configured 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.
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

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.
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.
…tures

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).
@JSONbored JSONbored merged commit f3f1f2b into main Jul 12, 2026
19 checks passed
@JSONbored JSONbored deleted the feat/full-attempt-assembly-5132 branch July 12, 2026 12:50
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

Development

Successfully merging this pull request may close these issues.

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

1 participant